@flowcast/mcp 0.1.6 → 0.1.9
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/flowcast.mjs +67 -147
- package/package.json +1 -1
package/flowcast.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var $x=Object.create;var Qu=Object.defineProperty;var Ex=Object.getOwnPropertyDescriptor;var Tx=Object.getOwnPropertyNames;var Rx=Object.getPrototypeOf,Ix=Object.prototype.hasOwnProperty;var Pe=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ed=(t,e)=>{for(var r in e)Qu(t,r,{get:e[r],enumerable:!0})},Px=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Tx(e))!Ix.call(t,s)&&s!==r&&Qu(t,s,{get:()=>e[s],enumerable:!(n=Ex(e,s))||n.enumerable});return t};var Ci=(t,e,r)=>(r=t!=null?$x(Rx(t)):{},Px(e||!t||!t.__esModule?Qu(r,"default",{value:t,enumerable:!0}):r,t));var fa=Pe(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.regexpCode=wt.getEsmExportName=wt.getProperty=wt.safeStringify=wt.stringify=wt.strConcat=wt.addCodeArg=wt.str=wt._=wt.nil=wt._Code=wt.Name=wt.IDENTIFIER=wt._CodeOrName=void 0;var da=class{};wt._CodeOrName=da;wt.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var oo=class extends da{constructor(e){if(super(),!wt.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}}};wt.Name=oo;var nn=class extends da{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 oo&&(r[n.str]=(r[n.str]||0)+1),r),{})}};wt._Code=nn;wt.nil=new nn("");function g2(t,...e){let r=[t[0]],n=0;for(;n<e.length;)jf(r,e[n]),r.push(t[++n]);return new nn(r)}wt._=g2;var Cf=new nn("+");function _2(t,...e){let r=[ha(t[0])],n=0;for(;n<e.length;)r.push(Cf),jf(r,e[n]),r.push(Cf,ha(t[++n]));return P6(r),new nn(r)}wt.str=_2;function jf(t,e){e instanceof nn?t.push(...e._items):e instanceof oo?t.push(e):t.push(A6(e))}wt.addCodeArg=jf;function P6(t){let e=1;for(;e<t.length-1;){if(t[e]===Cf){let r=M6(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function M6(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof oo||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 oo))return`"${t}${e.slice(1)}`}function O6(t,e){return e.emptyStr()?t:t.emptyStr()?e:_2`${t}${e}`}wt.strConcat=O6;function A6(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:ha(Array.isArray(t)?t.join(","):t)}function z6(t){return new nn(ha(t))}wt.stringify=z6;function ha(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}wt.safeStringify=ha;function N6(t){return typeof t=="string"&&wt.IDENTIFIER.test(t)?new nn(`.${t}`):g2`[${t}]`}wt.getProperty=N6;function C6(t){if(typeof t=="string"&&wt.IDENTIFIER.test(t))return new nn(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}wt.getEsmExportName=C6;function j6(t){return new nn(t.toString())}wt.regexpCode=j6});var Zf=Pe(Ar=>{"use strict";Object.defineProperty(Ar,"__esModule",{value:!0});Ar.ValueScope=Ar.ValueScopeName=Ar.Scope=Ar.varKinds=Ar.UsedValueState=void 0;var Or=fa(),Df=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},ul;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(ul||(Ar.UsedValueState=ul={}));Ar.varKinds={const:new Or.Name("const"),let:new Or.Name("let"),var:new Or.Name("var")};var dl=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Or.Name?e:this.name(e)}name(e){return new Or.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}}};Ar.Scope=dl;var hl=class extends Or.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,Or._)`.${new Or.Name(r)}[${n}]`}};Ar.ValueScopeName=hl;var D6=(0,Or._)`\n`,Lf=class extends dl{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?D6:Or.nil}}get(){return this._scope}name(e){return new hl(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,Or._)`${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=Or.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,ul.Started);let l=r(d);if(l){let u=this.opts.es5?Ar.varKinds.var:Ar.varKinds.const;o=(0,Or._)`${o}${u} ${d} = ${l};${this.opts._n}`}else if(l=s?.(d))o=(0,Or._)`${o}${l}${this.opts._n}`;else throw new Df(d);c.set(d,ul.Completed)})}return o}};Ar.ValueScope=Lf});var ct=Pe(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.or=lt.and=lt.not=lt.CodeGen=lt.operators=lt.varKinds=lt.ValueScopeName=lt.ValueScope=lt.Scope=lt.Name=lt.regexpCode=lt.stringify=lt.getProperty=lt.nil=lt.strConcat=lt.str=lt._=void 0;var mt=fa(),wn=Zf(),ps=fa();Object.defineProperty(lt,"_",{enumerable:!0,get:function(){return ps._}});Object.defineProperty(lt,"str",{enumerable:!0,get:function(){return ps.str}});Object.defineProperty(lt,"strConcat",{enumerable:!0,get:function(){return ps.strConcat}});Object.defineProperty(lt,"nil",{enumerable:!0,get:function(){return ps.nil}});Object.defineProperty(lt,"getProperty",{enumerable:!0,get:function(){return ps.getProperty}});Object.defineProperty(lt,"stringify",{enumerable:!0,get:function(){return ps.stringify}});Object.defineProperty(lt,"regexpCode",{enumerable:!0,get:function(){return ps.regexpCode}});Object.defineProperty(lt,"Name",{enumerable:!0,get:function(){return ps.Name}});var gl=Zf();Object.defineProperty(lt,"Scope",{enumerable:!0,get:function(){return gl.Scope}});Object.defineProperty(lt,"ValueScope",{enumerable:!0,get:function(){return gl.ValueScope}});Object.defineProperty(lt,"ValueScopeName",{enumerable:!0,get:function(){return gl.ValueScopeName}});Object.defineProperty(lt,"varKinds",{enumerable:!0,get:function(){return gl.varKinds}});lt.operators={GT:new mt._Code(">"),GTE:new mt._Code(">="),LT:new mt._Code("<"),LTE:new mt._Code("<="),EQ:new mt._Code("==="),NEQ:new mt._Code("!=="),NOT:new mt._Code("!"),OR:new mt._Code("||"),AND:new mt._Code("&&"),ADD:new mt._Code("+")};var Xn=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},Bf=class extends Xn{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?wn.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=Ko(this.rhs,e,r)),this}get names(){return this.rhs instanceof mt._CodeOrName?this.rhs.names:{}}},fl=class extends Xn{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 mt.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=Ko(this.rhs,e,r),this}get names(){let e=this.lhs instanceof mt.Name?{}:{...this.lhs.names};return ml(e,this.rhs)}},Vf=class extends fl{constructor(e,r,n,s){super(e,n,s),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},qf=class extends Xn{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Ff=class extends Xn{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Hf=class extends Xn{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Uf=class extends Xn{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=Ko(this.code,e,r),this}get names(){return this.code instanceof mt._CodeOrName?this.code.names:{}}},pa=class extends Xn{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)||(L6(e,o.names),n.splice(s,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>co(e,r.names),{})}},Kn=class extends pa{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Gf=class extends pa{},Xo=class extends Kn{};Xo.kind="else";var io=class t extends Kn{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 Xo(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(b2(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=Ko(this.condition,e,r),this}get names(){let e=super.names;return ml(e,this.condition),this.else&&co(e,this.else.names),e}};io.kind="if";var ao=class extends Kn{};ao.kind="for";var Wf=class extends ao{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=Ko(this.iteration,e,r),this}get names(){return co(super.names,this.iteration.names)}},Yf=class extends ao{constructor(e,r,n,s){super(),this.varKind=e,this.name=r,this.from=n,this.to=s}render(e){let r=e.es5?wn.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=ml(super.names,this.from);return ml(e,this.to)}},pl=class extends ao{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=Ko(this.iterable,e,r),this}get names(){return co(super.names,this.iterable.names)}},ma=class extends Kn{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)}};ma.kind="func";var ga=class extends pa{render(e){return"return "+super.render(e)}};ga.kind="return";var Xf=class extends Kn{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&&co(e,this.catch.names),this.finally&&co(e,this.finally.names),e}},_a=class extends Kn{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};_a.kind="catch";var ba=class extends Kn{render(e){return"finally"+super.render(e)}};ba.kind="finally";var Kf=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
3
|
-
`:""},this._extScope=e,this._scope=new wn.Scope({parent:e}),this._nodes=[new Gf]}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 Bf(e,o,n)),o}const(e,r,n){return this._def(wn.varKinds.const,e,r,n)}let(e,r,n){return this._def(wn.varKinds.let,e,r,n)}var(e,r,n){return this._def(wn.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new fl(e,r,n))}add(e,r){return this._leafNode(new Vf(e,lt.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==mt.nil&&this._leafNode(new Uf(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,mt.addCodeArg)(r,s));return r.push("}"),new mt._Code(r)}if(e,r,n){if(this._blockNode(new io(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 io(e))}else(){return this._elseNode(new Xo)}endIf(){return this._endBlockNode(io,Xo)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Wf(e),r)}forRange(e,r,n,s,o=this.opts.es5?wn.varKinds.var:wn.varKinds.let){let i=this._scope.toName(e);return this._for(new Yf(o,i,r,n),()=>s(i))}forOf(e,r,n,s=wn.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let i=r instanceof mt.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,mt._)`${i}.length`,a=>{this.var(o,(0,mt._)`${i}[${a}]`),n(o)})}return this._for(new pl("of",s,o,r),()=>n(o))}forIn(e,r,n,s=this.opts.es5?wn.varKinds.var:wn.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,mt._)`Object.keys(${r})`,n);let o=this._scope.toName(e);return this._for(new pl("in",s,o,r),()=>n(o))}endFor(){return this._endBlockNode(ao)}label(e){return this._leafNode(new qf(e))}break(e){return this._leafNode(new Ff(e))}return(e){let r=new ga;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(ga)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let s=new Xf;if(this._blockNode(s),this.code(e),r){let o=this.name("e");this._currNode=s.catch=new _a(o),r(o)}return n&&(this._currNode=s.finally=new ba,this.code(n)),this._endBlockNode(_a,ba)}throw(e){return this._leafNode(new Hf(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=mt.nil,n,s){return this._blockNode(new ma(e,r,n)),s&&this.code(s).endFunc(),this}endFunc(){return this._endBlockNode(ma)}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 io))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}};lt.CodeGen=Kf;function co(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function ml(t,e){return e instanceof mt._CodeOrName?co(t,e.names):t}function Ko(t,e,r){if(t instanceof mt.Name)return n(t);if(!s(t))return t;return new mt._Code(t._items.reduce((o,i)=>(i instanceof mt.Name&&(i=n(i)),i instanceof mt._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 mt._Code&&o._items.some(i=>i instanceof mt.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function L6(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function b2(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,mt._)`!${Jf(t)}`}lt.not=b2;var Z6=y2(lt.operators.AND);function B6(...t){return t.reduce(Z6)}lt.and=B6;var V6=y2(lt.operators.OR);function q6(...t){return t.reduce(V6)}lt.or=q6;function y2(t){return(e,r)=>e===mt.nil?r:r===mt.nil?e:(0,mt._)`${Jf(e)} ${t} ${Jf(r)}`}function Jf(t){return t instanceof mt.Name?t:(0,mt._)`(${t})`}});var _t=Pe(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.checkStrictMode=ut.getErrorPath=ut.Type=ut.useFunc=ut.setEvaluated=ut.evaluatedPropsToName=ut.mergeEvaluated=ut.eachItem=ut.unescapeJsonPointer=ut.escapeJsonPointer=ut.escapeFragment=ut.unescapeFragment=ut.schemaRefOrVal=ut.schemaHasRulesButRef=ut.schemaHasRules=ut.checkUnknownRules=ut.alwaysValidSchema=ut.toHash=void 0;var Rt=ct(),F6=fa();function H6(t){let e={};for(let r of t)e[r]=!0;return e}ut.toHash=H6;function U6(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(x2(t,e),!S2(e,t.self.RULES.all))}ut.alwaysValidSchema=U6;function x2(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]||E2(t,`unknown keyword: "${o}"`)}ut.checkUnknownRules=x2;function S2(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}ut.schemaHasRules=S2;function G6(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}ut.schemaHasRulesButRef=G6;function W6({topSchemaRef:t,schemaPath:e},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,Rt._)`${r}`}return(0,Rt._)`${t}${e}${(0,Rt.getProperty)(n)}`}ut.schemaRefOrVal=W6;function Y6(t){return k2(decodeURIComponent(t))}ut.unescapeFragment=Y6;function X6(t){return encodeURIComponent(ep(t))}ut.escapeFragment=X6;function ep(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}ut.escapeJsonPointer=ep;function k2(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}ut.unescapeJsonPointer=k2;function K6(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}ut.eachItem=K6;function v2({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(s,o,i,a)=>{let c=i===void 0?o:i instanceof Rt.Name?(o instanceof Rt.Name?t(s,o,i):e(s,o,i),i):o instanceof Rt.Name?(e(s,i,o),o):r(o,i);return a===Rt.Name&&!(c instanceof Rt.Name)?n(s,c):c}}ut.mergeEvaluated={props:v2({mergeNames:(t,e,r)=>t.if((0,Rt._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,Rt._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,Rt._)`${r} || {}`).code((0,Rt._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,Rt._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,Rt._)`${r} || {}`),tp(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:$2}),items:v2({mergeNames:(t,e,r)=>t.if((0,Rt._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,Rt._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,Rt._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,Rt._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function $2(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,Rt._)`{}`);return e!==void 0&&tp(t,r,e),r}ut.evaluatedPropsToName=$2;function tp(t,e,r){Object.keys(r).forEach(n=>t.assign((0,Rt._)`${e}${(0,Rt.getProperty)(n)}`,!0))}ut.setEvaluated=tp;var w2={};function J6(t,e){return t.scopeValue("func",{ref:e,code:w2[e.code]||(w2[e.code]=new F6._Code(e.code))})}ut.useFunc=J6;var Qf;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Qf||(ut.Type=Qf={}));function Q6(t,e,r){if(t instanceof Rt.Name){let n=e===Qf.Num;return r?n?(0,Rt._)`"[" + ${t} + "]"`:(0,Rt._)`"['" + ${t} + "']"`:n?(0,Rt._)`"/" + ${t}`:(0,Rt._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,Rt.getProperty)(t).toString():"/"+ep(t)}ut.getErrorPath=Q6;function E2(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}ut.checkStrictMode=E2});var Jn=Pe(rp=>{"use strict";Object.defineProperty(rp,"__esModule",{value:!0});var pr=ct(),e$={data:new pr.Name("data"),valCxt:new pr.Name("valCxt"),instancePath:new pr.Name("instancePath"),parentData:new pr.Name("parentData"),parentDataProperty:new pr.Name("parentDataProperty"),rootData:new pr.Name("rootData"),dynamicAnchors:new pr.Name("dynamicAnchors"),vErrors:new pr.Name("vErrors"),errors:new pr.Name("errors"),this:new pr.Name("this"),self:new pr.Name("self"),scope:new pr.Name("scope"),json:new pr.Name("json"),jsonPos:new pr.Name("jsonPos"),jsonLen:new pr.Name("jsonLen"),jsonPart:new pr.Name("jsonPart")};rp.default=e$});var ya=Pe(mr=>{"use strict";Object.defineProperty(mr,"__esModule",{value:!0});mr.extendErrors=mr.resetErrorsCount=mr.reportExtraError=mr.reportError=mr.keyword$DataError=mr.keywordError=void 0;var bt=ct(),_l=_t(),xr=Jn();mr.keywordError={message:({keyword:t})=>(0,bt.str)`must pass "${t}" keyword validation`};mr.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,bt.str)`"${t}" keyword must be ${e} ($data)`:(0,bt.str)`"${t}" keyword is invalid ($data)`};function t$(t,e=mr.keywordError,r,n){let{it:s}=t,{gen:o,compositeRule:i,allErrors:a}=s,c=I2(t,e,r);n??(i||a)?T2(o,c):R2(s,(0,bt._)`[${c}]`)}mr.reportError=t$;function r$(t,e=mr.keywordError,r){let{it:n}=t,{gen:s,compositeRule:o,allErrors:i}=n,a=I2(t,e,r);T2(s,a),o||i||R2(n,xr.default.vErrors)}mr.reportExtraError=r$;function n$(t,e){t.assign(xr.default.errors,e),t.if((0,bt._)`${xr.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,bt._)`${xr.default.vErrors}.length`,e),()=>t.assign(xr.default.vErrors,null)))}mr.resetErrorsCount=n$;function s$({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,xr.default.errors,a=>{t.const(i,(0,bt._)`${xr.default.vErrors}[${a}]`),t.if((0,bt._)`${i}.instancePath === undefined`,()=>t.assign((0,bt._)`${i}.instancePath`,(0,bt.strConcat)(xr.default.instancePath,o.errorPath))),t.assign((0,bt._)`${i}.schemaPath`,(0,bt.str)`${o.errSchemaPath}/${e}`),o.opts.verbose&&(t.assign((0,bt._)`${i}.schema`,r),t.assign((0,bt._)`${i}.data`,n))})}mr.extendErrors=s$;function T2(t,e){let r=t.const("err",e);t.if((0,bt._)`${xr.default.vErrors} === null`,()=>t.assign(xr.default.vErrors,(0,bt._)`[${r}]`),(0,bt._)`${xr.default.vErrors}.push(${r})`),t.code((0,bt._)`${xr.default.errors}++`)}function R2(t,e){let{gen:r,validateName:n,schemaEnv:s}=t;s.$async?r.throw((0,bt._)`new ${t.ValidationError}(${e})`):(r.assign((0,bt._)`${n}.errors`,e),r.return(!1))}var lo={keyword:new bt.Name("keyword"),schemaPath:new bt.Name("schemaPath"),params:new bt.Name("params"),propertyName:new bt.Name("propertyName"),message:new bt.Name("message"),schema:new bt.Name("schema"),parentSchema:new bt.Name("parentSchema")};function I2(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,bt._)`{}`:o$(t,e,r)}function o$(t,e,r={}){let{gen:n,it:s}=t,o=[i$(s,r),a$(t,r)];return c$(t,e,o),n.object(...o)}function i$({errorPath:t},{instancePath:e}){let r=e?(0,bt.str)`${t}${(0,_l.getErrorPath)(e,_l.Type.Str)}`:t;return[xr.default.instancePath,(0,bt.strConcat)(xr.default.instancePath,r)]}function a$({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let s=n?e:(0,bt.str)`${e}/${t}`;return r&&(s=(0,bt.str)`${s}${(0,_l.getErrorPath)(r,_l.Type.Str)}`),[lo.schemaPath,s]}function c$(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([lo.keyword,s],[lo.params,typeof e=="function"?e(t):e||(0,bt._)`{}`]),c.messages&&n.push([lo.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([lo.schema,i],[lo.parentSchema,(0,bt._)`${l}${u}`],[xr.default.data,o]),d&&n.push([lo.propertyName,d])}});var M2=Pe(Jo=>{"use strict";Object.defineProperty(Jo,"__esModule",{value:!0});Jo.boolOrEmptySchema=Jo.topBoolOrEmptySchema=void 0;var l$=ya(),u$=ct(),d$=Jn(),h$={message:"boolean schema is false"};function f$(t){let{gen:e,schema:r,validateName:n}=t;r===!1?P2(t,!1):typeof r=="object"&&r.$async===!0?e.return(d$.default.data):(e.assign((0,u$._)`${n}.errors`,null),e.return(!0))}Jo.topBoolOrEmptySchema=f$;function p$(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),P2(t)):r.var(e,!0)}Jo.boolOrEmptySchema=p$;function P2(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,l$.reportError)(s,h$,void 0,e)}});var np=Pe(Qo=>{"use strict";Object.defineProperty(Qo,"__esModule",{value:!0});Qo.getRules=Qo.isJSONType=void 0;var m$=["string","number","integer","boolean","null","object","array"],g$=new Set(m$);function _$(t){return typeof t=="string"&&g$.has(t)}Qo.isJSONType=_$;function b$(){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:{}}}Qo.getRules=b$});var sp=Pe(ms=>{"use strict";Object.defineProperty(ms,"__esModule",{value:!0});ms.shouldUseRule=ms.shouldUseGroup=ms.schemaHasRulesForType=void 0;function y$({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&O2(t,n)}ms.schemaHasRulesForType=y$;function O2(t,e){return e.rules.some(r=>A2(t,r))}ms.shouldUseGroup=O2;function A2(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))}ms.shouldUseRule=A2});var va=Pe(gr=>{"use strict";Object.defineProperty(gr,"__esModule",{value:!0});gr.reportTypeError=gr.checkDataTypes=gr.checkDataType=gr.coerceAndCheckDataType=gr.getJSONTypes=gr.getSchemaTypes=gr.DataType=void 0;var v$=np(),w$=sp(),x$=ya(),it=ct(),z2=_t(),ei;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(ei||(gr.DataType=ei={}));function S$(t){let e=N2(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}gr.getSchemaTypes=S$;function N2(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(v$.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}gr.getJSONTypes=N2;function k$(t,e){let{gen:r,data:n,opts:s}=t,o=$$(e,s.coerceTypes),i=e.length>0&&!(o.length===0&&e.length===1&&(0,w$.schemaHasRulesForType)(t,e[0]));if(i){let a=ip(e,n,s.strictNumbers,ei.Wrong);r.if(a,()=>{o.length?E$(t,e,o):ap(t)})}return i}gr.coerceAndCheckDataType=k$;var C2=new Set(["string","number","integer","boolean","null"]);function $$(t,e){return e?t.filter(r=>C2.has(r)||e==="array"&&r==="array"):[]}function E$(t,e,r){let{gen:n,data:s,opts:o}=t,i=n.let("dataType",(0,it._)`typeof ${s}`),a=n.let("coerced",(0,it._)`undefined`);o.coerceTypes==="array"&&n.if((0,it._)`${i} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,it._)`${s}[0]`).assign(i,(0,it._)`typeof ${s}`).if(ip(e,s,o.strictNumbers),()=>n.assign(a,s))),n.if((0,it._)`${a} !== undefined`);for(let d of r)(C2.has(d)||d==="array"&&o.coerceTypes==="array")&&c(d);n.else(),ap(t),n.endIf(),n.if((0,it._)`${a} !== undefined`,()=>{n.assign(s,a),T$(t,a)});function c(d){switch(d){case"string":n.elseIf((0,it._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,it._)`"" + ${s}`).elseIf((0,it._)`${s} === null`).assign(a,(0,it._)`""`);return;case"number":n.elseIf((0,it._)`${i} == "boolean" || ${s} === null
|
|
2
|
+
var kx=Object.create;var Qu=Object.defineProperty;var $x=Object.getOwnPropertyDescriptor;var Ex=Object.getOwnPropertyNames;var Tx=Object.getPrototypeOf,Rx=Object.prototype.hasOwnProperty;var Me=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ed=(t,e)=>{for(var r in e)Qu(t,r,{get:e[r],enumerable:!0})},Px=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ex(e))!Rx.call(t,s)&&s!==r&&Qu(t,s,{get:()=>e[s],enumerable:!(n=$x(e,s))||n.enumerable});return t};var Ni=(t,e,r)=>(r=t!=null?kx(Tx(t)):{},Px(e||!t||!t.__esModule?Qu(r,"default",{value:t,enumerable:!0}):r,t));var ha=Me(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.regexpCode=wt.getEsmExportName=wt.getProperty=wt.safeStringify=wt.stringify=wt.strConcat=wt.addCodeArg=wt.str=wt._=wt.nil=wt._Code=wt.Name=wt.IDENTIFIER=wt._CodeOrName=void 0;var ua=class{};wt._CodeOrName=ua;wt.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var so=class extends ua{constructor(e){if(super(),!wt.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}}};wt.Name=so;var nn=class extends ua{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 so&&(r[n.str]=(r[n.str]||0)+1),r),{})}};wt._Code=nn;wt.nil=new nn("");function g2(t,...e){let r=[t[0]],n=0;for(;n<e.length;)jf(r,e[n]),r.push(t[++n]);return new nn(r)}wt._=g2;var Cf=new nn("+");function _2(t,...e){let r=[da(t[0])],n=0;for(;n<e.length;)r.push(Cf),jf(r,e[n]),r.push(Cf,da(t[++n]));return P6(r),new nn(r)}wt.str=_2;function jf(t,e){e instanceof nn?t.push(...e._items):e instanceof so?t.push(e):t.push(z6(e))}wt.addCodeArg=jf;function P6(t){let e=1;for(;e<t.length-1;){if(t[e]===Cf){let r=M6(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function M6(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof so||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 so))return`"${t}${e.slice(1)}`}function I6(t,e){return e.emptyStr()?t:t.emptyStr()?e:_2`${t}${e}`}wt.strConcat=I6;function z6(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:da(Array.isArray(t)?t.join(","):t)}function A6(t){return new nn(da(t))}wt.stringify=A6;function da(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}wt.safeStringify=da;function O6(t){return typeof t=="string"&&wt.IDENTIFIER.test(t)?new nn(`.${t}`):g2`[${t}]`}wt.getProperty=O6;function N6(t){if(typeof t=="string"&&wt.IDENTIFIER.test(t))return new nn(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}wt.getEsmExportName=N6;function C6(t){return new nn(t.toString())}wt.regexpCode=C6});var Zf=Me(Ar=>{"use strict";Object.defineProperty(Ar,"__esModule",{value:!0});Ar.ValueScope=Ar.ValueScopeName=Ar.Scope=Ar.varKinds=Ar.UsedValueState=void 0;var zr=ha(),Df=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},ll;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(ll||(Ar.UsedValueState=ll={}));Ar.varKinds={const:new zr.Name("const"),let:new zr.Name("let"),var:new zr.Name("var")};var ul=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof zr.Name?e:this.name(e)}name(e){return new zr.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}}};Ar.Scope=ul;var dl=class extends zr.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,zr._)`.${new zr.Name(r)}[${n}]`}};Ar.ValueScopeName=dl;var j6=(0,zr._)`\n`,Lf=class extends ul{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?j6:zr.nil}}get(){return this._scope}name(e){return new dl(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,zr._)`${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=zr.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,ll.Started);let l=r(d);if(l){let u=this.opts.es5?Ar.varKinds.var:Ar.varKinds.const;o=(0,zr._)`${o}${u} ${d} = ${l};${this.opts._n}`}else if(l=s?.(d))o=(0,zr._)`${o}${l}${this.opts._n}`;else throw new Df(d);c.set(d,ll.Completed)})}return o}};Ar.ValueScope=Lf});var ct=Me(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.or=lt.and=lt.not=lt.CodeGen=lt.operators=lt.varKinds=lt.ValueScopeName=lt.ValueScope=lt.Scope=lt.Name=lt.regexpCode=lt.stringify=lt.getProperty=lt.nil=lt.strConcat=lt.str=lt._=void 0;var mt=ha(),wn=Zf(),ps=ha();Object.defineProperty(lt,"_",{enumerable:!0,get:function(){return ps._}});Object.defineProperty(lt,"str",{enumerable:!0,get:function(){return ps.str}});Object.defineProperty(lt,"strConcat",{enumerable:!0,get:function(){return ps.strConcat}});Object.defineProperty(lt,"nil",{enumerable:!0,get:function(){return ps.nil}});Object.defineProperty(lt,"getProperty",{enumerable:!0,get:function(){return ps.getProperty}});Object.defineProperty(lt,"stringify",{enumerable:!0,get:function(){return ps.stringify}});Object.defineProperty(lt,"regexpCode",{enumerable:!0,get:function(){return ps.regexpCode}});Object.defineProperty(lt,"Name",{enumerable:!0,get:function(){return ps.Name}});var ml=Zf();Object.defineProperty(lt,"Scope",{enumerable:!0,get:function(){return ml.Scope}});Object.defineProperty(lt,"ValueScope",{enumerable:!0,get:function(){return ml.ValueScope}});Object.defineProperty(lt,"ValueScopeName",{enumerable:!0,get:function(){return ml.ValueScopeName}});Object.defineProperty(lt,"varKinds",{enumerable:!0,get:function(){return ml.varKinds}});lt.operators={GT:new mt._Code(">"),GTE:new mt._Code(">="),LT:new mt._Code("<"),LTE:new mt._Code("<="),EQ:new mt._Code("==="),NEQ:new mt._Code("!=="),NOT:new mt._Code("!"),OR:new mt._Code("||"),AND:new mt._Code("&&"),ADD:new mt._Code("+")};var Xn=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},Bf=class extends Xn{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?wn.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=Xo(this.rhs,e,r)),this}get names(){return this.rhs instanceof mt._CodeOrName?this.rhs.names:{}}},hl=class extends Xn{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 mt.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=Xo(this.rhs,e,r),this}get names(){let e=this.lhs instanceof mt.Name?{}:{...this.lhs.names};return pl(e,this.rhs)}},Vf=class extends hl{constructor(e,r,n,s){super(e,n,s),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},qf=class extends Xn{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Ff=class extends Xn{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Uf=class extends Xn{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Hf=class extends Xn{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=Xo(this.code,e,r),this}get names(){return this.code instanceof mt._CodeOrName?this.code.names:{}}},fa=class extends Xn{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)||(D6(e,o.names),n.splice(s,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>ao(e,r.names),{})}},Kn=class extends fa{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Gf=class extends fa{},Yo=class extends Kn{};Yo.kind="else";var oo=class t extends Kn{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 Yo(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(b2(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=Xo(this.condition,e,r),this}get names(){let e=super.names;return pl(e,this.condition),this.else&&ao(e,this.else.names),e}};oo.kind="if";var io=class extends Kn{};io.kind="for";var Wf=class extends io{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=Xo(this.iteration,e,r),this}get names(){return ao(super.names,this.iteration.names)}},Yf=class extends io{constructor(e,r,n,s){super(),this.varKind=e,this.name=r,this.from=n,this.to=s}render(e){let r=e.es5?wn.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=pl(super.names,this.from);return pl(e,this.to)}},fl=class extends io{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=Xo(this.iterable,e,r),this}get names(){return ao(super.names,this.iterable.names)}},pa=class extends Kn{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)}};pa.kind="func";var ma=class extends fa{render(e){return"return "+super.render(e)}};ma.kind="return";var Xf=class extends Kn{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&&ao(e,this.catch.names),this.finally&&ao(e,this.finally.names),e}},ga=class extends Kn{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};ga.kind="catch";var _a=class extends Kn{render(e){return"finally"+super.render(e)}};_a.kind="finally";var Kf=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
3
|
+
`:""},this._extScope=e,this._scope=new wn.Scope({parent:e}),this._nodes=[new Gf]}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 Bf(e,o,n)),o}const(e,r,n){return this._def(wn.varKinds.const,e,r,n)}let(e,r,n){return this._def(wn.varKinds.let,e,r,n)}var(e,r,n){return this._def(wn.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new hl(e,r,n))}add(e,r){return this._leafNode(new Vf(e,lt.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==mt.nil&&this._leafNode(new Hf(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,mt.addCodeArg)(r,s));return r.push("}"),new mt._Code(r)}if(e,r,n){if(this._blockNode(new oo(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 oo(e))}else(){return this._elseNode(new Yo)}endIf(){return this._endBlockNode(oo,Yo)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Wf(e),r)}forRange(e,r,n,s,o=this.opts.es5?wn.varKinds.var:wn.varKinds.let){let i=this._scope.toName(e);return this._for(new Yf(o,i,r,n),()=>s(i))}forOf(e,r,n,s=wn.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let i=r instanceof mt.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,mt._)`${i}.length`,a=>{this.var(o,(0,mt._)`${i}[${a}]`),n(o)})}return this._for(new fl("of",s,o,r),()=>n(o))}forIn(e,r,n,s=this.opts.es5?wn.varKinds.var:wn.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,mt._)`Object.keys(${r})`,n);let o=this._scope.toName(e);return this._for(new fl("in",s,o,r),()=>n(o))}endFor(){return this._endBlockNode(io)}label(e){return this._leafNode(new qf(e))}break(e){return this._leafNode(new Ff(e))}return(e){let r=new ma;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(ma)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let s=new Xf;if(this._blockNode(s),this.code(e),r){let o=this.name("e");this._currNode=s.catch=new ga(o),r(o)}return n&&(this._currNode=s.finally=new _a,this.code(n)),this._endBlockNode(ga,_a)}throw(e){return this._leafNode(new Uf(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=mt.nil,n,s){return this._blockNode(new pa(e,r,n)),s&&this.code(s).endFunc(),this}endFunc(){return this._endBlockNode(pa)}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 oo))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}};lt.CodeGen=Kf;function ao(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function pl(t,e){return e instanceof mt._CodeOrName?ao(t,e.names):t}function Xo(t,e,r){if(t instanceof mt.Name)return n(t);if(!s(t))return t;return new mt._Code(t._items.reduce((o,i)=>(i instanceof mt.Name&&(i=n(i)),i instanceof mt._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 mt._Code&&o._items.some(i=>i instanceof mt.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function D6(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function b2(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,mt._)`!${Jf(t)}`}lt.not=b2;var L6=y2(lt.operators.AND);function Z6(...t){return t.reduce(L6)}lt.and=Z6;var B6=y2(lt.operators.OR);function V6(...t){return t.reduce(B6)}lt.or=V6;function y2(t){return(e,r)=>e===mt.nil?r:r===mt.nil?e:(0,mt._)`${Jf(e)} ${t} ${Jf(r)}`}function Jf(t){return t instanceof mt.Name?t:(0,mt._)`(${t})`}});var _t=Me(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.checkStrictMode=ut.getErrorPath=ut.Type=ut.useFunc=ut.setEvaluated=ut.evaluatedPropsToName=ut.mergeEvaluated=ut.eachItem=ut.unescapeJsonPointer=ut.escapeJsonPointer=ut.escapeFragment=ut.unescapeFragment=ut.schemaRefOrVal=ut.schemaHasRulesButRef=ut.schemaHasRules=ut.checkUnknownRules=ut.alwaysValidSchema=ut.toHash=void 0;var Rt=ct(),q6=ha();function F6(t){let e={};for(let r of t)e[r]=!0;return e}ut.toHash=F6;function U6(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(x2(t,e),!S2(e,t.self.RULES.all))}ut.alwaysValidSchema=U6;function x2(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]||E2(t,`unknown keyword: "${o}"`)}ut.checkUnknownRules=x2;function S2(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}ut.schemaHasRules=S2;function H6(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}ut.schemaHasRulesButRef=H6;function G6({topSchemaRef:t,schemaPath:e},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,Rt._)`${r}`}return(0,Rt._)`${t}${e}${(0,Rt.getProperty)(n)}`}ut.schemaRefOrVal=G6;function W6(t){return k2(decodeURIComponent(t))}ut.unescapeFragment=W6;function Y6(t){return encodeURIComponent(ep(t))}ut.escapeFragment=Y6;function ep(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}ut.escapeJsonPointer=ep;function k2(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}ut.unescapeJsonPointer=k2;function X6(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}ut.eachItem=X6;function v2({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(s,o,i,a)=>{let c=i===void 0?o:i instanceof Rt.Name?(o instanceof Rt.Name?t(s,o,i):e(s,o,i),i):o instanceof Rt.Name?(e(s,i,o),o):r(o,i);return a===Rt.Name&&!(c instanceof Rt.Name)?n(s,c):c}}ut.mergeEvaluated={props:v2({mergeNames:(t,e,r)=>t.if((0,Rt._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,Rt._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,Rt._)`${r} || {}`).code((0,Rt._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,Rt._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,Rt._)`${r} || {}`),tp(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:$2}),items:v2({mergeNames:(t,e,r)=>t.if((0,Rt._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,Rt._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,Rt._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,Rt._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function $2(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,Rt._)`{}`);return e!==void 0&&tp(t,r,e),r}ut.evaluatedPropsToName=$2;function tp(t,e,r){Object.keys(r).forEach(n=>t.assign((0,Rt._)`${e}${(0,Rt.getProperty)(n)}`,!0))}ut.setEvaluated=tp;var w2={};function K6(t,e){return t.scopeValue("func",{ref:e,code:w2[e.code]||(w2[e.code]=new q6._Code(e.code))})}ut.useFunc=K6;var Qf;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Qf||(ut.Type=Qf={}));function J6(t,e,r){if(t instanceof Rt.Name){let n=e===Qf.Num;return r?n?(0,Rt._)`"[" + ${t} + "]"`:(0,Rt._)`"['" + ${t} + "']"`:n?(0,Rt._)`"/" + ${t}`:(0,Rt._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,Rt.getProperty)(t).toString():"/"+ep(t)}ut.getErrorPath=J6;function E2(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}ut.checkStrictMode=E2});var Jn=Me(rp=>{"use strict";Object.defineProperty(rp,"__esModule",{value:!0});var pr=ct(),Q6={data:new pr.Name("data"),valCxt:new pr.Name("valCxt"),instancePath:new pr.Name("instancePath"),parentData:new pr.Name("parentData"),parentDataProperty:new pr.Name("parentDataProperty"),rootData:new pr.Name("rootData"),dynamicAnchors:new pr.Name("dynamicAnchors"),vErrors:new pr.Name("vErrors"),errors:new pr.Name("errors"),this:new pr.Name("this"),self:new pr.Name("self"),scope:new pr.Name("scope"),json:new pr.Name("json"),jsonPos:new pr.Name("jsonPos"),jsonLen:new pr.Name("jsonLen"),jsonPart:new pr.Name("jsonPart")};rp.default=Q6});var ba=Me(mr=>{"use strict";Object.defineProperty(mr,"__esModule",{value:!0});mr.extendErrors=mr.resetErrorsCount=mr.reportExtraError=mr.reportError=mr.keyword$DataError=mr.keywordError=void 0;var bt=ct(),gl=_t(),xr=Jn();mr.keywordError={message:({keyword:t})=>(0,bt.str)`must pass "${t}" keyword validation`};mr.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,bt.str)`"${t}" keyword must be ${e} ($data)`:(0,bt.str)`"${t}" keyword is invalid ($data)`};function e$(t,e=mr.keywordError,r,n){let{it:s}=t,{gen:o,compositeRule:i,allErrors:a}=s,c=P2(t,e,r);n??(i||a)?T2(o,c):R2(s,(0,bt._)`[${c}]`)}mr.reportError=e$;function t$(t,e=mr.keywordError,r){let{it:n}=t,{gen:s,compositeRule:o,allErrors:i}=n,a=P2(t,e,r);T2(s,a),o||i||R2(n,xr.default.vErrors)}mr.reportExtraError=t$;function r$(t,e){t.assign(xr.default.errors,e),t.if((0,bt._)`${xr.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,bt._)`${xr.default.vErrors}.length`,e),()=>t.assign(xr.default.vErrors,null)))}mr.resetErrorsCount=r$;function n$({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,xr.default.errors,a=>{t.const(i,(0,bt._)`${xr.default.vErrors}[${a}]`),t.if((0,bt._)`${i}.instancePath === undefined`,()=>t.assign((0,bt._)`${i}.instancePath`,(0,bt.strConcat)(xr.default.instancePath,o.errorPath))),t.assign((0,bt._)`${i}.schemaPath`,(0,bt.str)`${o.errSchemaPath}/${e}`),o.opts.verbose&&(t.assign((0,bt._)`${i}.schema`,r),t.assign((0,bt._)`${i}.data`,n))})}mr.extendErrors=n$;function T2(t,e){let r=t.const("err",e);t.if((0,bt._)`${xr.default.vErrors} === null`,()=>t.assign(xr.default.vErrors,(0,bt._)`[${r}]`),(0,bt._)`${xr.default.vErrors}.push(${r})`),t.code((0,bt._)`${xr.default.errors}++`)}function R2(t,e){let{gen:r,validateName:n,schemaEnv:s}=t;s.$async?r.throw((0,bt._)`new ${t.ValidationError}(${e})`):(r.assign((0,bt._)`${n}.errors`,e),r.return(!1))}var co={keyword:new bt.Name("keyword"),schemaPath:new bt.Name("schemaPath"),params:new bt.Name("params"),propertyName:new bt.Name("propertyName"),message:new bt.Name("message"),schema:new bt.Name("schema"),parentSchema:new bt.Name("parentSchema")};function P2(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,bt._)`{}`:s$(t,e,r)}function s$(t,e,r={}){let{gen:n,it:s}=t,o=[o$(s,r),i$(t,r)];return a$(t,e,o),n.object(...o)}function o$({errorPath:t},{instancePath:e}){let r=e?(0,bt.str)`${t}${(0,gl.getErrorPath)(e,gl.Type.Str)}`:t;return[xr.default.instancePath,(0,bt.strConcat)(xr.default.instancePath,r)]}function i$({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let s=n?e:(0,bt.str)`${e}/${t}`;return r&&(s=(0,bt.str)`${s}${(0,gl.getErrorPath)(r,gl.Type.Str)}`),[co.schemaPath,s]}function a$(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([co.keyword,s],[co.params,typeof e=="function"?e(t):e||(0,bt._)`{}`]),c.messages&&n.push([co.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([co.schema,i],[co.parentSchema,(0,bt._)`${l}${u}`],[xr.default.data,o]),d&&n.push([co.propertyName,d])}});var I2=Me(Ko=>{"use strict";Object.defineProperty(Ko,"__esModule",{value:!0});Ko.boolOrEmptySchema=Ko.topBoolOrEmptySchema=void 0;var c$=ba(),l$=ct(),u$=Jn(),d$={message:"boolean schema is false"};function h$(t){let{gen:e,schema:r,validateName:n}=t;r===!1?M2(t,!1):typeof r=="object"&&r.$async===!0?e.return(u$.default.data):(e.assign((0,l$._)`${n}.errors`,null),e.return(!0))}Ko.topBoolOrEmptySchema=h$;function f$(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),M2(t)):r.var(e,!0)}Ko.boolOrEmptySchema=f$;function M2(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,c$.reportError)(s,d$,void 0,e)}});var np=Me(Jo=>{"use strict";Object.defineProperty(Jo,"__esModule",{value:!0});Jo.getRules=Jo.isJSONType=void 0;var p$=["string","number","integer","boolean","null","object","array"],m$=new Set(p$);function g$(t){return typeof t=="string"&&m$.has(t)}Jo.isJSONType=g$;function _$(){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=_$});var sp=Me(ms=>{"use strict";Object.defineProperty(ms,"__esModule",{value:!0});ms.shouldUseRule=ms.shouldUseGroup=ms.schemaHasRulesForType=void 0;function b$({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&z2(t,n)}ms.schemaHasRulesForType=b$;function z2(t,e){return e.rules.some(r=>A2(t,r))}ms.shouldUseGroup=z2;function A2(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))}ms.shouldUseRule=A2});var ya=Me(gr=>{"use strict";Object.defineProperty(gr,"__esModule",{value:!0});gr.reportTypeError=gr.checkDataTypes=gr.checkDataType=gr.coerceAndCheckDataType=gr.getJSONTypes=gr.getSchemaTypes=gr.DataType=void 0;var y$=np(),v$=sp(),w$=ba(),it=ct(),O2=_t(),Qo;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(Qo||(gr.DataType=Qo={}));function x$(t){let e=N2(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}gr.getSchemaTypes=x$;function N2(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(y$.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}gr.getJSONTypes=N2;function S$(t,e){let{gen:r,data:n,opts:s}=t,o=k$(e,s.coerceTypes),i=e.length>0&&!(o.length===0&&e.length===1&&(0,v$.schemaHasRulesForType)(t,e[0]));if(i){let a=ip(e,n,s.strictNumbers,Qo.Wrong);r.if(a,()=>{o.length?$$(t,e,o):ap(t)})}return i}gr.coerceAndCheckDataType=S$;var C2=new Set(["string","number","integer","boolean","null"]);function k$(t,e){return e?t.filter(r=>C2.has(r)||e==="array"&&r==="array"):[]}function $$(t,e,r){let{gen:n,data:s,opts:o}=t,i=n.let("dataType",(0,it._)`typeof ${s}`),a=n.let("coerced",(0,it._)`undefined`);o.coerceTypes==="array"&&n.if((0,it._)`${i} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,it._)`${s}[0]`).assign(i,(0,it._)`typeof ${s}`).if(ip(e,s,o.strictNumbers),()=>n.assign(a,s))),n.if((0,it._)`${a} !== undefined`);for(let d of r)(C2.has(d)||d==="array"&&o.coerceTypes==="array")&&c(d);n.else(),ap(t),n.endIf(),n.if((0,it._)`${a} !== undefined`,()=>{n.assign(s,a),E$(t,a)});function c(d){switch(d){case"string":n.elseIf((0,it._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,it._)`"" + ${s}`).elseIf((0,it._)`${s} === null`).assign(a,(0,it._)`""`);return;case"number":n.elseIf((0,it._)`${i} == "boolean" || ${s} === null
|
|
4
4
|
|| (${i} == "string" && ${s} && ${s} == +${s})`).assign(a,(0,it._)`+${s}`);return;case"integer":n.elseIf((0,it._)`${i} === "boolean" || ${s} === null
|
|
5
5
|
|| (${i} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(a,(0,it._)`+${s}`);return;case"boolean":n.elseIf((0,it._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(a,!1).elseIf((0,it._)`${s} === "true" || ${s} === 1`).assign(a,!0);return;case"null":n.elseIf((0,it._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(a,null);return;case"array":n.elseIf((0,it._)`${i} === "string" || ${i} === "number"
|
|
6
|
-
|| ${i} === "boolean" || ${s} === null`).assign(a,(0,it._)`[${s}]`)}}}function T$({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,it._)`${e} !== undefined`,()=>t.assign((0,it._)`${e}[${r}]`,n))}function op(t,e,r,n=ei.Correct){let s=n===ei.Correct?it.operators.EQ:it.operators.NEQ,o;switch(t){case"null":return(0,it._)`${e} ${s} null`;case"array":o=(0,it._)`Array.isArray(${e})`;break;case"object":o=(0,it._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":o=i((0,it._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":o=i();break;default:return(0,it._)`typeof ${e} ${s} ${t}`}return n===ei.Correct?o:(0,it.not)(o);function i(a=it.nil){return(0,it.and)((0,it._)`typeof ${e} == "number"`,a,r?(0,it._)`isFinite(${e})`:it.nil)}}gr.checkDataType=op;function ip(t,e,r,n){if(t.length===1)return op(t[0],e,r,n);let s,o=(0,z2.toHash)(t);if(o.array&&o.object){let i=(0,it._)`typeof ${e} != "object"`;s=o.null?i:(0,it._)`!${e} || ${i}`,delete o.null,delete o.array,delete o.object}else s=it.nil;o.number&&delete o.integer;for(let i in o)s=(0,it.and)(s,op(i,e,r,n));return s}gr.checkDataTypes=ip;var R$={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,it._)`{type: ${t}}`:(0,it._)`{type: ${e}}`};function ap(t){let e=I$(t);(0,x$.reportError)(e,R$)}gr.reportTypeError=ap;function I$(t){let{gen:e,data:r,schema:n}=t,s=(0,z2.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:t}}});var D2=Pe(bl=>{"use strict";Object.defineProperty(bl,"__esModule",{value:!0});bl.assignDefaults=void 0;var ti=ct(),P$=_t();function M$(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let s in r)j2(t,s,r[s].default);else e==="array"&&Array.isArray(n)&&n.forEach((s,o)=>j2(t,o,s.default))}bl.assignDefaults=M$;function j2(t,e,r){let{gen:n,compositeRule:s,data:o,opts:i}=t;if(r===void 0)return;let a=(0,ti._)`${o}${(0,ti.getProperty)(e)}`;if(s){(0,P$.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,ti._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,ti._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,ti._)`${a} = ${(0,ti.stringify)(r)}`)}});var sn=Pe($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.validateUnion=$t.validateArray=$t.usePattern=$t.callValidateCode=$t.schemaProperties=$t.allSchemaProperties=$t.noPropertyInData=$t.propertyInData=$t.isOwnProperty=$t.hasPropFunc=$t.reportMissingProp=$t.checkMissingProp=$t.checkReportMissingProp=void 0;var zt=ct(),cp=_t(),gs=Jn(),O$=_t();function A$(t,e){let{gen:r,data:n,it:s}=t;r.if(up(r,n,e,s.opts.ownProperties),()=>{t.setParams({missingProperty:(0,zt._)`${e}`},!0),t.error()})}$t.checkReportMissingProp=A$;function z$({gen:t,data:e,it:{opts:r}},n,s){return(0,zt.or)(...n.map(o=>(0,zt.and)(up(t,e,o,r.ownProperties),(0,zt._)`${s} = ${o}`)))}$t.checkMissingProp=z$;function N$(t,e){t.setParams({missingProperty:e},!0),t.error()}$t.reportMissingProp=N$;function L2(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,zt._)`Object.prototype.hasOwnProperty`})}$t.hasPropFunc=L2;function lp(t,e,r){return(0,zt._)`${L2(t)}.call(${e}, ${r})`}$t.isOwnProperty=lp;function C$(t,e,r,n){let s=(0,zt._)`${e}${(0,zt.getProperty)(r)} !== undefined`;return n?(0,zt._)`${s} && ${lp(t,e,r)}`:s}$t.propertyInData=C$;function up(t,e,r,n){let s=(0,zt._)`${e}${(0,zt.getProperty)(r)} === undefined`;return n?(0,zt.or)(s,(0,zt.not)(lp(t,e,r))):s}$t.noPropertyInData=up;function Z2(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}$t.allSchemaProperties=Z2;function j$(t,e){return Z2(e).filter(r=>!(0,cp.alwaysValidSchema)(t,e[r]))}$t.schemaProperties=j$;function D$({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=[[gs.default.instancePath,(0,zt.strConcat)(gs.default.instancePath,o)],[gs.default.parentData,i.parentData],[gs.default.parentDataProperty,i.parentDataProperty],[gs.default.rootData,gs.default.rootData]];i.opts.dynamicRef&&u.push([gs.default.dynamicAnchors,gs.default.dynamicAnchors]);let f=(0,zt._)`${l}, ${r.object(...u)}`;return c!==zt.nil?(0,zt._)`${a}.call(${c}, ${f})`:(0,zt._)`${a}(${f})`}$t.callValidateCode=D$;var L$=(0,zt._)`new RegExp`;function Z$({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"?L$:(0,O$.useFunc)(t,s)}(${r}, ${n})`})}$t.usePattern=Z$;function B$(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:cp.Type.Num},o),e.if((0,zt.not)(o),a)})}}$t.validateArray=B$;function V$(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,cp.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))}$t.validateUnion=V$});var q2=Pe(Cn=>{"use strict";Object.defineProperty(Cn,"__esModule",{value:!0});Cn.validateKeywordUsage=Cn.validSchemaType=Cn.funcKeywordCode=Cn.macroKeywordCode=void 0;var Sr=ct(),uo=Jn(),q$=sn(),F$=ya();function H$(t,e){let{gen:r,keyword:n,schema:s,parentSchema:o,it:i}=t,a=e.macro.call(i.self,s,o,i),c=V2(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let d=r.name("valid");t.subschema({schema:a,schemaPath:Sr.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},d),t.pass(d,()=>t.error(!0))}Cn.macroKeywordCode=H$;function U$(t,e){var r;let{gen:n,keyword:s,schema:o,parentSchema:i,$data:a,it:c}=t;W$(c,e);let d=!a&&e.compile?e.compile.call(c.self,o,i,c):e.validate,l=V2(n,s,d),u=n.let("valid");t.block$data(u,f),t.ok((r=e.valid)!==null&&r!==void 0?r:u);function f(){if(e.errors===!1)y(),e.modifying&&B2(t),k(()=>t.error());else{let x=e.async?p():m();e.modifying&&B2(t),k(()=>G$(t,x))}}function p(){let x=n.let("ruleErrs",null);return n.try(()=>y((0,Sr._)`await `),_=>n.assign(u,!1).if((0,Sr._)`${_} instanceof ${c.ValidationError}`,()=>n.assign(x,(0,Sr._)`${_}.errors`),()=>n.throw(_))),x}function m(){let x=(0,Sr._)`${l}.errors`;return n.assign(x,null),y(Sr.nil),x}function y(x=e.async?(0,Sr._)`await `:Sr.nil){let _=c.opts.passContext?uo.default.this:uo.default.self,g=!("compile"in e&&!a||e.schema===!1);n.assign(u,(0,Sr._)`${x}${(0,q$.callValidateCode)(t,l,_,g)}`,e.modifying)}function k(x){var _;n.if((0,Sr.not)((_=e.valid)!==null&&_!==void 0?_:u),x)}}Cn.funcKeywordCode=U$;function B2(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,Sr._)`${n.parentData}[${n.parentDataProperty}]`))}function G$(t,e){let{gen:r}=t;r.if((0,Sr._)`Array.isArray(${e})`,()=>{r.assign(uo.default.vErrors,(0,Sr._)`${uo.default.vErrors} === null ? ${e} : ${uo.default.vErrors}.concat(${e})`).assign(uo.default.errors,(0,Sr._)`${uo.default.vErrors}.length`),(0,F$.extendErrors)(t)},()=>t.error())}function W$({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function V2(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,Sr.stringify)(r)})}function Y$(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")}Cn.validSchemaType=Y$;function X$({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)}}Cn.validateKeywordUsage=X$});var H2=Pe(_s=>{"use strict";Object.defineProperty(_s,"__esModule",{value:!0});_s.extendSubschemaMode=_s.extendSubschemaData=_s.getSubschema=void 0;var jn=ct(),F2=_t();function K$(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,jn._)`${t.schemaPath}${(0,jn.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,jn._)`${t.schemaPath}${(0,jn.getProperty)(e)}${(0,jn.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,F2.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')}_s.getSubschema=K$;function J$(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,f=a.let("data",(0,jn._)`${e.data}${(0,jn.getProperty)(r)}`,!0);c(f),t.errorPath=(0,jn.str)`${d}${(0,F2.getErrorPath)(r,n,u.jsPropertySyntax)}`,t.parentDataProperty=(0,jn._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(s!==void 0){let d=s instanceof jn.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]}}_s.extendSubschemaData=J$;function Q$(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}_s.extendSubschemaMode=Q$});var dp=Pe(($B,U2)=>{"use strict";U2.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 W2=Pe((EB,G2)=>{"use strict";var bs=G2.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(){};yl(e,n,s,t,"",t)};bs.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};bs.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};bs.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};bs.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 yl(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 bs.arrayKeywords)for(var f=0;f<u.length;f++)yl(t,e,r,u[f],s+"/"+l+"/"+f,o,s,l,n,f)}else if(l in bs.propsKeywords){if(u&&typeof u=="object")for(var p in u)yl(t,e,r,u[p],s+"/"+l+"/"+e8(p),o,s,l,n,p)}else(l in bs.keywords||t.allKeys&&!(l in bs.skipKeywords))&&yl(t,e,r,u,s+"/"+l,o,s,l,n)}r(n,s,o,i,a,c,d)}}function e8(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var wa=Pe(zr=>{"use strict";Object.defineProperty(zr,"__esModule",{value:!0});zr.getSchemaRefs=zr.resolveUrl=zr.normalizeId=zr._getFullPath=zr.getFullPath=zr.inlineRef=void 0;var t8=_t(),r8=dp(),n8=W2(),s8=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function o8(t,e=!0){return typeof t=="boolean"?!0:e===!0?!hp(t):e?Y2(t)<=e:!1}zr.inlineRef=o8;var i8=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function hp(t){for(let e in t){if(i8.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(hp)||typeof r=="object"&&hp(r))return!0}return!1}function Y2(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!s8.has(r)&&(typeof t[r]=="object"&&(0,t8.eachItem)(t[r],n=>e+=Y2(n)),e===1/0))return 1/0}return e}function X2(t,e="",r){r!==!1&&(e=ri(e));let n=t.parse(e);return K2(t,n)}zr.getFullPath=X2;function K2(t,e){return t.serialize(e).split("#")[0]+"#"}zr._getFullPath=K2;var a8=/#\/?$/;function ri(t){return t?t.replace(a8,""):""}zr.normalizeId=ri;function c8(t,e,r){return r=ri(r),t.resolve(e,r)}zr.resolveUrl=c8;var l8=/^[a-z_][-a-z0-9._]*$/i;function u8(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,s=ri(t[r]||e),o={"":s},i=X2(n,s,!1),a={},c=new Set;return n8(t,{allKeys:!0},(u,f,p,m)=>{if(m===void 0)return;let y=i+f,k=o[m];typeof u[r]=="string"&&(k=x.call(this,u[r])),_.call(this,u.$anchor),_.call(this,u.$dynamicAnchor),o[f]=k;function x(g){let E=this.opts.uriResolver.resolve;if(g=ri(k?E(k,g):g),c.has(g))throw l(g);c.add(g);let h=this.refs[g];return typeof h=="string"&&(h=this.refs[h]),typeof h=="object"?d(u,h.schema,g):g!==ri(y)&&(g[0]==="#"?(d(u,a[g],g),a[g]=u):this.refs[g]=y),g}function _(g){if(typeof g=="string"){if(!l8.test(g))throw new Error(`invalid anchor "${g}"`);x.call(this,`#${g}`)}}}),a;function d(u,f,p){if(f!==void 0&&!r8(u,f))throw l(p)}function l(u){return new Error(`reference "${u}" resolves to more than one schema`)}}zr.getSchemaRefs=u8});var ka=Pe(ys=>{"use strict";Object.defineProperty(ys,"__esModule",{value:!0});ys.getData=ys.KeywordCxt=ys.validateFunctionCode=void 0;var rb=M2(),J2=va(),pp=sp(),vl=va(),d8=D2(),Sa=q2(),fp=H2(),He=ct(),Qe=Jn(),h8=wa(),Qn=_t(),xa=ya();function f8(t){if(ob(t)&&(ib(t),sb(t))){g8(t);return}nb(t,()=>(0,rb.topBoolOrEmptySchema)(t))}ys.validateFunctionCode=f8;function nb({gen:t,validateName:e,schema:r,schemaEnv:n,opts:s},o){s.code.es5?t.func(e,(0,He._)`${Qe.default.data}, ${Qe.default.valCxt}`,n.$async,()=>{t.code((0,He._)`"use strict"; ${Q2(r,s)}`),m8(t,s),t.code(o)}):t.func(e,(0,He._)`${Qe.default.data}, ${p8(s)}`,n.$async,()=>t.code(Q2(r,s)).code(o))}function p8(t){return(0,He._)`{${Qe.default.instancePath}="", ${Qe.default.parentData}, ${Qe.default.parentDataProperty}, ${Qe.default.rootData}=${Qe.default.data}${t.dynamicRef?(0,He._)`, ${Qe.default.dynamicAnchors}={}`:He.nil}}={}`}function m8(t,e){t.if(Qe.default.valCxt,()=>{t.var(Qe.default.instancePath,(0,He._)`${Qe.default.valCxt}.${Qe.default.instancePath}`),t.var(Qe.default.parentData,(0,He._)`${Qe.default.valCxt}.${Qe.default.parentData}`),t.var(Qe.default.parentDataProperty,(0,He._)`${Qe.default.valCxt}.${Qe.default.parentDataProperty}`),t.var(Qe.default.rootData,(0,He._)`${Qe.default.valCxt}.${Qe.default.rootData}`),e.dynamicRef&&t.var(Qe.default.dynamicAnchors,(0,He._)`${Qe.default.valCxt}.${Qe.default.dynamicAnchors}`)},()=>{t.var(Qe.default.instancePath,(0,He._)`""`),t.var(Qe.default.parentData,(0,He._)`undefined`),t.var(Qe.default.parentDataProperty,(0,He._)`undefined`),t.var(Qe.default.rootData,Qe.default.data),e.dynamicRef&&t.var(Qe.default.dynamicAnchors,(0,He._)`{}`)})}function g8(t){let{schema:e,opts:r,gen:n}=t;nb(t,()=>{r.$comment&&e.$comment&&cb(t),w8(t),n.let(Qe.default.vErrors,null),n.let(Qe.default.errors,0),r.unevaluated&&_8(t),ab(t),k8(t)})}function _8(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,He._)`${r}.evaluated`),e.if((0,He._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,He._)`${t.evaluated}.props`,(0,He._)`undefined`)),e.if((0,He._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,He._)`${t.evaluated}.items`,(0,He._)`undefined`))}function Q2(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,He._)`/*# sourceURL=${r} */`:He.nil}function b8(t,e){if(ob(t)&&(ib(t),sb(t))){y8(t,e);return}(0,rb.boolOrEmptySchema)(t,e)}function sb({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 ob(t){return typeof t.schema!="boolean"}function y8(t,e){let{schema:r,gen:n,opts:s}=t;s.$comment&&r.$comment&&cb(t),x8(t),S8(t);let o=n.const("_errs",Qe.default.errors);ab(t,o),n.var(e,(0,He._)`${o} === ${Qe.default.errors}`)}function ib(t){(0,Qn.checkUnknownRules)(t),v8(t)}function ab(t,e){if(t.opts.jtd)return eb(t,[],!1,e);let r=(0,J2.getSchemaTypes)(t.schema),n=(0,J2.coerceAndCheckDataType)(t,r);eb(t,r,!n,e)}function v8(t){let{schema:e,errSchemaPath:r,opts:n,self:s}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Qn.schemaHasRulesButRef)(e,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function w8(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Qn.checkStrictMode)(t,"default is ignored in the schema root")}function x8(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,h8.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function S8(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function cb({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:s}){let o=r.$comment;if(s.$comment===!0)t.code((0,He._)`${Qe.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){let i=(0,He.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,He._)`${Qe.default.self}.opts.$comment(${o}, ${i}, ${a}.schema)`)}}function k8(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=t;r.$async?e.if((0,He._)`${Qe.default.errors} === 0`,()=>e.return(Qe.default.data),()=>e.throw((0,He._)`new ${s}(${Qe.default.vErrors})`)):(e.assign((0,He._)`${n}.errors`,Qe.default.vErrors),o.unevaluated&&$8(t),e.return((0,He._)`${Qe.default.errors} === 0`))}function $8({gen:t,evaluated:e,props:r,items:n}){r instanceof He.Name&&t.assign((0,He._)`${e}.props`,r),n instanceof He.Name&&t.assign((0,He._)`${e}.items`,n)}function eb(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,Qn.schemaHasRulesButRef)(o,l))){s.block(()=>ub(t,"$ref",l.all.$ref.definition));return}c.jtd||E8(t,e),s.block(()=>{for(let f of l.rules)u(f);u(l.post)});function u(f){(0,pp.shouldUseGroup)(o,f)&&(f.type?(s.if((0,vl.checkDataType)(f.type,i,c.strictNumbers)),tb(t,f),e.length===1&&e[0]===f.type&&r&&(s.else(),(0,vl.reportTypeError)(t)),s.endIf()):tb(t,f),a||s.if((0,He._)`${Qe.default.errors} === ${n||0}`))}}function tb(t,e){let{gen:r,schema:n,opts:{useDefaults:s}}=t;s&&(0,d8.assignDefaults)(t,e.type),r.block(()=>{for(let o of e.rules)(0,pp.shouldUseRule)(n,o)&&ub(t,o.keyword,o.definition,e.type)})}function E8(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(T8(t,e),t.opts.allowUnionTypes||R8(t,e),I8(t,t.dataTypes))}function T8(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{lb(t.dataTypes,r)||mp(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),M8(t,e)}}function R8(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&mp(t,"use allowUnionTypes to allow union type keyword")}function I8(t,e){let r=t.self.RULES.all;for(let n in r){let s=r[n];if(typeof s=="object"&&(0,pp.shouldUseRule)(t.schema,s)){let{type:o}=s.definition;o.length&&!o.some(i=>P8(e,i))&&mp(t,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function P8(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function lb(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function M8(t,e){let r=[];for(let n of t.dataTypes)lb(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function mp(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Qn.checkStrictMode)(t,e,t.opts.strictTypes)}var wl=class{constructor(e,r,n){if((0,Sa.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,Qn.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",db(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,Sa.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",Qe.default.errors))}result(e,r,n){this.failResult((0,He.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,He.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,He._)`${r} !== undefined && (${(0,He.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?xa.reportExtraError:xa.reportError)(this,this.def.error,r)}$dataError(){(0,xa.reportError)(this,this.def.$dataError||xa.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,xa.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=He.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=He.nil,r=He.nil){if(!this.$data)return;let{gen:n,schemaCode:s,schemaType:o,def:i}=this;n.if((0,He.or)((0,He._)`${s} === undefined`,r)),e!==He.nil&&n.assign(e,!0),(o.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==He.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,He.or)(i(),a());function i(){if(n.length){if(!(r instanceof He.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,He._)`${(0,vl.checkDataTypes)(c,r,o.opts.strictNumbers,vl.DataType.Wrong)}`}return He.nil}function a(){if(s.validateSchema){let c=e.scopeValue("validate$data",{ref:s.validateSchema});return(0,He._)`!${c}(${r})`}return He.nil}}subschema(e,r){let n=(0,fp.getSubschema)(this.it,e);(0,fp.extendSubschemaData)(n,this.it,e),(0,fp.extendSubschemaMode)(n,e);let s={...this.it,...n,items:void 0,props:void 0};return b8(s,r),s}mergeEvaluated(e,r){let{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Qn.mergeEvaluated.props(s,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Qn.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,He.Name)),!0}};ys.KeywordCxt=wl;function ub(t,e,r,n){let s=new wl(t,r,e);"code"in r?r.code(s,n):s.$data&&r.validate?(0,Sa.funcKeywordCode)(s,r):"macro"in r?(0,Sa.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,Sa.funcKeywordCode)(s,r)}var O8=/^\/(?:[^~]|~0|~1)*$/,A8=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function db(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let s,o;if(t==="")return Qe.default.rootData;if(t[0]==="/"){if(!O8.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);s=t,o=Qe.default.rootData}else{let d=A8.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,He._)`${o}${(0,He.getProperty)((0,Qn.unescapeJsonPointer)(d))}`,i=(0,He._)`${i} && ${o}`);return i;function c(d,l){return`Cannot access ${d} ${l} levels up, current level is ${e}`}}ys.getData=db});var xl=Pe(_p=>{"use strict";Object.defineProperty(_p,"__esModule",{value:!0});var gp=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};_p.default=gp});var $a=Pe(vp=>{"use strict";Object.defineProperty(vp,"__esModule",{value:!0});var bp=wa(),yp=class extends Error{constructor(e,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,bp.resolveUrl)(e,r,n),this.missingSchema=(0,bp.normalizeId)((0,bp.getFullPath)(e,this.missingRef))}};vp.default=yp});var kl=Pe(on=>{"use strict";Object.defineProperty(on,"__esModule",{value:!0});on.resolveSchema=on.getCompilingSchema=on.resolveRef=on.compileSchema=on.SchemaEnv=void 0;var xn=ct(),z8=xl(),ho=Jn(),Sn=wa(),hb=_t(),N8=ka(),ni=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,Sn.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};on.SchemaEnv=ni;function xp(t){let e=fb.call(this,t);if(e)return e;let r=(0,Sn.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,i=new xn.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o}),a;t.$async&&(a=i.scopeValue("Error",{ref:z8.default,code:(0,xn._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let d={gen:i,allErrors:this.opts.allErrors,data:ho.default.data,parentData:ho.default.parentData,parentDataProperty:ho.default.parentDataProperty,dataNames:[ho.default.data],dataPathArr:[xn.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,xn.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:xn.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,xn._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,N8.validateFunctionCode)(d),i.optimize(this.opts.code.optimize);let u=i.toString();l=`${i.scopeRefs(ho.default.scope)}return ${u}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let p=new Function(`${ho.default.self}`,`${ho.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:m,items:y}=d;p.evaluated={props:m instanceof xn.Name?void 0:m,items:y instanceof xn.Name?void 0:y,dynamicProps:m instanceof xn.Name,dynamicItems:y instanceof xn.Name},p.source&&(p.source.evaluated=(0,xn.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)}}on.compileSchema=xp;function C8(t,e,r){var n;r=(0,Sn.resolveUrl)(this.opts.uriResolver,e,r);let s=t.refs[r];if(s)return s;let o=L8.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 ni({schema:i,schemaId:a,root:t,baseId:e}))}if(o!==void 0)return t.refs[r]=j8.call(this,o)}on.resolveRef=C8;function j8(t){return(0,Sn.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:xp.call(this,t)}function fb(t){for(let e of this._compilations)if(D8(e,t))return e}on.getCompilingSchema=fb;function D8(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function L8(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||Sl.call(this,t,e)}function Sl(t,e){let r=this.opts.uriResolver.parse(e),n=(0,Sn._getFullPath)(this.opts.uriResolver,r),s=(0,Sn.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===s)return wp.call(this,r,t);let o=(0,Sn.normalizeId)(n),i=this.refs[o]||this.schemas[o];if(typeof i=="string"){let a=Sl.call(this,t,i);return typeof a?.schema!="object"?void 0:wp.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||xp.call(this,i),o===(0,Sn.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,d=a[c];return d&&(s=(0,Sn.resolveUrl)(this.opts.uriResolver,s,d)),new ni({schema:a,schemaId:c,root:t,baseId:s})}return wp.call(this,r,i)}}on.resolveSchema=Sl;var Z8=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function wp(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,hb.unescapeFragment)(a)];if(c===void 0)return;r=c;let d=typeof r=="object"&&r[this.opts.schemaId];!Z8.has(a)&&d&&(e=(0,Sn.resolveUrl)(this.opts.uriResolver,e,d))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,hb.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Sn.resolveUrl)(this.opts.uriResolver,e,r.$ref);o=Sl.call(this,n,a)}let{schemaId:i}=this.opts;if(o=o||new ni({schema:r,schemaId:i,root:n,baseId:e}),o.schema!==o.root.schema)return o}});var pb=Pe((OB,B8)=>{B8.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 $p=Pe((AB,vb)=>{"use strict";var V8=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),gb=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),Sp=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),_b=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),q8=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function kp(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 F8=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function mb(t){return t.length=0,!0}function H8(t,e,r){if(t.length){let n=kp(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function U8(t){let e=0,r={error:!1,address:"",zone:""},n=[],s=[],o=!1,i=!1,a=H8;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=mb}else{s.push(d);continue}}return s.length&&(a===mb?r.zone=s.join(""):i?n.push(s.join("")):n.push(kp(s))),r.address=n.join(""),r}function bb(t){if(G8(t,":")<2)return{host:t,isIPV6:!1};let e=U8(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 G8(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function W8(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 Y8={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},X8=/[@/?#:]/g,K8=/[@/?#]/g;function yb(t,e){let r=e?K8:X8;return r.lastIndex=0,t.replace(r,n=>Y8[n])}function J8(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(Sp(s)){let o=s.toUpperCase(),i=String.fromCharCode(parseInt(o,16));e&&_b(i)?r+=i:r+="%"+o,n+=2;continue}}r+=t[n]}return r}function Q8(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(Sp(n)){let s=n.toUpperCase(),o=String.fromCharCode(parseInt(s,16));o!=="."&&_b(o)?e+=o:e+="%"+s,r+=2;continue}}q8(t[r])?e+=t[r]:e+=escape(t[r])}return e}function eE(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(Sp(n)){e+="%"+n.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function tE(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!gb(r)){let n=bb(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=yb(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}vb.exports={nonSimpleDomain:F8,recomposeAuthority:tE,reescapeHostDelimiters:yb,normalizePercentEncoding:J8,normalizePathEncoding:Q8,escapePreservingEscapes:eE,removeDotSegments:W8,isIPv4:gb,isUUID:V8,normalizeIPv6:bb,stringArrayToHexStripped:kp}});var $b=Pe((zB,kb)=>{"use strict";var{isUUID:rE}=$p(),nE=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,sE=["http","https","ws","wss","urn","urn:uuid"];function oE(t){return sE.indexOf(t)!==-1}function Ep(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 wb(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function xb(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 iE(t){return t.secure=Ep(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function aE(t){if((t.port===(Ep(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 cE(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(nE);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=Tp(s);t.path=void 0,o&&(t=o.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function lE(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=Tp(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 uE(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!rE(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function dE(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var Sb={scheme:"http",domainHost:!0,parse:wb,serialize:xb},hE={scheme:"https",domainHost:Sb.domainHost,parse:wb,serialize:xb},$l={scheme:"ws",domainHost:!0,parse:iE,serialize:aE},fE={scheme:"wss",domainHost:$l.domainHost,parse:$l.parse,serialize:$l.serialize},pE={scheme:"urn",parse:cE,serialize:lE,skipNormalize:!0},mE={scheme:"urn:uuid",parse:uE,serialize:dE,skipNormalize:!0},El={http:Sb,https:hE,ws:$l,wss:fE,urn:pE,"urn:uuid":mE};Object.setPrototypeOf(El,null);function Tp(t){return t&&(El[t]||El[t.toLowerCase()])||void 0}kb.exports={wsIsSecure:Ep,SCHEMES:El,isValidSchemeName:oE,getSchemeHandler:Tp}});var Mb=Pe((NB,Tl)=>{"use strict";var{normalizeIPv6:gE,removeDotSegments:Ea,recomposeAuthority:_E,normalizePercentEncoding:bE,normalizePathEncoding:yE,escapePreservingEscapes:vE,reescapeHostDelimiters:wE,isIPv4:xE,nonSimpleDomain:SE}=$p(),{SCHEMES:kE,getSchemeHandler:Tb}=$b();function $E(t,e){return typeof t=="string"?t=PE(t,e):typeof t=="object"&&(t=si(fo(t,e),e)),t}function EE(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},s=Rb(si(t,n),si(e,n),n,!0);return n.skipEscape=!0,fo(s,n)}function Rb(t,e,r,n){let s={};return n||(t=si(fo(t,r),r),e=si(fo(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=Ea(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=Ea(e.path||""),s.query=e.query):(e.path?(e.path[0]==="/"?s.path=Ea(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=Ea(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 TE(t,e,r){let n=Eb(t,r),s=Eb(e,r);return n!==void 0&&s!==void 0&&n.toLowerCase()===s.toLowerCase()}function fo(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=Tb(n.scheme||r.scheme);o&&o.serialize&&o.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=bE(r.path):(r.path=vE(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&s.push(r.scheme,":");let i=_E(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=Ea(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 RE=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function IE(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 Ib(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(RE);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=IE(n,i);if(a!==void 0&&(n.error=n.error||a,s=!0),n.host)if(xE(n.host)===!1){let l=gE(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=Tb(r.scheme||n.scheme);if(!r.unicodeSupport&&(!c||!c.unicodeSupport)&&n.host&&(r.domainHost||c&&c.domainHost)&&o===!1&&SE(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=wE(unescape(n.host),o))),n.path&&(n.path=yE(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 si(t,e){return Ib(t,e).parsed}function PE(t,e){return Pb(t,e).normalized}function Pb(t,e){let{parsed:r,malformedAuthorityOrPort:n}=Ib(t,e);return{normalized:n?t:fo(r,e),malformedAuthorityOrPort:n}}function Eb(t,e){if(typeof t=="string"){let{normalized:r,malformedAuthorityOrPort:n}=Pb(t,e);return n?void 0:r}if(typeof t=="object")return fo(t,e)}var Rp={SCHEMES:kE,normalize:$E,resolve:EE,resolveComponent:Rb,equal:TE,serialize:fo,parse:si};Tl.exports=Rp;Tl.exports.default=Rp;Tl.exports.fastUri=Rp});var Ab=Pe(Ip=>{"use strict";Object.defineProperty(Ip,"__esModule",{value:!0});var Ob=Mb();Ob.code='require("ajv/dist/runtime/uri").default';Ip.default=Ob});var Bb=Pe(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});ur.CodeGen=ur.Name=ur.nil=ur.stringify=ur.str=ur._=ur.KeywordCxt=void 0;var ME=ka();Object.defineProperty(ur,"KeywordCxt",{enumerable:!0,get:function(){return ME.KeywordCxt}});var oi=ct();Object.defineProperty(ur,"_",{enumerable:!0,get:function(){return oi._}});Object.defineProperty(ur,"str",{enumerable:!0,get:function(){return oi.str}});Object.defineProperty(ur,"stringify",{enumerable:!0,get:function(){return oi.stringify}});Object.defineProperty(ur,"nil",{enumerable:!0,get:function(){return oi.nil}});Object.defineProperty(ur,"Name",{enumerable:!0,get:function(){return oi.Name}});Object.defineProperty(ur,"CodeGen",{enumerable:!0,get:function(){return oi.CodeGen}});var OE=xl(),Db=$a(),AE=np(),Ta=kl(),zE=ct(),Ra=wa(),Rl=va(),Mp=_t(),zb=pb(),NE=Ab(),Lb=(t,e)=>new RegExp(t,e);Lb.code="new RegExp";var CE=["removeAdditional","useDefaults","coerceTypes"],jE=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),DE={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."},LE={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Nb=200;function ZE(t){var e,r,n,s,o,i,a,c,d,l,u,f,p,m,y,k,x,_,g,E,h,$,O,L,q;let C=t.strict,Z=(e=t.code)===null||e===void 0?void 0:e.optimize,he=Z===!0||Z===void 0?1:Z||0,z=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:Lb,b=(s=t.uriResolver)!==null&&s!==void 0?s:NE.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:(f=(u=t.strictTuples)!==null&&u!==void 0?u:C)!==null&&f!==void 0?f:"log",strictRequired:(m=(p=t.strictRequired)!==null&&p!==void 0?p:C)!==null&&m!==void 0?m:!1,code:t.code?{...t.code,optimize:he,regExp:z}:{optimize:he,regExp:z},loopRequired:(y=t.loopRequired)!==null&&y!==void 0?y:Nb,loopEnum:(k=t.loopEnum)!==null&&k!==void 0?k:Nb,meta:(x=t.meta)!==null&&x!==void 0?x:!0,messages:(_=t.messages)!==null&&_!==void 0?_:!0,inlineRefs:(g=t.inlineRefs)!==null&&g!==void 0?g:!0,schemaId:(E=t.schemaId)!==null&&E!==void 0?E:"$id",addUsedSchema:(h=t.addUsedSchema)!==null&&h!==void 0?h:!0,validateSchema:($=t.validateSchema)!==null&&$!==void 0?$:!0,validateFormats:(O=t.validateFormats)!==null&&O!==void 0?O:!0,unicodeRegExp:(L=t.unicodeRegExp)!==null&&L!==void 0?L:!0,int32range:(q=t.int32range)!==null&&q!==void 0?q:!0,uriResolver:b}}var Ia=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,...ZE(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new zE.ValueScope({scope:{},prefixes:jE,es5:r,lines:n}),this.logger=UE(e.logger);let s=e.validateFormats;e.validateFormats=!1,this.RULES=(0,AE.getRules)(),Cb.call(this,DE,e,"NOT SUPPORTED"),Cb.call(this,LE,e,"DEPRECATED","warn"),this._metaOpts=FE.call(this),e.formats&&VE.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&qE.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),BE.call(this),e.validateFormats=s}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,s=zb;n==="id"&&(s={...zb},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 f=this._addSchema(l,u);return f.validate||i.call(this,f)}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 Db.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,Ra.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=jb.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,s=new Ta.SchemaEnv({schema:{},schemaId:n});if(r=Ta.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=jb.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,Ra.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(WE.call(this,n,r),!r)return(0,Mp.eachItem)(n,o=>Pp.call(this,o)),this;XE.call(this,r);let s={...r,type:(0,Rl.getJSONTypes)(r.type),schemaType:(0,Rl.getJSONTypes)(r.schemaType)};return(0,Mp.eachItem)(n,s.type.length===0?o=>Pp.call(this,o,s):o=>s.type.forEach(i=>Pp.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]=Zb(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,Ra.normalizeId)(i||n);let d=Ra.getSchemaRefs.call(this,e,n);return c=new Ta.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):Ta.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{Ta.compileSchema.call(this,e)}finally{this.opts=r}}};Ia.ValidationError=OE.default;Ia.MissingRefError=Db.default;ur.default=Ia;function Cb(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 jb(t){return t=(0,Ra.normalizeId)(t),this.schemas[t]||this.refs[t]}function BE(){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 VE(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function qE(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 FE(){let t={...this.opts};for(let e of CE)delete t[e];return t}var HE={log(){},warn(){},error(){}};function UE(t){if(t===!1)return HE;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 GE=/^[a-z_$][a-z0-9_$:-]*$/i;function WE(t,e){let{RULES:r}=this;if((0,Mp.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!GE.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 Pp(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,Rl.getJSONTypes)(e.type),schemaType:(0,Rl.getJSONTypes)(e.schemaType)}};e.before?YE.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 YE(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 XE(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=Zb(e)),t.validateSchema=this.compile(e,!0))}var KE={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Zb(t){return{anyOf:[t,KE]}}});var Vb=Pe(Op=>{"use strict";Object.defineProperty(Op,"__esModule",{value:!0});var JE={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Op.default=JE});var Ub=Pe(po=>{"use strict";Object.defineProperty(po,"__esModule",{value:!0});po.callRef=po.getValidate=void 0;var QE=$a(),qb=sn(),Nr=ct(),ii=Jn(),Fb=kl(),Il=_t(),eT={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=Fb.resolveRef.call(c,d,s,r);if(l===void 0)throw new QE.default(n.opts.uriResolver,s,r);if(l instanceof Fb.SchemaEnv)return f(l);return p(l);function u(){if(o===d)return Pl(t,i,o,o.$async);let m=e.scopeValue("root",{ref:d});return Pl(t,(0,Nr._)`${m}.validate`,d,d.$async)}function f(m){let y=Hb(t,m);Pl(t,y,m,m.$async)}function p(m){let y=e.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Nr.stringify)(m)}:{ref:m}),k=e.name("valid"),x=t.subschema({schema:m,dataTypes:[],schemaPath:Nr.nil,topSchemaRef:y,errSchemaPath:r},k);t.mergeEvaluated(x),t.ok(k)}}};function Hb(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Nr._)`${r.scopeValue("wrapper",{ref:e})}.validate`}po.getValidate=Hb;function Pl(t,e,r,n){let{gen:s,it:o}=t,{allErrors:i,schemaEnv:a,opts:c}=o,d=c.passContext?ii.default.this:Nr.nil;n?l():u();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let m=s.let("valid");s.try(()=>{s.code((0,Nr._)`await ${(0,qb.callValidateCode)(t,e,d)}`),p(e),i||s.assign(m,!0)},y=>{s.if((0,Nr._)`!(${y} instanceof ${o.ValidationError})`,()=>s.throw(y)),f(y),i||s.assign(m,!1)}),t.ok(m)}function u(){t.result((0,qb.callValidateCode)(t,e,d),()=>p(e),()=>f(e))}function f(m){let y=(0,Nr._)`${m}.errors`;s.assign(ii.default.vErrors,(0,Nr._)`${ii.default.vErrors} === null ? ${y} : ${ii.default.vErrors}.concat(${y})`),s.assign(ii.default.errors,(0,Nr._)`${ii.default.vErrors}.length`)}function p(m){var y;if(!o.opts.unevaluated)return;let k=(y=r?.validate)===null||y===void 0?void 0:y.evaluated;if(o.props!==!0)if(k&&!k.dynamicProps)k.props!==void 0&&(o.props=Il.mergeEvaluated.props(s,k.props,o.props));else{let x=s.var("props",(0,Nr._)`${m}.evaluated.props`);o.props=Il.mergeEvaluated.props(s,x,o.props,Nr.Name)}if(o.items!==!0)if(k&&!k.dynamicItems)k.items!==void 0&&(o.items=Il.mergeEvaluated.items(s,k.items,o.items));else{let x=s.var("items",(0,Nr._)`${m}.evaluated.items`);o.items=Il.mergeEvaluated.items(s,x,o.items,Nr.Name)}}}po.callRef=Pl;po.default=eT});var Gb=Pe(Ap=>{"use strict";Object.defineProperty(Ap,"__esModule",{value:!0});var tT=Vb(),rT=Ub(),nT=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",tT.default,rT.default];Ap.default=nT});var Wb=Pe(zp=>{"use strict";Object.defineProperty(zp,"__esModule",{value:!0});var Ml=ct(),vs=Ml.operators,Ol={maximum:{okStr:"<=",ok:vs.LTE,fail:vs.GT},minimum:{okStr:">=",ok:vs.GTE,fail:vs.LT},exclusiveMaximum:{okStr:"<",ok:vs.LT,fail:vs.GTE},exclusiveMinimum:{okStr:">",ok:vs.GT,fail:vs.LTE}},sT={message:({keyword:t,schemaCode:e})=>(0,Ml.str)`must be ${Ol[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Ml._)`{comparison: ${Ol[t].okStr}, limit: ${e}}`},oT={keyword:Object.keys(Ol),type:"number",schemaType:"number",$data:!0,error:sT,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,Ml._)`${r} ${Ol[e].fail} ${n} || isNaN(${r})`)}};zp.default=oT});var Yb=Pe(Np=>{"use strict";Object.defineProperty(Np,"__esModule",{value:!0});var Pa=ct(),iT={message:({schemaCode:t})=>(0,Pa.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Pa._)`{multipleOf: ${t}}`},aT={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:iT,code(t){let{gen:e,data:r,schemaCode:n,it:s}=t,o=s.opts.multipleOfPrecision,i=e.let("res"),a=o?(0,Pa._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${o}`:(0,Pa._)`${i} !== parseInt(${i})`;t.fail$data((0,Pa._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};Np.default=aT});var Kb=Pe(Cp=>{"use strict";Object.defineProperty(Cp,"__esModule",{value:!0});function Xb(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}Cp.default=Xb;Xb.code='require("ajv/dist/runtime/ucs2length").default'});var Jb=Pe(jp=>{"use strict";Object.defineProperty(jp,"__esModule",{value:!0});var mo=ct(),cT=_t(),lT=Kb(),uT={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,mo.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,mo._)`{limit: ${t}}`},dT={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:uT,code(t){let{keyword:e,data:r,schemaCode:n,it:s}=t,o=e==="maxLength"?mo.operators.GT:mo.operators.LT,i=s.opts.unicode===!1?(0,mo._)`${r}.length`:(0,mo._)`${(0,cT.useFunc)(t.gen,lT.default)}(${r})`;t.fail$data((0,mo._)`${i} ${o} ${n}`)}};jp.default=dT});var Qb=Pe(Dp=>{"use strict";Object.defineProperty(Dp,"__esModule",{value:!0});var hT=sn(),fT=_t(),ai=ct(),pT={message:({schemaCode:t})=>(0,ai.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,ai._)`{pattern: ${t}}`},mT={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:pT,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,ai._)`new RegExp`:(0,fT.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,ai._)`${d}(${o}, ${a}).test(${r})`),()=>e.assign(l,!1)),t.fail$data((0,ai._)`!${l}`)}else{let c=(0,hT.usePattern)(t,s);t.fail$data((0,ai._)`!${c}.test(${r})`)}}};Dp.default=mT});var ey=Pe(Lp=>{"use strict";Object.defineProperty(Lp,"__esModule",{value:!0});var Ma=ct(),gT={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,Ma.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,Ma._)`{limit: ${t}}`},_T={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:gT,code(t){let{keyword:e,data:r,schemaCode:n}=t,s=e==="maxProperties"?Ma.operators.GT:Ma.operators.LT;t.fail$data((0,Ma._)`Object.keys(${r}).length ${s} ${n}`)}};Lp.default=_T});var ty=Pe(Zp=>{"use strict";Object.defineProperty(Zp,"__esModule",{value:!0});var Oa=sn(),Aa=ct(),bT=_t(),yT={message:({params:{missingProperty:t}})=>(0,Aa.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Aa._)`{missingProperty: ${t}}`},vT={keyword:"required",type:"object",schemaType:"array",$data:!0,error:yT,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:m}=t.it;for(let y of r)if(p?.[y]===void 0&&!m.has(y)){let k=i.schemaEnv.baseId+i.errSchemaPath,x=`required property "${y}" is not defined at "${k}" (strictRequired)`;(0,bT.checkStrictMode)(i,x,i.opts.strictRequired)}}function d(){if(c||o)t.block$data(Aa.nil,u);else for(let p of r)(0,Oa.checkReportMissingProp)(t,p)}function l(){let p=e.let("missing");if(c||o){let m=e.let("valid",!0);t.block$data(m,()=>f(p,m)),t.ok(m)}else e.if((0,Oa.checkMissingProp)(t,r,p)),(0,Oa.reportMissingProp)(t,p),e.else()}function u(){e.forOf("prop",n,p=>{t.setParams({missingProperty:p}),e.if((0,Oa.noPropertyInData)(e,s,p,a.ownProperties),()=>t.error())})}function f(p,m){t.setParams({missingProperty:p}),e.forOf(p,n,()=>{e.assign(m,(0,Oa.propertyInData)(e,s,p,a.ownProperties)),e.if((0,Aa.not)(m),()=>{t.error(),e.break()})},Aa.nil)}}};Zp.default=vT});var ry=Pe(Bp=>{"use strict";Object.defineProperty(Bp,"__esModule",{value:!0});var za=ct(),wT={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,za.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,za._)`{limit: ${t}}`},xT={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:wT,code(t){let{keyword:e,data:r,schemaCode:n}=t,s=e==="maxItems"?za.operators.GT:za.operators.LT;t.fail$data((0,za._)`${r}.length ${s} ${n}`)}};Bp.default=xT});var Al=Pe(Vp=>{"use strict";Object.defineProperty(Vp,"__esModule",{value:!0});var ny=dp();ny.code='require("ajv/dist/runtime/equal").default';Vp.default=ny});var sy=Pe(Fp=>{"use strict";Object.defineProperty(Fp,"__esModule",{value:!0});var qp=va(),dr=ct(),ST=_t(),kT=Al(),$T={message:({params:{i:t,j:e}})=>(0,dr.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,dr._)`{i: ${t}, j: ${e}}`},ET={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:$T,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,qp.getSchemaTypes)(o.items):[];t.block$data(c,l,(0,dr._)`${i} === false`),t.ok(c);function l(){let m=e.let("i",(0,dr._)`${r}.length`),y=e.let("j");t.setParams({i:m,j:y}),e.assign(c,!0),e.if((0,dr._)`${m} > 1`,()=>(u()?f:p)(m,y))}function u(){return d.length>0&&!d.some(m=>m==="object"||m==="array")}function f(m,y){let k=e.name("item"),x=(0,qp.checkDataTypes)(d,k,a.opts.strictNumbers,qp.DataType.Wrong),_=e.const("indices",(0,dr._)`{}`);e.for((0,dr._)`;${m}--;`,()=>{e.let(k,(0,dr._)`${r}[${m}]`),e.if(x,(0,dr._)`continue`),d.length>1&&e.if((0,dr._)`typeof ${k} == "string"`,(0,dr._)`${k} += "_"`),e.if((0,dr._)`typeof ${_}[${k}] == "number"`,()=>{e.assign(y,(0,dr._)`${_}[${k}]`),t.error(),e.assign(c,!1).break()}).code((0,dr._)`${_}[${k}] = ${m}`)})}function p(m,y){let k=(0,ST.useFunc)(e,kT.default),x=e.name("outer");e.label(x).for((0,dr._)`;${m}--;`,()=>e.for((0,dr._)`${y} = ${m}; ${y}--;`,()=>e.if((0,dr._)`${k}(${r}[${m}], ${r}[${y}])`,()=>{t.error(),e.assign(c,!1).break(x)})))}}};Fp.default=ET});var oy=Pe(Up=>{"use strict";Object.defineProperty(Up,"__esModule",{value:!0});var Hp=ct(),TT=_t(),RT=Al(),IT={message:"must be equal to constant",params:({schemaCode:t})=>(0,Hp._)`{allowedValue: ${t}}`},PT={keyword:"const",$data:!0,error:IT,code(t){let{gen:e,data:r,$data:n,schemaCode:s,schema:o}=t;n||o&&typeof o=="object"?t.fail$data((0,Hp._)`!${(0,TT.useFunc)(e,RT.default)}(${r}, ${s})`):t.fail((0,Hp._)`${o} !== ${r}`)}};Up.default=PT});var iy=Pe(Gp=>{"use strict";Object.defineProperty(Gp,"__esModule",{value:!0});var Na=ct(),MT=_t(),OT=Al(),AT={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Na._)`{allowedValues: ${t}}`},zT={keyword:"enum",schemaType:"array",$data:!0,error:AT,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,MT.useFunc)(e,OT.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,Na.or)(...s.map((m,y)=>f(p,y)))}t.pass(l);function u(){e.assign(l,!1),e.forOf("v",o,p=>e.if((0,Na._)`${d()}(${r}, ${p})`,()=>e.assign(l,!0).break()))}function f(p,m){let y=s[m];return typeof y=="object"&&y!==null?(0,Na._)`${d()}(${r}, ${p}[${m}])`:(0,Na._)`${r} === ${y}`}}};Gp.default=zT});var ay=Pe(Wp=>{"use strict";Object.defineProperty(Wp,"__esModule",{value:!0});var NT=Wb(),CT=Yb(),jT=Jb(),DT=Qb(),LT=ey(),ZT=ty(),BT=ry(),VT=sy(),qT=oy(),FT=iy(),HT=[NT.default,CT.default,jT.default,DT.default,LT.default,ZT.default,BT.default,VT.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},qT.default,FT.default];Wp.default=HT});var Xp=Pe(Ca=>{"use strict";Object.defineProperty(Ca,"__esModule",{value:!0});Ca.validateAdditionalItems=void 0;var go=ct(),Yp=_t(),UT={message:({params:{len:t}})=>(0,go.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,go._)`{limit: ${t}}`},GT={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:UT,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,Yp.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}cy(t,n)}};function cy(t,e){let{gen:r,schema:n,data:s,keyword:o,it:i}=t;i.items=!0;let a=r.const("len",(0,go._)`${s}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,go._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,Yp.alwaysValidSchema)(i,n)){let d=r.var("valid",(0,go._)`${a} <= ${e.length}`);r.if((0,go.not)(d),()=>c(d)),t.ok(d)}function c(d){r.forRange("i",e.length,a,l=>{t.subschema({keyword:o,dataProp:l,dataPropType:Yp.Type.Num},d),i.allErrors||r.if((0,go.not)(d),()=>r.break())})}}Ca.validateAdditionalItems=cy;Ca.default=GT});var Kp=Pe(ja=>{"use strict";Object.defineProperty(ja,"__esModule",{value:!0});ja.validateTuple=void 0;var ly=ct(),zl=_t(),WT=sn(),YT={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return uy(t,"additionalItems",e);r.items=!0,!(0,zl.alwaysValidSchema)(r,e)&&t.ok((0,WT.validateArray)(t))}};function uy(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=zl.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),d=n.const("len",(0,ly._)`${o}.length`);r.forEach((u,f)=>{(0,zl.alwaysValidSchema)(a,u)||(n.if((0,ly._)`${d} > ${f}`,()=>t.subschema({keyword:i,schemaProp:f,dataProp:f},c)),t.ok(c))});function l(u){let{opts:f,errSchemaPath:p}=a,m=r.length,y=m===u.minItems&&(m===u.maxItems||u[e]===!1);if(f.strictTuples&&!y){let k=`"${i}" is ${m}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0,zl.checkStrictMode)(a,k,f.strictTuples)}}}ja.validateTuple=uy;ja.default=YT});var dy=Pe(Jp=>{"use strict";Object.defineProperty(Jp,"__esModule",{value:!0});var XT=Kp(),KT={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,XT.validateTuple)(t,"items")};Jp.default=KT});var fy=Pe(Qp=>{"use strict";Object.defineProperty(Qp,"__esModule",{value:!0});var hy=ct(),JT=_t(),QT=sn(),e7=Xp(),t7={message:({params:{len:t}})=>(0,hy.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,hy._)`{limit: ${t}}`},r7={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:t7,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:s}=r;n.items=!0,!(0,JT.alwaysValidSchema)(n,e)&&(s?(0,e7.validateAdditionalItems)(t,s):t.ok((0,QT.validateArray)(t)))}};Qp.default=r7});var py=Pe(em=>{"use strict";Object.defineProperty(em,"__esModule",{value:!0});var an=ct(),Nl=_t(),n7={message:({params:{min:t,max:e}})=>e===void 0?(0,an.str)`must contain at least ${t} valid item(s)`:(0,an.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,an._)`{minContains: ${t}}`:(0,an._)`{minContains: ${t}, maxContains: ${e}}`},s7={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:n7,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,an._)`${s}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,Nl.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,Nl.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,Nl.alwaysValidSchema)(o,r)){let y=(0,an._)`${l} >= ${i}`;a!==void 0&&(y=(0,an._)`${y} && ${l} <= ${a}`),t.pass(y);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,an._)`${s}.length > 0`,f)):(e.let(u,!1),f()),t.result(u,()=>t.reset());function f(){let y=e.name("_valid"),k=e.let("count",0);p(y,()=>e.if(y,()=>m(k)))}function p(y,k){e.forRange("i",0,l,x=>{t.subschema({keyword:"contains",dataProp:x,dataPropType:Nl.Type.Num,compositeRule:!0},y),k()})}function m(y){e.code((0,an._)`${y}++`),a===void 0?e.if((0,an._)`${y} >= ${i}`,()=>e.assign(u,!0).break()):(e.if((0,an._)`${y} > ${a}`,()=>e.assign(u,!1).break()),i===1?e.assign(u,!0):e.if((0,an._)`${y} >= ${i}`,()=>e.assign(u,!0)))}}};em.default=s7});var _y=Pe(Dn=>{"use strict";Object.defineProperty(Dn,"__esModule",{value:!0});Dn.validateSchemaDeps=Dn.validatePropertyDeps=Dn.error=void 0;var tm=ct(),o7=_t(),Da=sn();Dn.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,tm.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,tm._)`{property: ${t},
|
|
6
|
+
|| ${i} === "boolean" || ${s} === null`).assign(a,(0,it._)`[${s}]`)}}}function E$({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,it._)`${e} !== undefined`,()=>t.assign((0,it._)`${e}[${r}]`,n))}function op(t,e,r,n=Qo.Correct){let s=n===Qo.Correct?it.operators.EQ:it.operators.NEQ,o;switch(t){case"null":return(0,it._)`${e} ${s} null`;case"array":o=(0,it._)`Array.isArray(${e})`;break;case"object":o=(0,it._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":o=i((0,it._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":o=i();break;default:return(0,it._)`typeof ${e} ${s} ${t}`}return n===Qo.Correct?o:(0,it.not)(o);function i(a=it.nil){return(0,it.and)((0,it._)`typeof ${e} == "number"`,a,r?(0,it._)`isFinite(${e})`:it.nil)}}gr.checkDataType=op;function ip(t,e,r,n){if(t.length===1)return op(t[0],e,r,n);let s,o=(0,O2.toHash)(t);if(o.array&&o.object){let i=(0,it._)`typeof ${e} != "object"`;s=o.null?i:(0,it._)`!${e} || ${i}`,delete o.null,delete o.array,delete o.object}else s=it.nil;o.number&&delete o.integer;for(let i in o)s=(0,it.and)(s,op(i,e,r,n));return s}gr.checkDataTypes=ip;var T$={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,it._)`{type: ${t}}`:(0,it._)`{type: ${e}}`};function ap(t){let e=R$(t);(0,w$.reportError)(e,T$)}gr.reportTypeError=ap;function R$(t){let{gen:e,data:r,schema:n}=t,s=(0,O2.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:t}}});var D2=Me(_l=>{"use strict";Object.defineProperty(_l,"__esModule",{value:!0});_l.assignDefaults=void 0;var ei=ct(),P$=_t();function M$(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let s in r)j2(t,s,r[s].default);else e==="array"&&Array.isArray(n)&&n.forEach((s,o)=>j2(t,o,s.default))}_l.assignDefaults=M$;function j2(t,e,r){let{gen:n,compositeRule:s,data:o,opts:i}=t;if(r===void 0)return;let a=(0,ei._)`${o}${(0,ei.getProperty)(e)}`;if(s){(0,P$.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,ei._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,ei._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,ei._)`${a} = ${(0,ei.stringify)(r)}`)}});var sn=Me($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.validateUnion=$t.validateArray=$t.usePattern=$t.callValidateCode=$t.schemaProperties=$t.allSchemaProperties=$t.noPropertyInData=$t.propertyInData=$t.isOwnProperty=$t.hasPropFunc=$t.reportMissingProp=$t.checkMissingProp=$t.checkReportMissingProp=void 0;var Ot=ct(),cp=_t(),gs=Jn(),I$=_t();function z$(t,e){let{gen:r,data:n,it:s}=t;r.if(up(r,n,e,s.opts.ownProperties),()=>{t.setParams({missingProperty:(0,Ot._)`${e}`},!0),t.error()})}$t.checkReportMissingProp=z$;function A$({gen:t,data:e,it:{opts:r}},n,s){return(0,Ot.or)(...n.map(o=>(0,Ot.and)(up(t,e,o,r.ownProperties),(0,Ot._)`${s} = ${o}`)))}$t.checkMissingProp=A$;function O$(t,e){t.setParams({missingProperty:e},!0),t.error()}$t.reportMissingProp=O$;function L2(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Ot._)`Object.prototype.hasOwnProperty`})}$t.hasPropFunc=L2;function lp(t,e,r){return(0,Ot._)`${L2(t)}.call(${e}, ${r})`}$t.isOwnProperty=lp;function N$(t,e,r,n){let s=(0,Ot._)`${e}${(0,Ot.getProperty)(r)} !== undefined`;return n?(0,Ot._)`${s} && ${lp(t,e,r)}`:s}$t.propertyInData=N$;function up(t,e,r,n){let s=(0,Ot._)`${e}${(0,Ot.getProperty)(r)} === undefined`;return n?(0,Ot.or)(s,(0,Ot.not)(lp(t,e,r))):s}$t.noPropertyInData=up;function Z2(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}$t.allSchemaProperties=Z2;function C$(t,e){return Z2(e).filter(r=>!(0,cp.alwaysValidSchema)(t,e[r]))}$t.schemaProperties=C$;function j$({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:i},a,c,d){let l=d?(0,Ot._)`${t}, ${e}, ${n}${s}`:e,u=[[gs.default.instancePath,(0,Ot.strConcat)(gs.default.instancePath,o)],[gs.default.parentData,i.parentData],[gs.default.parentDataProperty,i.parentDataProperty],[gs.default.rootData,gs.default.rootData]];i.opts.dynamicRef&&u.push([gs.default.dynamicAnchors,gs.default.dynamicAnchors]);let f=(0,Ot._)`${l}, ${r.object(...u)}`;return c!==Ot.nil?(0,Ot._)`${a}.call(${c}, ${f})`:(0,Ot._)`${a}(${f})`}$t.callValidateCode=j$;var D$=(0,Ot._)`new RegExp`;function L$({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,Ot._)`${s.code==="new RegExp"?D$:(0,I$.useFunc)(t,s)}(${r}, ${n})`})}$t.usePattern=L$;function Z$(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,Ot._)`${r}.length`);e.forRange("i",0,c,d=>{t.subschema({keyword:n,dataProp:d,dataPropType:cp.Type.Num},o),e.if((0,Ot.not)(o),a)})}}$t.validateArray=Z$;function B$(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,cp.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,Ot._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,Ot.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}$t.validateUnion=B$});var q2=Me(Cn=>{"use strict";Object.defineProperty(Cn,"__esModule",{value:!0});Cn.validateKeywordUsage=Cn.validSchemaType=Cn.funcKeywordCode=Cn.macroKeywordCode=void 0;var Sr=ct(),lo=Jn(),V$=sn(),q$=ba();function F$(t,e){let{gen:r,keyword:n,schema:s,parentSchema:o,it:i}=t,a=e.macro.call(i.self,s,o,i),c=V2(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let d=r.name("valid");t.subschema({schema:a,schemaPath:Sr.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},d),t.pass(d,()=>t.error(!0))}Cn.macroKeywordCode=F$;function U$(t,e){var r;let{gen:n,keyword:s,schema:o,parentSchema:i,$data:a,it:c}=t;G$(c,e);let d=!a&&e.compile?e.compile.call(c.self,o,i,c):e.validate,l=V2(n,s,d),u=n.let("valid");t.block$data(u,f),t.ok((r=e.valid)!==null&&r!==void 0?r:u);function f(){if(e.errors===!1)y(),e.modifying&&B2(t),k(()=>t.error());else{let x=e.async?p():m();e.modifying&&B2(t),k(()=>H$(t,x))}}function p(){let x=n.let("ruleErrs",null);return n.try(()=>y((0,Sr._)`await `),_=>n.assign(u,!1).if((0,Sr._)`${_} instanceof ${c.ValidationError}`,()=>n.assign(x,(0,Sr._)`${_}.errors`),()=>n.throw(_))),x}function m(){let x=(0,Sr._)`${l}.errors`;return n.assign(x,null),y(Sr.nil),x}function y(x=e.async?(0,Sr._)`await `:Sr.nil){let _=c.opts.passContext?lo.default.this:lo.default.self,g=!("compile"in e&&!a||e.schema===!1);n.assign(u,(0,Sr._)`${x}${(0,V$.callValidateCode)(t,l,_,g)}`,e.modifying)}function k(x){var _;n.if((0,Sr.not)((_=e.valid)!==null&&_!==void 0?_:u),x)}}Cn.funcKeywordCode=U$;function B2(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,Sr._)`${n.parentData}[${n.parentDataProperty}]`))}function H$(t,e){let{gen:r}=t;r.if((0,Sr._)`Array.isArray(${e})`,()=>{r.assign(lo.default.vErrors,(0,Sr._)`${lo.default.vErrors} === null ? ${e} : ${lo.default.vErrors}.concat(${e})`).assign(lo.default.errors,(0,Sr._)`${lo.default.vErrors}.length`),(0,q$.extendErrors)(t)},()=>t.error())}function G$({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function V2(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,Sr.stringify)(r)})}function W$(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")}Cn.validSchemaType=W$;function Y$({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)}}Cn.validateKeywordUsage=Y$});var U2=Me(_s=>{"use strict";Object.defineProperty(_s,"__esModule",{value:!0});_s.extendSubschemaMode=_s.extendSubschemaData=_s.getSubschema=void 0;var jn=ct(),F2=_t();function X$(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,jn._)`${t.schemaPath}${(0,jn.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,jn._)`${t.schemaPath}${(0,jn.getProperty)(e)}${(0,jn.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,F2.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')}_s.getSubschema=X$;function K$(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,f=a.let("data",(0,jn._)`${e.data}${(0,jn.getProperty)(r)}`,!0);c(f),t.errorPath=(0,jn.str)`${d}${(0,F2.getErrorPath)(r,n,u.jsPropertySyntax)}`,t.parentDataProperty=(0,jn._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(s!==void 0){let d=s instanceof jn.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]}}_s.extendSubschemaData=K$;function J$(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}_s.extendSubschemaMode=J$});var dp=Me(($B,H2)=>{"use strict";H2.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 W2=Me((EB,G2)=>{"use strict";var bs=G2.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(){};bl(e,n,s,t,"",t)};bs.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};bs.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};bs.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};bs.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 bl(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 bs.arrayKeywords)for(var f=0;f<u.length;f++)bl(t,e,r,u[f],s+"/"+l+"/"+f,o,s,l,n,f)}else if(l in bs.propsKeywords){if(u&&typeof u=="object")for(var p in u)bl(t,e,r,u[p],s+"/"+l+"/"+Q$(p),o,s,l,n,p)}else(l in bs.keywords||t.allKeys&&!(l in bs.skipKeywords))&&bl(t,e,r,u,s+"/"+l,o,s,l,n)}r(n,s,o,i,a,c,d)}}function Q$(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var va=Me(Or=>{"use strict";Object.defineProperty(Or,"__esModule",{value:!0});Or.getSchemaRefs=Or.resolveUrl=Or.normalizeId=Or._getFullPath=Or.getFullPath=Or.inlineRef=void 0;var e8=_t(),t8=dp(),r8=W2(),n8=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function s8(t,e=!0){return typeof t=="boolean"?!0:e===!0?!hp(t):e?Y2(t)<=e:!1}Or.inlineRef=s8;var o8=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function hp(t){for(let e in t){if(o8.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(hp)||typeof r=="object"&&hp(r))return!0}return!1}function Y2(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!n8.has(r)&&(typeof t[r]=="object"&&(0,e8.eachItem)(t[r],n=>e+=Y2(n)),e===1/0))return 1/0}return e}function X2(t,e="",r){r!==!1&&(e=ti(e));let n=t.parse(e);return K2(t,n)}Or.getFullPath=X2;function K2(t,e){return t.serialize(e).split("#")[0]+"#"}Or._getFullPath=K2;var i8=/#\/?$/;function ti(t){return t?t.replace(i8,""):""}Or.normalizeId=ti;function a8(t,e,r){return r=ti(r),t.resolve(e,r)}Or.resolveUrl=a8;var c8=/^[a-z_][-a-z0-9._]*$/i;function l8(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,s=ti(t[r]||e),o={"":s},i=X2(n,s,!1),a={},c=new Set;return r8(t,{allKeys:!0},(u,f,p,m)=>{if(m===void 0)return;let y=i+f,k=o[m];typeof u[r]=="string"&&(k=x.call(this,u[r])),_.call(this,u.$anchor),_.call(this,u.$dynamicAnchor),o[f]=k;function x(g){let E=this.opts.uriResolver.resolve;if(g=ti(k?E(k,g):g),c.has(g))throw l(g);c.add(g);let h=this.refs[g];return typeof h=="string"&&(h=this.refs[h]),typeof h=="object"?d(u,h.schema,g):g!==ti(y)&&(g[0]==="#"?(d(u,a[g],g),a[g]=u):this.refs[g]=y),g}function _(g){if(typeof g=="string"){if(!c8.test(g))throw new Error(`invalid anchor "${g}"`);x.call(this,`#${g}`)}}}),a;function d(u,f,p){if(f!==void 0&&!t8(u,f))throw l(p)}function l(u){return new Error(`reference "${u}" resolves to more than one schema`)}}Or.getSchemaRefs=l8});var Sa=Me(ys=>{"use strict";Object.defineProperty(ys,"__esModule",{value:!0});ys.getData=ys.KeywordCxt=ys.validateFunctionCode=void 0;var rb=I2(),J2=ya(),pp=sp(),yl=ya(),u8=D2(),xa=q2(),fp=U2(),Ue=ct(),Qe=Jn(),d8=va(),Qn=_t(),wa=ba();function h8(t){if(ob(t)&&(ib(t),sb(t))){m8(t);return}nb(t,()=>(0,rb.topBoolOrEmptySchema)(t))}ys.validateFunctionCode=h8;function nb({gen:t,validateName:e,schema:r,schemaEnv:n,opts:s},o){s.code.es5?t.func(e,(0,Ue._)`${Qe.default.data}, ${Qe.default.valCxt}`,n.$async,()=>{t.code((0,Ue._)`"use strict"; ${Q2(r,s)}`),p8(t,s),t.code(o)}):t.func(e,(0,Ue._)`${Qe.default.data}, ${f8(s)}`,n.$async,()=>t.code(Q2(r,s)).code(o))}function f8(t){return(0,Ue._)`{${Qe.default.instancePath}="", ${Qe.default.parentData}, ${Qe.default.parentDataProperty}, ${Qe.default.rootData}=${Qe.default.data}${t.dynamicRef?(0,Ue._)`, ${Qe.default.dynamicAnchors}={}`:Ue.nil}}={}`}function p8(t,e){t.if(Qe.default.valCxt,()=>{t.var(Qe.default.instancePath,(0,Ue._)`${Qe.default.valCxt}.${Qe.default.instancePath}`),t.var(Qe.default.parentData,(0,Ue._)`${Qe.default.valCxt}.${Qe.default.parentData}`),t.var(Qe.default.parentDataProperty,(0,Ue._)`${Qe.default.valCxt}.${Qe.default.parentDataProperty}`),t.var(Qe.default.rootData,(0,Ue._)`${Qe.default.valCxt}.${Qe.default.rootData}`),e.dynamicRef&&t.var(Qe.default.dynamicAnchors,(0,Ue._)`${Qe.default.valCxt}.${Qe.default.dynamicAnchors}`)},()=>{t.var(Qe.default.instancePath,(0,Ue._)`""`),t.var(Qe.default.parentData,(0,Ue._)`undefined`),t.var(Qe.default.parentDataProperty,(0,Ue._)`undefined`),t.var(Qe.default.rootData,Qe.default.data),e.dynamicRef&&t.var(Qe.default.dynamicAnchors,(0,Ue._)`{}`)})}function m8(t){let{schema:e,opts:r,gen:n}=t;nb(t,()=>{r.$comment&&e.$comment&&cb(t),v8(t),n.let(Qe.default.vErrors,null),n.let(Qe.default.errors,0),r.unevaluated&&g8(t),ab(t),S8(t)})}function g8(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,Ue._)`${r}.evaluated`),e.if((0,Ue._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,Ue._)`${t.evaluated}.props`,(0,Ue._)`undefined`)),e.if((0,Ue._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,Ue._)`${t.evaluated}.items`,(0,Ue._)`undefined`))}function Q2(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,Ue._)`/*# sourceURL=${r} */`:Ue.nil}function _8(t,e){if(ob(t)&&(ib(t),sb(t))){b8(t,e);return}(0,rb.boolOrEmptySchema)(t,e)}function sb({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 ob(t){return typeof t.schema!="boolean"}function b8(t,e){let{schema:r,gen:n,opts:s}=t;s.$comment&&r.$comment&&cb(t),w8(t),x8(t);let o=n.const("_errs",Qe.default.errors);ab(t,o),n.var(e,(0,Ue._)`${o} === ${Qe.default.errors}`)}function ib(t){(0,Qn.checkUnknownRules)(t),y8(t)}function ab(t,e){if(t.opts.jtd)return eb(t,[],!1,e);let r=(0,J2.getSchemaTypes)(t.schema),n=(0,J2.coerceAndCheckDataType)(t,r);eb(t,r,!n,e)}function y8(t){let{schema:e,errSchemaPath:r,opts:n,self:s}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Qn.schemaHasRulesButRef)(e,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function v8(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Qn.checkStrictMode)(t,"default is ignored in the schema root")}function w8(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,d8.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function x8(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function cb({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:s}){let o=r.$comment;if(s.$comment===!0)t.code((0,Ue._)`${Qe.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){let i=(0,Ue.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,Ue._)`${Qe.default.self}.opts.$comment(${o}, ${i}, ${a}.schema)`)}}function S8(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=t;r.$async?e.if((0,Ue._)`${Qe.default.errors} === 0`,()=>e.return(Qe.default.data),()=>e.throw((0,Ue._)`new ${s}(${Qe.default.vErrors})`)):(e.assign((0,Ue._)`${n}.errors`,Qe.default.vErrors),o.unevaluated&&k8(t),e.return((0,Ue._)`${Qe.default.errors} === 0`))}function k8({gen:t,evaluated:e,props:r,items:n}){r instanceof Ue.Name&&t.assign((0,Ue._)`${e}.props`,r),n instanceof Ue.Name&&t.assign((0,Ue._)`${e}.items`,n)}function eb(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,Qn.schemaHasRulesButRef)(o,l))){s.block(()=>ub(t,"$ref",l.all.$ref.definition));return}c.jtd||$8(t,e),s.block(()=>{for(let f of l.rules)u(f);u(l.post)});function u(f){(0,pp.shouldUseGroup)(o,f)&&(f.type?(s.if((0,yl.checkDataType)(f.type,i,c.strictNumbers)),tb(t,f),e.length===1&&e[0]===f.type&&r&&(s.else(),(0,yl.reportTypeError)(t)),s.endIf()):tb(t,f),a||s.if((0,Ue._)`${Qe.default.errors} === ${n||0}`))}}function tb(t,e){let{gen:r,schema:n,opts:{useDefaults:s}}=t;s&&(0,u8.assignDefaults)(t,e.type),r.block(()=>{for(let o of e.rules)(0,pp.shouldUseRule)(n,o)&&ub(t,o.keyword,o.definition,e.type)})}function $8(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(E8(t,e),t.opts.allowUnionTypes||T8(t,e),R8(t,t.dataTypes))}function E8(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{lb(t.dataTypes,r)||mp(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),M8(t,e)}}function T8(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&mp(t,"use allowUnionTypes to allow union type keyword")}function R8(t,e){let r=t.self.RULES.all;for(let n in r){let s=r[n];if(typeof s=="object"&&(0,pp.shouldUseRule)(t.schema,s)){let{type:o}=s.definition;o.length&&!o.some(i=>P8(e,i))&&mp(t,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function P8(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function lb(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function M8(t,e){let r=[];for(let n of t.dataTypes)lb(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function mp(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Qn.checkStrictMode)(t,e,t.opts.strictTypes)}var vl=class{constructor(e,r,n){if((0,xa.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,Qn.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",db(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,xa.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",Qe.default.errors))}result(e,r,n){this.failResult((0,Ue.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,Ue.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,Ue._)`${r} !== undefined && (${(0,Ue.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?wa.reportExtraError:wa.reportError)(this,this.def.error,r)}$dataError(){(0,wa.reportError)(this,this.def.$dataError||wa.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,wa.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=Ue.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=Ue.nil,r=Ue.nil){if(!this.$data)return;let{gen:n,schemaCode:s,schemaType:o,def:i}=this;n.if((0,Ue.or)((0,Ue._)`${s} === undefined`,r)),e!==Ue.nil&&n.assign(e,!0),(o.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==Ue.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,Ue.or)(i(),a());function i(){if(n.length){if(!(r instanceof Ue.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,Ue._)`${(0,yl.checkDataTypes)(c,r,o.opts.strictNumbers,yl.DataType.Wrong)}`}return Ue.nil}function a(){if(s.validateSchema){let c=e.scopeValue("validate$data",{ref:s.validateSchema});return(0,Ue._)`!${c}(${r})`}return Ue.nil}}subschema(e,r){let n=(0,fp.getSubschema)(this.it,e);(0,fp.extendSubschemaData)(n,this.it,e),(0,fp.extendSubschemaMode)(n,e);let s={...this.it,...n,items:void 0,props:void 0};return _8(s,r),s}mergeEvaluated(e,r){let{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Qn.mergeEvaluated.props(s,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Qn.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,Ue.Name)),!0}};ys.KeywordCxt=vl;function ub(t,e,r,n){let s=new vl(t,r,e);"code"in r?r.code(s,n):s.$data&&r.validate?(0,xa.funcKeywordCode)(s,r):"macro"in r?(0,xa.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,xa.funcKeywordCode)(s,r)}var I8=/^\/(?:[^~]|~0|~1)*$/,z8=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function db(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let s,o;if(t==="")return Qe.default.rootData;if(t[0]==="/"){if(!I8.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);s=t,o=Qe.default.rootData}else{let d=z8.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,Ue._)`${o}${(0,Ue.getProperty)((0,Qn.unescapeJsonPointer)(d))}`,i=(0,Ue._)`${i} && ${o}`);return i;function c(d,l){return`Cannot access ${d} ${l} levels up, current level is ${e}`}}ys.getData=db});var wl=Me(_p=>{"use strict";Object.defineProperty(_p,"__esModule",{value:!0});var gp=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};_p.default=gp});var ka=Me(vp=>{"use strict";Object.defineProperty(vp,"__esModule",{value:!0});var bp=va(),yp=class extends Error{constructor(e,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,bp.resolveUrl)(e,r,n),this.missingSchema=(0,bp.normalizeId)((0,bp.getFullPath)(e,this.missingRef))}};vp.default=yp});var Sl=Me(on=>{"use strict";Object.defineProperty(on,"__esModule",{value:!0});on.resolveSchema=on.getCompilingSchema=on.resolveRef=on.compileSchema=on.SchemaEnv=void 0;var xn=ct(),A8=wl(),uo=Jn(),Sn=va(),hb=_t(),O8=Sa(),ri=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,Sn.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};on.SchemaEnv=ri;function xp(t){let e=fb.call(this,t);if(e)return e;let r=(0,Sn.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,i=new xn.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o}),a;t.$async&&(a=i.scopeValue("Error",{ref:A8.default,code:(0,xn._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let d={gen:i,allErrors:this.opts.allErrors,data:uo.default.data,parentData:uo.default.parentData,parentDataProperty:uo.default.parentDataProperty,dataNames:[uo.default.data],dataPathArr:[xn.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,xn.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:xn.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,xn._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,O8.validateFunctionCode)(d),i.optimize(this.opts.code.optimize);let u=i.toString();l=`${i.scopeRefs(uo.default.scope)}return ${u}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let p=new Function(`${uo.default.self}`,`${uo.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:m,items:y}=d;p.evaluated={props:m instanceof xn.Name?void 0:m,items:y instanceof xn.Name?void 0:y,dynamicProps:m instanceof xn.Name,dynamicItems:y instanceof xn.Name},p.source&&(p.source.evaluated=(0,xn.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)}}on.compileSchema=xp;function N8(t,e,r){var n;r=(0,Sn.resolveUrl)(this.opts.uriResolver,e,r);let s=t.refs[r];if(s)return s;let o=D8.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 ri({schema:i,schemaId:a,root:t,baseId:e}))}if(o!==void 0)return t.refs[r]=C8.call(this,o)}on.resolveRef=N8;function C8(t){return(0,Sn.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:xp.call(this,t)}function fb(t){for(let e of this._compilations)if(j8(e,t))return e}on.getCompilingSchema=fb;function j8(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function D8(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||xl.call(this,t,e)}function xl(t,e){let r=this.opts.uriResolver.parse(e),n=(0,Sn._getFullPath)(this.opts.uriResolver,r),s=(0,Sn.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===s)return wp.call(this,r,t);let o=(0,Sn.normalizeId)(n),i=this.refs[o]||this.schemas[o];if(typeof i=="string"){let a=xl.call(this,t,i);return typeof a?.schema!="object"?void 0:wp.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||xp.call(this,i),o===(0,Sn.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,d=a[c];return d&&(s=(0,Sn.resolveUrl)(this.opts.uriResolver,s,d)),new ri({schema:a,schemaId:c,root:t,baseId:s})}return wp.call(this,r,i)}}on.resolveSchema=xl;var L8=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function wp(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,hb.unescapeFragment)(a)];if(c===void 0)return;r=c;let d=typeof r=="object"&&r[this.opts.schemaId];!L8.has(a)&&d&&(e=(0,Sn.resolveUrl)(this.opts.uriResolver,e,d))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,hb.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Sn.resolveUrl)(this.opts.uriResolver,e,r.$ref);o=xl.call(this,n,a)}let{schemaId:i}=this.opts;if(o=o||new ri({schema:r,schemaId:i,root:n,baseId:e}),o.schema!==o.root.schema)return o}});var pb=Me((zB,Z8)=>{Z8.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 $p=Me((AB,vb)=>{"use strict";var B8=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),gb=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),Sp=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),_b=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),V8=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function kp(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 q8=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function mb(t){return t.length=0,!0}function F8(t,e,r){if(t.length){let n=kp(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function U8(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=mb}else{s.push(d);continue}}return s.length&&(a===mb?r.zone=s.join(""):i?n.push(s.join("")):n.push(kp(s))),r.address=n.join(""),r}function bb(t){if(H8(t,":")<2)return{host:t,isIPV6:!1};let e=U8(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 H8(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function G8(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 W8={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},Y8=/[@/?#:]/g,X8=/[@/?#]/g;function yb(t,e){let r=e?X8:Y8;return r.lastIndex=0,t.replace(r,n=>W8[n])}function K8(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(Sp(s)){let o=s.toUpperCase(),i=String.fromCharCode(parseInt(o,16));e&&_b(i)?r+=i:r+="%"+o,n+=2;continue}}r+=t[n]}return r}function J8(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(Sp(n)){let s=n.toUpperCase(),o=String.fromCharCode(parseInt(s,16));o!=="."&&_b(o)?e+=o:e+="%"+s,r+=2;continue}}V8(t[r])?e+=t[r]:e+=escape(t[r])}return e}function Q8(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(Sp(n)){e+="%"+n.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function eE(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!gb(r)){let n=bb(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=yb(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}vb.exports={nonSimpleDomain:q8,recomposeAuthority:eE,reescapeHostDelimiters:yb,normalizePercentEncoding:K8,normalizePathEncoding:J8,escapePreservingEscapes:Q8,removeDotSegments:G8,isIPv4:gb,isUUID:B8,normalizeIPv6:bb,stringArrayToHexStripped:kp}});var $b=Me((OB,kb)=>{"use strict";var{isUUID:tE}=$p(),rE=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,nE=["http","https","ws","wss","urn","urn:uuid"];function sE(t){return nE.indexOf(t)!==-1}function Ep(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 wb(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function xb(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 oE(t){return t.secure=Ep(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function iE(t){if((t.port===(Ep(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 aE(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(rE);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=Tp(s);t.path=void 0,o&&(t=o.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function cE(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=Tp(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 lE(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!tE(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function uE(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var Sb={scheme:"http",domainHost:!0,parse:wb,serialize:xb},dE={scheme:"https",domainHost:Sb.domainHost,parse:wb,serialize:xb},kl={scheme:"ws",domainHost:!0,parse:oE,serialize:iE},hE={scheme:"wss",domainHost:kl.domainHost,parse:kl.parse,serialize:kl.serialize},fE={scheme:"urn",parse:aE,serialize:cE,skipNormalize:!0},pE={scheme:"urn:uuid",parse:lE,serialize:uE,skipNormalize:!0},$l={http:Sb,https:dE,ws:kl,wss:hE,urn:fE,"urn:uuid":pE};Object.setPrototypeOf($l,null);function Tp(t){return t&&($l[t]||$l[t.toLowerCase()])||void 0}kb.exports={wsIsSecure:Ep,SCHEMES:$l,isValidSchemeName:sE,getSchemeHandler:Tp}});var Ib=Me((NB,El)=>{"use strict";var{normalizeIPv6:mE,removeDotSegments:$a,recomposeAuthority:gE,normalizePercentEncoding:_E,normalizePathEncoding:bE,escapePreservingEscapes:yE,reescapeHostDelimiters:vE,isIPv4:wE,nonSimpleDomain:xE}=$p(),{SCHEMES:SE,getSchemeHandler:Tb}=$b();function kE(t,e){return typeof t=="string"?t=PE(t,e):typeof t=="object"&&(t=ni(ho(t,e),e)),t}function $E(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},s=Rb(ni(t,n),ni(e,n),n,!0);return n.skipEscape=!0,ho(s,n)}function Rb(t,e,r,n){let s={};return n||(t=ni(ho(t,r),r),e=ni(ho(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=$a(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=$a(e.path||""),s.query=e.query):(e.path?(e.path[0]==="/"?s.path=$a(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=$a(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 EE(t,e,r){let n=Eb(t,r),s=Eb(e,r);return n!==void 0&&s!==void 0&&n.toLowerCase()===s.toLowerCase()}function ho(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=Tb(n.scheme||r.scheme);o&&o.serialize&&o.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=_E(r.path):(r.path=yE(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&s.push(r.scheme,":");let i=gE(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=$a(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 TE=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function RE(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 Pb(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(TE);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=RE(n,i);if(a!==void 0&&(n.error=n.error||a,s=!0),n.host)if(wE(n.host)===!1){let l=mE(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=Tb(r.scheme||n.scheme);if(!r.unicodeSupport&&(!c||!c.unicodeSupport)&&n.host&&(r.domainHost||c&&c.domainHost)&&o===!1&&xE(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=vE(unescape(n.host),o))),n.path&&(n.path=bE(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 ni(t,e){return Pb(t,e).parsed}function PE(t,e){return Mb(t,e).normalized}function Mb(t,e){let{parsed:r,malformedAuthorityOrPort:n}=Pb(t,e);return{normalized:n?t:ho(r,e),malformedAuthorityOrPort:n}}function Eb(t,e){if(typeof t=="string"){let{normalized:r,malformedAuthorityOrPort:n}=Mb(t,e);return n?void 0:r}if(typeof t=="object")return ho(t,e)}var Rp={SCHEMES:SE,normalize:kE,resolve:$E,resolveComponent:Rb,equal:EE,serialize:ho,parse:ni};El.exports=Rp;El.exports.default=Rp;El.exports.fastUri=Rp});var Ab=Me(Pp=>{"use strict";Object.defineProperty(Pp,"__esModule",{value:!0});var zb=Ib();zb.code='require("ajv/dist/runtime/uri").default';Pp.default=zb});var Bb=Me(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});ur.CodeGen=ur.Name=ur.nil=ur.stringify=ur.str=ur._=ur.KeywordCxt=void 0;var ME=Sa();Object.defineProperty(ur,"KeywordCxt",{enumerable:!0,get:function(){return ME.KeywordCxt}});var si=ct();Object.defineProperty(ur,"_",{enumerable:!0,get:function(){return si._}});Object.defineProperty(ur,"str",{enumerable:!0,get:function(){return si.str}});Object.defineProperty(ur,"stringify",{enumerable:!0,get:function(){return si.stringify}});Object.defineProperty(ur,"nil",{enumerable:!0,get:function(){return si.nil}});Object.defineProperty(ur,"Name",{enumerable:!0,get:function(){return si.Name}});Object.defineProperty(ur,"CodeGen",{enumerable:!0,get:function(){return si.CodeGen}});var IE=wl(),Db=ka(),zE=np(),Ea=Sl(),AE=ct(),Ta=va(),Tl=ya(),Ip=_t(),Ob=pb(),OE=Ab(),Lb=(t,e)=>new RegExp(t,e);Lb.code="new RegExp";var NE=["removeAdditional","useDefaults","coerceTypes"],CE=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),jE={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."},DE={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Nb=200;function LE(t){var e,r,n,s,o,i,a,c,d,l,u,f,p,m,y,k,x,_,g,E,h,$,z,L,q;let C=t.strict,Z=(e=t.code)===null||e===void 0?void 0:e.optimize,he=Z===!0||Z===void 0?1:Z||0,O=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:Lb,b=(s=t.uriResolver)!==null&&s!==void 0?s:OE.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:(f=(u=t.strictTuples)!==null&&u!==void 0?u:C)!==null&&f!==void 0?f:"log",strictRequired:(m=(p=t.strictRequired)!==null&&p!==void 0?p:C)!==null&&m!==void 0?m:!1,code:t.code?{...t.code,optimize:he,regExp:O}:{optimize:he,regExp:O},loopRequired:(y=t.loopRequired)!==null&&y!==void 0?y:Nb,loopEnum:(k=t.loopEnum)!==null&&k!==void 0?k:Nb,meta:(x=t.meta)!==null&&x!==void 0?x:!0,messages:(_=t.messages)!==null&&_!==void 0?_:!0,inlineRefs:(g=t.inlineRefs)!==null&&g!==void 0?g:!0,schemaId:(E=t.schemaId)!==null&&E!==void 0?E:"$id",addUsedSchema:(h=t.addUsedSchema)!==null&&h!==void 0?h:!0,validateSchema:($=t.validateSchema)!==null&&$!==void 0?$:!0,validateFormats:(z=t.validateFormats)!==null&&z!==void 0?z:!0,unicodeRegExp:(L=t.unicodeRegExp)!==null&&L!==void 0?L:!0,int32range:(q=t.int32range)!==null&&q!==void 0?q:!0,uriResolver:b}}var Ra=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,...LE(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new AE.ValueScope({scope:{},prefixes:CE,es5:r,lines:n}),this.logger=UE(e.logger);let s=e.validateFormats;e.validateFormats=!1,this.RULES=(0,zE.getRules)(),Cb.call(this,jE,e,"NOT SUPPORTED"),Cb.call(this,DE,e,"DEPRECATED","warn"),this._metaOpts=qE.call(this),e.formats&&BE.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&VE.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),ZE.call(this),e.validateFormats=s}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,s=Ob;n==="id"&&(s={...Ob},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 f=this._addSchema(l,u);return f.validate||i.call(this,f)}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 Db.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,Ta.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=jb.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,s=new Ea.SchemaEnv({schema:{},schemaId:n});if(r=Ea.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=jb.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,Ta.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(GE.call(this,n,r),!r)return(0,Ip.eachItem)(n,o=>Mp.call(this,o)),this;YE.call(this,r);let s={...r,type:(0,Tl.getJSONTypes)(r.type),schemaType:(0,Tl.getJSONTypes)(r.schemaType)};return(0,Ip.eachItem)(n,s.type.length===0?o=>Mp.call(this,o,s):o=>s.type.forEach(i=>Mp.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]=Zb(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,Ta.normalizeId)(i||n);let d=Ta.getSchemaRefs.call(this,e,n);return c=new Ea.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):Ea.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{Ea.compileSchema.call(this,e)}finally{this.opts=r}}};Ra.ValidationError=IE.default;Ra.MissingRefError=Db.default;ur.default=Ra;function Cb(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 jb(t){return t=(0,Ta.normalizeId)(t),this.schemas[t]||this.refs[t]}function ZE(){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 BE(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function VE(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 qE(){let t={...this.opts};for(let e of NE)delete t[e];return t}var FE={log(){},warn(){},error(){}};function UE(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 HE=/^[a-z_$][a-z0-9_$:-]*$/i;function GE(t,e){let{RULES:r}=this;if((0,Ip.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!HE.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 Mp(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,Tl.getJSONTypes)(e.type),schemaType:(0,Tl.getJSONTypes)(e.schemaType)}};e.before?WE.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 WE(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 YE(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=Zb(e)),t.validateSchema=this.compile(e,!0))}var XE={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Zb(t){return{anyOf:[t,XE]}}});var Vb=Me(zp=>{"use strict";Object.defineProperty(zp,"__esModule",{value:!0});var KE={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};zp.default=KE});var Hb=Me(fo=>{"use strict";Object.defineProperty(fo,"__esModule",{value:!0});fo.callRef=fo.getValidate=void 0;var JE=ka(),qb=sn(),Nr=ct(),oi=Jn(),Fb=Sl(),Rl=_t(),QE={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=Fb.resolveRef.call(c,d,s,r);if(l===void 0)throw new JE.default(n.opts.uriResolver,s,r);if(l instanceof Fb.SchemaEnv)return f(l);return p(l);function u(){if(o===d)return Pl(t,i,o,o.$async);let m=e.scopeValue("root",{ref:d});return Pl(t,(0,Nr._)`${m}.validate`,d,d.$async)}function f(m){let y=Ub(t,m);Pl(t,y,m,m.$async)}function p(m){let y=e.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Nr.stringify)(m)}:{ref:m}),k=e.name("valid"),x=t.subschema({schema:m,dataTypes:[],schemaPath:Nr.nil,topSchemaRef:y,errSchemaPath:r},k);t.mergeEvaluated(x),t.ok(k)}}};function Ub(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Nr._)`${r.scopeValue("wrapper",{ref:e})}.validate`}fo.getValidate=Ub;function Pl(t,e,r,n){let{gen:s,it:o}=t,{allErrors:i,schemaEnv:a,opts:c}=o,d=c.passContext?oi.default.this:Nr.nil;n?l():u();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let m=s.let("valid");s.try(()=>{s.code((0,Nr._)`await ${(0,qb.callValidateCode)(t,e,d)}`),p(e),i||s.assign(m,!0)},y=>{s.if((0,Nr._)`!(${y} instanceof ${o.ValidationError})`,()=>s.throw(y)),f(y),i||s.assign(m,!1)}),t.ok(m)}function u(){t.result((0,qb.callValidateCode)(t,e,d),()=>p(e),()=>f(e))}function f(m){let y=(0,Nr._)`${m}.errors`;s.assign(oi.default.vErrors,(0,Nr._)`${oi.default.vErrors} === null ? ${y} : ${oi.default.vErrors}.concat(${y})`),s.assign(oi.default.errors,(0,Nr._)`${oi.default.vErrors}.length`)}function p(m){var y;if(!o.opts.unevaluated)return;let k=(y=r?.validate)===null||y===void 0?void 0:y.evaluated;if(o.props!==!0)if(k&&!k.dynamicProps)k.props!==void 0&&(o.props=Rl.mergeEvaluated.props(s,k.props,o.props));else{let x=s.var("props",(0,Nr._)`${m}.evaluated.props`);o.props=Rl.mergeEvaluated.props(s,x,o.props,Nr.Name)}if(o.items!==!0)if(k&&!k.dynamicItems)k.items!==void 0&&(o.items=Rl.mergeEvaluated.items(s,k.items,o.items));else{let x=s.var("items",(0,Nr._)`${m}.evaluated.items`);o.items=Rl.mergeEvaluated.items(s,x,o.items,Nr.Name)}}}fo.callRef=Pl;fo.default=QE});var Gb=Me(Ap=>{"use strict";Object.defineProperty(Ap,"__esModule",{value:!0});var e7=Vb(),t7=Hb(),r7=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",e7.default,t7.default];Ap.default=r7});var Wb=Me(Op=>{"use strict";Object.defineProperty(Op,"__esModule",{value:!0});var Ml=ct(),vs=Ml.operators,Il={maximum:{okStr:"<=",ok:vs.LTE,fail:vs.GT},minimum:{okStr:">=",ok:vs.GTE,fail:vs.LT},exclusiveMaximum:{okStr:"<",ok:vs.LT,fail:vs.GTE},exclusiveMinimum:{okStr:">",ok:vs.GT,fail:vs.LTE}},n7={message:({keyword:t,schemaCode:e})=>(0,Ml.str)`must be ${Il[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Ml._)`{comparison: ${Il[t].okStr}, limit: ${e}}`},s7={keyword:Object.keys(Il),type:"number",schemaType:"number",$data:!0,error:n7,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,Ml._)`${r} ${Il[e].fail} ${n} || isNaN(${r})`)}};Op.default=s7});var Yb=Me(Np=>{"use strict";Object.defineProperty(Np,"__esModule",{value:!0});var Pa=ct(),o7={message:({schemaCode:t})=>(0,Pa.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Pa._)`{multipleOf: ${t}}`},i7={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:o7,code(t){let{gen:e,data:r,schemaCode:n,it:s}=t,o=s.opts.multipleOfPrecision,i=e.let("res"),a=o?(0,Pa._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${o}`:(0,Pa._)`${i} !== parseInt(${i})`;t.fail$data((0,Pa._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};Np.default=i7});var Kb=Me(Cp=>{"use strict";Object.defineProperty(Cp,"__esModule",{value:!0});function Xb(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}Cp.default=Xb;Xb.code='require("ajv/dist/runtime/ucs2length").default'});var Jb=Me(jp=>{"use strict";Object.defineProperty(jp,"__esModule",{value:!0});var po=ct(),a7=_t(),c7=Kb(),l7={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,po.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,po._)`{limit: ${t}}`},u7={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:l7,code(t){let{keyword:e,data:r,schemaCode:n,it:s}=t,o=e==="maxLength"?po.operators.GT:po.operators.LT,i=s.opts.unicode===!1?(0,po._)`${r}.length`:(0,po._)`${(0,a7.useFunc)(t.gen,c7.default)}(${r})`;t.fail$data((0,po._)`${i} ${o} ${n}`)}};jp.default=u7});var Qb=Me(Dp=>{"use strict";Object.defineProperty(Dp,"__esModule",{value:!0});var d7=sn(),h7=_t(),ii=ct(),f7={message:({schemaCode:t})=>(0,ii.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,ii._)`{pattern: ${t}}`},p7={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:f7,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,ii._)`new RegExp`:(0,h7.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,ii._)`${d}(${o}, ${a}).test(${r})`),()=>e.assign(l,!1)),t.fail$data((0,ii._)`!${l}`)}else{let c=(0,d7.usePattern)(t,s);t.fail$data((0,ii._)`!${c}.test(${r})`)}}};Dp.default=p7});var ey=Me(Lp=>{"use strict";Object.defineProperty(Lp,"__esModule",{value:!0});var Ma=ct(),m7={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,Ma.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,Ma._)`{limit: ${t}}`},g7={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:m7,code(t){let{keyword:e,data:r,schemaCode:n}=t,s=e==="maxProperties"?Ma.operators.GT:Ma.operators.LT;t.fail$data((0,Ma._)`Object.keys(${r}).length ${s} ${n}`)}};Lp.default=g7});var ty=Me(Zp=>{"use strict";Object.defineProperty(Zp,"__esModule",{value:!0});var Ia=sn(),za=ct(),_7=_t(),b7={message:({params:{missingProperty:t}})=>(0,za.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,za._)`{missingProperty: ${t}}`},y7={keyword:"required",type:"object",schemaType:"array",$data:!0,error:b7,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:m}=t.it;for(let y of r)if(p?.[y]===void 0&&!m.has(y)){let k=i.schemaEnv.baseId+i.errSchemaPath,x=`required property "${y}" is not defined at "${k}" (strictRequired)`;(0,_7.checkStrictMode)(i,x,i.opts.strictRequired)}}function d(){if(c||o)t.block$data(za.nil,u);else for(let p of r)(0,Ia.checkReportMissingProp)(t,p)}function l(){let p=e.let("missing");if(c||o){let m=e.let("valid",!0);t.block$data(m,()=>f(p,m)),t.ok(m)}else e.if((0,Ia.checkMissingProp)(t,r,p)),(0,Ia.reportMissingProp)(t,p),e.else()}function u(){e.forOf("prop",n,p=>{t.setParams({missingProperty:p}),e.if((0,Ia.noPropertyInData)(e,s,p,a.ownProperties),()=>t.error())})}function f(p,m){t.setParams({missingProperty:p}),e.forOf(p,n,()=>{e.assign(m,(0,Ia.propertyInData)(e,s,p,a.ownProperties)),e.if((0,za.not)(m),()=>{t.error(),e.break()})},za.nil)}}};Zp.default=y7});var ry=Me(Bp=>{"use strict";Object.defineProperty(Bp,"__esModule",{value:!0});var Aa=ct(),v7={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,Aa.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,Aa._)`{limit: ${t}}`},w7={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:v7,code(t){let{keyword:e,data:r,schemaCode:n}=t,s=e==="maxItems"?Aa.operators.GT:Aa.operators.LT;t.fail$data((0,Aa._)`${r}.length ${s} ${n}`)}};Bp.default=w7});var zl=Me(Vp=>{"use strict";Object.defineProperty(Vp,"__esModule",{value:!0});var ny=dp();ny.code='require("ajv/dist/runtime/equal").default';Vp.default=ny});var sy=Me(Fp=>{"use strict";Object.defineProperty(Fp,"__esModule",{value:!0});var qp=ya(),dr=ct(),x7=_t(),S7=zl(),k7={message:({params:{i:t,j:e}})=>(0,dr.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,dr._)`{i: ${t}, j: ${e}}`},$7={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:k7,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,qp.getSchemaTypes)(o.items):[];t.block$data(c,l,(0,dr._)`${i} === false`),t.ok(c);function l(){let m=e.let("i",(0,dr._)`${r}.length`),y=e.let("j");t.setParams({i:m,j:y}),e.assign(c,!0),e.if((0,dr._)`${m} > 1`,()=>(u()?f:p)(m,y))}function u(){return d.length>0&&!d.some(m=>m==="object"||m==="array")}function f(m,y){let k=e.name("item"),x=(0,qp.checkDataTypes)(d,k,a.opts.strictNumbers,qp.DataType.Wrong),_=e.const("indices",(0,dr._)`{}`);e.for((0,dr._)`;${m}--;`,()=>{e.let(k,(0,dr._)`${r}[${m}]`),e.if(x,(0,dr._)`continue`),d.length>1&&e.if((0,dr._)`typeof ${k} == "string"`,(0,dr._)`${k} += "_"`),e.if((0,dr._)`typeof ${_}[${k}] == "number"`,()=>{e.assign(y,(0,dr._)`${_}[${k}]`),t.error(),e.assign(c,!1).break()}).code((0,dr._)`${_}[${k}] = ${m}`)})}function p(m,y){let k=(0,x7.useFunc)(e,S7.default),x=e.name("outer");e.label(x).for((0,dr._)`;${m}--;`,()=>e.for((0,dr._)`${y} = ${m}; ${y}--;`,()=>e.if((0,dr._)`${k}(${r}[${m}], ${r}[${y}])`,()=>{t.error(),e.assign(c,!1).break(x)})))}}};Fp.default=$7});var oy=Me(Hp=>{"use strict";Object.defineProperty(Hp,"__esModule",{value:!0});var Up=ct(),E7=_t(),T7=zl(),R7={message:"must be equal to constant",params:({schemaCode:t})=>(0,Up._)`{allowedValue: ${t}}`},P7={keyword:"const",$data:!0,error:R7,code(t){let{gen:e,data:r,$data:n,schemaCode:s,schema:o}=t;n||o&&typeof o=="object"?t.fail$data((0,Up._)`!${(0,E7.useFunc)(e,T7.default)}(${r}, ${s})`):t.fail((0,Up._)`${o} !== ${r}`)}};Hp.default=P7});var iy=Me(Gp=>{"use strict";Object.defineProperty(Gp,"__esModule",{value:!0});var Oa=ct(),M7=_t(),I7=zl(),z7={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Oa._)`{allowedValues: ${t}}`},A7={keyword:"enum",schemaType:"array",$data:!0,error:z7,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,M7.useFunc)(e,I7.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,Oa.or)(...s.map((m,y)=>f(p,y)))}t.pass(l);function u(){e.assign(l,!1),e.forOf("v",o,p=>e.if((0,Oa._)`${d()}(${r}, ${p})`,()=>e.assign(l,!0).break()))}function f(p,m){let y=s[m];return typeof y=="object"&&y!==null?(0,Oa._)`${d()}(${r}, ${p}[${m}])`:(0,Oa._)`${r} === ${y}`}}};Gp.default=A7});var ay=Me(Wp=>{"use strict";Object.defineProperty(Wp,"__esModule",{value:!0});var O7=Wb(),N7=Yb(),C7=Jb(),j7=Qb(),D7=ey(),L7=ty(),Z7=ry(),B7=sy(),V7=oy(),q7=iy(),F7=[O7.default,N7.default,C7.default,j7.default,D7.default,L7.default,Z7.default,B7.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},V7.default,q7.default];Wp.default=F7});var Xp=Me(Na=>{"use strict";Object.defineProperty(Na,"__esModule",{value:!0});Na.validateAdditionalItems=void 0;var mo=ct(),Yp=_t(),U7={message:({params:{len:t}})=>(0,mo.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,mo._)`{limit: ${t}}`},H7={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:U7,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,Yp.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}cy(t,n)}};function cy(t,e){let{gen:r,schema:n,data:s,keyword:o,it:i}=t;i.items=!0;let a=r.const("len",(0,mo._)`${s}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,mo._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,Yp.alwaysValidSchema)(i,n)){let d=r.var("valid",(0,mo._)`${a} <= ${e.length}`);r.if((0,mo.not)(d),()=>c(d)),t.ok(d)}function c(d){r.forRange("i",e.length,a,l=>{t.subschema({keyword:o,dataProp:l,dataPropType:Yp.Type.Num},d),i.allErrors||r.if((0,mo.not)(d),()=>r.break())})}}Na.validateAdditionalItems=cy;Na.default=H7});var Kp=Me(Ca=>{"use strict";Object.defineProperty(Ca,"__esModule",{value:!0});Ca.validateTuple=void 0;var ly=ct(),Al=_t(),G7=sn(),W7={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return uy(t,"additionalItems",e);r.items=!0,!(0,Al.alwaysValidSchema)(r,e)&&t.ok((0,G7.validateArray)(t))}};function uy(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=Al.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),d=n.const("len",(0,ly._)`${o}.length`);r.forEach((u,f)=>{(0,Al.alwaysValidSchema)(a,u)||(n.if((0,ly._)`${d} > ${f}`,()=>t.subschema({keyword:i,schemaProp:f,dataProp:f},c)),t.ok(c))});function l(u){let{opts:f,errSchemaPath:p}=a,m=r.length,y=m===u.minItems&&(m===u.maxItems||u[e]===!1);if(f.strictTuples&&!y){let k=`"${i}" is ${m}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0,Al.checkStrictMode)(a,k,f.strictTuples)}}}Ca.validateTuple=uy;Ca.default=W7});var dy=Me(Jp=>{"use strict";Object.defineProperty(Jp,"__esModule",{value:!0});var Y7=Kp(),X7={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,Y7.validateTuple)(t,"items")};Jp.default=X7});var fy=Me(Qp=>{"use strict";Object.defineProperty(Qp,"__esModule",{value:!0});var hy=ct(),K7=_t(),J7=sn(),Q7=Xp(),eT={message:({params:{len:t}})=>(0,hy.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,hy._)`{limit: ${t}}`},tT={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:eT,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:s}=r;n.items=!0,!(0,K7.alwaysValidSchema)(n,e)&&(s?(0,Q7.validateAdditionalItems)(t,s):t.ok((0,J7.validateArray)(t)))}};Qp.default=tT});var py=Me(em=>{"use strict";Object.defineProperty(em,"__esModule",{value:!0});var an=ct(),Ol=_t(),rT={message:({params:{min:t,max:e}})=>e===void 0?(0,an.str)`must contain at least ${t} valid item(s)`:(0,an.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,an._)`{minContains: ${t}}`:(0,an._)`{minContains: ${t}, maxContains: ${e}}`},nT={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:rT,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,an._)`${s}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,Ol.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,Ol.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,Ol.alwaysValidSchema)(o,r)){let y=(0,an._)`${l} >= ${i}`;a!==void 0&&(y=(0,an._)`${y} && ${l} <= ${a}`),t.pass(y);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,an._)`${s}.length > 0`,f)):(e.let(u,!1),f()),t.result(u,()=>t.reset());function f(){let y=e.name("_valid"),k=e.let("count",0);p(y,()=>e.if(y,()=>m(k)))}function p(y,k){e.forRange("i",0,l,x=>{t.subschema({keyword:"contains",dataProp:x,dataPropType:Ol.Type.Num,compositeRule:!0},y),k()})}function m(y){e.code((0,an._)`${y}++`),a===void 0?e.if((0,an._)`${y} >= ${i}`,()=>e.assign(u,!0).break()):(e.if((0,an._)`${y} > ${a}`,()=>e.assign(u,!1).break()),i===1?e.assign(u,!0):e.if((0,an._)`${y} >= ${i}`,()=>e.assign(u,!0)))}}};em.default=nT});var _y=Me(Dn=>{"use strict";Object.defineProperty(Dn,"__esModule",{value:!0});Dn.validateSchemaDeps=Dn.validatePropertyDeps=Dn.error=void 0;var tm=ct(),sT=_t(),ja=sn();Dn.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,tm.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,tm._)`{property: ${t},
|
|
7
7
|
missingProperty: ${n},
|
|
8
8
|
depsCount: ${e},
|
|
9
|
-
deps: ${r}}`};var i7={keyword:"dependencies",type:"object",schemaType:"object",error:Dn.error,code(t){let[e,r]=a7(t);my(t,e),gy(t,r)}};function a7({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 my(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,Da.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,Da.checkReportMissingProp)(t,d)}):(r.if((0,tm._)`${c} && (${(0,Da.checkMissingProp)(t,a,o)})`),(0,Da.reportMissingProp)(t,o),r.else())}}Dn.validatePropertyDeps=my;function gy(t,e=t.schema){let{gen:r,data:n,keyword:s,it:o}=t,i=r.name("valid");for(let a in e)(0,o7.alwaysValidSchema)(o,e[a])||(r.if((0,Da.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))}Dn.validateSchemaDeps=gy;Dn.default=i7});var yy=Pe(rm=>{"use strict";Object.defineProperty(rm,"__esModule",{value:!0});var by=ct(),c7=_t(),l7={message:"property name must be valid",params:({params:t})=>(0,by._)`{propertyName: ${t.propertyName}}`},u7={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:l7,code(t){let{gen:e,schema:r,data:n,it:s}=t;if((0,c7.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,by.not)(o),()=>{t.error(!0),s.allErrors||e.break()})}),t.ok(o)}};rm.default=u7});var sm=Pe(nm=>{"use strict";Object.defineProperty(nm,"__esModule",{value:!0});var Cl=sn(),kn=ct(),d7=Jn(),jl=_t(),h7={message:"must NOT have additional properties",params:({params:t})=>(0,kn._)`{additionalProperty: ${t.additionalProperty}}`},f7={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:h7,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,jl.alwaysValidSchema)(i,r))return;let d=(0,Cl.allSchemaProperties)(n.properties),l=(0,Cl.allSchemaProperties)(n.patternProperties);u(),t.ok((0,kn._)`${o} === ${d7.default.errors}`);function u(){e.forIn("key",s,k=>{!d.length&&!l.length?m(k):e.if(f(k),()=>m(k))})}function f(k){let x;if(d.length>8){let _=(0,jl.schemaRefOrVal)(i,n.properties,"properties");x=(0,Cl.isOwnProperty)(e,_,k)}else d.length?x=(0,kn.or)(...d.map(_=>(0,kn._)`${k} === ${_}`)):x=kn.nil;return l.length&&(x=(0,kn.or)(x,...l.map(_=>(0,kn._)`${(0,Cl.usePattern)(t,_)}.test(${k})`))),(0,kn.not)(x)}function p(k){e.code((0,kn._)`delete ${s}[${k}]`)}function m(k){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(k);return}if(r===!1){t.setParams({additionalProperty:k}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,jl.alwaysValidSchema)(i,r)){let x=e.name("valid");c.removeAdditional==="failing"?(y(k,x,!1),e.if((0,kn.not)(x),()=>{t.reset(),p(k)})):(y(k,x),a||e.if((0,kn.not)(x),()=>e.break()))}}function y(k,x,_){let g={keyword:"additionalProperties",dataProp:k,dataPropType:jl.Type.Str};_===!1&&Object.assign(g,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(g,x)}}};nm.default=f7});var xy=Pe(im=>{"use strict";Object.defineProperty(im,"__esModule",{value:!0});var p7=ka(),vy=sn(),om=_t(),wy=sm(),m7={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&&wy.default.code(new p7.KeywordCxt(o,wy.default,"additionalProperties"));let i=(0,vy.allSchemaProperties)(r);for(let u of i)o.definedProperties.add(u);o.opts.unevaluated&&i.length&&o.props!==!0&&(o.props=om.mergeEvaluated.props(e,(0,om.toHash)(i),o.props));let a=i.filter(u=>!(0,om.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,vy.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)}}};im.default=m7});var Ey=Pe(am=>{"use strict";Object.defineProperty(am,"__esModule",{value:!0});var Sy=sn(),Dl=ct(),ky=_t(),$y=_t(),g7={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,Sy.allSchemaProperties)(r),c=a.filter(y=>(0,ky.alwaysValidSchema)(o,r[y]));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 Dl.Name)&&(o.props=(0,$y.evaluatedPropsToName)(e,o.props));let{props:u}=o;f();function f(){for(let y of a)d&&p(y),o.allErrors?m(y):(e.var(l,!0),m(y),e.if(l))}function p(y){for(let k in d)new RegExp(y).test(k)&&(0,ky.checkStrictMode)(o,`property ${k} matches pattern ${y} (use allowMatchingProperties)`)}function m(y){e.forIn("key",n,k=>{e.if((0,Dl._)`${(0,Sy.usePattern)(t,y)}.test(${k})`,()=>{let x=c.includes(y);x||t.subschema({keyword:"patternProperties",schemaProp:y,dataProp:k,dataPropType:$y.Type.Str},l),o.opts.unevaluated&&u!==!0?e.assign((0,Dl._)`${u}[${k}]`,!0):!x&&!o.allErrors&&e.if((0,Dl.not)(l),()=>e.break())})})}}};am.default=g7});var Ty=Pe(cm=>{"use strict";Object.defineProperty(cm,"__esModule",{value:!0});var _7=_t(),b7={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,_7.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"}};cm.default=b7});var Ry=Pe(lm=>{"use strict";Object.defineProperty(lm,"__esModule",{value:!0});var y7=sn(),v7={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:y7.validateUnion,error:{message:"must match a schema in anyOf"}};lm.default=v7});var Iy=Pe(um=>{"use strict";Object.defineProperty(um,"__esModule",{value:!0});var Ll=ct(),w7=_t(),x7={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Ll._)`{passingSchemas: ${t.passing}}`},S7={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:x7,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 f;(0,w7.alwaysValidSchema)(s,l)?e.var(c,!0):f=t.subschema({keyword:"oneOf",schemaProp:u,compositeRule:!0},c),u>0&&e.if((0,Ll._)`${c} && ${i}`).assign(i,!1).assign(a,(0,Ll._)`[${a}, ${u}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,u),f&&t.mergeEvaluated(f,Ll.Name)})})}}};um.default=S7});var Py=Pe(dm=>{"use strict";Object.defineProperty(dm,"__esModule",{value:!0});var k7=_t(),$7={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,k7.alwaysValidSchema)(n,o))return;let a=t.subschema({keyword:"allOf",schemaProp:i},s);t.ok(s),t.mergeEvaluated(a)})}};dm.default=$7});var Ay=Pe(hm=>{"use strict";Object.defineProperty(hm,"__esModule",{value:!0});var Zl=ct(),Oy=_t(),E7={message:({params:t})=>(0,Zl.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,Zl._)`{failingKeyword: ${t.ifClause}}`},T7={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:E7,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,Oy.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let s=My(n,"then"),o=My(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,Zl.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 f=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(f,i),u?e.assign(u,(0,Zl._)`${l}`):t.setParams({ifClause:l})}}}};function My(t,e){let r=t.schema[e];return r!==void 0&&!(0,Oy.alwaysValidSchema)(t,r)}hm.default=T7});var zy=Pe(fm=>{"use strict";Object.defineProperty(fm,"__esModule",{value:!0});var R7=_t(),I7={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,R7.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};fm.default=I7});var Ny=Pe(pm=>{"use strict";Object.defineProperty(pm,"__esModule",{value:!0});var P7=Xp(),M7=dy(),O7=Kp(),A7=fy(),z7=py(),N7=_y(),C7=yy(),j7=sm(),D7=xy(),L7=Ey(),Z7=Ty(),B7=Ry(),V7=Iy(),q7=Py(),F7=Ay(),H7=zy();function U7(t=!1){let e=[Z7.default,B7.default,V7.default,q7.default,F7.default,H7.default,C7.default,j7.default,N7.default,D7.default,L7.default];return t?e.push(M7.default,A7.default):e.push(P7.default,O7.default),e.push(z7.default),e}pm.default=U7});var Cy=Pe(mm=>{"use strict";Object.defineProperty(mm,"__esModule",{value:!0});var Yt=ct(),G7={message:({schemaCode:t})=>(0,Yt.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,Yt._)`{format: ${t}}`},W7={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:G7,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?f():p();function f(){let m=r.scopeValue("formats",{ref:u.formats,code:c.code.formats}),y=r.const("fDef",(0,Yt._)`${m}[${i}]`),k=r.let("fType"),x=r.let("format");r.if((0,Yt._)`typeof ${y} == "object" && !(${y} instanceof RegExp)`,()=>r.assign(k,(0,Yt._)`${y}.type || "string"`).assign(x,(0,Yt._)`${y}.validate`),()=>r.assign(k,(0,Yt._)`"string"`).assign(x,y)),t.fail$data((0,Yt.or)(_(),g()));function _(){return c.strictSchema===!1?Yt.nil:(0,Yt._)`${i} && !${x}`}function g(){let E=l.$async?(0,Yt._)`(${y}.async ? await ${x}(${n}) : ${x}(${n}))`:(0,Yt._)`${x}(${n})`,h=(0,Yt._)`(typeof ${x} == "function" ? ${E} : ${x}.test(${n}))`;return(0,Yt._)`${x} && ${x} !== true && ${k} === ${e} && !${h}`}}function p(){let m=u.formats[o];if(!m){_();return}if(m===!0)return;let[y,k,x]=g(m);y===e&&t.pass(E());function _(){if(c.strictSchema===!1){u.logger.warn(h());return}throw new Error(h());function h(){return`unknown format "${o}" ignored in schema at path "${d}"`}}function g(h){let $=h instanceof RegExp?(0,Yt.regexpCode)(h):c.code.formats?(0,Yt._)`${c.code.formats}${(0,Yt.getProperty)(o)}`:void 0,O=r.scopeValue("formats",{key:o,ref:h,code:$});return typeof h=="object"&&!(h instanceof RegExp)?[h.type||"string",h.validate,(0,Yt._)`${O}.validate`]:["string",h,O]}function E(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!l.$async)throw new Error("async format in sync schema");return(0,Yt._)`await ${x}(${n})`}return typeof k=="function"?(0,Yt._)`${x}(${n})`:(0,Yt._)`${x}.test(${n})`}}}};mm.default=W7});var jy=Pe(gm=>{"use strict";Object.defineProperty(gm,"__esModule",{value:!0});var Y7=Cy(),X7=[Y7.default];gm.default=X7});var Dy=Pe(ci=>{"use strict";Object.defineProperty(ci,"__esModule",{value:!0});ci.contentVocabulary=ci.metadataVocabulary=void 0;ci.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];ci.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Zy=Pe(_m=>{"use strict";Object.defineProperty(_m,"__esModule",{value:!0});var K7=Gb(),J7=ay(),Q7=Ny(),eR=jy(),Ly=Dy(),tR=[K7.default,J7.default,(0,Q7.default)(),eR.default,Ly.metadataVocabulary,Ly.contentVocabulary];_m.default=tR});var Vy=Pe(Bl=>{"use strict";Object.defineProperty(Bl,"__esModule",{value:!0});Bl.DiscrError=void 0;var By;(function(t){t.Tag="tag",t.Mapping="mapping"})(By||(Bl.DiscrError=By={}))});var Fy=Pe(ym=>{"use strict";Object.defineProperty(ym,"__esModule",{value:!0});var li=ct(),bm=Vy(),qy=kl(),rR=$a(),nR=_t(),sR={message:({params:{discrError:t,tagName:e}})=>t===bm.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,li._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},oR={keyword:"discriminator",type:"object",schemaType:"object",error:sR,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,li._)`${r}${(0,li.getProperty)(a)}`);e.if((0,li._)`typeof ${d} == "string"`,()=>l(),()=>t.error(!1,{discrError:bm.DiscrError.Tag,tag:d,tagName:a})),t.ok(c);function l(){let p=f();e.if(!1);for(let m in p)e.elseIf((0,li._)`${d} === ${m}`),e.assign(c,u(p[m]));e.else(),t.error(!1,{discrError:bm.DiscrError.Mapping,tag:d,tagName:a}),e.endIf()}function u(p){let m=e.name("valid"),y=t.subschema({keyword:"oneOf",schemaProp:p},m);return t.mergeEvaluated(y,li.Name),m}function f(){var p;let m={},y=x(s),k=!0;for(let E=0;E<i.length;E++){let h=i[E];if(h?.$ref&&!(0,nR.schemaHasRulesButRef)(h,o.self.RULES)){let O=h.$ref;if(h=qy.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,O),h instanceof qy.SchemaEnv&&(h=h.schema),h===void 0)throw new rR.default(o.opts.uriResolver,o.baseId,O)}let $=(p=h?.properties)===null||p===void 0?void 0:p[a];if(typeof $!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);k=k&&(y||x(h)),_($,E)}if(!k)throw new Error(`discriminator: "${a}" must be required`);return m;function x({required:E}){return Array.isArray(E)&&E.includes(a)}function _(E,h){if(E.const)g(E.const,h);else if(E.enum)for(let $ of E.enum)g($,h);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function g(E,h){if(typeof E!="string"||E in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[E]=h}}}};ym.default=oR});var Hy=Pe((SV,iR)=>{iR.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 wm=Pe((Nt,vm)=>{"use strict";Object.defineProperty(Nt,"__esModule",{value:!0});Nt.MissingRefError=Nt.ValidationError=Nt.CodeGen=Nt.Name=Nt.nil=Nt.stringify=Nt.str=Nt._=Nt.KeywordCxt=Nt.Ajv=void 0;var aR=Bb(),cR=Zy(),lR=Fy(),Uy=Hy(),uR=["/properties"],Vl="http://json-schema.org/draft-07/schema",ui=class extends aR.default{_addVocabularies(){super._addVocabularies(),cR.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(lR.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(Uy,uR):Uy;this.addMetaSchema(e,Vl,!1),this.refs["http://json-schema.org/schema"]=Vl}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Vl)?Vl:void 0)}};Nt.Ajv=ui;vm.exports=Nt=ui;vm.exports.Ajv=ui;Object.defineProperty(Nt,"__esModule",{value:!0});Nt.default=ui;var dR=ka();Object.defineProperty(Nt,"KeywordCxt",{enumerable:!0,get:function(){return dR.KeywordCxt}});var di=ct();Object.defineProperty(Nt,"_",{enumerable:!0,get:function(){return di._}});Object.defineProperty(Nt,"str",{enumerable:!0,get:function(){return di.str}});Object.defineProperty(Nt,"stringify",{enumerable:!0,get:function(){return di.stringify}});Object.defineProperty(Nt,"nil",{enumerable:!0,get:function(){return di.nil}});Object.defineProperty(Nt,"Name",{enumerable:!0,get:function(){return di.Name}});Object.defineProperty(Nt,"CodeGen",{enumerable:!0,get:function(){return di.CodeGen}});var hR=xl();Object.defineProperty(Nt,"ValidationError",{enumerable:!0,get:function(){return hR.default}});var fR=$a();Object.defineProperty(Nt,"MissingRefError",{enumerable:!0,get:function(){return fR.default}})});var ev=Pe(Zn=>{"use strict";Object.defineProperty(Zn,"__esModule",{value:!0});Zn.formatNames=Zn.fastFormats=Zn.fullFormats=void 0;function Ln(t,e){return{validate:t,compare:e}}Zn.fullFormats={date:Ln(Xy,$m),time:Ln(Sm(!0),Em),"date-time":Ln(Gy(!0),Jy),"iso-time":Ln(Sm(),Ky),"iso-date-time":Ln(Gy(),Qy),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:yR,"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:ER,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:vR,int32:{type:"number",validate:SR},int64:{type:"number",validate:kR},float:{type:"number",validate:Yy},double:{type:"number",validate:Yy},password:!0,binary:!0};Zn.fastFormats={...Zn.fullFormats,date:Ln(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,$m),time:Ln(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Em),"date-time":Ln(/^\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,Jy),"iso-time":Ln(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Ky),"iso-date-time":Ln(/^\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,Qy),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};Zn.formatNames=Object.keys(Zn.fullFormats);function pR(t){return t%4===0&&(t%100!==0||t%400===0)}var mR=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,gR=[0,31,28,31,30,31,30,31,31,30,31,30,31];function Xy(t){let e=mR.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&&pR(r)?29:gR[n])}function $m(t,e){if(t&&e)return t>e?1:t<e?-1:0}var xm=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Sm(t){return function(r){let n=xm.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,f=s-d*c-(u<0?1:0);return(f===23||f===-1)&&(u===59||u===-1)&&i<61}}function Em(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 Ky(t,e){if(!(t&&e))return;let r=xm.exec(t),n=xm.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 km=/t|\s/i;function Gy(t){let e=Sm(t);return function(n){let s=n.split(km);return s.length===2&&Xy(s[0])&&e(s[1])}}function Jy(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function Qy(t,e){if(!(t&&e))return;let[r,n]=t.split(km),[s,o]=e.split(km),i=$m(r,s);if(i!==void 0)return i||Em(n,o)}var _R=/\/|:/,bR=/^(?:[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 yR(t){return _R.test(t)&&bR.test(t)}var Wy=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function vR(t){return Wy.lastIndex=0,Wy.test(t)}var wR=-(2**31),xR=2**31-1;function SR(t){return Number.isInteger(t)&&t<=xR&&t>=wR}function kR(t){return Number.isInteger(t)}function Yy(){return!0}var $R=/[^\\]\\Z/;function ER(t){if($R.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var tv=Pe(hi=>{"use strict";Object.defineProperty(hi,"__esModule",{value:!0});hi.formatLimitDefinition=void 0;var TR=wm(),$n=ct(),ws=$n.operators,ql={formatMaximum:{okStr:"<=",ok:ws.LTE,fail:ws.GT},formatMinimum:{okStr:">=",ok:ws.GTE,fail:ws.LT},formatExclusiveMaximum:{okStr:"<",ok:ws.LT,fail:ws.GTE},formatExclusiveMinimum:{okStr:">",ok:ws.GT,fail:ws.LTE}},RR={message:({keyword:t,schemaCode:e})=>(0,$n.str)`should be ${ql[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,$n._)`{comparison: ${ql[t].okStr}, limit: ${e}}`};hi.formatLimitDefinition={keyword:Object.keys(ql),type:"string",schemaType:"string",$data:!0,error:RR,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 TR.KeywordCxt(o,a.RULES.all.format.definition,"format");c.$data?d():l();function d(){let f=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),p=e.const("fmt",(0,$n._)`${f}[${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 f=c.schema,p=a.formats[f];if(!p||p===!0)return;if(typeof p!="object"||p instanceof RegExp||typeof p.compare!="function")throw new Error(`"${s}": format "${f}" does not define "compare" function`);let m=e.scopeValue("formats",{key:f,ref:p,code:i.code.formats?(0,$n._)`${i.code.formats}${(0,$n.getProperty)(f)}`:void 0});t.fail$data(u(m))}function u(f){return(0,$n._)`${f}.compare(${r}, ${n}) ${ql[s].fail} 0`}},dependencies:["format"]};var IR=t=>(t.addKeyword(hi.formatLimitDefinition),t);hi.default=IR});var ov=Pe((La,sv)=>{"use strict";Object.defineProperty(La,"__esModule",{value:!0});var fi=ev(),PR=tv(),Tm=ct(),rv=new Tm.Name("fullFormats"),MR=new Tm.Name("fastFormats"),Rm=(t,e={keywords:!0})=>{if(Array.isArray(e))return nv(t,e,fi.fullFormats,rv),t;let[r,n]=e.mode==="fast"?[fi.fastFormats,MR]:[fi.fullFormats,rv],s=e.formats||fi.formatNames;return nv(t,s,r,n),e.keywords&&(0,PR.default)(t),t};Rm.get=(t,e="full")=>{let n=(e==="fast"?fi.fastFormats:fi.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function nv(t,e,r,n){var s,o;(s=(o=t.opts.code).formats)!==null&&s!==void 0||(o.formats=(0,Tm._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}sv.exports=La=Rm;Object.defineProperty(La,"__esModule",{value:!0});La.default=Rm});var J1=Pe((tH,D4)=>{"use strict";var X1="\x1B",Ht=`${X1}[`,aN="\x07",K1={to(t,e){return e?`${Ht}${e+1};${t+1}H`:`${Ht}${t+1}G`},move(t,e){let r="";return t<0?r+=`${Ht}${-t}D`:t>0&&(r+=`${Ht}${t}C`),e<0?r+=`${Ht}${-e}A`:e>0&&(r+=`${Ht}${e}B`),r},up:(t=1)=>`${Ht}${t}A`,down:(t=1)=>`${Ht}${t}B`,forward:(t=1)=>`${Ht}${t}C`,backward:(t=1)=>`${Ht}${t}D`,nextLine:(t=1)=>`${Ht}E`.repeat(t),prevLine:(t=1)=>`${Ht}F`.repeat(t),left:`${Ht}G`,hide:`${Ht}?25l`,show:`${Ht}?25h`,save:`${X1}7`,restore:`${X1}8`},cN={up:(t=1)=>`${Ht}S`.repeat(t),down:(t=1)=>`${Ht}T`.repeat(t)},lN={screen:`${Ht}2J`,up:(t=1)=>`${Ht}1J`.repeat(t),down:(t=1)=>`${Ht}J`.repeat(t),line:`${Ht}2K`,lineEnd:`${Ht}K`,lineStart:`${Ht}1K`,lines(t){let e="";for(let r=0;r<t;r++)e+=this.line+(r<t-1?K1.up():"");return t&&(e+=K1.left),e}};D4.exports={cursor:K1,scroll:cN,erase:lN,beep:aN}});var lx=Pe((TH,a0)=>{var Vu=process||{},ax=Vu.argv||[],Bu=Vu.env||{},NN=!(Bu.NO_COLOR||ax.includes("--no-color"))&&(!!Bu.FORCE_COLOR||ax.includes("--color")||Vu.platform==="win32"||(Vu.stdout||{}).isTTY&&Bu.TERM!=="dumb"||!!Bu.CI),CN=(t,e,r=t)=>n=>{let s=""+n,o=s.indexOf(e,t.length);return~o?t+jN(s,e,r,o)+e:t+s+e},jN=(t,e,r,n)=>{let s="",o=0;do s+=t.substring(o,n)+r,o=n+e.length,n=t.indexOf(e,o);while(~n);return s+t.substring(o)},cx=(t=NN)=>{let e=t?CN:()=>String;return{isColorSupported:t,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};a0.exports=cx();a0.exports.createColors=cx});var W={};ed(W,{BRAND:()=>r5,DIRTY:()=>Cs,EMPTY_PATH:()=>zx,INVALID:()=>Ye,NEVER:()=>L5,OK:()=>fr,ParseStatus:()=>ir,Schema:()=>at,ZodAny:()=>is,ZodArray:()=>Wn,ZodBigInt:()=>Ds,ZodBoolean:()=>Ls,ZodBranded:()=>Di,ZodCatch:()=>Xs,ZodDate:()=>Zs,ZodDefault:()=>Ys,ZodDiscriminatedUnion:()=>hc,ZodEffects:()=>Qr,ZodEnum:()=>Gs,ZodError:()=>Rr,ZodFirstPartyTypeKind:()=>ye,ZodFunction:()=>pc,ZodIntersection:()=>Fs,ZodIssueCode:()=>be,ZodLazy:()=>Hs,ZodLiteral:()=>Us,ZodMap:()=>Do,ZodNaN:()=>Zo,ZodNativeEnum:()=>Ws,ZodNever:()=>_n,ZodNull:()=>Vs,ZodNullable:()=>zn,ZodNumber:()=>js,ZodObject:()=>Pr,ZodOptional:()=>Ir,ZodParsedType:()=>ze,ZodPipeline:()=>Li,ZodPromise:()=>as,ZodReadonly:()=>Ks,ZodRecord:()=>fc,ZodSchema:()=>at,ZodSet:()=>Lo,ZodString:()=>os,ZodSymbol:()=>Co,ZodTransformer:()=>Qr,ZodTuple:()=>An,ZodType:()=>at,ZodUndefined:()=>Bs,ZodUnion:()=>qs,ZodUnknown:()=>Gn,ZodVoid:()=>jo,addIssueToContext:()=>Ee,any:()=>d5,array:()=>m5,bigint:()=>i5,boolean:()=>M0,coerce:()=>D5,custom:()=>R0,date:()=>a5,datetimeRegex:()=>E0,defaultErrorMap:()=>Hn,discriminatedUnion:()=>b5,effect:()=>P5,enum:()=>T5,function:()=>k5,getErrorMap:()=>Ao,getParsedType:()=>On,instanceof:()=>s5,intersection:()=>y5,isAborted:()=>uc,isAsync:()=>zo,isDirty:()=>dc,isValid:()=>ss,late:()=>n5,lazy:()=>$5,literal:()=>E5,makeIssue:()=>ji,map:()=>x5,nan:()=>o5,nativeEnum:()=>R5,never:()=>f5,null:()=>u5,nullable:()=>O5,number:()=>P0,object:()=>sd,objectUtil:()=>td,oboolean:()=>j5,onumber:()=>C5,optional:()=>M5,ostring:()=>N5,pipeline:()=>z5,preprocess:()=>A5,promise:()=>I5,quotelessJson:()=>Mx,record:()=>w5,set:()=>S5,setErrorMap:()=>Ax,strictObject:()=>g5,string:()=>I0,symbol:()=>c5,transformer:()=>P5,tuple:()=>v5,undefined:()=>l5,union:()=>_5,unknown:()=>h5,util:()=>dt,void:()=>p5});var dt;(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})(dt||(dt={}));var td;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(td||(td={}));var ze=dt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),On=t=>{switch(typeof t){case"undefined":return ze.undefined;case"string":return ze.string;case"number":return Number.isNaN(t)?ze.nan:ze.number;case"boolean":return ze.boolean;case"function":return ze.function;case"bigint":return ze.bigint;case"symbol":return ze.symbol;case"object":return Array.isArray(t)?ze.array:t===null?ze.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?ze.promise:typeof Map<"u"&&t instanceof Map?ze.map:typeof Set<"u"&&t instanceof Set?ze.set:typeof Date<"u"&&t instanceof Date?ze.date:ze.object;default:return ze.unknown}};var be=dt.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"]),Mx=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Rr=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,dt.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()}};Rr.create=t=>new Rr(t);var Ox=(t,e)=>{let r;switch(t.code){case be.invalid_type:t.received===ze.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case be.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,dt.jsonStringifyReplacer)}`;break;case be.unrecognized_keys:r=`Unrecognized key(s) in object: ${dt.joinValues(t.keys,", ")}`;break;case be.invalid_union:r="Invalid input";break;case be.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${dt.joinValues(t.options)}`;break;case be.invalid_enum_value:r=`Invalid enum value. Expected ${dt.joinValues(t.options)}, received '${t.received}'`;break;case be.invalid_arguments:r="Invalid function arguments";break;case be.invalid_return_type:r="Invalid function return type";break;case be.invalid_date:r="Invalid date";break;case be.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}"`:dt.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case be.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 be.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 be.custom:r="Invalid input";break;case be.invalid_intersection_types:r="Intersection results could not be merged";break;case be.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case be.not_finite:r="Number must be finite";break;default:r=e.defaultError,dt.assertNever(t)}return{message:r}},Hn=Ox;var w0=Hn;function Ax(t){w0=t}function Ao(){return w0}var ji=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}},zx=[];function Ee(t,e){let r=Ao(),n=ji({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Hn?void 0:Hn].filter(s=>!!s)});t.common.issues.push(n)}var ir=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"}),Cs=t=>({status:"dirty",value:t}),fr=t=>({status:"valid",value:t}),uc=t=>t.status==="aborted",dc=t=>t.status==="dirty",ss=t=>t.status==="valid",zo=t=>typeof Promise<"u"&&t instanceof Promise;var Ze;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Ze||(Ze={}));var Jr=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}},x0=(t,e)=>{if(ss(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 Rr(t.common.issues);return this._error=r,this._error}}};function ot(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 at=class{get description(){return this._def.description}_getType(e){return On(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:On(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ir,ctx:{common:e.parent.common,data:e.data,parsedType:On(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(zo(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:On(e)},s=this._parseSync({data:e,path:n.path,parent:n});return x0(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:On(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return ss(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=>ss(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:On(e)},s=this._parse({data:e,path:n.path,parent:n}),o=await(zo(s)?s:Promise.resolve(s));return x0(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:be.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 Qr({schema:this,typeName:ye.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 Ir.create(this,this._def)}nullable(){return zn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Wn.create(this)}promise(){return as.create(this,this._def)}or(e){return qs.create([this,e],this._def)}and(e){return Fs.create(this,e,this._def)}transform(e){return new Qr({...ot(this._def),schema:this,typeName:ye.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Ys({...ot(this._def),innerType:this,defaultValue:r,typeName:ye.ZodDefault})}brand(){return new Di({typeName:ye.ZodBranded,type:this,...ot(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new Xs({...ot(this._def),innerType:this,catchValue:r,typeName:ye.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Li.create(this,e)}readonly(){return Ks.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Nx=/^c[^\s-]{8,}$/i,Cx=/^[0-9a-z]+$/,jx=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Dx=/^[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,Lx=/^[a-z0-9_-]{21}$/i,Zx=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Bx=/^[-+]?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)?)??$/,Vx=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,qx="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",rd,Fx=/^(?:(?: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])$/,Hx=/^(?:(?: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])$/,Ux=/^(([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]))$/,Gx=/^(([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])$/,Wx=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Yx=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,k0="((\\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])))",Xx=new RegExp(`^${k0}$`);function $0(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 Kx(t){return new RegExp(`^${$0(t)}$`)}function E0(t){let e=`${k0}T${$0(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 Jx(t,e){return!!((e==="v4"||!e)&&Fx.test(t)||(e==="v6"||!e)&&Ux.test(t))}function Qx(t,e){if(!Zx.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 e5(t,e){return!!((e==="v4"||!e)&&Hx.test(t)||(e==="v6"||!e)&&Gx.test(t))}var os=class t extends at{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ze.string){let o=this._getOrReturnCtx(e);return Ee(o,{code:be.invalid_type,expected:ze.string,received:o.parsedType}),Ye}let n=new ir,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:be.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:be.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:be.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&Ee(s,{code:be.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")Vx.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"email",code:be.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")rd||(rd=new RegExp(qx,"u")),rd.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"emoji",code:be.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")Dx.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"uuid",code:be.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")Lx.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"nanoid",code:be.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")Nx.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"cuid",code:be.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")Cx.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"cuid2",code:be.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")jx.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"ulid",code:be.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:be.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:be.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:be.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:be.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:be.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?E0(o).test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{code:be.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?Xx.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{code:be.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?Kx(o).test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{code:be.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?Bx.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"duration",code:be.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?Jx(e.data,o.version)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"ip",code:be.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?Qx(e.data,o.alg)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"jwt",code:be.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?e5(e.data,o.version)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"cidr",code:be.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?Wx.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"base64",code:be.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?Yx.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"base64url",code:be.invalid_string,message:o.message}),n.dirty()):dt.assertNever(o);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:be.invalid_string,...Ze.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Ze.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ze.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Ze.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ze.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Ze.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ze.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Ze.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Ze.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Ze.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Ze.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Ze.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Ze.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Ze.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,...Ze.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,...Ze.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Ze.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Ze.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...Ze.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Ze.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Ze.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Ze.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Ze.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Ze.errToObj(r)})}nonempty(e){return this.min(1,Ze.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}};os.create=t=>new os({checks:[],typeName:ye.ZodString,coerce:t?.coerce??!1,...ot(t)});function t5(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 js=class t extends at{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)!==ze.number){let o=this._getOrReturnCtx(e);return Ee(o,{code:be.invalid_type,expected:ze.number,received:o.parsedType}),Ye}let n,s=new ir;for(let o of this._def.checks)o.kind==="int"?dt.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),Ee(n,{code:be.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:be.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:be.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),s.dirty()):o.kind==="multipleOf"?t5(e.data,o.value)!==0&&(n=this._getOrReturnCtx(e,n),Ee(n,{code:be.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:be.not_finite,message:o.message}),s.dirty()):dt.assertNever(o);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Ze.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Ze.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Ze.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Ze.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Ze.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Ze.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ze.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ze.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ze.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ze.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Ze.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Ze.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ze.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ze.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"&&dt.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)}};js.create=t=>new js({checks:[],typeName:ye.ZodNumber,coerce:t?.coerce||!1,...ot(t)});var Ds=class t extends at{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)!==ze.bigint)return this._getInvalidInput(e);let n,s=new ir;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:be.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:be.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:be.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):dt.assertNever(o);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return Ee(r,{code:be.invalid_type,expected:ze.bigint,received:r.parsedType}),Ye}gte(e,r){return this.setLimit("min",e,!0,Ze.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Ze.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Ze.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Ze.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Ze.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:Ze.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ze.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ze.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ze.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Ze.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}};Ds.create=t=>new Ds({checks:[],typeName:ye.ZodBigInt,coerce:t?.coerce??!1,...ot(t)});var Ls=class extends at{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ze.boolean){let n=this._getOrReturnCtx(e);return Ee(n,{code:be.invalid_type,expected:ze.boolean,received:n.parsedType}),Ye}return fr(e.data)}};Ls.create=t=>new Ls({typeName:ye.ZodBoolean,coerce:t?.coerce||!1,...ot(t)});var Zs=class t extends at{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ze.date){let o=this._getOrReturnCtx(e);return Ee(o,{code:be.invalid_type,expected:ze.date,received:o.parsedType}),Ye}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return Ee(o,{code:be.invalid_date}),Ye}let n=new ir,s;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(s=this._getOrReturnCtx(e,s),Ee(s,{code:be.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:be.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):dt.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:Ze.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Ze.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}};Zs.create=t=>new Zs({checks:[],coerce:t?.coerce||!1,typeName:ye.ZodDate,...ot(t)});var Co=class extends at{_parse(e){if(this._getType(e)!==ze.symbol){let n=this._getOrReturnCtx(e);return Ee(n,{code:be.invalid_type,expected:ze.symbol,received:n.parsedType}),Ye}return fr(e.data)}};Co.create=t=>new Co({typeName:ye.ZodSymbol,...ot(t)});var Bs=class extends at{_parse(e){if(this._getType(e)!==ze.undefined){let n=this._getOrReturnCtx(e);return Ee(n,{code:be.invalid_type,expected:ze.undefined,received:n.parsedType}),Ye}return fr(e.data)}};Bs.create=t=>new Bs({typeName:ye.ZodUndefined,...ot(t)});var Vs=class extends at{_parse(e){if(this._getType(e)!==ze.null){let n=this._getOrReturnCtx(e);return Ee(n,{code:be.invalid_type,expected:ze.null,received:n.parsedType}),Ye}return fr(e.data)}};Vs.create=t=>new Vs({typeName:ye.ZodNull,...ot(t)});var is=class extends at{constructor(){super(...arguments),this._any=!0}_parse(e){return fr(e.data)}};is.create=t=>new is({typeName:ye.ZodAny,...ot(t)});var Gn=class extends at{constructor(){super(...arguments),this._unknown=!0}_parse(e){return fr(e.data)}};Gn.create=t=>new Gn({typeName:ye.ZodUnknown,...ot(t)});var _n=class extends at{_parse(e){let r=this._getOrReturnCtx(e);return Ee(r,{code:be.invalid_type,expected:ze.never,received:r.parsedType}),Ye}};_n.create=t=>new _n({typeName:ye.ZodNever,...ot(t)});var jo=class extends at{_parse(e){if(this._getType(e)!==ze.undefined){let n=this._getOrReturnCtx(e);return Ee(n,{code:be.invalid_type,expected:ze.void,received:n.parsedType}),Ye}return fr(e.data)}};jo.create=t=>new jo({typeName:ye.ZodVoid,...ot(t)});var Wn=class t extends at{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==ze.array)return Ee(r,{code:be.invalid_type,expected:ze.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?be.too_big:be.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:be.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:be.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 Jr(r,i,r.path,a)))).then(i=>ir.mergeArray(n,i));let o=[...r.data].map((i,a)=>s.type._parseSync(new Jr(r,i,r.path,a)));return ir.mergeArray(n,o)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:Ze.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:Ze.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:Ze.toString(r)}})}nonempty(e){return this.min(1,e)}};Wn.create=(t,e)=>new Wn({type:t,minLength:null,maxLength:null,exactLength:null,typeName:ye.ZodArray,...ot(e)});function No(t){if(t instanceof Pr){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=Ir.create(No(n))}return new Pr({...t._def,shape:()=>e})}else return t instanceof Wn?new Wn({...t._def,type:No(t.element)}):t instanceof Ir?Ir.create(No(t.unwrap())):t instanceof zn?zn.create(No(t.unwrap())):t instanceof An?An.create(t.items.map(e=>No(e))):t}var Pr=class t extends at{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=dt.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==ze.object){let d=this._getOrReturnCtx(e);return Ee(d,{code:be.invalid_type,expected:ze.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 _n&&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 Jr(s,u,s.path,d)),alwaysSet:d in s.data})}if(this._def.catchall instanceof _n){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:be.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 Jr(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,f=await l.value;d.push({key:u,value:f,alwaysSet:l.alwaysSet})}return d}).then(d=>ir.mergeObjectSync(n,d)):ir.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return Ze.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:Ze.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:ye.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 dt.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 dt.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return No(this)}partial(e){let r={};for(let n of dt.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 dt.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof Ir;)o=o._def.innerType;r[n]=o}return new t({...this._def,shape:()=>r})}keyof(){return T0(dt.objectKeys(this.shape))}};Pr.create=(t,e)=>new Pr({shape:()=>t,unknownKeys:"strip",catchall:_n.create(),typeName:ye.ZodObject,...ot(e)});Pr.strictCreate=(t,e)=>new Pr({shape:()=>t,unknownKeys:"strict",catchall:_n.create(),typeName:ye.ZodObject,...ot(e)});Pr.lazycreate=(t,e)=>new Pr({shape:t,unknownKeys:"strip",catchall:_n.create(),typeName:ye.ZodObject,...ot(e)});var qs=class extends at{_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 Rr(a.ctx.common.issues));return Ee(r,{code:be.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 Rr(c));return Ee(r,{code:be.invalid_union,unionErrors:a}),Ye}}get options(){return this._def.options}};qs.create=(t,e)=>new qs({options:t,typeName:ye.ZodUnion,...ot(e)});var Un=t=>t instanceof Hs?Un(t.schema):t instanceof Qr?Un(t.innerType()):t instanceof Us?[t.value]:t instanceof Gs?t.options:t instanceof Ws?dt.objectValues(t.enum):t instanceof Ys?Un(t._def.innerType):t instanceof Bs?[void 0]:t instanceof Vs?[null]:t instanceof Ir?[void 0,...Un(t.unwrap())]:t instanceof zn?[null,...Un(t.unwrap())]:t instanceof Di||t instanceof Ks?Un(t.unwrap()):t instanceof Xs?Un(t._def.innerType):[],hc=class t extends at{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==ze.object)return Ee(r,{code:be.invalid_type,expected:ze.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:be.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=Un(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:ye.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...ot(n)})}};function nd(t,e){let r=On(t),n=On(e);if(t===e)return{valid:!0,data:t};if(r===ze.object&&n===ze.object){let s=dt.objectKeys(e),o=dt.objectKeys(t).filter(a=>s.indexOf(a)!==-1),i={...t,...e};for(let a of o){let c=nd(t[a],e[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(r===ze.array&&n===ze.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=nd(i,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===ze.date&&n===ze.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Fs=class extends at{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(o,i)=>{if(uc(o)||uc(i))return Ye;let a=nd(o.value,i.value);return a.valid?((dc(o)||dc(i))&&r.dirty(),{status:r.value,value:a.data}):(Ee(n,{code:be.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}))}};Fs.create=(t,e,r)=>new Fs({left:t,right:e,typeName:ye.ZodIntersection,...ot(r)});var An=class t extends at{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==ze.array)return Ee(n,{code:be.invalid_type,expected:ze.array,received:n.parsedType}),Ye;if(n.data.length<this._def.items.length)return Ee(n,{code:be.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:be.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 Jr(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(o).then(i=>ir.mergeArray(r,i)):ir.mergeArray(r,o)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};An.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new An({items:t,typeName:ye.ZodTuple,rest:null,...ot(e)})};var fc=class t extends at{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!==ze.object)return Ee(n,{code:be.invalid_type,expected:ze.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 Jr(n,a,n.path,a)),value:i._parse(new Jr(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?ir.mergeObjectAsync(r,s):ir.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof at?new t({keyType:e,valueType:r,typeName:ye.ZodRecord,...ot(n)}):new t({keyType:os.create(),valueType:e,typeName:ye.ZodRecord,...ot(r)})}},Do=class extends at{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!==ze.map)return Ee(n,{code:be.invalid_type,expected:ze.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 Jr(n,a,n.path,[d,"key"])),value:o._parse(new Jr(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}}}};Do.create=(t,e,r)=>new Do({valueType:e,keyType:t,typeName:ye.ZodMap,...ot(r)});var Lo=class t extends at{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==ze.set)return Ee(n,{code:be.invalid_type,expected:ze.set,received:n.parsedType}),Ye;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(Ee(n,{code:be.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:be.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 Jr(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:Ze.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:Ze.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Lo.create=(t,e)=>new Lo({valueType:t,minSize:null,maxSize:null,typeName:ye.ZodSet,...ot(e)});var pc=class t extends at{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==ze.function)return Ee(r,{code:be.invalid_type,expected:ze.function,received:r.parsedType}),Ye;function n(a,c){return ji({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ao(),Hn].filter(d=>!!d),issueData:{code:be.invalid_arguments,argumentsError:c}})}function s(a,c){return ji({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ao(),Hn].filter(d=>!!d),issueData:{code:be.invalid_return_type,returnTypeError:c}})}let o={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof as){let a=this;return fr(async function(...c){let d=new Rr([]),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 fr(function(...c){let d=a._def.args.safeParse(c,o);if(!d.success)throw new Rr([n(c,d.error)]);let l=Reflect.apply(i,this,d.data),u=a._def.returns.safeParse(l,o);if(!u.success)throw new Rr([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:An.create(e).rest(Gn.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||An.create([]).rest(Gn.create()),returns:r||Gn.create(),typeName:ye.ZodFunction,...ot(n)})}},Hs=class extends at{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})}};Hs.create=(t,e)=>new Hs({getter:t,typeName:ye.ZodLazy,...ot(e)});var Us=class extends at{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return Ee(r,{received:r.data,code:be.invalid_literal,expected:this._def.value}),Ye}return{status:"valid",value:e.data}}get value(){return this._def.value}};Us.create=(t,e)=>new Us({value:t,typeName:ye.ZodLiteral,...ot(e)});function T0(t,e){return new Gs({values:t,typeName:ye.ZodEnum,...ot(e)})}var Gs=class t extends at{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return Ee(r,{expected:dt.joinValues(n),received:r.parsedType,code:be.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:be.invalid_enum_value,options:n}),Ye}return fr(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})}};Gs.create=T0;var Ws=class extends at{_parse(e){let r=dt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==ze.string&&n.parsedType!==ze.number){let s=dt.objectValues(r);return Ee(n,{expected:dt.joinValues(s),received:n.parsedType,code:be.invalid_type}),Ye}if(this._cache||(this._cache=new Set(dt.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=dt.objectValues(r);return Ee(n,{received:n.data,code:be.invalid_enum_value,options:s}),Ye}return fr(e.data)}get enum(){return this._def.values}};Ws.create=(t,e)=>new Ws({values:t,typeName:ye.ZodNativeEnum,...ot(e)});var as=class extends at{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==ze.promise&&r.common.async===!1)return Ee(r,{code:be.invalid_type,expected:ze.promise,received:r.parsedType}),Ye;let n=r.parsedType===ze.promise?r.data:Promise.resolve(r.data);return fr(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};as.create=(t,e)=>new as({type:t,typeName:ye.ZodPromise,...ot(e)});var Qr=class extends at{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ye.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"?Cs(c.value):r.value==="dirty"?Cs(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"?Cs(a.value):r.value==="dirty"?Cs(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(!ss(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=>ss(i)?Promise.resolve(s.transform(i.value,o)).then(a=>({status:r.value,value:a})):Ye);dt.assertNever(s)}};Qr.create=(t,e,r)=>new Qr({schema:t,typeName:ye.ZodEffects,effect:e,...ot(r)});Qr.createWithPreprocess=(t,e,r)=>new Qr({schema:e,effect:{type:"preprocess",transform:t},typeName:ye.ZodEffects,...ot(r)});var Ir=class extends at{_parse(e){return this._getType(e)===ze.undefined?fr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ir.create=(t,e)=>new Ir({innerType:t,typeName:ye.ZodOptional,...ot(e)});var zn=class extends at{_parse(e){return this._getType(e)===ze.null?fr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};zn.create=(t,e)=>new zn({innerType:t,typeName:ye.ZodNullable,...ot(e)});var Ys=class extends at{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===ze.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Ys.create=(t,e)=>new Ys({innerType:t,typeName:ye.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ot(e)});var Xs=class extends at{_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 zo(s)?s.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Rr(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Rr(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Xs.create=(t,e)=>new Xs({innerType:t,typeName:ye.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ot(e)});var Zo=class extends at{_parse(e){if(this._getType(e)!==ze.nan){let n=this._getOrReturnCtx(e);return Ee(n,{code:be.invalid_type,expected:ze.nan,received:n.parsedType}),Ye}return{status:"valid",value:e.data}}};Zo.create=t=>new Zo({typeName:ye.ZodNaN,...ot(t)});var r5=Symbol("zod_brand"),Di=class extends at{_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}},Li=class t extends at{_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(),Cs(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:ye.ZodPipeline})}},Ks=class extends at{_parse(e){let r=this._def.innerType._parse(e),n=s=>(ss(s)&&(s.value=Object.freeze(s.value)),s);return zo(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};Ks.create=(t,e)=>new Ks({innerType:t,typeName:ye.ZodReadonly,...ot(e)});function S0(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function R0(t,e={},r){return t?is.create().superRefine((n,s)=>{let o=t(n);if(o instanceof Promise)return o.then(i=>{if(!i){let a=S0(e,n),c=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!o){let i=S0(e,n),a=i.fatal??r??!0;s.addIssue({code:"custom",...i,fatal:a})}}):is.create()}var n5={object:Pr.lazycreate},ye;(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"})(ye||(ye={}));var s5=(t,e={message:`Input not instance of ${t.name}`})=>R0(r=>r instanceof t,e),I0=os.create,P0=js.create,o5=Zo.create,i5=Ds.create,M0=Ls.create,a5=Zs.create,c5=Co.create,l5=Bs.create,u5=Vs.create,d5=is.create,h5=Gn.create,f5=_n.create,p5=jo.create,m5=Wn.create,sd=Pr.create,g5=Pr.strictCreate,_5=qs.create,b5=hc.create,y5=Fs.create,v5=An.create,w5=fc.create,x5=Do.create,S5=Lo.create,k5=pc.create,$5=Hs.create,E5=Us.create,T5=Gs.create,R5=Ws.create,I5=as.create,P5=Qr.create,M5=Ir.create,O5=zn.create,A5=Qr.createWithPreprocess,z5=Li.create,N5=()=>I0().optional(),C5=()=>P0().optional(),j5=()=>M0().optional(),D5={string:t=>os.create({...t,coerce:!0}),number:t=>js.create({...t,coerce:!0}),boolean:t=>Ls.create({...t,coerce:!0}),bigint:t=>Ds.create({...t,coerce:!0}),date:t=>Zs.create({...t,coerce:!0})};var L5=Ye;var Z5=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 B5=Symbol("zod_brand"),Yn=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},mc={};function qr(t){return t&&Object.assign(mc,t),mc}var ht={};ed(ht,{BIGINT_FORMAT_RANGES:()=>A0,Class:()=>id,NUMBER_FORMAT_RANGES:()=>fd,aborted:()=>Qs,allowsEval:()=>ud,assert:()=>U5,assertEqual:()=>V5,assertIs:()=>F5,assertNever:()=>H5,assertNotEqual:()=>q5,assignProp:()=>ld,cached:()=>Vi,captureStackTrace:()=>_c,cleanEnum:()=>oS,cleanRegex:()=>Fi,clone:()=>Fr,createTransparentProxy:()=>J5,defineLazy:()=>Pt,esc:()=>Js,escapeRegex:()=>cs,extend:()=>tS,finalizeIssue:()=>bn,floatSafeRemainder:()=>cd,getElementAtPath:()=>G5,getEnumValues:()=>Bi,getLengthableOrigin:()=>Hi,getParsedType:()=>K5,getSizableOrigin:()=>z0,isObject:()=>Bo,isPlainObject:()=>Vo,issue:()=>pd,joinValues:()=>gc,jsonStringifyReplacer:()=>ad,merge:()=>rS,normalizeParams:()=>Xe,nullish:()=>qi,numKeys:()=>X5,omit:()=>eS,optionalKeys:()=>hd,partial:()=>nS,pick:()=>Q5,prefixIssues:()=>Nn,primitiveTypes:()=>O0,promiseAllObject:()=>W5,propertyKeyTypes:()=>dd,randomString:()=>Y5,required:()=>sS,stringifyPrimitive:()=>bc,unwrapMessage:()=>Zi});function V5(t){return t}function q5(t){return t}function F5(t){}function H5(t){throw new Error}function U5(t){}function Bi(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 gc(t,e="|"){return t.map(r=>bc(r)).join(e)}function ad(t,e){return typeof e=="bigint"?e.toString():e}function Vi(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function qi(t){return t==null}function Fi(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function cd(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 Pt(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 ld(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function G5(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function W5(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 Y5(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function Js(t){return JSON.stringify(t)}var _c=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function Bo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var ud=Vi(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function Vo(t){if(Bo(t)===!1)return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(Bo(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function X5(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var K5=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}`)}},dd=new Set(["string","number","symbol"]),O0=new Set(["string","number","bigint","boolean","symbol","undefined"]);function cs(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Fr(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 J5(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 bc(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function hd(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var fd={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]},A0={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Q5(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 Fr(t,{...t._zod.def,shape:r,checks:[]})}function eS(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 Fr(t,{...t._zod.def,shape:r,checks:[]})}function tS(t,e){if(!Vo(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 ld(this,"shape",n),n},checks:[]};return Fr(t,r)}function rS(t,e){return Fr(t,{...t._zod.def,get shape(){let r={...t._zod.def.shape,...e._zod.def.shape};return ld(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}function nS(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 Fr(e,{...e._zod.def,shape:s,checks:[]})}function sS(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 Fr(e,{...e._zod.def,shape:s,checks:[]})}function Qs(t,e=0){for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function Nn(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Zi(t){return typeof t=="string"?t:t?.message}function bn(t,e,r){let n={...t,path:t.path??[]};if(!t.message){let s=Zi(t.inst?._zod.def?.error?.(t))??Zi(e?.error?.(t))??Zi(r.customError?.(t))??Zi(r.localeError?.(t))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function z0(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Hi(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function pd(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function oS(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}var id=class{constructor(...e){}};var N0=(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,ad,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},yc=le("$ZodError",N0),Ui=le("$ZodError",N0,{Parent:Error});function md(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 gd(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 _d=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 Yn;if(i.issues.length){let a=new(s?.Err??t)(i.issues.map(c=>bn(c,o,qr())));throw _c(a,s?.callee),a}return i.value},bd=_d(Ui),yd=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=>bn(c,o,qr())));throw _c(a,s?.callee),a}return i.value},vd=yd(Ui),wd=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 Yn;return o.issues.length?{success:!1,error:new(t??yc)(o.issues.map(i=>bn(i,s,qr())))}:{success:!0,data:o.value}},eo=wd(Ui),xd=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=>bn(i,s,qr())))}:{success:!0,data:o.value}},to=xd(Ui);var C0=/^[cC][^\s-]{8,}$/,j0=/^[0-9a-z]+$/,D0=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,L0=/^[0-9a-vA-V]{20}$/,Z0=/^[A-Za-z0-9]{27}$/,B0=/^[a-zA-Z0-9_-]{21}$/,V0=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var q0=/^([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})$/,Sd=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 F0=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var aS="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function H0(){return new RegExp(aS,"u")}var U0=/^(?:(?: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])$/,G0=/^(([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})$/,W0=/^((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])$/,Y0=/^(([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])$/,X0=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,kd=/^[A-Za-z0-9_-]*$/,K0=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var J0=/^\+(?:[0-9]){6,14}[0-9]$/,Q0="(?:(?:\\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])))",eg=new RegExp(`^${Q0}$`);function tg(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 rg(t){return new RegExp(`^${tg(t)}$`)}function ng(t){let e=tg({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(`^${Q0}T(?:${n})$`)}var sg=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)};var og=/^\d+$/,ig=/^-?\d+(?:\.\d+)?/i,ag=/true|false/i,cg=/null/i;var lg=/^[^A-Z]*$/,ug=/^[^a-z]*$/;var ar=le("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),dg={number:"number",bigint:"bigint",object:"date"},$d=le("$ZodCheckLessThan",(t,e)=>{ar.init(t,e);let r=dg[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})}}),Ed=le("$ZodCheckGreaterThan",(t,e)=>{ar.init(t,e);let r=dg[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})}}),hg=le("$ZodCheckMultipleOf",(t,e)=>{ar.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):cd(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})}}),fg=le("$ZodCheckNumberFormat",(t,e)=>{ar.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[s,o]=fd[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=og)}),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 pg=le("$ZodCheckMaxLength",(t,e)=>{var r;ar.init(t,e),(r=t._zod.def).when??(r.when=n=>{let s=n.value;return!qi(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=Hi(s);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),mg=le("$ZodCheckMinLength",(t,e)=>{var r;ar.init(t,e),(r=t._zod.def).when??(r.when=n=>{let s=n.value;return!qi(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=Hi(s);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),gg=le("$ZodCheckLengthEquals",(t,e)=>{var r;ar.init(t,e),(r=t._zod.def).when??(r.when=n=>{let s=n.value;return!qi(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=Hi(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})}}),Gi=le("$ZodCheckStringFormat",(t,e)=>{var r,n;ar.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=()=>{})}),_g=le("$ZodCheckRegex",(t,e)=>{Gi.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})}}),bg=le("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=lg),Gi.init(t,e)}),yg=le("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=ug),Gi.init(t,e)}),vg=le("$ZodCheckIncludes",(t,e)=>{ar.init(t,e);let r=cs(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})}}),wg=le("$ZodCheckStartsWith",(t,e)=>{ar.init(t,e);let r=new RegExp(`^${cs(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})}}),xg=le("$ZodCheckEndsWith",(t,e)=>{ar.init(t,e);let r=new RegExp(`.*${cs(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 Sg=le("$ZodCheckOverwrite",(t,e)=>{ar.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});var wc=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(`
|
|
9
|
+
deps: ${r}}`};var oT={keyword:"dependencies",type:"object",schemaType:"object",error:Dn.error,code(t){let[e,r]=iT(t);my(t,e),gy(t,r)}};function iT({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 my(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,ja.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,ja.checkReportMissingProp)(t,d)}):(r.if((0,tm._)`${c} && (${(0,ja.checkMissingProp)(t,a,o)})`),(0,ja.reportMissingProp)(t,o),r.else())}}Dn.validatePropertyDeps=my;function gy(t,e=t.schema){let{gen:r,data:n,keyword:s,it:o}=t,i=r.name("valid");for(let a in e)(0,sT.alwaysValidSchema)(o,e[a])||(r.if((0,ja.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))}Dn.validateSchemaDeps=gy;Dn.default=oT});var yy=Me(rm=>{"use strict";Object.defineProperty(rm,"__esModule",{value:!0});var by=ct(),aT=_t(),cT={message:"property name must be valid",params:({params:t})=>(0,by._)`{propertyName: ${t.propertyName}}`},lT={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:cT,code(t){let{gen:e,schema:r,data:n,it:s}=t;if((0,aT.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,by.not)(o),()=>{t.error(!0),s.allErrors||e.break()})}),t.ok(o)}};rm.default=lT});var sm=Me(nm=>{"use strict";Object.defineProperty(nm,"__esModule",{value:!0});var Nl=sn(),kn=ct(),uT=Jn(),Cl=_t(),dT={message:"must NOT have additional properties",params:({params:t})=>(0,kn._)`{additionalProperty: ${t.additionalProperty}}`},hT={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:dT,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,Cl.alwaysValidSchema)(i,r))return;let d=(0,Nl.allSchemaProperties)(n.properties),l=(0,Nl.allSchemaProperties)(n.patternProperties);u(),t.ok((0,kn._)`${o} === ${uT.default.errors}`);function u(){e.forIn("key",s,k=>{!d.length&&!l.length?m(k):e.if(f(k),()=>m(k))})}function f(k){let x;if(d.length>8){let _=(0,Cl.schemaRefOrVal)(i,n.properties,"properties");x=(0,Nl.isOwnProperty)(e,_,k)}else d.length?x=(0,kn.or)(...d.map(_=>(0,kn._)`${k} === ${_}`)):x=kn.nil;return l.length&&(x=(0,kn.or)(x,...l.map(_=>(0,kn._)`${(0,Nl.usePattern)(t,_)}.test(${k})`))),(0,kn.not)(x)}function p(k){e.code((0,kn._)`delete ${s}[${k}]`)}function m(k){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(k);return}if(r===!1){t.setParams({additionalProperty:k}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,Cl.alwaysValidSchema)(i,r)){let x=e.name("valid");c.removeAdditional==="failing"?(y(k,x,!1),e.if((0,kn.not)(x),()=>{t.reset(),p(k)})):(y(k,x),a||e.if((0,kn.not)(x),()=>e.break()))}}function y(k,x,_){let g={keyword:"additionalProperties",dataProp:k,dataPropType:Cl.Type.Str};_===!1&&Object.assign(g,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(g,x)}}};nm.default=hT});var xy=Me(im=>{"use strict";Object.defineProperty(im,"__esModule",{value:!0});var fT=Sa(),vy=sn(),om=_t(),wy=sm(),pT={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&&wy.default.code(new fT.KeywordCxt(o,wy.default,"additionalProperties"));let i=(0,vy.allSchemaProperties)(r);for(let u of i)o.definedProperties.add(u);o.opts.unevaluated&&i.length&&o.props!==!0&&(o.props=om.mergeEvaluated.props(e,(0,om.toHash)(i),o.props));let a=i.filter(u=>!(0,om.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,vy.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)}}};im.default=pT});var Ey=Me(am=>{"use strict";Object.defineProperty(am,"__esModule",{value:!0});var Sy=sn(),jl=ct(),ky=_t(),$y=_t(),mT={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,Sy.allSchemaProperties)(r),c=a.filter(y=>(0,ky.alwaysValidSchema)(o,r[y]));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 jl.Name)&&(o.props=(0,$y.evaluatedPropsToName)(e,o.props));let{props:u}=o;f();function f(){for(let y of a)d&&p(y),o.allErrors?m(y):(e.var(l,!0),m(y),e.if(l))}function p(y){for(let k in d)new RegExp(y).test(k)&&(0,ky.checkStrictMode)(o,`property ${k} matches pattern ${y} (use allowMatchingProperties)`)}function m(y){e.forIn("key",n,k=>{e.if((0,jl._)`${(0,Sy.usePattern)(t,y)}.test(${k})`,()=>{let x=c.includes(y);x||t.subschema({keyword:"patternProperties",schemaProp:y,dataProp:k,dataPropType:$y.Type.Str},l),o.opts.unevaluated&&u!==!0?e.assign((0,jl._)`${u}[${k}]`,!0):!x&&!o.allErrors&&e.if((0,jl.not)(l),()=>e.break())})})}}};am.default=mT});var Ty=Me(cm=>{"use strict";Object.defineProperty(cm,"__esModule",{value:!0});var gT=_t(),_T={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,gT.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"}};cm.default=_T});var Ry=Me(lm=>{"use strict";Object.defineProperty(lm,"__esModule",{value:!0});var bT=sn(),yT={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:bT.validateUnion,error:{message:"must match a schema in anyOf"}};lm.default=yT});var Py=Me(um=>{"use strict";Object.defineProperty(um,"__esModule",{value:!0});var Dl=ct(),vT=_t(),wT={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Dl._)`{passingSchemas: ${t.passing}}`},xT={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:wT,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 f;(0,vT.alwaysValidSchema)(s,l)?e.var(c,!0):f=t.subschema({keyword:"oneOf",schemaProp:u,compositeRule:!0},c),u>0&&e.if((0,Dl._)`${c} && ${i}`).assign(i,!1).assign(a,(0,Dl._)`[${a}, ${u}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,u),f&&t.mergeEvaluated(f,Dl.Name)})})}}};um.default=xT});var My=Me(dm=>{"use strict";Object.defineProperty(dm,"__esModule",{value:!0});var ST=_t(),kT={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,ST.alwaysValidSchema)(n,o))return;let a=t.subschema({keyword:"allOf",schemaProp:i},s);t.ok(s),t.mergeEvaluated(a)})}};dm.default=kT});var Ay=Me(hm=>{"use strict";Object.defineProperty(hm,"__esModule",{value:!0});var Ll=ct(),zy=_t(),$T={message:({params:t})=>(0,Ll.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,Ll._)`{failingKeyword: ${t.ifClause}}`},ET={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:$T,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,zy.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let s=Iy(n,"then"),o=Iy(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,Ll.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 f=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(f,i),u?e.assign(u,(0,Ll._)`${l}`):t.setParams({ifClause:l})}}}};function Iy(t,e){let r=t.schema[e];return r!==void 0&&!(0,zy.alwaysValidSchema)(t,r)}hm.default=ET});var Oy=Me(fm=>{"use strict";Object.defineProperty(fm,"__esModule",{value:!0});var TT=_t(),RT={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,TT.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};fm.default=RT});var Ny=Me(pm=>{"use strict";Object.defineProperty(pm,"__esModule",{value:!0});var PT=Xp(),MT=dy(),IT=Kp(),zT=fy(),AT=py(),OT=_y(),NT=yy(),CT=sm(),jT=xy(),DT=Ey(),LT=Ty(),ZT=Ry(),BT=Py(),VT=My(),qT=Ay(),FT=Oy();function UT(t=!1){let e=[LT.default,ZT.default,BT.default,VT.default,qT.default,FT.default,NT.default,CT.default,OT.default,jT.default,DT.default];return t?e.push(MT.default,zT.default):e.push(PT.default,IT.default),e.push(AT.default),e}pm.default=UT});var Cy=Me(mm=>{"use strict";Object.defineProperty(mm,"__esModule",{value:!0});var Yt=ct(),HT={message:({schemaCode:t})=>(0,Yt.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,Yt._)`{format: ${t}}`},GT={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:HT,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?f():p();function f(){let m=r.scopeValue("formats",{ref:u.formats,code:c.code.formats}),y=r.const("fDef",(0,Yt._)`${m}[${i}]`),k=r.let("fType"),x=r.let("format");r.if((0,Yt._)`typeof ${y} == "object" && !(${y} instanceof RegExp)`,()=>r.assign(k,(0,Yt._)`${y}.type || "string"`).assign(x,(0,Yt._)`${y}.validate`),()=>r.assign(k,(0,Yt._)`"string"`).assign(x,y)),t.fail$data((0,Yt.or)(_(),g()));function _(){return c.strictSchema===!1?Yt.nil:(0,Yt._)`${i} && !${x}`}function g(){let E=l.$async?(0,Yt._)`(${y}.async ? await ${x}(${n}) : ${x}(${n}))`:(0,Yt._)`${x}(${n})`,h=(0,Yt._)`(typeof ${x} == "function" ? ${E} : ${x}.test(${n}))`;return(0,Yt._)`${x} && ${x} !== true && ${k} === ${e} && !${h}`}}function p(){let m=u.formats[o];if(!m){_();return}if(m===!0)return;let[y,k,x]=g(m);y===e&&t.pass(E());function _(){if(c.strictSchema===!1){u.logger.warn(h());return}throw new Error(h());function h(){return`unknown format "${o}" ignored in schema at path "${d}"`}}function g(h){let $=h instanceof RegExp?(0,Yt.regexpCode)(h):c.code.formats?(0,Yt._)`${c.code.formats}${(0,Yt.getProperty)(o)}`:void 0,z=r.scopeValue("formats",{key:o,ref:h,code:$});return typeof h=="object"&&!(h instanceof RegExp)?[h.type||"string",h.validate,(0,Yt._)`${z}.validate`]:["string",h,z]}function E(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!l.$async)throw new Error("async format in sync schema");return(0,Yt._)`await ${x}(${n})`}return typeof k=="function"?(0,Yt._)`${x}(${n})`:(0,Yt._)`${x}.test(${n})`}}}};mm.default=GT});var jy=Me(gm=>{"use strict";Object.defineProperty(gm,"__esModule",{value:!0});var WT=Cy(),YT=[WT.default];gm.default=YT});var Dy=Me(ai=>{"use strict";Object.defineProperty(ai,"__esModule",{value:!0});ai.contentVocabulary=ai.metadataVocabulary=void 0;ai.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];ai.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Zy=Me(_m=>{"use strict";Object.defineProperty(_m,"__esModule",{value:!0});var XT=Gb(),KT=ay(),JT=Ny(),QT=jy(),Ly=Dy(),eR=[XT.default,KT.default,(0,JT.default)(),QT.default,Ly.metadataVocabulary,Ly.contentVocabulary];_m.default=eR});var Vy=Me(Zl=>{"use strict";Object.defineProperty(Zl,"__esModule",{value:!0});Zl.DiscrError=void 0;var By;(function(t){t.Tag="tag",t.Mapping="mapping"})(By||(Zl.DiscrError=By={}))});var Fy=Me(ym=>{"use strict";Object.defineProperty(ym,"__esModule",{value:!0});var ci=ct(),bm=Vy(),qy=Sl(),tR=ka(),rR=_t(),nR={message:({params:{discrError:t,tagName:e}})=>t===bm.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,ci._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},sR={keyword:"discriminator",type:"object",schemaType:"object",error:nR,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,ci._)`${r}${(0,ci.getProperty)(a)}`);e.if((0,ci._)`typeof ${d} == "string"`,()=>l(),()=>t.error(!1,{discrError:bm.DiscrError.Tag,tag:d,tagName:a})),t.ok(c);function l(){let p=f();e.if(!1);for(let m in p)e.elseIf((0,ci._)`${d} === ${m}`),e.assign(c,u(p[m]));e.else(),t.error(!1,{discrError:bm.DiscrError.Mapping,tag:d,tagName:a}),e.endIf()}function u(p){let m=e.name("valid"),y=t.subschema({keyword:"oneOf",schemaProp:p},m);return t.mergeEvaluated(y,ci.Name),m}function f(){var p;let m={},y=x(s),k=!0;for(let E=0;E<i.length;E++){let h=i[E];if(h?.$ref&&!(0,rR.schemaHasRulesButRef)(h,o.self.RULES)){let z=h.$ref;if(h=qy.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,z),h instanceof qy.SchemaEnv&&(h=h.schema),h===void 0)throw new tR.default(o.opts.uriResolver,o.baseId,z)}let $=(p=h?.properties)===null||p===void 0?void 0:p[a];if(typeof $!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);k=k&&(y||x(h)),_($,E)}if(!k)throw new Error(`discriminator: "${a}" must be required`);return m;function x({required:E}){return Array.isArray(E)&&E.includes(a)}function _(E,h){if(E.const)g(E.const,h);else if(E.enum)for(let $ of E.enum)g($,h);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function g(E,h){if(typeof E!="string"||E in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[E]=h}}}};ym.default=sR});var Uy=Me((SV,oR)=>{oR.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 wm=Me((Nt,vm)=>{"use strict";Object.defineProperty(Nt,"__esModule",{value:!0});Nt.MissingRefError=Nt.ValidationError=Nt.CodeGen=Nt.Name=Nt.nil=Nt.stringify=Nt.str=Nt._=Nt.KeywordCxt=Nt.Ajv=void 0;var iR=Bb(),aR=Zy(),cR=Fy(),Hy=Uy(),lR=["/properties"],Bl="http://json-schema.org/draft-07/schema",li=class extends iR.default{_addVocabularies(){super._addVocabularies(),aR.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(cR.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(Hy,lR):Hy;this.addMetaSchema(e,Bl,!1),this.refs["http://json-schema.org/schema"]=Bl}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Bl)?Bl:void 0)}};Nt.Ajv=li;vm.exports=Nt=li;vm.exports.Ajv=li;Object.defineProperty(Nt,"__esModule",{value:!0});Nt.default=li;var uR=Sa();Object.defineProperty(Nt,"KeywordCxt",{enumerable:!0,get:function(){return uR.KeywordCxt}});var ui=ct();Object.defineProperty(Nt,"_",{enumerable:!0,get:function(){return ui._}});Object.defineProperty(Nt,"str",{enumerable:!0,get:function(){return ui.str}});Object.defineProperty(Nt,"stringify",{enumerable:!0,get:function(){return ui.stringify}});Object.defineProperty(Nt,"nil",{enumerable:!0,get:function(){return ui.nil}});Object.defineProperty(Nt,"Name",{enumerable:!0,get:function(){return ui.Name}});Object.defineProperty(Nt,"CodeGen",{enumerable:!0,get:function(){return ui.CodeGen}});var dR=wl();Object.defineProperty(Nt,"ValidationError",{enumerable:!0,get:function(){return dR.default}});var hR=ka();Object.defineProperty(Nt,"MissingRefError",{enumerable:!0,get:function(){return hR.default}})});var ev=Me(Zn=>{"use strict";Object.defineProperty(Zn,"__esModule",{value:!0});Zn.formatNames=Zn.fastFormats=Zn.fullFormats=void 0;function Ln(t,e){return{validate:t,compare:e}}Zn.fullFormats={date:Ln(Xy,$m),time:Ln(Sm(!0),Em),"date-time":Ln(Gy(!0),Jy),"iso-time":Ln(Sm(),Ky),"iso-date-time":Ln(Gy(),Qy),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:bR,"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:$R,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:yR,int32:{type:"number",validate:xR},int64:{type:"number",validate:SR},float:{type:"number",validate:Yy},double:{type:"number",validate:Yy},password:!0,binary:!0};Zn.fastFormats={...Zn.fullFormats,date:Ln(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,$m),time:Ln(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Em),"date-time":Ln(/^\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,Jy),"iso-time":Ln(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Ky),"iso-date-time":Ln(/^\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,Qy),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};Zn.formatNames=Object.keys(Zn.fullFormats);function fR(t){return t%4===0&&(t%100!==0||t%400===0)}var pR=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,mR=[0,31,28,31,30,31,30,31,31,30,31,30,31];function Xy(t){let e=pR.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&&fR(r)?29:mR[n])}function $m(t,e){if(t&&e)return t>e?1:t<e?-1:0}var xm=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Sm(t){return function(r){let n=xm.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,f=s-d*c-(u<0?1:0);return(f===23||f===-1)&&(u===59||u===-1)&&i<61}}function Em(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 Ky(t,e){if(!(t&&e))return;let r=xm.exec(t),n=xm.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 km=/t|\s/i;function Gy(t){let e=Sm(t);return function(n){let s=n.split(km);return s.length===2&&Xy(s[0])&&e(s[1])}}function Jy(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function Qy(t,e){if(!(t&&e))return;let[r,n]=t.split(km),[s,o]=e.split(km),i=$m(r,s);if(i!==void 0)return i||Em(n,o)}var gR=/\/|:/,_R=/^(?:[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 bR(t){return gR.test(t)&&_R.test(t)}var Wy=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function yR(t){return Wy.lastIndex=0,Wy.test(t)}var vR=-(2**31),wR=2**31-1;function xR(t){return Number.isInteger(t)&&t<=wR&&t>=vR}function SR(t){return Number.isInteger(t)}function Yy(){return!0}var kR=/[^\\]\\Z/;function $R(t){if(kR.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var tv=Me(di=>{"use strict";Object.defineProperty(di,"__esModule",{value:!0});di.formatLimitDefinition=void 0;var ER=wm(),$n=ct(),ws=$n.operators,Vl={formatMaximum:{okStr:"<=",ok:ws.LTE,fail:ws.GT},formatMinimum:{okStr:">=",ok:ws.GTE,fail:ws.LT},formatExclusiveMaximum:{okStr:"<",ok:ws.LT,fail:ws.GTE},formatExclusiveMinimum:{okStr:">",ok:ws.GT,fail:ws.LTE}},TR={message:({keyword:t,schemaCode:e})=>(0,$n.str)`should be ${Vl[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,$n._)`{comparison: ${Vl[t].okStr}, limit: ${e}}`};di.formatLimitDefinition={keyword:Object.keys(Vl),type:"string",schemaType:"string",$data:!0,error:TR,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 ER.KeywordCxt(o,a.RULES.all.format.definition,"format");c.$data?d():l();function d(){let f=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),p=e.const("fmt",(0,$n._)`${f}[${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 f=c.schema,p=a.formats[f];if(!p||p===!0)return;if(typeof p!="object"||p instanceof RegExp||typeof p.compare!="function")throw new Error(`"${s}": format "${f}" does not define "compare" function`);let m=e.scopeValue("formats",{key:f,ref:p,code:i.code.formats?(0,$n._)`${i.code.formats}${(0,$n.getProperty)(f)}`:void 0});t.fail$data(u(m))}function u(f){return(0,$n._)`${f}.compare(${r}, ${n}) ${Vl[s].fail} 0`}},dependencies:["format"]};var RR=t=>(t.addKeyword(di.formatLimitDefinition),t);di.default=RR});var ov=Me((Da,sv)=>{"use strict";Object.defineProperty(Da,"__esModule",{value:!0});var hi=ev(),PR=tv(),Tm=ct(),rv=new Tm.Name("fullFormats"),MR=new Tm.Name("fastFormats"),Rm=(t,e={keywords:!0})=>{if(Array.isArray(e))return nv(t,e,hi.fullFormats,rv),t;let[r,n]=e.mode==="fast"?[hi.fastFormats,MR]:[hi.fullFormats,rv],s=e.formats||hi.formatNames;return nv(t,s,r,n),e.keywords&&(0,PR.default)(t),t};Rm.get=(t,e="full")=>{let n=(e==="fast"?hi.fastFormats:hi.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function nv(t,e,r,n){var s,o;(s=(o=t.opts.code).formats)!==null&&s!==void 0||(o.formats=(0,Tm._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}sv.exports=Da=Rm;Object.defineProperty(Da,"__esModule",{value:!0});Da.default=Rm});var J1=Me((tU,j4)=>{"use strict";var X1="\x1B",Ut=`${X1}[`,aN="\x07",K1={to(t,e){return e?`${Ut}${e+1};${t+1}H`:`${Ut}${t+1}G`},move(t,e){let r="";return t<0?r+=`${Ut}${-t}D`:t>0&&(r+=`${Ut}${t}C`),e<0?r+=`${Ut}${-e}A`:e>0&&(r+=`${Ut}${e}B`),r},up:(t=1)=>`${Ut}${t}A`,down:(t=1)=>`${Ut}${t}B`,forward:(t=1)=>`${Ut}${t}C`,backward:(t=1)=>`${Ut}${t}D`,nextLine:(t=1)=>`${Ut}E`.repeat(t),prevLine:(t=1)=>`${Ut}F`.repeat(t),left:`${Ut}G`,hide:`${Ut}?25l`,show:`${Ut}?25h`,save:`${X1}7`,restore:`${X1}8`},cN={up:(t=1)=>`${Ut}S`.repeat(t),down:(t=1)=>`${Ut}T`.repeat(t)},lN={screen:`${Ut}2J`,up:(t=1)=>`${Ut}1J`.repeat(t),down:(t=1)=>`${Ut}J`.repeat(t),line:`${Ut}2K`,lineEnd:`${Ut}K`,lineStart:`${Ut}1K`,lines(t){let e="";for(let r=0;r<t;r++)e+=this.line+(r<t-1?K1.up():"");return t&&(e+=K1.left),e}};j4.exports={cursor:K1,scroll:cN,erase:lN,beep:aN}});var cx=Me((TU,a0)=>{var Vu=process||{},ix=Vu.argv||[],Bu=Vu.env||{},NN=!(Bu.NO_COLOR||ix.includes("--no-color"))&&(!!Bu.FORCE_COLOR||ix.includes("--color")||Vu.platform==="win32"||(Vu.stdout||{}).isTTY&&Bu.TERM!=="dumb"||!!Bu.CI),CN=(t,e,r=t)=>n=>{let s=""+n,o=s.indexOf(e,t.length);return~o?t+jN(s,e,r,o)+e:t+s+e},jN=(t,e,r,n)=>{let s="",o=0;do s+=t.substring(o,n)+r,o=n+e.length,n=t.indexOf(e,o);while(~n);return s+t.substring(o)},ax=(t=NN)=>{let e=t?CN:()=>String;return{isColorSupported:t,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};a0.exports=ax();a0.exports.createColors=ax});var W={};ed(W,{BRAND:()=>t5,DIRTY:()=>Ns,EMPTY_PATH:()=>Ax,INVALID:()=>Ye,NEVER:()=>D5,OK:()=>fr,ParseStatus:()=>ir,Schema:()=>at,ZodAny:()=>is,ZodArray:()=>Wn,ZodBigInt:()=>js,ZodBoolean:()=>Ds,ZodBranded:()=>ji,ZodCatch:()=>Ys,ZodDate:()=>Ls,ZodDefault:()=>Ws,ZodDiscriminatedUnion:()=>dc,ZodEffects:()=>Qr,ZodEnum:()=>Hs,ZodError:()=>Rr,ZodFirstPartyTypeKind:()=>ye,ZodFunction:()=>fc,ZodIntersection:()=>qs,ZodIssueCode:()=>be,ZodLazy:()=>Fs,ZodLiteral:()=>Us,ZodMap:()=>jo,ZodNaN:()=>Lo,ZodNativeEnum:()=>Gs,ZodNever:()=>_n,ZodNull:()=>Bs,ZodNullable:()=>On,ZodNumber:()=>Cs,ZodObject:()=>Mr,ZodOptional:()=>Pr,ZodParsedType:()=>Oe,ZodPipeline:()=>Di,ZodPromise:()=>as,ZodReadonly:()=>Xs,ZodRecord:()=>hc,ZodSchema:()=>at,ZodSet:()=>Do,ZodString:()=>os,ZodSymbol:()=>No,ZodTransformer:()=>Qr,ZodTuple:()=>An,ZodType:()=>at,ZodUndefined:()=>Zs,ZodUnion:()=>Vs,ZodUnknown:()=>Gn,ZodVoid:()=>Co,addIssueToContext:()=>Ee,any:()=>u5,array:()=>p5,bigint:()=>o5,boolean:()=>I0,coerce:()=>j5,custom:()=>R0,date:()=>i5,datetimeRegex:()=>E0,defaultErrorMap:()=>Un,discriminatedUnion:()=>_5,effect:()=>P5,enum:()=>E5,function:()=>S5,getErrorMap:()=>zo,getParsedType:()=>zn,instanceof:()=>n5,intersection:()=>b5,isAborted:()=>lc,isAsync:()=>Ao,isDirty:()=>uc,isValid:()=>ss,late:()=>r5,lazy:()=>k5,literal:()=>$5,makeIssue:()=>Ci,map:()=>w5,nan:()=>s5,nativeEnum:()=>T5,never:()=>h5,null:()=>l5,nullable:()=>I5,number:()=>M0,object:()=>sd,objectUtil:()=>td,oboolean:()=>C5,onumber:()=>N5,optional:()=>M5,ostring:()=>O5,pipeline:()=>A5,preprocess:()=>z5,promise:()=>R5,quotelessJson:()=>Mx,record:()=>v5,set:()=>x5,setErrorMap:()=>zx,strictObject:()=>m5,string:()=>P0,symbol:()=>a5,transformer:()=>P5,tuple:()=>y5,undefined:()=>c5,union:()=>g5,unknown:()=>d5,util:()=>dt,void:()=>f5});var dt;(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})(dt||(dt={}));var td;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(td||(td={}));var Oe=dt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),zn=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 be=dt.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"]),Mx=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Rr=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,dt.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()}};Rr.create=t=>new Rr(t);var Ix=(t,e)=>{let r;switch(t.code){case be.invalid_type:t.received===Oe.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case be.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,dt.jsonStringifyReplacer)}`;break;case be.unrecognized_keys:r=`Unrecognized key(s) in object: ${dt.joinValues(t.keys,", ")}`;break;case be.invalid_union:r="Invalid input";break;case be.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${dt.joinValues(t.options)}`;break;case be.invalid_enum_value:r=`Invalid enum value. Expected ${dt.joinValues(t.options)}, received '${t.received}'`;break;case be.invalid_arguments:r="Invalid function arguments";break;case be.invalid_return_type:r="Invalid function return type";break;case be.invalid_date:r="Invalid date";break;case be.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}"`:dt.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case be.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 be.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 be.custom:r="Invalid input";break;case be.invalid_intersection_types:r="Intersection results could not be merged";break;case be.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case be.not_finite:r="Number must be finite";break;default:r=e.defaultError,dt.assertNever(t)}return{message:r}},Un=Ix;var w0=Un;function zx(t){w0=t}function zo(){return w0}var Ci=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}},Ax=[];function Ee(t,e){let r=zo(),n=Ci({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Un?void 0:Un].filter(s=>!!s)});t.common.issues.push(n)}var ir=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"}),Ns=t=>({status:"dirty",value:t}),fr=t=>({status:"valid",value:t}),lc=t=>t.status==="aborted",uc=t=>t.status==="dirty",ss=t=>t.status==="valid",Ao=t=>typeof Promise<"u"&&t instanceof Promise;var Ze;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Ze||(Ze={}));var Jr=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}},x0=(t,e)=>{if(ss(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 Rr(t.common.issues);return this._error=r,this._error}}};function ot(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 at=class{get description(){return this._def.description}_getType(e){return zn(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:zn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ir,ctx:{common:e.parent.common,data:e.data,parsedType:zn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Ao(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:zn(e)},s=this._parseSync({data:e,path:n.path,parent:n});return x0(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:zn(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return ss(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=>ss(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:zn(e)},s=this._parse({data:e,path:n.path,parent:n}),o=await(Ao(s)?s:Promise.resolve(s));return x0(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:be.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 Qr({schema:this,typeName:ye.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 Pr.create(this,this._def)}nullable(){return On.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Wn.create(this)}promise(){return as.create(this,this._def)}or(e){return Vs.create([this,e],this._def)}and(e){return qs.create(this,e,this._def)}transform(e){return new Qr({...ot(this._def),schema:this,typeName:ye.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Ws({...ot(this._def),innerType:this,defaultValue:r,typeName:ye.ZodDefault})}brand(){return new ji({typeName:ye.ZodBranded,type:this,...ot(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new Ys({...ot(this._def),innerType:this,catchValue:r,typeName:ye.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Di.create(this,e)}readonly(){return Xs.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Ox=/^c[^\s-]{8,}$/i,Nx=/^[0-9a-z]+$/,Cx=/^[0-9A-HJKMNP-TV-Z]{26}$/i,jx=/^[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,Dx=/^[a-z0-9_-]{21}$/i,Lx=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Zx=/^[-+]?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)?)??$/,Bx=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Vx="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",rd,qx=/^(?:(?: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])$/,Fx=/^(?:(?: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])$/,Ux=/^(([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]))$/,Hx=/^(([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])$/,Gx=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Wx=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,k0="((\\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])))",Yx=new RegExp(`^${k0}$`);function $0(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 Xx(t){return new RegExp(`^${$0(t)}$`)}function E0(t){let e=`${k0}T${$0(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 Kx(t,e){return!!((e==="v4"||!e)&&qx.test(t)||(e==="v6"||!e)&&Ux.test(t))}function Jx(t,e){if(!Lx.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 Qx(t,e){return!!((e==="v4"||!e)&&Fx.test(t)||(e==="v6"||!e)&&Hx.test(t))}var os=class t extends at{_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:be.invalid_type,expected:Oe.string,received:o.parsedType}),Ye}let n=new ir,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:be.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:be.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:be.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&Ee(s,{code:be.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")Bx.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"email",code:be.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")rd||(rd=new RegExp(Vx,"u")),rd.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"emoji",code:be.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")jx.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"uuid",code:be.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")Dx.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"nanoid",code:be.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")Ox.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"cuid",code:be.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")Nx.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"cuid2",code:be.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")Cx.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"ulid",code:be.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:be.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:be.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:be.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:be.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:be.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?E0(o).test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{code:be.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?Yx.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{code:be.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?Xx(o).test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{code:be.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?Zx.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"duration",code:be.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?Kx(e.data,o.version)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"ip",code:be.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?Jx(e.data,o.alg)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"jwt",code:be.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?Qx(e.data,o.version)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"cidr",code:be.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?Gx.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"base64",code:be.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?Wx.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"base64url",code:be.invalid_string,message:o.message}),n.dirty()):dt.assertNever(o);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:be.invalid_string,...Ze.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Ze.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ze.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Ze.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ze.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Ze.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ze.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Ze.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Ze.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Ze.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Ze.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Ze.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Ze.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Ze.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,...Ze.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,...Ze.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Ze.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Ze.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...Ze.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Ze.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Ze.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Ze.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Ze.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Ze.errToObj(r)})}nonempty(e){return this.min(1,Ze.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}};os.create=t=>new os({checks:[],typeName:ye.ZodString,coerce:t?.coerce??!1,...ot(t)});function e5(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 Cs=class t extends at{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:be.invalid_type,expected:Oe.number,received:o.parsedType}),Ye}let n,s=new ir;for(let o of this._def.checks)o.kind==="int"?dt.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),Ee(n,{code:be.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:be.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:be.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),s.dirty()):o.kind==="multipleOf"?e5(e.data,o.value)!==0&&(n=this._getOrReturnCtx(e,n),Ee(n,{code:be.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:be.not_finite,message:o.message}),s.dirty()):dt.assertNever(o);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Ze.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Ze.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Ze.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Ze.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Ze.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Ze.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ze.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ze.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ze.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ze.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Ze.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Ze.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ze.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ze.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"&&dt.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)}};Cs.create=t=>new Cs({checks:[],typeName:ye.ZodNumber,coerce:t?.coerce||!1,...ot(t)});var js=class t extends at{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 ir;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:be.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:be.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:be.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):dt.assertNever(o);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return Ee(r,{code:be.invalid_type,expected:Oe.bigint,received:r.parsedType}),Ye}gte(e,r){return this.setLimit("min",e,!0,Ze.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Ze.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Ze.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Ze.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Ze.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:Ze.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ze.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ze.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ze.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Ze.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}};js.create=t=>new js({checks:[],typeName:ye.ZodBigInt,coerce:t?.coerce??!1,...ot(t)});var Ds=class extends at{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Oe.boolean){let n=this._getOrReturnCtx(e);return Ee(n,{code:be.invalid_type,expected:Oe.boolean,received:n.parsedType}),Ye}return fr(e.data)}};Ds.create=t=>new Ds({typeName:ye.ZodBoolean,coerce:t?.coerce||!1,...ot(t)});var Ls=class t extends at{_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:be.invalid_type,expected:Oe.date,received:o.parsedType}),Ye}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return Ee(o,{code:be.invalid_date}),Ye}let n=new ir,s;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(s=this._getOrReturnCtx(e,s),Ee(s,{code:be.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:be.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):dt.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:Ze.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Ze.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}};Ls.create=t=>new Ls({checks:[],coerce:t?.coerce||!1,typeName:ye.ZodDate,...ot(t)});var No=class extends at{_parse(e){if(this._getType(e)!==Oe.symbol){let n=this._getOrReturnCtx(e);return Ee(n,{code:be.invalid_type,expected:Oe.symbol,received:n.parsedType}),Ye}return fr(e.data)}};No.create=t=>new No({typeName:ye.ZodSymbol,...ot(t)});var Zs=class extends at{_parse(e){if(this._getType(e)!==Oe.undefined){let n=this._getOrReturnCtx(e);return Ee(n,{code:be.invalid_type,expected:Oe.undefined,received:n.parsedType}),Ye}return fr(e.data)}};Zs.create=t=>new Zs({typeName:ye.ZodUndefined,...ot(t)});var Bs=class extends at{_parse(e){if(this._getType(e)!==Oe.null){let n=this._getOrReturnCtx(e);return Ee(n,{code:be.invalid_type,expected:Oe.null,received:n.parsedType}),Ye}return fr(e.data)}};Bs.create=t=>new Bs({typeName:ye.ZodNull,...ot(t)});var is=class extends at{constructor(){super(...arguments),this._any=!0}_parse(e){return fr(e.data)}};is.create=t=>new is({typeName:ye.ZodAny,...ot(t)});var Gn=class extends at{constructor(){super(...arguments),this._unknown=!0}_parse(e){return fr(e.data)}};Gn.create=t=>new Gn({typeName:ye.ZodUnknown,...ot(t)});var _n=class extends at{_parse(e){let r=this._getOrReturnCtx(e);return Ee(r,{code:be.invalid_type,expected:Oe.never,received:r.parsedType}),Ye}};_n.create=t=>new _n({typeName:ye.ZodNever,...ot(t)});var Co=class extends at{_parse(e){if(this._getType(e)!==Oe.undefined){let n=this._getOrReturnCtx(e);return Ee(n,{code:be.invalid_type,expected:Oe.void,received:n.parsedType}),Ye}return fr(e.data)}};Co.create=t=>new Co({typeName:ye.ZodVoid,...ot(t)});var Wn=class t extends at{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==Oe.array)return Ee(r,{code:be.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?be.too_big:be.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:be.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:be.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 Jr(r,i,r.path,a)))).then(i=>ir.mergeArray(n,i));let o=[...r.data].map((i,a)=>s.type._parseSync(new Jr(r,i,r.path,a)));return ir.mergeArray(n,o)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:Ze.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:Ze.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:Ze.toString(r)}})}nonempty(e){return this.min(1,e)}};Wn.create=(t,e)=>new Wn({type:t,minLength:null,maxLength:null,exactLength:null,typeName:ye.ZodArray,...ot(e)});function Oo(t){if(t instanceof Mr){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=Pr.create(Oo(n))}return new Mr({...t._def,shape:()=>e})}else return t instanceof Wn?new Wn({...t._def,type:Oo(t.element)}):t instanceof Pr?Pr.create(Oo(t.unwrap())):t instanceof On?On.create(Oo(t.unwrap())):t instanceof An?An.create(t.items.map(e=>Oo(e))):t}var Mr=class t extends at{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=dt.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:be.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 _n&&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 Jr(s,u,s.path,d)),alwaysSet:d in s.data})}if(this._def.catchall instanceof _n){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:be.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 Jr(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,f=await l.value;d.push({key:u,value:f,alwaysSet:l.alwaysSet})}return d}).then(d=>ir.mergeObjectSync(n,d)):ir.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return Ze.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:Ze.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:ye.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 dt.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 dt.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Oo(this)}partial(e){let r={};for(let n of dt.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 dt.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof Pr;)o=o._def.innerType;r[n]=o}return new t({...this._def,shape:()=>r})}keyof(){return T0(dt.objectKeys(this.shape))}};Mr.create=(t,e)=>new Mr({shape:()=>t,unknownKeys:"strip",catchall:_n.create(),typeName:ye.ZodObject,...ot(e)});Mr.strictCreate=(t,e)=>new Mr({shape:()=>t,unknownKeys:"strict",catchall:_n.create(),typeName:ye.ZodObject,...ot(e)});Mr.lazycreate=(t,e)=>new Mr({shape:t,unknownKeys:"strip",catchall:_n.create(),typeName:ye.ZodObject,...ot(e)});var Vs=class extends at{_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 Rr(a.ctx.common.issues));return Ee(r,{code:be.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 Rr(c));return Ee(r,{code:be.invalid_union,unionErrors:a}),Ye}}get options(){return this._def.options}};Vs.create=(t,e)=>new Vs({options:t,typeName:ye.ZodUnion,...ot(e)});var Hn=t=>t instanceof Fs?Hn(t.schema):t instanceof Qr?Hn(t.innerType()):t instanceof Us?[t.value]:t instanceof Hs?t.options:t instanceof Gs?dt.objectValues(t.enum):t instanceof Ws?Hn(t._def.innerType):t instanceof Zs?[void 0]:t instanceof Bs?[null]:t instanceof Pr?[void 0,...Hn(t.unwrap())]:t instanceof On?[null,...Hn(t.unwrap())]:t instanceof ji||t instanceof Xs?Hn(t.unwrap()):t instanceof Ys?Hn(t._def.innerType):[],dc=class t extends at{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==Oe.object)return Ee(r,{code:be.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:be.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=Hn(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:ye.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...ot(n)})}};function nd(t,e){let r=zn(t),n=zn(e);if(t===e)return{valid:!0,data:t};if(r===Oe.object&&n===Oe.object){let s=dt.objectKeys(e),o=dt.objectKeys(t).filter(a=>s.indexOf(a)!==-1),i={...t,...e};for(let a of o){let c=nd(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=nd(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 qs=class extends at{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(o,i)=>{if(lc(o)||lc(i))return Ye;let a=nd(o.value,i.value);return a.valid?((uc(o)||uc(i))&&r.dirty(),{status:r.value,value:a.data}):(Ee(n,{code:be.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}))}};qs.create=(t,e,r)=>new qs({left:t,right:e,typeName:ye.ZodIntersection,...ot(r)});var An=class t extends at{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Oe.array)return Ee(n,{code:be.invalid_type,expected:Oe.array,received:n.parsedType}),Ye;if(n.data.length<this._def.items.length)return Ee(n,{code:be.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:be.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 Jr(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(o).then(i=>ir.mergeArray(r,i)):ir.mergeArray(r,o)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};An.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new An({items:t,typeName:ye.ZodTuple,rest:null,...ot(e)})};var hc=class t extends at{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:be.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 Jr(n,a,n.path,a)),value:i._parse(new Jr(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?ir.mergeObjectAsync(r,s):ir.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof at?new t({keyType:e,valueType:r,typeName:ye.ZodRecord,...ot(n)}):new t({keyType:os.create(),valueType:e,typeName:ye.ZodRecord,...ot(r)})}},jo=class extends at{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:be.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 Jr(n,a,n.path,[d,"key"])),value:o._parse(new Jr(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}}}};jo.create=(t,e,r)=>new jo({valueType:e,keyType:t,typeName:ye.ZodMap,...ot(r)});var Do=class t extends at{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Oe.set)return Ee(n,{code:be.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:be.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:be.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 Jr(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:Ze.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:Ze.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Do.create=(t,e)=>new Do({valueType:t,minSize:null,maxSize:null,typeName:ye.ZodSet,...ot(e)});var fc=class t extends at{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==Oe.function)return Ee(r,{code:be.invalid_type,expected:Oe.function,received:r.parsedType}),Ye;function n(a,c){return Ci({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,zo(),Un].filter(d=>!!d),issueData:{code:be.invalid_arguments,argumentsError:c}})}function s(a,c){return Ci({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,zo(),Un].filter(d=>!!d),issueData:{code:be.invalid_return_type,returnTypeError:c}})}let o={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof as){let a=this;return fr(async function(...c){let d=new Rr([]),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 fr(function(...c){let d=a._def.args.safeParse(c,o);if(!d.success)throw new Rr([n(c,d.error)]);let l=Reflect.apply(i,this,d.data),u=a._def.returns.safeParse(l,o);if(!u.success)throw new Rr([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:An.create(e).rest(Gn.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||An.create([]).rest(Gn.create()),returns:r||Gn.create(),typeName:ye.ZodFunction,...ot(n)})}},Fs=class extends at{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})}};Fs.create=(t,e)=>new Fs({getter:t,typeName:ye.ZodLazy,...ot(e)});var Us=class extends at{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return Ee(r,{received:r.data,code:be.invalid_literal,expected:this._def.value}),Ye}return{status:"valid",value:e.data}}get value(){return this._def.value}};Us.create=(t,e)=>new Us({value:t,typeName:ye.ZodLiteral,...ot(e)});function T0(t,e){return new Hs({values:t,typeName:ye.ZodEnum,...ot(e)})}var Hs=class t extends at{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return Ee(r,{expected:dt.joinValues(n),received:r.parsedType,code:be.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:be.invalid_enum_value,options:n}),Ye}return fr(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})}};Hs.create=T0;var Gs=class extends at{_parse(e){let r=dt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Oe.string&&n.parsedType!==Oe.number){let s=dt.objectValues(r);return Ee(n,{expected:dt.joinValues(s),received:n.parsedType,code:be.invalid_type}),Ye}if(this._cache||(this._cache=new Set(dt.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=dt.objectValues(r);return Ee(n,{received:n.data,code:be.invalid_enum_value,options:s}),Ye}return fr(e.data)}get enum(){return this._def.values}};Gs.create=(t,e)=>new Gs({values:t,typeName:ye.ZodNativeEnum,...ot(e)});var as=class extends at{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:be.invalid_type,expected:Oe.promise,received:r.parsedType}),Ye;let n=r.parsedType===Oe.promise?r.data:Promise.resolve(r.data);return fr(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};as.create=(t,e)=>new as({type:t,typeName:ye.ZodPromise,...ot(e)});var Qr=class extends at{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ye.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"?Ns(c.value):r.value==="dirty"?Ns(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"?Ns(a.value):r.value==="dirty"?Ns(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(!ss(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=>ss(i)?Promise.resolve(s.transform(i.value,o)).then(a=>({status:r.value,value:a})):Ye);dt.assertNever(s)}};Qr.create=(t,e,r)=>new Qr({schema:t,typeName:ye.ZodEffects,effect:e,...ot(r)});Qr.createWithPreprocess=(t,e,r)=>new Qr({schema:e,effect:{type:"preprocess",transform:t},typeName:ye.ZodEffects,...ot(r)});var Pr=class extends at{_parse(e){return this._getType(e)===Oe.undefined?fr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Pr.create=(t,e)=>new Pr({innerType:t,typeName:ye.ZodOptional,...ot(e)});var On=class extends at{_parse(e){return this._getType(e)===Oe.null?fr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};On.create=(t,e)=>new On({innerType:t,typeName:ye.ZodNullable,...ot(e)});var Ws=class extends at{_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}};Ws.create=(t,e)=>new Ws({innerType:t,typeName:ye.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ot(e)});var Ys=class extends at{_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 Ao(s)?s.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Rr(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Rr(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Ys.create=(t,e)=>new Ys({innerType:t,typeName:ye.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ot(e)});var Lo=class extends at{_parse(e){if(this._getType(e)!==Oe.nan){let n=this._getOrReturnCtx(e);return Ee(n,{code:be.invalid_type,expected:Oe.nan,received:n.parsedType}),Ye}return{status:"valid",value:e.data}}};Lo.create=t=>new Lo({typeName:ye.ZodNaN,...ot(t)});var t5=Symbol("zod_brand"),ji=class extends at{_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}},Di=class t extends at{_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(),Ns(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:ye.ZodPipeline})}},Xs=class extends at{_parse(e){let r=this._def.innerType._parse(e),n=s=>(ss(s)&&(s.value=Object.freeze(s.value)),s);return Ao(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};Xs.create=(t,e)=>new Xs({innerType:t,typeName:ye.ZodReadonly,...ot(e)});function S0(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function R0(t,e={},r){return t?is.create().superRefine((n,s)=>{let o=t(n);if(o instanceof Promise)return o.then(i=>{if(!i){let a=S0(e,n),c=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!o){let i=S0(e,n),a=i.fatal??r??!0;s.addIssue({code:"custom",...i,fatal:a})}}):is.create()}var r5={object:Mr.lazycreate},ye;(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"})(ye||(ye={}));var n5=(t,e={message:`Input not instance of ${t.name}`})=>R0(r=>r instanceof t,e),P0=os.create,M0=Cs.create,s5=Lo.create,o5=js.create,I0=Ds.create,i5=Ls.create,a5=No.create,c5=Zs.create,l5=Bs.create,u5=is.create,d5=Gn.create,h5=_n.create,f5=Co.create,p5=Wn.create,sd=Mr.create,m5=Mr.strictCreate,g5=Vs.create,_5=dc.create,b5=qs.create,y5=An.create,v5=hc.create,w5=jo.create,x5=Do.create,S5=fc.create,k5=Fs.create,$5=Us.create,E5=Hs.create,T5=Gs.create,R5=as.create,P5=Qr.create,M5=Pr.create,I5=On.create,z5=Qr.createWithPreprocess,A5=Di.create,O5=()=>P0().optional(),N5=()=>M0().optional(),C5=()=>I0().optional(),j5={string:t=>os.create({...t,coerce:!0}),number:t=>Cs.create({...t,coerce:!0}),boolean:t=>Ds.create({...t,coerce:!0}),bigint:t=>js.create({...t,coerce:!0}),date:t=>Ls.create({...t,coerce:!0})};var D5=Ye;var L5=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 Z5=Symbol("zod_brand"),Yn=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},pc={};function qr(t){return t&&Object.assign(pc,t),pc}var ht={};ed(ht,{BIGINT_FORMAT_RANGES:()=>A0,Class:()=>id,NUMBER_FORMAT_RANGES:()=>fd,aborted:()=>Js,allowsEval:()=>ud,assert:()=>U5,assertEqual:()=>B5,assertIs:()=>q5,assertNever:()=>F5,assertNotEqual:()=>V5,assignProp:()=>ld,cached:()=>Bi,captureStackTrace:()=>gc,cleanEnum:()=>sS,cleanRegex:()=>qi,clone:()=>Fr,createTransparentProxy:()=>K5,defineLazy:()=>Mt,esc:()=>Ks,escapeRegex:()=>cs,extend:()=>eS,finalizeIssue:()=>bn,floatSafeRemainder:()=>cd,getElementAtPath:()=>H5,getEnumValues:()=>Zi,getLengthableOrigin:()=>Fi,getParsedType:()=>X5,getSizableOrigin:()=>O0,isObject:()=>Zo,isPlainObject:()=>Bo,issue:()=>pd,joinValues:()=>mc,jsonStringifyReplacer:()=>ad,merge:()=>tS,normalizeParams:()=>Xe,nullish:()=>Vi,numKeys:()=>Y5,omit:()=>Q5,optionalKeys:()=>hd,partial:()=>rS,pick:()=>J5,prefixIssues:()=>Nn,primitiveTypes:()=>z0,promiseAllObject:()=>G5,propertyKeyTypes:()=>dd,randomString:()=>W5,required:()=>nS,stringifyPrimitive:()=>_c,unwrapMessage:()=>Li});function B5(t){return t}function V5(t){return t}function q5(t){}function F5(t){throw new Error}function U5(t){}function Zi(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 mc(t,e="|"){return t.map(r=>_c(r)).join(e)}function ad(t,e){return typeof e=="bigint"?e.toString():e}function Bi(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Vi(t){return t==null}function qi(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function cd(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 Mt(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 ld(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function H5(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function G5(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 W5(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function Ks(t){return JSON.stringify(t)}var gc=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function Zo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var ud=Bi(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function Bo(t){if(Zo(t)===!1)return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(Zo(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Y5(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var X5=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}`)}},dd=new Set(["string","number","symbol"]),z0=new Set(["string","number","bigint","boolean","symbol","undefined"]);function cs(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Fr(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 K5(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 _c(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function hd(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var fd={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]},A0={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function J5(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 Fr(t,{...t._zod.def,shape:r,checks:[]})}function Q5(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 Fr(t,{...t._zod.def,shape:r,checks:[]})}function eS(t,e){if(!Bo(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 ld(this,"shape",n),n},checks:[]};return Fr(t,r)}function tS(t,e){return Fr(t,{...t._zod.def,get shape(){let r={...t._zod.def.shape,...e._zod.def.shape};return ld(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}function rS(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 Fr(e,{...e._zod.def,shape:s,checks:[]})}function nS(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 Fr(e,{...e._zod.def,shape:s,checks:[]})}function Js(t,e=0){for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function Nn(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Li(t){return typeof t=="string"?t:t?.message}function bn(t,e,r){let n={...t,path:t.path??[]};if(!t.message){let s=Li(t.inst?._zod.def?.error?.(t))??Li(e?.error?.(t))??Li(r.customError?.(t))??Li(r.localeError?.(t))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function O0(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Fi(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function pd(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function sS(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}var id=class{constructor(...e){}};var N0=(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,ad,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},bc=le("$ZodError",N0),Ui=le("$ZodError",N0,{Parent:Error});function md(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 gd(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 _d=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 Yn;if(i.issues.length){let a=new(s?.Err??t)(i.issues.map(c=>bn(c,o,qr())));throw gc(a,s?.callee),a}return i.value},bd=_d(Ui),yd=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=>bn(c,o,qr())));throw gc(a,s?.callee),a}return i.value},vd=yd(Ui),wd=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 Yn;return o.issues.length?{success:!1,error:new(t??bc)(o.issues.map(i=>bn(i,s,qr())))}:{success:!0,data:o.value}},Qs=wd(Ui),xd=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=>bn(i,s,qr())))}:{success:!0,data:o.value}},eo=xd(Ui);var C0=/^[cC][^\s-]{8,}$/,j0=/^[0-9a-z]+$/,D0=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,L0=/^[0-9a-vA-V]{20}$/,Z0=/^[A-Za-z0-9]{27}$/,B0=/^[a-zA-Z0-9_-]{21}$/,V0=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var q0=/^([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})$/,Sd=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 F0=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var iS="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function U0(){return new RegExp(iS,"u")}var H0=/^(?:(?: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])$/,G0=/^(([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})$/,W0=/^((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])$/,Y0=/^(([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])$/,X0=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,kd=/^[A-Za-z0-9_-]*$/,K0=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var J0=/^\+(?:[0-9]){6,14}[0-9]$/,Q0="(?:(?:\\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])))",eg=new RegExp(`^${Q0}$`);function tg(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 rg(t){return new RegExp(`^${tg(t)}$`)}function ng(t){let e=tg({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(`^${Q0}T(?:${n})$`)}var sg=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)};var og=/^\d+$/,ig=/^-?\d+(?:\.\d+)?/i,ag=/true|false/i,cg=/null/i;var lg=/^[^A-Z]*$/,ug=/^[^a-z]*$/;var ar=le("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),dg={number:"number",bigint:"bigint",object:"date"},$d=le("$ZodCheckLessThan",(t,e)=>{ar.init(t,e);let r=dg[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})}}),Ed=le("$ZodCheckGreaterThan",(t,e)=>{ar.init(t,e);let r=dg[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})}}),hg=le("$ZodCheckMultipleOf",(t,e)=>{ar.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):cd(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})}}),fg=le("$ZodCheckNumberFormat",(t,e)=>{ar.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[s,o]=fd[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=og)}),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 pg=le("$ZodCheckMaxLength",(t,e)=>{var r;ar.init(t,e),(r=t._zod.def).when??(r.when=n=>{let s=n.value;return!Vi(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=Fi(s);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),mg=le("$ZodCheckMinLength",(t,e)=>{var r;ar.init(t,e),(r=t._zod.def).when??(r.when=n=>{let s=n.value;return!Vi(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=Fi(s);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),gg=le("$ZodCheckLengthEquals",(t,e)=>{var r;ar.init(t,e),(r=t._zod.def).when??(r.when=n=>{let s=n.value;return!Vi(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=Fi(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})}}),Hi=le("$ZodCheckStringFormat",(t,e)=>{var r,n;ar.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=()=>{})}),_g=le("$ZodCheckRegex",(t,e)=>{Hi.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})}}),bg=le("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=lg),Hi.init(t,e)}),yg=le("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=ug),Hi.init(t,e)}),vg=le("$ZodCheckIncludes",(t,e)=>{ar.init(t,e);let r=cs(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})}}),wg=le("$ZodCheckStartsWith",(t,e)=>{ar.init(t,e);let r=new RegExp(`^${cs(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})}}),xg=le("$ZodCheckEndsWith",(t,e)=>{ar.init(t,e);let r=new RegExp(`.*${cs(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 Sg=le("$ZodCheckOverwrite",(t,e)=>{ar.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});var vc=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
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 $g={major:4,minor:0,patch:0};var kt=le("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=$g;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=
|
|
11
|
+
`))}};var $g={major:4,minor:0,patch:0};var kt=le("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=$g;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=Js(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,f=l._zod.check(o);if(f instanceof Promise&&a?.async===!1)throw new Yn;if(d||f instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await f,o.issues.length!==u&&(c||(c=Js(o,u)))});else{if(o.issues.length===u)continue;c||(c=Js(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 Yn;return a.then(c=>s(c,n,i))}return s(a,n,i)}}t["~standard"]={validate:s=>{try{let o=Qs(t,s);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return eo(t,s).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),Gi=le("$ZodString",(t,e)=>{kt.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??sg(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}}),It=le("$ZodStringFormat",(t,e)=>{Hi.init(t,e),Gi.init(t,e)}),Rd=le("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=q0),It.init(t,e)}),Pd=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=Sd(n))}else e.pattern??(e.pattern=Sd());It.init(t,e)}),Md=le("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=F0),It.init(t,e)}),Id=le("$ZodURL",(t,e)=>{It.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:K0.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})}}}),zd=le("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=U0()),It.init(t,e)}),Ad=le("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=B0),It.init(t,e)}),Od=le("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=C0),It.init(t,e)}),Nd=le("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=j0),It.init(t,e)}),Cd=le("$ZodULID",(t,e)=>{e.pattern??(e.pattern=D0),It.init(t,e)}),jd=le("$ZodXID",(t,e)=>{e.pattern??(e.pattern=L0),It.init(t,e)}),Dd=le("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=Z0),It.init(t,e)}),Ng=le("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=ng(e)),It.init(t,e)}),Cg=le("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=eg),It.init(t,e)}),jg=le("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=rg(e)),It.init(t,e)}),Dg=le("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=V0),It.init(t,e)}),Ld=le("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=H0),It.init(t,e),t._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv4"})}),Zd=le("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=G0),It.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})}}}),Bd=le("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=W0),It.init(t,e)}),Vd=le("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=Y0),It.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 Lg(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}var qd=le("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=X0),It.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),t._zod.check=r=>{Lg(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function aS(t){if(!kd.test(t))return!1;let e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return Lg(r)}var Fd=le("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=kd),It.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),t._zod.check=r=>{aS(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),Ud=le("$ZodE164",(t,e)=>{e.pattern??(e.pattern=J0),It.init(t,e)});function cS(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)=>{It.init(t,e),t._zod.check=r=>{cS(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}});var xc=le("$ZodNumber",(t,e)=>{kt.init(t,e),t._zod.pattern=t._zod.bag.pattern??ig,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}}),Gd=le("$ZodNumber",(t,e)=>{fg.init(t,e),xc.init(t,e)}),Wd=le("$ZodBoolean",(t,e)=>{kt.init(t,e),t._zod.pattern=ag,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 Yd=le("$ZodNull",(t,e)=>{kt.init(t,e),t._zod.pattern=cg,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 Xd=le("$ZodUnknown",(t,e)=>{kt.init(t,e),t._zod.parse=r=>r}),Kd=le("$ZodNever",(t,e)=>{kt.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function Eg(t,e,r){t.issues.length&&e.issues.push(...Nn(r,t.issues)),e.value[r]=t.value}var Jd=le("$ZodArray",(t,e)=>{kt.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=>Eg(d,r,i))):Eg(c,r,i)}return o.length?Promise.all(o).then(()=>r):r}});function wc(t,e,r){t.issues.length&&e.issues.push(...Nn(r,t.issues)),e.value[r]=t.value}function Tg(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(...Nn(r,t.issues)):t.value===void 0?r in n&&(e.value[r]=void 0):e.value[r]=t.value}var Sc=le("$ZodObject",(t,e)=>{kt.init(t,e);let r=Bi(()=>{let u=Object.keys(e.shape);for(let p of u)if(!(e.shape[p]instanceof kt))throw new Error(`Invalid element at key "${p}": expected a Zod schema`);let f=hd(e.shape);return{shape:e.shape,keys:u,keySet:new Set(u),numKeys:u.length,optionalKeys:new Set(f)}});Mt(t._zod,"propValues",()=>{let u=e.shape,f={};for(let p in u){let m=u[p]._zod;if(m.values){f[p]??(f[p]=new Set);for(let y of m.values)f[p].add(y)}}return f});let n=u=>{let f=new vc(["shape","payload","ctx"]),p=r.value,m=_=>{let g=Ks(_);return`shape[${g}]._zod.run({ value: input[${g}], issues: [] }, ctx)`};f.write("const input = payload.value;");let y=Object.create(null),k=0;for(let _ of p.keys)y[_]=`key_${k++}`;f.write("const newResult = {}");for(let _ of p.keys)if(p.optionalKeys.has(_)){let g=y[_];f.write(`const ${g} = ${m(_)};`);let E=Ks(_);f.write(`
|
|
12
12
|
if (${g}.issues.length) {
|
|
13
13
|
if (input[${E}] === undefined) {
|
|
14
14
|
if (${E} in input) {
|
|
@@ -30,109 +30,29 @@ var $x=Object.create;var Qu=Object.defineProperty;var Ex=Object.getOwnPropertyDe
|
|
|
30
30
|
`)}else{let g=y[_];f.write(`const ${g} = ${m(_)};`),f.write(`
|
|
31
31
|
if (${g}.issues.length) payload.issues = payload.issues.concat(${g}.issues.map(iss => ({
|
|
32
32
|
...iss,
|
|
33
|
-
path: iss.path ? [${
|
|
34
|
-
})));`),f.write(`newResult[${Js(_)}] = ${g}.value`)}f.write("payload.value = newResult;"),f.write("return payload;");let x=f.compile();return(_,g)=>x(u,_,g)},s,o=Bo,i=!mc.jitless,c=i&&ud.value,d=e.catchall,l;t._zod.parse=(u,f)=>{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 m=[];if(i&&c&&f?.async===!1&&f.jitless!==!0)s||(s=n(e.shape)),u=s(u,f);else{u.value={};let g=l.shape;for(let E of l.keys){let h=g[E],$=h._zod.run({value:p[E],issues:[]},f),O=h._zod.optin==="optional"&&h._zod.optout==="optional";$ instanceof Promise?m.push($.then(L=>O?Tg(L,u,E,p):xc(L,u,E))):O?Tg($,u,E,p):xc($,u,E)}}if(!d)return m.length?Promise.all(m).then(()=>u):u;let y=[],k=l.keySet,x=d._zod,_=x.def.type;for(let g of Object.keys(p)){if(k.has(g))continue;if(_==="never"){y.push(g);continue}let E=x.run({value:p[g],issues:[]},f);E instanceof Promise?m.push(E.then(h=>xc(h,u,g))):xc(E,u,g)}return y.length&&u.issues.push({code:"unrecognized_keys",keys:y,input:p,inst:t}),m.length?Promise.all(m).then(()=>u):u}});function Rg(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=>bn(o,n,qr())))}),e}var $c=le("$ZodUnion",(t,e)=>{kt.init(t,e),Pt(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Pt(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Pt(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),Pt(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=>Fi(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=>Rg(i,r,t,n)):Rg(o,r,t,n)}}),Qd=le("$ZodDiscriminatedUnion",(t,e)=>{$c.init(t,e);let r=t._zod.parse;Pt(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=Vi(()=>{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(!Bo(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)}}),eh=le("$ZodIntersection",(t,e)=>{kt.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])=>Ig(r,c,d)):Ig(r,o,i)}});function Td(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(Vo(t)&&Vo(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=Td(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=Td(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 Ig(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),Qs(t))return t;let n=Td(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 th=le("$ZodRecord",(t,e)=>{kt.init(t,e),t._zod.parse=(r,n)=>{let s=r.value;if(!Vo(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(...Nn(c,l.issues)),r.value[c]=l.value})):(d.issues.length&&r.issues.push(...Nn(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=>bn(d,n,qr())),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(...Nn(i,d.issues)),r.value[a.value]=d.value})):(c.issues.length&&r.issues.push(...Nn(i,c.issues)),r.value[a.value]=c.value)}}return o.length?Promise.all(o).then(()=>r):r}});var rh=le("$ZodEnum",(t,e)=>{kt.init(t,e);let r=Bi(e.entries);t._zod.values=new Set(r),t._zod.pattern=new RegExp(`^(${r.filter(n=>dd.has(typeof n)).map(n=>typeof n=="string"?cs(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}}),nh=le("$ZodLiteral",(t,e)=>{kt.init(t,e),t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?cs(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 sh=le("$ZodTransform",(t,e)=>{kt.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 Yn;return r.value=s,r}}),oh=le("$ZodOptional",(t,e)=>{kt.init(t,e),t._zod.optin="optional",t._zod.optout="optional",Pt(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),Pt(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Fi(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)}),ih=le("$ZodNullable",(t,e)=>{kt.init(t,e),Pt(t._zod,"optin",()=>e.innerType._zod.optin),Pt(t._zod,"optout",()=>e.innerType._zod.optout),Pt(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Fi(r.source)}|null)$`):void 0}),Pt(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)}),ah=le("$ZodDefault",(t,e)=>{kt.init(t,e),t._zod.optin="optional",Pt(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=>Pg(o,e)):Pg(s,e)}});function Pg(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}var ch=le("$ZodPrefault",(t,e)=>{kt.init(t,e),t._zod.optin="optional",Pt(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))}),lh=le("$ZodNonOptional",(t,e)=>{kt.init(t,e),Pt(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=>Mg(o,t)):Mg(s,t)}});function Mg(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 uh=le("$ZodCatch",(t,e)=>{kt.init(t,e),t._zod.optin="optional",Pt(t._zod,"optout",()=>e.innerType._zod.optout),Pt(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=>bn(i,n,qr()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(o=>bn(o,n,qr()))},input:r.value}),r.issues=[]),r)}});var dh=le("$ZodPipe",(t,e)=>{kt.init(t,e),Pt(t._zod,"values",()=>e.in._zod.values),Pt(t._zod,"optin",()=>e.in._zod.optin),Pt(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=>Og(o,e,n)):Og(s,e,n)}});function Og(t,e,r){return Qs(t)?t:e.out._zod.run({value:t.value,issues:t.issues},r)}var hh=le("$ZodReadonly",(t,e)=>{kt.init(t,e),Pt(t._zod,"propValues",()=>e.innerType._zod.propValues),Pt(t._zod,"values",()=>e.innerType._zod.values),Pt(t._zod,"optin",()=>e.innerType._zod.optin),Pt(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(Ag):Ag(s)}});function Ag(t){return t.value=Object.freeze(t.value),t}var fh=le("$ZodCustom",(t,e)=>{ar.init(t,e),kt.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=>zg(o,r,n,t));zg(s,r,n,t)}});function zg(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(pd(s))}}var uS=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},dS=()=>{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 ${uS(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${bc(n.values[0])}`:`Invalid option: expected one of ${gc(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":""}: ${gc(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 Zg(){return{localeError:dS()}}var hS=Symbol("ZodOutput"),fS=Symbol("ZodInput"),Yi=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 Bg(){return new Yi}var ls=Bg();function ph(t,e){return new t({type:"string",...Xe(e)})}function mh(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...Xe(e)})}function Ec(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...Xe(e)})}function gh(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...Xe(e)})}function _h(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Xe(e)})}function bh(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Xe(e)})}function yh(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Xe(e)})}function vh(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Xe(e)})}function wh(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...Xe(e)})}function xh(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...Xe(e)})}function Sh(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...Xe(e)})}function kh(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...Xe(e)})}function $h(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...Xe(e)})}function Eh(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...Xe(e)})}function Th(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...Xe(e)})}function Rh(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...Xe(e)})}function Ih(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...Xe(e)})}function Ph(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Xe(e)})}function Mh(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Xe(e)})}function Oh(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...Xe(e)})}function Ah(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...Xe(e)})}function zh(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...Xe(e)})}function Nh(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...Xe(e)})}function Vg(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Xe(e)})}function qg(t,e){return new t({type:"string",format:"date",check:"string_format",...Xe(e)})}function Fg(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...Xe(e)})}function Hg(t,e){return new t({type:"string",format:"duration",check:"string_format",...Xe(e)})}function Ch(t,e){return new t({type:"number",checks:[],...Xe(e)})}function jh(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Xe(e)})}function Dh(t,e){return new t({type:"boolean",...Xe(e)})}function Lh(t,e){return new t({type:"null",...Xe(e)})}function Zh(t){return new t({type:"unknown"})}function Bh(t,e){return new t({type:"never",...Xe(e)})}function Tc(t,e){return new $d({check:"less_than",...Xe(e),value:t,inclusive:!1})}function Xi(t,e){return new $d({check:"less_than",...Xe(e),value:t,inclusive:!0})}function Rc(t,e){return new Ed({check:"greater_than",...Xe(e),value:t,inclusive:!1})}function Ki(t,e){return new Ed({check:"greater_than",...Xe(e),value:t,inclusive:!0})}function Ic(t,e){return new hg({check:"multiple_of",...Xe(e),value:t})}function Pc(t,e){return new pg({check:"max_length",...Xe(e),maximum:t})}function qo(t,e){return new mg({check:"min_length",...Xe(e),minimum:t})}function Mc(t,e){return new gg({check:"length_equals",...Xe(e),length:t})}function Vh(t,e){return new _g({check:"string_format",format:"regex",...Xe(e),pattern:t})}function qh(t){return new bg({check:"string_format",format:"lowercase",...Xe(t)})}function Fh(t){return new yg({check:"string_format",format:"uppercase",...Xe(t)})}function Hh(t,e){return new vg({check:"string_format",format:"includes",...Xe(e),includes:t})}function Uh(t,e){return new wg({check:"string_format",format:"starts_with",...Xe(e),prefix:t})}function Gh(t,e){return new xg({check:"string_format",format:"ends_with",...Xe(e),suffix:t})}function ro(t){return new Sg({check:"overwrite",tx:t})}function Wh(t){return ro(e=>e.normalize(t))}function Yh(){return ro(t=>t.trim())}function Xh(){return ro(t=>t.toLowerCase())}function Kh(){return ro(t=>t.toUpperCase())}function Ug(t,e,r){return new t({type:"array",element:e,...Xe(r)})}function Jh(t,e,r){let n=Xe(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function Qh(t,e,r){return new t({type:"custom",check:"custom",fn:e,...Xe(r)})}var Oc=class{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??ls,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},f=e._zod.parent;if(f)a.ref=f,this.process(f,u),this.seen.get(f).isParent=!0;else{let p=a.schema;switch(s.type){case"string":{let m=p;m.type="string";let{minimum:y,maximum:k,format:x,patterns:_,contentEncoding:g}=e._zod.bag;if(typeof y=="number"&&(m.minLength=y),typeof k=="number"&&(m.maxLength=k),x&&(m.format=o[x]??x,m.format===""&&delete m.format),g&&(m.contentEncoding=g),_&&_.size>0){let E=[..._];E.length===1?m.pattern=E[0].source:E.length>1&&(a.schema.allOf=[...E.map(h=>({...this.target==="draft-7"?{type:"string"}:{},pattern:h.source}))])}break}case"number":{let m=p,{minimum:y,maximum:k,format:x,multipleOf:_,exclusiveMaximum:g,exclusiveMinimum:E}=e._zod.bag;typeof x=="string"&&x.includes("int")?m.type="integer":m.type="number",typeof E=="number"&&(m.exclusiveMinimum=E),typeof y=="number"&&(m.minimum=y,typeof E=="number"&&(E>=y?delete m.minimum:delete m.exclusiveMinimum)),typeof g=="number"&&(m.exclusiveMaximum=g),typeof k=="number"&&(m.maximum=k,typeof g=="number"&&(g<=k?delete m.maximum:delete m.exclusiveMaximum)),typeof _=="number"&&(m.multipleOf=_);break}case"boolean":{let m=p;m.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 m=p,{minimum:y,maximum:k}=e._zod.bag;typeof y=="number"&&(m.minItems=y),typeof k=="number"&&(m.maxItems=k),m.type="array",m.items=this.process(s.element,{...u,path:[...u.path,"items"]});break}case"object":{let m=p;m.type="object",m.properties={};let y=s.shape;for(let _ in y)m.properties[_]=this.process(y[_],{...u,path:[...u.path,"properties",_]});let k=new Set(Object.keys(y)),x=new Set([...k].filter(_=>{let g=s.shape[_]._zod;return this.io==="input"?g.optin===void 0:g.optout===void 0}));x.size>0&&(m.required=Array.from(x)),s.catchall?._zod.def.type==="never"?m.additionalProperties=!1:s.catchall?s.catchall&&(m.additionalProperties=this.process(s.catchall,{...u,path:[...u.path,"additionalProperties"]})):this.io==="output"&&(m.additionalProperties=!1);break}case"union":{let m=p;m.anyOf=s.options.map((y,k)=>this.process(y,{...u,path:[...u.path,"anyOf",k]}));break}case"intersection":{let m=p,y=this.process(s.left,{...u,path:[...u.path,"allOf",0]}),k=this.process(s.right,{...u,path:[...u.path,"allOf",1]}),x=g=>"allOf"in g&&Object.keys(g).length===1,_=[...x(y)?y.allOf:[y],...x(k)?k.allOf:[k]];m.allOf=_;break}case"tuple":{let m=p;m.type="array";let y=s.items.map((_,g)=>this.process(_,{...u,path:[...u.path,"prefixItems",g]}));if(this.target==="draft-2020-12"?m.prefixItems=y:m.items=y,s.rest){let _=this.process(s.rest,{...u,path:[...u.path,"items"]});this.target==="draft-2020-12"?m.items=_:m.additionalItems=_}s.rest&&(m.items=this.process(s.rest,{...u,path:[...u.path,"items"]}));let{minimum:k,maximum:x}=e._zod.bag;typeof k=="number"&&(m.minItems=k),typeof x=="number"&&(m.maxItems=x);break}case"record":{let m=p;m.type="object",m.propertyNames=this.process(s.keyType,{...u,path:[...u.path,"propertyNames"]}),m.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 m=p,y=Bi(s.entries);y.every(k=>typeof k=="number")&&(m.type="number"),y.every(k=>typeof k=="string")&&(m.type="string"),m.enum=y;break}case"literal":{let m=p,y=[];for(let k of s.values)if(k===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof k=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");y.push(Number(k))}else y.push(k);if(y.length!==0)if(y.length===1){let k=y[0];m.type=k===null?"null":typeof k,m.const=k}else y.every(k=>typeof k=="number")&&(m.type="number"),y.every(k=>typeof k=="string")&&(m.type="string"),y.every(k=>typeof k=="boolean")&&(m.type="string"),y.every(k=>k===null)&&(m.type="null"),m.enum=y;break}case"file":{let m=p,y={type:"string",format:"binary",contentEncoding:"binary"},{minimum:k,maximum:x,mime:_}=e._zod.bag;k!==void 0&&(y.minLength=k),x!==void 0&&(y.maxLength=x),_?_.length===1?(y.contentMediaType=_[0],Object.assign(m,y)):m.anyOf=_.map(g=>({...y,contentMediaType:g})):Object.assign(m,y);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let m=this.process(s.innerType,u);p.anyOf=[m,{type:"null"}];break}case"nonoptional":{this.process(s.innerType,u),a.ref=s.innerType;break}case"success":{let m=p;m.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 m;try{m=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}p.default=m;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let m=p,y=e._zod.pattern;if(!y)throw new Error("Pattern not found in template literal");m.type="string",m.pattern=y.source;break}case"pipe":{let m=this.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;this.process(m,u),a.ref=m;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 m=e._zod.innerType;this.process(m,u),a.ref=m;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"&&Qt(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 y=n.external.registry.get(l[0])?.id,k=n.external.uri??(_=>_);if(y)return{ref:k(y)};let x=l[1].defId??l[1].schema.id??`schema${this.counter++}`;return l[1].defId=x,{defId:x,ref:`${k("__shared")}#/${u}/${x}`}}if(l[1]===s)return{ref:"#"};let p=`#/${u}/`,m=l[1].schema.id??`__schema${this.counter++}`;return{defId:m,ref:p+m}},i=l=>{if(l[1].schema.$ref)return;let u=l[1],{ref:f,defId:p}=o(l);u.def={...u.schema},p&&(u.defId=p);let m=u.schema;for(let y in m)delete m[y];m.$ref=f};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>
|
|
33
|
+
path: iss.path ? [${Ks(_)}, ...iss.path] : [${Ks(_)}]
|
|
34
|
+
})));`),f.write(`newResult[${Ks(_)}] = ${g}.value`)}f.write("payload.value = newResult;"),f.write("return payload;");let x=f.compile();return(_,g)=>x(u,_,g)},s,o=Zo,i=!pc.jitless,c=i&&ud.value,d=e.catchall,l;t._zod.parse=(u,f)=>{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 m=[];if(i&&c&&f?.async===!1&&f.jitless!==!0)s||(s=n(e.shape)),u=s(u,f);else{u.value={};let g=l.shape;for(let E of l.keys){let h=g[E],$=h._zod.run({value:p[E],issues:[]},f),z=h._zod.optin==="optional"&&h._zod.optout==="optional";$ instanceof Promise?m.push($.then(L=>z?Tg(L,u,E,p):wc(L,u,E))):z?Tg($,u,E,p):wc($,u,E)}}if(!d)return m.length?Promise.all(m).then(()=>u):u;let y=[],k=l.keySet,x=d._zod,_=x.def.type;for(let g of Object.keys(p)){if(k.has(g))continue;if(_==="never"){y.push(g);continue}let E=x.run({value:p[g],issues:[]},f);E instanceof Promise?m.push(E.then(h=>wc(h,u,g))):wc(E,u,g)}return y.length&&u.issues.push({code:"unrecognized_keys",keys:y,input:p,inst:t}),m.length?Promise.all(m).then(()=>u):u}});function Rg(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=>bn(o,n,qr())))}),e}var kc=le("$ZodUnion",(t,e)=>{kt.init(t,e),Mt(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Mt(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Mt(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),Mt(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=>qi(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=>Rg(i,r,t,n)):Rg(o,r,t,n)}}),Qd=le("$ZodDiscriminatedUnion",(t,e)=>{kc.init(t,e);let r=t._zod.parse;Mt(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=Bi(()=>{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(!Zo(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)}}),eh=le("$ZodIntersection",(t,e)=>{kt.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])=>Pg(r,c,d)):Pg(r,o,i)}});function Td(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(Bo(t)&&Bo(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=Td(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=Td(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 Pg(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),Js(t))return t;let n=Td(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 th=le("$ZodRecord",(t,e)=>{kt.init(t,e),t._zod.parse=(r,n)=>{let s=r.value;if(!Bo(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(...Nn(c,l.issues)),r.value[c]=l.value})):(d.issues.length&&r.issues.push(...Nn(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=>bn(d,n,qr())),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(...Nn(i,d.issues)),r.value[a.value]=d.value})):(c.issues.length&&r.issues.push(...Nn(i,c.issues)),r.value[a.value]=c.value)}}return o.length?Promise.all(o).then(()=>r):r}});var rh=le("$ZodEnum",(t,e)=>{kt.init(t,e);let r=Zi(e.entries);t._zod.values=new Set(r),t._zod.pattern=new RegExp(`^(${r.filter(n=>dd.has(typeof n)).map(n=>typeof n=="string"?cs(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}}),nh=le("$ZodLiteral",(t,e)=>{kt.init(t,e),t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?cs(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 sh=le("$ZodTransform",(t,e)=>{kt.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 Yn;return r.value=s,r}}),oh=le("$ZodOptional",(t,e)=>{kt.init(t,e),t._zod.optin="optional",t._zod.optout="optional",Mt(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),Mt(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${qi(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)}),ih=le("$ZodNullable",(t,e)=>{kt.init(t,e),Mt(t._zod,"optin",()=>e.innerType._zod.optin),Mt(t._zod,"optout",()=>e.innerType._zod.optout),Mt(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${qi(r.source)}|null)$`):void 0}),Mt(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)}),ah=le("$ZodDefault",(t,e)=>{kt.init(t,e),t._zod.optin="optional",Mt(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=>Mg(o,e)):Mg(s,e)}});function Mg(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}var ch=le("$ZodPrefault",(t,e)=>{kt.init(t,e),t._zod.optin="optional",Mt(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))}),lh=le("$ZodNonOptional",(t,e)=>{kt.init(t,e),Mt(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=>Ig(o,t)):Ig(s,t)}});function Ig(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 uh=le("$ZodCatch",(t,e)=>{kt.init(t,e),t._zod.optin="optional",Mt(t._zod,"optout",()=>e.innerType._zod.optout),Mt(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=>bn(i,n,qr()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(o=>bn(o,n,qr()))},input:r.value}),r.issues=[]),r)}});var dh=le("$ZodPipe",(t,e)=>{kt.init(t,e),Mt(t._zod,"values",()=>e.in._zod.values),Mt(t._zod,"optin",()=>e.in._zod.optin),Mt(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=>zg(o,e,n)):zg(s,e,n)}});function zg(t,e,r){return Js(t)?t:e.out._zod.run({value:t.value,issues:t.issues},r)}var hh=le("$ZodReadonly",(t,e)=>{kt.init(t,e),Mt(t._zod,"propValues",()=>e.innerType._zod.propValues),Mt(t._zod,"values",()=>e.innerType._zod.values),Mt(t._zod,"optin",()=>e.innerType._zod.optin),Mt(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(Ag):Ag(s)}});function Ag(t){return t.value=Object.freeze(t.value),t}var fh=le("$ZodCustom",(t,e)=>{ar.init(t,e),kt.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=>Og(o,r,n,t));Og(s,r,n,t)}});function Og(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(pd(s))}}var lS=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},uS=()=>{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 ${lS(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${_c(n.values[0])}`:`Invalid option: expected one of ${mc(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":""}: ${mc(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 Zg(){return{localeError:uS()}}var dS=Symbol("ZodOutput"),hS=Symbol("ZodInput"),Wi=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 Bg(){return new Wi}var ls=Bg();function ph(t,e){return new t({type:"string",...Xe(e)})}function mh(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...Xe(e)})}function $c(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...Xe(e)})}function gh(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...Xe(e)})}function _h(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Xe(e)})}function bh(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Xe(e)})}function yh(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Xe(e)})}function vh(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Xe(e)})}function wh(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...Xe(e)})}function xh(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...Xe(e)})}function Sh(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...Xe(e)})}function kh(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...Xe(e)})}function $h(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...Xe(e)})}function Eh(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...Xe(e)})}function Th(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...Xe(e)})}function Rh(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...Xe(e)})}function Ph(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...Xe(e)})}function Mh(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Xe(e)})}function Ih(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Xe(e)})}function zh(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...Xe(e)})}function Ah(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...Xe(e)})}function Oh(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...Xe(e)})}function Nh(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...Xe(e)})}function Vg(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Xe(e)})}function qg(t,e){return new t({type:"string",format:"date",check:"string_format",...Xe(e)})}function Fg(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...Xe(e)})}function Ug(t,e){return new t({type:"string",format:"duration",check:"string_format",...Xe(e)})}function Ch(t,e){return new t({type:"number",checks:[],...Xe(e)})}function jh(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Xe(e)})}function Dh(t,e){return new t({type:"boolean",...Xe(e)})}function Lh(t,e){return new t({type:"null",...Xe(e)})}function Zh(t){return new t({type:"unknown"})}function Bh(t,e){return new t({type:"never",...Xe(e)})}function Ec(t,e){return new $d({check:"less_than",...Xe(e),value:t,inclusive:!1})}function Yi(t,e){return new $d({check:"less_than",...Xe(e),value:t,inclusive:!0})}function Tc(t,e){return new Ed({check:"greater_than",...Xe(e),value:t,inclusive:!1})}function Xi(t,e){return new Ed({check:"greater_than",...Xe(e),value:t,inclusive:!0})}function Rc(t,e){return new hg({check:"multiple_of",...Xe(e),value:t})}function Pc(t,e){return new pg({check:"max_length",...Xe(e),maximum:t})}function Vo(t,e){return new mg({check:"min_length",...Xe(e),minimum:t})}function Mc(t,e){return new gg({check:"length_equals",...Xe(e),length:t})}function Vh(t,e){return new _g({check:"string_format",format:"regex",...Xe(e),pattern:t})}function qh(t){return new bg({check:"string_format",format:"lowercase",...Xe(t)})}function Fh(t){return new yg({check:"string_format",format:"uppercase",...Xe(t)})}function Uh(t,e){return new vg({check:"string_format",format:"includes",...Xe(e),includes:t})}function Hh(t,e){return new wg({check:"string_format",format:"starts_with",...Xe(e),prefix:t})}function Gh(t,e){return new xg({check:"string_format",format:"ends_with",...Xe(e),suffix:t})}function to(t){return new Sg({check:"overwrite",tx:t})}function Wh(t){return to(e=>e.normalize(t))}function Yh(){return to(t=>t.trim())}function Xh(){return to(t=>t.toLowerCase())}function Kh(){return to(t=>t.toUpperCase())}function Hg(t,e,r){return new t({type:"array",element:e,...Xe(r)})}function Jh(t,e,r){let n=Xe(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function Qh(t,e,r){return new t({type:"custom",check:"custom",fn:e,...Xe(r)})}var Ic=class{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??ls,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},f=e._zod.parent;if(f)a.ref=f,this.process(f,u),this.seen.get(f).isParent=!0;else{let p=a.schema;switch(s.type){case"string":{let m=p;m.type="string";let{minimum:y,maximum:k,format:x,patterns:_,contentEncoding:g}=e._zod.bag;if(typeof y=="number"&&(m.minLength=y),typeof k=="number"&&(m.maxLength=k),x&&(m.format=o[x]??x,m.format===""&&delete m.format),g&&(m.contentEncoding=g),_&&_.size>0){let E=[..._];E.length===1?m.pattern=E[0].source:E.length>1&&(a.schema.allOf=[...E.map(h=>({...this.target==="draft-7"?{type:"string"}:{},pattern:h.source}))])}break}case"number":{let m=p,{minimum:y,maximum:k,format:x,multipleOf:_,exclusiveMaximum:g,exclusiveMinimum:E}=e._zod.bag;typeof x=="string"&&x.includes("int")?m.type="integer":m.type="number",typeof E=="number"&&(m.exclusiveMinimum=E),typeof y=="number"&&(m.minimum=y,typeof E=="number"&&(E>=y?delete m.minimum:delete m.exclusiveMinimum)),typeof g=="number"&&(m.exclusiveMaximum=g),typeof k=="number"&&(m.maximum=k,typeof g=="number"&&(g<=k?delete m.maximum:delete m.exclusiveMaximum)),typeof _=="number"&&(m.multipleOf=_);break}case"boolean":{let m=p;m.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 m=p,{minimum:y,maximum:k}=e._zod.bag;typeof y=="number"&&(m.minItems=y),typeof k=="number"&&(m.maxItems=k),m.type="array",m.items=this.process(s.element,{...u,path:[...u.path,"items"]});break}case"object":{let m=p;m.type="object",m.properties={};let y=s.shape;for(let _ in y)m.properties[_]=this.process(y[_],{...u,path:[...u.path,"properties",_]});let k=new Set(Object.keys(y)),x=new Set([...k].filter(_=>{let g=s.shape[_]._zod;return this.io==="input"?g.optin===void 0:g.optout===void 0}));x.size>0&&(m.required=Array.from(x)),s.catchall?._zod.def.type==="never"?m.additionalProperties=!1:s.catchall?s.catchall&&(m.additionalProperties=this.process(s.catchall,{...u,path:[...u.path,"additionalProperties"]})):this.io==="output"&&(m.additionalProperties=!1);break}case"union":{let m=p;m.anyOf=s.options.map((y,k)=>this.process(y,{...u,path:[...u.path,"anyOf",k]}));break}case"intersection":{let m=p,y=this.process(s.left,{...u,path:[...u.path,"allOf",0]}),k=this.process(s.right,{...u,path:[...u.path,"allOf",1]}),x=g=>"allOf"in g&&Object.keys(g).length===1,_=[...x(y)?y.allOf:[y],...x(k)?k.allOf:[k]];m.allOf=_;break}case"tuple":{let m=p;m.type="array";let y=s.items.map((_,g)=>this.process(_,{...u,path:[...u.path,"prefixItems",g]}));if(this.target==="draft-2020-12"?m.prefixItems=y:m.items=y,s.rest){let _=this.process(s.rest,{...u,path:[...u.path,"items"]});this.target==="draft-2020-12"?m.items=_:m.additionalItems=_}s.rest&&(m.items=this.process(s.rest,{...u,path:[...u.path,"items"]}));let{minimum:k,maximum:x}=e._zod.bag;typeof k=="number"&&(m.minItems=k),typeof x=="number"&&(m.maxItems=x);break}case"record":{let m=p;m.type="object",m.propertyNames=this.process(s.keyType,{...u,path:[...u.path,"propertyNames"]}),m.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 m=p,y=Zi(s.entries);y.every(k=>typeof k=="number")&&(m.type="number"),y.every(k=>typeof k=="string")&&(m.type="string"),m.enum=y;break}case"literal":{let m=p,y=[];for(let k of s.values)if(k===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof k=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");y.push(Number(k))}else y.push(k);if(y.length!==0)if(y.length===1){let k=y[0];m.type=k===null?"null":typeof k,m.const=k}else y.every(k=>typeof k=="number")&&(m.type="number"),y.every(k=>typeof k=="string")&&(m.type="string"),y.every(k=>typeof k=="boolean")&&(m.type="string"),y.every(k=>k===null)&&(m.type="null"),m.enum=y;break}case"file":{let m=p,y={type:"string",format:"binary",contentEncoding:"binary"},{minimum:k,maximum:x,mime:_}=e._zod.bag;k!==void 0&&(y.minLength=k),x!==void 0&&(y.maxLength=x),_?_.length===1?(y.contentMediaType=_[0],Object.assign(m,y)):m.anyOf=_.map(g=>({...y,contentMediaType:g})):Object.assign(m,y);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let m=this.process(s.innerType,u);p.anyOf=[m,{type:"null"}];break}case"nonoptional":{this.process(s.innerType,u),a.ref=s.innerType;break}case"success":{let m=p;m.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 m;try{m=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}p.default=m;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let m=p,y=e._zod.pattern;if(!y)throw new Error("Pattern not found in template literal");m.type="string",m.pattern=y.source;break}case"pipe":{let m=this.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;this.process(m,u),a.ref=m;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 m=e._zod.innerType;this.process(m,u),a.ref=m;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"&&Qt(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 y=n.external.registry.get(l[0])?.id,k=n.external.uri??(_=>_);if(y)return{ref:k(y)};let x=l[1].defId??l[1].schema.id??`schema${this.counter++}`;return l[1].defId=x,{defId:x,ref:`${k("__shared")}#/${u}/${x}`}}if(l[1]===s)return{ref:"#"};let p=`#/${u}/`,m=l[1].schema.id??`__schema${this.counter++}`;return{defId:m,ref:p+m}},i=l=>{if(l[1].schema.$ref)return;let u=l[1],{ref:f,defId:p}=o(l);u.def={...u.schema},p&&(u.defId=p);let m=u.schema;for(let y in m)delete m[y];m.$ref=f};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
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 f=this.seen.get(l),p=f.def??f.schema,m={...p};if(f.ref===null)return;let y=f.ref;if(f.ref=null,y){a(y,u);let k=this.seen.get(y).schema;k.$ref&&u.target==="draft-7"?(p.allOf=p.allOf??[],p.allOf.push(k)):(Object.assign(p,k),Object.assign(p,m))}f.isParent||this.override({zodSchema:l,jsonSchema:p,path:f.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 ef(t,e){if(t instanceof Yi){let n=new Oc(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 Oc(e);return r.process(t),r.emit(t,e)}function Qt(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 Qt(s.element,r);case"object":{for(let o in s.shape)if(Qt(s.shape[o],r))return!0;return!1}case"union":{for(let o of s.options)if(Qt(o,r))return!0;return!1}case"intersection":return Qt(s.left,r)||Qt(s.right,r);case"tuple":{for(let o of s.items)if(Qt(o,r))return!0;return!!(s.rest&&Qt(s.rest,r))}case"record":return Qt(s.keyType,r)||Qt(s.valueType,r);case"map":return Qt(s.keyType,r)||Qt(s.valueType,r);case"set":return Qt(s.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return Qt(s.innerType,r);case"lazy":return Qt(s.getter(),r);case"default":return Qt(s.innerType,r);case"prefault":return Qt(s.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return Qt(s.in,r)||Qt(s.out,r);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${s.type}`)}var WS=le("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");kt.init(t,e),t.def=e,t.parse=(r,n)=>bd(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>eo(t,r,n),t.parseAsync=async(r,n)=>vd(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>to(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)=>Fr(t,r,n),t.brand=()=>t,t.register=(r,n)=>(r.add(t,n),t)});var YS=le("ZodMiniObject",(t,e)=>{kc.init(t,e),WS.init(t,e),ht.defineLazy(t,"shape",()=>e.shape)});function tf(t,e){let r={type:"object",get shape(){return ht.assignProp(this,"shape",{...t}),this.shape},...ht.normalizeParams(e)};return new YS(r)}function en(t){return!!t._zod}function so(t){let e=Object.values(t);if(e.length===0)return tf({});let r=e.every(en),n=e.every(s=>!en(s));if(r)return tf(t);if(n)return sd(t);throw new Error("Mixed Zod versions detected in object shape.")}function us(t,e){return en(t)?eo(t,e):t.safeParse(e)}async function Ac(t,e){return en(t)?await to(t,e):await t.safeParseAsync(e)}function ds(t){if(!t)return;let e;if(en(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function Fo(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 so(t)}}if(en(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 zc(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 Wg(t){return t.description}function Yg(t){if(en(t))return t._zod?.def?.type==="optional";let e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function Nc(t){if(en(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 Ji={};ed(Ji,{ZodISODate:()=>Kg,ZodISODateTime:()=>Xg,ZodISODuration:()=>Qg,ZodISOTime:()=>Jg,date:()=>nf,datetime:()=>rf,duration:()=>of,time:()=>sf});var Xg=le("ZodISODateTime",(t,e)=>{Ng.init(t,e),Lt.init(t,e)});function rf(t){return Vg(Xg,t)}var Kg=le("ZodISODate",(t,e)=>{Cg.init(t,e),Lt.init(t,e)});function nf(t){return qg(Kg,t)}var Jg=le("ZodISOTime",(t,e)=>{jg.init(t,e),Lt.init(t,e)});function sf(t){return Fg(Jg,t)}var Qg=le("ZodISODuration",(t,e)=>{Dg.init(t,e),Lt.init(t,e)});function of(t){return Hg(Qg,t)}var e_=(t,e)=>{yc.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>gd(t,r)},flatten:{value:r=>md(t,r)},addIssue:{value:r=>t.issues.push(r)},addIssues:{value:r=>t.issues.push(...r)},isEmpty:{get(){return t.issues.length===0}}})},Lj=le("ZodError",e_),Qi=le("ZodError",e_,{Parent:Error});var t_=_d(Qi),r_=yd(Qi),n_=wd(Qi),s_=xd(Qi);var Ft=le("ZodType",(t,e)=>(kt.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)=>Fr(t,r,n),t.brand=()=>t,t.register=(r,n)=>(r.add(t,n),t),t.parse=(r,n)=>t_(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>n_(t,r,n),t.parseAsync=async(r,n)=>r_(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>s_(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(Uk(r,n)),t.superRefine=r=>t.check(Gk(r)),t.overwrite=r=>t.check(ro(r)),t.optional=()=>Bt(t),t.nullable=()=>a_(t),t.nullish=()=>Bt(a_(t)),t.nonoptional=r=>Lk(t,r),t.array=()=>ft(t),t.or=r=>At([t,r]),t.and=r=>jc(t,r),t.transform=r=>cf(t,f_(r)),t.default=r=>Ck(t,r),t.prefault=r=>Dk(t,r),t.catch=r=>Bk(t,r),t.pipe=r=>cf(t,r),t.readonly=()=>Fk(t),t.describe=r=>{let n=t.clone();return ls.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return ls.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return ls.get(t);let n=t.clone();return ls.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),c_=le("_ZodString",(t,e)=>{Wi.init(t,e),Ft.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(Vh(...n)),t.includes=(...n)=>t.check(Hh(...n)),t.startsWith=(...n)=>t.check(Uh(...n)),t.endsWith=(...n)=>t.check(Gh(...n)),t.min=(...n)=>t.check(qo(...n)),t.max=(...n)=>t.check(Pc(...n)),t.length=(...n)=>t.check(Mc(...n)),t.nonempty=(...n)=>t.check(qo(1,...n)),t.lowercase=n=>t.check(qh(n)),t.uppercase=n=>t.check(Fh(n)),t.trim=()=>t.check(Yh()),t.normalize=(...n)=>t.check(Wh(...n)),t.toLowerCase=()=>t.check(Xh()),t.toUpperCase=()=>t.check(Kh())}),sk=le("ZodString",(t,e)=>{Wi.init(t,e),c_.init(t,e),t.email=r=>t.check(mh(ok,r)),t.url=r=>t.check(vh(ik,r)),t.jwt=r=>t.check(Nh(wk,r)),t.emoji=r=>t.check(wh(ak,r)),t.guid=r=>t.check(Ec(o_,r)),t.uuid=r=>t.check(gh(Cc,r)),t.uuidv4=r=>t.check(_h(Cc,r)),t.uuidv6=r=>t.check(bh(Cc,r)),t.uuidv7=r=>t.check(yh(Cc,r)),t.nanoid=r=>t.check(xh(ck,r)),t.guid=r=>t.check(Ec(o_,r)),t.cuid=r=>t.check(Sh(lk,r)),t.cuid2=r=>t.check(kh(uk,r)),t.ulid=r=>t.check($h(dk,r)),t.base64=r=>t.check(Oh(bk,r)),t.base64url=r=>t.check(Ah(yk,r)),t.xid=r=>t.check(Eh(hk,r)),t.ksuid=r=>t.check(Th(fk,r)),t.ipv4=r=>t.check(Rh(pk,r)),t.ipv6=r=>t.check(Ih(mk,r)),t.cidrv4=r=>t.check(Ph(gk,r)),t.cidrv6=r=>t.check(Mh(_k,r)),t.e164=r=>t.check(zh(vk,r)),t.datetime=r=>t.check(rf(r)),t.date=r=>t.check(nf(r)),t.time=r=>t.check(sf(r)),t.duration=r=>t.check(of(r))});function ce(t){return ph(sk,t)}var Lt=le("ZodStringFormat",(t,e)=>{Mt.init(t,e),c_.init(t,e)}),ok=le("ZodEmail",(t,e)=>{Pd.init(t,e),Lt.init(t,e)});var o_=le("ZodGUID",(t,e)=>{Rd.init(t,e),Lt.init(t,e)});var Cc=le("ZodUUID",(t,e)=>{Id.init(t,e),Lt.init(t,e)});var ik=le("ZodURL",(t,e)=>{Md.init(t,e),Lt.init(t,e)});var ak=le("ZodEmoji",(t,e)=>{Od.init(t,e),Lt.init(t,e)});var ck=le("ZodNanoID",(t,e)=>{Ad.init(t,e),Lt.init(t,e)});var lk=le("ZodCUID",(t,e)=>{zd.init(t,e),Lt.init(t,e)});var uk=le("ZodCUID2",(t,e)=>{Nd.init(t,e),Lt.init(t,e)});var dk=le("ZodULID",(t,e)=>{Cd.init(t,e),Lt.init(t,e)});var hk=le("ZodXID",(t,e)=>{jd.init(t,e),Lt.init(t,e)});var fk=le("ZodKSUID",(t,e)=>{Dd.init(t,e),Lt.init(t,e)});var pk=le("ZodIPv4",(t,e)=>{Ld.init(t,e),Lt.init(t,e)});var mk=le("ZodIPv6",(t,e)=>{Zd.init(t,e),Lt.init(t,e)});var gk=le("ZodCIDRv4",(t,e)=>{Bd.init(t,e),Lt.init(t,e)});var _k=le("ZodCIDRv6",(t,e)=>{Vd.init(t,e),Lt.init(t,e)});var bk=le("ZodBase64",(t,e)=>{qd.init(t,e),Lt.init(t,e)});var yk=le("ZodBase64URL",(t,e)=>{Fd.init(t,e),Lt.init(t,e)});var vk=le("ZodE164",(t,e)=>{Hd.init(t,e),Lt.init(t,e)});var wk=le("ZodJWT",(t,e)=>{Ud.init(t,e),Lt.init(t,e)});var l_=le("ZodNumber",(t,e)=>{Sc.init(t,e),Ft.init(t,e),t.gt=(n,s)=>t.check(Rc(n,s)),t.gte=(n,s)=>t.check(Ki(n,s)),t.min=(n,s)=>t.check(Ki(n,s)),t.lt=(n,s)=>t.check(Tc(n,s)),t.lte=(n,s)=>t.check(Xi(n,s)),t.max=(n,s)=>t.check(Xi(n,s)),t.int=n=>t.check(i_(n)),t.safe=n=>t.check(i_(n)),t.positive=n=>t.check(Rc(0,n)),t.nonnegative=n=>t.check(Ki(0,n)),t.negative=n=>t.check(Tc(0,n)),t.nonpositive=n=>t.check(Xi(0,n)),t.multipleOf=(n,s)=>t.check(Ic(n,s)),t.step=(n,s)=>t.check(Ic(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 St(t){return Ch(l_,t)}var xk=le("ZodNumberFormat",(t,e)=>{Gd.init(t,e),l_.init(t,e)});function i_(t){return jh(xk,t)}var Sk=le("ZodBoolean",(t,e)=>{Wd.init(t,e),Ft.init(t,e)});function or(t){return Dh(Sk,t)}var kk=le("ZodNull",(t,e)=>{Yd.init(t,e),Ft.init(t,e)});function u_(t){return Lh(kk,t)}var $k=le("ZodUnknown",(t,e)=>{Xd.init(t,e),Ft.init(t,e)});function Zt(){return Zh($k)}var Ek=le("ZodNever",(t,e)=>{Kd.init(t,e),Ft.init(t,e)});function Tk(t){return Bh(Ek,t)}var Rk=le("ZodArray",(t,e)=>{Jd.init(t,e),Ft.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(qo(r,n)),t.nonempty=r=>t.check(qo(1,r)),t.max=(r,n)=>t.check(Pc(r,n)),t.length=(r,n)=>t.check(Mc(r,n)),t.unwrap=()=>t.element});function ft(t,e){return Ug(Rk,t,e)}var d_=le("ZodObject",(t,e)=>{kc.init(t,e),Ft.init(t,e),ht.defineLazy(t,"shape",()=>e.shape),t.keyof=()=>Mr(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:Zt()}),t.loose=()=>t.clone({...t._zod.def,catchall:Zt()}),t.strict=()=>t.clone({...t._zod.def,catchall:Tk()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>ht.extend(t,r),t.merge=r=>ht.merge(t,r),t.pick=r=>ht.pick(t,r),t.omit=r=>ht.omit(t,r),t.partial=(...r)=>ht.partial(p_,t,r[0]),t.required=(...r)=>ht.required(m_,t,r[0])});function Ne(t,e){let r={type:"object",get shape(){return ht.assignProp(this,"shape",{...t}),this.shape},...ht.normalizeParams(e)};return new d_(r)}function vr(t,e){return new d_({type:"object",get shape(){return ht.assignProp(this,"shape",{...t}),this.shape},catchall:Zt(),...ht.normalizeParams(e)})}var h_=le("ZodUnion",(t,e)=>{$c.init(t,e),Ft.init(t,e),t.options=e.options});function At(t,e){return new h_({type:"union",options:t,...ht.normalizeParams(e)})}var Ik=le("ZodDiscriminatedUnion",(t,e)=>{h_.init(t,e),Qd.init(t,e)});function lf(t,e,r){return new Ik({type:"union",options:e,discriminator:t,...ht.normalizeParams(r)})}var Pk=le("ZodIntersection",(t,e)=>{eh.init(t,e),Ft.init(t,e)});function jc(t,e){return new Pk({type:"intersection",left:t,right:e})}var Mk=le("ZodRecord",(t,e)=>{th.init(t,e),Ft.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});function Ot(t,e,r){return new Mk({type:"record",keyType:t,valueType:e,...ht.normalizeParams(r)})}var af=le("ZodEnum",(t,e)=>{rh.init(t,e),Ft.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 af({...e,checks:[],...ht.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 af({...e,checks:[],...ht.normalizeParams(s),entries:o})}});function Mr(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new af({type:"enum",entries:r,...ht.normalizeParams(e)})}var Ok=le("ZodLiteral",(t,e)=>{nh.init(t,e),Ft.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 Fe(t,e){return new Ok({type:"literal",values:Array.isArray(t)?t:[t],...ht.normalizeParams(e)})}var Ak=le("ZodTransform",(t,e)=>{sh.init(t,e),Ft.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push(ht.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(ht.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 f_(t){return new Ak({type:"transform",transform:t})}var p_=le("ZodOptional",(t,e)=>{oh.init(t,e),Ft.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Bt(t){return new p_({type:"optional",innerType:t})}var zk=le("ZodNullable",(t,e)=>{ih.init(t,e),Ft.init(t,e),t.unwrap=()=>t._zod.def.innerType});function a_(t){return new zk({type:"nullable",innerType:t})}var Nk=le("ZodDefault",(t,e)=>{ah.init(t,e),Ft.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function Ck(t,e){return new Nk({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var jk=le("ZodPrefault",(t,e)=>{ch.init(t,e),Ft.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Dk(t,e){return new jk({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var m_=le("ZodNonOptional",(t,e)=>{lh.init(t,e),Ft.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Lk(t,e){return new m_({type:"nonoptional",innerType:t,...ht.normalizeParams(e)})}var Zk=le("ZodCatch",(t,e)=>{uh.init(t,e),Ft.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function Bk(t,e){return new Zk({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var Vk=le("ZodPipe",(t,e)=>{dh.init(t,e),Ft.init(t,e),t.in=e.in,t.out=e.out});function cf(t,e){return new Vk({type:"pipe",in:t,out:e})}var qk=le("ZodReadonly",(t,e)=>{hh.init(t,e),Ft.init(t,e)});function Fk(t){return new qk({type:"readonly",innerType:t})}var g_=le("ZodCustom",(t,e)=>{fh.init(t,e),Ft.init(t,e)});function Hk(t){let e=new ar({check:"custom"});return e._zod.check=t,e}function __(t,e){return Jh(g_,t??(()=>!0),e)}function Uk(t,e={}){return Qh(g_,t,e)}function Gk(t){let e=Hk(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(ht.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(ht.issue(s))}},t(r.value,r)));return e}function uf(t,e){return cf(f_(t),e)}qr(Zg());var hf="2025-11-25";var b_=[hf,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],hs="io.modelcontextprotocol/related-task",Lc="2.0",er=__(t=>t!==null&&(typeof t=="object"||typeof t=="function")),y_=At([ce(),St().int()]),v_=ce(),Qj=vr({ttl:St().optional(),pollInterval:St().optional()}),Wk=Ne({ttl:St().optional()}),Yk=Ne({taskId:ce()}),ff=vr({progressToken:y_.optional(),[hs]:Yk.optional()}),Hr=Ne({_meta:ff.optional()}),ea=Hr.extend({task:Wk.optional()}),w_=t=>ea.safeParse(t).success,cr=Ne({method:ce(),params:Hr.loose().optional()}),tn=Ne({_meta:ff.optional()}),rn=Ne({method:ce(),params:tn.loose().optional()}),lr=vr({_meta:ff.optional()}),Zc=At([ce(),St().int()]),x_=Ne({jsonrpc:Fe(Lc),id:Zc,...cr.shape}).strict(),pf=t=>x_.safeParse(t).success,S_=Ne({jsonrpc:Fe(Lc),...rn.shape}).strict(),k_=t=>S_.safeParse(t).success,mf=Ne({jsonrpc:Fe(Lc),id:Zc,result:lr}).strict(),ta=t=>mf.safeParse(t).success;var Ge;(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"})(Ge||(Ge={}));var gf=Ne({jsonrpc:Fe(Lc),id:Zc.optional(),error:Ne({code:St().int(),message:ce(),data:Zt().optional()})}).strict();var $_=t=>gf.safeParse(t).success;var E_=At([x_,S_,mf,gf]),eD=At([mf,gf]),Bc=lr.strict(),Xk=tn.extend({requestId:Zc.optional(),reason:ce().optional()}),Vc=rn.extend({method:Fe("notifications/cancelled"),params:Xk}),Kk=Ne({src:ce(),mimeType:ce().optional(),sizes:ft(ce()).optional(),theme:Mr(["light","dark"]).optional()}),ra=Ne({icons:ft(Kk).optional()}),Ho=Ne({name:ce(),title:ce().optional()}),T_=Ho.extend({...Ho.shape,...ra.shape,version:ce(),websiteUrl:ce().optional(),description:ce().optional()}),Jk=jc(Ne({applyDefaults:or().optional()}),Ot(ce(),Zt())),Qk=uf(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,jc(Ne({form:Jk.optional(),url:er.optional()}),Ot(ce(),Zt()).optional())),e9=vr({list:er.optional(),cancel:er.optional(),requests:vr({sampling:vr({createMessage:er.optional()}).optional(),elicitation:vr({create:er.optional()}).optional()}).optional()}),t9=vr({list:er.optional(),cancel:er.optional(),requests:vr({tools:vr({call:er.optional()}).optional()}).optional()}),r9=Ne({experimental:Ot(ce(),er).optional(),sampling:Ne({context:er.optional(),tools:er.optional()}).optional(),elicitation:Qk.optional(),roots:Ne({listChanged:or().optional()}).optional(),tasks:e9.optional(),extensions:Ot(ce(),er).optional()}),n9=Hr.extend({protocolVersion:ce(),capabilities:r9,clientInfo:T_}),_f=cr.extend({method:Fe("initialize"),params:n9});var s9=Ne({experimental:Ot(ce(),er).optional(),logging:er.optional(),completions:er.optional(),prompts:Ne({listChanged:or().optional()}).optional(),resources:Ne({subscribe:or().optional(),listChanged:or().optional()}).optional(),tools:Ne({listChanged:or().optional()}).optional(),tasks:t9.optional(),extensions:Ot(ce(),er).optional()}),o9=lr.extend({protocolVersion:ce(),capabilities:s9,serverInfo:T_,instructions:ce().optional()}),bf=rn.extend({method:Fe("notifications/initialized"),params:tn.optional()});var qc=cr.extend({method:Fe("ping"),params:Hr.optional()}),i9=Ne({progress:St(),total:Bt(St()),message:Bt(ce())}),a9=Ne({...tn.shape,...i9.shape,progressToken:y_}),Fc=rn.extend({method:Fe("notifications/progress"),params:a9}),c9=Hr.extend({cursor:v_.optional()}),na=cr.extend({params:c9.optional()}),sa=lr.extend({nextCursor:v_.optional()}),l9=Mr(["working","input_required","completed","failed","cancelled"]),oa=Ne({taskId:ce(),status:l9,ttl:At([St(),u_()]),createdAt:ce(),lastUpdatedAt:ce(),pollInterval:Bt(St()),statusMessage:Bt(ce())}),Uo=lr.extend({task:oa}),u9=tn.merge(oa),ia=rn.extend({method:Fe("notifications/tasks/status"),params:u9}),Hc=cr.extend({method:Fe("tasks/get"),params:Hr.extend({taskId:ce()})}),Uc=lr.merge(oa),Gc=cr.extend({method:Fe("tasks/result"),params:Hr.extend({taskId:ce()})}),tD=lr.loose(),Wc=na.extend({method:Fe("tasks/list")}),Yc=sa.extend({tasks:ft(oa)}),Xc=cr.extend({method:Fe("tasks/cancel"),params:Hr.extend({taskId:ce()})}),R_=lr.merge(oa),I_=Ne({uri:ce(),mimeType:Bt(ce()),_meta:Ot(ce(),Zt()).optional()}),P_=I_.extend({text:ce()}),yf=ce().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),M_=I_.extend({blob:yf}),aa=Mr(["user","assistant"]),Go=Ne({audience:ft(aa).optional(),priority:St().min(0).max(1).optional(),lastModified:Ji.datetime({offset:!0}).optional()}),O_=Ne({...Ho.shape,...ra.shape,uri:ce(),description:Bt(ce()),mimeType:Bt(ce()),size:Bt(St()),annotations:Go.optional(),_meta:Bt(vr({}))}),d9=Ne({...Ho.shape,...ra.shape,uriTemplate:ce(),description:Bt(ce()),mimeType:Bt(ce()),annotations:Go.optional(),_meta:Bt(vr({}))}),Kc=na.extend({method:Fe("resources/list")}),h9=sa.extend({resources:ft(O_)}),Jc=na.extend({method:Fe("resources/templates/list")}),f9=sa.extend({resourceTemplates:ft(d9)}),vf=Hr.extend({uri:ce()}),p9=vf,Qc=cr.extend({method:Fe("resources/read"),params:p9}),m9=lr.extend({contents:ft(At([P_,M_]))}),g9=rn.extend({method:Fe("notifications/resources/list_changed"),params:tn.optional()}),_9=vf,b9=cr.extend({method:Fe("resources/subscribe"),params:_9}),y9=vf,v9=cr.extend({method:Fe("resources/unsubscribe"),params:y9}),w9=tn.extend({uri:ce()}),x9=rn.extend({method:Fe("notifications/resources/updated"),params:w9}),S9=Ne({name:ce(),description:Bt(ce()),required:Bt(or())}),k9=Ne({...Ho.shape,...ra.shape,description:Bt(ce()),arguments:Bt(ft(S9)),_meta:Bt(vr({}))}),el=na.extend({method:Fe("prompts/list")}),$9=sa.extend({prompts:ft(k9)}),E9=Hr.extend({name:ce(),arguments:Ot(ce(),ce()).optional()}),tl=cr.extend({method:Fe("prompts/get"),params:E9}),wf=Ne({type:Fe("text"),text:ce(),annotations:Go.optional(),_meta:Ot(ce(),Zt()).optional()}),xf=Ne({type:Fe("image"),data:yf,mimeType:ce(),annotations:Go.optional(),_meta:Ot(ce(),Zt()).optional()}),Sf=Ne({type:Fe("audio"),data:yf,mimeType:ce(),annotations:Go.optional(),_meta:Ot(ce(),Zt()).optional()}),T9=Ne({type:Fe("tool_use"),name:ce(),id:ce(),input:Ot(ce(),Zt()),_meta:Ot(ce(),Zt()).optional()}),R9=Ne({type:Fe("resource"),resource:At([P_,M_]),annotations:Go.optional(),_meta:Ot(ce(),Zt()).optional()}),I9=O_.extend({type:Fe("resource_link")}),kf=At([wf,xf,Sf,I9,R9]),P9=Ne({role:aa,content:kf}),M9=lr.extend({description:ce().optional(),messages:ft(P9)}),O9=rn.extend({method:Fe("notifications/prompts/list_changed"),params:tn.optional()}),A9=Ne({title:ce().optional(),readOnlyHint:or().optional(),destructiveHint:or().optional(),idempotentHint:or().optional(),openWorldHint:or().optional()}),z9=Ne({taskSupport:Mr(["required","optional","forbidden"]).optional()}),A_=Ne({...Ho.shape,...ra.shape,description:ce().optional(),inputSchema:Ne({type:Fe("object"),properties:Ot(ce(),er).optional(),required:ft(ce()).optional()}).catchall(Zt()),outputSchema:Ne({type:Fe("object"),properties:Ot(ce(),er).optional(),required:ft(ce()).optional()}).catchall(Zt()).optional(),annotations:A9.optional(),execution:z9.optional(),_meta:Ot(ce(),Zt()).optional()}),rl=na.extend({method:Fe("tools/list")}),N9=sa.extend({tools:ft(A_)}),nl=lr.extend({content:ft(kf).default([]),structuredContent:Ot(ce(),Zt()).optional(),isError:or().optional()}),rD=nl.or(lr.extend({toolResult:Zt()})),C9=ea.extend({name:ce(),arguments:Ot(ce(),Zt()).optional()}),Wo=cr.extend({method:Fe("tools/call"),params:C9}),j9=rn.extend({method:Fe("notifications/tools/list_changed"),params:tn.optional()}),nD=Ne({autoRefresh:or().default(!0),debounceMs:St().int().nonnegative().default(300)}),ca=Mr(["debug","info","notice","warning","error","critical","alert","emergency"]),D9=Hr.extend({level:ca}),$f=cr.extend({method:Fe("logging/setLevel"),params:D9}),L9=tn.extend({level:ca,logger:ce().optional(),data:Zt()}),Z9=rn.extend({method:Fe("notifications/message"),params:L9}),B9=Ne({name:ce().optional()}),V9=Ne({hints:ft(B9).optional(),costPriority:St().min(0).max(1).optional(),speedPriority:St().min(0).max(1).optional(),intelligencePriority:St().min(0).max(1).optional()}),q9=Ne({mode:Mr(["auto","required","none"]).optional()}),F9=Ne({type:Fe("tool_result"),toolUseId:ce().describe("The unique identifier for the corresponding tool call."),content:ft(kf).default([]),structuredContent:Ne({}).loose().optional(),isError:or().optional(),_meta:Ot(ce(),Zt()).optional()}),H9=lf("type",[wf,xf,Sf]),Dc=lf("type",[wf,xf,Sf,T9,F9]),U9=Ne({role:aa,content:At([Dc,ft(Dc)]),_meta:Ot(ce(),Zt()).optional()}),G9=ea.extend({messages:ft(U9),modelPreferences:V9.optional(),systemPrompt:ce().optional(),includeContext:Mr(["none","thisServer","allServers"]).optional(),temperature:St().optional(),maxTokens:St().int(),stopSequences:ft(ce()).optional(),metadata:er.optional(),tools:ft(A_).optional(),toolChoice:q9.optional()}),W9=cr.extend({method:Fe("sampling/createMessage"),params:G9}),la=lr.extend({model:ce(),stopReason:Bt(Mr(["endTurn","stopSequence","maxTokens"]).or(ce())),role:aa,content:H9}),Ef=lr.extend({model:ce(),stopReason:Bt(Mr(["endTurn","stopSequence","maxTokens","toolUse"]).or(ce())),role:aa,content:At([Dc,ft(Dc)])}),Y9=Ne({type:Fe("boolean"),title:ce().optional(),description:ce().optional(),default:or().optional()}),X9=Ne({type:Fe("string"),title:ce().optional(),description:ce().optional(),minLength:St().optional(),maxLength:St().optional(),format:Mr(["email","uri","date","date-time"]).optional(),default:ce().optional()}),K9=Ne({type:Mr(["number","integer"]),title:ce().optional(),description:ce().optional(),minimum:St().optional(),maximum:St().optional(),default:St().optional()}),J9=Ne({type:Fe("string"),title:ce().optional(),description:ce().optional(),enum:ft(ce()),default:ce().optional()}),Q9=Ne({type:Fe("string"),title:ce().optional(),description:ce().optional(),oneOf:ft(Ne({const:ce(),title:ce()})),default:ce().optional()}),e6=Ne({type:Fe("string"),title:ce().optional(),description:ce().optional(),enum:ft(ce()),enumNames:ft(ce()).optional(),default:ce().optional()}),t6=At([J9,Q9]),r6=Ne({type:Fe("array"),title:ce().optional(),description:ce().optional(),minItems:St().optional(),maxItems:St().optional(),items:Ne({type:Fe("string"),enum:ft(ce())}),default:ft(ce()).optional()}),n6=Ne({type:Fe("array"),title:ce().optional(),description:ce().optional(),minItems:St().optional(),maxItems:St().optional(),items:Ne({anyOf:ft(Ne({const:ce(),title:ce()}))}),default:ft(ce()).optional()}),s6=At([r6,n6]),o6=At([e6,t6,s6]),i6=At([o6,Y9,X9,K9]),a6=ea.extend({mode:Fe("form").optional(),message:ce(),requestedSchema:Ne({type:Fe("object"),properties:Ot(ce(),i6),required:ft(ce()).optional()})}),c6=ea.extend({mode:Fe("url"),message:ce(),elicitationId:ce(),url:ce().url()}),l6=At([a6,c6]),u6=cr.extend({method:Fe("elicitation/create"),params:l6}),d6=tn.extend({elicitationId:ce()}),h6=rn.extend({method:Fe("notifications/elicitation/complete"),params:d6}),Yo=lr.extend({action:Mr(["accept","decline","cancel"]),content:uf(t=>t===null?void 0:t,Ot(ce(),At([ce(),St(),or(),ft(ce())])).optional())}),f6=Ne({type:Fe("ref/resource"),uri:ce()});var p6=Ne({type:Fe("ref/prompt"),name:ce()}),m6=Hr.extend({ref:At([p6,f6]),argument:Ne({name:ce(),value:ce()}),context:Ne({arguments:Ot(ce(),ce()).optional()}).optional()}),sl=cr.extend({method:Fe("completion/complete"),params:m6});function z_(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function N_(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}var g6=lr.extend({completion:vr({values:ft(ce()).max(100),total:Bt(St().int()),hasMore:Bt(or())})}),_6=Ne({uri:ce().startsWith("file://"),name:ce().optional(),_meta:Ot(ce(),Zt()).optional()}),b6=cr.extend({method:Fe("roots/list"),params:Hr.optional()}),Tf=lr.extend({roots:ft(_6)}),y6=rn.extend({method:Fe("notifications/roots/list_changed"),params:tn.optional()}),sD=At([qc,_f,sl,$f,tl,el,Kc,Jc,Qc,b9,v9,Wo,rl,Hc,Gc,Wc,Xc]),oD=At([Vc,Fc,bf,y6,ia]),iD=At([Bc,la,Ef,Yo,Tf,Uc,Yc,Uo]),aD=At([qc,W9,u6,b6,Hc,Gc,Wc,Xc]),cD=At([Vc,Fc,Z9,x9,g9,j9,O9,ia,h6]),lD=At([Bc,o9,g6,M9,$9,h9,f9,m9,nl,N9,Uc,Yc,Uo]),Be=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===Ge.UrlElicitationRequired&&n){let s=n;if(s.elicitations)return new df(s.elicitations,r)}return new t(e,r,n)}},df=class extends Be{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(Ge.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function fs(t){return t==="completed"||t==="failed"||t==="cancelled"}var j_=Symbol("Let zodToJsonSchema decide on which parser to use");var C_={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"},D_=t=>typeof t=="string"?{...C_,name:t}:{...C_,...t};var L_=t=>{let e=D_(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 Rf(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function pt(t,e,r,n,s){t[e]=r,Rf(t,e,n,s)}var ol=(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 Vt(t){if(t.target!=="openAi")return{};let e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?ol(e,t.currentPath):e.join("/")}}function Z_(t,e){let r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==ye.ZodAny&&(r.items=Ke(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&pt(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&pt(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(pt(r,"minItems",t.exactLength.value,t.exactLength.message,e),pt(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}function B_(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?pt(r,"minimum",n.value,n.message,e):pt(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),pt(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?pt(r,"maximum",n.value,n.message,e):pt(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),pt(r,"maximum",n.value,n.message,e));break;case"multipleOf":pt(r,"multipleOf",n.value,n.message,e);break}return r}function V_(){return{type:"boolean"}}function il(t,e){return Ke(t.type._def,e)}var q_=(t,e)=>Ke(t.innerType._def,e);function If(t,e,r){let n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((s,o)=>If(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 v6(t,e)}}var v6=(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":pt(r,"minimum",n.value,n.message,e);break;case"max":pt(r,"maximum",n.value,n.message,e);break}return r};function F_(t,e){return{...Ke(t.innerType._def,e),default:t.defaultValue()}}function H_(t,e){return e.effectStrategy==="input"?Ke(t.schema._def,e):Vt(e)}function U_(t){return{type:"string",enum:Array.from(t.values)}}var w6=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function G_(t,e){let r=[Ke(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),Ke(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(w6(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 W_(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 Pf,yn={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:()=>(Pf===void 0&&(Pf=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Pf),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 al(t,e){let r={type:"string"};if(t.checks)for(let n of t.checks)switch(n.kind){case"min":pt(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":pt(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":vn(r,"email",n.message,e);break;case"format:idn-email":vn(r,"idn-email",n.message,e);break;case"pattern:zod":wr(r,yn.email,n.message,e);break}break;case"url":vn(r,"uri",n.message,e);break;case"uuid":vn(r,"uuid",n.message,e);break;case"regex":wr(r,n.regex,n.message,e);break;case"cuid":wr(r,yn.cuid,n.message,e);break;case"cuid2":wr(r,yn.cuid2,n.message,e);break;case"startsWith":wr(r,RegExp(`^${Mf(n.value,e)}`),n.message,e);break;case"endsWith":wr(r,RegExp(`${Mf(n.value,e)}$`),n.message,e);break;case"datetime":vn(r,"date-time",n.message,e);break;case"date":vn(r,"date",n.message,e);break;case"time":vn(r,"time",n.message,e);break;case"duration":vn(r,"duration",n.message,e);break;case"length":pt(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),pt(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{wr(r,RegExp(Mf(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&vn(r,"ipv4",n.message,e),n.version!=="v4"&&vn(r,"ipv6",n.message,e);break}case"base64url":wr(r,yn.base64url,n.message,e);break;case"jwt":wr(r,yn.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&wr(r,yn.ipv4Cidr,n.message,e),n.version!=="v4"&&wr(r,yn.ipv6Cidr,n.message,e);break}case"emoji":wr(r,yn.emoji(),n.message,e);break;case"ulid":{wr(r,yn.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{vn(r,"binary",n.message,e);break}case"contentEncoding:base64":{pt(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{wr(r,yn.base64,n.message,e);break}}break}case"nanoid":wr(r,yn.nanoid,n.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function Mf(t,e){return e.patternStrategy==="escape"?S6(t):t}var x6=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function S6(t){let e="";for(let r=0;r<t.length;r++)x6.has(t[r])||(e+="\\"),e+=t[r];return e}function vn(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}}})):pt(t,"format",e,r,n)}function wr(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:Y_(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):pt(t,"pattern",Y_(e,n),r,n)}function Y_(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
|
|
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 f=this.seen.get(l),p=f.def??f.schema,m={...p};if(f.ref===null)return;let y=f.ref;if(f.ref=null,y){a(y,u);let k=this.seen.get(y).schema;k.$ref&&u.target==="draft-7"?(p.allOf=p.allOf??[],p.allOf.push(k)):(Object.assign(p,k),Object.assign(p,m))}f.isParent||this.override({zodSchema:l,jsonSchema:p,path:f.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 ef(t,e){if(t instanceof Wi){let n=new Ic(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 Ic(e);return r.process(t),r.emit(t,e)}function Qt(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 Qt(s.element,r);case"object":{for(let o in s.shape)if(Qt(s.shape[o],r))return!0;return!1}case"union":{for(let o of s.options)if(Qt(o,r))return!0;return!1}case"intersection":return Qt(s.left,r)||Qt(s.right,r);case"tuple":{for(let o of s.items)if(Qt(o,r))return!0;return!!(s.rest&&Qt(s.rest,r))}case"record":return Qt(s.keyType,r)||Qt(s.valueType,r);case"map":return Qt(s.keyType,r)||Qt(s.valueType,r);case"set":return Qt(s.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return Qt(s.innerType,r);case"lazy":return Qt(s.getter(),r);case"default":return Qt(s.innerType,r);case"prefault":return Qt(s.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return Qt(s.in,r)||Qt(s.out,r);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${s.type}`)}var GS=le("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");kt.init(t,e),t.def=e,t.parse=(r,n)=>bd(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Qs(t,r,n),t.parseAsync=async(r,n)=>vd(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>eo(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)=>Fr(t,r,n),t.brand=()=>t,t.register=(r,n)=>(r.add(t,n),t)});var WS=le("ZodMiniObject",(t,e)=>{Sc.init(t,e),GS.init(t,e),ht.defineLazy(t,"shape",()=>e.shape)});function tf(t,e){let r={type:"object",get shape(){return ht.assignProp(this,"shape",{...t}),this.shape},...ht.normalizeParams(e)};return new WS(r)}function en(t){return!!t._zod}function no(t){let e=Object.values(t);if(e.length===0)return tf({});let r=e.every(en),n=e.every(s=>!en(s));if(r)return tf(t);if(n)return sd(t);throw new Error("Mixed Zod versions detected in object shape.")}function us(t,e){return en(t)?Qs(t,e):t.safeParse(e)}async function zc(t,e){return en(t)?await eo(t,e):await t.safeParseAsync(e)}function ds(t){if(!t)return;let e;if(en(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function qo(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 no(t)}}if(en(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 Ac(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 Wg(t){return t.description}function Yg(t){if(en(t))return t._zod?.def?.type==="optional";let e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function Oc(t){if(en(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 Ki={};ed(Ki,{ZodISODate:()=>Kg,ZodISODateTime:()=>Xg,ZodISODuration:()=>Qg,ZodISOTime:()=>Jg,date:()=>nf,datetime:()=>rf,duration:()=>of,time:()=>sf});var Xg=le("ZodISODateTime",(t,e)=>{Ng.init(t,e),Lt.init(t,e)});function rf(t){return Vg(Xg,t)}var Kg=le("ZodISODate",(t,e)=>{Cg.init(t,e),Lt.init(t,e)});function nf(t){return qg(Kg,t)}var Jg=le("ZodISOTime",(t,e)=>{jg.init(t,e),Lt.init(t,e)});function sf(t){return Fg(Jg,t)}var Qg=le("ZodISODuration",(t,e)=>{Dg.init(t,e),Lt.init(t,e)});function of(t){return Ug(Qg,t)}var e_=(t,e)=>{bc.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>gd(t,r)},flatten:{value:r=>md(t,r)},addIssue:{value:r=>t.issues.push(r)},addIssues:{value:r=>t.issues.push(...r)},isEmpty:{get(){return t.issues.length===0}}})},Lj=le("ZodError",e_),Ji=le("ZodError",e_,{Parent:Error});var t_=_d(Ji),r_=yd(Ji),n_=wd(Ji),s_=xd(Ji);var Ft=le("ZodType",(t,e)=>(kt.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)=>Fr(t,r,n),t.brand=()=>t,t.register=(r,n)=>(r.add(t,n),t),t.parse=(r,n)=>t_(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>n_(t,r,n),t.parseAsync=async(r,n)=>r_(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>s_(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(U9(r,n)),t.superRefine=r=>t.check(H9(r)),t.overwrite=r=>t.check(to(r)),t.optional=()=>Bt(t),t.nullable=()=>a_(t),t.nullish=()=>Bt(a_(t)),t.nonoptional=r=>D9(t,r),t.array=()=>ft(t),t.or=r=>At([t,r]),t.and=r=>Cc(t,r),t.transform=r=>cf(t,f_(r)),t.default=r=>N9(t,r),t.prefault=r=>j9(t,r),t.catch=r=>Z9(t,r),t.pipe=r=>cf(t,r),t.readonly=()=>q9(t),t.describe=r=>{let n=t.clone();return ls.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return ls.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return ls.get(t);let n=t.clone();return ls.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),c_=le("_ZodString",(t,e)=>{Gi.init(t,e),Ft.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(Vh(...n)),t.includes=(...n)=>t.check(Uh(...n)),t.startsWith=(...n)=>t.check(Hh(...n)),t.endsWith=(...n)=>t.check(Gh(...n)),t.min=(...n)=>t.check(Vo(...n)),t.max=(...n)=>t.check(Pc(...n)),t.length=(...n)=>t.check(Mc(...n)),t.nonempty=(...n)=>t.check(Vo(1,...n)),t.lowercase=n=>t.check(qh(n)),t.uppercase=n=>t.check(Fh(n)),t.trim=()=>t.check(Yh()),t.normalize=(...n)=>t.check(Wh(...n)),t.toLowerCase=()=>t.check(Xh()),t.toUpperCase=()=>t.check(Kh())}),n9=le("ZodString",(t,e)=>{Gi.init(t,e),c_.init(t,e),t.email=r=>t.check(mh(s9,r)),t.url=r=>t.check(vh(o9,r)),t.jwt=r=>t.check(Nh(v9,r)),t.emoji=r=>t.check(wh(i9,r)),t.guid=r=>t.check($c(o_,r)),t.uuid=r=>t.check(gh(Nc,r)),t.uuidv4=r=>t.check(_h(Nc,r)),t.uuidv6=r=>t.check(bh(Nc,r)),t.uuidv7=r=>t.check(yh(Nc,r)),t.nanoid=r=>t.check(xh(a9,r)),t.guid=r=>t.check($c(o_,r)),t.cuid=r=>t.check(Sh(c9,r)),t.cuid2=r=>t.check(kh(l9,r)),t.ulid=r=>t.check($h(u9,r)),t.base64=r=>t.check(zh(_9,r)),t.base64url=r=>t.check(Ah(b9,r)),t.xid=r=>t.check(Eh(d9,r)),t.ksuid=r=>t.check(Th(h9,r)),t.ipv4=r=>t.check(Rh(f9,r)),t.ipv6=r=>t.check(Ph(p9,r)),t.cidrv4=r=>t.check(Mh(m9,r)),t.cidrv6=r=>t.check(Ih(g9,r)),t.e164=r=>t.check(Oh(y9,r)),t.datetime=r=>t.check(rf(r)),t.date=r=>t.check(nf(r)),t.time=r=>t.check(sf(r)),t.duration=r=>t.check(of(r))});function ce(t){return ph(n9,t)}var Lt=le("ZodStringFormat",(t,e)=>{It.init(t,e),c_.init(t,e)}),s9=le("ZodEmail",(t,e)=>{Md.init(t,e),Lt.init(t,e)});var o_=le("ZodGUID",(t,e)=>{Rd.init(t,e),Lt.init(t,e)});var Nc=le("ZodUUID",(t,e)=>{Pd.init(t,e),Lt.init(t,e)});var o9=le("ZodURL",(t,e)=>{Id.init(t,e),Lt.init(t,e)});var i9=le("ZodEmoji",(t,e)=>{zd.init(t,e),Lt.init(t,e)});var a9=le("ZodNanoID",(t,e)=>{Ad.init(t,e),Lt.init(t,e)});var c9=le("ZodCUID",(t,e)=>{Od.init(t,e),Lt.init(t,e)});var l9=le("ZodCUID2",(t,e)=>{Nd.init(t,e),Lt.init(t,e)});var u9=le("ZodULID",(t,e)=>{Cd.init(t,e),Lt.init(t,e)});var d9=le("ZodXID",(t,e)=>{jd.init(t,e),Lt.init(t,e)});var h9=le("ZodKSUID",(t,e)=>{Dd.init(t,e),Lt.init(t,e)});var f9=le("ZodIPv4",(t,e)=>{Ld.init(t,e),Lt.init(t,e)});var p9=le("ZodIPv6",(t,e)=>{Zd.init(t,e),Lt.init(t,e)});var m9=le("ZodCIDRv4",(t,e)=>{Bd.init(t,e),Lt.init(t,e)});var g9=le("ZodCIDRv6",(t,e)=>{Vd.init(t,e),Lt.init(t,e)});var _9=le("ZodBase64",(t,e)=>{qd.init(t,e),Lt.init(t,e)});var b9=le("ZodBase64URL",(t,e)=>{Fd.init(t,e),Lt.init(t,e)});var y9=le("ZodE164",(t,e)=>{Ud.init(t,e),Lt.init(t,e)});var v9=le("ZodJWT",(t,e)=>{Hd.init(t,e),Lt.init(t,e)});var l_=le("ZodNumber",(t,e)=>{xc.init(t,e),Ft.init(t,e),t.gt=(n,s)=>t.check(Tc(n,s)),t.gte=(n,s)=>t.check(Xi(n,s)),t.min=(n,s)=>t.check(Xi(n,s)),t.lt=(n,s)=>t.check(Ec(n,s)),t.lte=(n,s)=>t.check(Yi(n,s)),t.max=(n,s)=>t.check(Yi(n,s)),t.int=n=>t.check(i_(n)),t.safe=n=>t.check(i_(n)),t.positive=n=>t.check(Tc(0,n)),t.nonnegative=n=>t.check(Xi(0,n)),t.negative=n=>t.check(Ec(0,n)),t.nonpositive=n=>t.check(Yi(0,n)),t.multipleOf=(n,s)=>t.check(Rc(n,s)),t.step=(n,s)=>t.check(Rc(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 St(t){return Ch(l_,t)}var w9=le("ZodNumberFormat",(t,e)=>{Gd.init(t,e),l_.init(t,e)});function i_(t){return jh(w9,t)}var x9=le("ZodBoolean",(t,e)=>{Wd.init(t,e),Ft.init(t,e)});function or(t){return Dh(x9,t)}var S9=le("ZodNull",(t,e)=>{Yd.init(t,e),Ft.init(t,e)});function u_(t){return Lh(S9,t)}var k9=le("ZodUnknown",(t,e)=>{Xd.init(t,e),Ft.init(t,e)});function Zt(){return Zh(k9)}var $9=le("ZodNever",(t,e)=>{Kd.init(t,e),Ft.init(t,e)});function E9(t){return Bh($9,t)}var T9=le("ZodArray",(t,e)=>{Jd.init(t,e),Ft.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(Vo(r,n)),t.nonempty=r=>t.check(Vo(1,r)),t.max=(r,n)=>t.check(Pc(r,n)),t.length=(r,n)=>t.check(Mc(r,n)),t.unwrap=()=>t.element});function ft(t,e){return Hg(T9,t,e)}var d_=le("ZodObject",(t,e)=>{Sc.init(t,e),Ft.init(t,e),ht.defineLazy(t,"shape",()=>e.shape),t.keyof=()=>Ir(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:Zt()}),t.loose=()=>t.clone({...t._zod.def,catchall:Zt()}),t.strict=()=>t.clone({...t._zod.def,catchall:E9()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>ht.extend(t,r),t.merge=r=>ht.merge(t,r),t.pick=r=>ht.pick(t,r),t.omit=r=>ht.omit(t,r),t.partial=(...r)=>ht.partial(p_,t,r[0]),t.required=(...r)=>ht.required(m_,t,r[0])});function Ne(t,e){let r={type:"object",get shape(){return ht.assignProp(this,"shape",{...t}),this.shape},...ht.normalizeParams(e)};return new d_(r)}function vr(t,e){return new d_({type:"object",get shape(){return ht.assignProp(this,"shape",{...t}),this.shape},catchall:Zt(),...ht.normalizeParams(e)})}var h_=le("ZodUnion",(t,e)=>{kc.init(t,e),Ft.init(t,e),t.options=e.options});function At(t,e){return new h_({type:"union",options:t,...ht.normalizeParams(e)})}var R9=le("ZodDiscriminatedUnion",(t,e)=>{h_.init(t,e),Qd.init(t,e)});function lf(t,e,r){return new R9({type:"union",options:e,discriminator:t,...ht.normalizeParams(r)})}var P9=le("ZodIntersection",(t,e)=>{eh.init(t,e),Ft.init(t,e)});function Cc(t,e){return new P9({type:"intersection",left:t,right:e})}var M9=le("ZodRecord",(t,e)=>{th.init(t,e),Ft.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});function zt(t,e,r){return new M9({type:"record",keyType:t,valueType:e,...ht.normalizeParams(r)})}var af=le("ZodEnum",(t,e)=>{rh.init(t,e),Ft.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 af({...e,checks:[],...ht.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 af({...e,checks:[],...ht.normalizeParams(s),entries:o})}});function Ir(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new af({type:"enum",entries:r,...ht.normalizeParams(e)})}var I9=le("ZodLiteral",(t,e)=>{nh.init(t,e),Ft.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 Fe(t,e){return new I9({type:"literal",values:Array.isArray(t)?t:[t],...ht.normalizeParams(e)})}var z9=le("ZodTransform",(t,e)=>{sh.init(t,e),Ft.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push(ht.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(ht.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 f_(t){return new z9({type:"transform",transform:t})}var p_=le("ZodOptional",(t,e)=>{oh.init(t,e),Ft.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Bt(t){return new p_({type:"optional",innerType:t})}var A9=le("ZodNullable",(t,e)=>{ih.init(t,e),Ft.init(t,e),t.unwrap=()=>t._zod.def.innerType});function a_(t){return new A9({type:"nullable",innerType:t})}var O9=le("ZodDefault",(t,e)=>{ah.init(t,e),Ft.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function N9(t,e){return new O9({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var C9=le("ZodPrefault",(t,e)=>{ch.init(t,e),Ft.init(t,e),t.unwrap=()=>t._zod.def.innerType});function j9(t,e){return new C9({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var m_=le("ZodNonOptional",(t,e)=>{lh.init(t,e),Ft.init(t,e),t.unwrap=()=>t._zod.def.innerType});function D9(t,e){return new m_({type:"nonoptional",innerType:t,...ht.normalizeParams(e)})}var L9=le("ZodCatch",(t,e)=>{uh.init(t,e),Ft.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function Z9(t,e){return new L9({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var B9=le("ZodPipe",(t,e)=>{dh.init(t,e),Ft.init(t,e),t.in=e.in,t.out=e.out});function cf(t,e){return new B9({type:"pipe",in:t,out:e})}var V9=le("ZodReadonly",(t,e)=>{hh.init(t,e),Ft.init(t,e)});function q9(t){return new V9({type:"readonly",innerType:t})}var g_=le("ZodCustom",(t,e)=>{fh.init(t,e),Ft.init(t,e)});function F9(t){let e=new ar({check:"custom"});return e._zod.check=t,e}function __(t,e){return Jh(g_,t??(()=>!0),e)}function U9(t,e={}){return Qh(g_,t,e)}function H9(t){let e=F9(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(ht.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(ht.issue(s))}},t(r.value,r)));return e}function uf(t,e){return cf(f_(t),e)}qr(Zg());var hf="2025-11-25";var b_=[hf,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],hs="io.modelcontextprotocol/related-task",Dc="2.0",er=__(t=>t!==null&&(typeof t=="object"||typeof t=="function")),y_=At([ce(),St().int()]),v_=ce(),Qj=vr({ttl:St().optional(),pollInterval:St().optional()}),G9=Ne({ttl:St().optional()}),W9=Ne({taskId:ce()}),ff=vr({progressToken:y_.optional(),[hs]:W9.optional()}),Ur=Ne({_meta:ff.optional()}),Qi=Ur.extend({task:G9.optional()}),w_=t=>Qi.safeParse(t).success,cr=Ne({method:ce(),params:Ur.loose().optional()}),tn=Ne({_meta:ff.optional()}),rn=Ne({method:ce(),params:tn.loose().optional()}),lr=vr({_meta:ff.optional()}),Lc=At([ce(),St().int()]),x_=Ne({jsonrpc:Fe(Dc),id:Lc,...cr.shape}).strict(),pf=t=>x_.safeParse(t).success,S_=Ne({jsonrpc:Fe(Dc),...rn.shape}).strict(),k_=t=>S_.safeParse(t).success,mf=Ne({jsonrpc:Fe(Dc),id:Lc,result:lr}).strict(),ea=t=>mf.safeParse(t).success;var Ge;(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"})(Ge||(Ge={}));var gf=Ne({jsonrpc:Fe(Dc),id:Lc.optional(),error:Ne({code:St().int(),message:ce(),data:Zt().optional()})}).strict();var $_=t=>gf.safeParse(t).success;var E_=At([x_,S_,mf,gf]),eD=At([mf,gf]),Zc=lr.strict(),Y9=tn.extend({requestId:Lc.optional(),reason:ce().optional()}),Bc=rn.extend({method:Fe("notifications/cancelled"),params:Y9}),X9=Ne({src:ce(),mimeType:ce().optional(),sizes:ft(ce()).optional(),theme:Ir(["light","dark"]).optional()}),ta=Ne({icons:ft(X9).optional()}),Fo=Ne({name:ce(),title:ce().optional()}),T_=Fo.extend({...Fo.shape,...ta.shape,version:ce(),websiteUrl:ce().optional(),description:ce().optional()}),K9=Cc(Ne({applyDefaults:or().optional()}),zt(ce(),Zt())),J9=uf(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,Cc(Ne({form:K9.optional(),url:er.optional()}),zt(ce(),Zt()).optional())),Q9=vr({list:er.optional(),cancel:er.optional(),requests:vr({sampling:vr({createMessage:er.optional()}).optional(),elicitation:vr({create:er.optional()}).optional()}).optional()}),ek=vr({list:er.optional(),cancel:er.optional(),requests:vr({tools:vr({call:er.optional()}).optional()}).optional()}),tk=Ne({experimental:zt(ce(),er).optional(),sampling:Ne({context:er.optional(),tools:er.optional()}).optional(),elicitation:J9.optional(),roots:Ne({listChanged:or().optional()}).optional(),tasks:Q9.optional(),extensions:zt(ce(),er).optional()}),rk=Ur.extend({protocolVersion:ce(),capabilities:tk,clientInfo:T_}),_f=cr.extend({method:Fe("initialize"),params:rk});var nk=Ne({experimental:zt(ce(),er).optional(),logging:er.optional(),completions:er.optional(),prompts:Ne({listChanged:or().optional()}).optional(),resources:Ne({subscribe:or().optional(),listChanged:or().optional()}).optional(),tools:Ne({listChanged:or().optional()}).optional(),tasks:ek.optional(),extensions:zt(ce(),er).optional()}),sk=lr.extend({protocolVersion:ce(),capabilities:nk,serverInfo:T_,instructions:ce().optional()}),bf=rn.extend({method:Fe("notifications/initialized"),params:tn.optional()});var Vc=cr.extend({method:Fe("ping"),params:Ur.optional()}),ok=Ne({progress:St(),total:Bt(St()),message:Bt(ce())}),ik=Ne({...tn.shape,...ok.shape,progressToken:y_}),qc=rn.extend({method:Fe("notifications/progress"),params:ik}),ak=Ur.extend({cursor:v_.optional()}),ra=cr.extend({params:ak.optional()}),na=lr.extend({nextCursor:v_.optional()}),ck=Ir(["working","input_required","completed","failed","cancelled"]),sa=Ne({taskId:ce(),status:ck,ttl:At([St(),u_()]),createdAt:ce(),lastUpdatedAt:ce(),pollInterval:Bt(St()),statusMessage:Bt(ce())}),Uo=lr.extend({task:sa}),lk=tn.merge(sa),oa=rn.extend({method:Fe("notifications/tasks/status"),params:lk}),Fc=cr.extend({method:Fe("tasks/get"),params:Ur.extend({taskId:ce()})}),Uc=lr.merge(sa),Hc=cr.extend({method:Fe("tasks/result"),params:Ur.extend({taskId:ce()})}),tD=lr.loose(),Gc=ra.extend({method:Fe("tasks/list")}),Wc=na.extend({tasks:ft(sa)}),Yc=cr.extend({method:Fe("tasks/cancel"),params:Ur.extend({taskId:ce()})}),R_=lr.merge(sa),P_=Ne({uri:ce(),mimeType:Bt(ce()),_meta:zt(ce(),Zt()).optional()}),M_=P_.extend({text:ce()}),yf=ce().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),I_=P_.extend({blob:yf}),ia=Ir(["user","assistant"]),Ho=Ne({audience:ft(ia).optional(),priority:St().min(0).max(1).optional(),lastModified:Ki.datetime({offset:!0}).optional()}),z_=Ne({...Fo.shape,...ta.shape,uri:ce(),description:Bt(ce()),mimeType:Bt(ce()),size:Bt(St()),annotations:Ho.optional(),_meta:Bt(vr({}))}),uk=Ne({...Fo.shape,...ta.shape,uriTemplate:ce(),description:Bt(ce()),mimeType:Bt(ce()),annotations:Ho.optional(),_meta:Bt(vr({}))}),Xc=ra.extend({method:Fe("resources/list")}),dk=na.extend({resources:ft(z_)}),Kc=ra.extend({method:Fe("resources/templates/list")}),hk=na.extend({resourceTemplates:ft(uk)}),vf=Ur.extend({uri:ce()}),fk=vf,Jc=cr.extend({method:Fe("resources/read"),params:fk}),pk=lr.extend({contents:ft(At([M_,I_]))}),mk=rn.extend({method:Fe("notifications/resources/list_changed"),params:tn.optional()}),gk=vf,_k=cr.extend({method:Fe("resources/subscribe"),params:gk}),bk=vf,yk=cr.extend({method:Fe("resources/unsubscribe"),params:bk}),vk=tn.extend({uri:ce()}),wk=rn.extend({method:Fe("notifications/resources/updated"),params:vk}),xk=Ne({name:ce(),description:Bt(ce()),required:Bt(or())}),Sk=Ne({...Fo.shape,...ta.shape,description:Bt(ce()),arguments:Bt(ft(xk)),_meta:Bt(vr({}))}),Qc=ra.extend({method:Fe("prompts/list")}),kk=na.extend({prompts:ft(Sk)}),$k=Ur.extend({name:ce(),arguments:zt(ce(),ce()).optional()}),el=cr.extend({method:Fe("prompts/get"),params:$k}),wf=Ne({type:Fe("text"),text:ce(),annotations:Ho.optional(),_meta:zt(ce(),Zt()).optional()}),xf=Ne({type:Fe("image"),data:yf,mimeType:ce(),annotations:Ho.optional(),_meta:zt(ce(),Zt()).optional()}),Sf=Ne({type:Fe("audio"),data:yf,mimeType:ce(),annotations:Ho.optional(),_meta:zt(ce(),Zt()).optional()}),Ek=Ne({type:Fe("tool_use"),name:ce(),id:ce(),input:zt(ce(),Zt()),_meta:zt(ce(),Zt()).optional()}),Tk=Ne({type:Fe("resource"),resource:At([M_,I_]),annotations:Ho.optional(),_meta:zt(ce(),Zt()).optional()}),Rk=z_.extend({type:Fe("resource_link")}),kf=At([wf,xf,Sf,Rk,Tk]),Pk=Ne({role:ia,content:kf}),Mk=lr.extend({description:ce().optional(),messages:ft(Pk)}),Ik=rn.extend({method:Fe("notifications/prompts/list_changed"),params:tn.optional()}),zk=Ne({title:ce().optional(),readOnlyHint:or().optional(),destructiveHint:or().optional(),idempotentHint:or().optional(),openWorldHint:or().optional()}),Ak=Ne({taskSupport:Ir(["required","optional","forbidden"]).optional()}),A_=Ne({...Fo.shape,...ta.shape,description:ce().optional(),inputSchema:Ne({type:Fe("object"),properties:zt(ce(),er).optional(),required:ft(ce()).optional()}).catchall(Zt()),outputSchema:Ne({type:Fe("object"),properties:zt(ce(),er).optional(),required:ft(ce()).optional()}).catchall(Zt()).optional(),annotations:zk.optional(),execution:Ak.optional(),_meta:zt(ce(),Zt()).optional()}),tl=ra.extend({method:Fe("tools/list")}),Ok=na.extend({tools:ft(A_)}),rl=lr.extend({content:ft(kf).default([]),structuredContent:zt(ce(),Zt()).optional(),isError:or().optional()}),rD=rl.or(lr.extend({toolResult:Zt()})),Nk=Qi.extend({name:ce(),arguments:zt(ce(),Zt()).optional()}),Go=cr.extend({method:Fe("tools/call"),params:Nk}),Ck=rn.extend({method:Fe("notifications/tools/list_changed"),params:tn.optional()}),nD=Ne({autoRefresh:or().default(!0),debounceMs:St().int().nonnegative().default(300)}),aa=Ir(["debug","info","notice","warning","error","critical","alert","emergency"]),jk=Ur.extend({level:aa}),$f=cr.extend({method:Fe("logging/setLevel"),params:jk}),Dk=tn.extend({level:aa,logger:ce().optional(),data:Zt()}),Lk=rn.extend({method:Fe("notifications/message"),params:Dk}),Zk=Ne({name:ce().optional()}),Bk=Ne({hints:ft(Zk).optional(),costPriority:St().min(0).max(1).optional(),speedPriority:St().min(0).max(1).optional(),intelligencePriority:St().min(0).max(1).optional()}),Vk=Ne({mode:Ir(["auto","required","none"]).optional()}),qk=Ne({type:Fe("tool_result"),toolUseId:ce().describe("The unique identifier for the corresponding tool call."),content:ft(kf).default([]),structuredContent:Ne({}).loose().optional(),isError:or().optional(),_meta:zt(ce(),Zt()).optional()}),Fk=lf("type",[wf,xf,Sf]),jc=lf("type",[wf,xf,Sf,Ek,qk]),Uk=Ne({role:ia,content:At([jc,ft(jc)]),_meta:zt(ce(),Zt()).optional()}),Hk=Qi.extend({messages:ft(Uk),modelPreferences:Bk.optional(),systemPrompt:ce().optional(),includeContext:Ir(["none","thisServer","allServers"]).optional(),temperature:St().optional(),maxTokens:St().int(),stopSequences:ft(ce()).optional(),metadata:er.optional(),tools:ft(A_).optional(),toolChoice:Vk.optional()}),Gk=cr.extend({method:Fe("sampling/createMessage"),params:Hk}),ca=lr.extend({model:ce(),stopReason:Bt(Ir(["endTurn","stopSequence","maxTokens"]).or(ce())),role:ia,content:Fk}),Ef=lr.extend({model:ce(),stopReason:Bt(Ir(["endTurn","stopSequence","maxTokens","toolUse"]).or(ce())),role:ia,content:At([jc,ft(jc)])}),Wk=Ne({type:Fe("boolean"),title:ce().optional(),description:ce().optional(),default:or().optional()}),Yk=Ne({type:Fe("string"),title:ce().optional(),description:ce().optional(),minLength:St().optional(),maxLength:St().optional(),format:Ir(["email","uri","date","date-time"]).optional(),default:ce().optional()}),Xk=Ne({type:Ir(["number","integer"]),title:ce().optional(),description:ce().optional(),minimum:St().optional(),maximum:St().optional(),default:St().optional()}),Kk=Ne({type:Fe("string"),title:ce().optional(),description:ce().optional(),enum:ft(ce()),default:ce().optional()}),Jk=Ne({type:Fe("string"),title:ce().optional(),description:ce().optional(),oneOf:ft(Ne({const:ce(),title:ce()})),default:ce().optional()}),Qk=Ne({type:Fe("string"),title:ce().optional(),description:ce().optional(),enum:ft(ce()),enumNames:ft(ce()).optional(),default:ce().optional()}),e6=At([Kk,Jk]),t6=Ne({type:Fe("array"),title:ce().optional(),description:ce().optional(),minItems:St().optional(),maxItems:St().optional(),items:Ne({type:Fe("string"),enum:ft(ce())}),default:ft(ce()).optional()}),r6=Ne({type:Fe("array"),title:ce().optional(),description:ce().optional(),minItems:St().optional(),maxItems:St().optional(),items:Ne({anyOf:ft(Ne({const:ce(),title:ce()}))}),default:ft(ce()).optional()}),n6=At([t6,r6]),s6=At([Qk,e6,n6]),o6=At([s6,Wk,Yk,Xk]),i6=Qi.extend({mode:Fe("form").optional(),message:ce(),requestedSchema:Ne({type:Fe("object"),properties:zt(ce(),o6),required:ft(ce()).optional()})}),a6=Qi.extend({mode:Fe("url"),message:ce(),elicitationId:ce(),url:ce().url()}),c6=At([i6,a6]),l6=cr.extend({method:Fe("elicitation/create"),params:c6}),u6=tn.extend({elicitationId:ce()}),d6=rn.extend({method:Fe("notifications/elicitation/complete"),params:u6}),Wo=lr.extend({action:Ir(["accept","decline","cancel"]),content:uf(t=>t===null?void 0:t,zt(ce(),At([ce(),St(),or(),ft(ce())])).optional())}),h6=Ne({type:Fe("ref/resource"),uri:ce()});var f6=Ne({type:Fe("ref/prompt"),name:ce()}),p6=Ur.extend({ref:At([f6,h6]),argument:Ne({name:ce(),value:ce()}),context:Ne({arguments:zt(ce(),ce()).optional()}).optional()}),nl=cr.extend({method:Fe("completion/complete"),params:p6});function O_(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function N_(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}var m6=lr.extend({completion:vr({values:ft(ce()).max(100),total:Bt(St().int()),hasMore:Bt(or())})}),g6=Ne({uri:ce().startsWith("file://"),name:ce().optional(),_meta:zt(ce(),Zt()).optional()}),_6=cr.extend({method:Fe("roots/list"),params:Ur.optional()}),Tf=lr.extend({roots:ft(g6)}),b6=rn.extend({method:Fe("notifications/roots/list_changed"),params:tn.optional()}),sD=At([Vc,_f,nl,$f,el,Qc,Xc,Kc,Jc,_k,yk,Go,tl,Fc,Hc,Gc,Yc]),oD=At([Bc,qc,bf,b6,oa]),iD=At([Zc,ca,Ef,Wo,Tf,Uc,Wc,Uo]),aD=At([Vc,Gk,l6,_6,Fc,Hc,Gc,Yc]),cD=At([Bc,qc,Lk,wk,mk,Ck,Ik,oa,d6]),lD=At([Zc,sk,m6,Mk,kk,dk,hk,pk,rl,Ok,Uc,Wc,Uo]),Be=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===Ge.UrlElicitationRequired&&n){let s=n;if(s.elicitations)return new df(s.elicitations,r)}return new t(e,r,n)}},df=class extends Be{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(Ge.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function fs(t){return t==="completed"||t==="failed"||t==="cancelled"}var j_=Symbol("Let zodToJsonSchema decide on which parser to use");var C_={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"},D_=t=>typeof t=="string"?{...C_,name:t}:{...C_,...t};var L_=t=>{let e=D_(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 Rf(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function pt(t,e,r,n,s){t[e]=r,Rf(t,e,n,s)}var sl=(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 Vt(t){if(t.target!=="openAi")return{};let e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?sl(e,t.currentPath):e.join("/")}}function Z_(t,e){let r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==ye.ZodAny&&(r.items=Ke(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&pt(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&pt(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(pt(r,"minItems",t.exactLength.value,t.exactLength.message,e),pt(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}function B_(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?pt(r,"minimum",n.value,n.message,e):pt(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),pt(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?pt(r,"maximum",n.value,n.message,e):pt(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),pt(r,"maximum",n.value,n.message,e));break;case"multipleOf":pt(r,"multipleOf",n.value,n.message,e);break}return r}function V_(){return{type:"boolean"}}function ol(t,e){return Ke(t.type._def,e)}var q_=(t,e)=>Ke(t.innerType._def,e);function Pf(t,e,r){let n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((s,o)=>Pf(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 y6(t,e)}}var y6=(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":pt(r,"minimum",n.value,n.message,e);break;case"max":pt(r,"maximum",n.value,n.message,e);break}return r};function F_(t,e){return{...Ke(t.innerType._def,e),default:t.defaultValue()}}function U_(t,e){return e.effectStrategy==="input"?Ke(t.schema._def,e):Vt(e)}function H_(t){return{type:"string",enum:Array.from(t.values)}}var v6=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function G_(t,e){let r=[Ke(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),Ke(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(v6(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 W_(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 Mf,yn={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:()=>(Mf===void 0&&(Mf=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Mf),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 il(t,e){let r={type:"string"};if(t.checks)for(let n of t.checks)switch(n.kind){case"min":pt(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":pt(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":vn(r,"email",n.message,e);break;case"format:idn-email":vn(r,"idn-email",n.message,e);break;case"pattern:zod":wr(r,yn.email,n.message,e);break}break;case"url":vn(r,"uri",n.message,e);break;case"uuid":vn(r,"uuid",n.message,e);break;case"regex":wr(r,n.regex,n.message,e);break;case"cuid":wr(r,yn.cuid,n.message,e);break;case"cuid2":wr(r,yn.cuid2,n.message,e);break;case"startsWith":wr(r,RegExp(`^${If(n.value,e)}`),n.message,e);break;case"endsWith":wr(r,RegExp(`${If(n.value,e)}$`),n.message,e);break;case"datetime":vn(r,"date-time",n.message,e);break;case"date":vn(r,"date",n.message,e);break;case"time":vn(r,"time",n.message,e);break;case"duration":vn(r,"duration",n.message,e);break;case"length":pt(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),pt(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{wr(r,RegExp(If(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&vn(r,"ipv4",n.message,e),n.version!=="v4"&&vn(r,"ipv6",n.message,e);break}case"base64url":wr(r,yn.base64url,n.message,e);break;case"jwt":wr(r,yn.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&wr(r,yn.ipv4Cidr,n.message,e),n.version!=="v4"&&wr(r,yn.ipv6Cidr,n.message,e);break}case"emoji":wr(r,yn.emoji(),n.message,e);break;case"ulid":{wr(r,yn.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{vn(r,"binary",n.message,e);break}case"contentEncoding:base64":{pt(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{wr(r,yn.base64,n.message,e);break}}break}case"nanoid":wr(r,yn.nanoid,n.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function If(t,e){return e.patternStrategy==="escape"?x6(t):t}var w6=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function x6(t){let e="";for(let r=0;r<t.length;r++)w6.has(t[r])||(e+="\\"),e+=t[r];return e}function vn(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}}})):pt(t,"format",e,r,n)}function wr(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:Y_(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):pt(t,"pattern",Y_(e,n),r,n)}function Y_(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
37
|
]))`;continue}else if(n[c]==="$"){s+=`($|(?=[\r
|
|
38
38
|
]))`;continue}}if(r.s&&n[c]==="."){s+=i?`${n[c]}\r
|
|
39
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 cl(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===ye.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,s)=>({...n,[s]:Ke(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",s]})??Vt(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let r={type:"object",additionalProperties:Ke(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===ye.ZodString&&t.keyType._def.checks?.length){let{type:n,...s}=al(t.keyType._def,e);return{...r,propertyNames:s}}else{if(t.keyType?._def.typeName===ye.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===ye.ZodBranded&&t.keyType._def.type._def.typeName===ye.ZodString&&t.keyType._def.type._def.checks?.length){let{type:n,...s}=il(t.keyType._def,e);return{...r,propertyNames:s}}}return r}function X_(t,e){if(e.mapStrategy==="record")return cl(t,e);let r=Ke(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||Vt(e),n=Ke(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||Vt(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function K_(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 J_(t){return t.target==="openAi"?void 0:{not:Vt({...t,currentPath:[...t.currentPath,"not"]})}}function Q_(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var ua={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function t2(t,e){if(e.target==="openApi3")return e2(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in ua&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((s,o)=>{let i=ua[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 e2(t,e)}var e2=(t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,s)=>Ke(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 r2(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:ua[t.innerType._def.typeName],nullable:!0}:{type:[ua[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let n=Ke(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=Ke(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function n2(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",Rf(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?pt(r,"minimum",n.value,n.message,e):pt(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),pt(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?pt(r,"maximum",n.value,n.message,e):pt(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),pt(r,"maximum",n.value,n.message,e));break;case"multipleOf":pt(r,"multipleOf",n.value,n.message,e);break}return r}function s2(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=$6(c);d&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),d=!1);let l=Ke(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=k6(t,e);return i!==void 0&&(n.additionalProperties=i),n}function k6(t,e){if(t.catchall._def.typeName!=="ZodNever")return Ke(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 $6(t){try{return t.isOptional()}catch{return!0}}var o2=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return Ke(t.innerType._def,e);let r=Ke(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Vt(e)},r]}:Vt(e)};var i2=(t,e)=>{if(e.pipeStrategy==="input")return Ke(t.in._def,e);if(e.pipeStrategy==="output")return Ke(t.out._def,e);let r=Ke(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=Ke(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(s=>s!==void 0)}};function a2(t,e){return Ke(t.type._def,e)}function c2(t,e){let n={type:"array",uniqueItems:!0,items:Ke(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&pt(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&pt(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}function l2(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>Ke(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:Ke(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>Ke(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function u2(t){return{not:Vt(t)}}function d2(t){return Vt(t)}var h2=(t,e)=>Ke(t.innerType._def,e);var f2=(t,e,r)=>{switch(e){case ye.ZodString:return al(t,r);case ye.ZodNumber:return n2(t,r);case ye.ZodObject:return s2(t,r);case ye.ZodBigInt:return B_(t,r);case ye.ZodBoolean:return V_();case ye.ZodDate:return If(t,r);case ye.ZodUndefined:return u2(r);case ye.ZodNull:return Q_(r);case ye.ZodArray:return Z_(t,r);case ye.ZodUnion:case ye.ZodDiscriminatedUnion:return t2(t,r);case ye.ZodIntersection:return G_(t,r);case ye.ZodTuple:return l2(t,r);case ye.ZodRecord:return cl(t,r);case ye.ZodLiteral:return W_(t,r);case ye.ZodEnum:return U_(t);case ye.ZodNativeEnum:return K_(t);case ye.ZodNullable:return r2(t,r);case ye.ZodOptional:return o2(t,r);case ye.ZodMap:return X_(t,r);case ye.ZodSet:return c2(t,r);case ye.ZodLazy:return()=>t.getter()._def;case ye.ZodPromise:return a2(t,r);case ye.ZodNaN:case ye.ZodNever:return J_(r);case ye.ZodEffects:return H_(t,r);case ye.ZodAny:return Vt(r);case ye.ZodUnknown:return d2(r);case ye.ZodDefault:return F_(t,r);case ye.ZodBranded:return il(t,r);case ye.ZodReadonly:return h2(t,r);case ye.ZodCatch:return q_(t,r);case ye.ZodPipeline:return i2(t,r);case ye.ZodFunction:case ye.ZodVoid:case ye.ZodSymbol:return;default:return(n=>{})(e)}};function Ke(t,e,r=!1){let n=e.seen.get(t);if(e.override){let a=e.override?.(t,e,n,r);if(a!==j_)return a}if(n&&!r){let a=E6(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=f2(t,t.typeName,e),i=typeof o=="function"?Ke(o(),e):o;if(i&&T6(t,e,i),e.postProcess){let a=e.postProcess(i,t,e);return s.jsonSchema=i,a}return s.jsonSchema=i,i}var E6=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:ol(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`),Vt(e)):e.$refStrategy==="seen"?Vt(e):void 0}},T6=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r);var Of=(t,e)=>{let r=L_(e),n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[d,l])=>({...c,[d]:Ke(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,d]},!0)??Vt(r)}),{}):void 0,s=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,o=Ke(t._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1)??Vt(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 R6(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function Af(t,e){return en(t)?ef(t,{target:R6(e?.target),io:e?.pipeStrategy??"input"}):Of(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function zf(t){let r=ds(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Nc(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Nf(t,e){let r=us(t,e);if(!r.success)throw r.error;return r.data}var I6=6e4,ll=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(Vc,r=>{this._oncancel(r)}),this.setNotificationHandler(Fc,r=>{this._onprogress(r)}),this.setRequestHandler(qc,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Hc,async(r,n)=>{let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new Be(Ge.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(Gc,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,f=new Be(u.error.code,u.error.message,u.error.data);l(f)}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 Be(Ge.InvalidParams,`Task not found: ${o}`);if(!fs(i.status))return await this._waitForTaskUpdate(o,n.signal),await s();if(fs(i.status)){let a=await this._taskStore.getTaskResult(o,n.sessionId);return this._clearTaskQueue(o),{...a,_meta:{...a._meta,[hs]:{taskId:o}}}}return await s()};return await s()}),this.setRequestHandler(Wc,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 Be(Ge.InvalidParams,`Failed to list tasks: ${s instanceof Error?s.message:String(s)}`)}}),this.setRequestHandler(Xc,async(r,n)=>{try{let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new Be(Ge.InvalidParams,`Task not found: ${r.params.taskId}`);if(fs(s.status))throw new Be(Ge.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 Be(Ge.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(s){throw s instanceof Be?s:new Be(Ge.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),Be.fromError(Ge.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),ta(o)||$_(o)?this._onresponse(o):pf(o)?this._onrequest(o,i):k_(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=Be.fromError(Ge.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?.[hs]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:Ge.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=w_(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,f)=>{if(i.signal.aborted)throw new Be(Ge.ConnectionClosed,"Request was cancelled");let p={...f,relatedRequestId:e.id};o&&!p.relatedTask&&(p.relatedTask={taskId:o});let m=p.relatedTask?.taskId??o;return m&&c&&await c.updateTaskStatus(m,"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:Ge.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),ta(e))n(e);else{let i=new Be(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(ta(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),ta(e))s(e);else{let i=Be.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 Be?i:new Be(Ge.InternalError,String(i))}}return}let o;try{let i=await this.request(e,Uo,n);if(i.task)o=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new Be(Ge.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:o},n);if(yield{type:"taskStatus",task:a},fs(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)}:a.status==="failed"?yield{type:"error",error:new Be(Ge.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new Be(Ge.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 Be?i:new Be(Ge.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 f=this._requestMessageId++,p={...e,jsonrpc:"2.0",id:f};n?.onprogress&&(this._progressHandlers.set(f,n.onprogress),p.params={...e.params,_meta:{...e.params?._meta||{},progressToken:f}}),a&&(p.params={...p.params,task:a}),c&&(p.params={...p.params,_meta:{...p.params?._meta||{},[hs]:c}});let m=_=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(_)}},{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i}).catch(E=>this._onerror(new Error(`Failed to send cancellation: ${E}`)));let g=_ instanceof Be?_:new Be(Ge.RequestTimeout,String(_));l(g)};this._responseHandlers.set(f,_=>{if(!n?.signal?.aborted){if(_ instanceof Error)return l(_);try{let g=us(r,_.result);g.success?d(g.data):l(g.error)}catch(g){l(g)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let y=n?.timeout??I6,k=()=>m(Be.fromError(Ge.RequestTimeout,"Request timed out",{timeout:y}));this._setupTimeout(f,y,n?.maxTotalTimeout,k,n?.resetTimeoutOnProgress??!1);let x=c?.taskId;if(x){let _=g=>{let E=this._responseHandlers.get(f);E?E(g):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,_),this._enqueueTaskMessage(x,{type:"request",message:p,timestamp:Date.now()}).catch(g=>{this._cleanupTimeout(f),l(g)})}else this._transport.send(p,{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i}).catch(_=>{this._cleanupTimeout(f),l(_)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Uc,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},Yc,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},R_,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||{},[hs]: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||{},[hs]: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||{},[hs]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let n=zf(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,o)=>{let i=Nf(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=zf(e);this._notificationHandlers.set(n,s=>{let o=Nf(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"&&pf(s.message)){let o=s.message.id,i=this._requestResolvers.get(o);i?(i(new Be(Ge.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 Be(Ge.InvalidRequest,"Request cancelled"));return}let i=setTimeout(s,n);r.addEventListener("abort",()=>{clearTimeout(i),o(new Be(Ge.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 Be(Ge.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=ia.parse({method:"notifications/tasks/status",params:a});await this.notification(c),fs(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 Be(Ge.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(fs(a.status))throw new Be(Ge.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=ia.parse({method:"notifications/tasks/status",params:c});await this.notification(d),fs(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}};function p2(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function m2(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];p2(i)&&p2(o)?r[s]={...i,...o}:r[s]=o}return r}var iv=Ci(wm(),1),av=Ci(ov(),1);function OR(){let t=new iv.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,av.default)(t),t}var Fl=class{constructor(e){this._ajv=e??OR()}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 Hl=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(f=>f.type==="tool_use").map(f=>f.id)),u=new Set(o.filter(f=>f.type==="tool_result").map(f=>f.toolUseId));if(l.size!==u.size||![...l].every(f=>u.has(f)))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},la,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},Yo,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 cv(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 lv(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 Ul=class extends ll{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(ca.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 Fl,this.setRequestHandler(_f,n=>this._oninitialize(n)),this.setNotificationHandler(bf,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler($f,async(n,s)=>{let o=s.sessionId||s.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=ca.safeParse(i);return a.success&&this._loggingLevels.set(o,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Hl(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=m2(this._capabilities,e)}setRequestHandler(e,r){let s=ds(e)?.method;if(!s)throw new Error("Schema is missing a method literal");let o;if(en(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=us(Wo,c);if(!l.success){let m=l.error instanceof Error?l.error.message:String(l.error);throw new Be(Ge.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:u}=l.data,f=await Promise.resolve(r(c,d));if(u.task){let m=us(Uo,f);if(!m.success){let y=m.error instanceof Error?m.error.message:String(m.error);throw new Be(Ge.InvalidParams,`Invalid task creation result: ${y}`)}return m.data}let p=us(nl,f);if(!p.success){let m=p.error instanceof Error?p.error.message:String(p.error);throw new Be(Ge.InvalidParams,`Invalid tools/call result: ${m}`)}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){lv(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&cv(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:b_.includes(r)?r:hf,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"},Bc)}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},Ef,r):this.request({method:"sampling/createMessage",params:e},la,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},Yo,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},Yo,r);if(o.action==="accept"&&o.content&&s.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(s.requestedSchema)(o.content);if(!a.valid)throw new Be(Ge.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof Be?i:new Be(Ge.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},Tf,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 dv=Symbol.for("mcp.completable");function Im(t){return!!t&&typeof t=="object"&&dv in t}function hv(t){return t[dv]?.complete}var uv;(function(t){t.Completable="McpCompletable"})(uv||(uv={}));var Gl=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 f of l)t.validateLength(f,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 AR=/^[A-Za-z0-9._-]{1,128}$/;function zR(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"),!AR.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 NR(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 Pm(t){let e=zR(t);return NR(t,e.warnings),e.isValid}var Wl=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 Yl=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 Ul(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new Wl(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(xs(rl)),this.server.assertCanSetRequestHandler(xs(Wo)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(rl,()=>({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=Fo(r.inputSchema);return s?Af(s,{strictUnions:!0,pipeStrategy:"input"}):CR})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let s=Fo(r.outputSchema);s&&(n.outputSchema=Af(s,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(Wo,async(e,r)=>{try{let n=this._registeredTools[e.params.name];if(!n)throw new Be(Ge.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new Be(Ge.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 Be(Ge.InternalError,`Tool ${e.params.name} has taskSupport '${o}' but was not registered with registerToolTask`);if(o==="required"&&!s)throw new Be(Ge.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 Be&&n.code===Ge.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=Fo(e.inputSchema)??e.inputSchema,i=await Ac(o,r);if(!i.success){let a="error"in i?i.error:"Unknown error",c=zc(a);throw new Be(Ge.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 Be(Ge.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let s=Fo(e.outputSchema),o=await Ac(s,r.structuredContent);if(!o.success){let i="error"in o?o.error:"Unknown error",a=zc(i);throw new Be(Ge.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(f=>setTimeout(f,l));let u=await n.taskStore.getTask(c);if(!u)throw new Be(Ge.InternalError,`Task ${c} not found during polling`);d=u}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(xs(sl)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(sl,async e=>{switch(e.params.ref.type){case"ref/prompt":return z_(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return N_(e),this.handleResourceCompletion(e,e.params.ref);default:throw new Be(Ge.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){let n=this._registeredPrompts[r.name];if(!n)throw new Be(Ge.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new Be(Ge.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return Za;let o=ds(n.argsSchema)?.[e.params.argument.name];if(!Im(o))return Za;let i=hv(o);if(!i)return Za;let a=await i(e.params.argument.value,e.params.context);return pv(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 Za;throw new Be(Ge.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let s=n.resourceTemplate.completeCallback(e.params.argument.name);if(!s)return Za;let o=await s(e.params.argument.value,e.params.context);return pv(o)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(xs(Kc)),this.server.assertCanSetRequestHandler(xs(Jc)),this.server.assertCanSetRequestHandler(xs(Qc)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Kc,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(Jc,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(Qc,async(e,r)=>{let n=new URL(e.params.uri),s=this._registeredResources[n.toString()];if(s){if(!s.enabled)throw new Be(Ge.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 Be(Ge.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(xs(el)),this.server.assertCanSetRequestHandler(xs(tl)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(el,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?jR(r.argsSchema):void 0}))})),this.server.setRequestHandler(tl,async(e,r)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new Be(Ge.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new Be(Ge.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let s=Fo(n.argsSchema),o=await Ac(s,e.params.arguments);if(!o.success){let c="error"in o?o.error:"Unknown error",d=zc(c);throw new Be(Ge.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:so(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=so(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 Ir?c._def?.innerType:c;return Im(d)})&&this.setCompletionRequestHandler(),i}_createRegisteredTool(e,r,n,s,o,i,a,c,d){Pm(e);let l={title:r,description:n,inputSchema:fv(s),outputSchema:fv(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"&&Pm(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=so(u.paramsSchema)),typeof u.outputSchema<"u"&&(l.outputSchema=so(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(Mm(c))s=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!Mm(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()}},Xl=class{constructor(e,r){this._callbacks=r,this._uriTemplate=typeof e=="string"?new Gl(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){return this._callbacks.complete?.[e]}},CR={type:"object",properties:{}};function mv(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function gv(t){return"_def"in t||"_zod"in t||mv(t)}function Mm(t){return typeof t!="object"||t===null||gv(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(mv)}function fv(t){if(t){if(Mm(t))return so(t);if(!gv(t))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return t}}function jR(t){let e=ds(t);return e?Object.entries(e).map(([r,n])=>{let s=Wg(n),o=Yg(n);return{name:r,description:s,required:!o}}):[]}function xs(t){let r=ds(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Nc(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function pv(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}var Za={completion:{values:[],hasMore:!1}};import bv from"node:process";var Kl=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),
|
|
42
|
-
`}var Jl=class{constructor(e=bv.stdin,r=bv.stdout){this._stdin=e,this._stdout=r,this._readBuffer=new Kl,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=_v(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};import{accessSync as GN,constants as WN,writeFileSync as YN,mkdirSync as bx}from"node:fs";import{fileURLToPath as XN,pathToFileURL as yx}from"node:url";import{tmpdir as gx}from"node:os";import{createServer as KN}from"node:http";import*as nr from"node:path";var Ur=["alloy","ash","ballad","coral","echo","fable","marin","nova","onyx","sage","shimmer","verse","cedar"],LR="cedar",Ss={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 yv(t){return t&&Ur.includes(t)?t:LR}var ZR="TTS voice to narrate with \u2014 pick the one that best fits the topic/audience. Defaults to cedar (warm, natural). Options: "+Ur.map(t=>`${t} (${Ss[t]})`).join(", ")+".",BR=W.object({find:W.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:W.string().describe("What `find` becomes. Only its changed region types out \u2014 not the whole file."),occurrence:W.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.")}),VR=W.object({say:W.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:W.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:W.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:W.array(BR).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:W.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:W.boolean().optional().describe("Animate `edits` as typing (default true). Set false to make an edit appear instantly. (`code` is always shown instantly regardless.)"),highlightCode:W.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:W.tuple([W.number(),W.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:W.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:W.string().optional().describe("If set, starts a named chapter at this step, shown as a labelled marker on the timeline."),holdMs:W.number().optional().describe("How long this step lasts, in milliseconds. Defaults to a duration derived from the narration and amount of typing.")}),Om={title:W.string().describe("Title of the walkthrough (shown in the player header and used for the filename)."),outputPath:W.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:W.enum(Ur).optional().describe(ZR),voiceTone:W.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:W.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:W.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:W.array(W.object({path:W.string(),content:W.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:W.array(VR).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.')},aq=W.object(Om);var zm=[],Sv=[];(()=>{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?Sv:zm).push(r=r+t[e])})();function qR(t){if(t<768)return!1;for(let e=0,r=zm.length;;){let n=e+r>>1;if(t<zm[n])r=n;else if(t>=Sv[n])e=n+1;else return!0;if(e==r)return!1}}function vv(t){return t>=127462&&t<=127487}var wv=8205;function kv(t,e,r=!0,n=!0){return(r?$v:FR)(t,e,n)}function $v(t,e,r){if(e==t.length)return e;e&&Ev(t.charCodeAt(e))&&Tv(t.charCodeAt(e-1))&&e--;let n=Am(t,e);for(e+=xv(n);e<t.length;){let s=Am(t,e);if(n==wv||s==wv||r&&qR(s))e+=xv(s),n=s;else if(vv(s)){let o=0,i=e-2;for(;i>=0&&vv(Am(t,i));)o++,i-=2;if(o%2==0)break;e+=2}else break}return e}function FR(t,e,r){for(;e>0;){let n=$v(t,e-2,r);if(n<e)return n;e--}return 0}function Am(t,e){let r=t.charCodeAt(e);if(!Tv(r)||e+1==t.length)return r;let n=t.charCodeAt(e+1);return Ev(n)?(r-55296<<10)+(n-56320)+65536:r}function Ev(t){return t>=56320&&t<57344}function Tv(t){return t>=55296&&t<56320}function xv(t){return t<65536?1:2}var tr=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]=bi(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),mi.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]=bi(this,e,r);let n=[];return this.decompose(e,r,n,0),mi.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 yo(this),o=new yo(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 yo(this,e)}iterRange(e,r=this.length){return new nu(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 su(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 Gr(e):mi.from(Gr.split(e,[]))}},Gr=class t extends tr{constructor(e,r=HR(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 Cm(s,a,n,i);s=a+1,n++}}decompose(e,r,n,s){let o=e<=0&&r>=this.length?this:new t(Rv(this.text,e,r),Math.min(r,this.length)-Math.max(0,e));if(s&1){let i=n.pop(),a=ru(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]=bi(this,e,r);let s=ru(this.text,ru(n.text,Rv(this.text,0,e)),r),o=this.length+n.length-(r-e);return s.length<=32?new t(s,o):mi.from(t.split(s,[]),o)}sliceString(e,r=this.length,n=`
|
|
43
|
-
`){[e,r]=
|
|
44
|
-
`){[e,r]=
|
|
45
|
-
`,this;e--}else if(s instanceof Gr){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 Gr?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)}},nu=class{constructor(e,r,n){this.value="",this.done=!1,this.cursor=new yo(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!=""}},su=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"&&(tr.prototype[Symbol.iterator]=function(){return this.iter()},yo.prototype[Symbol.iterator]=nu.prototype[Symbol.iterator]=su.prototype[Symbol.iterator]=function(){return this});var Cm=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 bi(t,e,r){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,r))]}function Iv(t,e,r=!0,n=!0){return kv(t,e,r,n)}var jm=/\r\n?|\n/,ks=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(ks||(ks={})),vo=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){Dm(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:zv(this,e)}mapDesc(e,r=!1){return e.empty?this:Lm(this,e,r)}mapPos(e,r=-1,n=ks.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!=ks.Simple&&d>=e&&(n==ks.TrackDel&&s<e&&d>e||n==ks.TrackBefore&&s<e||n==ks.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)}},ln=class t extends vo{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 Dm(this,(r,n,s,o,i)=>e=e.replace(s,s+(n-r),i),!1),e}mapDesc(e,r=!1){return Lm(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(tr.empty);n.push(i?e.slice(o,o+i):tr.empty)}o+=i}return new t(r,n)}compose(e){return this.empty?e:e.empty?this:zv(this,e,!0)}map(e,r=!1){return e.empty?this:Lm(this,e,r,!0)}iterChanges(e,r=!1){Dm(this,e,r)}get desc(){return vo.create(this.sections)}filter(e){let r=[],n=[],s=[],o=new wo(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);_r(s,l,-1);let u=o.ins==-1?-1:o.off==0?o.ins:0;_r(r,l,u),u>0&&$s(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);_r(r,l,-1),_r(s,l,o.ins==-1?-1:o.off==0?o.ins:0),o.forward(l),a+=l}}return{changes:new t(r,n),filtered:vo.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&&_r(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:f=u,insert:p}=l;if(u>f||u<0||f>r)throw new RangeError(`Invalid change range ${u} to ${f} (in doc of length ${r})`);let m=p?typeof p=="string"?tr.of(p.split(n||jm)):p:tr.empty,y=m.length;if(u==f&&y==0)return;u<i&&c(),u>i&&_r(s,u-i,-1),_r(s,f-u,y),$s(o,s,m),i=f}}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(tr.empty);n[s]=tr.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 _r(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 $s(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(tr.empty);t.push(r)}}function Dm(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=tr.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 Lm(t,e,r,n=!1){let s=[],o=n?[]:null,i=new wo(t),a=new wo(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);_r(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(_r(s,a.ins,-1);d;){let l=Math.min(i.len,d);i.ins>=0&&c<i.i&&i.len<=l&&(_r(s,0,i.ins),o&&$s(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;_r(s,d,c<i.i?i.ins:0),o&&c<i.i&&$s(o,s,i.text),c=i.i,i.forward(i.len-l)}else{if(i.done&&a.done)return o?ln.createSet(s,o):vo.create(s);throw new Error("Mismatched change set lengths")}}}function zv(t,e,r=!1){let n=[],s=r?[]:null,o=new wo(t),i=new wo(e);for(let a=!1;;){if(o.done&&i.done)return s?ln.createSet(n,s):vo.create(n);if(o.ins==0)_r(n,o.len,0,a),o.next();else if(i.len==0&&!i.done)_r(n,0,i.ins,a),s&&$s(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;_r(n,c,l,a),s&&l&&$s(s,n,i.text)}else i.ins==-1?(_r(n,o.off?0:o.len,c,a),s&&$s(s,n,o.textBit(c))):(_r(n,o.off?0:o.len,i.off?0:i.ins,a),s&&!i.off&&$s(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 wo=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?tr.empty:e[r]}textBit(e){let{inserted:r}=this.set,n=this.i-2>>1;return n>=r.length&&!e?tr.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)}},pi=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 Cr.range(e,r,void 0,void 0,n);let s=Math.abs(e-this.anchor)>Math.abs(r-this.anchor)?e:r;return Cr.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 Cr.range(e.anchor,e.head)}static create(e,r,n){return new t(e,r,n)}},Cr=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=>pi.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 pi.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?pi.create(r,e,48|i):pi.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 Nv(t,e){for(let r of t.ranges)if(r.to>e)throw new RangeError("Selection points outside of document")}var Ym=0,Wr=class t{constructor(e,r,n,s,o){this.combine=e,this.compareInput=r,this.compare=n,this.isStatic=s,this.id=Ym++,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:Xm),!!e.static,e.enables)}of(e){return new gi([],this,0,e)}compute(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new gi(e,this,1,r)}computeN(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new gi(e,this,2,r)}from(e,r){return r||(r=n=>n),this.compute([e],n=>r(n.field(e)))}};function Xm(t,e){return t==e||t.length==e.length&&t.every((r,n)=>r===e[n])}var gi=class{constructor(e,r,n,s){this.dependencies=e,this.facet=r,this.type=n,this.value=s,this.id=Ym++}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,f){if(c&&f.docChanged||d&&(f.docChanged||f.selection)||Zm(u,l)){let p=n(u);if(a?!Pv(p,u.values[i],s):!s(p,u.values[i]))return u.values[i]=p,1}return 0},reconfigure:(u,f)=>{let p,m=f.config.address[o];if(m!=null){let y=cu(f,m);if(this.dependencies.every(k=>k instanceof Wr?f.facet(k)===u.facet(k):k instanceof yi?f.field(k,!1)==u.field(k,!1):!0)||(a?Pv(p=n(u),y,s):s(p=n(u),y)))return u.values[i]=y,0}else p=n(u);return u.values[i]=p,1}}}};function Pv(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 Zm(t,e){let r=!1;for(let n of e)Va(t,n)&1&&(r=!0);return r}function UR(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=cu(c,n[l]);if(s[l]==2)for(let f of u)d.push(f);else d.push(u)}return e.combine(d)}return{create(c){for(let d of n)Va(c,d);return c.values[i]=a(c),1},update(c,d){if(!Zm(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=Zm(c,n),u=d.config.facets[e.id],f=d.facet(e);if(u&&!l&&Xm(r,u))return c.values[i]=f,0;let p=a(c);return e.compare(p,f)?(c.values[i]=f,0):(c.values[i]=p,1)}}}var Ql=Wr.define({static:!0}),yi=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(Ym++,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(Ql).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(Ql),i=s.facet(Ql),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,Ql.of({field:this,create:e})]}get extension(){return this}},_o={lowest:4,low:3,default:2,high:1,highest:0};function Ba(t){return e=>new ou(e,t)}var dq={highest:Ba(_o.highest),high:Ba(_o.high),default:Ba(_o.default),low:Ba(_o.low),lowest:Ba(_o.lowest)},ou=class{constructor(e,r){this.inner=e,this.prec=r}},iu=class t{of(e){return new qa(this,e)}reconfigure(e){return t.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},qa=class{constructor(e,r){this.compartment=e,this.inner=r}},au=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 f of GR(e,r,i))f instanceof yi?s.push(f):(o[f.facet.id]||(o[f.facet.id]=[])).push(f);let a=Object.create(null),c=[],d=[];for(let f of s)a[f.id]=d.length<<1,d.push(p=>f.slot(p));let l=n?.config.facets;for(let f in o){let p=o[f],m=p[0].facet,y=l&&l[f]||[];if(p.every(k=>k.type==0))if(a[m.id]=c.length<<1|1,Xm(y,p))c.push(n.facet(m));else{let k=m.combine(p.map(x=>x.value));c.push(n&&m.compare(k,n.facet(m))?n.facet(m):k)}else{for(let k of p)k.type==0?(a[k.id]=c.length<<1|1,c.push(k.value)):(a[k.id]=d.length<<1,d.push(x=>k.dynamicSlot(x)));a[m.id]=d.length<<1,d.push(k=>UR(k,m,p))}}let u=d.map(f=>f(a));return new t(e,i,u,a,c,o)}};function GR(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 qa&&r.delete(i.compartment)}if(s.set(i,a),Array.isArray(i))for(let d of i)o(d,a);else if(i instanceof qa){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 ou)o(i.inner,i.prec);else if(i instanceof yi)n[a].push(i),i.provides&&o(i.provides,a);else if(i instanceof gi)n[a].push(i),i.facet.extensions&&o(i.facet.extensions,_o.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,_o.default),n.reduce((i,a)=>i.concat(a))}function Va(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 cu(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}var Cv=Wr.define(),Bm=Wr.define({combine:t=>t.some(e=>e),static:!0}),jv=Wr.define({combine:t=>t.length?t[0]:void 0,static:!0}),Dv=Wr.define(),Lv=Wr.define(),Zv=Wr.define(),Bv=Wr.define({combine:t=>t.length?t[0]:!1}),xo=class{constructor(e,r){this.type=e,this.value=r}static define(){return new Vm}},Vm=class{of(e){return new xo(this,e)}},qm=class{constructor(e){this.map=e}of(e){return new kr(this,e)}},kr=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 qm(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}};kr.reconfigure=kr.define();kr.appendConfig=kr.define();var cn=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&&Nv(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]=="."))}};cn.time=xo.define();cn.userEvent=xo.define();cn.addToHistory=xo.define();cn.remote=xo.define();function WR(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 Vv(t,e,r){var n;let s,o,i;return r?(s=e.changes,o=ln.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:kr.mapEffects(t.effects,s).concat(kr.mapEffects(e.effects,o)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function Fm(t,e,r){let n=e.selection,s=_i(e.annotations);return e.userEvent&&(s=s.concat(cn.userEvent.of(e.userEvent))),{changes:e.changes instanceof ln?e.changes:ln.of(e.changes||[],r,t.facet(jv)),selection:n&&(n instanceof Cr?n:Cr.single(n.anchor,n.head)),effects:_i(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function qv(t,e,r){let n=Fm(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=Vv(n,Fm(t,e[o],i?n.changes.newLength:t.doc.length),i)}let s=cn.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return XR(r?YR(s):s)}function YR(t){let e=t.startState,r=!0;for(let s of e.facet(Dv)){let o=s(t);if(o===!1){r=!1;break}Array.isArray(o)&&(r=r===!0?o:WR(r,o))}if(r!==!0){let s,o;if(r===!1)o=t.changes.invertedDesc,s=ln.empty(e.doc.length);else{let i=t.changes.filter(r);s=i.changes,o=i.filtered.mapDesc(i.changes).invertedDesc}t=cn.create(e,s,t.selection&&t.selection.map(o),kr.mapEffects(t.effects,o),t.annotations,t.scrollIntoView)}let n=e.facet(Lv);for(let s=n.length-1;s>=0;s--){let o=n[s](t);o instanceof cn?t=o:Array.isArray(o)&&o.length==1&&o[0]instanceof cn?t=o[0]:t=qv(e,_i(o),!1)}return t}function XR(t){let e=t.startState,r=e.facet(Zv),n=t;for(let s=r.length-1;s>=0;s--){let o=r[s](t);o&&Object.keys(o).length&&(n=Vv(n,Fm(e,o,t.changes.newLength),!0))}return n==t?t:cn.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}var KR=[];function _i(t){return t==null?KR:Array.isArray(t)?t:[t]}var Es=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Es||(Es={})),JR=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Hm;try{Hm=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function QR(t){if(Hm)return Hm.test(t);for(let e=0;e<t.length;e++){let r=t[e];if(/\w/.test(r)||r>"\x80"&&(r.toUpperCase()!=r.toLowerCase()||JR.test(r)))return!0}return!1}function eI(t){return e=>{if(!/\S/.test(e))return Es.Space;if(QR(e))return Es.Word;for(let r=0;r<t.length;r++)if(e.indexOf(t[r])>-1)return Es.Word;return Es.Other}}var En=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++)Va(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 Va(this,n),cu(this,n)}update(...e){return qv(this,e,!0)}applyTransaction(e){let r=this.config,{base:n,compartments:s}=r;for(let a of e.effects)a.is(iu.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(kr.reconfigure)?(r=null,n=a.value):a.is(kr.appendConfig)&&(r=null,n=_i(n).concat(a.value));let o;r?o=e.startState.values.slice():(r=au.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(Bm)?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:Cr.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=_i(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 f=0;f<a;f++)o[f]=o[f].map(l);let u=s.mapDesc(d,!0);o.push(c.range.map(u)),s=s.compose(l),i=kr.mapEffects(i,l).concat(kr.mapEffects(_i(c.effects),u))}return{changes:s,selection:Cr.create(o,r.mainIndex),effects:i}}changes(e=[]){return e instanceof ln?e:ln.of(e,this.doc.length,this.facet(t.lineSeparator))}toText(e){return tr.of(e.split(this.facet(t.lineSeparator)||jm))}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:(Va(this,r),cu(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 yi&&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:Cr.fromJSON(e.selection),extensions:r.extensions?s.concat([r.extensions]):s})}static create(e={}){let r=au.resolve(e.extensions||[],new Map),n=e.doc instanceof tr?e.doc:tr.of((e.doc||"").split(r.staticFacet(t.lineSeparator)||jm)),s=e.selection?e.selection instanceof Cr?e.selection:Cr.single(e.selection.anchor,e.selection.head):Cr.single(0);return Nv(s,n.length),r.staticFacet(Bm)||(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(Bv)}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(Cv))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 eI(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=Iv(r,i,!1);if(o(r.slice(c,i))!=Es.Word)break;i=c}for(;a<s;){let c=Iv(r,a);if(o(r.slice(a,c))!=Es.Word)break;a=c}return i==a?null:Cr.range(i+n,a+n)}};En.allowMultipleSelections=Bm;En.tabSize=Wr.define({combine:t=>t.length?t[0]:4});En.lineSeparator=jv;En.readOnly=Bv;En.phrases=Wr.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])}});En.languageData=Cv;En.changeFilter=Dv;En.transactionFilter=Lv;En.transactionExtender=Zv;iu.reconfigure=kr.define();var vi=class{eq(e){return this==e}range(e,r=e){return Fa.create(e,r,this)}};vi.prototype.startSide=vi.prototype.endSide=0;vi.prototype.point=!1;vi.prototype.mapMode=ks.TrackDel;function Km(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}var Fa=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 Um(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}var Gm=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,f,p;if(l==u){let m=r.mapPos(l,d.startSide,d.mapMode);if(m==null||(f=p=m,d.startSide!=d.endSide&&(p=r.mapPos(l,d.endSide),p<f)))continue}else if(f=r.mapPos(l,d.startSide),p=r.mapPos(u,d.endSide),f>p||f==p&&d.startSide>0&&d.endSide<=0)continue;(p-f||d.endSide-d.startSide)<0||(i<0&&(i=f),d.point&&(a=Math.max(a,p-f)),n.push(d),s.push(f-i),o.push(p-i))}return{mapped:n.length?new t(s,o,n,a):null,pos:i}}},Ts=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(Um)),this.isEmpty)return r.length?t.of(r):this;let a=new uu(this,null,-1).goto(0),c=0,d=[],l=new lu;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(Fa.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 Ha.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,r=0){return Ha.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=Mv(i,a,n),d=new bo(i,c,o),l=new bo(a,c,o);n.iterGaps((u,f,p)=>Ov(d,u,l,f,p,s)),n.empty&&n.length==0&&Ov(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=Mv(o,i),c=new bo(o,a,0).goto(n),d=new bo(i,a,0).goto(n);for(;;){if(c.to!=d.to||!Wm(c.active,d.active)||c.point&&(!d.point||!Km(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 bo(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 lu;for(let s of e instanceof Fa?[e]:r?tI(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}};Ts.empty=new Ts([],[],null,-1);function tI(t){if(t.length>1)for(let e=t[0],r=1;r<t.length;r++){let n=t[r];if(Um(e,n)>0)return t.slice().sort(Um);e=n}return t}Ts.empty.nextLayer=Ts.empty;var lu=class t{finishChunk(e){this.chunks.push(new Gm(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(Ts.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let r=Ts.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,r}};function Mv(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 uu=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}},Ha=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 uu(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--)Nm(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--)Nm(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(),Nm(this.heap,0)}}};function Nm(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 bo=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=Ha.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){eu(this.active,e),eu(this.activeTo,e),eu(this.activeRank,e),this.minActive=Av(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++;tu(this.active,r,n),tu(this.activeTo,r,s),tu(this.activeRank,r,o),e&&tu(e,r,this.cursor.from),this.minActive=Av(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&&eu(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 Ov(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,f=u||t.endSide-r.endSide,p=f<0?t.to+c:r.to,m=Math.min(p,i);if(t.point||r.point?(t.point&&r.point&&Km(t.point,r.point)&&Wm(t.activeForPoint(t.to),r.activeForPoint(r.to))||o.comparePoint(a,m,t.point,r.point),l=!1):(l&&o.boundChange(a),m>a&&!Wm(t.active,r.active)&&o.compareRange(a,m,t.active,r.active),d&&m<i&&(u||t.openEnd(p)!=r.openEnd(p))&&(l=!0)),p>i)break;a=p,f<=0&&t.next(),f>=0&&r.next()}}function Wm(t,e){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!=e[r]&&!Km(t[r],e[r]))return!1;return!0}function eu(t,e){for(let r=e,n=t.length-1;r<n;r++)t[r]=t[r+1];t.pop()}function tu(t,e,r){for(let n=t.length-1;n>=e;n--)t[n+1]=t[n];t[e]=r}function Av(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 rI=350,nI=26,sI=60,oI=120,iI=600,aI=450;function cI(t){return Math.max(1,t.trim().split(/\s+/).length)}function lI(t){return Math.max(1500,cI(t)*rI)}function Fv(t){return t<=0?0:Math.min(6e3,Math.max(350,t*nI))}function Hv(t,e){let r=Math.min(t.length,e.length),n=0;for(;n<r&&t[n]===e[n];)n++;return n}function Uv(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 uI(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 dI(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
|
|
48
|
-
`);i.push({t:Math.round(k+Math.min(300,
|
|
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 al(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===ye.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,s)=>({...n,[s]:Ke(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",s]})??Vt(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let r={type:"object",additionalProperties:Ke(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===ye.ZodString&&t.keyType._def.checks?.length){let{type:n,...s}=il(t.keyType._def,e);return{...r,propertyNames:s}}else{if(t.keyType?._def.typeName===ye.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===ye.ZodBranded&&t.keyType._def.type._def.typeName===ye.ZodString&&t.keyType._def.type._def.checks?.length){let{type:n,...s}=ol(t.keyType._def,e);return{...r,propertyNames:s}}}return r}function X_(t,e){if(e.mapStrategy==="record")return al(t,e);let r=Ke(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||Vt(e),n=Ke(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||Vt(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function K_(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 J_(t){return t.target==="openAi"?void 0:{not:Vt({...t,currentPath:[...t.currentPath,"not"]})}}function Q_(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var la={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function t2(t,e){if(e.target==="openApi3")return e2(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in la&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((s,o)=>{let i=la[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 e2(t,e)}var e2=(t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,s)=>Ke(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 r2(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:la[t.innerType._def.typeName],nullable:!0}:{type:[la[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let n=Ke(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=Ke(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function n2(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",Rf(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?pt(r,"minimum",n.value,n.message,e):pt(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),pt(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?pt(r,"maximum",n.value,n.message,e):pt(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),pt(r,"maximum",n.value,n.message,e));break;case"multipleOf":pt(r,"multipleOf",n.value,n.message,e);break}return r}function s2(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=k6(c);d&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),d=!1);let l=Ke(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=S6(t,e);return i!==void 0&&(n.additionalProperties=i),n}function S6(t,e){if(t.catchall._def.typeName!=="ZodNever")return Ke(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 k6(t){try{return t.isOptional()}catch{return!0}}var o2=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return Ke(t.innerType._def,e);let r=Ke(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Vt(e)},r]}:Vt(e)};var i2=(t,e)=>{if(e.pipeStrategy==="input")return Ke(t.in._def,e);if(e.pipeStrategy==="output")return Ke(t.out._def,e);let r=Ke(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=Ke(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(s=>s!==void 0)}};function a2(t,e){return Ke(t.type._def,e)}function c2(t,e){let n={type:"array",uniqueItems:!0,items:Ke(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&pt(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&pt(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}function l2(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>Ke(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:Ke(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>Ke(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function u2(t){return{not:Vt(t)}}function d2(t){return Vt(t)}var h2=(t,e)=>Ke(t.innerType._def,e);var f2=(t,e,r)=>{switch(e){case ye.ZodString:return il(t,r);case ye.ZodNumber:return n2(t,r);case ye.ZodObject:return s2(t,r);case ye.ZodBigInt:return B_(t,r);case ye.ZodBoolean:return V_();case ye.ZodDate:return Pf(t,r);case ye.ZodUndefined:return u2(r);case ye.ZodNull:return Q_(r);case ye.ZodArray:return Z_(t,r);case ye.ZodUnion:case ye.ZodDiscriminatedUnion:return t2(t,r);case ye.ZodIntersection:return G_(t,r);case ye.ZodTuple:return l2(t,r);case ye.ZodRecord:return al(t,r);case ye.ZodLiteral:return W_(t,r);case ye.ZodEnum:return H_(t);case ye.ZodNativeEnum:return K_(t);case ye.ZodNullable:return r2(t,r);case ye.ZodOptional:return o2(t,r);case ye.ZodMap:return X_(t,r);case ye.ZodSet:return c2(t,r);case ye.ZodLazy:return()=>t.getter()._def;case ye.ZodPromise:return a2(t,r);case ye.ZodNaN:case ye.ZodNever:return J_(r);case ye.ZodEffects:return U_(t,r);case ye.ZodAny:return Vt(r);case ye.ZodUnknown:return d2(r);case ye.ZodDefault:return F_(t,r);case ye.ZodBranded:return ol(t,r);case ye.ZodReadonly:return h2(t,r);case ye.ZodCatch:return q_(t,r);case ye.ZodPipeline:return i2(t,r);case ye.ZodFunction:case ye.ZodVoid:case ye.ZodSymbol:return;default:return(n=>{})(e)}};function Ke(t,e,r=!1){let n=e.seen.get(t);if(e.override){let a=e.override?.(t,e,n,r);if(a!==j_)return a}if(n&&!r){let a=$6(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=f2(t,t.typeName,e),i=typeof o=="function"?Ke(o(),e):o;if(i&&E6(t,e,i),e.postProcess){let a=e.postProcess(i,t,e);return s.jsonSchema=i,a}return s.jsonSchema=i,i}var $6=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:sl(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`),Vt(e)):e.$refStrategy==="seen"?Vt(e):void 0}},E6=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r);var zf=(t,e)=>{let r=L_(e),n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[d,l])=>({...c,[d]:Ke(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,d]},!0)??Vt(r)}),{}):void 0,s=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,o=Ke(t._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1)??Vt(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 T6(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function Af(t,e){return en(t)?ef(t,{target:T6(e?.target),io:e?.pipeStrategy??"input"}):zf(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function Of(t){let r=ds(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Oc(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Nf(t,e){let r=us(t,e);if(!r.success)throw r.error;return r.data}var R6=6e4,cl=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(Bc,r=>{this._oncancel(r)}),this.setNotificationHandler(qc,r=>{this._onprogress(r)}),this.setRequestHandler(Vc,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Fc,async(r,n)=>{let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new Be(Ge.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(Hc,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,f=new Be(u.error.code,u.error.message,u.error.data);l(f)}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 Be(Ge.InvalidParams,`Task not found: ${o}`);if(!fs(i.status))return await this._waitForTaskUpdate(o,n.signal),await s();if(fs(i.status)){let a=await this._taskStore.getTaskResult(o,n.sessionId);return this._clearTaskQueue(o),{...a,_meta:{...a._meta,[hs]:{taskId:o}}}}return await s()};return await s()}),this.setRequestHandler(Gc,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 Be(Ge.InvalidParams,`Failed to list tasks: ${s instanceof Error?s.message:String(s)}`)}}),this.setRequestHandler(Yc,async(r,n)=>{try{let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new Be(Ge.InvalidParams,`Task not found: ${r.params.taskId}`);if(fs(s.status))throw new Be(Ge.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 Be(Ge.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(s){throw s instanceof Be?s:new Be(Ge.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),Be.fromError(Ge.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),ea(o)||$_(o)?this._onresponse(o):pf(o)?this._onrequest(o,i):k_(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=Be.fromError(Ge.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?.[hs]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:Ge.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=w_(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,f)=>{if(i.signal.aborted)throw new Be(Ge.ConnectionClosed,"Request was cancelled");let p={...f,relatedRequestId:e.id};o&&!p.relatedTask&&(p.relatedTask={taskId:o});let m=p.relatedTask?.taskId??o;return m&&c&&await c.updateTaskStatus(m,"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:Ge.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),ea(e))n(e);else{let i=new Be(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(ea(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),ea(e))s(e);else{let i=Be.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 Be?i:new Be(Ge.InternalError,String(i))}}return}let o;try{let i=await this.request(e,Uo,n);if(i.task)o=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new Be(Ge.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:o},n);if(yield{type:"taskStatus",task:a},fs(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)}:a.status==="failed"?yield{type:"error",error:new Be(Ge.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new Be(Ge.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 Be?i:new Be(Ge.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 f=this._requestMessageId++,p={...e,jsonrpc:"2.0",id:f};n?.onprogress&&(this._progressHandlers.set(f,n.onprogress),p.params={...e.params,_meta:{...e.params?._meta||{},progressToken:f}}),a&&(p.params={...p.params,task:a}),c&&(p.params={...p.params,_meta:{...p.params?._meta||{},[hs]:c}});let m=_=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(_)}},{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i}).catch(E=>this._onerror(new Error(`Failed to send cancellation: ${E}`)));let g=_ instanceof Be?_:new Be(Ge.RequestTimeout,String(_));l(g)};this._responseHandlers.set(f,_=>{if(!n?.signal?.aborted){if(_ instanceof Error)return l(_);try{let g=us(r,_.result);g.success?d(g.data):l(g.error)}catch(g){l(g)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let y=n?.timeout??R6,k=()=>m(Be.fromError(Ge.RequestTimeout,"Request timed out",{timeout:y}));this._setupTimeout(f,y,n?.maxTotalTimeout,k,n?.resetTimeoutOnProgress??!1);let x=c?.taskId;if(x){let _=g=>{let E=this._responseHandlers.get(f);E?E(g):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,_),this._enqueueTaskMessage(x,{type:"request",message:p,timestamp:Date.now()}).catch(g=>{this._cleanupTimeout(f),l(g)})}else this._transport.send(p,{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i}).catch(_=>{this._cleanupTimeout(f),l(_)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Uc,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},Wc,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},R_,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||{},[hs]: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||{},[hs]: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||{},[hs]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let n=Of(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,o)=>{let i=Nf(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=Of(e);this._notificationHandlers.set(n,s=>{let o=Nf(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"&&pf(s.message)){let o=s.message.id,i=this._requestResolvers.get(o);i?(i(new Be(Ge.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 Be(Ge.InvalidRequest,"Request cancelled"));return}let i=setTimeout(s,n);r.addEventListener("abort",()=>{clearTimeout(i),o(new Be(Ge.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 Be(Ge.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=oa.parse({method:"notifications/tasks/status",params:a});await this.notification(c),fs(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 Be(Ge.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(fs(a.status))throw new Be(Ge.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=oa.parse({method:"notifications/tasks/status",params:c});await this.notification(d),fs(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}};function p2(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function m2(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];p2(i)&&p2(o)?r[s]={...i,...o}:r[s]=o}return r}var iv=Ni(wm(),1),av=Ni(ov(),1);function IR(){let t=new iv.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,av.default)(t),t}var ql=class{constructor(e){this._ajv=e??IR()}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 Fl=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(f=>f.type==="tool_use").map(f=>f.id)),u=new Set(o.filter(f=>f.type==="tool_result").map(f=>f.toolUseId));if(l.size!==u.size||![...l].every(f=>u.has(f)))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},ca,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},Wo,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 cv(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 lv(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 Ul=class extends cl{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(aa.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 ql,this.setRequestHandler(_f,n=>this._oninitialize(n)),this.setNotificationHandler(bf,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler($f,async(n,s)=>{let o=s.sessionId||s.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=aa.safeParse(i);return a.success&&this._loggingLevels.set(o,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Fl(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=m2(this._capabilities,e)}setRequestHandler(e,r){let s=ds(e)?.method;if(!s)throw new Error("Schema is missing a method literal");let o;if(en(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=us(Go,c);if(!l.success){let m=l.error instanceof Error?l.error.message:String(l.error);throw new Be(Ge.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:u}=l.data,f=await Promise.resolve(r(c,d));if(u.task){let m=us(Uo,f);if(!m.success){let y=m.error instanceof Error?m.error.message:String(m.error);throw new Be(Ge.InvalidParams,`Invalid task creation result: ${y}`)}return m.data}let p=us(rl,f);if(!p.success){let m=p.error instanceof Error?p.error.message:String(p.error);throw new Be(Ge.InvalidParams,`Invalid tools/call result: ${m}`)}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){lv(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&cv(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:b_.includes(r)?r:hf,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"},Zc)}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},Ef,r):this.request({method:"sampling/createMessage",params:e},ca,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},Wo,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},Wo,r);if(o.action==="accept"&&o.content&&s.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(s.requestedSchema)(o.content);if(!a.valid)throw new Be(Ge.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof Be?i:new Be(Ge.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},Tf,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 dv=Symbol.for("mcp.completable");function Pm(t){return!!t&&typeof t=="object"&&dv in t}function hv(t){return t[dv]?.complete}var uv;(function(t){t.Completable="McpCompletable"})(uv||(uv={}));var Hl=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 f of l)t.validateLength(f,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 zR=/^[A-Za-z0-9._-]{1,128}$/;function AR(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"),!zR.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 OR(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 Mm(t){let e=AR(t);return OR(t,e.warnings),e.isValid}var Gl=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 Wl=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 Ul(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new Gl(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(xs(tl)),this.server.assertCanSetRequestHandler(xs(Go)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(tl,()=>({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=qo(r.inputSchema);return s?Af(s,{strictUnions:!0,pipeStrategy:"input"}):NR})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let s=qo(r.outputSchema);s&&(n.outputSchema=Af(s,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(Go,async(e,r)=>{try{let n=this._registeredTools[e.params.name];if(!n)throw new Be(Ge.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new Be(Ge.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 Be(Ge.InternalError,`Tool ${e.params.name} has taskSupport '${o}' but was not registered with registerToolTask`);if(o==="required"&&!s)throw new Be(Ge.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 Be&&n.code===Ge.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=qo(e.inputSchema)??e.inputSchema,i=await zc(o,r);if(!i.success){let a="error"in i?i.error:"Unknown error",c=Ac(a);throw new Be(Ge.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 Be(Ge.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let s=qo(e.outputSchema),o=await zc(s,r.structuredContent);if(!o.success){let i="error"in o?o.error:"Unknown error",a=Ac(i);throw new Be(Ge.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(f=>setTimeout(f,l));let u=await n.taskStore.getTask(c);if(!u)throw new Be(Ge.InternalError,`Task ${c} not found during polling`);d=u}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(xs(nl)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(nl,async e=>{switch(e.params.ref.type){case"ref/prompt":return O_(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return N_(e),this.handleResourceCompletion(e,e.params.ref);default:throw new Be(Ge.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){let n=this._registeredPrompts[r.name];if(!n)throw new Be(Ge.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new Be(Ge.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return La;let o=ds(n.argsSchema)?.[e.params.argument.name];if(!Pm(o))return La;let i=hv(o);if(!i)return La;let a=await i(e.params.argument.value,e.params.context);return pv(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 La;throw new Be(Ge.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let s=n.resourceTemplate.completeCallback(e.params.argument.name);if(!s)return La;let o=await s(e.params.argument.value,e.params.context);return pv(o)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(xs(Xc)),this.server.assertCanSetRequestHandler(xs(Kc)),this.server.assertCanSetRequestHandler(xs(Jc)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Xc,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(Kc,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(Jc,async(e,r)=>{let n=new URL(e.params.uri),s=this._registeredResources[n.toString()];if(s){if(!s.enabled)throw new Be(Ge.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 Be(Ge.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(xs(Qc)),this.server.assertCanSetRequestHandler(xs(el)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Qc,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?CR(r.argsSchema):void 0}))})),this.server.setRequestHandler(el,async(e,r)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new Be(Ge.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new Be(Ge.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let s=qo(n.argsSchema),o=await zc(s,e.params.arguments);if(!o.success){let c="error"in o?o.error:"Unknown error",d=Ac(c);throw new Be(Ge.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:no(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=no(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 Pr?c._def?.innerType:c;return Pm(d)})&&this.setCompletionRequestHandler(),i}_createRegisteredTool(e,r,n,s,o,i,a,c,d){Mm(e);let l={title:r,description:n,inputSchema:fv(s),outputSchema:fv(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"&&Mm(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=no(u.paramsSchema)),typeof u.outputSchema<"u"&&(l.outputSchema=no(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(Im(c))s=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!Im(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()}},Yl=class{constructor(e,r){this._callbacks=r,this._uriTemplate=typeof e=="string"?new Hl(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){return this._callbacks.complete?.[e]}},NR={type:"object",properties:{}};function mv(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function gv(t){return"_def"in t||"_zod"in t||mv(t)}function Im(t){return typeof t!="object"||t===null||gv(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(mv)}function fv(t){if(t){if(Im(t))return no(t);if(!gv(t))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return t}}function CR(t){let e=ds(t);return e?Object.entries(e).map(([r,n])=>{let s=Wg(n),o=Yg(n);return{name:r,description:s,required:!o}}):[]}function xs(t){let r=ds(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Oc(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function pv(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}var La={completion:{values:[],hasMore:!1}};import bv from"node:process";var Xl=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),jR(r)}clear(){this._buffer=void 0}};function jR(t){return E_.parse(JSON.parse(t))}function _v(t){return JSON.stringify(t)+`
|
|
42
|
+
`}var Kl=class{constructor(e=bv.stdin,r=bv.stdout){this._stdin=e,this._stdout=r,this._readBuffer=new Xl,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=_v(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};import{accessSync as GN,constants as WN,writeFileSync as YN,mkdirSync as _x}from"node:fs";import{fileURLToPath as XN,pathToFileURL as bx}from"node:url";import{tmpdir as mx}from"node:os";import{createServer as KN}from"node:http";import*as nr from"node:path";var Hr=["alloy","ash","ballad","coral","echo","fable","marin","nova","onyx","sage","shimmer","verse","cedar"],DR="cedar",Jl={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 yv(t){return t&&Hr.includes(t)?t:DR}var LR="TTS voice (default cedar). Options: "+Hr.join(", ")+".",ZR=W.object({find:W.string().min(1).describe('Exact existing snippet to anchor the change \u2014 smallest unique text, whitespace exact. Insert by keeping the anchor inside `replace`; delete with replace "".'),replace:W.string().describe("What `find` becomes \u2014 only the changed region types out."),occurrence:W.number().int().positive().optional().describe("1-based which occurrence of `find` when it is not unique (default 1).")}),BR=W.object({say:W.string().optional().describe("Narration for this step \u2014 one short beat (4\u201314 words), spoken + captioned. Write the whole script and chop it into beats that flow continuously; split compound sentences. Highlight syncs to the beat start."),file:W.string().optional().describe("File to show this step (created if new, becomes the active tab). Omit to keep the current file. A step with `file` + no `code` just switches tabs."),code:W.string().optional().describe("Full contents of `file` \u2014 ONLY to introduce a file the first time (shown instantly, not typed). To change an existing file use `edits`. For a deliberate full rewrite set `rewrite:true`."),edits:W.array(ZR).optional().describe("Small find/replace edits to the current file (these type out). Prefer over resending `code`. A step uses EITHER `code` OR `edits`, never both."),rewrite:W.boolean().optional().describe("Set true only for a deliberate full-file rewrite via `code` on a non-empty file."),typing:W.boolean().optional().describe("Animate `edits` as typing (default true)."),highlightCode:W.string().optional().describe("Preferred way to point at code: an EXACT, UNIQUE snippet of the current file to highlight \u2014 a single token/line, or a whole multi-line block. Found as-it-stands each step, so it never drifts when edits move lines."),highlight:W.array(W.number()).length(2).optional().describe("Highlight a line range [start,end] (1-based, inclusive). Prefer `highlightCode` once the file has been edited."),terminal:W.string().optional().describe('Text appended to the terminal panel this step (e.g. "$ npm test\\n\u2713 3 passed").'),chapter:W.string().optional().describe("If set, starts a named chapter marker on the timeline."),holdMs:W.number().optional().describe("Step duration in ms (default derived from narration + typing).")}),zm={title:W.string().describe("Title of the walkthrough (player header + filename)."),outputPath:W.string().optional().describe("Optional path to also write the .html to (absolute, or relative to the server cwd)."),voiceName:W.enum(Hr).optional().describe(LR),voiceTone:W.string().optional().describe('How the narrator should sound, matched to the topic (e.g. "calm and precise", "upbeat and encouraging"). Default relaxed-senior-engineer.'),intro:W.string().optional().describe("Opening line spoken before step 1 (a short hook). Default title-based; '' to skip. Don't also write your own welcome step."),outro:W.string().optional().describe("Closing recap line spoken after the last step. Default title-based; '' to skip. Don't write your own."),files:W.array(W.object({path:W.string(),content:W.string().optional()})).optional().describe("Pre-existing files present in FULL from t=0 \u2014 put already-written code here with its `content`. Steps then show + highlight them (no typing)."),steps:W.array(BR).min(1).describe("Ordered timeline as a LESSON: open on the problem/why, build ONE idea per beat (short `say` + tight `highlightCode`), grouped into named chapters, then recap. Lean high \u2014 many short beats; the `say` lines read as one continuous script.")},aq=W.object(zm);var Om=[],Sv=[];(()=>{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?Sv:Om).push(r=r+t[e])})();function VR(t){if(t<768)return!1;for(let e=0,r=Om.length;;){let n=e+r>>1;if(t<Om[n])r=n;else if(t>=Sv[n])e=n+1;else return!0;if(e==r)return!1}}function vv(t){return t>=127462&&t<=127487}var wv=8205;function kv(t,e,r=!0,n=!0){return(r?$v:qR)(t,e,n)}function $v(t,e,r){if(e==t.length)return e;e&&Ev(t.charCodeAt(e))&&Tv(t.charCodeAt(e-1))&&e--;let n=Am(t,e);for(e+=xv(n);e<t.length;){let s=Am(t,e);if(n==wv||s==wv||r&&VR(s))e+=xv(s),n=s;else if(vv(s)){let o=0,i=e-2;for(;i>=0&&vv(Am(t,i));)o++,i-=2;if(o%2==0)break;e+=2}else break}return e}function qR(t,e,r){for(;e>0;){let n=$v(t,e-2,r);if(n<e)return n;e--}return 0}function Am(t,e){let r=t.charCodeAt(e);if(!Tv(r)||e+1==t.length)return r;let n=t.charCodeAt(e+1);return Ev(n)?(r-55296<<10)+(n-56320)+65536:r}function Ev(t){return t>=56320&&t<57344}function Tv(t){return t>=55296&&t<56320}function xv(t){return t<65536?1:2}var tr=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]=_i(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),pi.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]=_i(this,e,r);let n=[];return this.decompose(e,r,n,0),pi.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 bo(this),o=new bo(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 bo(this,e)}iterRange(e,r=this.length){return new nu(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 su(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 Gr(e):pi.from(Gr.split(e,[]))}},Gr=class t extends tr{constructor(e,r=FR(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 Cm(s,a,n,i);s=a+1,n++}}decompose(e,r,n,s){let o=e<=0&&r>=this.length?this:new t(Rv(this.text,e,r),Math.min(r,this.length)-Math.max(0,e));if(s&1){let i=n.pop(),a=ru(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]=_i(this,e,r);let s=ru(this.text,ru(n.text,Rv(this.text,0,e)),r),o=this.length+n.length-(r-e);return s.length<=32?new t(s,o):pi.from(t.split(s,[]),o)}sliceString(e,r=this.length,n=`
|
|
43
|
+
`){[e,r]=_i(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}},pi=class t extends tr{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]=_i(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]=_i(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 m of e)m.flatten(p);return new Gr(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 m;if(p.lines>o&&p instanceof t)for(let y of p.children)u(y);else p.lines>i&&(c>i||!c)?(f(),a.push(p)):p instanceof Gr&&c&&(m=l[l.length-1])instanceof Gr&&p.lines+m.lines<=32?(c+=p.lines,d+=p.length+1,l[l.length-1]=new Gr(m.text.concat(p.text),m.length+1+p.length)):(c+p.lines>s&&f(),c+=p.lines,d+=p.length+1,l.push(p))}function f(){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 f(),a.length==1?a[0]:new t(a,r)}};tr.empty=new Gr([""],0);function FR(t){let e=-1;for(let r of t)e+=r.length+1;return e}function ru(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 Rv(t,e,r){return ru(t,[""],e,r)}var bo=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 Gr?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 Gr?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 Gr){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 Gr?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)}},nu=class{constructor(e,r,n){this.value="",this.done=!1,this.cursor=new bo(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!=""}},su=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"&&(tr.prototype[Symbol.iterator]=function(){return this.iter()},bo.prototype[Symbol.iterator]=nu.prototype[Symbol.iterator]=su.prototype[Symbol.iterator]=function(){return this});var Cm=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 _i(t,e,r){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,r))]}function Pv(t,e,r=!0,n=!0){return kv(t,e,r,n)}var jm=/\r\n?|\n/,Ss=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(Ss||(Ss={})),yo=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){Dm(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:Ov(this,e)}mapDesc(e,r=!1){return e.empty?this:Lm(this,e,r)}mapPos(e,r=-1,n=Ss.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!=Ss.Simple&&d>=e&&(n==Ss.TrackDel&&s<e&&d>e||n==Ss.TrackBefore&&s<e||n==Ss.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)}},ln=class t extends yo{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 Dm(this,(r,n,s,o,i)=>e=e.replace(s,s+(n-r),i),!1),e}mapDesc(e,r=!1){return Lm(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(tr.empty);n.push(i?e.slice(o,o+i):tr.empty)}o+=i}return new t(r,n)}compose(e){return this.empty?e:e.empty?this:Ov(this,e,!0)}map(e,r=!1){return e.empty?this:Lm(this,e,r,!0)}iterChanges(e,r=!1){Dm(this,e,r)}get desc(){return yo.create(this.sections)}filter(e){let r=[],n=[],s=[],o=new vo(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);_r(s,l,-1);let u=o.ins==-1?-1:o.off==0?o.ins:0;_r(r,l,u),u>0&&ks(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);_r(r,l,-1),_r(s,l,o.ins==-1?-1:o.off==0?o.ins:0),o.forward(l),a+=l}}return{changes:new t(r,n),filtered:yo.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&&_r(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:f=u,insert:p}=l;if(u>f||u<0||f>r)throw new RangeError(`Invalid change range ${u} to ${f} (in doc of length ${r})`);let m=p?typeof p=="string"?tr.of(p.split(n||jm)):p:tr.empty,y=m.length;if(u==f&&y==0)return;u<i&&c(),u>i&&_r(s,u-i,-1),_r(s,f-u,y),ks(o,s,m),i=f}}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(tr.empty);n[s]=tr.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 _r(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 ks(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(tr.empty);t.push(r)}}function Dm(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=tr.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 Lm(t,e,r,n=!1){let s=[],o=n?[]:null,i=new vo(t),a=new vo(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);_r(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(_r(s,a.ins,-1);d;){let l=Math.min(i.len,d);i.ins>=0&&c<i.i&&i.len<=l&&(_r(s,0,i.ins),o&&ks(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;_r(s,d,c<i.i?i.ins:0),o&&c<i.i&&ks(o,s,i.text),c=i.i,i.forward(i.len-l)}else{if(i.done&&a.done)return o?ln.createSet(s,o):yo.create(s);throw new Error("Mismatched change set lengths")}}}function Ov(t,e,r=!1){let n=[],s=r?[]:null,o=new vo(t),i=new vo(e);for(let a=!1;;){if(o.done&&i.done)return s?ln.createSet(n,s):yo.create(n);if(o.ins==0)_r(n,o.len,0,a),o.next();else if(i.len==0&&!i.done)_r(n,0,i.ins,a),s&&ks(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;_r(n,c,l,a),s&&l&&ks(s,n,i.text)}else i.ins==-1?(_r(n,o.off?0:o.len,c,a),s&&ks(s,n,o.textBit(c))):(_r(n,o.off?0:o.len,i.off?0:i.ins,a),s&&!i.off&&ks(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 vo=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?tr.empty:e[r]}textBit(e){let{inserted:r}=this.set,n=this.i-2>>1;return n>=r.length&&!e?tr.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)}},fi=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 Cr.range(e,r,void 0,void 0,n);let s=Math.abs(e-this.anchor)>Math.abs(r-this.anchor)?e:r;return Cr.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 Cr.range(e.anchor,e.head)}static create(e,r,n){return new t(e,r,n)}},Cr=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=>fi.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 fi.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?fi.create(r,e,48|i):fi.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 Nv(t,e){for(let r of t.ranges)if(r.to>e)throw new RangeError("Selection points outside of document")}var Ym=0,Wr=class t{constructor(e,r,n,s,o){this.combine=e,this.compareInput=r,this.compare=n,this.isStatic=s,this.id=Ym++,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:Xm),!!e.static,e.enables)}of(e){return new mi([],this,0,e)}compute(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new mi(e,this,1,r)}computeN(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new mi(e,this,2,r)}from(e,r){return r||(r=n=>n),this.compute([e],n=>r(n.field(e)))}};function Xm(t,e){return t==e||t.length==e.length&&t.every((r,n)=>r===e[n])}var mi=class{constructor(e,r,n,s){this.dependencies=e,this.facet=r,this.type=n,this.value=s,this.id=Ym++}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,f){if(c&&f.docChanged||d&&(f.docChanged||f.selection)||Zm(u,l)){let p=n(u);if(a?!Mv(p,u.values[i],s):!s(p,u.values[i]))return u.values[i]=p,1}return 0},reconfigure:(u,f)=>{let p,m=f.config.address[o];if(m!=null){let y=cu(f,m);if(this.dependencies.every(k=>k instanceof Wr?f.facet(k)===u.facet(k):k instanceof bi?f.field(k,!1)==u.field(k,!1):!0)||(a?Mv(p=n(u),y,s):s(p=n(u),y)))return u.values[i]=y,0}else p=n(u);return u.values[i]=p,1}}}};function Mv(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 Zm(t,e){let r=!1;for(let n of e)Ba(t,n)&1&&(r=!0);return r}function UR(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=cu(c,n[l]);if(s[l]==2)for(let f of u)d.push(f);else d.push(u)}return e.combine(d)}return{create(c){for(let d of n)Ba(c,d);return c.values[i]=a(c),1},update(c,d){if(!Zm(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=Zm(c,n),u=d.config.facets[e.id],f=d.facet(e);if(u&&!l&&Xm(r,u))return c.values[i]=f,0;let p=a(c);return e.compare(p,f)?(c.values[i]=f,0):(c.values[i]=p,1)}}}var Ql=Wr.define({static:!0}),bi=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(Ym++,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(Ql).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(Ql),i=s.facet(Ql),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,Ql.of({field:this,create:e})]}get extension(){return this}},go={lowest:4,low:3,default:2,high:1,highest:0};function Za(t){return e=>new ou(e,t)}var dq={highest:Za(go.highest),high:Za(go.high),default:Za(go.default),low:Za(go.low),lowest:Za(go.lowest)},ou=class{constructor(e,r){this.inner=e,this.prec=r}},iu=class t{of(e){return new Va(this,e)}reconfigure(e){return t.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Va=class{constructor(e,r){this.compartment=e,this.inner=r}},au=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 f of HR(e,r,i))f instanceof bi?s.push(f):(o[f.facet.id]||(o[f.facet.id]=[])).push(f);let a=Object.create(null),c=[],d=[];for(let f of s)a[f.id]=d.length<<1,d.push(p=>f.slot(p));let l=n?.config.facets;for(let f in o){let p=o[f],m=p[0].facet,y=l&&l[f]||[];if(p.every(k=>k.type==0))if(a[m.id]=c.length<<1|1,Xm(y,p))c.push(n.facet(m));else{let k=m.combine(p.map(x=>x.value));c.push(n&&m.compare(k,n.facet(m))?n.facet(m):k)}else{for(let k of p)k.type==0?(a[k.id]=c.length<<1|1,c.push(k.value)):(a[k.id]=d.length<<1,d.push(x=>k.dynamicSlot(x)));a[m.id]=d.length<<1,d.push(k=>UR(k,m,p))}}let u=d.map(f=>f(a));return new t(e,i,u,a,c,o)}};function HR(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 Va&&r.delete(i.compartment)}if(s.set(i,a),Array.isArray(i))for(let d of i)o(d,a);else if(i instanceof Va){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 ou)o(i.inner,i.prec);else if(i instanceof bi)n[a].push(i),i.provides&&o(i.provides,a);else if(i instanceof mi)n[a].push(i),i.facet.extensions&&o(i.facet.extensions,go.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,go.default),n.reduce((i,a)=>i.concat(a))}function Ba(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 cu(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}var Cv=Wr.define(),Bm=Wr.define({combine:t=>t.some(e=>e),static:!0}),jv=Wr.define({combine:t=>t.length?t[0]:void 0,static:!0}),Dv=Wr.define(),Lv=Wr.define(),Zv=Wr.define(),Bv=Wr.define({combine:t=>t.length?t[0]:!1}),wo=class{constructor(e,r){this.type=e,this.value=r}static define(){return new Vm}},Vm=class{of(e){return new wo(this,e)}},qm=class{constructor(e){this.map=e}of(e){return new kr(this,e)}},kr=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 qm(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}};kr.reconfigure=kr.define();kr.appendConfig=kr.define();var cn=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&&Nv(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]=="."))}};cn.time=wo.define();cn.userEvent=wo.define();cn.addToHistory=wo.define();cn.remote=wo.define();function GR(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 Vv(t,e,r){var n;let s,o,i;return r?(s=e.changes,o=ln.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:kr.mapEffects(t.effects,s).concat(kr.mapEffects(e.effects,o)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function Fm(t,e,r){let n=e.selection,s=gi(e.annotations);return e.userEvent&&(s=s.concat(cn.userEvent.of(e.userEvent))),{changes:e.changes instanceof ln?e.changes:ln.of(e.changes||[],r,t.facet(jv)),selection:n&&(n instanceof Cr?n:Cr.single(n.anchor,n.head)),effects:gi(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function qv(t,e,r){let n=Fm(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=Vv(n,Fm(t,e[o],i?n.changes.newLength:t.doc.length),i)}let s=cn.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return YR(r?WR(s):s)}function WR(t){let e=t.startState,r=!0;for(let s of e.facet(Dv)){let o=s(t);if(o===!1){r=!1;break}Array.isArray(o)&&(r=r===!0?o:GR(r,o))}if(r!==!0){let s,o;if(r===!1)o=t.changes.invertedDesc,s=ln.empty(e.doc.length);else{let i=t.changes.filter(r);s=i.changes,o=i.filtered.mapDesc(i.changes).invertedDesc}t=cn.create(e,s,t.selection&&t.selection.map(o),kr.mapEffects(t.effects,o),t.annotations,t.scrollIntoView)}let n=e.facet(Lv);for(let s=n.length-1;s>=0;s--){let o=n[s](t);o instanceof cn?t=o:Array.isArray(o)&&o.length==1&&o[0]instanceof cn?t=o[0]:t=qv(e,gi(o),!1)}return t}function YR(t){let e=t.startState,r=e.facet(Zv),n=t;for(let s=r.length-1;s>=0;s--){let o=r[s](t);o&&Object.keys(o).length&&(n=Vv(n,Fm(e,o,t.changes.newLength),!0))}return n==t?t:cn.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}var XR=[];function gi(t){return t==null?XR:Array.isArray(t)?t:[t]}var $s=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}($s||($s={})),KR=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Um;try{Um=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function JR(t){if(Um)return Um.test(t);for(let e=0;e<t.length;e++){let r=t[e];if(/\w/.test(r)||r>"\x80"&&(r.toUpperCase()!=r.toLowerCase()||KR.test(r)))return!0}return!1}function QR(t){return e=>{if(!/\S/.test(e))return $s.Space;if(JR(e))return $s.Word;for(let r=0;r<t.length;r++)if(e.indexOf(t[r])>-1)return $s.Word;return $s.Other}}var En=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++)Ba(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 Ba(this,n),cu(this,n)}update(...e){return qv(this,e,!0)}applyTransaction(e){let r=this.config,{base:n,compartments:s}=r;for(let a of e.effects)a.is(iu.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(kr.reconfigure)?(r=null,n=a.value):a.is(kr.appendConfig)&&(r=null,n=gi(n).concat(a.value));let o;r?o=e.startState.values.slice():(r=au.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(Bm)?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:Cr.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=gi(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 f=0;f<a;f++)o[f]=o[f].map(l);let u=s.mapDesc(d,!0);o.push(c.range.map(u)),s=s.compose(l),i=kr.mapEffects(i,l).concat(kr.mapEffects(gi(c.effects),u))}return{changes:s,selection:Cr.create(o,r.mainIndex),effects:i}}changes(e=[]){return e instanceof ln?e:ln.of(e,this.doc.length,this.facet(t.lineSeparator))}toText(e){return tr.of(e.split(this.facet(t.lineSeparator)||jm))}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:(Ba(this,r),cu(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 bi&&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:Cr.fromJSON(e.selection),extensions:r.extensions?s.concat([r.extensions]):s})}static create(e={}){let r=au.resolve(e.extensions||[],new Map),n=e.doc instanceof tr?e.doc:tr.of((e.doc||"").split(r.staticFacet(t.lineSeparator)||jm)),s=e.selection?e.selection instanceof Cr?e.selection:Cr.single(e.selection.anchor,e.selection.head):Cr.single(0);return Nv(s,n.length),r.staticFacet(Bm)||(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(Bv)}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(Cv))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 QR(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=Pv(r,i,!1);if(o(r.slice(c,i))!=$s.Word)break;i=c}for(;a<s;){let c=Pv(r,a);if(o(r.slice(a,c))!=$s.Word)break;a=c}return i==a?null:Cr.range(i+n,a+n)}};En.allowMultipleSelections=Bm;En.tabSize=Wr.define({combine:t=>t.length?t[0]:4});En.lineSeparator=jv;En.readOnly=Bv;En.phrases=Wr.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])}});En.languageData=Cv;En.changeFilter=Dv;En.transactionFilter=Lv;En.transactionExtender=Zv;iu.reconfigure=kr.define();var yi=class{eq(e){return this==e}range(e,r=e){return qa.create(e,r,this)}};yi.prototype.startSide=yi.prototype.endSide=0;yi.prototype.point=!1;yi.prototype.mapMode=Ss.TrackDel;function Km(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}var qa=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 Gm=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,f,p;if(l==u){let m=r.mapPos(l,d.startSide,d.mapMode);if(m==null||(f=p=m,d.startSide!=d.endSide&&(p=r.mapPos(l,d.endSide),p<f)))continue}else if(f=r.mapPos(l,d.startSide),p=r.mapPos(u,d.endSide),f>p||f==p&&d.startSide>0&&d.endSide<=0)continue;(p-f||d.endSide-d.startSide)<0||(i<0&&(i=f),d.point&&(a=Math.max(a,p-f)),n.push(d),s.push(f-i),o.push(p-i))}return{mapped:n.length?new t(s,o,n,a):null,pos:i}}},Es=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 uu(this,null,-1).goto(0),c=0,d=[],l=new lu;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(qa.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 Fa.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,r=0){return Fa.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=Iv(i,a,n),d=new _o(i,c,o),l=new _o(a,c,o);n.iterGaps((u,f,p)=>zv(d,u,l,f,p,s)),n.empty&&n.length==0&&zv(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=Iv(o,i),c=new _o(o,a,0).goto(n),d=new _o(i,a,0).goto(n);for(;;){if(c.to!=d.to||!Wm(c.active,d.active)||c.point&&(!d.point||!Km(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 _o(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 lu;for(let s of e instanceof qa?[e]:r?eP(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}};Es.empty=new Es([],[],null,-1);function eP(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}Es.empty.nextLayer=Es.empty;var lu=class t{finishChunk(e){this.chunks.push(new Gm(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(Es.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let r=Es.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,r}};function Iv(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 uu=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}},Fa=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 uu(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--)Nm(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--)Nm(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(),Nm(this.heap,0)}}};function Nm(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 _o=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=Fa.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){eu(this.active,e),eu(this.activeTo,e),eu(this.activeRank,e),this.minActive=Av(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++;tu(this.active,r,n),tu(this.activeTo,r,s),tu(this.activeRank,r,o),e&&tu(e,r,this.cursor.from),this.minActive=Av(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&&eu(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 zv(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,f=u||t.endSide-r.endSide,p=f<0?t.to+c:r.to,m=Math.min(p,i);if(t.point||r.point?(t.point&&r.point&&Km(t.point,r.point)&&Wm(t.activeForPoint(t.to),r.activeForPoint(r.to))||o.comparePoint(a,m,t.point,r.point),l=!1):(l&&o.boundChange(a),m>a&&!Wm(t.active,r.active)&&o.compareRange(a,m,t.active,r.active),d&&m<i&&(u||t.openEnd(p)!=r.openEnd(p))&&(l=!0)),p>i)break;a=p,f<=0&&t.next(),f>=0&&r.next()}}function Wm(t,e){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!=e[r]&&!Km(t[r],e[r]))return!1;return!0}function eu(t,e){for(let r=e,n=t.length-1;r<n;r++)t[r]=t[r+1];t.pop()}function tu(t,e,r){for(let n=t.length-1;n>=e;n--)t[n+1]=t[n];t[e]=r}function Av(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 tP=350,rP=26,nP=60,sP=120,oP=600,iP=450;function aP(t){return Math.max(1,t.trim().split(/\s+/).length)}function cP(t){return Math.max(1500,aP(t)*tP)}function Fv(t){return t<=0?0:Math.min(6e3,Math.max(350,t*rP))}function Uv(t,e){let r=Math.min(t.length,e.length),n=0;for(;n<r&&t[n]===e[n];)n++;return n}function Hv(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 lP(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 uP(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 dP(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 Gv(t,e,r,n,s,o,i,a){let c=(y,k,x,_)=>ln.of([{from:y,to:k,insert:x}],_).toJSON(),d=(y,k)=>({t:k,type:"editor.selection",path:t,ranges:[[y,y]]});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 f=lP(s,nP),p=i/f.length,m=r;return f.forEach((y,k)=>{let x=Math.round(o+p*(k+1));l.push({t:x,type:"editor.change",path:t,changes:c(m,m,y,u)}),m+=y.length,u+=y.length,l.push(d(m,x))}),l}function hP(t,e,r,n,s,o){let i=Uv(e,r),a=Hv(e,r,i);return Gv(t,e.length,i,e.length-a,r.slice(i,r.length-a),n,s,o)}function fP(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 pP(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 mP(t,e,r,n,s,o,i){let a=Math.max(1,r.reduce((p,m)=>p+m.replace.length,0)),c=[],d=e,l=n,u=null,f=0;for(let p of r){let m=fP(d,p.find,p.occurrence,i),y=Uv(p.find,p.replace),k=Hv(p.find,p.replace,y),x=p.replace.slice(y,p.replace.length-k),_=m+y,g=m+p.find.length-k,E=s*(Math.max(1,x.length)/a);c.push(...Gv(t,d.length,_,g,x,l,E,o)),d=d.slice(0,m)+p.replace+d.slice(m+p.find.length),l+=E,f+=x.length,u=x.length>0?[_,_+x.length]:null}return{events:c,content:d,lastRange:u,inserted:f}}function Wv(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,f)=>{let p=u.file??c??void 0,m=!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,m=!0));let y=Math.max(m?oP:0,u.chapter?iP:0),k=d+y,x=f+1,_=p&&s[p]||"",g=p!=null&&u.code!=null,E=p!=null&&(u.edits?.length??0)>0;if(u.code!=null&&u.edits?.length)throw new Error(`Step ${x}: use either \`code\` or \`edits\`, not both.`);if(g&&_.length>0&&!u.rewrite)throw new Error(`Step ${x}: "${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(E&&_.length===0)throw new Error(`Step ${x}: \`edits\` target "${p}" which has no code yet \u2014 introduce it first with top-level \`files\` or a \`code\` step.`);let h=E?u.edits.reduce((C,Z)=>C+Z.replace.length,0):0,$=Math.max(u.say?cP(u.say):0,Fv(h),u.terminal?1400:0,1200),z=u.holdMs??e.sayDurationsMs?.[f]??$,L=h>0?Math.min(Fv(h),Math.round(z*.7)):0,q=null;if(g&&p)i.push(...hP(p,_,u.code,k,0,!1)),s[p]=u.code;else if(E&&p){let C=mP(p,_,u.edits,k,L,u.typing!==!1,x);i.push(...C.events),s[p]=C.content,q=C.lastRange}if(p){let C;if(u.highlightCode!=null){let Z=pP(s[p]??"",u.highlightCode,x);C=[Z,Z+u.highlightCode.length]}else u.highlight?C=uP(s[p]??"",u.highlight[0],u.highlight[1]):C=q;C&&i.push({t:Math.round(k+L),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(k+Math.min(300,z*.2)),type:"term.data",data:C.endsWith(`\r
|
|
49
49
|
`)?C:C+`\r
|
|
50
|
-
`})}u.chapter&&i.push({t:d,type:"marker",label:u.chapter}),u.say&&a.push({t:k,dur:O,text:u.say,words:hI(u.say,k,O)}),d=k+O+oI}),i.sort((u,f)=>u.t-f.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 Yv=`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 _I={id:"code",tool:{name:"create_walkthrough",title:"Create interactive code walkthrough",description:Yv},promptLine:"\u2022 CODE \u2014 real code types out in an editor with synced highlights \u2192 create_walkthrough",schema:Om,makeBeat:t=>({say:t}),forceOutro:!1,compile:(t,e)=>Wv(t,e)},Xv=_I;var bI="TTS voice to narrate with \u2014 pick the one that best fits the topic/audience. Defaults to cedar (warm, natural). Options: "+Ur.map(t=>`${t} (${Ss[t]})`).join(", ")+".",yI=W.object({say:W.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:W.union([W.string(),W.array(W.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:W.union([W.string(),W.array(W.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:W.string().optional().describe("If set, starts a named chapter at this beat (timeline marker)."),holdMs:W.number().optional().describe("Beat duration in ms. Defaults to a duration derived from the narration.")}),Jm={title:W.string().describe("Title of the whiteboard walkthrough (header + filename)."),outputPath:W.string().optional().describe("Optional path to also write the .html to (same mapping as create_walkthrough)."),voiceName:W.enum(Ur).optional().describe(bI),voiceTone:W.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:W.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:W.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:W.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:W.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:W.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:W.record(W.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:W.record(W.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:W.record(W.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:W.array(yI).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.")},xq=W.object(Jm);var uw=Object.defineProperty,vI=(t,e,r)=>e in t?uw(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,wI=(t,e)=>{for(var r in e)uw(t,r,{get:e[r],enumerable:!0})},xI=(t,e,r)=>vI(t,typeof e!="symbol"?e+"":e,r),dw={};wI(dw,{Graph:()=>un,alg:()=>i1,json:()=>fw,version:()=>$I});var SI=Object.defineProperty,hw=(t,e)=>{for(var r in e)SI(t,r,{get:e[r],enumerable:!0})},un=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=Ua(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=kI(this._isDirected,s,o,i);return s=l.v,o=l.w,Object.freeze(l),this._edgeObjs[d]=l,Kv(this._preds[o],s),Kv(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?Qm(this._isDirected,t):Ua(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?Qm(this._isDirected,t):Ua(this._isDirected,t,e,r))in this._edgeLabels}removeEdge(t,e,r){let n=arguments.length===1?Qm(this._isDirected,t):Ua(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],Jv(this._preds[i],o),Jv(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 Kv(t,e){t[e]?t[e]++:t[e]=1}function Jv(t,e){t[e]!==void 0&&!--t[e]&&delete t[e]}function Ua(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 kI(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 Qm(t,e){return Ua(t,e.v,e.w,e.name)}var $I="4.0.1",fw={};hw(fw,{read:()=>II,write:()=>EI});function EI(t){let e={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:TI(t),edges:RI(t)},r=t.graph();return r!==void 0&&(e.value=structuredClone(r)),e}function TI(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 RI(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 II(t){let e=new un(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 i1={};hw(i1,{CycleException:()=>hu,bellmanFord:()=>pw,components:()=>OI,dijkstra:()=>du,dijkstraAll:()=>NI,findCycles:()=>CI,floydWarshall:()=>DI,isAcyclic:()=>ZI,postorder:()=>VI,preorder:()=>qI,prim:()=>FI,shortestPaths:()=>HI,tarjan:()=>gw,topsort:()=>_w});var PI=()=>1;function pw(t,e,r,n){return MI(t,String(e),r||PI,n||function(s){return t.outEdges(s)})}function MI(t,e,r,n){let s={},o,i=0,a=t.nodes(),c=function(u){let f=r(u);s[u.v].distance+f<s[u.w].distance&&(s[u.w]={distance:s[u.v].distance+f,predecessor:u.v},o=!0)},d=function(){a.forEach(function(u){n(u).forEach(function(f){let p=f.v===u?f.v:f.w,m=p===f.v?f.w:f.v;c({v:p,w:m})})})};a.forEach(function(u){let f=u===e?0:Number.POSITIVE_INFINITY;s[u]={distance:f,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 OI(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 mw=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}},AI=()=>1;function du(t,e,r,n){let s=function(o){return t.outEdges(o)};return zI(t,String(e),r||AI,n||s)}function zI(t,e,r,n){let s={},o=new mw,i,a,c=function(d){let l=d.v!==i?d.v:d.w,u=s[l],f=r(d),p=a.distance+f;if(f<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+d+" Weight: "+f);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 NI(t,e,r){return t.nodes().reduce(function(n,s){return n[s]=du(t,s,e,r),n},{})}function gw(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 CI(t){return gw(t).filter(function(e){return e.length>1||e.length===1&&t.hasEdge(e[0],e[0])})}var jI=()=>1;function DI(t,e,r){return LI(t,e||jI,r||function(n){return t.outEdges(n)})}function LI(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],f=c[d],p=l.distance+u.distance;p<f.distance&&(f.distance=p,f.predecessor=u.predecessor)})})}),n}var hu=class extends Error{constructor(...t){super(...t)}};function _w(t){let e={},r={},n=[];function s(o){if(o in r)throw new hu;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 hu;return n}function ZI(t){try{_w(t)}catch(e){if(e instanceof hu)return!1;throw e}return!0}function BI(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=bw(t,a,r==="post",i,o,n,s)}),s}function bw(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=bw(t,a,r,n,s,o,i)}),r&&(i=o(i,e))),i}function yw(t,e,r){return BI(t,e,r,function(n,s){return n.push(s),n},[])}function VI(t,e){return yw(t,e,"post")}function qI(t,e){return yw(t,e,"pre")}function FI(t,e){let r=new un,n={},s=new mw,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 HI(t,e,r,n){return UI(t,e,r,n??(s=>{let o=t.outEdges(s);return o??[]}))}function UI(t,e,r,n){if(r===void 0)return du(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 pw(t,e,r,n)}return du(t,e,r,n)}function xi(t,e,r,n){let s=n;for(;t.hasNode(s);)s=a1(n);return r.dummy=e,t.setNode(s,r),s}function GI(t){let e=new un().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 vw(t){let e=new un({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 Qv(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 Wa(t){let e=Ga(xw(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 WI(t){let e=t.nodes().map(n=>{let s=t.node(n).rank;return s===void 0?Number.MAX_VALUE:s}),r=Bn(Math.min,e);t.nodes().forEach(n=>{let s=t.node(n);Object.hasOwn(s,"rank")&&(s.rank-=r)})}function YI(t){let e=t.nodes().map(i=>t.node(i).rank).filter(i=>i!==void 0),r=Bn(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 ew(t,e,r,n){let s={width:0,height:0};return arguments.length>=4&&(s.rank=r,s.order=n),xi(t,"border",s,e)}function XI(t,e=ww){let r=[];for(let n=0;n<t.length;n+=e){let s=t.slice(n,n+e);r.push(s)}return r}var ww=65535;function Bn(t,e){if(e.length>ww){let r=XI(e);return t(...r.map(n=>t(...n)))}else return t(...e)}function xw(t){let e=t.nodes().map(r=>{let n=t.node(r).rank;return n===void 0?Number.MIN_VALUE:n});return Bn(Math.max,e)}function KI(t,e){let r={lhs:[],rhs:[]};return t.forEach(n=>{e(n)?r.lhs.push(n):r.rhs.push(n)}),r}function Sw(t,e){let r=Date.now();try{return e()}finally{console.log(t+" time: "+(Date.now()-r)+"ms")}}function kw(t,e){return e()}var JI=0;function a1(t){let e=++JI;return t+(""+e)}function Ga(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 fu(t,e){let r={};for(let n of e)t[n]!==void 0&&(r[n]=t[n]);return r}function pu(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 QI(t,e){return t.reduce((r,n,s)=>(r[n]=e[s],r),{})}var mu="\0",eP="3.0.0",tP=class{constructor(){xI(this,"_sentinel");let t={};t._next=t._prev=t,this._sentinel=t}dequeue(){let t=this._sentinel,e=t._prev;if(e!==t)return tw(e),e}enqueue(t){let e=this._sentinel;t._prev&&t._next&&tw(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,rP)),r=r._prev;return"["+t.join(", ")+"]"}};function tw(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function rP(t,e){if(t!=="_next"&&t!=="_prev")return e}var nP=tP,sP=()=>1;function oP(t,e){if(t.nodeCount()<=1)return[];let r=aP(t,e||sP);return iP(r.graph,r.buckets,r.zeroIdx).flatMap(n=>t.outEdges(n.v,n.w)||[])}function iP(t,e,r){var n;let s=[],o=e[e.length-1],i=e[0],a;for(;t.nodeCount();){for(;a=i.dequeue();)e1(t,e,r,a);for(;a=o.dequeue();)e1(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(e1(t,e,r,a,!0)||[]);break}}}return s}function e1(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,o1(e,r,d)}),(t.outEdges(n.v)||[]).forEach(a=>{let c=t.edge(a),d=a.w,l=t.node(d);l.in-=c,o1(e,r,l)}),t.removeNode(n.v),i}function aP(t,e){let r=new un,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),f=r.node(a.w);s=Math.max(s,u.out+=d),n=Math.max(n,f.in+=d)});let o=cP(s+n+3).map(()=>new nP),i=n+1;return r.nodes().forEach(a=>{o1(o,i,r.node(a))}),{graph:r,buckets:o,zeroIdx:i}}function o1(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 cP(t){let e=[];for(let r=0;r<t;r++)e.push(r);return e}function lP(t){(t.graph().acyclicer==="greedy"?oP(t,e(t)):uP(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,a1("rev"))});function e(r){return n=>r.edge(n).weight}}function uP(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 dP(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 hP(t){t.graph().dummyChains=[],t.edges().forEach(e=>fP(t,e))}function fP(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=xi(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 pP(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 c1(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=Bn(Math.min,i);return a===Number.POSITIVE_INFINITY&&(a=0),s.rank=a}t.sources().forEach(r)}function wi(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen}var $w=mP;function mP(t){let e=new un({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(;gP(e,t)<s&&(o=_P(e,t),!!o);)i=e.hasNode(o.v)?wi(t,o):-wi(t,o),bP(e,t,i);return e}function gP(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)&&!wi(e,o)&&(t.setNode(a,{}),t.setEdge(n,a,{}),r(a))})}return t.nodes().forEach(r),t.nodeCount()}function _P(t,e){return e.edges().reduce((r,n)=>{let s=Number.POSITIVE_INFINITY;return t.hasNode(n.v)!==t.hasNode(n.w)&&(s=wi(e,n)),s<r[0]?[s,n]:r},[Number.POSITIVE_INFINITY,null])[1]}function bP(t,e,r){t.nodes().forEach(n=>e.node(n).rank+=r)}var{preorder:yP,postorder:vP}=i1,wP=So;So.initLowLimValues=u1;So.initCutValues=l1;So.calcCutValue=Ew;So.leaveEdge=Rw;So.enterEdge=Iw;So.exchangeEdges=Pw;function So(t){t=GI(t),c1(t);let e=$w(t);u1(e),l1(e,t);let r,n;for(;r=Rw(e);)n=Iw(e,t,r),Pw(e,t,r,n)}function l1(t,e){let r=vP(t,t.nodes());r=r.slice(0,r.length-1),r.forEach(n=>xP(t,e,n))}function xP(t,e,r){let n=t.node(r).parent,s=t.edge(r,n);s.cutvalue=Ew(t,e,r)}function Ew(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,f=e.edge(c).weight;if(i+=u?f:-f,kP(t,r,l)){let p=t.edge(r,l).cutvalue;i+=u?-p:p}}}),i}function u1(t,e){arguments.length<2&&(e=t.nodes()[0]),Tw(t,{},1,e)}function Tw(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=Tw(t,e,r,c,n))}),i.low=o,i.lim=r++,s?i.parent=s:delete i.parent,r}function Rw(t){return t.edges().find(e=>t.edge(e).cutvalue<0)}function Iw(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===rw(t,t.node(d.v),a)&&c!==rw(t,t.node(d.w),a)).reduce((d,l)=>wi(e,l)<wi(e,d)?l:d)}function Pw(t,e,r,n){let s=r.v,o=r.w;t.removeEdge(s,o),t.setEdge(n.v,n.w,{}),u1(t),l1(t,e),SP(t,e)}function SP(t,e){let r=t.nodes().find(s=>!t.node(s).parent);if(!r)return;let n=yP(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 kP(t,e,r){return t.hasEdge(e,r)}function rw(t,e,r){return r.low<=e.lim&&e.lim<=r.lim}var $P=EP;function EP(t){let e=t.graph().ranker;if(typeof e=="function")return e(t);switch(e){case"network-simplex":nw(t);break;case"tight-tree":RP(t);break;case"longest-path":TP(t);break;case"none":break;default:nw(t)}}var TP=c1;function RP(t){c1(t),$w(t)}function nw(t){wP(t)}var IP=PP;function PP(t){let e=OP(t);t.graph().dummyChains.forEach(r=>{let n=t.node(r),s=n.edgeObj,o=MP(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 MP(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 OP(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(mu).forEach(n),e}function AP(t){let e=xi(t,"root",{},"_root"),r=zP(t),n=Object.values(r),s=Bn(Math.max,n)-1,o=2*s+1;t.graph().nestingRoot=e,t.edges().forEach(a=>t.edge(a).minlen*=o);let i=NP(t)+1;t.children(mu).forEach(a=>Mw(t,e,o,i,s,r,a)),t.graph().nodeRankFactor=o}function Mw(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=ew(t,"_bt"),l=ew(t,"_bb"),u=t.node(i);t.setParent(d,i),u.borderTop=d,t.setParent(l,i),u.borderBottom=l,c.forEach(f=>{var p;Mw(t,e,r,n,s,o,f);let m=t.node(f),y=m.borderTop?m.borderTop:f,k=m.borderBottom?m.borderBottom:f,x=m.borderTop?n:2*n,_=y!==k?1:s-((p=o[i])!=null?p:0)+1;t.setEdge(d,y,{weight:x,minlen:_,nestingEdge:!0}),t.setEdge(k,l,{weight:x,minlen:_,nestingEdge:!0})}),t.parent(i)||t.setEdge(e,d,{weight:0,minlen:s+((a=o[i])!=null?a:0)})}function zP(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(mu).forEach(n=>r(n,1)),e}function NP(t){return t.edges().reduce((e,r)=>e+t.edge(r).weight,0)}function CP(t){let e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,t.edges().forEach(r=>{t.edge(r).nestingEdge&&t.removeEdge(r)})}var jP=DP;function DP(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)sw(t,"borderLeft","_bl",r,s,o),sw(t,"borderRight","_br",r,s,o)}}t.children(mu).forEach(e)}function sw(t,e,r,n,s,o){let i={width:0,height:0,rank:o,borderType:e},a=s[e][o-1],c=xi(t,"border",i,r);s[e][o]=c,t.setParent(c,n),a&&t.setEdge(a,c,{weight:1})}function LP(t){var e;let r=(e=t.graph().rankdir)==null?void 0:e.toLowerCase();(r==="lr"||r==="rl")&&Ow(t)}function ZP(t){var e;let r=(e=t.graph().rankdir)==null?void 0:e.toLowerCase();(r==="bt"||r==="rl")&&BP(t),(r==="lr"||r==="rl")&&(VP(t),Ow(t))}function Ow(t){t.nodes().forEach(e=>ow(t.node(e))),t.edges().forEach(e=>ow(t.edge(e)))}function ow(t){let e=t.width;t.width=t.height,t.height=e}function BP(t){t.nodes().forEach(e=>t1(t.node(e))),t.edges().forEach(e=>{var r;let n=t.edge(e);(r=n.points)==null||r.forEach(t1),Object.hasOwn(n,"y")&&t1(n)})}function t1(t){t.y=-t.y}function VP(t){t.nodes().forEach(e=>r1(t.node(e))),t.edges().forEach(e=>{var r;let n=t.edge(e);(r=n.points)==null||r.forEach(r1),Object.hasOwn(n,"x")&&r1(n)})}function r1(t){let e=t.x;t.x=t.y,t.y=e}function qP(t){let e={},r=t.nodes().filter(a=>!t.children(a).length),n=r.map(a=>t.node(a).rank),s=Bn(Math.max,n),o=Ga(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 FP(t,e){let r=0;for(let n=1;n<e.length;++n)r+=HP(t,e[n-1],e[n]);return r}function HP(t,e,r){let n=QI(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,f)=>u.pos-f.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 UP(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 GP(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 WP(n)}function WP(t){let e=[];function r(s){return o=>{o.merged||(o.barycenter===void 0||s.barycenter===void 0||o.barycenter>=s.barycenter)&&YP(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=>fu(s,["vs","i","barycenter","weight"]))}function YP(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 XP(t,e){let r=KI(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(KP(!!e)),c=iw(o,s,c),n.forEach(l=>{c+=l.vs.length,o.push(l.vs),i+=l.barycenter*l.weight,a+=l.weight,c=iw(o,s,c)});let d={vs:o.flat(1)};return a&&(d.barycenter=i/a,d.weight=a),d}function iw(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 KP(t){return(e,r)=>e.barycenter<r.barycenter?-1:e.barycenter>r.barycenter?1:t?r.i-e.i:e.i-r.i}function Aw(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(f=>f!==i&&f!==a));let d=UP(t,s);d.forEach(f=>{if(t.children(f.v).length){let p=Aw(t,f.v,r,n);c[f.v]=p,Object.hasOwn(p,"barycenter")&&QP(f,p)}});let l=GP(d,r);JP(l,c);let u=XP(l,n);if(i&&a){u.vs=[i,u.vs,a].flat(1);let f=t.predecessors(i);if(f&&f.length){let p=t.node(f[0]),m=t.predecessors(a),y=t.node(m[0]);Object.hasOwn(u,"barycenter")||(u.barycenter=0,u.weight=0),u.barycenter=(u.barycenter*u.weight+p.order+y.order)/(u.weight+2),u.weight+=2}}return u}function JP(t,e){t.forEach(r=>{r.vs=r.vs.flatMap(n=>e[n]?e[n].vs:n)})}function QP(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 eM(t,e,r,n){n||(n=t.nodes());let s=tM(t),o=new un({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,f=o.edge(u,i),p=f!==void 0?f.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 tM(t){let e;for(;t.hasNode(e=a1("_root")););return e}function rM(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 zw(t,e={}){if(typeof e.customOrder=="function"){e.customOrder(t,zw);return}let r=xw(t),n=aw(t,Ga(1,r+1),"inEdges"),s=aw(t,Ga(r-1,-1,-1),"outEdges"),o=qP(t);if(cw(t,o),e.disableOptimalOrderHeuristic)return;let i=Number.POSITIVE_INFINITY,a,c=e.constraints||[];for(let d=0,l=0;l<4;++d,++l){nM(d%2?n:s,d%4>=2,c),o=Wa(t);let u=FP(t,o);u<i?(l=0,a=Object.assign({},o),i=u):u===i&&(a=structuredClone(o))}cw(t,a)}function aw(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 eM(t,o,r,n.get(o)||[])})}function nM(t,e,r){let n=new un;t.forEach(function(s){r.forEach(a=>n.setEdge(a.left,a.right));let o=s.graph().root,i=Aw(s,o,n,e);i.vs.forEach((a,c)=>s.node(a).order=c),rM(s,n,i.vs)})}function cw(t,e){Object.values(e).forEach(r=>r.forEach((n,s)=>t.node(n).order=s))}function sM(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 f=iM(t,l),p=f?t.node(f).order:c;(f||l===d)&&(o.slice(a,u+1).forEach(m=>{let y=t.predecessors(m);y&&y.forEach(k=>{let x=t.node(k),_=x.order;(_<i||p<_)&&!(x.dummy&&t.node(m).dummy)&&Nw(r,k,m)})}),a=u+1,i=p)}),o}return e.length&&e.reduce(n),r}function oM(t,e){let r={};function n(o,i,a,c,d){Ga(i,a).forEach(l=>{let u=o[l];if(u!==void 0&&t.node(u).dummy){let f=t.predecessors(u);f&&f.forEach(p=>{if(p===void 0)return;let m=t.node(p);m.dummy&&(m.order<c||m.order>d)&&Nw(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 f=t.predecessors(l);if(f&&f.length){let p=f[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 iM(t,e){if(t.node(e).dummy){let r=t.predecessors(e);if(r)return r.find(n=>t.node(n).dummy)}}function Nw(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 aM(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 cM(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,m)=>{let y=i[p],k=i[m];return(y!==void 0?y:0)-(k!==void 0?k:0)}),f=(u.length-1)/2;for(let p=Math.floor(f),m=Math.ceil(f);p<=m;++p){let y=u[p];if(y===void 0)continue;let k=i[y];if(k!==void 0&&o[d]===d&&c<k&&!aM(r,d,y)){let x=s[y];x!==void 0&&(o[y]=d,o[d]=s[d]=x,c=k)}}}})}),{root:s,align:o}}function lM(t,e,r,n,s=!1){let o={},i=uM(t,e,r,s),a=s?"borderLeft":"borderRight";function c(p,m){let y=i.nodes().slice(),k={},x=y.pop();for(;x;){if(k[x])p(x);else{k[x]=!0,y.push(x);for(let _ of m(x))y.push(_)}x=y.pop()}}function d(p){let m=i.inEdges(p);m?o[p]=m.reduce((y,k)=>{var x;let _=(x=o[k.v])!=null?x:0,g=i.edge(k);return Math.max(y,_+(g!==void 0?g:0))},0):o[p]=0}function l(p){let m=i.outEdges(p),y=Number.POSITIVE_INFINITY;m&&(y=m.reduce((x,_)=>{let g=o[_.w],E=i.edge(_);return Math.min(x,(g!==void 0?g:0)-(E!==void 0?E:0))},Number.POSITIVE_INFINITY));let k=t.node(p);y!==Number.POSITIVE_INFINITY&&k.borderType!==a&&(o[p]=Math.max(o[p]!==void 0?o[p]:0,y))}function u(p){return i.predecessors(p)||[]}function f(p){return i.successors(p)||[]}return c(d,u),c(l,f),Object.keys(n).forEach(p=>{var m;let y=r[p];y!==void 0&&(o[p]=(m=o[y])!=null?m:0)}),o}function uM(t,e,r,n){let s=new un,o=t.graph(),i=mM(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 f=s.edge(u,l);s.setEdge(u,l,Math.max(i(t,d,c),f||0))}}c=d}})}),s}function dM(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=gM(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 hM(t,e){let r=Object.values(e),n=Bn(Math.min,r),s=Bn(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-Bn(Math.min,d);i!=="l"&&(l=s-Bn(Math.max,d)),l&&(t[a]=pu(c,u=>u+l))})})}function fM(t,e=void 0){let r=t.ul;return r?pu(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 pM(t){let e=Wa(t),r=Object.assign(sM(t,e),oM(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=cM(t,s,r,l=>(i==="u"?t.predecessors(l):t.successors(l))||[]),d=lM(t,s,c.root,c.align,a==="r");a==="r"&&(d=pu(d,l=>-l)),n[i+a]=d})});let o=dM(t,n);return hM(n,o),fM(n,t.graph().align)}function mM(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 gM(t,e){return t.node(e).width}function _M(t){t=vw(t),bM(t),Object.entries(pM(t)).forEach(([e,r])=>t.node(e).x=r)}function bM(t){let e=Wa(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 yM(t,e={}){let r=e.debugTiming?Sw:kw;return r("layout",()=>{let n=r(" buildLayoutGraph",()=>IM(t));return r(" runLayout",()=>vM(n,r,e)),r(" updateInputGraph",()=>wM(t,n)),n})}function vM(t,e,r){e(" makeSpaceForEdgeLabels",()=>PM(t)),e(" removeSelfEdges",()=>LM(t)),e(" acyclic",()=>lP(t)),e(" nestingGraph.run",()=>AP(t)),e(" rank",()=>$P(vw(t))),e(" injectEdgeLabelProxies",()=>MM(t)),e(" removeEmptyRanks",()=>YI(t)),e(" nestingGraph.cleanup",()=>CP(t)),e(" normalizeRanks",()=>WI(t)),e(" assignRankMinMax",()=>OM(t)),e(" removeEdgeLabelProxies",()=>AM(t)),e(" normalize.run",()=>hP(t)),e(" parentDummyChains",()=>IP(t)),e(" addBorderSegments",()=>jP(t)),e(" order",()=>zw(t,r)),e(" insertSelfEdges",()=>ZM(t)),e(" adjustCoordinateSystem",()=>LP(t)),e(" position",()=>_M(t)),e(" positionSelfEdges",()=>BM(t)),e(" removeBorderNodes",()=>DM(t)),e(" normalize.undo",()=>pP(t)),e(" fixupEdgeLabelCoords",()=>CM(t)),e(" undoCoordinateSystem",()=>ZP(t)),e(" translateGraph",()=>zM(t)),e(" assignNodeIntersects",()=>NM(t)),e(" reversePoints",()=>jM(t)),e(" acyclic.undo",()=>dP(t))}function wM(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 xM=["nodesep","edgesep","ranksep","marginx","marginy"],SM={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},kM=["acyclicer","ranker","rankdir","align","rankalign"],$M=["width","height","rank"],lw={width:0,height:0},EM=["minlen","weight","width","height","labeloffset"],TM={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},RM=["labelpos"];function IM(t){let e=new un({multigraph:!0,compound:!0}),r=s1(t.graph());return e.setGraph(Object.assign({},SM,n1(r,xM),fu(r,kM))),t.nodes().forEach(n=>{let s=s1(t.node(n)),o=n1(s,$M);Object.keys(lw).forEach(a=>{o[a]===void 0&&(o[a]=lw[a])}),e.setNode(n,o);let i=t.parent(n);i!==void 0&&e.setParent(n,i)}),t.edges().forEach(n=>{let s=s1(t.edge(n));e.setEdge(n,Object.assign({},TM,n1(s,EM),fu(s,RM)))}),e}function PM(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 MM(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};xi(t,"edge-proxy",s,"_ep")}})}function OM(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 AM(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 zM(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,f=d.width,p=d.height;e=Math.min(e,l-f/2),r=Math.max(r,l+f/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 NM(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(Qv(n,o)),r.points.push(Qv(s,i))})}function CM(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 jM(t){t.edges().forEach(e=>{let r=t.edge(e);r.reversed&&r.points.reverse()})}function DM(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 LM(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 ZM(t){Wa(t).forEach(e=>{let r=0;e.forEach((n,s)=>{let o=t.node(n);o.order=s+r,(o.selfEdges||[]).forEach(i=>{xi(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 BM(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 n1(t,e){return pu(fu(t,e),Number)}function s1(t){let e={};return t&&Object.entries(t).forEach(([r,n])=>{typeof r=="string"&&(r=r.toLowerCase()),e[r]=n}),e}function VM(t){let e=Wa(t),r=new un({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 qM={graphlib:dw,version:eP,layout:yM,debug:VM,util:{time:Sw,notime:kw}},d1=qM;var FM={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 p1(t){return t?FM[t.trim().toLowerCase()]:void 0}var gu={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"}},Cw=["sky","green","amber","pink","purple","teal","peach","indigo","mint","rose"];function Lw(t){return gu[Cw[t%Cw.length]]}var HM=[["([","])","stadium"],["[[","]]","subroutine"],["[(",")]","cylinder"],["((","))","circle"],["{{","}}","hexagon"],["[","]","rect"],["(",")","round"],["{","}","diamond"]];function h1(t){let e=t.trim();return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function f1(t){return t.replace(/\\n/g,`
|
|
50
|
+
`})}u.chapter&&i.push({t:d,type:"marker",label:u.chapter}),u.say&&a.push({t:k,dur:z,text:u.say,words:dP(u.say,k,z)}),d=k+z+sP}),i.sort((u,f)=>u.t-f.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 Yv='Render an interactive code walkthrough into ONE self-contained .html file.\n\nYou (the agent) are the author: gather the code + explanation, then describe the walkthrough as an ordered list of `steps`. The page replays inside a real CodeMirror editor \u2014 the viewer scrubs a timeline, watches code TYPE OUT in sync with narration, and can pause/edit. No server or deps; opens in any browser. (Sibling tools: create_whiteboard_walkthrough, create_map_walkthrough, create_3d_walkthrough \u2014 if it\'s unclear which the user wants, ask.)\n\nTeach it like a screencast lesson:\n- HOOK on the problem/why first (not "here\'s a file"); ORIENT; BUILD one idea at a time in chapters named after the sub-goal; PAY OFF (show it run); RECAP.\n- Say the INTENT before the code. ONE new idea per beat. Surface the non-obvious reasoning.\n\nGranularity (most important): MANY small beats, not a few monologues. Lean high \u2014 a small feature is often 20\u201350 steps. Each `say` is ONE short beat (~4\u201314 words, one breath); split any sentence with an "and"/comma joining two ideas. Write the narration as one continuous script, then chop it into beats that flow together (use connectors like "so", "then", "now").\n\nThree kinds of step:\n1. INTRODUCE a file once: `file` + `code` (full initial contents, shown instantly). Or declare already-existing files in top-level `files`.\n2. SHOW/explain (most common, NO code): `file` (to switch tabs) + `say` + `highlightCode`.\n3. EDIT: `edits: [{ find, replace }]` \u2014 a find/replace delta that types out only the change.\n\nRules the server enforces: after a file is introduced, never resend `code` for it (use `edits`, or `rewrite:true` for a deliberate full rewrite); a step uses EITHER `code` OR `edits`.\n\nHighlighting is half the lesson: every step that discusses code MUST point at it with `highlightCode` \u2014 paste the EXACT, UNIQUE snippet (a token/line, or a whole multi-line block). It scrolls + glows into view and never drifts when edits move lines. (On an `edits` step the new code is highlighted automatically.)\n\nVoice: set `voiceName` + `voiceTone` to fit the topic. The server auto-adds spoken intro/outro beats \u2014 don\'t write your own welcome/sign-off (customize via `intro`/`outro`).\n\nOutput: the primary deliverable is a local URL (http://127.0.0.1:<port>/<id>.html) returned as a resource_link \u2014 give it to the user to open in a browser. A ui://flowcast/<id> resource is also returned (resources/read \u2192 full HTML). Pass `outputPath` only to also write the file somewhere.';var gP={id:"code",tool:{name:"create_walkthrough",title:"Create interactive code walkthrough",description:Yv},promptLine:"\u2022 CODE \u2014 real code types out in an editor with synced highlights \u2192 create_walkthrough",schema:zm,makeBeat:t=>({say:t}),forceOutro:!1,compile:(t,e)=>Wv(t,e)},Xv=gP;var _P="TTS voice to narrate with \u2014 pick the one that best fits the topic/audience. Defaults to cedar (warm, natural). Options: "+Hr.map(t=>`${t} (${Jl[t]})`).join(", ")+".",bP=W.object({say:W.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:W.union([W.string(),W.array(W.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:W.union([W.string(),W.array(W.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:W.string().optional().describe("If set, starts a named chapter at this beat (timeline marker)."),holdMs:W.number().optional().describe("Beat duration in ms. Defaults to a duration derived from the narration.")}),Jm={title:W.string().describe("Title of the whiteboard walkthrough (header + filename)."),outputPath:W.string().optional().describe("Optional path to also write the .html to (same mapping as create_walkthrough)."),voiceName:W.enum(Hr).optional().describe(_P),voiceTone:W.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:W.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:W.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:W.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:W.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:W.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:W.record(W.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:W.record(W.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:W.record(W.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:W.array(bP).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.")},xq=W.object(Jm);var uw=Object.defineProperty,yP=(t,e,r)=>e in t?uw(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,vP=(t,e)=>{for(var r in e)uw(t,r,{get:e[r],enumerable:!0})},wP=(t,e,r)=>yP(t,typeof e!="symbol"?e+"":e,r),dw={};vP(dw,{Graph:()=>un,alg:()=>i1,json:()=>fw,version:()=>kP});var xP=Object.defineProperty,hw=(t,e)=>{for(var r in e)xP(t,r,{get:e[r],enumerable:!0})},un=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=Ua(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=SP(this._isDirected,s,o,i);return s=l.v,o=l.w,Object.freeze(l),this._edgeObjs[d]=l,Kv(this._preds[o],s),Kv(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?Qm(this._isDirected,t):Ua(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?Qm(this._isDirected,t):Ua(this._isDirected,t,e,r))in this._edgeLabels}removeEdge(t,e,r){let n=arguments.length===1?Qm(this._isDirected,t):Ua(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],Jv(this._preds[i],o),Jv(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 Kv(t,e){t[e]?t[e]++:t[e]=1}function Jv(t,e){t[e]!==void 0&&!--t[e]&&delete t[e]}function Ua(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 SP(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 Qm(t,e){return Ua(t,e.v,e.w,e.name)}var kP="4.0.1",fw={};hw(fw,{read:()=>RP,write:()=>$P});function $P(t){let e={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:EP(t),edges:TP(t)},r=t.graph();return r!==void 0&&(e.value=structuredClone(r)),e}function EP(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 TP(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 RP(t){let e=new un(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 i1={};hw(i1,{CycleException:()=>hu,bellmanFord:()=>pw,components:()=>IP,dijkstra:()=>du,dijkstraAll:()=>OP,findCycles:()=>NP,floydWarshall:()=>jP,isAcyclic:()=>LP,postorder:()=>BP,preorder:()=>VP,prim:()=>qP,shortestPaths:()=>FP,tarjan:()=>gw,topsort:()=>_w});var PP=()=>1;function pw(t,e,r,n){return MP(t,String(e),r||PP,n||function(s){return t.outEdges(s)})}function MP(t,e,r,n){let s={},o,i=0,a=t.nodes(),c=function(u){let f=r(u);s[u.v].distance+f<s[u.w].distance&&(s[u.w]={distance:s[u.v].distance+f,predecessor:u.v},o=!0)},d=function(){a.forEach(function(u){n(u).forEach(function(f){let p=f.v===u?f.v:f.w,m=p===f.v?f.w:f.v;c({v:p,w:m})})})};a.forEach(function(u){let f=u===e?0:Number.POSITIVE_INFINITY;s[u]={distance:f,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 IP(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 mw=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}},zP=()=>1;function du(t,e,r,n){let s=function(o){return t.outEdges(o)};return AP(t,String(e),r||zP,n||s)}function AP(t,e,r,n){let s={},o=new mw,i,a,c=function(d){let l=d.v!==i?d.v:d.w,u=s[l],f=r(d),p=a.distance+f;if(f<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+d+" Weight: "+f);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 OP(t,e,r){return t.nodes().reduce(function(n,s){return n[s]=du(t,s,e,r),n},{})}function gw(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 NP(t){return gw(t).filter(function(e){return e.length>1||e.length===1&&t.hasEdge(e[0],e[0])})}var CP=()=>1;function jP(t,e,r){return DP(t,e||CP,r||function(n){return t.outEdges(n)})}function DP(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],f=c[d],p=l.distance+u.distance;p<f.distance&&(f.distance=p,f.predecessor=u.predecessor)})})}),n}var hu=class extends Error{constructor(...t){super(...t)}};function _w(t){let e={},r={},n=[];function s(o){if(o in r)throw new hu;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 hu;return n}function LP(t){try{_w(t)}catch(e){if(e instanceof hu)return!1;throw e}return!0}function ZP(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=bw(t,a,r==="post",i,o,n,s)}),s}function bw(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=bw(t,a,r,n,s,o,i)}),r&&(i=o(i,e))),i}function yw(t,e,r){return ZP(t,e,r,function(n,s){return n.push(s),n},[])}function BP(t,e){return yw(t,e,"post")}function VP(t,e){return yw(t,e,"pre")}function qP(t,e){let r=new un,n={},s=new mw,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 FP(t,e,r,n){return UP(t,e,r,n??(s=>{let o=t.outEdges(s);return o??[]}))}function UP(t,e,r,n){if(r===void 0)return du(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 pw(t,e,r,n)}return du(t,e,r,n)}function wi(t,e,r,n){let s=n;for(;t.hasNode(s);)s=a1(n);return r.dummy=e,t.setNode(s,r),s}function HP(t){let e=new un().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 vw(t){let e=new un({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 Qv(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 Ga(t){let e=Ha(xw(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 GP(t){let e=t.nodes().map(n=>{let s=t.node(n).rank;return s===void 0?Number.MAX_VALUE:s}),r=Bn(Math.min,e);t.nodes().forEach(n=>{let s=t.node(n);Object.hasOwn(s,"rank")&&(s.rank-=r)})}function WP(t){let e=t.nodes().map(i=>t.node(i).rank).filter(i=>i!==void 0),r=Bn(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 ew(t,e,r,n){let s={width:0,height:0};return arguments.length>=4&&(s.rank=r,s.order=n),wi(t,"border",s,e)}function YP(t,e=ww){let r=[];for(let n=0;n<t.length;n+=e){let s=t.slice(n,n+e);r.push(s)}return r}var ww=65535;function Bn(t,e){if(e.length>ww){let r=YP(e);return t(...r.map(n=>t(...n)))}else return t(...e)}function xw(t){let e=t.nodes().map(r=>{let n=t.node(r).rank;return n===void 0?Number.MIN_VALUE:n});return Bn(Math.max,e)}function XP(t,e){let r={lhs:[],rhs:[]};return t.forEach(n=>{e(n)?r.lhs.push(n):r.rhs.push(n)}),r}function Sw(t,e){let r=Date.now();try{return e()}finally{console.log(t+" time: "+(Date.now()-r)+"ms")}}function kw(t,e){return e()}var KP=0;function a1(t){let e=++KP;return t+(""+e)}function Ha(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 fu(t,e){let r={};for(let n of e)t[n]!==void 0&&(r[n]=t[n]);return r}function pu(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 JP(t,e){return t.reduce((r,n,s)=>(r[n]=e[s],r),{})}var mu="\0",QP="3.0.0",eM=class{constructor(){wP(this,"_sentinel");let t={};t._next=t._prev=t,this._sentinel=t}dequeue(){let t=this._sentinel,e=t._prev;if(e!==t)return tw(e),e}enqueue(t){let e=this._sentinel;t._prev&&t._next&&tw(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,tM)),r=r._prev;return"["+t.join(", ")+"]"}};function tw(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function tM(t,e){if(t!=="_next"&&t!=="_prev")return e}var rM=eM,nM=()=>1;function sM(t,e){if(t.nodeCount()<=1)return[];let r=iM(t,e||nM);return oM(r.graph,r.buckets,r.zeroIdx).flatMap(n=>t.outEdges(n.v,n.w)||[])}function oM(t,e,r){var n;let s=[],o=e[e.length-1],i=e[0],a;for(;t.nodeCount();){for(;a=i.dequeue();)e1(t,e,r,a);for(;a=o.dequeue();)e1(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(e1(t,e,r,a,!0)||[]);break}}}return s}function e1(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,o1(e,r,d)}),(t.outEdges(n.v)||[]).forEach(a=>{let c=t.edge(a),d=a.w,l=t.node(d);l.in-=c,o1(e,r,l)}),t.removeNode(n.v),i}function iM(t,e){let r=new un,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),f=r.node(a.w);s=Math.max(s,u.out+=d),n=Math.max(n,f.in+=d)});let o=aM(s+n+3).map(()=>new rM),i=n+1;return r.nodes().forEach(a=>{o1(o,i,r.node(a))}),{graph:r,buckets:o,zeroIdx:i}}function o1(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 aM(t){let e=[];for(let r=0;r<t;r++)e.push(r);return e}function cM(t){(t.graph().acyclicer==="greedy"?sM(t,e(t)):lM(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,a1("rev"))});function e(r){return n=>r.edge(n).weight}}function lM(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 uM(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 dM(t){t.graph().dummyChains=[],t.edges().forEach(e=>hM(t,e))}function hM(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=wi(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 fM(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 c1(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=Bn(Math.min,i);return a===Number.POSITIVE_INFINITY&&(a=0),s.rank=a}t.sources().forEach(r)}function vi(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen}var $w=pM;function pM(t){let e=new un({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(;mM(e,t)<s&&(o=gM(e,t),!!o);)i=e.hasNode(o.v)?vi(t,o):-vi(t,o),_M(e,t,i);return e}function mM(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)&&!vi(e,o)&&(t.setNode(a,{}),t.setEdge(n,a,{}),r(a))})}return t.nodes().forEach(r),t.nodeCount()}function gM(t,e){return e.edges().reduce((r,n)=>{let s=Number.POSITIVE_INFINITY;return t.hasNode(n.v)!==t.hasNode(n.w)&&(s=vi(e,n)),s<r[0]?[s,n]:r},[Number.POSITIVE_INFINITY,null])[1]}function _M(t,e,r){t.nodes().forEach(n=>e.node(n).rank+=r)}var{preorder:bM,postorder:yM}=i1,vM=xo;xo.initLowLimValues=u1;xo.initCutValues=l1;xo.calcCutValue=Ew;xo.leaveEdge=Rw;xo.enterEdge=Pw;xo.exchangeEdges=Mw;function xo(t){t=HP(t),c1(t);let e=$w(t);u1(e),l1(e,t);let r,n;for(;r=Rw(e);)n=Pw(e,t,r),Mw(e,t,r,n)}function l1(t,e){let r=yM(t,t.nodes());r=r.slice(0,r.length-1),r.forEach(n=>wM(t,e,n))}function wM(t,e,r){let n=t.node(r).parent,s=t.edge(r,n);s.cutvalue=Ew(t,e,r)}function Ew(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,f=e.edge(c).weight;if(i+=u?f:-f,SM(t,r,l)){let p=t.edge(r,l).cutvalue;i+=u?-p:p}}}),i}function u1(t,e){arguments.length<2&&(e=t.nodes()[0]),Tw(t,{},1,e)}function Tw(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=Tw(t,e,r,c,n))}),i.low=o,i.lim=r++,s?i.parent=s:delete i.parent,r}function Rw(t){return t.edges().find(e=>t.edge(e).cutvalue<0)}function Pw(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===rw(t,t.node(d.v),a)&&c!==rw(t,t.node(d.w),a)).reduce((d,l)=>vi(e,l)<vi(e,d)?l:d)}function Mw(t,e,r,n){let s=r.v,o=r.w;t.removeEdge(s,o),t.setEdge(n.v,n.w,{}),u1(t),l1(t,e),xM(t,e)}function xM(t,e){let r=t.nodes().find(s=>!t.node(s).parent);if(!r)return;let n=bM(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 SM(t,e,r){return t.hasEdge(e,r)}function rw(t,e,r){return r.low<=e.lim&&e.lim<=r.lim}var kM=$M;function $M(t){let e=t.graph().ranker;if(typeof e=="function")return e(t);switch(e){case"network-simplex":nw(t);break;case"tight-tree":TM(t);break;case"longest-path":EM(t);break;case"none":break;default:nw(t)}}var EM=c1;function TM(t){c1(t),$w(t)}function nw(t){vM(t)}var RM=PM;function PM(t){let e=IM(t);t.graph().dummyChains.forEach(r=>{let n=t.node(r),s=n.edgeObj,o=MM(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 MM(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 IM(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(mu).forEach(n),e}function zM(t){let e=wi(t,"root",{},"_root"),r=AM(t),n=Object.values(r),s=Bn(Math.max,n)-1,o=2*s+1;t.graph().nestingRoot=e,t.edges().forEach(a=>t.edge(a).minlen*=o);let i=OM(t)+1;t.children(mu).forEach(a=>Iw(t,e,o,i,s,r,a)),t.graph().nodeRankFactor=o}function Iw(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=ew(t,"_bt"),l=ew(t,"_bb"),u=t.node(i);t.setParent(d,i),u.borderTop=d,t.setParent(l,i),u.borderBottom=l,c.forEach(f=>{var p;Iw(t,e,r,n,s,o,f);let m=t.node(f),y=m.borderTop?m.borderTop:f,k=m.borderBottom?m.borderBottom:f,x=m.borderTop?n:2*n,_=y!==k?1:s-((p=o[i])!=null?p:0)+1;t.setEdge(d,y,{weight:x,minlen:_,nestingEdge:!0}),t.setEdge(k,l,{weight:x,minlen:_,nestingEdge:!0})}),t.parent(i)||t.setEdge(e,d,{weight:0,minlen:s+((a=o[i])!=null?a:0)})}function AM(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(mu).forEach(n=>r(n,1)),e}function OM(t){return t.edges().reduce((e,r)=>e+t.edge(r).weight,0)}function NM(t){let e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,t.edges().forEach(r=>{t.edge(r).nestingEdge&&t.removeEdge(r)})}var CM=jM;function jM(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)sw(t,"borderLeft","_bl",r,s,o),sw(t,"borderRight","_br",r,s,o)}}t.children(mu).forEach(e)}function sw(t,e,r,n,s,o){let i={width:0,height:0,rank:o,borderType:e},a=s[e][o-1],c=wi(t,"border",i,r);s[e][o]=c,t.setParent(c,n),a&&t.setEdge(a,c,{weight:1})}function DM(t){var e;let r=(e=t.graph().rankdir)==null?void 0:e.toLowerCase();(r==="lr"||r==="rl")&&zw(t)}function LM(t){var e;let r=(e=t.graph().rankdir)==null?void 0:e.toLowerCase();(r==="bt"||r==="rl")&&ZM(t),(r==="lr"||r==="rl")&&(BM(t),zw(t))}function zw(t){t.nodes().forEach(e=>ow(t.node(e))),t.edges().forEach(e=>ow(t.edge(e)))}function ow(t){let e=t.width;t.width=t.height,t.height=e}function ZM(t){t.nodes().forEach(e=>t1(t.node(e))),t.edges().forEach(e=>{var r;let n=t.edge(e);(r=n.points)==null||r.forEach(t1),Object.hasOwn(n,"y")&&t1(n)})}function t1(t){t.y=-t.y}function BM(t){t.nodes().forEach(e=>r1(t.node(e))),t.edges().forEach(e=>{var r;let n=t.edge(e);(r=n.points)==null||r.forEach(r1),Object.hasOwn(n,"x")&&r1(n)})}function r1(t){let e=t.x;t.x=t.y,t.y=e}function VM(t){let e={},r=t.nodes().filter(a=>!t.children(a).length),n=r.map(a=>t.node(a).rank),s=Bn(Math.max,n),o=Ha(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 qM(t,e){let r=0;for(let n=1;n<e.length;++n)r+=FM(t,e[n-1],e[n]);return r}function FM(t,e,r){let n=JP(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,f)=>u.pos-f.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 UM(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 HM(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 GM(n)}function GM(t){let e=[];function r(s){return o=>{o.merged||(o.barycenter===void 0||s.barycenter===void 0||o.barycenter>=s.barycenter)&&WM(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=>fu(s,["vs","i","barycenter","weight"]))}function WM(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 YM(t,e){let r=XP(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(XM(!!e)),c=iw(o,s,c),n.forEach(l=>{c+=l.vs.length,o.push(l.vs),i+=l.barycenter*l.weight,a+=l.weight,c=iw(o,s,c)});let d={vs:o.flat(1)};return a&&(d.barycenter=i/a,d.weight=a),d}function iw(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 XM(t){return(e,r)=>e.barycenter<r.barycenter?-1:e.barycenter>r.barycenter?1:t?r.i-e.i:e.i-r.i}function Aw(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(f=>f!==i&&f!==a));let d=UM(t,s);d.forEach(f=>{if(t.children(f.v).length){let p=Aw(t,f.v,r,n);c[f.v]=p,Object.hasOwn(p,"barycenter")&&JM(f,p)}});let l=HM(d,r);KM(l,c);let u=YM(l,n);if(i&&a){u.vs=[i,u.vs,a].flat(1);let f=t.predecessors(i);if(f&&f.length){let p=t.node(f[0]),m=t.predecessors(a),y=t.node(m[0]);Object.hasOwn(u,"barycenter")||(u.barycenter=0,u.weight=0),u.barycenter=(u.barycenter*u.weight+p.order+y.order)/(u.weight+2),u.weight+=2}}return u}function KM(t,e){t.forEach(r=>{r.vs=r.vs.flatMap(n=>e[n]?e[n].vs:n)})}function JM(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 QM(t,e,r,n){n||(n=t.nodes());let s=eI(t),o=new un({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,f=o.edge(u,i),p=f!==void 0?f.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 eI(t){let e;for(;t.hasNode(e=a1("_root")););return e}function tI(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 Ow(t,e={}){if(typeof e.customOrder=="function"){e.customOrder(t,Ow);return}let r=xw(t),n=aw(t,Ha(1,r+1),"inEdges"),s=aw(t,Ha(r-1,-1,-1),"outEdges"),o=VM(t);if(cw(t,o),e.disableOptimalOrderHeuristic)return;let i=Number.POSITIVE_INFINITY,a,c=e.constraints||[];for(let d=0,l=0;l<4;++d,++l){rI(d%2?n:s,d%4>=2,c),o=Ga(t);let u=qM(t,o);u<i?(l=0,a=Object.assign({},o),i=u):u===i&&(a=structuredClone(o))}cw(t,a)}function aw(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 QM(t,o,r,n.get(o)||[])})}function rI(t,e,r){let n=new un;t.forEach(function(s){r.forEach(a=>n.setEdge(a.left,a.right));let o=s.graph().root,i=Aw(s,o,n,e);i.vs.forEach((a,c)=>s.node(a).order=c),tI(s,n,i.vs)})}function cw(t,e){Object.values(e).forEach(r=>r.forEach((n,s)=>t.node(n).order=s))}function nI(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 f=oI(t,l),p=f?t.node(f).order:c;(f||l===d)&&(o.slice(a,u+1).forEach(m=>{let y=t.predecessors(m);y&&y.forEach(k=>{let x=t.node(k),_=x.order;(_<i||p<_)&&!(x.dummy&&t.node(m).dummy)&&Nw(r,k,m)})}),a=u+1,i=p)}),o}return e.length&&e.reduce(n),r}function sI(t,e){let r={};function n(o,i,a,c,d){Ha(i,a).forEach(l=>{let u=o[l];if(u!==void 0&&t.node(u).dummy){let f=t.predecessors(u);f&&f.forEach(p=>{if(p===void 0)return;let m=t.node(p);m.dummy&&(m.order<c||m.order>d)&&Nw(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 f=t.predecessors(l);if(f&&f.length){let p=f[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 oI(t,e){if(t.node(e).dummy){let r=t.predecessors(e);if(r)return r.find(n=>t.node(n).dummy)}}function Nw(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 iI(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 aI(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,m)=>{let y=i[p],k=i[m];return(y!==void 0?y:0)-(k!==void 0?k:0)}),f=(u.length-1)/2;for(let p=Math.floor(f),m=Math.ceil(f);p<=m;++p){let y=u[p];if(y===void 0)continue;let k=i[y];if(k!==void 0&&o[d]===d&&c<k&&!iI(r,d,y)){let x=s[y];x!==void 0&&(o[y]=d,o[d]=s[d]=x,c=k)}}}})}),{root:s,align:o}}function cI(t,e,r,n,s=!1){let o={},i=lI(t,e,r,s),a=s?"borderLeft":"borderRight";function c(p,m){let y=i.nodes().slice(),k={},x=y.pop();for(;x;){if(k[x])p(x);else{k[x]=!0,y.push(x);for(let _ of m(x))y.push(_)}x=y.pop()}}function d(p){let m=i.inEdges(p);m?o[p]=m.reduce((y,k)=>{var x;let _=(x=o[k.v])!=null?x:0,g=i.edge(k);return Math.max(y,_+(g!==void 0?g:0))},0):o[p]=0}function l(p){let m=i.outEdges(p),y=Number.POSITIVE_INFINITY;m&&(y=m.reduce((x,_)=>{let g=o[_.w],E=i.edge(_);return Math.min(x,(g!==void 0?g:0)-(E!==void 0?E:0))},Number.POSITIVE_INFINITY));let k=t.node(p);y!==Number.POSITIVE_INFINITY&&k.borderType!==a&&(o[p]=Math.max(o[p]!==void 0?o[p]:0,y))}function u(p){return i.predecessors(p)||[]}function f(p){return i.successors(p)||[]}return c(d,u),c(l,f),Object.keys(n).forEach(p=>{var m;let y=r[p];y!==void 0&&(o[p]=(m=o[y])!=null?m:0)}),o}function lI(t,e,r,n){let s=new un,o=t.graph(),i=pI(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 f=s.edge(u,l);s.setEdge(u,l,Math.max(i(t,d,c),f||0))}}c=d}})}),s}function uI(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=mI(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 dI(t,e){let r=Object.values(e),n=Bn(Math.min,r),s=Bn(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-Bn(Math.min,d);i!=="l"&&(l=s-Bn(Math.max,d)),l&&(t[a]=pu(c,u=>u+l))})})}function hI(t,e=void 0){let r=t.ul;return r?pu(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 fI(t){let e=Ga(t),r=Object.assign(nI(t,e),sI(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=aI(t,s,r,l=>(i==="u"?t.predecessors(l):t.successors(l))||[]),d=cI(t,s,c.root,c.align,a==="r");a==="r"&&(d=pu(d,l=>-l)),n[i+a]=d})});let o=uI(t,n);return dI(n,o),hI(n,t.graph().align)}function pI(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 mI(t,e){return t.node(e).width}function gI(t){t=vw(t),_I(t),Object.entries(fI(t)).forEach(([e,r])=>t.node(e).x=r)}function _I(t){let e=Ga(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 bI(t,e={}){let r=e.debugTiming?Sw:kw;return r("layout",()=>{let n=r(" buildLayoutGraph",()=>RI(t));return r(" runLayout",()=>yI(n,r,e)),r(" updateInputGraph",()=>vI(t,n)),n})}function yI(t,e,r){e(" makeSpaceForEdgeLabels",()=>PI(t)),e(" removeSelfEdges",()=>DI(t)),e(" acyclic",()=>cM(t)),e(" nestingGraph.run",()=>zM(t)),e(" rank",()=>kM(vw(t))),e(" injectEdgeLabelProxies",()=>MI(t)),e(" removeEmptyRanks",()=>WP(t)),e(" nestingGraph.cleanup",()=>NM(t)),e(" normalizeRanks",()=>GP(t)),e(" assignRankMinMax",()=>II(t)),e(" removeEdgeLabelProxies",()=>zI(t)),e(" normalize.run",()=>dM(t)),e(" parentDummyChains",()=>RM(t)),e(" addBorderSegments",()=>CM(t)),e(" order",()=>Ow(t,r)),e(" insertSelfEdges",()=>LI(t)),e(" adjustCoordinateSystem",()=>DM(t)),e(" position",()=>gI(t)),e(" positionSelfEdges",()=>ZI(t)),e(" removeBorderNodes",()=>jI(t)),e(" normalize.undo",()=>fM(t)),e(" fixupEdgeLabelCoords",()=>NI(t)),e(" undoCoordinateSystem",()=>LM(t)),e(" translateGraph",()=>AI(t)),e(" assignNodeIntersects",()=>OI(t)),e(" reversePoints",()=>CI(t)),e(" acyclic.undo",()=>uM(t))}function vI(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 wI=["nodesep","edgesep","ranksep","marginx","marginy"],xI={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},SI=["acyclicer","ranker","rankdir","align","rankalign"],kI=["width","height","rank"],lw={width:0,height:0},$I=["minlen","weight","width","height","labeloffset"],EI={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},TI=["labelpos"];function RI(t){let e=new un({multigraph:!0,compound:!0}),r=s1(t.graph());return e.setGraph(Object.assign({},xI,n1(r,wI),fu(r,SI))),t.nodes().forEach(n=>{let s=s1(t.node(n)),o=n1(s,kI);Object.keys(lw).forEach(a=>{o[a]===void 0&&(o[a]=lw[a])}),e.setNode(n,o);let i=t.parent(n);i!==void 0&&e.setParent(n,i)}),t.edges().forEach(n=>{let s=s1(t.edge(n));e.setEdge(n,Object.assign({},EI,n1(s,$I),fu(s,TI)))}),e}function PI(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 MI(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};wi(t,"edge-proxy",s,"_ep")}})}function II(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 zI(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 AI(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,f=d.width,p=d.height;e=Math.min(e,l-f/2),r=Math.max(r,l+f/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 OI(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(Qv(n,o)),r.points.push(Qv(s,i))})}function NI(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 CI(t){t.edges().forEach(e=>{let r=t.edge(e);r.reversed&&r.points.reverse()})}function jI(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 DI(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 LI(t){Ga(t).forEach(e=>{let r=0;e.forEach((n,s)=>{let o=t.node(n);o.order=s+r,(o.selfEdges||[]).forEach(i=>{wi(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 ZI(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 n1(t,e){return pu(fu(t,e),Number)}function s1(t){let e={};return t&&Object.entries(t).forEach(([r,n])=>{typeof r=="string"&&(r=r.toLowerCase()),e[r]=n}),e}function BI(t){let e=Ga(t),r=new un({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 VI={graphlib:dw,version:QP,layout:bI,debug:BI,util:{time:Sw,notime:kw}},d1=VI;var qI={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 p1(t){return t?qI[t.trim().toLowerCase()]:void 0}var gu={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"}},Cw=["sky","green","amber","pink","purple","teal","peach","indigo","mint","rose"];function Lw(t){return gu[Cw[t%Cw.length]]}var FI=[["([","])","stadium"],["[[","]]","subroutine"],["[(",")]","cylinder"],["((","))","circle"],["{{","}}","hexagon"],["[","]","rect"],["(",")","round"],["{","}","diamond"]];function h1(t){let e=t.trim();return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function f1(t){return t.replace(/\\n/g,`
|
|
131
51
|
`).replace(/\\t/g," ").replace(/<br\s*\/?>/gi,`
|
|
132
52
|
`).replace(/<\/?(?:span|small|sub|sup|mark|font)\b[^>]*>/gi,"").replace(/[ \t]+\n/g,`
|
|
133
|
-
`).trim()}function
|
|
53
|
+
`).trim()}function UI(t){return t.replace(/<\/?(?:b|strong|i|em|u|code)\b[^>]*>/gi,"").replace(/\t/g," ")}function jw(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 FI)if(n.startsWith(a)){let l=n.indexOf(c,a.length);if(l>=0){let u=f1(h1(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 Dw(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 HI=/^\s*(-\.->|-->|---|-\.-|==>|===|--o|--x)\s*/;function Zw(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(gu)),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 g=u[2].toUpperCase();if(r=g==="TD"?"TB":g,l=l.slice(u[0].length).trim(),!l)continue}let f=l.match(/^classDef\s+([A-Za-z0-9_-]+)\s+(.+)$/i);if(f){i.set(f[1],{...i.get(f[1]),...Dw(f[2])});continue}let p=l.match(/^class\s+([A-Za-z0-9_.,\s-]+?)\s+([A-Za-z0-9_-]+)\s*$/i);if(p){for(let g of p[1].split(",").map(E=>E.trim()).filter(Boolean))a.set(g,p[2]);continue}let m=l.match(/^style\s+([A-Za-z0-9_.-]+)\s+(.+)$/i);if(m){c.set(m[1],{...c.get(m[1]),...Dw(m[2])});continue}let y=l.match(/^([A-Za-z0-9_.-]+)@\{(.+)\}\s*$/);if(y){let g=y[2].match(/\bshape\s*:\s*["']?([A-Za-z0-9_-]+)/i),E=p1(g?.[1]);E&&(d.set(y[1],E),o({id:y[1],label:y[1],shape:E}));continue}if(/^(subgraph|end|linkStyle|click)\b/i.test(l))continue;let k=l,x=jw(k);if(!x)continue;o(x.node),x.className&&a.set(x.node.id,x.className);let _=x.node.id;for(k=x.rest.trim();k;){let g,E=k.match(/^(--|-\.|==)\s*([^->|]+?)\s*(--?>|\.->|==>|---)/);E&&(g=f1(h1(E[2])),k="-"+k.slice(E[1].length+E[2].length).replace(/^\s+/,""));let h=k.match(HI);if(!h)break;let $=h[1];k=k.slice(h[0].length);let z=k.match(/^\|([^|]*)\|\s*/);z&&(g=f1(h1(z[1])),k=k.slice(z[0].length));let L=jw(k.trim());if(!L)break;o(L.node),L.className&&a.set(L.node.id,L.className),s.push({from:_,to:L.node.id,label:g,arrow:!/^---$|^-\.-$|^===$/.test($),dashed:$.includes(".")}),_=L.node.id,k=L.rest.trim()}}for(let l of n.values()){let u=a.get(l.id),f=u?i.get(u):void 0,p=c.get(l.id),m={...f,...p};m.fill&&(l.fill=m.fill),m.stroke&&(l.stroke=m.stroke),m.color&&(l.color=m.color);let y=d.get(l.id);y&&(l.shape=y)}return{direction:r,nodes:[...n.values()],edges:s}}function GI(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=UI(t.label),r=Math.max(...e.split(`
|
|
134
54
|
`).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 Bw(t){let e=new d1.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=WM(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}`)),d1.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 f=(e.edge(d.from,d.to,`e${l}`)?.points??[]).map(p=>[p.x,p.y]);return{...d,points:f}}),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 m1={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 YM(t){let e=t.trim();return!e||e.length>4e3||!/^[MmLlHhVvCcSsQqTtAaZz0-9.,\-+eE\s]+$/.test(e)||!/^[Mm]/.test(e)?null:e}function Vw(t){if(!t)return null;let e=t.trim().toLowerCase();return m1[e]?m1[e]:YM(t)}var Mq=Object.keys(m1);var Tn="board.wb",XM=285,g1=140,KM=320,JM=280,QM=400,eO={rect:"rectangle",round:"roundRectangle",stadium:"roundRectangle",circle:"ellipse",diamond:"diamond",hexagon:"hexagon",subroutine:"rectangle",cylinder:"cylinder",stack:"stack",cloud:"cloud"},qw=Object.fromEntries(Object.entries(gu).map(([t,e])=>[e.fill,t]));function tO(t){return Math.max(1,t.trim().split(/\s+/).length)}function rO(t){return Math.max(1500,tO(t)*XM)}function Ya(t){return{children:[{text:t}]}}function _1(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 nO(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:Ya(s?n.label:""),revealAt:r}:{id:e,type:"geometry",shape:eO[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&&qw[n.fill]?{tone:qw[n.fill]}:{},...n.icon?{icon:n.icon}:{},text:Ya(n.label),revealAt:r}}function sO(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,f=n[0]-c*l,p=n[1]-d*l,m=-d,y=c;return{id:t,type:"arrow-head",points:[n,[f+m*u,p+y*u],[f-m*u,p-y*u]]}}function Fw(t,e={}){let r=Zw(t.mermaid),n=t.icons??{},s=e.images??{},o=t.shapes??{};r.nodes.forEach((g,E)=>{if(s[g.id]){g.image=s[g.id];return}let h=p1(o[g.id]);h&&(g.shape=h);let $=Vw(n[g.id]);if($&&(g.icon=$),t.theme==="pastel"&&!g.fill){let O=Lw(E);g.fill=O.fill,g.stroke=O.stroke,g.color=O.color}});let i=Bw(r),a=new Map(i.nodes.map(g=>[g.id,g])),c=new Set(i.nodes.map(g=>g.id)),d=i.edges.map((g,E)=>{let h=`${g.from}__${g.to}__${E}`,$=g.points.length>=2,O=[g.from,g.to],L={id:h,type:"arrow-line",points:$?g.points:[],strokeWidth:2,dashed:g.dashed,target:{marker:"none"},ends:O},q=g.arrow&&$?{...sO(h+"__h",g.points),ends:O}:null,C=null;if(g.label&&g.points.length){let Z=g.points[Math.floor(g.points.length/2)];C={id:h+"__l",type:"edge-label",points:[[Z[0],Z[1]]],text:Ya(g.label),ends:O}}return{from:g.from,to:g.to,lineEl:L,headEl:q,labelEl:C}}),l=[],u=[],f=1;l.push({t:f,type:"editor.switch",path:Tn});let p=i.bounds,m={id:"__frame",type:"frame",points:[[p.minX-24,p.minY-24],[p.maxX+24,p.maxY+24]]};l.push({t:f,type:"wb.snapshot",path:Tn,scene:[m]});let y=new Set,k=new Set,x=g=>g==null?[]:Array.isArray(g)?g:[g];t.steps.forEach((g,E)=>{let h=g.card,$=g.chapter?KM:0,O=f+$,L=g.holdMs??e.sayDurationsMs?.[E]??Math.max(g.say?rO(g.say):0,1400);if(g.chapter&&l.push({t:f,type:"marker",label:g.chapter}),h==="intro"){let z=(p.minX+p.maxX)/2,b=(p.minY+p.maxY)/2,j=Math.max(280,t.title.length*17),A=92,G={id:"__title",type:"geometry",shape:"text",fontSize:30,points:[[z-j/2,b-A/2],[z+j/2,b+A/2]],text:Ya(t.title)};l.push({t:Math.round(O),type:"wb.delta",path:Tn,changed:[G],deleted:[]}),l.push({t:Math.round(O),type:"wb.selection",path:Tn,ids:["__title"]});let F=O+L;l.push({t:Math.round(F),type:"wb.delta",path:Tn,changed:[],deleted:["__title"]}),l.push({t:Math.round(F),type:"wb.selection",path:Tn,ids:[]}),g.say&&u.push({t:O,dur:L,text:g.say,words:_1(g.say,O,L)}),f=F+g1;return}if(h==="outro"){l.push({t:Math.round(O),type:"wb.selection",path:Tn,ids:["__recap"]}),g.say&&u.push({t:O,dur:L,text:g.say,words:_1(g.say,O,L)}),f=O+L+g1;return}let q=O,C=(z,...b)=>{l.push({t:Math.round(z),type:"wb.delta",path:Tn,changed:b,deleted:[]}),q=Math.max(q,z)},Z=x(g.show).filter(z=>c.has(z)&&!y.has(z));for(let z of Z)C(O,nO(i,z,O)),y.add(z);for(let z of d){if(k.has(z.lineEl.id)||!y.has(z.from)||!y.has(z.to))continue;k.add(z.lineEl.id);let b=O+JM;C(b,z.lineEl);let j=[z.headEl,z.labelEl].filter(Boolean);j.length&&C(b+QM,...j)}let he=(x(g.point).length?x(g.point):x(g.show)).filter(z=>c.has(z));l.push({t:Math.round(O),type:"wb.selection",path:Tn,ids:he}),g.say&&u.push({t:O,dur:L,text:g.say,words:_1(g.say,O,L)}),f=Math.max(O+L,q+90)+g1}),l.sort((g,E)=>g.t-E.t);let _=[{t:0,vfs:{[Tn]:""},activeFile:Tn,terminalState:""}];return{manifest:{version:2,title:t.title,createdAt:e.createdAt??new Date().toISOString(),durationMs:Math.max(f,1500),appearance:t.appearance??"system"},events:l,snapshots:_,captions:u.length?u:void 0}}var Hw='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 oO from"sharp";var Uw=520,iO=70,aO=12*1024*1024,cO=15e3;async function b1(t){if(!/^https?:\/\//i.test(t))return null;try{let e=await fetch(t,{signal:AbortSignal.timeout(cO),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>aO)return null;let s=await oO(n,{failOn:"none",animated:!1}).rotate().resize({width:Uw,height:Uw,fit:"inside",withoutEnlargement:!0}).webp({quality:iO}).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 Gw(t){let e={};return await Promise.all(Object.entries(t).map(async([r,n])=>{let s=await b1(n);s&&(e[r]=s)})),e}var lO={id:"whiteboard",tool:{name:"create_whiteboard_walkthrough",title:"Create a narrated whiteboard diagram",description:Hw},promptLine:"\u2022 WHITEBOARD \u2014 a diagram drawn on a board (concepts, architecture, data flow) \u2192 create_whiteboard_walkthrough",schema:Jm,makeBeat:(t,e)=>({say:t,card:e}),forceOutro:!0,async prepare(t){let e=t.images&&Object.keys(t.images).length?await Gw(t.images):{};return Object.keys(e).length?{images:e}:{}},compile:(t,e)=>Fw(t,e)},Ww=lO;var uO="TTS voice to narrate with. Defaults to cedar (warm, natural). Options: "+Ur.map(t=>`${t} (${Ss[t]})`).join(", ")+".",dO=W.object({say:W.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:W.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:W.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:W.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:W.array(W.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:W.array(W.string()).min(3).optional().describe('Highlight an area by connecting these place names into a polygon (3+ corners), e.g. ["Lisbon","Madrid","Barcelona"].'),chapter:W.string().optional().describe("If set, starts a named chapter at this beat (timeline marker)."),holdMs:W.number().optional().describe("Beat duration in ms. Defaults to a duration derived from the narration.")}),y1={title:W.string().describe("Title of the map walkthrough (header + filename)."),outputPath:W.string().optional().describe("Optional path to also write the .html to (same mapping as create_walkthrough)."),voiceName:W.enum(Ur).optional().describe(uO),voiceTone:W.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:W.string().optional().describe("Opening line spoken before the tour. Defaults to a title-based welcome; set to '' to skip."),outro:W.string().optional().describe("Closing wrap-up line spoken at the end (always added). Customize the wording here."),tiles:W.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:W.array(dO).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.")},Uq=W.object(y1);var hO=t=>Math.max(1,t.trim().split(/\s+/).length),fO=t=>Math.max(1600,hO(t)*350);function pO(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 v1(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 mO(){return 13}function Yw(t,e={}){let r=e.geo??{},n=e.routes??{},s=y=>y&&r[y]?r[y]:null,o=Object.values(r).map(y=>[y.lat,y.lng]),i=v1(o),a=o.length?{lat:o.reduce((y,k)=>y+k[0],0)/o.length,lng:o.reduce((y,k)=>y+k[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=[],f=1;t.steps.forEach((y,k)=>{let x=y.chapter?450:0,_=f+x,g=y.holdMs??e.sayDurationsMs?.[k]??Math.max(y.say?fO(y.say):0,1600);y.chapter&&u.push({t:f,type:"marker",label:y.chapter});let E={t:Math.round(_)};if(y.card==="intro"||y.card==="outro")E.camera=c;else{let h=[],$=s(y.marker);if($){let q={lat:$.lat,lng:$.lng,label:y.marker};h.push(q)}h.length&&(E.markers=h);let O=n[k];if(O&&O.length>=2){E.route=O;let q=v1(O);q&&(E.camera={lat:(q[0][0]+q[1][0])/2,lng:(q[0][1]+q[1][1])/2,zoom:6,bounds:q})}if(y.region){let q=y.region.map(s).filter(Boolean).map(C=>[C.lat,C.lng]);if(q.length>=3){E.region=q;let C=v1(q);C&&(E.camera={lat:(C[0][0]+C[1][0])/2,lng:(C[0][1]+C[1][1])/2,zoom:6,bounds:C})}}let L=s(y.goTo);L?E.camera={lat:L.lat,lng:L.lng,zoom:y.zoom??7}:$&&!E.route&&!E.region?E.camera={lat:$.lat,lng:$.lng,zoom:y.zoom??mO()}:y.zoom&&E.camera&&(E.camera.zoom=y.zoom)}d.push(E),y.say&&l.push({t:_,dur:g,text:y.say,words:pO(y.say,_,g)}),f=_+g+250});let p={tiles:t.tiles??"streets",beats:d},m=[{t:0,vfs:{},activeFile:null,terminalState:""}];return{manifest:{version:2,title:t.title,createdAt:e.createdAt??new Date().toISOString(),durationMs:Math.max(f,1500),mode:"map"},events:u,snapshots:m,captions:l.length?l:void 0,map:p}}var Xw=`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.
|
|
55
|
+
`).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 Bw(t){let e=new d1.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=GI(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}`)),d1.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 f=(e.edge(d.from,d.to,`e${l}`)?.points??[]).map(p=>[p.x,p.y]);return{...d,points:f}}),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 m1={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 WI(t){let e=t.trim();return!e||e.length>4e3||!/^[MmLlHhVvCcSsQqTtAaZz0-9.,\-+eE\s]+$/.test(e)||!/^[Mm]/.test(e)?null:e}function Vw(t){if(!t)return null;let e=t.trim().toLowerCase();return m1[e]?m1[e]:WI(t)}var Iq=Object.keys(m1);var Tn="board.wb",YI=285,g1=140,XI=320,KI=280,JI=400,QI={rect:"rectangle",round:"roundRectangle",stadium:"roundRectangle",circle:"ellipse",diamond:"diamond",hexagon:"hexagon",subroutine:"rectangle",cylinder:"cylinder",stack:"stack",cloud:"cloud"},qw=Object.fromEntries(Object.entries(gu).map(([t,e])=>[e.fill,t]));function ez(t){return Math.max(1,t.trim().split(/\s+/).length)}function tz(t){return Math.max(1500,ez(t)*YI)}function Wa(t){return{children:[{text:t}]}}function _1(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 rz(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:Wa(s?n.label:""),revealAt:r}:{id:e,type:"geometry",shape:QI[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&&qw[n.fill]?{tone:qw[n.fill]}:{},...n.icon?{icon:n.icon}:{},text:Wa(n.label),revealAt:r}}function nz(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,f=n[0]-c*l,p=n[1]-d*l,m=-d,y=c;return{id:t,type:"arrow-head",points:[n,[f+m*u,p+y*u],[f-m*u,p-y*u]]}}function Fw(t,e={}){let r=Zw(t.mermaid),n=t.icons??{},s=e.images??{},o=t.shapes??{};r.nodes.forEach((g,E)=>{if(s[g.id]){g.image=s[g.id];return}let h=p1(o[g.id]);h&&(g.shape=h);let $=Vw(n[g.id]);if($&&(g.icon=$),t.theme==="pastel"&&!g.fill){let z=Lw(E);g.fill=z.fill,g.stroke=z.stroke,g.color=z.color}});let i=Bw(r),a=new Map(i.nodes.map(g=>[g.id,g])),c=new Set(i.nodes.map(g=>g.id)),d=i.edges.map((g,E)=>{let h=`${g.from}__${g.to}__${E}`,$=g.points.length>=2,z=[g.from,g.to],L={id:h,type:"arrow-line",points:$?g.points:[],strokeWidth:2,dashed:g.dashed,target:{marker:"none"},ends:z},q=g.arrow&&$?{...nz(h+"__h",g.points),ends:z}:null,C=null;if(g.label&&g.points.length){let Z=g.points[Math.floor(g.points.length/2)];C={id:h+"__l",type:"edge-label",points:[[Z[0],Z[1]]],text:Wa(g.label),ends:z}}return{from:g.from,to:g.to,lineEl:L,headEl:q,labelEl:C}}),l=[],u=[],f=1;l.push({t:f,type:"editor.switch",path:Tn});let p=i.bounds,m={id:"__frame",type:"frame",points:[[p.minX-24,p.minY-24],[p.maxX+24,p.maxY+24]]};l.push({t:f,type:"wb.snapshot",path:Tn,scene:[m]});let y=new Set,k=new Set,x=g=>g==null?[]:Array.isArray(g)?g:[g];t.steps.forEach((g,E)=>{let h=g.card,$=g.chapter?XI:0,z=f+$,L=g.holdMs??e.sayDurationsMs?.[E]??Math.max(g.say?tz(g.say):0,1400);if(g.chapter&&l.push({t:f,type:"marker",label:g.chapter}),h==="intro"){let O=(p.minX+p.maxX)/2,b=(p.minY+p.maxY)/2,j=Math.max(280,t.title.length*17),A=92,G={id:"__title",type:"geometry",shape:"text",fontSize:30,points:[[O-j/2,b-A/2],[O+j/2,b+A/2]],text:Wa(t.title)};l.push({t:Math.round(z),type:"wb.delta",path:Tn,changed:[G],deleted:[]}),l.push({t:Math.round(z),type:"wb.selection",path:Tn,ids:["__title"]});let F=z+L;l.push({t:Math.round(F),type:"wb.delta",path:Tn,changed:[],deleted:["__title"]}),l.push({t:Math.round(F),type:"wb.selection",path:Tn,ids:[]}),g.say&&u.push({t:z,dur:L,text:g.say,words:_1(g.say,z,L)}),f=F+g1;return}if(h==="outro"){l.push({t:Math.round(z),type:"wb.selection",path:Tn,ids:["__recap"]}),g.say&&u.push({t:z,dur:L,text:g.say,words:_1(g.say,z,L)}),f=z+L+g1;return}let q=z,C=(O,...b)=>{l.push({t:Math.round(O),type:"wb.delta",path:Tn,changed:b,deleted:[]}),q=Math.max(q,O)},Z=x(g.show).filter(O=>c.has(O)&&!y.has(O));for(let O of Z)C(z,rz(i,O,z)),y.add(O);for(let O of d){if(k.has(O.lineEl.id)||!y.has(O.from)||!y.has(O.to))continue;k.add(O.lineEl.id);let b=z+KI;C(b,O.lineEl);let j=[O.headEl,O.labelEl].filter(Boolean);j.length&&C(b+JI,...j)}let he=(x(g.point).length?x(g.point):x(g.show)).filter(O=>c.has(O));l.push({t:Math.round(z),type:"wb.selection",path:Tn,ids:he}),g.say&&u.push({t:z,dur:L,text:g.say,words:_1(g.say,z,L)}),f=Math.max(z+L,q+90)+g1}),l.sort((g,E)=>g.t-E.t);let _=[{t:0,vfs:{[Tn]:""},activeFile:Tn,terminalState:""}];return{manifest:{version:2,title:t.title,createdAt:e.createdAt??new Date().toISOString(),durationMs:Math.max(f,1500),appearance:t.appearance??"system"},events:l,snapshots:_,captions:u.length?u:void 0}}var Uw='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 sz from"sharp";var Hw=520,oz=70,iz=12*1024*1024,az=15e3;async function b1(t){if(!/^https?:\/\//i.test(t))return null;try{let e=await fetch(t,{signal:AbortSignal.timeout(az),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>iz)return null;let s=await sz(n,{failOn:"none",animated:!1}).rotate().resize({width:Hw,height:Hw,fit:"inside",withoutEnlargement:!0}).webp({quality:oz}).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 Gw(t){let e={};return await Promise.all(Object.entries(t).map(async([r,n])=>{let s=await b1(n);s&&(e[r]=s)})),e}var cz={id:"whiteboard",tool:{name:"create_whiteboard_walkthrough",title:"Create a narrated whiteboard diagram",description:Uw},promptLine:"\u2022 WHITEBOARD \u2014 a diagram drawn on a board (concepts, architecture, data flow) \u2192 create_whiteboard_walkthrough",schema:Jm,makeBeat:(t,e)=>({say:t,card:e}),forceOutro:!0,async prepare(t){let e=t.images&&Object.keys(t.images).length?await Gw(t.images):{};return Object.keys(e).length?{images:e}:{}},compile:(t,e)=>Fw(t,e)},Ww=cz;var lz="TTS voice to narrate with. Defaults to cedar (warm, natural). Options: "+Hr.map(t=>`${t} (${Jl[t]})`).join(", ")+".",uz=W.object({say:W.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:W.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:W.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:W.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:W.array(W.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:W.array(W.string()).min(3).optional().describe('Highlight an area by connecting these place names into a polygon (3+ corners), e.g. ["Lisbon","Madrid","Barcelona"].'),chapter:W.string().optional().describe("If set, starts a named chapter at this beat (timeline marker)."),holdMs:W.number().optional().describe("Beat duration in ms. Defaults to a duration derived from the narration.")}),y1={title:W.string().describe("Title of the map walkthrough (header + filename)."),outputPath:W.string().optional().describe("Optional path to also write the .html to (same mapping as create_walkthrough)."),voiceName:W.enum(Hr).optional().describe(lz),voiceTone:W.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:W.string().optional().describe("Opening line spoken before the tour. Defaults to a title-based welcome; set to '' to skip."),outro:W.string().optional().describe("Closing wrap-up line spoken at the end (always added). Customize the wording here."),tiles:W.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:W.array(uz).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.")},Hq=W.object(y1);var dz=t=>Math.max(1,t.trim().split(/\s+/).length),hz=t=>Math.max(1600,dz(t)*350);function fz(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 v1(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 pz(){return 13}function Yw(t,e={}){let r=e.geo??{},n=e.routes??{},s=y=>y&&r[y]?r[y]:null,o=Object.values(r).map(y=>[y.lat,y.lng]),i=v1(o),a=o.length?{lat:o.reduce((y,k)=>y+k[0],0)/o.length,lng:o.reduce((y,k)=>y+k[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=[],f=1;t.steps.forEach((y,k)=>{let x=y.chapter?450:0,_=f+x,g=y.holdMs??e.sayDurationsMs?.[k]??Math.max(y.say?hz(y.say):0,1600);y.chapter&&u.push({t:f,type:"marker",label:y.chapter});let E={t:Math.round(_)};if(y.card==="intro"||y.card==="outro")E.camera=c;else{let h=[],$=s(y.marker);if($){let q={lat:$.lat,lng:$.lng,label:y.marker};h.push(q)}h.length&&(E.markers=h);let z=n[k];if(z&&z.length>=2){E.route=z;let q=v1(z);q&&(E.camera={lat:(q[0][0]+q[1][0])/2,lng:(q[0][1]+q[1][1])/2,zoom:6,bounds:q})}if(y.region){let q=y.region.map(s).filter(Boolean).map(C=>[C.lat,C.lng]);if(q.length>=3){E.region=q;let C=v1(q);C&&(E.camera={lat:(C[0][0]+C[1][0])/2,lng:(C[0][1]+C[1][1])/2,zoom:6,bounds:C})}}let L=s(y.goTo);L?E.camera={lat:L.lat,lng:L.lng,zoom:y.zoom??7}:$&&!E.route&&!E.region?E.camera={lat:$.lat,lng:$.lng,zoom:y.zoom??pz()}:y.zoom&&E.camera&&(E.camera.zoom=y.zoom)}d.push(E),y.say&&l.push({t:_,dur:g,text:y.say,words:fz(y.say,_,g)}),f=_+g+250});let p={tiles:t.tiles??"streets",beats:d},m=[{t:0,vfs:{},activeFile:null,terminalState:""}];return{manifest:{version:2,title:t.title,createdAt:e.createdAt??new Date().toISOString(),durationMs:Math.max(f,1500),mode:"map"},events:u,snapshots:m,captions:l.length?l:void 0,map:p}}var Xw=`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
56
|
|
|
137
57
|
You write PLACE NAMES (your strength) \u2014 the server geocodes them to coordinates and routes roads automatically. Never write lat/long.
|
|
138
58
|
|
|
@@ -155,7 +75,7 @@ Worked shape:
|
|
|
155
75
|
- { say:"then on to the coast at Marseille.", marker:"Marseille, France" }
|
|
156
76
|
- { say:"This is the whole drive.", route:["Paris, France","Lyon, France","Marseille, France"] }
|
|
157
77
|
|
|
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 gO="https://nominatim.openstreetmap.org/search",_O="https://router.project-osrm.org/route/v1/driving",Kw="FlowCast/0.1 (map walkthrough generator)";var w1=new Map;async function bO(t){let e=t.trim().toLowerCase();if(!e)return null;if(w1.has(e))return w1.get(e);let r=null;try{let n=`${gO}?q=${encodeURIComponent(t)}&format=json&limit=1`,s=await fetch(n,{headers:{"user-agent":Kw,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 w1.set(e,r),r}async function Jw(t){let e={};return await Promise.all([...new Set(t)].map(async r=>{let n=await bO(r);n&&(e[r]=n)})),e}async function Qw(t){if(t.length<2)return null;let e=t.map(r=>`${r.lng},${r.lat}`).join(";");try{let r=`${_O}/${e}?overview=full&geometries=geojson`,n=await fetch(r,{headers:{"user-agent":Kw},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 yO={id:"map",tool:{name:"create_map_walkthrough",title:"Map walkthrough",description:Xw},promptLine:"\u2022 MAP \u2014 a narrated tour over a real map (travel, geography, history, logistics) \u2192 create_map_walkthrough",schema:y1,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 Jw([...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 Qw(i);a&&(n[o]=a)}})),{geo:r,routes:n}},compile:(t,e)=>Yw(t,e)},e3=yO;var vO="TTS voice to narrate with. Defaults to cedar (warm, natural). Options: "+Ur.map(t=>`${t} (${Ss[t]})`).join(", ")+".",t3=["box","sphere","cylinder","cone","plane","torus","icosahedron","pyramid","wedge","disc","ring","tube","dome"],r3="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).",wO=W.object({shape:W.enum(t3).default("box").describe("Primitive for this piece. "+r3),at:W.tuple([W.number(),W.number(),W.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:W.union([W.number(),W.tuple([W.number(),W.number(),W.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:W.string().optional().describe("CSS color for this piece. Defaults to the object color."),rotation:W.tuple([W.number(),W.number(),W.number()]).optional().describe("Optional local rotation [x,y,z] in RADIANS.")}),xO=W.object({id:W.string().describe("Unique id the beats reference."),shape:W.enum(t3).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. "+r3),parts:W.array(wO).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:W.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:W.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:W.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:W.string().optional().describe("Floating label shown next to the object (with a leader line pointing at it)."),value:W.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:W.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:W.string().optional().describe('CSS color (e.g. "#7cc6ff" or "tomato"). Defaults to a pleasant auto color.'),size:W.number().optional().describe("Relative size (default 1). 2 = twice as big."),scale:W.union([W.number(),W.tuple([W.number(),W.number(),W.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:W.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:W.array(W.tuple([W.number(),W.number(),W.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:W.boolean().optional().describe("Place a subtle round platform under the object so it feels seated on the floor (nice for showcased items)."),reveal:W.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:W.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:W.tuple([W.number(),W.number(),W.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.")}),SO=W.object({say:W.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:W.union([W.string(),W.array(W.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:W.string().optional().describe("Object id to move the camera to and frame this beat (like walking up to it)."),overview:W.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:W.boolean().optional().describe("Slowly orbit around the focused object during this beat (a turntable look)."),showcase:W.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:W.array(W.string()).optional().describe("Object/chart ids to SPOTLIGHT this beat while everything else recedes \u2014 great for comparing 2\u20133 items."),filter:W.array(W.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:W.object({target:W.string(),text:W.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:W.object({target:W.string(),values:W.array(W.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:W.string().optional().describe("If set, starts a named chapter at this beat (timeline marker)."),holdMs:W.number().optional().describe("Beat duration in ms. Defaults to a duration derived from the narration.")}),kO=W.object({label:W.string().optional().describe("Category label (axis tick / segment label)."),value:W.number().describe("The numeric value."),color:W.string().optional().describe("Optional per-datum color (else the chart accent).")}),$O=W.object({id:W.string().describe("Unique id beats reference via show/focus (a chart behaves like an object)."),type:W.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:W.array(kO).min(1).describe("The data points. For a ring use a single datum (value vs max = the %)."),at:W.tuple([W.number(),W.number(),W.number()]).optional().describe("Position [x,y,z]; omit to auto-place. The chart sits on the floor."),width:W.number().optional().describe("Horizontal extent (default ~6)."),height:W.number().optional().describe("Vertical extent \u2014 the value mapped to `max` (default ~4)."),max:W.number().optional().describe("Value mapped to full height/percent (defaults to the largest data value)."),unit:W.string().optional().describe('Unit appended to value labels (e.g. "%", "M", "ms").'),color:W.string().optional().describe("Accent color for series without their own color."),label:W.string().optional().describe("Chart title shown above it.")}),x1={title:W.string().describe("Title of the 3D walkthrough (header + filename)."),pace:W.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:W.string().optional().describe("Optional path to also write the .html to (same mapping as create_walkthrough)."),voiceName:W.enum(Ur).optional().describe(vO),voiceTone:W.string().optional().describe("How the narrator should SOUND, matched to the topic. A natural human delivery is always layered on top."),intro:W.string().optional().describe("Opening line spoken before the tour. Defaults to a title-based welcome; set to '' to skip."),outro:W.string().optional().describe("Closing wrap-up line spoken at the end (always added). Customize the wording here."),background:W.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:W.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:W.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:W.array(W.object({from:W.string(),to:W.string(),label:W.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:W.array($O).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:W.array(xO).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:W.array(SO).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.")},sF=W.object(x1);import{readFile as EO,stat as TO}from"node:fs/promises";var RO=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 S1(t){return!!t&&RO.has(t.trim().toLowerCase())}var IO=16*1024*1024,PO=2e4,s3=t=>/\.(glb|gltf)(\?|$)/i.test(t);function n3(t,e){return!t.length||t.length>IO?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 MO(t){let e=t.trim();try{if(/^https?:\/\//i.test(e)){let s=await fetch(e,{signal:AbortSignal.timeout(PO),redirect:"follow"});return s.ok?n3(Buffer.from(await s.arrayBuffer()),e):null}let r=e.startsWith("file://")?new URL(e).pathname:e;if(!s3(r))return null;let n=await TO(r).catch(()=>null);return!n||!n.isFile()?null:n3(await EO(r),r)}catch{return null}}function OO(t){return!t||S1(t)?!1:/^https?:\/\//i.test(t)||t.startsWith("file://")||s3(t)}async function o3(t){let e={};return await Promise.all(t.map(async r=>{if(OO(r.model)){let n=await MO(r.model);n&&(e[r.id]=n)}})),e}var AO=285,zO={calm:{gap:250,chapter:450},normal:{gap:140,chapter:320},snappy:{gap:90,chapter:240}},_u=["#7cc6ff","#9be08b","#ffd166","#ff8c69","#c89bff","#5ad1c4","#ff9ecb","#a0d8ef"],NO=t=>Math.max(1,t.trim().split(/\s+/).length),CO=t=>Math.max(1600,NO(t)*AO);function jO(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 Xa=(t,e)=>[t[0]+e[0],t[1]+e[1],t[2]+e[2]],i3=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),DO=t=>t==null?[]:Array.isArray(t)?t:[t];function LO(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 k1=(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 ZO(t,e){let r=u=>u.model?S1(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,f)=>u.parts?.length?u.parts.map(p=>({shape:p.shape??"box",pos:p.at??[0,0,0],size:s(p.size),color:p.color||f,...p.rotation?{rotation:p.rotation}:{}})):void 0,i=(u,f,p,m={})=>{let y=u.color||_u[f%_u.length],k=o(u,y);return{id:u.id,shape:u.shape??"box",pos:p,size:u.size??1,scale:n(u.scale),color:y,...u.label?{label:u.label}:{},...u.value!=null?{value:u.value}:{},...u.valueSuffix?{valueSuffix:u.valueSuffix}:{},...k?{parts:k}:{},...u.svg&&!k?{svg:u.svg}:{},...!k&&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",...m}},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,f)=>{if(f===0)return i(u,f,[0,0,0],{glow:!0,motion:u.motion??"spin",shape:u.shape??"sphere"});let p=5+(f-1)*3.2;return i(u,f,k1(f-1,Math.max(3,a.length-1),p),{shape:u.shape??"sphere",motion:"orbit",orbit:{radius:p,speed:.18/Math.sqrt(f),phase:f/a.length*Math.PI*2}})});else if(t.template==="molecule"){if(l=a.map((u,f)=>f===0?i(u,f,[0,0,0],{shape:u.shape??"sphere"}):i(u,f,k1(f-1,a.length-1,2.6,(f%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,f)=>i(u,f,k1(f,a.length,Math.max(4,a.length*.9),(f%2?1:-1)*.8))):t.template==="stack"?l=a.map((u,f)=>i(u,f,[0,(a.length-1)/2-f,0],{shape:u.shape??"box",motion:u.motion??"none",size:u.size??1.6})):l=a.map((u,f)=>i(u,f,u.at?u.at:LO(f,a.length)));return{objects:l,connections:c,starfield:d}}function a3(t,e={}){let{objects:r,connections:n,starfield:s}=ZO(t,e.models??{}),o=new Map(r.map(A=>[A.id,A]));for(let A of r){let G=e.images?.[A.id];G&&(A.image=G.href,A.imageAspect=G.h>0?G.w/G.h:1)}let i=t.charts??[],a=4.5,c=i.map(A=>A.width??6),l=-(c.reduce((A,G)=>A+G,0)+a*Math.max(0,i.length-1))/2,u=r.map(A=>A.pos[2]),f=r.length?Math.min(0,...u)-9:0,p=i.map((A,G)=>{let F=c[G],Q=A.height??4,B=l+F/2;l+=F+a;let T=A.at?A.at:[B,0,f];return{id:A.id,type:A.type,pos:T,width:F,height:Q,data:A.data.map(v=>({...v.label?{label:v.label}:{},value:v.value,...v.color?{color:v.color}:{}})),max:A.max??Math.max(...A.data.map(v=>v.value),1),...A.unit?{unit:A.unit}:{},color:A.color||_u[(r.length+G)%_u.length],...A.label?{label:A.label}:{}}}),m=new Map(p.map(A=>[A.id,A])),y=A=>o.has(A)||m.has(A),k=[...r.map(A=>A.pos),...p.map(A=>A.pos)],x=k.length,_=x?[k.reduce((A,G)=>A+G[0],0)/x,k.reduce((A,G)=>A+G[1],0)/x,k.reduce((A,G)=>A+G[2],0)/x]:[0,0,0],g=Math.max(5,...r.map(A=>i3(A.pos,_)+A.size*1.6),...p.map(A=>i3(A.pos,_)+Math.max(A.width,A.height))),E=()=>({pos:Xa(_,[0,g*.7,g*2.7]),look:_}),h=()=>({pos:Xa(_,[g*1.9,g*.55,g*1.9]),look:_}),$=(A,G)=>{let F=o.get(A);if(F){let B=F.size*4.6+6;return{pos:Xa(F.pos,[B*.34,B*.3,B*1.05]),look:F.pos,...G?{orbit:!0}:{}}}let Q=m.get(A);if(Q){let B=Math.max(Q.width,Q.height)*1.5+6;return{pos:Xa(Q.pos,[B*.2,B*.5,B*1.1]),look:Xa(Q.pos,[0,Q.height/2,0])}}return null},O=t.pace??"normal",{gap:L,chapter:q}=zO[O],C=[],Z=[],he=[],z=1;t.steps.forEach((A,G)=>{let F=A.chapter?q:0,Q=z+F,B=A.holdMs??e.sayDurationsMs?.[G]??Math.max(A.say?CO(A.say):0,1600);A.chapter&&he.push({t:z,type:"marker",label:A.chapter});let T={t:Math.round(Q)};if(A.card==="intro")T.camera=h();else if(A.card==="outro")T.camera=E();else{let R=DO(A.show).filter(y);R.length&&(T.show=R),A.overview&&(T.camera=E());let N=A.focus??(R.length===1?R[0]:void 0);if(N&&!A.overview){T.focus=N;let K=$(N,A.orbit);K&&(T.camera=K)}}if(A.showcase&&o.has(A.showcase)){T.focus=A.showcase,T.showcase=!0;let R=$(A.showcase);R&&(T.camera=R);let N=o.get(A.showcase);N&&(N.pedestal=!0)}let v=(A.highlight??[]).filter(y);v.length&&(T.highlight=v);let w=(A.filter??[]).filter(y);w.length&&(T.filter=w),A.callout&&y(A.callout.target)&&(T.callout=A.callout),A.set&&m.has(A.set.target)&&(T.set=A.set),C.push(T),A.say&&Z.push({t:Q,dur:B,text:A.say,words:jO(A.say,Q,B)}),z=Q+B+L});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:O},j=[{t:0,vfs:{},activeFile:null,terminalState:""}];return{manifest:{version:2,title:t.title,createdAt:e.createdAt??new Date().toISOString(),durationMs:Math.max(z,1500),mode:"3d"},events:he,snapshots:j,captions:Z.length?Z:void 0,scene3d:b}}var c3='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 BO={id:"3d",tool:{name:"create_3d_walkthrough",aliases:["create_three_d_walkthrough"],title:"Create a narrated 3D tour",description:c3},promptLine:"\u2022 3D \u2014 a narrated tour through a 3D scene (spatial structure, a showcase of parts) \u2192 create_3d_walkthrough",schema:x1,mode:"3d",makeBeat:(t,e)=>({say:t,card:e}),forceOutro:!0,async prepare(t){let e=await o3(t.objects??[]),r={};return await Promise.all((t.objects??[]).map(async n=>{if(!n.image||!/^https?:\/\//i.test(n.image))return;let s=await b1(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)=>a3(t,e)},l3=BO;var bu=[Xv,Ww,e3,l3];var VO=t=>`Welcome! In this walkthrough, we'll look at ${t}. Let's dive in.`,u3=t=>`And that's ${t}. Thanks for watching \u2014 see you in the next one.`;function d3(t,e,r,n,s,o=!1){let i=r===void 0?VO(e):r,a=n===void 0?u3(e):n;o&&!a.trim()&&(a=u3(e));let c=[...t];return a.trim()&&c.push(s(a,"outro")),i.trim()&&c.unshift(s(i,"intro")),c}import{gzipSync as qO}from"node:zlib";import{readFileSync as FO,existsSync as HO}from"node:fs";import{fileURLToPath as UO}from"node:url";import*as Si from"node:path";function h3(t,e,r,n){return`<!doctype html>
|
|
78
|
+
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 mz="https://nominatim.openstreetmap.org/search",gz="https://router.project-osrm.org/route/v1/driving",Kw="FlowCast/0.1 (map walkthrough generator)";var w1=new Map;async function _z(t){let e=t.trim().toLowerCase();if(!e)return null;if(w1.has(e))return w1.get(e);let r=null;try{let n=`${mz}?q=${encodeURIComponent(t)}&format=json&limit=1`,s=await fetch(n,{headers:{"user-agent":Kw,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 w1.set(e,r),r}async function Jw(t){let e={};return await Promise.all([...new Set(t)].map(async r=>{let n=await _z(r);n&&(e[r]=n)})),e}async function Qw(t){if(t.length<2)return null;let e=t.map(r=>`${r.lng},${r.lat}`).join(";");try{let r=`${gz}/${e}?overview=full&geometries=geojson`,n=await fetch(r,{headers:{"user-agent":Kw},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 bz={id:"map",tool:{name:"create_map_walkthrough",title:"Map walkthrough",description:Xw},promptLine:"\u2022 MAP \u2014 a narrated tour over a real map (travel, geography, history, logistics) \u2192 create_map_walkthrough",schema:y1,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 Jw([...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 Qw(i);a&&(n[o]=a)}})),{geo:r,routes:n}},compile:(t,e)=>Yw(t,e)},e3=bz;var yz="TTS voice (default cedar). Options: "+Hr.join(", ")+".",t3=["box","sphere","cylinder","cone","plane","torus","icosahedron","pyramid","wedge","disc","ring","tube","dome"],vz="box=service/block, sphere=node/planet, cylinder=tank/db, cone/pyramid=peak, disc=platform, ring/torus=loop/orbit, tube=pipe, dome=hill, icosahedron=crystal.",wz=W.object({shape:W.enum(t3).default("box").describe("Primitive for this piece."),at:W.array(W.number()).length(3).default([0,0,0]).describe("Local offset [x,y,z] from the object center."),size:W.union([W.number(),W.array(W.number()).length(3)]).default(1).describe("Size \u2014 number or [x,y,z] (parts ~0.2\u20132)."),color:W.string().optional().describe("CSS color (defaults to the object color)."),rotation:W.array(W.number()).length(3).optional().describe("Local rotation [x,y,z] in radians.")}),xz=W.object({id:W.string().describe("Unique id the beats reference."),shape:W.enum(t3).default("box").describe("Geometric primitive \u2014 use only when the object truly is one; otherwise prefer `svg`/`image`. "+vz),parts:W.array(wz).max(10).optional().describe("Fallback for blocky assemblies (prefer svg/image). Use 5\u20139 parts with varied colors + small detail parts, stacked in local space (origin = base on floor)."),svg:W.string().optional().describe("Inline SVG of ONE solid silhouette (pin, leaf, gear, star, simple logo) \u2014 extruded to 3D; its fill becomes the color. For complex art use `image`."),image:W.string().optional().describe("Image URL (https://\u2026) for anything complex/real (flag, photo, detailed logo, map) \u2014 embedded as a textured panel with exact colors."),model:W.string().optional().describe("Advanced: a glTF/GLB URL or local .glb/.gltf path for a real imported 3D model."),label:W.string().optional().describe("Floating label next to the object (with a leader line)."),value:W.number().optional().describe("Numeric value shown under the label, counting up on reveal (good for stats/charts)."),valueSuffix:W.string().optional().describe('Unit appended to the value, e.g. "M", "%", "ms".'),color:W.string().optional().describe("CSS color (default auto)."),size:W.number().optional().describe("Relative size (default 1)."),scale:W.union([W.number(),W.array(W.number()).length(3)]).optional().describe("Non-uniform scale \u2014 number or [x,y,z]. Tall Y = stat bar (height encodes value)."),finish:W.enum(["matte","glossy","metal","gradient","matcap","glass","iridescent"]).optional().describe("Surface material (default matte)."),path:W.array(W.array(W.number()).length(3)).optional().describe("Poly-line of [x,y,z] points the object travels along (2+ points, smoothed into a curve)."),pedestal:W.boolean().optional().describe("Place a round platform under the object."),reveal:W.enum(["grow","pop","fade","drop","rise"]).optional().describe("Entrance animation (default pop). grow = rise from floor (stat bars)."),motion:W.enum(["none","spin","bob","orbit"]).optional().describe("Idle motion (default none). spin/bob/orbit."),at:W.array(W.number()).length(3).optional().describe("Explicit [x,y,z]; omit for auto layout.")}),Sz=W.object({say:W.string().optional().describe("Narration for this beat \u2014 one short idea (4\u201314 words), spoken. Beats read as one continuous script."),show:W.union([W.string(),W.array(W.string())]).optional().describe("Object id(s) to reveal this beat (one per beat builds up)."),focus:W.string().optional().describe("Object id to move the camera to and frame."),overview:W.boolean().optional().describe("Frame the whole staged scene this beat."),orbit:W.boolean().optional().describe("Slowly orbit the focused object (turntable)."),showcase:W.string().optional().describe("Hero-showcase this object id (plinth + turntable + label)."),highlight:W.array(W.string()).optional().describe("Object/chart ids to spotlight while others recede."),filter:W.array(W.string()).optional().describe("Object ids to keep; everything else fades out."),callout:W.object({target:W.string(),text:W.string()}).optional().describe("Pin a note onto a target: { target, text }."),set:W.object({target:W.string(),values:W.array(W.number())}).optional().describe("Change a chart's data: { target, values } \u2014 animates before\u2192after with a delta badge."),chapter:W.string().optional().describe("Start a named chapter marker."),holdMs:W.number().optional().describe("Beat duration in ms (default from narration).")}),kz=W.object({label:W.string().optional().describe("Category label."),value:W.number().describe("The numeric value."),color:W.string().optional().describe("Optional per-datum color.")}),$z=W.object({id:W.string().describe("Unique id beats reference via show/focus."),type:W.enum(["bar","line","area","pie","donut","ring"]).describe("Chart kind. ring = single % gauge (value vs max)."),data:W.array(kz).min(1).describe("Data points. For a ring use a single datum."),at:W.array(W.number()).length(3).optional().describe("Position [x,y,z]; omit to auto-place."),width:W.number().optional().describe("Horizontal extent (default ~6)."),height:W.number().optional().describe("Vertical extent (default ~4)."),max:W.number().optional().describe("Value mapped to full height/percent (default = largest value)."),unit:W.string().optional().describe("Unit appended to value labels."),color:W.string().optional().describe("Accent color."),label:W.string().optional().describe("Chart title shown above it.")}),x1={title:W.string().describe("Title of the 3D walkthrough (header + filename)."),pace:W.enum(["calm","normal","snappy"]).optional().describe("Animation tempo (default 'normal')."),outputPath:W.string().optional().describe("Optional path to also write the .html to."),voiceName:W.enum(Hr).optional().describe(yz),voiceTone:W.string().optional().describe("How the narrator should sound, matched to the topic."),intro:W.string().optional().describe("Opening line spoken before the tour (default title-based; '' to skip)."),outro:W.string().optional().describe("Closing wrap-up line (always added)."),background:W.string().optional().describe('Scene background CSS color (default dark studio). Prefer a deep near-black, e.g. "#0d1018".'),floor:W.string().optional().describe("Optional floor color (defaults just off the background)."),template:W.enum(["solar-system","molecule","network","stack"]).optional().describe("Optional ready-made scene; you can omit `objects` or add your own. Your beats still drive the tour."),connections:W.array(W.object({from:W.string(),to:W.string(),label:W.string().optional()})).optional().describe("Glowing beams between objects (from\u2192to) showing relationships."),charts:W.array($z).max(8).optional().describe("Animated charts (bars grow, lines draw, pie/ring fill). Each has an id beats reveal via show/focus."),objects:W.array(xz).max(14).optional().describe("Scene objects (3\u20138 labeled works best). Geometry priority: primitive `shape` \u2192 `svg` silhouette \u2192 `image` URL (complex/real) \u2192 `parts` \u2192 `model`. Omit `at` for auto layout."),steps:W.array(Sz).min(1).describe("Ordered tour as a story: open with an overview, reveal/focus ONE object at a time while explaining, then recap. Many short beats; `say` lines read as one script.")},sF=W.object(x1);import{readFile as Ez,stat as Tz}from"node:fs/promises";var Rz=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 S1(t){return!!t&&Rz.has(t.trim().toLowerCase())}var Pz=16*1024*1024,Mz=2e4,n3=t=>/\.(glb|gltf)(\?|$)/i.test(t);function r3(t,e){return!t.length||t.length>Pz?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 Iz(t){let e=t.trim();try{if(/^https?:\/\//i.test(e)){let s=await fetch(e,{signal:AbortSignal.timeout(Mz),redirect:"follow"});return s.ok?r3(Buffer.from(await s.arrayBuffer()),e):null}let r=e.startsWith("file://")?new URL(e).pathname:e;if(!n3(r))return null;let n=await Tz(r).catch(()=>null);return!n||!n.isFile()?null:r3(await Ez(r),r)}catch{return null}}function zz(t){return!t||S1(t)?!1:/^https?:\/\//i.test(t)||t.startsWith("file://")||n3(t)}async function s3(t){let e={};return await Promise.all(t.map(async r=>{if(zz(r.model)){let n=await Iz(r.model);n&&(e[r.id]=n)}})),e}var Az=285,Oz={calm:{gap:250,chapter:450},normal:{gap:140,chapter:320},snappy:{gap:90,chapter:240}},_u=["#7cc6ff","#9be08b","#ffd166","#ff8c69","#c89bff","#5ad1c4","#ff9ecb","#a0d8ef"],Nz=t=>Math.max(1,t.trim().split(/\s+/).length),Cz=t=>Math.max(1600,Nz(t)*Az);function jz(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 Ya=(t,e)=>[t[0]+e[0],t[1]+e[1],t[2]+e[2]],o3=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),Dz=t=>t==null?[]:Array.isArray(t)?t:[t];function Lz(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 k1=(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 Zz(t,e){let r=u=>u.model?S1(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,f)=>u.parts?.length?u.parts.map(p=>({shape:p.shape??"box",pos:p.at??[0,0,0],size:s(p.size),color:p.color||f,...p.rotation?{rotation:p.rotation}:{}})):void 0,i=(u,f,p,m={})=>{let y=u.color||_u[f%_u.length],k=o(u,y);return{id:u.id,shape:u.shape??"box",pos:p,size:u.size??1,scale:n(u.scale),color:y,...u.label?{label:u.label}:{},...u.value!=null?{value:u.value}:{},...u.valueSuffix?{valueSuffix:u.valueSuffix}:{},...k?{parts:k}:{},...u.svg&&!k?{svg:u.svg}:{},...!k&&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",...m}},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,f)=>{if(f===0)return i(u,f,[0,0,0],{glow:!0,motion:u.motion??"spin",shape:u.shape??"sphere"});let p=5+(f-1)*3.2;return i(u,f,k1(f-1,Math.max(3,a.length-1),p),{shape:u.shape??"sphere",motion:"orbit",orbit:{radius:p,speed:.18/Math.sqrt(f),phase:f/a.length*Math.PI*2}})});else if(t.template==="molecule"){if(l=a.map((u,f)=>f===0?i(u,f,[0,0,0],{shape:u.shape??"sphere"}):i(u,f,k1(f-1,a.length-1,2.6,(f%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,f)=>i(u,f,k1(f,a.length,Math.max(4,a.length*.9),(f%2?1:-1)*.8))):t.template==="stack"?l=a.map((u,f)=>i(u,f,[0,(a.length-1)/2-f,0],{shape:u.shape??"box",motion:u.motion??"none",size:u.size??1.6})):l=a.map((u,f)=>i(u,f,u.at?u.at:Lz(f,a.length)));return{objects:l,connections:c,starfield:d}}function i3(t,e={}){let{objects:r,connections:n,starfield:s}=Zz(t,e.models??{}),o=new Map(r.map(A=>[A.id,A]));for(let A of r){let G=e.images?.[A.id];G&&(A.image=G.href,A.imageAspect=G.h>0?G.w/G.h:1)}let i=t.charts??[],a=4.5,c=i.map(A=>A.width??6),l=-(c.reduce((A,G)=>A+G,0)+a*Math.max(0,i.length-1))/2,u=r.map(A=>A.pos[2]),f=r.length?Math.min(0,...u)-9:0,p=i.map((A,G)=>{let F=c[G],Q=A.height??4,B=l+F/2;l+=F+a;let T=A.at?A.at:[B,0,f];return{id:A.id,type:A.type,pos:T,width:F,height:Q,data:A.data.map(v=>({...v.label?{label:v.label}:{},value:v.value,...v.color?{color:v.color}:{}})),max:A.max??Math.max(...A.data.map(v=>v.value),1),...A.unit?{unit:A.unit}:{},color:A.color||_u[(r.length+G)%_u.length],...A.label?{label:A.label}:{}}}),m=new Map(p.map(A=>[A.id,A])),y=A=>o.has(A)||m.has(A),k=[...r.map(A=>A.pos),...p.map(A=>A.pos)],x=k.length,_=x?[k.reduce((A,G)=>A+G[0],0)/x,k.reduce((A,G)=>A+G[1],0)/x,k.reduce((A,G)=>A+G[2],0)/x]:[0,0,0],g=Math.max(5,...r.map(A=>o3(A.pos,_)+A.size*1.6),...p.map(A=>o3(A.pos,_)+Math.max(A.width,A.height))),E=()=>({pos:Ya(_,[0,g*.7,g*2.7]),look:_}),h=()=>({pos:Ya(_,[g*1.9,g*.55,g*1.9]),look:_}),$=(A,G)=>{let F=o.get(A);if(F){let B=F.size*4.6+6;return{pos:Ya(F.pos,[B*.34,B*.3,B*1.05]),look:F.pos,...G?{orbit:!0}:{}}}let Q=m.get(A);if(Q){let B=Math.max(Q.width,Q.height)*1.5+6;return{pos:Ya(Q.pos,[B*.2,B*.5,B*1.1]),look:Ya(Q.pos,[0,Q.height/2,0])}}return null},z=t.pace??"normal",{gap:L,chapter:q}=Oz[z],C=[],Z=[],he=[],O=1;t.steps.forEach((A,G)=>{let F=A.chapter?q:0,Q=O+F,B=A.holdMs??e.sayDurationsMs?.[G]??Math.max(A.say?Cz(A.say):0,1600);A.chapter&&he.push({t:O,type:"marker",label:A.chapter});let T={t:Math.round(Q)};if(A.card==="intro")T.camera=h();else if(A.card==="outro")T.camera=E();else{let R=Dz(A.show).filter(y);R.length&&(T.show=R),A.overview&&(T.camera=E());let N=A.focus??(R.length===1?R[0]:void 0);if(N&&!A.overview){T.focus=N;let K=$(N,A.orbit);K&&(T.camera=K)}}if(A.showcase&&o.has(A.showcase)){T.focus=A.showcase,T.showcase=!0;let R=$(A.showcase);R&&(T.camera=R);let N=o.get(A.showcase);N&&(N.pedestal=!0)}let v=(A.highlight??[]).filter(y);v.length&&(T.highlight=v);let w=(A.filter??[]).filter(y);w.length&&(T.filter=w),A.callout&&y(A.callout.target)&&(T.callout=A.callout),A.set&&m.has(A.set.target)&&(T.set=A.set),C.push(T),A.say&&Z.push({t:Q,dur:B,text:A.say,words:jz(A.say,Q,B)}),O=Q+B+L});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:z},j=[{t:0,vfs:{},activeFile:null,terminalState:""}];return{manifest:{version:2,title:t.title,createdAt:e.createdAt??new Date().toISOString(),durationMs:Math.max(O,1500),mode:"3d"},events:he,snapshots:j,captions:Z.length?Z:void 0,scene3d:b}}var a3='Render a narrated, animated 3D tour: a staged 3D model (objects arranged in space) revealed and focused beat by beat with a gliding camera, plus animated `charts`/`callouts`. Produces ONE self-contained interactive HTML (scrubbable, with voice) in the same FlowCast player as the other casts. Use it when SPATIAL/3D structure helps \u2014 comparing sizes, layers, arrangement, a parts showcase, or a data story.\n\nYou list OBJECTS + beats; the server lays out the scene and the player auto-frames it, so no camera math.\n\nObjects \u2014 pick geometry in this order:\n1. `shape` primitive \u2014 only if it truly is one (sphere node, cylinder tank, box/stat-bar).\n2. `svg` \u2014 ONE simple solid icon (pin, gear, star, simple logo); extruded, fill = color.\n3. `image` \u2014 an image URL for anything complex/real (flag, photo, detailed logo, map); embedded as a textured panel.\n4. `parts` \u2014 fallback for blocky assemblies (5\u20139 varied parts).\n5. `model` \u2014 a real glTF/GLB URL.\nStat bars: shape:"box", scale:[1,value,1], reveal:"grow", plus `value`+`valueSuffix` to count up.\n\nCharts: [{ id, type:"bar"|"line"|"area"|"pie"|"donut"|"ring", data:[{label,value}] }] \u2014 revealed by beats like objects.\n\nBeats: each has a short `say` + an action \u2014 `show` (reveal id[s]), `focus` (camera to id), `overview` (frame all), `orbit` (turntable the focused object), `showcase` (hero plinth reveal), `highlight`/`filter` (spotlight a subset), `callout:{target,text}`, `set:{target,values}` (animate a chart\'s data). 3\u20138 objects; omit `at` for auto layout on a clean grid-floor stage.\n\nTell it as a story: open with an overview, focus ONE object per beat while explaining, recap with another overview. Many short beats that read as one script. Set `voiceName`+`voiceTone`; intro/outro are auto-added.\n\nOutput: the primary result is a local URL (http://127.0.0.1:<port>/<id>.html) returned as a resource_link \u2014 give it to the user. Pass `outputPath` only to also write the file.';var Bz={id:"3d",tool:{name:"create_3d_walkthrough",title:"Create a narrated 3D tour",description:a3},promptLine:"\u2022 3D \u2014 a narrated tour through a 3D scene (spatial structure, a showcase of parts) \u2192 create_3d_walkthrough",schema:x1,mode:"3d",makeBeat:(t,e)=>({say:t,card:e}),forceOutro:!0,async prepare(t){let e=await s3(t.objects??[]),r={};return await Promise.all((t.objects??[]).map(async n=>{if(!n.image||!/^https?:\/\//i.test(n.image))return;let s=await b1(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)=>i3(t,e)},c3=Bz;var bu=[Xv,Ww,e3,c3];var Vz=t=>`Welcome! In this walkthrough, we'll look at ${t}. Let's dive in.`,l3=t=>`And that's ${t}. Thanks for watching \u2014 see you in the next one.`;function u3(t,e,r,n,s,o=!1){let i=r===void 0?Vz(e):r,a=n===void 0?l3(e):n;o&&!a.trim()&&(a=l3(e));let c=[...t];return a.trim()&&c.push(s(a,"outro")),i.trim()&&c.unshift(s(i,"intro")),c}import{gzipSync as qz}from"node:zlib";import{readFileSync as Fz,existsSync as Uz}from"node:fs";import{fileURLToPath as Hz}from"node:url";import*as xi from"node:path";function d3(t,e,r,n){return`<!doctype html>
|
|
159
79
|
<html lang="en">
|
|
160
80
|
<head>
|
|
161
81
|
<meta charset="utf-8" />
|
|
@@ -189,10 +109,10 @@ Delivery is identical to the other tools: the PRIMARY result is a http://127.0.0
|
|
|
189
109
|
})();
|
|
190
110
|
</script>
|
|
191
111
|
</body>
|
|
192
|
-
</html>`}function f3(t){return!!t.preview}function p3(t){return t.events.some(e=>e.type==="term.data"||e.type==="term.resize")}var GO=Si.dirname(UO(import.meta.url));function WO(t){let e=Si.join(t,"player");return HO(e)?e:Si.join(t,"../../../../packages/player/dist")}var m3=WO(GO);function YO(t){let e;if(t.manifest.mode)e=`_player-bundle.${t.manifest.mode}.gz.b64`;else{let r=f3(t),n=p3(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 FO(Si.join(m3,e),"utf8").trim()}catch{throw new Error(`Player bundle "${e}" not found in ${m3} (run pnpm build:player).`)}}function g3(t,e=""){let r=qO(Buffer.from(JSON.stringify({...t,audio:null}),"utf8"),{level:9}).toString("base64"),n=YO(t);return h3(t.manifest.title,r,e,n)}var q3={};function XO(t){return new Int8Array(t)}function F3(t){return new Int16Array(t)}function H3(t){return new Int32Array(t)}function U3(t){return new Float32Array(t)}function KO(t){return new Float64Array(t)}function G3(t){if(t.length==1)return U3(t[0]);var e=t[0];t=t.slice(1);for(var r=[],n=0;n<e;n++)r.push(G3(t));return r}function W3(t){if(t.length==1)return H3(t[0]);var e=t[0];t=t.slice(1);for(var r=[],n=0;n<e;n++)r.push(W3(t));return r}function Y3(t){if(t.length==1)return F3(t[0]);var e=t[0];t=t.slice(1);for(var r=[],n=0;n<e;n++)r.push(Y3(t));return r}function X3(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(X3(t));return r}var K3={};K3.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 ec={};ec.arraycopy=function(t,e,r,n,s){for(var o=e+s;e<o;)r[n++]=t[e++]};ec.out={};ec.out.println=function(t){console.log(t)};ec.out.printf=function(){console.log.apply(console,arguments)};var ku={};ku.SQRT2=1.4142135623730951;ku.FAST_LOG10=function(t){return Math.log10(t)};ku.FAST_LOG10_X=function(t,e){return Math.log10(t)*e};function ts(t){this.ordinal=t}ts.short_block_allowed=new ts(0);ts.short_block_coupled=new ts(1);ts.short_block_dispensed=new ts(2);ts.short_block_forced=new ts(3);var J3={};J3.MAX_VALUE=34028235e31;function Yr(t){this.ordinal=t}Yr.vbr_off=new Yr(0);Yr.vbr_mt=new Yr(1);Yr.vbr_rh=new Yr(2);Yr.vbr_abr=new Yr(3);Yr.vbr_mtrh=new Yr(4);Yr.vbr_default=Yr.vbr_mtrh;var JO=function(t){},qt={System:ec,VbrMode:Yr,Float:J3,ShortBlock:ts,Util:ku,Arrays:K3,new_array_n:X3,new_byte:XO,new_double:KO,new_float:U3,new_float_n:G3,new_int:H3,new_int_n:W3,new_short:F3,new_short_n:Y3,assert:JO},$1,_3;function QO(){if(_3)return $1;_3=1;var t=qt,e=t.System,r=t.Util,n=t.Arrays,s=t.new_float,o=br();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],f=l[o.SHORT_TYPE],p=l[o.SHORT_TYPE],m=l[o.SHORT_TYPE],y=[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 k(g,E,h){for(var $=10,O=E+238-14-286,L=-15;L<0;L++){var q,C,Z;q=a[$+-10],C=g[O+-224]*q,Z=g[E+224]*q,q=a[$+-9],C+=g[O+-160]*q,Z+=g[E+160]*q,q=a[$+-8],C+=g[O+-96]*q,Z+=g[E+96]*q,q=a[$+-7],C+=g[O+-32]*q,Z+=g[E+32]*q,q=a[$+-6],C+=g[O+32]*q,Z+=g[E+-32]*q,q=a[$+-5],C+=g[O+96]*q,Z+=g[E+-96]*q,q=a[$+-4],C+=g[O+160]*q,Z+=g[E+-160]*q,q=a[$+-3],C+=g[O+224]*q,Z+=g[E+-224]*q,q=a[$+-2],C+=g[E+-256]*q,Z-=g[O+256]*q,q=a[$+-1],C+=g[E+-192]*q,Z-=g[O+192]*q,q=a[$+0],C+=g[E+-128]*q,Z-=g[O+128]*q,q=a[$+1],C+=g[E+-64]*q,Z-=g[O+64]*q,q=a[$+2],C+=g[E+0]*q,Z-=g[O+0]*q,q=a[$+3],C+=g[E+64]*q,Z-=g[O+-64]*q,q=a[$+4],C+=g[E+128]*q,Z-=g[O+-128]*q,q=a[$+5],C+=g[E+192]*q,Z-=g[O+-192]*q,C*=a[$+6],q=Z-C,h[30+L*2]=Z+C,h[31+L*2]=a[$+7]*q,$+=18,E--,O++}{var C,Z,he,z;Z=g[E+-16]*a[$+-10],C=g[E+-32]*a[$+-2],Z+=(g[E+-48]-g[E+16])*a[$+-9],C+=g[E+-96]*a[$+-1],Z+=(g[E+-80]+g[E+48])*a[$+-8],C+=g[E+-160]*a[$+0],Z+=(g[E+-112]-g[E+80])*a[$+-7],C+=g[E+-224]*a[$+1],Z+=(g[E+-144]+g[E+112])*a[$+-6],C-=g[E+32]*a[$+2],Z+=(g[E+-176]-g[E+144])*a[$+-5],C-=g[E+96]*a[$+3],Z+=(g[E+-208]+g[E+176])*a[$+-4],C-=g[E+160]*a[$+4],Z+=(g[E+-240]-g[E+208])*a[$+-3],C-=g[E+224],he=C-Z,z=C+Z,Z=h[14],C=h[15]-Z,h[31]=z+Z,h[30]=he+C,h[15]=he-C,h[14]=z-Z}{var b;b=h[28]-h[0],h[0]+=h[28],h[28]=b*a[$+-2*18+7],b=h[29]-h[1],h[1]+=h[29],h[29]=b*a[$+-2*18+7],b=h[26]-h[2],h[2]+=h[26],h[26]=b*a[$+-4*18+7],b=h[27]-h[3],h[3]+=h[27],h[27]=b*a[$+-4*18+7],b=h[24]-h[4],h[4]+=h[24],h[24]=b*a[$+-6*18+7],b=h[25]-h[5],h[5]+=h[25],h[25]=b*a[$+-6*18+7],b=h[22]-h[6],h[6]+=h[22],h[22]=b*r.SQRT2,b=h[23]-h[7],h[7]+=h[23],h[23]=b*r.SQRT2-h[7],h[7]-=h[6],h[22]-=h[7],h[23]-=h[22],b=h[6],h[6]=h[31]-b,h[31]=h[31]+b,b=h[7],h[7]=h[30]-b,h[30]=h[30]+b,b=h[22],h[22]=h[15]-b,h[15]=h[15]+b,b=h[23],h[23]=h[14]-b,h[14]=h[14]+b,b=h[20]-h[8],h[8]+=h[20],h[20]=b*a[$+-10*18+7],b=h[21]-h[9],h[9]+=h[21],h[21]=b*a[$+-10*18+7],b=h[18]-h[10],h[10]+=h[18],h[18]=b*a[$+-12*18+7],b=h[19]-h[11],h[11]+=h[19],h[19]=b*a[$+-12*18+7],b=h[16]-h[12],h[12]+=h[16],h[16]=b*a[$+-14*18+7],b=h[17]-h[13],h[13]+=h[17],h[17]=b*a[$+-14*18+7],b=-h[20]+h[24],h[20]+=h[24],h[24]=b*a[$+-12*18+7],b=-h[21]+h[25],h[21]+=h[25],h[25]=b*a[$+-12*18+7],b=h[4]-h[8],h[4]+=h[8],h[8]=b*a[$+-12*18+7],b=h[5]-h[9],h[5]+=h[9],h[9]=b*a[$+-12*18+7],b=h[0]-h[12],h[0]+=h[12],h[12]=b*a[$+-4*18+7],b=h[1]-h[13],h[1]+=h[13],h[13]=b*a[$+-4*18+7],b=h[16]-h[28],h[16]+=h[28],h[28]=b*a[$+-4*18+7],b=-h[17]+h[29],h[17]+=h[29],h[29]=b*a[$+-4*18+7],b=r.SQRT2*(h[2]-h[10]),h[2]+=h[10],h[10]=b,b=r.SQRT2*(h[3]-h[11]),h[3]+=h[11],h[11]=b,b=r.SQRT2*(-h[18]+h[26]),h[18]+=h[26],h[26]=b-h[18],b=r.SQRT2*(-h[19]+h[27]),h[19]+=h[27],h[27]=b-h[19],b=h[2],h[19]-=h[3],h[3]-=b,h[2]=h[31]-b,h[31]+=b,b=h[3],h[11]-=h[19],h[18]-=b,h[3]=h[30]-b,h[30]+=b,b=h[18],h[27]-=h[11],h[19]-=b,h[18]=h[15]-b,h[15]+=b,b=h[19],h[10]-=b,h[19]=h[14]-b,h[14]+=b,b=h[10],h[11]-=b,h[10]=h[23]-b,h[23]+=b,b=h[11],h[26]-=b,h[11]=h[22]-b,h[22]+=b,b=h[26],h[27]-=b,h[26]=h[7]-b,h[7]+=b,b=h[27],h[27]=h[6]-b,h[6]+=b,b=r.SQRT2*(h[0]-h[4]),h[0]+=h[4],h[4]=b,b=r.SQRT2*(h[1]-h[5]),h[1]+=h[5],h[5]=b,b=r.SQRT2*(h[16]-h[20]),h[16]+=h[20],h[20]=b,b=r.SQRT2*(h[17]-h[21]),h[17]+=h[21],h[21]=b,b=-r.SQRT2*(h[8]-h[12]),h[8]+=h[12],h[12]=b-h[8],b=-r.SQRT2*(h[9]-h[13]),h[9]+=h[13],h[13]=b-h[9],b=-r.SQRT2*(h[25]-h[29]),h[25]+=h[29],h[29]=b-h[25],b=-r.SQRT2*(h[24]+h[28]),h[24]-=h[28],h[28]=b-h[24],b=h[24]-h[16],h[24]=b,b=h[20]-b,h[20]=b,b=h[28]-b,h[28]=b,b=h[25]-h[17],h[25]=b,b=h[21]-b,h[21]=b,b=h[29]-b,h[29]=b,b=h[17]-h[1],h[17]=b,b=h[9]-b,h[9]=b,b=h[25]-b,h[25]=b,b=h[5]-b,h[5]=b,b=h[21]-b,h[21]=b,b=h[13]-b,h[13]=b,b=h[29]-b,h[29]=b,b=h[1]-h[0],h[1]=b,b=h[16]-b,h[16]=b,b=h[17]-b,h[17]=b,b=h[8]-b,h[8]=b,b=h[9]-b,h[9]=b,b=h[24]-b,h[24]=b,b=h[25]-b,h[25]=b,b=h[4]-b,h[4]=b,b=h[5]-b,h[5]=b,b=h[20]-b,h[20]=b,b=h[21]-b,h[21]=b,b=h[12]-b,h[12]=b,b=h[13]-b,h[13]=b,b=h[28]-b,h[28]=b,b=h[29]-b,h[29]=b,b=h[0],h[0]+=h[31],h[31]-=b,b=h[1],h[1]+=h[30],h[30]-=b,b=h[16],h[16]+=h[15],h[15]-=b,b=h[17],h[17]+=h[14],h[14]-=b,b=h[8],h[8]+=h[23],h[23]-=b,b=h[9],h[9]+=h[22],h[22]-=b,b=h[24],h[24]+=h[7],h[7]-=b,b=h[25],h[25]+=h[6],h[6]-=b,b=h[4],h[4]+=h[27],h[27]-=b,b=h[5],h[5]+=h[26],h[26]-=b,b=h[20],h[20]+=h[11],h[11]-=b,b=h[21],h[21]+=h[10],h[10]-=b,b=h[12],h[12]+=h[19],h[19]-=b,b=h[13],h[13]+=h[18],h[18]-=b,b=h[28],h[28]+=h[3],h[3]-=b,b=h[29],h[29]+=h[2],h[2]-=b}}function x(g,E){for(var h=0;h<3;h++){var $,O,L,q,C,Z;q=g[E+2*3]*l[o.SHORT_TYPE][0]-g[E+5*3],$=g[E+0*3]*l[o.SHORT_TYPE][2]-g[E+3*3],O=q+$,L=q-$,q=g[E+5*3]*l[o.SHORT_TYPE][0]+g[E+2*3],$=g[E+3*3]*l[o.SHORT_TYPE][2]+g[E+0*3],C=q+$,Z=-q+$,$=(g[E+1*3]*l[o.SHORT_TYPE][1]-g[E+4*3])*2069978111953089e-26,q=(g[E+4*3]*l[o.SHORT_TYPE][1]+g[E+1*3])*2069978111953089e-26,g[E+3*0]=O*190752519173728e-25+$,g[E+3*5]=-C*190752519173728e-25+q,L=L*.8660254037844387*1907525191737281e-26,C=C*.5*1907525191737281e-26+q,g[E+3*1]=L-C,g[E+3*2]=L+C,O=O*.5*1907525191737281e-26-$,Z=Z*.8660254037844387*1907525191737281e-26,g[E+3*3]=O+Z,g[E+3*4]=O-Z,E++}}function _(g,E,h){var $,O;{var L,q,C,Z,he,z,b,j;L=h[17]-h[9],C=h[15]-h[11],Z=h[14]-h[12],he=h[0]+h[8],z=h[1]+h[7],b=h[2]+h[6],j=h[3]+h[5],g[E+17]=he+b-j-(z-h[4]),O=(he+b-j)*f[19]+(z-h[4]),$=(L-C-Z)*f[18],g[E+5]=$+O,g[E+6]=$-O,q=(h[16]-h[10])*f[18],z=z*f[19]+h[4],$=L*f[12]+q+C*f[13]+Z*f[14],O=-he*f[16]+z-b*f[17]+j*f[15],g[E+1]=$+O,g[E+2]=$-O,$=L*f[13]-q-C*f[14]+Z*f[12],O=-he*f[17]+z-b*f[15]+j*f[16],g[E+9]=$+O,g[E+10]=$-O,$=L*f[14]-q+C*f[12]-Z*f[13],O=he*f[15]-z+b*f[16]-j*f[17],g[E+13]=$+O,g[E+14]=$-O}{var A,G,F,Q,B,T,v,w;A=h[8]-h[0],F=h[6]-h[2],Q=h[5]-h[3],B=h[17]+h[9],T=h[16]+h[10],v=h[15]+h[11],w=h[14]+h[12],g[E+0]=B+v+w+(T+h[13]),$=(B+v+w)*f[19]-(T+h[13]),O=(A-F+Q)*f[18],g[E+11]=$+O,g[E+12]=$-O,G=(h[7]-h[1])*f[18],T=h[13]-T*f[19],$=B*f[15]-T+v*f[16]+w*f[17],O=A*f[14]+G+F*f[12]+Q*f[13],g[E+3]=$+O,g[E+4]=$-O,$=-B*f[17]+T-v*f[15]-w*f[16],O=A*f[13]+G-F*f[14]-Q*f[12],g[E+7]=$+O,g[E+8]=$-O,$=-B*f[16]+T-v*f[17]-w*f[15],O=A*f[12]-G+F*f[13]-Q*f[14],g[E+15]=$+O,g[E+16]=$-O}}this.mdct_sub48=function(g,E,h){for(var $=E,O=286,L=0;L<g.channels_out;L++){for(var q=0;q<g.mode_gr;q++){for(var C,Z=g.l3_side.tt[q][L],he=Z.xr,z=0,b=g.sb_sample[L][1-q],j=0,A=0;A<18/2;A++)for(k($,O,b[j]),k($,O+32,b[j+1]),j+=2,O+=64,C=1;C<32;C+=2)b[j-1][C]*=-1;for(C=0;C<32;C++,z+=18){var G=Z.block_type,F=g.sb_sample[L][q],Q=g.sb_sample[L][1-q];if(Z.mixed_block_flag!=0&&C<2&&(G=0),g.amp_filter[C]<1e-12)n.fill(he,z+0,z+18,0);else{if(g.amp_filter[C]<1)for(var A=0;A<18;A++)Q[A][y[C]]*=g.amp_filter[C];if(G==o.SHORT_TYPE){for(var A=-c/4;A<0;A++){var B=l[o.SHORT_TYPE][A+3];he[z+A*3+9]=F[9+A][y[C]]*B-F[8-A][y[C]],he[z+A*3+18]=F[14-A][y[C]]*B+F[15+A][y[C]],he[z+A*3+10]=F[15+A][y[C]]*B-F[14-A][y[C]],he[z+A*3+19]=Q[2-A][y[C]]*B+Q[3+A][y[C]],he[z+A*3+11]=Q[3+A][y[C]]*B-Q[2-A][y[C]],he[z+A*3+20]=Q[8-A][y[C]]*B+Q[9+A][y[C]]}x(he,z)}else{for(var T=s(18),A=-d/4;A<0;A++){var v,w;v=l[G][A+27]*Q[A+9][y[C]]+l[G][A+36]*Q[8-A][y[C]],w=l[G][A+9]*F[A+9][y[C]]-l[G][A+18]*F[8-A][y[C]],T[A+9]=v-w*u[3+A+9],T[A+18]=v*u[3+A+9]+w}_(he,z,T)}}if(G!=o.SHORT_TYPE&&C!=0)for(var A=7;A>=0;--A){var R,N;R=he[z+A]*p[20+A]+he[z+-1-A]*m[28+A],N=he[z+A]*m[28+A]-he[z+-1-A]*p[20+A],he[z+-1-A]=R,he[z+A]=N}}}if($=h,O=286,g.mode_gr==1)for(var K=0;K<18;K++)e.arraycopy(g.sb_sample[L][1][K],0,g.sb_sample[L][0][K],0,32)}}}return $1=i,$1}var E1,b3;function Q3(){if(b3)return E1;b3=1;var t=br(),e=qt,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 E1=o,E1}var T1,y3;function eA(){if(y3)return T1;y3=1;var t=Q3();function e(){this.thm=new t,this.en=new t}return T1=e,T1}function Pn(t){var e=t;this.ordinal=function(){return e}}Pn.STEREO=new Pn(0);Pn.JOINT_STEREO=new Pn(1);Pn.DUAL_CHANNEL=new Pn(2);Pn.MONO=new Pn(3);Pn.NOT_SET=new Pn(4);var tc=Pn,R1,v3;function br(){if(v3)return R1;v3=1;var t=qt,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=QO(),l=eA(),u=tc,f=c.FFTOFFSET,p=c.MPG_MD_MS_LR,m=null;this.psy=null;var y=null,k=null,x=null;this.setModules=function($,O,L,q){m=$,this.psy=O,y=O,k=q,x=L};var _=new d;function g($){var O,L;if($.ATH.useAdjust==0){$.ATH.adjust=1;return}if(L=$.loudness_sq[0][0],O=$.loudness_sq[1][0],$.channels_out==2?(L+=$.loudness_sq[0][1],O+=$.loudness_sq[1][1]):(L+=L,O+=O),$.mode_gr==2&&(L=Math.max(L,O)),L*=.5,L*=$.ATH.aaSensitivityP,L>.03125)$.ATH.adjust>=1?$.ATH.adjust=1:$.ATH.adjust<$.ATH.adjustLimit&&($.ATH.adjust=$.ATH.adjustLimit),$.ATH.adjustLimit=1;else{var q=31.98*L+625e-6;$.ATH.adjust>=q?($.ATH.adjust*=q*.075+.925,$.ATH.adjust<q&&($.ATH.adjust=q)):$.ATH.adjustLimit>=q?$.ATH.adjust=q:$.ATH.adjust<$.ATH.adjustLimit&&($.ATH.adjust=$.ATH.adjustLimit),$.ATH.adjustLimit=q}}function E($){var O,L;for(a(0<=$.bitrate_index&&$.bitrate_index<16),a(0<=$.mode_ext&&$.mode_ext<4),$.bitrate_stereoMode_Hist[$.bitrate_index][4]++,$.bitrate_stereoMode_Hist[15][4]++,$.channels_out==2&&($.bitrate_stereoMode_Hist[$.bitrate_index][$.mode_ext]++,$.bitrate_stereoMode_Hist[15][$.mode_ext]++),O=0;O<$.mode_gr;++O)for(L=0;L<$.channels_out;++L){var q=$.l3_side.tt[O][L].block_type|0;$.l3_side.tt[O][L].mixed_block_flag!=0&&(q=4),$.bitrate_blockType_Hist[$.bitrate_index][q]++,$.bitrate_blockType_Hist[$.bitrate_index][5]++,$.bitrate_blockType_Hist[15][q]++,$.bitrate_blockType_Hist[15][5]++}}function h($,O){var L=$.internal_flags,q,C;if(L.lame_encode_frame_init==0){var Z,he,z=s(2014),b=s(2014);for(L.lame_encode_frame_init=1,Z=0,he=0;Z<286+576*(1+L.mode_gr);++Z)Z<576*L.mode_gr?(z[Z]=0,L.channels_out==2&&(b[Z]=0)):(z[Z]=O[0][he],L.channels_out==2&&(b[Z]=O[1][he]),++he);for(C=0;C<L.mode_gr;C++)for(q=0;q<L.channels_out;q++)L.l3_side.tt[C][q].block_type=c.SHORT_TYPE;_.mdct_sub48(L,z,b),a(576>=c.FFTOFFSET),a(L.mf_size>=c.BLKSIZE+$.framesize-c.FFTOFFSET),a(L.mf_size>=512+$.framesize-32)}}this.lame_encode_mp3_frame=function($,O,L,q,C,Z){var he,z=n([2,2]);z[0][0]=new l,z[0][1]=new l,z[1][0]=new l,z[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 j,A=[null,null],G=$.internal_flags,F=o([2,4]),Q=[.5,.5],B=[[0,0],[0,0]],T=[[0,0],[0,0]],v,w,R;if(A[0]=O,A[1]=L,G.lame_encode_frame_init==0&&h($,A),G.padding=0,(G.slot_lag-=G.frac_SpF)<0&&(G.slot_lag+=$.out_samplerate,G.padding=1),G.psymodel!=0){var N,K=[null,null],se=0,H=i(2);for(R=0;R<G.mode_gr;R++){for(w=0;w<G.channels_out;w++)K[w]=A[w],se=576+R*576-c.FFTOFFSET;if($.VBR==r.vbr_mtrh||$.VBR==r.vbr_mt?N=y.L3psycho_anal_vbr($,K,se,R,z,b,B[R],T[R],F[R],H):N=y.L3psycho_anal_ns($,K,se,R,z,b,B[R],T[R],F[R],H),N!=0)return-4;for($.mode==u.JOINT_STEREO&&(Q[R]=F[R][2]+F[R][3],Q[R]>0&&(Q[R]=F[R][3]/Q[R])),w=0;w<G.channels_out;w++){var ee=G.l3_side.tt[R][w];ee.block_type=H[w],ee.mixed_block_flag=0}}}else for(R=0;R<G.mode_gr;R++)for(w=0;w<G.channels_out;w++)G.l3_side.tt[R][w].block_type=c.NORM_TYPE,G.l3_side.tt[R][w].mixed_block_flag=0,T[R][w]=B[R][w]=700;if(g(G),_.mdct_sub48(G,A[0],A[1]),G.mode_ext=c.MPG_MD_LR_LR,$.force_ms)G.mode_ext=c.MPG_MD_MS_LR;else if($.mode==u.JOINT_STEREO){var de=0,_e=0;for(R=0;R<G.mode_gr;R++)for(w=0;w<G.channels_out;w++)de+=T[R][w],_e+=B[R][w];if(de<=1*_e){var ke=G.l3_side.tt[0],Ie=G.l3_side.tt[G.mode_gr-1];ke[0].block_type==ke[1].block_type&&Ie[0].block_type==Ie[1].block_type&&(G.mode_ext=c.MPG_MD_MS_LR)}}if(G.mode_ext==p?(j=b,v=T):(j=z,v=B),$.analysis&&G.pinfo!=null)for(R=0;R<G.mode_gr;R++)for(w=0;w<G.channels_out;w++)G.pinfo.ms_ratio[R]=G.ms_ratio[R],G.pinfo.ms_ener_ratio[R]=Q[R],G.pinfo.blocktype[R][w]=G.l3_side.tt[R][w].block_type,G.pinfo.pe[R][w]=v[R][w],e.arraycopy(G.l3_side.tt[R][w].xr,0,G.pinfo.xr[R][w],0,576),G.mode_ext==p&&(G.pinfo.ers[R][w]=G.pinfo.ers[R][w+2],e.arraycopy(G.pinfo.energy[R][w+2],0,G.pinfo.energy[R][w],0,G.pinfo.energy[R][w].length));if($.VBR==r.vbr_off||$.VBR==r.vbr_abr){var Te,$e;for(Te=0;Te<18;Te++)G.nsPsy.pefirbuf[Te]=G.nsPsy.pefirbuf[Te+1];for($e=0,R=0;R<G.mode_gr;R++)for(w=0;w<G.channels_out;w++)$e+=v[R][w];for(G.nsPsy.pefirbuf[18]=$e,$e=G.nsPsy.pefirbuf[9],Te=0;Te<9;Te++)$e+=(G.nsPsy.pefirbuf[Te]+G.nsPsy.pefirbuf[18-Te])*c.fircoef[Te];for($e=670*5*G.mode_gr*G.channels_out/$e,R=0;R<G.mode_gr;R++)for(w=0;w<G.channels_out;w++)v[R][w]*=$e}if(G.iteration_loop.iteration_loop($,v,Q,j),m.format_bitstream($),he=m.copy_buffer(G,q,C,Z,1),$.bWriteVbrTag&&k.addVbrFrame($),$.analysis&&G.pinfo!=null){for(w=0;w<G.channels_out;w++){var je;for(je=0;je<f;je++)G.pinfo.pcmdata[w][je]=G.pinfo.pcmdata[w][je+$.framesize];for(je=f;je<1600;je++)G.pinfo.pcmdata[w][je]=A[w][je-f]}x.set_frame_pinfo($,j)}return E(G),he}}return R1=c,R1}var e4=qt,w3=e4.Util,x3=e4.new_float,Xt=br();function tA(){var t=x3(Xt.BLKSIZE),e=x3(Xt.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 f=i+a;d=4;do{var p,m,y,k,x,_,g;g=d>>1,k=d,x=d<<1,_=x+k,d=x<<1,l=i,u=l+g;do{var E,h,$,O;h=o[l+0]-o[l+k],E=o[l+0]+o[l+k],O=o[l+x]-o[l+_],$=o[l+x]+o[l+_],o[l+x]=E-$,o[l+0]=E+$,o[l+_]=h-O,o[l+k]=h+O,h=o[u+0]-o[u+k],E=o[u+0]+o[u+k],O=w3.SQRT2*o[u+_],$=w3.SQRT2*o[u+x],o[u+x]=E-$,o[u+0]=E+$,o[u+_]=h-O,o[u+k]=h+O,u+=d,l+=d}while(l<f);for(m=r[c+0],p=r[c+1],y=1;y<g;y++){var L,q;L=1-2*p*p,q=2*p*m,l=i+y,u=i+k-y;do{var C,Z,he,E,h,z,$,b,O,j;Z=q*o[l+k]-L*o[u+k],C=L*o[l+k]+q*o[u+k],h=o[l+0]-C,E=o[l+0]+C,z=o[u+0]-Z,he=o[u+0]+Z,Z=q*o[l+_]-L*o[u+_],C=L*o[l+_]+q*o[u+_],O=o[l+x]-C,$=o[l+x]+C,j=o[u+x]-Z,b=o[u+x]+Z,Z=p*$-m*j,C=m*$+p*j,o[l+x]=E-C,o[l+0]=E+C,o[u+_]=z-Z,o[u+k]=z+Z,Z=m*b-p*O,C=p*b+m*O,o[u+x]=he-C,o[u+0]=he+C,o[l+_]=h-Z,o[l+k]=h+Z,u+=d,l+=d}while(l<f);L=m,m=L*r[c+0]-p*r[c+1],p=L*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=Xt.BLKSIZE_s/2,f=65535&576/3*(l+1),p=Xt.BLKSIZE_s/8-1;do{var m,y,k,x,_,g=s[p<<2]&255;m=e[g]*c[a][d+g+f],_=e[127-g]*c[a][d+g+f+128],y=m-_,m=m+_,k=e[g+64]*c[a][d+g+f+64],_=e[63-g]*c[a][d+g+f+192],x=k-_,k=k+_,u-=4,i[l][u+0]=m+k,i[l][u+2]=m-k,i[l][u+1]=y+x,i[l][u+3]=y-x,m=e[g+1]*c[a][d+g+f+1],_=e[126-g]*c[a][d+g+f+129],y=m-_,m=m+_,k=e[g+65]*c[a][d+g+f+65],_=e[62-g]*c[a][d+g+f+193],x=k-_,k=k+_,i[l][u+Xt.BLKSIZE_s/2+0]=m+k,i[l][u+Xt.BLKSIZE_s/2+2]=m-k,i[l][u+Xt.BLKSIZE_s/2+1]=y+x,i[l][u+Xt.BLKSIZE_s/2+3]=y-x}while(--p>=0);n(i[l],u,Xt.BLKSIZE_s/2)}},this.fft_long=function(o,i,a,c,d){var l=Xt.BLKSIZE/8-1,u=Xt.BLKSIZE/2;do{var f,p,m,y,k,x=s[l]&255;f=t[x]*c[a][d+x],k=t[x+512]*c[a][d+x+512],p=f-k,f=f+k,m=t[x+256]*c[a][d+x+256],k=t[x+768]*c[a][d+x+768],y=m-k,m=m+k,u-=4,i[u+0]=f+m,i[u+2]=f-m,i[u+1]=p+y,i[u+3]=p-y,f=t[x+1]*c[a][d+x+1],k=t[x+513]*c[a][d+x+513],p=f-k,f=f+k,m=t[x+257]*c[a][d+x+257],k=t[x+769]*c[a][d+x+769],y=m-k,m=m+k,i[u+Xt.BLKSIZE/2+0]=f+m,i[u+Xt.BLKSIZE/2+2]=f-m,i[u+Xt.BLKSIZE/2+1]=p+y,i[u+Xt.BLKSIZE/2+3]=p-y}while(--l>=0);n(i,u,Xt.BLKSIZE/2)},this.init_fft=function(o){for(var i=0;i<Xt.BLKSIZE;i++)t[i]=.42-.5*Math.cos(2*Math.PI*(i+.5)/Xt.BLKSIZE)+.08*Math.cos(4*Math.PI*(i+.5)/Xt.BLKSIZE);for(var i=0;i<Xt.BLKSIZE_s/2;i++)e[i]=.5*(1-Math.cos(2*Math.PI*(i+.5)/Xt.BLKSIZE_s))}}var rA=tA,rs=qt,ki=rs.VbrMode,S3=rs.Float,$i=rs.ShortBlock,jr=rs.Util,nA=rs.Arrays,Kt=rs.new_float,dn=rs.new_float_n,ko=rs.new_int,et=rs.assert,sA=rA,ae=br();function oA(){var t=tc,e=new sA,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,f=.3,p=3.5,m=21,y=.2302585093;function k(P){return P}function x(P,M){for(var V=0,U=0;U<ae.BLKSIZE/2;++U)V+=P[U]*M.ATH.eql_w[U];return V*=c,V}function _(P,M,V,U,J,D,Y,te,X,oe,re){var ie=P.internal_flags;if(X<2)e.fft_long(ie,U[J],X,oe,re),e.fft_short(ie,D[Y],X,oe,re);else if(X==2){for(var ve=ae.BLKSIZE-1;ve>=0;--ve){var Ve=U[J+0][ve],fe=U[J+1][ve];U[J+0][ve]=(Ve+fe)*jr.SQRT2*.5,U[J+1][ve]=(Ve-fe)*jr.SQRT2*.5}for(var Le=2;Le>=0;--Le)for(var ve=ae.BLKSIZE_s-1;ve>=0;--ve){var Ve=D[Y+0][Le][ve],fe=D[Y+1][Le][ve];D[Y+0][Le][ve]=(Ve+fe)*jr.SQRT2*.5,D[Y+1][Le][ve]=(Ve-fe)*jr.SQRT2*.5}}M[0]=U[J+0][0],M[0]*=M[0];for(var ve=ae.BLKSIZE/2-1;ve>=0;--ve){var ne=U[J+0][ae.BLKSIZE/2-ve],Re=U[J+0][ae.BLKSIZE/2+ve];M[ae.BLKSIZE/2-ve]=(ne*ne+Re*Re)*.5}for(var Le=2;Le>=0;--Le){V[Le][0]=D[Y+0][Le][0],V[Le][0]*=V[Le][0];for(var ve=ae.BLKSIZE_s/2-1;ve>=0;--ve){var ne=D[Y+0][Le][ae.BLKSIZE_s/2-ve],Re=D[Y+0][Le][ae.BLKSIZE_s/2+ve];V[Le][ae.BLKSIZE_s/2-ve]=(ne*ne+Re*Re)*.5}}{for(var rt=0,ve=11;ve<ae.HBLKSIZE;ve++)rt+=M[ve];ie.tot_ener[X]=rt}if(P.analysis){for(var ve=0;ve<ae.HBLKSIZE;ve++)ie.pinfo.energy[te][X][ve]=ie.pinfo.energy_save[X][ve],ie.pinfo.energy_save[X][ve]=M[ve];ie.pinfo.pe[te][X]=ie.pe[X]}P.athaa_loudapprox==2&&X<2&&(ie.loudness_sq[te][X]=ie.loudness_sq_save[X],ie.loudness_sq_save[X]=x(M,ie))}var g=8,E=23,h=15,$,O,L,q=[1,.79433,.63096,.63096,.63096,.63096,.63096,.25119,.11749];function C(){$=Math.pow(10,(g+1)/16),O=Math.pow(10,(E+1)/16),L=Math.pow(10,h/10)}var Z=[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],he=[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],z=[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(P,M,V,U,J,D){var Y;if(M>P)if(M<P*O)Y=M/P;else return P+M;else{if(P>=M*O)return P+M;Y=P/M}if(P+=M,U+3<=6){if(Y>=$)return P;var te=0|jr.FAST_LOG10_X(Y,16);return P*he[te]}var te=0|jr.FAST_LOG10_X(Y,16);if(D!=0?M=J.ATH.cb_s[V]*J.ATH.adjust:M=J.ATH.cb_l[V]*J.ATH.adjust,P<L*M){if(P>M){var X,oe;return X=1,te<=13&&(X=z[te]),oe=jr.FAST_LOG10_X(P/M,10/15),P*((Z[te]-X)*oe+X)}return te>13?P:P*z[te]}return P*Z[te]}var j=[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 A(P,M,V){var U;if(P<0&&(P=0),M<0&&(M=0),P<=0)return M;if(M<=0)return P;if(M>P?U=M/P:U=P/M,-2<=V&&V<=2){if(U>=$)return P+M;var J=0|jr.FAST_LOG10_X(U,16);return(P+M)*j[J]}return U<O?P+M:(P<M&&(P=M),P)}function G(P,M){var V=P.internal_flags;if(V.channels_out>1){for(var U=0;U<ae.SBMAX_l;U++){var J=V.thm[0].l[U],D=V.thm[1].l[U];V.thm[0].l[U]+=D*M,V.thm[1].l[U]+=J*M}for(var U=0;U<ae.SBMAX_s;U++)for(var Y=0;Y<3;Y++){var J=V.thm[0].s[U][Y],D=V.thm[1].s[U][Y];V.thm[0].s[U][Y]+=D*M,V.thm[1].s[U][Y]+=J*M}}}function F(P){for(var M=0;M<ae.SBMAX_l;M++)if(!(P.thm[0].l[M]>1.58*P.thm[1].l[M]||P.thm[1].l[M]>1.58*P.thm[0].l[M])){var V=P.mld_l[M]*P.en[3].l[M],U=Math.max(P.thm[2].l[M],Math.min(P.thm[3].l[M],V));V=P.mld_l[M]*P.en[2].l[M];var J=Math.max(P.thm[3].l[M],Math.min(P.thm[2].l[M],V));P.thm[2].l[M]=U,P.thm[3].l[M]=J}for(var M=0;M<ae.SBMAX_s;M++)for(var D=0;D<3;D++)if(!(P.thm[0].s[M][D]>1.58*P.thm[1].s[M][D]||P.thm[1].s[M][D]>1.58*P.thm[0].s[M][D])){var V=P.mld_s[M]*P.en[3].s[M][D],U=Math.max(P.thm[2].s[M][D],Math.min(P.thm[3].s[M][D],V));V=P.mld_s[M]*P.en[2].s[M][D];var J=Math.max(P.thm[3].s[M][D],Math.min(P.thm[2].s[M][D],V));P.thm[2].s[M][D]=U,P.thm[3].s[M][D]=J}}function Q(P,M,V){var U=M,J=Math.pow(10,V);M*=2,U*=2;for(var D=0;D<ae.SBMAX_l;D++){var Y,te,X,oe;if(oe=P.ATH.cb_l[P.bm_l[D]]*J,Y=Math.min(Math.max(P.thm[0].l[D],oe),Math.max(P.thm[1].l[D],oe)),te=Math.max(P.thm[2].l[D],oe),X=Math.max(P.thm[3].l[D],oe),Y*M<te+X){var re=Y*U/(te+X);te*=re,X*=re}P.thm[2].l[D]=Math.min(te,P.thm[2].l[D]),P.thm[3].l[D]=Math.min(X,P.thm[3].l[D])}J*=ae.BLKSIZE_s/ae.BLKSIZE;for(var D=0;D<ae.SBMAX_s;D++)for(var ie=0;ie<3;ie++){var Y,te,X,oe;if(oe=P.ATH.cb_s[P.bm_s[D]]*J,Y=Math.min(Math.max(P.thm[0].s[D][ie],oe),Math.max(P.thm[1].s[D][ie],oe)),te=Math.max(P.thm[2].s[D][ie],oe),X=Math.max(P.thm[3].s[D][ie],oe),Y*M<te+X){var re=Y*M/(te+X);te*=re,X*=re}P.thm[2].s[D][ie]=Math.min(P.thm[2].s[D][ie],te),P.thm[3].s[D][ie]=Math.min(P.thm[3].s[D][ie],X)}}function B(P,M,V,U,J){var D,Y,te=0,X=0;for(D=Y=0;D<ae.SBMAX_s;++Y,++D){for(var oe=P.bo_s[D],re=P.npart_s,ie=oe<re?oe:re;Y<ie;)et(M[Y]>=0),et(V[Y]>=0),te+=M[Y],X+=V[Y],Y++;if(P.en[U].s[D][J]=te,P.thm[U].s[D][J]=X,Y>=re){++D;break}et(M[Y]>=0),et(V[Y]>=0);{var ve=P.PSY.bo_s_weight[D],Ve=1-ve;te=ve*M[Y],X=ve*V[Y],P.en[U].s[D][J]+=te,P.thm[U].s[D][J]+=X,te=Ve*M[Y],X=Ve*V[Y]}}for(;D<ae.SBMAX_s;++D)P.en[U].s[D][J]=0,P.thm[U].s[D][J]=0}function T(P,M,V,U){var J,D,Y=0,te=0;for(J=D=0;J<ae.SBMAX_l;++D,++J){for(var X=P.bo_l[J],oe=P.npart_l,re=X<oe?X:oe;D<re;)et(M[D]>=0),et(V[D]>=0),Y+=M[D],te+=V[D],D++;if(P.en[U].l[J]=Y,P.thm[U].l[J]=te,D>=oe){++J;break}et(M[D]>=0),et(V[D]>=0);{var ie=P.PSY.bo_l_weight[J],ve=1-ie;Y=ie*M[D],te=ie*V[D],P.en[U].l[J]+=Y,P.thm[U].l[J]+=te,Y=ve*M[D],te=ve*V[D]}}for(;J<ae.SBMAX_l;++J)P.en[U].l[J]=0,P.thm[U].l[J]=0}function v(P,M,V,U,J,D){var Y=P.internal_flags,te,X;for(X=te=0;X<Y.npart_s;++X){for(var oe=0,re=Y.numlines_s[X],ie=0;ie<re;++ie,++te){var ve=M[D][te];oe+=ve}V[X]=oe}for(et(X==Y.npart_s),te=X=0;X<Y.npart_s;X++){var Ve=Y.s3ind_s[X][0],fe=Y.s3_ss[te++]*V[Ve];for(++Ve;Ve<=Y.s3ind_s[X][1];)fe+=Y.s3_ss[te]*V[Ve],++te,++Ve;{var Le=o*Y.nb_s1[J][X];U[X]=Math.min(fe,Le)}if(Y.blocktype_old[J&1]==ae.SHORT_TYPE){var Le=i*Y.nb_s2[J][X],ne=U[X];U[X]=Math.min(Le,ne)}Y.nb_s2[J][X]=Y.nb_s1[J][X],Y.nb_s1[J][X]=fe,et(U[X]>=0)}for(;X<=ae.CBANDS;++X)V[X]=0,U[X]=0}function w(P,M,V,U){var J=P.internal_flags;P.short_blocks==$i.short_block_coupled&&!(M[0]!=0&&M[1]!=0)&&(M[0]=M[1]=0);for(var D=0;D<J.channels_out;D++)U[D]=ae.NORM_TYPE,P.short_blocks==$i.short_block_dispensed&&(M[D]=1),P.short_blocks==$i.short_block_forced&&(M[D]=0),M[D]!=0?(et(J.blocktype_old[D]!=ae.START_TYPE),J.blocktype_old[D]==ae.SHORT_TYPE&&(U[D]=ae.STOP_TYPE)):(U[D]=ae.SHORT_TYPE,J.blocktype_old[D]==ae.NORM_TYPE&&(J.blocktype_old[D]=ae.START_TYPE),J.blocktype_old[D]==ae.STOP_TYPE&&(J.blocktype_old[D]=ae.SHORT_TYPE)),V[D]=J.blocktype_old[D],J.blocktype_old[D]=U[D]}function R(P,M,V){return V>=1?P:V<=0?M:M>0?Math.pow(P/M,V)*M:0}var N=[11.8,13.6,17.2,32,46.5,51.3,57.5,67.1,71.5,84.6,97.6,130];function K(P,M){for(var V=309.07,U=0;U<ae.SBMAX_s-1;U++)for(var J=0;J<3;J++){var D=P.thm.s[U][J];if(D>0){var Y=D*M,te=P.en.s[U][J];te>Y&&(te>Y*1e10?V+=N[U]*(10*r):V+=N[U]*jr.FAST_LOG10(te/Y))}}return V}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 H(P,M){for(var V=281.0575,U=0;U<ae.SBMAX_l-1;U++){var J=P.thm.l[U];if(J>0){var D=J*M,Y=P.en.l[U];Y>D&&(Y>D*1e10?V+=se[U]*(10*r):V+=se[U]*jr.FAST_LOG10(Y/D))}}return V}function ee(P,M,V,U,J){var D,Y;for(D=Y=0;D<P.npart_l;++D){var te=0,X=0,oe;for(oe=0;oe<P.numlines_l[D];++oe,++Y){var re=M[Y];te+=re,X<re&&(X=re)}V[D]=te,U[D]=X,J[D]=te*P.rnumlines_l[D],et(P.rnumlines_l[D]>=0),et(V[D]>=0),et(U[D]>=0),et(J[D]>=0)}}function de(P,M,V,U){var J=q.length-1,D=0,Y=V[D]+V[D+1];if(Y>0){var te=M[D];te<M[D+1]&&(te=M[D+1]),et(P.numlines_l[D]+P.numlines_l[D+1]-1>0),Y=20*(te*2-Y)/(Y*(P.numlines_l[D]+P.numlines_l[D+1]-1));var X=0|Y;X>J&&(X=J),U[D]=X}else U[D]=0;for(D=1;D<P.npart_l-1;D++)if(Y=V[D-1]+V[D]+V[D+1],Y>0){var te=M[D-1];te<M[D]&&(te=M[D]),te<M[D+1]&&(te=M[D+1]),et(P.numlines_l[D-1]+P.numlines_l[D]+P.numlines_l[D+1]-1>0),Y=20*(te*3-Y)/(Y*(P.numlines_l[D-1]+P.numlines_l[D]+P.numlines_l[D+1]-1));var X=0|Y;X>J&&(X=J),U[D]=X}else U[D]=0;if(et(D==P.npart_l-1),Y=V[D-1]+V[D],Y>0){var te=M[D-1];te<M[D]&&(te=M[D]),et(P.numlines_l[D-1]+P.numlines_l[D]-1>0),Y=20*(te*2-Y)/(Y*(P.numlines_l[D-1]+P.numlines_l[D]-1));var X=0|Y;X>J&&(X=J),U[D]=X}else U[D]=0;et(D==P.npart_l-1)}var _e=[-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(P,M,V,U,J,D,Y,te,X,oe){var re=P.internal_flags,ie=dn([2,ae.BLKSIZE]),ve=dn([2,3,ae.BLKSIZE_s]),Ve=Kt(ae.CBANDS+1),fe=Kt(ae.CBANDS+1),Le=Kt(ae.CBANDS+2),ne=ko(2),Re=ko(2),rt,pe,Oe,me,qe,It,xe,Je,st=dn([2,576]),Ct,Zr=ko(ae.CBANDS+2),Wt=ko(ae.CBANDS+2);for(nA.fill(Wt,0),rt=re.channels_out,P.mode==t.JOINT_STEREO&&(rt=4),P.VBR==ki.vbr_off?Ct=re.ResvMax==0?0:re.ResvSize/re.ResvMax*.5:P.VBR==ki.vbr_rh||P.VBR==ki.vbr_mtrh||P.VBR==ki.vbr_mt?Ct=.6:Ct=1,pe=0;pe<re.channels_out;pe++){var jt=M[pe],Er=V+576-350-m+192;for(me=0;me<576;me++){var Br,Vr;for(Br=jt[Er+me+10],Vr=0,qe=0;qe<(m-1)/2-1;qe+=2)Br+=_e[qe]*(jt[Er+me+qe]+jt[Er+me+m-qe]),Vr+=_e[qe+1]*(jt[Er+me+qe+1]+jt[Er+me+m-qe-1]);st[pe][me]=Br+Vr}J[U][pe].en.assign(re.en[pe]),J[U][pe].thm.assign(re.thm[pe]),rt>2&&(D[U][pe].en.assign(re.en[pe+2]),D[U][pe].thm.assign(re.thm[pe+2]))}for(pe=0;pe<rt;pe++){var mn,gn,hr=Kt(12),Mn=[0,0,0,0],Oo=Kt(12),Hu=1,m0,g0=Kt(ae.CBANDS),_0=Kt(ae.CBANDS),Dt=[0,0,0,0],b0=Kt(ae.HBLKSIZE),y0=dn([3,ae.HBLKSIZE_s]);for(et(re.npart_s<=ae.CBANDS),et(re.npart_l<=ae.CBANDS),me=0;me<3;me++)hr[me]=re.nsPsy.last_en_subshort[pe][me+6],et(re.nsPsy.last_en_subshort[pe][me+4]>0),Oo[me]=hr[me]/re.nsPsy.last_en_subshort[pe][me+4],Mn[0]+=hr[me];if(pe==2)for(me=0;me<576;me++){var Uu,Gu;Uu=st[0][me],Gu=st[1][me],st[0][me]=Uu+Gu,st[1][me]=Uu-Gu}{var v0=st[pe&1],Oi=0;for(me=0;me<9;me++){for(var kx=Oi+64,sr=1;Oi<kx;Oi++)sr<Math.abs(v0[Oi])&&(sr=Math.abs(v0[Oi]));re.nsPsy.last_en_subshort[pe][me]=hr[me+3]=sr,Mn[1+me/3]+=sr,sr>hr[me+3-2]?(et(hr[me+3-2]>0),sr=sr/hr[me+3-2]):hr[me+3-2]>sr*10?sr=hr[me+3-2]/(sr*10):sr=0,Oo[me+3]=sr}}if(P.analysis){var Wu=Oo[0];for(me=1;me<12;me++)Wu<Oo[me]&&(Wu=Oo[me]);re.pinfo.ers[U][pe]=re.pinfo.ers_save[pe],re.pinfo.ers_save[pe]=Wu}for(m0=pe==3?re.nsPsy.attackthre_s:re.nsPsy.attackthre,me=0;me<12;me++)Dt[me/3]==0&&Oo[me]>m0&&(Dt[me/3]=me%3+1);for(me=1;me<4;me++){var Yu;Mn[me-1]>Mn[me]?(et(Mn[me]>0),Yu=Mn[me-1]/Mn[me]):(et(Mn[me-1]>0),Yu=Mn[me]/Mn[me-1]),Yu<1.7&&(Dt[me]=0,me==1&&(Dt[0]=0))}for(Dt[0]!=0&&re.nsPsy.lastAttacks[pe]!=0&&(Dt[0]=0),(re.nsPsy.lastAttacks[pe]==3||Dt[0]+Dt[1]+Dt[2]+Dt[3]!=0)&&(Hu=0,Dt[1]!=0&&Dt[0]!=0&&(Dt[1]=0),Dt[2]!=0&&Dt[1]!=0&&(Dt[2]=0),Dt[3]!=0&&Dt[2]!=0&&(Dt[3]=0)),pe<2?Re[pe]=Hu:Hu==0&&(Re[0]=Re[1]=0),X[pe]=re.tot_ener[pe],gn=ve,mn=ie,_(P,b0,y0,mn,pe&1,gn,pe&1,U,pe,M,V),ee(re,b0,Ve,g0,_0),de(re,g0,_0,Zr),Je=0;Je<3;Je++){var Xu,Tr;for(v(P,y0,fe,Le,pe,Je),B(re,fe,Le,pe,Je),xe=0;xe<ae.SBMAX_s;xe++){if(Tr=re.thm[pe].s[xe][Je],Tr*=l,Dt[Je]>=2||Dt[Je+1]==1){var Ai=Je!=0?Je-1:2,sr=R(re.thm[pe].s[xe][Ai],Tr,u*Ct);Tr=Math.min(Tr,sr)}if(Dt[Je]==1){var Ai=Je!=0?Je-1:2,sr=R(re.thm[pe].s[xe][Ai],Tr,f*Ct);Tr=Math.min(Tr,sr)}else if(Je!=0&&Dt[Je-1]==3||Je==0&&re.nsPsy.lastAttacks[pe]==3){var Ai=Je!=2?Je+1:0,sr=R(re.thm[pe].s[xe][Ai],Tr,f*Ct);Tr=Math.min(Tr,sr)}Xu=hr[Je*3+3]+hr[Je*3+4]+hr[Je*3+5],hr[Je*3+5]*6<Xu&&(Tr*=.5,hr[Je*3+4]*6<Xu&&(Tr*=.5)),re.thm[pe].s[xe][Je]=Tr}}for(re.nsPsy.lastAttacks[pe]=Dt[2],It=0,Oe=0;Oe<re.npart_l;Oe++){for(var zs=re.s3ind[Oe][0],Ku=Ve[zs]*q[Zr[zs]],Ns=re.s3_ll[It++]*Ku;++zs<=re.s3ind[Oe][1];)Ku=Ve[zs]*q[Zr[zs]],Ns=b(Ns,re.s3_ll[It++]*Ku,zs,zs-Oe,re,0);Ns*=.158489319246111,re.blocktype_old[pe&1]==ae.SHORT_TYPE?Le[Oe]=Ns:Le[Oe]=R(Math.min(Ns,Math.min(n*re.nb_1[pe][Oe],s*re.nb_2[pe][Oe])),Ns,Ct),re.nb_2[pe][Oe]=re.nb_1[pe][Oe],re.nb_1[pe][Oe]=Ns}for(;Oe<=ae.CBANDS;++Oe)Ve[Oe]=0,Le[Oe]=0;T(re,Ve,Le,pe)}if((P.mode==t.STEREO||P.mode==t.JOINT_STEREO)&&P.interChRatio>0&&G(P,P.interChRatio),P.mode==t.JOINT_STEREO){var Ju;F(re),Ju=P.msfix,Math.abs(Ju)>0&&Q(re,Ju,P.ATHlower*re.ATH.adjust)}for(w(P,Re,oe,ne),pe=0;pe<rt;pe++){var zi,Ni=0,cc,lc;pe>1?(zi=te,Ni=-2,cc=ae.NORM_TYPE,(oe[0]==ae.SHORT_TYPE||oe[1]==ae.SHORT_TYPE)&&(cc=ae.SHORT_TYPE),lc=D[U][pe-2]):(zi=Y,Ni=0,cc=oe[pe],lc=J[U][pe]),cc==ae.SHORT_TYPE?zi[Ni+pe]=K(lc,re.masking_lower):zi[Ni+pe]=H(lc,re.masking_lower),P.analysis&&(re.pinfo.pe[U][pe]=zi[Ni+pe])}return 0};function ke(P,M,V,U,J,D,Y,te){var X=P.internal_flags;if(U<2)e.fft_long(X,Y[te],U,M,V);else if(U==2)for(var oe=ae.BLKSIZE-1;oe>=0;--oe){var re=Y[te+0][oe],ie=Y[te+1][oe];Y[te+0][oe]=(re+ie)*jr.SQRT2*.5,Y[te+1][oe]=(re-ie)*jr.SQRT2*.5}D[0]=Y[te+0][0],D[0]*=D[0];for(var oe=ae.BLKSIZE/2-1;oe>=0;--oe){var ve=Y[te+0][ae.BLKSIZE/2-oe],Ve=Y[te+0][ae.BLKSIZE/2+oe];D[ae.BLKSIZE/2-oe]=(ve*ve+Ve*Ve)*.5}{for(var fe=0,oe=11;oe<ae.HBLKSIZE;oe++)fe+=D[oe];X.tot_ener[U]=fe}if(P.analysis){for(var oe=0;oe<ae.HBLKSIZE;oe++)X.pinfo.energy[J][U][oe]=X.pinfo.energy_save[U][oe],X.pinfo.energy_save[U][oe]=D[oe];X.pinfo.pe[J][U]=X.pe[U]}}function Ie(P,M,V,U,J,D,Y,te){var X=P.internal_flags;if(J==0&&U<2&&e.fft_short(X,Y[te],U,M,V),U==2)for(var oe=ae.BLKSIZE_s-1;oe>=0;--oe){var re=Y[te+0][J][oe],ie=Y[te+1][J][oe];Y[te+0][J][oe]=(re+ie)*jr.SQRT2*.5,Y[te+1][J][oe]=(re-ie)*jr.SQRT2*.5}D[J][0]=Y[te+0][J][0],D[J][0]*=D[J][0];for(var oe=ae.BLKSIZE_s/2-1;oe>=0;--oe){var ve=Y[te+0][J][ae.BLKSIZE_s/2-oe],Ve=Y[te+0][J][ae.BLKSIZE_s/2+oe];D[J][ae.BLKSIZE_s/2-oe]=(ve*ve+Ve*Ve)*.5}}function Te(P,M,V,U){var J=P.internal_flags;P.athaa_loudapprox==2&&V<2&&(J.loudness_sq[M][V]=J.loudness_sq_save[V],J.loudness_sq_save[V]=x(U,J))}var $e=[-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 je(P,M,V,U,J,D,Y,te,X,oe){for(var re=dn([2,576]),ie=P.internal_flags,ve=ie.channels_out,Ve=P.mode==t.JOINT_STEREO?4:ve,fe=0;fe<ve;fe++){firbuf=M[fe];for(var Le=V+576-350-m+192,ne=0;ne<576;ne++){var Re,rt;Re=firbuf[Le+ne+10],rt=0;for(var pe=0;pe<(m-1)/2-1;pe+=2)Re+=$e[pe]*(firbuf[Le+ne+pe]+firbuf[Le+ne+m-pe]),rt+=$e[pe+1]*(firbuf[Le+ne+pe+1]+firbuf[Le+ne+m-pe-1]);re[fe][ne]=Re+rt}J[U][fe].en.assign(ie.en[fe]),J[U][fe].thm.assign(ie.thm[fe]),Ve>2&&(D[U][fe].en.assign(ie.en[fe+2]),D[U][fe].thm.assign(ie.thm[fe+2]))}for(var fe=0;fe<Ve;fe++){var Oe=Kt(12),me=Kt(12),qe=[0,0,0,0],It=re[fe&1],xe=0,Je=fe==3?ie.nsPsy.attackthre_s:ie.nsPsy.attackthre,st=1;if(fe==2)for(var ne=0,pe=576;pe>0;++ne,--pe){var Ct=re[0][ne],Zr=re[1][ne];re[0][ne]=Ct+Zr,re[1][ne]=Ct-Zr}for(var ne=0;ne<3;ne++)me[ne]=ie.nsPsy.last_en_subshort[fe][ne+6],et(ie.nsPsy.last_en_subshort[fe][ne+4]>0),Oe[ne]=me[ne]/ie.nsPsy.last_en_subshort[fe][ne+4],qe[0]+=me[ne];for(var ne=0;ne<9;ne++){for(var Wt=xe+64,jt=1;xe<Wt;xe++)jt<Math.abs(It[xe])&&(jt=Math.abs(It[xe]));ie.nsPsy.last_en_subshort[fe][ne]=me[ne+3]=jt,qe[1+ne/3]+=jt,jt>me[ne+3-2]?(et(me[ne+3-2]>0),jt=jt/me[ne+3-2]):me[ne+3-2]>jt*10?jt=me[ne+3-2]/(jt*10):jt=0,Oe[ne+3]=jt}for(var ne=0;ne<3;++ne){var Er=me[ne*3+3]+me[ne*3+4]+me[ne*3+5],Br=1;me[ne*3+5]*6<Er&&(Br*=.5,me[ne*3+4]*6<Er&&(Br*=.5)),te[fe][ne]=Br}if(P.analysis){for(var Vr=Oe[0],ne=1;ne<12;ne++)Vr<Oe[ne]&&(Vr=Oe[ne]);ie.pinfo.ers[U][fe]=ie.pinfo.ers_save[fe],ie.pinfo.ers_save[fe]=Vr}for(var ne=0;ne<12;ne++)X[fe][ne/3]==0&&Oe[ne]>Je&&(X[fe][ne/3]=ne%3+1);for(var ne=1;ne<4;ne++){var mn=qe[ne-1],gn=qe[ne],hr=Math.max(mn,gn);hr<4e4&&mn<1.7*gn&&gn<1.7*mn&&(ne==1&&X[fe][0]<=X[fe][ne]&&(X[fe][0]=0),X[fe][ne]=0)}X[fe][0]<=ie.nsPsy.lastAttacks[fe]&&(X[fe][0]=0),(ie.nsPsy.lastAttacks[fe]==3||X[fe][0]+X[fe][1]+X[fe][2]+X[fe][3]!=0)&&(st=0,X[fe][1]!=0&&X[fe][0]!=0&&(X[fe][1]=0),X[fe][2]!=0&&X[fe][1]!=0&&(X[fe][2]=0),X[fe][3]!=0&&X[fe][2]!=0&&(X[fe][3]=0)),fe<2?oe[fe]=st:st==0&&(oe[0]=oe[1]=0),Y[fe]=ie.tot_ener[fe]}}function Tt(P,M,V){if(V==0)for(var U=0;U<P.npart_s;U++)P.nb_s2[M][U]=P.nb_s1[M][U],P.nb_s1[M][U]=0}function Kr(P,M){for(var V=0;V<P.npart_l;V++)P.nb_2[M][V]=P.nb_1[M][V],P.nb_1[M][V]=0}function S(P,M,V,U){var J=q.length-1,D=0,Y=V[D]+V[D+1];if(Y>0){var te=M[D];te<M[D+1]&&(te=M[D+1]),et(P.numlines_s[D]+P.numlines_s[D+1]-1>0),Y=20*(te*2-Y)/(Y*(P.numlines_s[D]+P.numlines_s[D+1]-1));var X=0|Y;X>J&&(X=J),U[D]=X}else U[D]=0;for(D=1;D<P.npart_s-1;D++)if(Y=V[D-1]+V[D]+V[D+1],et(D+1<P.npart_s),Y>0){var te=M[D-1];te<M[D]&&(te=M[D]),te<M[D+1]&&(te=M[D+1]),et(P.numlines_s[D-1]+P.numlines_s[D]+P.numlines_s[D+1]-1>0),Y=20*(te*3-Y)/(Y*(P.numlines_s[D-1]+P.numlines_s[D]+P.numlines_s[D+1]-1));var X=0|Y;X>J&&(X=J),U[D]=X}else U[D]=0;if(et(D==P.npart_s-1),Y=V[D-1]+V[D],Y>0){var te=M[D-1];te<M[D]&&(te=M[D]),et(P.numlines_s[D-1]+P.numlines_s[D]-1>0),Y=20*(te*2-Y)/(Y*(P.numlines_s[D-1]+P.numlines_s[D]-1));var X=0|Y;X>J&&(X=J),U[D]=X}else U[D]=0;et(D==P.npart_s-1)}function I(P,M,V,U,J,D){var Y=P.internal_flags,te=new float[ae.CBANDS],X=Kt(ae.CBANDS),oe,re,ie,ve=new int[ae.CBANDS];for(ie=re=0;ie<Y.npart_s;++ie){var Ve=0,fe=0,Le=Y.numlines_s[ie];for(oe=0;oe<Le;++oe,++re){var ne=M[D][re];Ve+=ne,fe<ne&&(fe=ne)}V[ie]=Ve,te[ie]=fe,X[ie]=Ve/Le,et(X[ie]>=0)}for(et(ie==Y.npart_s);ie<ae.CBANDS;++ie)te[ie]=0,X[ie]=0;for(S(Y,te,X,ve),re=ie=0;ie<Y.npart_s;ie++){var Re=Y.s3ind_s[ie][0],rt=Y.s3ind_s[ie][1],pe,Oe,me,qe,It;for(pe=ve[Re],Oe=1,qe=Y.s3_ss[re]*V[Re]*q[ve[Re]],++re,++Re;Re<=rt;)pe+=ve[Re],Oe+=1,me=Y.s3_ss[re]*V[Re]*q[ve[Re]],qe=A(qe,me,Re-ie),++re,++Re;pe=(1+2*pe)/(2*Oe),It=q[pe]*.5,qe*=It,U[ie]=qe,Y.nb_s2[J][ie]=Y.nb_s1[J][ie],Y.nb_s1[J][ie]=qe,me=te[ie],me*=Y.minval_s[ie],me*=It,U[ie]>me&&(U[ie]=me),Y.masking_lower>1&&(U[ie]*=Y.masking_lower),U[ie]>V[ie]&&(U[ie]=V[ie]),Y.masking_lower<1&&(U[ie]*=Y.masking_lower),et(U[ie]>=0)}for(;ie<ae.CBANDS;++ie)V[ie]=0,U[ie]=0}function Se(P,M,V,U,J){var D=Kt(ae.CBANDS),Y=Kt(ae.CBANDS),te=ko(ae.CBANDS+2),X;ee(P,M,V,D,Y),de(P,D,Y,te);var oe=0;for(X=0;X<P.npart_l;X++){var re,ie,ve,Ve,fe=P.s3ind[X][0],Le=P.s3ind[X][1],ne=0,Re=0;for(ne=te[fe],Re+=1,ie=P.s3_ll[oe]*V[fe]*q[te[fe]],++oe,++fe;fe<=Le;)ne+=te[fe],Re+=1,re=P.s3_ll[oe]*V[fe]*q[te[fe]],Ve=A(ie,re,fe-X),ie=Ve,++oe,++fe;if(ne=(1+2*ne)/(2*Re),ve=q[ne]*.5,ie*=ve,P.blocktype_old[J&1]==ae.SHORT_TYPE){var rt=n*P.nb_1[J][X];rt>0?U[X]=Math.min(ie,rt):U[X]=Math.min(ie,V[X]*f)}else{var pe=s*P.nb_2[J][X],Oe=n*P.nb_1[J][X],rt;pe<=0&&(pe=ie),Oe<=0&&(Oe=ie),P.blocktype_old[J&1]==ae.NORM_TYPE?rt=Math.min(Oe,pe):rt=Oe,U[X]=Math.min(ie,rt)}P.nb_2[J][X]=P.nb_1[J][X],P.nb_1[J][X]=ie,re=D[X],re*=P.minval_l[X],re*=ve,U[X]>re&&(U[X]=re),P.masking_lower>1&&(U[X]*=P.masking_lower),U[X]>V[X]&&(U[X]=V[X]),P.masking_lower<1&&(U[X]*=P.masking_lower),et(U[X]>=0)}for(;X<ae.CBANDS;++X)V[X]=0,U[X]=0}function Me(P,M){var V=P.internal_flags;P.short_blocks==$i.short_block_coupled&&!(M[0]!=0&&M[1]!=0)&&(M[0]=M[1]=0);for(var U=0;U<V.channels_out;U++)P.short_blocks==$i.short_block_dispensed&&(M[U]=1),P.short_blocks==$i.short_block_forced&&(M[U]=0)}function We(P,M,V){for(var U=P.internal_flags,J=0;J<U.channels_out;J++){var D=ae.NORM_TYPE;M[J]!=0?(et(U.blocktype_old[J]!=ae.START_TYPE),U.blocktype_old[J]==ae.SHORT_TYPE&&(D=ae.STOP_TYPE)):(D=ae.SHORT_TYPE,U.blocktype_old[J]==ae.NORM_TYPE&&(U.blocktype_old[J]=ae.START_TYPE),U.blocktype_old[J]==ae.STOP_TYPE&&(U.blocktype_old[J]=ae.SHORT_TYPE)),V[J]=U.blocktype_old[J],U.blocktype_old[J]=D}}function Ue(P,M,V,U,J,D,Y){for(var te=D*2,X=D>0?Math.pow(10,J):1,oe,re,ie=0;ie<Y;++ie){var ve=P[2][ie],Ve=P[3][ie],fe=M[0][ie],Le=M[1][ie],ne=M[2][ie],Re=M[3][ie];if(fe<=1.58*Le&&Le<=1.58*fe){var rt=V[ie]*Ve,pe=V[ie]*ve;re=Math.max(ne,Math.min(Re,rt)),oe=Math.max(Re,Math.min(ne,pe))}else re=ne,oe=Re;if(D>0){var Oe,me,qe=U[ie]*X;if(Oe=Math.min(Math.max(fe,qe),Math.max(Le,qe)),ne=Math.max(re,qe),Re=Math.max(oe,qe),me=ne+Re,me>0&&Oe*te<me){var It=Oe*te/me;ne*=It,Re*=It}re=Math.min(ne,re),oe=Math.min(Re,oe)}re>ve&&(re=ve),oe>Ve&&(oe=Ve),M[2][ie]=re,M[3][ie]=oe}}this.L3psycho_anal_vbr=function(P,M,V,U,J,D,Y,te,X,oe){var re=P.internal_flags,ie,ve,Ve=Kt(ae.HBLKSIZE),fe=dn([3,ae.HBLKSIZE_s]),Le=dn([2,ae.BLKSIZE]),ne=dn([2,3,ae.BLKSIZE_s]),Re=dn([4,ae.CBANDS]),rt=dn([4,ae.CBANDS]),pe=dn([4,3]),Oe=.6,me=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],qe=ko(2),It=P.mode==t.JOINT_STEREO?4:re.channels_out;je(P,M,V,U,J,D,X,pe,me,qe),Me(P,qe);{for(var xe=0;xe<It;xe++){var Je=xe&1;ie=Le,ke(P,M,V,xe,U,Ve,ie,Je),Te(P,U,xe,Ve),qe[Je]!=0?Se(re,Ve,Re[xe],rt[xe],xe):Kr(re,xe)}qe[0]+qe[1]==2&&P.mode==t.JOINT_STEREO&&Ue(Re,rt,re.mld_cb_l,re.ATH.cb_l,P.ATHlower*re.ATH.adjust,P.msfix,re.npart_l);for(var xe=0;xe<It;xe++){var Je=xe&1;qe[Je]!=0&&T(re,Re[xe],rt[xe],xe)}}{for(var st=0;st<3;st++){for(var xe=0;xe<It;++xe){var Je=xe&1;qe[Je]!=0?Tt(re,xe,st):(ve=ne,Ie(P,M,V,xe,st,fe,ve,Je),I(P,fe,Re[xe],rt[xe],xe,st))}qe[0]+qe[1]==0&&P.mode==t.JOINT_STEREO&&Ue(Re,rt,re.mld_cb_s,re.ATH.cb_s,P.ATHlower*re.ATH.adjust,P.msfix,re.npart_s);for(var xe=0;xe<It;++xe){var Je=xe&1;qe[Je]==0&&B(re,Re[xe],rt[xe],xe,st)}}for(var xe=0;xe<It;xe++){var Je=xe&1;if(qe[Je]==0)for(var Ct=0;Ct<ae.SBMAX_s;Ct++){for(var Zr=Kt(3),st=0;st<3;st++){var Wt=re.thm[xe].s[Ct][st];if(Wt*=l,me[xe][st]>=2||me[xe][st+1]==1){var jt=st!=0?st-1:2,Er=R(re.thm[xe].s[Ct][jt],Wt,u*Oe);Wt=Math.min(Wt,Er)}else if(me[xe][st]==1){var jt=st!=0?st-1:2,Er=R(re.thm[xe].s[Ct][jt],Wt,f*Oe);Wt=Math.min(Wt,Er)}else if(st!=0&&me[xe][st-1]==3||st==0&&re.nsPsy.lastAttacks[xe]==3){var jt=st!=2?st+1:0,Er=R(re.thm[xe].s[Ct][jt],Wt,f*Oe);Wt=Math.min(Wt,Er)}Wt*=pe[xe][st],Zr[st]=Wt}for(var st=0;st<3;st++)re.thm[xe].s[Ct][st]=Zr[st]}}}for(var xe=0;xe<It;xe++)re.nsPsy.lastAttacks[xe]=me[xe][2];We(P,qe,oe);for(var xe=0;xe<It;xe++){var Br,Vr,mn,gn;xe>1?(Br=te,Vr=-2,mn=ae.NORM_TYPE,(oe[0]==ae.SHORT_TYPE||oe[1]==ae.SHORT_TYPE)&&(mn=ae.SHORT_TYPE),gn=D[U][xe-2]):(Br=Y,Vr=0,mn=oe[xe],gn=J[U][xe]),mn==ae.SHORT_TYPE?Br[Vr+xe]=K(gn,re.masking_lower):Br[Vr+xe]=H(gn,re.masking_lower),P.analysis&&(re.pinfo.pe[U][xe]=Br[Vr+xe])}return 0};function Ce(P,M){var V=P,U;return V>=0?U=-V*27:U=V*M,U<=-72?0:Math.exp(U*y)}function Ae(P){var M=0,V=0;{var U=0,J,D;for(U=0;Ce(U,P)>1e-20;U-=1);for(J=U,D=0;Math.abs(D-J)>1e-12;)U=(D+J)/2,Ce(U,P)>0?D=U:J=U;M=J}{var U=0,J,D;for(U=0;Ce(U,P)>1e-20;U+=1);for(J=0,D=U;Math.abs(D-J)>1e-12;)U=(D+J)/2,Ce(U,P)>0?J=U:D=U;V=D}{var Y=0,te=1e3,X;for(X=0;X<=te;++X){var U=M+X*(V-M)/te,oe=Ce(U,P);Y+=oe}{var re=(te+1)/(Y*(V-M));return re}}}function tt(P){var M,V,U,J;return M=P,M>=0?M*=3:M*=1.5,M>=.5&&M<=2.5?(J=M-.5,V=8*(J*J-2*J)):V=0,M+=.474,U=15.811389+7.5*M-17.5*Math.sqrt(1+M*M),U<=-60?0:(M=Math.exp((V+U)*y),M/=.6609193,M)}function De(P){return P<0&&(P=0),P=P*.001,13*Math.atan(.76*P)+3.5*Math.atan(P*P/(7.5*7.5))}function we(P,M,V,U,J,D,Y,te,X,oe,re,ie){var ve=Kt(ae.CBANDS+1),Ve=te/(ie>15?2*576:2*192),fe=ko(ae.HBLKSIZE),Le;te/=X;var ne=0,Re=0;for(Le=0;Le<ae.CBANDS;Le++){var rt,pe;for(rt=De(te*ne),ve[Le]=te*ne,pe=ne;De(te*pe)-rt<a&&pe<=X/2;pe++);for(P[Le]=pe-ne,Re=Le+1;ne<pe;)et(ne<ae.HBLKSIZE),fe[ne++]=Le;if(ne>X/2){ne=X/2,++Le;break}}et(Le<ae.CBANDS),ve[Le]=te*ne;for(var Oe=0;Oe<ie;Oe++){var me,qe,It,xe,Je;It=oe[Oe],xe=oe[Oe+1],me=0|Math.floor(.5+re*(It-.5)),me<0&&(me=0),qe=0|Math.floor(.5+re*(xe-.5)),qe>X/2&&(qe=X/2),V[Oe]=(fe[me]+fe[qe])/2,M[Oe]=fe[qe];var st=Ve*xe;Y[Oe]=(st-ve[M[Oe]])/(ve[M[Oe]+1]-ve[M[Oe]]),Y[Oe]<0?Y[Oe]=0:Y[Oe]>1&&(Y[Oe]=1),Je=De(te*oe[Oe]*re),Je=Math.min(Je,15.5)/15.5,D[Oe]=Math.pow(10,1.25*(1-Math.cos(Math.PI*Je))-2.5)}ne=0;for(var Ct=0;Ct<Re;Ct++){var Zr=P[Ct],rt,Wt;rt=De(te*ne),Wt=De(te*(ne+Zr-1)),U[Ct]=.5*(rt+Wt),rt=De(te*(ne-.5)),Wt=De(te*(ne+Zr-.5)),J[Ct]=Wt-rt,ne+=Zr}return Re}function xt(P,M,V,U,J,D){var Y=dn([ae.CBANDS,ae.CBANDS]),te,X=0;if(D)for(var oe=0;oe<M;oe++)for(te=0;te<M;te++){var re=tt(V[oe]-V[te])*U[te];Y[oe][te]=re*J[oe]}else for(te=0;te<M;te++)for(var ie=15+Math.min(21/V[te],12),ve=Ae(ie),oe=0;oe<M;oe++){var re=ve*Ce(V[oe]-V[te],ie)*U[te];Y[oe][te]=re*J[oe]}for(var oe=0;oe<M;oe++){for(te=0;te<M&&!(Y[oe][te]>0);te++);for(P[oe][0]=te,te=M-1;te>0&&!(Y[oe][te]>0);te--);P[oe][1]=te,X+=P[oe][1]-P[oe][0]+1}for(var Ve=Kt(X),fe=0,oe=0;oe<M;oe++)for(te=P[oe][0];te<=P[oe][1];te++)Ve[fe++]=Y[oe][te];return Ve}function Jt(P){var M=De(P);return M=Math.min(M,15.5)/15.5,Math.pow(10,1.25*(1-Math.cos(Math.PI*M))-2.5)}this.psymodel_init=function(P){var M=P.internal_flags,V,U=!0,J=13,D=24,Y=0,te=0,X=-8.25,oe=-4.5,re=Kt(ae.CBANDS),ie=Kt(ae.CBANDS),ve=Kt(ae.CBANDS),Ve=P.out_samplerate;switch(P.experimentalZ){default:case 0:U=!0;break;case 1:U=!(P.VBR==ki.vbr_mtrh||P.VBR==ki.vbr_mt);break;case 2:U=!1;break;case 3:J=8,Y=-1.75,te=-.0125,X=-8.25,oe=-2.25;break}for(M.ms_ener_ratio_old=.25,M.blocktype_old[0]=M.blocktype_old[1]=ae.NORM_TYPE,V=0;V<4;++V){for(var ne=0;ne<ae.CBANDS;++ne)M.nb_1[V][ne]=1e20,M.nb_2[V][ne]=1e20,M.nb_s1[V][ne]=M.nb_s2[V][ne]=1;for(var fe=0;fe<ae.SBMAX_l;fe++)M.en[V].l[fe]=1e20,M.thm[V].l[fe]=1e20;for(var ne=0;ne<3;++ne){for(var fe=0;fe<ae.SBMAX_s;fe++)M.en[V].s[fe][ne]=1e20,M.thm[V].s[fe][ne]=1e20;M.nsPsy.lastAttacks[V]=0}for(var ne=0;ne<9;ne++)M.nsPsy.last_en_subshort[V][ne]=10}for(M.loudness_sq_save[0]=M.loudness_sq_save[1]=0,M.npart_l=we(M.numlines_l,M.bo_l,M.bm_l,re,ie,M.mld_l,M.PSY.bo_l_weight,Ve,ae.BLKSIZE,M.scalefac_band.l,ae.BLKSIZE/(2*576),ae.SBMAX_l),et(M.npart_l<ae.CBANDS),V=0;V<M.npart_l;V++){var Le=Y;re[V]>=J&&(Le=te*(re[V]-J)/(D-J)+Y*(D-re[V])/(D-J)),ve[V]=Math.pow(10,Le/10),M.numlines_l[V]>0?M.rnumlines_l[V]=1/M.numlines_l[V]:M.rnumlines_l[V]=0}M.s3_ll=xt(M.s3ind,M.npart_l,re,ie,ve,U);var ne=0;for(V=0;V<M.npart_l;V++){var Re;Re=S3.MAX_VALUE;for(var rt=0;rt<M.numlines_l[V];rt++,ne++){var pe=Ve*ne/(1e3*ae.BLKSIZE),Oe;Oe=this.ATHformula(pe*1e3,P)-20,Oe=Math.pow(10,.1*Oe),Oe*=M.numlines_l[V],Re>Oe&&(Re=Oe)}M.ATH.cb_l[V]=Re,Re=-20+re[V]*20/10,Re>6&&(Re=100),Re<-15&&(Re=-15),Re-=8,M.minval_l[V]=Math.pow(10,Re/10)*M.numlines_l[V]}for(M.npart_s=we(M.numlines_s,M.bo_s,M.bm_s,re,ie,M.mld_s,M.PSY.bo_s_weight,Ve,ae.BLKSIZE_s,M.scalefac_band.s,ae.BLKSIZE_s/(2*192),ae.SBMAX_s),et(M.npart_s<ae.CBANDS),ne=0,V=0;V<M.npart_s;V++){var Re,Le=X;re[V]>=J&&(Le=oe*(re[V]-J)/(D-J)+X*(D-re[V])/(D-J)),ve[V]=Math.pow(10,Le/10),Re=S3.MAX_VALUE;for(var rt=0;rt<M.numlines_s[V];rt++,ne++){var pe=Ve*ne/(1e3*ae.BLKSIZE_s),Oe;Oe=this.ATHformula(pe*1e3,P)-20,Oe=Math.pow(10,.1*Oe),Oe*=M.numlines_s[V],Re>Oe&&(Re=Oe)}M.ATH.cb_s[V]=Re,Re=-7+re[V]*7/12,re[V]>12&&(Re*=1+Math.log(1+Re)*3.1),re[V]<12&&(Re*=1+Math.log(1-Re)*2.3),Re<-15&&(Re=-15),Re-=8,M.minval_s[V]=Math.pow(10,Re/10)*M.numlines_s[V]}M.s3_ss=xt(M.s3ind_s,M.npart_s,re,ie,ve,U),C(),e.init_fft(M),M.decay=Math.exp(-1*r/(d*Ve/192));{var me;me=p,P.exp_nspsytune&2&&(me=1),Math.abs(P.msfix)>0&&(me=P.msfix),P.msfix=me;for(var qe=0;qe<M.npart_l;qe++)M.s3ind[qe][1]>M.npart_l-1&&(M.s3ind[qe][1]=M.npart_l-1)}var It=576*M.mode_gr/Ve;if(M.ATH.decay=Math.pow(10,-12/10*It),M.ATH.adjust=.01,M.ATH.adjustLimit=1,et(M.bo_l[ae.SBMAX_l-1]<=M.npart_l),et(M.bo_s[ae.SBMAX_s-1]<=M.npart_s),P.ATHtype!=-1){var pe,xe=P.out_samplerate/ae.BLKSIZE,Je=0;for(pe=0,V=0;V<ae.BLKSIZE/2;++V)pe+=xe,M.ATH.eql_w[V]=1/Math.pow(10,this.ATHformula(pe,P)/10),Je+=M.ATH.eql_w[V];for(Je=1/Je,V=ae.BLKSIZE/2;--V>=0;)M.ATH.eql_w[V]*=Je}{for(var qe=ne=0;qe<M.npart_s;++qe)for(V=0;V<M.numlines_s[qe];++V)++ne;for(var qe=ne=0;qe<M.npart_l;++qe)for(V=0;V<M.numlines_l[qe];++V)++ne}for(ne=0,V=0;V<M.npart_l;V++){var pe=Ve*(ne+M.numlines_l[V]/2)/(1*ae.BLKSIZE);M.mld_cb_l[V]=Jt(pe),ne+=M.numlines_l[V]}for(;V<ae.CBANDS;++V)M.mld_cb_l[V]=1;for(ne=0,V=0;V<M.npart_s;V++){var pe=Ve*(ne+M.numlines_s[V]/2)/(1*ae.BLKSIZE_s);M.mld_cb_s[V]=Jt(pe),ne+=M.numlines_s[V]}for(;V<ae.CBANDS;++V)M.mld_cb_s[V]=1;return 0};function gt(P,M){P<-.3&&(P=3410),P/=1e3,P=Math.max(.1,P);var V=3.64*Math.pow(P,-.8)-6.8*Math.exp(-.6*Math.pow(P-3.4,2))+6*Math.exp(-.15*Math.pow(P-8.7,2))+(.6+.04*M)*.001*Math.pow(P,4);return V}this.ATHformula=function(P,M){var V;switch(M.ATHtype){case 0:V=gt(P,9);break;case 1:V=gt(P,-1);break;case 2:V=gt(P,0);break;case 3:V=gt(P,1)+6;break;case 4:V=gt(P,M.ATHcurve);break;default:V=gt(P,0);break}return V}}var iA=oA,aA=tc;function cA(){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=aA.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 lA=cA,uA=br(),t4={};t4.SFBMAX=uA.SBMAX_s*3;var $u=t4,r4=qt,dA=r4.new_float,$o=r4.new_int,I1=$u;function hA(){this.xr=dA(576),this.l3_enc=$o(576),this.scalefac=$o(I1.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=$o(3),this.subblock_gain=$o(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=$o(I1.SFBMAX),this.window=$o(I1.SFBMAX),this.count1bits=0,this.sfb_partition_table=null,this.slen=$o(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 D1=hA,fA=qt,k3=fA.new_int,pA=D1;function mA(){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=[k3(4),k3(4)];for(var t=0;t<2;t++)for(var e=0;e<2;e++)this.tt[t][e]=new pA}var gA=mA,n4=qt,yu=n4.System,vu=n4.new_int,wu=br();function _A(t,e,r,n){this.l=vu(1+wu.SBMAX_l),this.s=vu(1+wu.SBMAX_s),this.psfb21=vu(1+wu.PSFB21),this.psfb12=vu(1+wu.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],yu.arraycopy(this.arrL,0,s,0,Math.min(this.arrL.length,this.l.length)),yu.arraycopy(this.arrS,0,o,0,Math.min(this.arrS.length,this.s.length)),yu.arraycopy(this.arr21,0,this.psfb21,0,Math.min(this.arr21.length,this.psfb21.length)),yu.arraycopy(this.arr12,0,this.psfb12,0,Math.min(this.arr12.length,this.psfb12.length)))}var s4=_A,L1=qt,P1=L1.new_float,bA=L1.new_float_n,yA=L1.new_int,$3=br();function vA(){this.last_en_subshort=bA([4,9]),this.lastAttacks=yA(4),this.pefirbuf=P1(19),this.longfact=P1($3.SBMAX_l),this.shortfact=P1($3.SBMAX_s),this.attackthre=0,this.attackthre_s=0}var wA=vA;function xA(){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 SA=xA,Ri=qt,kA=Ri.new_byte,$A=Ri.new_double,hn=Ri.new_float,Eo=Ri.new_float_n,Rn=Ri.new_int,xu=Ri.new_int_n,EA=gA,TA=s4,RA=wA,IA=SA,E3=Q3(),Ut=br(),PA=$u;es.MFSIZE=3*1152+Ut.ENCDELAY-Ut.MDCTDELAY;es.MAX_HEADER_BUF=256;es.MAX_BITS_PER_CHANNEL=4095;es.MAX_BITS_PER_GRANULE=7680;es.BPC=320;function es(){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=Eo([2,es.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 EA,this.ms_ratio=hn(2),this.padding=0,this.frac_SpF=0,this.slot_lag=0,this.tag_spec=null,this.nMusicCRC=0,this.OldValue=Rn(2),this.CurrentStep=Rn(2),this.masking_lower=0,this.bv_scf=Rn(576),this.pseudohalf=Rn(PA.SFBMAX),this.sfb21_extra=!1,this.inbuf_old=new Array(2),this.blackfilt=new Array(2*es.BPC+1),this.itime=$A(2),this.sideinfo_len=0,this.sb_sample=Eo([2,2,18,Ut.SBLIMIT]),this.amp_filter=hn(32);function e(){this.write_timing=0,this.ptr=0,this.buf=kA(t)}this.header=new Array(es.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 TA,this.minval_l=hn(Ut.CBANDS),this.minval_s=hn(Ut.CBANDS),this.nb_1=Eo([4,Ut.CBANDS]),this.nb_2=Eo([4,Ut.CBANDS]),this.nb_s1=Eo([4,Ut.CBANDS]),this.nb_s2=Eo([4,Ut.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=hn(4),this.loudness_sq=Eo([2,2]),this.loudness_sq_save=hn(2),this.mld_l=hn(Ut.SBMAX_l),this.mld_s=hn(Ut.SBMAX_s),this.bm_l=Rn(Ut.SBMAX_l),this.bo_l=Rn(Ut.SBMAX_l),this.bm_s=Rn(Ut.SBMAX_s),this.bo_s=Rn(Ut.SBMAX_s),this.npart_l=0,this.npart_s=0,this.s3ind=xu([Ut.CBANDS,2]),this.s3ind_s=xu([Ut.CBANDS,2]),this.numlines_s=Rn(Ut.CBANDS),this.numlines_l=Rn(Ut.CBANDS),this.rnumlines_l=hn(Ut.CBANDS),this.mld_cb_l=hn(Ut.CBANDS),this.mld_cb_s=hn(Ut.CBANDS),this.numlines_s_num1=0,this.numlines_l_num1=0,this.pe=hn(4),this.ms_ratio_s_old=0,this.ms_ratio_l_old=0,this.ms_ener_ratio_old=0,this.blocktype_old=Rn(2),this.nsPsy=new RA,this.VBR_seek_table=new IA,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=xu([16,5]),this.bitrate_blockType_Hist=xu([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 E3;for(var r=0;r<this.thm.length;r++)this.thm[r]=new E3;for(var r=0;r<this.header.length;r++)this.header[r]=new e}var Eu=es,MA=qt,To=MA.new_float,Ro=br();function OA(){this.useAdjust=0,this.aaSensitivityP=0,this.adjust=0,this.adjustLimit=0,this.decay=0,this.floor=0,this.l=To(Ro.SBMAX_l),this.s=To(Ro.SBMAX_s),this.psfb21=To(Ro.PSFB21),this.psfb12=To(Ro.PSFB12),this.cb_l=To(Ro.CBANDS),this.cb_s=To(Ro.CBANDS),this.eql_w=To(Ro.BLKSIZE/2)}var AA=OA,o4=qt,Dr=o4.System,T3=o4.Arrays;Gt.STEPS_per_dB=100;Gt.MAX_dB=120;Gt.GAIN_NOT_ENOUGH_SAMPLES=-24601;Gt.GAIN_ANALYSIS_ERROR=0;Gt.GAIN_ANALYSIS_OK=1;Gt.INIT_GAIN_ANALYSIS_ERROR=0;Gt.INIT_GAIN_ANALYSIS_OK=1;Gt.YULE_ORDER=10;Gt.MAX_ORDER=Gt.YULE_ORDER;Gt.MAX_SAMP_FREQ=48e3;Gt.RMS_WINDOW_TIME_NUMERATOR=1;Gt.RMS_WINDOW_TIME_DENOMINATOR=20;Gt.MAX_SAMPLES_PER_WINDOW=Gt.MAX_SAMP_FREQ*Gt.RMS_WINDOW_TIME_NUMERATOR/Gt.RMS_WINDOW_TIME_DENOMINATOR+1;function Gt(){var t=64.82,e=.95,r=Gt.RMS_WINDOW_TIME_NUMERATOR,n=Gt.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,f,p,m,y,k){for(;y--!=0;)p[m]=1e-10+u[f+0]*k[0]-p[m-1]*k[1]+u[f-1]*k[2]-p[m-2]*k[3]+u[f-2]*k[4]-p[m-3]*k[5]+u[f-3]*k[6]-p[m-4]*k[7]+u[f-4]*k[8]-p[m-5]*k[9]+u[f-5]*k[10]-p[m-6]*k[11]+u[f-6]*k[12]-p[m-7]*k[13]+u[f-7]*k[14]-p[m-8]*k[15]+u[f-8]*k[16]-p[m-9]*k[17]+u[f-9]*k[18]-p[m-10]*k[19]+u[f-10]*k[20],++m,++f}function a(u,f,p,m,y,k){for(;y--!=0;)p[m]=u[f+0]*k[0]-p[m-1]*k[1]+u[f-1]*k[2]-p[m-2]*k[3]+u[f-2]*k[4],++m,++f}function c(u,f){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|f){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|(f*r+n-1)/n,u.lsum=0,u.rsum=0,u.totsamp=0,T3.ill(u.A,0),INIT_GAIN_ANALYSIS_OK}this.InitGainAnalysis=function(u,f){return c(u,f)!=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,T3.fill(u.B,0),INIT_GAIN_ANALYSIS_OK)};function d(u){return u*u}this.AnalyzeSamples=function(u,f,p,m,y,k,x){var _,g,E,h,$,O,L;if(k==0)return GAIN_ANALYSIS_OK;switch(L=0,$=k,x){case 1:m=f,y=p;break;case 2:break;default:return GAIN_ANALYSIS_ERROR}for(k<MAX_ORDER?(Dr.arraycopy(f,p,u.linprebuf,MAX_ORDER,k),Dr.arraycopy(m,y,u.rinprebuf,MAX_ORDER,k)):(Dr.arraycopy(f,p,u.linprebuf,MAX_ORDER,MAX_ORDER),Dr.arraycopy(m,y,u.rinprebuf,MAX_ORDER,MAX_ORDER));$>0;){O=$>u.sampleWindow-u.totsamp?u.sampleWindow-u.totsamp:$,L<MAX_ORDER?(_=u.linpre+L,g=u.linprebuf,E=u.rinpre+L,h=u.rinprebuf,O>MAX_ORDER-L&&(O=MAX_ORDER-L)):(_=p+L,g=f,E=y+L,h=m),i(g,_,u.lstepbuf,u.lstep+u.totsamp,O,s[u.reqindex]),i(h,E,u.rstepbuf,u.rstep+u.totsamp,O,s[u.reqindex]),a(u.lstepbuf,u.lstep+u.totsamp,u.loutbuf,u.lout+u.totsamp,O,o[u.reqindex]),a(u.rstepbuf,u.rstep+u.totsamp,u.routbuf,u.rout+u.totsamp,O,o[u.reqindex]),_=u.lout+u.totsamp,g=u.loutbuf,E=u.rout+u.totsamp,h=u.routbuf;for(var q=O%8;q--!=0;)u.lsum+=d(g[_++]),u.rsum+=d(h[E++]);for(q=O/8;q--!=0;)u.lsum+=d(g[_+0])+d(g[_+1])+d(g[_+2])+d(g[_+3])+d(g[_+4])+d(g[_+5])+d(g[_+6])+d(g[_+7]),_+=8,u.rsum+=d(h[E+0])+d(h[E+1])+d(h[E+2])+d(h[E+3])+d(h[E+4])+d(h[E+5])+d(h[E+6])+d(h[E+7]),E+=8;if($-=O,L+=O,u.totsamp+=O,u.totsamp==u.sampleWindow){var C=Gt.STEPS_per_dB*10*Math.log10((u.lsum+u.rsum)/u.totsamp*.5+1e-37),Z=C<=0?0:0|C;Z>=u.A.length&&(Z=u.A.length-1),u.A[Z]++,u.lsum=u.rsum=0,Dr.arraycopy(u.loutbuf,u.totsamp,u.loutbuf,0,MAX_ORDER),Dr.arraycopy(u.routbuf,u.totsamp,u.routbuf,0,MAX_ORDER),Dr.arraycopy(u.lstepbuf,u.totsamp,u.lstepbuf,0,MAX_ORDER),Dr.arraycopy(u.rstepbuf,u.totsamp,u.rstepbuf,0,MAX_ORDER),u.totsamp=0}if(u.totsamp>u.sampleWindow)return GAIN_ANALYSIS_ERROR}return k<MAX_ORDER?(Dr.arraycopy(u.linprebuf,k,u.linprebuf,0,MAX_ORDER-k),Dr.arraycopy(u.rinprebuf,k,u.rinprebuf,0,MAX_ORDER-k),Dr.arraycopy(f,p,u.linprebuf,MAX_ORDER-k,k),Dr.arraycopy(m,y,u.rinprebuf,MAX_ORDER-k,k)):(Dr.arraycopy(f,p+k-MAX_ORDER,u.linprebuf,0,MAX_ORDER),Dr.arraycopy(m,y+k-MAX_ORDER,u.rinprebuf,0,MAX_ORDER)),GAIN_ANALYSIS_OK};function l(u,f){var p,m=0;for(p=0;p<f;p++)m+=u[p];if(m==0)return GAIN_NOT_ENOUGH_SAMPLES;var y=0|Math.ceil(m*(1-e));for(p=f;p-- >0&&!((y-=u[p])<=0););return t-p/Gt.STEPS_per_dB}this.GetTitleGain=function(u){for(var f=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,f}}var i4=Gt,a4=qt,Ei=a4.new_float,R3=a4.new_int,Lr=i4;function zA(){this.linprebuf=Ei(Lr.MAX_ORDER*2),this.linpre=0,this.lstepbuf=Ei(Lr.MAX_SAMPLES_PER_WINDOW+Lr.MAX_ORDER),this.lstep=0,this.loutbuf=Ei(Lr.MAX_SAMPLES_PER_WINDOW+Lr.MAX_ORDER),this.lout=0,this.rinprebuf=Ei(Lr.MAX_ORDER*2),this.rinpre=0,this.rstepbuf=Ei(Lr.MAX_SAMPLES_PER_WINDOW+Lr.MAX_ORDER),this.rstep=0,this.routbuf=Ei(Lr.MAX_SAMPLES_PER_WINDOW+Lr.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=R3(0|Lr.STEPS_per_dB*Lr.MAX_dB),this.B=R3(0|Lr.STEPS_per_dB*Lr.MAX_dB)}var NA=zA;function CA(t){this.bits=t}var c4=CA,Z1=qt,I3=Z1.new_float,jA=Z1.new_int,P3=Z1.assert,DA=c4,M3=br(),LA=$u,ZA=Eu;function BA(t){var e=t;this.quantize=e,this.iteration_loop=function(r,n,s,o){var i=r.internal_flags,a=I3(LA.SFBMAX),c=I3(576),d=jA(2),l=0,u,f=i.l3_side,p=new DA(l);this.quantize.rv.ResvFrameBegin(r,p),l=p.bits;for(var m=0;m<i.mode_gr;m++){u=this.quantize.qupvt.on_pe(r,n,d,l,m,m),i.mode_ext==M3.MPG_MD_MS_LR&&(this.quantize.ms_convert(i.l3_side,m),this.quantize.qupvt.reduce_side(d,s[m],l,u));for(var y=0;y<i.channels_out;y++){var k,x,_=f.tt[m][y];_.block_type!=M3.SHORT_TYPE?(k=0,x=i.PSY.mask_adjust-k):(k=0,x=i.PSY.mask_adjust_short-k),i.masking_lower=Math.pow(10,x*.1),this.quantize.init_outer_loop(i,_),this.quantize.init_xrpow(i,_,c)&&(this.quantize.qupvt.calc_xmin(r,o[m][y],_,a),this.quantize.outer_loop(r,_,a,c,y,d[y])),this.quantize.iteration_finish_one(i,m,y),P3(_.part2_3_length<=ZA.MAX_BITS_PER_CHANNEL),P3(_.part2_3_length<=d[y])}}this.quantize.rv.ResvFrameEnd(i,l)}}var VA=BA;function yt(t,e,r,n){this.xlen=t,this.linmax=e,this.table=r,this.hlen=n}var ge={};ge.t1HB=[1,1,1,0];ge.t2HB=[1,2,1,3,1,1,3,2,0];ge.t3HB=[3,2,1,1,1,1,3,2,0];ge.t5HB=[1,2,6,5,3,1,4,4,7,5,7,1,6,1,1,0];ge.t6HB=[7,3,5,1,6,2,3,2,5,4,4,1,3,3,2,0];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.t32HB=[1,10,8,20,12,20,16,32,14,12,24,0,28,16,24,16];ge.t33HB=[15,28,26,48,22,40,36,64,14,24,20,32,12,16,8,0];ge.t1l=[1,4,3,5];ge.t2l=[1,4,7,4,5,7,6,7,8];ge.t3l=[2,3,7,4,4,7,6,7,8];ge.t5l=[1,4,7,8,4,5,8,9,7,8,9,10,8,8,9,10];ge.t6l=[3,4,6,8,4,4,6,7,5,6,7,8,7,7,8,9];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.t32l=[1,5,5,7,5,8,7,9,5,7,7,9,7,9,9,10];ge.t33l=[4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8];ge.ht=[new yt(0,0,null,null),new yt(2,0,ge.t1HB,ge.t1l),new yt(3,0,ge.t2HB,ge.t2l),new yt(3,0,ge.t3HB,ge.t3l),new yt(0,0,null,null),new yt(4,0,ge.t5HB,ge.t5l),new yt(4,0,ge.t6HB,ge.t6l),new yt(6,0,ge.t7HB,ge.t7l),new yt(6,0,ge.t8HB,ge.t8l),new yt(6,0,ge.t9HB,ge.t9l),new yt(8,0,ge.t10HB,ge.t10l),new yt(8,0,ge.t11HB,ge.t11l),new yt(8,0,ge.t12HB,ge.t12l),new yt(16,0,ge.t13HB,ge.t13l),new yt(0,0,null,ge.t16_5l),new yt(16,0,ge.t15HB,ge.t15l),new yt(1,1,ge.t16HB,ge.t16l),new yt(2,3,ge.t16HB,ge.t16l),new yt(3,7,ge.t16HB,ge.t16l),new yt(4,15,ge.t16HB,ge.t16l),new yt(6,63,ge.t16HB,ge.t16l),new yt(8,255,ge.t16HB,ge.t16l),new yt(10,1023,ge.t16HB,ge.t16l),new yt(13,8191,ge.t16HB,ge.t16l),new yt(4,15,ge.t24HB,ge.t24l),new yt(5,31,ge.t24HB,ge.t24l),new yt(6,63,ge.t24HB,ge.t24l),new yt(7,127,ge.t24HB,ge.t24l),new yt(8,255,ge.t24HB,ge.t24l),new yt(9,511,ge.t24HB,ge.t24l),new yt(11,2047,ge.t24HB,ge.t24l),new yt(13,8191,ge.t24HB,ge.t24l),new yt(0,0,ge.t32HB,ge.t32l),new yt(0,0,ge.t33HB,ge.t33l)];ge.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];ge.table23=[65538,262147,458759,262148,327684,458759,393222,458759,524296];ge.table56=[65539,262148,458758,524296,262148,327684,524294,589831,458757,524294,589831,655368,524295,524295,589832,655369];ge.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]];ge.samplerate_table=[[22050,24e3,16e3,-1],[44100,48e3,32e3,-1],[11025,12e3,8e3,-1]];ge.scfsi_band=[0,6,11,16,21];var B1=ge,M1,O3;function l4(){if(O3)return M1;O3=1;var t=s4,e=qt,r=e.VbrMode,n=e.Float,s=e.Util,o=e.new_float,i=e.new_int,a=e.assert,c=br(),d=c4,l=Eu;u.Q_MAX=257,u.Q_MAX2=116,u.LARGE_BITS=1e5,u.IXMAX_VAL=8206;function u(){var f=V1(),p=null,m=null,y=null;this.setModules=function(j,A,G){p=j,m=A,y=G};function k(j){return a(0<=j+u.Q_MAX2&&j<u.Q_MAX),L[j+u.Q_MAX2]}this.IPOW20=function(j){return a(0<=j&&j<u.Q_MAX),q[j]};var x=2220446049250313e-31,_=u.IXMAX_VAL,g=_+2,E=u.Q_MAX,h=u.Q_MAX2;u.LARGE_BITS;var $=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 O=[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,2,0];this.pretab=O,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 L=o(E+h+1),q=o(E),C=o(g),Z=o(g);this.adj43=Z;function he(j,A){var G=y.ATHformula(A,j);return G-=$,G=Math.pow(10,G/10+j.ATHlower),G}function z(j){for(var A=j.internal_flags.ATH.l,G=j.internal_flags.ATH.psfb21,F=j.internal_flags.ATH.s,Q=j.internal_flags.ATH.psfb12,B=j.internal_flags,T=j.out_samplerate,v=0;v<c.SBMAX_l;v++){var w=B.scalefac_band.l[v],R=B.scalefac_band.l[v+1];A[v]=n.MAX_VALUE;for(var N=w;N<R;N++){var K=N*T/1152,se=he(j,K);A[v]=Math.min(A[v],se)}}for(var v=0;v<c.PSFB21;v++){var w=B.scalefac_band.psfb21[v],R=B.scalefac_band.psfb21[v+1];G[v]=n.MAX_VALUE;for(var N=w;N<R;N++){var K=N*T/1152,se=he(j,K);G[v]=Math.min(G[v],se)}}for(var v=0;v<c.SBMAX_s;v++){var w=B.scalefac_band.s[v],R=B.scalefac_band.s[v+1];F[v]=n.MAX_VALUE;for(var N=w;N<R;N++){var K=N*T/384,se=he(j,K);F[v]=Math.min(F[v],se)}F[v]*=B.scalefac_band.s[v+1]-B.scalefac_band.s[v]}for(var v=0;v<c.PSFB12;v++){var w=B.scalefac_band.psfb12[v],R=B.scalefac_band.psfb12[v+1];Q[v]=n.MAX_VALUE;for(var N=w;N<R;N++){var K=N*T/384,se=he(j,K);Q[v]=Math.min(Q[v],se)}Q[v]*=B.scalefac_band.s[13]-B.scalefac_band.s[12]}if(j.noATH){for(var v=0;v<c.SBMAX_l;v++)A[v]=1e-20;for(var v=0;v<c.PSFB21;v++)G[v]=1e-20;for(var v=0;v<c.SBMAX_s;v++)F[v]=1e-20;for(var v=0;v<c.PSFB12;v++)Q[v]=1e-20}B.ATH.floor=10*Math.log10(he(j,-1))}this.iteration_init=function(j){var A=j.internal_flags,G=A.l3_side,F;if(A.iteration_init_init==0){for(A.iteration_init_init=1,G.main_data_begin=0,z(j),C[0]=0,F=1;F<g;F++)C[F]=Math.pow(F,4/3);for(F=0;F<g-1;F++)Z[F]=F+1-Math.pow(.5*(C[F]+C[F+1]),.75);for(Z[F]=.5,F=0;F<E;F++)q[F]=Math.pow(2,(F-210)*-.1875);for(F=0;F<=E+h;F++)L[F]=Math.pow(2,(F-210-h)*.25);p.huffman_init(A);{var Q,B,T,v;for(F=j.exp_nspsytune>>2&63,F>=32&&(F-=64),Q=Math.pow(10,F/4/10),F=j.exp_nspsytune>>8&63,F>=32&&(F-=64),B=Math.pow(10,F/4/10),F=j.exp_nspsytune>>14&63,F>=32&&(F-=64),T=Math.pow(10,F/4/10),F=j.exp_nspsytune>>20&63,F>=32&&(F-=64),v=T*Math.pow(10,F/4/10),F=0;F<c.SBMAX_l;F++){var w;F<=6?w=Q:F<=13?w=B:F<=20?w=T:w=v,A.nsPsy.longfact[F]=w}for(F=0;F<c.SBMAX_s;F++){var w;F<=5?w=Q:F<=10?w=B:F<=11?w=T:w=v,A.nsPsy.shortfact[F]=w}}}},this.on_pe=function(j,A,G,F,Q,B){var T=j.internal_flags,v=0,w,R=i(2),N,K=new d(v),se=m.ResvMaxBits(j,F,K,B);v=K.bits;var H=v+se;for(H>l.MAX_BITS_PER_GRANULE&&(H=l.MAX_BITS_PER_GRANULE),w=0,N=0;N<T.channels_out;++N)G[N]=Math.min(l.MAX_BITS_PER_CHANNEL,v/T.channels_out),R[N]=0|G[N]*A[Q][N]/700-G[N],R[N]>F*3/4&&(R[N]=F*3/4),R[N]<0&&(R[N]=0),R[N]+G[N]>l.MAX_BITS_PER_CHANNEL&&(R[N]=Math.max(0,l.MAX_BITS_PER_CHANNEL-G[N])),w+=R[N];if(w>se)for(N=0;N<T.channels_out;++N)R[N]=se*R[N]/w;for(N=0;N<T.channels_out;++N)G[N]+=R[N],se-=R[N];for(w=0,N=0;N<T.channels_out;++N)w+=G[N];if(w>l.MAX_BITS_PER_GRANULE){var ee=0;for(N=0;N<T.channels_out;++N)G[N]*=l.MAX_BITS_PER_GRANULE,G[N]/=w,ee+=G[N]}return H},this.reduce_side=function(j,A,G,F){a(j[0]+j[1]<=l.MAX_BITS_PER_GRANULE);var Q=.33*(.5-A)/.5;Q<0&&(Q=0),Q>.5&&(Q=.5);var B=0|Q*.5*(j[0]+j[1]);B>l.MAX_BITS_PER_CHANNEL-j[0]&&(B=l.MAX_BITS_PER_CHANNEL-j[0]),B<0&&(B=0),j[1]>=125&&(j[1]-B>125?(j[0]<G&&(j[0]+=B),j[1]-=B):(j[0]+=j[1]-125,j[1]=125)),B=j[0]+j[1],B>F&&(j[0]=F*j[0]/B,j[1]=F*j[1]/B),a(j[0]<=l.MAX_BITS_PER_CHANNEL),a(j[1]<=l.MAX_BITS_PER_CHANNEL),a(j[0]+j[1]<=l.MAX_BITS_PER_GRANULE)},this.athAdjust=function(j,A,G){var F=90.30873362,Q=94.82444863,B=s.FAST_LOG10_X(A,10),T=j*j,v=0;return B-=G,T>1e-20&&(v=1+s.FAST_LOG10_X(T,10/F)),v<0&&(v=0),B*=v,B+=G+F-Q,Math.pow(10,.1*B)},this.calc_xmin=function(j,A,G,F){var Q=0,B=j.internal_flags,T,v=0,w=0,R=B.ATH,N=G.xr,K=j.VBR==r.vbr_mtrh?1:0,se=B.masking_lower;for((j.VBR==r.vbr_mtrh||j.VBR==r.vbr_mt)&&(se=1),T=0;T<G.psy_lmax;T++){var H,ee,de,_e,ke,Ie;j.VBR==r.vbr_rh||j.VBR==r.vbr_mtrh?ee=athAdjust(R.adjust,R.l[T],R.floor):ee=R.adjust*R.l[T],ke=G.width[T],de=ee/ke,_e=x,Ie=ke>>1,H=0;do{var Te,$e;Te=N[v]*N[v],H+=Te,_e+=Te<de?Te:de,v++,$e=N[v]*N[v],H+=$e,_e+=$e<de?$e:de,v++}while(--Ie>0);if(H>ee&&w++,T==c.SBPSY_l){var je=ee*B.nsPsy.longfact[T];_e<je&&(_e=je)}if(K!=0&&(ee=_e),!j.ATHonly){var Tt=A.en.l[T];if(Tt>0){var je;je=H*A.thm.l[T]*se/Tt,K!=0&&(je*=B.nsPsy.longfact[T]),ee<je&&(ee=je)}}K!=0?F[Q++]=ee:F[Q++]=ee*B.nsPsy.longfact[T]}var Kr=575;if(G.block_type!=c.SHORT_TYPE)for(var S=576;S--!=0&&f.EQ(N[S],0);)Kr=S;G.max_nonzero_coeff=Kr;for(var I=G.sfb_smin;T<G.psymax;I++,T+=3){var ke,Se,Me;for(j.VBR==r.vbr_rh||j.VBR==r.vbr_mtrh?Me=athAdjust(R.adjust,R.s[I],R.floor):Me=R.adjust*R.s[I],ke=G.width[T],Se=0;Se<3;Se++){var H=0,ee,de,_e,Ie=ke>>1;de=Me/ke,_e=x;do{var Te,$e;Te=N[v]*N[v],H+=Te,_e+=Te<de?Te:de,v++,$e=N[v]*N[v],H+=$e,_e+=$e<de?$e:de,v++}while(--Ie>0);if(H>Me&&w++,I==c.SBPSY_s){var je=Me*B.nsPsy.shortfact[I];_e<je&&(_e=je)}if(K!=0?ee=_e:ee=Me,!j.ATHonly&&!j.ATHshort){var Tt=A.en.s[I][Se];if(Tt>0){var je;je=H*A.thm.s[I][Se]*se/Tt,K!=0&&(je*=B.nsPsy.shortfact[I]),ee<je&&(ee=je)}}K!=0?F[Q++]=ee:F[Q++]=ee*B.nsPsy.shortfact[I]}j.useTemporal&&(F[Q-3]>F[Q-3+1]&&(F[Q-3+1]+=(F[Q-3]-F[Q-3+1])*B.decay),F[Q-3+1]>F[Q-3+2]&&(F[Q-3+2]+=(F[Q-3+1]-F[Q-3+2])*B.decay))}return w};function b(j){this.s=j}this.calc_noise_core=function(j,A,G,F){var Q=0,B=A.s,T=j.l3_enc;if(B>j.count1)for(;G--!=0;){var v;v=j.xr[B],B++,Q+=v*v,v=j.xr[B],B++,Q+=v*v}else if(B>j.big_values){var w=o(2);for(w[0]=0,w[1]=F;G--!=0;){var v;v=Math.abs(j.xr[B])-w[T[B]],B++,Q+=v*v,v=Math.abs(j.xr[B])-w[T[B]],B++,Q+=v*v}}else for(;G--!=0;){var v;v=Math.abs(j.xr[B])-C[T[B]]*F,B++,Q+=v*v,v=Math.abs(j.xr[B])-C[T[B]]*F,B++,Q+=v*v}return A.s=B,Q},this.calc_noise=function(j,A,G,F,Q){var B=0,T=0,v,w,R=0,N=0,K=0,se=-20,H=0,ee=j.scalefac,de=0;for(F.over_SSD=0,v=0;v<j.psymax;v++){var _e=j.global_gain-(ee[de++]+(j.preflag!=0?O[v]:0)<<j.scalefac_scale+1)-j.subblock_gain[j.window[v]]*8,ke=0;if(Q!=null&&Q.step[v]==_e)ke=Q.noise[v],H+=j.width[v],G[B++]=ke/A[T++],ke=Q.noise_log[v];else{var Ie=k(_e);if(w=j.width[v]>>1,H+j.width[v]>j.max_nonzero_coeff){var Te;Te=j.max_nonzero_coeff-H+1,Te>0?w=Te>>1:w=0}var $e=new b(H);ke=this.calc_noise_core(j,$e,w,Ie),H=$e.s,Q!=null&&(Q.step[v]=_e,Q.noise[v]=ke),ke=G[B++]=ke/A[T++],ke=s.FAST_LOG10(Math.max(ke,1e-20)),Q!=null&&(Q.noise_log[v]=ke)}if(Q!=null&&(Q.global_gain=j.global_gain),K+=ke,ke>0){var je;je=Math.max(0|ke*10+.5,1),F.over_SSD+=je*je,R++,N+=ke}se=Math.max(se,ke)}return F.over_count=R,F.tot_noise=K,F.over_noise=N,F.max_noise=se,R},this.set_pinfo=function(j,A,G,F,Q){var B=j.internal_flags,T,v,w,R,N,K=A.scalefac_scale==0?.5:1,se=A.scalefac,H=o(L3Side.SFBMAX),ee=o(L3Side.SFBMAX),de=new CalcNoiseResult;calc_xmin(j,G,A,H),calc_noise(A,H,ee,de,null);var _e=0;for(v=A.sfb_lmax,A.block_type!=c.SHORT_TYPE&&A.mixed_block_flag==0&&(v=22),T=0;T<v;T++){var ke=B.scalefac_band.l[T],Ie=B.scalefac_band.l[T+1],Te=Ie-ke;for(R=0;_e<Ie;_e++)R+=A.xr[_e]*A.xr[_e];R/=Te,N=1e15,B.pinfo.en[F][Q][T]=N*R,B.pinfo.xfsf[F][Q][T]=N*H[T]*ee[T]/Te,G.en.l[T]>0&&!j.ATHonly?R=R/G.en.l[T]:R=0,B.pinfo.thr[F][Q][T]=N*Math.max(R*G.thm.l[T],B.ATH.l[T]),B.pinfo.LAMEsfb[F][Q][T]=0,A.preflag!=0&&T>=11&&(B.pinfo.LAMEsfb[F][Q][T]=-K*O[T]),T<c.SBPSY_l&&(a(se[T]>=0),B.pinfo.LAMEsfb[F][Q][T]-=K*se[T])}if(A.block_type==c.SHORT_TYPE)for(v=T,T=A.sfb_smin;T<c.SBMAX_s;T++)for(var ke=B.scalefac_band.s[T],Ie=B.scalefac_band.s[T+1],Te=Ie-ke,$e=0;$e<3;$e++){for(R=0,w=ke;w<Ie;w++)R+=A.xr[_e]*A.xr[_e],_e++;R=Math.max(R/Te,1e-20),N=1e15,B.pinfo.en_s[F][Q][3*T+$e]=N*R,B.pinfo.xfsf_s[F][Q][3*T+$e]=N*H[v]*ee[v]/Te,G.en.s[T][$e]>0?R=R/G.en.s[T][$e]:R=0,(j.ATHonly||j.ATHshort)&&(R=0),B.pinfo.thr_s[F][Q][3*T+$e]=N*Math.max(R*G.thm.s[T][$e],B.ATH.s[T]),B.pinfo.LAMEsfb_s[F][Q][3*T+$e]=-2*A.subblock_gain[$e],T<c.SBPSY_s&&(B.pinfo.LAMEsfb_s[F][Q][3*T+$e]-=K*se[v]),v++}B.pinfo.LAMEqss[F][Q]=A.global_gain,B.pinfo.LAMEmainbits[F][Q]=A.part2_3_length+A.part2_length,B.pinfo.LAMEsfbits[F][Q]=A.part2_length,B.pinfo.over[F][Q]=de.over_count,B.pinfo.max_noise[F][Q]=de.max_noise*10,B.pinfo.over_noise[F][Q]=de.over_noise*10,B.pinfo.tot_noise[F][Q]=de.tot_noise*10,B.pinfo.over_SSD[F][Q]=de.over_SSD}}return M1=u,M1}var O1,A3;function u4(){if(A3)return O1;A3=1;var t=qt,e=t.System,r=t.Arrays,n=t.new_int,s=t.assert,o=br(),i=B1,a=D1,c=l4();function d(){var l=null;this.qupvt=null,this.setModules=function(B){this.qupvt=B,l=B};function u(B){this.bits=0|B}var f=[[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(B,T,v,w,R,N){var K=.5946/T;for(B=B>>1;B--!=0;)R[N++]=K>v[w++]?0:1,R[N++]=K>v[w++]?0:1}function m(B,T,v,w,R,N){B=B>>1;var K=B%2;for(B=B>>1;B--!=0;){var se,H,ee,de,_e,ke,Ie,Te;se=v[w++]*T,H=v[w++]*T,_e=0|se,ee=v[w++]*T,ke=0|H,de=v[w++]*T,Ie=0|ee,se+=l.adj43[_e],Te=0|de,H+=l.adj43[ke],R[N++]=0|se,ee+=l.adj43[Ie],R[N++]=0|H,de+=l.adj43[Te],R[N++]=0|ee,R[N++]=0|de}if(K!=0){var se,H,_e,ke;se=v[w++]*T,H=v[w++]*T,_e=0|se,ke=0|H,se+=l.adj43[_e],H+=l.adj43[ke],R[N++]=0|se,R[N++]=0|H}}function y(B,T,v,w,R){var N,K,se=0,H,ee=0,de=0,_e=0,ke=T,Ie=0,Te=ke,$e=0,je=B,Tt=0;for(H=R!=null&&w.global_gain==R.global_gain,w.block_type==o.SHORT_TYPE?K=38:K=21,N=0;N<=K;N++){var Kr=-1;if((H||w.block_type==o.NORM_TYPE)&&(Kr=w.global_gain-(w.scalefac[N]+(w.preflag!=0?l.pretab[N]:0)<<w.scalefac_scale+1)-w.subblock_gain[w.window[N]]*8),s(w.width[N]>=0),H&&R.step[N]==Kr)ee!=0&&(m(ee,v,je,Tt,Te,$e),ee=0),de!=0&&(p(de,v,je,Tt,Te,$e),de=0);else{var S=w.width[N];if(se+w.width[N]>w.max_nonzero_coeff){var I;I=w.max_nonzero_coeff-se+1,r.fill(T,w.max_nonzero_coeff,576,0),S=I,S<0&&(S=0),N=K+1}if(ee==0&&de==0&&(Te=ke,$e=Ie,je=B,Tt=_e),R!=null&&R.sfb_count1>0&&N>=R.sfb_count1&&R.step[N]>0&&Kr>=R.step[N]?(ee!=0&&(m(ee,v,je,Tt,Te,$e),ee=0,Te=ke,$e=Ie,je=B,Tt=_e),de+=S):(de!=0&&(p(de,v,je,Tt,Te,$e),de=0,Te=ke,$e=Ie,je=B,Tt=_e),ee+=S),S<=0){de!=0&&(p(de,v,je,Tt,Te,$e),de=0),ee!=0&&(m(ee,v,je,Tt,Te,$e),ee=0);break}}N<=K&&(Ie+=w.width[N],_e+=w.width[N],se+=w.width[N])}ee!=0&&(m(ee,v,je,Tt,Te,$e),ee=0),de!=0&&(p(de,v,je,Tt,Te,$e),de=0)}function k(B,T,v){var w=0,R=0;do{var N=B[T++],K=B[T++];w<N&&(w=N),R<K&&(R=K)}while(T<v);return w<R&&(w=R),w}function x(B,T,v,w,R,N){var K=i.ht[w].xlen*65536+i.ht[R].xlen,se=0,H;do{var ee=B[T++],de=B[T++];ee!=0&&(ee>14&&(ee=15,se+=K),ee*=16),de!=0&&(de>14&&(de=15,se+=K),ee+=de),se+=i.largetbl[ee]}while(T<v);return H=se&65535,se>>=16,se>H&&(se=H,w=R),N.bits+=se,w}function _(B,T,v,w){var R=0,N=i.ht[1].hlen;do{var K=B[T+0]*2+B[T+1];T+=2,R+=N[K]}while(T<v);return w.bits+=R,1}function g(B,T,v,w,R){var N=0,K,se=i.ht[w].xlen,H;w==2?H=i.table23:H=i.table56;do{var ee=B[T+0]*se+B[T+1];T+=2,N+=H[ee]}while(T<v);return K=N&65535,N>>=16,N>K&&(N=K,w++),R.bits+=N,w}function E(B,T,v,w,R){var N=0,K=0,se=0,H=i.ht[w].xlen,ee=i.ht[w].hlen,de=i.ht[w+1].hlen,_e=i.ht[w+2].hlen;do{var ke=B[T+0]*H+B[T+1];T+=2,N+=ee[ke],K+=de[ke],se+=_e[ke]}while(T<v);var Ie=w;return N>K&&(N=K,Ie++),N>se&&(N=se,Ie=w+2),R.bits+=N,Ie}var h=[1,2,5,7,7,10,10,13,13,13,13,13,13,13,13];function $(B,T,v,w){var R=k(B,T,v);switch(R){case 0:return R;case 1:return _(B,T,v,w);case 2:case 3:return g(B,T,v,h[R-1],w);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 E(B,T,v,h[R-1],w);default:if(R>c.IXMAX_VAL)return w.bits=c.LARGE_BITS,-1;R-=15;var N;for(N=24;N<32&&!(i.ht[N].linmax>=R);N++);var K;for(K=N-8;K<24&&!(i.ht[K].linmax>=R);K++);return x(B,T,v,K,N,w)}}this.noquant_count_bits=function(B,T,v){var w=T.l3_enc,R=Math.min(576,T.max_nonzero_coeff+2>>1<<1);for(v!=null&&(v.sfb_count1=0);R>1&&!(w[R-1]|w[R-2]);R-=2);T.count1=R;for(var N=0,K=0;R>3;R-=4){var se;if(((w[R-1]|w[R-2]|w[R-3]|w[R-4])&2147483647)>1)break;se=((w[R-4]*2+w[R-3])*2+w[R-2])*2+w[R-1],N+=i.t32l[se],K+=i.t33l[se]}var H=N;if(T.count1table_select=0,N>K&&(H=K,T.count1table_select=1),T.count1bits=H,T.big_values=R,R==0)return H;if(T.block_type==o.SHORT_TYPE)N=3*B.scalefac_band.s[3],N>T.big_values&&(N=T.big_values),K=T.big_values;else if(T.block_type==o.NORM_TYPE){if(N=T.region0_count=B.bv_scf[R-2],K=T.region1_count=B.bv_scf[R-1],s(N+K+2<o.SBPSY_l),K=B.scalefac_band.l[N+K+2],N=B.scalefac_band.l[N+1],K<R){var ee=new u(H);T.table_select[2]=$(w,K,R,ee),H=ee.bits}}else T.region0_count=7,T.region1_count=o.SBMAX_l-1-7-1,N=B.scalefac_band.l[8],K=R,N>K&&(N=K);if(N=Math.min(N,R),K=Math.min(K,R),0<N){var ee=new u(H);T.table_select[0]=$(w,0,N,ee),H=ee.bits}if(N<K){var ee=new u(H);T.table_select[1]=$(w,N,K,ee),H=ee.bits}if(B.use_best_huffman==2&&(T.part2_3_length=H,best_huffman_divide(B,T),H=T.part2_3_length),v!=null&&T.block_type==o.NORM_TYPE){for(var de=0;B.scalefac_band.l[de]<T.big_values;)de++;v.sfb_count1=de}return H},this.count_bits=function(B,T,v,w){var R=v.l3_enc,N=c.IXMAX_VAL/l.IPOW20(v.global_gain);if(v.xrpow_max>N)return c.LARGE_BITS;if(y(T,R,l.IPOW20(v.global_gain),v,w),B.substep_shaping&2)for(var K=0,se=v.global_gain+v.scalefac_scale,H=.634521682242439/l.IPOW20(se),ee=0;ee<v.sfbmax;ee++){var de=v.width[ee];if(B.pseudohalf[ee]==0)K+=de;else{var _e;for(_e=K,K+=de;_e<K;++_e)R[_e]=T[_e]>=H?R[_e]:0}}return this.noquant_count_bits(B,v,w)};function O(B,T,v,w,R,N,K){for(var se=T.big_values,H=0;H<=22;H++)w[H]=c.LARGE_BITS;for(var H=0;H<16;H++){var ee=B.scalefac_band.l[H+1];if(ee>=se)break;var de=0,_e=new u(de),ke=$(v,0,ee,_e);de=_e.bits;for(var Ie=0;Ie<8;Ie++){var Te=B.scalefac_band.l[H+Ie+2];if(Te>=se)break;var $e=de;_e=new u($e);var je=$(v,ee,Te,_e);$e=_e.bits,w[H+Ie]>$e&&(w[H+Ie]=$e,R[H+Ie]=H,N[H+Ie]=ke,K[H+Ie]=je)}}}function L(B,T,v,w,R,N,K,se){for(var H=T.big_values,ee=2;ee<o.SBMAX_l+1;ee++){var de=B.scalefac_band.l[ee];if(de>=H)break;var _e=R[ee-2]+T.count1bits;if(v.part2_3_length<=_e)break;var ke=new u(_e),Ie=$(w,de,H,ke);_e=ke.bits,!(v.part2_3_length<=_e)&&(v.assign(T),v.part2_3_length=_e,v.region0_count=N[ee-2],v.region1_count=ee-2-N[ee-2],v.table_select[0]=K[ee-2],v.table_select[1]=se[ee-2],v.table_select[2]=Ie)}}this.best_huffman_divide=function(B,T){var v=new a,w=T.l3_enc,R=n(23),N=n(23),K=n(23),se=n(23);if(!(T.block_type==o.SHORT_TYPE&&B.mode_gr==1)){v.assign(T),T.block_type==o.NORM_TYPE&&(O(B,T,w,R,N,K,se),L(B,v,T,w,R,N,K,se));var H=v.big_values;if(!(H==0||(w[H-2]|w[H-1])>1)&&(H=T.count1+2,!(H>576))){v.assign(T),v.count1=H;for(var ee=0,de=0;H>v.big_values;H-=4){var _e=((w[H-4]*2+w[H-3])*2+w[H-2])*2+w[H-1];ee+=i.t32l[_e],de+=i.t33l[_e]}if(v.big_values=H,v.count1table_select=0,ee>de&&(ee=de,v.count1table_select=1),v.count1bits=ee,v.block_type==o.NORM_TYPE)L(B,v,T,w,R,N,K,se);else{if(v.part2_3_length=ee,ee=B.scalefac_band.l[8],ee>H&&(ee=H),ee>0){var ke=new u(v.part2_3_length);v.table_select[0]=$(w,0,ee,ke),v.part2_3_length=ke.bits}if(H>ee){var ke=new u(v.part2_3_length);v.table_select[1]=$(w,ee,H,ke),v.part2_3_length=ke.bits}T.part2_3_length>v.part2_3_length&&T.assign(v)}}}};var q=[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],Z=[0,0,0,0,3,1,1,1,2,2,2,3,3,3,4,4],he=[0,1,2,3,0,1,2,3,1,2,3,1,2,3,2,3];d.slen1_tab=Z,d.slen2_tab=he;function z(B,T){for(var v,w=T.tt[1][B],R=T.tt[0][B],N=0;N<i.scfsi_band.length-1;N++){for(v=i.scfsi_band[N];v<i.scfsi_band[N+1]&&!(R.scalefac[v]!=w.scalefac[v]&&w.scalefac[v]>=0);v++);if(v==i.scfsi_band[N+1]){for(v=i.scfsi_band[N];v<i.scfsi_band[N+1];v++)w.scalefac[v]=-1;T.scfsi[B][N]=1}}var K=0,se=0;for(v=0;v<11;v++)w.scalefac[v]!=-1&&(se++,K<w.scalefac[v]&&(K=w.scalefac[v]));for(var H=0,ee=0;v<o.SBPSY_l;v++)w.scalefac[v]!=-1&&(ee++,H<w.scalefac[v]&&(H=w.scalefac[v]));for(var N=0;N<16;N++)if(K<q[N]&&H<C[N]){var de=Z[N]*se+he[N]*ee;w.part2_length>de&&(w.part2_length=de,w.scalefac_compress=N)}}this.best_scalefac_store=function(B,T,v,w){var R=w.tt[T][v],N,K,se,H,ee=0;for(se=0,N=0;N<R.sfbmax;N++){var de=R.width[N];for(se+=de,H=-de;H<0&&R.l3_enc[H+se]==0;H++);H==0&&(R.scalefac[N]=ee=-2)}if(R.scalefac_scale==0&&R.preflag==0){var _e=0;for(N=0;N<R.sfbmax;N++)R.scalefac[N]>0&&(_e|=R.scalefac[N]);if(!(_e&1)&&_e!=0){for(N=0;N<R.sfbmax;N++)R.scalefac[N]>0&&(R.scalefac[N]>>=1);R.scalefac_scale=ee=1}}if(R.preflag==0&&R.block_type!=o.SHORT_TYPE&&B.mode_gr==2){for(N=11;N<o.SBPSY_l&&!(R.scalefac[N]<l.pretab[N]&&R.scalefac[N]!=-2);N++);if(N==o.SBPSY_l){for(N=11;N<o.SBPSY_l;N++)R.scalefac[N]>0&&(R.scalefac[N]-=l.pretab[N]);R.preflag=ee=1}}for(K=0;K<4;K++)w.scfsi[v][K]=0;for(B.mode_gr==2&&T==1&&w.tt[0][v].block_type!=o.SHORT_TYPE&&w.tt[1][v].block_type!=o.SHORT_TYPE&&(z(v,w),ee=0),N=0;N<R.sfbmax;N++)R.scalefac[N]==-2&&(R.scalefac[N]=0);ee!=0&&(B.mode_gr==2?this.scale_bitcount(R):this.scale_bitcount_lsf(B,R))};function b(B,T){for(var v=0;v<T;++v)if(B[v]<0)return!1;return!0}var j=[0,18,36,54,54,36,54,72,54,72,90,72,90,108,108,126],A=[0,18,36,54,51,35,53,71,52,70,88,69,87,105,104,122],G=[0,10,20,30,33,21,31,41,32,42,52,43,53,63,64,74];this.scale_bitcount=function(B){var T,v,w=0,R=0,N,K=B.scalefac;if(s(b(K,B.sfbmax)),B.block_type==o.SHORT_TYPE)N=j,B.mixed_block_flag!=0&&(N=A);else if(N=G,B.preflag==0){for(v=11;v<o.SBPSY_l&&!(K[v]<l.pretab[v]);v++);if(v==o.SBPSY_l)for(B.preflag=1,v=11;v<o.SBPSY_l;v++)K[v]-=l.pretab[v]}for(v=0;v<B.sfbdivide;v++)w<K[v]&&(w=K[v]);for(;v<B.sfbmax;v++)R<K[v]&&(R=K[v]);for(B.part2_length=c.LARGE_BITS,T=0;T<16;T++)w<q[T]&&R<C[T]&&B.part2_length>N[T]&&(B.part2_length=N[T],B.scalefac_compress=T);return B.part2_length==c.LARGE_BITS};var F=[[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(B,T){var v,w,R,N,K,se,H,ee,de=n(4),_e=T.scalefac;for(T.preflag!=0?v=2:v=0,H=0;H<4;H++)de[H]=0;if(T.block_type==o.SHORT_TYPE){w=1;var ke=l.nr_of_sfb_block[v][w];for(ee=0,R=0;R<4;R++)for(N=ke[R]/3,H=0;H<N;H++,ee++)for(K=0;K<3;K++)_e[ee*3+K]>de[R]&&(de[R]=_e[ee*3+K])}else{w=0;var ke=l.nr_of_sfb_block[v][w];for(ee=0,R=0;R<4;R++)for(N=ke[R],H=0;H<N;H++,ee++)_e[ee]>de[R]&&(de[R]=_e[ee])}for(se=!1,R=0;R<4;R++)de[R]>F[v][R]&&(se=!0);if(!se){var Ie,Te,$e,je;for(T.sfb_partition_table=l.nr_of_sfb_block[v][w],R=0;R<4;R++)T.slen[R]=Q[de[R]];switch(Ie=T.slen[0],Te=T.slen[1],$e=T.slen[2],je=T.slen[3],v){case 0:T.scalefac_compress=(Ie*5+Te<<4)+($e<<2)+je;break;case 1:T.scalefac_compress=400+(Ie*5+Te<<2)+$e;break;case 2:T.scalefac_compress=500+Ie*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 Q=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];this.huffman_init=function(B){for(var T=2;T<=576;T+=2){for(var v=0,w;B.scalefac_band.l[++v]<T;);for(w=f[v][0];B.scalefac_band.l[w+1]>T;)w--;for(w<0&&(w=f[v][0]),B.bv_scf[T-2]=w,w=f[v][1];B.scalefac_band.l[w+B.bv_scf[T-2]+2]>T;)w--;w<0&&(w=f[v][1]),B.bv_scf[T-1]=w}}}return
|
|
194
|
-
`)}}function b(T,v){var w=c.ht[v.count1table_select+32],R,N=0,K=v.big_values,se=v.big_values;for(i(v.count1table_select<2),R=(v.count1-v.big_values)/4;R>0;--R){var
|
|
195
|
-
`),R}this.flush_bitstream=function(T){var v=T.internal_flags,w,R,N=v.h_ptr-1;if(N==-1&&(N=l.MAX_HEADER_BUF-1),w=v.l3_side,!((R=B(T,new Q))<0)){if(C(T,R),i(v.header[N].write_timing+this.getframebits(T)==E),v.ResvSize=0,w.main_data_begin=0,v.findReplayGain){var K=y.GetTitleGain(v.rgdata);i(NEQ(K,GainAnalysis.GAIN_NOT_ENOUGH_SAMPLES)),v.RadioGain=Math.floor(K*10+.5)|0}v.findPeakSample&&(v.noclipGainChange=Math.ceil(Math.log10(v.PeakSample/32767)*20*10)|0,v.noclipGainChange>0&&(EQ(T.scale,1)||EQ(T.scale,0))?v.noclipScale=Math.floor(32767/v.PeakSample*100)/100:v.noclipScale=-1)}},this.add_dummy_byte=function(T,v,w){for(var R=T.internal_flags,N;w-- >0;)for(q(R,v,8),N=0;N<l.MAX_HEADER_BUF;++N)R.header[N].write_timing+=8},this.format_bitstream=function(T){var v=T.internal_flags,w;w=v.l3_side;var R=this.getframebits(T);C(T,w.resvDrain_pre),
|
|
112
|
+
</html>`}function h3(t){return!!t.preview}function f3(t){return t.events.some(e=>e.type==="term.data"||e.type==="term.resize")}var Gz=xi.dirname(Hz(import.meta.url));function Wz(t){let e=xi.join(t,"player");return Uz(e)?e:xi.join(t,"../../../../packages/player/dist")}var p3=Wz(Gz);function Yz(t){let e;if(t.manifest.mode)e=`_player-bundle.${t.manifest.mode}.gz.b64`;else{let r=h3(t),n=f3(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 Fz(xi.join(p3,e),"utf8").trim()}catch{throw new Error(`Player bundle "${e}" not found in ${p3} (run pnpm build:player).`)}}function m3(t,e=""){let r=qz(Buffer.from(JSON.stringify({...t,audio:null}),"utf8"),{level:9}).toString("base64"),n=Yz(t);return d3(t.manifest.title,r,e,n)}var V3={};function Xz(t){return new Int8Array(t)}function q3(t){return new Int16Array(t)}function F3(t){return new Int32Array(t)}function U3(t){return new Float32Array(t)}function Kz(t){return new Float64Array(t)}function H3(t){if(t.length==1)return U3(t[0]);var e=t[0];t=t.slice(1);for(var r=[],n=0;n<e;n++)r.push(H3(t));return r}function G3(t){if(t.length==1)return F3(t[0]);var e=t[0];t=t.slice(1);for(var r=[],n=0;n<e;n++)r.push(G3(t));return r}function W3(t){if(t.length==1)return q3(t[0]);var e=t[0];t=t.slice(1);for(var r=[],n=0;n<e;n++)r.push(W3(t));return r}function Y3(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(Y3(t));return r}var X3={};X3.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 Qa={};Qa.arraycopy=function(t,e,r,n,s){for(var o=e+s;e<o;)r[n++]=t[e++]};Qa.out={};Qa.out.println=function(t){console.log(t)};Qa.out.printf=function(){console.log.apply(console,arguments)};var ku={};ku.SQRT2=1.4142135623730951;ku.FAST_LOG10=function(t){return Math.log10(t)};ku.FAST_LOG10_X=function(t,e){return Math.log10(t)*e};function ts(t){this.ordinal=t}ts.short_block_allowed=new ts(0);ts.short_block_coupled=new ts(1);ts.short_block_dispensed=new ts(2);ts.short_block_forced=new ts(3);var K3={};K3.MAX_VALUE=34028235e31;function Yr(t){this.ordinal=t}Yr.vbr_off=new Yr(0);Yr.vbr_mt=new Yr(1);Yr.vbr_rh=new Yr(2);Yr.vbr_abr=new Yr(3);Yr.vbr_mtrh=new Yr(4);Yr.vbr_default=Yr.vbr_mtrh;var Jz=function(t){},qt={System:Qa,VbrMode:Yr,Float:K3,ShortBlock:ts,Util:ku,Arrays:X3,new_array_n:Y3,new_byte:Xz,new_double:Kz,new_float:U3,new_float_n:H3,new_int:F3,new_int_n:G3,new_short:q3,new_short_n:W3,assert:Jz},$1,g3;function Qz(){if(g3)return $1;g3=1;var t=qt,e=t.System,r=t.Util,n=t.Arrays,s=t.new_float,o=br();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],f=l[o.SHORT_TYPE],p=l[o.SHORT_TYPE],m=l[o.SHORT_TYPE],y=[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 k(g,E,h){for(var $=10,z=E+238-14-286,L=-15;L<0;L++){var q,C,Z;q=a[$+-10],C=g[z+-224]*q,Z=g[E+224]*q,q=a[$+-9],C+=g[z+-160]*q,Z+=g[E+160]*q,q=a[$+-8],C+=g[z+-96]*q,Z+=g[E+96]*q,q=a[$+-7],C+=g[z+-32]*q,Z+=g[E+32]*q,q=a[$+-6],C+=g[z+32]*q,Z+=g[E+-32]*q,q=a[$+-5],C+=g[z+96]*q,Z+=g[E+-96]*q,q=a[$+-4],C+=g[z+160]*q,Z+=g[E+-160]*q,q=a[$+-3],C+=g[z+224]*q,Z+=g[E+-224]*q,q=a[$+-2],C+=g[E+-256]*q,Z-=g[z+256]*q,q=a[$+-1],C+=g[E+-192]*q,Z-=g[z+192]*q,q=a[$+0],C+=g[E+-128]*q,Z-=g[z+128]*q,q=a[$+1],C+=g[E+-64]*q,Z-=g[z+64]*q,q=a[$+2],C+=g[E+0]*q,Z-=g[z+0]*q,q=a[$+3],C+=g[E+64]*q,Z-=g[z+-64]*q,q=a[$+4],C+=g[E+128]*q,Z-=g[z+-128]*q,q=a[$+5],C+=g[E+192]*q,Z-=g[z+-192]*q,C*=a[$+6],q=Z-C,h[30+L*2]=Z+C,h[31+L*2]=a[$+7]*q,$+=18,E--,z++}{var C,Z,he,O;Z=g[E+-16]*a[$+-10],C=g[E+-32]*a[$+-2],Z+=(g[E+-48]-g[E+16])*a[$+-9],C+=g[E+-96]*a[$+-1],Z+=(g[E+-80]+g[E+48])*a[$+-8],C+=g[E+-160]*a[$+0],Z+=(g[E+-112]-g[E+80])*a[$+-7],C+=g[E+-224]*a[$+1],Z+=(g[E+-144]+g[E+112])*a[$+-6],C-=g[E+32]*a[$+2],Z+=(g[E+-176]-g[E+144])*a[$+-5],C-=g[E+96]*a[$+3],Z+=(g[E+-208]+g[E+176])*a[$+-4],C-=g[E+160]*a[$+4],Z+=(g[E+-240]-g[E+208])*a[$+-3],C-=g[E+224],he=C-Z,O=C+Z,Z=h[14],C=h[15]-Z,h[31]=O+Z,h[30]=he+C,h[15]=he-C,h[14]=O-Z}{var b;b=h[28]-h[0],h[0]+=h[28],h[28]=b*a[$+-2*18+7],b=h[29]-h[1],h[1]+=h[29],h[29]=b*a[$+-2*18+7],b=h[26]-h[2],h[2]+=h[26],h[26]=b*a[$+-4*18+7],b=h[27]-h[3],h[3]+=h[27],h[27]=b*a[$+-4*18+7],b=h[24]-h[4],h[4]+=h[24],h[24]=b*a[$+-6*18+7],b=h[25]-h[5],h[5]+=h[25],h[25]=b*a[$+-6*18+7],b=h[22]-h[6],h[6]+=h[22],h[22]=b*r.SQRT2,b=h[23]-h[7],h[7]+=h[23],h[23]=b*r.SQRT2-h[7],h[7]-=h[6],h[22]-=h[7],h[23]-=h[22],b=h[6],h[6]=h[31]-b,h[31]=h[31]+b,b=h[7],h[7]=h[30]-b,h[30]=h[30]+b,b=h[22],h[22]=h[15]-b,h[15]=h[15]+b,b=h[23],h[23]=h[14]-b,h[14]=h[14]+b,b=h[20]-h[8],h[8]+=h[20],h[20]=b*a[$+-10*18+7],b=h[21]-h[9],h[9]+=h[21],h[21]=b*a[$+-10*18+7],b=h[18]-h[10],h[10]+=h[18],h[18]=b*a[$+-12*18+7],b=h[19]-h[11],h[11]+=h[19],h[19]=b*a[$+-12*18+7],b=h[16]-h[12],h[12]+=h[16],h[16]=b*a[$+-14*18+7],b=h[17]-h[13],h[13]+=h[17],h[17]=b*a[$+-14*18+7],b=-h[20]+h[24],h[20]+=h[24],h[24]=b*a[$+-12*18+7],b=-h[21]+h[25],h[21]+=h[25],h[25]=b*a[$+-12*18+7],b=h[4]-h[8],h[4]+=h[8],h[8]=b*a[$+-12*18+7],b=h[5]-h[9],h[5]+=h[9],h[9]=b*a[$+-12*18+7],b=h[0]-h[12],h[0]+=h[12],h[12]=b*a[$+-4*18+7],b=h[1]-h[13],h[1]+=h[13],h[13]=b*a[$+-4*18+7],b=h[16]-h[28],h[16]+=h[28],h[28]=b*a[$+-4*18+7],b=-h[17]+h[29],h[17]+=h[29],h[29]=b*a[$+-4*18+7],b=r.SQRT2*(h[2]-h[10]),h[2]+=h[10],h[10]=b,b=r.SQRT2*(h[3]-h[11]),h[3]+=h[11],h[11]=b,b=r.SQRT2*(-h[18]+h[26]),h[18]+=h[26],h[26]=b-h[18],b=r.SQRT2*(-h[19]+h[27]),h[19]+=h[27],h[27]=b-h[19],b=h[2],h[19]-=h[3],h[3]-=b,h[2]=h[31]-b,h[31]+=b,b=h[3],h[11]-=h[19],h[18]-=b,h[3]=h[30]-b,h[30]+=b,b=h[18],h[27]-=h[11],h[19]-=b,h[18]=h[15]-b,h[15]+=b,b=h[19],h[10]-=b,h[19]=h[14]-b,h[14]+=b,b=h[10],h[11]-=b,h[10]=h[23]-b,h[23]+=b,b=h[11],h[26]-=b,h[11]=h[22]-b,h[22]+=b,b=h[26],h[27]-=b,h[26]=h[7]-b,h[7]+=b,b=h[27],h[27]=h[6]-b,h[6]+=b,b=r.SQRT2*(h[0]-h[4]),h[0]+=h[4],h[4]=b,b=r.SQRT2*(h[1]-h[5]),h[1]+=h[5],h[5]=b,b=r.SQRT2*(h[16]-h[20]),h[16]+=h[20],h[20]=b,b=r.SQRT2*(h[17]-h[21]),h[17]+=h[21],h[21]=b,b=-r.SQRT2*(h[8]-h[12]),h[8]+=h[12],h[12]=b-h[8],b=-r.SQRT2*(h[9]-h[13]),h[9]+=h[13],h[13]=b-h[9],b=-r.SQRT2*(h[25]-h[29]),h[25]+=h[29],h[29]=b-h[25],b=-r.SQRT2*(h[24]+h[28]),h[24]-=h[28],h[28]=b-h[24],b=h[24]-h[16],h[24]=b,b=h[20]-b,h[20]=b,b=h[28]-b,h[28]=b,b=h[25]-h[17],h[25]=b,b=h[21]-b,h[21]=b,b=h[29]-b,h[29]=b,b=h[17]-h[1],h[17]=b,b=h[9]-b,h[9]=b,b=h[25]-b,h[25]=b,b=h[5]-b,h[5]=b,b=h[21]-b,h[21]=b,b=h[13]-b,h[13]=b,b=h[29]-b,h[29]=b,b=h[1]-h[0],h[1]=b,b=h[16]-b,h[16]=b,b=h[17]-b,h[17]=b,b=h[8]-b,h[8]=b,b=h[9]-b,h[9]=b,b=h[24]-b,h[24]=b,b=h[25]-b,h[25]=b,b=h[4]-b,h[4]=b,b=h[5]-b,h[5]=b,b=h[20]-b,h[20]=b,b=h[21]-b,h[21]=b,b=h[12]-b,h[12]=b,b=h[13]-b,h[13]=b,b=h[28]-b,h[28]=b,b=h[29]-b,h[29]=b,b=h[0],h[0]+=h[31],h[31]-=b,b=h[1],h[1]+=h[30],h[30]-=b,b=h[16],h[16]+=h[15],h[15]-=b,b=h[17],h[17]+=h[14],h[14]-=b,b=h[8],h[8]+=h[23],h[23]-=b,b=h[9],h[9]+=h[22],h[22]-=b,b=h[24],h[24]+=h[7],h[7]-=b,b=h[25],h[25]+=h[6],h[6]-=b,b=h[4],h[4]+=h[27],h[27]-=b,b=h[5],h[5]+=h[26],h[26]-=b,b=h[20],h[20]+=h[11],h[11]-=b,b=h[21],h[21]+=h[10],h[10]-=b,b=h[12],h[12]+=h[19],h[19]-=b,b=h[13],h[13]+=h[18],h[18]-=b,b=h[28],h[28]+=h[3],h[3]-=b,b=h[29],h[29]+=h[2],h[2]-=b}}function x(g,E){for(var h=0;h<3;h++){var $,z,L,q,C,Z;q=g[E+2*3]*l[o.SHORT_TYPE][0]-g[E+5*3],$=g[E+0*3]*l[o.SHORT_TYPE][2]-g[E+3*3],z=q+$,L=q-$,q=g[E+5*3]*l[o.SHORT_TYPE][0]+g[E+2*3],$=g[E+3*3]*l[o.SHORT_TYPE][2]+g[E+0*3],C=q+$,Z=-q+$,$=(g[E+1*3]*l[o.SHORT_TYPE][1]-g[E+4*3])*2069978111953089e-26,q=(g[E+4*3]*l[o.SHORT_TYPE][1]+g[E+1*3])*2069978111953089e-26,g[E+3*0]=z*190752519173728e-25+$,g[E+3*5]=-C*190752519173728e-25+q,L=L*.8660254037844387*1907525191737281e-26,C=C*.5*1907525191737281e-26+q,g[E+3*1]=L-C,g[E+3*2]=L+C,z=z*.5*1907525191737281e-26-$,Z=Z*.8660254037844387*1907525191737281e-26,g[E+3*3]=z+Z,g[E+3*4]=z-Z,E++}}function _(g,E,h){var $,z;{var L,q,C,Z,he,O,b,j;L=h[17]-h[9],C=h[15]-h[11],Z=h[14]-h[12],he=h[0]+h[8],O=h[1]+h[7],b=h[2]+h[6],j=h[3]+h[5],g[E+17]=he+b-j-(O-h[4]),z=(he+b-j)*f[19]+(O-h[4]),$=(L-C-Z)*f[18],g[E+5]=$+z,g[E+6]=$-z,q=(h[16]-h[10])*f[18],O=O*f[19]+h[4],$=L*f[12]+q+C*f[13]+Z*f[14],z=-he*f[16]+O-b*f[17]+j*f[15],g[E+1]=$+z,g[E+2]=$-z,$=L*f[13]-q-C*f[14]+Z*f[12],z=-he*f[17]+O-b*f[15]+j*f[16],g[E+9]=$+z,g[E+10]=$-z,$=L*f[14]-q+C*f[12]-Z*f[13],z=he*f[15]-O+b*f[16]-j*f[17],g[E+13]=$+z,g[E+14]=$-z}{var A,G,F,Q,B,T,v,w;A=h[8]-h[0],F=h[6]-h[2],Q=h[5]-h[3],B=h[17]+h[9],T=h[16]+h[10],v=h[15]+h[11],w=h[14]+h[12],g[E+0]=B+v+w+(T+h[13]),$=(B+v+w)*f[19]-(T+h[13]),z=(A-F+Q)*f[18],g[E+11]=$+z,g[E+12]=$-z,G=(h[7]-h[1])*f[18],T=h[13]-T*f[19],$=B*f[15]-T+v*f[16]+w*f[17],z=A*f[14]+G+F*f[12]+Q*f[13],g[E+3]=$+z,g[E+4]=$-z,$=-B*f[17]+T-v*f[15]-w*f[16],z=A*f[13]+G-F*f[14]-Q*f[12],g[E+7]=$+z,g[E+8]=$-z,$=-B*f[16]+T-v*f[17]-w*f[15],z=A*f[12]-G+F*f[13]-Q*f[14],g[E+15]=$+z,g[E+16]=$-z}}this.mdct_sub48=function(g,E,h){for(var $=E,z=286,L=0;L<g.channels_out;L++){for(var q=0;q<g.mode_gr;q++){for(var C,Z=g.l3_side.tt[q][L],he=Z.xr,O=0,b=g.sb_sample[L][1-q],j=0,A=0;A<18/2;A++)for(k($,z,b[j]),k($,z+32,b[j+1]),j+=2,z+=64,C=1;C<32;C+=2)b[j-1][C]*=-1;for(C=0;C<32;C++,O+=18){var G=Z.block_type,F=g.sb_sample[L][q],Q=g.sb_sample[L][1-q];if(Z.mixed_block_flag!=0&&C<2&&(G=0),g.amp_filter[C]<1e-12)n.fill(he,O+0,O+18,0);else{if(g.amp_filter[C]<1)for(var A=0;A<18;A++)Q[A][y[C]]*=g.amp_filter[C];if(G==o.SHORT_TYPE){for(var A=-c/4;A<0;A++){var B=l[o.SHORT_TYPE][A+3];he[O+A*3+9]=F[9+A][y[C]]*B-F[8-A][y[C]],he[O+A*3+18]=F[14-A][y[C]]*B+F[15+A][y[C]],he[O+A*3+10]=F[15+A][y[C]]*B-F[14-A][y[C]],he[O+A*3+19]=Q[2-A][y[C]]*B+Q[3+A][y[C]],he[O+A*3+11]=Q[3+A][y[C]]*B-Q[2-A][y[C]],he[O+A*3+20]=Q[8-A][y[C]]*B+Q[9+A][y[C]]}x(he,O)}else{for(var T=s(18),A=-d/4;A<0;A++){var v,w;v=l[G][A+27]*Q[A+9][y[C]]+l[G][A+36]*Q[8-A][y[C]],w=l[G][A+9]*F[A+9][y[C]]-l[G][A+18]*F[8-A][y[C]],T[A+9]=v-w*u[3+A+9],T[A+18]=v*u[3+A+9]+w}_(he,O,T)}}if(G!=o.SHORT_TYPE&&C!=0)for(var A=7;A>=0;--A){var R,N;R=he[O+A]*p[20+A]+he[O+-1-A]*m[28+A],N=he[O+A]*m[28+A]-he[O+-1-A]*p[20+A],he[O+-1-A]=R,he[O+A]=N}}}if($=h,z=286,g.mode_gr==1)for(var K=0;K<18;K++)e.arraycopy(g.sb_sample[L][1][K],0,g.sb_sample[L][0][K],0,32)}}}return $1=i,$1}var E1,_3;function J3(){if(_3)return E1;_3=1;var t=br(),e=qt,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 E1=o,E1}var T1,b3;function eA(){if(b3)return T1;b3=1;var t=J3();function e(){this.thm=new t,this.en=new t}return T1=e,T1}function Mn(t){var e=t;this.ordinal=function(){return e}}Mn.STEREO=new Mn(0);Mn.JOINT_STEREO=new Mn(1);Mn.DUAL_CHANNEL=new Mn(2);Mn.MONO=new Mn(3);Mn.NOT_SET=new Mn(4);var ec=Mn,R1,y3;function br(){if(y3)return R1;y3=1;var t=qt,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=Qz(),l=eA(),u=ec,f=c.FFTOFFSET,p=c.MPG_MD_MS_LR,m=null;this.psy=null;var y=null,k=null,x=null;this.setModules=function($,z,L,q){m=$,this.psy=z,y=z,k=q,x=L};var _=new d;function g($){var z,L;if($.ATH.useAdjust==0){$.ATH.adjust=1;return}if(L=$.loudness_sq[0][0],z=$.loudness_sq[1][0],$.channels_out==2?(L+=$.loudness_sq[0][1],z+=$.loudness_sq[1][1]):(L+=L,z+=z),$.mode_gr==2&&(L=Math.max(L,z)),L*=.5,L*=$.ATH.aaSensitivityP,L>.03125)$.ATH.adjust>=1?$.ATH.adjust=1:$.ATH.adjust<$.ATH.adjustLimit&&($.ATH.adjust=$.ATH.adjustLimit),$.ATH.adjustLimit=1;else{var q=31.98*L+625e-6;$.ATH.adjust>=q?($.ATH.adjust*=q*.075+.925,$.ATH.adjust<q&&($.ATH.adjust=q)):$.ATH.adjustLimit>=q?$.ATH.adjust=q:$.ATH.adjust<$.ATH.adjustLimit&&($.ATH.adjust=$.ATH.adjustLimit),$.ATH.adjustLimit=q}}function E($){var z,L;for(a(0<=$.bitrate_index&&$.bitrate_index<16),a(0<=$.mode_ext&&$.mode_ext<4),$.bitrate_stereoMode_Hist[$.bitrate_index][4]++,$.bitrate_stereoMode_Hist[15][4]++,$.channels_out==2&&($.bitrate_stereoMode_Hist[$.bitrate_index][$.mode_ext]++,$.bitrate_stereoMode_Hist[15][$.mode_ext]++),z=0;z<$.mode_gr;++z)for(L=0;L<$.channels_out;++L){var q=$.l3_side.tt[z][L].block_type|0;$.l3_side.tt[z][L].mixed_block_flag!=0&&(q=4),$.bitrate_blockType_Hist[$.bitrate_index][q]++,$.bitrate_blockType_Hist[$.bitrate_index][5]++,$.bitrate_blockType_Hist[15][q]++,$.bitrate_blockType_Hist[15][5]++}}function h($,z){var L=$.internal_flags,q,C;if(L.lame_encode_frame_init==0){var Z,he,O=s(2014),b=s(2014);for(L.lame_encode_frame_init=1,Z=0,he=0;Z<286+576*(1+L.mode_gr);++Z)Z<576*L.mode_gr?(O[Z]=0,L.channels_out==2&&(b[Z]=0)):(O[Z]=z[0][he],L.channels_out==2&&(b[Z]=z[1][he]),++he);for(C=0;C<L.mode_gr;C++)for(q=0;q<L.channels_out;q++)L.l3_side.tt[C][q].block_type=c.SHORT_TYPE;_.mdct_sub48(L,O,b),a(576>=c.FFTOFFSET),a(L.mf_size>=c.BLKSIZE+$.framesize-c.FFTOFFSET),a(L.mf_size>=512+$.framesize-32)}}this.lame_encode_mp3_frame=function($,z,L,q,C,Z){var he,O=n([2,2]);O[0][0]=new l,O[0][1]=new l,O[1][0]=new l,O[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 j,A=[null,null],G=$.internal_flags,F=o([2,4]),Q=[.5,.5],B=[[0,0],[0,0]],T=[[0,0],[0,0]],v,w,R;if(A[0]=z,A[1]=L,G.lame_encode_frame_init==0&&h($,A),G.padding=0,(G.slot_lag-=G.frac_SpF)<0&&(G.slot_lag+=$.out_samplerate,G.padding=1),G.psymodel!=0){var N,K=[null,null],se=0,U=i(2);for(R=0;R<G.mode_gr;R++){for(w=0;w<G.channels_out;w++)K[w]=A[w],se=576+R*576-c.FFTOFFSET;if($.VBR==r.vbr_mtrh||$.VBR==r.vbr_mt?N=y.L3psycho_anal_vbr($,K,se,R,O,b,B[R],T[R],F[R],U):N=y.L3psycho_anal_ns($,K,se,R,O,b,B[R],T[R],F[R],U),N!=0)return-4;for($.mode==u.JOINT_STEREO&&(Q[R]=F[R][2]+F[R][3],Q[R]>0&&(Q[R]=F[R][3]/Q[R])),w=0;w<G.channels_out;w++){var ee=G.l3_side.tt[R][w];ee.block_type=U[w],ee.mixed_block_flag=0}}}else for(R=0;R<G.mode_gr;R++)for(w=0;w<G.channels_out;w++)G.l3_side.tt[R][w].block_type=c.NORM_TYPE,G.l3_side.tt[R][w].mixed_block_flag=0,T[R][w]=B[R][w]=700;if(g(G),_.mdct_sub48(G,A[0],A[1]),G.mode_ext=c.MPG_MD_LR_LR,$.force_ms)G.mode_ext=c.MPG_MD_MS_LR;else if($.mode==u.JOINT_STEREO){var de=0,_e=0;for(R=0;R<G.mode_gr;R++)for(w=0;w<G.channels_out;w++)de+=T[R][w],_e+=B[R][w];if(de<=1*_e){var ke=G.l3_side.tt[0],Pe=G.l3_side.tt[G.mode_gr-1];ke[0].block_type==ke[1].block_type&&Pe[0].block_type==Pe[1].block_type&&(G.mode_ext=c.MPG_MD_MS_LR)}}if(G.mode_ext==p?(j=b,v=T):(j=O,v=B),$.analysis&&G.pinfo!=null)for(R=0;R<G.mode_gr;R++)for(w=0;w<G.channels_out;w++)G.pinfo.ms_ratio[R]=G.ms_ratio[R],G.pinfo.ms_ener_ratio[R]=Q[R],G.pinfo.blocktype[R][w]=G.l3_side.tt[R][w].block_type,G.pinfo.pe[R][w]=v[R][w],e.arraycopy(G.l3_side.tt[R][w].xr,0,G.pinfo.xr[R][w],0,576),G.mode_ext==p&&(G.pinfo.ers[R][w]=G.pinfo.ers[R][w+2],e.arraycopy(G.pinfo.energy[R][w+2],0,G.pinfo.energy[R][w],0,G.pinfo.energy[R][w].length));if($.VBR==r.vbr_off||$.VBR==r.vbr_abr){var Te,$e;for(Te=0;Te<18;Te++)G.nsPsy.pefirbuf[Te]=G.nsPsy.pefirbuf[Te+1];for($e=0,R=0;R<G.mode_gr;R++)for(w=0;w<G.channels_out;w++)$e+=v[R][w];for(G.nsPsy.pefirbuf[18]=$e,$e=G.nsPsy.pefirbuf[9],Te=0;Te<9;Te++)$e+=(G.nsPsy.pefirbuf[Te]+G.nsPsy.pefirbuf[18-Te])*c.fircoef[Te];for($e=670*5*G.mode_gr*G.channels_out/$e,R=0;R<G.mode_gr;R++)for(w=0;w<G.channels_out;w++)v[R][w]*=$e}if(G.iteration_loop.iteration_loop($,v,Q,j),m.format_bitstream($),he=m.copy_buffer(G,q,C,Z,1),$.bWriteVbrTag&&k.addVbrFrame($),$.analysis&&G.pinfo!=null){for(w=0;w<G.channels_out;w++){var je;for(je=0;je<f;je++)G.pinfo.pcmdata[w][je]=G.pinfo.pcmdata[w][je+$.framesize];for(je=f;je<1600;je++)G.pinfo.pcmdata[w][je]=A[w][je-f]}x.set_frame_pinfo($,j)}return E(G),he}}return R1=c,R1}var Q3=qt,v3=Q3.Util,w3=Q3.new_float,Xt=br();function tA(){var t=w3(Xt.BLKSIZE),e=w3(Xt.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 f=i+a;d=4;do{var p,m,y,k,x,_,g;g=d>>1,k=d,x=d<<1,_=x+k,d=x<<1,l=i,u=l+g;do{var E,h,$,z;h=o[l+0]-o[l+k],E=o[l+0]+o[l+k],z=o[l+x]-o[l+_],$=o[l+x]+o[l+_],o[l+x]=E-$,o[l+0]=E+$,o[l+_]=h-z,o[l+k]=h+z,h=o[u+0]-o[u+k],E=o[u+0]+o[u+k],z=v3.SQRT2*o[u+_],$=v3.SQRT2*o[u+x],o[u+x]=E-$,o[u+0]=E+$,o[u+_]=h-z,o[u+k]=h+z,u+=d,l+=d}while(l<f);for(m=r[c+0],p=r[c+1],y=1;y<g;y++){var L,q;L=1-2*p*p,q=2*p*m,l=i+y,u=i+k-y;do{var C,Z,he,E,h,O,$,b,z,j;Z=q*o[l+k]-L*o[u+k],C=L*o[l+k]+q*o[u+k],h=o[l+0]-C,E=o[l+0]+C,O=o[u+0]-Z,he=o[u+0]+Z,Z=q*o[l+_]-L*o[u+_],C=L*o[l+_]+q*o[u+_],z=o[l+x]-C,$=o[l+x]+C,j=o[u+x]-Z,b=o[u+x]+Z,Z=p*$-m*j,C=m*$+p*j,o[l+x]=E-C,o[l+0]=E+C,o[u+_]=O-Z,o[u+k]=O+Z,Z=m*b-p*z,C=p*b+m*z,o[u+x]=he-C,o[u+0]=he+C,o[l+_]=h-Z,o[l+k]=h+Z,u+=d,l+=d}while(l<f);L=m,m=L*r[c+0]-p*r[c+1],p=L*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=Xt.BLKSIZE_s/2,f=65535&576/3*(l+1),p=Xt.BLKSIZE_s/8-1;do{var m,y,k,x,_,g=s[p<<2]&255;m=e[g]*c[a][d+g+f],_=e[127-g]*c[a][d+g+f+128],y=m-_,m=m+_,k=e[g+64]*c[a][d+g+f+64],_=e[63-g]*c[a][d+g+f+192],x=k-_,k=k+_,u-=4,i[l][u+0]=m+k,i[l][u+2]=m-k,i[l][u+1]=y+x,i[l][u+3]=y-x,m=e[g+1]*c[a][d+g+f+1],_=e[126-g]*c[a][d+g+f+129],y=m-_,m=m+_,k=e[g+65]*c[a][d+g+f+65],_=e[62-g]*c[a][d+g+f+193],x=k-_,k=k+_,i[l][u+Xt.BLKSIZE_s/2+0]=m+k,i[l][u+Xt.BLKSIZE_s/2+2]=m-k,i[l][u+Xt.BLKSIZE_s/2+1]=y+x,i[l][u+Xt.BLKSIZE_s/2+3]=y-x}while(--p>=0);n(i[l],u,Xt.BLKSIZE_s/2)}},this.fft_long=function(o,i,a,c,d){var l=Xt.BLKSIZE/8-1,u=Xt.BLKSIZE/2;do{var f,p,m,y,k,x=s[l]&255;f=t[x]*c[a][d+x],k=t[x+512]*c[a][d+x+512],p=f-k,f=f+k,m=t[x+256]*c[a][d+x+256],k=t[x+768]*c[a][d+x+768],y=m-k,m=m+k,u-=4,i[u+0]=f+m,i[u+2]=f-m,i[u+1]=p+y,i[u+3]=p-y,f=t[x+1]*c[a][d+x+1],k=t[x+513]*c[a][d+x+513],p=f-k,f=f+k,m=t[x+257]*c[a][d+x+257],k=t[x+769]*c[a][d+x+769],y=m-k,m=m+k,i[u+Xt.BLKSIZE/2+0]=f+m,i[u+Xt.BLKSIZE/2+2]=f-m,i[u+Xt.BLKSIZE/2+1]=p+y,i[u+Xt.BLKSIZE/2+3]=p-y}while(--l>=0);n(i,u,Xt.BLKSIZE/2)},this.init_fft=function(o){for(var i=0;i<Xt.BLKSIZE;i++)t[i]=.42-.5*Math.cos(2*Math.PI*(i+.5)/Xt.BLKSIZE)+.08*Math.cos(4*Math.PI*(i+.5)/Xt.BLKSIZE);for(var i=0;i<Xt.BLKSIZE_s/2;i++)e[i]=.5*(1-Math.cos(2*Math.PI*(i+.5)/Xt.BLKSIZE_s))}}var rA=tA,rs=qt,Si=rs.VbrMode,x3=rs.Float,ki=rs.ShortBlock,jr=rs.Util,nA=rs.Arrays,Kt=rs.new_float,dn=rs.new_float_n,So=rs.new_int,et=rs.assert,sA=rA,ae=br();function oA(){var t=ec,e=new sA,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,f=.3,p=3.5,m=21,y=.2302585093;function k(M){return M}function x(M,I){for(var V=0,H=0;H<ae.BLKSIZE/2;++H)V+=M[H]*I.ATH.eql_w[H];return V*=c,V}function _(M,I,V,H,J,D,Y,te,X,oe,re){var ie=M.internal_flags;if(X<2)e.fft_long(ie,H[J],X,oe,re),e.fft_short(ie,D[Y],X,oe,re);else if(X==2){for(var ve=ae.BLKSIZE-1;ve>=0;--ve){var Ve=H[J+0][ve],fe=H[J+1][ve];H[J+0][ve]=(Ve+fe)*jr.SQRT2*.5,H[J+1][ve]=(Ve-fe)*jr.SQRT2*.5}for(var Le=2;Le>=0;--Le)for(var ve=ae.BLKSIZE_s-1;ve>=0;--ve){var Ve=D[Y+0][Le][ve],fe=D[Y+1][Le][ve];D[Y+0][Le][ve]=(Ve+fe)*jr.SQRT2*.5,D[Y+1][Le][ve]=(Ve-fe)*jr.SQRT2*.5}}I[0]=H[J+0][0],I[0]*=I[0];for(var ve=ae.BLKSIZE/2-1;ve>=0;--ve){var ne=H[J+0][ae.BLKSIZE/2-ve],Re=H[J+0][ae.BLKSIZE/2+ve];I[ae.BLKSIZE/2-ve]=(ne*ne+Re*Re)*.5}for(var Le=2;Le>=0;--Le){V[Le][0]=D[Y+0][Le][0],V[Le][0]*=V[Le][0];for(var ve=ae.BLKSIZE_s/2-1;ve>=0;--ve){var ne=D[Y+0][Le][ae.BLKSIZE_s/2-ve],Re=D[Y+0][Le][ae.BLKSIZE_s/2+ve];V[Le][ae.BLKSIZE_s/2-ve]=(ne*ne+Re*Re)*.5}}{for(var rt=0,ve=11;ve<ae.HBLKSIZE;ve++)rt+=I[ve];ie.tot_ener[X]=rt}if(M.analysis){for(var ve=0;ve<ae.HBLKSIZE;ve++)ie.pinfo.energy[te][X][ve]=ie.pinfo.energy_save[X][ve],ie.pinfo.energy_save[X][ve]=I[ve];ie.pinfo.pe[te][X]=ie.pe[X]}M.athaa_loudapprox==2&&X<2&&(ie.loudness_sq[te][X]=ie.loudness_sq_save[X],ie.loudness_sq_save[X]=x(I,ie))}var g=8,E=23,h=15,$,z,L,q=[1,.79433,.63096,.63096,.63096,.63096,.63096,.25119,.11749];function C(){$=Math.pow(10,(g+1)/16),z=Math.pow(10,(E+1)/16),L=Math.pow(10,h/10)}var Z=[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],he=[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],O=[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,I,V,H,J,D){var Y;if(I>M)if(I<M*z)Y=I/M;else return M+I;else{if(M>=I*z)return M+I;Y=M/I}if(M+=I,H+3<=6){if(Y>=$)return M;var te=0|jr.FAST_LOG10_X(Y,16);return M*he[te]}var te=0|jr.FAST_LOG10_X(Y,16);if(D!=0?I=J.ATH.cb_s[V]*J.ATH.adjust:I=J.ATH.cb_l[V]*J.ATH.adjust,M<L*I){if(M>I){var X,oe;return X=1,te<=13&&(X=O[te]),oe=jr.FAST_LOG10_X(M/I,10/15),M*((Z[te]-X)*oe+X)}return te>13?M:M*O[te]}return M*Z[te]}var j=[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 A(M,I,V){var H;if(M<0&&(M=0),I<0&&(I=0),M<=0)return I;if(I<=0)return M;if(I>M?H=I/M:H=M/I,-2<=V&&V<=2){if(H>=$)return M+I;var J=0|jr.FAST_LOG10_X(H,16);return(M+I)*j[J]}return H<z?M+I:(M<I&&(M=I),M)}function G(M,I){var V=M.internal_flags;if(V.channels_out>1){for(var H=0;H<ae.SBMAX_l;H++){var J=V.thm[0].l[H],D=V.thm[1].l[H];V.thm[0].l[H]+=D*I,V.thm[1].l[H]+=J*I}for(var H=0;H<ae.SBMAX_s;H++)for(var Y=0;Y<3;Y++){var J=V.thm[0].s[H][Y],D=V.thm[1].s[H][Y];V.thm[0].s[H][Y]+=D*I,V.thm[1].s[H][Y]+=J*I}}}function F(M){for(var I=0;I<ae.SBMAX_l;I++)if(!(M.thm[0].l[I]>1.58*M.thm[1].l[I]||M.thm[1].l[I]>1.58*M.thm[0].l[I])){var V=M.mld_l[I]*M.en[3].l[I],H=Math.max(M.thm[2].l[I],Math.min(M.thm[3].l[I],V));V=M.mld_l[I]*M.en[2].l[I];var J=Math.max(M.thm[3].l[I],Math.min(M.thm[2].l[I],V));M.thm[2].l[I]=H,M.thm[3].l[I]=J}for(var I=0;I<ae.SBMAX_s;I++)for(var D=0;D<3;D++)if(!(M.thm[0].s[I][D]>1.58*M.thm[1].s[I][D]||M.thm[1].s[I][D]>1.58*M.thm[0].s[I][D])){var V=M.mld_s[I]*M.en[3].s[I][D],H=Math.max(M.thm[2].s[I][D],Math.min(M.thm[3].s[I][D],V));V=M.mld_s[I]*M.en[2].s[I][D];var J=Math.max(M.thm[3].s[I][D],Math.min(M.thm[2].s[I][D],V));M.thm[2].s[I][D]=H,M.thm[3].s[I][D]=J}}function Q(M,I,V){var H=I,J=Math.pow(10,V);I*=2,H*=2;for(var D=0;D<ae.SBMAX_l;D++){var Y,te,X,oe;if(oe=M.ATH.cb_l[M.bm_l[D]]*J,Y=Math.min(Math.max(M.thm[0].l[D],oe),Math.max(M.thm[1].l[D],oe)),te=Math.max(M.thm[2].l[D],oe),X=Math.max(M.thm[3].l[D],oe),Y*I<te+X){var re=Y*H/(te+X);te*=re,X*=re}M.thm[2].l[D]=Math.min(te,M.thm[2].l[D]),M.thm[3].l[D]=Math.min(X,M.thm[3].l[D])}J*=ae.BLKSIZE_s/ae.BLKSIZE;for(var D=0;D<ae.SBMAX_s;D++)for(var ie=0;ie<3;ie++){var Y,te,X,oe;if(oe=M.ATH.cb_s[M.bm_s[D]]*J,Y=Math.min(Math.max(M.thm[0].s[D][ie],oe),Math.max(M.thm[1].s[D][ie],oe)),te=Math.max(M.thm[2].s[D][ie],oe),X=Math.max(M.thm[3].s[D][ie],oe),Y*I<te+X){var re=Y*I/(te+X);te*=re,X*=re}M.thm[2].s[D][ie]=Math.min(M.thm[2].s[D][ie],te),M.thm[3].s[D][ie]=Math.min(M.thm[3].s[D][ie],X)}}function B(M,I,V,H,J){var D,Y,te=0,X=0;for(D=Y=0;D<ae.SBMAX_s;++Y,++D){for(var oe=M.bo_s[D],re=M.npart_s,ie=oe<re?oe:re;Y<ie;)et(I[Y]>=0),et(V[Y]>=0),te+=I[Y],X+=V[Y],Y++;if(M.en[H].s[D][J]=te,M.thm[H].s[D][J]=X,Y>=re){++D;break}et(I[Y]>=0),et(V[Y]>=0);{var ve=M.PSY.bo_s_weight[D],Ve=1-ve;te=ve*I[Y],X=ve*V[Y],M.en[H].s[D][J]+=te,M.thm[H].s[D][J]+=X,te=Ve*I[Y],X=Ve*V[Y]}}for(;D<ae.SBMAX_s;++D)M.en[H].s[D][J]=0,M.thm[H].s[D][J]=0}function T(M,I,V,H){var J,D,Y=0,te=0;for(J=D=0;J<ae.SBMAX_l;++D,++J){for(var X=M.bo_l[J],oe=M.npart_l,re=X<oe?X:oe;D<re;)et(I[D]>=0),et(V[D]>=0),Y+=I[D],te+=V[D],D++;if(M.en[H].l[J]=Y,M.thm[H].l[J]=te,D>=oe){++J;break}et(I[D]>=0),et(V[D]>=0);{var ie=M.PSY.bo_l_weight[J],ve=1-ie;Y=ie*I[D],te=ie*V[D],M.en[H].l[J]+=Y,M.thm[H].l[J]+=te,Y=ve*I[D],te=ve*V[D]}}for(;J<ae.SBMAX_l;++J)M.en[H].l[J]=0,M.thm[H].l[J]=0}function v(M,I,V,H,J,D){var Y=M.internal_flags,te,X;for(X=te=0;X<Y.npart_s;++X){for(var oe=0,re=Y.numlines_s[X],ie=0;ie<re;++ie,++te){var ve=I[D][te];oe+=ve}V[X]=oe}for(et(X==Y.npart_s),te=X=0;X<Y.npart_s;X++){var Ve=Y.s3ind_s[X][0],fe=Y.s3_ss[te++]*V[Ve];for(++Ve;Ve<=Y.s3ind_s[X][1];)fe+=Y.s3_ss[te]*V[Ve],++te,++Ve;{var Le=o*Y.nb_s1[J][X];H[X]=Math.min(fe,Le)}if(Y.blocktype_old[J&1]==ae.SHORT_TYPE){var Le=i*Y.nb_s2[J][X],ne=H[X];H[X]=Math.min(Le,ne)}Y.nb_s2[J][X]=Y.nb_s1[J][X],Y.nb_s1[J][X]=fe,et(H[X]>=0)}for(;X<=ae.CBANDS;++X)V[X]=0,H[X]=0}function w(M,I,V,H){var J=M.internal_flags;M.short_blocks==ki.short_block_coupled&&!(I[0]!=0&&I[1]!=0)&&(I[0]=I[1]=0);for(var D=0;D<J.channels_out;D++)H[D]=ae.NORM_TYPE,M.short_blocks==ki.short_block_dispensed&&(I[D]=1),M.short_blocks==ki.short_block_forced&&(I[D]=0),I[D]!=0?(et(J.blocktype_old[D]!=ae.START_TYPE),J.blocktype_old[D]==ae.SHORT_TYPE&&(H[D]=ae.STOP_TYPE)):(H[D]=ae.SHORT_TYPE,J.blocktype_old[D]==ae.NORM_TYPE&&(J.blocktype_old[D]=ae.START_TYPE),J.blocktype_old[D]==ae.STOP_TYPE&&(J.blocktype_old[D]=ae.SHORT_TYPE)),V[D]=J.blocktype_old[D],J.blocktype_old[D]=H[D]}function R(M,I,V){return V>=1?M:V<=0?I:I>0?Math.pow(M/I,V)*I:0}var N=[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,I){for(var V=309.07,H=0;H<ae.SBMAX_s-1;H++)for(var J=0;J<3;J++){var D=M.thm.s[H][J];if(D>0){var Y=D*I,te=M.en.s[H][J];te>Y&&(te>Y*1e10?V+=N[H]*(10*r):V+=N[H]*jr.FAST_LOG10(te/Y))}}return V}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 U(M,I){for(var V=281.0575,H=0;H<ae.SBMAX_l-1;H++){var J=M.thm.l[H];if(J>0){var D=J*I,Y=M.en.l[H];Y>D&&(Y>D*1e10?V+=se[H]*(10*r):V+=se[H]*jr.FAST_LOG10(Y/D))}}return V}function ee(M,I,V,H,J){var D,Y;for(D=Y=0;D<M.npart_l;++D){var te=0,X=0,oe;for(oe=0;oe<M.numlines_l[D];++oe,++Y){var re=I[Y];te+=re,X<re&&(X=re)}V[D]=te,H[D]=X,J[D]=te*M.rnumlines_l[D],et(M.rnumlines_l[D]>=0),et(V[D]>=0),et(H[D]>=0),et(J[D]>=0)}}function de(M,I,V,H){var J=q.length-1,D=0,Y=V[D]+V[D+1];if(Y>0){var te=I[D];te<I[D+1]&&(te=I[D+1]),et(M.numlines_l[D]+M.numlines_l[D+1]-1>0),Y=20*(te*2-Y)/(Y*(M.numlines_l[D]+M.numlines_l[D+1]-1));var X=0|Y;X>J&&(X=J),H[D]=X}else H[D]=0;for(D=1;D<M.npart_l-1;D++)if(Y=V[D-1]+V[D]+V[D+1],Y>0){var te=I[D-1];te<I[D]&&(te=I[D]),te<I[D+1]&&(te=I[D+1]),et(M.numlines_l[D-1]+M.numlines_l[D]+M.numlines_l[D+1]-1>0),Y=20*(te*3-Y)/(Y*(M.numlines_l[D-1]+M.numlines_l[D]+M.numlines_l[D+1]-1));var X=0|Y;X>J&&(X=J),H[D]=X}else H[D]=0;if(et(D==M.npart_l-1),Y=V[D-1]+V[D],Y>0){var te=I[D-1];te<I[D]&&(te=I[D]),et(M.numlines_l[D-1]+M.numlines_l[D]-1>0),Y=20*(te*2-Y)/(Y*(M.numlines_l[D-1]+M.numlines_l[D]-1));var X=0|Y;X>J&&(X=J),H[D]=X}else H[D]=0;et(D==M.npart_l-1)}var _e=[-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,I,V,H,J,D,Y,te,X,oe){var re=M.internal_flags,ie=dn([2,ae.BLKSIZE]),ve=dn([2,3,ae.BLKSIZE_s]),Ve=Kt(ae.CBANDS+1),fe=Kt(ae.CBANDS+1),Le=Kt(ae.CBANDS+2),ne=So(2),Re=So(2),rt,pe,ze,me,qe,Pt,xe,Je,st=dn([2,576]),Ct,Zr=So(ae.CBANDS+2),Wt=So(ae.CBANDS+2);for(nA.fill(Wt,0),rt=re.channels_out,M.mode==t.JOINT_STEREO&&(rt=4),M.VBR==Si.vbr_off?Ct=re.ResvMax==0?0:re.ResvSize/re.ResvMax*.5:M.VBR==Si.vbr_rh||M.VBR==Si.vbr_mtrh||M.VBR==Si.vbr_mt?Ct=.6:Ct=1,pe=0;pe<re.channels_out;pe++){var jt=I[pe],Er=V+576-350-m+192;for(me=0;me<576;me++){var Br,Vr;for(Br=jt[Er+me+10],Vr=0,qe=0;qe<(m-1)/2-1;qe+=2)Br+=_e[qe]*(jt[Er+me+qe]+jt[Er+me+m-qe]),Vr+=_e[qe+1]*(jt[Er+me+qe+1]+jt[Er+me+m-qe-1]);st[pe][me]=Br+Vr}J[H][pe].en.assign(re.en[pe]),J[H][pe].thm.assign(re.thm[pe]),rt>2&&(D[H][pe].en.assign(re.en[pe+2]),D[H][pe].thm.assign(re.thm[pe+2]))}for(pe=0;pe<rt;pe++){var mn,gn,hr=Kt(12),In=[0,0,0,0],Io=Kt(12),Uu=1,m0,g0=Kt(ae.CBANDS),_0=Kt(ae.CBANDS),Dt=[0,0,0,0],b0=Kt(ae.HBLKSIZE),y0=dn([3,ae.HBLKSIZE_s]);for(et(re.npart_s<=ae.CBANDS),et(re.npart_l<=ae.CBANDS),me=0;me<3;me++)hr[me]=re.nsPsy.last_en_subshort[pe][me+6],et(re.nsPsy.last_en_subshort[pe][me+4]>0),Io[me]=hr[me]/re.nsPsy.last_en_subshort[pe][me+4],In[0]+=hr[me];if(pe==2)for(me=0;me<576;me++){var Hu,Gu;Hu=st[0][me],Gu=st[1][me],st[0][me]=Hu+Gu,st[1][me]=Hu-Gu}{var v0=st[pe&1],Ii=0;for(me=0;me<9;me++){for(var Sx=Ii+64,sr=1;Ii<Sx;Ii++)sr<Math.abs(v0[Ii])&&(sr=Math.abs(v0[Ii]));re.nsPsy.last_en_subshort[pe][me]=hr[me+3]=sr,In[1+me/3]+=sr,sr>hr[me+3-2]?(et(hr[me+3-2]>0),sr=sr/hr[me+3-2]):hr[me+3-2]>sr*10?sr=hr[me+3-2]/(sr*10):sr=0,Io[me+3]=sr}}if(M.analysis){var Wu=Io[0];for(me=1;me<12;me++)Wu<Io[me]&&(Wu=Io[me]);re.pinfo.ers[H][pe]=re.pinfo.ers_save[pe],re.pinfo.ers_save[pe]=Wu}for(m0=pe==3?re.nsPsy.attackthre_s:re.nsPsy.attackthre,me=0;me<12;me++)Dt[me/3]==0&&Io[me]>m0&&(Dt[me/3]=me%3+1);for(me=1;me<4;me++){var Yu;In[me-1]>In[me]?(et(In[me]>0),Yu=In[me-1]/In[me]):(et(In[me-1]>0),Yu=In[me]/In[me-1]),Yu<1.7&&(Dt[me]=0,me==1&&(Dt[0]=0))}for(Dt[0]!=0&&re.nsPsy.lastAttacks[pe]!=0&&(Dt[0]=0),(re.nsPsy.lastAttacks[pe]==3||Dt[0]+Dt[1]+Dt[2]+Dt[3]!=0)&&(Uu=0,Dt[1]!=0&&Dt[0]!=0&&(Dt[1]=0),Dt[2]!=0&&Dt[1]!=0&&(Dt[2]=0),Dt[3]!=0&&Dt[2]!=0&&(Dt[3]=0)),pe<2?Re[pe]=Uu:Uu==0&&(Re[0]=Re[1]=0),X[pe]=re.tot_ener[pe],gn=ve,mn=ie,_(M,b0,y0,mn,pe&1,gn,pe&1,H,pe,I,V),ee(re,b0,Ve,g0,_0),de(re,g0,_0,Zr),Je=0;Je<3;Je++){var Xu,Tr;for(v(M,y0,fe,Le,pe,Je),B(re,fe,Le,pe,Je),xe=0;xe<ae.SBMAX_s;xe++){if(Tr=re.thm[pe].s[xe][Je],Tr*=l,Dt[Je]>=2||Dt[Je+1]==1){var zi=Je!=0?Je-1:2,sr=R(re.thm[pe].s[xe][zi],Tr,u*Ct);Tr=Math.min(Tr,sr)}if(Dt[Je]==1){var zi=Je!=0?Je-1:2,sr=R(re.thm[pe].s[xe][zi],Tr,f*Ct);Tr=Math.min(Tr,sr)}else if(Je!=0&&Dt[Je-1]==3||Je==0&&re.nsPsy.lastAttacks[pe]==3){var zi=Je!=2?Je+1:0,sr=R(re.thm[pe].s[xe][zi],Tr,f*Ct);Tr=Math.min(Tr,sr)}Xu=hr[Je*3+3]+hr[Je*3+4]+hr[Je*3+5],hr[Je*3+5]*6<Xu&&(Tr*=.5,hr[Je*3+4]*6<Xu&&(Tr*=.5)),re.thm[pe].s[xe][Je]=Tr}}for(re.nsPsy.lastAttacks[pe]=Dt[2],Pt=0,ze=0;ze<re.npart_l;ze++){for(var As=re.s3ind[ze][0],Ku=Ve[As]*q[Zr[As]],Os=re.s3_ll[Pt++]*Ku;++As<=re.s3ind[ze][1];)Ku=Ve[As]*q[Zr[As]],Os=b(Os,re.s3_ll[Pt++]*Ku,As,As-ze,re,0);Os*=.158489319246111,re.blocktype_old[pe&1]==ae.SHORT_TYPE?Le[ze]=Os:Le[ze]=R(Math.min(Os,Math.min(n*re.nb_1[pe][ze],s*re.nb_2[pe][ze])),Os,Ct),re.nb_2[pe][ze]=re.nb_1[pe][ze],re.nb_1[pe][ze]=Os}for(;ze<=ae.CBANDS;++ze)Ve[ze]=0,Le[ze]=0;T(re,Ve,Le,pe)}if((M.mode==t.STEREO||M.mode==t.JOINT_STEREO)&&M.interChRatio>0&&G(M,M.interChRatio),M.mode==t.JOINT_STEREO){var Ju;F(re),Ju=M.msfix,Math.abs(Ju)>0&&Q(re,Ju,M.ATHlower*re.ATH.adjust)}for(w(M,Re,oe,ne),pe=0;pe<rt;pe++){var Ai,Oi=0,ac,cc;pe>1?(Ai=te,Oi=-2,ac=ae.NORM_TYPE,(oe[0]==ae.SHORT_TYPE||oe[1]==ae.SHORT_TYPE)&&(ac=ae.SHORT_TYPE),cc=D[H][pe-2]):(Ai=Y,Oi=0,ac=oe[pe],cc=J[H][pe]),ac==ae.SHORT_TYPE?Ai[Oi+pe]=K(cc,re.masking_lower):Ai[Oi+pe]=U(cc,re.masking_lower),M.analysis&&(re.pinfo.pe[H][pe]=Ai[Oi+pe])}return 0};function ke(M,I,V,H,J,D,Y,te){var X=M.internal_flags;if(H<2)e.fft_long(X,Y[te],H,I,V);else if(H==2)for(var oe=ae.BLKSIZE-1;oe>=0;--oe){var re=Y[te+0][oe],ie=Y[te+1][oe];Y[te+0][oe]=(re+ie)*jr.SQRT2*.5,Y[te+1][oe]=(re-ie)*jr.SQRT2*.5}D[0]=Y[te+0][0],D[0]*=D[0];for(var oe=ae.BLKSIZE/2-1;oe>=0;--oe){var ve=Y[te+0][ae.BLKSIZE/2-oe],Ve=Y[te+0][ae.BLKSIZE/2+oe];D[ae.BLKSIZE/2-oe]=(ve*ve+Ve*Ve)*.5}{for(var fe=0,oe=11;oe<ae.HBLKSIZE;oe++)fe+=D[oe];X.tot_ener[H]=fe}if(M.analysis){for(var oe=0;oe<ae.HBLKSIZE;oe++)X.pinfo.energy[J][H][oe]=X.pinfo.energy_save[H][oe],X.pinfo.energy_save[H][oe]=D[oe];X.pinfo.pe[J][H]=X.pe[H]}}function Pe(M,I,V,H,J,D,Y,te){var X=M.internal_flags;if(J==0&&H<2&&e.fft_short(X,Y[te],H,I,V),H==2)for(var oe=ae.BLKSIZE_s-1;oe>=0;--oe){var re=Y[te+0][J][oe],ie=Y[te+1][J][oe];Y[te+0][J][oe]=(re+ie)*jr.SQRT2*.5,Y[te+1][J][oe]=(re-ie)*jr.SQRT2*.5}D[J][0]=Y[te+0][J][0],D[J][0]*=D[J][0];for(var oe=ae.BLKSIZE_s/2-1;oe>=0;--oe){var ve=Y[te+0][J][ae.BLKSIZE_s/2-oe],Ve=Y[te+0][J][ae.BLKSIZE_s/2+oe];D[J][ae.BLKSIZE_s/2-oe]=(ve*ve+Ve*Ve)*.5}}function Te(M,I,V,H){var J=M.internal_flags;M.athaa_loudapprox==2&&V<2&&(J.loudness_sq[I][V]=J.loudness_sq_save[V],J.loudness_sq_save[V]=x(H,J))}var $e=[-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 je(M,I,V,H,J,D,Y,te,X,oe){for(var re=dn([2,576]),ie=M.internal_flags,ve=ie.channels_out,Ve=M.mode==t.JOINT_STEREO?4:ve,fe=0;fe<ve;fe++){firbuf=I[fe];for(var Le=V+576-350-m+192,ne=0;ne<576;ne++){var Re,rt;Re=firbuf[Le+ne+10],rt=0;for(var pe=0;pe<(m-1)/2-1;pe+=2)Re+=$e[pe]*(firbuf[Le+ne+pe]+firbuf[Le+ne+m-pe]),rt+=$e[pe+1]*(firbuf[Le+ne+pe+1]+firbuf[Le+ne+m-pe-1]);re[fe][ne]=Re+rt}J[H][fe].en.assign(ie.en[fe]),J[H][fe].thm.assign(ie.thm[fe]),Ve>2&&(D[H][fe].en.assign(ie.en[fe+2]),D[H][fe].thm.assign(ie.thm[fe+2]))}for(var fe=0;fe<Ve;fe++){var ze=Kt(12),me=Kt(12),qe=[0,0,0,0],Pt=re[fe&1],xe=0,Je=fe==3?ie.nsPsy.attackthre_s:ie.nsPsy.attackthre,st=1;if(fe==2)for(var ne=0,pe=576;pe>0;++ne,--pe){var Ct=re[0][ne],Zr=re[1][ne];re[0][ne]=Ct+Zr,re[1][ne]=Ct-Zr}for(var ne=0;ne<3;ne++)me[ne]=ie.nsPsy.last_en_subshort[fe][ne+6],et(ie.nsPsy.last_en_subshort[fe][ne+4]>0),ze[ne]=me[ne]/ie.nsPsy.last_en_subshort[fe][ne+4],qe[0]+=me[ne];for(var ne=0;ne<9;ne++){for(var Wt=xe+64,jt=1;xe<Wt;xe++)jt<Math.abs(Pt[xe])&&(jt=Math.abs(Pt[xe]));ie.nsPsy.last_en_subshort[fe][ne]=me[ne+3]=jt,qe[1+ne/3]+=jt,jt>me[ne+3-2]?(et(me[ne+3-2]>0),jt=jt/me[ne+3-2]):me[ne+3-2]>jt*10?jt=me[ne+3-2]/(jt*10):jt=0,ze[ne+3]=jt}for(var ne=0;ne<3;++ne){var Er=me[ne*3+3]+me[ne*3+4]+me[ne*3+5],Br=1;me[ne*3+5]*6<Er&&(Br*=.5,me[ne*3+4]*6<Er&&(Br*=.5)),te[fe][ne]=Br}if(M.analysis){for(var Vr=ze[0],ne=1;ne<12;ne++)Vr<ze[ne]&&(Vr=ze[ne]);ie.pinfo.ers[H][fe]=ie.pinfo.ers_save[fe],ie.pinfo.ers_save[fe]=Vr}for(var ne=0;ne<12;ne++)X[fe][ne/3]==0&&ze[ne]>Je&&(X[fe][ne/3]=ne%3+1);for(var ne=1;ne<4;ne++){var mn=qe[ne-1],gn=qe[ne],hr=Math.max(mn,gn);hr<4e4&&mn<1.7*gn&&gn<1.7*mn&&(ne==1&&X[fe][0]<=X[fe][ne]&&(X[fe][0]=0),X[fe][ne]=0)}X[fe][0]<=ie.nsPsy.lastAttacks[fe]&&(X[fe][0]=0),(ie.nsPsy.lastAttacks[fe]==3||X[fe][0]+X[fe][1]+X[fe][2]+X[fe][3]!=0)&&(st=0,X[fe][1]!=0&&X[fe][0]!=0&&(X[fe][1]=0),X[fe][2]!=0&&X[fe][1]!=0&&(X[fe][2]=0),X[fe][3]!=0&&X[fe][2]!=0&&(X[fe][3]=0)),fe<2?oe[fe]=st:st==0&&(oe[0]=oe[1]=0),Y[fe]=ie.tot_ener[fe]}}function Tt(M,I,V){if(V==0)for(var H=0;H<M.npart_s;H++)M.nb_s2[I][H]=M.nb_s1[I][H],M.nb_s1[I][H]=0}function Kr(M,I){for(var V=0;V<M.npart_l;V++)M.nb_2[I][V]=M.nb_1[I][V],M.nb_1[I][V]=0}function S(M,I,V,H){var J=q.length-1,D=0,Y=V[D]+V[D+1];if(Y>0){var te=I[D];te<I[D+1]&&(te=I[D+1]),et(M.numlines_s[D]+M.numlines_s[D+1]-1>0),Y=20*(te*2-Y)/(Y*(M.numlines_s[D]+M.numlines_s[D+1]-1));var X=0|Y;X>J&&(X=J),H[D]=X}else H[D]=0;for(D=1;D<M.npart_s-1;D++)if(Y=V[D-1]+V[D]+V[D+1],et(D+1<M.npart_s),Y>0){var te=I[D-1];te<I[D]&&(te=I[D]),te<I[D+1]&&(te=I[D+1]),et(M.numlines_s[D-1]+M.numlines_s[D]+M.numlines_s[D+1]-1>0),Y=20*(te*3-Y)/(Y*(M.numlines_s[D-1]+M.numlines_s[D]+M.numlines_s[D+1]-1));var X=0|Y;X>J&&(X=J),H[D]=X}else H[D]=0;if(et(D==M.npart_s-1),Y=V[D-1]+V[D],Y>0){var te=I[D-1];te<I[D]&&(te=I[D]),et(M.numlines_s[D-1]+M.numlines_s[D]-1>0),Y=20*(te*2-Y)/(Y*(M.numlines_s[D-1]+M.numlines_s[D]-1));var X=0|Y;X>J&&(X=J),H[D]=X}else H[D]=0;et(D==M.npart_s-1)}function P(M,I,V,H,J,D){var Y=M.internal_flags,te=new float[ae.CBANDS],X=Kt(ae.CBANDS),oe,re,ie,ve=new int[ae.CBANDS];for(ie=re=0;ie<Y.npart_s;++ie){var Ve=0,fe=0,Le=Y.numlines_s[ie];for(oe=0;oe<Le;++oe,++re){var ne=I[D][re];Ve+=ne,fe<ne&&(fe=ne)}V[ie]=Ve,te[ie]=fe,X[ie]=Ve/Le,et(X[ie]>=0)}for(et(ie==Y.npart_s);ie<ae.CBANDS;++ie)te[ie]=0,X[ie]=0;for(S(Y,te,X,ve),re=ie=0;ie<Y.npart_s;ie++){var Re=Y.s3ind_s[ie][0],rt=Y.s3ind_s[ie][1],pe,ze,me,qe,Pt;for(pe=ve[Re],ze=1,qe=Y.s3_ss[re]*V[Re]*q[ve[Re]],++re,++Re;Re<=rt;)pe+=ve[Re],ze+=1,me=Y.s3_ss[re]*V[Re]*q[ve[Re]],qe=A(qe,me,Re-ie),++re,++Re;pe=(1+2*pe)/(2*ze),Pt=q[pe]*.5,qe*=Pt,H[ie]=qe,Y.nb_s2[J][ie]=Y.nb_s1[J][ie],Y.nb_s1[J][ie]=qe,me=te[ie],me*=Y.minval_s[ie],me*=Pt,H[ie]>me&&(H[ie]=me),Y.masking_lower>1&&(H[ie]*=Y.masking_lower),H[ie]>V[ie]&&(H[ie]=V[ie]),Y.masking_lower<1&&(H[ie]*=Y.masking_lower),et(H[ie]>=0)}for(;ie<ae.CBANDS;++ie)V[ie]=0,H[ie]=0}function Se(M,I,V,H,J){var D=Kt(ae.CBANDS),Y=Kt(ae.CBANDS),te=So(ae.CBANDS+2),X;ee(M,I,V,D,Y),de(M,D,Y,te);var oe=0;for(X=0;X<M.npart_l;X++){var re,ie,ve,Ve,fe=M.s3ind[X][0],Le=M.s3ind[X][1],ne=0,Re=0;for(ne=te[fe],Re+=1,ie=M.s3_ll[oe]*V[fe]*q[te[fe]],++oe,++fe;fe<=Le;)ne+=te[fe],Re+=1,re=M.s3_ll[oe]*V[fe]*q[te[fe]],Ve=A(ie,re,fe-X),ie=Ve,++oe,++fe;if(ne=(1+2*ne)/(2*Re),ve=q[ne]*.5,ie*=ve,M.blocktype_old[J&1]==ae.SHORT_TYPE){var rt=n*M.nb_1[J][X];rt>0?H[X]=Math.min(ie,rt):H[X]=Math.min(ie,V[X]*f)}else{var pe=s*M.nb_2[J][X],ze=n*M.nb_1[J][X],rt;pe<=0&&(pe=ie),ze<=0&&(ze=ie),M.blocktype_old[J&1]==ae.NORM_TYPE?rt=Math.min(ze,pe):rt=ze,H[X]=Math.min(ie,rt)}M.nb_2[J][X]=M.nb_1[J][X],M.nb_1[J][X]=ie,re=D[X],re*=M.minval_l[X],re*=ve,H[X]>re&&(H[X]=re),M.masking_lower>1&&(H[X]*=M.masking_lower),H[X]>V[X]&&(H[X]=V[X]),M.masking_lower<1&&(H[X]*=M.masking_lower),et(H[X]>=0)}for(;X<ae.CBANDS;++X)V[X]=0,H[X]=0}function Ie(M,I){var V=M.internal_flags;M.short_blocks==ki.short_block_coupled&&!(I[0]!=0&&I[1]!=0)&&(I[0]=I[1]=0);for(var H=0;H<V.channels_out;H++)M.short_blocks==ki.short_block_dispensed&&(I[H]=1),M.short_blocks==ki.short_block_forced&&(I[H]=0)}function We(M,I,V){for(var H=M.internal_flags,J=0;J<H.channels_out;J++){var D=ae.NORM_TYPE;I[J]!=0?(et(H.blocktype_old[J]!=ae.START_TYPE),H.blocktype_old[J]==ae.SHORT_TYPE&&(D=ae.STOP_TYPE)):(D=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)),V[J]=H.blocktype_old[J],H.blocktype_old[J]=D}}function He(M,I,V,H,J,D,Y){for(var te=D*2,X=D>0?Math.pow(10,J):1,oe,re,ie=0;ie<Y;++ie){var ve=M[2][ie],Ve=M[3][ie],fe=I[0][ie],Le=I[1][ie],ne=I[2][ie],Re=I[3][ie];if(fe<=1.58*Le&&Le<=1.58*fe){var rt=V[ie]*Ve,pe=V[ie]*ve;re=Math.max(ne,Math.min(Re,rt)),oe=Math.max(Re,Math.min(ne,pe))}else re=ne,oe=Re;if(D>0){var ze,me,qe=H[ie]*X;if(ze=Math.min(Math.max(fe,qe),Math.max(Le,qe)),ne=Math.max(re,qe),Re=Math.max(oe,qe),me=ne+Re,me>0&&ze*te<me){var Pt=ze*te/me;ne*=Pt,Re*=Pt}re=Math.min(ne,re),oe=Math.min(Re,oe)}re>ve&&(re=ve),oe>Ve&&(oe=Ve),I[2][ie]=re,I[3][ie]=oe}}this.L3psycho_anal_vbr=function(M,I,V,H,J,D,Y,te,X,oe){var re=M.internal_flags,ie,ve,Ve=Kt(ae.HBLKSIZE),fe=dn([3,ae.HBLKSIZE_s]),Le=dn([2,ae.BLKSIZE]),ne=dn([2,3,ae.BLKSIZE_s]),Re=dn([4,ae.CBANDS]),rt=dn([4,ae.CBANDS]),pe=dn([4,3]),ze=.6,me=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],qe=So(2),Pt=M.mode==t.JOINT_STEREO?4:re.channels_out;je(M,I,V,H,J,D,X,pe,me,qe),Ie(M,qe);{for(var xe=0;xe<Pt;xe++){var Je=xe&1;ie=Le,ke(M,I,V,xe,H,Ve,ie,Je),Te(M,H,xe,Ve),qe[Je]!=0?Se(re,Ve,Re[xe],rt[xe],xe):Kr(re,xe)}qe[0]+qe[1]==2&&M.mode==t.JOINT_STEREO&&He(Re,rt,re.mld_cb_l,re.ATH.cb_l,M.ATHlower*re.ATH.adjust,M.msfix,re.npart_l);for(var xe=0;xe<Pt;xe++){var Je=xe&1;qe[Je]!=0&&T(re,Re[xe],rt[xe],xe)}}{for(var st=0;st<3;st++){for(var xe=0;xe<Pt;++xe){var Je=xe&1;qe[Je]!=0?Tt(re,xe,st):(ve=ne,Pe(M,I,V,xe,st,fe,ve,Je),P(M,fe,Re[xe],rt[xe],xe,st))}qe[0]+qe[1]==0&&M.mode==t.JOINT_STEREO&&He(Re,rt,re.mld_cb_s,re.ATH.cb_s,M.ATHlower*re.ATH.adjust,M.msfix,re.npart_s);for(var xe=0;xe<Pt;++xe){var Je=xe&1;qe[Je]==0&&B(re,Re[xe],rt[xe],xe,st)}}for(var xe=0;xe<Pt;xe++){var Je=xe&1;if(qe[Je]==0)for(var Ct=0;Ct<ae.SBMAX_s;Ct++){for(var Zr=Kt(3),st=0;st<3;st++){var Wt=re.thm[xe].s[Ct][st];if(Wt*=l,me[xe][st]>=2||me[xe][st+1]==1){var jt=st!=0?st-1:2,Er=R(re.thm[xe].s[Ct][jt],Wt,u*ze);Wt=Math.min(Wt,Er)}else if(me[xe][st]==1){var jt=st!=0?st-1:2,Er=R(re.thm[xe].s[Ct][jt],Wt,f*ze);Wt=Math.min(Wt,Er)}else if(st!=0&&me[xe][st-1]==3||st==0&&re.nsPsy.lastAttacks[xe]==3){var jt=st!=2?st+1:0,Er=R(re.thm[xe].s[Ct][jt],Wt,f*ze);Wt=Math.min(Wt,Er)}Wt*=pe[xe][st],Zr[st]=Wt}for(var st=0;st<3;st++)re.thm[xe].s[Ct][st]=Zr[st]}}}for(var xe=0;xe<Pt;xe++)re.nsPsy.lastAttacks[xe]=me[xe][2];We(M,qe,oe);for(var xe=0;xe<Pt;xe++){var Br,Vr,mn,gn;xe>1?(Br=te,Vr=-2,mn=ae.NORM_TYPE,(oe[0]==ae.SHORT_TYPE||oe[1]==ae.SHORT_TYPE)&&(mn=ae.SHORT_TYPE),gn=D[H][xe-2]):(Br=Y,Vr=0,mn=oe[xe],gn=J[H][xe]),mn==ae.SHORT_TYPE?Br[Vr+xe]=K(gn,re.masking_lower):Br[Vr+xe]=U(gn,re.masking_lower),M.analysis&&(re.pinfo.pe[H][xe]=Br[Vr+xe])}return 0};function Ce(M,I){var V=M,H;return V>=0?H=-V*27:H=V*I,H<=-72?0:Math.exp(H*y)}function Ae(M){var I=0,V=0;{var H=0,J,D;for(H=0;Ce(H,M)>1e-20;H-=1);for(J=H,D=0;Math.abs(D-J)>1e-12;)H=(D+J)/2,Ce(H,M)>0?D=H:J=H;I=J}{var H=0,J,D;for(H=0;Ce(H,M)>1e-20;H+=1);for(J=0,D=H;Math.abs(D-J)>1e-12;)H=(D+J)/2,Ce(H,M)>0?J=H:D=H;V=D}{var Y=0,te=1e3,X;for(X=0;X<=te;++X){var H=I+X*(V-I)/te,oe=Ce(H,M);Y+=oe}{var re=(te+1)/(Y*(V-I));return re}}}function tt(M){var I,V,H,J;return I=M,I>=0?I*=3:I*=1.5,I>=.5&&I<=2.5?(J=I-.5,V=8*(J*J-2*J)):V=0,I+=.474,H=15.811389+7.5*I-17.5*Math.sqrt(1+I*I),H<=-60?0:(I=Math.exp((V+H)*y),I/=.6609193,I)}function De(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 we(M,I,V,H,J,D,Y,te,X,oe,re,ie){var ve=Kt(ae.CBANDS+1),Ve=te/(ie>15?2*576:2*192),fe=So(ae.HBLKSIZE),Le;te/=X;var ne=0,Re=0;for(Le=0;Le<ae.CBANDS;Le++){var rt,pe;for(rt=De(te*ne),ve[Le]=te*ne,pe=ne;De(te*pe)-rt<a&&pe<=X/2;pe++);for(M[Le]=pe-ne,Re=Le+1;ne<pe;)et(ne<ae.HBLKSIZE),fe[ne++]=Le;if(ne>X/2){ne=X/2,++Le;break}}et(Le<ae.CBANDS),ve[Le]=te*ne;for(var ze=0;ze<ie;ze++){var me,qe,Pt,xe,Je;Pt=oe[ze],xe=oe[ze+1],me=0|Math.floor(.5+re*(Pt-.5)),me<0&&(me=0),qe=0|Math.floor(.5+re*(xe-.5)),qe>X/2&&(qe=X/2),V[ze]=(fe[me]+fe[qe])/2,I[ze]=fe[qe];var st=Ve*xe;Y[ze]=(st-ve[I[ze]])/(ve[I[ze]+1]-ve[I[ze]]),Y[ze]<0?Y[ze]=0:Y[ze]>1&&(Y[ze]=1),Je=De(te*oe[ze]*re),Je=Math.min(Je,15.5)/15.5,D[ze]=Math.pow(10,1.25*(1-Math.cos(Math.PI*Je))-2.5)}ne=0;for(var Ct=0;Ct<Re;Ct++){var Zr=M[Ct],rt,Wt;rt=De(te*ne),Wt=De(te*(ne+Zr-1)),H[Ct]=.5*(rt+Wt),rt=De(te*(ne-.5)),Wt=De(te*(ne+Zr-.5)),J[Ct]=Wt-rt,ne+=Zr}return Re}function xt(M,I,V,H,J,D){var Y=dn([ae.CBANDS,ae.CBANDS]),te,X=0;if(D)for(var oe=0;oe<I;oe++)for(te=0;te<I;te++){var re=tt(V[oe]-V[te])*H[te];Y[oe][te]=re*J[oe]}else for(te=0;te<I;te++)for(var ie=15+Math.min(21/V[te],12),ve=Ae(ie),oe=0;oe<I;oe++){var re=ve*Ce(V[oe]-V[te],ie)*H[te];Y[oe][te]=re*J[oe]}for(var oe=0;oe<I;oe++){for(te=0;te<I&&!(Y[oe][te]>0);te++);for(M[oe][0]=te,te=I-1;te>0&&!(Y[oe][te]>0);te--);M[oe][1]=te,X+=M[oe][1]-M[oe][0]+1}for(var Ve=Kt(X),fe=0,oe=0;oe<I;oe++)for(te=M[oe][0];te<=M[oe][1];te++)Ve[fe++]=Y[oe][te];return Ve}function Jt(M){var I=De(M);return I=Math.min(I,15.5)/15.5,Math.pow(10,1.25*(1-Math.cos(Math.PI*I))-2.5)}this.psymodel_init=function(M){var I=M.internal_flags,V,H=!0,J=13,D=24,Y=0,te=0,X=-8.25,oe=-4.5,re=Kt(ae.CBANDS),ie=Kt(ae.CBANDS),ve=Kt(ae.CBANDS),Ve=M.out_samplerate;switch(M.experimentalZ){default:case 0:H=!0;break;case 1:H=!(M.VBR==Si.vbr_mtrh||M.VBR==Si.vbr_mt);break;case 2:H=!1;break;case 3:J=8,Y=-1.75,te=-.0125,X=-8.25,oe=-2.25;break}for(I.ms_ener_ratio_old=.25,I.blocktype_old[0]=I.blocktype_old[1]=ae.NORM_TYPE,V=0;V<4;++V){for(var ne=0;ne<ae.CBANDS;++ne)I.nb_1[V][ne]=1e20,I.nb_2[V][ne]=1e20,I.nb_s1[V][ne]=I.nb_s2[V][ne]=1;for(var fe=0;fe<ae.SBMAX_l;fe++)I.en[V].l[fe]=1e20,I.thm[V].l[fe]=1e20;for(var ne=0;ne<3;++ne){for(var fe=0;fe<ae.SBMAX_s;fe++)I.en[V].s[fe][ne]=1e20,I.thm[V].s[fe][ne]=1e20;I.nsPsy.lastAttacks[V]=0}for(var ne=0;ne<9;ne++)I.nsPsy.last_en_subshort[V][ne]=10}for(I.loudness_sq_save[0]=I.loudness_sq_save[1]=0,I.npart_l=we(I.numlines_l,I.bo_l,I.bm_l,re,ie,I.mld_l,I.PSY.bo_l_weight,Ve,ae.BLKSIZE,I.scalefac_band.l,ae.BLKSIZE/(2*576),ae.SBMAX_l),et(I.npart_l<ae.CBANDS),V=0;V<I.npart_l;V++){var Le=Y;re[V]>=J&&(Le=te*(re[V]-J)/(D-J)+Y*(D-re[V])/(D-J)),ve[V]=Math.pow(10,Le/10),I.numlines_l[V]>0?I.rnumlines_l[V]=1/I.numlines_l[V]:I.rnumlines_l[V]=0}I.s3_ll=xt(I.s3ind,I.npart_l,re,ie,ve,H);var ne=0;for(V=0;V<I.npart_l;V++){var Re;Re=x3.MAX_VALUE;for(var rt=0;rt<I.numlines_l[V];rt++,ne++){var pe=Ve*ne/(1e3*ae.BLKSIZE),ze;ze=this.ATHformula(pe*1e3,M)-20,ze=Math.pow(10,.1*ze),ze*=I.numlines_l[V],Re>ze&&(Re=ze)}I.ATH.cb_l[V]=Re,Re=-20+re[V]*20/10,Re>6&&(Re=100),Re<-15&&(Re=-15),Re-=8,I.minval_l[V]=Math.pow(10,Re/10)*I.numlines_l[V]}for(I.npart_s=we(I.numlines_s,I.bo_s,I.bm_s,re,ie,I.mld_s,I.PSY.bo_s_weight,Ve,ae.BLKSIZE_s,I.scalefac_band.s,ae.BLKSIZE_s/(2*192),ae.SBMAX_s),et(I.npart_s<ae.CBANDS),ne=0,V=0;V<I.npart_s;V++){var Re,Le=X;re[V]>=J&&(Le=oe*(re[V]-J)/(D-J)+X*(D-re[V])/(D-J)),ve[V]=Math.pow(10,Le/10),Re=x3.MAX_VALUE;for(var rt=0;rt<I.numlines_s[V];rt++,ne++){var pe=Ve*ne/(1e3*ae.BLKSIZE_s),ze;ze=this.ATHformula(pe*1e3,M)-20,ze=Math.pow(10,.1*ze),ze*=I.numlines_s[V],Re>ze&&(Re=ze)}I.ATH.cb_s[V]=Re,Re=-7+re[V]*7/12,re[V]>12&&(Re*=1+Math.log(1+Re)*3.1),re[V]<12&&(Re*=1+Math.log(1-Re)*2.3),Re<-15&&(Re=-15),Re-=8,I.minval_s[V]=Math.pow(10,Re/10)*I.numlines_s[V]}I.s3_ss=xt(I.s3ind_s,I.npart_s,re,ie,ve,H),C(),e.init_fft(I),I.decay=Math.exp(-1*r/(d*Ve/192));{var me;me=p,M.exp_nspsytune&2&&(me=1),Math.abs(M.msfix)>0&&(me=M.msfix),M.msfix=me;for(var qe=0;qe<I.npart_l;qe++)I.s3ind[qe][1]>I.npart_l-1&&(I.s3ind[qe][1]=I.npart_l-1)}var Pt=576*I.mode_gr/Ve;if(I.ATH.decay=Math.pow(10,-12/10*Pt),I.ATH.adjust=.01,I.ATH.adjustLimit=1,et(I.bo_l[ae.SBMAX_l-1]<=I.npart_l),et(I.bo_s[ae.SBMAX_s-1]<=I.npart_s),M.ATHtype!=-1){var pe,xe=M.out_samplerate/ae.BLKSIZE,Je=0;for(pe=0,V=0;V<ae.BLKSIZE/2;++V)pe+=xe,I.ATH.eql_w[V]=1/Math.pow(10,this.ATHformula(pe,M)/10),Je+=I.ATH.eql_w[V];for(Je=1/Je,V=ae.BLKSIZE/2;--V>=0;)I.ATH.eql_w[V]*=Je}{for(var qe=ne=0;qe<I.npart_s;++qe)for(V=0;V<I.numlines_s[qe];++V)++ne;for(var qe=ne=0;qe<I.npart_l;++qe)for(V=0;V<I.numlines_l[qe];++V)++ne}for(ne=0,V=0;V<I.npart_l;V++){var pe=Ve*(ne+I.numlines_l[V]/2)/(1*ae.BLKSIZE);I.mld_cb_l[V]=Jt(pe),ne+=I.numlines_l[V]}for(;V<ae.CBANDS;++V)I.mld_cb_l[V]=1;for(ne=0,V=0;V<I.npart_s;V++){var pe=Ve*(ne+I.numlines_s[V]/2)/(1*ae.BLKSIZE_s);I.mld_cb_s[V]=Jt(pe),ne+=I.numlines_s[V]}for(;V<ae.CBANDS;++V)I.mld_cb_s[V]=1;return 0};function gt(M,I){M<-.3&&(M=3410),M/=1e3,M=Math.max(.1,M);var V=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*I)*.001*Math.pow(M,4);return V}this.ATHformula=function(M,I){var V;switch(I.ATHtype){case 0:V=gt(M,9);break;case 1:V=gt(M,-1);break;case 2:V=gt(M,0);break;case 3:V=gt(M,1)+6;break;case 4:V=gt(M,I.ATHcurve);break;default:V=gt(M,0);break}return V}}var iA=oA,aA=ec;function cA(){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=aA.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 lA=cA,uA=br(),e4={};e4.SFBMAX=uA.SBMAX_s*3;var $u=e4,t4=qt,dA=t4.new_float,ko=t4.new_int,P1=$u;function hA(){this.xr=dA(576),this.l3_enc=ko(576),this.scalefac=ko(P1.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=ko(3),this.subblock_gain=ko(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=ko(P1.SFBMAX),this.window=ko(P1.SFBMAX),this.count1bits=0,this.sfb_partition_table=null,this.slen=ko(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 D1=hA,fA=qt,S3=fA.new_int,pA=D1;function mA(){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=[S3(4),S3(4)];for(var t=0;t<2;t++)for(var e=0;e<2;e++)this.tt[t][e]=new pA}var gA=mA,r4=qt,yu=r4.System,vu=r4.new_int,wu=br();function _A(t,e,r,n){this.l=vu(1+wu.SBMAX_l),this.s=vu(1+wu.SBMAX_s),this.psfb21=vu(1+wu.PSFB21),this.psfb12=vu(1+wu.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],yu.arraycopy(this.arrL,0,s,0,Math.min(this.arrL.length,this.l.length)),yu.arraycopy(this.arrS,0,o,0,Math.min(this.arrS.length,this.s.length)),yu.arraycopy(this.arr21,0,this.psfb21,0,Math.min(this.arr21.length,this.psfb21.length)),yu.arraycopy(this.arr12,0,this.psfb12,0,Math.min(this.arr12.length,this.psfb12.length)))}var n4=_A,L1=qt,M1=L1.new_float,bA=L1.new_float_n,yA=L1.new_int,k3=br();function vA(){this.last_en_subshort=bA([4,9]),this.lastAttacks=yA(4),this.pefirbuf=M1(19),this.longfact=M1(k3.SBMAX_l),this.shortfact=M1(k3.SBMAX_s),this.attackthre=0,this.attackthre_s=0}var wA=vA;function xA(){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 SA=xA,Ti=qt,kA=Ti.new_byte,$A=Ti.new_double,hn=Ti.new_float,$o=Ti.new_float_n,Rn=Ti.new_int,xu=Ti.new_int_n,EA=gA,TA=n4,RA=wA,PA=SA,$3=J3(),Ht=br(),MA=$u;es.MFSIZE=3*1152+Ht.ENCDELAY-Ht.MDCTDELAY;es.MAX_HEADER_BUF=256;es.MAX_BITS_PER_CHANNEL=4095;es.MAX_BITS_PER_GRANULE=7680;es.BPC=320;function es(){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=$o([2,es.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 EA,this.ms_ratio=hn(2),this.padding=0,this.frac_SpF=0,this.slot_lag=0,this.tag_spec=null,this.nMusicCRC=0,this.OldValue=Rn(2),this.CurrentStep=Rn(2),this.masking_lower=0,this.bv_scf=Rn(576),this.pseudohalf=Rn(MA.SFBMAX),this.sfb21_extra=!1,this.inbuf_old=new Array(2),this.blackfilt=new Array(2*es.BPC+1),this.itime=$A(2),this.sideinfo_len=0,this.sb_sample=$o([2,2,18,Ht.SBLIMIT]),this.amp_filter=hn(32);function e(){this.write_timing=0,this.ptr=0,this.buf=kA(t)}this.header=new Array(es.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 TA,this.minval_l=hn(Ht.CBANDS),this.minval_s=hn(Ht.CBANDS),this.nb_1=$o([4,Ht.CBANDS]),this.nb_2=$o([4,Ht.CBANDS]),this.nb_s1=$o([4,Ht.CBANDS]),this.nb_s2=$o([4,Ht.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=hn(4),this.loudness_sq=$o([2,2]),this.loudness_sq_save=hn(2),this.mld_l=hn(Ht.SBMAX_l),this.mld_s=hn(Ht.SBMAX_s),this.bm_l=Rn(Ht.SBMAX_l),this.bo_l=Rn(Ht.SBMAX_l),this.bm_s=Rn(Ht.SBMAX_s),this.bo_s=Rn(Ht.SBMAX_s),this.npart_l=0,this.npart_s=0,this.s3ind=xu([Ht.CBANDS,2]),this.s3ind_s=xu([Ht.CBANDS,2]),this.numlines_s=Rn(Ht.CBANDS),this.numlines_l=Rn(Ht.CBANDS),this.rnumlines_l=hn(Ht.CBANDS),this.mld_cb_l=hn(Ht.CBANDS),this.mld_cb_s=hn(Ht.CBANDS),this.numlines_s_num1=0,this.numlines_l_num1=0,this.pe=hn(4),this.ms_ratio_s_old=0,this.ms_ratio_l_old=0,this.ms_ener_ratio_old=0,this.blocktype_old=Rn(2),this.nsPsy=new RA,this.VBR_seek_table=new PA,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=xu([16,5]),this.bitrate_blockType_Hist=xu([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 $3;for(var r=0;r<this.thm.length;r++)this.thm[r]=new $3;for(var r=0;r<this.header.length;r++)this.header[r]=new e}var Eu=es,IA=qt,Eo=IA.new_float,To=br();function zA(){this.useAdjust=0,this.aaSensitivityP=0,this.adjust=0,this.adjustLimit=0,this.decay=0,this.floor=0,this.l=Eo(To.SBMAX_l),this.s=Eo(To.SBMAX_s),this.psfb21=Eo(To.PSFB21),this.psfb12=Eo(To.PSFB12),this.cb_l=Eo(To.CBANDS),this.cb_s=Eo(To.CBANDS),this.eql_w=Eo(To.BLKSIZE/2)}var AA=zA,s4=qt,Dr=s4.System,E3=s4.Arrays;Gt.STEPS_per_dB=100;Gt.MAX_dB=120;Gt.GAIN_NOT_ENOUGH_SAMPLES=-24601;Gt.GAIN_ANALYSIS_ERROR=0;Gt.GAIN_ANALYSIS_OK=1;Gt.INIT_GAIN_ANALYSIS_ERROR=0;Gt.INIT_GAIN_ANALYSIS_OK=1;Gt.YULE_ORDER=10;Gt.MAX_ORDER=Gt.YULE_ORDER;Gt.MAX_SAMP_FREQ=48e3;Gt.RMS_WINDOW_TIME_NUMERATOR=1;Gt.RMS_WINDOW_TIME_DENOMINATOR=20;Gt.MAX_SAMPLES_PER_WINDOW=Gt.MAX_SAMP_FREQ*Gt.RMS_WINDOW_TIME_NUMERATOR/Gt.RMS_WINDOW_TIME_DENOMINATOR+1;function Gt(){var t=64.82,e=.95,r=Gt.RMS_WINDOW_TIME_NUMERATOR,n=Gt.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,f,p,m,y,k){for(;y--!=0;)p[m]=1e-10+u[f+0]*k[0]-p[m-1]*k[1]+u[f-1]*k[2]-p[m-2]*k[3]+u[f-2]*k[4]-p[m-3]*k[5]+u[f-3]*k[6]-p[m-4]*k[7]+u[f-4]*k[8]-p[m-5]*k[9]+u[f-5]*k[10]-p[m-6]*k[11]+u[f-6]*k[12]-p[m-7]*k[13]+u[f-7]*k[14]-p[m-8]*k[15]+u[f-8]*k[16]-p[m-9]*k[17]+u[f-9]*k[18]-p[m-10]*k[19]+u[f-10]*k[20],++m,++f}function a(u,f,p,m,y,k){for(;y--!=0;)p[m]=u[f+0]*k[0]-p[m-1]*k[1]+u[f-1]*k[2]-p[m-2]*k[3]+u[f-2]*k[4],++m,++f}function c(u,f){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|f){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|(f*r+n-1)/n,u.lsum=0,u.rsum=0,u.totsamp=0,E3.ill(u.A,0),INIT_GAIN_ANALYSIS_OK}this.InitGainAnalysis=function(u,f){return c(u,f)!=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,E3.fill(u.B,0),INIT_GAIN_ANALYSIS_OK)};function d(u){return u*u}this.AnalyzeSamples=function(u,f,p,m,y,k,x){var _,g,E,h,$,z,L;if(k==0)return GAIN_ANALYSIS_OK;switch(L=0,$=k,x){case 1:m=f,y=p;break;case 2:break;default:return GAIN_ANALYSIS_ERROR}for(k<MAX_ORDER?(Dr.arraycopy(f,p,u.linprebuf,MAX_ORDER,k),Dr.arraycopy(m,y,u.rinprebuf,MAX_ORDER,k)):(Dr.arraycopy(f,p,u.linprebuf,MAX_ORDER,MAX_ORDER),Dr.arraycopy(m,y,u.rinprebuf,MAX_ORDER,MAX_ORDER));$>0;){z=$>u.sampleWindow-u.totsamp?u.sampleWindow-u.totsamp:$,L<MAX_ORDER?(_=u.linpre+L,g=u.linprebuf,E=u.rinpre+L,h=u.rinprebuf,z>MAX_ORDER-L&&(z=MAX_ORDER-L)):(_=p+L,g=f,E=y+L,h=m),i(g,_,u.lstepbuf,u.lstep+u.totsamp,z,s[u.reqindex]),i(h,E,u.rstepbuf,u.rstep+u.totsamp,z,s[u.reqindex]),a(u.lstepbuf,u.lstep+u.totsamp,u.loutbuf,u.lout+u.totsamp,z,o[u.reqindex]),a(u.rstepbuf,u.rstep+u.totsamp,u.routbuf,u.rout+u.totsamp,z,o[u.reqindex]),_=u.lout+u.totsamp,g=u.loutbuf,E=u.rout+u.totsamp,h=u.routbuf;for(var q=z%8;q--!=0;)u.lsum+=d(g[_++]),u.rsum+=d(h[E++]);for(q=z/8;q--!=0;)u.lsum+=d(g[_+0])+d(g[_+1])+d(g[_+2])+d(g[_+3])+d(g[_+4])+d(g[_+5])+d(g[_+6])+d(g[_+7]),_+=8,u.rsum+=d(h[E+0])+d(h[E+1])+d(h[E+2])+d(h[E+3])+d(h[E+4])+d(h[E+5])+d(h[E+6])+d(h[E+7]),E+=8;if($-=z,L+=z,u.totsamp+=z,u.totsamp==u.sampleWindow){var C=Gt.STEPS_per_dB*10*Math.log10((u.lsum+u.rsum)/u.totsamp*.5+1e-37),Z=C<=0?0:0|C;Z>=u.A.length&&(Z=u.A.length-1),u.A[Z]++,u.lsum=u.rsum=0,Dr.arraycopy(u.loutbuf,u.totsamp,u.loutbuf,0,MAX_ORDER),Dr.arraycopy(u.routbuf,u.totsamp,u.routbuf,0,MAX_ORDER),Dr.arraycopy(u.lstepbuf,u.totsamp,u.lstepbuf,0,MAX_ORDER),Dr.arraycopy(u.rstepbuf,u.totsamp,u.rstepbuf,0,MAX_ORDER),u.totsamp=0}if(u.totsamp>u.sampleWindow)return GAIN_ANALYSIS_ERROR}return k<MAX_ORDER?(Dr.arraycopy(u.linprebuf,k,u.linprebuf,0,MAX_ORDER-k),Dr.arraycopy(u.rinprebuf,k,u.rinprebuf,0,MAX_ORDER-k),Dr.arraycopy(f,p,u.linprebuf,MAX_ORDER-k,k),Dr.arraycopy(m,y,u.rinprebuf,MAX_ORDER-k,k)):(Dr.arraycopy(f,p+k-MAX_ORDER,u.linprebuf,0,MAX_ORDER),Dr.arraycopy(m,y+k-MAX_ORDER,u.rinprebuf,0,MAX_ORDER)),GAIN_ANALYSIS_OK};function l(u,f){var p,m=0;for(p=0;p<f;p++)m+=u[p];if(m==0)return GAIN_NOT_ENOUGH_SAMPLES;var y=0|Math.ceil(m*(1-e));for(p=f;p-- >0&&!((y-=u[p])<=0););return t-p/Gt.STEPS_per_dB}this.GetTitleGain=function(u){for(var f=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,f}}var o4=Gt,i4=qt,$i=i4.new_float,T3=i4.new_int,Lr=o4;function OA(){this.linprebuf=$i(Lr.MAX_ORDER*2),this.linpre=0,this.lstepbuf=$i(Lr.MAX_SAMPLES_PER_WINDOW+Lr.MAX_ORDER),this.lstep=0,this.loutbuf=$i(Lr.MAX_SAMPLES_PER_WINDOW+Lr.MAX_ORDER),this.lout=0,this.rinprebuf=$i(Lr.MAX_ORDER*2),this.rinpre=0,this.rstepbuf=$i(Lr.MAX_SAMPLES_PER_WINDOW+Lr.MAX_ORDER),this.rstep=0,this.routbuf=$i(Lr.MAX_SAMPLES_PER_WINDOW+Lr.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=T3(0|Lr.STEPS_per_dB*Lr.MAX_dB),this.B=T3(0|Lr.STEPS_per_dB*Lr.MAX_dB)}var NA=OA;function CA(t){this.bits=t}var a4=CA,Z1=qt,R3=Z1.new_float,jA=Z1.new_int,P3=Z1.assert,DA=a4,M3=br(),LA=$u,ZA=Eu;function BA(t){var e=t;this.quantize=e,this.iteration_loop=function(r,n,s,o){var i=r.internal_flags,a=R3(LA.SFBMAX),c=R3(576),d=jA(2),l=0,u,f=i.l3_side,p=new DA(l);this.quantize.rv.ResvFrameBegin(r,p),l=p.bits;for(var m=0;m<i.mode_gr;m++){u=this.quantize.qupvt.on_pe(r,n,d,l,m,m),i.mode_ext==M3.MPG_MD_MS_LR&&(this.quantize.ms_convert(i.l3_side,m),this.quantize.qupvt.reduce_side(d,s[m],l,u));for(var y=0;y<i.channels_out;y++){var k,x,_=f.tt[m][y];_.block_type!=M3.SHORT_TYPE?(k=0,x=i.PSY.mask_adjust-k):(k=0,x=i.PSY.mask_adjust_short-k),i.masking_lower=Math.pow(10,x*.1),this.quantize.init_outer_loop(i,_),this.quantize.init_xrpow(i,_,c)&&(this.quantize.qupvt.calc_xmin(r,o[m][y],_,a),this.quantize.outer_loop(r,_,a,c,y,d[y])),this.quantize.iteration_finish_one(i,m,y),P3(_.part2_3_length<=ZA.MAX_BITS_PER_CHANNEL),P3(_.part2_3_length<=d[y])}}this.quantize.rv.ResvFrameEnd(i,l)}}var VA=BA;function yt(t,e,r,n){this.xlen=t,this.linmax=e,this.table=r,this.hlen=n}var ge={};ge.t1HB=[1,1,1,0];ge.t2HB=[1,2,1,3,1,1,3,2,0];ge.t3HB=[3,2,1,1,1,1,3,2,0];ge.t5HB=[1,2,6,5,3,1,4,4,7,5,7,1,6,1,1,0];ge.t6HB=[7,3,5,1,6,2,3,2,5,4,4,1,3,3,2,0];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.t32HB=[1,10,8,20,12,20,16,32,14,12,24,0,28,16,24,16];ge.t33HB=[15,28,26,48,22,40,36,64,14,24,20,32,12,16,8,0];ge.t1l=[1,4,3,5];ge.t2l=[1,4,7,4,5,7,6,7,8];ge.t3l=[2,3,7,4,4,7,6,7,8];ge.t5l=[1,4,7,8,4,5,8,9,7,8,9,10,8,8,9,10];ge.t6l=[3,4,6,8,4,4,6,7,5,6,7,8,7,7,8,9];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.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];ge.t32l=[1,5,5,7,5,8,7,9,5,7,7,9,7,9,9,10];ge.t33l=[4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8];ge.ht=[new yt(0,0,null,null),new yt(2,0,ge.t1HB,ge.t1l),new yt(3,0,ge.t2HB,ge.t2l),new yt(3,0,ge.t3HB,ge.t3l),new yt(0,0,null,null),new yt(4,0,ge.t5HB,ge.t5l),new yt(4,0,ge.t6HB,ge.t6l),new yt(6,0,ge.t7HB,ge.t7l),new yt(6,0,ge.t8HB,ge.t8l),new yt(6,0,ge.t9HB,ge.t9l),new yt(8,0,ge.t10HB,ge.t10l),new yt(8,0,ge.t11HB,ge.t11l),new yt(8,0,ge.t12HB,ge.t12l),new yt(16,0,ge.t13HB,ge.t13l),new yt(0,0,null,ge.t16_5l),new yt(16,0,ge.t15HB,ge.t15l),new yt(1,1,ge.t16HB,ge.t16l),new yt(2,3,ge.t16HB,ge.t16l),new yt(3,7,ge.t16HB,ge.t16l),new yt(4,15,ge.t16HB,ge.t16l),new yt(6,63,ge.t16HB,ge.t16l),new yt(8,255,ge.t16HB,ge.t16l),new yt(10,1023,ge.t16HB,ge.t16l),new yt(13,8191,ge.t16HB,ge.t16l),new yt(4,15,ge.t24HB,ge.t24l),new yt(5,31,ge.t24HB,ge.t24l),new yt(6,63,ge.t24HB,ge.t24l),new yt(7,127,ge.t24HB,ge.t24l),new yt(8,255,ge.t24HB,ge.t24l),new yt(9,511,ge.t24HB,ge.t24l),new yt(11,2047,ge.t24HB,ge.t24l),new yt(13,8191,ge.t24HB,ge.t24l),new yt(0,0,ge.t32HB,ge.t32l),new yt(0,0,ge.t33HB,ge.t33l)];ge.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];ge.table23=[65538,262147,458759,262148,327684,458759,393222,458759,524296];ge.table56=[65539,262148,458758,524296,262148,327684,524294,589831,458757,524294,589831,655368,524295,524295,589832,655369];ge.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]];ge.samplerate_table=[[22050,24e3,16e3,-1],[44100,48e3,32e3,-1],[11025,12e3,8e3,-1]];ge.scfsi_band=[0,6,11,16,21];var B1=ge,I1,I3;function c4(){if(I3)return I1;I3=1;var t=n4,e=qt,r=e.VbrMode,n=e.Float,s=e.Util,o=e.new_float,i=e.new_int,a=e.assert,c=br(),d=a4,l=Eu;u.Q_MAX=257,u.Q_MAX2=116,u.LARGE_BITS=1e5,u.IXMAX_VAL=8206;function u(){var f=V1(),p=null,m=null,y=null;this.setModules=function(j,A,G){p=j,m=A,y=G};function k(j){return a(0<=j+u.Q_MAX2&&j<u.Q_MAX),L[j+u.Q_MAX2]}this.IPOW20=function(j){return a(0<=j&&j<u.Q_MAX),q[j]};var x=2220446049250313e-31,_=u.IXMAX_VAL,g=_+2,E=u.Q_MAX,h=u.Q_MAX2;u.LARGE_BITS;var $=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 z=[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,2,0];this.pretab=z,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 L=o(E+h+1),q=o(E),C=o(g),Z=o(g);this.adj43=Z;function he(j,A){var G=y.ATHformula(A,j);return G-=$,G=Math.pow(10,G/10+j.ATHlower),G}function O(j){for(var A=j.internal_flags.ATH.l,G=j.internal_flags.ATH.psfb21,F=j.internal_flags.ATH.s,Q=j.internal_flags.ATH.psfb12,B=j.internal_flags,T=j.out_samplerate,v=0;v<c.SBMAX_l;v++){var w=B.scalefac_band.l[v],R=B.scalefac_band.l[v+1];A[v]=n.MAX_VALUE;for(var N=w;N<R;N++){var K=N*T/1152,se=he(j,K);A[v]=Math.min(A[v],se)}}for(var v=0;v<c.PSFB21;v++){var w=B.scalefac_band.psfb21[v],R=B.scalefac_band.psfb21[v+1];G[v]=n.MAX_VALUE;for(var N=w;N<R;N++){var K=N*T/1152,se=he(j,K);G[v]=Math.min(G[v],se)}}for(var v=0;v<c.SBMAX_s;v++){var w=B.scalefac_band.s[v],R=B.scalefac_band.s[v+1];F[v]=n.MAX_VALUE;for(var N=w;N<R;N++){var K=N*T/384,se=he(j,K);F[v]=Math.min(F[v],se)}F[v]*=B.scalefac_band.s[v+1]-B.scalefac_band.s[v]}for(var v=0;v<c.PSFB12;v++){var w=B.scalefac_band.psfb12[v],R=B.scalefac_band.psfb12[v+1];Q[v]=n.MAX_VALUE;for(var N=w;N<R;N++){var K=N*T/384,se=he(j,K);Q[v]=Math.min(Q[v],se)}Q[v]*=B.scalefac_band.s[13]-B.scalefac_band.s[12]}if(j.noATH){for(var v=0;v<c.SBMAX_l;v++)A[v]=1e-20;for(var v=0;v<c.PSFB21;v++)G[v]=1e-20;for(var v=0;v<c.SBMAX_s;v++)F[v]=1e-20;for(var v=0;v<c.PSFB12;v++)Q[v]=1e-20}B.ATH.floor=10*Math.log10(he(j,-1))}this.iteration_init=function(j){var A=j.internal_flags,G=A.l3_side,F;if(A.iteration_init_init==0){for(A.iteration_init_init=1,G.main_data_begin=0,O(j),C[0]=0,F=1;F<g;F++)C[F]=Math.pow(F,4/3);for(F=0;F<g-1;F++)Z[F]=F+1-Math.pow(.5*(C[F]+C[F+1]),.75);for(Z[F]=.5,F=0;F<E;F++)q[F]=Math.pow(2,(F-210)*-.1875);for(F=0;F<=E+h;F++)L[F]=Math.pow(2,(F-210-h)*.25);p.huffman_init(A);{var Q,B,T,v;for(F=j.exp_nspsytune>>2&63,F>=32&&(F-=64),Q=Math.pow(10,F/4/10),F=j.exp_nspsytune>>8&63,F>=32&&(F-=64),B=Math.pow(10,F/4/10),F=j.exp_nspsytune>>14&63,F>=32&&(F-=64),T=Math.pow(10,F/4/10),F=j.exp_nspsytune>>20&63,F>=32&&(F-=64),v=T*Math.pow(10,F/4/10),F=0;F<c.SBMAX_l;F++){var w;F<=6?w=Q:F<=13?w=B:F<=20?w=T:w=v,A.nsPsy.longfact[F]=w}for(F=0;F<c.SBMAX_s;F++){var w;F<=5?w=Q:F<=10?w=B:F<=11?w=T:w=v,A.nsPsy.shortfact[F]=w}}}},this.on_pe=function(j,A,G,F,Q,B){var T=j.internal_flags,v=0,w,R=i(2),N,K=new d(v),se=m.ResvMaxBits(j,F,K,B);v=K.bits;var U=v+se;for(U>l.MAX_BITS_PER_GRANULE&&(U=l.MAX_BITS_PER_GRANULE),w=0,N=0;N<T.channels_out;++N)G[N]=Math.min(l.MAX_BITS_PER_CHANNEL,v/T.channels_out),R[N]=0|G[N]*A[Q][N]/700-G[N],R[N]>F*3/4&&(R[N]=F*3/4),R[N]<0&&(R[N]=0),R[N]+G[N]>l.MAX_BITS_PER_CHANNEL&&(R[N]=Math.max(0,l.MAX_BITS_PER_CHANNEL-G[N])),w+=R[N];if(w>se)for(N=0;N<T.channels_out;++N)R[N]=se*R[N]/w;for(N=0;N<T.channels_out;++N)G[N]+=R[N],se-=R[N];for(w=0,N=0;N<T.channels_out;++N)w+=G[N];if(w>l.MAX_BITS_PER_GRANULE){var ee=0;for(N=0;N<T.channels_out;++N)G[N]*=l.MAX_BITS_PER_GRANULE,G[N]/=w,ee+=G[N]}return U},this.reduce_side=function(j,A,G,F){a(j[0]+j[1]<=l.MAX_BITS_PER_GRANULE);var Q=.33*(.5-A)/.5;Q<0&&(Q=0),Q>.5&&(Q=.5);var B=0|Q*.5*(j[0]+j[1]);B>l.MAX_BITS_PER_CHANNEL-j[0]&&(B=l.MAX_BITS_PER_CHANNEL-j[0]),B<0&&(B=0),j[1]>=125&&(j[1]-B>125?(j[0]<G&&(j[0]+=B),j[1]-=B):(j[0]+=j[1]-125,j[1]=125)),B=j[0]+j[1],B>F&&(j[0]=F*j[0]/B,j[1]=F*j[1]/B),a(j[0]<=l.MAX_BITS_PER_CHANNEL),a(j[1]<=l.MAX_BITS_PER_CHANNEL),a(j[0]+j[1]<=l.MAX_BITS_PER_GRANULE)},this.athAdjust=function(j,A,G){var F=90.30873362,Q=94.82444863,B=s.FAST_LOG10_X(A,10),T=j*j,v=0;return B-=G,T>1e-20&&(v=1+s.FAST_LOG10_X(T,10/F)),v<0&&(v=0),B*=v,B+=G+F-Q,Math.pow(10,.1*B)},this.calc_xmin=function(j,A,G,F){var Q=0,B=j.internal_flags,T,v=0,w=0,R=B.ATH,N=G.xr,K=j.VBR==r.vbr_mtrh?1:0,se=B.masking_lower;for((j.VBR==r.vbr_mtrh||j.VBR==r.vbr_mt)&&(se=1),T=0;T<G.psy_lmax;T++){var U,ee,de,_e,ke,Pe;j.VBR==r.vbr_rh||j.VBR==r.vbr_mtrh?ee=athAdjust(R.adjust,R.l[T],R.floor):ee=R.adjust*R.l[T],ke=G.width[T],de=ee/ke,_e=x,Pe=ke>>1,U=0;do{var Te,$e;Te=N[v]*N[v],U+=Te,_e+=Te<de?Te:de,v++,$e=N[v]*N[v],U+=$e,_e+=$e<de?$e:de,v++}while(--Pe>0);if(U>ee&&w++,T==c.SBPSY_l){var je=ee*B.nsPsy.longfact[T];_e<je&&(_e=je)}if(K!=0&&(ee=_e),!j.ATHonly){var Tt=A.en.l[T];if(Tt>0){var je;je=U*A.thm.l[T]*se/Tt,K!=0&&(je*=B.nsPsy.longfact[T]),ee<je&&(ee=je)}}K!=0?F[Q++]=ee:F[Q++]=ee*B.nsPsy.longfact[T]}var Kr=575;if(G.block_type!=c.SHORT_TYPE)for(var S=576;S--!=0&&f.EQ(N[S],0);)Kr=S;G.max_nonzero_coeff=Kr;for(var P=G.sfb_smin;T<G.psymax;P++,T+=3){var ke,Se,Ie;for(j.VBR==r.vbr_rh||j.VBR==r.vbr_mtrh?Ie=athAdjust(R.adjust,R.s[P],R.floor):Ie=R.adjust*R.s[P],ke=G.width[T],Se=0;Se<3;Se++){var U=0,ee,de,_e,Pe=ke>>1;de=Ie/ke,_e=x;do{var Te,$e;Te=N[v]*N[v],U+=Te,_e+=Te<de?Te:de,v++,$e=N[v]*N[v],U+=$e,_e+=$e<de?$e:de,v++}while(--Pe>0);if(U>Ie&&w++,P==c.SBPSY_s){var je=Ie*B.nsPsy.shortfact[P];_e<je&&(_e=je)}if(K!=0?ee=_e:ee=Ie,!j.ATHonly&&!j.ATHshort){var Tt=A.en.s[P][Se];if(Tt>0){var je;je=U*A.thm.s[P][Se]*se/Tt,K!=0&&(je*=B.nsPsy.shortfact[P]),ee<je&&(ee=je)}}K!=0?F[Q++]=ee:F[Q++]=ee*B.nsPsy.shortfact[P]}j.useTemporal&&(F[Q-3]>F[Q-3+1]&&(F[Q-3+1]+=(F[Q-3]-F[Q-3+1])*B.decay),F[Q-3+1]>F[Q-3+2]&&(F[Q-3+2]+=(F[Q-3+1]-F[Q-3+2])*B.decay))}return w};function b(j){this.s=j}this.calc_noise_core=function(j,A,G,F){var Q=0,B=A.s,T=j.l3_enc;if(B>j.count1)for(;G--!=0;){var v;v=j.xr[B],B++,Q+=v*v,v=j.xr[B],B++,Q+=v*v}else if(B>j.big_values){var w=o(2);for(w[0]=0,w[1]=F;G--!=0;){var v;v=Math.abs(j.xr[B])-w[T[B]],B++,Q+=v*v,v=Math.abs(j.xr[B])-w[T[B]],B++,Q+=v*v}}else for(;G--!=0;){var v;v=Math.abs(j.xr[B])-C[T[B]]*F,B++,Q+=v*v,v=Math.abs(j.xr[B])-C[T[B]]*F,B++,Q+=v*v}return A.s=B,Q},this.calc_noise=function(j,A,G,F,Q){var B=0,T=0,v,w,R=0,N=0,K=0,se=-20,U=0,ee=j.scalefac,de=0;for(F.over_SSD=0,v=0;v<j.psymax;v++){var _e=j.global_gain-(ee[de++]+(j.preflag!=0?z[v]:0)<<j.scalefac_scale+1)-j.subblock_gain[j.window[v]]*8,ke=0;if(Q!=null&&Q.step[v]==_e)ke=Q.noise[v],U+=j.width[v],G[B++]=ke/A[T++],ke=Q.noise_log[v];else{var Pe=k(_e);if(w=j.width[v]>>1,U+j.width[v]>j.max_nonzero_coeff){var Te;Te=j.max_nonzero_coeff-U+1,Te>0?w=Te>>1:w=0}var $e=new b(U);ke=this.calc_noise_core(j,$e,w,Pe),U=$e.s,Q!=null&&(Q.step[v]=_e,Q.noise[v]=ke),ke=G[B++]=ke/A[T++],ke=s.FAST_LOG10(Math.max(ke,1e-20)),Q!=null&&(Q.noise_log[v]=ke)}if(Q!=null&&(Q.global_gain=j.global_gain),K+=ke,ke>0){var je;je=Math.max(0|ke*10+.5,1),F.over_SSD+=je*je,R++,N+=ke}se=Math.max(se,ke)}return F.over_count=R,F.tot_noise=K,F.over_noise=N,F.max_noise=se,R},this.set_pinfo=function(j,A,G,F,Q){var B=j.internal_flags,T,v,w,R,N,K=A.scalefac_scale==0?.5:1,se=A.scalefac,U=o(L3Side.SFBMAX),ee=o(L3Side.SFBMAX),de=new CalcNoiseResult;calc_xmin(j,G,A,U),calc_noise(A,U,ee,de,null);var _e=0;for(v=A.sfb_lmax,A.block_type!=c.SHORT_TYPE&&A.mixed_block_flag==0&&(v=22),T=0;T<v;T++){var ke=B.scalefac_band.l[T],Pe=B.scalefac_band.l[T+1],Te=Pe-ke;for(R=0;_e<Pe;_e++)R+=A.xr[_e]*A.xr[_e];R/=Te,N=1e15,B.pinfo.en[F][Q][T]=N*R,B.pinfo.xfsf[F][Q][T]=N*U[T]*ee[T]/Te,G.en.l[T]>0&&!j.ATHonly?R=R/G.en.l[T]:R=0,B.pinfo.thr[F][Q][T]=N*Math.max(R*G.thm.l[T],B.ATH.l[T]),B.pinfo.LAMEsfb[F][Q][T]=0,A.preflag!=0&&T>=11&&(B.pinfo.LAMEsfb[F][Q][T]=-K*z[T]),T<c.SBPSY_l&&(a(se[T]>=0),B.pinfo.LAMEsfb[F][Q][T]-=K*se[T])}if(A.block_type==c.SHORT_TYPE)for(v=T,T=A.sfb_smin;T<c.SBMAX_s;T++)for(var ke=B.scalefac_band.s[T],Pe=B.scalefac_band.s[T+1],Te=Pe-ke,$e=0;$e<3;$e++){for(R=0,w=ke;w<Pe;w++)R+=A.xr[_e]*A.xr[_e],_e++;R=Math.max(R/Te,1e-20),N=1e15,B.pinfo.en_s[F][Q][3*T+$e]=N*R,B.pinfo.xfsf_s[F][Q][3*T+$e]=N*U[v]*ee[v]/Te,G.en.s[T][$e]>0?R=R/G.en.s[T][$e]:R=0,(j.ATHonly||j.ATHshort)&&(R=0),B.pinfo.thr_s[F][Q][3*T+$e]=N*Math.max(R*G.thm.s[T][$e],B.ATH.s[T]),B.pinfo.LAMEsfb_s[F][Q][3*T+$e]=-2*A.subblock_gain[$e],T<c.SBPSY_s&&(B.pinfo.LAMEsfb_s[F][Q][3*T+$e]-=K*se[v]),v++}B.pinfo.LAMEqss[F][Q]=A.global_gain,B.pinfo.LAMEmainbits[F][Q]=A.part2_3_length+A.part2_length,B.pinfo.LAMEsfbits[F][Q]=A.part2_length,B.pinfo.over[F][Q]=de.over_count,B.pinfo.max_noise[F][Q]=de.max_noise*10,B.pinfo.over_noise[F][Q]=de.over_noise*10,B.pinfo.tot_noise[F][Q]=de.tot_noise*10,B.pinfo.over_SSD[F][Q]=de.over_SSD}}return I1=u,I1}var z1,z3;function l4(){if(z3)return z1;z3=1;var t=qt,e=t.System,r=t.Arrays,n=t.new_int,s=t.assert,o=br(),i=B1,a=D1,c=c4();function d(){var l=null;this.qupvt=null,this.setModules=function(B){this.qupvt=B,l=B};function u(B){this.bits=0|B}var f=[[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(B,T,v,w,R,N){var K=.5946/T;for(B=B>>1;B--!=0;)R[N++]=K>v[w++]?0:1,R[N++]=K>v[w++]?0:1}function m(B,T,v,w,R,N){B=B>>1;var K=B%2;for(B=B>>1;B--!=0;){var se,U,ee,de,_e,ke,Pe,Te;se=v[w++]*T,U=v[w++]*T,_e=0|se,ee=v[w++]*T,ke=0|U,de=v[w++]*T,Pe=0|ee,se+=l.adj43[_e],Te=0|de,U+=l.adj43[ke],R[N++]=0|se,ee+=l.adj43[Pe],R[N++]=0|U,de+=l.adj43[Te],R[N++]=0|ee,R[N++]=0|de}if(K!=0){var se,U,_e,ke;se=v[w++]*T,U=v[w++]*T,_e=0|se,ke=0|U,se+=l.adj43[_e],U+=l.adj43[ke],R[N++]=0|se,R[N++]=0|U}}function y(B,T,v,w,R){var N,K,se=0,U,ee=0,de=0,_e=0,ke=T,Pe=0,Te=ke,$e=0,je=B,Tt=0;for(U=R!=null&&w.global_gain==R.global_gain,w.block_type==o.SHORT_TYPE?K=38:K=21,N=0;N<=K;N++){var Kr=-1;if((U||w.block_type==o.NORM_TYPE)&&(Kr=w.global_gain-(w.scalefac[N]+(w.preflag!=0?l.pretab[N]:0)<<w.scalefac_scale+1)-w.subblock_gain[w.window[N]]*8),s(w.width[N]>=0),U&&R.step[N]==Kr)ee!=0&&(m(ee,v,je,Tt,Te,$e),ee=0),de!=0&&(p(de,v,je,Tt,Te,$e),de=0);else{var S=w.width[N];if(se+w.width[N]>w.max_nonzero_coeff){var P;P=w.max_nonzero_coeff-se+1,r.fill(T,w.max_nonzero_coeff,576,0),S=P,S<0&&(S=0),N=K+1}if(ee==0&&de==0&&(Te=ke,$e=Pe,je=B,Tt=_e),R!=null&&R.sfb_count1>0&&N>=R.sfb_count1&&R.step[N]>0&&Kr>=R.step[N]?(ee!=0&&(m(ee,v,je,Tt,Te,$e),ee=0,Te=ke,$e=Pe,je=B,Tt=_e),de+=S):(de!=0&&(p(de,v,je,Tt,Te,$e),de=0,Te=ke,$e=Pe,je=B,Tt=_e),ee+=S),S<=0){de!=0&&(p(de,v,je,Tt,Te,$e),de=0),ee!=0&&(m(ee,v,je,Tt,Te,$e),ee=0);break}}N<=K&&(Pe+=w.width[N],_e+=w.width[N],se+=w.width[N])}ee!=0&&(m(ee,v,je,Tt,Te,$e),ee=0),de!=0&&(p(de,v,je,Tt,Te,$e),de=0)}function k(B,T,v){var w=0,R=0;do{var N=B[T++],K=B[T++];w<N&&(w=N),R<K&&(R=K)}while(T<v);return w<R&&(w=R),w}function x(B,T,v,w,R,N){var K=i.ht[w].xlen*65536+i.ht[R].xlen,se=0,U;do{var ee=B[T++],de=B[T++];ee!=0&&(ee>14&&(ee=15,se+=K),ee*=16),de!=0&&(de>14&&(de=15,se+=K),ee+=de),se+=i.largetbl[ee]}while(T<v);return U=se&65535,se>>=16,se>U&&(se=U,w=R),N.bits+=se,w}function _(B,T,v,w){var R=0,N=i.ht[1].hlen;do{var K=B[T+0]*2+B[T+1];T+=2,R+=N[K]}while(T<v);return w.bits+=R,1}function g(B,T,v,w,R){var N=0,K,se=i.ht[w].xlen,U;w==2?U=i.table23:U=i.table56;do{var ee=B[T+0]*se+B[T+1];T+=2,N+=U[ee]}while(T<v);return K=N&65535,N>>=16,N>K&&(N=K,w++),R.bits+=N,w}function E(B,T,v,w,R){var N=0,K=0,se=0,U=i.ht[w].xlen,ee=i.ht[w].hlen,de=i.ht[w+1].hlen,_e=i.ht[w+2].hlen;do{var ke=B[T+0]*U+B[T+1];T+=2,N+=ee[ke],K+=de[ke],se+=_e[ke]}while(T<v);var Pe=w;return N>K&&(N=K,Pe++),N>se&&(N=se,Pe=w+2),R.bits+=N,Pe}var h=[1,2,5,7,7,10,10,13,13,13,13,13,13,13,13];function $(B,T,v,w){var R=k(B,T,v);switch(R){case 0:return R;case 1:return _(B,T,v,w);case 2:case 3:return g(B,T,v,h[R-1],w);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 E(B,T,v,h[R-1],w);default:if(R>c.IXMAX_VAL)return w.bits=c.LARGE_BITS,-1;R-=15;var N;for(N=24;N<32&&!(i.ht[N].linmax>=R);N++);var K;for(K=N-8;K<24&&!(i.ht[K].linmax>=R);K++);return x(B,T,v,K,N,w)}}this.noquant_count_bits=function(B,T,v){var w=T.l3_enc,R=Math.min(576,T.max_nonzero_coeff+2>>1<<1);for(v!=null&&(v.sfb_count1=0);R>1&&!(w[R-1]|w[R-2]);R-=2);T.count1=R;for(var N=0,K=0;R>3;R-=4){var se;if(((w[R-1]|w[R-2]|w[R-3]|w[R-4])&2147483647)>1)break;se=((w[R-4]*2+w[R-3])*2+w[R-2])*2+w[R-1],N+=i.t32l[se],K+=i.t33l[se]}var U=N;if(T.count1table_select=0,N>K&&(U=K,T.count1table_select=1),T.count1bits=U,T.big_values=R,R==0)return U;if(T.block_type==o.SHORT_TYPE)N=3*B.scalefac_band.s[3],N>T.big_values&&(N=T.big_values),K=T.big_values;else if(T.block_type==o.NORM_TYPE){if(N=T.region0_count=B.bv_scf[R-2],K=T.region1_count=B.bv_scf[R-1],s(N+K+2<o.SBPSY_l),K=B.scalefac_band.l[N+K+2],N=B.scalefac_band.l[N+1],K<R){var ee=new u(U);T.table_select[2]=$(w,K,R,ee),U=ee.bits}}else T.region0_count=7,T.region1_count=o.SBMAX_l-1-7-1,N=B.scalefac_band.l[8],K=R,N>K&&(N=K);if(N=Math.min(N,R),K=Math.min(K,R),0<N){var ee=new u(U);T.table_select[0]=$(w,0,N,ee),U=ee.bits}if(N<K){var ee=new u(U);T.table_select[1]=$(w,N,K,ee),U=ee.bits}if(B.use_best_huffman==2&&(T.part2_3_length=U,best_huffman_divide(B,T),U=T.part2_3_length),v!=null&&T.block_type==o.NORM_TYPE){for(var de=0;B.scalefac_band.l[de]<T.big_values;)de++;v.sfb_count1=de}return U},this.count_bits=function(B,T,v,w){var R=v.l3_enc,N=c.IXMAX_VAL/l.IPOW20(v.global_gain);if(v.xrpow_max>N)return c.LARGE_BITS;if(y(T,R,l.IPOW20(v.global_gain),v,w),B.substep_shaping&2)for(var K=0,se=v.global_gain+v.scalefac_scale,U=.634521682242439/l.IPOW20(se),ee=0;ee<v.sfbmax;ee++){var de=v.width[ee];if(B.pseudohalf[ee]==0)K+=de;else{var _e;for(_e=K,K+=de;_e<K;++_e)R[_e]=T[_e]>=U?R[_e]:0}}return this.noquant_count_bits(B,v,w)};function z(B,T,v,w,R,N,K){for(var se=T.big_values,U=0;U<=22;U++)w[U]=c.LARGE_BITS;for(var U=0;U<16;U++){var ee=B.scalefac_band.l[U+1];if(ee>=se)break;var de=0,_e=new u(de),ke=$(v,0,ee,_e);de=_e.bits;for(var Pe=0;Pe<8;Pe++){var Te=B.scalefac_band.l[U+Pe+2];if(Te>=se)break;var $e=de;_e=new u($e);var je=$(v,ee,Te,_e);$e=_e.bits,w[U+Pe]>$e&&(w[U+Pe]=$e,R[U+Pe]=U,N[U+Pe]=ke,K[U+Pe]=je)}}}function L(B,T,v,w,R,N,K,se){for(var U=T.big_values,ee=2;ee<o.SBMAX_l+1;ee++){var de=B.scalefac_band.l[ee];if(de>=U)break;var _e=R[ee-2]+T.count1bits;if(v.part2_3_length<=_e)break;var ke=new u(_e),Pe=$(w,de,U,ke);_e=ke.bits,!(v.part2_3_length<=_e)&&(v.assign(T),v.part2_3_length=_e,v.region0_count=N[ee-2],v.region1_count=ee-2-N[ee-2],v.table_select[0]=K[ee-2],v.table_select[1]=se[ee-2],v.table_select[2]=Pe)}}this.best_huffman_divide=function(B,T){var v=new a,w=T.l3_enc,R=n(23),N=n(23),K=n(23),se=n(23);if(!(T.block_type==o.SHORT_TYPE&&B.mode_gr==1)){v.assign(T),T.block_type==o.NORM_TYPE&&(z(B,T,w,R,N,K,se),L(B,v,T,w,R,N,K,se));var U=v.big_values;if(!(U==0||(w[U-2]|w[U-1])>1)&&(U=T.count1+2,!(U>576))){v.assign(T),v.count1=U;for(var ee=0,de=0;U>v.big_values;U-=4){var _e=((w[U-4]*2+w[U-3])*2+w[U-2])*2+w[U-1];ee+=i.t32l[_e],de+=i.t33l[_e]}if(v.big_values=U,v.count1table_select=0,ee>de&&(ee=de,v.count1table_select=1),v.count1bits=ee,v.block_type==o.NORM_TYPE)L(B,v,T,w,R,N,K,se);else{if(v.part2_3_length=ee,ee=B.scalefac_band.l[8],ee>U&&(ee=U),ee>0){var ke=new u(v.part2_3_length);v.table_select[0]=$(w,0,ee,ke),v.part2_3_length=ke.bits}if(U>ee){var ke=new u(v.part2_3_length);v.table_select[1]=$(w,ee,U,ke),v.part2_3_length=ke.bits}T.part2_3_length>v.part2_3_length&&T.assign(v)}}}};var q=[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],Z=[0,0,0,0,3,1,1,1,2,2,2,3,3,3,4,4],he=[0,1,2,3,0,1,2,3,1,2,3,1,2,3,2,3];d.slen1_tab=Z,d.slen2_tab=he;function O(B,T){for(var v,w=T.tt[1][B],R=T.tt[0][B],N=0;N<i.scfsi_band.length-1;N++){for(v=i.scfsi_band[N];v<i.scfsi_band[N+1]&&!(R.scalefac[v]!=w.scalefac[v]&&w.scalefac[v]>=0);v++);if(v==i.scfsi_band[N+1]){for(v=i.scfsi_band[N];v<i.scfsi_band[N+1];v++)w.scalefac[v]=-1;T.scfsi[B][N]=1}}var K=0,se=0;for(v=0;v<11;v++)w.scalefac[v]!=-1&&(se++,K<w.scalefac[v]&&(K=w.scalefac[v]));for(var U=0,ee=0;v<o.SBPSY_l;v++)w.scalefac[v]!=-1&&(ee++,U<w.scalefac[v]&&(U=w.scalefac[v]));for(var N=0;N<16;N++)if(K<q[N]&&U<C[N]){var de=Z[N]*se+he[N]*ee;w.part2_length>de&&(w.part2_length=de,w.scalefac_compress=N)}}this.best_scalefac_store=function(B,T,v,w){var R=w.tt[T][v],N,K,se,U,ee=0;for(se=0,N=0;N<R.sfbmax;N++){var de=R.width[N];for(se+=de,U=-de;U<0&&R.l3_enc[U+se]==0;U++);U==0&&(R.scalefac[N]=ee=-2)}if(R.scalefac_scale==0&&R.preflag==0){var _e=0;for(N=0;N<R.sfbmax;N++)R.scalefac[N]>0&&(_e|=R.scalefac[N]);if(!(_e&1)&&_e!=0){for(N=0;N<R.sfbmax;N++)R.scalefac[N]>0&&(R.scalefac[N]>>=1);R.scalefac_scale=ee=1}}if(R.preflag==0&&R.block_type!=o.SHORT_TYPE&&B.mode_gr==2){for(N=11;N<o.SBPSY_l&&!(R.scalefac[N]<l.pretab[N]&&R.scalefac[N]!=-2);N++);if(N==o.SBPSY_l){for(N=11;N<o.SBPSY_l;N++)R.scalefac[N]>0&&(R.scalefac[N]-=l.pretab[N]);R.preflag=ee=1}}for(K=0;K<4;K++)w.scfsi[v][K]=0;for(B.mode_gr==2&&T==1&&w.tt[0][v].block_type!=o.SHORT_TYPE&&w.tt[1][v].block_type!=o.SHORT_TYPE&&(O(v,w),ee=0),N=0;N<R.sfbmax;N++)R.scalefac[N]==-2&&(R.scalefac[N]=0);ee!=0&&(B.mode_gr==2?this.scale_bitcount(R):this.scale_bitcount_lsf(B,R))};function b(B,T){for(var v=0;v<T;++v)if(B[v]<0)return!1;return!0}var j=[0,18,36,54,54,36,54,72,54,72,90,72,90,108,108,126],A=[0,18,36,54,51,35,53,71,52,70,88,69,87,105,104,122],G=[0,10,20,30,33,21,31,41,32,42,52,43,53,63,64,74];this.scale_bitcount=function(B){var T,v,w=0,R=0,N,K=B.scalefac;if(s(b(K,B.sfbmax)),B.block_type==o.SHORT_TYPE)N=j,B.mixed_block_flag!=0&&(N=A);else if(N=G,B.preflag==0){for(v=11;v<o.SBPSY_l&&!(K[v]<l.pretab[v]);v++);if(v==o.SBPSY_l)for(B.preflag=1,v=11;v<o.SBPSY_l;v++)K[v]-=l.pretab[v]}for(v=0;v<B.sfbdivide;v++)w<K[v]&&(w=K[v]);for(;v<B.sfbmax;v++)R<K[v]&&(R=K[v]);for(B.part2_length=c.LARGE_BITS,T=0;T<16;T++)w<q[T]&&R<C[T]&&B.part2_length>N[T]&&(B.part2_length=N[T],B.scalefac_compress=T);return B.part2_length==c.LARGE_BITS};var F=[[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(B,T){var v,w,R,N,K,se,U,ee,de=n(4),_e=T.scalefac;for(T.preflag!=0?v=2:v=0,U=0;U<4;U++)de[U]=0;if(T.block_type==o.SHORT_TYPE){w=1;var ke=l.nr_of_sfb_block[v][w];for(ee=0,R=0;R<4;R++)for(N=ke[R]/3,U=0;U<N;U++,ee++)for(K=0;K<3;K++)_e[ee*3+K]>de[R]&&(de[R]=_e[ee*3+K])}else{w=0;var ke=l.nr_of_sfb_block[v][w];for(ee=0,R=0;R<4;R++)for(N=ke[R],U=0;U<N;U++,ee++)_e[ee]>de[R]&&(de[R]=_e[ee])}for(se=!1,R=0;R<4;R++)de[R]>F[v][R]&&(se=!0);if(!se){var Pe,Te,$e,je;for(T.sfb_partition_table=l.nr_of_sfb_block[v][w],R=0;R<4;R++)T.slen[R]=Q[de[R]];switch(Pe=T.slen[0],Te=T.slen[1],$e=T.slen[2],je=T.slen[3],v){case 0:T.scalefac_compress=(Pe*5+Te<<4)+($e<<2)+je;break;case 1:T.scalefac_compress=400+(Pe*5+Te<<2)+$e;break;case 2:T.scalefac_compress=500+Pe*3+Te;break;default:e.err.printf(`intensity stereo not implemented yet
|
|
113
|
+
`);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 Q=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];this.huffman_init=function(B){for(var T=2;T<=576;T+=2){for(var v=0,w;B.scalefac_band.l[++v]<T;);for(w=f[v][0];B.scalefac_band.l[w+1]>T;)w--;for(w<0&&(w=f[v][0]),B.bv_scf[T-2]=w,w=f[v][1];B.scalefac_band.l[w+B.bv_scf[T-2]+2]>T;)w--;w<0&&(w=f[v][1]),B.bv_scf[T-1]=w}}}return z1=d,z1}var A1,A3;function V1(){if(A3)return A1;A3=1;var t=qt,e=t.System,r=t.Arrays,n=t.new_byte,s=t.new_float_n,o=t.new_int,i=t.assert,a=l4(),c=B1,d=br(),l=Eu;u.EQ=function(f,p){return Math.abs(f)>Math.abs(p)?Math.abs(f-p)<=Math.abs(f)*1e-6:Math.abs(f-p)<=Math.abs(p)*1e-6},u.NEQ=function(f,p){return!u.EQ(f,p)};function u(){var f=q1(),p=this,m=32773,y=null,k=null,x=null,_=null;this.setModules=function(T,v,w,R){y=T,k=v,x=w,_=R};var g=null,E=0,h=0,$=0;this.getframebits=function(T){var v=T.internal_flags,w;v.bitrate_index!=0?w=c.bitrate_table[T.version][v.bitrate_index]:w=T.brate;var R=0|(T.version+1)*72e3*w/T.out_samplerate+v.padding;return 8*R};function z(T){e.arraycopy(T.header[T.w_ptr].buf,0,g,h,T.sideinfo_len),h+=T.sideinfo_len,E+=T.sideinfo_len*8,T.w_ptr=T.w_ptr+1&l.MAX_HEADER_BUF-1}function L(T,v,w){for(;w>0;){var R;$==0&&($=8,h++,i(h<f.LAME_MAXMP3BUFFER),i(T.header[T.w_ptr].write_timing>=E),T.header[T.w_ptr].write_timing==E&&z(T),g[h]=0),R=Math.min(w,$),w-=R,$-=R,g[h]|=v>>w<<$,E+=R}}function q(T,v,w){for(;w>0;){var R;$==0&&($=8,h++,i(h<f.LAME_MAXMP3BUFFER),g[h]=0),R=Math.min(w,$),w-=R,$-=R,g[h]|=v>>w<<$,E+=R}}function C(T,v){var w=T.internal_flags,R;if(v>=8&&(L(w,76,8),v-=8),v>=8&&(L(w,65,8),v-=8),v>=8&&(L(w,77,8),v-=8),v>=8&&(L(w,69,8),v-=8),v>=32){var N=x.getLameShortVersion();if(v>=32)for(R=0;R<N.length&&v>=8;++R)v-=8,L(w,N.charAt(R),8)}for(;v>=1;v-=1)L(w,w.ancillary_flag,1),w.ancillary_flag^=T.disable_reservoir?0:1}function Z(T,v,w){for(var R=T.header[T.h_ptr].ptr;w>0;){var N=Math.min(w,8-(R&7));w-=N,T.header[T.h_ptr].buf[R>>3]|=v>>w<<8-(R&7)-N,R+=N}T.header[T.h_ptr].ptr=R}function he(T,v){T<<=8;for(var w=0;w<8;w++)T<<=1,v<<=1,(v^T)&65536&&(v^=m);return v}this.CRC_writeheader=function(T,v){var w=65535;w=he(v[2]&255,w),w=he(v[3]&255,w);for(var R=6;R<T.sideinfo_len;R++)w=he(v[R]&255,w);v[4]=byte(w>>8),v[5]=byte(w&255)};function O(T,v){var w=T.internal_flags,R,N,K;if(R=w.l3_side,w.header[w.h_ptr].ptr=0,r.fill(w.header[w.h_ptr].buf,0,w.sideinfo_len,0),T.out_samplerate<16e3?Z(w,4094,12):Z(w,4095,12),Z(w,T.version,1),Z(w,1,2),Z(w,T.error_protection?0:1,1),Z(w,w.bitrate_index,4),Z(w,w.samplerate_index,2),Z(w,w.padding,1),Z(w,T.extension,1),Z(w,T.mode.ordinal(),2),Z(w,w.mode_ext,2),Z(w,T.copyright,1),Z(w,T.original,1),Z(w,T.emphasis,2),T.error_protection&&Z(w,0,16),T.version==1){for(i(R.main_data_begin>=0),Z(w,R.main_data_begin,9),w.channels_out==2?Z(w,R.private_bits,3):Z(w,R.private_bits,5),K=0;K<w.channels_out;K++){var se;for(se=0;se<4;se++)Z(w,R.scfsi[K][se],1)}for(N=0;N<2;N++)for(K=0;K<w.channels_out;K++){var U=R.tt[N][K];Z(w,U.part2_3_length+U.part2_length,12),Z(w,U.big_values/2,9),Z(w,U.global_gain,8),Z(w,U.scalefac_compress,4),U.block_type!=d.NORM_TYPE?(Z(w,1,1),Z(w,U.block_type,2),Z(w,U.mixed_block_flag,1),U.table_select[0]==14&&(U.table_select[0]=16),Z(w,U.table_select[0],5),U.table_select[1]==14&&(U.table_select[1]=16),Z(w,U.table_select[1],5),Z(w,U.subblock_gain[0],3),Z(w,U.subblock_gain[1],3),Z(w,U.subblock_gain[2],3)):(Z(w,0,1),U.table_select[0]==14&&(U.table_select[0]=16),Z(w,U.table_select[0],5),U.table_select[1]==14&&(U.table_select[1]=16),Z(w,U.table_select[1],5),U.table_select[2]==14&&(U.table_select[2]=16),Z(w,U.table_select[2],5),i(0<=U.region0_count&&U.region0_count<16),i(0<=U.region1_count&&U.region1_count<8),Z(w,U.region0_count,4),Z(w,U.region1_count,3)),Z(w,U.preflag,1),Z(w,U.scalefac_scale,1),Z(w,U.count1table_select,1)}}else for(i(R.main_data_begin>=0),Z(w,R.main_data_begin,8),Z(w,R.private_bits,w.channels_out),N=0,K=0;K<w.channels_out;K++){var U=R.tt[N][K];Z(w,U.part2_3_length+U.part2_length,12),Z(w,U.big_values/2,9),Z(w,U.global_gain,8),Z(w,U.scalefac_compress,9),U.block_type!=d.NORM_TYPE?(Z(w,1,1),Z(w,U.block_type,2),Z(w,U.mixed_block_flag,1),U.table_select[0]==14&&(U.table_select[0]=16),Z(w,U.table_select[0],5),U.table_select[1]==14&&(U.table_select[1]=16),Z(w,U.table_select[1],5),Z(w,U.subblock_gain[0],3),Z(w,U.subblock_gain[1],3),Z(w,U.subblock_gain[2],3)):(Z(w,0,1),U.table_select[0]==14&&(U.table_select[0]=16),Z(w,U.table_select[0],5),U.table_select[1]==14&&(U.table_select[1]=16),Z(w,U.table_select[1],5),U.table_select[2]==14&&(U.table_select[2]=16),Z(w,U.table_select[2],5),i(0<=U.region0_count&&U.region0_count<16),i(0<=U.region1_count&&U.region1_count<8),Z(w,U.region0_count,4),Z(w,U.region1_count,3)),Z(w,U.scalefac_scale,1),Z(w,U.count1table_select,1)}T.error_protection&&CRC_writeheader(w,w.header[w.h_ptr].buf);{var ee=w.h_ptr;i(w.header[ee].ptr==w.sideinfo_len*8),w.h_ptr=ee+1&l.MAX_HEADER_BUF-1,w.header[w.h_ptr].write_timing=w.header[ee].write_timing+v,w.h_ptr==w.w_ptr&&e.err.println(`Error: MAX_HEADER_BUF too small in bitstream.c
|
|
114
|
+
`)}}function b(T,v){var w=c.ht[v.count1table_select+32],R,N=0,K=v.big_values,se=v.big_values;for(i(v.count1table_select<2),R=(v.count1-v.big_values)/4;R>0;--R){var U=0,ee=0,de;de=v.l3_enc[K+0],de!=0&&(ee+=8,v.xr[se+0]<0&&U++),de=v.l3_enc[K+1],de!=0&&(ee+=4,U*=2,v.xr[se+1]<0&&U++),de=v.l3_enc[K+2],de!=0&&(ee+=2,U*=2,v.xr[se+2]<0&&U++),de=v.l3_enc[K+3],de!=0&&(ee++,U*=2,v.xr[se+3]<0&&U++),K+=4,se+=4,L(T,U+w.table[ee],w.hlen[ee]),N+=w.hlen[ee]}return N}function j(T,v,w,R,N){var K=c.ht[v],se=0;if(v==0)return se;for(var U=w;U<R;U+=2){var ee=0,de=0,_e=K.xlen,ke=K.xlen,Pe=0,Te=N.l3_enc[U],$e=N.l3_enc[U+1];if(Te!=0&&(N.xr[U]<0&&Pe++,ee--),v>15){if(Te>14){var je=Te-15;i(je<=K.linmax),Pe|=je<<1,de=_e,Te=15}if($e>14){var Tt=$e-15;i(Tt<=K.linmax),Pe<<=_e,Pe|=Tt,de+=_e,$e=15}ke=16}$e!=0&&(Pe<<=1,N.xr[U+1]<0&&Pe++,ee--),Te=Te*ke+$e,de-=ee,ee+=K.hlen[Te],L(T,K.table[Te],ee),L(T,Pe,de),se+=ee+de}return se}function A(T,v){var w=3*T.scalefac_band.s[3];w>v.big_values&&(w=v.big_values);var R=j(T,v.table_select[0],0,w,v);return R+=j(T,v.table_select[1],w,v.big_values,v),R}function G(T,v){var w,R,N,K;w=v.big_values;var se=v.region0_count+1;return i(se<T.scalefac_band.l.length),N=T.scalefac_band.l[se],se+=v.region1_count+1,i(se<T.scalefac_band.l.length),K=T.scalefac_band.l[se],N>w&&(N=w),K>w&&(K=w),R=j(T,v.table_select[0],0,N,v),R+=j(T,v.table_select[1],N,K,v),R+=j(T,v.table_select[2],K,w,v),R}function F(T){var v,w,R,N,K=0,se=T.internal_flags,U=se.l3_side;if(T.version==1)for(v=0;v<2;v++)for(w=0;w<se.channels_out;w++){var ee=U.tt[v][w],de=a.slen1_tab[ee.scalefac_compress],_e=a.slen2_tab[ee.scalefac_compress];for(N=0,R=0;R<ee.sfbdivide;R++)ee.scalefac[R]!=-1&&(L(se,ee.scalefac[R],de),N+=de);for(;R<ee.sfbmax;R++)ee.scalefac[R]!=-1&&(L(se,ee.scalefac[R],_e),N+=_e);i(N==ee.part2_length),ee.block_type==d.SHORT_TYPE?N+=A(se,ee):N+=G(se,ee),N+=b(se,ee),i(N==ee.part2_3_length+ee.part2_length),K+=N}else for(v=0,w=0;w<se.channels_out;w++){var ee=U.tt[v][w],ke,Pe,Te=0;if(i(ee.sfb_partition_table!=null),N=0,R=0,Pe=0,ee.block_type==d.SHORT_TYPE){for(;Pe<4;Pe++){var $e=ee.sfb_partition_table[Pe]/3,je=ee.slen[Pe];for(ke=0;ke<$e;ke++,R++)L(se,Math.max(ee.scalefac[R*3+0],0),je),L(se,Math.max(ee.scalefac[R*3+1],0),je),L(se,Math.max(ee.scalefac[R*3+2],0),je),Te+=3*je}N+=A(se,ee)}else{for(;Pe<4;Pe++){var $e=ee.sfb_partition_table[Pe],je=ee.slen[Pe];for(ke=0;ke<$e;ke++,R++)L(se,Math.max(ee.scalefac[R],0),je),Te+=je}N+=G(se,ee)}N+=b(se,ee),i(N==ee.part2_3_length),i(Te==ee.part2_length),K+=Te+N}return K}function Q(){this.total=0}function B(T,v){var w=T.internal_flags,R,N,K,se,U;return U=w.w_ptr,se=w.h_ptr-1,se==-1&&(se=l.MAX_HEADER_BUF-1),R=w.header[se].write_timing-E,v.total=R,R>=0&&(N=1+se-U,se<U&&(N=1+se-U+l.MAX_HEADER_BUF),R-=N*8*w.sideinfo_len),K=p.getframebits(T),R+=K,v.total+=K,v.total%8!=0?v.total=1+v.total/8:v.total=v.total/8,v.total+=h+1,R<0&&e.err.println(`strange error flushing buffer ...
|
|
115
|
+
`),R}this.flush_bitstream=function(T){var v=T.internal_flags,w,R,N=v.h_ptr-1;if(N==-1&&(N=l.MAX_HEADER_BUF-1),w=v.l3_side,!((R=B(T,new Q))<0)){if(C(T,R),i(v.header[N].write_timing+this.getframebits(T)==E),v.ResvSize=0,w.main_data_begin=0,v.findReplayGain){var K=y.GetTitleGain(v.rgdata);i(NEQ(K,GainAnalysis.GAIN_NOT_ENOUGH_SAMPLES)),v.RadioGain=Math.floor(K*10+.5)|0}v.findPeakSample&&(v.noclipGainChange=Math.ceil(Math.log10(v.PeakSample/32767)*20*10)|0,v.noclipGainChange>0&&(EQ(T.scale,1)||EQ(T.scale,0))?v.noclipScale=Math.floor(32767/v.PeakSample*100)/100:v.noclipScale=-1)}},this.add_dummy_byte=function(T,v,w){for(var R=T.internal_flags,N;w-- >0;)for(q(R,v,8),N=0;N<l.MAX_HEADER_BUF;++N)R.header[N].write_timing+=8},this.format_bitstream=function(T){var v=T.internal_flags,w;w=v.l3_side;var R=this.getframebits(T);C(T,w.resvDrain_pre),O(T,R);var N=8*v.sideinfo_len;if(N+=F(T),C(T,w.resvDrain_post),N+=w.resvDrain_post,w.main_data_begin+=(R-N)/8,B(T,new Q)!=v.ResvSize&&e.err.println("Internal buffer inconsistency. flushbits <> ResvSize"),w.main_data_begin*8!=v.ResvSize&&(e.err.printf(`bit reservoir error:
|
|
196
116
|
l3_side.main_data_begin: %d
|
|
197
117
|
Resvoir size: %d
|
|
198
118
|
resv drain (post) %d
|
|
@@ -201,35 +121,35 @@ header and sideinfo: %d
|
|
|
201
121
|
data bits: %d
|
|
202
122
|
total bits: %d (remainder: %d)
|
|
203
123
|
bitsperframe: %d
|
|
204
|
-
`,8*w.main_data_begin,v.ResvSize,w.resvDrain_post,w.resvDrain_pre,8*v.sideinfo_len,N-w.resvDrain_post-8*v.sideinfo_len,N,N%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"),v.ResvSize=w.main_data_begin*8),E>1e9){var K;for(K=0;K<l.MAX_HEADER_BUF;++K)v.header[K].write_timing-=E;E=0}return 0},this.copy_buffer=function(T,v,w,R,N){var K=h+1;if(K<=0)return 0;if(R!=0&&K>R)return-1;if(e.arraycopy(g,0,v,w,K),h=-1,$=0,N!=0){var se=o(1);if(se[0]=T.nMusicCRC,_.updateMusicCRC(se,v,w,K),T.nMusicCRC=se[0],K>0&&(T.VBR_seek_table.nBytesWritten+=K),T.decode_on_the_fly){for(var
|
|
205
|
-
`)),I.highpass2>0){for(var Ae=-1,Ue=0;Ue<=31;Ue++){var Ce=Ue/31;Ce<=I.highpass1&&(Me=Math.max(Me,Ue)),I.highpass1<Ce&&Ce<I.highpass2&&(Ae=Math.max(Ae,Ue))}I.highpass1=Me/31,Ae==-1?I.highpass2=(Me+.75)/31:I.highpass2=(Ae+.75)/31}for(var Ue=0;Ue<32;Ue++){var tt,De,Ce=Ue/31;I.highpass2>I.highpass1?tt=B((I.highpass2-Ce)/(I.highpass2-I.highpass1+1e-20)):tt=1,I.lowpass2>I.lowpass1?De=B((Ce-I.lowpass1)/(I.lowpass2-I.lowpass1+1e-20)):De=1,I.amp_filter[Ue]=tt*De}}function se(S){var I=S.internal_flags;switch(S.quality){default:case 9:I.psymodel=0,I.noise_shaping=0,I.noise_shaping_amp=0,I.noise_shaping_stop=0,I.use_best_huffman=0,I.full_outer_loop=0;break;case 8:S.quality=7;case 7:I.psymodel=1,I.noise_shaping=0,I.noise_shaping_amp=0,I.noise_shaping_stop=0,I.use_best_huffman=0,I.full_outer_loop=0;break;case 6:I.psymodel=1,I.noise_shaping==0&&(I.noise_shaping=1),I.noise_shaping_amp=0,I.noise_shaping_stop=0,I.subblock_gain==-1&&(I.subblock_gain=1),I.use_best_huffman=0,I.full_outer_loop=0;break;case 5:I.psymodel=1,I.noise_shaping==0&&(I.noise_shaping=1),I.noise_shaping_amp=0,I.noise_shaping_stop=0,I.subblock_gain==-1&&(I.subblock_gain=1),I.use_best_huffman=0,I.full_outer_loop=0;break;case 4:I.psymodel=1,I.noise_shaping==0&&(I.noise_shaping=1),I.noise_shaping_amp=0,I.noise_shaping_stop=0,I.subblock_gain==-1&&(I.subblock_gain=1),I.use_best_huffman=1,I.full_outer_loop=0;break;case 3:I.psymodel=1,I.noise_shaping==0&&(I.noise_shaping=1),I.noise_shaping_amp=1,I.noise_shaping_stop=1,I.subblock_gain==-1&&(I.subblock_gain=1),I.use_best_huffman=1,I.full_outer_loop=0;break;case 2:I.psymodel=1,I.noise_shaping==0&&(I.noise_shaping=1),I.substep_shaping==0&&(I.substep_shaping=2),I.noise_shaping_amp=1,I.noise_shaping_stop=1,I.subblock_gain==-1&&(I.subblock_gain=1),I.use_best_huffman=1,I.full_outer_loop=0;break;case 1:I.psymodel=1,I.noise_shaping==0&&(I.noise_shaping=1),I.substep_shaping==0&&(I.substep_shaping=2),I.noise_shaping_amp=2,I.noise_shaping_stop=1,I.subblock_gain==-1&&(I.subblock_gain=1),I.use_best_huffman=1,I.full_outer_loop=0;break;case 0:I.psymodel=1,I.noise_shaping==0&&(I.noise_shaping=1),I.substep_shaping==0&&(I.substep_shaping=2),I.noise_shaping_amp=2,I.noise_shaping_stop=1,I.subblock_gain==-1&&(I.subblock_gain=1),I.use_best_huffman=1,I.full_outer_loop=0;break}}function H(S){var I=S.internal_flags;S.frameNum=0,S.write_id3tag_automatic&&z.id3tag_write_v2(S),I.bitrate_stereoMode_Hist=o([16,5]),I.bitrate_blockType_Hist=o([16,6]),I.PeakSample=0,S.bWriteVbrTag&&he.InitVbrTag(S)}this.lame_init_params=function(S){var I=S.internal_flags;if(I.Class_ID=0,I.ATH==null&&(I.ATH=new u),I.PSY==null&&(I.PSY=new j),I.rgdata==null&&(I.rgdata=new f),I.channels_in=S.num_channels,I.channels_in==1&&(S.mode=_.MONO),I.channels_out=S.mode==_.MONO?1:2,I.mode_ext=k.MPG_MD_MS_LR,S.mode==_.MONO&&(S.force_ms=!1),S.VBR==r.vbr_off&&S.VBR_mean_bitrate_kbps!=128&&S.brate==0&&(S.brate=S.VBR_mean_bitrate_kbps),S.VBR==r.vbr_off||S.VBR==r.vbr_mtrh||S.VBR==r.vbr_mt||(S.free_format=!1),S.VBR==r.vbr_off&&S.brate==0&&m.EQ(S.compression_ratio,0)&&(S.compression_ratio=11.025),S.VBR==r.vbr_off&&S.compression_ratio>0&&(S.out_samplerate==0&&(S.out_samplerate=map2MP3Frequency(int(.97*S.in_samplerate))),S.brate=0|S.out_samplerate*16*I.channels_out/(1e3*S.compression_ratio),I.samplerate_index=v(S.out_samplerate,S),S.free_format||(S.brate=w(S.brate,S.version,S.out_samplerate))),S.out_samplerate!=0&&(S.out_samplerate<16e3?(S.VBR_mean_bitrate_kbps=Math.max(S.VBR_mean_bitrate_kbps,8),S.VBR_mean_bitrate_kbps=Math.min(S.VBR_mean_bitrate_kbps,64)):S.out_samplerate<32e3?(S.VBR_mean_bitrate_kbps=Math.max(S.VBR_mean_bitrate_kbps,8),S.VBR_mean_bitrate_kbps=Math.min(S.VBR_mean_bitrate_kbps,160)):(S.VBR_mean_bitrate_kbps=Math.max(S.VBR_mean_bitrate_kbps,32),S.VBR_mean_bitrate_kbps=Math.min(S.VBR_mean_bitrate_kbps,320))),S.lowpassfreq==0){var Se=16e3;switch(S.VBR){case r.vbr_off:{var Me=new A;N(Me,S.brate),Se=Me.lowerlimit;break}case r.vbr_abr:{var Me=new A;N(Me,S.VBR_mean_bitrate_kbps),Se=Me.lowerlimit;break}case r.vbr_rh:{var We=[19500,19e3,18600,18e3,17500,16e3,15600,14900,12500,1e4,3950];if(0<=S.VBR_q&&S.VBR_q<=9){var Ue=We[S.VBR_q],Ce=We[S.VBR_q+1],Ae=S.VBR_q_frac;Se=linear_int(Ue,Ce,Ae)}else Se=19500;break}default:{var We=[19500,19e3,18500,18e3,17500,16500,15500,14500,12500,9500,3950];if(0<=S.VBR_q&&S.VBR_q<=9){var Ue=We[S.VBR_q],Ce=We[S.VBR_q+1],Ae=S.VBR_q_frac;Se=linear_int(Ue,Ce,Ae)}else Se=19500}}S.mode==_.MONO&&(S.VBR==r.vbr_off||S.VBR==r.vbr_abr)&&(Se*=1.5),S.lowpassfreq=Se|0}if(S.out_samplerate==0&&(2*S.lowpassfreq>S.in_samplerate&&(S.lowpassfreq=S.in_samplerate/2),S.out_samplerate=T(S.lowpassfreq|0,S.in_samplerate)),S.lowpassfreq=Math.min(20500,S.lowpassfreq),S.lowpassfreq=Math.min(S.out_samplerate/2,S.lowpassfreq),S.VBR==r.vbr_off&&(S.compression_ratio=S.out_samplerate*16*I.channels_out/(1e3*S.brate)),S.VBR==r.vbr_abr&&(S.compression_ratio=S.out_samplerate*16*I.channels_out/(1e3*S.VBR_mean_bitrate_kbps)),S.bWriteVbrTag||(S.findReplayGain=!1,S.decode_on_the_fly=!1,I.findPeakSample=!1),I.findReplayGain=S.findReplayGain,I.decode_on_the_fly=S.decode_on_the_fly,I.decode_on_the_fly&&(I.findPeakSample=!0),I.findReplayGain&&$.InitGainAnalysis(I.rgdata,S.out_samplerate)==GainAnalysis.INIT_GAIN_ANALYSIS_ERROR)return S.internal_flags=null,-6;switch(I.decode_on_the_fly&&!S.decode_only&&(I.hip!=null&&b.hip_decode_exit(I.hip),I.hip=b.hip_decode_init()),I.mode_gr=S.out_samplerate<=24e3?1:2,S.framesize=576*I.mode_gr,S.encoder_delay=k.ENCDELAY,I.resample_ratio=S.in_samplerate/S.out_samplerate,S.VBR){case r.vbr_mt:case r.vbr_rh:case r.vbr_mtrh:{var tt=[5.7,6.5,7.3,8.2,10,11.9,13,14,15,16.5];S.compression_ratio=tt[S.VBR_q]}break;case r.vbr_abr:S.compression_ratio=S.out_samplerate*16*I.channels_out/(1e3*S.VBR_mean_bitrate_kbps);break;default:S.compression_ratio=S.out_samplerate*16*I.channels_out/(1e3*S.brate);break}if(S.mode==_.NOT_SET&&(S.mode=_.JOINT_STEREO),S.highpassfreq>0?(I.highpass1=2*S.highpassfreq,S.highpasswidth>=0?I.highpass2=2*(S.highpassfreq+S.highpasswidth):I.highpass2=1*2*S.highpassfreq,I.highpass1/=S.out_samplerate,I.highpass2/=S.out_samplerate):(I.highpass1=0,I.highpass2=0),S.lowpassfreq>0?(I.lowpass2=2*S.lowpassfreq,S.lowpasswidth>=0?(I.lowpass1=2*(S.lowpassfreq-S.lowpasswidth),I.lowpass1<0&&(I.lowpass1=0)):I.lowpass1=1*2*S.lowpassfreq,I.lowpass1/=S.out_samplerate,I.lowpass2/=S.out_samplerate):(I.lowpass1=0,I.lowpass2=0),K(S),I.samplerate_index=v(S.out_samplerate,S),I.samplerate_index<0)return S.internal_flags=null,-1;if(S.VBR==r.vbr_off){if(S.free_format)I.bitrate_index=0;else if(S.brate=w(S.brate,S.version,S.out_samplerate),I.bitrate_index=R(S.brate,S.version,S.out_samplerate),I.bitrate_index<=0)return S.internal_flags=null,-1}else I.bitrate_index=1;S.analysis&&(S.bWriteVbrTag=!1),I.pinfo!=null&&(S.bWriteVbrTag=!1),O.init_bit_stream_w(I);for(var De=I.samplerate_index+3*S.version+6*(S.out_samplerate<16e3?1:0),we=0;we<k.SBMAX_l+1;we++)I.scalefac_band.l[we]=q.sfBandIndex[De].l[we];for(var we=0;we<k.PSFB21+1;we++){var xt=(I.scalefac_band.l[22]-I.scalefac_band.l[21])/k.PSFB21,Jt=I.scalefac_band.l[21]+we*xt;I.scalefac_band.psfb21[we]=Jt}I.scalefac_band.psfb21[k.PSFB21]=576;for(var we=0;we<k.SBMAX_s+1;we++)I.scalefac_band.s[we]=q.sfBandIndex[De].s[we];for(var we=0;we<k.PSFB12+1;we++){var xt=(I.scalefac_band.s[13]-I.scalefac_band.s[12])/k.PSFB12,Jt=I.scalefac_band.s[12]+we*xt;I.scalefac_band.psfb12[we]=Jt}I.scalefac_band.psfb12[k.PSFB12]=192,S.version==1?I.sideinfo_len=I.channels_out==1?21:36:I.sideinfo_len=I.channels_out==1?13:21,S.error_protection&&(I.sideinfo_len+=2),H(S),I.Class_ID=F;{var gt;for(gt=0;gt<19;gt++)I.nsPsy.pefirbuf[gt]=700*I.mode_gr*I.channels_out;S.ATHtype==-1&&(S.ATHtype=4)}switch(a(S.VBR_q<=9),a(S.VBR_q>=0),S.VBR){case r.vbr_mt:S.VBR=r.vbr_mtrh;case r.vbr_mtrh:{S.useTemporal==null&&(S.useTemporal=!1),L.apply_preset(S,500-S.VBR_q*10,0),S.quality<0&&(S.quality=LAME_DEFAULT_QUALITY),S.quality<5&&(S.quality=0),S.quality>5&&(S.quality=5),I.PSY.mask_adjust=S.maskingadjust,I.PSY.mask_adjust_short=S.maskingadjust_short,S.experimentalY?I.sfb21_extra=!1:I.sfb21_extra=S.out_samplerate>44e3,I.iteration_loop=new VBRNewIterationLoop(C);break}case r.vbr_rh:{L.apply_preset(S,500-S.VBR_q*10,0),I.PSY.mask_adjust=S.maskingadjust,I.PSY.mask_adjust_short=S.maskingadjust_short,S.experimentalY?I.sfb21_extra=!1:I.sfb21_extra=S.out_samplerate>44e3,S.quality>6&&(S.quality=6),S.quality<0&&(S.quality=LAME_DEFAULT_QUALITY),I.iteration_loop=new VBROldIterationLoop(C);break}default:{var P;I.sfb21_extra=!1,S.quality<0&&(S.quality=LAME_DEFAULT_QUALITY),P=S.VBR,P==r.vbr_off&&(S.VBR_mean_bitrate_kbps=S.brate),L.apply_preset(S,S.VBR_mean_bitrate_kbps,0),S.VBR=P,I.PSY.mask_adjust=S.maskingadjust,I.PSY.mask_adjust_short=S.maskingadjust_short,P==r.vbr_off?I.iteration_loop=new p(C):I.iteration_loop=new ABRIterationLoop(C);break}}if(a(S.scale>=0),S.VBR!=r.vbr_off){if(I.VBR_min_bitrate=1,I.VBR_max_bitrate=14,S.out_samplerate<16e3&&(I.VBR_max_bitrate=8),S.VBR_min_bitrate_kbps!=0&&(S.VBR_min_bitrate_kbps=w(S.VBR_min_bitrate_kbps,S.version,S.out_samplerate),I.VBR_min_bitrate=R(S.VBR_min_bitrate_kbps,S.version,S.out_samplerate),I.VBR_min_bitrate<0)||S.VBR_max_bitrate_kbps!=0&&(S.VBR_max_bitrate_kbps=w(S.VBR_max_bitrate_kbps,S.version,S.out_samplerate),I.VBR_max_bitrate=R(S.VBR_max_bitrate_kbps,S.version,S.out_samplerate),I.VBR_max_bitrate<0))return-1;S.VBR_min_bitrate_kbps=y.bitrate_table[S.version][I.VBR_min_bitrate],S.VBR_max_bitrate_kbps=y.bitrate_table[S.version][I.VBR_max_bitrate],S.VBR_mean_bitrate_kbps=Math.min(y.bitrate_table[S.version][I.VBR_max_bitrate],S.VBR_mean_bitrate_kbps),S.VBR_mean_bitrate_kbps=Math.max(y.bitrate_table[S.version][I.VBR_min_bitrate],S.VBR_mean_bitrate_kbps)}return S.tune&&(I.PSY.mask_adjust+=S.tune_value_a,I.PSY.mask_adjust_short+=S.tune_value_a),se(S),a(S.scale>=0),S.athaa_type<0?I.ATH.useAdjust=3:I.ATH.useAdjust=S.athaa_type,I.ATH.aaSensitivityP=Math.pow(10,S.athaa_sensitivity/-10),S.short_blocks==null&&(S.short_blocks=n.short_block_allowed),S.short_blocks==n.short_block_allowed&&(S.mode==_.JOINT_STEREO||S.mode==_.STEREO)&&(S.short_blocks=n.short_block_coupled),S.quant_comp<0&&(S.quant_comp=1),S.quant_comp_short<0&&(S.quant_comp_short=0),S.msfix<0&&(S.msfix=0),S.exp_nspsytune=S.exp_nspsytune|1,S.internal_flags.nsPsy.attackthre<0&&(S.internal_flags.nsPsy.attackthre=c.NSATTACKTHRE),S.internal_flags.nsPsy.attackthre_s<0&&(S.internal_flags.nsPsy.attackthre_s=c.NSATTACKTHRE_S),a(S.scale>=0),S.scale<0&&(S.scale=1),S.ATHtype<0&&(S.ATHtype=4),S.ATHcurve<0&&(S.ATHcurve=4),S.athaa_loudapprox<0&&(S.athaa_loudapprox=2),S.interChRatio<0&&(S.interChRatio=0),S.useTemporal==null&&(S.useTemporal=!0),I.slot_lag=I.frac_SpF=0,S.VBR==r.vbr_off&&(I.slot_lag=I.frac_SpF=(S.version+1)*72e3*S.brate%S.out_samplerate|0),q.iteration_init(S),Z.psymodel_init(S),a(S.scale>=0),0};function ee(S,I){(S.in_buffer_0==null||S.in_buffer_nsamples<I)&&(S.in_buffer_0=s(I),S.in_buffer_1=s(I),S.in_buffer_nsamples=I)}this.lame_encode_flush=function(S,I,Se,Me){var We=S.internal_flags,Ue=i([2,1152]),Ce=0,Ae,tt,De,we,xt=We.mf_samples_to_encode-k.POSTDELAY,Jt=de(S);if(We.mf_samples_to_encode<1)return 0;for(Ae=0,S.in_samplerate!=S.out_samplerate&&(xt+=16*S.out_samplerate/S.in_samplerate),De=S.framesize-xt%S.framesize,De<576&&(De+=S.framesize),S.encoder_padding=De,we=(xt+De)/S.framesize;we>0&&Ce>=0;){var gt=Jt-We.mf_size,P=S.frameNum;gt*=S.in_samplerate,gt/=S.out_samplerate,gt>1152&&(gt=1152),gt<1&&(gt=1),tt=Me-Ae,Me==0&&(tt=0),Ce=this.lame_encode_buffer(S,Ue[0],Ue[1],gt,I,Se,tt),Se+=Ce,Ae+=Ce,we-=P!=S.frameNum?1:0}if(We.mf_samples_to_encode=0,Ce<0||(tt=Me-Ae,Me==0&&(tt=0),O.flush_bitstream(S),Ce=O.copy_buffer(We,I,Se,tt,1),Ce<0))return Ce;if(Se+=Ce,Ae+=Ce,tt=Me-Ae,Me==0&&(tt=0),S.write_id3tag_automatic){if(z.id3tag_write_v1(S),Ce=O.copy_buffer(We,I,Se,tt,0),Ce<0)return Ce;Ae+=Ce}return Ae},this.lame_encode_buffer=function(S,I,Se,Me,We,Ue,Ce){var Ae=S.internal_flags,tt=[null,null];if(Ae.Class_ID!=F)return-3;if(Me==0)return 0;ee(Ae,Me),tt[0]=Ae.in_buffer_0,tt[1]=Ae.in_buffer_1;for(var De=0;De<Me;De++)tt[0][De]=I[De],Ae.channels_in>1&&(tt[1][De]=Se[De]);return _e(S,tt[0],tt[1],Me,We,Ue,Ce)};function de(S){var I=k.BLKSIZE+S.framesize-k.FFTOFFSET;return I=Math.max(I,512+S.framesize-32),I}function _e(S,I,Se,Me,We,Ue,Ce){var Ae=S.internal_flags,tt=0,De,we,xt,Jt,gt,P=[null,null],M=[null,null];if(Ae.Class_ID!=F)return-3;if(Me==0)return 0;if(gt=O.copy_buffer(Ae,We,Ue,Ce,0),gt<0)return gt;if(Ue+=gt,tt+=gt,M[0]=I,M[1]=Se,m.NEQ(S.scale,0)&&m.NEQ(S.scale,1))for(we=0;we<Me;++we)M[0][we]*=S.scale,Ae.channels_out==2&&(M[1][we]*=S.scale);if(m.NEQ(S.scale_left,0)&&m.NEQ(S.scale_left,1))for(we=0;we<Me;++we)M[0][we]*=S.scale_left;if(m.NEQ(S.scale_right,0)&&m.NEQ(S.scale_right,1))for(we=0;we<Me;++we)M[1][we]*=S.scale_right;if(S.num_channels==2&&Ae.channels_out==1)for(we=0;we<Me;++we)M[0][we]=.5*(M[0][we]+M[1][we]),M[1][we]=0;Jt=de(S),P[0]=Ae.mfbuf[0],P[1]=Ae.mfbuf[1];for(var V=0;Me>0;){var U=[null,null],J=0,D=0;U[0]=M[0],U[1]=M[1];var Y=new Ie;if(Kr(S,P,U,V,Me,Y),J=Y.n_in,D=Y.n_out,Ae.findReplayGain&&!Ae.decode_on_the_fly&&$.AnalyzeSamples(Ae.rgdata,P[0],Ae.mf_size,P[1],Ae.mf_size,D,Ae.channels_out)==GainAnalysis.GAIN_ANALYSIS_ERROR)return-6;if(Me-=J,V+=J,Ae.channels_out==2,Ae.mf_size+=D,a(Ae.mf_size<=l.MFSIZE),Ae.mf_samples_to_encode<1&&(Ae.mf_samples_to_encode=k.ENCDELAY+k.POSTDELAY),Ae.mf_samples_to_encode+=D,Ae.mf_size>=Jt){var te=Ce-tt;if(Ce==0&&(te=0),De=ke(S,P[0],P[1],We,Ue,te),De<0)return De;for(Ue+=De,tt+=De,Ae.mf_size-=S.framesize,Ae.mf_samples_to_encode-=S.framesize,xt=0;xt<Ae.channels_out;xt++)for(we=0;we<Ae.mf_size;we++)P[xt][we]=P[xt][we+S.framesize]}}return tt}function ke(S,I,Se,Me,We,Ue){var Ce=g.enc.lame_encode_mp3_frame(S,I,Se,Me,We,Ue);return S.frameNum++,Ce}function Ie(){this.n_in=0,this.n_out=0}function Te(){this.num_used=0}function $e(S,I){return I!=0?$e(I,S%I):S}function je(S,I,Se){var Me=Math.PI*I;S/=Se,S<0&&(S=0),S>1&&(S=1);var We=S-.5,Ue=.42-.5*Math.cos(2*S*Math.PI)+.08*Math.cos(4*S*Math.PI);return Math.abs(We)<1e-9?Me/Math.PI:Ue*Math.sin(Se*Me*We)/(Math.PI*Se*We)}function Tt(S,I,Se,Me,We,Ue,Ce,Ae,tt){var De=S.internal_flags,we,xt=0,Jt,gt=S.out_samplerate/$e(S.out_samplerate,S.in_samplerate);gt>l.BPC&&(gt=l.BPC);var P=Math.abs(De.resample_ratio-Math.floor(.5+De.resample_ratio))<1e-4?1:0,M=1/De.resample_ratio;M>1&&(M=1);var V=31;V%2==0&&--V,V+=P;var U=V+1;if(De.fill_buffer_resample_init==0){for(De.inbuf_old[0]=s(U),De.inbuf_old[1]=s(U),we=0;we<=2*gt;++we)De.blackfilt[we]=s(U);for(De.itime[0]=0,De.itime[1]=0,xt=0;xt<=2*gt;xt++){var J=0,D=(xt-gt)/(2*gt);for(we=0;we<=V;we++)J+=De.blackfilt[xt][we]=je(we-D,M,V);for(we=0;we<=V;we++)De.blackfilt[xt][we]/=J}De.fill_buffer_resample_init=1}var Y=De.inbuf_old[tt];for(Jt=0;Jt<Me;Jt++){var te,X;if(te=Jt*De.resample_ratio,xt=0|Math.floor(te-De.itime[tt]),V+xt-V/2>=Ce)break;var D=te-De.itime[tt]-(xt+.5*(V%2));X=0|Math.floor(D*2*gt+gt+.5);var oe=0;for(we=0;we<=V;++we){var re=0|we+xt-V/2,ie;ie=re<0?Y[U+re]:We[Ue+re],oe+=ie*De.blackfilt[X][we]}I[Se+Jt]=oe}if(Ae.num_used=Math.min(Ce,V+xt-V/2),De.itime[tt]+=Ae.num_used-Jt*De.resample_ratio,Ae.num_used>=U)for(we=0;we<U;we++)Y[we]=We[Ue+Ae.num_used+we-U];else{var ve=U-Ae.num_used;for(we=0;we<ve;++we)Y[we]=Y[we+Ae.num_used];for(xt=0;we<U;++we,++xt)Y[we]=We[Ue+xt];a(xt==Ae.num_used)}return Jt}function Kr(S,I,Se,Me,We,Ue){var Ce=S.internal_flags;if(Ce.resample_ratio<.9999||Ce.resample_ratio>1.0001)for(var Ae=0;Ae<Ce.channels_out;Ae++){var tt=new Te;Ue.n_out=Tt(S,I[Ae],Ce.mf_size,S.framesize,Se[Ae],Me,We,tt,Ae),Ue.n_in=tt.num_used}else{Ue.n_out=Math.min(S.framesize,We),Ue.n_in=Ue.n_out;for(var De=0;De<Ue.n_out;++De)I[0][Ce.mf_size+De]=Se[0][Me+De],Ce.channels_out==2&&(I[1][Ce.mf_size+De]=Se[1][Me+De])}}}return z1=x,z1}var qA=qt,Vn=qA.VbrMode;function FA(){var t=q1();function e(l,u,f,p,m,y,k,x,_,g,E,h,$,O,L){this.vbr_q=l,this.quant_comp=u,this.quant_comp_s=f,this.expY=p,this.st_lrm=m,this.st_s=y,this.masking_adj=k,this.masking_adj_short=x,this.ath_lower=_,this.ath_curve=g,this.ath_sensitivity=E,this.interch=h,this.safejoint=$,this.sfb21mod=O,this.msfix=L}function r(l,u,f,p,m,y,k,x,_,g,E,h,$,O){this.quant_comp=u,this.quant_comp_s=f,this.safejoint=p,this.nsmsfix=m,this.st_lrm=y,this.st_s=k,this.nsbass=x,this.scale=_,this.masking_adj=g,this.ath_lower=E,this.ath_curve=h,this.interch=$,this.sfscale=O}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,f){var p=l.VBR==Vn.vbr_rh?s:o,m=l.VBR_q_frac,y=p[u],k=p[u+1],x=y;y.st_lrm=y.st_lrm+m*(k.st_lrm-y.st_lrm),y.st_s=y.st_s+m*(k.st_s-y.st_s),y.masking_adj=y.masking_adj+m*(k.masking_adj-y.masking_adj),y.masking_adj_short=y.masking_adj_short+m*(k.masking_adj_short-y.masking_adj_short),y.ath_lower=y.ath_lower+m*(k.ath_lower-y.ath_lower),y.ath_curve=y.ath_curve+m*(k.ath_curve-y.ath_curve),y.ath_sensitivity=y.ath_sensitivity+m*(k.ath_sensitivity-y.ath_sensitivity),y.interch=y.interch+m*(k.interch-y.interch),y.msfix=y.msfix+m*(k.msfix-y.msfix),d(l,x.vbr_q),f!=0?l.quant_comp=x.quant_comp:Math.abs(l.quant_comp- -1)>0||(l.quant_comp=x.quant_comp),f!=0?l.quant_comp_short=x.quant_comp_s:Math.abs(l.quant_comp_short- -1)>0||(l.quant_comp_short=x.quant_comp_s),x.expY!=0&&(l.experimentalY=x.expY!=0),f!=0?l.internal_flags.nsPsy.attackthre=x.st_lrm:Math.abs(l.internal_flags.nsPsy.attackthre- -1)>0||(l.internal_flags.nsPsy.attackthre=x.st_lrm),f!=0?l.internal_flags.nsPsy.attackthre_s=x.st_s:Math.abs(l.internal_flags.nsPsy.attackthre_s- -1)>0||(l.internal_flags.nsPsy.attackthre_s=x.st_s),f!=0?l.maskingadjust=x.masking_adj:Math.abs(l.maskingadjust-0)>0||(l.maskingadjust=x.masking_adj),f!=0?l.maskingadjust_short=x.masking_adj_short:Math.abs(l.maskingadjust_short-0)>0||(l.maskingadjust_short=x.masking_adj_short),f!=0?l.ATHlower=-x.ath_lower/10:Math.abs(-l.ATHlower*10-0)>0||(l.ATHlower=-x.ath_lower/10),f!=0?l.ATHcurve=x.ath_curve:Math.abs(l.ATHcurve- -1)>0||(l.ATHcurve=x.ath_curve),f!=0?l.athaa_sensitivity=x.ath_sensitivity:Math.abs(l.athaa_sensitivity- -1)>0||(l.athaa_sensitivity=x.ath_sensitivity),x.interch>0&&(f!=0?l.interChRatio=x.interch:Math.abs(l.interChRatio- -1)>0||(l.interChRatio=x.interch)),x.safejoint>0&&(l.exp_nspsytune=l.exp_nspsytune|x.safejoint),x.sfb21mod>0&&(l.exp_nspsytune=l.exp_nspsytune|x.sfb21mod<<20),f!=0?l.msfix=x.msfix:Math.abs(l.msfix- -1)>0||(l.msfix=x.msfix),f==0&&(l.VBR_q=u,l.VBR_q_frac=m)}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,f){var p=u,m=n.nearestBitrateFullIndex(u);if(l.VBR=Vn.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[m].safejoint>0&&(l.exp_nspsytune=l.exp_nspsytune|2),a[m].sfscale>0&&(l.internal_flags.noise_shaping=2),Math.abs(a[m].nsbass)>0){var y=int(a[m].nsbass*4);y<0&&(y+=64),l.exp_nspsytune=l.exp_nspsytune|y<<2}return f!=0?l.quant_comp=a[m].quant_comp:Math.abs(l.quant_comp- -1)>0||(l.quant_comp=a[m].quant_comp),f!=0?l.quant_comp_short=a[m].quant_comp_s:Math.abs(l.quant_comp_short- -1)>0||(l.quant_comp_short=a[m].quant_comp_s),f!=0?l.msfix=a[m].nsmsfix:Math.abs(l.msfix- -1)>0||(l.msfix=a[m].nsmsfix),f!=0?l.internal_flags.nsPsy.attackthre=a[m].st_lrm:Math.abs(l.internal_flags.nsPsy.attackthre- -1)>0||(l.internal_flags.nsPsy.attackthre=a[m].st_lrm),f!=0?l.internal_flags.nsPsy.attackthre_s=a[m].st_s:Math.abs(l.internal_flags.nsPsy.attackthre_s- -1)>0||(l.internal_flags.nsPsy.attackthre_s=a[m].st_s),f!=0?l.scale=a[m].scale:Math.abs(l.scale- -1)>0||(l.scale=a[m].scale),f!=0?l.maskingadjust=a[m].masking_adj:Math.abs(l.maskingadjust-0)>0||(l.maskingadjust=a[m].masking_adj),a[m].masking_adj>0?f!=0?l.maskingadjust_short=a[m].masking_adj*.9:Math.abs(l.maskingadjust_short-0)>0||(l.maskingadjust_short=a[m].masking_adj*.9):f!=0?l.maskingadjust_short=a[m].masking_adj*1.1:Math.abs(l.maskingadjust_short-0)>0||(l.maskingadjust_short=a[m].masking_adj*1.1),f!=0?l.ATHlower=-a[m].ath_lower/10:Math.abs(-l.ATHlower*10-0)>0||(l.ATHlower=-a[m].ath_lower/10),f!=0?l.ATHcurve=a[m].ath_curve:Math.abs(l.ATHcurve- -1)>0||(l.ATHcurve=a[m].ath_curve),f!=0?l.interChRatio=a[m].interch:Math.abs(l.interChRatio- -1)>0||(l.interChRatio=a[m].interch),u}this.apply_preset=function(l,u,f){switch(u){case t.R3MIX:{u=t.V3,l.VBR=Vn.vbr_mtrh;break}case t.MEDIUM:{u=t.V4,l.VBR=Vn.vbr_rh;break}case t.MEDIUM_FAST:{u=t.V4,l.VBR=Vn.vbr_mtrh;break}case t.STANDARD:{u=t.V2,l.VBR=Vn.vbr_rh;break}case t.STANDARD_FAST:{u=t.V2,l.VBR=Vn.vbr_mtrh;break}case t.EXTREME:{u=t.V0,l.VBR=Vn.vbr_rh;break}case t.EXTREME_FAST:{u=t.V0,l.VBR=Vn.vbr_mtrh;break}case t.INSANE:return u=320,l.preset=u,c(l,u,f),l.VBR=Vn.vbr_off,u}switch(l.preset=u,u){case t.V9:return i(l,9,f),u;case t.V8:return i(l,8,f),u;case t.V7:return i(l,7,f),u;case t.V6:return i(l,6,f),u;case t.V5:return i(l,5,f),u;case t.V4:return i(l,4,f),u;case t.V3:return i(l,3,f),u;case t.V2:return i(l,2,f),u;case t.V1:return i(l,1,f),u;case t.V0:return i(l,0,f),u}return 8<=u&&u<=320?c(l,u,f):(l.preset=0,u)};function d(l,u){var f=0;return 0>u&&(f=-1,u=0),9<u&&(f=-1,u=9),l.VBR_q=u,l.VBR_q_frac=0,f}}var HA=FA;function UA(){this.setModules=function(t,e){}}var GA=UA;function WA(){this.over_noise=0,this.tot_noise=0,this.max_noise=0,this.over_count=0,this.over_SSD=0,this.bits=0}var YA=WA,d4=qt,C3=d4.new_float,XA=d4.new_int;function KA(){this.global_gain=0,this.sfb_count1=0,this.step=XA(39),this.noise=C3(39),this.noise_log=C3(39)}var JA=KA,Ii=qt,Rs=Ii.System,j3=Ii.VbrMode,N1=Ii.Util,Ti=Ii.Arrays,Ka=Ii.new_float,Ja=Ii.assert,QA=GA,C1=YA,ez=JA,vt=br(),D3=D1,L3=$u;function tz(){var t;this.rv=null;var e;this.qupvt=null;var r,n=new QA,s;this.setModules=function(x,_,g,E){t=x,e=_,this.rv=_,r=g,this.qupvt=g,s=E,n.setModules(r,s)},this.ms_convert=function(x,_){for(var g=0;g<576;++g){var E=x.tt[_][0].xr[g],h=x.tt[_][1].xr[g];x.tt[_][0].xr[g]=(E+h)*(N1.SQRT2*.5),x.tt[_][1].xr[g]=(E-h)*(N1.SQRT2*.5)}};function o(x,_,g,E){E=0;for(var h=0;h<=g;++h){var $=Math.abs(x.xr[h]);E+=$,_[h]=Math.sqrt($*Math.sqrt($)),_[h]>x.xrpow_max&&(x.xrpow_max=_[h])}return E}this.init_xrpow=function(x,_,g){var E=0,h=0|_.max_nonzero_coeff;if(_.xrpow_max=0,Ti.fill(g,h,576,0),E=o(_,g,h,E),E>1e-20){var $=0;x.substep_shaping&2&&($=1);for(var O=0;O<_.psymax;O++)x.pseudohalf[O]=$;return!0}return Ti.fill(_.l3_enc,0,576,0),!1};function i(x,_){var g=x.ATH,E=_.xr;if(_.block_type!=vt.SHORT_TYPE)for(var h=!1,$=vt.PSFB21-1;$>=0&&!h;$--){var O=x.scalefac_band.psfb21[$],L=x.scalefac_band.psfb21[$+1],q=r.athAdjust(g.adjust,g.psfb21[$],g.floor);x.nsPsy.longfact[21]>1e-12&&(q*=x.nsPsy.longfact[21]);for(var C=L-1;C>=O;C--)if(Math.abs(E[C])<q)E[C]=0;else{h=!0;break}}else for(var Z=0;Z<3;Z++)for(var h=!1,$=vt.PSFB12-1;$>=0&&!h;$--){var O=x.scalefac_band.s[12]*3+(x.scalefac_band.s[13]-x.scalefac_band.s[12])*Z+(x.scalefac_band.psfb12[$]-x.scalefac_band.psfb12[0]),L=O+(x.scalefac_band.psfb12[$+1]-x.scalefac_band.psfb12[$]),he=r.athAdjust(g.adjust,g.psfb12[$],g.floor);x.nsPsy.shortfact[12]>1e-12&&(he*=x.nsPsy.shortfact[12]);for(var C=L-1;C>=O;C--)if(Math.abs(E[C])<he)E[C]=0;else{h=!0;break}}}this.init_outer_loop=function(x,_){_.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=vt.SBPSY_l,_.sfb_smin=vt.SBPSY_s,_.psy_lmax=x.sfb21_extra?vt.SBMAX_l:vt.SBPSY_l,_.psymax=_.psy_lmax,_.sfbmax=_.sfb_lmax,_.sfbdivide=11;for(var g=0;g<vt.SBMAX_l;g++)_.width[g]=x.scalefac_band.l[g+1]-x.scalefac_band.l[g],_.window[g]=3;if(_.block_type==vt.SHORT_TYPE){var E=Ka(576);_.sfb_smin=0,_.sfb_lmax=0,_.mixed_block_flag!=0&&(_.sfb_smin=3,_.sfb_lmax=x.mode_gr*2+4),_.psymax=_.sfb_lmax+3*((x.sfb21_extra?vt.SBMAX_s:vt.SBPSY_s)-_.sfb_smin),_.sfbmax=_.sfb_lmax+3*(vt.SBPSY_s-_.sfb_smin),_.sfbdivide=_.sfbmax-18,_.psy_lmax=_.sfb_lmax;var h=x.scalefac_band.l[_.sfb_lmax];Rs.arraycopy(_.xr,0,E,0,576);for(var g=_.sfb_smin;g<vt.SBMAX_s;g++)for(var $=x.scalefac_band.s[g],O=x.scalefac_band.s[g+1],L=0;L<3;L++)for(var q=$;q<O;q++)_.xr[h++]=E[3*q+L];for(var C=_.sfb_lmax,g=_.sfb_smin;g<vt.SBMAX_s;g++)_.width[C]=_.width[C+1]=_.width[C+2]=x.scalefac_band.s[g+1]-x.scalefac_band.s[g],_.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,Ti.fill(_.scalefac,0),i(x,_)};function a(x){this.ordinal=x}a.BINSEARCH_NONE=new a(0),a.BINSEARCH_UP=new a(1),a.BINSEARCH_DOWN=new a(2);function c(x,_,g,E,h){var $,O=x.CurrentStep[E],L=!1,q=x.OldValue[E],C=a.BINSEARCH_NONE;for(_.global_gain=q,g-=_.part2_length;;){var Z;if($=s.count_bits(x,h,_,null),O==1||$==g)break;$>g?(C==a.BINSEARCH_DOWN&&(L=!0),L&&(O/=2),C=a.BINSEARCH_UP,Z=O):(C==a.BINSEARCH_UP&&(L=!0),L&&(O/=2),C=a.BINSEARCH_DOWN,Z=-O),_.global_gain+=Z,_.global_gain<0&&(_.global_gain=0,L=!0),_.global_gain>255&&(_.global_gain=255,L=!0)}for(Ja(_.global_gain>=0),Ja(_.global_gain<256);$>g&&_.global_gain<255;)_.global_gain++,$=s.count_bits(x,h,_,null);return x.CurrentStep[E]=q-_.global_gain>=4?4:2,x.OldValue[E]=_.global_gain,_.part2_3_length=$,$}this.trancate_smallspectrums=function(x,_,g,E){var h=Ka(L3.SFBMAX);if(!(!(x.substep_shaping&4)&&_.block_type==vt.SHORT_TYPE||x.substep_shaping&128)){r.calc_noise(_,g,h,new C1,null);for(var O=0;O<576;O++){var $=0;_.l3_enc[O]!=0&&($=Math.abs(_.xr[O])),E[O]=$}var O=0,L=8;_.block_type==vt.SHORT_TYPE&&(L=6);do{var q,C,Z,he,z=_.width[L];if(O+=z,!(h[L]>=1)&&(Ti.sort(E,O-z,z),!BitStream.EQ(E[O-1],0))){q=(1-h[L])*g[L],C=0,he=0;do{var b;for(Z=1;he+Z<z&&!BitStream.NEQ(E[he+O-z],E[he+O+Z-z]);Z++);if(b=E[he+O-z]*E[he+O-z]*Z,q<b){he!=0&&(C=E[he+O-z-1]);break}q-=b,he+=Z}while(he<z);if(!BitStream.EQ(C,0))do Math.abs(_.xr[O-z])<=C&&(_.l3_enc[O-z]=0);while(--z>0)}}while(++L<_.psymax);_.part2_3_length=s.noquant_count_bits(x,_,null)}};function d(x){for(var _=0;_<x.sfbmax;_++)if(x.scalefac[_]+x.subblock_gain[x.window[_]]==0)return!1;return!0}function l(x){return N1.FAST_LOG10(.368+.632*x*x*x)}function u(x,_){for(var g=1e-37,E=0;E<_.psymax;E++)g+=l(x[E]);return Math.max(1e-20,g)}function f(x,_,g,E,h){var $;switch(x){default:case 9:{_.over_count>0?($=g.over_SSD<=_.over_SSD,g.over_SSD==_.over_SSD&&($=g.bits<_.bits)):$=g.max_noise<0&&g.max_noise*10+g.bits<=_.max_noise*10+_.bits;break}case 0:$=g.over_count<_.over_count||g.over_count==_.over_count&&g.over_noise<_.over_noise||g.over_count==_.over_count&&BitStream.EQ(g.over_noise,_.over_noise)&&g.tot_noise<_.tot_noise;break;case 8:g.max_noise=u(h,E);case 1:$=g.max_noise<_.max_noise;break;case 2:$=g.tot_noise<_.tot_noise;break;case 3:$=g.tot_noise<_.tot_noise&&g.max_noise<_.max_noise;break;case 4:$=g.max_noise<=0&&_.max_noise>.2||g.max_noise<=0&&_.max_noise<0&&_.max_noise>g.max_noise-.2&&g.tot_noise<_.tot_noise||g.max_noise<=0&&_.max_noise>0&&_.max_noise>g.max_noise-.2&&g.tot_noise<_.tot_noise+_.over_noise||g.max_noise>0&&_.max_noise>-.05&&_.max_noise>g.max_noise-.1&&g.tot_noise+g.over_noise<_.tot_noise+_.over_noise||g.max_noise>0&&_.max_noise>-.1&&_.max_noise>g.max_noise-.15&&g.tot_noise+g.over_noise+g.over_noise<_.tot_noise+_.over_noise+_.over_noise;break;case 5:$=g.over_noise<_.over_noise||BitStream.EQ(g.over_noise,_.over_noise)&&g.tot_noise<_.tot_noise;break;case 6:$=g.over_noise<_.over_noise||BitStream.EQ(g.over_noise,_.over_noise)&&(g.max_noise<_.max_noise||BitStream.EQ(g.max_noise,_.max_noise)&&g.tot_noise<=_.tot_noise);break;case 7:$=g.over_count<_.over_count||g.over_noise<_.over_noise;break}return _.over_count==0&&($=$&&g.bits<_.bits),$}function p(x,_,g,E,h){var $=x.internal_flags,O;_.scalefac_scale==0?O=1.2968395546510096:O=1.6817928305074292;for(var L=0,q=0;q<_.sfbmax;q++)L<g[q]&&(L=g[q]);var C=$.noise_shaping_amp;switch(C==3&&(h?C=2:C=1),C){case 2:break;case 1:L>1?L=Math.pow(L,.5):L*=.95;break;case 0:default:L>1?L=1:L*=.95;break}for(var Z=0,q=0;q<_.sfbmax;q++){var he=_.width[q],z;if(Z+=he,!(g[q]<L)){if($.substep_shaping&2&&($.pseudohalf[q]=$.pseudohalf[q]==0?1:0,$.pseudohalf[q]==0&&$.noise_shaping_amp==2))return;for(_.scalefac[q]++,z=-he;z<0;z++)E[Z+z]*=O,E[Z+z]>_.xrpow_max&&(_.xrpow_max=E[Z+z]);if($.noise_shaping_amp==2)return}}}function m(x,_){for(var g=1.2968395546510096,E=0,h=0;h<x.sfbmax;h++){var $=x.width[h],O=x.scalefac[h];if(x.preflag!=0&&(O+=r.pretab[h]),E+=$,O&1){O++;for(var L=-$;L<0;L++)_[E+L]*=g,_[E+L]>x.xrpow_max&&(x.xrpow_max=_[E+L])}x.scalefac[h]=O>>1}x.preflag=0,x.scalefac_scale=1}function y(x,_,g){var E,h=_.scalefac;for(E=0;E<_.sfb_lmax;E++)if(h[E]>=16)return!0;for(var $=0;$<3;$++){var O=0,L=0;for(E=_.sfb_lmax+$;E<_.sfbdivide;E+=3)O<h[E]&&(O=h[E]);for(;E<_.sfbmax;E+=3)L<h[E]&&(L=h[E]);if(!(O<16&&L<8)){if(_.subblock_gain[$]>=7)return!0;_.subblock_gain[$]++;var q=x.scalefac_band.l[_.sfb_lmax];for(E=_.sfb_lmax+$;E<_.sfbmax;E+=3){var C,Z=_.width[E],he=h[E];if(he=he-(4>>_.scalefac_scale),he>=0){h[E]=he,q+=Z*3;continue}h[E]=0;{var z=210+(he<<_.scalefac_scale+1);C=r.IPOW20(z)}q+=Z*($+1);for(var b=-Z;b<0;b++)g[q+b]*=C,g[q+b]>_.xrpow_max&&(_.xrpow_max=g[q+b]);q+=Z*(3-$-1)}{var C=r.IPOW20(202);q+=_.width[E]*($+1);for(var b=-_.width[E];b<0;b++)g[q+b]*=C,g[q+b]>_.xrpow_max&&(_.xrpow_max=g[q+b])}}}return!1}function k(x,_,g,E,h){var $=x.internal_flags;p(x,_,g,E,h);var O=d(_);return O?!1:($.mode_gr==2?O=s.scale_bitcount(_):O=s.scale_bitcount_lsf($,_),O?($.noise_shaping>1&&(Ti.fill($.pseudohalf,0),_.scalefac_scale==0?(m(_,E),O=!1):_.block_type==vt.SHORT_TYPE&&$.subblock_gain>0&&(O=y($,_,E)||d(_))),O||($.mode_gr==2?O=s.scale_bitcount(_):O=s.scale_bitcount_lsf($,_)),!O):!0)}this.outer_loop=function(x,_,g,E,h,$){var O=x.internal_flags,L=new D3,q=Ka(576),C=Ka(L3.SFBMAX),Z=new C1,he,z=new ez,b=9999999,j=!1,A=!1,G=0;if(c(O,_,$,h,E),O.noise_shaping==0)return 100;r.calc_noise(_,g,C,Z,z),Z.bits=_.part2_3_length,L.assign(_);var F=0;for(Rs.arraycopy(E,0,q,0,576);!j;){do{var Q=new C1,B,T=255;if(O.substep_shaping&2?B=20:B=3,O.sfb21_extra&&(C[L.sfbmax]>1||L.block_type==vt.SHORT_TYPE&&(C[L.sfbmax+1]>1||C[L.sfbmax+2]>1))||!k(x,L,C,E,A))break;L.scalefac_scale!=0&&(T=254);var v=$-L.part2_length;if(v<=0)break;for(;(L.part2_3_length=s.count_bits(O,E,L,z))>v&&L.global_gain<=T;)L.global_gain++;if(L.global_gain>T)break;if(Z.over_count==0){for(;(L.part2_3_length=s.count_bits(O,E,L,z))>b&&L.global_gain<=T;)L.global_gain++;if(L.global_gain>T)break}if(r.calc_noise(L,g,C,Q,z),Q.bits=L.part2_3_length,_.block_type!=vt.SHORT_TYPE?he=x.quant_comp:he=x.quant_comp_short,he=f(he,Z,Q,L,C)?1:0,he!=0)b=_.part2_3_length,Z=Q,_.assign(L),F=0,Rs.arraycopy(E,0,q,0,576);else if(O.full_outer_loop==0&&(++F>B&&Z.over_count==0||O.noise_shaping_amp==3&&A&&F>30||O.noise_shaping_amp==3&&A&&L.global_gain-G>15))break}while(L.global_gain+L.scalefac_scale<255);O.noise_shaping_amp==3?A?j=!0:(L.assign(_),Rs.arraycopy(q,0,E,0,576),F=0,G=L.global_gain,A=!0):j=!0}return Ja(_.global_gain+_.scalefac_scale<=255),x.VBR==j3.vbr_rh||x.VBR==j3.vbr_mtrh?Rs.arraycopy(q,0,E,0,576):O.substep_shaping&1&&trancate_smallspectrums(O,_,g,E),Z.over_count},this.iteration_finish_one=function(x,_,g){var E=x.l3_side,h=E.tt[_][g];s.best_scalefac_store(x,_,g,E),x.use_best_huffman==1&&s.best_huffman_divide(x,h),e.ResvAdjust(x,h)},this.VBR_encode_granule=function(x,_,g,E,h,$,O){var L=x.internal_flags,q=new D3,C=Ka(576),Z=O,he=O+1,z=(O+$)/2,b,j,A=0,G=L.sfb21_extra;Ja(Z<=LameInternalFlags.MAX_BITS_PER_CHANNEL),Ti.fill(q.l3_enc,0);do z>Z-42?L.sfb21_extra=!1:L.sfb21_extra=G,j=outer_loop(x,_,g,E,h,z),j<=0?(A=1,he=_.part2_3_length,q.assign(_),Rs.arraycopy(E,0,C,0,576),O=he-32,b=O-$,z=(O+$)/2):($=z+32,b=O-$,z=(O+$)/2,A!=0&&(A=2,_.assign(q),Rs.arraycopy(C,0,E,0,576)));while(b>12);L.sfb21_extra=G,A==2&&Rs.arraycopy(q.l3_enc,0,_.l3_enc,0,576),Ja(_.part2_3_length<=Z)},this.get_framebits=function(x,_){var g=x.internal_flags;g.bitrate_index=g.VBR_min_bitrate;var E=t.getframebits(x);g.bitrate_index=1,E=t.getframebits(x);for(var h=1;h<=g.VBR_max_bitrate;h++){g.bitrate_index=h;var $=new MeanBits(E);_[h]=e.ResvFrameBegin(x,$),E=$.bits}},this.VBR_old_prepare=function(x,_,g,E,h,$,O,L,q){var C=x.internal_flags,Z,he=0,z=1,b=0;C.bitrate_index=C.VBR_max_bitrate;var j=e.ResvFrameBegin(x,new MeanBits(0))/C.mode_gr;get_framebits(x,$);for(var A=0;A<C.mode_gr;A++){var G=r.on_pe(x,_,L[A],j,A,0);C.mode_ext==vt.MPG_MD_MS_LR&&(ms_convert(C.l3_side,A),r.reduce_side(L[A],g[A],j,G));for(var F=0;F<C.channels_out;++F){var Q=C.l3_side.tt[A][F];Q.block_type!=vt.SHORT_TYPE?(he=1.28/(1+Math.exp(3.5-_[A][F]/300))-.05,Z=C.PSY.mask_adjust-he):(he=2.56/(1+Math.exp(3.5-_[A][F]/300))-.14,Z=C.PSY.mask_adjust_short-he),C.masking_lower=Math.pow(10,Z*.1),init_outer_loop(C,Q),q[A][F]=r.calc_xmin(x,E[A][F],Q,h[A][F]),q[A][F]!=0&&(z=0),O[A][F]=126,b+=L[A][F]}}for(var A=0;A<C.mode_gr;A++)for(var F=0;F<C.channels_out;F++)b>$[C.VBR_max_bitrate]&&(L[A][F]*=$[C.VBR_max_bitrate],L[A][F]/=b),O[A][F]>L[A][F]&&(O[A][F]=L[A][F]);return z},this.bitpressure_strategy=function(x,_,g,E){for(var h=0;h<x.mode_gr;h++)for(var $=0;$<x.channels_out;$++){for(var O=x.l3_side.tt[h][$],L=_[h][$],q=0,C=0;C<O.psy_lmax;C++)L[q++]*=1+.029*C*C/vt.SBMAX_l/vt.SBMAX_l;if(O.block_type==vt.SHORT_TYPE)for(var C=O.sfb_smin;C<vt.SBMAX_s;C++)L[q++]*=1+.029*C*C/vt.SBMAX_s/vt.SBMAX_s,L[q++]*=1+.029*C*C/vt.SBMAX_s/vt.SBMAX_s,L[q++]*=1+.029*C*C/vt.SBMAX_s/vt.SBMAX_s;E[h][$]=0|Math.max(g[h][$],.9*E[h][$])}},this.VBR_new_prepare=function(x,_,g,E,h,$){var O=x.internal_flags,L=1,q=0,C=0,Z;if(x.free_format){O.bitrate_index=0;var he=new MeanBits(q);Z=e.ResvFrameBegin(x,he),q=he.bits,h[0]=Z}else{O.bitrate_index=O.VBR_max_bitrate;var he=new MeanBits(q);e.ResvFrameBegin(x,he),q=he.bits,get_framebits(x,h),Z=h[O.VBR_max_bitrate]}for(var z=0;z<O.mode_gr;z++){r.on_pe(x,_,$[z],q,z,0),O.mode_ext==vt.MPG_MD_MS_LR&&ms_convert(O.l3_side,z);for(var b=0;b<O.channels_out;++b){var j=O.l3_side.tt[z][b];O.masking_lower=Math.pow(10,O.PSY.mask_adjust*.1),init_outer_loop(O,j),r.calc_xmin(x,g[z][b],j,E[z][b])!=0&&(L=0),C+=$[z][b]}}for(var z=0;z<O.mode_gr;z++)for(var b=0;b<O.channels_out;b++)C>Z&&($[z][b]*=Z,$[z][b]/=C);return L},this.calc_target_bits=function(x,_,g,E,h,$){var O=x.internal_flags,L=O.l3_side,q,C,Z,he,z=0;O.bitrate_index=O.VBR_max_bitrate;var b=new MeanBits(z);for($[0]=e.ResvFrameBegin(x,b),z=b.bits,O.bitrate_index=1,z=t.getframebits(x)-O.sideinfo_len*8,h[0]=z/(O.mode_gr*O.channels_out),z=x.VBR_mean_bitrate_kbps*x.framesize*1e3,O.substep_shaping&1&&(z*=1.09),z/=x.out_samplerate,z-=O.sideinfo_len*8,z/=O.mode_gr*O.channels_out,q=.93+.07*(11-x.compression_ratio)/(11-5.5),q<.9&&(q=.9),q>1&&(q=1),C=0;C<O.mode_gr;C++){var j=0;for(Z=0;Z<O.channels_out;Z++){if(E[C][Z]=int(q*z),_[C][Z]>700){var A=int((_[C][Z]-700)/1.4),G=L.tt[C][Z];E[C][Z]=int(q*z),G.block_type==vt.SHORT_TYPE&&A<z/2&&(A=z/2),A>z*3/2?A=z*3/2:A<0&&(A=0),E[C][Z]+=A}E[C][Z]>LameInternalFlags.MAX_BITS_PER_CHANNEL&&(E[C][Z]=LameInternalFlags.MAX_BITS_PER_CHANNEL),j+=E[C][Z]}if(j>LameInternalFlags.MAX_BITS_PER_GRANULE)for(Z=0;Z<O.channels_out;++Z)E[C][Z]*=LameInternalFlags.MAX_BITS_PER_GRANULE,E[C][Z]/=j}if(O.mode_ext==vt.MPG_MD_MS_LR)for(C=0;C<O.mode_gr;C++)r.reduce_side(E[C],g[C],z*O.channels_out,LameInternalFlags.MAX_BITS_PER_GRANULE);for(he=0,C=0;C<O.mode_gr;C++)for(Z=0;Z<O.channels_out;Z++)E[C][Z]>LameInternalFlags.MAX_BITS_PER_CHANNEL&&(E[C][Z]=LameInternalFlags.MAX_BITS_PER_CHANNEL),he+=E[C][Z];if(he>$[0])for(C=0;C<O.mode_gr;C++)for(Z=0;Z<O.channels_out;Z++)E[C][Z]*=$[0],E[C][Z]/=he}}var rz=tz,nz=qt,Z3=nz.assert;function sz(){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),Z3(n.ResvMax%8==0),Z3(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 oz=sz;function iz(){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 az=iz,Pi=qt,cz=Pi.System,j1=Pi.VbrMode,B3=Pi.ShortBlock,lz=Pi.Arrays,Su=Pi.new_byte,uz=Pi.assert;Qa.NUMTOCENTRIES=100;Qa.MAXFRAMESIZE=2880;function Qa(){var t,e,r;this.setModules=function(z,b,j){t=z,e=b,r=j};var n=1,s=2,o=4,i=8,a=Qa.NUMTOCENTRIES,c=Qa.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,f=64,p=32,m=null,y="Xing",k="Info",x=[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 _(z,b){if(z.nVbrNumFrames++,z.sum+=b,z.seen++,!(z.seen<z.want)&&(z.pos<z.size&&(z.bag[z.pos]=z.sum,z.pos++,z.seen=0),z.pos==z.size)){for(var j=1;j<z.size;j+=2)z.bag[j/2]=z.bag[j];z.want*=2,z.pos/=2}}function g(z,b){if(!(z.pos<=0))for(var j=1;j<a;++j){var A=j/a,G,F,Q=0|Math.floor(A*z.pos);Q>z.pos-1&&(Q=z.pos-1),G=z.bag[Q],F=z.sum;var B=0|256*G/F;B>255&&(B=255),b[j]=255&B}}this.addVbrFrame=function(z){var b=z.internal_flags,j=Tables.bitrate_table[z.version][b.bitrate_index];uz(b.VBR_seek_table.bag!=null),_(b.VBR_seek_table,j)};function E(z,b){var j=z[b+0]&255;return j<<=8,j|=z[b+1]&255,j<<=8,j|=z[b+2]&255,j<<=8,j|=z[b+3]&255,j}function h(z,b,j){z[b+0]=255&(j>>24&255),z[b+1]=255&(j>>16&255),z[b+2]=255&(j>>8&255),z[b+3]=255&(j&255)}function $(z,b,j){z[b+0]=255&(j>>8&255),z[b+1]=255&(j&255)}function O(z,b){return new String(z,b,y.length(),m).equals(y)||new String(z,b,k.length(),m).equals(k)}function L(z,b,j){return 255&(z<<b|j&~(-1<<b))}function q(z,b){var j=z.internal_flags;b[0]=L(b[0],8,255),b[1]=L(b[1],3,7),b[1]=L(b[1],1,z.out_samplerate<16e3?0:1),b[1]=L(b[1],1,z.version),b[1]=L(b[1],2,1),b[1]=L(b[1],1,z.error_protection?0:1),b[2]=L(b[2],4,j.bitrate_index),b[2]=L(b[2],2,j.samplerate_index),b[2]=L(b[2],1,0),b[2]=L(b[2],1,z.extension),b[3]=L(b[3],2,z.mode.ordinal()),b[3]=L(b[3],2,j.mode_ext),b[3]=L(b[3],1,z.copyright),b[3]=L(b[3],1,z.original),b[3]=L(b[3],2,z.emphasis),b[0]=255;var A=255&(b[1]&241),G;z.version==1?G=u:z.out_samplerate<16e3?G=p:G=f,z.VBR==j1.vbr_off&&(G=z.brate);var F;z.free_format?F=0:F=255&16*t.BitrateIndex(G,z.version,z.out_samplerate),z.version==1?(b[1]=255&(A|10),A=255&(b[2]&13),b[2]=255&(F|A)):(b[1]=255&(A|2),A=255&(b[2]&13),b[2]=255&(F|A))}this.getVbrTag=function(z){var b=new VBRTagData,j=0;b.flags=0;var A=z[j+1]>>3&1,G=z[j+2]>>2&3,F=z[j+3]>>6&3,Q=z[j+2]>>4&15;if(Q=Tables.bitrate_table[A][Q],z[j+1]>>4==14?b.samprate=Tables.samplerate_table[2][G]:b.samprate=Tables.samplerate_table[A][G],A!=0?F!=3?j+=36:j+=21:F!=3?j+=21:j+=13,!O(z,j))return null;j+=4,b.hId=A;var B=b.flags=E(z,j);if(j+=4,B&n&&(b.frames=E(z,j),j+=4),B&s&&(b.bytes=E(z,j),j+=4),B&o){if(b.toc!=null)for(var T=0;T<a;T++)b.toc[T]=z[j+T];j+=a}b.vbrScale=-1,B&i&&(b.vbrScale=E(z,j),j+=4),b.headersize=(A+1)*72e3*Q/b.samprate,j+=21;var v=z[j+0]<<4;v+=z[j+1]>>4;var w=(z[j+1]&15)<<8;return w+=z[j+2]&255,(v<0||v>3e3)&&(v=-1),(w<0||w>3e3)&&(w=-1),b.encDelay=v,b.encPadding=w,b},this.InitVbrTag=function(z){var b=z.internal_flags,j;z.version==1?j=u:z.out_samplerate<16e3?j=p:j=f,z.VBR==j1.vbr_off&&(j=z.brate);var A=(z.version+1)*72e3*j/z.out_samplerate,G=b.sideinfo_len+l;if(b.VBR_seek_table.TotalFrameSize=A,A<G||A>c){z.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 F=Su(c);q(z,F);for(var Q=b.VBR_seek_table.TotalFrameSize,B=0;B<Q;++B)e.add_dummy_byte(z,F[B]&255,1)};function C(z,b){var j=b^z;return b=b>>8^x[j&255],b}this.updateMusicCRC=function(z,b,j,A){for(var G=0;G<A;++G)z[0]=C(b[j+G],z[0])};function Z(z,b,j,A,G){var F=z.internal_flags,Q=0,B=z.encoder_delay,T=z.encoder_padding,v=100-10*z.VBR_q-z.quality,w=r.getLameVeryShortVersion(),R,N=0,K,se=[1,5,3,2,4,0,3],H=0|(z.lowpassfreq/100+.5>255?255:z.lowpassfreq/100+.5),ee=0,de=0,_e=0,ke=z.internal_flags.noise_shaping,Ie=0,Te=0,$e=0,je=0,Tt=0,Kr=(z.exp_nspsytune&1)!=0,S=(z.exp_nspsytune&2)!=0,I=!1,Se=!1,Me=z.internal_flags.nogap_total,We=z.internal_flags.nogap_current,Ue=z.ATHtype,Ce=0,Ae;switch(z.VBR){case vbr_abr:Ae=z.VBR_mean_bitrate_kbps;break;case vbr_off:Ae=z.brate;break;default:Ae=z.VBR_min_bitrate_kbps}switch(z.VBR.ordinal()<se.length?R=se[z.VBR.ordinal()]:R=0,K=16*N+R,F.findReplayGain&&(F.RadioGain>510&&(F.RadioGain=510),F.RadioGain<-510&&(F.RadioGain=-510),de=8192,de|=3072,F.RadioGain>=0?de|=F.RadioGain:(de|=512,de|=-F.RadioGain)),F.findPeakSample&&(ee=Math.abs(0|F.PeakSample/32767*Math.pow(2,23)+.5)),Me!=-1&&(We>0&&(Se=!0),We<Me-1&&(I=!0)),Ce=Ue+((Kr?1:0)<<4)+((S?1:0)<<5)+((I?1:0)<<6)+((Se?1:0)<<7),v<0&&(v=0),z.mode){case MONO:Ie=0;break;case STEREO:Ie=1;break;case DUAL_CHANNEL:Ie=2;break;case JOINT_STEREO:z.force_ms?Ie=4:Ie=3;break;case NOT_SET:default:Ie=7;break}z.in_samplerate<=32e3?$e=0:z.in_samplerate==48e3?$e=2:z.in_samplerate>48e3?$e=3:$e=1,(z.short_blocks==B3.short_block_forced||z.short_blocks==B3.short_block_dispensed||z.lowpassfreq==-1&&z.highpassfreq==-1||z.scale_left<z.scale_right||z.scale_left>z.scale_right||z.disable_reservoir&&z.brate<320||z.noATH||z.ATHonly||Ue==0||z.in_samplerate<=32e3)&&(Te=1),je=ke+(Ie<<2)+(Te<<5)+($e<<6),Tt=F.nMusicCRC,h(j,A+Q,v),Q+=4;for(var tt=0;tt<9;tt++)j[A+Q+tt]=255&w.charAt(tt);Q+=9,j[A+Q]=255&K,Q++,j[A+Q]=255&H,Q++,h(j,A+Q,ee),Q+=4,$(j,A+Q,de),Q+=2,$(j,A+Q,_e),Q+=2,j[A+Q]=255&Ce,Q++,Ae>=255?j[A+Q]=255:j[A+Q]=255&Ae,Q++,j[A+Q]=255&B>>4,j[A+Q+1]=255&(B<<4)+(T>>8),j[A+Q+2]=255&T,Q+=3,j[A+Q]=255&je,Q++,j[A+Q++]=0,$(j,A+Q,z.preset),Q+=2,h(j,A+Q,b),Q+=4,$(j,A+Q,Tt),Q+=2;for(var De=0;De<Q;De++)G=C(j[A+De],G);return $(j,A+Q,G),Q+=2,Q}function he(z){z.seek(0);var b=Su(10);z.readFully(b);var j;return new String(b,"ISO-8859-1").startsWith("ID3")?j=0:j=((b[6]&127)<<21|(b[7]&127)<<14|(b[8]&127)<<7|b[9]&127)+b.length,j}this.getLameTagFrame=function(z,b){var j=z.internal_flags;if(!z.bWriteVbrTag||j.Class_ID!=Lame.LAME_ID||j.VBR_seek_table.pos<=0)return 0;if(b.length<j.VBR_seek_table.TotalFrameSize)return j.VBR_seek_table.TotalFrameSize;lz.fill(b,0,j.VBR_seek_table.TotalFrameSize,0),q(z,b);var A=Su(a);if(z.free_format)for(var G=1;G<a;++G)A[G]=255&255*G/100;else g(j.VBR_seek_table,A);var F=j.sideinfo_len;z.error_protection&&(F-=2),z.VBR==j1.vbr_off?(b[F++]=255&k.charAt(0),b[F++]=255&k.charAt(1),b[F++]=255&k.charAt(2),b[F++]=255&k.charAt(3)):(b[F++]=255&y.charAt(0),b[F++]=255&y.charAt(1),b[F++]=255&y.charAt(2),b[F++]=255&y.charAt(3)),h(b,F,n+s+o+i),F+=4,h(b,F,j.VBR_seek_table.nVbrNumFrames),F+=4;var Q=j.VBR_seek_table.nBytesWritten+j.VBR_seek_table.TotalFrameSize;h(b,F,0|Q),F+=4,cz.arraycopy(A,0,b,F,A.length),F+=A.length,z.error_protection&&e.CRC_writeheader(j,b);for(var B=0,G=0;G<F;G++)B=C(b[G],B);return F+=Z(z,Q,b,F,B),j.VBR_seek_table.TotalFrameSize},this.putVbrTag=function(z,b){var j=z.internal_flags;if(j.VBR_seek_table.pos<=0||(b.seek(b.length()),b.length()==0))return-1;var A=he(b);b.seek(A);var G=Su(c),F=getLameTagFrame(z,G);return F>G.length?-1:(F<1||b.write(G,0,F),0)}}var dz=Qa,h4=qt,V3=h4.new_byte,hz=h4.assert,fz=q1(),pz=HA,mz=i4,gz=l4(),_z=rz,bz=u4(),yz=oz,vz=tc,wz=V1();br();var xz=az,Sz=dz;function kz(){this.setModules=function(t,e){}}function $z(){this.setModules=function(t,e,r){}}function Ez(){}function Tz(){this.setModules=function(t,e){}}function Rz(t,e,r){arguments.length!=3&&(console.error("WARN: Mp3Encoder(channels, samplerate, kbps) not specified"),t=1,e=44100,r=128);var n=new fz,s=new kz,o=new mz,i=new wz,a=new pz,c=new gz,d=new _z,l=new Sz,u=new xz,f=new Tz,p=new yz,m=new bz,y=new $z,k=new Ez;n.setModules(o,i,a,c,d,l,u,f,k),i.setModules(o,k,u,l),f.setModules(i,u),a.setModules(n),d.setModules(i,p,c,m),c.setModules(m,p,n.enc.psy),p.setModules(i),m.setModules(c),l.setModules(n,i,u),s.setModules(y,k),y.setModules(u,f,a);var x=n.lame_init();x.num_channels=t,x.in_samplerate=e,x.brate=r,x.mode=vz.STEREO,x.quality=3,x.bWriteVbrTag=!1,x.disable_reservoir=!0,x.write_id3tag_automatic=!1,n.lame_init_params(x);var _=1152,g=0|1.25*_+7200,E=V3(g);this.encodeBuffer=function(h,$){t==1&&($=h),hz(h.length==$.length),h.length>_&&(_=h.length,g=0|1.25*_+7200,E=V3(g));var O=n.lame_encode_buffer(x,h,$,h.length,E,0,g);return new Int8Array(E.subarray(0,O))},this.flush=function(){var h=n.lame_encode_flush(x,E,0,g);return new Int8Array(E.subarray(0,h))}}function In(){this.dataOffset=0,this.dataLen=0,this.channels=0,this.sampleRate=0}function Tu(t){return t.charCodeAt(0)<<24|t.charCodeAt(1)<<16|t.charCodeAt(2)<<8|t.charCodeAt(3)}In.RIFF=Tu("RIFF");In.WAVE=Tu("WAVE");In.fmt_=Tu("fmt ");In.data=Tu("data");In.readHeader=function(t){var e=new In,r=t.getUint32(0,!1);if(In.RIFF==r&&(t.getUint32(4,!0),In.WAVE==t.getUint32(8,!1)&&In.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=In.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 f4=q3.Mp3Encoder=Rz,MF=q3.WavHeader=In;var Io=24e3;function F1(t){let e=Buffer.from(t);return new Int16Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/2))}function Iz(t){let e=t.indexOf("data",0,"ascii"),r=e>=0?e+8:44;return F1(t.subarray(r))}var Pz="Tone: friendly, clear, and natural \u2014 like a knowledgeable teacher explaining something they enjoy. Calm and encouraging, not theatrical.",Mz="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 Oz(t){return process.env.FLOWCAST_TTS_INSTRUCTIONS?process.env.FLOWCAST_TTS_INSTRUCTIONS:`${t&&t.trim()?`Tone & delivery for this walkthrough: ${t.trim()}`:Pz}
|
|
206
|
-
|
|
207
|
-
${
|
|
208
|
-
`);try{
|
|
209
|
-
`),l=!1;for(let u=0;u<d.length;u++){let f=d[u];if(n+=f,l)l=!1;else if(l=f>="\uD800"&&f<="\uDBFF",l)continue;if(f===
|
|
210
|
-
`){o&&(n+=
|
|
211
|
-
`&&(s&&
|
|
212
|
-
`)}var yr=
|
|
124
|
+
`,8*w.main_data_begin,v.ResvSize,w.resvDrain_post,w.resvDrain_pre,8*v.sideinfo_len,N-w.resvDrain_post-8*v.sideinfo_len,N,N%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"),v.ResvSize=w.main_data_begin*8),E>1e9){var K;for(K=0;K<l.MAX_HEADER_BUF;++K)v.header[K].write_timing-=E;E=0}return 0},this.copy_buffer=function(T,v,w,R,N){var K=h+1;if(K<=0)return 0;if(R!=0&&K>R)return-1;if(e.arraycopy(g,0,v,w,K),h=-1,$=0,N!=0){var se=o(1);if(se[0]=T.nMusicCRC,_.updateMusicCRC(se,v,w,K),T.nMusicCRC=se[0],K>0&&(T.VBR_seek_table.nBytesWritten+=K),T.decode_on_the_fly){for(var U=s([2,1152]),ee=K,de=-1,_e;de!=0;)if(de=k.hip_decode1_unclipped(T.hip,v,w,ee,U[0],U[1]),ee=0,de==-1&&(de=0),de>0){if(T.findPeakSample){for(_e=0;_e<de;_e++)U[0][_e]>T.PeakSample?T.PeakSample=U[0][_e]:-U[0][_e]>T.PeakSample&&(T.PeakSample=-U[0][_e]);if(T.channels_out>1)for(_e=0;_e<de;_e++)U[1][_e]>T.PeakSample?T.PeakSample=U[1][_e]:-U[1][_e]>T.PeakSample&&(T.PeakSample=-U[1][_e])}if(T.findReplayGain&&y.AnalyzeSamples(T.rgdata,U[0],0,U[1],0,de,T.channels_out)==GainAnalysis.GAIN_ANALYSIS_ERROR)return-6}}}return K},this.init_bit_stream_w=function(T){g=n(f.LAME_MAXMP3BUFFER),T.h_ptr=T.w_ptr=0,T.header[T.h_ptr].write_timing=0,h=-1,$=0,E=0}}return A1=u,A1}var O1,O3;function q1(){if(O3)return O1;O3=1;var t=qt,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=iA,d=lA,l=Eu,u=AA,f=NA,p=VA,m=V1(),y=B1,k=br();function x(){var _=ec,g=this,E=128*1024;x.V9=410,x.V8=420,x.V7=430,x.V6=440,x.V5=450,x.V4=460,x.V3=470,x.V2=480,x.V1=490,x.V0=500,x.R3MIX=1e3,x.STANDARD=1001,x.EXTREME=1002,x.INSANE=1003,x.STANDARD_FAST=1004,x.EXTREME_FAST=1005,x.MEDIUM=1006,x.MEDIUM_FAST=1007;var h=16384+E;x.LAME_MAXMP3BUFFER=h;var $,z,L,q,C,Z=new c,he,O,b;this.enc=new k,this.setModules=function(S,P,Se,Ie,We,He,Ce,Ae,tt){$=S,z=P,L=Se,q=Ie,C=We,he=He,O=Ae,b=tt,this.enc.setModules(z,Z,q,he)};function j(){this.mask_adjust=0,this.mask_adjust_short=0,this.bo_l_weight=s(k.SBMAX_l),this.bo_s_weight=s(k.SBMAX_s)}function A(){this.lowerlimit=0}function G(S,P){this.lowpass=P}var F=4294479419;function Q(S){var P;return S.class_id=F,P=S.internal_flags=new l,S.mode=_.NOT_SET,S.original=1,S.in_samplerate=44100,S.num_channels=2,S.num_samples=-1,S.bWriteVbrTag=!0,S.quality=-1,S.short_blocks=null,P.subblock_gain=-1,S.lowpassfreq=0,S.highpassfreq=0,S.lowpasswidth=-1,S.highpasswidth=-1,S.VBR=r.vbr_off,S.VBR_q=4,S.ATHcurve=-1,S.VBR_mean_bitrate_kbps=128,S.VBR_min_bitrate_kbps=0,S.VBR_max_bitrate_kbps=0,S.VBR_hard_min=0,P.VBR_min_bitrate=1,P.VBR_max_bitrate=13,S.quant_comp=-1,S.quant_comp_short=-1,S.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,S.scale=-1,S.athaa_type=-1,S.ATHtype=-1,S.athaa_loudapprox=-1,S.athaa_sensitivity=0,S.useTemporal=null,S.interChRatio=-1,P.mf_samples_to_encode=k.ENCDELAY+k.POSTDELAY,S.encoder_padding=0,P.mf_size=k.ENCDELAY-k.MDCTDELAY,S.findReplayGain=!1,S.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,S.preset=0,S.write_id3tag_automatic=!0,0}this.lame_init=function(){var S=new d;return Q(S),S.lame_allocated_gfp=1,S};function B(S){return S>1?0:S<=0?1:Math.cos(Math.PI/2*S)}this.nearestBitrateFullIndex=function(S){var P=[8,16,24,32,40,48,56,64,80,96,112,128,160,192,224,256,320],Se=0,Ie=0,We=0,He=0;He=P[16],We=16,Ie=P[16],Se=16;for(var Ce=0;Ce<16;Ce++)if(Math.max(S,P[Ce+1])!=S){He=P[Ce+1],We=Ce+1,Ie=P[Ce],Se=Ce;break}return He-S>S-Ie?Se:We};function T(S,P){var Se=44100;return P>=48e3?Se=48e3:P>=44100?Se=44100:P>=32e3?Se=32e3:P>=24e3?Se=24e3:P>=22050?Se=22050:P>=16e3?Se=16e3:P>=12e3?Se=12e3:P>=11025?Se=11025:P>=8e3&&(Se=8e3),S==-1?Se:(S<=15960&&(Se=44100),S<=15250&&(Se=32e3),S<=11220&&(Se=24e3),S<=9970&&(Se=22050),S<=7230&&(Se=16e3),S<=5420&&(Se=12e3),S<=4510&&(Se=11025),S<=3970&&(Se=8e3),P<Se?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:Se)}function v(S,P){switch(S){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 w(S,P,Se){Se<16e3&&(P=2);for(var Ie=y.bitrate_table[P][1],We=2;We<=14;We++)y.bitrate_table[P][We]>0&&Math.abs(y.bitrate_table[P][We]-S)<Math.abs(Ie-S)&&(Ie=y.bitrate_table[P][We]);return Ie}function R(S,P,Se){Se<16e3&&(P=2);for(var Ie=0;Ie<=14;Ie++)if(y.bitrate_table[P][Ie]>0&&y.bitrate_table[P][Ie]==S)return Ie;return-1}function N(S,P){var Se=[new G(8,2e3),new G(16,3700),new G(24,3900),new G(32,5500),new G(40,7e3),new G(48,7500),new G(56,1e4),new G(64,11e3),new G(80,13500),new G(96,15100),new G(112,15600),new G(128,17e3),new G(160,17500),new G(192,18600),new G(224,19400),new G(256,19700),new G(320,20500)],Ie=g.nearestBitrateFullIndex(P);S.lowerlimit=Se[Ie].lowpass}function K(S){var P=S.internal_flags,Se=32,Ie=-1;if(P.lowpass1>0){for(var We=999,He=0;He<=31;He++){var Ce=He/31;Ce>=P.lowpass2&&(Se=Math.min(Se,He)),P.lowpass1<Ce&&Ce<P.lowpass2&&(We=Math.min(We,He))}We==999?P.lowpass1=(Se-.75)/31:P.lowpass1=(We-.75)/31,P.lowpass2=Se/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
|
|
125
|
+
`)),P.highpass2>0){for(var Ae=-1,He=0;He<=31;He++){var Ce=He/31;Ce<=P.highpass1&&(Ie=Math.max(Ie,He)),P.highpass1<Ce&&Ce<P.highpass2&&(Ae=Math.max(Ae,He))}P.highpass1=Ie/31,Ae==-1?P.highpass2=(Ie+.75)/31:P.highpass2=(Ae+.75)/31}for(var He=0;He<32;He++){var tt,De,Ce=He/31;P.highpass2>P.highpass1?tt=B((P.highpass2-Ce)/(P.highpass2-P.highpass1+1e-20)):tt=1,P.lowpass2>P.lowpass1?De=B((Ce-P.lowpass1)/(P.lowpass2-P.lowpass1+1e-20)):De=1,P.amp_filter[He]=tt*De}}function se(S){var P=S.internal_flags;switch(S.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:S.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 U(S){var P=S.internal_flags;S.frameNum=0,S.write_id3tag_automatic&&O.id3tag_write_v2(S),P.bitrate_stereoMode_Hist=o([16,5]),P.bitrate_blockType_Hist=o([16,6]),P.PeakSample=0,S.bWriteVbrTag&&he.InitVbrTag(S)}this.lame_init_params=function(S){var P=S.internal_flags;if(P.Class_ID=0,P.ATH==null&&(P.ATH=new u),P.PSY==null&&(P.PSY=new j),P.rgdata==null&&(P.rgdata=new f),P.channels_in=S.num_channels,P.channels_in==1&&(S.mode=_.MONO),P.channels_out=S.mode==_.MONO?1:2,P.mode_ext=k.MPG_MD_MS_LR,S.mode==_.MONO&&(S.force_ms=!1),S.VBR==r.vbr_off&&S.VBR_mean_bitrate_kbps!=128&&S.brate==0&&(S.brate=S.VBR_mean_bitrate_kbps),S.VBR==r.vbr_off||S.VBR==r.vbr_mtrh||S.VBR==r.vbr_mt||(S.free_format=!1),S.VBR==r.vbr_off&&S.brate==0&&m.EQ(S.compression_ratio,0)&&(S.compression_ratio=11.025),S.VBR==r.vbr_off&&S.compression_ratio>0&&(S.out_samplerate==0&&(S.out_samplerate=map2MP3Frequency(int(.97*S.in_samplerate))),S.brate=0|S.out_samplerate*16*P.channels_out/(1e3*S.compression_ratio),P.samplerate_index=v(S.out_samplerate,S),S.free_format||(S.brate=w(S.brate,S.version,S.out_samplerate))),S.out_samplerate!=0&&(S.out_samplerate<16e3?(S.VBR_mean_bitrate_kbps=Math.max(S.VBR_mean_bitrate_kbps,8),S.VBR_mean_bitrate_kbps=Math.min(S.VBR_mean_bitrate_kbps,64)):S.out_samplerate<32e3?(S.VBR_mean_bitrate_kbps=Math.max(S.VBR_mean_bitrate_kbps,8),S.VBR_mean_bitrate_kbps=Math.min(S.VBR_mean_bitrate_kbps,160)):(S.VBR_mean_bitrate_kbps=Math.max(S.VBR_mean_bitrate_kbps,32),S.VBR_mean_bitrate_kbps=Math.min(S.VBR_mean_bitrate_kbps,320))),S.lowpassfreq==0){var Se=16e3;switch(S.VBR){case r.vbr_off:{var Ie=new A;N(Ie,S.brate),Se=Ie.lowerlimit;break}case r.vbr_abr:{var Ie=new A;N(Ie,S.VBR_mean_bitrate_kbps),Se=Ie.lowerlimit;break}case r.vbr_rh:{var We=[19500,19e3,18600,18e3,17500,16e3,15600,14900,12500,1e4,3950];if(0<=S.VBR_q&&S.VBR_q<=9){var He=We[S.VBR_q],Ce=We[S.VBR_q+1],Ae=S.VBR_q_frac;Se=linear_int(He,Ce,Ae)}else Se=19500;break}default:{var We=[19500,19e3,18500,18e3,17500,16500,15500,14500,12500,9500,3950];if(0<=S.VBR_q&&S.VBR_q<=9){var He=We[S.VBR_q],Ce=We[S.VBR_q+1],Ae=S.VBR_q_frac;Se=linear_int(He,Ce,Ae)}else Se=19500}}S.mode==_.MONO&&(S.VBR==r.vbr_off||S.VBR==r.vbr_abr)&&(Se*=1.5),S.lowpassfreq=Se|0}if(S.out_samplerate==0&&(2*S.lowpassfreq>S.in_samplerate&&(S.lowpassfreq=S.in_samplerate/2),S.out_samplerate=T(S.lowpassfreq|0,S.in_samplerate)),S.lowpassfreq=Math.min(20500,S.lowpassfreq),S.lowpassfreq=Math.min(S.out_samplerate/2,S.lowpassfreq),S.VBR==r.vbr_off&&(S.compression_ratio=S.out_samplerate*16*P.channels_out/(1e3*S.brate)),S.VBR==r.vbr_abr&&(S.compression_ratio=S.out_samplerate*16*P.channels_out/(1e3*S.VBR_mean_bitrate_kbps)),S.bWriteVbrTag||(S.findReplayGain=!1,S.decode_on_the_fly=!1,P.findPeakSample=!1),P.findReplayGain=S.findReplayGain,P.decode_on_the_fly=S.decode_on_the_fly,P.decode_on_the_fly&&(P.findPeakSample=!0),P.findReplayGain&&$.InitGainAnalysis(P.rgdata,S.out_samplerate)==GainAnalysis.INIT_GAIN_ANALYSIS_ERROR)return S.internal_flags=null,-6;switch(P.decode_on_the_fly&&!S.decode_only&&(P.hip!=null&&b.hip_decode_exit(P.hip),P.hip=b.hip_decode_init()),P.mode_gr=S.out_samplerate<=24e3?1:2,S.framesize=576*P.mode_gr,S.encoder_delay=k.ENCDELAY,P.resample_ratio=S.in_samplerate/S.out_samplerate,S.VBR){case r.vbr_mt:case r.vbr_rh:case r.vbr_mtrh:{var tt=[5.7,6.5,7.3,8.2,10,11.9,13,14,15,16.5];S.compression_ratio=tt[S.VBR_q]}break;case r.vbr_abr:S.compression_ratio=S.out_samplerate*16*P.channels_out/(1e3*S.VBR_mean_bitrate_kbps);break;default:S.compression_ratio=S.out_samplerate*16*P.channels_out/(1e3*S.brate);break}if(S.mode==_.NOT_SET&&(S.mode=_.JOINT_STEREO),S.highpassfreq>0?(P.highpass1=2*S.highpassfreq,S.highpasswidth>=0?P.highpass2=2*(S.highpassfreq+S.highpasswidth):P.highpass2=1*2*S.highpassfreq,P.highpass1/=S.out_samplerate,P.highpass2/=S.out_samplerate):(P.highpass1=0,P.highpass2=0),S.lowpassfreq>0?(P.lowpass2=2*S.lowpassfreq,S.lowpasswidth>=0?(P.lowpass1=2*(S.lowpassfreq-S.lowpasswidth),P.lowpass1<0&&(P.lowpass1=0)):P.lowpass1=1*2*S.lowpassfreq,P.lowpass1/=S.out_samplerate,P.lowpass2/=S.out_samplerate):(P.lowpass1=0,P.lowpass2=0),K(S),P.samplerate_index=v(S.out_samplerate,S),P.samplerate_index<0)return S.internal_flags=null,-1;if(S.VBR==r.vbr_off){if(S.free_format)P.bitrate_index=0;else if(S.brate=w(S.brate,S.version,S.out_samplerate),P.bitrate_index=R(S.brate,S.version,S.out_samplerate),P.bitrate_index<=0)return S.internal_flags=null,-1}else P.bitrate_index=1;S.analysis&&(S.bWriteVbrTag=!1),P.pinfo!=null&&(S.bWriteVbrTag=!1),z.init_bit_stream_w(P);for(var De=P.samplerate_index+3*S.version+6*(S.out_samplerate<16e3?1:0),we=0;we<k.SBMAX_l+1;we++)P.scalefac_band.l[we]=q.sfBandIndex[De].l[we];for(var we=0;we<k.PSFB21+1;we++){var xt=(P.scalefac_band.l[22]-P.scalefac_band.l[21])/k.PSFB21,Jt=P.scalefac_band.l[21]+we*xt;P.scalefac_band.psfb21[we]=Jt}P.scalefac_band.psfb21[k.PSFB21]=576;for(var we=0;we<k.SBMAX_s+1;we++)P.scalefac_band.s[we]=q.sfBandIndex[De].s[we];for(var we=0;we<k.PSFB12+1;we++){var xt=(P.scalefac_band.s[13]-P.scalefac_band.s[12])/k.PSFB12,Jt=P.scalefac_band.s[12]+we*xt;P.scalefac_band.psfb12[we]=Jt}P.scalefac_band.psfb12[k.PSFB12]=192,S.version==1?P.sideinfo_len=P.channels_out==1?21:36:P.sideinfo_len=P.channels_out==1?13:21,S.error_protection&&(P.sideinfo_len+=2),U(S),P.Class_ID=F;{var gt;for(gt=0;gt<19;gt++)P.nsPsy.pefirbuf[gt]=700*P.mode_gr*P.channels_out;S.ATHtype==-1&&(S.ATHtype=4)}switch(a(S.VBR_q<=9),a(S.VBR_q>=0),S.VBR){case r.vbr_mt:S.VBR=r.vbr_mtrh;case r.vbr_mtrh:{S.useTemporal==null&&(S.useTemporal=!1),L.apply_preset(S,500-S.VBR_q*10,0),S.quality<0&&(S.quality=LAME_DEFAULT_QUALITY),S.quality<5&&(S.quality=0),S.quality>5&&(S.quality=5),P.PSY.mask_adjust=S.maskingadjust,P.PSY.mask_adjust_short=S.maskingadjust_short,S.experimentalY?P.sfb21_extra=!1:P.sfb21_extra=S.out_samplerate>44e3,P.iteration_loop=new VBRNewIterationLoop(C);break}case r.vbr_rh:{L.apply_preset(S,500-S.VBR_q*10,0),P.PSY.mask_adjust=S.maskingadjust,P.PSY.mask_adjust_short=S.maskingadjust_short,S.experimentalY?P.sfb21_extra=!1:P.sfb21_extra=S.out_samplerate>44e3,S.quality>6&&(S.quality=6),S.quality<0&&(S.quality=LAME_DEFAULT_QUALITY),P.iteration_loop=new VBROldIterationLoop(C);break}default:{var M;P.sfb21_extra=!1,S.quality<0&&(S.quality=LAME_DEFAULT_QUALITY),M=S.VBR,M==r.vbr_off&&(S.VBR_mean_bitrate_kbps=S.brate),L.apply_preset(S,S.VBR_mean_bitrate_kbps,0),S.VBR=M,P.PSY.mask_adjust=S.maskingadjust,P.PSY.mask_adjust_short=S.maskingadjust_short,M==r.vbr_off?P.iteration_loop=new p(C):P.iteration_loop=new ABRIterationLoop(C);break}}if(a(S.scale>=0),S.VBR!=r.vbr_off){if(P.VBR_min_bitrate=1,P.VBR_max_bitrate=14,S.out_samplerate<16e3&&(P.VBR_max_bitrate=8),S.VBR_min_bitrate_kbps!=0&&(S.VBR_min_bitrate_kbps=w(S.VBR_min_bitrate_kbps,S.version,S.out_samplerate),P.VBR_min_bitrate=R(S.VBR_min_bitrate_kbps,S.version,S.out_samplerate),P.VBR_min_bitrate<0)||S.VBR_max_bitrate_kbps!=0&&(S.VBR_max_bitrate_kbps=w(S.VBR_max_bitrate_kbps,S.version,S.out_samplerate),P.VBR_max_bitrate=R(S.VBR_max_bitrate_kbps,S.version,S.out_samplerate),P.VBR_max_bitrate<0))return-1;S.VBR_min_bitrate_kbps=y.bitrate_table[S.version][P.VBR_min_bitrate],S.VBR_max_bitrate_kbps=y.bitrate_table[S.version][P.VBR_max_bitrate],S.VBR_mean_bitrate_kbps=Math.min(y.bitrate_table[S.version][P.VBR_max_bitrate],S.VBR_mean_bitrate_kbps),S.VBR_mean_bitrate_kbps=Math.max(y.bitrate_table[S.version][P.VBR_min_bitrate],S.VBR_mean_bitrate_kbps)}return S.tune&&(P.PSY.mask_adjust+=S.tune_value_a,P.PSY.mask_adjust_short+=S.tune_value_a),se(S),a(S.scale>=0),S.athaa_type<0?P.ATH.useAdjust=3:P.ATH.useAdjust=S.athaa_type,P.ATH.aaSensitivityP=Math.pow(10,S.athaa_sensitivity/-10),S.short_blocks==null&&(S.short_blocks=n.short_block_allowed),S.short_blocks==n.short_block_allowed&&(S.mode==_.JOINT_STEREO||S.mode==_.STEREO)&&(S.short_blocks=n.short_block_coupled),S.quant_comp<0&&(S.quant_comp=1),S.quant_comp_short<0&&(S.quant_comp_short=0),S.msfix<0&&(S.msfix=0),S.exp_nspsytune=S.exp_nspsytune|1,S.internal_flags.nsPsy.attackthre<0&&(S.internal_flags.nsPsy.attackthre=c.NSATTACKTHRE),S.internal_flags.nsPsy.attackthre_s<0&&(S.internal_flags.nsPsy.attackthre_s=c.NSATTACKTHRE_S),a(S.scale>=0),S.scale<0&&(S.scale=1),S.ATHtype<0&&(S.ATHtype=4),S.ATHcurve<0&&(S.ATHcurve=4),S.athaa_loudapprox<0&&(S.athaa_loudapprox=2),S.interChRatio<0&&(S.interChRatio=0),S.useTemporal==null&&(S.useTemporal=!0),P.slot_lag=P.frac_SpF=0,S.VBR==r.vbr_off&&(P.slot_lag=P.frac_SpF=(S.version+1)*72e3*S.brate%S.out_samplerate|0),q.iteration_init(S),Z.psymodel_init(S),a(S.scale>=0),0};function ee(S,P){(S.in_buffer_0==null||S.in_buffer_nsamples<P)&&(S.in_buffer_0=s(P),S.in_buffer_1=s(P),S.in_buffer_nsamples=P)}this.lame_encode_flush=function(S,P,Se,Ie){var We=S.internal_flags,He=i([2,1152]),Ce=0,Ae,tt,De,we,xt=We.mf_samples_to_encode-k.POSTDELAY,Jt=de(S);if(We.mf_samples_to_encode<1)return 0;for(Ae=0,S.in_samplerate!=S.out_samplerate&&(xt+=16*S.out_samplerate/S.in_samplerate),De=S.framesize-xt%S.framesize,De<576&&(De+=S.framesize),S.encoder_padding=De,we=(xt+De)/S.framesize;we>0&&Ce>=0;){var gt=Jt-We.mf_size,M=S.frameNum;gt*=S.in_samplerate,gt/=S.out_samplerate,gt>1152&&(gt=1152),gt<1&&(gt=1),tt=Ie-Ae,Ie==0&&(tt=0),Ce=this.lame_encode_buffer(S,He[0],He[1],gt,P,Se,tt),Se+=Ce,Ae+=Ce,we-=M!=S.frameNum?1:0}if(We.mf_samples_to_encode=0,Ce<0||(tt=Ie-Ae,Ie==0&&(tt=0),z.flush_bitstream(S),Ce=z.copy_buffer(We,P,Se,tt,1),Ce<0))return Ce;if(Se+=Ce,Ae+=Ce,tt=Ie-Ae,Ie==0&&(tt=0),S.write_id3tag_automatic){if(O.id3tag_write_v1(S),Ce=z.copy_buffer(We,P,Se,tt,0),Ce<0)return Ce;Ae+=Ce}return Ae},this.lame_encode_buffer=function(S,P,Se,Ie,We,He,Ce){var Ae=S.internal_flags,tt=[null,null];if(Ae.Class_ID!=F)return-3;if(Ie==0)return 0;ee(Ae,Ie),tt[0]=Ae.in_buffer_0,tt[1]=Ae.in_buffer_1;for(var De=0;De<Ie;De++)tt[0][De]=P[De],Ae.channels_in>1&&(tt[1][De]=Se[De]);return _e(S,tt[0],tt[1],Ie,We,He,Ce)};function de(S){var P=k.BLKSIZE+S.framesize-k.FFTOFFSET;return P=Math.max(P,512+S.framesize-32),P}function _e(S,P,Se,Ie,We,He,Ce){var Ae=S.internal_flags,tt=0,De,we,xt,Jt,gt,M=[null,null],I=[null,null];if(Ae.Class_ID!=F)return-3;if(Ie==0)return 0;if(gt=z.copy_buffer(Ae,We,He,Ce,0),gt<0)return gt;if(He+=gt,tt+=gt,I[0]=P,I[1]=Se,m.NEQ(S.scale,0)&&m.NEQ(S.scale,1))for(we=0;we<Ie;++we)I[0][we]*=S.scale,Ae.channels_out==2&&(I[1][we]*=S.scale);if(m.NEQ(S.scale_left,0)&&m.NEQ(S.scale_left,1))for(we=0;we<Ie;++we)I[0][we]*=S.scale_left;if(m.NEQ(S.scale_right,0)&&m.NEQ(S.scale_right,1))for(we=0;we<Ie;++we)I[1][we]*=S.scale_right;if(S.num_channels==2&&Ae.channels_out==1)for(we=0;we<Ie;++we)I[0][we]=.5*(I[0][we]+I[1][we]),I[1][we]=0;Jt=de(S),M[0]=Ae.mfbuf[0],M[1]=Ae.mfbuf[1];for(var V=0;Ie>0;){var H=[null,null],J=0,D=0;H[0]=I[0],H[1]=I[1];var Y=new Pe;if(Kr(S,M,H,V,Ie,Y),J=Y.n_in,D=Y.n_out,Ae.findReplayGain&&!Ae.decode_on_the_fly&&$.AnalyzeSamples(Ae.rgdata,M[0],Ae.mf_size,M[1],Ae.mf_size,D,Ae.channels_out)==GainAnalysis.GAIN_ANALYSIS_ERROR)return-6;if(Ie-=J,V+=J,Ae.channels_out==2,Ae.mf_size+=D,a(Ae.mf_size<=l.MFSIZE),Ae.mf_samples_to_encode<1&&(Ae.mf_samples_to_encode=k.ENCDELAY+k.POSTDELAY),Ae.mf_samples_to_encode+=D,Ae.mf_size>=Jt){var te=Ce-tt;if(Ce==0&&(te=0),De=ke(S,M[0],M[1],We,He,te),De<0)return De;for(He+=De,tt+=De,Ae.mf_size-=S.framesize,Ae.mf_samples_to_encode-=S.framesize,xt=0;xt<Ae.channels_out;xt++)for(we=0;we<Ae.mf_size;we++)M[xt][we]=M[xt][we+S.framesize]}}return tt}function ke(S,P,Se,Ie,We,He){var Ce=g.enc.lame_encode_mp3_frame(S,P,Se,Ie,We,He);return S.frameNum++,Ce}function Pe(){this.n_in=0,this.n_out=0}function Te(){this.num_used=0}function $e(S,P){return P!=0?$e(P,S%P):S}function je(S,P,Se){var Ie=Math.PI*P;S/=Se,S<0&&(S=0),S>1&&(S=1);var We=S-.5,He=.42-.5*Math.cos(2*S*Math.PI)+.08*Math.cos(4*S*Math.PI);return Math.abs(We)<1e-9?Ie/Math.PI:He*Math.sin(Se*Ie*We)/(Math.PI*Se*We)}function Tt(S,P,Se,Ie,We,He,Ce,Ae,tt){var De=S.internal_flags,we,xt=0,Jt,gt=S.out_samplerate/$e(S.out_samplerate,S.in_samplerate);gt>l.BPC&&(gt=l.BPC);var M=Math.abs(De.resample_ratio-Math.floor(.5+De.resample_ratio))<1e-4?1:0,I=1/De.resample_ratio;I>1&&(I=1);var V=31;V%2==0&&--V,V+=M;var H=V+1;if(De.fill_buffer_resample_init==0){for(De.inbuf_old[0]=s(H),De.inbuf_old[1]=s(H),we=0;we<=2*gt;++we)De.blackfilt[we]=s(H);for(De.itime[0]=0,De.itime[1]=0,xt=0;xt<=2*gt;xt++){var J=0,D=(xt-gt)/(2*gt);for(we=0;we<=V;we++)J+=De.blackfilt[xt][we]=je(we-D,I,V);for(we=0;we<=V;we++)De.blackfilt[xt][we]/=J}De.fill_buffer_resample_init=1}var Y=De.inbuf_old[tt];for(Jt=0;Jt<Ie;Jt++){var te,X;if(te=Jt*De.resample_ratio,xt=0|Math.floor(te-De.itime[tt]),V+xt-V/2>=Ce)break;var D=te-De.itime[tt]-(xt+.5*(V%2));X=0|Math.floor(D*2*gt+gt+.5);var oe=0;for(we=0;we<=V;++we){var re=0|we+xt-V/2,ie;ie=re<0?Y[H+re]:We[He+re],oe+=ie*De.blackfilt[X][we]}P[Se+Jt]=oe}if(Ae.num_used=Math.min(Ce,V+xt-V/2),De.itime[tt]+=Ae.num_used-Jt*De.resample_ratio,Ae.num_used>=H)for(we=0;we<H;we++)Y[we]=We[He+Ae.num_used+we-H];else{var ve=H-Ae.num_used;for(we=0;we<ve;++we)Y[we]=Y[we+Ae.num_used];for(xt=0;we<H;++we,++xt)Y[we]=We[He+xt];a(xt==Ae.num_used)}return Jt}function Kr(S,P,Se,Ie,We,He){var Ce=S.internal_flags;if(Ce.resample_ratio<.9999||Ce.resample_ratio>1.0001)for(var Ae=0;Ae<Ce.channels_out;Ae++){var tt=new Te;He.n_out=Tt(S,P[Ae],Ce.mf_size,S.framesize,Se[Ae],Ie,We,tt,Ae),He.n_in=tt.num_used}else{He.n_out=Math.min(S.framesize,We),He.n_in=He.n_out;for(var De=0;De<He.n_out;++De)P[0][Ce.mf_size+De]=Se[0][Ie+De],Ce.channels_out==2&&(P[1][Ce.mf_size+De]=Se[1][Ie+De])}}}return O1=x,O1}var qA=qt,Vn=qA.VbrMode;function FA(){var t=q1();function e(l,u,f,p,m,y,k,x,_,g,E,h,$,z,L){this.vbr_q=l,this.quant_comp=u,this.quant_comp_s=f,this.expY=p,this.st_lrm=m,this.st_s=y,this.masking_adj=k,this.masking_adj_short=x,this.ath_lower=_,this.ath_curve=g,this.ath_sensitivity=E,this.interch=h,this.safejoint=$,this.sfb21mod=z,this.msfix=L}function r(l,u,f,p,m,y,k,x,_,g,E,h,$,z){this.quant_comp=u,this.quant_comp_s=f,this.safejoint=p,this.nsmsfix=m,this.st_lrm=y,this.st_s=k,this.nsbass=x,this.scale=_,this.masking_adj=g,this.ath_lower=E,this.ath_curve=h,this.interch=$,this.sfscale=z}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,f){var p=l.VBR==Vn.vbr_rh?s:o,m=l.VBR_q_frac,y=p[u],k=p[u+1],x=y;y.st_lrm=y.st_lrm+m*(k.st_lrm-y.st_lrm),y.st_s=y.st_s+m*(k.st_s-y.st_s),y.masking_adj=y.masking_adj+m*(k.masking_adj-y.masking_adj),y.masking_adj_short=y.masking_adj_short+m*(k.masking_adj_short-y.masking_adj_short),y.ath_lower=y.ath_lower+m*(k.ath_lower-y.ath_lower),y.ath_curve=y.ath_curve+m*(k.ath_curve-y.ath_curve),y.ath_sensitivity=y.ath_sensitivity+m*(k.ath_sensitivity-y.ath_sensitivity),y.interch=y.interch+m*(k.interch-y.interch),y.msfix=y.msfix+m*(k.msfix-y.msfix),d(l,x.vbr_q),f!=0?l.quant_comp=x.quant_comp:Math.abs(l.quant_comp- -1)>0||(l.quant_comp=x.quant_comp),f!=0?l.quant_comp_short=x.quant_comp_s:Math.abs(l.quant_comp_short- -1)>0||(l.quant_comp_short=x.quant_comp_s),x.expY!=0&&(l.experimentalY=x.expY!=0),f!=0?l.internal_flags.nsPsy.attackthre=x.st_lrm:Math.abs(l.internal_flags.nsPsy.attackthre- -1)>0||(l.internal_flags.nsPsy.attackthre=x.st_lrm),f!=0?l.internal_flags.nsPsy.attackthre_s=x.st_s:Math.abs(l.internal_flags.nsPsy.attackthre_s- -1)>0||(l.internal_flags.nsPsy.attackthre_s=x.st_s),f!=0?l.maskingadjust=x.masking_adj:Math.abs(l.maskingadjust-0)>0||(l.maskingadjust=x.masking_adj),f!=0?l.maskingadjust_short=x.masking_adj_short:Math.abs(l.maskingadjust_short-0)>0||(l.maskingadjust_short=x.masking_adj_short),f!=0?l.ATHlower=-x.ath_lower/10:Math.abs(-l.ATHlower*10-0)>0||(l.ATHlower=-x.ath_lower/10),f!=0?l.ATHcurve=x.ath_curve:Math.abs(l.ATHcurve- -1)>0||(l.ATHcurve=x.ath_curve),f!=0?l.athaa_sensitivity=x.ath_sensitivity:Math.abs(l.athaa_sensitivity- -1)>0||(l.athaa_sensitivity=x.ath_sensitivity),x.interch>0&&(f!=0?l.interChRatio=x.interch:Math.abs(l.interChRatio- -1)>0||(l.interChRatio=x.interch)),x.safejoint>0&&(l.exp_nspsytune=l.exp_nspsytune|x.safejoint),x.sfb21mod>0&&(l.exp_nspsytune=l.exp_nspsytune|x.sfb21mod<<20),f!=0?l.msfix=x.msfix:Math.abs(l.msfix- -1)>0||(l.msfix=x.msfix),f==0&&(l.VBR_q=u,l.VBR_q_frac=m)}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,f){var p=u,m=n.nearestBitrateFullIndex(u);if(l.VBR=Vn.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[m].safejoint>0&&(l.exp_nspsytune=l.exp_nspsytune|2),a[m].sfscale>0&&(l.internal_flags.noise_shaping=2),Math.abs(a[m].nsbass)>0){var y=int(a[m].nsbass*4);y<0&&(y+=64),l.exp_nspsytune=l.exp_nspsytune|y<<2}return f!=0?l.quant_comp=a[m].quant_comp:Math.abs(l.quant_comp- -1)>0||(l.quant_comp=a[m].quant_comp),f!=0?l.quant_comp_short=a[m].quant_comp_s:Math.abs(l.quant_comp_short- -1)>0||(l.quant_comp_short=a[m].quant_comp_s),f!=0?l.msfix=a[m].nsmsfix:Math.abs(l.msfix- -1)>0||(l.msfix=a[m].nsmsfix),f!=0?l.internal_flags.nsPsy.attackthre=a[m].st_lrm:Math.abs(l.internal_flags.nsPsy.attackthre- -1)>0||(l.internal_flags.nsPsy.attackthre=a[m].st_lrm),f!=0?l.internal_flags.nsPsy.attackthre_s=a[m].st_s:Math.abs(l.internal_flags.nsPsy.attackthre_s- -1)>0||(l.internal_flags.nsPsy.attackthre_s=a[m].st_s),f!=0?l.scale=a[m].scale:Math.abs(l.scale- -1)>0||(l.scale=a[m].scale),f!=0?l.maskingadjust=a[m].masking_adj:Math.abs(l.maskingadjust-0)>0||(l.maskingadjust=a[m].masking_adj),a[m].masking_adj>0?f!=0?l.maskingadjust_short=a[m].masking_adj*.9:Math.abs(l.maskingadjust_short-0)>0||(l.maskingadjust_short=a[m].masking_adj*.9):f!=0?l.maskingadjust_short=a[m].masking_adj*1.1:Math.abs(l.maskingadjust_short-0)>0||(l.maskingadjust_short=a[m].masking_adj*1.1),f!=0?l.ATHlower=-a[m].ath_lower/10:Math.abs(-l.ATHlower*10-0)>0||(l.ATHlower=-a[m].ath_lower/10),f!=0?l.ATHcurve=a[m].ath_curve:Math.abs(l.ATHcurve- -1)>0||(l.ATHcurve=a[m].ath_curve),f!=0?l.interChRatio=a[m].interch:Math.abs(l.interChRatio- -1)>0||(l.interChRatio=a[m].interch),u}this.apply_preset=function(l,u,f){switch(u){case t.R3MIX:{u=t.V3,l.VBR=Vn.vbr_mtrh;break}case t.MEDIUM:{u=t.V4,l.VBR=Vn.vbr_rh;break}case t.MEDIUM_FAST:{u=t.V4,l.VBR=Vn.vbr_mtrh;break}case t.STANDARD:{u=t.V2,l.VBR=Vn.vbr_rh;break}case t.STANDARD_FAST:{u=t.V2,l.VBR=Vn.vbr_mtrh;break}case t.EXTREME:{u=t.V0,l.VBR=Vn.vbr_rh;break}case t.EXTREME_FAST:{u=t.V0,l.VBR=Vn.vbr_mtrh;break}case t.INSANE:return u=320,l.preset=u,c(l,u,f),l.VBR=Vn.vbr_off,u}switch(l.preset=u,u){case t.V9:return i(l,9,f),u;case t.V8:return i(l,8,f),u;case t.V7:return i(l,7,f),u;case t.V6:return i(l,6,f),u;case t.V5:return i(l,5,f),u;case t.V4:return i(l,4,f),u;case t.V3:return i(l,3,f),u;case t.V2:return i(l,2,f),u;case t.V1:return i(l,1,f),u;case t.V0:return i(l,0,f),u}return 8<=u&&u<=320?c(l,u,f):(l.preset=0,u)};function d(l,u){var f=0;return 0>u&&(f=-1,u=0),9<u&&(f=-1,u=9),l.VBR_q=u,l.VBR_q_frac=0,f}}var UA=FA;function HA(){this.setModules=function(t,e){}}var GA=HA;function WA(){this.over_noise=0,this.tot_noise=0,this.max_noise=0,this.over_count=0,this.over_SSD=0,this.bits=0}var YA=WA,u4=qt,N3=u4.new_float,XA=u4.new_int;function KA(){this.global_gain=0,this.sfb_count1=0,this.step=XA(39),this.noise=N3(39),this.noise_log=N3(39)}var JA=KA,Ri=qt,Ts=Ri.System,C3=Ri.VbrMode,N1=Ri.Util,Ei=Ri.Arrays,Xa=Ri.new_float,Ka=Ri.assert,QA=GA,C1=YA,eO=JA,vt=br(),j3=D1,D3=$u;function tO(){var t;this.rv=null;var e;this.qupvt=null;var r,n=new QA,s;this.setModules=function(x,_,g,E){t=x,e=_,this.rv=_,r=g,this.qupvt=g,s=E,n.setModules(r,s)},this.ms_convert=function(x,_){for(var g=0;g<576;++g){var E=x.tt[_][0].xr[g],h=x.tt[_][1].xr[g];x.tt[_][0].xr[g]=(E+h)*(N1.SQRT2*.5),x.tt[_][1].xr[g]=(E-h)*(N1.SQRT2*.5)}};function o(x,_,g,E){E=0;for(var h=0;h<=g;++h){var $=Math.abs(x.xr[h]);E+=$,_[h]=Math.sqrt($*Math.sqrt($)),_[h]>x.xrpow_max&&(x.xrpow_max=_[h])}return E}this.init_xrpow=function(x,_,g){var E=0,h=0|_.max_nonzero_coeff;if(_.xrpow_max=0,Ei.fill(g,h,576,0),E=o(_,g,h,E),E>1e-20){var $=0;x.substep_shaping&2&&($=1);for(var z=0;z<_.psymax;z++)x.pseudohalf[z]=$;return!0}return Ei.fill(_.l3_enc,0,576,0),!1};function i(x,_){var g=x.ATH,E=_.xr;if(_.block_type!=vt.SHORT_TYPE)for(var h=!1,$=vt.PSFB21-1;$>=0&&!h;$--){var z=x.scalefac_band.psfb21[$],L=x.scalefac_band.psfb21[$+1],q=r.athAdjust(g.adjust,g.psfb21[$],g.floor);x.nsPsy.longfact[21]>1e-12&&(q*=x.nsPsy.longfact[21]);for(var C=L-1;C>=z;C--)if(Math.abs(E[C])<q)E[C]=0;else{h=!0;break}}else for(var Z=0;Z<3;Z++)for(var h=!1,$=vt.PSFB12-1;$>=0&&!h;$--){var z=x.scalefac_band.s[12]*3+(x.scalefac_band.s[13]-x.scalefac_band.s[12])*Z+(x.scalefac_band.psfb12[$]-x.scalefac_band.psfb12[0]),L=z+(x.scalefac_band.psfb12[$+1]-x.scalefac_band.psfb12[$]),he=r.athAdjust(g.adjust,g.psfb12[$],g.floor);x.nsPsy.shortfact[12]>1e-12&&(he*=x.nsPsy.shortfact[12]);for(var C=L-1;C>=z;C--)if(Math.abs(E[C])<he)E[C]=0;else{h=!0;break}}}this.init_outer_loop=function(x,_){_.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=vt.SBPSY_l,_.sfb_smin=vt.SBPSY_s,_.psy_lmax=x.sfb21_extra?vt.SBMAX_l:vt.SBPSY_l,_.psymax=_.psy_lmax,_.sfbmax=_.sfb_lmax,_.sfbdivide=11;for(var g=0;g<vt.SBMAX_l;g++)_.width[g]=x.scalefac_band.l[g+1]-x.scalefac_band.l[g],_.window[g]=3;if(_.block_type==vt.SHORT_TYPE){var E=Xa(576);_.sfb_smin=0,_.sfb_lmax=0,_.mixed_block_flag!=0&&(_.sfb_smin=3,_.sfb_lmax=x.mode_gr*2+4),_.psymax=_.sfb_lmax+3*((x.sfb21_extra?vt.SBMAX_s:vt.SBPSY_s)-_.sfb_smin),_.sfbmax=_.sfb_lmax+3*(vt.SBPSY_s-_.sfb_smin),_.sfbdivide=_.sfbmax-18,_.psy_lmax=_.sfb_lmax;var h=x.scalefac_band.l[_.sfb_lmax];Ts.arraycopy(_.xr,0,E,0,576);for(var g=_.sfb_smin;g<vt.SBMAX_s;g++)for(var $=x.scalefac_band.s[g],z=x.scalefac_band.s[g+1],L=0;L<3;L++)for(var q=$;q<z;q++)_.xr[h++]=E[3*q+L];for(var C=_.sfb_lmax,g=_.sfb_smin;g<vt.SBMAX_s;g++)_.width[C]=_.width[C+1]=_.width[C+2]=x.scalefac_band.s[g+1]-x.scalefac_band.s[g],_.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,Ei.fill(_.scalefac,0),i(x,_)};function a(x){this.ordinal=x}a.BINSEARCH_NONE=new a(0),a.BINSEARCH_UP=new a(1),a.BINSEARCH_DOWN=new a(2);function c(x,_,g,E,h){var $,z=x.CurrentStep[E],L=!1,q=x.OldValue[E],C=a.BINSEARCH_NONE;for(_.global_gain=q,g-=_.part2_length;;){var Z;if($=s.count_bits(x,h,_,null),z==1||$==g)break;$>g?(C==a.BINSEARCH_DOWN&&(L=!0),L&&(z/=2),C=a.BINSEARCH_UP,Z=z):(C==a.BINSEARCH_UP&&(L=!0),L&&(z/=2),C=a.BINSEARCH_DOWN,Z=-z),_.global_gain+=Z,_.global_gain<0&&(_.global_gain=0,L=!0),_.global_gain>255&&(_.global_gain=255,L=!0)}for(Ka(_.global_gain>=0),Ka(_.global_gain<256);$>g&&_.global_gain<255;)_.global_gain++,$=s.count_bits(x,h,_,null);return x.CurrentStep[E]=q-_.global_gain>=4?4:2,x.OldValue[E]=_.global_gain,_.part2_3_length=$,$}this.trancate_smallspectrums=function(x,_,g,E){var h=Xa(D3.SFBMAX);if(!(!(x.substep_shaping&4)&&_.block_type==vt.SHORT_TYPE||x.substep_shaping&128)){r.calc_noise(_,g,h,new C1,null);for(var z=0;z<576;z++){var $=0;_.l3_enc[z]!=0&&($=Math.abs(_.xr[z])),E[z]=$}var z=0,L=8;_.block_type==vt.SHORT_TYPE&&(L=6);do{var q,C,Z,he,O=_.width[L];if(z+=O,!(h[L]>=1)&&(Ei.sort(E,z-O,O),!BitStream.EQ(E[z-1],0))){q=(1-h[L])*g[L],C=0,he=0;do{var b;for(Z=1;he+Z<O&&!BitStream.NEQ(E[he+z-O],E[he+z+Z-O]);Z++);if(b=E[he+z-O]*E[he+z-O]*Z,q<b){he!=0&&(C=E[he+z-O-1]);break}q-=b,he+=Z}while(he<O);if(!BitStream.EQ(C,0))do Math.abs(_.xr[z-O])<=C&&(_.l3_enc[z-O]=0);while(--O>0)}}while(++L<_.psymax);_.part2_3_length=s.noquant_count_bits(x,_,null)}};function d(x){for(var _=0;_<x.sfbmax;_++)if(x.scalefac[_]+x.subblock_gain[x.window[_]]==0)return!1;return!0}function l(x){return N1.FAST_LOG10(.368+.632*x*x*x)}function u(x,_){for(var g=1e-37,E=0;E<_.psymax;E++)g+=l(x[E]);return Math.max(1e-20,g)}function f(x,_,g,E,h){var $;switch(x){default:case 9:{_.over_count>0?($=g.over_SSD<=_.over_SSD,g.over_SSD==_.over_SSD&&($=g.bits<_.bits)):$=g.max_noise<0&&g.max_noise*10+g.bits<=_.max_noise*10+_.bits;break}case 0:$=g.over_count<_.over_count||g.over_count==_.over_count&&g.over_noise<_.over_noise||g.over_count==_.over_count&&BitStream.EQ(g.over_noise,_.over_noise)&&g.tot_noise<_.tot_noise;break;case 8:g.max_noise=u(h,E);case 1:$=g.max_noise<_.max_noise;break;case 2:$=g.tot_noise<_.tot_noise;break;case 3:$=g.tot_noise<_.tot_noise&&g.max_noise<_.max_noise;break;case 4:$=g.max_noise<=0&&_.max_noise>.2||g.max_noise<=0&&_.max_noise<0&&_.max_noise>g.max_noise-.2&&g.tot_noise<_.tot_noise||g.max_noise<=0&&_.max_noise>0&&_.max_noise>g.max_noise-.2&&g.tot_noise<_.tot_noise+_.over_noise||g.max_noise>0&&_.max_noise>-.05&&_.max_noise>g.max_noise-.1&&g.tot_noise+g.over_noise<_.tot_noise+_.over_noise||g.max_noise>0&&_.max_noise>-.1&&_.max_noise>g.max_noise-.15&&g.tot_noise+g.over_noise+g.over_noise<_.tot_noise+_.over_noise+_.over_noise;break;case 5:$=g.over_noise<_.over_noise||BitStream.EQ(g.over_noise,_.over_noise)&&g.tot_noise<_.tot_noise;break;case 6:$=g.over_noise<_.over_noise||BitStream.EQ(g.over_noise,_.over_noise)&&(g.max_noise<_.max_noise||BitStream.EQ(g.max_noise,_.max_noise)&&g.tot_noise<=_.tot_noise);break;case 7:$=g.over_count<_.over_count||g.over_noise<_.over_noise;break}return _.over_count==0&&($=$&&g.bits<_.bits),$}function p(x,_,g,E,h){var $=x.internal_flags,z;_.scalefac_scale==0?z=1.2968395546510096:z=1.6817928305074292;for(var L=0,q=0;q<_.sfbmax;q++)L<g[q]&&(L=g[q]);var C=$.noise_shaping_amp;switch(C==3&&(h?C=2:C=1),C){case 2:break;case 1:L>1?L=Math.pow(L,.5):L*=.95;break;case 0:default:L>1?L=1:L*=.95;break}for(var Z=0,q=0;q<_.sfbmax;q++){var he=_.width[q],O;if(Z+=he,!(g[q]<L)){if($.substep_shaping&2&&($.pseudohalf[q]=$.pseudohalf[q]==0?1:0,$.pseudohalf[q]==0&&$.noise_shaping_amp==2))return;for(_.scalefac[q]++,O=-he;O<0;O++)E[Z+O]*=z,E[Z+O]>_.xrpow_max&&(_.xrpow_max=E[Z+O]);if($.noise_shaping_amp==2)return}}}function m(x,_){for(var g=1.2968395546510096,E=0,h=0;h<x.sfbmax;h++){var $=x.width[h],z=x.scalefac[h];if(x.preflag!=0&&(z+=r.pretab[h]),E+=$,z&1){z++;for(var L=-$;L<0;L++)_[E+L]*=g,_[E+L]>x.xrpow_max&&(x.xrpow_max=_[E+L])}x.scalefac[h]=z>>1}x.preflag=0,x.scalefac_scale=1}function y(x,_,g){var E,h=_.scalefac;for(E=0;E<_.sfb_lmax;E++)if(h[E]>=16)return!0;for(var $=0;$<3;$++){var z=0,L=0;for(E=_.sfb_lmax+$;E<_.sfbdivide;E+=3)z<h[E]&&(z=h[E]);for(;E<_.sfbmax;E+=3)L<h[E]&&(L=h[E]);if(!(z<16&&L<8)){if(_.subblock_gain[$]>=7)return!0;_.subblock_gain[$]++;var q=x.scalefac_band.l[_.sfb_lmax];for(E=_.sfb_lmax+$;E<_.sfbmax;E+=3){var C,Z=_.width[E],he=h[E];if(he=he-(4>>_.scalefac_scale),he>=0){h[E]=he,q+=Z*3;continue}h[E]=0;{var O=210+(he<<_.scalefac_scale+1);C=r.IPOW20(O)}q+=Z*($+1);for(var b=-Z;b<0;b++)g[q+b]*=C,g[q+b]>_.xrpow_max&&(_.xrpow_max=g[q+b]);q+=Z*(3-$-1)}{var C=r.IPOW20(202);q+=_.width[E]*($+1);for(var b=-_.width[E];b<0;b++)g[q+b]*=C,g[q+b]>_.xrpow_max&&(_.xrpow_max=g[q+b])}}}return!1}function k(x,_,g,E,h){var $=x.internal_flags;p(x,_,g,E,h);var z=d(_);return z?!1:($.mode_gr==2?z=s.scale_bitcount(_):z=s.scale_bitcount_lsf($,_),z?($.noise_shaping>1&&(Ei.fill($.pseudohalf,0),_.scalefac_scale==0?(m(_,E),z=!1):_.block_type==vt.SHORT_TYPE&&$.subblock_gain>0&&(z=y($,_,E)||d(_))),z||($.mode_gr==2?z=s.scale_bitcount(_):z=s.scale_bitcount_lsf($,_)),!z):!0)}this.outer_loop=function(x,_,g,E,h,$){var z=x.internal_flags,L=new j3,q=Xa(576),C=Xa(D3.SFBMAX),Z=new C1,he,O=new eO,b=9999999,j=!1,A=!1,G=0;if(c(z,_,$,h,E),z.noise_shaping==0)return 100;r.calc_noise(_,g,C,Z,O),Z.bits=_.part2_3_length,L.assign(_);var F=0;for(Ts.arraycopy(E,0,q,0,576);!j;){do{var Q=new C1,B,T=255;if(z.substep_shaping&2?B=20:B=3,z.sfb21_extra&&(C[L.sfbmax]>1||L.block_type==vt.SHORT_TYPE&&(C[L.sfbmax+1]>1||C[L.sfbmax+2]>1))||!k(x,L,C,E,A))break;L.scalefac_scale!=0&&(T=254);var v=$-L.part2_length;if(v<=0)break;for(;(L.part2_3_length=s.count_bits(z,E,L,O))>v&&L.global_gain<=T;)L.global_gain++;if(L.global_gain>T)break;if(Z.over_count==0){for(;(L.part2_3_length=s.count_bits(z,E,L,O))>b&&L.global_gain<=T;)L.global_gain++;if(L.global_gain>T)break}if(r.calc_noise(L,g,C,Q,O),Q.bits=L.part2_3_length,_.block_type!=vt.SHORT_TYPE?he=x.quant_comp:he=x.quant_comp_short,he=f(he,Z,Q,L,C)?1:0,he!=0)b=_.part2_3_length,Z=Q,_.assign(L),F=0,Ts.arraycopy(E,0,q,0,576);else if(z.full_outer_loop==0&&(++F>B&&Z.over_count==0||z.noise_shaping_amp==3&&A&&F>30||z.noise_shaping_amp==3&&A&&L.global_gain-G>15))break}while(L.global_gain+L.scalefac_scale<255);z.noise_shaping_amp==3?A?j=!0:(L.assign(_),Ts.arraycopy(q,0,E,0,576),F=0,G=L.global_gain,A=!0):j=!0}return Ka(_.global_gain+_.scalefac_scale<=255),x.VBR==C3.vbr_rh||x.VBR==C3.vbr_mtrh?Ts.arraycopy(q,0,E,0,576):z.substep_shaping&1&&trancate_smallspectrums(z,_,g,E),Z.over_count},this.iteration_finish_one=function(x,_,g){var E=x.l3_side,h=E.tt[_][g];s.best_scalefac_store(x,_,g,E),x.use_best_huffman==1&&s.best_huffman_divide(x,h),e.ResvAdjust(x,h)},this.VBR_encode_granule=function(x,_,g,E,h,$,z){var L=x.internal_flags,q=new j3,C=Xa(576),Z=z,he=z+1,O=(z+$)/2,b,j,A=0,G=L.sfb21_extra;Ka(Z<=LameInternalFlags.MAX_BITS_PER_CHANNEL),Ei.fill(q.l3_enc,0);do O>Z-42?L.sfb21_extra=!1:L.sfb21_extra=G,j=outer_loop(x,_,g,E,h,O),j<=0?(A=1,he=_.part2_3_length,q.assign(_),Ts.arraycopy(E,0,C,0,576),z=he-32,b=z-$,O=(z+$)/2):($=O+32,b=z-$,O=(z+$)/2,A!=0&&(A=2,_.assign(q),Ts.arraycopy(C,0,E,0,576)));while(b>12);L.sfb21_extra=G,A==2&&Ts.arraycopy(q.l3_enc,0,_.l3_enc,0,576),Ka(_.part2_3_length<=Z)},this.get_framebits=function(x,_){var g=x.internal_flags;g.bitrate_index=g.VBR_min_bitrate;var E=t.getframebits(x);g.bitrate_index=1,E=t.getframebits(x);for(var h=1;h<=g.VBR_max_bitrate;h++){g.bitrate_index=h;var $=new MeanBits(E);_[h]=e.ResvFrameBegin(x,$),E=$.bits}},this.VBR_old_prepare=function(x,_,g,E,h,$,z,L,q){var C=x.internal_flags,Z,he=0,O=1,b=0;C.bitrate_index=C.VBR_max_bitrate;var j=e.ResvFrameBegin(x,new MeanBits(0))/C.mode_gr;get_framebits(x,$);for(var A=0;A<C.mode_gr;A++){var G=r.on_pe(x,_,L[A],j,A,0);C.mode_ext==vt.MPG_MD_MS_LR&&(ms_convert(C.l3_side,A),r.reduce_side(L[A],g[A],j,G));for(var F=0;F<C.channels_out;++F){var Q=C.l3_side.tt[A][F];Q.block_type!=vt.SHORT_TYPE?(he=1.28/(1+Math.exp(3.5-_[A][F]/300))-.05,Z=C.PSY.mask_adjust-he):(he=2.56/(1+Math.exp(3.5-_[A][F]/300))-.14,Z=C.PSY.mask_adjust_short-he),C.masking_lower=Math.pow(10,Z*.1),init_outer_loop(C,Q),q[A][F]=r.calc_xmin(x,E[A][F],Q,h[A][F]),q[A][F]!=0&&(O=0),z[A][F]=126,b+=L[A][F]}}for(var A=0;A<C.mode_gr;A++)for(var F=0;F<C.channels_out;F++)b>$[C.VBR_max_bitrate]&&(L[A][F]*=$[C.VBR_max_bitrate],L[A][F]/=b),z[A][F]>L[A][F]&&(z[A][F]=L[A][F]);return O},this.bitpressure_strategy=function(x,_,g,E){for(var h=0;h<x.mode_gr;h++)for(var $=0;$<x.channels_out;$++){for(var z=x.l3_side.tt[h][$],L=_[h][$],q=0,C=0;C<z.psy_lmax;C++)L[q++]*=1+.029*C*C/vt.SBMAX_l/vt.SBMAX_l;if(z.block_type==vt.SHORT_TYPE)for(var C=z.sfb_smin;C<vt.SBMAX_s;C++)L[q++]*=1+.029*C*C/vt.SBMAX_s/vt.SBMAX_s,L[q++]*=1+.029*C*C/vt.SBMAX_s/vt.SBMAX_s,L[q++]*=1+.029*C*C/vt.SBMAX_s/vt.SBMAX_s;E[h][$]=0|Math.max(g[h][$],.9*E[h][$])}},this.VBR_new_prepare=function(x,_,g,E,h,$){var z=x.internal_flags,L=1,q=0,C=0,Z;if(x.free_format){z.bitrate_index=0;var he=new MeanBits(q);Z=e.ResvFrameBegin(x,he),q=he.bits,h[0]=Z}else{z.bitrate_index=z.VBR_max_bitrate;var he=new MeanBits(q);e.ResvFrameBegin(x,he),q=he.bits,get_framebits(x,h),Z=h[z.VBR_max_bitrate]}for(var O=0;O<z.mode_gr;O++){r.on_pe(x,_,$[O],q,O,0),z.mode_ext==vt.MPG_MD_MS_LR&&ms_convert(z.l3_side,O);for(var b=0;b<z.channels_out;++b){var j=z.l3_side.tt[O][b];z.masking_lower=Math.pow(10,z.PSY.mask_adjust*.1),init_outer_loop(z,j),r.calc_xmin(x,g[O][b],j,E[O][b])!=0&&(L=0),C+=$[O][b]}}for(var O=0;O<z.mode_gr;O++)for(var b=0;b<z.channels_out;b++)C>Z&&($[O][b]*=Z,$[O][b]/=C);return L},this.calc_target_bits=function(x,_,g,E,h,$){var z=x.internal_flags,L=z.l3_side,q,C,Z,he,O=0;z.bitrate_index=z.VBR_max_bitrate;var b=new MeanBits(O);for($[0]=e.ResvFrameBegin(x,b),O=b.bits,z.bitrate_index=1,O=t.getframebits(x)-z.sideinfo_len*8,h[0]=O/(z.mode_gr*z.channels_out),O=x.VBR_mean_bitrate_kbps*x.framesize*1e3,z.substep_shaping&1&&(O*=1.09),O/=x.out_samplerate,O-=z.sideinfo_len*8,O/=z.mode_gr*z.channels_out,q=.93+.07*(11-x.compression_ratio)/(11-5.5),q<.9&&(q=.9),q>1&&(q=1),C=0;C<z.mode_gr;C++){var j=0;for(Z=0;Z<z.channels_out;Z++){if(E[C][Z]=int(q*O),_[C][Z]>700){var A=int((_[C][Z]-700)/1.4),G=L.tt[C][Z];E[C][Z]=int(q*O),G.block_type==vt.SHORT_TYPE&&A<O/2&&(A=O/2),A>O*3/2?A=O*3/2:A<0&&(A=0),E[C][Z]+=A}E[C][Z]>LameInternalFlags.MAX_BITS_PER_CHANNEL&&(E[C][Z]=LameInternalFlags.MAX_BITS_PER_CHANNEL),j+=E[C][Z]}if(j>LameInternalFlags.MAX_BITS_PER_GRANULE)for(Z=0;Z<z.channels_out;++Z)E[C][Z]*=LameInternalFlags.MAX_BITS_PER_GRANULE,E[C][Z]/=j}if(z.mode_ext==vt.MPG_MD_MS_LR)for(C=0;C<z.mode_gr;C++)r.reduce_side(E[C],g[C],O*z.channels_out,LameInternalFlags.MAX_BITS_PER_GRANULE);for(he=0,C=0;C<z.mode_gr;C++)for(Z=0;Z<z.channels_out;Z++)E[C][Z]>LameInternalFlags.MAX_BITS_PER_CHANNEL&&(E[C][Z]=LameInternalFlags.MAX_BITS_PER_CHANNEL),he+=E[C][Z];if(he>$[0])for(C=0;C<z.mode_gr;C++)for(Z=0;Z<z.channels_out;Z++)E[C][Z]*=$[0],E[C][Z]/=he}}var rO=tO,nO=qt,L3=nO.assert;function sO(){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),L3(n.ResvMax%8==0),L3(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 oO=sO;function iO(){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 aO=iO,Pi=qt,cO=Pi.System,j1=Pi.VbrMode,Z3=Pi.ShortBlock,lO=Pi.Arrays,Su=Pi.new_byte,uO=Pi.assert;Ja.NUMTOCENTRIES=100;Ja.MAXFRAMESIZE=2880;function Ja(){var t,e,r;this.setModules=function(O,b,j){t=O,e=b,r=j};var n=1,s=2,o=4,i=8,a=Ja.NUMTOCENTRIES,c=Ja.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,f=64,p=32,m=null,y="Xing",k="Info",x=[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 _(O,b){if(O.nVbrNumFrames++,O.sum+=b,O.seen++,!(O.seen<O.want)&&(O.pos<O.size&&(O.bag[O.pos]=O.sum,O.pos++,O.seen=0),O.pos==O.size)){for(var j=1;j<O.size;j+=2)O.bag[j/2]=O.bag[j];O.want*=2,O.pos/=2}}function g(O,b){if(!(O.pos<=0))for(var j=1;j<a;++j){var A=j/a,G,F,Q=0|Math.floor(A*O.pos);Q>O.pos-1&&(Q=O.pos-1),G=O.bag[Q],F=O.sum;var B=0|256*G/F;B>255&&(B=255),b[j]=255&B}}this.addVbrFrame=function(O){var b=O.internal_flags,j=Tables.bitrate_table[O.version][b.bitrate_index];uO(b.VBR_seek_table.bag!=null),_(b.VBR_seek_table,j)};function E(O,b){var j=O[b+0]&255;return j<<=8,j|=O[b+1]&255,j<<=8,j|=O[b+2]&255,j<<=8,j|=O[b+3]&255,j}function h(O,b,j){O[b+0]=255&(j>>24&255),O[b+1]=255&(j>>16&255),O[b+2]=255&(j>>8&255),O[b+3]=255&(j&255)}function $(O,b,j){O[b+0]=255&(j>>8&255),O[b+1]=255&(j&255)}function z(O,b){return new String(O,b,y.length(),m).equals(y)||new String(O,b,k.length(),m).equals(k)}function L(O,b,j){return 255&(O<<b|j&~(-1<<b))}function q(O,b){var j=O.internal_flags;b[0]=L(b[0],8,255),b[1]=L(b[1],3,7),b[1]=L(b[1],1,O.out_samplerate<16e3?0:1),b[1]=L(b[1],1,O.version),b[1]=L(b[1],2,1),b[1]=L(b[1],1,O.error_protection?0:1),b[2]=L(b[2],4,j.bitrate_index),b[2]=L(b[2],2,j.samplerate_index),b[2]=L(b[2],1,0),b[2]=L(b[2],1,O.extension),b[3]=L(b[3],2,O.mode.ordinal()),b[3]=L(b[3],2,j.mode_ext),b[3]=L(b[3],1,O.copyright),b[3]=L(b[3],1,O.original),b[3]=L(b[3],2,O.emphasis),b[0]=255;var A=255&(b[1]&241),G;O.version==1?G=u:O.out_samplerate<16e3?G=p:G=f,O.VBR==j1.vbr_off&&(G=O.brate);var F;O.free_format?F=0:F=255&16*t.BitrateIndex(G,O.version,O.out_samplerate),O.version==1?(b[1]=255&(A|10),A=255&(b[2]&13),b[2]=255&(F|A)):(b[1]=255&(A|2),A=255&(b[2]&13),b[2]=255&(F|A))}this.getVbrTag=function(O){var b=new VBRTagData,j=0;b.flags=0;var A=O[j+1]>>3&1,G=O[j+2]>>2&3,F=O[j+3]>>6&3,Q=O[j+2]>>4&15;if(Q=Tables.bitrate_table[A][Q],O[j+1]>>4==14?b.samprate=Tables.samplerate_table[2][G]:b.samprate=Tables.samplerate_table[A][G],A!=0?F!=3?j+=36:j+=21:F!=3?j+=21:j+=13,!z(O,j))return null;j+=4,b.hId=A;var B=b.flags=E(O,j);if(j+=4,B&n&&(b.frames=E(O,j),j+=4),B&s&&(b.bytes=E(O,j),j+=4),B&o){if(b.toc!=null)for(var T=0;T<a;T++)b.toc[T]=O[j+T];j+=a}b.vbrScale=-1,B&i&&(b.vbrScale=E(O,j),j+=4),b.headersize=(A+1)*72e3*Q/b.samprate,j+=21;var v=O[j+0]<<4;v+=O[j+1]>>4;var w=(O[j+1]&15)<<8;return w+=O[j+2]&255,(v<0||v>3e3)&&(v=-1),(w<0||w>3e3)&&(w=-1),b.encDelay=v,b.encPadding=w,b},this.InitVbrTag=function(O){var b=O.internal_flags,j;O.version==1?j=u:O.out_samplerate<16e3?j=p:j=f,O.VBR==j1.vbr_off&&(j=O.brate);var A=(O.version+1)*72e3*j/O.out_samplerate,G=b.sideinfo_len+l;if(b.VBR_seek_table.TotalFrameSize=A,A<G||A>c){O.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 F=Su(c);q(O,F);for(var Q=b.VBR_seek_table.TotalFrameSize,B=0;B<Q;++B)e.add_dummy_byte(O,F[B]&255,1)};function C(O,b){var j=b^O;return b=b>>8^x[j&255],b}this.updateMusicCRC=function(O,b,j,A){for(var G=0;G<A;++G)O[0]=C(b[j+G],O[0])};function Z(O,b,j,A,G){var F=O.internal_flags,Q=0,B=O.encoder_delay,T=O.encoder_padding,v=100-10*O.VBR_q-O.quality,w=r.getLameVeryShortVersion(),R,N=0,K,se=[1,5,3,2,4,0,3],U=0|(O.lowpassfreq/100+.5>255?255:O.lowpassfreq/100+.5),ee=0,de=0,_e=0,ke=O.internal_flags.noise_shaping,Pe=0,Te=0,$e=0,je=0,Tt=0,Kr=(O.exp_nspsytune&1)!=0,S=(O.exp_nspsytune&2)!=0,P=!1,Se=!1,Ie=O.internal_flags.nogap_total,We=O.internal_flags.nogap_current,He=O.ATHtype,Ce=0,Ae;switch(O.VBR){case vbr_abr:Ae=O.VBR_mean_bitrate_kbps;break;case vbr_off:Ae=O.brate;break;default:Ae=O.VBR_min_bitrate_kbps}switch(O.VBR.ordinal()<se.length?R=se[O.VBR.ordinal()]:R=0,K=16*N+R,F.findReplayGain&&(F.RadioGain>510&&(F.RadioGain=510),F.RadioGain<-510&&(F.RadioGain=-510),de=8192,de|=3072,F.RadioGain>=0?de|=F.RadioGain:(de|=512,de|=-F.RadioGain)),F.findPeakSample&&(ee=Math.abs(0|F.PeakSample/32767*Math.pow(2,23)+.5)),Ie!=-1&&(We>0&&(Se=!0),We<Ie-1&&(P=!0)),Ce=He+((Kr?1:0)<<4)+((S?1:0)<<5)+((P?1:0)<<6)+((Se?1:0)<<7),v<0&&(v=0),O.mode){case MONO:Pe=0;break;case STEREO:Pe=1;break;case DUAL_CHANNEL:Pe=2;break;case JOINT_STEREO:O.force_ms?Pe=4:Pe=3;break;case NOT_SET:default:Pe=7;break}O.in_samplerate<=32e3?$e=0:O.in_samplerate==48e3?$e=2:O.in_samplerate>48e3?$e=3:$e=1,(O.short_blocks==Z3.short_block_forced||O.short_blocks==Z3.short_block_dispensed||O.lowpassfreq==-1&&O.highpassfreq==-1||O.scale_left<O.scale_right||O.scale_left>O.scale_right||O.disable_reservoir&&O.brate<320||O.noATH||O.ATHonly||He==0||O.in_samplerate<=32e3)&&(Te=1),je=ke+(Pe<<2)+(Te<<5)+($e<<6),Tt=F.nMusicCRC,h(j,A+Q,v),Q+=4;for(var tt=0;tt<9;tt++)j[A+Q+tt]=255&w.charAt(tt);Q+=9,j[A+Q]=255&K,Q++,j[A+Q]=255&U,Q++,h(j,A+Q,ee),Q+=4,$(j,A+Q,de),Q+=2,$(j,A+Q,_e),Q+=2,j[A+Q]=255&Ce,Q++,Ae>=255?j[A+Q]=255:j[A+Q]=255&Ae,Q++,j[A+Q]=255&B>>4,j[A+Q+1]=255&(B<<4)+(T>>8),j[A+Q+2]=255&T,Q+=3,j[A+Q]=255&je,Q++,j[A+Q++]=0,$(j,A+Q,O.preset),Q+=2,h(j,A+Q,b),Q+=4,$(j,A+Q,Tt),Q+=2;for(var De=0;De<Q;De++)G=C(j[A+De],G);return $(j,A+Q,G),Q+=2,Q}function he(O){O.seek(0);var b=Su(10);O.readFully(b);var j;return new String(b,"ISO-8859-1").startsWith("ID3")?j=0:j=((b[6]&127)<<21|(b[7]&127)<<14|(b[8]&127)<<7|b[9]&127)+b.length,j}this.getLameTagFrame=function(O,b){var j=O.internal_flags;if(!O.bWriteVbrTag||j.Class_ID!=Lame.LAME_ID||j.VBR_seek_table.pos<=0)return 0;if(b.length<j.VBR_seek_table.TotalFrameSize)return j.VBR_seek_table.TotalFrameSize;lO.fill(b,0,j.VBR_seek_table.TotalFrameSize,0),q(O,b);var A=Su(a);if(O.free_format)for(var G=1;G<a;++G)A[G]=255&255*G/100;else g(j.VBR_seek_table,A);var F=j.sideinfo_len;O.error_protection&&(F-=2),O.VBR==j1.vbr_off?(b[F++]=255&k.charAt(0),b[F++]=255&k.charAt(1),b[F++]=255&k.charAt(2),b[F++]=255&k.charAt(3)):(b[F++]=255&y.charAt(0),b[F++]=255&y.charAt(1),b[F++]=255&y.charAt(2),b[F++]=255&y.charAt(3)),h(b,F,n+s+o+i),F+=4,h(b,F,j.VBR_seek_table.nVbrNumFrames),F+=4;var Q=j.VBR_seek_table.nBytesWritten+j.VBR_seek_table.TotalFrameSize;h(b,F,0|Q),F+=4,cO.arraycopy(A,0,b,F,A.length),F+=A.length,O.error_protection&&e.CRC_writeheader(j,b);for(var B=0,G=0;G<F;G++)B=C(b[G],B);return F+=Z(O,Q,b,F,B),j.VBR_seek_table.TotalFrameSize},this.putVbrTag=function(O,b){var j=O.internal_flags;if(j.VBR_seek_table.pos<=0||(b.seek(b.length()),b.length()==0))return-1;var A=he(b);b.seek(A);var G=Su(c),F=getLameTagFrame(O,G);return F>G.length?-1:(F<1||b.write(G,0,F),0)}}var dO=Ja,d4=qt,B3=d4.new_byte,hO=d4.assert,fO=q1(),pO=UA,mO=o4,gO=c4(),_O=rO,bO=l4(),yO=oO,vO=ec,wO=V1();br();var xO=aO,SO=dO;function kO(){this.setModules=function(t,e){}}function $O(){this.setModules=function(t,e,r){}}function EO(){}function TO(){this.setModules=function(t,e){}}function RO(t,e,r){arguments.length!=3&&(console.error("WARN: Mp3Encoder(channels, samplerate, kbps) not specified"),t=1,e=44100,r=128);var n=new fO,s=new kO,o=new mO,i=new wO,a=new pO,c=new gO,d=new _O,l=new SO,u=new xO,f=new TO,p=new yO,m=new bO,y=new $O,k=new EO;n.setModules(o,i,a,c,d,l,u,f,k),i.setModules(o,k,u,l),f.setModules(i,u),a.setModules(n),d.setModules(i,p,c,m),c.setModules(m,p,n.enc.psy),p.setModules(i),m.setModules(c),l.setModules(n,i,u),s.setModules(y,k),y.setModules(u,f,a);var x=n.lame_init();x.num_channels=t,x.in_samplerate=e,x.brate=r,x.mode=vO.STEREO,x.quality=3,x.bWriteVbrTag=!1,x.disable_reservoir=!0,x.write_id3tag_automatic=!1,n.lame_init_params(x);var _=1152,g=0|1.25*_+7200,E=B3(g);this.encodeBuffer=function(h,$){t==1&&($=h),hO(h.length==$.length),h.length>_&&(_=h.length,g=0|1.25*_+7200,E=B3(g));var z=n.lame_encode_buffer(x,h,$,h.length,E,0,g);return new Int8Array(E.subarray(0,z))},this.flush=function(){var h=n.lame_encode_flush(x,E,0,g);return new Int8Array(E.subarray(0,h))}}function Pn(){this.dataOffset=0,this.dataLen=0,this.channels=0,this.sampleRate=0}function Tu(t){return t.charCodeAt(0)<<24|t.charCodeAt(1)<<16|t.charCodeAt(2)<<8|t.charCodeAt(3)}Pn.RIFF=Tu("RIFF");Pn.WAVE=Tu("WAVE");Pn.fmt_=Tu("fmt ");Pn.data=Tu("data");Pn.readHeader=function(t){var e=new Pn,r=t.getUint32(0,!1);if(Pn.RIFF==r&&(t.getUint32(4,!0),Pn.WAVE==t.getUint32(8,!1)&&Pn.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=Pn.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 h4=V3.Mp3Encoder=RO,IF=V3.WavHeader=Pn;var Ro=24e3;function F1(t){let e=Buffer.from(t);return new Int16Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/2))}function PO(t){let e=t.indexOf("data",0,"ascii"),r=e>=0?e+8:44;return F1(t.subarray(r))}var MO="Tone: friendly, clear, and natural \u2014 like a knowledgeable teacher explaining something they enjoy. Calm and encouraging, not theatrical.",IO="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 zO(t){return process.env.FLOWCAST_TTS_INSTRUCTIONS?process.env.FLOWCAST_TTS_INSTRUCTIONS:`${t&&t.trim()?`Tone & delivery for this walkthrough: ${t.trim()}`:MO}
|
|
126
|
+
|
|
127
|
+
${IO}`}var AO={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||yv(e.voiceName),input:t,response_format:"pcm",instructions:zO(e.voiceTone)})});if(!n.ok)throw new Error(`OpenAI TTS ${n.status}: ${(await n.text().catch(()=>"")).slice(0,200)}`);return F1(Buffer.from(await n.arrayBuffer()))}},OO={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 F1(Buffer.from(await n.arrayBuffer()))}},NO={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:Ro}})});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 PO(Buffer.from(s,"base64"))}},Ru={openai:AO,elevenlabs:OO,google:NO};function f4(){let t=(process.env.VOICE_MODEL||"openai").trim().toLowerCase(),e=Ru[t];if(!e)throw new Error(`Unknown VOICE_MODEL "${t}". Use one of: ${Object.keys(Ru).join(", ")}.`);return e}async function CO(t){let e=f4();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/Ro*1e3)+180)}return{clips:n,sayDurationsMs:s}}function p4(t,e,r){if(!e.length)return"";let n=Math.ceil(r/1e3*Ro)+Ro,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*Ro));s.set(a.subarray(0,Math.max(0,Math.min(a.length,n-c))),c)}),"data:audio/mpeg;base64,"+LO(s)}var jO=40,DO=Math.max(jO,Math.min(128,Number(process.env.FLOWCAST_TTS_BITRATE)||48));function LO(t){let e=new h4(1,Ro,DO),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 m4(t){let e=await CO(t);return{clips:e.clips,sayDurationsMs:e.sayDurationsMs,voice:"embedded"}}async function U1(t,e){let r=t.makeBeat??(u=>({say:u})),n=u3(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 m4(s),d=t.compile(s,{...a?{sayDurationsMs:a}:{},...o}),l=i?p4(d.captions??[],i,d.manifest.durationMs):"";return{html:m3(d,l),data:d,voice:c}}function g4(t){return t.trim().split(/\s+/).filter(Boolean).length}function Pu(t){return t.length>40?`${t.slice(0,40)}\u2026`:t}function _4(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 ZO(t,e){t.forEach((r,n)=>{r.say&&g4(r.say)>18&&e.push({severity:"warn",code:"SAY_TOO_LONG",step:n+1,field:"say",message:`Narration is ${g4(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 BO(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]||"",f=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.`}),f&&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.`}),f&&l)n[l]=a.code;else if(p&&l){let m=u;for(let y of a.edits){let k=_4(m,y.find);if(k.length===0){e.push({severity:"error",code:"ANCHOR_NOT_FOUND",step:d,field:"edits",message:`Step ${d}: edit \`find\` not found: ${JSON.stringify(Pu(y.find))}. It must match the file's current contents exactly.`});continue}let x=k[0];y.occurrence==null&&k.length>1?e.push({severity:"error",code:"ANCHOR_AMBIGUOUS",step:d,field:"edits",message:`Step ${d}: edit \`find\` ${JSON.stringify(Pu(y.find))} appears ${k.length} times \u2014 set \`occurrence\` (1-based).`}):y.occurrence!=null&&(y.occurrence<1||y.occurrence>k.length?e.push({severity:"error",code:"ANCHOR_AMBIGUOUS",step:d,field:"edits",message:`Step ${d}: edit \`occurrence\` ${y.occurrence} is out of range \u2014 \`find\` appears ${k.length} time(s).`}):x=k[y.occurrence-1]),m=m.slice(0,x)+y.replace+m.slice(x+y.find.length)}n[l]=m}if(l&&a.highlightCode!=null){let m=_4(n[l]??"",a.highlightCode);m.length===0?e.push({severity:"error",code:"HIGHLIGHT_NOT_FOUND",step:d,field:"highlightCode",message:`Step ${d}: \`highlightCode\` snippet not found: ${JSON.stringify(Pu(a.highlightCode))}.`}):m.length>1&&e.push({severity:"error",code:"HIGHLIGHT_AMBIGUOUS",step:d,field:"highlightCode",message:`Step ${d}: \`highlightCode\` snippet ${JSON.stringify(Pu(a.highlightCode))} appears ${m.length} times \u2014 extend it until unique.`,suggestion:"Add surrounding characters until the snippet is unique in the file."})}})}function Mu(t,e){let r=[];return t==="code"&&BO(e,r),ZO(e.steps,r),r.sort((n,s)=>n.step-s.step||(n.severity===s.severity?0:n.severity==="error"?-1:1))}function VO(t,e,r){return t.split(e).join(r)}function b4(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]=VO(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 qO}from"node:os";import{join as y4}from"node:path";import{readFileSync as FO,writeFileSync as UO,mkdirSync as HO,chmodSync as GO}from"node:fs";function v4(){return process.env.FLOWCAST_CONFIG_DIR||y4(qO(),".flowcast")}function tc(){return y4(v4(),"config.json")}function H1(){try{let t=JSON.parse(FO(tc(),"utf8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function w4(t){HO(v4(),{recursive:!0}),UO(tc(),JSON.stringify(t,null,2)+`
|
|
128
|
+
`);try{GO(tc(),384)}catch{}}function x4(){for(let[t,e]of Object.entries(H1()))typeof e=="string"&&process.env[t]===void 0&&(process.env[t]=e)}import{styleText as Q1}from"node:util";import{stdout as t0,stdin as L4}from"node:process";import*as Rs from"node:readline";import uN from"node:readline";var S4=(()=>{let t=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return e=>{let r=0;for(t.lastIndex=0;t.test(e);)r+=1;return e.length-r}})(),k4=t=>t===12288||t>=65281&&t<=65376||t>=65504&&t<=65510,$4=t=>t===8987||t===9001||t>=12272&&t<=12287||t>=12289&&t<=12350||t>=12441&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12783&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=65040&&t<=65049||t>=65072&&t<=65106||t>=65108&&t<=65126||t>=65128&&t<=65131||t>=127488&&t<=127490||t>=127504&&t<=127547||t>=127552&&t<=127560||t>=131072&&t<=196605||t>=196608&&t<=262141;var WO=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,YO=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,E4=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,XO=/\t{1,1000}/y,T4=new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*","yu"),KO=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,JO=new RegExp("\\p{M}+","gu"),QO={limit:1/0,ellipsis:""},R4=(t,e={},r={})=>{let n=e.limit??1/0,s=e.ellipsis??"",o=e?.ellipsisWidth??(s?R4(s,QO,r).width:0),i=0,a=r.controlWidth??0,c=r.tabWidth??8,d=r.emojiWidth??2,l=2,u=r.regularWidth??1,f=r.wideWidth??l,p=[[KO,u],[WO,i],[YO,a],[XO,c],[T4,d],[E4,f]],m=0,y=0,k=t.length,x=0,_=!1,g=k,E=Math.max(0,n-o),h=0,$=0,z=0,L=0;e:for(;;){if($>h||y>=k&&y>m){let q=t.slice(h,$)||t.slice(m,y);x=0;for(let C of q.replaceAll(JO,"")){let Z=C.codePointAt(0)||0;if(k4(Z)?L=l:$4(Z)?L=f:L=u,z+L>E&&(g=Math.min(g,Math.max(h,m)+x)),z+L>n){_=!0;break e}x+=C.length,z+=L}h=$=0}if(y>=k)break e;for(let q=0,C=p.length;q<C;q++){let[Z,he]=p[q];if(Z.lastIndex=y,Z.test(t)){if(x=Z===E4?S4(t.slice(y,Z.lastIndex)):Z===T4?1:Z.lastIndex-y,L=x*he,z+L>E&&(g=Math.min(g,y+Math.floor((E-z)/he))),z+L>n){_=!0;break e}z+=L,h=m,$=y,y=m=Z.lastIndex;continue e}}y+=1}return{width:_?E:z,index:_?g:k,truncated:_,ellipsed:_&&n>=o}},P4=R4;var eN={limit:1/0,ellipsis:"",ellipsisWidth:0},tN=(t,e={})=>P4(t,eN,e).width,$r=tN;var Iu="\x1B",O4="\x9B",rN=39,W1="\x07",N4="[",nN="]",C4="m",Y1=`${nN}8;;`,M4=new RegExp(`(?:\\${N4}(?<code>\\d+)m|\\${Y1}(?<uri>.*)${W1})`,"y"),I4=t=>{if(t>=30&&t<=37||t>=90&&t<=97)return 39;if(t>=40&&t<=47||t>=100&&t<=107)return 49;if(t===1||t===2)return 22;if(t===3)return 23;if(t===4)return 24;if(t===7)return 27;if(t===8)return 28;if(t===9)return 29;if(t===0)return 0},z4=t=>`${Iu}${N4}${t}${C4}`,A4=t=>`${Iu}${Y1}${t}${W1}`,G1=(t,e,r)=>{let n=e[Symbol.iterator](),s=!1,o=!1,i=t.at(-1),a=i===void 0?0:$r(i),c=n.next(),d=n.next(),l=0;for(;!c.done;){let u=c.value,f=$r(u);a+f<=r?t[t.length-1]+=u:(t.push(u),a=0),(u===Iu||u===O4)&&(s=!0,o=e.startsWith(Y1,l+1)),s?o?u===W1&&(s=!1,o=!1):u===C4&&(s=!1):(a+=f,a===r&&!d.done&&(t.push(""),a=0)),c=d,d=n.next(),l+=u.length}i=t.at(-1),!a&&i!==void 0&&i.length&&t.length>1&&(t[t.length-2]+=t.pop())},sN=t=>{let e=t.split(" "),r=e.length;for(;r&&!$r(e[r-1]);)r--;return r===e.length?t:e.slice(0,r).join(" ")+e.slice(r).join("")},oN=(t,e,r={})=>{if(r.trim!==!1&&t.trim()==="")return"";let n="",s,o,i=t.split(" "),a=[""],c=0;for(let u=0;u<i.length;u++){let f=i[u];if(r.trim!==!1){let m=a.at(-1)??"",y=m.trimStart();m.length!==y.length&&(a[a.length-1]=y,c=$r(y))}u!==0&&(c>=e&&(r.wordWrap===!1||r.trim===!1)&&(a.push(""),c=0),(c||r.trim===!1)&&(a[a.length-1]+=" ",c++));let p=$r(f);if(r.hard&&p>e){let m=e-c,y=1+Math.floor((p-m-1)/e);Math.floor((p-1)/e)<y&&a.push(""),G1(a,f,e),c=$r(a.at(-1)??"");continue}if(c+p>e&&c&&p){if(r.wordWrap===!1&&c<e){G1(a,f,e),c=$r(a.at(-1)??"");continue}a.push(""),c=0}if(c+p>e&&r.wordWrap===!1){G1(a,f,e),c=$r(a.at(-1)??"");continue}a[a.length-1]+=f,c+=p}r.trim!==!1&&(a=a.map(u=>sN(u)));let d=a.join(`
|
|
129
|
+
`),l=!1;for(let u=0;u<d.length;u++){let f=d[u];if(n+=f,l)l=!1;else if(l=f>="\uD800"&&f<="\uDBFF",l)continue;if(f===Iu||f===O4){M4.lastIndex=u+1;let m=M4.exec(d)?.groups;if(m?.code!==void 0){let y=Number.parseFloat(m.code);s=y===rN?void 0:y}else m?.uri!==void 0&&(o=m.uri.length===0?void 0:m.uri)}if(d[u+1]===`
|
|
130
|
+
`){o&&(n+=A4(""));let p=s?I4(s):void 0;s&&p&&(n+=z4(p))}else f===`
|
|
131
|
+
`&&(s&&I4(s)&&(n+=z4(s)),o&&(n+=A4(o)))}return n},iN=/\r?\n/;function qn(t,e,r){return String(t).normalize().split(iN).map(n=>oN(n,e,r)).join(`
|
|
132
|
+
`)}var yr=Ni(J1(),1);import{ReadStream as D4}from"node:tty";function Po(t,e,r){if(!r.some(i=>!i.disabled))return t;let n=t+e,s=Math.max(r.length-1,0),o=n<0?s:n>s?0:n;return r[o].disabled?Po(o,e<0?-1:1,r):o}var dN=["up","down","left","right","space","enter","cancel"],hN=["January","February","March","April","May","June","July","August","September","October","November","December"],rr={actions:new Set(dN),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,date:{monthNames:[...hN],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(t,e)=>`There are only ${t} days in ${e}`,afterMin:t=>`Date must be on or after ${t.toISOString().slice(0,10)}`,beforeMax:t=>`Date must be on or before ${t.toISOString().slice(0,10)}`}}};function r0(t,e){if(typeof t=="string")return rr.aliases.get(t)===e;for(let r of t)if(r!==void 0&&r0(r,e))return!0;return!1}function fN(t,e){if(t===e)return;let r=t.split(`
|
|
213
133
|
`),n=e.split(`
|
|
214
|
-
`),s=Math.max(r.length,n.length),o=[];for(let i=0;i<s;i++)r[i]!==n[i]&&o.push(i);return{lines:o,numLinesBefore:r.length,numLinesAfter:n.length,numLines:s}}var pN=globalThis.process.platform.startsWith("win"),e0=Symbol("clack:cancel");function Ps(t){return t===e0}function
|
|
134
|
+
`),s=Math.max(r.length,n.length),o=[];for(let i=0;i<s;i++)r[i]!==n[i]&&o.push(i);return{lines:o,numLinesBefore:r.length,numLinesAfter:n.length,numLines:s}}var pN=globalThis.process.platform.startsWith("win"),e0=Symbol("clack:cancel");function Ps(t){return t===e0}function zu(t,e){let r=t;r.isTTY&&r.setRawMode(e)}function Z4({input:t=L4,output:e=t0,overwrite:r=!0,hideCursor:n=!0}={}){let s=Rs.createInterface({input:t,output:e,prompt:"",tabSize:1});Rs.emitKeypressEvents(t,s),t instanceof D4&&t.isTTY&&t.setRawMode(!0);let o=(i,{name:a,sequence:c})=>{let d=String(i);if(r0([d,a,c],"cancel")){n&&e.write(yr.cursor.show),process.exit(0);return}if(!r)return;Rs.moveCursor(e,a==="return"?0:-1,a==="return"?-1:0,()=>{Rs.clearLine(e,1,()=>{t.once("keypress",o)})})};return n&&e.write(yr.cursor.hide),t.once("keypress",o),()=>{t.off("keypress",o),n&&e.write(yr.cursor.show),t instanceof D4&&t.isTTY&&!pN&&t.setRawMode(!1),s.terminal=!1,s.close()}}var rc=t=>"columns"in t&&typeof t.columns=="number"?t.columns:80,n0=t=>"rows"in t&&typeof t.rows=="number"?t.rows:20;function Ms(t,e,r,n=r,s=r,o){let i=rc(t??t0);return qn(e,i-r.length,{hard:!0,trim:!1}).split(`
|
|
215
135
|
`).map((a,c,d)=>{let l=o?o(a,c):a;return c===0?`${n}${l}`:c===d.length-1?`${s}${l}`:`${r}${l}`}).join(`
|
|
216
|
-
`)}function
|
|
217
|
-
`),
|
|
136
|
+
`)}function B4(t,e){if("~standard"in t){let r=t["~standard"].validate(e);if(r instanceof Promise)throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return r.issues?.at(0)?.message}return t(e)}var Mo=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(e,r=!0){let{input:n=L4,output:s=t0,render:o,signal:i,...a}=e;this.opts=a,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=o.bind(this),this._track=r,this._abortSignal=i,this.input=n,this.output=s}unsubscribe(){this._subscribers.clear()}setSubscriber(e,r){let n=this._subscribers.get(e)??[];n.push(r),this._subscribers.set(e,n)}on(e,r){this.setSubscriber(e,{cb:r})}once(e,r){this.setSubscriber(e,{cb:r,once:!0})}emit(e,...r){let n=this._subscribers.get(e)??[],s=[];for(let o of n)o.cb(...r),o.once&&s.push(()=>n.splice(n.indexOf(o),1));for(let o of s)o()}prompt(){return new Promise(e=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(e0);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=uN.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),zu(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(yr.cursor.show),this.output.off("resize",this.render),zu(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(yr.cursor.show),this.output.off("resize",this.render),zu(this.input,!1),e(e0)})})}_isActionKey(e,r){return e===" "}_shouldSubmit(e,r){return!0}_setValue(e){this.value=e,this.emit("value",this.value)}_setUserInput(e,r){this.userInput=e??"",this.emit("userInput",this.userInput),r&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(e,r){if(this._track&&r.name!=="return"&&(r.name&&this._isActionKey(e,r)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),r?.name&&(!this._track&&rr.aliases.has(r.name)&&this.emit("cursor",rr.aliases.get(r.name)),rr.actions.has(r.name)&&this.emit("cursor",r.name)),e&&(e.toLowerCase()==="y"||e.toLowerCase()==="n")&&this.emit("confirm",e.toLowerCase()==="y"),this.emit("key",e,r),r?.name==="return"&&this._shouldSubmit(e,r)){if(this.opts.validate){let n=B4(this.opts.validate,this.value);n&&(this.error=n instanceof Error?n.message:n,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}r0([e,r?.name,r?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
137
|
+
`),zu(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=qn(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
|
|
218
138
|
`).length-1;this.output.write(yr.cursor.move(-999,e*-1))}render(){let e=qn(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(yr.cursor.hide);else{let r=fN(this._prevFrame,e),n=n0(this.output);if(this.restoreCursor(),r){let s=Math.max(0,r.numLinesAfter-n),o=Math.max(0,r.numLinesBefore-n),i=r.lines.find(a=>a>=s);if(i===void 0){this._prevFrame=e;return}if(r.lines.length===1){this.output.write(yr.cursor.move(0,i-o)),this.output.write(yr.erase.lines(1));let a=e.split(`
|
|
219
139
|
`);this.output.write(a[i]),this._prevFrame=e,this.output.write(yr.cursor.move(0,a.length-i-1));return}else if(r.lines.length>1){if(s<o)i=s;else{let c=i-o;c>0&&this.output.write(yr.cursor.move(0,c))}this.output.write(yr.erase.down());let a=e.split(`
|
|
220
140
|
`).slice(i);this.output.write(a.join(`
|
|
221
|
-
`)),this._prevFrame=e;return}}this.output.write(yr.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}};var Au=class extends Mo{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",r=>{this.output.write(yr.cursor.move(0,-1)),this.value=r,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};var
|
|
222
|
-
`);k.push($),x+=$.length}if(x>l){let h=0,$=0,
|
|
141
|
+
`)),this._prevFrame=e;return}}this.output.write(yr.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}};var Au=class extends Mo{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",r=>{this.output.write(yr.cursor.move(0,-1)),this.value=r,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};var V4=class extends Mo{options;cursor=0;get _value(){return this.options[this.cursor].value}get _enabledOptions(){return this.options.filter(e=>e.disabled!==!0)}toggleAll(){let e=this._enabledOptions,r=this.value!==void 0&&this.value.length===e.length;this.value=r?[]:e.map(n=>n.value)}toggleInvert(){let e=this.value;if(!e)return;let r=this._enabledOptions.filter(n=>!e.includes(n.value));this.value=r.map(n=>n.value)}toggleValue(){this.value===void 0&&(this.value=[]);let e=this.value.includes(this._value);this.value=e?this.value.filter(r=>r!==this._value):[...this.value,this._value]}constructor(e){super(e,!1),this.options=e.options,this.value=[...e.initialValues??[]];let r=Math.max(this.options.findIndex(({value:n})=>n===e.cursorAt),0);this.cursor=this.options[r].disabled?Po(r,1,this.options):r,this.on("key",(n,s)=>{s.name==="a"&&this.toggleAll(),s.name==="i"&&this.toggleInvert()}),this.on("cursor",n=>{switch(n){case"left":case"up":this.cursor=Po(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=Po(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}},Ou=class extends Mo{_mask="\u2022";get cursor(){return this._cursor}get masked(){return this.userInput.replaceAll(/./g,this._mask)}get userInputWithCursor(){if(this.state==="submit"||this.state==="cancel")return this.masked;let e=this.userInput;if(this.cursor>=e.length)return`${this.masked}${Q1(["inverse","hidden"],"_")}`;let r=this.masked,n=r.slice(0,this.cursor),s=r.slice(this.cursor);return`${n}${Q1("inverse",s[0])}${s.slice(1)}`}clear(){this._clearUserInput()}constructor({mask:e,...r}){super(r),this._mask=e??"\u2022",this.on("userInput",n=>{this._setValue(n)}),this.on("finalize",()=>{this.value===void 0&&(this.value="")})}},Nu=class extends Mo{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(e){super(e,!1),this.options=e.options;let r=this.options.findIndex(({value:s})=>s===e.initialValue),n=r===-1?0:r;this.cursor=this.options[n].disabled?Po(n,1,this.options):n,this.changeValue(),this.on("cursor",s=>{switch(s){case"left":case"up":this.cursor=Po(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=Po(this.cursor,1,this.options);break}this.changeValue()})}};var Cu=class extends Mo{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let e=this.userInput;if(this.cursor>=e.length)return`${this.userInput}\u2588`;let r=e.slice(0,this.cursor),[n,...s]=e.slice(this.cursor);return`${r}${Q1("inverse",n)}${s.join("")}`}get cursor(){return this._cursor}constructor(e){super({...e,initialUserInput:e.initialUserInput??e.initialValue}),this.on("userInput",r=>{this._setValue(r)}),this.on("finalize",()=>{this.value||(this.value=e.defaultValue),this.value===void 0&&(this.value="")})}};import{styleText as ue,stripVTControlCharacters as _U}from"node:util";import fn from"node:process";var sc=Ni(J1(),1);function mN(){return fn.platform!=="win32"?fn.env.TERM!=="linux":!!fn.env.CI||!!fn.env.WT_SESSION||!!fn.env.TERMINUS_SUBLIME||fn.env.ConEmuTask==="{cmd::Cmder}"||fn.env.TERM_PROGRAM==="Terminus-Sublime"||fn.env.TERM_PROGRAM==="vscode"||fn.env.TERM==="xterm-256color"||fn.env.TERM==="alacritty"||fn.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var s0=mN(),gN=()=>process.env.CI==="true";var Et=(t,e)=>s0?t:e,_N=Et("\u25C6","*"),G4=Et("\u25A0","x"),W4=Et("\u25B2","x"),Lu=Et("\u25C7","o"),bN=Et("\u250C","T"),nt=Et("\u2502","|"),ns=Et("\u2514","\u2014"),wU=Et("\u2510","T"),xU=Et("\u2518","\u2014"),o0=Et("\u25CF",">"),Du=Et("\u25CB"," "),yN=Et("\u25FB","[\u2022]"),q4=Et("\u25FC","[+]"),F4=Et("\u25FB","[ ]"),vN=Et("\u25AA","\u2022"),U4=Et("\u2500","-"),wN=Et("\u256E","+"),xN=Et("\u251C","+"),SN=Et("\u256F","+"),kN=Et("\u2570","+"),SU=Et("\u256D","+"),$N=Et("\u25CF","\u2022"),EN=Et("\u25C6","*"),TN=Et("\u25B2","!"),RN=Et("\u25A0","x"),oc=t=>{switch(t){case"initial":case"active":return ue("cyan",_N);case"cancel":return ue("red",G4);case"error":return ue("yellow",W4);case"submit":return ue("green",Lu)}},Y4=t=>{switch(t){case"initial":case"active":return ue("cyan",nt);case"cancel":return ue("red",nt);case"error":return ue("yellow",nt);case"submit":return ue("green",nt)}};function X4(t,e){let r=[`${e?`${ue("cyan",nt)} `:""}${t.join(" \u2022 ")}`];return e&&r.push(ue("cyan",ns)),r}var H4=(t,e,r,n,s,o=!1)=>{let i=e,a=0;if(o)for(let c=n-1;c>=r&&(i-=t[c].length,a++,!(i<=s));c--);else for(let c=r;c<n&&(i-=t[c].length,a++,!(i<=s));c++);return{lineCount:i,removals:a}},i0=({cursor:t,options:e,style:r,output:n=process.stdout,maxItems:s=Number.POSITIVE_INFINITY,columnPadding:o=0,rowPadding:i=4})=>{let a=rc(n)-o,c=n0(n),d=ue("dim","..."),l=Math.max(c-i,0),u=Math.max(Math.min(s,l),5),f=0;t>=u-3&&(f=Math.max(Math.min(t-u+3,e.length-u),0));let p=u<e.length&&f>0,m=u<e.length&&f+u<e.length,y=Math.min(f+u,e.length),k=[],x=0;p&&x++,m&&x++;let _=f+(p?1:0),g=y-(m?1:0);for(let h=_;h<g;h++){let $=qn(r(e[h],h===t),a,{hard:!0,trim:!1}).split(`
|
|
142
|
+
`);k.push($),x+=$.length}if(x>l){let h=0,$=0,z=x,L=t-_,q=l,C=()=>H4(k,z,0,L,q),Z=()=>H4(k,z,L+1,k.length,q,!0);p?({lineCount:z,removals:h}=C(),z>q&&(m||(q-=1),{lineCount:z,removals:$}=Z())):(m||(q-=1),{lineCount:z,removals:$}=Z(),z>q&&(q-=1,{lineCount:z,removals:h}=C())),h>0&&(p=!0,k.splice(0,h)),$>0&&(m=!0,k.splice(k.length-$,$))}let E=[];p&&E.push(d);for(let h of k)for(let $ of h)E.push($);return m&&E.push(d),E};var K4=t=>{let e=t.active??"Yes",r=t.inactive??"No";return new Au({active:e,inactive:r,signal:t.signal,input:t.input,output:t.output,initialValue:t.initialValue??!0,render(){let n=t.withGuide??rr.withGuide,s=`${oc(this.state)} `,o=n?`${ue("gray",nt)} `:"",i=Ms(t.output,t.message,o,s),a=`${n?`${ue("gray",nt)}
|
|
223
143
|
`:""}${i}
|
|
224
144
|
`,c=this.value?e:r;switch(this.state){case"submit":{let d=n?`${ue("gray",nt)} `:"";return`${a}${d}${ue("dim",c)}`}case"cancel":{let d=n?`${ue("gray",nt)} `:"";return`${a}${d}${ue(["strikethrough","dim"],c)}${n?`
|
|
225
145
|
${ue("gray",nt)}`:""}`}default:{let d=n?`${ue("cyan",nt)} `:"",l=n?ue("cyan",ns):"";return`${a}${d}${this.value?`${ue("green",o0)} ${e}`:`${ue("dim",Du)} ${ue("dim",e)}`}${t.vertical?n?`
|
|
226
146
|
${ue("cyan",nt)} `:`
|
|
227
147
|
`:` ${ue("dim","/")} `}${this.value?`${ue("dim",Du)} ${ue("dim",r)}`:`${ue("green",o0)} ${r}`}
|
|
228
148
|
${l}
|
|
229
|
-
`}}}}).prompt()};var
|
|
149
|
+
`}}}}).prompt()};var PN=[`${ue("dim","\u2191/\u2193")} to navigate`,`${ue("dim","Space:")} select`,`${ue("dim","Enter:")} confirm`],nc=(t,e)=>t.split(`
|
|
230
150
|
`).map(r=>e(r)).join(`
|
|
231
|
-
`),
|
|
232
|
-
${ue("reset",ue("dim",`Press ${ue(["gray","bgWhite","inverse"]," space ")} to select, ${ue("gray",ue("bgWhite",ue("inverse"," enter ")))} to submit`))}`},render(){let n=t.withGuide??rr.withGuide,s=Ms(t.output,t.message,n?`${
|
|
151
|
+
`),J4=t=>{let e=(n,s)=>{let o=n.label??String(n.value);return s==="disabled"?`${ue("gray",F4)} ${nc(o,i=>ue(["strikethrough","gray"],i))}${n.hint?` ${ue("dim",`(${n.hint??"disabled"})`)}`:""}`:s==="active"?`${ue("cyan",yN)} ${o}${n.hint?` ${ue("dim",`(${n.hint})`)}`:""}`:s==="selected"?`${ue("green",q4)} ${nc(o,i=>ue("dim",i))}${n.hint?` ${ue("dim",`(${n.hint})`)}`:""}`:s==="cancelled"?`${nc(o,i=>ue(["strikethrough","dim"],i))}`:s==="active-selected"?`${ue("green",q4)} ${o}${n.hint?` ${ue("dim",`(${n.hint})`)}`:""}`:s==="submitted"?`${nc(o,i=>ue("dim",i))}`:`${ue("dim",F4)} ${nc(o,i=>ue("dim",i))}`},r=t.required??!0;return new V4({options:t.options,signal:t.signal,input:t.input,output:t.output,initialValues:t.initialValues,required:r,cursorAt:t.cursorAt,validate(n){if(r&&(n===void 0||n.length===0))return`Please select at least one option.
|
|
152
|
+
${ue("reset",ue("dim",`Press ${ue(["gray","bgWhite","inverse"]," space ")} to select, ${ue("gray",ue("bgWhite",ue("inverse"," enter ")))} to submit`))}`},render(){let n=t.withGuide??rr.withGuide,s=Ms(t.output,t.message,n?`${Y4(this.state)} `:"",`${oc(this.state)} `),o=`${n?`${ue("gray",nt)}
|
|
233
153
|
`:""}${s}
|
|
234
154
|
`,i=this.value??[],a=(c,d)=>{if(c.disabled)return e(c,"disabled");let l=i.includes(c.value);return d&&l?e(c,"active-selected"):l?e(c,"selected"):e(c,d?"active":"inactive")};switch(this.state){case"submit":{let c=this.options.filter(({value:l})=>i.includes(l)).map(l=>e(l,"submitted")).join(ue("dim",", "))||ue("dim","none"),d=Ms(t.output,c,n?`${ue("gray",nt)} `:"");return`${o}${d}`}case"cancel":{let c=this.options.filter(({value:l})=>i.includes(l)).map(l=>e(l,"cancelled")).join(ue("dim",", "));if(c.trim()==="")return`${o}${ue("gray",nt)}`;let d=Ms(t.output,c,n?`${ue("gray",nt)} `:"");return`${o}${d}${n?`
|
|
235
155
|
${ue("gray",nt)}`:""}`}case"error":{let c=n?`${ue("yellow",nt)} `:"",d=this.error.split(`
|
|
@@ -240,65 +160,65 @@ ${ue("gray",nt)}`:""}`}case"error":{let c=n?`${ue("yellow",nt)} `:"",d=this.err
|
|
|
240
160
|
${c}`)}
|
|
241
161
|
${d}
|
|
242
162
|
`}default:{let c=n?`${ue("cyan",nt)} `:"",d=o.split(`
|
|
243
|
-
`).length,l=
|
|
163
|
+
`).length,l=X4(PN,n),u=l.join(`
|
|
244
164
|
`),f=l.length+1;return`${o}${c}${i0({output:t.output,options:this.options,cursor:this.cursor,maxItems:t.maxItems,columnPadding:c.length,rowPadding:d+f,style:a}).join(`
|
|
245
165
|
${c}`)}
|
|
246
166
|
${u}
|
|
247
167
|
`}}}}).prompt()};var Fn={message:(t=[],{symbol:e=ue("gray",nt),secondarySymbol:r=ue("gray",nt),output:n=process.stdout,spacing:s=1,withGuide:o}={})=>{let i=[],a=o??rr.withGuide,c=a?r:"",d=a?`${e} `:"",l=a?`${r} `:"";for(let f=0;f<s;f++)i.push(c);let u=Array.isArray(t)?t:t.split(`
|
|
248
168
|
`);if(u.length>0){let[f,...p]=u;f.length>0?i.push(`${d}${f}`):i.push(a?e:"");for(let m of p)m.length>0?i.push(`${l}${m}`):i.push(a?r:"")}n.write(`${i.join(`
|
|
249
169
|
`)}
|
|
250
|
-
`)},info:(t,e)=>{Fn.message(t,{...e,symbol:ue("blue",$N)})},success:(t,e)=>{Fn.message(t,{...e,symbol:ue("green",EN)})},step:(t,e)=>{Fn.message(t,{...e,symbol:ue("green",Lu)})},warn:(t,e)=>{Fn.message(t,{...e,symbol:ue("yellow",TN)})},warning:(t,e)=>{Fn.warn(t,e)},error:(t,e)=>{Fn.message(t,{...e,symbol:ue("red",RN)})}},
|
|
170
|
+
`)},info:(t,e)=>{Fn.message(t,{...e,symbol:ue("blue",$N)})},success:(t,e)=>{Fn.message(t,{...e,symbol:ue("green",EN)})},step:(t,e)=>{Fn.message(t,{...e,symbol:ue("green",Lu)})},warn:(t,e)=>{Fn.message(t,{...e,symbol:ue("yellow",TN)})},warning:(t,e)=>{Fn.warn(t,e)},error:(t,e)=>{Fn.message(t,{...e,symbol:ue("red",RN)})}},Q4=(t="",e)=>{let r=e?.output??process.stdout,n=e?.withGuide??rr.withGuide?`${ue("gray",ns)} `:"";r.write(`${n}${ue("red",t)}
|
|
251
171
|
|
|
252
|
-
`)},
|
|
253
|
-
`)},
|
|
172
|
+
`)},ex=(t="",e)=>{let r=e?.output??process.stdout,n=e?.withGuide??rr.withGuide?`${ue("gray",bN)} `:"";r.write(`${n}${t}
|
|
173
|
+
`)},tx=(t="",e)=>{let r=e?.output??process.stdout,n=e?.withGuide??rr.withGuide?`${ue("gray",nt)}
|
|
254
174
|
${ue("gray",ns)} `:"";r.write(`${n}${t}
|
|
255
175
|
|
|
256
|
-
`)};var
|
|
257
|
-
`),o=s.reduce((c,d)=>Math.max($r(d),c),0),i=s.map(r).reduce((c,d)=>Math.max($r(d),c),0),a=e-(i-o);return qn(t,a,n)},Zu=(t="",e="",r)=>{let n=r?.output??fn.stdout,s=r?.withGuide??rr.withGuide,o=r?.format??
|
|
176
|
+
`)};var MN=t=>t,IN=(t,e,r)=>{let n={hard:!0,trim:!1},s=qn(t,e,n).split(`
|
|
177
|
+
`),o=s.reduce((c,d)=>Math.max($r(d),c),0),i=s.map(r).reduce((c,d)=>Math.max($r(d),c),0),a=e-(i-o);return qn(t,a,n)},Zu=(t="",e="",r)=>{let n=r?.output??fn.stdout,s=r?.withGuide??rr.withGuide,o=r?.format??MN,i=["",...IN(t,rc(n)-6,o).split(`
|
|
258
178
|
`).map(o),""],a=$r(e),c=Math.max(i.reduce((f,p)=>{let m=$r(p);return m>f?m:f},0),a)+2,d=i.map(f=>`${ue("gray",nt)} ${f}${" ".repeat(c-$r(f))}${ue("gray",nt)}`).join(`
|
|
259
179
|
`),l=s?`${ue("gray",nt)}
|
|
260
180
|
`:"",u=s?xN:kN;n.write(`${l}${ue("green",Lu)} ${ue("reset",e)} ${ue("gray",U4.repeat(Math.max(c-a-1,1))+wN)}
|
|
261
181
|
${d}
|
|
262
182
|
${ue("gray",u+U4.repeat(c+2)+SN)}
|
|
263
|
-
`)},
|
|
264
|
-
`:""}${
|
|
183
|
+
`)},rx=t=>new Ou({validate:t.validate,mask:t.mask??vN,signal:t.signal,input:t.input,output:t.output,render(){let e=t.withGuide??rr.withGuide,r=`${e?`${ue("gray",nt)}
|
|
184
|
+
`:""}${oc(this.state)} ${t.message}
|
|
265
185
|
`,n=this.userInputWithCursor,s=this.masked;switch(this.state){case"error":{let o=e?`${ue("yellow",nt)} `:"",i=e?`${ue("yellow",ns)} `:"",a=s??"";return t.clearOnError&&this.clear(),`${r.trim()}
|
|
266
186
|
${o}${a}
|
|
267
187
|
${i}${ue("yellow",this.error)}
|
|
268
188
|
`}case"submit":{let o=e?`${ue("gray",nt)} `:"",i=s?ue("dim",s):"";return`${r}${o}${i}`}case"cancel":{let o=e?`${ue("gray",nt)} `:"",i=s?ue(["strikethrough","dim"],s):"";return`${r}${o}${i}${s&&e?`
|
|
269
189
|
${ue("gray",nt)}`:""}`}default:{let o=e?`${ue("cyan",nt)} `:"",i=e?ue("cyan",ns):"";return`${r}${o}${n}
|
|
270
190
|
${i}
|
|
271
|
-
`}}}}).prompt();var
|
|
191
|
+
`}}}}).prompt();var zN=t=>ue("magenta",t),nx=({indicator:t="dots",onCancel:e,output:r=process.stdout,cancelMessage:n,errorMessage:s,frames:o=s0?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:i=s0?80:120,signal:a,...c}={})=>{let d=gN(),l,u,f=!1,p=!1,m="",y,k=performance.now(),x=rc(r),_=c?.styleFrame??zN,g=b=>{let j=b>1?s??rr.messages.error:n??rr.messages.cancel;p=b===1,f&&(O(j,b),p&&typeof e=="function"&&e())},E=()=>g(2),h=()=>g(1),$=()=>{process.on("uncaughtExceptionMonitor",E),process.on("unhandledRejection",E),process.on("SIGINT",h),process.on("SIGTERM",h),process.on("exit",g),a&&a.addEventListener("abort",h)},z=()=>{process.removeListener("uncaughtExceptionMonitor",E),process.removeListener("unhandledRejection",E),process.removeListener("SIGINT",h),process.removeListener("SIGTERM",h),process.removeListener("exit",g),a&&a.removeEventListener("abort",h)},L=()=>{if(y===void 0)return;d&&r.write(`
|
|
272
192
|
`);let b=qn(y,x,{hard:!0,trim:!1}).split(`
|
|
273
|
-
`);b.length>1&&r.write(
|
|
274
|
-
`);let j=0,A=0;$(),u=setInterval(()=>{if(d&&m===y)return;L(),y=m;let G=_(o[j]),F;if(d)F=`${G} ${m}...`;else if(t==="timer")F=`${G} ${m} ${C(k)}`;else{let B=".".repeat(Math.floor(A)).slice(0,3);F=`${G} ${m}${B}`}let Q=qn(F,x,{hard:!0,trim:!1});r.write(Q),j=j+1<o.length?j+1:0,A=A<4?A+.125:0},i)},
|
|
193
|
+
`);b.length>1&&r.write(sc.cursor.up(b.length-1)),r.write(sc.cursor.to(0)),r.write(sc.erase.down())},q=b=>b.replace(/\.+$/,""),C=b=>{let j=(performance.now()-b)/1e3,A=Math.floor(j/60),G=Math.floor(j%60);return A>0?`[${A}m ${G}s]`:`[${G}s]`},Z=c.withGuide??rr.withGuide,he=(b="")=>{f=!0,l=Z4({output:r}),m=q(b),k=performance.now(),Z&&r.write(`${ue("gray",nt)}
|
|
194
|
+
`);let j=0,A=0;$(),u=setInterval(()=>{if(d&&m===y)return;L(),y=m;let G=_(o[j]),F;if(d)F=`${G} ${m}...`;else if(t==="timer")F=`${G} ${m} ${C(k)}`;else{let B=".".repeat(Math.floor(A)).slice(0,3);F=`${G} ${m}${B}`}let Q=qn(F,x,{hard:!0,trim:!1});r.write(Q),j=j+1<o.length?j+1:0,A=A<4?A+.125:0},i)},O=(b="",j=0,A=!1)=>{if(!f)return;f=!1,clearInterval(u),L();let G=j===0?ue("green",Lu):j===1?ue("red",G4):ue("red",W4);m=b??m,A||(t==="timer"?r.write(`${G} ${m} ${C(k)}
|
|
275
195
|
`):r.write(`${G} ${m}
|
|
276
|
-
`)),
|
|
196
|
+
`)),z(),l()};return{start:he,stop:(b="")=>O(b,0),message:(b="")=>{m=q(b??m)},cancel:(b="")=>O(b,1),error:(b="")=>O(b,2),clear:()=>O("",0,!0),get isCancelled(){return p}}},kU={light:Et("\u2500","-"),heavy:Et("\u2501","="),block:Et("\u2588","#")};var AN=[`${ue("dim","\u2191/\u2193")} to navigate`,`${ue("dim","Enter:")} confirm`],ju=(t,e)=>t.includes(`
|
|
277
197
|
`)?t.split(`
|
|
278
198
|
`).map(r=>e(r)).join(`
|
|
279
|
-
`):e(t),
|
|
199
|
+
`):e(t),sx=t=>{let e=(r,n)=>{let s=r.label??String(r.value);switch(n){case"disabled":return`${ue("gray",Du)} ${ju(s,o=>ue("gray",o))}${r.hint?` ${ue("dim",`(${r.hint??"disabled"})`)}`:""}`;case"selected":return`${ju(s,o=>ue("dim",o))}`;case"active":return`${ue("green",o0)} ${s}${r.hint?` ${ue("dim",`(${r.hint})`)}`:""}`;case"cancelled":return`${ju(s,o=>ue(["strikethrough","dim"],o))}`;default:return`${ue("dim",Du)} ${ju(s,o=>ue("dim",o))}`}};return new Nu({options:t.options,signal:t.signal,input:t.input,output:t.output,initialValue:t.initialValue,render(){let r=t.withGuide??rr.withGuide,n=`${oc(this.state)} `,s=`${Y4(this.state)} `,o=Ms(t.output,t.message,s,n),i=`${r?`${ue("gray",nt)}
|
|
280
200
|
`:""}${o}
|
|
281
201
|
`;switch(this.state){case"submit":{let a=r?`${ue("gray",nt)} `:"",c=Ms(t.output,e(this.options[this.cursor],"selected"),a);return`${i}${c}`}case"cancel":{let a=r?`${ue("gray",nt)} `:"",c=Ms(t.output,e(this.options[this.cursor],"cancelled"),a);return`${i}${c}${r?`
|
|
282
202
|
${ue("gray",nt)}`:""}`}default:{let a=r?`${ue("cyan",nt)} `:"",c=i.split(`
|
|
283
|
-
`).length,d=
|
|
203
|
+
`).length,d=X4(AN,r),l=d.join(`
|
|
284
204
|
`),u=d.length+1;return`${i}${a}${i0({output:t.output,cursor:this.cursor,options:this.options,maxItems:t.maxItems,columnPadding:a.length,rowPadding:c+u,style:(f,p)=>e(f,f.disabled?"disabled":p?"active":"inactive")}).join(`
|
|
285
205
|
${a}`)}
|
|
286
206
|
${l}
|
|
287
|
-
`}}}}).prompt()};var $
|
|
288
|
-
`:""}${
|
|
207
|
+
`}}}}).prompt()};var $U=`${ue("gray",nt)} `;var ox=t=>new Cu({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,output:t.output,signal:t.signal,input:t.input,render(){let e=t?.withGuide??rr.withGuide,r=`${`${e?`${ue("gray",nt)}
|
|
208
|
+
`:""}${oc(this.state)} `}${t.message}
|
|
289
209
|
`,n=t.placeholder?ue("inverse",t.placeholder[0])+ue("dim",t.placeholder.slice(1)):ue(["inverse","hidden"],"_"),s=this.userInput?this.userInputWithCursor:n,o=this.value??"";switch(this.state){case"error":{let i=this.error?` ${ue("yellow",this.error)}`:"",a=e?`${ue("yellow",nt)} `:"",c=e?ue("yellow",ns):"";return`${r.trim()}
|
|
290
210
|
${a}${s}
|
|
291
211
|
${c}${i}
|
|
292
212
|
`}case"submit":{let i=o?` ${ue("dim",o)}`:"",a=e?ue("gray",nt):"";return`${r}${a}${i}`}case"cancel":{let i=o?` ${ue(["strikethrough","dim"],o)}`:"",a=e?ue("gray",nt):"";return`${r}${a}${i}${o.trim()?`
|
|
293
213
|
${a}`:""}`}default:{let i=e?`${ue("cyan",nt)} `:"",a=e?ue("cyan",ns):"";return`${r}${i}${s}
|
|
294
214
|
${a}
|
|
295
|
-
`}}}}).prompt();var Xr=
|
|
296
|
-
`),s?"updated":"added"}function
|
|
297
|
-
Save anyway?`:"No audio came back. Save anyway?",initialValue:!1});if(Ps(l)||!l)return t()}
|
|
215
|
+
`}}}}).prompt();var Xr=Ni(cx(),1);import{stdin as FN}from"node:process";import{spawnSync as u0}from"node:child_process";import{existsSync as Mi,readFileSync as DN,writeFileSync as LN,copyFileSync as ZN,mkdirSync as BN}from"node:fs";import{homedir as ux}from"node:os";import{join as pn,dirname as dx}from"node:path";var VN={command:"npx",args:["-y","@flowcast/mcp@latest"]};function c0(t){let e=process.platform==="win32"?u0("where",[t],{stdio:"ignore"}):u0("sh",["-c",`command -v ${t}`],{stdio:"ignore"});return!e.error&&e.status===0}function l0(t,e){let r=u0(t,e,{stdio:"inherit"});return!r.error&&r.status===0}function ic(t,e="mcpServers"){let r={};if(Mi(t)){ZN(t,`${t}.bak`);try{let o=JSON.parse(DN(t,"utf8"));o&&typeof o=="object"&&!Array.isArray(o)&&(r=o)}catch{}}else BN(dx(t),{recursive:!0});let n=r[e]&&typeof r[e]=="object"?r[e]:{},s="flowcast"in n;return r[e]={...n,flowcast:VN},LN(t,JSON.stringify(r,null,2)+`
|
|
216
|
+
`),s?"updated":"added"}function lx(){let t=ux();return process.platform==="darwin"?pn(t,"Library","Application Support","Claude","claude_desktop_config.json"):process.platform==="win32"?pn(process.env.APPDATA||pn(t,"AppData","Roaming"),"Claude","claude_desktop_config.json"):pn(t,".config","Claude","claude_desktop_config.json")}function qN(){let t=ux(),e=r=>{throw new Error(r)};return[{name:"Claude Code",detect:()=>c0("claude"),apply:()=>l0("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(dx(lx())),apply:()=>`${ic(lx())} in claude_desktop_config.json`},{name:"Cursor",detect:()=>Mi(pn(t,".cursor")),apply:()=>`${ic(pn(t,".cursor","mcp.json"))} in ~/.cursor/mcp.json`},{name:"Codex",detect:()=>c0("codex"),apply:()=>l0("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(pn(t,".kiro")),apply:()=>`${ic(pn(t,".kiro","settings","mcp.json"))} in ~/.kiro/settings/mcp.json`},{name:"Windsurf",detect:()=>Mi(pn(t,".codeium")),apply:()=>`${ic(pn(t,".codeium","windsurf","mcp_config.json"))} in ~/.codeium/windsurf/mcp_config.json`},{name:"Gemini CLI",detect:()=>Mi(pn(t,".gemini")),apply:()=>`${ic(pn(t,".gemini","settings.json"))} in ~/.gemini/settings.json`},{name:"VS Code",detect:()=>c0("code"),apply:()=>l0("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)")}]}function hx(){return qN().filter(t=>t.detect())}var d0=t=>`\x1B[38;2;255;91;52m${t}\x1B[39m`,fx=[{id:"openai",label:"OpenAI",hint:"gpt-4o-mini-tts \xB7 easiest to start",keyEnv:"OPENAI_API_KEY",keyUrl:"https://platform.openai.com/api-keys"},{id:"elevenlabs",label:"ElevenLabs",hint:"the most natural voices",keyEnv:"ELEVENLABS_API_KEY",keyUrl:"https://elevenlabs.io/app/settings/api-keys",extra:[{env:"ELEVENLABS_VOICE_ID",prompt:"ElevenLabs voice id",placeholder:"blank = account default"}]},{id:"google",label:"Google",hint:"Cloud Text-to-Speech",keyEnv:"GOOGLE_TTS_API_KEY",keyUrl:"https://console.cloud.google.com/apis/credentials",extra:[{env:"GOOGLE_TTS_VOICE",prompt:"Google voice",default:"en-US-Neural2-D"}]}],UN="Use FlowCast to make a whiteboard walkthrough of how the water cycle works.";function HN(t,e){return Promise.race([t,new Promise((r,n)=>setTimeout(()=>n(new Error(`timed out after ${e/1e3}s`)),e).unref())])}async function px(){if(!FN.isTTY){console.log("flowcast setup needs an interactive terminal.\nRun it directly in your shell, or set your key via your MCP client's `env` block\n(VOICE_MODEL + the provider key), or write ~/.flowcast/config.json by hand.");return}let t=()=>Q4("Setup cancelled \u2014 nothing saved.");ex(`${d0("\u25C6 FlowCast")} ${Xr.default.dim("\xB7 setup")}`);let e=await sx({message:"Pick a voice provider for narration",options:fx.map(l=>({value:l.id,label:l.label,hint:l.hint})),initialValue:"openai"});if(Ps(e))return t();let r=fx.find(l=>l.id===e);Zu(Xr.default.cyan(Xr.default.underline(r.keyUrl)),`Get your ${r.label} key here`);let n=await rx({message:`Paste your ${Xr.default.bold(r.keyEnv)}`,validate:l=>l&&l.trim()?void 0:"A key is required \u2014 voice is always on."});if(Ps(n))return t();let s={...H1(),VOICE_MODEL:r.id,[r.keyEnv]:n.trim()};for(let l of r.extra??[]){let u=await ox({message:l.prompt,placeholder:l.placeholder??l.default??"",defaultValue:l.default??""});if(Ps(u))return t();let f=typeof u=="string"&&u.trim()||l.default;f&&(s[l.env]=f)}for(let[l,u]of Object.entries(s))process.env[l]=u;let o=nx();o.start("Testing your key with a quick voice sample");let i=!1,a="";try{i=(await HN(Ru[r.id].synth("Testing FlowCast voice.",{}),2e4)).length>0}catch(l){a=l instanceof Error?l.message:String(l)}if(o.stop(i?Xr.default.green("Voice key works \u2713"):Xr.default.yellow("Could not verify the key")),!i){let l=await K4({message:a?`${a}
|
|
217
|
+
Save anyway?`:"No audio came back. Save anyway?",initialValue:!1});if(Ps(l)||!l)return t()}w4(s),Fn.success(`Saved your key to ${Xr.default.dim(tc())}`);let c=hx(),d=[];if(!c.length)Zu(Xr.default.dim('{ "mcpServers": { "flowcast": { "command": "npx", "args": ["-y", "@flowcast/mcp@latest"] } } }'),"No AI tools detected \u2014 add this to your client manually");else{let l=await J4({message:`Add FlowCast to which tools? ${Xr.default.dim("(space toggles, enter confirms)")}`,options:c.map(u=>({value:u.name,label:u.name})),initialValues:c.map(u=>u.name),required:!1});if(Ps(l))return t();for(let u of c.filter(f=>l.includes(f.name)))try{u.apply(),Fn.success(`${Xr.default.green("\u2713")} ${u.name}`),d.push(u.name)}catch(f){Fn.warn(`${u.name} \u2014 ${f instanceof Error?f.message:String(f)}`)}}d.length&&Zu(`Open ${Xr.default.bold(d[0])} and try:
|
|
298
218
|
|
|
299
|
-
${d0(`"${
|
|
219
|
+
${d0(`"${UN}"`)}`,"Make your first cast"),tx(`${d0("FlowCast is ready.")} ${Xr.default.dim("Restart any open client so it picks up the new server.")}`)}process.argv[2]==="setup"&&(await px(),process.exit(0));x4();function JN(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"walkthrough"}var QN=`Export a previously generated walkthrough HTML file to a caller-specified path.
|
|
300
220
|
|
|
301
|
-
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.`,
|
|
221
|
+
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.`,zs=new Wl({name:"flowcast",version:"0.1.0"}),Is=new Map,eC=50,tC=0,f0=null;function yx(t){let e=t?t.replace(/^ui:\/\/flowcast\//,""):f0;if(!e)return null;let r=Is.get(e);return r?{id:e,entry:r}:null}function p0(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 Fu="/mnt/user-data/outputs",rC=nr.dirname(XN(import.meta.url)),nC=nr.resolve(rC,"../../..");function sC(t){try{return _x(t,{recursive:!0}),GN(t,WN.W_OK),!0}catch{return!1}}function oC(){return[process.env.FLOWCAST_OUTPUT_DIR,process.cwd()!==nr.parse(process.cwd()).root?process.cwd():void 0,nC,nr.join(mx(),"flowcast")].filter(e=>!!e).find(sC)??mx()}function gx(t,e){let r=nr.relative(nr.resolve(t),e);return r===""||!r.startsWith("..")&&!nr.isAbsolute(r)}function iC(t){if(t===Fu||t.startsWith(`${Fu}/`)){let r=nr.relative(Fu,t),n=oC(),s=nr.resolve(n,r===""?"walkthrough.html":r);if(!gx(n,s))throw new Error(`outputPath escapes the output directory: ${t}`);return s}if(nr.isAbsolute(t))return nr.resolve(t);let e=nr.resolve(process.cwd(),t);if(!gx(process.cwd(),e))throw new Error(`relative outputPath escapes the working directory: ${t} \u2014 pass an absolute path to write elsewhere`);return e}function vx(t,e){let r=iC(t);return _x(nr.dirname(r),{recursive:!0}),YN(r,e,"utf8"),r}var h0=null;function aC(t,e){let r=new URL(t.url??"/","http://127.0.0.1").pathname,n=decodeURIComponent(r.replace(/^\/+/,"").replace(/\.html$/i,"")),s=n?Is.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 cC(t,e){return new Promise(r=>{let n=KN(aC);n.once("error",()=>r(!1)),n.listen(e,t,()=>{h0=n,h0.unref(),r(!0)})})}var qu=null;function lC(){return qu||(qu=(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 cC(t,r))return`http://${t}:${r}`;return null})(),qu)}zs.registerResource("walkthrough",new Yl("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=Is.get(r);if(!n)throw new Error(`Unknown walkthrough id: ${r}`);return{contents:[{uri:t.href,mimeType:"text/html",text:n.html}]}});zs.registerTool("export_walkthrough",{title:"Export generated walkthrough HTML",description:QN,inputSchema:{outputPath:W.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:W.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\//,""):f0;if(!n)return{isError:!0,content:[{type:"text",text:"No walkthrough has been generated yet. Call create_walkthrough first."}]};let s=Is.get(n);if(!s)return{isError:!0,content:[{type:"text",text:`Unknown walkthrough id: ${n}`}]};try{let o=vx(e,s.html),i=o!==e&&e.startsWith(Fu)?` 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:bx(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 wx(t){let{title:e,outputPath:r,html:n,data:s,kind:o,typeId:i,spec:a,diagnostics:c=[]}=t,d=JN(e),l=Buffer.byteLength(n),u=(l/1024).toFixed(0),f=`${d}-${(++tC).toString(36)}`;for(Is.set(f,{html:n,title:e,slug:d,bytes:l,typeId:i,spec:a,diagnostics:c}),f0=f;Is.size>eC;)Is.delete(Is.keys().next().value);let p=`ui://flowcast/${f}`,m=null;if(r)try{m=vx(r,n)}catch{}let y=await lC(),k=y?`${y}/${f}.html`:null,x=!k&&l<=9e5,_=`${o} ready \u2014 ${u} KB, ${s.events.length} events, ${Math.round(s.manifest.durationMs/1e3)}s. Narration audio embedded.`;k?_+=`
|
|
302
222
|
|
|
303
223
|
Give the user this link to open the interactive player in their browser (voice included):
|
|
304
224
|
${k}`:x?_+=`
|
|
@@ -309,15 +229,15 @@ No local server and the page is large: read ${p} via resources/read to get the s
|
|
|
309
229
|
|
|
310
230
|
${g.length} quality note(s) \u2014 fix targeted beats with revise_walkthrough (uri: ${p}):
|
|
311
231
|
${g.map(p0).join(`
|
|
312
|
-
`)}`),{content:[{type:"text",text:_},...k?[{type:"resource_link",uri:k,name:`${d}.html`,title:e,mimeType:"text/html",description:`Open in browser \u2014 interactive player on the user's machine: ${e}`}]:[],...x?[{type:"resource",resource:{uri:p,mimeType:"text/html",text:n}}]:[],...m?[{type:"resource_link",uri:
|
|
232
|
+
`)}`),{content:[{type:"text",text:_},...k?[{type:"resource_link",uri:k,name:`${d}.html`,title:e,mimeType:"text/html",description:`Open in browser \u2014 interactive player on the user's machine: ${e}`}]:[],...x?[{type:"resource",resource:{uri:p,mimeType:"text/html",text:n}}]:[],...m?[{type:"resource_link",uri:bx(m).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 bu){let e=async n=>{let s=n;try{let{html:o,data:i,voice:a}=await U1(t,s),c=Mu(t.id,s);return await wx({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};zs.registerTool(t.tool.name,r,e);for(let n of t.tool.aliases??[])zs.registerTool(n,r,e)}zs.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:W.string().optional().describe("ui://flowcast/<id> to check. Omit to check the most recently generated walkthrough."),severity:W.enum(["error","warn","all"]).optional().describe("Filter findings by severity (default 'all').")}},async t=>{let e=yx(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=Mu(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):
|
|
313
233
|
${o.map(p0).join(`
|
|
314
234
|
`)}
|
|
315
235
|
|
|
316
|
-
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}]}});
|
|
236
|
+
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}]}});zs.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:W.string().optional().describe("ui://flowcast/<id> to revise. Omit to revise the most recent walkthrough."),outputPath:W.string().optional().describe("Optional path to also write the revised .html to (same mapping as create_*)."),edits:W.array(W.discriminatedUnion("op",[W.object({op:W.literal("updateStep"),step:W.number().int().min(1).describe("1-based beat index to modify."),set:W.object({say:W.string().optional(),highlightCode:W.string().optional(),holdMs:W.number().optional(),chapter:W.string().optional()}).describe("Fields to overwrite on the beat. Omitted fields are left untouched.")}),W.object({op:W.literal("replaceText"),find:W.string().min(1).describe("Exact text to find."),replace:W.string().describe("Replacement text."),step:W.number().int().min(1).optional().describe("Limit to one beat; omit to apply across all narration."),field:W.literal("say").optional().describe("Field to search (only 'say' for now).")}),W.object({op:W.literal("deleteStep"),step:W.number().int().min(1).describe("1-based beat index to remove.")}),W.object({op:W.literal("insertStep"),after:W.number().int().min(0).describe("Insert the new beat after this 1-based index (0 = before the first beat)."),value:W.record(W.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=yx(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=bu.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=b4(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=Mu(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:
|
|
317
237
|
${i.map(p0).join(`
|
|
318
|
-
`)}`}]};try{let{html:a,data:c,voice:d}=await
|
|
238
|
+
`)}`}]};try{let{html:a,data:c,voice:d}=await U1(n,s),l=typeof t.outputPath=="string"?t.outputPath:void 0;return await wx({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)}`}]}}});zs.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:W.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}`:""}.
|
|
319
239
|
|
|
320
240
|
Before building it, ask me these two choices, then create it with the matching tool:
|
|
321
241
|
1. FORMAT \u2014 pick the one that best fits the topic:
|
|
322
242
|
`+bu.map(e=>` ${e.promptLine}`).join(`
|
|
323
|
-
`)+'\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
|
|
243
|
+
`)+'\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 xx(){try{h0?.close()}catch{}process.exit(0)}process.once("SIGINT",xx);process.once("SIGTERM",xx);await zs.connect(new Kl);
|