@flowcast/mcp 0.1.0 → 0.1.2

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 CHANGED
@@ -1,53 +1,53 @@
1
1
  #!/usr/bin/env node
2
- var U3=Object.create;var vu=Object.defineProperty;var G3=Object.getOwnPropertyDescriptor;var Y3=Object.getOwnPropertyNames;var X3=Object.getPrototypeOf,W3=Object.prototype.hasOwnProperty;var Ie=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),wu=(t,e)=>{for(var r in e)vu(t,r,{get:e[r],enumerable:!0})},K3=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Y3(e))!W3.call(t,s)&&s!==r&&vu(t,s,{get:()=>e[s],enumerable:!(n=G3(e,s))||n.enumerable});return t};var T1=(t,e,r)=>(r=t!=null?U3(X3(t)):{},K3(e||!t||!t.__esModule?vu(r,"default",{value:t,enumerable:!0}):r,t));var Wi=Ie(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.regexpCode=yt.getEsmExportName=yt.getProperty=yt.safeStringify=yt.stringify=yt.strConcat=yt.addCodeArg=yt.str=yt._=yt.nil=yt._Code=yt.Name=yt.IDENTIFIER=yt._CodeOrName=void 0;var Yi=class{};yt._CodeOrName=Yi;yt.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Hs=class extends Yi{constructor(e){if(super(),!yt.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};yt.Name=Hs;var Wr=class extends Yi{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof Hs&&(r[n.str]=(r[n.str]||0)+1),r),{})}};yt._Code=Wr;yt.nil=new Wr("");function x_(t,...e){let r=[t[0]],n=0;for(;n<e.length;)sh(r,e[n]),r.push(t[++n]);return new Wr(r)}yt._=x_;var nh=new Wr("+");function k_(t,...e){let r=[Xi(t[0])],n=0;for(;n<e.length;)r.push(nh),sh(r,e[n]),r.push(nh,Xi(t[++n]));return K6(r),new Wr(r)}yt.str=k_;function sh(t,e){e instanceof Wr?t.push(...e._items):e instanceof Hs?t.push(e):t.push(eS(e))}yt.addCodeArg=sh;function K6(t){let e=1;for(;e<t.length-1;){if(t[e]===nh){let r=J6(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function J6(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Hs||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof Hs))return`"${t}${e.slice(1)}`}function Q6(t,e){return e.emptyStr()?t:t.emptyStr()?e:k_`${t}${e}`}yt.strConcat=Q6;function eS(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:Xi(Array.isArray(t)?t.join(","):t)}function tS(t){return new Wr(Xi(t))}yt.stringify=tS;function Xi(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}yt.safeStringify=Xi;function rS(t){return typeof t=="string"&&yt.IDENTIFIER.test(t)?new Wr(`.${t}`):x_`[${t}]`}yt.getProperty=rS;function nS(t){if(typeof t=="string"&&yt.IDENTIFIER.test(t))return new Wr(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}yt.getEsmExportName=nS;function sS(t){return new Wr(t.toString())}yt.regexpCode=sS});var ah=Ie(Tr=>{"use strict";Object.defineProperty(Tr,"__esModule",{value:!0});Tr.ValueScope=Tr.ValueScopeName=Tr.Scope=Tr.varKinds=Tr.UsedValueState=void 0;var Er=Wi(),oh=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Vc;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(Vc||(Tr.UsedValueState=Vc={}));Tr.varKinds={const:new Er.Name("const"),let:new Er.Name("let"),var:new Er.Name("var")};var Fc=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Er.Name?e:this.name(e)}name(e){return new Er.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Tr.Scope=Fc;var Hc=class extends Er.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,Er._)`.${new Er.Name(r)}[${n}]`}};Tr.ValueScopeName=Hc;var oS=(0,Er._)`\n`,ih=class extends Fc{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?oS:Er.nil}}get(){return this._scope}name(e){return new Hc(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let s=this.toName(e),{prefix:o}=s,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[o];if(a){let l=a.get(i);if(l)return l}else a=this._values[o]=new Map;a.set(i,s);let c=this._scope[o]||(this._scope[o]=[]),d=c.length;return c[d]=r.ref,s.setValue(r,{property:o,itemIndex:d}),s}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Er._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,s=>{if(s.value===void 0)throw new Error(`CodeGen: name "${s}" has no value`);return s.value.code},r,n)}_reduceValues(e,r,n={},s){let o=Er.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(d=>{if(c.has(d))return;c.set(d,Vc.Started);let l=r(d);if(l){let u=this.opts.es5?Tr.varKinds.var:Tr.varKinds.const;o=(0,Er._)`${o}${u} ${d} = ${l};${this.opts._n}`}else if(l=s?.(d))o=(0,Er._)`${o}${l}${this.opts._n}`;else throw new oh(d);c.set(d,Vc.Completed)})}return o}};Tr.ValueScope=ih});var it=Ie(at=>{"use strict";Object.defineProperty(at,"__esModule",{value:!0});at.or=at.and=at.not=at.CodeGen=at.operators=at.varKinds=at.ValueScopeName=at.ValueScope=at.Scope=at.Name=at.regexpCode=at.stringify=at.getProperty=at.nil=at.strConcat=at.str=at._=void 0;var ht=Wi(),hn=ah(),ns=Wi();Object.defineProperty(at,"_",{enumerable:!0,get:function(){return ns._}});Object.defineProperty(at,"str",{enumerable:!0,get:function(){return ns.str}});Object.defineProperty(at,"strConcat",{enumerable:!0,get:function(){return ns.strConcat}});Object.defineProperty(at,"nil",{enumerable:!0,get:function(){return ns.nil}});Object.defineProperty(at,"getProperty",{enumerable:!0,get:function(){return ns.getProperty}});Object.defineProperty(at,"stringify",{enumerable:!0,get:function(){return ns.stringify}});Object.defineProperty(at,"regexpCode",{enumerable:!0,get:function(){return ns.regexpCode}});Object.defineProperty(at,"Name",{enumerable:!0,get:function(){return ns.Name}});var Xc=ah();Object.defineProperty(at,"Scope",{enumerable:!0,get:function(){return Xc.Scope}});Object.defineProperty(at,"ValueScope",{enumerable:!0,get:function(){return Xc.ValueScope}});Object.defineProperty(at,"ValueScopeName",{enumerable:!0,get:function(){return Xc.ValueScopeName}});Object.defineProperty(at,"varKinds",{enumerable:!0,get:function(){return Xc.varKinds}});at.operators={GT:new ht._Code(">"),GTE:new ht._Code(">="),LT:new ht._Code("<"),LTE:new ht._Code("<="),EQ:new ht._Code("==="),NEQ:new ht._Code("!=="),NOT:new ht._Code("!"),OR:new ht._Code("||"),AND:new ht._Code("&&"),ADD:new ht._Code("+")};var Zn=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},ch=class extends Zn{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?hn.varKinds.var:this.varKind,s=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${s};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=No(this.rhs,e,r)),this}get names(){return this.rhs instanceof ht._CodeOrName?this.rhs.names:{}}},Uc=class extends Zn{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof ht.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=No(this.rhs,e,r),this}get names(){let e=this.lhs instanceof ht.Name?{}:{...this.lhs.names};return Yc(e,this.rhs)}},lh=class extends Uc{constructor(e,r,n,s){super(e,n,s),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},uh=class extends Zn{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},dh=class extends Zn{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},fh=class extends Zn{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},hh=class extends Zn{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=No(this.code,e,r),this}get names(){return this.code instanceof ht._CodeOrName?this.code.names:{}}},Ki=class extends Zn{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,s=n.length;for(;s--;){let o=n[s];o.optimizeNames(e,r)||(iS(e,o.names),n.splice(s,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Ys(e,r.names),{})}},Bn=class extends Ki{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},ph=class extends Ki{},Ao=class extends Bn{};Ao.kind="else";var Us=class t extends Bn{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Ao(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(S_(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=No(this.condition,e,r),this}get names(){let e=super.names;return Yc(e,this.condition),this.else&&Ys(e,this.else.names),e}};Us.kind="if";var Gs=class extends Bn{};Gs.kind="for";var mh=class extends Gs{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=No(this.iteration,e,r),this}get names(){return Ys(super.names,this.iteration.names)}},gh=class extends Gs{constructor(e,r,n,s){super(),this.varKind=e,this.name=r,this.from=n,this.to=s}render(e){let r=e.es5?hn.varKinds.var:this.varKind,{name:n,from:s,to:o}=this;return`for(${r} ${n}=${s}; ${n}<${o}; ${n}++)`+super.render(e)}get names(){let e=Yc(super.names,this.from);return Yc(e,this.to)}},Gc=class extends Gs{constructor(e,r,n,s){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=s}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=No(this.iterable,e,r),this}get names(){return Ys(super.names,this.iterable.names)}},Ji=class extends Bn{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};Ji.kind="func";var Qi=class extends Ki{render(e){return"return "+super.render(e)}};Qi.kind="return";var _h=class extends Bn{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,s;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(s=this.finally)===null||s===void 0||s.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&Ys(e,this.catch.names),this.finally&&Ys(e,this.finally.names),e}},ea=class extends Bn{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};ea.kind="catch";var ta=class extends Bn{render(e){return"finally"+super.render(e)}};ta.kind="finally";var bh=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
3
- `:""},this._extScope=e,this._scope=new hn.Scope({parent:e}),this._nodes=[new ph]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,s){let o=this._scope.toName(r);return n!==void 0&&s&&(this._constants[o.str]=n),this._leafNode(new ch(e,o,n)),o}const(e,r,n){return this._def(hn.varKinds.const,e,r,n)}let(e,r,n){return this._def(hn.varKinds.let,e,r,n)}var(e,r,n){return this._def(hn.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new Uc(e,r,n))}add(e,r){return this._leafNode(new lh(e,at.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==ht.nil&&this._leafNode(new hh(e)),this}object(...e){let r=["{"];for(let[n,s]of e)r.length>1&&r.push(","),r.push(n),(n!==s||this.opts.es5)&&(r.push(":"),(0,ht.addCodeArg)(r,s));return r.push("}"),new ht._Code(r)}if(e,r,n){if(this._blockNode(new Us(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new Us(e))}else(){return this._elseNode(new Ao)}endIf(){return this._endBlockNode(Us,Ao)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new mh(e),r)}forRange(e,r,n,s,o=this.opts.es5?hn.varKinds.var:hn.varKinds.let){let i=this._scope.toName(e);return this._for(new gh(o,i,r,n),()=>s(i))}forOf(e,r,n,s=hn.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let i=r instanceof ht.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,ht._)`${i}.length`,a=>{this.var(o,(0,ht._)`${i}[${a}]`),n(o)})}return this._for(new Gc("of",s,o,r),()=>n(o))}forIn(e,r,n,s=this.opts.es5?hn.varKinds.var:hn.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,ht._)`Object.keys(${r})`,n);let o=this._scope.toName(e);return this._for(new Gc("in",s,o,r),()=>n(o))}endFor(){return this._endBlockNode(Gs)}label(e){return this._leafNode(new uh(e))}break(e){return this._leafNode(new dh(e))}return(e){let r=new Qi;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Qi)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let s=new _h;if(this._blockNode(s),this.code(e),r){let o=this.name("e");this._currNode=s.catch=new ea(o),r(o)}return n&&(this._currNode=s.finally=new ta,this.code(n)),this._endBlockNode(ea,ta)}throw(e){return this._leafNode(new fh(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=ht.nil,n,s){return this._blockNode(new Ji(e,r,n)),s&&this.code(s).endFunc(),this}endFunc(){return this._endBlockNode(Ji)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof Us))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};at.CodeGen=bh;function Ys(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function Yc(t,e){return e instanceof ht._CodeOrName?Ys(t,e.names):t}function No(t,e,r){if(t instanceof ht.Name)return n(t);if(!s(t))return t;return new ht._Code(t._items.reduce((o,i)=>(i instanceof ht.Name&&(i=n(i)),i instanceof ht._Code?o.push(...i._items):o.push(i),o),[]));function n(o){let i=r[o.str];return i===void 0||e[o.str]!==1?o:(delete e[o.str],i)}function s(o){return o instanceof ht._Code&&o._items.some(i=>i instanceof ht.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function iS(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function S_(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,ht._)`!${yh(t)}`}at.not=S_;var aS=E_(at.operators.AND);function cS(...t){return t.reduce(aS)}at.and=cS;var lS=E_(at.operators.OR);function uS(...t){return t.reduce(lS)}at.or=uS;function E_(t){return(e,r)=>e===ht.nil?r:r===ht.nil?e:(0,ht._)`${yh(e)} ${t} ${yh(r)}`}function yh(t){return t instanceof ht.Name?t:(0,ht._)`(${t})`}});var mt=Ie(ct=>{"use strict";Object.defineProperty(ct,"__esModule",{value:!0});ct.checkStrictMode=ct.getErrorPath=ct.Type=ct.useFunc=ct.setEvaluated=ct.evaluatedPropsToName=ct.mergeEvaluated=ct.eachItem=ct.unescapeJsonPointer=ct.escapeJsonPointer=ct.escapeFragment=ct.unescapeFragment=ct.schemaRefOrVal=ct.schemaHasRulesButRef=ct.schemaHasRules=ct.checkUnknownRules=ct.alwaysValidSchema=ct.toHash=void 0;var Et=it(),dS=Wi();function fS(t){let e={};for(let r of t)e[r]=!0;return e}ct.toHash=fS;function hS(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(R_(t,e),!P_(e,t.self.RULES.all))}ct.alwaysValidSchema=hS;function R_(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let s=n.RULES.keywords;for(let o in e)s[o]||I_(t,`unknown keyword: "${o}"`)}ct.checkUnknownRules=R_;function P_(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}ct.schemaHasRules=P_;function pS(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}ct.schemaHasRulesButRef=pS;function mS({topSchemaRef:t,schemaPath:e},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,Et._)`${r}`}return(0,Et._)`${t}${e}${(0,Et.getProperty)(n)}`}ct.schemaRefOrVal=mS;function gS(t){return M_(decodeURIComponent(t))}ct.unescapeFragment=gS;function _S(t){return encodeURIComponent(wh(t))}ct.escapeFragment=_S;function wh(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}ct.escapeJsonPointer=wh;function M_(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}ct.unescapeJsonPointer=M_;function bS(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}ct.eachItem=bS;function T_({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(s,o,i,a)=>{let c=i===void 0?o:i instanceof Et.Name?(o instanceof Et.Name?t(s,o,i):e(s,o,i),i):o instanceof Et.Name?(e(s,i,o),o):r(o,i);return a===Et.Name&&!(c instanceof Et.Name)?n(s,c):c}}ct.mergeEvaluated={props:T_({mergeNames:(t,e,r)=>t.if((0,Et._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,Et._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,Et._)`${r} || {}`).code((0,Et._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,Et._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,Et._)`${r} || {}`),xh(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:z_}),items:T_({mergeNames:(t,e,r)=>t.if((0,Et._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,Et._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,Et._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,Et._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function z_(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,Et._)`{}`);return e!==void 0&&xh(t,r,e),r}ct.evaluatedPropsToName=z_;function xh(t,e,r){Object.keys(r).forEach(n=>t.assign((0,Et._)`${e}${(0,Et.getProperty)(n)}`,!0))}ct.setEvaluated=xh;var $_={};function yS(t,e){return t.scopeValue("func",{ref:e,code:$_[e.code]||($_[e.code]=new dS._Code(e.code))})}ct.useFunc=yS;var vh;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(vh||(ct.Type=vh={}));function vS(t,e,r){if(t instanceof Et.Name){let n=e===vh.Num;return r?n?(0,Et._)`"[" + ${t} + "]"`:(0,Et._)`"['" + ${t} + "']"`:n?(0,Et._)`"/" + ${t}`:(0,Et._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,Et.getProperty)(t).toString():"/"+wh(t)}ct.getErrorPath=vS;function I_(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}ct.checkStrictMode=I_});var qn=Ie(kh=>{"use strict";Object.defineProperty(kh,"__esModule",{value:!0});var lr=it(),wS={data:new lr.Name("data"),valCxt:new lr.Name("valCxt"),instancePath:new lr.Name("instancePath"),parentData:new lr.Name("parentData"),parentDataProperty:new lr.Name("parentDataProperty"),rootData:new lr.Name("rootData"),dynamicAnchors:new lr.Name("dynamicAnchors"),vErrors:new lr.Name("vErrors"),errors:new lr.Name("errors"),this:new lr.Name("this"),self:new lr.Name("self"),scope:new lr.Name("scope"),json:new lr.Name("json"),jsonPos:new lr.Name("jsonPos"),jsonLen:new lr.Name("jsonLen"),jsonPart:new lr.Name("jsonPart")};kh.default=wS});var ra=Ie(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});ur.extendErrors=ur.resetErrorsCount=ur.reportExtraError=ur.reportError=ur.keyword$DataError=ur.keywordError=void 0;var gt=it(),Wc=mt(),gr=qn();ur.keywordError={message:({keyword:t})=>(0,gt.str)`must pass "${t}" keyword validation`};ur.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,gt.str)`"${t}" keyword must be ${e} ($data)`:(0,gt.str)`"${t}" keyword is invalid ($data)`};function xS(t,e=ur.keywordError,r,n){let{it:s}=t,{gen:o,compositeRule:i,allErrors:a}=s,c=N_(t,e,r);n??(i||a)?O_(o,c):A_(s,(0,gt._)`[${c}]`)}ur.reportError=xS;function kS(t,e=ur.keywordError,r){let{it:n}=t,{gen:s,compositeRule:o,allErrors:i}=n,a=N_(t,e,r);O_(s,a),o||i||A_(n,gr.default.vErrors)}ur.reportExtraError=kS;function SS(t,e){t.assign(gr.default.errors,e),t.if((0,gt._)`${gr.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,gt._)`${gr.default.vErrors}.length`,e),()=>t.assign(gr.default.vErrors,null)))}ur.resetErrorsCount=SS;function ES({gen:t,keyword:e,schemaValue:r,data:n,errsCount:s,it:o}){if(s===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",s,gr.default.errors,a=>{t.const(i,(0,gt._)`${gr.default.vErrors}[${a}]`),t.if((0,gt._)`${i}.instancePath === undefined`,()=>t.assign((0,gt._)`${i}.instancePath`,(0,gt.strConcat)(gr.default.instancePath,o.errorPath))),t.assign((0,gt._)`${i}.schemaPath`,(0,gt.str)`${o.errSchemaPath}/${e}`),o.opts.verbose&&(t.assign((0,gt._)`${i}.schema`,r),t.assign((0,gt._)`${i}.data`,n))})}ur.extendErrors=ES;function O_(t,e){let r=t.const("err",e);t.if((0,gt._)`${gr.default.vErrors} === null`,()=>t.assign(gr.default.vErrors,(0,gt._)`[${r}]`),(0,gt._)`${gr.default.vErrors}.push(${r})`),t.code((0,gt._)`${gr.default.errors}++`)}function A_(t,e){let{gen:r,validateName:n,schemaEnv:s}=t;s.$async?r.throw((0,gt._)`new ${t.ValidationError}(${e})`):(r.assign((0,gt._)`${n}.errors`,e),r.return(!1))}var Xs={keyword:new gt.Name("keyword"),schemaPath:new gt.Name("schemaPath"),params:new gt.Name("params"),propertyName:new gt.Name("propertyName"),message:new gt.Name("message"),schema:new gt.Name("schema"),parentSchema:new gt.Name("parentSchema")};function N_(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,gt._)`{}`:TS(t,e,r)}function TS(t,e,r={}){let{gen:n,it:s}=t,o=[$S(s,r),RS(t,r)];return PS(t,e,o),n.object(...o)}function $S({errorPath:t},{instancePath:e}){let r=e?(0,gt.str)`${t}${(0,Wc.getErrorPath)(e,Wc.Type.Str)}`:t;return[gr.default.instancePath,(0,gt.strConcat)(gr.default.instancePath,r)]}function RS({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let s=n?e:(0,gt.str)`${e}/${t}`;return r&&(s=(0,gt.str)`${s}${(0,Wc.getErrorPath)(r,Wc.Type.Str)}`),[Xs.schemaPath,s]}function PS(t,{params:e,message:r},n){let{keyword:s,data:o,schemaValue:i,it:a}=t,{opts:c,propertyName:d,topSchemaRef:l,schemaPath:u}=a;n.push([Xs.keyword,s],[Xs.params,typeof e=="function"?e(t):e||(0,gt._)`{}`]),c.messages&&n.push([Xs.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([Xs.schema,i],[Xs.parentSchema,(0,gt._)`${l}${u}`],[gr.default.data,o]),d&&n.push([Xs.propertyName,d])}});var j_=Ie(Co=>{"use strict";Object.defineProperty(Co,"__esModule",{value:!0});Co.boolOrEmptySchema=Co.topBoolOrEmptySchema=void 0;var MS=ra(),zS=it(),IS=qn(),OS={message:"boolean schema is false"};function AS(t){let{gen:e,schema:r,validateName:n}=t;r===!1?C_(t,!1):typeof r=="object"&&r.$async===!0?e.return(IS.default.data):(e.assign((0,zS._)`${n}.errors`,null),e.return(!0))}Co.topBoolOrEmptySchema=AS;function NS(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),C_(t)):r.var(e,!0)}Co.boolOrEmptySchema=NS;function C_(t,e){let{gen:r,data:n}=t,s={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,MS.reportError)(s,OS,void 0,e)}});var Sh=Ie(jo=>{"use strict";Object.defineProperty(jo,"__esModule",{value:!0});jo.getRules=jo.isJSONType=void 0;var CS=["string","number","integer","boolean","null","object","array"],jS=new Set(CS);function DS(t){return typeof t=="string"&&jS.has(t)}jo.isJSONType=DS;function LS(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}jo.getRules=LS});var Eh=Ie(ss=>{"use strict";Object.defineProperty(ss,"__esModule",{value:!0});ss.shouldUseRule=ss.shouldUseGroup=ss.schemaHasRulesForType=void 0;function ZS({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&D_(t,n)}ss.schemaHasRulesForType=ZS;function D_(t,e){return e.rules.some(r=>L_(t,r))}ss.shouldUseGroup=D_;function L_(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}ss.shouldUseRule=L_});var na=Ie(dr=>{"use strict";Object.defineProperty(dr,"__esModule",{value:!0});dr.reportTypeError=dr.checkDataTypes=dr.checkDataType=dr.coerceAndCheckDataType=dr.getJSONTypes=dr.getSchemaTypes=dr.DataType=void 0;var BS=Sh(),qS=Eh(),VS=ra(),st=it(),Z_=mt(),Do;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(Do||(dr.DataType=Do={}));function FS(t){let e=B_(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}dr.getSchemaTypes=FS;function B_(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(BS.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}dr.getJSONTypes=B_;function HS(t,e){let{gen:r,data:n,opts:s}=t,o=US(e,s.coerceTypes),i=e.length>0&&!(o.length===0&&e.length===1&&(0,qS.schemaHasRulesForType)(t,e[0]));if(i){let a=$h(e,n,s.strictNumbers,Do.Wrong);r.if(a,()=>{o.length?GS(t,e,o):Rh(t)})}return i}dr.coerceAndCheckDataType=HS;var q_=new Set(["string","number","integer","boolean","null"]);function US(t,e){return e?t.filter(r=>q_.has(r)||e==="array"&&r==="array"):[]}function GS(t,e,r){let{gen:n,data:s,opts:o}=t,i=n.let("dataType",(0,st._)`typeof ${s}`),a=n.let("coerced",(0,st._)`undefined`);o.coerceTypes==="array"&&n.if((0,st._)`${i} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,st._)`${s}[0]`).assign(i,(0,st._)`typeof ${s}`).if($h(e,s,o.strictNumbers),()=>n.assign(a,s))),n.if((0,st._)`${a} !== undefined`);for(let d of r)(q_.has(d)||d==="array"&&o.coerceTypes==="array")&&c(d);n.else(),Rh(t),n.endIf(),n.if((0,st._)`${a} !== undefined`,()=>{n.assign(s,a),YS(t,a)});function c(d){switch(d){case"string":n.elseIf((0,st._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,st._)`"" + ${s}`).elseIf((0,st._)`${s} === null`).assign(a,(0,st._)`""`);return;case"number":n.elseIf((0,st._)`${i} == "boolean" || ${s} === null
4
- || (${i} == "string" && ${s} && ${s} == +${s})`).assign(a,(0,st._)`+${s}`);return;case"integer":n.elseIf((0,st._)`${i} === "boolean" || ${s} === null
5
- || (${i} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(a,(0,st._)`+${s}`);return;case"boolean":n.elseIf((0,st._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(a,!1).elseIf((0,st._)`${s} === "true" || ${s} === 1`).assign(a,!0);return;case"null":n.elseIf((0,st._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(a,null);return;case"array":n.elseIf((0,st._)`${i} === "string" || ${i} === "number"
6
- || ${i} === "boolean" || ${s} === null`).assign(a,(0,st._)`[${s}]`)}}}function YS({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,st._)`${e} !== undefined`,()=>t.assign((0,st._)`${e}[${r}]`,n))}function Th(t,e,r,n=Do.Correct){let s=n===Do.Correct?st.operators.EQ:st.operators.NEQ,o;switch(t){case"null":return(0,st._)`${e} ${s} null`;case"array":o=(0,st._)`Array.isArray(${e})`;break;case"object":o=(0,st._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":o=i((0,st._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":o=i();break;default:return(0,st._)`typeof ${e} ${s} ${t}`}return n===Do.Correct?o:(0,st.not)(o);function i(a=st.nil){return(0,st.and)((0,st._)`typeof ${e} == "number"`,a,r?(0,st._)`isFinite(${e})`:st.nil)}}dr.checkDataType=Th;function $h(t,e,r,n){if(t.length===1)return Th(t[0],e,r,n);let s,o=(0,Z_.toHash)(t);if(o.array&&o.object){let i=(0,st._)`typeof ${e} != "object"`;s=o.null?i:(0,st._)`!${e} || ${i}`,delete o.null,delete o.array,delete o.object}else s=st.nil;o.number&&delete o.integer;for(let i in o)s=(0,st.and)(s,Th(i,e,r,n));return s}dr.checkDataTypes=$h;var XS={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,st._)`{type: ${t}}`:(0,st._)`{type: ${e}}`};function Rh(t){let e=WS(t);(0,VS.reportError)(e,XS)}dr.reportTypeError=Rh;function WS(t){let{gen:e,data:r,schema:n}=t,s=(0,Z_.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:t}}});var F_=Ie(Kc=>{"use strict";Object.defineProperty(Kc,"__esModule",{value:!0});Kc.assignDefaults=void 0;var Lo=it(),KS=mt();function JS(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let s in r)V_(t,s,r[s].default);else e==="array"&&Array.isArray(n)&&n.forEach((s,o)=>V_(t,o,s.default))}Kc.assignDefaults=JS;function V_(t,e,r){let{gen:n,compositeRule:s,data:o,opts:i}=t;if(r===void 0)return;let a=(0,Lo._)`${o}${(0,Lo.getProperty)(e)}`;if(s){(0,KS.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,Lo._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Lo._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Lo._)`${a} = ${(0,Lo.stringify)(r)}`)}});var Kr=Ie(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});kt.validateUnion=kt.validateArray=kt.usePattern=kt.callValidateCode=kt.schemaProperties=kt.allSchemaProperties=kt.noPropertyInData=kt.propertyInData=kt.isOwnProperty=kt.hasPropFunc=kt.reportMissingProp=kt.checkMissingProp=kt.checkReportMissingProp=void 0;var zt=it(),Ph=mt(),os=qn(),QS=mt();function e9(t,e){let{gen:r,data:n,it:s}=t;r.if(zh(r,n,e,s.opts.ownProperties),()=>{t.setParams({missingProperty:(0,zt._)`${e}`},!0),t.error()})}kt.checkReportMissingProp=e9;function t9({gen:t,data:e,it:{opts:r}},n,s){return(0,zt.or)(...n.map(o=>(0,zt.and)(zh(t,e,o,r.ownProperties),(0,zt._)`${s} = ${o}`)))}kt.checkMissingProp=t9;function r9(t,e){t.setParams({missingProperty:e},!0),t.error()}kt.reportMissingProp=r9;function H_(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,zt._)`Object.prototype.hasOwnProperty`})}kt.hasPropFunc=H_;function Mh(t,e,r){return(0,zt._)`${H_(t)}.call(${e}, ${r})`}kt.isOwnProperty=Mh;function n9(t,e,r,n){let s=(0,zt._)`${e}${(0,zt.getProperty)(r)} !== undefined`;return n?(0,zt._)`${s} && ${Mh(t,e,r)}`:s}kt.propertyInData=n9;function zh(t,e,r,n){let s=(0,zt._)`${e}${(0,zt.getProperty)(r)} === undefined`;return n?(0,zt.or)(s,(0,zt.not)(Mh(t,e,r))):s}kt.noPropertyInData=zh;function U_(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}kt.allSchemaProperties=U_;function s9(t,e){return U_(e).filter(r=>!(0,Ph.alwaysValidSchema)(t,e[r]))}kt.schemaProperties=s9;function o9({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:i},a,c,d){let l=d?(0,zt._)`${t}, ${e}, ${n}${s}`:e,u=[[os.default.instancePath,(0,zt.strConcat)(os.default.instancePath,o)],[os.default.parentData,i.parentData],[os.default.parentDataProperty,i.parentDataProperty],[os.default.rootData,os.default.rootData]];i.opts.dynamicRef&&u.push([os.default.dynamicAnchors,os.default.dynamicAnchors]);let h=(0,zt._)`${l}, ${r.object(...u)}`;return c!==zt.nil?(0,zt._)`${a}.call(${c}, ${h})`:(0,zt._)`${a}(${h})`}kt.callValidateCode=o9;var i9=(0,zt._)`new RegExp`;function a9({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:s}=e.code,o=s(r,n);return t.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,zt._)`${s.code==="new RegExp"?i9:(0,QS.useFunc)(t,s)}(${r}, ${n})`})}kt.usePattern=a9;function c9(t){let{gen:e,data:r,keyword:n,it:s}=t,o=e.name("valid");if(s.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(o,!0),i(()=>e.break()),o;function i(a){let c=e.const("len",(0,zt._)`${r}.length`);e.forRange("i",0,c,d=>{t.subschema({keyword:n,dataProp:d,dataPropType:Ph.Type.Num},o),e.if((0,zt.not)(o),a)})}}kt.validateArray=c9;function l9(t){let{gen:e,schema:r,keyword:n,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Ph.alwaysValidSchema)(s,c))&&!s.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,d)=>{let l=t.subschema({keyword:n,schemaProp:d,compositeRule:!0},a);e.assign(i,(0,zt._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,zt.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}kt.validateUnion=l9});var X_=Ie(Rn=>{"use strict";Object.defineProperty(Rn,"__esModule",{value:!0});Rn.validateKeywordUsage=Rn.validSchemaType=Rn.funcKeywordCode=Rn.macroKeywordCode=void 0;var _r=it(),Ws=qn(),u9=Kr(),d9=ra();function f9(t,e){let{gen:r,keyword:n,schema:s,parentSchema:o,it:i}=t,a=e.macro.call(i.self,s,o,i),c=Y_(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let d=r.name("valid");t.subschema({schema:a,schemaPath:_r.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},d),t.pass(d,()=>t.error(!0))}Rn.macroKeywordCode=f9;function h9(t,e){var r;let{gen:n,keyword:s,schema:o,parentSchema:i,$data:a,it:c}=t;m9(c,e);let d=!a&&e.compile?e.compile.call(c.self,o,i,c):e.validate,l=Y_(n,s,d),u=n.let("valid");t.block$data(u,h),t.ok((r=e.valid)!==null&&r!==void 0?r:u);function h(){if(e.errors===!1)x(),e.modifying&&G_(t),S(()=>t.error());else{let k=e.async?p():g();e.modifying&&G_(t),S(()=>p9(t,k))}}function p(){let k=n.let("ruleErrs",null);return n.try(()=>x((0,_r._)`await `),_=>n.assign(u,!1).if((0,_r._)`${_} instanceof ${c.ValidationError}`,()=>n.assign(k,(0,_r._)`${_}.errors`),()=>n.throw(_))),k}function g(){let k=(0,_r._)`${l}.errors`;return n.assign(k,null),x(_r.nil),k}function x(k=e.async?(0,_r._)`await `:_r.nil){let _=c.opts.passContext?Ws.default.this:Ws.default.self,m=!("compile"in e&&!a||e.schema===!1);n.assign(u,(0,_r._)`${k}${(0,u9.callValidateCode)(t,l,_,m)}`,e.modifying)}function S(k){var _;n.if((0,_r.not)((_=e.valid)!==null&&_!==void 0?_:u),k)}}Rn.funcKeywordCode=h9;function G_(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,_r._)`${n.parentData}[${n.parentDataProperty}]`))}function p9(t,e){let{gen:r}=t;r.if((0,_r._)`Array.isArray(${e})`,()=>{r.assign(Ws.default.vErrors,(0,_r._)`${Ws.default.vErrors} === null ? ${e} : ${Ws.default.vErrors}.concat(${e})`).assign(Ws.default.errors,(0,_r._)`${Ws.default.vErrors}.length`),(0,d9.extendErrors)(t)},()=>t.error())}function m9({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Y_(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,_r.stringify)(r)})}function g9(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}Rn.validSchemaType=g9;function _9({schema:t,opts:e,self:r,errSchemaPath:n},s,o){if(Array.isArray(s.keyword)?!s.keyword.includes(o):s.keyword!==o)throw new Error("ajv implementation error");let i=s.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${o}: ${i.join(",")}`);if(s.validateSchema&&!s.validateSchema(t[o])){let c=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}Rn.validateKeywordUsage=_9});var K_=Ie(is=>{"use strict";Object.defineProperty(is,"__esModule",{value:!0});is.extendSubschemaMode=is.extendSubschemaData=is.getSubschema=void 0;var Pn=it(),W_=mt();function b9(t,{keyword:e,schemaProp:r,schema:n,schemaPath:s,errSchemaPath:o,topSchemaRef:i}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,Pn._)`${t.schemaPath}${(0,Pn.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,Pn._)`${t.schemaPath}${(0,Pn.getProperty)(e)}${(0,Pn.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,W_.escapeFragment)(r)}`}}if(n!==void 0){if(s===void 0||o===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:s,topSchemaRef:i,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}is.getSubschema=b9;function y9(t,e,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:i}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:d,dataPathArr:l,opts:u}=e,h=a.let("data",(0,Pn._)`${e.data}${(0,Pn.getProperty)(r)}`,!0);c(h),t.errorPath=(0,Pn.str)`${d}${(0,W_.getErrorPath)(r,n,u.jsPropertySyntax)}`,t.parentDataProperty=(0,Pn._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(s!==void 0){let d=s instanceof Pn.Name?s:a.let("data",s,!0);c(d),i!==void 0&&(t.propertyName=i)}o&&(t.dataTypes=o);function c(d){t.data=d,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,d]}}is.extendSubschemaData=y9;function v9(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:o}){n!==void 0&&(t.compositeRule=n),s!==void 0&&(t.createErrors=s),o!==void 0&&(t.allErrors=o),t.jtdDiscriminator=e,t.jtdMetadata=r}is.extendSubschemaMode=v9});var Ih=Ie((tL,J_)=>{"use strict";J_.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,s,o;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(s=n;s--!==0;)if(!t(e[s],r[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(o=Object.keys(e),n=o.length,n!==Object.keys(r).length)return!1;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[s]))return!1;for(s=n;s--!==0;){var i=o[s];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}});var e2=Ie((rL,Q_)=>{"use strict";var as=Q_.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},s=r.post||function(){};Jc(e,n,s,t,"",t)};as.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};as.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};as.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};as.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Jc(t,e,r,n,s,o,i,a,c,d){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,s,o,i,a,c,d);for(var l in n){var u=n[l];if(Array.isArray(u)){if(l in as.arrayKeywords)for(var h=0;h<u.length;h++)Jc(t,e,r,u[h],s+"/"+l+"/"+h,o,s,l,n,h)}else if(l in as.propsKeywords){if(u&&typeof u=="object")for(var p in u)Jc(t,e,r,u[p],s+"/"+l+"/"+w9(p),o,s,l,n,p)}else(l in as.keywords||t.allKeys&&!(l in as.skipKeywords))&&Jc(t,e,r,u,s+"/"+l,o,s,l,n)}r(n,s,o,i,a,c,d)}}function w9(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var sa=Ie($r=>{"use strict";Object.defineProperty($r,"__esModule",{value:!0});$r.getSchemaRefs=$r.resolveUrl=$r.normalizeId=$r._getFullPath=$r.getFullPath=$r.inlineRef=void 0;var x9=mt(),k9=Ih(),S9=e2(),E9=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function T9(t,e=!0){return typeof t=="boolean"?!0:e===!0?!Oh(t):e?t2(t)<=e:!1}$r.inlineRef=T9;var $9=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Oh(t){for(let e in t){if($9.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(Oh)||typeof r=="object"&&Oh(r))return!0}return!1}function t2(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!E9.has(r)&&(typeof t[r]=="object"&&(0,x9.eachItem)(t[r],n=>e+=t2(n)),e===1/0))return 1/0}return e}function r2(t,e="",r){r!==!1&&(e=Zo(e));let n=t.parse(e);return n2(t,n)}$r.getFullPath=r2;function n2(t,e){return t.serialize(e).split("#")[0]+"#"}$r._getFullPath=n2;var R9=/#\/?$/;function Zo(t){return t?t.replace(R9,""):""}$r.normalizeId=Zo;function P9(t,e,r){return r=Zo(r),t.resolve(e,r)}$r.resolveUrl=P9;var M9=/^[a-z_][-a-z0-9._]*$/i;function z9(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,s=Zo(t[r]||e),o={"":s},i=r2(n,s,!1),a={},c=new Set;return S9(t,{allKeys:!0},(u,h,p,g)=>{if(g===void 0)return;let x=i+h,S=o[g];typeof u[r]=="string"&&(S=k.call(this,u[r])),_.call(this,u.$anchor),_.call(this,u.$dynamicAnchor),o[h]=S;function k(m){let $=this.opts.uriResolver.resolve;if(m=Zo(S?$(S,m):m),c.has(m))throw l(m);c.add(m);let f=this.refs[m];return typeof f=="string"&&(f=this.refs[f]),typeof f=="object"?d(u,f.schema,m):m!==Zo(x)&&(m[0]==="#"?(d(u,a[m],m),a[m]=u):this.refs[m]=x),m}function _(m){if(typeof m=="string"){if(!M9.test(m))throw new Error(`invalid anchor "${m}"`);k.call(this,`#${m}`)}}}),a;function d(u,h,p){if(h!==void 0&&!k9(u,h))throw l(p)}function l(u){return new Error(`reference "${u}" resolves to more than one schema`)}}$r.getSchemaRefs=z9});var aa=Ie(cs=>{"use strict";Object.defineProperty(cs,"__esModule",{value:!0});cs.getData=cs.KeywordCxt=cs.validateFunctionCode=void 0;var c2=j_(),s2=na(),Nh=Eh(),Qc=na(),I9=F_(),ia=X_(),Ah=K_(),Fe=it(),Je=qn(),O9=sa(),Vn=mt(),oa=ra();function A9(t){if(d2(t)&&(f2(t),u2(t))){j9(t);return}l2(t,()=>(0,c2.topBoolOrEmptySchema)(t))}cs.validateFunctionCode=A9;function l2({gen:t,validateName:e,schema:r,schemaEnv:n,opts:s},o){s.code.es5?t.func(e,(0,Fe._)`${Je.default.data}, ${Je.default.valCxt}`,n.$async,()=>{t.code((0,Fe._)`"use strict"; ${o2(r,s)}`),C9(t,s),t.code(o)}):t.func(e,(0,Fe._)`${Je.default.data}, ${N9(s)}`,n.$async,()=>t.code(o2(r,s)).code(o))}function N9(t){return(0,Fe._)`{${Je.default.instancePath}="", ${Je.default.parentData}, ${Je.default.parentDataProperty}, ${Je.default.rootData}=${Je.default.data}${t.dynamicRef?(0,Fe._)`, ${Je.default.dynamicAnchors}={}`:Fe.nil}}={}`}function C9(t,e){t.if(Je.default.valCxt,()=>{t.var(Je.default.instancePath,(0,Fe._)`${Je.default.valCxt}.${Je.default.instancePath}`),t.var(Je.default.parentData,(0,Fe._)`${Je.default.valCxt}.${Je.default.parentData}`),t.var(Je.default.parentDataProperty,(0,Fe._)`${Je.default.valCxt}.${Je.default.parentDataProperty}`),t.var(Je.default.rootData,(0,Fe._)`${Je.default.valCxt}.${Je.default.rootData}`),e.dynamicRef&&t.var(Je.default.dynamicAnchors,(0,Fe._)`${Je.default.valCxt}.${Je.default.dynamicAnchors}`)},()=>{t.var(Je.default.instancePath,(0,Fe._)`""`),t.var(Je.default.parentData,(0,Fe._)`undefined`),t.var(Je.default.parentDataProperty,(0,Fe._)`undefined`),t.var(Je.default.rootData,Je.default.data),e.dynamicRef&&t.var(Je.default.dynamicAnchors,(0,Fe._)`{}`)})}function j9(t){let{schema:e,opts:r,gen:n}=t;l2(t,()=>{r.$comment&&e.$comment&&p2(t),q9(t),n.let(Je.default.vErrors,null),n.let(Je.default.errors,0),r.unevaluated&&D9(t),h2(t),H9(t)})}function D9(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,Fe._)`${r}.evaluated`),e.if((0,Fe._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,Fe._)`${t.evaluated}.props`,(0,Fe._)`undefined`)),e.if((0,Fe._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,Fe._)`${t.evaluated}.items`,(0,Fe._)`undefined`))}function o2(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,Fe._)`/*# sourceURL=${r} */`:Fe.nil}function L9(t,e){if(d2(t)&&(f2(t),u2(t))){Z9(t,e);return}(0,c2.boolOrEmptySchema)(t,e)}function u2({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function d2(t){return typeof t.schema!="boolean"}function Z9(t,e){let{schema:r,gen:n,opts:s}=t;s.$comment&&r.$comment&&p2(t),V9(t),F9(t);let o=n.const("_errs",Je.default.errors);h2(t,o),n.var(e,(0,Fe._)`${o} === ${Je.default.errors}`)}function f2(t){(0,Vn.checkUnknownRules)(t),B9(t)}function h2(t,e){if(t.opts.jtd)return i2(t,[],!1,e);let r=(0,s2.getSchemaTypes)(t.schema),n=(0,s2.coerceAndCheckDataType)(t,r);i2(t,r,!n,e)}function B9(t){let{schema:e,errSchemaPath:r,opts:n,self:s}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Vn.schemaHasRulesButRef)(e,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function q9(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Vn.checkStrictMode)(t,"default is ignored in the schema root")}function V9(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,O9.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function F9(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function p2({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:s}){let o=r.$comment;if(s.$comment===!0)t.code((0,Fe._)`${Je.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){let i=(0,Fe.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,Fe._)`${Je.default.self}.opts.$comment(${o}, ${i}, ${a}.schema)`)}}function H9(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=t;r.$async?e.if((0,Fe._)`${Je.default.errors} === 0`,()=>e.return(Je.default.data),()=>e.throw((0,Fe._)`new ${s}(${Je.default.vErrors})`)):(e.assign((0,Fe._)`${n}.errors`,Je.default.vErrors),o.unevaluated&&U9(t),e.return((0,Fe._)`${Je.default.errors} === 0`))}function U9({gen:t,evaluated:e,props:r,items:n}){r instanceof Fe.Name&&t.assign((0,Fe._)`${e}.props`,r),n instanceof Fe.Name&&t.assign((0,Fe._)`${e}.items`,n)}function i2(t,e,r,n){let{gen:s,schema:o,data:i,allErrors:a,opts:c,self:d}=t,{RULES:l}=d;if(o.$ref&&(c.ignoreKeywordsWithRef||!(0,Vn.schemaHasRulesButRef)(o,l))){s.block(()=>g2(t,"$ref",l.all.$ref.definition));return}c.jtd||G9(t,e),s.block(()=>{for(let h of l.rules)u(h);u(l.post)});function u(h){(0,Nh.shouldUseGroup)(o,h)&&(h.type?(s.if((0,Qc.checkDataType)(h.type,i,c.strictNumbers)),a2(t,h),e.length===1&&e[0]===h.type&&r&&(s.else(),(0,Qc.reportTypeError)(t)),s.endIf()):a2(t,h),a||s.if((0,Fe._)`${Je.default.errors} === ${n||0}`))}}function a2(t,e){let{gen:r,schema:n,opts:{useDefaults:s}}=t;s&&(0,I9.assignDefaults)(t,e.type),r.block(()=>{for(let o of e.rules)(0,Nh.shouldUseRule)(n,o)&&g2(t,o.keyword,o.definition,e.type)})}function G9(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(Y9(t,e),t.opts.allowUnionTypes||X9(t,e),W9(t,t.dataTypes))}function Y9(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{m2(t.dataTypes,r)||Ch(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),J9(t,e)}}function X9(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&Ch(t,"use allowUnionTypes to allow union type keyword")}function W9(t,e){let r=t.self.RULES.all;for(let n in r){let s=r[n];if(typeof s=="object"&&(0,Nh.shouldUseRule)(t.schema,s)){let{type:o}=s.definition;o.length&&!o.some(i=>K9(e,i))&&Ch(t,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function K9(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function m2(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function J9(t,e){let r=[];for(let n of t.dataTypes)m2(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function Ch(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Vn.checkStrictMode)(t,e,t.opts.strictTypes)}var el=class{constructor(e,r,n){if((0,ia.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Vn.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",_2(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,ia.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",Je.default.errors))}result(e,r,n){this.failResult((0,Fe.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,Fe.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,Fe._)`${r} !== undefined && (${(0,Fe.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?oa.reportExtraError:oa.reportError)(this,this.def.error,r)}$dataError(){(0,oa.reportError)(this,this.def.$dataError||oa.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,oa.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=Fe.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=Fe.nil,r=Fe.nil){if(!this.$data)return;let{gen:n,schemaCode:s,schemaType:o,def:i}=this;n.if((0,Fe.or)((0,Fe._)`${s} === undefined`,r)),e!==Fe.nil&&n.assign(e,!0),(o.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==Fe.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,Fe.or)(i(),a());function i(){if(n.length){if(!(r instanceof Fe.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,Fe._)`${(0,Qc.checkDataTypes)(c,r,o.opts.strictNumbers,Qc.DataType.Wrong)}`}return Fe.nil}function a(){if(s.validateSchema){let c=e.scopeValue("validate$data",{ref:s.validateSchema});return(0,Fe._)`!${c}(${r})`}return Fe.nil}}subschema(e,r){let n=(0,Ah.getSubschema)(this.it,e);(0,Ah.extendSubschemaData)(n,this.it,e),(0,Ah.extendSubschemaMode)(n,e);let s={...this.it,...n,items:void 0,props:void 0};return L9(s,r),s}mergeEvaluated(e,r){let{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Vn.mergeEvaluated.props(s,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Vn.mergeEvaluated.items(s,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return s.if(r,()=>this.mergeEvaluated(e,Fe.Name)),!0}};cs.KeywordCxt=el;function g2(t,e,r,n){let s=new el(t,r,e);"code"in r?r.code(s,n):s.$data&&r.validate?(0,ia.funcKeywordCode)(s,r):"macro"in r?(0,ia.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,ia.funcKeywordCode)(s,r)}var Q9=/^\/(?:[^~]|~0|~1)*$/,e8=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function _2(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let s,o;if(t==="")return Je.default.rootData;if(t[0]==="/"){if(!Q9.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);s=t,o=Je.default.rootData}else{let d=e8.exec(t);if(!d)throw new Error(`Invalid JSON-pointer: ${t}`);let l=+d[1];if(s=d[2],s==="#"){if(l>=e)throw new Error(c("property/index",l));return n[e-l]}if(l>e)throw new Error(c("data",l));if(o=r[e-l],!s)return o}let i=o,a=s.split("/");for(let d of a)d&&(o=(0,Fe._)`${o}${(0,Fe.getProperty)((0,Vn.unescapeJsonPointer)(d))}`,i=(0,Fe._)`${i} && ${o}`);return i;function c(d,l){return`Cannot access ${d} ${l} levels up, current level is ${e}`}}cs.getData=_2});var tl=Ie(Dh=>{"use strict";Object.defineProperty(Dh,"__esModule",{value:!0});var jh=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};Dh.default=jh});var ca=Ie(Bh=>{"use strict";Object.defineProperty(Bh,"__esModule",{value:!0});var Lh=sa(),Zh=class extends Error{constructor(e,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Lh.resolveUrl)(e,r,n),this.missingSchema=(0,Lh.normalizeId)((0,Lh.getFullPath)(e,this.missingRef))}};Bh.default=Zh});var nl=Ie(Jr=>{"use strict";Object.defineProperty(Jr,"__esModule",{value:!0});Jr.resolveSchema=Jr.getCompilingSchema=Jr.resolveRef=Jr.compileSchema=Jr.SchemaEnv=void 0;var pn=it(),t8=tl(),Ks=qn(),mn=sa(),b2=mt(),r8=aa(),Bo=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,mn.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};Jr.SchemaEnv=Bo;function Vh(t){let e=y2.call(this,t);if(e)return e;let r=(0,mn.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,i=new pn.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o}),a;t.$async&&(a=i.scopeValue("Error",{ref:t8.default,code:(0,pn._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let d={gen:i,allErrors:this.opts.allErrors,data:Ks.default.data,parentData:Ks.default.parentData,parentDataProperty:Ks.default.parentDataProperty,dataNames:[Ks.default.data],dataPathArr:[pn.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,pn.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:pn.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,pn._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,r8.validateFunctionCode)(d),i.optimize(this.opts.code.optimize);let u=i.toString();l=`${i.scopeRefs(Ks.default.scope)}return ${u}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let p=new Function(`${Ks.default.self}`,`${Ks.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:p}),p.errors=null,p.schema=t.schema,p.schemaEnv=t,t.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:c,validateCode:u,scopeValues:i._values}),this.opts.unevaluated){let{props:g,items:x}=d;p.evaluated={props:g instanceof pn.Name?void 0:g,items:x instanceof pn.Name?void 0:x,dynamicProps:g instanceof pn.Name,dynamicItems:x instanceof pn.Name},p.source&&(p.source.evaluated=(0,pn.stringify)(p.evaluated))}return t.validate=p,t}catch(u){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),u}finally{this._compilations.delete(t)}}Jr.compileSchema=Vh;function n8(t,e,r){var n;r=(0,mn.resolveUrl)(this.opts.uriResolver,e,r);let s=t.refs[r];if(s)return s;let o=i8.call(this,t,r);if(o===void 0){let i=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(o=new Bo({schema:i,schemaId:a,root:t,baseId:e}))}if(o!==void 0)return t.refs[r]=s8.call(this,o)}Jr.resolveRef=n8;function s8(t){return(0,mn.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:Vh.call(this,t)}function y2(t){for(let e of this._compilations)if(o8(e,t))return e}Jr.getCompilingSchema=y2;function o8(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function i8(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||rl.call(this,t,e)}function rl(t,e){let r=this.opts.uriResolver.parse(e),n=(0,mn._getFullPath)(this.opts.uriResolver,r),s=(0,mn.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===s)return qh.call(this,r,t);let o=(0,mn.normalizeId)(n),i=this.refs[o]||this.schemas[o];if(typeof i=="string"){let a=rl.call(this,t,i);return typeof a?.schema!="object"?void 0:qh.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Vh.call(this,i),o===(0,mn.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,d=a[c];return d&&(s=(0,mn.resolveUrl)(this.opts.uriResolver,s,d)),new Bo({schema:a,schemaId:c,root:t,baseId:s})}return qh.call(this,r,i)}}Jr.resolveSchema=rl;var a8=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function qh(t,{baseId:e,schema:r,root:n}){var s;if(((s=t.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,b2.unescapeFragment)(a)];if(c===void 0)return;r=c;let d=typeof r=="object"&&r[this.opts.schemaId];!a8.has(a)&&d&&(e=(0,mn.resolveUrl)(this.opts.uriResolver,e,d))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,b2.schemaHasRulesButRef)(r,this.RULES)){let a=(0,mn.resolveUrl)(this.opts.uriResolver,e,r.$ref);o=rl.call(this,n,a)}let{schemaId:i}=this.opts;if(o=o||new Bo({schema:r,schemaId:i,root:n,baseId:e}),o.schema!==o.root.schema)return o}});var v2=Ie((cL,c8)=>{c8.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var Uh=Ie((lL,T2)=>{"use strict";var l8=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),x2=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),Fh=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),k2=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),u8=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function Hh(t){let e="",r=0,n=0;for(n=0;n<t.length;n++)if(r=t[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n];break}for(n+=1;n<t.length;n++){if(r=t[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n]}return e}var d8=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function w2(t){return t.length=0,!0}function f8(t,e,r){if(t.length){let n=Hh(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function h8(t){let e=0,r={error:!1,address:"",zone:""},n=[],s=[],o=!1,i=!1,a=f8;for(let c=0;c<t.length;c++){let d=t[c];if(!(d==="["||d==="]"))if(d===":"){if(o===!0&&(i=!0),!a(s,n,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(o=!0),n.push(":");continue}else if(d==="%"){if(!a(s,n,r))break;a=w2}else{s.push(d);continue}}return s.length&&(a===w2?r.zone=s.join(""):i?n.push(s.join("")):n.push(Hh(s))),r.address=n.join(""),r}function S2(t){if(p8(t,":")<2)return{host:t,isIPV6:!1};let e=h8(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:n}}}function p8(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function m8(t){let e=t,r=[],n=-1,s=0;for(;s=e.length;){if(s===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(s===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(s===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}var g8={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},_8=/[@/?#:]/g,b8=/[@/?#]/g;function E2(t,e){let r=e?b8:_8;return r.lastIndex=0,t.replace(r,n=>g8[n])}function y8(t,e=!1){if(t.indexOf("%")===-1)return t;let r="";for(let n=0;n<t.length;n++){if(t[n]==="%"&&n+2<t.length){let s=t.slice(n+1,n+3);if(Fh(s)){let o=s.toUpperCase(),i=String.fromCharCode(parseInt(o,16));e&&k2(i)?r+=i:r+="%"+o,n+=2;continue}}r+=t[n]}return r}function v8(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Fh(n)){let s=n.toUpperCase(),o=String.fromCharCode(parseInt(s,16));o!=="."&&k2(o)?e+=o:e+="%"+s,r+=2;continue}}u8(t[r])?e+=t[r]:e+=escape(t[r])}return e}function w8(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Fh(n)){e+="%"+n.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function x8(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!x2(r)){let n=S2(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=E2(r,!1)}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}T2.exports={nonSimpleDomain:d8,recomposeAuthority:x8,reescapeHostDelimiters:E2,normalizePercentEncoding:y8,normalizePathEncoding:v8,escapePreservingEscapes:w8,removeDotSegments:m8,isIPv4:x2,isUUID:l8,normalizeIPv6:S2,stringArrayToHexStripped:Hh}});var z2=Ie((uL,M2)=>{"use strict";var{isUUID:k8}=Uh(),S8=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,E8=["http","https","ws","wss","urn","urn:uuid"];function T8(t){return E8.indexOf(t)!==-1}function Gh(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function $2(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function R2(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function $8(t){return t.secure=Gh(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function R8(t){if((t.port===(Gh(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function P8(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(S8);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let s=`${n}:${e.nid||t.nid}`,o=Yh(s);t.path=void 0,o&&(t=o.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function M8(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),s=`${r}:${e.nid||n}`,o=Yh(s);o&&(t=o.serialize(t,e));let i=t,a=t.nss;return i.path=`${n||e.nid}:${a}`,e.skipEscape=!0,i}function z8(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!k8(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function I8(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var P2={scheme:"http",domainHost:!0,parse:$2,serialize:R2},O8={scheme:"https",domainHost:P2.domainHost,parse:$2,serialize:R2},sl={scheme:"ws",domainHost:!0,parse:$8,serialize:R8},A8={scheme:"wss",domainHost:sl.domainHost,parse:sl.parse,serialize:sl.serialize},N8={scheme:"urn",parse:P8,serialize:M8,skipNormalize:!0},C8={scheme:"urn:uuid",parse:z8,serialize:I8,skipNormalize:!0},ol={http:P2,https:O8,ws:sl,wss:A8,urn:N8,"urn:uuid":C8};Object.setPrototypeOf(ol,null);function Yh(t){return t&&(ol[t]||ol[t.toLowerCase()])||void 0}M2.exports={wsIsSecure:Gh,SCHEMES:ol,isValidSchemeName:T8,getSchemeHandler:Yh}});var j2=Ie((dL,il)=>{"use strict";var{normalizeIPv6:j8,removeDotSegments:la,recomposeAuthority:D8,normalizePercentEncoding:L8,normalizePathEncoding:Z8,escapePreservingEscapes:B8,reescapeHostDelimiters:q8,isIPv4:V8,nonSimpleDomain:F8}=Uh(),{SCHEMES:H8,getSchemeHandler:O2}=z2();function U8(t,e){return typeof t=="string"?t=K8(t,e):typeof t=="object"&&(t=qo(Js(t,e),e)),t}function G8(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},s=A2(qo(t,n),qo(e,n),n,!0);return n.skipEscape=!0,Js(s,n)}function A2(t,e,r,n){let s={};return n||(t=qo(Js(t,r),r),e=qo(Js(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(s.scheme=e.scheme,s.userinfo=e.userinfo,s.host=e.host,s.port=e.port,s.path=la(e.path||""),s.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(s.userinfo=e.userinfo,s.host=e.host,s.port=e.port,s.path=la(e.path||""),s.query=e.query):(e.path?(e.path[0]==="/"?s.path=la(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?s.path="/"+e.path:t.path?s.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:s.path=e.path,s.path=la(s.path)),s.query=e.query):(s.path=t.path,e.query!==void 0?s.query=e.query:s.query=t.query),s.userinfo=t.userinfo,s.host=t.host,s.port=t.port),s.scheme=t.scheme),s.fragment=e.fragment,s}function Y8(t,e,r){let n=I2(t,r),s=I2(e,r);return n!==void 0&&s!==void 0&&n.toLowerCase()===s.toLowerCase()}function Js(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),s=[],o=O2(n.scheme||r.scheme);o&&o.serialize&&o.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=L8(r.path):(r.path=B8(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&s.push(r.scheme,":");let i=D8(r);if(i!==void 0&&(n.reference!=="suffix"&&s.push("//"),s.push(i),r.path&&r.path[0]!=="/"&&s.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!o||!o.absolutePath)&&(a=la(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),s.push(a)}return r.query!==void 0&&s.push("?",r.query),r.fragment!==void 0&&s.push("#",r.fragment),s.join("")}var X8=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function W8(t,e){if(e[2]!==void 0&&t.path&&t.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof t.port=="number"&&(t.port<0||t.port>65535))return"URI port is malformed."}function N2(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},s=!1,o=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let i=t.match(X8);if(i){n.scheme=i[1],n.userinfo=i[3],n.host=i[4],n.port=parseInt(i[5],10),n.path=i[6]||"",n.query=i[7],n.fragment=i[8],isNaN(n.port)&&(n.port=i[5]);let a=W8(n,i);if(a!==void 0&&(n.error=n.error||a,s=!0),n.host)if(V8(n.host)===!1){let l=j8(n.host);n.host=l.host.toLowerCase(),o=l.isIPV6}else o=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let c=O2(r.scheme||n.scheme);if(!r.unicodeSupport&&(!c||!c.unicodeSupport)&&n.host&&(r.domainHost||c&&c.domainHost)&&o===!1&&F8(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(d){n.error=n.error||"Host's domain name can not be converted to ASCII: "+d}if((!c||c&&!c.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=q8(unescape(n.host),o))),n.path&&(n.path=Z8(n.path)),n.fragment))try{n.fragment=encodeURI(decodeURIComponent(n.fragment))}catch{n.error=n.error||"URI malformed"}c&&c.parse&&c.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:s}}function qo(t,e){return N2(t,e).parsed}function K8(t,e){return C2(t,e).normalized}function C2(t,e){let{parsed:r,malformedAuthorityOrPort:n}=N2(t,e);return{normalized:n?t:Js(r,e),malformedAuthorityOrPort:n}}function I2(t,e){if(typeof t=="string"){let{normalized:r,malformedAuthorityOrPort:n}=C2(t,e);return n?void 0:r}if(typeof t=="object")return Js(t,e)}var Xh={SCHEMES:H8,normalize:U8,resolve:G8,resolveComponent:A2,equal:Y8,serialize:Js,parse:qo};il.exports=Xh;il.exports.default=Xh;il.exports.fastUri=Xh});var L2=Ie(Wh=>{"use strict";Object.defineProperty(Wh,"__esModule",{value:!0});var D2=j2();D2.code='require("ajv/dist/runtime/uri").default';Wh.default=D2});var G2=Ie(or=>{"use strict";Object.defineProperty(or,"__esModule",{value:!0});or.CodeGen=or.Name=or.nil=or.stringify=or.str=or._=or.KeywordCxt=void 0;var J8=aa();Object.defineProperty(or,"KeywordCxt",{enumerable:!0,get:function(){return J8.KeywordCxt}});var Vo=it();Object.defineProperty(or,"_",{enumerable:!0,get:function(){return Vo._}});Object.defineProperty(or,"str",{enumerable:!0,get:function(){return Vo.str}});Object.defineProperty(or,"stringify",{enumerable:!0,get:function(){return Vo.stringify}});Object.defineProperty(or,"nil",{enumerable:!0,get:function(){return Vo.nil}});Object.defineProperty(or,"Name",{enumerable:!0,get:function(){return Vo.Name}});Object.defineProperty(or,"CodeGen",{enumerable:!0,get:function(){return Vo.CodeGen}});var Q8=tl(),F2=ca(),eE=Sh(),ua=nl(),tE=it(),da=sa(),al=na(),Jh=mt(),Z2=v2(),rE=L2(),H2=(t,e)=>new RegExp(t,e);H2.code="new RegExp";var nE=["removeAdditional","useDefaults","coerceTypes"],sE=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),oE={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},iE={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},B2=200;function aE(t){var e,r,n,s,o,i,a,c,d,l,u,h,p,g,x,S,k,_,m,$,f,E,N,B,U;let C=t.strict,q=(e=t.code)===null||e===void 0?void 0:e.optimize,de=q===!0||q===void 0?1:q||0,A=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:H2,b=(s=t.uriResolver)!==null&&s!==void 0?s:rE.default;return{strictSchema:(i=(o=t.strictSchema)!==null&&o!==void 0?o:C)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:C)!==null&&c!==void 0?c:!0,strictTypes:(l=(d=t.strictTypes)!==null&&d!==void 0?d:C)!==null&&l!==void 0?l:"log",strictTuples:(h=(u=t.strictTuples)!==null&&u!==void 0?u:C)!==null&&h!==void 0?h:"log",strictRequired:(g=(p=t.strictRequired)!==null&&p!==void 0?p:C)!==null&&g!==void 0?g:!1,code:t.code?{...t.code,optimize:de,regExp:A}:{optimize:de,regExp:A},loopRequired:(x=t.loopRequired)!==null&&x!==void 0?x:B2,loopEnum:(S=t.loopEnum)!==null&&S!==void 0?S:B2,meta:(k=t.meta)!==null&&k!==void 0?k:!0,messages:(_=t.messages)!==null&&_!==void 0?_:!0,inlineRefs:(m=t.inlineRefs)!==null&&m!==void 0?m:!0,schemaId:($=t.schemaId)!==null&&$!==void 0?$:"$id",addUsedSchema:(f=t.addUsedSchema)!==null&&f!==void 0?f:!0,validateSchema:(E=t.validateSchema)!==null&&E!==void 0?E:!0,validateFormats:(N=t.validateFormats)!==null&&N!==void 0?N:!0,unicodeRegExp:(B=t.unicodeRegExp)!==null&&B!==void 0?B:!0,int32range:(U=t.int32range)!==null&&U!==void 0?U:!0,uriResolver:b}}var fa=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...aE(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new tE.ValueScope({scope:{},prefixes:sE,es5:r,lines:n}),this.logger=hE(e.logger);let s=e.validateFormats;e.validateFormats=!1,this.RULES=(0,eE.getRules)(),q2.call(this,oE,e,"NOT SUPPORTED"),q2.call(this,iE,e,"DEPRECATED","warn"),this._metaOpts=dE.call(this),e.formats&&lE.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&uE.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),cE.call(this),e.validateFormats=s}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,s=Z2;n==="id"&&(s={...Z2},s.id=s.$id,delete s.$id),r&&e&&this.addMetaSchema(s,s[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let s=n(r);return"$async"in n||(this.errors=n.errors),s}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return s.call(this,e,r);async function s(l,u){await o.call(this,l.$schema);let h=this._addSchema(l,u);return h.validate||i.call(this,h)}async function o(l){l&&!this.getSchema(l)&&await s.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(u){if(!(u instanceof F2.default))throw u;return a.call(this,u),await c.call(this,u.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:u}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${u} cannot be resolved`)}async function c(l){let u=await d.call(this,l);this.refs[l]||await o.call(this,u.$schema),this.refs[l]||this.addSchema(u,l,r)}async function d(l){let u=this._loading[l];if(u)return u;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(e,r,n,s=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,n,s);return this}let o;if(typeof e=="object"){let{schemaId:i}=this.opts;if(o=e[i],o!==void 0&&typeof o!="string")throw new Error(`schema ${i} must be string`)}return r=(0,da.normalizeId)(r||o),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,s,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let s=this.validate(n,e);if(!s&&r){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return s}getSchema(e){let r;for(;typeof(r=V2.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,s=new ua.SchemaEnv({schema:{},schemaId:n});if(r=ua.resolveSchema.call(this,s,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=V2.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,da.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(mE.call(this,n,r),!r)return(0,Jh.eachItem)(n,o=>Kh.call(this,o)),this;_E.call(this,r);let s={...r,type:(0,al.getJSONTypes)(r.type),schemaType:(0,al.getJSONTypes)(r.schemaType)};return(0,Jh.eachItem)(n,s.type.length===0?o=>Kh.call(this,o,s):o=>s.type.forEach(i=>Kh.call(this,o,s,i))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let s=n.rules.findIndex(o=>o.keyword===e);s>=0&&n.rules.splice(s,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(s=>`${n}${s.instancePath} ${s.message}`).reduce((s,o)=>s+r+o)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let s of r){let o=s.split("/").slice(1),i=e;for(let a of o)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:d}=c.definition,l=i[a];d&&l&&(i[a]=U2(l))}}return e}_removeAllSchemas(e,r){for(let n in e){let s=e[n];(!r||r.test(n))&&(typeof s=="string"?delete e[n]:s&&!s.meta&&(this._cache.delete(s.schema),delete e[n]))}}_addSchema(e,r,n,s=this.opts.validateSchema,o=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof e=="object")i=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,da.normalizeId)(i||n);let d=da.getSchemaRefs.call(this,e,n);return c=new ua.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:d}),this._cache.set(c.schema,c),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),s&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):ua.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{ua.compileSchema.call(this,e)}finally{this.opts=r}}};fa.ValidationError=Q8.default;fa.MissingRefError=F2.default;or.default=fa;function q2(t,e,r,n="error"){for(let s in t){let o=s;o in e&&this.logger[n](`${r}: option ${s}. ${t[o]}`)}}function V2(t){return t=(0,da.normalizeId)(t),this.schemas[t]||this.refs[t]}function cE(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function lE(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function uE(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function dE(){let t={...this.opts};for(let e of nE)delete t[e];return t}var fE={log(){},warn(){},error(){}};function hE(t){if(t===!1)return fE;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var pE=/^[a-z_$][a-z0-9_$:-]*$/i;function mE(t,e){let{RULES:r}=this;if((0,Jh.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!pE.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function Kh(t,e,r){var n;let s=e?.post;if(r&&s)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,i=s?o.post:o.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},o.rules.push(i)),o.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,al.getJSONTypes)(e.type),schemaType:(0,al.getJSONTypes)(e.schemaType)}};e.before?gE.call(this,i,a,e.before):i.rules.push(a),o.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function gE(t,e,r){let n=t.rules.findIndex(s=>s.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function _E(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=U2(e)),t.validateSchema=this.compile(e,!0))}var bE={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function U2(t){return{anyOf:[t,bE]}}});var Y2=Ie(Qh=>{"use strict";Object.defineProperty(Qh,"__esModule",{value:!0});var yE={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Qh.default=yE});var J2=Ie(Qs=>{"use strict";Object.defineProperty(Qs,"__esModule",{value:!0});Qs.callRef=Qs.getValidate=void 0;var vE=ca(),X2=Kr(),Rr=it(),Fo=qn(),W2=nl(),cl=mt(),wE={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:s,schemaEnv:o,validateName:i,opts:a,self:c}=n,{root:d}=o;if((r==="#"||r==="#/")&&s===d.baseId)return u();let l=W2.resolveRef.call(c,d,s,r);if(l===void 0)throw new vE.default(n.opts.uriResolver,s,r);if(l instanceof W2.SchemaEnv)return h(l);return p(l);function u(){if(o===d)return ll(t,i,o,o.$async);let g=e.scopeValue("root",{ref:d});return ll(t,(0,Rr._)`${g}.validate`,d,d.$async)}function h(g){let x=K2(t,g);ll(t,x,g,g.$async)}function p(g){let x=e.scopeValue("schema",a.code.source===!0?{ref:g,code:(0,Rr.stringify)(g)}:{ref:g}),S=e.name("valid"),k=t.subschema({schema:g,dataTypes:[],schemaPath:Rr.nil,topSchemaRef:x,errSchemaPath:r},S);t.mergeEvaluated(k),t.ok(S)}}};function K2(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Rr._)`${r.scopeValue("wrapper",{ref:e})}.validate`}Qs.getValidate=K2;function ll(t,e,r,n){let{gen:s,it:o}=t,{allErrors:i,schemaEnv:a,opts:c}=o,d=c.passContext?Fo.default.this:Rr.nil;n?l():u();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let g=s.let("valid");s.try(()=>{s.code((0,Rr._)`await ${(0,X2.callValidateCode)(t,e,d)}`),p(e),i||s.assign(g,!0)},x=>{s.if((0,Rr._)`!(${x} instanceof ${o.ValidationError})`,()=>s.throw(x)),h(x),i||s.assign(g,!1)}),t.ok(g)}function u(){t.result((0,X2.callValidateCode)(t,e,d),()=>p(e),()=>h(e))}function h(g){let x=(0,Rr._)`${g}.errors`;s.assign(Fo.default.vErrors,(0,Rr._)`${Fo.default.vErrors} === null ? ${x} : ${Fo.default.vErrors}.concat(${x})`),s.assign(Fo.default.errors,(0,Rr._)`${Fo.default.vErrors}.length`)}function p(g){var x;if(!o.opts.unevaluated)return;let S=(x=r?.validate)===null||x===void 0?void 0:x.evaluated;if(o.props!==!0)if(S&&!S.dynamicProps)S.props!==void 0&&(o.props=cl.mergeEvaluated.props(s,S.props,o.props));else{let k=s.var("props",(0,Rr._)`${g}.evaluated.props`);o.props=cl.mergeEvaluated.props(s,k,o.props,Rr.Name)}if(o.items!==!0)if(S&&!S.dynamicItems)S.items!==void 0&&(o.items=cl.mergeEvaluated.items(s,S.items,o.items));else{let k=s.var("items",(0,Rr._)`${g}.evaluated.items`);o.items=cl.mergeEvaluated.items(s,k,o.items,Rr.Name)}}}Qs.callRef=ll;Qs.default=wE});var Q2=Ie(ep=>{"use strict";Object.defineProperty(ep,"__esModule",{value:!0});var xE=Y2(),kE=J2(),SE=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",xE.default,kE.default];ep.default=SE});var eb=Ie(tp=>{"use strict";Object.defineProperty(tp,"__esModule",{value:!0});var ul=it(),ls=ul.operators,dl={maximum:{okStr:"<=",ok:ls.LTE,fail:ls.GT},minimum:{okStr:">=",ok:ls.GTE,fail:ls.LT},exclusiveMaximum:{okStr:"<",ok:ls.LT,fail:ls.GTE},exclusiveMinimum:{okStr:">",ok:ls.GT,fail:ls.LTE}},EE={message:({keyword:t,schemaCode:e})=>(0,ul.str)`must be ${dl[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,ul._)`{comparison: ${dl[t].okStr}, limit: ${e}}`},TE={keyword:Object.keys(dl),type:"number",schemaType:"number",$data:!0,error:EE,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,ul._)`${r} ${dl[e].fail} ${n} || isNaN(${r})`)}};tp.default=TE});var tb=Ie(rp=>{"use strict";Object.defineProperty(rp,"__esModule",{value:!0});var ha=it(),$E={message:({schemaCode:t})=>(0,ha.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,ha._)`{multipleOf: ${t}}`},RE={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:$E,code(t){let{gen:e,data:r,schemaCode:n,it:s}=t,o=s.opts.multipleOfPrecision,i=e.let("res"),a=o?(0,ha._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${o}`:(0,ha._)`${i} !== parseInt(${i})`;t.fail$data((0,ha._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};rp.default=RE});var nb=Ie(np=>{"use strict";Object.defineProperty(np,"__esModule",{value:!0});function rb(t){let e=t.length,r=0,n=0,s;for(;n<e;)r++,s=t.charCodeAt(n++),s>=55296&&s<=56319&&n<e&&(s=t.charCodeAt(n),(s&64512)===56320&&n++);return r}np.default=rb;rb.code='require("ajv/dist/runtime/ucs2length").default'});var sb=Ie(sp=>{"use strict";Object.defineProperty(sp,"__esModule",{value:!0});var eo=it(),PE=mt(),ME=nb(),zE={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,eo.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,eo._)`{limit: ${t}}`},IE={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:zE,code(t){let{keyword:e,data:r,schemaCode:n,it:s}=t,o=e==="maxLength"?eo.operators.GT:eo.operators.LT,i=s.opts.unicode===!1?(0,eo._)`${r}.length`:(0,eo._)`${(0,PE.useFunc)(t.gen,ME.default)}(${r})`;t.fail$data((0,eo._)`${i} ${o} ${n}`)}};sp.default=IE});var ob=Ie(op=>{"use strict";Object.defineProperty(op,"__esModule",{value:!0});var OE=Kr(),AE=mt(),Ho=it(),NE={message:({schemaCode:t})=>(0,Ho.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,Ho._)`{pattern: ${t}}`},CE={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:NE,code(t){let{gen:e,data:r,$data:n,schema:s,schemaCode:o,it:i}=t,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,d=c.code==="new RegExp"?(0,Ho._)`new RegExp`:(0,AE.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,Ho._)`${d}(${o}, ${a}).test(${r})`),()=>e.assign(l,!1)),t.fail$data((0,Ho._)`!${l}`)}else{let c=(0,OE.usePattern)(t,s);t.fail$data((0,Ho._)`!${c}.test(${r})`)}}};op.default=CE});var ib=Ie(ip=>{"use strict";Object.defineProperty(ip,"__esModule",{value:!0});var pa=it(),jE={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,pa.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,pa._)`{limit: ${t}}`},DE={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:jE,code(t){let{keyword:e,data:r,schemaCode:n}=t,s=e==="maxProperties"?pa.operators.GT:pa.operators.LT;t.fail$data((0,pa._)`Object.keys(${r}).length ${s} ${n}`)}};ip.default=DE});var ab=Ie(ap=>{"use strict";Object.defineProperty(ap,"__esModule",{value:!0});var ma=Kr(),ga=it(),LE=mt(),ZE={message:({params:{missingProperty:t}})=>(0,ga.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,ga._)`{missingProperty: ${t}}`},BE={keyword:"required",type:"object",schemaType:"array",$data:!0,error:ZE,code(t){let{gen:e,schema:r,schemaCode:n,data:s,$data:o,it:i}=t,{opts:a}=i;if(!o&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?d():l(),a.strictRequired){let p=t.parentSchema.properties,{definedProperties:g}=t.it;for(let x of r)if(p?.[x]===void 0&&!g.has(x)){let S=i.schemaEnv.baseId+i.errSchemaPath,k=`required property "${x}" is not defined at "${S}" (strictRequired)`;(0,LE.checkStrictMode)(i,k,i.opts.strictRequired)}}function d(){if(c||o)t.block$data(ga.nil,u);else for(let p of r)(0,ma.checkReportMissingProp)(t,p)}function l(){let p=e.let("missing");if(c||o){let g=e.let("valid",!0);t.block$data(g,()=>h(p,g)),t.ok(g)}else e.if((0,ma.checkMissingProp)(t,r,p)),(0,ma.reportMissingProp)(t,p),e.else()}function u(){e.forOf("prop",n,p=>{t.setParams({missingProperty:p}),e.if((0,ma.noPropertyInData)(e,s,p,a.ownProperties),()=>t.error())})}function h(p,g){t.setParams({missingProperty:p}),e.forOf(p,n,()=>{e.assign(g,(0,ma.propertyInData)(e,s,p,a.ownProperties)),e.if((0,ga.not)(g),()=>{t.error(),e.break()})},ga.nil)}}};ap.default=BE});var cb=Ie(cp=>{"use strict";Object.defineProperty(cp,"__esModule",{value:!0});var _a=it(),qE={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,_a.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,_a._)`{limit: ${t}}`},VE={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:qE,code(t){let{keyword:e,data:r,schemaCode:n}=t,s=e==="maxItems"?_a.operators.GT:_a.operators.LT;t.fail$data((0,_a._)`${r}.length ${s} ${n}`)}};cp.default=VE});var fl=Ie(lp=>{"use strict";Object.defineProperty(lp,"__esModule",{value:!0});var lb=Ih();lb.code='require("ajv/dist/runtime/equal").default';lp.default=lb});var ub=Ie(dp=>{"use strict";Object.defineProperty(dp,"__esModule",{value:!0});var up=na(),ir=it(),FE=mt(),HE=fl(),UE={message:({params:{i:t,j:e}})=>(0,ir.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,ir._)`{i: ${t}, j: ${e}}`},GE={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:UE,code(t){let{gen:e,data:r,$data:n,schema:s,parentSchema:o,schemaCode:i,it:a}=t;if(!n&&!s)return;let c=e.let("valid"),d=o.items?(0,up.getSchemaTypes)(o.items):[];t.block$data(c,l,(0,ir._)`${i} === false`),t.ok(c);function l(){let g=e.let("i",(0,ir._)`${r}.length`),x=e.let("j");t.setParams({i:g,j:x}),e.assign(c,!0),e.if((0,ir._)`${g} > 1`,()=>(u()?h:p)(g,x))}function u(){return d.length>0&&!d.some(g=>g==="object"||g==="array")}function h(g,x){let S=e.name("item"),k=(0,up.checkDataTypes)(d,S,a.opts.strictNumbers,up.DataType.Wrong),_=e.const("indices",(0,ir._)`{}`);e.for((0,ir._)`;${g}--;`,()=>{e.let(S,(0,ir._)`${r}[${g}]`),e.if(k,(0,ir._)`continue`),d.length>1&&e.if((0,ir._)`typeof ${S} == "string"`,(0,ir._)`${S} += "_"`),e.if((0,ir._)`typeof ${_}[${S}] == "number"`,()=>{e.assign(x,(0,ir._)`${_}[${S}]`),t.error(),e.assign(c,!1).break()}).code((0,ir._)`${_}[${S}] = ${g}`)})}function p(g,x){let S=(0,FE.useFunc)(e,HE.default),k=e.name("outer");e.label(k).for((0,ir._)`;${g}--;`,()=>e.for((0,ir._)`${x} = ${g}; ${x}--;`,()=>e.if((0,ir._)`${S}(${r}[${g}], ${r}[${x}])`,()=>{t.error(),e.assign(c,!1).break(k)})))}}};dp.default=GE});var db=Ie(hp=>{"use strict";Object.defineProperty(hp,"__esModule",{value:!0});var fp=it(),YE=mt(),XE=fl(),WE={message:"must be equal to constant",params:({schemaCode:t})=>(0,fp._)`{allowedValue: ${t}}`},KE={keyword:"const",$data:!0,error:WE,code(t){let{gen:e,data:r,$data:n,schemaCode:s,schema:o}=t;n||o&&typeof o=="object"?t.fail$data((0,fp._)`!${(0,YE.useFunc)(e,XE.default)}(${r}, ${s})`):t.fail((0,fp._)`${o} !== ${r}`)}};hp.default=KE});var fb=Ie(pp=>{"use strict";Object.defineProperty(pp,"__esModule",{value:!0});var ba=it(),JE=mt(),QE=fl(),e7={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,ba._)`{allowedValues: ${t}}`},t7={keyword:"enum",schemaType:"array",$data:!0,error:e7,code(t){let{gen:e,data:r,$data:n,schema:s,schemaCode:o,it:i}=t;if(!n&&s.length===0)throw new Error("enum must have non-empty array");let a=s.length>=i.opts.loopEnum,c,d=()=>c??(c=(0,JE.useFunc)(e,QE.default)),l;if(a||n)l=e.let("valid"),t.block$data(l,u);else{if(!Array.isArray(s))throw new Error("ajv implementation error");let p=e.const("vSchema",o);l=(0,ba.or)(...s.map((g,x)=>h(p,x)))}t.pass(l);function u(){e.assign(l,!1),e.forOf("v",o,p=>e.if((0,ba._)`${d()}(${r}, ${p})`,()=>e.assign(l,!0).break()))}function h(p,g){let x=s[g];return typeof x=="object"&&x!==null?(0,ba._)`${d()}(${r}, ${p}[${g}])`:(0,ba._)`${r} === ${x}`}}};pp.default=t7});var hb=Ie(mp=>{"use strict";Object.defineProperty(mp,"__esModule",{value:!0});var r7=eb(),n7=tb(),s7=sb(),o7=ob(),i7=ib(),a7=ab(),c7=cb(),l7=ub(),u7=db(),d7=fb(),f7=[r7.default,n7.default,s7.default,o7.default,i7.default,a7.default,c7.default,l7.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},u7.default,d7.default];mp.default=f7});var _p=Ie(ya=>{"use strict";Object.defineProperty(ya,"__esModule",{value:!0});ya.validateAdditionalItems=void 0;var to=it(),gp=mt(),h7={message:({params:{len:t}})=>(0,to.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,to._)`{limit: ${t}}`},p7={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:h7,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,gp.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}pb(t,n)}};function pb(t,e){let{gen:r,schema:n,data:s,keyword:o,it:i}=t;i.items=!0;let a=r.const("len",(0,to._)`${s}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,to._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,gp.alwaysValidSchema)(i,n)){let d=r.var("valid",(0,to._)`${a} <= ${e.length}`);r.if((0,to.not)(d),()=>c(d)),t.ok(d)}function c(d){r.forRange("i",e.length,a,l=>{t.subschema({keyword:o,dataProp:l,dataPropType:gp.Type.Num},d),i.allErrors||r.if((0,to.not)(d),()=>r.break())})}}ya.validateAdditionalItems=pb;ya.default=p7});var bp=Ie(va=>{"use strict";Object.defineProperty(va,"__esModule",{value:!0});va.validateTuple=void 0;var mb=it(),hl=mt(),m7=Kr(),g7={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return gb(t,"additionalItems",e);r.items=!0,!(0,hl.alwaysValidSchema)(r,e)&&t.ok((0,m7.validateArray)(t))}};function gb(t,e,r=t.schema){let{gen:n,parentSchema:s,data:o,keyword:i,it:a}=t;l(s),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=hl.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),d=n.const("len",(0,mb._)`${o}.length`);r.forEach((u,h)=>{(0,hl.alwaysValidSchema)(a,u)||(n.if((0,mb._)`${d} > ${h}`,()=>t.subschema({keyword:i,schemaProp:h,dataProp:h},c)),t.ok(c))});function l(u){let{opts:h,errSchemaPath:p}=a,g=r.length,x=g===u.minItems&&(g===u.maxItems||u[e]===!1);if(h.strictTuples&&!x){let S=`"${i}" is ${g}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0,hl.checkStrictMode)(a,S,h.strictTuples)}}}va.validateTuple=gb;va.default=g7});var _b=Ie(yp=>{"use strict";Object.defineProperty(yp,"__esModule",{value:!0});var _7=bp(),b7={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,_7.validateTuple)(t,"items")};yp.default=b7});var yb=Ie(vp=>{"use strict";Object.defineProperty(vp,"__esModule",{value:!0});var bb=it(),y7=mt(),v7=Kr(),w7=_p(),x7={message:({params:{len:t}})=>(0,bb.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,bb._)`{limit: ${t}}`},k7={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:x7,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:s}=r;n.items=!0,!(0,y7.alwaysValidSchema)(n,e)&&(s?(0,w7.validateAdditionalItems)(t,s):t.ok((0,v7.validateArray)(t)))}};vp.default=k7});var vb=Ie(wp=>{"use strict";Object.defineProperty(wp,"__esModule",{value:!0});var Qr=it(),pl=mt(),S7={message:({params:{min:t,max:e}})=>e===void 0?(0,Qr.str)`must contain at least ${t} valid item(s)`:(0,Qr.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,Qr._)`{minContains: ${t}}`:(0,Qr._)`{minContains: ${t}, maxContains: ${e}}`},E7={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:S7,code(t){let{gen:e,schema:r,parentSchema:n,data:s,it:o}=t,i,a,{minContains:c,maxContains:d}=n;o.opts.next?(i=c===void 0?1:c,a=d):i=1;let l=e.const("len",(0,Qr._)`${s}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,pl.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,pl.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,pl.alwaysValidSchema)(o,r)){let x=(0,Qr._)`${l} >= ${i}`;a!==void 0&&(x=(0,Qr._)`${x} && ${l} <= ${a}`),t.pass(x);return}o.items=!0;let u=e.name("valid");a===void 0&&i===1?p(u,()=>e.if(u,()=>e.break())):i===0?(e.let(u,!0),a!==void 0&&e.if((0,Qr._)`${s}.length > 0`,h)):(e.let(u,!1),h()),t.result(u,()=>t.reset());function h(){let x=e.name("_valid"),S=e.let("count",0);p(x,()=>e.if(x,()=>g(S)))}function p(x,S){e.forRange("i",0,l,k=>{t.subschema({keyword:"contains",dataProp:k,dataPropType:pl.Type.Num,compositeRule:!0},x),S()})}function g(x){e.code((0,Qr._)`${x}++`),a===void 0?e.if((0,Qr._)`${x} >= ${i}`,()=>e.assign(u,!0).break()):(e.if((0,Qr._)`${x} > ${a}`,()=>e.assign(u,!1).break()),i===1?e.assign(u,!0):e.if((0,Qr._)`${x} >= ${i}`,()=>e.assign(u,!0)))}}};wp.default=E7});var kb=Ie(Mn=>{"use strict";Object.defineProperty(Mn,"__esModule",{value:!0});Mn.validateSchemaDeps=Mn.validatePropertyDeps=Mn.error=void 0;var xp=it(),T7=mt(),wa=Kr();Mn.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,xp.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,xp._)`{property: ${t},
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
4
+ || (${i} == "string" && ${s} && ${s} == +${s})`).assign(a,(0,it._)`+${s}`);return;case"integer":n.elseIf((0,it._)`${i} === "boolean" || ${s} === null
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},
7
7
  missingProperty: ${n},
8
8
  depsCount: ${e},
9
- deps: ${r}}`};var $7={keyword:"dependencies",type:"object",schemaType:"object",error:Mn.error,code(t){let[e,r]=R7(t);wb(t,e),xb(t,r)}};function R7({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let s=Array.isArray(t[n])?e:r;s[n]=t[n]}return[e,r]}function wb(t,e=t.schema){let{gen:r,data:n,it:s}=t;if(Object.keys(e).length===0)return;let o=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,wa.propertyInData)(r,n,i,s.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),s.allErrors?r.if(c,()=>{for(let d of a)(0,wa.checkReportMissingProp)(t,d)}):(r.if((0,xp._)`${c} && (${(0,wa.checkMissingProp)(t,a,o)})`),(0,wa.reportMissingProp)(t,o),r.else())}}Mn.validatePropertyDeps=wb;function xb(t,e=t.schema){let{gen:r,data:n,keyword:s,it:o}=t,i=r.name("valid");for(let a in e)(0,T7.alwaysValidSchema)(o,e[a])||(r.if((0,wa.propertyInData)(r,n,a,o.opts.ownProperties),()=>{let c=t.subschema({keyword:s,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}Mn.validateSchemaDeps=xb;Mn.default=$7});var Eb=Ie(kp=>{"use strict";Object.defineProperty(kp,"__esModule",{value:!0});var Sb=it(),P7=mt(),M7={message:"property name must be valid",params:({params:t})=>(0,Sb._)`{propertyName: ${t.propertyName}}`},z7={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:M7,code(t){let{gen:e,schema:r,data:n,it:s}=t;if((0,P7.alwaysValidSchema)(s,r))return;let o=e.name("valid");e.forIn("key",n,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},o),e.if((0,Sb.not)(o),()=>{t.error(!0),s.allErrors||e.break()})}),t.ok(o)}};kp.default=z7});var Ep=Ie(Sp=>{"use strict";Object.defineProperty(Sp,"__esModule",{value:!0});var ml=Kr(),gn=it(),I7=qn(),gl=mt(),O7={message:"must NOT have additional properties",params:({params:t})=>(0,gn._)`{additionalProperty: ${t.additionalProperty}}`},A7={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:O7,code(t){let{gen:e,schema:r,parentSchema:n,data:s,errsCount:o,it:i}=t;if(!o)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,gl.alwaysValidSchema)(i,r))return;let d=(0,ml.allSchemaProperties)(n.properties),l=(0,ml.allSchemaProperties)(n.patternProperties);u(),t.ok((0,gn._)`${o} === ${I7.default.errors}`);function u(){e.forIn("key",s,S=>{!d.length&&!l.length?g(S):e.if(h(S),()=>g(S))})}function h(S){let k;if(d.length>8){let _=(0,gl.schemaRefOrVal)(i,n.properties,"properties");k=(0,ml.isOwnProperty)(e,_,S)}else d.length?k=(0,gn.or)(...d.map(_=>(0,gn._)`${S} === ${_}`)):k=gn.nil;return l.length&&(k=(0,gn.or)(k,...l.map(_=>(0,gn._)`${(0,ml.usePattern)(t,_)}.test(${S})`))),(0,gn.not)(k)}function p(S){e.code((0,gn._)`delete ${s}[${S}]`)}function g(S){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(S);return}if(r===!1){t.setParams({additionalProperty:S}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,gl.alwaysValidSchema)(i,r)){let k=e.name("valid");c.removeAdditional==="failing"?(x(S,k,!1),e.if((0,gn.not)(k),()=>{t.reset(),p(S)})):(x(S,k),a||e.if((0,gn.not)(k),()=>e.break()))}}function x(S,k,_){let m={keyword:"additionalProperties",dataProp:S,dataPropType:gl.Type.Str};_===!1&&Object.assign(m,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(m,k)}}};Sp.default=A7});var Rb=Ie($p=>{"use strict";Object.defineProperty($p,"__esModule",{value:!0});var N7=aa(),Tb=Kr(),Tp=mt(),$b=Ep(),C7={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:s,it:o}=t;o.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&$b.default.code(new N7.KeywordCxt(o,$b.default,"additionalProperties"));let i=(0,Tb.allSchemaProperties)(r);for(let u of i)o.definedProperties.add(u);o.opts.unevaluated&&i.length&&o.props!==!0&&(o.props=Tp.mergeEvaluated.props(e,(0,Tp.toHash)(i),o.props));let a=i.filter(u=>!(0,Tp.alwaysValidSchema)(o,r[u]));if(a.length===0)return;let c=e.name("valid");for(let u of a)d(u)?l(u):(e.if((0,Tb.propertyInData)(e,s,u,o.opts.ownProperties)),l(u),o.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(u),t.ok(c);function d(u){return o.opts.useDefaults&&!o.compositeRule&&r[u].default!==void 0}function l(u){t.subschema({keyword:"properties",schemaProp:u,dataProp:u},c)}}};$p.default=C7});var Ib=Ie(Rp=>{"use strict";Object.defineProperty(Rp,"__esModule",{value:!0});var Pb=Kr(),_l=it(),Mb=mt(),zb=mt(),j7={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:s,it:o}=t,{opts:i}=o,a=(0,Pb.allSchemaProperties)(r),c=a.filter(x=>(0,Mb.alwaysValidSchema)(o,r[x]));if(a.length===0||c.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;let d=i.strictSchema&&!i.allowMatchingProperties&&s.properties,l=e.name("valid");o.props!==!0&&!(o.props instanceof _l.Name)&&(o.props=(0,zb.evaluatedPropsToName)(e,o.props));let{props:u}=o;h();function h(){for(let x of a)d&&p(x),o.allErrors?g(x):(e.var(l,!0),g(x),e.if(l))}function p(x){for(let S in d)new RegExp(x).test(S)&&(0,Mb.checkStrictMode)(o,`property ${S} matches pattern ${x} (use allowMatchingProperties)`)}function g(x){e.forIn("key",n,S=>{e.if((0,_l._)`${(0,Pb.usePattern)(t,x)}.test(${S})`,()=>{let k=c.includes(x);k||t.subschema({keyword:"patternProperties",schemaProp:x,dataProp:S,dataPropType:zb.Type.Str},l),o.opts.unevaluated&&u!==!0?e.assign((0,_l._)`${u}[${S}]`,!0):!k&&!o.allErrors&&e.if((0,_l.not)(l),()=>e.break())})})}}};Rp.default=j7});var Ob=Ie(Pp=>{"use strict";Object.defineProperty(Pp,"__esModule",{value:!0});var D7=mt(),L7={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,D7.alwaysValidSchema)(n,r)){t.fail();return}let s=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},s),t.failResult(s,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};Pp.default=L7});var Ab=Ie(Mp=>{"use strict";Object.defineProperty(Mp,"__esModule",{value:!0});var Z7=Kr(),B7={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Z7.validateUnion,error:{message:"must match a schema in anyOf"}};Mp.default=B7});var Nb=Ie(zp=>{"use strict";Object.defineProperty(zp,"__esModule",{value:!0});var bl=it(),q7=mt(),V7={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,bl._)`{passingSchemas: ${t.passing}}`},F7={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:V7,code(t){let{gen:e,schema:r,parentSchema:n,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;let o=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(d),t.result(i,()=>t.reset(),()=>t.error(!0));function d(){o.forEach((l,u)=>{let h;(0,q7.alwaysValidSchema)(s,l)?e.var(c,!0):h=t.subschema({keyword:"oneOf",schemaProp:u,compositeRule:!0},c),u>0&&e.if((0,bl._)`${c} && ${i}`).assign(i,!1).assign(a,(0,bl._)`[${a}, ${u}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,u),h&&t.mergeEvaluated(h,bl.Name)})})}}};zp.default=F7});var Cb=Ie(Ip=>{"use strict";Object.defineProperty(Ip,"__esModule",{value:!0});var H7=mt(),U7={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let s=e.name("valid");r.forEach((o,i)=>{if((0,H7.alwaysValidSchema)(n,o))return;let a=t.subschema({keyword:"allOf",schemaProp:i},s);t.ok(s),t.mergeEvaluated(a)})}};Ip.default=U7});var Lb=Ie(Op=>{"use strict";Object.defineProperty(Op,"__esModule",{value:!0});var yl=it(),Db=mt(),G7={message:({params:t})=>(0,yl.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,yl._)`{failingKeyword: ${t.ifClause}}`},Y7={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:G7,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,Db.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let s=jb(n,"then"),o=jb(n,"else");if(!s&&!o)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),s&&o){let l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,d("then",l),d("else",l))}else s?e.if(a,d("then")):e.if((0,yl.not)(a),d("else"));t.pass(i,()=>t.error(!0));function c(){let l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function d(l,u){return()=>{let h=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(h,i),u?e.assign(u,(0,yl._)`${l}`):t.setParams({ifClause:l})}}}};function jb(t,e){let r=t.schema[e];return r!==void 0&&!(0,Db.alwaysValidSchema)(t,r)}Op.default=Y7});var Zb=Ie(Ap=>{"use strict";Object.defineProperty(Ap,"__esModule",{value:!0});var X7=mt(),W7={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,X7.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};Ap.default=W7});var Bb=Ie(Np=>{"use strict";Object.defineProperty(Np,"__esModule",{value:!0});var K7=_p(),J7=_b(),Q7=bp(),eT=yb(),tT=vb(),rT=kb(),nT=Eb(),sT=Ep(),oT=Rb(),iT=Ib(),aT=Ob(),cT=Ab(),lT=Nb(),uT=Cb(),dT=Lb(),fT=Zb();function hT(t=!1){let e=[aT.default,cT.default,lT.default,uT.default,dT.default,fT.default,nT.default,sT.default,rT.default,oT.default,iT.default];return t?e.push(J7.default,eT.default):e.push(K7.default,Q7.default),e.push(tT.default),e}Np.default=hT});var qb=Ie(Cp=>{"use strict";Object.defineProperty(Cp,"__esModule",{value:!0});var Ht=it(),pT={message:({schemaCode:t})=>(0,Ht.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,Ht._)`{format: ${t}}`},mT={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:pT,code(t,e){let{gen:r,data:n,$data:s,schema:o,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:d,schemaEnv:l,self:u}=a;if(!c.validateFormats)return;s?h():p();function h(){let g=r.scopeValue("formats",{ref:u.formats,code:c.code.formats}),x=r.const("fDef",(0,Ht._)`${g}[${i}]`),S=r.let("fType"),k=r.let("format");r.if((0,Ht._)`typeof ${x} == "object" && !(${x} instanceof RegExp)`,()=>r.assign(S,(0,Ht._)`${x}.type || "string"`).assign(k,(0,Ht._)`${x}.validate`),()=>r.assign(S,(0,Ht._)`"string"`).assign(k,x)),t.fail$data((0,Ht.or)(_(),m()));function _(){return c.strictSchema===!1?Ht.nil:(0,Ht._)`${i} && !${k}`}function m(){let $=l.$async?(0,Ht._)`(${x}.async ? await ${k}(${n}) : ${k}(${n}))`:(0,Ht._)`${k}(${n})`,f=(0,Ht._)`(typeof ${k} == "function" ? ${$} : ${k}.test(${n}))`;return(0,Ht._)`${k} && ${k} !== true && ${S} === ${e} && !${f}`}}function p(){let g=u.formats[o];if(!g){_();return}if(g===!0)return;let[x,S,k]=m(g);x===e&&t.pass($());function _(){if(c.strictSchema===!1){u.logger.warn(f());return}throw new Error(f());function f(){return`unknown format "${o}" ignored in schema at path "${d}"`}}function m(f){let E=f instanceof RegExp?(0,Ht.regexpCode)(f):c.code.formats?(0,Ht._)`${c.code.formats}${(0,Ht.getProperty)(o)}`:void 0,N=r.scopeValue("formats",{key:o,ref:f,code:E});return typeof f=="object"&&!(f instanceof RegExp)?[f.type||"string",f.validate,(0,Ht._)`${N}.validate`]:["string",f,N]}function $(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!l.$async)throw new Error("async format in sync schema");return(0,Ht._)`await ${k}(${n})`}return typeof S=="function"?(0,Ht._)`${k}(${n})`:(0,Ht._)`${k}.test(${n})`}}}};Cp.default=mT});var Vb=Ie(jp=>{"use strict";Object.defineProperty(jp,"__esModule",{value:!0});var gT=qb(),_T=[gT.default];jp.default=_T});var Fb=Ie(Uo=>{"use strict";Object.defineProperty(Uo,"__esModule",{value:!0});Uo.contentVocabulary=Uo.metadataVocabulary=void 0;Uo.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Uo.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Ub=Ie(Dp=>{"use strict";Object.defineProperty(Dp,"__esModule",{value:!0});var bT=Q2(),yT=hb(),vT=Bb(),wT=Vb(),Hb=Fb(),xT=[bT.default,yT.default,(0,vT.default)(),wT.default,Hb.metadataVocabulary,Hb.contentVocabulary];Dp.default=xT});var Yb=Ie(vl=>{"use strict";Object.defineProperty(vl,"__esModule",{value:!0});vl.DiscrError=void 0;var Gb;(function(t){t.Tag="tag",t.Mapping="mapping"})(Gb||(vl.DiscrError=Gb={}))});var Wb=Ie(Zp=>{"use strict";Object.defineProperty(Zp,"__esModule",{value:!0});var Go=it(),Lp=Yb(),Xb=nl(),kT=ca(),ST=mt(),ET={message:({params:{discrError:t,tagName:e}})=>t===Lp.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,Go._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},TT={keyword:"discriminator",type:"object",schemaType:"object",error:ET,code(t){let{gen:e,data:r,schema:n,parentSchema:s,it:o}=t,{oneOf:i}=s;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),d=e.const("tag",(0,Go._)`${r}${(0,Go.getProperty)(a)}`);e.if((0,Go._)`typeof ${d} == "string"`,()=>l(),()=>t.error(!1,{discrError:Lp.DiscrError.Tag,tag:d,tagName:a})),t.ok(c);function l(){let p=h();e.if(!1);for(let g in p)e.elseIf((0,Go._)`${d} === ${g}`),e.assign(c,u(p[g]));e.else(),t.error(!1,{discrError:Lp.DiscrError.Mapping,tag:d,tagName:a}),e.endIf()}function u(p){let g=e.name("valid"),x=t.subschema({keyword:"oneOf",schemaProp:p},g);return t.mergeEvaluated(x,Go.Name),g}function h(){var p;let g={},x=k(s),S=!0;for(let $=0;$<i.length;$++){let f=i[$];if(f?.$ref&&!(0,ST.schemaHasRulesButRef)(f,o.self.RULES)){let N=f.$ref;if(f=Xb.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,N),f instanceof Xb.SchemaEnv&&(f=f.schema),f===void 0)throw new kT.default(o.opts.uriResolver,o.baseId,N)}let E=(p=f?.properties)===null||p===void 0?void 0:p[a];if(typeof E!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);S=S&&(x||k(f)),_(E,$)}if(!S)throw new Error(`discriminator: "${a}" must be required`);return g;function k({required:$}){return Array.isArray($)&&$.includes(a)}function _($,f){if($.const)m($.const,f);else if($.enum)for(let E of $.enum)m(E,f);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function m($,f){if(typeof $!="string"||$ in g)throw new Error(`discriminator: "${a}" values must be unique strings`);g[$]=f}}}};Zp.default=TT});var Kb=Ie((QL,$T)=>{$T.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var qp=Ie((It,Bp)=>{"use strict";Object.defineProperty(It,"__esModule",{value:!0});It.MissingRefError=It.ValidationError=It.CodeGen=It.Name=It.nil=It.stringify=It.str=It._=It.KeywordCxt=It.Ajv=void 0;var RT=G2(),PT=Ub(),MT=Wb(),Jb=Kb(),zT=["/properties"],wl="http://json-schema.org/draft-07/schema",Yo=class extends RT.default{_addVocabularies(){super._addVocabularies(),PT.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(MT.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(Jb,zT):Jb;this.addMetaSchema(e,wl,!1),this.refs["http://json-schema.org/schema"]=wl}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(wl)?wl:void 0)}};It.Ajv=Yo;Bp.exports=It=Yo;Bp.exports.Ajv=Yo;Object.defineProperty(It,"__esModule",{value:!0});It.default=Yo;var IT=aa();Object.defineProperty(It,"KeywordCxt",{enumerable:!0,get:function(){return IT.KeywordCxt}});var Xo=it();Object.defineProperty(It,"_",{enumerable:!0,get:function(){return Xo._}});Object.defineProperty(It,"str",{enumerable:!0,get:function(){return Xo.str}});Object.defineProperty(It,"stringify",{enumerable:!0,get:function(){return Xo.stringify}});Object.defineProperty(It,"nil",{enumerable:!0,get:function(){return Xo.nil}});Object.defineProperty(It,"Name",{enumerable:!0,get:function(){return Xo.Name}});Object.defineProperty(It,"CodeGen",{enumerable:!0,get:function(){return Xo.CodeGen}});var OT=tl();Object.defineProperty(It,"ValidationError",{enumerable:!0,get:function(){return OT.default}});var AT=ca();Object.defineProperty(It,"MissingRefError",{enumerable:!0,get:function(){return AT.default}})});var iy=Ie(In=>{"use strict";Object.defineProperty(In,"__esModule",{value:!0});In.formatNames=In.fastFormats=In.fullFormats=void 0;function zn(t,e){return{validate:t,compare:e}}In.fullFormats={date:zn(ry,Up),time:zn(Fp(!0),Gp),"date-time":zn(Qb(!0),sy),"iso-time":zn(Fp(),ny),"iso-date-time":zn(Qb(),oy),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:ZT,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:GT,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:BT,int32:{type:"number",validate:FT},int64:{type:"number",validate:HT},float:{type:"number",validate:ty},double:{type:"number",validate:ty},password:!0,binary:!0};In.fastFormats={...In.fullFormats,date:zn(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Up),time:zn(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Gp),"date-time":zn(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,sy),"iso-time":zn(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,ny),"iso-date-time":zn(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,oy),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};In.formatNames=Object.keys(In.fullFormats);function NT(t){return t%4===0&&(t%100!==0||t%400===0)}var CT=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,jT=[0,31,28,31,30,31,30,31,31,30,31,30,31];function ry(t){let e=CT.exec(t);if(!e)return!1;let r=+e[1],n=+e[2],s=+e[3];return n>=1&&n<=12&&s>=1&&s<=(n===2&&NT(r)?29:jT[n])}function Up(t,e){if(t&&e)return t>e?1:t<e?-1:0}var Vp=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Fp(t){return function(r){let n=Vp.exec(r);if(!n)return!1;let s=+n[1],o=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,d=+(n[6]||0),l=+(n[7]||0);if(d>23||l>59||t&&!a)return!1;if(s<=23&&o<=59&&i<60)return!0;let u=o-l*c,h=s-d*c-(u<0?1:0);return(h===23||h===-1)&&(u===59||u===-1)&&i<61}}function Gp(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),n=new Date("2020-01-01T"+e).valueOf();if(r&&n)return r-n}function ny(t,e){if(!(t&&e))return;let r=Vp.exec(t),n=Vp.exec(e);if(r&&n)return t=r[1]+r[2]+r[3],e=n[1]+n[2]+n[3],t>e?1:t<e?-1:0}var Hp=/t|\s/i;function Qb(t){let e=Fp(t);return function(n){let s=n.split(Hp);return s.length===2&&ry(s[0])&&e(s[1])}}function sy(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function oy(t,e){if(!(t&&e))return;let[r,n]=t.split(Hp),[s,o]=e.split(Hp),i=Up(r,s);if(i!==void 0)return i||Gp(n,o)}var DT=/\/|:/,LT=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function ZT(t){return DT.test(t)&&LT.test(t)}var ey=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function BT(t){return ey.lastIndex=0,ey.test(t)}var qT=-(2**31),VT=2**31-1;function FT(t){return Number.isInteger(t)&&t<=VT&&t>=qT}function HT(t){return Number.isInteger(t)}function ty(){return!0}var UT=/[^\\]\\Z/;function GT(t){if(UT.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var ay=Ie(Wo=>{"use strict";Object.defineProperty(Wo,"__esModule",{value:!0});Wo.formatLimitDefinition=void 0;var YT=qp(),_n=it(),us=_n.operators,xl={formatMaximum:{okStr:"<=",ok:us.LTE,fail:us.GT},formatMinimum:{okStr:">=",ok:us.GTE,fail:us.LT},formatExclusiveMaximum:{okStr:"<",ok:us.LT,fail:us.GTE},formatExclusiveMinimum:{okStr:">",ok:us.GT,fail:us.LTE}},XT={message:({keyword:t,schemaCode:e})=>(0,_n.str)`should be ${xl[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,_n._)`{comparison: ${xl[t].okStr}, limit: ${e}}`};Wo.formatLimitDefinition={keyword:Object.keys(xl),type:"string",schemaType:"string",$data:!0,error:XT,code(t){let{gen:e,data:r,schemaCode:n,keyword:s,it:o}=t,{opts:i,self:a}=o;if(!i.validateFormats)return;let c=new YT.KeywordCxt(o,a.RULES.all.format.definition,"format");c.$data?d():l();function d(){let h=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),p=e.const("fmt",(0,_n._)`${h}[${c.schemaCode}]`);t.fail$data((0,_n.or)((0,_n._)`typeof ${p} != "object"`,(0,_n._)`${p} instanceof RegExp`,(0,_n._)`typeof ${p}.compare != "function"`,u(p)))}function l(){let h=c.schema,p=a.formats[h];if(!p||p===!0)return;if(typeof p!="object"||p instanceof RegExp||typeof p.compare!="function")throw new Error(`"${s}": format "${h}" does not define "compare" function`);let g=e.scopeValue("formats",{key:h,ref:p,code:i.code.formats?(0,_n._)`${i.code.formats}${(0,_n.getProperty)(h)}`:void 0});t.fail$data(u(g))}function u(h){return(0,_n._)`${h}.compare(${r}, ${n}) ${xl[s].fail} 0`}},dependencies:["format"]};var WT=t=>(t.addKeyword(Wo.formatLimitDefinition),t);Wo.default=WT});var dy=Ie((xa,uy)=>{"use strict";Object.defineProperty(xa,"__esModule",{value:!0});var Ko=iy(),KT=ay(),Yp=it(),cy=new Yp.Name("fullFormats"),JT=new Yp.Name("fastFormats"),Xp=(t,e={keywords:!0})=>{if(Array.isArray(e))return ly(t,e,Ko.fullFormats,cy),t;let[r,n]=e.mode==="fast"?[Ko.fastFormats,JT]:[Ko.fullFormats,cy],s=e.formats||Ko.formatNames;return ly(t,s,r,n),e.keywords&&(0,KT.default)(t),t};Xp.get=(t,e="full")=>{let n=(e==="fast"?Ko.fastFormats:Ko.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function ly(t,e,r,n){var s,o;(s=(o=t.opts.code).formats)!==null&&s!==void 0||(o.formats=(0,Yp._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}uy.exports=xa=Xp;Object.defineProperty(xa,"__esModule",{value:!0});xa.default=Xp});var G={};wu(G,{BRAND:()=>k4,DIRTY:()=>xs,EMPTY_PATH:()=>t4,INVALID:()=>Ye,NEVER:()=>i5,OK:()=>cr,ParseStatus:()=>tr,Schema:()=>ot,ZodAny:()=>Xn,ZodArray:()=>Dn,ZodBigInt:()=>Ss,ZodBoolean:()=>Es,ZodBranded:()=>wi,ZodCatch:()=>Cs,ZodDate:()=>Ts,ZodDefault:()=>Ns,ZodDiscriminatedUnion:()=>Ha,ZodEffects:()=>Ur,ZodEnum:()=>Os,ZodError:()=>wr,ZodFirstPartyTypeKind:()=>be,ZodFunction:()=>Ga,ZodIntersection:()=>Ms,ZodIssueCode:()=>_e,ZodLazy:()=>zs,ZodLiteral:()=>Is,ZodMap:()=>xo,ZodNaN:()=>So,ZodNativeEnum:()=>As,ZodNever:()=>ln,ZodNull:()=>Rs,ZodNullable:()=>Tn,ZodNumber:()=>ks,ZodObject:()=>kr,ZodOptional:()=>xr,ZodParsedType:()=>Oe,ZodPipeline:()=>xi,ZodPromise:()=>Wn,ZodReadonly:()=>js,ZodRecord:()=>Ua,ZodSchema:()=>ot,ZodSet:()=>ko,ZodString:()=>Yn,ZodSymbol:()=>vo,ZodTransformer:()=>Ur,ZodTuple:()=>En,ZodType:()=>ot,ZodUndefined:()=>$s,ZodUnion:()=>Ps,ZodUnknown:()=>jn,ZodVoid:()=>wo,addIssueToContext:()=>Ee,any:()=>I4,array:()=>C4,bigint:()=>$4,boolean:()=>j1,coerce:()=>o5,custom:()=>A1,date:()=>R4,datetimeRegex:()=>I1,defaultErrorMap:()=>Nn,discriminatedUnion:()=>L4,effect:()=>K4,enum:()=>Y4,function:()=>H4,getErrorMap:()=>_o,getParsedType:()=>Sn,instanceof:()=>E4,intersection:()=>Z4,isAborted:()=>Va,isAsync:()=>bo,isDirty:()=>Fa,isValid:()=>Gn,late:()=>S4,lazy:()=>U4,literal:()=>G4,makeIssue:()=>vi,map:()=>V4,nan:()=>T4,nativeEnum:()=>X4,never:()=>A4,null:()=>z4,nullable:()=>Q4,number:()=>C1,object:()=>Eu,objectUtil:()=>xu,oboolean:()=>s5,onumber:()=>n5,optional:()=>J4,ostring:()=>r5,pipeline:()=>t5,preprocess:()=>e5,promise:()=>W4,quotelessJson:()=>J3,record:()=>q4,set:()=>F4,setErrorMap:()=>e4,strictObject:()=>j4,string:()=>N1,symbol:()=>P4,transformer:()=>K4,tuple:()=>B4,undefined:()=>M4,union:()=>D4,unknown:()=>O4,util:()=>lt,void:()=>N4});var lt;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let o={};for(let i of s)o[i]=i;return o},t.getValidEnumValues=s=>{let o=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),i={};for(let a of o)i[a]=s[a];return t.objectValues(i)},t.objectValues=s=>t.objectKeys(s).map(function(o){return s[o]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let o=[];for(let i in s)Object.prototype.hasOwnProperty.call(s,i)&&o.push(i);return o},t.find=(s,o)=>{for(let i of s)if(o(i))return i},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,o=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(o)}t.joinValues=n,t.jsonStringifyReplacer=(s,o)=>typeof o=="bigint"?o.toString():o})(lt||(lt={}));var xu;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(xu||(xu={}));var Oe=lt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Sn=t=>{switch(typeof t){case"undefined":return Oe.undefined;case"string":return Oe.string;case"number":return Number.isNaN(t)?Oe.nan:Oe.number;case"boolean":return Oe.boolean;case"function":return Oe.function;case"bigint":return Oe.bigint;case"symbol":return Oe.symbol;case"object":return Array.isArray(t)?Oe.array:t===null?Oe.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Oe.promise:typeof Map<"u"&&t instanceof Map?Oe.map:typeof Set<"u"&&t instanceof Set?Oe.set:typeof Date<"u"&&t instanceof Date?Oe.date:Oe.object;default:return Oe.unknown}};var _e=lt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),J3=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),wr=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(o){return o.message},n={_errors:[]},s=o=>{for(let i of o.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;for(;c<i.path.length;){let d=i.path[c];c===i.path.length-1?(a[d]=a[d]||{_errors:[]},a[d]._errors.push(r(i))):a[d]=a[d]||{_errors:[]},a=a[d],c++}}};return s(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,lt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)if(s.path.length>0){let o=s.path[0];r[o]=r[o]||[],r[o].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};wr.create=t=>new wr(t);var Q3=(t,e)=>{let r;switch(t.code){case _e.invalid_type:t.received===Oe.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case _e.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,lt.jsonStringifyReplacer)}`;break;case _e.unrecognized_keys:r=`Unrecognized key(s) in object: ${lt.joinValues(t.keys,", ")}`;break;case _e.invalid_union:r="Invalid input";break;case _e.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${lt.joinValues(t.options)}`;break;case _e.invalid_enum_value:r=`Invalid enum value. Expected ${lt.joinValues(t.options)}, received '${t.received}'`;break;case _e.invalid_arguments:r="Invalid function arguments";break;case _e.invalid_return_type:r="Invalid function return type";break;case _e.invalid_date:r="Invalid date";break;case _e.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:lt.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case _e.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case _e.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case _e.custom:r="Invalid input";break;case _e.invalid_intersection_types:r="Intersection results could not be merged";break;case _e.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case _e.not_finite:r="Number must be finite";break;default:r=e.defaultError,lt.assertNever(t)}return{message:r}},Nn=Q3;var $1=Nn;function e4(t){$1=t}function _o(){return $1}var vi=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,o=[...r,...s.path||[]],i={...s,path:o};if(s.message!==void 0)return{...s,path:o,message:s.message};let a="",c=n.filter(d=>!!d).slice().reverse();for(let d of c)a=d(i,{data:e,defaultError:a}).message;return{...s,path:o,message:a}},t4=[];function Ee(t,e){let r=_o(),n=vi({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Nn?void 0:Nn].filter(s=>!!s)});t.common.issues.push(n)}var tr=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return Ye;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r){let o=await s.key,i=await s.value;n.push({key:o,value:i})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:o,value:i}=s;if(o.status==="aborted"||i.status==="aborted")return Ye;o.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[o.value]=i.value)}return{status:e.value,value:n}}},Ye=Object.freeze({status:"aborted"}),xs=t=>({status:"dirty",value:t}),cr=t=>({status:"valid",value:t}),Va=t=>t.status==="aborted",Fa=t=>t.status==="dirty",Gn=t=>t.status==="valid",bo=t=>typeof Promise<"u"&&t instanceof Promise;var Le;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Le||(Le={}));var Hr=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},R1=(t,e)=>{if(Gn(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new wr(t.common.issues);return this._error=r,this._error}}};function nt(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,a)=>{let{message:c}=t;return i.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:s}}var ot=class{get description(){return this._def.description}_getType(e){return Sn(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Sn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new tr,ctx:{common:e.parent.common,data:e.data,parsedType:Sn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(bo(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Sn(e)},s=this._parseSync({data:e,path:n.path,parent:n});return R1(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Sn(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return Gn(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>Gn(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Sn(e)},s=this._parse({data:e,path:n.path,parent:n}),o=await(bo(s)?s:Promise.resolve(s));return R1(n,o)}refine(e,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,o)=>{let i=e(s),a=()=>o.addIssue({code:_e.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new Ur({schema:this,typeName:be.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return xr.create(this,this._def)}nullable(){return Tn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Dn.create(this)}promise(){return Wn.create(this,this._def)}or(e){return Ps.create([this,e],this._def)}and(e){return Ms.create(this,e,this._def)}transform(e){return new Ur({...nt(this._def),schema:this,typeName:be.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Ns({...nt(this._def),innerType:this,defaultValue:r,typeName:be.ZodDefault})}brand(){return new wi({typeName:be.ZodBranded,type:this,...nt(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new Cs({...nt(this._def),innerType:this,catchValue:r,typeName:be.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return xi.create(this,e)}readonly(){return js.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},r4=/^c[^\s-]{8,}$/i,n4=/^[0-9a-z]+$/,s4=/^[0-9A-HJKMNP-TV-Z]{26}$/i,o4=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,i4=/^[a-z0-9_-]{21}$/i,a4=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,c4=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,l4=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,u4="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ku,d4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,f4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,h4=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,p4=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,m4=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,g4=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,M1="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",_4=new RegExp(`^${M1}$`);function z1(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function b4(t){return new RegExp(`^${z1(t)}$`)}function I1(t){let e=`${M1}T${z1(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function y4(t,e){return!!((e==="v4"||!e)&&d4.test(t)||(e==="v6"||!e)&&h4.test(t))}function v4(t,e){if(!a4.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function w4(t,e){return!!((e==="v4"||!e)&&f4.test(t)||(e==="v6"||!e)&&p4.test(t))}var Yn=class t extends ot{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Oe.string){let o=this._getOrReturnCtx(e);return Ee(o,{code:_e.invalid_type,expected:Oe.string,received:o.parsedType}),Ye}let n=new tr,s;for(let o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(s=this._getOrReturnCtx(e,s),Ee(s,{code:_e.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="max")e.data.length>o.value&&(s=this._getOrReturnCtx(e,s),Ee(s,{code:_e.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){let i=e.data.length>o.value,a=e.data.length<o.value;(i||a)&&(s=this._getOrReturnCtx(e,s),i?Ee(s,{code:_e.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&Ee(s,{code:_e.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")l4.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"email",code:_e.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")ku||(ku=new RegExp(u4,"u")),ku.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"emoji",code:_e.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")o4.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"uuid",code:_e.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")i4.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"nanoid",code:_e.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")r4.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"cuid",code:_e.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")n4.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"cuid2",code:_e.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")s4.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"ulid",code:_e.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),Ee(s,{validation:"url",code:_e.invalid_string,message:o.message}),n.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"regex",code:_e.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(s=this._getOrReturnCtx(e,s),Ee(s,{code:_e.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(s=this._getOrReturnCtx(e,s),Ee(s,{code:_e.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(s=this._getOrReturnCtx(e,s),Ee(s,{code:_e.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?I1(o).test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{code:_e.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?_4.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{code:_e.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?b4(o).test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{code:_e.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?c4.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"duration",code:_e.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?y4(e.data,o.version)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"ip",code:_e.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?v4(e.data,o.alg)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"jwt",code:_e.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?w4(e.data,o.version)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"cidr",code:_e.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?m4.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"base64",code:_e.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?g4.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"base64url",code:_e.invalid_string,message:o.message}),n.dirty()):lt.assertNever(o);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:_e.invalid_string,...Le.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Le.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Le.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Le.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Le.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Le.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Le.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Le.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Le.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Le.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Le.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Le.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Le.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Le.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Le.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...Le.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Le.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Le.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...Le.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Le.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Le.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Le.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Le.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Le.errToObj(r)})}nonempty(e){return this.min(1,Le.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Yn.create=t=>new Yn({checks:[],typeName:be.ZodString,coerce:t?.coerce??!1,...nt(t)});function x4(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,o=Number.parseInt(t.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return o%i/10**s}var ks=class t extends ot{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==Oe.number){let o=this._getOrReturnCtx(e);return Ee(o,{code:_e.invalid_type,expected:Oe.number,received:o.parsedType}),Ye}let n,s=new tr;for(let o of this._def.checks)o.kind==="int"?lt.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),Ee(n,{code:_e.invalid_type,expected:"integer",received:"float",message:o.message}),s.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),Ee(n,{code:_e.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),Ee(n,{code:_e.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),s.dirty()):o.kind==="multipleOf"?x4(e.data,o.value)!==0&&(n=this._getOrReturnCtx(e,n),Ee(n,{code:_e.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),Ee(n,{code:_e.not_finite,message:o.message}),s.dirty()):lt.assertNever(o);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Le.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Le.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Le.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Le.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Le.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Le.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Le.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Le.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Le.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Le.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Le.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Le.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Le.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Le.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&lt.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};ks.create=t=>new ks({checks:[],typeName:be.ZodNumber,coerce:t?.coerce||!1,...nt(t)});var Ss=class t extends ot{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==Oe.bigint)return this._getInvalidInput(e);let n,s=new tr;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),Ee(n,{code:_e.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),Ee(n,{code:_e.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),Ee(n,{code:_e.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):lt.assertNever(o);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return Ee(r,{code:_e.invalid_type,expected:Oe.bigint,received:r.parsedType}),Ye}gte(e,r){return this.setLimit("min",e,!0,Le.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Le.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Le.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Le.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Le.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Le.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Le.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Le.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Le.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Le.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Ss.create=t=>new Ss({checks:[],typeName:be.ZodBigInt,coerce:t?.coerce??!1,...nt(t)});var Es=class extends ot{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Oe.boolean){let n=this._getOrReturnCtx(e);return Ee(n,{code:_e.invalid_type,expected:Oe.boolean,received:n.parsedType}),Ye}return cr(e.data)}};Es.create=t=>new Es({typeName:be.ZodBoolean,coerce:t?.coerce||!1,...nt(t)});var Ts=class t extends ot{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Oe.date){let o=this._getOrReturnCtx(e);return Ee(o,{code:_e.invalid_type,expected:Oe.date,received:o.parsedType}),Ye}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return Ee(o,{code:_e.invalid_date}),Ye}let n=new tr,s;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(s=this._getOrReturnCtx(e,s),Ee(s,{code:_e.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(s=this._getOrReturnCtx(e,s),Ee(s,{code:_e.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):lt.assertNever(o);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Le.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Le.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};Ts.create=t=>new Ts({checks:[],coerce:t?.coerce||!1,typeName:be.ZodDate,...nt(t)});var vo=class extends ot{_parse(e){if(this._getType(e)!==Oe.symbol){let n=this._getOrReturnCtx(e);return Ee(n,{code:_e.invalid_type,expected:Oe.symbol,received:n.parsedType}),Ye}return cr(e.data)}};vo.create=t=>new vo({typeName:be.ZodSymbol,...nt(t)});var $s=class extends ot{_parse(e){if(this._getType(e)!==Oe.undefined){let n=this._getOrReturnCtx(e);return Ee(n,{code:_e.invalid_type,expected:Oe.undefined,received:n.parsedType}),Ye}return cr(e.data)}};$s.create=t=>new $s({typeName:be.ZodUndefined,...nt(t)});var Rs=class extends ot{_parse(e){if(this._getType(e)!==Oe.null){let n=this._getOrReturnCtx(e);return Ee(n,{code:_e.invalid_type,expected:Oe.null,received:n.parsedType}),Ye}return cr(e.data)}};Rs.create=t=>new Rs({typeName:be.ZodNull,...nt(t)});var Xn=class extends ot{constructor(){super(...arguments),this._any=!0}_parse(e){return cr(e.data)}};Xn.create=t=>new Xn({typeName:be.ZodAny,...nt(t)});var jn=class extends ot{constructor(){super(...arguments),this._unknown=!0}_parse(e){return cr(e.data)}};jn.create=t=>new jn({typeName:be.ZodUnknown,...nt(t)});var ln=class extends ot{_parse(e){let r=this._getOrReturnCtx(e);return Ee(r,{code:_e.invalid_type,expected:Oe.never,received:r.parsedType}),Ye}};ln.create=t=>new ln({typeName:be.ZodNever,...nt(t)});var wo=class extends ot{_parse(e){if(this._getType(e)!==Oe.undefined){let n=this._getOrReturnCtx(e);return Ee(n,{code:_e.invalid_type,expected:Oe.void,received:n.parsedType}),Ye}return cr(e.data)}};wo.create=t=>new wo({typeName:be.ZodVoid,...nt(t)});var Dn=class t extends ot{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==Oe.array)return Ee(r,{code:_e.invalid_type,expected:Oe.array,received:r.parsedType}),Ye;if(s.exactLength!==null){let i=r.data.length>s.exactLength.value,a=r.data.length<s.exactLength.value;(i||a)&&(Ee(r,{code:i?_e.too_big:_e.too_small,minimum:a?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(Ee(r,{code:_e.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(Ee(r,{code:_e.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,a)=>s.type._parseAsync(new Hr(r,i,r.path,a)))).then(i=>tr.mergeArray(n,i));let o=[...r.data].map((i,a)=>s.type._parseSync(new Hr(r,i,r.path,a)));return tr.mergeArray(n,o)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:Le.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:Le.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:Le.toString(r)}})}nonempty(e){return this.min(1,e)}};Dn.create=(t,e)=>new Dn({type:t,minLength:null,maxLength:null,exactLength:null,typeName:be.ZodArray,...nt(e)});function yo(t){if(t instanceof kr){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=xr.create(yo(n))}return new kr({...t._def,shape:()=>e})}else return t instanceof Dn?new Dn({...t._def,type:yo(t.element)}):t instanceof xr?xr.create(yo(t.unwrap())):t instanceof Tn?Tn.create(yo(t.unwrap())):t instanceof En?En.create(t.items.map(e=>yo(e))):t}var kr=class t extends ot{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=lt.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==Oe.object){let d=this._getOrReturnCtx(e);return Ee(d,{code:_e.invalid_type,expected:Oe.object,received:d.parsedType}),Ye}let{status:n,ctx:s}=this._processInputParams(e),{shape:o,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof ln&&this._def.unknownKeys==="strip"))for(let d in s.data)i.includes(d)||a.push(d);let c=[];for(let d of i){let l=o[d],u=s.data[d];c.push({key:{status:"valid",value:d},value:l._parse(new Hr(s,u,s.path,d)),alwaysSet:d in s.data})}if(this._def.catchall instanceof ln){let d=this._def.unknownKeys;if(d==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(d==="strict")a.length>0&&(Ee(s,{code:_e.unrecognized_keys,keys:a}),n.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let l of a){let u=s.data[l];c.push({key:{status:"valid",value:l},value:d._parse(new Hr(s,u,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let d=[];for(let l of c){let u=await l.key,h=await l.value;d.push({key:u,value:h,alwaysSet:l.alwaysSet})}return d}).then(d=>tr.mergeObjectSync(n,d)):tr.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return Le.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:Le.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:be.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of lt.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of lt.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return yo(this)}partial(e){let r={};for(let n of lt.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of lt.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof xr;)o=o._def.innerType;r[n]=o}return new t({...this._def,shape:()=>r})}keyof(){return O1(lt.objectKeys(this.shape))}};kr.create=(t,e)=>new kr({shape:()=>t,unknownKeys:"strip",catchall:ln.create(),typeName:be.ZodObject,...nt(e)});kr.strictCreate=(t,e)=>new kr({shape:()=>t,unknownKeys:"strict",catchall:ln.create(),typeName:be.ZodObject,...nt(e)});kr.lazycreate=(t,e)=>new kr({shape:t,unknownKeys:"strip",catchall:ln.create(),typeName:be.ZodObject,...nt(e)});var Ps=class extends ot{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(o){for(let a of o)if(a.result.status==="valid")return a.result;for(let a of o)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let i=o.map(a=>new wr(a.ctx.common.issues));return Ee(r,{code:_e.invalid_union,unionErrors:i}),Ye}if(r.common.async)return Promise.all(n.map(async o=>{let i={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(s);{let o,i=[];for(let c of n){let d={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:d});if(l.status==="valid")return l;l.status==="dirty"&&!o&&(o={result:l,ctx:d}),d.common.issues.length&&i.push(d.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let a=i.map(c=>new wr(c));return Ee(r,{code:_e.invalid_union,unionErrors:a}),Ye}}get options(){return this._def.options}};Ps.create=(t,e)=>new Ps({options:t,typeName:be.ZodUnion,...nt(e)});var Cn=t=>t instanceof zs?Cn(t.schema):t instanceof Ur?Cn(t.innerType()):t instanceof Is?[t.value]:t instanceof Os?t.options:t instanceof As?lt.objectValues(t.enum):t instanceof Ns?Cn(t._def.innerType):t instanceof $s?[void 0]:t instanceof Rs?[null]:t instanceof xr?[void 0,...Cn(t.unwrap())]:t instanceof Tn?[null,...Cn(t.unwrap())]:t instanceof wi||t instanceof js?Cn(t.unwrap()):t instanceof Cs?Cn(t._def.innerType):[],Ha=class t extends ot{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==Oe.object)return Ee(r,{code:_e.invalid_type,expected:Oe.object,received:r.parsedType}),Ye;let n=this.discriminator,s=r.data[n],o=this.optionsMap.get(s);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(Ee(r,{code:_e.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Ye)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=new Map;for(let o of r){let i=Cn(o.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of i){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,o)}}return new t({typeName:be.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...nt(n)})}};function Su(t,e){let r=Sn(t),n=Sn(e);if(t===e)return{valid:!0,data:t};if(r===Oe.object&&n===Oe.object){let s=lt.objectKeys(e),o=lt.objectKeys(t).filter(a=>s.indexOf(a)!==-1),i={...t,...e};for(let a of o){let c=Su(t[a],e[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(r===Oe.array&&n===Oe.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let o=0;o<t.length;o++){let i=t[o],a=e[o],c=Su(i,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===Oe.date&&n===Oe.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Ms=class extends ot{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(o,i)=>{if(Va(o)||Va(i))return Ye;let a=Su(o.value,i.value);return a.valid?((Fa(o)||Fa(i))&&r.dirty(),{status:r.value,value:a.data}):(Ee(n,{code:_e.invalid_intersection_types}),Ye)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,i])=>s(o,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Ms.create=(t,e,r)=>new Ms({left:t,right:e,typeName:be.ZodIntersection,...nt(r)});var En=class t extends ot{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Oe.array)return Ee(n,{code:_e.invalid_type,expected:Oe.array,received:n.parsedType}),Ye;if(n.data.length<this._def.items.length)return Ee(n,{code:_e.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Ye;!this._def.rest&&n.data.length>this._def.items.length&&(Ee(n,{code:_e.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let o=[...n.data].map((i,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new Hr(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(o).then(i=>tr.mergeArray(r,i)):tr.mergeArray(r,o)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};En.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new En({items:t,typeName:be.ZodTuple,rest:null,...nt(e)})};var Ua=class t extends ot{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Oe.object)return Ee(n,{code:_e.invalid_type,expected:Oe.object,received:n.parsedType}),Ye;let s=[],o=this._def.keyType,i=this._def.valueType;for(let a in n.data)s.push({key:o._parse(new Hr(n,a,n.path,a)),value:i._parse(new Hr(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?tr.mergeObjectAsync(r,s):tr.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof ot?new t({keyType:e,valueType:r,typeName:be.ZodRecord,...nt(n)}):new t({keyType:Yn.create(),valueType:e,typeName:be.ZodRecord,...nt(r)})}},xo=class extends ot{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Oe.map)return Ee(n,{code:_e.invalid_type,expected:Oe.map,received:n.parsedType}),Ye;let s=this._def.keyType,o=this._def.valueType,i=[...n.data.entries()].map(([a,c],d)=>({key:s._parse(new Hr(n,a,n.path,[d,"key"])),value:o._parse(new Hr(n,c,n.path,[d,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of i){let d=await c.key,l=await c.value;if(d.status==="aborted"||l.status==="aborted")return Ye;(d.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(d.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of i){let d=c.key,l=c.value;if(d.status==="aborted"||l.status==="aborted")return Ye;(d.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(d.value,l.value)}return{status:r.value,value:a}}}};xo.create=(t,e,r)=>new xo({valueType:e,keyType:t,typeName:be.ZodMap,...nt(r)});var ko=class t extends ot{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Oe.set)return Ee(n,{code:_e.invalid_type,expected:Oe.set,received:n.parsedType}),Ye;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(Ee(n,{code:_e.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(Ee(n,{code:_e.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let o=this._def.valueType;function i(c){let d=new Set;for(let l of c){if(l.status==="aborted")return Ye;l.status==="dirty"&&r.dirty(),d.add(l.value)}return{status:r.value,value:d}}let a=[...n.data.values()].map((c,d)=>o._parse(new Hr(n,c,n.path,d)));return n.common.async?Promise.all(a).then(c=>i(c)):i(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:Le.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:Le.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};ko.create=(t,e)=>new ko({valueType:t,minSize:null,maxSize:null,typeName:be.ZodSet,...nt(e)});var Ga=class t extends ot{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==Oe.function)return Ee(r,{code:_e.invalid_type,expected:Oe.function,received:r.parsedType}),Ye;function n(a,c){return vi({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,_o(),Nn].filter(d=>!!d),issueData:{code:_e.invalid_arguments,argumentsError:c}})}function s(a,c){return vi({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,_o(),Nn].filter(d=>!!d),issueData:{code:_e.invalid_return_type,returnTypeError:c}})}let o={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof Wn){let a=this;return cr(async function(...c){let d=new wr([]),l=await a._def.args.parseAsync(c,o).catch(p=>{throw d.addIssue(n(c,p)),d}),u=await Reflect.apply(i,this,l);return await a._def.returns._def.type.parseAsync(u,o).catch(p=>{throw d.addIssue(s(u,p)),d})})}else{let a=this;return cr(function(...c){let d=a._def.args.safeParse(c,o);if(!d.success)throw new wr([n(c,d.error)]);let l=Reflect.apply(i,this,d.data),u=a._def.returns.safeParse(l,o);if(!u.success)throw new wr([s(l,u.error)]);return u.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:En.create(e).rest(jn.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||En.create([]).rest(jn.create()),returns:r||jn.create(),typeName:be.ZodFunction,...nt(n)})}},zs=class extends ot{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};zs.create=(t,e)=>new zs({getter:t,typeName:be.ZodLazy,...nt(e)});var Is=class extends ot{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return Ee(r,{received:r.data,code:_e.invalid_literal,expected:this._def.value}),Ye}return{status:"valid",value:e.data}}get value(){return this._def.value}};Is.create=(t,e)=>new Is({value:t,typeName:be.ZodLiteral,...nt(e)});function O1(t,e){return new Os({values:t,typeName:be.ZodEnum,...nt(e)})}var Os=class t extends ot{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return Ee(r,{expected:lt.joinValues(n),received:r.parsedType,code:_e.invalid_type}),Ye}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return Ee(r,{received:r.data,code:_e.invalid_enum_value,options:n}),Ye}return cr(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};Os.create=O1;var As=class extends ot{_parse(e){let r=lt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Oe.string&&n.parsedType!==Oe.number){let s=lt.objectValues(r);return Ee(n,{expected:lt.joinValues(s),received:n.parsedType,code:_e.invalid_type}),Ye}if(this._cache||(this._cache=new Set(lt.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=lt.objectValues(r);return Ee(n,{received:n.data,code:_e.invalid_enum_value,options:s}),Ye}return cr(e.data)}get enum(){return this._def.values}};As.create=(t,e)=>new As({values:t,typeName:be.ZodNativeEnum,...nt(e)});var Wn=class extends ot{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==Oe.promise&&r.common.async===!1)return Ee(r,{code:_e.invalid_type,expected:Oe.promise,received:r.parsedType}),Ye;let n=r.parsedType===Oe.promise?r.data:Promise.resolve(r.data);return cr(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Wn.create=(t,e)=>new Wn({type:t,typeName:be.ZodPromise,...nt(e)});var Ur=class extends ot{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===be.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,o={addIssue:i=>{Ee(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),s.type==="preprocess"){let i=s.transform(n.data,o);if(n.common.async)return Promise.resolve(i).then(async a=>{if(r.value==="aborted")return Ye;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?Ye:c.status==="dirty"?xs(c.value):r.value==="dirty"?xs(c.value):c});{if(r.value==="aborted")return Ye;let a=this._def.schema._parseSync({data:i,path:n.path,parent:n});return a.status==="aborted"?Ye:a.status==="dirty"?xs(a.value):r.value==="dirty"?xs(a.value):a}}if(s.type==="refinement"){let i=a=>{let c=s.refinement(a,o);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?Ye:(a.status==="dirty"&&r.dirty(),i(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?Ye:(a.status==="dirty"&&r.dirty(),i(a.value).then(()=>({status:r.value,value:a.value}))))}if(s.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Gn(i))return Ye;let a=s.transform(i.value,o);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>Gn(i)?Promise.resolve(s.transform(i.value,o)).then(a=>({status:r.value,value:a})):Ye);lt.assertNever(s)}};Ur.create=(t,e,r)=>new Ur({schema:t,typeName:be.ZodEffects,effect:e,...nt(r)});Ur.createWithPreprocess=(t,e,r)=>new Ur({schema:e,effect:{type:"preprocess",transform:t},typeName:be.ZodEffects,...nt(r)});var xr=class extends ot{_parse(e){return this._getType(e)===Oe.undefined?cr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};xr.create=(t,e)=>new xr({innerType:t,typeName:be.ZodOptional,...nt(e)});var Tn=class extends ot{_parse(e){return this._getType(e)===Oe.null?cr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Tn.create=(t,e)=>new Tn({innerType:t,typeName:be.ZodNullable,...nt(e)});var Ns=class extends ot{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===Oe.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Ns.create=(t,e)=>new Ns({innerType:t,typeName:be.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...nt(e)});var Cs=class extends ot{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return bo(s)?s.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new wr(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new wr(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Cs.create=(t,e)=>new Cs({innerType:t,typeName:be.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...nt(e)});var So=class extends ot{_parse(e){if(this._getType(e)!==Oe.nan){let n=this._getOrReturnCtx(e);return Ee(n,{code:_e.invalid_type,expected:Oe.nan,received:n.parsedType}),Ye}return{status:"valid",value:e.data}}};So.create=t=>new So({typeName:be.ZodNaN,...nt(t)});var k4=Symbol("zod_brand"),wi=class extends ot{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},xi=class t extends ot{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Ye:o.status==="dirty"?(r.dirty(),xs(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?Ye:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:be.ZodPipeline})}},js=class extends ot{_parse(e){let r=this._def.innerType._parse(e),n=s=>(Gn(s)&&(s.value=Object.freeze(s.value)),s);return bo(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};js.create=(t,e)=>new js({innerType:t,typeName:be.ZodReadonly,...nt(e)});function P1(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function A1(t,e={},r){return t?Xn.create().superRefine((n,s)=>{let o=t(n);if(o instanceof Promise)return o.then(i=>{if(!i){let a=P1(e,n),c=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!o){let i=P1(e,n),a=i.fatal??r??!0;s.addIssue({code:"custom",...i,fatal:a})}}):Xn.create()}var S4={object:kr.lazycreate},be;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(be||(be={}));var E4=(t,e={message:`Input not instance of ${t.name}`})=>A1(r=>r instanceof t,e),N1=Yn.create,C1=ks.create,T4=So.create,$4=Ss.create,j1=Es.create,R4=Ts.create,P4=vo.create,M4=$s.create,z4=Rs.create,I4=Xn.create,O4=jn.create,A4=ln.create,N4=wo.create,C4=Dn.create,Eu=kr.create,j4=kr.strictCreate,D4=Ps.create,L4=Ha.create,Z4=Ms.create,B4=En.create,q4=Ua.create,V4=xo.create,F4=ko.create,H4=Ga.create,U4=zs.create,G4=Is.create,Y4=Os.create,X4=As.create,W4=Wn.create,K4=Ur.create,J4=xr.create,Q4=Tn.create,e5=Ur.createWithPreprocess,t5=xi.create,r5=()=>N1().optional(),n5=()=>C1().optional(),s5=()=>j1().optional(),o5={string:t=>Yn.create({...t,coerce:!0}),number:t=>ks.create({...t,coerce:!0}),boolean:t=>Es.create({...t,coerce:!0}),bigint:t=>Ss.create({...t,coerce:!0}),date:t=>Ts.create({...t,coerce:!0})};var i5=Ye;var a5=Object.freeze({status:"aborted"});function le(t,e,r){function n(a,c){var d;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(d=a._zod).traits??(d.traits=new Set),a._zod.traits.add(t),e(a,c);for(let l in i.prototype)l in a||Object.defineProperty(a,l,{value:i.prototype[l].bind(a)});a._zod.constr=i,a._zod.def=c}let s=r?.Parent??Object;class o extends s{}Object.defineProperty(o,"name",{value:t});function i(a){var c;let d=r?.Parent?new o:this;n(d,a),(c=d._zod).deferred??(c.deferred=[]);for(let l of d._zod.deferred)l();return d}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(i,"name",{value:t}),i}var c5=Symbol("zod_brand"),Ln=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ya={};function Cr(t){return t&&Object.assign(Ya,t),Ya}var ut={};wu(ut,{BIGINT_FORMAT_RANGES:()=>L1,Class:()=>$u,NUMBER_FORMAT_RANGES:()=>Au,aborted:()=>Ls,allowsEval:()=>zu,assert:()=>h5,assertEqual:()=>l5,assertIs:()=>d5,assertNever:()=>f5,assertNotEqual:()=>u5,assignProp:()=>Mu,cached:()=>Ei,captureStackTrace:()=>Wa,cleanEnum:()=>T5,cleanRegex:()=>$i,clone:()=>jr,createTransparentProxy:()=>y5,defineLazy:()=>$t,esc:()=>Ds,escapeRegex:()=>Kn,extend:()=>x5,finalizeIssue:()=>un,floatSafeRemainder:()=>Pu,getElementAtPath:()=>p5,getEnumValues:()=>Si,getLengthableOrigin:()=>Ri,getParsedType:()=>b5,getSizableOrigin:()=>Z1,isObject:()=>Eo,isPlainObject:()=>To,issue:()=>Nu,joinValues:()=>Xa,jsonStringifyReplacer:()=>Ru,merge:()=>k5,normalizeParams:()=>Xe,nullish:()=>Ti,numKeys:()=>_5,omit:()=>w5,optionalKeys:()=>Ou,partial:()=>S5,pick:()=>v5,prefixIssues:()=>$n,primitiveTypes:()=>D1,promiseAllObject:()=>m5,propertyKeyTypes:()=>Iu,randomString:()=>g5,required:()=>E5,stringifyPrimitive:()=>Ka,unwrapMessage:()=>ki});function l5(t){return t}function u5(t){return t}function d5(t){}function f5(t){throw new Error}function h5(t){}function Si(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,s])=>e.indexOf(+n)===-1).map(([n,s])=>s)}function Xa(t,e="|"){return t.map(r=>Ka(r)).join(e)}function Ru(t,e){return typeof e=="bigint"?e.toString():e}function Ei(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Ti(t){return t==null}function $i(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function Pu(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,o=Number.parseInt(t.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return o%i/10**s}function $t(t,e,r){Object.defineProperty(t,e,{get(){{let s=r();return t[e]=s,s}throw new Error("cached value already set")},set(s){Object.defineProperty(t,e,{value:s})},configurable:!0})}function Mu(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function p5(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function m5(t){let e=Object.keys(t),r=e.map(n=>t[n]);return Promise.all(r).then(n=>{let s={};for(let o=0;o<e.length;o++)s[e[o]]=n[o];return s})}function g5(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function Ds(t){return JSON.stringify(t)}var Wa=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function Eo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var zu=Ei(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function To(t){if(Eo(t)===!1)return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(Eo(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function _5(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var b5=t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},Iu=new Set(["string","number","symbol"]),D1=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Kn(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function jr(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function Xe(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function y5(t){let e;return new Proxy({},{get(r,n,s){return e??(e=t()),Reflect.get(e,n,s)},set(r,n,s,o){return e??(e=t()),Reflect.set(e,n,s,o)},has(r,n){return e??(e=t()),Reflect.has(e,n)},deleteProperty(r,n){return e??(e=t()),Reflect.deleteProperty(e,n)},ownKeys(r){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,n){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,n)},defineProperty(r,n,s){return e??(e=t()),Reflect.defineProperty(e,n,s)}})}function Ka(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function Ou(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var Au={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},L1={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function v5(t,e){let r={},n=t._zod.def;for(let s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&(r[s]=n.shape[s])}return jr(t,{...t._zod.def,shape:r,checks:[]})}function w5(t,e){let r={...t._zod.def.shape},n=t._zod.def;for(let s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&delete r[s]}return jr(t,{...t._zod.def,shape:r,checks:[]})}function x5(t,e){if(!To(e))throw new Error("Invalid input to extend: expected a plain object");let r={...t._zod.def,get shape(){let n={...t._zod.def.shape,...e};return Mu(this,"shape",n),n},checks:[]};return jr(t,r)}function k5(t,e){return jr(t,{...t._zod.def,get shape(){let r={...t._zod.def.shape,...e._zod.def.shape};return Mu(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}function S5(t,e,r){let n=e._zod.def.shape,s={...n};if(r)for(let o in r){if(!(o in n))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(s[o]=t?new t({type:"optional",innerType:n[o]}):n[o])}else for(let o in n)s[o]=t?new t({type:"optional",innerType:n[o]}):n[o];return jr(e,{...e._zod.def,shape:s,checks:[]})}function E5(t,e,r){let n=e._zod.def.shape,s={...n};if(r)for(let o in r){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(s[o]=new t({type:"nonoptional",innerType:n[o]}))}else for(let o in n)s[o]=new t({type:"nonoptional",innerType:n[o]});return jr(e,{...e._zod.def,shape:s,checks:[]})}function Ls(t,e=0){for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function $n(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function ki(t){return typeof t=="string"?t:t?.message}function un(t,e,r){let n={...t,path:t.path??[]};if(!t.message){let s=ki(t.inst?._zod.def?.error?.(t))??ki(e?.error?.(t))??ki(r.customError?.(t))??ki(r.localeError?.(t))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function Z1(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Ri(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Nu(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function T5(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}var $u=class{constructor(...e){}};var B1=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),Object.defineProperty(t,"message",{get(){return JSON.stringify(e,Ru,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Ja=le("$ZodError",B1),Pi=le("$ZodError",B1,{Parent:Error});function Cu(t,e=r=>r.message){let r={},n=[];for(let s of t.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}function ju(t,e){let r=e||function(o){return o.message},n={_errors:[]},s=o=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>s({issues:a}));else if(i.code==="invalid_key")s({issues:i.issues});else if(i.code==="invalid_element")s({issues:i.issues});else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;for(;c<i.path.length;){let d=i.path[c];c===i.path.length-1?(a[d]=a[d]||{_errors:[]},a[d]._errors.push(r(i))):a[d]=a[d]||{_errors:[]},a=a[d],c++}}};return s(t),n}var Du=t=>(e,r,n,s)=>{let o=n?Object.assign(n,{async:!1}):{async:!1},i=e._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new Ln;if(i.issues.length){let a=new(s?.Err??t)(i.issues.map(c=>un(c,o,Cr())));throw Wa(a,s?.callee),a}return i.value},Lu=Du(Pi),Zu=t=>async(e,r,n,s)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},i=e._zod.run({value:r,issues:[]},o);if(i instanceof Promise&&(i=await i),i.issues.length){let a=new(s?.Err??t)(i.issues.map(c=>un(c,o,Cr())));throw Wa(a,s?.callee),a}return i.value},Bu=Zu(Pi),qu=t=>(e,r,n)=>{let s=n?{...n,async:!1}:{async:!1},o=e._zod.run({value:r,issues:[]},s);if(o instanceof Promise)throw new Ln;return o.issues.length?{success:!1,error:new(t??Ja)(o.issues.map(i=>un(i,s,Cr())))}:{success:!0,data:o.value}},Zs=qu(Pi),Vu=t=>async(e,r,n)=>{let s=n?Object.assign(n,{async:!0}):{async:!0},o=e._zod.run({value:r,issues:[]},s);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new t(o.issues.map(i=>un(i,s,Cr())))}:{success:!0,data:o.value}},Bs=Vu(Pi);var q1=/^[cC][^\s-]{8,}$/,V1=/^[0-9a-z]+$/,F1=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,H1=/^[0-9a-vA-V]{20}$/,U1=/^[A-Za-z0-9]{27}$/,G1=/^[a-zA-Z0-9_-]{21}$/,Y1=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var X1=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Fu=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;var W1=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var R5="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function K1(){return new RegExp(R5,"u")}var J1=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Q1=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,e0=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,t0=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,r0=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Hu=/^[A-Za-z0-9_-]*$/,n0=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var s0=/^\+(?:[0-9]){6,14}[0-9]$/,o0="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",i0=new RegExp(`^${o0}$`);function a0(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function c0(t){return new RegExp(`^${a0(t)}$`)}function l0(t){let e=a0({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-]\\d{2}:\\d{2})");let n=`${e}(?:${r.join("|")})`;return new RegExp(`^${o0}T(?:${n})$`)}var u0=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)};var d0=/^\d+$/,f0=/^-?\d+(?:\.\d+)?/i,h0=/true|false/i,p0=/null/i;var m0=/^[^A-Z]*$/,g0=/^[^a-z]*$/;var rr=le("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),_0={number:"number",bigint:"bigint",object:"date"},Uu=le("$ZodCheckLessThan",(t,e)=>{rr.init(t,e);let r=_0[typeof e.value];t._zod.onattach.push(n=>{let s=n._zod.bag,o=(e.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<o&&(e.inclusive?s.maximum=e.value:s.exclusiveMaximum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:r,code:"too_big",maximum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Gu=le("$ZodCheckGreaterThan",(t,e)=>{rr.init(t,e);let r=_0[typeof e.value];t._zod.onattach.push(n=>{let s=n._zod.bag,o=(e.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>o&&(e.inclusive?s.minimum=e.value:s.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),b0=le("$ZodCheckMultipleOf",(t,e)=>{rr.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):Pu(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),y0=le("$ZodCheckNumberFormat",(t,e)=>{rr.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[s,o]=Au[e.format];t._zod.onattach.push(i=>{let a=i._zod.bag;a.format=e.format,a.minimum=s,a.maximum=o,r&&(a.pattern=d0)}),t._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:e.format,code:"invalid_type",input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort});return}}a<s&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:s,inclusive:!0,inst:t,continue:!e.abort}),a>o&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inst:t})}});var v0=le("$ZodCheckMaxLength",(t,e)=>{var r;rr.init(t,e),(r=t._zod.def).when??(r.when=n=>{let s=n.value;return!Ti(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{let s=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<s&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{let s=n.value;if(s.length<=e.maximum)return;let i=Ri(s);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),w0=le("$ZodCheckMinLength",(t,e)=>{var r;rr.init(t,e),(r=t._zod.def).when??(r.when=n=>{let s=n.value;return!Ti(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{let s=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>s&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{let s=n.value;if(s.length>=e.minimum)return;let i=Ri(s);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),x0=le("$ZodCheckLengthEquals",(t,e)=>{var r;rr.init(t,e),(r=t._zod.def).when??(r.when=n=>{let s=n.value;return!Ti(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{let s=n._zod.bag;s.minimum=e.length,s.maximum=e.length,s.length=e.length}),t._zod.check=n=>{let s=n.value,o=s.length;if(o===e.length)return;let i=Ri(s),a=o>e.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),Mi=le("$ZodCheckStringFormat",(t,e)=>{var r,n;rr.init(t,e),t._zod.onattach.push(s=>{let o=s._zod.bag;o.format=e.format,e.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),k0=le("$ZodCheckRegex",(t,e)=>{Mi.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),S0=le("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=m0),Mi.init(t,e)}),E0=le("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=g0),Mi.init(t,e)}),T0=le("$ZodCheckIncludes",(t,e)=>{rr.init(t,e);let r=Kn(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(s=>{let o=s._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),t._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:t,continue:!e.abort})}}),$0=le("$ZodCheckStartsWith",(t,e)=>{rr.init(t,e);let r=new RegExp(`^${Kn(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),R0=le("$ZodCheckEndsWith",(t,e)=>{rr.init(t,e);let r=new RegExp(`.*${Kn(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}});var P0=le("$ZodCheckOverwrite",(t,e)=>{rr.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});var ec=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
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(`
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 z0={major:4,minor:0,patch:0};var xt=le("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=z0;let n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(let s of n)for(let o of s._zod.onattach)o(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let s=(o,i,a)=>{let c=Ls(o),d;for(let l of i){if(l._zod.def.when){if(!l._zod.def.when(o))continue}else if(c)continue;let u=o.issues.length,h=l._zod.check(o);if(h instanceof Promise&&a?.async===!1)throw new Ln;if(d||h instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await h,o.issues.length!==u&&(c||(c=Ls(o,u)))});else{if(o.issues.length===u)continue;c||(c=Ls(o,u))}}return d?d.then(()=>o):o};t._zod.run=(o,i)=>{let a=t._zod.parse(o,i);if(a instanceof Promise){if(i.async===!1)throw new Ln;return a.then(c=>s(c,n,i))}return s(a,n,i)}}t["~standard"]={validate:s=>{try{let o=Zs(t,s);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return Bs(t,s).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),zi=le("$ZodString",(t,e)=>{xt.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??u0(t._zod.bag),t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),Rt=le("$ZodStringFormat",(t,e)=>{Mi.init(t,e),zi.init(t,e)}),Xu=le("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=X1),Rt.init(t,e)}),Wu=le("$ZodUUID",(t,e)=>{if(e.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(n===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=Fu(n))}else e.pattern??(e.pattern=Fu());Rt.init(t,e)}),Ku=le("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=W1),Rt.init(t,e)}),Ju=le("$ZodURL",(t,e)=>{Rt.init(t,e),t._zod.check=r=>{try{let n=r.value,s=new URL(n),o=s.href;e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(s.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:n0.source,input:r.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:r.value,inst:t,continue:!e.abort})),!n.endsWith("/")&&o.endsWith("/")?r.value=o.slice(0,-1):r.value=o;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}}),Qu=le("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=K1()),Rt.init(t,e)}),ed=le("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=G1),Rt.init(t,e)}),td=le("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=q1),Rt.init(t,e)}),rd=le("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=V1),Rt.init(t,e)}),nd=le("$ZodULID",(t,e)=>{e.pattern??(e.pattern=F1),Rt.init(t,e)}),sd=le("$ZodXID",(t,e)=>{e.pattern??(e.pattern=H1),Rt.init(t,e)}),od=le("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=U1),Rt.init(t,e)}),B0=le("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=l0(e)),Rt.init(t,e)}),q0=le("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=i0),Rt.init(t,e)}),V0=le("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=c0(e)),Rt.init(t,e)}),F0=le("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=Y1),Rt.init(t,e)}),id=le("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=J1),Rt.init(t,e),t._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv4"})}),ad=le("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=Q1),Rt.init(t,e),t._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv6"}),t._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:t,continue:!e.abort})}}}),cd=le("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=e0),Rt.init(t,e)}),ld=le("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=t0),Rt.init(t,e),t._zod.check=r=>{let[n,s]=r.value.split("/");try{if(!s)throw new Error;let o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:t,continue:!e.abort})}}});function H0(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}var ud=le("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=r0),Rt.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),t._zod.check=r=>{H0(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function P5(t){if(!Hu.test(t))return!1;let e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return H0(r)}var dd=le("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Hu),Rt.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),t._zod.check=r=>{P5(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),fd=le("$ZodE164",(t,e)=>{e.pattern??(e.pattern=s0),Rt.init(t,e)});function M5(t,e=null){try{let r=t.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let s=JSON.parse(atob(n));return!("typ"in s&&s?.typ!=="JWT"||!s.alg||e&&(!("alg"in s)||s.alg!==e))}catch{return!1}}var hd=le("$ZodJWT",(t,e)=>{Rt.init(t,e),t._zod.check=r=>{M5(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}});var rc=le("$ZodNumber",(t,e)=>{xt.init(t,e),t._zod.pattern=t._zod.bag.pattern??f0,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=Number(r.value)}catch{}let s=r.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return r;let o=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:s,inst:t,...o?{received:o}:{}}),r}}),pd=le("$ZodNumber",(t,e)=>{y0.init(t,e),rc.init(t,e)}),md=le("$ZodBoolean",(t,e)=>{xt.init(t,e),t._zod.pattern=h0,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=!!r.value}catch{}let s=r.value;return typeof s=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:t}),r}});var gd=le("$ZodNull",(t,e)=>{xt.init(t,e),t._zod.pattern=p0,t._zod.values=new Set([null]),t._zod.parse=(r,n)=>{let s=r.value;return s===null||r.issues.push({expected:"null",code:"invalid_type",input:s,inst:t}),r}});var _d=le("$ZodUnknown",(t,e)=>{xt.init(t,e),t._zod.parse=r=>r}),bd=le("$ZodNever",(t,e)=>{xt.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function I0(t,e,r){t.issues.length&&e.issues.push(...$n(r,t.issues)),e.value[r]=t.value}var yd=le("$ZodArray",(t,e)=>{xt.init(t,e),t._zod.parse=(r,n)=>{let s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:t}),r;r.value=Array(s.length);let o=[];for(let i=0;i<s.length;i++){let a=s[i],c=e.element._zod.run({value:a,issues:[]},n);c instanceof Promise?o.push(c.then(d=>I0(d,r,i))):I0(c,r,i)}return o.length?Promise.all(o).then(()=>r):r}});function tc(t,e,r){t.issues.length&&e.issues.push(...$n(r,t.issues)),e.value[r]=t.value}function O0(t,e,r,n){t.issues.length?n[r]===void 0?r in n?e.value[r]=void 0:e.value[r]=t.value:e.issues.push(...$n(r,t.issues)):t.value===void 0?r in n&&(e.value[r]=void 0):e.value[r]=t.value}var nc=le("$ZodObject",(t,e)=>{xt.init(t,e);let r=Ei(()=>{let u=Object.keys(e.shape);for(let p of u)if(!(e.shape[p]instanceof xt))throw new Error(`Invalid element at key "${p}": expected a Zod schema`);let h=Ou(e.shape);return{shape:e.shape,keys:u,keySet:new Set(u),numKeys:u.length,optionalKeys:new Set(h)}});$t(t._zod,"propValues",()=>{let u=e.shape,h={};for(let p in u){let g=u[p]._zod;if(g.values){h[p]??(h[p]=new Set);for(let x of g.values)h[p].add(x)}}return h});let n=u=>{let h=new ec(["shape","payload","ctx"]),p=r.value,g=_=>{let m=Ds(_);return`shape[${m}]._zod.run({ value: input[${m}], issues: [] }, ctx)`};h.write("const input = payload.value;");let x=Object.create(null),S=0;for(let _ of p.keys)x[_]=`key_${S++}`;h.write("const newResult = {}");for(let _ of p.keys)if(p.optionalKeys.has(_)){let m=x[_];h.write(`const ${m} = ${g(_)};`);let $=Ds(_);h.write(`
12
- if (${m}.issues.length) {
13
- if (input[${$}] === undefined) {
14
- if (${$} in input) {
15
- newResult[${$}] = undefined;
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=Qs(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=Qs(o,u)))});else{if(o.issues.length===u)continue;c||(c=Qs(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=eo(t,s);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return to(t,s).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),Wi=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}}),Mt=le("$ZodStringFormat",(t,e)=>{Gi.init(t,e),Wi.init(t,e)}),Rd=le("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=q0),Mt.init(t,e)}),Id=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());Mt.init(t,e)}),Pd=le("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=F0),Mt.init(t,e)}),Md=le("$ZodURL",(t,e)=>{Mt.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})}}}),Od=le("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=H0()),Mt.init(t,e)}),Ad=le("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=B0),Mt.init(t,e)}),zd=le("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=C0),Mt.init(t,e)}),Nd=le("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=j0),Mt.init(t,e)}),Cd=le("$ZodULID",(t,e)=>{e.pattern??(e.pattern=D0),Mt.init(t,e)}),jd=le("$ZodXID",(t,e)=>{e.pattern??(e.pattern=L0),Mt.init(t,e)}),Dd=le("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=Z0),Mt.init(t,e)}),Ng=le("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=ng(e)),Mt.init(t,e)}),Cg=le("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=eg),Mt.init(t,e)}),jg=le("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=rg(e)),Mt.init(t,e)}),Dg=le("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=V0),Mt.init(t,e)}),Ld=le("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=U0),Mt.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),Mt.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),Mt.init(t,e)}),Vd=le("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=Y0),Mt.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),Mt.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 cS(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),Mt.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),t._zod.check=r=>{cS(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),Hd=le("$ZodE164",(t,e)=>{e.pattern??(e.pattern=J0),Mt.init(t,e)});function lS(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 Ud=le("$ZodJWT",(t,e)=>{Mt.init(t,e),t._zod.check=r=>{lS(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}});var Sc=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),Sc.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 xc(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 kc=le("$ZodObject",(t,e)=>{kt.init(t,e);let r=Vi(()=>{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)}});Pt(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 wc(["shape","payload","ctx"]),p=r.value,m=_=>{let g=Js(_);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=Js(_);f.write(`
12
+ if (${g}.issues.length) {
13
+ if (input[${E}] === undefined) {
14
+ if (${E} in input) {
15
+ newResult[${E}] = undefined;
16
16
  }
17
17
  } else {
18
18
  payload.issues = payload.issues.concat(
19
- ${m}.issues.map((iss) => ({
19
+ ${g}.issues.map((iss) => ({
20
20
  ...iss,
21
- path: iss.path ? [${$}, ...iss.path] : [${$}],
21
+ path: iss.path ? [${E}, ...iss.path] : [${E}],
22
22
  }))
23
23
  );
24
24
  }
25
- } else if (${m}.value === undefined) {
26
- if (${$} in input) newResult[${$}] = undefined;
25
+ } else if (${g}.value === undefined) {
26
+ if (${E} in input) newResult[${E}] = undefined;
27
27
  } else {
28
- newResult[${$}] = ${m}.value;
28
+ newResult[${E}] = ${g}.value;
29
29
  }
30
- `)}else{let m=x[_];h.write(`const ${m} = ${g(_)};`),h.write(`
31
- if (${m}.issues.length) payload.issues = payload.issues.concat(${m}.issues.map(iss => ({
30
+ `)}else{let g=y[_];f.write(`const ${g} = ${m(_)};`),f.write(`
31
+ if (${g}.issues.length) payload.issues = payload.issues.concat(${g}.issues.map(iss => ({
32
32
  ...iss,
33
- path: iss.path ? [${Ds(_)}, ...iss.path] : [${Ds(_)}]
34
- })));`),h.write(`newResult[${Ds(_)}] = ${m}.value`)}h.write("payload.value = newResult;"),h.write("return payload;");let k=h.compile();return(_,m)=>k(u,_,m)},s,o=Eo,i=!Ya.jitless,c=i&&zu.value,d=e.catchall,l;t._zod.parse=(u,h)=>{l??(l=r.value);let p=u.value;if(!o(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:t}),u;let g=[];if(i&&c&&h?.async===!1&&h.jitless!==!0)s||(s=n(e.shape)),u=s(u,h);else{u.value={};let m=l.shape;for(let $ of l.keys){let f=m[$],E=f._zod.run({value:p[$],issues:[]},h),N=f._zod.optin==="optional"&&f._zod.optout==="optional";E instanceof Promise?g.push(E.then(B=>N?O0(B,u,$,p):tc(B,u,$))):N?O0(E,u,$,p):tc(E,u,$)}}if(!d)return g.length?Promise.all(g).then(()=>u):u;let x=[],S=l.keySet,k=d._zod,_=k.def.type;for(let m of Object.keys(p)){if(S.has(m))continue;if(_==="never"){x.push(m);continue}let $=k.run({value:p[m],issues:[]},h);$ instanceof Promise?g.push($.then(f=>tc(f,u,m))):tc($,u,m)}return x.length&&u.issues.push({code:"unrecognized_keys",keys:x,input:p,inst:t}),g.length?Promise.all(g).then(()=>u):u}});function A0(t,e,r,n){for(let s of t)if(s.issues.length===0)return e.value=s.value,e;return e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(s=>s.issues.map(o=>un(o,n,Cr())))}),e}var sc=le("$ZodUnion",(t,e)=>{xt.init(t,e),$t(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),$t(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),$t(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),$t(t._zod,"pattern",()=>{if(e.options.every(r=>r._zod.pattern)){let r=e.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>$i(n.source)).join("|")})$`)}}),t._zod.parse=(r,n)=>{let s=!1,o=[];for(let i of e.options){let a=i._zod.run({value:r.value,issues:[]},n);if(a instanceof Promise)o.push(a),s=!0;else{if(a.issues.length===0)return a;o.push(a)}}return s?Promise.all(o).then(i=>A0(i,r,t,n)):A0(o,r,t,n)}}),vd=le("$ZodDiscriminatedUnion",(t,e)=>{sc.init(t,e);let r=t._zod.parse;$t(t._zod,"propValues",()=>{let s={};for(let o of e.options){let i=o._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(o)}"`);for(let[a,c]of Object.entries(i)){s[a]||(s[a]=new Set);for(let d of c)s[a].add(d)}}return s});let n=Ei(()=>{let s=e.options,o=new Map;for(let i of s){let a=i._zod.propValues[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(let c of a){if(o.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);o.set(c,i)}}return o});t._zod.parse=(s,o)=>{let i=s.value;if(!Eo(i))return s.issues.push({code:"invalid_type",expected:"object",input:i,inst:t}),s;let a=n.value.get(i?.[e.discriminator]);return a?a._zod.run(s,o):e.unionFallback?r(s,o):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[e.discriminator],inst:t}),s)}}),wd=le("$ZodIntersection",(t,e)=>{xt.init(t,e),t._zod.parse=(r,n)=>{let s=r.value,o=e.left._zod.run({value:s,issues:[]},n),i=e.right._zod.run({value:s,issues:[]},n);return o instanceof Promise||i instanceof Promise?Promise.all([o,i]).then(([c,d])=>N0(r,c,d)):N0(r,o,i)}});function Yu(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(To(t)&&To(e)){let r=Object.keys(e),n=Object.keys(t).filter(o=>r.indexOf(o)!==-1),s={...t,...e};for(let o of n){let i=Yu(t[o],e[o]);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};s[o]=i.data}return{valid:!0,data:s}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<t.length;n++){let s=t[n],o=e[n],i=Yu(s,o);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function N0(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),Ls(t))return t;let n=Yu(e.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return t.value=n.data,t}var xd=le("$ZodRecord",(t,e)=>{xt.init(t,e),t._zod.parse=(r,n)=>{let s=r.value;if(!To(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:t}),r;let o=[];if(e.keyType._zod.values){let i=e.keyType._zod.values;r.value={};for(let c of i)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){let d=e.valueType._zod.run({value:s[c],issues:[]},n);d instanceof Promise?o.push(d.then(l=>{l.issues.length&&r.issues.push(...$n(c,l.issues)),r.value[c]=l.value})):(d.issues.length&&r.issues.push(...$n(c,d.issues)),r.value[c]=d.value)}let a;for(let c in s)i.has(c)||(a=a??[],a.push(c));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:s,inst:t,keys:a})}else{r.value={};for(let i of Reflect.ownKeys(s)){if(i==="__proto__")continue;let a=e.keyType._zod.run({value:i,issues:[]},n);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(d=>un(d,n,Cr())),input:i,path:[i],inst:t}),r.value[a.value]=a.value;continue}let c=e.valueType._zod.run({value:s[i],issues:[]},n);c instanceof Promise?o.push(c.then(d=>{d.issues.length&&r.issues.push(...$n(i,d.issues)),r.value[a.value]=d.value})):(c.issues.length&&r.issues.push(...$n(i,c.issues)),r.value[a.value]=c.value)}}return o.length?Promise.all(o).then(()=>r):r}});var kd=le("$ZodEnum",(t,e)=>{xt.init(t,e);let r=Si(e.entries);t._zod.values=new Set(r),t._zod.pattern=new RegExp(`^(${r.filter(n=>Iu.has(typeof n)).map(n=>typeof n=="string"?Kn(n):n.toString()).join("|")})$`),t._zod.parse=(n,s)=>{let o=n.value;return t._zod.values.has(o)||n.issues.push({code:"invalid_value",values:r,input:o,inst:t}),n}}),Sd=le("$ZodLiteral",(t,e)=>{xt.init(t,e),t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?Kn(r):r?r.toString():String(r)).join("|")})$`),t._zod.parse=(r,n)=>{let s=r.value;return t._zod.values.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:t}),r}});var Ed=le("$ZodTransform",(t,e)=>{xt.init(t,e),t._zod.parse=(r,n)=>{let s=e.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(i=>(r.value=i,r));if(s instanceof Promise)throw new Ln;return r.value=s,r}}),Td=le("$ZodOptional",(t,e)=>{xt.init(t,e),t._zod.optin="optional",t._zod.optout="optional",$t(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),$t(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${$i(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>e.innerType._zod.optin==="optional"?e.innerType._zod.run(r,n):r.value===void 0?r:e.innerType._zod.run(r,n)}),$d=le("$ZodNullable",(t,e)=>{xt.init(t,e),$t(t._zod,"optin",()=>e.innerType._zod.optin),$t(t._zod,"optout",()=>e.innerType._zod.optout),$t(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${$i(r.source)}|null)$`):void 0}),$t(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),Rd=le("$ZodDefault",(t,e)=>{xt.init(t,e),t._zod.optin="optional",$t(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=e.defaultValue,r;let s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>C0(o,e)):C0(s,e)}});function C0(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}var Pd=le("$ZodPrefault",(t,e)=>{xt.init(t,e),t._zod.optin="optional",$t(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),Md=le("$ZodNonOptional",(t,e)=>{xt.init(t,e),$t(t._zod,"values",()=>{let r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{let s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>j0(o,t)):j0(s,t)}});function j0(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}var zd=le("$ZodCatch",(t,e)=>{xt.init(t,e),t._zod.optin="optional",$t(t._zod,"optout",()=>e.innerType._zod.optout),$t(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{let s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(i=>un(i,n,Cr()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(o=>un(o,n,Cr()))},input:r.value}),r.issues=[]),r)}});var Id=le("$ZodPipe",(t,e)=>{xt.init(t,e),$t(t._zod,"values",()=>e.in._zod.values),$t(t._zod,"optin",()=>e.in._zod.optin),$t(t._zod,"optout",()=>e.out._zod.optout),t._zod.parse=(r,n)=>{let s=e.in._zod.run(r,n);return s instanceof Promise?s.then(o=>D0(o,e,n)):D0(s,e,n)}});function D0(t,e,r){return Ls(t)?t:e.out._zod.run({value:t.value,issues:t.issues},r)}var Od=le("$ZodReadonly",(t,e)=>{xt.init(t,e),$t(t._zod,"propValues",()=>e.innerType._zod.propValues),$t(t._zod,"values",()=>e.innerType._zod.values),$t(t._zod,"optin",()=>e.innerType._zod.optin),$t(t._zod,"optout",()=>e.innerType._zod.optout),t._zod.parse=(r,n)=>{let s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(L0):L0(s)}});function L0(t){return t.value=Object.freeze(t.value),t}var Ad=le("$ZodCustom",(t,e)=>{rr.init(t,e),xt.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{let n=r.value,s=e.fn(n);if(s instanceof Promise)return s.then(o=>Z0(o,r,n,t));Z0(s,r,n,t)}});function Z0(t,e,r,n){if(!t){let s={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(s.params=n._zod.def.params),e.issues.push(Nu(s))}}var z5=t=>{let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"NaN":"number";case"object":{if(Array.isArray(t))return"array";if(t===null)return"null";if(Object.getPrototypeOf(t)!==Object.prototype&&t.constructor)return t.constructor.name}}return e},I5=()=>{let t={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function e(n){return t[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Invalid input: expected ${n.expected}, received ${z5(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${Ka(n.values[0])}`:`Invalid option: expected one of ${Xa(n.values,"|")}`;case"too_big":{let s=n.inclusive?"<=":"<",o=e(n.origin);return o?`Too big: expected ${n.origin??"value"} to have ${s}${n.maximum.toString()} ${o.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${s}${n.maximum.toString()}`}case"too_small":{let s=n.inclusive?">=":">",o=e(n.origin);return o?`Too small: expected ${n.origin} to have ${s}${n.minimum.toString()} ${o.unit}`:`Too small: expected ${n.origin} to be ${s}${n.minimum.toString()}`}case"invalid_format":{let s=n;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${r[s.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${Xa(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function U0(){return{localeError:I5()}}var O5=Symbol("ZodOutput"),A5=Symbol("ZodInput"),Ii=class{constructor(){this._map=new Map,this._idmap=new Map}add(e,...r){let n=r[0];if(this._map.set(e,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};function G0(){return new Ii}var Jn=G0();function Nd(t,e){return new t({type:"string",...Xe(e)})}function Cd(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...Xe(e)})}function oc(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...Xe(e)})}function jd(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...Xe(e)})}function Dd(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Xe(e)})}function Ld(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Xe(e)})}function Zd(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Xe(e)})}function Bd(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Xe(e)})}function qd(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...Xe(e)})}function Vd(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...Xe(e)})}function Fd(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...Xe(e)})}function Hd(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...Xe(e)})}function Ud(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...Xe(e)})}function Gd(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...Xe(e)})}function Yd(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...Xe(e)})}function Xd(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...Xe(e)})}function Wd(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...Xe(e)})}function Kd(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Xe(e)})}function Jd(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Xe(e)})}function Qd(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...Xe(e)})}function ef(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...Xe(e)})}function tf(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...Xe(e)})}function rf(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...Xe(e)})}function Y0(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Xe(e)})}function X0(t,e){return new t({type:"string",format:"date",check:"string_format",...Xe(e)})}function W0(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...Xe(e)})}function K0(t,e){return new t({type:"string",format:"duration",check:"string_format",...Xe(e)})}function nf(t,e){return new t({type:"number",checks:[],...Xe(e)})}function sf(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Xe(e)})}function of(t,e){return new t({type:"boolean",...Xe(e)})}function af(t,e){return new t({type:"null",...Xe(e)})}function cf(t){return new t({type:"unknown"})}function lf(t,e){return new t({type:"never",...Xe(e)})}function ic(t,e){return new Uu({check:"less_than",...Xe(e),value:t,inclusive:!1})}function Oi(t,e){return new Uu({check:"less_than",...Xe(e),value:t,inclusive:!0})}function ac(t,e){return new Gu({check:"greater_than",...Xe(e),value:t,inclusive:!1})}function Ai(t,e){return new Gu({check:"greater_than",...Xe(e),value:t,inclusive:!0})}function cc(t,e){return new b0({check:"multiple_of",...Xe(e),value:t})}function lc(t,e){return new v0({check:"max_length",...Xe(e),maximum:t})}function $o(t,e){return new w0({check:"min_length",...Xe(e),minimum:t})}function uc(t,e){return new x0({check:"length_equals",...Xe(e),length:t})}function uf(t,e){return new k0({check:"string_format",format:"regex",...Xe(e),pattern:t})}function df(t){return new S0({check:"string_format",format:"lowercase",...Xe(t)})}function ff(t){return new E0({check:"string_format",format:"uppercase",...Xe(t)})}function hf(t,e){return new T0({check:"string_format",format:"includes",...Xe(e),includes:t})}function pf(t,e){return new $0({check:"string_format",format:"starts_with",...Xe(e),prefix:t})}function mf(t,e){return new R0({check:"string_format",format:"ends_with",...Xe(e),suffix:t})}function qs(t){return new P0({check:"overwrite",tx:t})}function gf(t){return qs(e=>e.normalize(t))}function _f(){return qs(t=>t.trim())}function bf(){return qs(t=>t.toLowerCase())}function yf(){return qs(t=>t.toUpperCase())}function J0(t,e,r){return new t({type:"array",element:e,...Xe(r)})}function vf(t,e,r){let n=Xe(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function wf(t,e,r){return new t({type:"custom",check:"custom",fn:e,...Xe(r)})}var dc=class{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??Jn,this.target=e?.target??"draft-2020-12",this.unrepresentable=e?.unrepresentable??"throw",this.override=e?.override??(()=>{}),this.io=e?.io??"output",this.seen=new Map}process(e,r={path:[],schemaPath:[]}){var n;let s=e._zod.def,o={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},i=this.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(e,a);let c=e._zod.toJSONSchema?.();if(c)a.schema=c;else{let u={...r,schemaPath:[...r.schemaPath,e],path:r.path},h=e._zod.parent;if(h)a.ref=h,this.process(h,u),this.seen.get(h).isParent=!0;else{let p=a.schema;switch(s.type){case"string":{let g=p;g.type="string";let{minimum:x,maximum:S,format:k,patterns:_,contentEncoding:m}=e._zod.bag;if(typeof x=="number"&&(g.minLength=x),typeof S=="number"&&(g.maxLength=S),k&&(g.format=o[k]??k,g.format===""&&delete g.format),m&&(g.contentEncoding=m),_&&_.size>0){let $=[..._];$.length===1?g.pattern=$[0].source:$.length>1&&(a.schema.allOf=[...$.map(f=>({...this.target==="draft-7"?{type:"string"}:{},pattern:f.source}))])}break}case"number":{let g=p,{minimum:x,maximum:S,format:k,multipleOf:_,exclusiveMaximum:m,exclusiveMinimum:$}=e._zod.bag;typeof k=="string"&&k.includes("int")?g.type="integer":g.type="number",typeof $=="number"&&(g.exclusiveMinimum=$),typeof x=="number"&&(g.minimum=x,typeof $=="number"&&($>=x?delete g.minimum:delete g.exclusiveMinimum)),typeof m=="number"&&(g.exclusiveMaximum=m),typeof S=="number"&&(g.maximum=S,typeof m=="number"&&(m<=S?delete g.maximum:delete g.exclusiveMaximum)),typeof _=="number"&&(g.multipleOf=_);break}case"boolean":{let g=p;g.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{p.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{p.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{let g=p,{minimum:x,maximum:S}=e._zod.bag;typeof x=="number"&&(g.minItems=x),typeof S=="number"&&(g.maxItems=S),g.type="array",g.items=this.process(s.element,{...u,path:[...u.path,"items"]});break}case"object":{let g=p;g.type="object",g.properties={};let x=s.shape;for(let _ in x)g.properties[_]=this.process(x[_],{...u,path:[...u.path,"properties",_]});let S=new Set(Object.keys(x)),k=new Set([...S].filter(_=>{let m=s.shape[_]._zod;return this.io==="input"?m.optin===void 0:m.optout===void 0}));k.size>0&&(g.required=Array.from(k)),s.catchall?._zod.def.type==="never"?g.additionalProperties=!1:s.catchall?s.catchall&&(g.additionalProperties=this.process(s.catchall,{...u,path:[...u.path,"additionalProperties"]})):this.io==="output"&&(g.additionalProperties=!1);break}case"union":{let g=p;g.anyOf=s.options.map((x,S)=>this.process(x,{...u,path:[...u.path,"anyOf",S]}));break}case"intersection":{let g=p,x=this.process(s.left,{...u,path:[...u.path,"allOf",0]}),S=this.process(s.right,{...u,path:[...u.path,"allOf",1]}),k=m=>"allOf"in m&&Object.keys(m).length===1,_=[...k(x)?x.allOf:[x],...k(S)?S.allOf:[S]];g.allOf=_;break}case"tuple":{let g=p;g.type="array";let x=s.items.map((_,m)=>this.process(_,{...u,path:[...u.path,"prefixItems",m]}));if(this.target==="draft-2020-12"?g.prefixItems=x:g.items=x,s.rest){let _=this.process(s.rest,{...u,path:[...u.path,"items"]});this.target==="draft-2020-12"?g.items=_:g.additionalItems=_}s.rest&&(g.items=this.process(s.rest,{...u,path:[...u.path,"items"]}));let{minimum:S,maximum:k}=e._zod.bag;typeof S=="number"&&(g.minItems=S),typeof k=="number"&&(g.maxItems=k);break}case"record":{let g=p;g.type="object",g.propertyNames=this.process(s.keyType,{...u,path:[...u.path,"propertyNames"]}),g.additionalProperties=this.process(s.valueType,{...u,path:[...u.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{let g=p,x=Si(s.entries);x.every(S=>typeof S=="number")&&(g.type="number"),x.every(S=>typeof S=="string")&&(g.type="string"),g.enum=x;break}case"literal":{let g=p,x=[];for(let S of s.values)if(S===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof S=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");x.push(Number(S))}else x.push(S);if(x.length!==0)if(x.length===1){let S=x[0];g.type=S===null?"null":typeof S,g.const=S}else x.every(S=>typeof S=="number")&&(g.type="number"),x.every(S=>typeof S=="string")&&(g.type="string"),x.every(S=>typeof S=="boolean")&&(g.type="string"),x.every(S=>S===null)&&(g.type="null"),g.enum=x;break}case"file":{let g=p,x={type:"string",format:"binary",contentEncoding:"binary"},{minimum:S,maximum:k,mime:_}=e._zod.bag;S!==void 0&&(x.minLength=S),k!==void 0&&(x.maxLength=k),_?_.length===1?(x.contentMediaType=_[0],Object.assign(g,x)):g.anyOf=_.map(m=>({...x,contentMediaType:m})):Object.assign(g,x);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let g=this.process(s.innerType,u);p.anyOf=[g,{type:"null"}];break}case"nonoptional":{this.process(s.innerType,u),a.ref=s.innerType;break}case"success":{let g=p;g.type="boolean";break}case"default":{this.process(s.innerType,u),a.ref=s.innerType,p.default=JSON.parse(JSON.stringify(s.defaultValue));break}case"prefault":{this.process(s.innerType,u),a.ref=s.innerType,this.io==="input"&&(p._prefault=JSON.parse(JSON.stringify(s.defaultValue)));break}case"catch":{this.process(s.innerType,u),a.ref=s.innerType;let g;try{g=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}p.default=g;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let g=p,x=e._zod.pattern;if(!x)throw new Error("Pattern not found in template literal");g.type="string",g.pattern=x.source;break}case"pipe":{let g=this.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;this.process(g,u),a.ref=g;break}case"readonly":{this.process(s.innerType,u),a.ref=s.innerType,p.readOnly=!0;break}case"promise":{this.process(s.innerType,u),a.ref=s.innerType;break}case"optional":{this.process(s.innerType,u),a.ref=s.innerType;break}case"lazy":{let g=e._zod.innerType;this.process(g,u),a.ref=g;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}default:}}}let d=this.metadataRegistry.get(e);return d&&Object.assign(a.schema,d),this.io==="input"&&Xt(e)&&(delete a.schema.examples,delete a.schema.default),this.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,this.seen.get(e).schema}emit(e,r){let n={cycles:r?.cycles??"ref",reused:r?.reused??"inline",external:r?.external??void 0},s=this.seen.get(e);if(!s)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=l=>{let u=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){let x=n.external.registry.get(l[0])?.id,S=n.external.uri??(_=>_);if(x)return{ref:S(x)};let k=l[1].defId??l[1].schema.id??`schema${this.counter++}`;return l[1].defId=k,{defId:k,ref:`${S("__shared")}#/${u}/${k}`}}if(l[1]===s)return{ref:"#"};let p=`#/${u}/`,g=l[1].schema.id??`__schema${this.counter++}`;return{defId:g,ref:p+g}},i=l=>{if(l[1].schema.$ref)return;let u=l[1],{ref:h,defId:p}=o(l);u.def={...u.schema},p&&(u.defId=p);let g=u.schema;for(let x in g)delete g[x];g.$ref=h};if(n.cycles==="throw")for(let l of this.seen.entries()){let u=l[1];if(u.cycle)throw new Error(`Cycle detected: #/${u.cycle?.join("/")}/<root>
33
+ path: iss.path ? [${Js(_)}, ...iss.path] : [${Js(_)}]
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>
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 h=this.seen.get(l),p=h.def??h.schema,g={...p};if(h.ref===null)return;let x=h.ref;if(h.ref=null,x){a(x,u);let S=this.seen.get(x).schema;S.$ref&&u.target==="draft-7"?(p.allOf=p.allOf??[],p.allOf.push(S)):(Object.assign(p,S),Object.assign(p,g))}h.isParent||this.override({zodSchema:l,jsonSchema:p,path:h.path??[]})};for(let l of[...this.seen.entries()].reverse())a(l[0],{target:this.target});let c={};if(this.target==="draft-2020-12"?c.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?c.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),n.external?.uri){let l=n.external.registry.get(e)?.id;if(!l)throw new Error("Schema is missing an `id` property");c.$id=n.external.uri(l)}Object.assign(c,s.def);let d=n.external?.defs??{};for(let l of this.seen.entries()){let u=l[1];u.def&&u.defId&&(d[u.defId]=u.def)}n.external||Object.keys(d).length>0&&(this.target==="draft-2020-12"?c.$defs=d:c.definitions=d);try{return JSON.parse(JSON.stringify(c))}catch{throw new Error("Error converting schema to JSON.")}}};function xf(t,e){if(t instanceof Ii){let n=new dc(e),s={};for(let a of t._idmap.entries()){let[c,d]=a;n.process(d)}let o={},i={registry:t,uri:e?.uri,defs:s};for(let a of t._idmap.entries()){let[c,d]=a;o[c]=n.emit(d,{...e,external:i})}if(Object.keys(s).length>0){let a=n.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[a]:s}}return{schemas:o}}let r=new dc(e);return r.process(t),r.emit(t,e)}function Xt(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let s=t._zod.def;switch(s.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return Xt(s.element,r);case"object":{for(let o in s.shape)if(Xt(s.shape[o],r))return!0;return!1}case"union":{for(let o of s.options)if(Xt(o,r))return!0;return!1}case"intersection":return Xt(s.left,r)||Xt(s.right,r);case"tuple":{for(let o of s.items)if(Xt(o,r))return!0;return!!(s.rest&&Xt(s.rest,r))}case"record":return Xt(s.keyType,r)||Xt(s.valueType,r);case"map":return Xt(s.keyType,r)||Xt(s.valueType,r);case"set":return Xt(s.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return Xt(s.innerType,r);case"lazy":return Xt(s.getter(),r);case"default":return Xt(s.innerType,r);case"prefault":return Xt(s.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return Xt(s.in,r)||Xt(s.out,r);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${s.type}`)}var mx=le("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");xt.init(t,e),t.def=e,t.parse=(r,n)=>Lu(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Zs(t,r,n),t.parseAsync=async(r,n)=>Bu(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>Bs(t,r,n),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>jr(t,r,n),t.brand=()=>t,t.register=(r,n)=>(r.add(t,n),t)});var gx=le("ZodMiniObject",(t,e)=>{nc.init(t,e),mx.init(t,e),ut.defineLazy(t,"shape",()=>e.shape)});function kf(t,e){let r={type:"object",get shape(){return ut.assignProp(this,"shape",{...t}),this.shape},...ut.normalizeParams(e)};return new gx(r)}function Gr(t){return!!t._zod}function Fs(t){let e=Object.values(t);if(e.length===0)return kf({});let r=e.every(Gr),n=e.every(s=>!Gr(s));if(r)return kf(t);if(n)return Eu(t);throw new Error("Mixed Zod versions detected in object shape.")}function Qn(t,e){return Gr(t)?Zs(t,e):t.safeParse(e)}async function fc(t,e){return Gr(t)?await Bs(t,e):await t.safeParseAsync(e)}function es(t){if(!t)return;let e;if(Gr(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function Ro(t){if(t){if(typeof t=="object"){let e=t,r=t;if(!e._def&&!r._zod){let n=Object.values(t);if(n.length>0&&n.every(s=>typeof s=="object"&&s!==null&&(s._def!==void 0||s._zod!==void 0||typeof s.parse=="function")))return Fs(t)}}if(Gr(t)){let r=t._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function hc(t){if(t&&typeof t=="object"){if("message"in t&&typeof t.message=="string")return t.message;if("issues"in t&&Array.isArray(t.issues)&&t.issues.length>0){let e=t.issues[0];if(e&&typeof e=="object"&&"message"in e)return String(e.message)}try{return JSON.stringify(t)}catch{return String(t)}}return String(t)}function eg(t){return t.description}function tg(t){if(Gr(t))return t._zod?.def?.type==="optional";let e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function pc(t){if(Gr(t)){let o=t._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}let r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=t.value;if(n!==void 0)return n}var Ni={};wu(Ni,{ZodISODate:()=>ng,ZodISODateTime:()=>rg,ZodISODuration:()=>og,ZodISOTime:()=>sg,date:()=>Ef,datetime:()=>Sf,duration:()=>$f,time:()=>Tf});var rg=le("ZodISODateTime",(t,e)=>{B0.init(t,e),Ct.init(t,e)});function Sf(t){return Y0(rg,t)}var ng=le("ZodISODate",(t,e)=>{q0.init(t,e),Ct.init(t,e)});function Ef(t){return X0(ng,t)}var sg=le("ZodISOTime",(t,e)=>{V0.init(t,e),Ct.init(t,e)});function Tf(t){return W0(sg,t)}var og=le("ZodISODuration",(t,e)=>{F0.init(t,e),Ct.init(t,e)});function $f(t){return K0(og,t)}var ig=(t,e)=>{Ja.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>ju(t,r)},flatten:{value:r=>Cu(t,r)},addIssue:{value:r=>t.issues.push(r)},addIssues:{value:r=>t.issues.push(...r)},isEmpty:{get(){return t.issues.length===0}}})},mN=le("ZodError",ig),Ci=le("ZodError",ig,{Parent:Error});var ag=Du(Ci),cg=Zu(Ci),lg=qu(Ci),ug=Vu(Ci);var Bt=le("ZodType",(t,e)=>(xt.init(t,e),t.def=e,Object.defineProperty(t,"_def",{value:e}),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>jr(t,r,n),t.brand=()=>t,t.register=(r,n)=>(r.add(t,n),t),t.parse=(r,n)=>ag(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>lg(t,r,n),t.parseAsync=async(r,n)=>cg(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>ug(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(hk(r,n)),t.superRefine=r=>t.check(pk(r)),t.overwrite=r=>t.check(qs(r)),t.optional=()=>Dt(t),t.nullable=()=>hg(t),t.nullish=()=>Dt(hg(t)),t.nonoptional=r=>ik(t,r),t.array=()=>dt(t),t.or=r=>Mt([t,r]),t.and=r=>gc(t,r),t.transform=r=>Pf(t,yg(r)),t.default=r=>nk(t,r),t.prefault=r=>ok(t,r),t.catch=r=>ck(t,r),t.pipe=r=>Pf(t,r),t.readonly=()=>dk(t),t.describe=r=>{let n=t.clone();return Jn.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return Jn.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return Jn.get(t);let n=t.clone();return Jn.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),pg=le("_ZodString",(t,e)=>{zi.init(t,e),Bt.init(t,e);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,t.regex=(...n)=>t.check(uf(...n)),t.includes=(...n)=>t.check(hf(...n)),t.startsWith=(...n)=>t.check(pf(...n)),t.endsWith=(...n)=>t.check(mf(...n)),t.min=(...n)=>t.check($o(...n)),t.max=(...n)=>t.check(lc(...n)),t.length=(...n)=>t.check(uc(...n)),t.nonempty=(...n)=>t.check($o(1,...n)),t.lowercase=n=>t.check(df(n)),t.uppercase=n=>t.check(ff(n)),t.trim=()=>t.check(_f()),t.normalize=(...n)=>t.check(gf(...n)),t.toLowerCase=()=>t.check(bf()),t.toUpperCase=()=>t.check(yf())}),Ex=le("ZodString",(t,e)=>{zi.init(t,e),pg.init(t,e),t.email=r=>t.check(Cd(Tx,r)),t.url=r=>t.check(Bd($x,r)),t.jwt=r=>t.check(rf(qx,r)),t.emoji=r=>t.check(qd(Rx,r)),t.guid=r=>t.check(oc(dg,r)),t.uuid=r=>t.check(jd(mc,r)),t.uuidv4=r=>t.check(Dd(mc,r)),t.uuidv6=r=>t.check(Ld(mc,r)),t.uuidv7=r=>t.check(Zd(mc,r)),t.nanoid=r=>t.check(Vd(Px,r)),t.guid=r=>t.check(oc(dg,r)),t.cuid=r=>t.check(Fd(Mx,r)),t.cuid2=r=>t.check(Hd(zx,r)),t.ulid=r=>t.check(Ud(Ix,r)),t.base64=r=>t.check(Qd(Lx,r)),t.base64url=r=>t.check(ef(Zx,r)),t.xid=r=>t.check(Gd(Ox,r)),t.ksuid=r=>t.check(Yd(Ax,r)),t.ipv4=r=>t.check(Xd(Nx,r)),t.ipv6=r=>t.check(Wd(Cx,r)),t.cidrv4=r=>t.check(Kd(jx,r)),t.cidrv6=r=>t.check(Jd(Dx,r)),t.e164=r=>t.check(tf(Bx,r)),t.datetime=r=>t.check(Sf(r)),t.date=r=>t.check(Ef(r)),t.time=r=>t.check(Tf(r)),t.duration=r=>t.check($f(r))});function ce(t){return Nd(Ex,t)}var Ct=le("ZodStringFormat",(t,e)=>{Rt.init(t,e),pg.init(t,e)}),Tx=le("ZodEmail",(t,e)=>{Ku.init(t,e),Ct.init(t,e)});var dg=le("ZodGUID",(t,e)=>{Xu.init(t,e),Ct.init(t,e)});var mc=le("ZodUUID",(t,e)=>{Wu.init(t,e),Ct.init(t,e)});var $x=le("ZodURL",(t,e)=>{Ju.init(t,e),Ct.init(t,e)});var Rx=le("ZodEmoji",(t,e)=>{Qu.init(t,e),Ct.init(t,e)});var Px=le("ZodNanoID",(t,e)=>{ed.init(t,e),Ct.init(t,e)});var Mx=le("ZodCUID",(t,e)=>{td.init(t,e),Ct.init(t,e)});var zx=le("ZodCUID2",(t,e)=>{rd.init(t,e),Ct.init(t,e)});var Ix=le("ZodULID",(t,e)=>{nd.init(t,e),Ct.init(t,e)});var Ox=le("ZodXID",(t,e)=>{sd.init(t,e),Ct.init(t,e)});var Ax=le("ZodKSUID",(t,e)=>{od.init(t,e),Ct.init(t,e)});var Nx=le("ZodIPv4",(t,e)=>{id.init(t,e),Ct.init(t,e)});var Cx=le("ZodIPv6",(t,e)=>{ad.init(t,e),Ct.init(t,e)});var jx=le("ZodCIDRv4",(t,e)=>{cd.init(t,e),Ct.init(t,e)});var Dx=le("ZodCIDRv6",(t,e)=>{ld.init(t,e),Ct.init(t,e)});var Lx=le("ZodBase64",(t,e)=>{ud.init(t,e),Ct.init(t,e)});var Zx=le("ZodBase64URL",(t,e)=>{dd.init(t,e),Ct.init(t,e)});var Bx=le("ZodE164",(t,e)=>{fd.init(t,e),Ct.init(t,e)});var qx=le("ZodJWT",(t,e)=>{hd.init(t,e),Ct.init(t,e)});var mg=le("ZodNumber",(t,e)=>{rc.init(t,e),Bt.init(t,e),t.gt=(n,s)=>t.check(ac(n,s)),t.gte=(n,s)=>t.check(Ai(n,s)),t.min=(n,s)=>t.check(Ai(n,s)),t.lt=(n,s)=>t.check(ic(n,s)),t.lte=(n,s)=>t.check(Oi(n,s)),t.max=(n,s)=>t.check(Oi(n,s)),t.int=n=>t.check(fg(n)),t.safe=n=>t.check(fg(n)),t.positive=n=>t.check(ac(0,n)),t.nonnegative=n=>t.check(Ai(0,n)),t.negative=n=>t.check(ic(0,n)),t.nonpositive=n=>t.check(Oi(0,n)),t.multipleOf=(n,s)=>t.check(cc(n,s)),t.step=(n,s)=>t.check(cc(n,s)),t.finite=()=>t;let r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});function wt(t){return nf(mg,t)}var Vx=le("ZodNumberFormat",(t,e)=>{pd.init(t,e),mg.init(t,e)});function fg(t){return sf(Vx,t)}var Fx=le("ZodBoolean",(t,e)=>{md.init(t,e),Bt.init(t,e)});function er(t){return of(Fx,t)}var Hx=le("ZodNull",(t,e)=>{gd.init(t,e),Bt.init(t,e)});function gg(t){return af(Hx,t)}var Ux=le("ZodUnknown",(t,e)=>{_d.init(t,e),Bt.init(t,e)});function jt(){return cf(Ux)}var Gx=le("ZodNever",(t,e)=>{bd.init(t,e),Bt.init(t,e)});function Yx(t){return lf(Gx,t)}var Xx=le("ZodArray",(t,e)=>{yd.init(t,e),Bt.init(t,e),t.element=e.element,t.min=(r,n)=>t.check($o(r,n)),t.nonempty=r=>t.check($o(1,r)),t.max=(r,n)=>t.check(lc(r,n)),t.length=(r,n)=>t.check(uc(r,n)),t.unwrap=()=>t.element});function dt(t,e){return J0(Xx,t,e)}var _g=le("ZodObject",(t,e)=>{nc.init(t,e),Bt.init(t,e),ut.defineLazy(t,"shape",()=>e.shape),t.keyof=()=>Sr(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:jt()}),t.loose=()=>t.clone({...t._zod.def,catchall:jt()}),t.strict=()=>t.clone({...t._zod.def,catchall:Yx()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>ut.extend(t,r),t.merge=r=>ut.merge(t,r),t.pick=r=>ut.pick(t,r),t.omit=r=>ut.omit(t,r),t.partial=(...r)=>ut.partial(vg,t,r[0]),t.required=(...r)=>ut.required(wg,t,r[0])});function Ae(t,e){let r={type:"object",get shape(){return ut.assignProp(this,"shape",{...t}),this.shape},...ut.normalizeParams(e)};return new _g(r)}function pr(t,e){return new _g({type:"object",get shape(){return ut.assignProp(this,"shape",{...t}),this.shape},catchall:jt(),...ut.normalizeParams(e)})}var bg=le("ZodUnion",(t,e)=>{sc.init(t,e),Bt.init(t,e),t.options=e.options});function Mt(t,e){return new bg({type:"union",options:t,...ut.normalizeParams(e)})}var Wx=le("ZodDiscriminatedUnion",(t,e)=>{bg.init(t,e),vd.init(t,e)});function Mf(t,e,r){return new Wx({type:"union",options:e,discriminator:t,...ut.normalizeParams(r)})}var Kx=le("ZodIntersection",(t,e)=>{wd.init(t,e),Bt.init(t,e)});function gc(t,e){return new Kx({type:"intersection",left:t,right:e})}var Jx=le("ZodRecord",(t,e)=>{xd.init(t,e),Bt.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});function Pt(t,e,r){return new Jx({type:"record",keyType:t,valueType:e,...ut.normalizeParams(r)})}var Rf=le("ZodEnum",(t,e)=>{kd.init(t,e),Bt.init(t,e),t.enum=e.entries,t.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));t.extract=(n,s)=>{let o={};for(let i of n)if(r.has(i))o[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Rf({...e,checks:[],...ut.normalizeParams(s),entries:o})},t.exclude=(n,s)=>{let o={...e.entries};for(let i of n)if(r.has(i))delete o[i];else throw new Error(`Key ${i} not found in enum`);return new Rf({...e,checks:[],...ut.normalizeParams(s),entries:o})}});function Sr(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new Rf({type:"enum",entries:r,...ut.normalizeParams(e)})}var Qx=le("ZodLiteral",(t,e)=>{Sd.init(t,e),Bt.init(t,e),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function Ve(t,e){return new Qx({type:"literal",values:Array.isArray(t)?t:[t],...ut.normalizeParams(e)})}var ek=le("ZodTransform",(t,e)=>{Ed.init(t,e),Bt.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push(ut.issue(o,r.value,e));else{let i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),i.continue??(i.continue=!0),r.issues.push(ut.issue(i))}};let s=e.transform(r.value,r);return s instanceof Promise?s.then(o=>(r.value=o,r)):(r.value=s,r)}});function yg(t){return new ek({type:"transform",transform:t})}var vg=le("ZodOptional",(t,e)=>{Td.init(t,e),Bt.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Dt(t){return new vg({type:"optional",innerType:t})}var tk=le("ZodNullable",(t,e)=>{$d.init(t,e),Bt.init(t,e),t.unwrap=()=>t._zod.def.innerType});function hg(t){return new tk({type:"nullable",innerType:t})}var rk=le("ZodDefault",(t,e)=>{Rd.init(t,e),Bt.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function nk(t,e){return new rk({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var sk=le("ZodPrefault",(t,e)=>{Pd.init(t,e),Bt.init(t,e),t.unwrap=()=>t._zod.def.innerType});function ok(t,e){return new sk({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var wg=le("ZodNonOptional",(t,e)=>{Md.init(t,e),Bt.init(t,e),t.unwrap=()=>t._zod.def.innerType});function ik(t,e){return new wg({type:"nonoptional",innerType:t,...ut.normalizeParams(e)})}var ak=le("ZodCatch",(t,e)=>{zd.init(t,e),Bt.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function ck(t,e){return new ak({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var lk=le("ZodPipe",(t,e)=>{Id.init(t,e),Bt.init(t,e),t.in=e.in,t.out=e.out});function Pf(t,e){return new lk({type:"pipe",in:t,out:e})}var uk=le("ZodReadonly",(t,e)=>{Od.init(t,e),Bt.init(t,e)});function dk(t){return new uk({type:"readonly",innerType:t})}var xg=le("ZodCustom",(t,e)=>{Ad.init(t,e),Bt.init(t,e)});function fk(t){let e=new rr({check:"custom"});return e._zod.check=t,e}function kg(t,e){return vf(xg,t??(()=>!0),e)}function hk(t,e={}){return wf(xg,t,e)}function pk(t){let e=fk(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(ut.issue(n,r.value,e._zod.def));else{let s=n;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),s.continue??(s.continue=!e._zod.def.abort),r.issues.push(ut.issue(s))}},t(r.value,r)));return e}function zf(t,e){return Pf(yg(t),e)}Cr(U0());var Of="2025-11-25";var Sg=[Of,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],ts="io.modelcontextprotocol/related-task",bc="2.0",Wt=kg(t=>t!==null&&(typeof t=="object"||typeof t=="function")),Eg=Mt([ce(),wt().int()]),Tg=ce(),PN=pr({ttl:wt().optional(),pollInterval:wt().optional()}),mk=Ae({ttl:wt().optional()}),gk=Ae({taskId:ce()}),Af=pr({progressToken:Eg.optional(),[ts]:gk.optional()}),Dr=Ae({_meta:Af.optional()}),ji=Dr.extend({task:mk.optional()}),$g=t=>ji.safeParse(t).success,nr=Ae({method:ce(),params:Dr.loose().optional()}),Yr=Ae({_meta:Af.optional()}),Xr=Ae({method:ce(),params:Yr.loose().optional()}),sr=pr({_meta:Af.optional()}),yc=Mt([ce(),wt().int()]),Rg=Ae({jsonrpc:Ve(bc),id:yc,...nr.shape}).strict(),Nf=t=>Rg.safeParse(t).success,Pg=Ae({jsonrpc:Ve(bc),...Xr.shape}).strict(),Mg=t=>Pg.safeParse(t).success,Cf=Ae({jsonrpc:Ve(bc),id:yc,result:sr}).strict(),Di=t=>Cf.safeParse(t).success;var Ue;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(Ue||(Ue={}));var jf=Ae({jsonrpc:Ve(bc),id:yc.optional(),error:Ae({code:wt().int(),message:ce(),data:jt().optional()})}).strict();var zg=t=>jf.safeParse(t).success;var Ig=Mt([Rg,Pg,Cf,jf]),MN=Mt([Cf,jf]),vc=sr.strict(),_k=Yr.extend({requestId:yc.optional(),reason:ce().optional()}),wc=Xr.extend({method:Ve("notifications/cancelled"),params:_k}),bk=Ae({src:ce(),mimeType:ce().optional(),sizes:dt(ce()).optional(),theme:Sr(["light","dark"]).optional()}),Li=Ae({icons:dt(bk).optional()}),Po=Ae({name:ce(),title:ce().optional()}),Og=Po.extend({...Po.shape,...Li.shape,version:ce(),websiteUrl:ce().optional(),description:ce().optional()}),yk=gc(Ae({applyDefaults:er().optional()}),Pt(ce(),jt())),vk=zf(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,gc(Ae({form:yk.optional(),url:Wt.optional()}),Pt(ce(),jt()).optional())),wk=pr({list:Wt.optional(),cancel:Wt.optional(),requests:pr({sampling:pr({createMessage:Wt.optional()}).optional(),elicitation:pr({create:Wt.optional()}).optional()}).optional()}),xk=pr({list:Wt.optional(),cancel:Wt.optional(),requests:pr({tools:pr({call:Wt.optional()}).optional()}).optional()}),kk=Ae({experimental:Pt(ce(),Wt).optional(),sampling:Ae({context:Wt.optional(),tools:Wt.optional()}).optional(),elicitation:vk.optional(),roots:Ae({listChanged:er().optional()}).optional(),tasks:wk.optional(),extensions:Pt(ce(),Wt).optional()}),Sk=Dr.extend({protocolVersion:ce(),capabilities:kk,clientInfo:Og}),Df=nr.extend({method:Ve("initialize"),params:Sk});var Ek=Ae({experimental:Pt(ce(),Wt).optional(),logging:Wt.optional(),completions:Wt.optional(),prompts:Ae({listChanged:er().optional()}).optional(),resources:Ae({subscribe:er().optional(),listChanged:er().optional()}).optional(),tools:Ae({listChanged:er().optional()}).optional(),tasks:xk.optional(),extensions:Pt(ce(),Wt).optional()}),Tk=sr.extend({protocolVersion:ce(),capabilities:Ek,serverInfo:Og,instructions:ce().optional()}),Lf=Xr.extend({method:Ve("notifications/initialized"),params:Yr.optional()});var xc=nr.extend({method:Ve("ping"),params:Dr.optional()}),$k=Ae({progress:wt(),total:Dt(wt()),message:Dt(ce())}),Rk=Ae({...Yr.shape,...$k.shape,progressToken:Eg}),kc=Xr.extend({method:Ve("notifications/progress"),params:Rk}),Pk=Dr.extend({cursor:Tg.optional()}),Zi=nr.extend({params:Pk.optional()}),Bi=sr.extend({nextCursor:Tg.optional()}),Mk=Sr(["working","input_required","completed","failed","cancelled"]),qi=Ae({taskId:ce(),status:Mk,ttl:Mt([wt(),gg()]),createdAt:ce(),lastUpdatedAt:ce(),pollInterval:Dt(wt()),statusMessage:Dt(ce())}),Mo=sr.extend({task:qi}),zk=Yr.merge(qi),Vi=Xr.extend({method:Ve("notifications/tasks/status"),params:zk}),Sc=nr.extend({method:Ve("tasks/get"),params:Dr.extend({taskId:ce()})}),Ec=sr.merge(qi),Tc=nr.extend({method:Ve("tasks/result"),params:Dr.extend({taskId:ce()})}),zN=sr.loose(),$c=Zi.extend({method:Ve("tasks/list")}),Rc=Bi.extend({tasks:dt(qi)}),Pc=nr.extend({method:Ve("tasks/cancel"),params:Dr.extend({taskId:ce()})}),Ag=sr.merge(qi),Ng=Ae({uri:ce(),mimeType:Dt(ce()),_meta:Pt(ce(),jt()).optional()}),Cg=Ng.extend({text:ce()}),Zf=ce().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),jg=Ng.extend({blob:Zf}),Fi=Sr(["user","assistant"]),zo=Ae({audience:dt(Fi).optional(),priority:wt().min(0).max(1).optional(),lastModified:Ni.datetime({offset:!0}).optional()}),Dg=Ae({...Po.shape,...Li.shape,uri:ce(),description:Dt(ce()),mimeType:Dt(ce()),size:Dt(wt()),annotations:zo.optional(),_meta:Dt(pr({}))}),Ik=Ae({...Po.shape,...Li.shape,uriTemplate:ce(),description:Dt(ce()),mimeType:Dt(ce()),annotations:zo.optional(),_meta:Dt(pr({}))}),Mc=Zi.extend({method:Ve("resources/list")}),Ok=Bi.extend({resources:dt(Dg)}),zc=Zi.extend({method:Ve("resources/templates/list")}),Ak=Bi.extend({resourceTemplates:dt(Ik)}),Bf=Dr.extend({uri:ce()}),Nk=Bf,Ic=nr.extend({method:Ve("resources/read"),params:Nk}),Ck=sr.extend({contents:dt(Mt([Cg,jg]))}),jk=Xr.extend({method:Ve("notifications/resources/list_changed"),params:Yr.optional()}),Dk=Bf,Lk=nr.extend({method:Ve("resources/subscribe"),params:Dk}),Zk=Bf,Bk=nr.extend({method:Ve("resources/unsubscribe"),params:Zk}),qk=Yr.extend({uri:ce()}),Vk=Xr.extend({method:Ve("notifications/resources/updated"),params:qk}),Fk=Ae({name:ce(),description:Dt(ce()),required:Dt(er())}),Hk=Ae({...Po.shape,...Li.shape,description:Dt(ce()),arguments:Dt(dt(Fk)),_meta:Dt(pr({}))}),Oc=Zi.extend({method:Ve("prompts/list")}),Uk=Bi.extend({prompts:dt(Hk)}),Gk=Dr.extend({name:ce(),arguments:Pt(ce(),ce()).optional()}),Ac=nr.extend({method:Ve("prompts/get"),params:Gk}),qf=Ae({type:Ve("text"),text:ce(),annotations:zo.optional(),_meta:Pt(ce(),jt()).optional()}),Vf=Ae({type:Ve("image"),data:Zf,mimeType:ce(),annotations:zo.optional(),_meta:Pt(ce(),jt()).optional()}),Ff=Ae({type:Ve("audio"),data:Zf,mimeType:ce(),annotations:zo.optional(),_meta:Pt(ce(),jt()).optional()}),Yk=Ae({type:Ve("tool_use"),name:ce(),id:ce(),input:Pt(ce(),jt()),_meta:Pt(ce(),jt()).optional()}),Xk=Ae({type:Ve("resource"),resource:Mt([Cg,jg]),annotations:zo.optional(),_meta:Pt(ce(),jt()).optional()}),Wk=Dg.extend({type:Ve("resource_link")}),Hf=Mt([qf,Vf,Ff,Wk,Xk]),Kk=Ae({role:Fi,content:Hf}),Jk=sr.extend({description:ce().optional(),messages:dt(Kk)}),Qk=Xr.extend({method:Ve("notifications/prompts/list_changed"),params:Yr.optional()}),e6=Ae({title:ce().optional(),readOnlyHint:er().optional(),destructiveHint:er().optional(),idempotentHint:er().optional(),openWorldHint:er().optional()}),t6=Ae({taskSupport:Sr(["required","optional","forbidden"]).optional()}),Lg=Ae({...Po.shape,...Li.shape,description:ce().optional(),inputSchema:Ae({type:Ve("object"),properties:Pt(ce(),Wt).optional(),required:dt(ce()).optional()}).catchall(jt()),outputSchema:Ae({type:Ve("object"),properties:Pt(ce(),Wt).optional(),required:dt(ce()).optional()}).catchall(jt()).optional(),annotations:e6.optional(),execution:t6.optional(),_meta:Pt(ce(),jt()).optional()}),Nc=Zi.extend({method:Ve("tools/list")}),r6=Bi.extend({tools:dt(Lg)}),Cc=sr.extend({content:dt(Hf).default([]),structuredContent:Pt(ce(),jt()).optional(),isError:er().optional()}),IN=Cc.or(sr.extend({toolResult:jt()})),n6=ji.extend({name:ce(),arguments:Pt(ce(),jt()).optional()}),Io=nr.extend({method:Ve("tools/call"),params:n6}),s6=Xr.extend({method:Ve("notifications/tools/list_changed"),params:Yr.optional()}),ON=Ae({autoRefresh:er().default(!0),debounceMs:wt().int().nonnegative().default(300)}),Hi=Sr(["debug","info","notice","warning","error","critical","alert","emergency"]),o6=Dr.extend({level:Hi}),Uf=nr.extend({method:Ve("logging/setLevel"),params:o6}),i6=Yr.extend({level:Hi,logger:ce().optional(),data:jt()}),a6=Xr.extend({method:Ve("notifications/message"),params:i6}),c6=Ae({name:ce().optional()}),l6=Ae({hints:dt(c6).optional(),costPriority:wt().min(0).max(1).optional(),speedPriority:wt().min(0).max(1).optional(),intelligencePriority:wt().min(0).max(1).optional()}),u6=Ae({mode:Sr(["auto","required","none"]).optional()}),d6=Ae({type:Ve("tool_result"),toolUseId:ce().describe("The unique identifier for the corresponding tool call."),content:dt(Hf).default([]),structuredContent:Ae({}).loose().optional(),isError:er().optional(),_meta:Pt(ce(),jt()).optional()}),f6=Mf("type",[qf,Vf,Ff]),_c=Mf("type",[qf,Vf,Ff,Yk,d6]),h6=Ae({role:Fi,content:Mt([_c,dt(_c)]),_meta:Pt(ce(),jt()).optional()}),p6=ji.extend({messages:dt(h6),modelPreferences:l6.optional(),systemPrompt:ce().optional(),includeContext:Sr(["none","thisServer","allServers"]).optional(),temperature:wt().optional(),maxTokens:wt().int(),stopSequences:dt(ce()).optional(),metadata:Wt.optional(),tools:dt(Lg).optional(),toolChoice:u6.optional()}),m6=nr.extend({method:Ve("sampling/createMessage"),params:p6}),Ui=sr.extend({model:ce(),stopReason:Dt(Sr(["endTurn","stopSequence","maxTokens"]).or(ce())),role:Fi,content:f6}),Gf=sr.extend({model:ce(),stopReason:Dt(Sr(["endTurn","stopSequence","maxTokens","toolUse"]).or(ce())),role:Fi,content:Mt([_c,dt(_c)])}),g6=Ae({type:Ve("boolean"),title:ce().optional(),description:ce().optional(),default:er().optional()}),_6=Ae({type:Ve("string"),title:ce().optional(),description:ce().optional(),minLength:wt().optional(),maxLength:wt().optional(),format:Sr(["email","uri","date","date-time"]).optional(),default:ce().optional()}),b6=Ae({type:Sr(["number","integer"]),title:ce().optional(),description:ce().optional(),minimum:wt().optional(),maximum:wt().optional(),default:wt().optional()}),y6=Ae({type:Ve("string"),title:ce().optional(),description:ce().optional(),enum:dt(ce()),default:ce().optional()}),v6=Ae({type:Ve("string"),title:ce().optional(),description:ce().optional(),oneOf:dt(Ae({const:ce(),title:ce()})),default:ce().optional()}),w6=Ae({type:Ve("string"),title:ce().optional(),description:ce().optional(),enum:dt(ce()),enumNames:dt(ce()).optional(),default:ce().optional()}),x6=Mt([y6,v6]),k6=Ae({type:Ve("array"),title:ce().optional(),description:ce().optional(),minItems:wt().optional(),maxItems:wt().optional(),items:Ae({type:Ve("string"),enum:dt(ce())}),default:dt(ce()).optional()}),S6=Ae({type:Ve("array"),title:ce().optional(),description:ce().optional(),minItems:wt().optional(),maxItems:wt().optional(),items:Ae({anyOf:dt(Ae({const:ce(),title:ce()}))}),default:dt(ce()).optional()}),E6=Mt([k6,S6]),T6=Mt([w6,x6,E6]),$6=Mt([T6,g6,_6,b6]),R6=ji.extend({mode:Ve("form").optional(),message:ce(),requestedSchema:Ae({type:Ve("object"),properties:Pt(ce(),$6),required:dt(ce()).optional()})}),P6=ji.extend({mode:Ve("url"),message:ce(),elicitationId:ce(),url:ce().url()}),M6=Mt([R6,P6]),z6=nr.extend({method:Ve("elicitation/create"),params:M6}),I6=Yr.extend({elicitationId:ce()}),O6=Xr.extend({method:Ve("notifications/elicitation/complete"),params:I6}),Oo=sr.extend({action:Sr(["accept","decline","cancel"]),content:zf(t=>t===null?void 0:t,Pt(ce(),Mt([ce(),wt(),er(),dt(ce())])).optional())}),A6=Ae({type:Ve("ref/resource"),uri:ce()});var N6=Ae({type:Ve("ref/prompt"),name:ce()}),C6=Dr.extend({ref:Mt([N6,A6]),argument:Ae({name:ce(),value:ce()}),context:Ae({arguments:Pt(ce(),ce()).optional()}).optional()}),jc=nr.extend({method:Ve("completion/complete"),params:C6});function Zg(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function Bg(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}var j6=sr.extend({completion:pr({values:dt(ce()).max(100),total:Dt(wt().int()),hasMore:Dt(er())})}),D6=Ae({uri:ce().startsWith("file://"),name:ce().optional(),_meta:Pt(ce(),jt()).optional()}),L6=nr.extend({method:Ve("roots/list"),params:Dr.optional()}),Yf=sr.extend({roots:dt(D6)}),Z6=Xr.extend({method:Ve("notifications/roots/list_changed"),params:Yr.optional()}),AN=Mt([xc,Df,jc,Uf,Ac,Oc,Mc,zc,Ic,Lk,Bk,Io,Nc,Sc,Tc,$c,Pc]),NN=Mt([wc,kc,Lf,Z6,Vi]),CN=Mt([vc,Ui,Gf,Oo,Yf,Ec,Rc,Mo]),jN=Mt([xc,m6,z6,L6,Sc,Tc,$c,Pc]),DN=Mt([wc,kc,a6,Vk,jk,s6,Qk,Vi,O6]),LN=Mt([vc,Tk,j6,Jk,Uk,Ok,Ak,Ck,Cc,r6,Ec,Rc,Mo]),Ze=class t extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}static fromError(e,r,n){if(e===Ue.UrlElicitationRequired&&n){let s=n;if(s.elicitations)return new If(s.elicitations,r)}return new t(e,r,n)}},If=class extends Ze{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(Ue.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function rs(t){return t==="completed"||t==="failed"||t==="cancelled"}var Vg=Symbol("Let zodToJsonSchema decide on which parser to use");var qg={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},Fg=t=>typeof t=="string"?{...qg,name:t}:{...qg,...t};var Hg=t=>{let e=Fg(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))}};function Xf(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function ft(t,e,r,n,s){t[e]=r,Xf(t,e,n,s)}var Dc=(t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")};function Lt(t){if(t.target!=="openAi")return{};let e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?Dc(e,t.currentPath):e.join("/")}}function Ug(t,e){let r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==be.ZodAny&&(r.items=We(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&ft(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&ft(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(ft(r,"minItems",t.exactLength.value,t.exactLength.message,e),ft(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}function Gg(t,e){let r={type:"integer",format:"int64"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?ft(r,"minimum",n.value,n.message,e):ft(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),ft(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?ft(r,"maximum",n.value,n.message,e):ft(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),ft(r,"maximum",n.value,n.message,e));break;case"multipleOf":ft(r,"multipleOf",n.value,n.message,e);break}return r}function Yg(){return{type:"boolean"}}function Lc(t,e){return We(t.type._def,e)}var Xg=(t,e)=>We(t.innerType._def,e);function Wf(t,e,r){let n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((s,o)=>Wf(t,e,s))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return B6(t,e)}}var B6=(t,e)=>{let r={type:"integer",format:"unix-time"};if(e.target==="openApi3")return r;for(let n of t.checks)switch(n.kind){case"min":ft(r,"minimum",n.value,n.message,e);break;case"max":ft(r,"maximum",n.value,n.message,e);break}return r};function Wg(t,e){return{...We(t.innerType._def,e),default:t.defaultValue()}}function Kg(t,e){return e.effectStrategy==="input"?We(t.schema._def,e):Lt(e)}function Jg(t){return{type:"string",enum:Array.from(t.values)}}var q6=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function Qg(t,e){let r=[We(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),We(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(o=>!!o),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,s=[];return r.forEach(o=>{if(q6(o))s.push(...o.allOf),o.unevaluatedProperties===void 0&&(n=void 0);else{let i=o;if("additionalProperties"in o&&o.additionalProperties===!1){let{additionalProperties:a,...c}=o;i=c}else n=void 0;s.push(i)}}),s.length?{allOf:s,...n}:void 0}function e_(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}var Kf,dn={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Kf===void 0&&(Kf=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Kf),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Zc(t,e){let r={type:"string"};if(t.checks)for(let n of t.checks)switch(n.kind){case"min":ft(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":ft(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"email":switch(e.emailStrategy){case"format:email":fn(r,"email",n.message,e);break;case"format:idn-email":fn(r,"idn-email",n.message,e);break;case"pattern:zod":mr(r,dn.email,n.message,e);break}break;case"url":fn(r,"uri",n.message,e);break;case"uuid":fn(r,"uuid",n.message,e);break;case"regex":mr(r,n.regex,n.message,e);break;case"cuid":mr(r,dn.cuid,n.message,e);break;case"cuid2":mr(r,dn.cuid2,n.message,e);break;case"startsWith":mr(r,RegExp(`^${Jf(n.value,e)}`),n.message,e);break;case"endsWith":mr(r,RegExp(`${Jf(n.value,e)}$`),n.message,e);break;case"datetime":fn(r,"date-time",n.message,e);break;case"date":fn(r,"date",n.message,e);break;case"time":fn(r,"time",n.message,e);break;case"duration":fn(r,"duration",n.message,e);break;case"length":ft(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),ft(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{mr(r,RegExp(Jf(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&fn(r,"ipv4",n.message,e),n.version!=="v4"&&fn(r,"ipv6",n.message,e);break}case"base64url":mr(r,dn.base64url,n.message,e);break;case"jwt":mr(r,dn.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&mr(r,dn.ipv4Cidr,n.message,e),n.version!=="v4"&&mr(r,dn.ipv6Cidr,n.message,e);break}case"emoji":mr(r,dn.emoji(),n.message,e);break;case"ulid":{mr(r,dn.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{fn(r,"binary",n.message,e);break}case"contentEncoding:base64":{ft(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{mr(r,dn.base64,n.message,e);break}}break}case"nanoid":mr(r,dn.nanoid,n.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function Jf(t,e){return e.patternStrategy==="escape"?F6(t):t}var V6=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function F6(t){let e="";for(let r=0;r<t.length;r++)V6.has(t[r])||(e+="\\"),e+=t[r];return e}function fn(t,e,r,n){t.format||t.anyOf?.some(s=>s.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push({format:e,...r&&n.errorMessages&&{errorMessage:{format:r}}})):ft(t,"format",e,r,n)}function mr(t,e,r,n){t.pattern||t.allOf?.some(s=>s.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push({pattern:t_(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):ft(t,"pattern",t_(e,n),r,n)}function t_(t,e){if(!e.applyRegexFlags||!t.flags)return t.source;let r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},n=r.i?t.source.toLowerCase():t.source,s="",o=!1,i=!1,a=!1;for(let c=0;c<n.length;c++){if(o){s+=n[c],o=!1;continue}if(r.i){if(i){if(n[c].match(/[a-z]/)){a?(s+=n[c],s+=`${n[c-2]}-${n[c]}`.toUpperCase(),a=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(s+=n[c],a=!0):s+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){s+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){s+=`(^|(?<=[\r
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
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 Bc(t,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&t.keyType?._def.typeName===be.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,s)=>({...n,[s]:We(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",s]})??Lt(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let r={type:"object",additionalProperties:We(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===be.ZodString&&t.keyType._def.checks?.length){let{type:n,...s}=Zc(t.keyType._def,e);return{...r,propertyNames:s}}else{if(t.keyType?._def.typeName===be.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===be.ZodBranded&&t.keyType._def.type._def.typeName===be.ZodString&&t.keyType._def.type._def.checks?.length){let{type:n,...s}=Lc(t.keyType._def,e);return{...r,propertyNames:s}}}return r}function r_(t,e){if(e.mapStrategy==="record")return Bc(t,e);let r=We(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||Lt(e),n=We(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||Lt(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function n_(t){let e=t.values,n=Object.keys(t.values).filter(o=>typeof e[e[o]]!="number").map(o=>e[o]),s=Array.from(new Set(n.map(o=>typeof o)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:n}}function s_(t){return t.target==="openAi"?void 0:{not:Lt({...t,currentPath:[...t.currentPath,"not"]})}}function o_(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var Gi={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function a_(t,e){if(e.target==="openApi3")return i_(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in Gi&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((s,o)=>{let i=Gi[o._def.typeName];return i&&!s.includes(i)?[...s,i]:s},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((s,o)=>{let i=typeof o._def.value;switch(i){case"string":case"number":case"boolean":return[...s,i];case"bigint":return[...s,"integer"];case"object":if(o._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(n.length===r.length){let s=n.filter((o,i,a)=>a.indexOf(o)===i);return{type:s.length>1?s:s[0],enum:r.reduce((o,i)=>o.includes(i._def.value)?o:[...o,i._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,s)=>[...n,...s._def.values.filter(o=>!n.includes(o))],[])};return i_(t,e)}var i_=(t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,s)=>We(n._def,{...e,currentPath:[...e.currentPath,"anyOf",`${s}`]})).filter(n=>!!n&&(!e.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function c_(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return e.target==="openApi3"?{type:Gi[t.innerType._def.typeName],nullable:!0}:{type:[Gi[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let n=We(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=We(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function l_(t,e){let r={type:"number"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",Xf(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?ft(r,"minimum",n.value,n.message,e):ft(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),ft(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?ft(r,"maximum",n.value,n.message,e):ft(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),ft(r,"maximum",n.value,n.message,e));break;case"multipleOf":ft(r,"multipleOf",n.value,n.message,e);break}return r}function u_(t,e){let r=e.target==="openAi",n={type:"object",properties:{}},s=[],o=t.shape();for(let a in o){let c=o[a];if(c===void 0||c._def===void 0)continue;let d=U6(c);d&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),d=!1);let l=We(c._def,{...e,currentPath:[...e.currentPath,"properties",a],propertyPath:[...e.currentPath,"properties",a]});l!==void 0&&(n.properties[a]=l,d||s.push(a))}s.length&&(n.required=s);let i=H6(t,e);return i!==void 0&&(n.additionalProperties=i),n}function H6(t,e){if(t.catchall._def.typeName!=="ZodNever")return We(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function U6(t){try{return t.isOptional()}catch{return!0}}var d_=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return We(t.innerType._def,e);let r=We(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Lt(e)},r]}:Lt(e)};var f_=(t,e)=>{if(e.pipeStrategy==="input")return We(t.in._def,e);if(e.pipeStrategy==="output")return We(t.out._def,e);let r=We(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=We(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(s=>s!==void 0)}};function h_(t,e){return We(t.type._def,e)}function p_(t,e){let n={type:"array",uniqueItems:!0,items:We(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&ft(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&ft(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}function m_(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>We(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:We(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>We(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function g_(t){return{not:Lt(t)}}function __(t){return Lt(t)}var b_=(t,e)=>We(t.innerType._def,e);var y_=(t,e,r)=>{switch(e){case be.ZodString:return Zc(t,r);case be.ZodNumber:return l_(t,r);case be.ZodObject:return u_(t,r);case be.ZodBigInt:return Gg(t,r);case be.ZodBoolean:return Yg();case be.ZodDate:return Wf(t,r);case be.ZodUndefined:return g_(r);case be.ZodNull:return o_(r);case be.ZodArray:return Ug(t,r);case be.ZodUnion:case be.ZodDiscriminatedUnion:return a_(t,r);case be.ZodIntersection:return Qg(t,r);case be.ZodTuple:return m_(t,r);case be.ZodRecord:return Bc(t,r);case be.ZodLiteral:return e_(t,r);case be.ZodEnum:return Jg(t);case be.ZodNativeEnum:return n_(t);case be.ZodNullable:return c_(t,r);case be.ZodOptional:return d_(t,r);case be.ZodMap:return r_(t,r);case be.ZodSet:return p_(t,r);case be.ZodLazy:return()=>t.getter()._def;case be.ZodPromise:return h_(t,r);case be.ZodNaN:case be.ZodNever:return s_(r);case be.ZodEffects:return Kg(t,r);case be.ZodAny:return Lt(r);case be.ZodUnknown:return __(r);case be.ZodDefault:return Wg(t,r);case be.ZodBranded:return Lc(t,r);case be.ZodReadonly:return b_(t,r);case be.ZodCatch:return Xg(t,r);case be.ZodPipeline:return f_(t,r);case be.ZodFunction:case be.ZodVoid:case be.ZodSymbol:return;default:return(n=>{})(e)}};function We(t,e,r=!1){let n=e.seen.get(t);if(e.override){let a=e.override?.(t,e,n,r);if(a!==Vg)return a}if(n&&!r){let a=G6(n,e);if(a!==void 0)return a}let s={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,s);let o=y_(t,t.typeName,e),i=typeof o=="function"?We(o(),e):o;if(i&&Y6(t,e,i),e.postProcess){let a=e.postProcess(i,t,e);return s.jsonSchema=i,a}return s.jsonSchema=i,i}var G6=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Dc(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),Lt(e)):e.$refStrategy==="seen"?Lt(e):void 0}},Y6=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r);var Qf=(t,e)=>{let r=Hg(e),n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[d,l])=>({...c,[d]:We(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,d]},!0)??Lt(r)}),{}):void 0,s=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,o=We(t._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1)??Lt(r),i=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;i!==void 0&&(o.title=i),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let a=s===void 0?n?{...o,[r.definitionPath]:n}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:{...n,[s]:o}};return r.target==="jsonSchema7"?a.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(a.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in a||"oneOf"in a||"allOf"in a||"type"in a&&Array.isArray(a.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),a};function X6(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function eh(t,e){return Gr(t)?xf(t,{target:X6(e?.target),io:e?.pipeStrategy??"input"}):Qf(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function th(t){let r=es(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=pc(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function rh(t,e){let r=Qn(t,e);if(!r.success)throw r.error;return r.data}var W6=6e4,qc=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(wc,r=>{this._oncancel(r)}),this.setNotificationHandler(kc,r=>{this._onprogress(r)}),this.setRequestHandler(xc,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Sc,async(r,n)=>{let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new Ze(Ue.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(Tc,async(r,n)=>{let s=async()=>{let o=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(o,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,d=c.id,l=this._requestResolvers.get(d);if(l)if(this._requestResolvers.delete(d),a.type==="response")l(c);else{let u=c,h=new Ze(u.error.code,u.error.message,u.error.data);l(h)}else{let u=a.type==="response"?"Response":"Error";this._onerror(new Error(`${u} handler missing for request ${d}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(o,n.sessionId);if(!i)throw new Ze(Ue.InvalidParams,`Task not found: ${o}`);if(!rs(i.status))return await this._waitForTaskUpdate(o,n.signal),await s();if(rs(i.status)){let a=await this._taskStore.getTaskResult(o,n.sessionId);return this._clearTaskQueue(o),{...a,_meta:{...a._meta,[ts]:{taskId:o}}}}return await s()};return await s()}),this.setRequestHandler($c,async(r,n)=>{try{let{tasks:s,nextCursor:o}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:s,nextCursor:o,_meta:{}}}catch(s){throw new Ze(Ue.InvalidParams,`Failed to list tasks: ${s instanceof Error?s.message:String(s)}`)}}),this.setRequestHandler(Pc,async(r,n)=>{try{let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new Ze(Ue.InvalidParams,`Task not found: ${r.params.taskId}`);if(rs(s.status))throw new Ze(Ue.InvalidParams,`Cannot cancel task in terminal status: ${s.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new Ze(Ue.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(s){throw s instanceof Ze?s:new Ze(Ue.InvalidRequest,`Failed to cancel task: ${s instanceof Error?s.message:String(s)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,s,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(s,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:o,onTimeout:s})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),Ze.fromError(Ue.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=o=>{n?.(o),this._onerror(o)};let s=this._transport?.onmessage;this._transport.onmessage=(o,i)=>{s?.(o,i),Di(o)||zg(o)?this._onresponse(o):Nf(o)?this._onrequest(o,i):Mg(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=Ze.fromError(Ue.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,r){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,s=this._transport,o=e.params?._meta?.[ts]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:Ue.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:l,timestamp:Date.now()},s?.sessionId).catch(u=>this._onerror(new Error(`Failed to enqueue error response: ${u}`))):s?.send(l).catch(u=>this._onerror(new Error(`Failed to send an error response: ${u}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=$g(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,s?.sessionId):void 0,d={signal:i.signal,sessionId:s?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let u={relatedRequestId:e.id};o&&(u.relatedTask={taskId:o}),await this.notification(l,u)},sendRequest:async(l,u,h)=>{if(i.signal.aborted)throw new Ze(Ue.ConnectionClosed,"Request was cancelled");let p={...h,relatedRequestId:e.id};o&&!p.relatedTask&&(p.relatedTask={taskId:o});let g=p.relatedTask?.taskId??o;return g&&c&&await c.updateTaskStatus(g,"input_required"),await this.request(l,u,p)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:o,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,d)).then(async l=>{if(i.signal.aborted)return;let u={result:l,jsonrpc:"2.0",id:e.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:u,timestamp:Date.now()},s?.sessionId):await s?.send(u)},async l=>{if(i.signal.aborted)return;let u={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:Ue.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:u,timestamp:Date.now()},s?.sessionId):await s?.send(u)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===i&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...n}=e.params,s=Number(r),o=this._progressHandlers.get(s);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(s),a=this._timeoutInfo.get(s);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(c){this._responseHandlers.delete(s),this._progressHandlers.delete(s),this._cleanupTimeout(s),i(c);return}o(n)}_onresponse(e){let r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Di(e))n(e);else{let i=new Ze(e.error.code,e.error.message,e.error.data);n(i)}return}let s=this._responseHandlers.get(r);if(s===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let o=!1;if(Di(e)&&e.result&&typeof e.result=="object"){let i=e.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(o=!0,this._taskProgressTokens.set(a.taskId,r))}}if(o||this._progressHandlers.delete(r),Di(e))s(e);else{let i=Ze.fromError(e.error.code,e.error.message,e.error.data);s(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){let{task:s}=n??{};if(!s){try{yield{type:"result",result:await this.request(e,r,n)}}catch(i){yield{type:"error",error:i instanceof Ze?i:new Ze(Ue.InternalError,String(i))}}return}let o;try{let i=await this.request(e,Mo,n);if(i.task)o=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new Ze(Ue.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:o},n);if(yield{type:"taskStatus",task:a},rs(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)}:a.status==="failed"?yield{type:"error",error:new Ze(Ue.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new Ze(Ue.InternalError,`Task ${o} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(d=>setTimeout(d,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof Ze?i:new Ze(Ue.InternalError,String(i))}}}request(e,r,n){let{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((d,l)=>{let u=_=>{l(_)};if(!this._transport){u(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(_){u(_);return}n?.signal?.throwIfAborted();let h=this._requestMessageId++,p={...e,jsonrpc:"2.0",id:h};n?.onprogress&&(this._progressHandlers.set(h,n.onprogress),p.params={...e.params,_meta:{...e.params?._meta||{},progressToken:h}}),a&&(p.params={...p.params,task:a}),c&&(p.params={...p.params,_meta:{...p.params?._meta||{},[ts]:c}});let g=_=>{this._responseHandlers.delete(h),this._progressHandlers.delete(h),this._cleanupTimeout(h),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:h,reason:String(_)}},{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i}).catch($=>this._onerror(new Error(`Failed to send cancellation: ${$}`)));let m=_ instanceof Ze?_:new Ze(Ue.RequestTimeout,String(_));l(m)};this._responseHandlers.set(h,_=>{if(!n?.signal?.aborted){if(_ instanceof Error)return l(_);try{let m=Qn(r,_.result);m.success?d(m.data):l(m.error)}catch(m){l(m)}}}),n?.signal?.addEventListener("abort",()=>{g(n?.signal?.reason)});let x=n?.timeout??W6,S=()=>g(Ze.fromError(Ue.RequestTimeout,"Request timed out",{timeout:x}));this._setupTimeout(h,x,n?.maxTotalTimeout,S,n?.resetTimeoutOnProgress??!1);let k=c?.taskId;if(k){let _=m=>{let $=this._responseHandlers.get(h);$?$(m):this._onerror(new Error(`Response handler missing for side-channeled request ${h}`))};this._requestResolvers.set(h,_),this._enqueueTaskMessage(k,{type:"request",message:p,timestamp:Date.now()}).catch(m=>{this._cleanupTimeout(h),l(m)})}else this._transport.send(p,{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i}).catch(_=>{this._cleanupTimeout(h),l(_)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Ec,r)}async getTaskResult(e,r,n){return this.request({method:"tasks/result",params:e},r,n)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},Rc,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},Ag,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n=r?.relatedTask?.taskId;if(n){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[ts]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[ts]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[ts]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let n=th(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,o)=>{let i=rh(e,s);return Promise.resolve(r(i,o))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let n=th(e);this._notificationHandlers.set(n,s=>{let o=rh(e,s);return Promise.resolve(r(o))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let s=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,n,s)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,r);for(let s of n)if(s.type==="request"&&Nf(s.message)){let o=s.message.id,i=this._requestResolvers.get(o);i?(i(new Ze(Ue.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let s=await this._taskStore?.getTask(e);s?.pollInterval&&(n=s.pollInterval)}catch{}return new Promise((s,o)=>{if(r.aborted){o(new Ze(Ue.InvalidRequest,"Request cancelled"));return}let i=setTimeout(s,n);r.addEventListener("abort",()=>{clearTimeout(i),o(new Ze(Ue.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async s=>{if(!e)throw new Error("No request provided");return await n.createTask(s,e.id,{method:e.method,params:e.params},r)},getTask:async s=>{let o=await n.getTask(s,r);if(!o)throw new Ze(Ue.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(s,o,i)=>{await n.storeTaskResult(s,o,i,r);let a=await n.getTask(s,r);if(a){let c=Vi.parse({method:"notifications/tasks/status",params:a});await this.notification(c),rs(a.status)&&this._cleanupTaskProgressHandler(s)}},getTaskResult:s=>n.getTaskResult(s,r),updateTaskStatus:async(s,o,i)=>{let a=await n.getTask(s,r);if(!a)throw new Ze(Ue.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(rs(a.status))throw new Ze(Ue.InvalidParams,`Cannot update task "${s}" from terminal status "${a.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(s,o,i,r);let c=await n.getTask(s,r);if(c){let d=Vi.parse({method:"notifications/tasks/status",params:c});await this.notification(d),rs(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}};function v_(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function w_(t,e){let r={...t};for(let n in e){let s=n,o=e[s];if(o===void 0)continue;let i=r[s];v_(i)&&v_(o)?r[s]={...i,...o}:r[s]=o}return r}var fy=T1(qp(),1),hy=T1(dy(),1);function QT(){let t=new fy.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,hy.default)(t),t}var kl=class{constructor(e){this._ajv=e??QT()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var Sl=class{constructor(e){this._server=e}requestStream(e,r,n){return this._server.requestStream(e,r,n)}createMessageStream(e,r){let n=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let s=e.messages[e.messages.length-1],o=Array.isArray(s.content)?s.content:[s.content],i=o.some(l=>l.type==="tool_result"),a=e.messages.length>1?e.messages[e.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],d=c.some(l=>l.type==="tool_use");if(i){if(o.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!d)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(d){let l=new Set(c.filter(h=>h.type==="tool_use").map(h=>h.id)),u=new Set(o.filter(h=>h.type==="tool_result").map(h=>h.toolUseId));if(l.size!==u.size||![...l].every(h=>u.has(h)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:e},Ui,r)}elicitInputStream(e,r){let n=this._server.getClientCapabilities(),s=e.mode??"form";switch(s){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let o=s==="form"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:o},Oo,r)}async getTask(e,r){return this._server.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._server.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._server.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._server.cancelTask({taskId:e},r)}};function py(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function my(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}var El=class extends qc{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Hi.options.map((n,s)=>[n,s])),this.isMessageIgnored=(n,s)=>{let o=this._loggingLevels.get(s);return o?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(o):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new kl,this.setRequestHandler(Df,n=>this._oninitialize(n)),this.setNotificationHandler(Lf,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Uf,async(n,s)=>{let o=s.sessionId||s.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=Hi.safeParse(i);return a.success&&this._loggingLevels.set(o,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Sl(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=w_(this._capabilities,e)}setRequestHandler(e,r){let s=es(e)?.method;if(!s)throw new Error("Schema is missing a method literal");let o;if(Gr(s)){let a=s;o=a._zod?.def?.value??a.value}else{let a=s;o=a._def?.value??a.value}if(typeof o!="string")throw new Error("Schema method literal must be a string");if(o==="tools/call"){let a=async(c,d)=>{let l=Qn(Io,c);if(!l.success){let g=l.error instanceof Error?l.error.message:String(l.error);throw new Ze(Ue.InvalidParams,`Invalid tools/call request: ${g}`)}let{params:u}=l.data,h=await Promise.resolve(r(c,d));if(u.task){let g=Qn(Mo,h);if(!g.success){let x=g.error instanceof Error?g.error.message:String(g.error);throw new Ze(Ue.InvalidParams,`Invalid task creation result: ${x}`)}return g.data}let p=Qn(Cc,h);if(!p.success){let g=p.error instanceof Error?p.error.message:String(p.error);throw new Ze(Ue.InvalidParams,`Invalid tools/call result: ${g}`)}return p.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`);break;case"ping":case"initialize":break}}assertTaskCapability(e){my(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&py(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:Sg.includes(r)?r:Of,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},vc)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let n=e.messages[e.messages.length-1],s=Array.isArray(n.content)?n.content:[n.content],o=s.some(d=>d.type==="tool_result"),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],c=a.some(d=>d.type==="tool_use");if(o){if(s.some(d=>d.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let d=new Set(a.filter(u=>u.type==="tool_use").map(u=>u.id)),l=new Set(s.filter(u=>u.type==="tool_result").map(u=>u.toolUseId));if(d.size!==l.size||![...d].every(u=>l.has(u)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},Gf,r):this.request({method:"sampling/createMessage",params:e},Ui,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let s=e;return this.request({method:"elicitation/create",params:s},Oo,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let s=e.mode==="form"?e:{...e,mode:"form"},o=await this.request({method:"elicitation/create",params:s},Oo,r);if(o.action==="accept"&&o.content&&s.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(s.requestedSchema)(o.content);if(!a.valid)throw new Ze(Ue.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof Ze?i:new Ze(Ue.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return o}}}createElicitationCompletionNotifier(e,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},Yf,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var _y=Symbol.for("mcp.completable");function Wp(t){return!!t&&typeof t=="object"&&_y in t}function by(t){return t[_y]?.complete}var gy;(function(t){t.Completable="McpCompletable"})(gy||(gy={}));var Tl=class t{static isTemplate(e){return/\{[^}\s]+\}/.test(e)}static validateLength(e,r,n){if(e.length>r)throw new Error(`${n} exceeds maximum length of ${r} characters (got ${e.length})`)}get variableNames(){return this.parts.flatMap(e=>typeof e=="string"?[]:e.names)}constructor(e){t.validateLength(e,1e6,"Template"),this.template=e,this.parts=this.parse(e)}toString(){return this.template}parse(e){let r=[],n="",s=0,o=0;for(;s<e.length;)if(e[s]==="{"){n&&(r.push(n),n="");let i=e.indexOf("}",s);if(i===-1)throw new Error("Unclosed template expression");if(o++,o>1e4)throw new Error("Template contains too many expressions (max 10000)");let a=e.slice(s+1,i),c=this.getOperator(a),d=a.includes("*"),l=this.getNames(a),u=l[0];for(let h of l)t.validateLength(h,1e6,"Variable name");r.push({name:u,operator:c,names:l,exploded:d}),s=i+1}else n+=e[s],s++;return n&&r.push(n),r}getOperator(e){return["+","#",".","/","?","&"].find(n=>e.startsWith(n))||""}getNames(e){let r=this.getOperator(e);return e.slice(r.length).split(",").map(n=>n.replace("*","").trim()).filter(n=>n.length>0)}encodeValue(e,r){return t.validateLength(e,1e6,"Variable value"),r==="+"||r==="#"?encodeURI(e):encodeURIComponent(e)}expandPart(e,r){if(e.operator==="?"||e.operator==="&"){let i=e.names.map(c=>{let d=r[c];if(d===void 0)return"";let l=Array.isArray(d)?d.map(u=>this.encodeValue(u,e.operator)).join(","):this.encodeValue(d.toString(),e.operator);return`${c}=${l}`}).filter(c=>c.length>0);return i.length===0?"":(e.operator==="?"?"?":"&")+i.join("&")}if(e.names.length>1){let i=e.names.map(a=>r[a]).filter(a=>a!==void 0);return i.length===0?"":i.map(a=>Array.isArray(a)?a[0]:a).join(",")}let n=r[e.name];if(n===void 0)return"";let o=(Array.isArray(n)?n:[n]).map(i=>this.encodeValue(i,e.operator));switch(e.operator){case"":return o.join(",");case"+":return o.join(",");case"#":return"#"+o.join(",");case".":return"."+o.join(".");case"/":return"/"+o.join("/");default:return o.join(",")}}expand(e){let r="",n=!1;for(let s of this.parts){if(typeof s=="string"){r+=s;continue}let o=this.expandPart(s,e);o&&((s.operator==="?"||s.operator==="&")&&n?r+=o.replace("?","&"):r+=o,(s.operator==="?"||s.operator==="&")&&(n=!0))}return r}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}partToRegExp(e){let r=[];for(let o of e.names)t.validateLength(o,1e6,"Variable name");if(e.operator==="?"||e.operator==="&"){for(let o=0;o<e.names.length;o++){let i=e.names[o],a=o===0?"\\"+e.operator:"&";r.push({pattern:a+this.escapeRegExp(i)+"=([^&]+)",name:i})}return r}let n,s=e.name;switch(e.operator){case"":n=e.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)";break;case"+":case"#":n="(.+)";break;case".":n="\\.([^/,]+)";break;case"/":n="/"+(e.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)");break;default:n="([^/]+)"}return r.push({pattern:n,name:s}),r}match(e){t.validateLength(e,1e6,"URI");let r="^",n=[];for(let a of this.parts)if(typeof a=="string")r+=this.escapeRegExp(a);else{let c=this.partToRegExp(a);for(let{pattern:d,name:l}of c)r+=d,n.push({name:l,exploded:a.exploded})}r+="$",t.validateLength(r,1e6,"Generated regex pattern");let s=new RegExp(r),o=e.match(s);if(!o)return null;let i={};for(let a=0;a<n.length;a++){let{name:c,exploded:d}=n[a],l=o[a+1],u=c.replace("*","");d&&l.includes(",")?i[u]=l.split(","):i[u]=l}return i}};var e$=/^[A-Za-z0-9._-]{1,128}$/;function t$(t){let e=[];if(t.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(t.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${t.length})`]};if(t.includes(" ")&&e.push("Tool name contains spaces, which may cause parsing issues"),t.includes(",")&&e.push("Tool name contains commas, which may cause parsing issues"),(t.startsWith("-")||t.endsWith("-"))&&e.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(t.startsWith(".")||t.endsWith("."))&&e.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!e$.test(t)){let r=t.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,s,o)=>o.indexOf(n)===s);return e.push(`Tool name contains invalid characters: ${r.map(n=>`"${n}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:e}}return{isValid:!0,warnings:e}}function r$(t,e){if(e.length>0){console.warn(`Tool name validation warning for "${t}":`);for(let r of e)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function Kp(t){let e=t$(t);return r$(t,e.warnings),e.isValid}var $l=class{constructor(e){this._mcpServer=e}registerToolTask(e,r,n){let s={taskSupport:"required",...r.execution};if(s.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,s,r._meta,n)}};var Rl=class{constructor(e,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new El(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new $l(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(ds(Nc)),this.server.assertCanSetRequestHandler(ds(Io)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Nc,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,r])=>{let n={name:e,title:r.title,description:r.description,inputSchema:(()=>{let s=Ro(r.inputSchema);return s?eh(s,{strictUnions:!0,pipeStrategy:"input"}):n$})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let s=Ro(r.outputSchema);s&&(n.outputSchema=eh(s,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(Io,async(e,r)=>{try{let n=this._registeredTools[e.params.name];if(!n)throw new Ze(Ue.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new Ze(Ue.InvalidParams,`Tool ${e.params.name} disabled`);let s=!!e.params.task,o=n.execution?.taskSupport,i="createTask"in n.handler;if((o==="required"||o==="optional")&&!i)throw new Ze(Ue.InternalError,`Tool ${e.params.name} has taskSupport '${o}' but was not registered with registerToolTask`);if(o==="required"&&!s)throw new Ze(Ue.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(o==="optional"&&!s&&i)return await this.handleAutomaticTaskPolling(n,e,r);let a=await this.validateToolInput(n,e.params.arguments,e.params.name),c=await this.executeToolHandler(n,a,r);return s||await this.validateToolOutput(n,c,e.params.name),c}catch(n){if(n instanceof Ze&&n.code===Ue.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,r,n){if(!e.inputSchema)return;let o=Ro(e.inputSchema)??e.inputSchema,i=await fc(o,r);if(!i.success){let a="error"in i?i.error:"Unknown error",c=hc(a);throw new Ze(Ue.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${c}`)}return i.data}async validateToolOutput(e,r,n){if(!e.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new Ze(Ue.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let s=Ro(e.outputSchema),o=await fc(s,r.structuredContent);if(!o.success){let i="error"in o?o.error:"Unknown error",a=hc(i);throw new Ze(Ue.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${a}`)}}async executeToolHandler(e,r,n){let s=e.handler;if("createTask"in s){if(!n.taskStore)throw new Error("No task store provided.");let i={...n,taskStore:n.taskStore};if(e.inputSchema){let a=s;return await Promise.resolve(a.createTask(r,i))}else{let a=s;return await Promise.resolve(a.createTask(i))}}if(e.inputSchema){let i=s;return await Promise.resolve(i(r,n))}else{let i=s;return await Promise.resolve(i(n))}}async handleAutomaticTaskPolling(e,r,n){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");let s=await this.validateToolInput(e,r.params.arguments,r.params.name),o=e.handler,i={...n,taskStore:n.taskStore},a=s?await Promise.resolve(o.createTask(s,i)):await Promise.resolve(o.createTask(i)),c=a.task.taskId,d=a.task,l=d.pollInterval??5e3;for(;d.status!=="completed"&&d.status!=="failed"&&d.status!=="cancelled";){await new Promise(h=>setTimeout(h,l));let u=await n.taskStore.getTask(c);if(!u)throw new Ze(Ue.InternalError,`Task ${c} not found during polling`);d=u}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(ds(jc)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(jc,async e=>{switch(e.params.ref.type){case"ref/prompt":return Zg(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return Bg(e),this.handleResourceCompletion(e,e.params.ref);default:throw new Ze(Ue.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){let n=this._registeredPrompts[r.name];if(!n)throw new Ze(Ue.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new Ze(Ue.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return ka;let o=es(n.argsSchema)?.[e.params.argument.name];if(!Wp(o))return ka;let i=by(o);if(!i)return ka;let a=await i(e.params.argument.value,e.params.context);return vy(a)}async handleResourceCompletion(e,r){let n=Object.values(this._registeredResourceTemplates).find(i=>i.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return ka;throw new Ze(Ue.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let s=n.resourceTemplate.completeCallback(e.params.argument.name);if(!s)return ka;let o=await s(e.params.argument.value,e.params.context);return vy(o)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(ds(Mc)),this.server.assertCanSetRequestHandler(ds(zc)),this.server.assertCanSetRequestHandler(ds(Ic)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Mc,async(e,r)=>{let n=Object.entries(this._registeredResources).filter(([o,i])=>i.enabled).map(([o,i])=>({uri:o,name:i.name,...i.metadata})),s=[];for(let o of Object.values(this._registeredResourceTemplates)){if(!o.resourceTemplate.listCallback)continue;let i=await o.resourceTemplate.listCallback(r);for(let a of i.resources)s.push({...o.metadata,...a})}return{resources:[...n,...s]}}),this.server.setRequestHandler(zc,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(Ic,async(e,r)=>{let n=new URL(e.params.uri),s=this._registeredResources[n.toString()];if(s){if(!s.enabled)throw new Ze(Ue.InvalidParams,`Resource ${n} disabled`);return s.readCallback(n,r)}for(let o of Object.values(this._registeredResourceTemplates)){let i=o.resourceTemplate.uriTemplate.match(n.toString());if(i)return o.readCallback(n,i,r)}throw new Ze(Ue.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(ds(Oc)),this.server.assertCanSetRequestHandler(ds(Ac)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Oc,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?s$(r.argsSchema):void 0}))})),this.server.setRequestHandler(Ac,async(e,r)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new Ze(Ue.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new Ze(Ue.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let s=Ro(n.argsSchema),o=await fc(s,e.params.arguments);if(!o.success){let c="error"in o?o.error:"Unknown error",d=hc(c);throw new Ze(Ue.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${d}`)}let i=o.data,a=n.callback;return await Promise.resolve(a(i,r))}else{let s=n.callback;return await Promise.resolve(s(r))}}),this._promptHandlersInitialized=!0)}resource(e,r,...n){let s;typeof n[0]=="object"&&(s=n.shift());let o=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let i=this._createRegisteredResource(e,void 0,r,s,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let i=this._createRegisteredResourceTemplate(e,void 0,r,s,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}registerResource(e,r,n,s){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let o=this._createRegisteredResource(e,n.title,r,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let o=this._createRegisteredResourceTemplate(e,n.title,r,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}_createRegisteredResource(e,r,n,s,o){let i={name:e,title:r,metadata:s,readCallback:o,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==n&&(delete this._registeredResources[n],a.uri&&(this._registeredResources[a.uri]=i)),typeof a.name<"u"&&(i.name=a.name),typeof a.title<"u"&&(i.title=a.title),typeof a.metadata<"u"&&(i.metadata=a.metadata),typeof a.callback<"u"&&(i.readCallback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=i,i}_createRegisteredResourceTemplate(e,r,n,s,o){let i={resourceTemplate:n,title:r,metadata:s,readCallback:o,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:d=>{typeof d.name<"u"&&d.name!==e&&(delete this._registeredResourceTemplates[e],d.name&&(this._registeredResourceTemplates[d.name]=i)),typeof d.title<"u"&&(i.title=d.title),typeof d.template<"u"&&(i.resourceTemplate=d.template),typeof d.metadata<"u"&&(i.metadata=d.metadata),typeof d.callback<"u"&&(i.readCallback=d.callback),typeof d.enabled<"u"&&(i.enabled=d.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=i;let a=n.uriTemplate.variableNames;return Array.isArray(a)&&a.some(d=>!!n.completeCallback(d))&&this.setCompletionRequestHandler(),i}_createRegisteredPrompt(e,r,n,s,o){let i={title:r,description:n,argsSchema:s===void 0?void 0:Fs(s),callback:o,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==e&&(delete this._registeredPrompts[e],a.name&&(this._registeredPrompts[a.name]=i)),typeof a.title<"u"&&(i.title=a.title),typeof a.description<"u"&&(i.description=a.description),typeof a.argsSchema<"u"&&(i.argsSchema=Fs(a.argsSchema)),typeof a.callback<"u"&&(i.callback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=i,s&&Object.values(s).some(c=>{let d=c instanceof xr?c._def?.innerType:c;return Wp(d)})&&this.setCompletionRequestHandler(),i}_createRegisteredTool(e,r,n,s,o,i,a,c,d){Kp(e);let l={title:r,description:n,inputSchema:yy(s),outputSchema:yy(o),annotations:i,execution:a,_meta:c,handler:d,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:u=>{typeof u.name<"u"&&u.name!==e&&(typeof u.name=="string"&&Kp(u.name),delete this._registeredTools[e],u.name&&(this._registeredTools[u.name]=l)),typeof u.title<"u"&&(l.title=u.title),typeof u.description<"u"&&(l.description=u.description),typeof u.paramsSchema<"u"&&(l.inputSchema=Fs(u.paramsSchema)),typeof u.outputSchema<"u"&&(l.outputSchema=Fs(u.outputSchema)),typeof u.callback<"u"&&(l.handler=u.callback),typeof u.annotations<"u"&&(l.annotations=u.annotations),typeof u._meta<"u"&&(l._meta=u._meta),typeof u.enabled<"u"&&(l.enabled=u.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(e,...r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let n,s,o,i;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let c=r[0];if(Jp(c))s=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!Jp(r[0])&&(i=r.shift());else if(typeof c=="object"&&c!==null){if(Object.values(c).some(d=>typeof d=="object"&&d!==null))throw new Error(`Tool ${e} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);i=r.shift()}}let a=r[0];return this._createRegisteredTool(e,void 0,n,s,o,i,{taskSupport:"forbidden"},void 0,a)}registerTool(e,r,n){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let{title:s,description:o,inputSchema:i,outputSchema:a,annotations:c,_meta:d}=r;return this._createRegisteredTool(e,s,o,i,a,c,{taskSupport:"forbidden"},d,n)}prompt(e,...r){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let s;r.length>1&&(s=r.shift());let o=r[0],i=this._createRegisteredPrompt(e,void 0,n,s,o);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),i}registerPrompt(e,r,n){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let{title:s,description:o,argsSchema:i}=r,a=this._createRegisteredPrompt(e,s,o,i,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,r){return this.server.sendLoggingMessage(e,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}},Pl=class{constructor(e,r){this._callbacks=r,this._uriTemplate=typeof e=="string"?new Tl(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){return this._callbacks.complete?.[e]}},n$={type:"object",properties:{}};function wy(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function xy(t){return"_def"in t||"_zod"in t||wy(t)}function Jp(t){return typeof t!="object"||t===null||xy(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(wy)}function yy(t){if(t){if(Jp(t))return Fs(t);if(!xy(t))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return t}}function s$(t){let e=es(t);return e?Object.entries(e).map(([r,n])=>{let s=eg(n),o=tg(n);return{name:r,description:s,required:!o}}):[]}function ds(t){let r=es(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=pc(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function vy(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}var ka={completion:{values:[],hasMore:!1}};import Sy from"node:process";var Ml=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
41
- `);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),o$(r)}clear(){this._buffer=void 0}};function o$(t){return Ig.parse(JSON.parse(t))}function ky(t){return JSON.stringify(t)+`
42
- `}var zl=class{constructor(e=Sy.stdin,r=Sy.stdout){this._stdin=e,this._stdout=r,this._readBuffer=new Ml,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(r=>{let n=ky(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};import{accessSync as kO,constants as SO,writeFileSync as EO,mkdirSync as L3}from"node:fs";import{fileURLToPath as TO,pathToFileURL as Z3}from"node:url";import{tmpdir as j3}from"node:os";import{createServer as $O}from"node:http";import*as Jt from"node:path";var Lr=["alloy","ash","ballad","coral","echo","fable","marin","nova","onyx","sage","shimmer","verse","cedar"],i$="cedar",fs={alloy:"neutral, balanced",ash:"warm, expressive",ballad:"soft, mellow",coral:"bright, friendly",echo:"calm, measured",fable:"storytelling, animated",marin:"natural, conversational",nova:"energetic, upbeat",onyx:"deep, authoritative",sage:"steady, thoughtful",shimmer:"light, gentle",verse:"lively, dynamic",cedar:"warm, natural (default)"};function Ey(t){return t&&Lr.includes(t)?t:i$}var a$="TTS voice to narrate with \u2014 pick the one that best fits the topic/audience. Defaults to cedar (warm, natural). Options: "+Lr.map(t=>`${t} (${fs[t]})`).join(", ")+".",c$=G.object({find:G.string().min(1).describe('An EXACT snippet that currently exists in the file, used to anchor the change. Use the SMALLEST text that is unique in the file (whitespace must match exactly). To INSERT, keep the anchor in both sides, e.g. find "return x" \u2192 replace "// note\\nreturn x". To DELETE, set replace to "".'),replace:G.string().describe("What `find` becomes. Only its changed region types out \u2014 not the whole file."),occurrence:G.number().int().positive().optional().describe("1-based index of WHICH occurrence of `find` to target when it appears more than once. Required if `find` is not unique; defaults to 1.")}),l$=G.object({say:G.string().optional().describe('Narration for this step \u2014 ONE SHORT BEAT: a single idea, roughly 4\u201314 words (one breath). Shown as a synced caption and spoken aloud. Write the whole walkthrough as one continuous spoken script and chop it into these little beats: read in order, every `say` should flow as one natural explanation, each beat CONTINUING the previous (use connectors like "so", "then", "now", "and", "but"). Do NOT write a long self-contained sentence \u2014 if it has an "and"/comma joining two ideas, split it into two steps. The highlight appears in sync with the START of this beat, so one beat = one subject.'),file:G.string().optional().describe('Path of the file to show this step, e.g. "src/debounce.ts". Created if new and made the active editor tab. If omitted, the previously shown file stays active. Switch files with a step that just sets `file` (+ `say`/`highlight`) and NO code \u2014 like a person clicking a tab.'),code:G.string().optional().describe("Full contents of `file`, used ONLY to INTRODUCE a file the first time. The file is shown INSTANTLY (not typed out) \u2014 initial files, especially big ones, just appear. To CHANGE an already-written file, use `edits` (small find/replace deltas that DO type out) \u2014 do NOT resend the whole file. To just explain or point at existing code, use a step with `say` + `highlight` and NO `code`. For a deliberate full rewrite of an existing file, set `rewrite: true`."),edits:G.array(c$).optional().describe("Small find/replace edits to the CURRENT file \u2014 the granular, human way to change already-written code. Prefer this over resending `code`. Each edit types out only its changed region. Keep each step to one small edit (or a few closely-related ones). A step uses EITHER `code` OR `edits`, never both."),rewrite:G.boolean().optional().describe("Set true ONLY for a deliberate full-file rewrite via `code` on a file that already has content. Normally use `edits` instead."),typing:G.boolean().optional().describe("Animate `edits` as typing (default true). Set false to make an edit appear instantly. (`code` is always shown instantly regardless.)"),highlightCode:G.string().optional().describe("PREFERRED way to point at code: an EXACT snippet of the current file to highlight. The server finds this exact text AS IT STANDS at this step and highlights precisely those characters (and scrolls + glows it into view), so it never drifts when edits shift line numbers. MATCH the snippet to what you are explaining: pass a SINGLE token/line when you name one thing, or an ENTIRE multi-line block (newlines included) \u2014 a function body, useEffect, JSX element, if/try/map \u2014 when you explain that whole block. Do not shrink a multi-line subject to one line. The snippet must be UNIQUE in the file (it errors if missing or appearing more than once); if a short snippet is not unique, extend it rather than narrowing your intended highlight. Prefer this over `highlight` whenever the file has been edited."),highlight:G.tuple([G.number(),G.number()]).optional().describe("Highlight a precise line range [startLine, endLine] (1-based, inclusive) in the current file. Prefer `highlightCode` (snippet) when the file has been edited, since line numbers drift. Use this for highlighting a whole block by line range. It appears in sync with the narration start. On an `edits` step the highlight defaults to the edited region if neither is given."),terminal:G.string().optional().describe('Text to append to the terminal panel this step \u2014 e.g. a command and its output ("$ npm test\\n\u2713 3 passed").'),chapter:G.string().optional().describe("If set, starts a named chapter at this step, shown as a labelled marker on the timeline."),holdMs:G.number().optional().describe("How long this step lasts, in milliseconds. Defaults to a duration derived from the narration and amount of typing.")}),Qp={title:G.string().describe("Title of the walkthrough (shown in the player header and used for the filename)."),outputPath:G.string().optional().describe("Where to write the .html (absolute, or relative to the server cwd). Defaults to <cwd>/<slug>.html, falling back to /mnt/user-data/outputs or the OS temp dir if cwd is read-only. If set to /mnt/user-data/outputs/<file>, local MCP servers map it to a writable server-local output path: FLOWCAST_OUTPUT_DIR, non-root cwd, package workspace root, then temp. The tool returns a file:// resource_link to the written file when possible, plus a ui:// MCP resource_link."),voiceName:G.enum(Lr).optional().describe(a$),voiceTone:G.string().optional().describe("How the narrator should SOUND, matched to the topic \u2014 steers the TTS voice. One or two phrases describing affect/emotion, e.g. 'upbeat and encouraging, like a friendly bootcamp instructor' for a beginner tutorial, 'calm, precise, and reassuring' for a tricky debugging or security topic, 'energetic and curious' for a fun feature demo. Leave unset for the default relaxed-senior-engineer tone. (A natural, human delivery is always applied on top.)"),intro:G.string().optional().describe("Opening line spoken BEFORE the first step \u2014 a one- or two-sentence hook: greet, say what we'll build and why it matters. The server adds it as the first beat (voiced + captioned), so DON'T also write your own welcome step. Defaults to a title-based welcome; set to '' to skip."),outro:G.string().optional().describe("Closing line spoken AFTER the last step \u2014 a quick recap + sign-off, held on the final code. The server adds it as the last beat, so DON'T write your own. Defaults to a title-based wrap-up; set to '' to skip."),files:G.array(G.object({path:G.string(),content:G.string().optional()})).optional().describe('Pre-existing files, present in FULL from t=0 \u2014 put EXISTING/already-written code here with its complete `content`. Steps then just `show` (`file`) and `highlight` them, with no typing. Use this for "explain this existing code" walkthroughs; use step `code` only for code written live.'),steps:G.array(l$).min(1).describe('The ordered timeline, shaped as a LESSON: open on the PROBLEM/why (not "here is a file"), build ONE idea at a time grouped into chapters named after the sub-goal, show it working, then recap. Say the intent before the code. Use as MANY short steps as the material needs \u2014 lean HIGH (a small feature is often 20\u201350 steps, not 6). Every line of code or distinct idea is its own beat: a short `say` (4\u201314 words) + a tight `highlightCode`, and the `say` lines must read as one continuous script when concatenated. Introduce a file once (shown instantly), then mostly switch files, point/highlight, and make small `edits`. Prefer 40 four-second beats over 6 thirty-second monologues.')},jZ=G.object(Qp);var tm=[],Py=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,r=0;e<t.length;e++)(e%2?Py:tm).push(r=r+t[e])})();function u$(t){if(t<768)return!1;for(let e=0,r=tm.length;;){let n=e+r>>1;if(t<tm[n])r=n;else if(t>=Py[n])e=n+1;else return!0;if(e==r)return!1}}function Ty(t){return t>=127462&&t<=127487}var $y=8205;function My(t,e,r=!0,n=!0){return(r?zy:d$)(t,e,n)}function zy(t,e,r){if(e==t.length)return e;e&&Iy(t.charCodeAt(e))&&Oy(t.charCodeAt(e-1))&&e--;let n=em(t,e);for(e+=Ry(n);e<t.length;){let s=em(t,e);if(n==$y||s==$y||r&&u$(s))e+=Ry(s),n=s;else if(Ty(s)){let o=0,i=e-2;for(;i>=0&&Ty(em(t,i));)o++,i-=2;if(o%2==0)break;e+=2}else break}return e}function d$(t,e,r){for(;e>0;){let n=zy(t,e-2,r);if(n<e)return n;e--}return 0}function em(t,e){let r=t.charCodeAt(e);if(!Oy(r)||e+1==t.length)return r;let n=t.charCodeAt(e+1);return Iy(n)?(r-55296<<10)+(n-56320)+65536:r}function Iy(t){return t>=56320&&t<57344}function Oy(t){return t>=55296&&t<56320}function Ry(t){return t<65536?1:2}var Kt=class t{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,r,n){[e,r]=ri(this,e,r);let s=[];return this.decompose(0,e,s,2),n.length&&n.decompose(0,n.length,s,3),this.decompose(r,this.length,s,1),Qo.from(s,this.length-(r-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,r=this.length){[e,r]=ri(this,e,r);let n=[];return this.decompose(e,r,n,0),Qo.from(n,r-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let r=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),s=new so(this),o=new so(e);for(let i=r,a=r;;){if(s.next(i),o.next(i),i=0,s.lineBreak!=o.lineBreak||s.done!=o.done||s.value!=o.value)return!1;if(a+=s.value.length,s.done||a>=n)return!0}}iter(e=1){return new so(this,e)}iterRange(e,r=this.length){return new Cl(this,e,r)}iterLines(e,r){let n;if(e==null)n=this.iter();else{r==null&&(r=this.lines+1);let s=this.line(e).from;n=this.iterRange(s,Math.max(s,r==this.lines+1?this.length:r<=1?0:this.line(r-1).to))}return new jl(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?t.empty:e.length<=32?new Zr(e):Qo.from(Zr.split(e,[]))}},Zr=class t extends Kt{constructor(e,r=f$(e)){super(),this.text=e,this.length=r}get lines(){return this.text.length}get children(){return null}lineInner(e,r,n,s){for(let o=0;;o++){let i=this.text[o],a=s+i.length;if((r?n:a)>=e)return new nm(s,a,n,i);s=a+1,n++}}decompose(e,r,n,s){let o=e<=0&&r>=this.length?this:new t(Ay(this.text,e,r),Math.min(r,this.length)-Math.max(0,e));if(s&1){let i=n.pop(),a=Nl(o.text,i.text.slice(),0,o.length);if(a.length<=32)n.push(new t(a,i.length+o.length));else{let c=a.length>>1;n.push(new t(a.slice(0,c)),new t(a.slice(c)))}}else n.push(o)}replace(e,r,n){if(!(n instanceof t))return super.replace(e,r,n);[e,r]=ri(this,e,r);let s=Nl(this.text,Nl(n.text,Ay(this.text,0,e)),r),o=this.length+n.length-(r-e);return s.length<=32?new t(s,o):Qo.from(t.split(s,[]),o)}sliceString(e,r=this.length,n=`
43
- `){[e,r]=ri(this,e,r);let s="";for(let o=0,i=0;o<=r&&i<this.text.length;i++){let a=this.text[i],c=o+a.length;o>e&&i&&(s+=n),e<c&&r>o&&(s+=a.slice(Math.max(0,e-o),r-o)),o=c+1}return s}flatten(e){for(let r of this.text)e.push(r)}scanIdentical(){return 0}static split(e,r){let n=[],s=-1;for(let o of e)n.push(o),s+=o.length+1,n.length==32&&(r.push(new t(n,s)),n=[],s=-1);return s>-1&&r.push(new t(n,s)),r}},Qo=class t extends Kt{constructor(e,r){super(),this.children=e,this.length=r,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,r,n,s){for(let o=0;;o++){let i=this.children[o],a=s+i.length,c=n+i.lines-1;if((r?c:a)>=e)return i.lineInner(e,r,n,s);s=a+1,n=c+1}}decompose(e,r,n,s){for(let o=0,i=0;i<=r&&o<this.children.length;o++){let a=this.children[o],c=i+a.length;if(e<=c&&r>=i){let d=s&((i<=e?1:0)|(c>=r?2:0));i>=e&&c<=r&&!d?n.push(a):a.decompose(e-i,r-i,n,d)}i=c+1}}replace(e,r,n){if([e,r]=ri(this,e,r),n.lines<this.lines)for(let s=0,o=0;s<this.children.length;s++){let i=this.children[s],a=o+i.length;if(e>=o&&r<=a){let c=i.replace(e-o,r-o,n),d=this.lines-i.lines+c.lines;if(c.lines<d>>4&&c.lines>d>>6){let l=this.children.slice();return l[s]=c,new t(l,this.length-(r-e)+n.length)}return super.replace(o,a,c)}o=a+1}return super.replace(e,r,n)}sliceString(e,r=this.length,n=`
44
- `){[e,r]=ri(this,e,r);let s="";for(let o=0,i=0;o<this.children.length&&i<=r;o++){let a=this.children[o],c=i+a.length;i>e&&o&&(s+=n),e<c&&r>i&&(s+=a.sliceString(e-i,r-i,n)),i=c+1}return s}flatten(e){for(let r of this.children)r.flatten(e)}scanIdentical(e,r){if(!(e instanceof t))return 0;let n=0,[s,o,i,a]=r>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=r,o+=r){if(s==i||o==a)return n;let c=this.children[s],d=e.children[o];if(c!=d)return n+c.scanIdentical(d,r);n+=c.length+1}}static from(e,r=e.reduce((n,s)=>n+s.length+1,-1)){let n=0;for(let p of e)n+=p.lines;if(n<32){let p=[];for(let g of e)g.flatten(p);return new Zr(p,r)}let s=Math.max(32,n>>5),o=s<<1,i=s>>1,a=[],c=0,d=-1,l=[];function u(p){let g;if(p.lines>o&&p instanceof t)for(let x of p.children)u(x);else p.lines>i&&(c>i||!c)?(h(),a.push(p)):p instanceof Zr&&c&&(g=l[l.length-1])instanceof Zr&&p.lines+g.lines<=32?(c+=p.lines,d+=p.length+1,l[l.length-1]=new Zr(g.text.concat(p.text),g.length+1+p.length)):(c+p.lines>s&&h(),c+=p.lines,d+=p.length+1,l.push(p))}function h(){c!=0&&(a.push(l.length==1?l[0]:t.from(l,d)),d=-1,c=l.length=0)}for(let p of e)u(p);return h(),a.length==1?a[0]:new t(a,r)}};Kt.empty=new Zr([""],0);function f$(t){let e=-1;for(let r of t)e+=r.length+1;return e}function Nl(t,e,r=0,n=1e9){for(let s=0,o=0,i=!0;o<t.length&&s<=n;o++){let a=t[o],c=s+a.length;c>=r&&(c>n&&(a=a.slice(0,n-s)),s<r&&(a=a.slice(r-s)),i?(e[e.length-1]+=a,i=!1):e.push(a)),s=c+1}return e}function Ay(t,e,r){return Nl(t,[""],e,r)}var so=class{constructor(e,r=1){this.dir=r,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[r>0?1:(e instanceof Zr?e.text.length:e.children.length)<<1]}nextInner(e,r){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,s=this.nodes[n],o=this.offsets[n],i=o>>1,a=s instanceof Zr?s.text.length:s.children.length;if(i==(r>0?a:0)){if(n==0)return this.done=!0,this.value="",this;r>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((o&1)==(r>0?0:1)){if(this.offsets[n]+=r,e==0)return this.lineBreak=!0,this.value=`
45
- `,this;e--}else if(s instanceof Zr){let c=s.text[i+(r<0?-1:0)];if(this.offsets[n]+=r,c.length>Math.max(0,e))return this.value=e==0?c:r>0?c.slice(e):c.slice(0,c.length-e),this;e-=c.length}else{let c=s.children[i+(r<0?-1:0)];e>c.length?(e-=c.length,this.offsets[n]+=r):(r<0&&this.offsets[n]--,this.nodes.push(c),this.offsets.push(r>0?1:(c instanceof Zr?c.text.length:c.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},Cl=class{constructor(e,r,n){this.value="",this.done=!1,this.cursor=new so(e,r>n?-1:1),this.pos=r>n?e.length:0,this.from=Math.min(r,n),this.to=Math.max(r,n)}nextInner(e,r){if(r<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,r<0?this.pos-this.to:this.from-this.pos);let n=r<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*r,this.value=s.length<=n?s:r<0?s.slice(s.length-n):s.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},jl=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:r,lineBreak:n,value:s}=this.inner.next(e);return r&&this.afterBreak?(this.value="",this.afterBreak=!1):r?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(Kt.prototype[Symbol.iterator]=function(){return this.iter()},so.prototype[Symbol.iterator]=Cl.prototype[Symbol.iterator]=jl.prototype[Symbol.iterator]=function(){return this});var nm=class{constructor(e,r,n,s){this.from=e,this.to=r,this.number=n,this.text=s}get length(){return this.to-this.from}};function ri(t,e,r){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,r))]}function Ny(t,e,r=!0,n=!0){return My(t,e,r,n)}var sm=/\r\n?|\n/,hs=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(hs||(hs={})),oo=class t{constructor(e){this.sections=e}get length(){let e=0;for(let r=0;r<this.sections.length;r+=2)e+=this.sections[r];return e}get newLength(){let e=0;for(let r=0;r<this.sections.length;r+=2){let n=this.sections[r+1];e+=n<0?this.sections[r]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let r=0,n=0,s=0;r<this.sections.length;){let o=this.sections[r++],i=this.sections[r++];i<0?(e(n,s,o),s+=o):s+=i,n+=o}}iterChangedRanges(e,r=!1){om(this,e,r)}get invertedDesc(){let e=[];for(let r=0;r<this.sections.length;){let n=this.sections[r++],s=this.sections[r++];s<0?e.push(n,s):e.push(s,n)}return new t(e)}composeDesc(e){return this.empty?e:e.empty?this:Zy(this,e)}mapDesc(e,r=!1){return e.empty?this:im(this,e,r)}mapPos(e,r=-1,n=hs.Simple){let s=0,o=0;for(let i=0;i<this.sections.length;){let a=this.sections[i++],c=this.sections[i++],d=s+a;if(c<0){if(d>e)return o+(e-s);o+=a}else{if(n!=hs.Simple&&d>=e&&(n==hs.TrackDel&&s<e&&d>e||n==hs.TrackBefore&&s<e||n==hs.TrackAfter&&d>e))return null;if(d>e||d==e&&r<0&&!a)return e==s||r<0?o:o+c;o+=c}s=d}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return o}touchesRange(e,r=e){for(let n=0,s=0;n<this.sections.length&&s<=r;){let o=this.sections[n++],i=this.sections[n++],a=s+o;if(i>=0&&s<=r&&a>=e)return s<e&&a>r?"cover":!0;s=a}return!1}toString(){let e="";for(let r=0;r<this.sections.length;){let n=this.sections[r++],s=this.sections[r++];e+=(e?" ":"")+n+(s>=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(r=>typeof r!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new t(e)}static create(e){return new t(e)}},tn=class t extends oo{constructor(e,r){super(e),this.inserted=r}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return om(this,(r,n,s,o,i)=>e=e.replace(s,s+(n-r),i),!1),e}mapDesc(e,r=!1){return im(this,e,r,!0)}invert(e){let r=this.sections.slice(),n=[];for(let s=0,o=0;s<r.length;s+=2){let i=r[s],a=r[s+1];if(a>=0){r[s]=a,r[s+1]=i;let c=s>>1;for(;n.length<c;)n.push(Kt.empty);n.push(i?e.slice(o,o+i):Kt.empty)}o+=i}return new t(r,n)}compose(e){return this.empty?e:e.empty?this:Zy(this,e,!0)}map(e,r=!1){return e.empty?this:im(this,e,r,!0)}iterChanges(e,r=!1){om(this,e,r)}get desc(){return oo.create(this.sections)}filter(e){let r=[],n=[],s=[],o=new io(this);e:for(let i=0,a=0;;){let c=i==e.length?1e9:e[i++];for(;a<c||a==c&&o.len==0;){if(o.done)break e;let l=Math.min(o.len,c-a);fr(s,l,-1);let u=o.ins==-1?-1:o.off==0?o.ins:0;fr(r,l,u),u>0&&ps(n,r,o.text),o.forward(l),a+=l}let d=e[i++];for(;a<d;){if(o.done)break e;let l=Math.min(o.len,d-a);fr(r,l,-1),fr(s,l,o.ins==-1?-1:o.off==0?o.ins:0),o.forward(l),a+=l}}return{changes:new t(r,n),filtered:oo.create(s)}}toJSON(){let e=[];for(let r=0;r<this.sections.length;r+=2){let n=this.sections[r],s=this.sections[r+1];s<0?e.push(n):s==0?e.push([n]):e.push([n].concat(this.inserted[r>>1].toJSON()))}return e}static of(e,r,n){let s=[],o=[],i=0,a=null;function c(l=!1){if(!l&&!s.length)return;i<r&&fr(s,r-i,-1);let u=new t(s,o);a=a?a.compose(u.map(a)):u,s=[],o=[],i=0}function d(l){if(Array.isArray(l))for(let u of l)d(u);else if(l instanceof t){if(l.length!=r)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${r})`);c(),a=a?a.compose(l.map(a)):l}else{let{from:u,to:h=u,insert:p}=l;if(u>h||u<0||h>r)throw new RangeError(`Invalid change range ${u} to ${h} (in doc of length ${r})`);let g=p?typeof p=="string"?Kt.of(p.split(n||sm)):p:Kt.empty,x=g.length;if(u==h&&x==0)return;u<i&&c(),u>i&&fr(s,u-i,-1),fr(s,h-u,x),ps(o,s,g),i=h}}return d(e),c(!a),a}static empty(e){return new t(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let r=[],n=[];for(let s=0;s<e.length;s++){let o=e[s];if(typeof o=="number")r.push(o,-1);else{if(!Array.isArray(o)||typeof o[0]!="number"||o.some((i,a)=>a&&typeof i!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)r.push(o[0],0);else{for(;n.length<s;)n.push(Kt.empty);n[s]=Kt.of(o.slice(1)),r.push(o[0],n[s].length)}}}return new t(r,n)}static createSet(e,r){return new t(e,r)}};function fr(t,e,r,n=!1){if(e==0&&r<=0)return;let s=t.length-2;s>=0&&r<=0&&r==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=r:n?(t[s]+=e,t[s+1]+=r):t.push(e,r)}function ps(t,e,r){if(r.length==0)return;let n=e.length-2>>1;if(n<t.length)t[t.length-1]=t[t.length-1].append(r);else{for(;t.length<n;)t.push(Kt.empty);t.push(r)}}function om(t,e,r){let n=t.inserted;for(let s=0,o=0,i=0;i<t.sections.length;){let a=t.sections[i++],c=t.sections[i++];if(c<0)s+=a,o+=a;else{let d=s,l=o,u=Kt.empty;for(;d+=a,l+=c,c&&n&&(u=u.append(n[i-2>>1])),!(r||i==t.sections.length||t.sections[i+1]<0);)a=t.sections[i++],c=t.sections[i++];e(s,d,o,l,u),s=d,o=l}}}function im(t,e,r,n=!1){let s=[],o=n?[]:null,i=new io(t),a=new io(e);for(let c=-1;;){if(i.done&&a.len||a.done&&i.len)throw new Error("Mismatched change set lengths");if(i.ins==-1&&a.ins==-1){let d=Math.min(i.len,a.len);fr(s,d,-1),i.forward(d),a.forward(d)}else if(a.ins>=0&&(i.ins<0||c==i.i||i.off==0&&(a.len<i.len||a.len==i.len&&!r))){let d=a.len;for(fr(s,a.ins,-1);d;){let l=Math.min(i.len,d);i.ins>=0&&c<i.i&&i.len<=l&&(fr(s,0,i.ins),o&&ps(o,s,i.text),c=i.i),i.forward(l),d-=l}a.next()}else if(i.ins>=0){let d=0,l=i.len;for(;l;)if(a.ins==-1){let u=Math.min(l,a.len);d+=u,l-=u,a.forward(u)}else if(a.ins==0&&a.len<l)l-=a.len,a.next();else break;fr(s,d,c<i.i?i.ins:0),o&&c<i.i&&ps(o,s,i.text),c=i.i,i.forward(i.len-l)}else{if(i.done&&a.done)return o?tn.createSet(s,o):oo.create(s);throw new Error("Mismatched change set lengths")}}}function Zy(t,e,r=!1){let n=[],s=r?[]:null,o=new io(t),i=new io(e);for(let a=!1;;){if(o.done&&i.done)return s?tn.createSet(n,s):oo.create(n);if(o.ins==0)fr(n,o.len,0,a),o.next();else if(i.len==0&&!i.done)fr(n,0,i.ins,a),s&&ps(s,n,i.text),i.next();else{if(o.done||i.done)throw new Error("Mismatched change set lengths");{let c=Math.min(o.len2,i.len),d=n.length;if(o.ins==-1){let l=i.ins==-1?-1:i.off?0:i.ins;fr(n,c,l,a),s&&l&&ps(s,n,i.text)}else i.ins==-1?(fr(n,o.off?0:o.len,c,a),s&&ps(s,n,o.textBit(c))):(fr(n,o.off?0:o.len,i.off?0:i.ins,a),s&&!i.off&&ps(s,n,i.text));a=(o.ins>c||i.ins>=0&&i.len>c)&&(a||n.length>d),o.forward2(c),i.forward(c)}}}}var io=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,r=this.i-2>>1;return r>=e.length?Kt.empty:e[r]}textBit(e){let{inserted:r}=this.set,n=this.i-2>>1;return n>=r.length&&!e?Kt.empty:r[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},Jo=class t{constructor(e,r,n){this.from=e,this.to=r,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,r=-1){let n,s;return this.empty?n=s=e.mapPos(this.from,r):(n=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),n==this.from&&s==this.to?this:new t(n,s,this.flags)}extend(e,r=e,n=0){if(e<=this.anchor&&r>=this.anchor)return Pr.range(e,r,void 0,void 0,n);let s=Math.abs(e-this.anchor)>Math.abs(r-this.anchor)?e:r;return Pr.range(this.anchor,s,void 0,void 0,n)}eq(e,r=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!r||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return Pr.range(e.anchor,e.head)}static create(e,r,n){return new t(e,r,n)}},Pr=class t{constructor(e,r){this.ranges=e,this.mainIndex=r}map(e,r=-1){return e.empty?this:t.create(this.ranges.map(n=>n.map(e,r)),this.mainIndex)}eq(e,r=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],r))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new t([this.main],0)}addRange(e,r=!0){return t.create([e].concat(this.ranges),r?0:this.mainIndex+1)}replaceRange(e,r=this.mainIndex){let n=this.ranges.slice();return n[r]=e,t.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new t(e.ranges.map(r=>Jo.fromJSON(r)),e.main)}static single(e,r=e){return new t([t.range(e,r)],0)}static create(e,r=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,s=0;s<e.length;s++){let o=e[s];if(o.empty?o.from<=n:o.from<n)return t.normalized(e.slice(),r);n=o.to}return new t(e,r)}static cursor(e,r=0,n,s){return Jo.create(e,e,(r==0?0:r<0?8:16)|(n==null?7:Math.min(6,n))|(s??16777215)<<6)}static range(e,r,n,s,o){let i=(n??16777215)<<6|(s==null?7:Math.min(6,s));return!o&&e!=r&&(o=r<e?1:-1),r<e?Jo.create(r,e,48|i):Jo.create(e,r,(o?o<0?8:16:0)|i)}static normalized(e,r=0){let n=e[r];e.sort((s,o)=>s.from-o.from),r=e.indexOf(n);for(let s=1;s<e.length;s++){let o=e[s],i=e[s-1];if(o.empty?o.from<=i.to:o.from<i.to){let a=i.from,c=Math.max(o.to,i.to);s<=r&&r--,e.splice(--s,2,o.anchor>o.head?t.range(c,a):t.range(a,c))}}return new t(e,r)}};function By(t,e){for(let r of t.ranges)if(r.to>e)throw new RangeError("Selection points outside of document")}var gm=0,Br=class t{constructor(e,r,n,s,o){this.combine=e,this.compareInput=r,this.compare=n,this.isStatic=s,this.id=gm++,this.default=e([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(e={}){return new t(e.combine||(r=>r),e.compareInput||((r,n)=>r===n),e.compare||(e.combine?(r,n)=>r===n:_m),!!e.static,e.enables)}of(e){return new ei([],this,0,e)}compute(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new ei(e,this,1,r)}computeN(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new ei(e,this,2,r)}from(e,r){return r||(r=n=>n),this.compute([e],n=>r(n.field(e)))}};function _m(t,e){return t==e||t.length==e.length&&t.every((r,n)=>r===e[n])}var ei=class{constructor(e,r,n,s){this.dependencies=e,this.facet=r,this.type=n,this.value=s,this.id=gm++}dynamicSlot(e){var r;let n=this.value,s=this.facet.compareInput,o=this.id,i=e[o]>>1,a=this.type==2,c=!1,d=!1,l=[];for(let u of this.dependencies)u=="doc"?c=!0:u=="selection"?d=!0:((r=e[u.id])!==null&&r!==void 0?r:1)&1||l.push(e[u.id]);return{create(u){return u.values[i]=n(u),1},update(u,h){if(c&&h.docChanged||d&&(h.docChanged||h.selection)||am(u,l)){let p=n(u);if(a?!Cy(p,u.values[i],s):!s(p,u.values[i]))return u.values[i]=p,1}return 0},reconfigure:(u,h)=>{let p,g=h.config.address[o];if(g!=null){let x=Bl(h,g);if(this.dependencies.every(S=>S instanceof Br?h.facet(S)===u.facet(S):S instanceof ni?h.field(S,!1)==u.field(S,!1):!0)||(a?Cy(p=n(u),x,s):s(p=n(u),x)))return u.values[i]=x,0}else p=n(u);return u.values[i]=p,1}}}};function Cy(t,e,r){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!r(t[n],e[n]))return!1;return!0}function am(t,e){let r=!1;for(let n of e)Ea(t,n)&1&&(r=!0);return r}function h$(t,e,r){let n=r.map(c=>t[c.id]),s=r.map(c=>c.type),o=n.filter(c=>!(c&1)),i=t[e.id]>>1;function a(c){let d=[];for(let l=0;l<n.length;l++){let u=Bl(c,n[l]);if(s[l]==2)for(let h of u)d.push(h);else d.push(u)}return e.combine(d)}return{create(c){for(let d of n)Ea(c,d);return c.values[i]=a(c),1},update(c,d){if(!am(c,o))return 0;let l=a(c);return e.compare(l,c.values[i])?0:(c.values[i]=l,1)},reconfigure(c,d){let l=am(c,n),u=d.config.facets[e.id],h=d.facet(e);if(u&&!l&&_m(r,u))return c.values[i]=h,0;let p=a(c);return e.compare(p,h)?(c.values[i]=h,0):(c.values[i]=p,1)}}}var Il=Br.define({static:!0}),ni=class t{constructor(e,r,n,s,o){this.id=e,this.createF=r,this.updateF=n,this.compareF=s,this.spec=o,this.provides=void 0}static define(e){let r=new t(gm++,e.create,e.update,e.compare||((n,s)=>n===s),e);return e.provide&&(r.provides=e.provide(r)),r}create(e){let r=e.facet(Il).find(n=>n.field==this);return(r?.create||this.createF)(e)}slot(e){let r=e[this.id]>>1;return{create:n=>(n.values[r]=this.create(n),1),update:(n,s)=>{let o=n.values[r],i=this.updateF(o,s);return this.compareF(o,i)?0:(n.values[r]=i,1)},reconfigure:(n,s)=>{let o=n.facet(Il),i=s.facet(Il),a;return(a=o.find(c=>c.field==this))&&a!=i.find(c=>c.field==this)?(n.values[r]=a.create(n),1):s.config.address[this.id]!=null?(n.values[r]=s.field(this),0):(n.values[r]=this.create(n),1)}}}init(e){return[this,Il.of({field:this,create:e})]}get extension(){return this}},ro={lowest:4,low:3,default:2,high:1,highest:0};function Sa(t){return e=>new Dl(e,t)}var BZ={highest:Sa(ro.highest),high:Sa(ro.high),default:Sa(ro.default),low:Sa(ro.low),lowest:Sa(ro.lowest)},Dl=class{constructor(e,r){this.inner=e,this.prec=r}},Ll=class t{of(e){return new Ta(this,e)}reconfigure(e){return t.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Ta=class{constructor(e,r){this.compartment=e,this.inner=r}},Zl=class t{constructor(e,r,n,s,o,i){for(this.base=e,this.compartments=r,this.dynamicSlots=n,this.address=s,this.staticValues=o,this.facets=i,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let r=this.address[e.id];return r==null?e.default:this.staticValues[r>>1]}static resolve(e,r,n){let s=[],o=Object.create(null),i=new Map;for(let h of p$(e,r,i))h instanceof ni?s.push(h):(o[h.facet.id]||(o[h.facet.id]=[])).push(h);let a=Object.create(null),c=[],d=[];for(let h of s)a[h.id]=d.length<<1,d.push(p=>h.slot(p));let l=n?.config.facets;for(let h in o){let p=o[h],g=p[0].facet,x=l&&l[h]||[];if(p.every(S=>S.type==0))if(a[g.id]=c.length<<1|1,_m(x,p))c.push(n.facet(g));else{let S=g.combine(p.map(k=>k.value));c.push(n&&g.compare(S,n.facet(g))?n.facet(g):S)}else{for(let S of p)S.type==0?(a[S.id]=c.length<<1|1,c.push(S.value)):(a[S.id]=d.length<<1,d.push(k=>S.dynamicSlot(k)));a[g.id]=d.length<<1,d.push(S=>h$(S,g,p))}}let u=d.map(h=>h(a));return new t(e,i,u,a,c,o)}};function p$(t,e,r){let n=[[],[],[],[],[]],s=new Map;function o(i,a){let c=s.get(i);if(c!=null){if(c<=a)return;let d=n[c].indexOf(i);d>-1&&n[c].splice(d,1),i instanceof Ta&&r.delete(i.compartment)}if(s.set(i,a),Array.isArray(i))for(let d of i)o(d,a);else if(i instanceof Ta){if(r.has(i.compartment))throw new RangeError("Duplicate use of compartment in extensions");let d=e.get(i.compartment)||i.inner;r.set(i.compartment,d),o(d,a)}else if(i instanceof Dl)o(i.inner,i.prec);else if(i instanceof ni)n[a].push(i),i.provides&&o(i.provides,a);else if(i instanceof ei)n[a].push(i),i.facet.extensions&&o(i.facet.extensions,ro.default);else{let d=i.extension;if(!d)throw new Error(`Unrecognized extension value in extension set (${i}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(d,a)}}return o(t,ro.default),n.reduce((i,a)=>i.concat(a))}function Ea(t,e){if(e&1)return 2;let r=e>>1,n=t.status[r];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;t.status[r]=4;let s=t.computeSlot(t,t.config.dynamicSlots[r]);return t.status[r]=2|s}function Bl(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}var qy=Br.define(),cm=Br.define({combine:t=>t.some(e=>e),static:!0}),Vy=Br.define({combine:t=>t.length?t[0]:void 0,static:!0}),Fy=Br.define(),Hy=Br.define(),Uy=Br.define(),Gy=Br.define({combine:t=>t.length?t[0]:!1}),ao=class{constructor(e,r){this.type=e,this.value=r}static define(){return new lm}},lm=class{of(e){return new ao(this,e)}},um=class{constructor(e){this.map=e}of(e){return new br(this,e)}},br=class t{constructor(e,r){this.type=e,this.value=r}map(e){let r=this.type.map(this.value,e);return r===void 0?void 0:r==this.value?this:new t(this.type,r)}is(e){return this.type==e}static define(e={}){return new um(e.map||(r=>r))}static mapEffects(e,r){if(!e.length)return e;let n=[];for(let s of e){let o=s.map(r);o&&n.push(o)}return n}};br.reconfigure=br.define();br.appendConfig=br.define();var en=class t{constructor(e,r,n,s,o,i){this.startState=e,this.changes=r,this.selection=n,this.effects=s,this.annotations=o,this.scrollIntoView=i,this._doc=null,this._state=null,n&&By(n,r.newLength),o.some(a=>a.type==t.time)||(this.annotations=o.concat(t.time.of(Date.now())))}static create(e,r,n,s,o,i){return new t(e,r,n,s,o,i)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let r of this.annotations)if(r.type==e)return r.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let r=this.annotation(t.userEvent);return!!(r&&(r==e||r.length>e.length&&r.slice(0,e.length)==e&&r[e.length]=="."))}};en.time=ao.define();en.userEvent=ao.define();en.addToHistory=ao.define();en.remote=ao.define();function m$(t,e){let r=[];for(let n=0,s=0;;){let o,i;if(n<t.length&&(s==e.length||e[s]>=t[n]))o=t[n++],i=t[n++];else if(s<e.length)o=e[s++],i=e[s++];else return r;!r.length||r[r.length-1]<o?r.push(o,i):r[r.length-1]<i&&(r[r.length-1]=i)}}function Yy(t,e,r){var n;let s,o,i;return r?(s=e.changes,o=tn.empty(e.changes.length),i=t.changes.compose(e.changes)):(s=e.changes.map(t.changes),o=t.changes.mapDesc(e.changes,!0),i=t.changes.compose(s)),{changes:i,selection:e.selection?e.selection.map(o):(n=t.selection)===null||n===void 0?void 0:n.map(s),effects:br.mapEffects(t.effects,s).concat(br.mapEffects(e.effects,o)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function dm(t,e,r){let n=e.selection,s=ti(e.annotations);return e.userEvent&&(s=s.concat(en.userEvent.of(e.userEvent))),{changes:e.changes instanceof tn?e.changes:tn.of(e.changes||[],r,t.facet(Vy)),selection:n&&(n instanceof Pr?n:Pr.single(n.anchor,n.head)),effects:ti(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function Xy(t,e,r){let n=dm(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(r=!1);for(let o=1;o<e.length;o++){e[o].filter===!1&&(r=!1);let i=!!e[o].sequential;n=Yy(n,dm(t,e[o],i?n.changes.newLength:t.doc.length),i)}let s=en.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return _$(r?g$(s):s)}function g$(t){let e=t.startState,r=!0;for(let s of e.facet(Fy)){let o=s(t);if(o===!1){r=!1;break}Array.isArray(o)&&(r=r===!0?o:m$(r,o))}if(r!==!0){let s,o;if(r===!1)o=t.changes.invertedDesc,s=tn.empty(e.doc.length);else{let i=t.changes.filter(r);s=i.changes,o=i.filtered.mapDesc(i.changes).invertedDesc}t=en.create(e,s,t.selection&&t.selection.map(o),br.mapEffects(t.effects,o),t.annotations,t.scrollIntoView)}let n=e.facet(Hy);for(let s=n.length-1;s>=0;s--){let o=n[s](t);o instanceof en?t=o:Array.isArray(o)&&o.length==1&&o[0]instanceof en?t=o[0]:t=Xy(e,ti(o),!1)}return t}function _$(t){let e=t.startState,r=e.facet(Uy),n=t;for(let s=r.length-1;s>=0;s--){let o=r[s](t);o&&Object.keys(o).length&&(n=Yy(n,dm(e,o,t.changes.newLength),!0))}return n==t?t:en.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}var b$=[];function ti(t){return t==null?b$:Array.isArray(t)?t:[t]}var ms=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(ms||(ms={})),y$=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,fm;try{fm=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function v$(t){if(fm)return fm.test(t);for(let e=0;e<t.length;e++){let r=t[e];if(/\w/.test(r)||r>"\x80"&&(r.toUpperCase()!=r.toLowerCase()||y$.test(r)))return!0}return!1}function w$(t){return e=>{if(!/\S/.test(e))return ms.Space;if(v$(e))return ms.Word;for(let r=0;r<t.length;r++)if(e.indexOf(t[r])>-1)return ms.Word;return ms.Other}}var bn=class t{constructor(e,r,n,s,o,i){this.config=e,this.doc=r,this.selection=n,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=o,i&&(i._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)Ea(this,a<<1);this.computeSlot=null}field(e,r=!0){let n=this.config.address[e.id];if(n==null){if(r)throw new RangeError("Field is not present in this state");return}return Ea(this,n),Bl(this,n)}update(...e){return Xy(this,e,!0)}applyTransaction(e){let r=this.config,{base:n,compartments:s}=r;for(let a of e.effects)a.is(Ll.reconfigure)?(r&&(s=new Map,r.compartments.forEach((c,d)=>s.set(d,c)),r=null),s.set(a.value.compartment,a.value.extension)):a.is(br.reconfigure)?(r=null,n=a.value):a.is(br.appendConfig)&&(r=null,n=ti(n).concat(a.value));let o;r?o=e.startState.values.slice():(r=Zl.resolve(n,s,this),o=new t(r,this.doc,this.selection,r.dynamicSlots.map(()=>null),(c,d)=>d.reconfigure(c,this),null).values);let i=e.startState.facet(cm)?e.newSelection:e.newSelection.asSingle();new t(r,e.newDoc,i,o,(a,c)=>c.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:e},range:Pr.cursor(r.from+e.length)}))}changeByRange(e){let r=this.selection,n=e(r.ranges[0]),s=this.changes(n.changes),o=[n.range],i=ti(n.effects);for(let a=1;a<r.ranges.length;a++){let c=e(r.ranges[a]),d=this.changes(c.changes),l=d.map(s);for(let h=0;h<a;h++)o[h]=o[h].map(l);let u=s.mapDesc(d,!0);o.push(c.range.map(u)),s=s.compose(l),i=br.mapEffects(i,l).concat(br.mapEffects(ti(c.effects),u))}return{changes:s,selection:Pr.create(o,r.mainIndex),effects:i}}changes(e=[]){return e instanceof tn?e:tn.of(e,this.doc.length,this.facet(t.lineSeparator))}toText(e){return Kt.of(e.split(this.facet(t.lineSeparator)||sm))}sliceDoc(e=0,r=this.doc.length){return this.doc.sliceString(e,r,this.lineBreak)}facet(e){let r=this.config.address[e.id];return r==null?e.default:(Ea(this,r),Bl(this,r))}toJSON(e){let r={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let s=e[n];s instanceof ni&&this.config.address[s.id]!=null&&(r[n]=s.spec.toJSON(this.field(e[n]),this))}return r}static fromJSON(e,r={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let s=[];if(n){for(let o in n)if(Object.prototype.hasOwnProperty.call(e,o)){let i=n[o],a=e[o];s.push(i.init(c=>i.spec.fromJSON(a,c)))}}return t.create({doc:e.doc,selection:Pr.fromJSON(e.selection),extensions:r.extensions?s.concat([r.extensions]):s})}static create(e={}){let r=Zl.resolve(e.extensions||[],new Map),n=e.doc instanceof Kt?e.doc:Kt.of((e.doc||"").split(r.staticFacet(t.lineSeparator)||sm)),s=e.selection?e.selection instanceof Pr?e.selection:Pr.single(e.selection.anchor,e.selection.head):Pr.single(0);return By(s,n.length),r.staticFacet(cm)||(s=s.asSingle()),new t(r,n,s,r.dynamicSlots.map(()=>null),(o,i)=>i.create(o),null)}get tabSize(){return this.facet(t.tabSize)}get lineBreak(){return this.facet(t.lineSeparator)||`
46
- `}get readOnly(){return this.facet(Gy)}phrase(e,...r){for(let n of this.facet(t.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return r.length&&(e=e.replace(/\$(\$|\d*)/g,(n,s)=>{if(s=="$")return"$";let o=+(s||1);return!o||o>r.length?n:r[o-1]})),e}languageDataAt(e,r,n=-1){let s=[];for(let o of this.facet(qy))for(let i of o(this,r,n))Object.prototype.hasOwnProperty.call(i,e)&&s.push(i[e]);return s}charCategorizer(e){let r=this.languageDataAt("wordChars",e);return w$(r.length?r[0]:"")}wordAt(e){let{text:r,from:n,length:s}=this.doc.lineAt(e),o=this.charCategorizer(e),i=e-n,a=e-n;for(;i>0;){let c=Ny(r,i,!1);if(o(r.slice(c,i))!=ms.Word)break;i=c}for(;a<s;){let c=Ny(r,a);if(o(r.slice(a,c))!=ms.Word)break;a=c}return i==a?null:Pr.range(i+n,a+n)}};bn.allowMultipleSelections=cm;bn.tabSize=Br.define({combine:t=>t.length?t[0]:4});bn.lineSeparator=Vy;bn.readOnly=Gy;bn.phrases=Br.define({compare(t,e){let r=Object.keys(t),n=Object.keys(e);return r.length==n.length&&r.every(s=>t[s]==e[s])}});bn.languageData=qy;bn.changeFilter=Fy;bn.transactionFilter=Hy;bn.transactionExtender=Uy;Ll.reconfigure=br.define();var si=class{eq(e){return this==e}range(e,r=e){return $a.create(e,r,this)}};si.prototype.startSide=si.prototype.endSide=0;si.prototype.point=!1;si.prototype.mapMode=hs.TrackDel;function bm(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}var $a=class t{constructor(e,r,n){this.from=e,this.to=r,this.value=n}static create(e,r,n){return new t(e,r,n)}};function hm(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}var pm=class t{constructor(e,r,n,s){this.from=e,this.to=r,this.value=n,this.maxPoint=s}get length(){return this.to[this.to.length-1]}findIndex(e,r,n,s=0){let o=n?this.to:this.from;for(let i=s,a=o.length;;){if(i==a)return i;let c=i+a>>1,d=o[c]-e||(n?this.value[c].endSide:this.value[c].startSide)-r;if(c==i)return d>=0?i:a;d>=0?a=c:i=c+1}}between(e,r,n,s){for(let o=this.findIndex(r,-1e9,!0),i=this.findIndex(n,1e9,!1,o);o<i;o++)if(s(this.from[o]+e,this.to[o]+e,this.value[o])===!1)return!1}map(e,r){let n=[],s=[],o=[],i=-1,a=-1;for(let c=0;c<this.value.length;c++){let d=this.value[c],l=this.from[c]+e,u=this.to[c]+e,h,p;if(l==u){let g=r.mapPos(l,d.startSide,d.mapMode);if(g==null||(h=p=g,d.startSide!=d.endSide&&(p=r.mapPos(l,d.endSide),p<h)))continue}else if(h=r.mapPos(l,d.startSide),p=r.mapPos(u,d.endSide),h>p||h==p&&d.startSide>0&&d.endSide<=0)continue;(p-h||d.endSide-d.startSide)<0||(i<0&&(i=h),d.point&&(a=Math.max(a,p-h)),n.push(d),s.push(h-i),o.push(p-i))}return{mapped:n.length?new t(s,o,n,a):null,pos:i}}},gs=class t{constructor(e,r,n,s){this.chunkPos=e,this.chunk=r,this.nextLayer=n,this.maxPoint=s}static create(e,r,n,s){return new t(e,r,n,s)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let r of this.chunk)e+=r.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:r=[],sort:n=!1,filterFrom:s=0,filterTo:o=this.length}=e,i=e.filter;if(r.length==0&&!i)return this;if(n&&(r=r.slice().sort(hm)),this.isEmpty)return r.length?t.of(r):this;let a=new Vl(this,null,-1).goto(0),c=0,d=[],l=new ql;for(;a.value||c<r.length;)if(c<r.length&&(a.from-r[c].from||a.startSide-r[c].value.startSide)>=0){let u=r[c++];l.addInner(u.from,u.to,u.value)||d.push(u)}else a.rangeIndex==1&&a.chunkIndex<this.chunk.length&&(c==r.length||this.chunkEnd(a.chunkIndex)<r[c].from)&&(!i||s>this.chunkEnd(a.chunkIndex)||o<this.chunkPos[a.chunkIndex])&&l.addChunk(this.chunkPos[a.chunkIndex],this.chunk[a.chunkIndex])?a.nextChunk():((!i||s>a.to||o<a.from||i(a.from,a.to,a.value))&&(l.addInner(a.from,a.to,a.value)||d.push($a.create(a.from,a.to,a.value))),a.next());return l.finishInner(this.nextLayer.isEmpty&&!d.length?t.empty:this.nextLayer.update({add:d,filter:i,filterFrom:s,filterTo:o}))}map(e){if(e.empty||this.isEmpty)return this;let r=[],n=[],s=-1;for(let i=0;i<this.chunk.length;i++){let a=this.chunkPos[i],c=this.chunk[i],d=e.touchesRange(a,a+c.length);if(d===!1)s=Math.max(s,c.maxPoint),r.push(c),n.push(e.mapPos(a));else if(d===!0){let{mapped:l,pos:u}=c.map(a,e);l&&(s=Math.max(s,l.maxPoint),r.push(l),n.push(u))}}let o=this.nextLayer.map(e);return r.length==0?o:new t(n,r,o||t.empty,s)}between(e,r,n){if(!this.isEmpty){for(let s=0;s<this.chunk.length;s++){let o=this.chunkPos[s],i=this.chunk[s];if(r>=o&&e<=o+i.length&&i.between(o,e-o,r-o,n)===!1)return}this.nextLayer.between(e,r,n)}}iter(e=0){return Ra.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,r=0){return Ra.from(e).goto(r)}static compare(e,r,n,s,o=-1){let i=e.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=o),a=r.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=o),c=jy(i,a,n),d=new no(i,c,o),l=new no(a,c,o);n.iterGaps((u,h,p)=>Dy(d,u,l,h,p,s)),n.empty&&n.length==0&&Dy(d,0,l,0,0,s)}static eq(e,r,n=0,s){s==null&&(s=999999999);let o=e.filter(l=>!l.isEmpty&&r.indexOf(l)<0),i=r.filter(l=>!l.isEmpty&&e.indexOf(l)<0);if(o.length!=i.length)return!1;if(!o.length)return!0;let a=jy(o,i),c=new no(o,a,0).goto(n),d=new no(i,a,0).goto(n);for(;;){if(c.to!=d.to||!mm(c.active,d.active)||c.point&&(!d.point||!bm(c.point,d.point)))return!1;if(c.to>s)return!0;c.next(),d.next()}}static spans(e,r,n,s,o=-1){let i=new no(e,null,o).goto(r),a=r,c=i.openStart;for(;;){let d=Math.min(i.to,n);if(i.point){let l=i.activeForPoint(i.to),u=i.pointFrom<r?l.length+1:i.point.startSide<0?l.length:Math.min(l.length,c);s.point(a,d,i.point,l,u,i.pointRank),c=Math.min(i.openEnd(d),l.length)}else d>a&&(s.span(a,d,i.active,c),c=i.openEnd(d));if(i.to>n)return c+(i.point&&i.to>n?1:0);a=i.to,i.next()}}static of(e,r=!1){let n=new ql;for(let s of e instanceof $a?[e]:r?x$(e):e)n.add(s.from,s.to,s.value);return n.finish()}static join(e){if(!e.length)return t.empty;let r=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let s=e[n];s!=t.empty;s=s.nextLayer)r=new t(s.chunkPos,s.chunk,r,Math.max(s.maxPoint,r.maxPoint));return r}};gs.empty=new gs([],[],null,-1);function x$(t){if(t.length>1)for(let e=t[0],r=1;r<t.length;r++){let n=t[r];if(hm(e,n)>0)return t.slice().sort(hm);e=n}return t}gs.empty.nextLayer=gs.empty;var ql=class t{finishChunk(e){this.chunks.push(new pm(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,r,n){this.addInner(e,r,n)||(this.nextLayer||(this.nextLayer=new t)).add(e,r,n)}addInner(e,r,n){let s=e-this.lastTo||n.startSide-this.last.endSide;if(s<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(r-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=r,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,r-e)),!0)}addChunk(e,r){if((e-this.lastTo||r.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,r.maxPoint),this.chunks.push(r),this.chunkPos.push(e);let n=r.value.length-1;return this.last=r.value[n],this.lastFrom=r.from[n]+e,this.lastTo=r.to[n]+e,!0}finish(){return this.finishInner(gs.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let r=gs.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,r}};function jy(t,e,r){let n=new Map;for(let o of t)for(let i=0;i<o.chunk.length;i++)o.chunk[i].maxPoint<=0&&n.set(o.chunk[i],o.chunkPos[i]);let s=new Set;for(let o of e)for(let i=0;i<o.chunk.length;i++){let a=n.get(o.chunk[i]);a!=null&&(r?r.mapPos(a):a)==o.chunkPos[i]&&!r?.touchesRange(a,a+o.chunk[i].length)&&s.add(o.chunk[i])}return s}var Vl=class{constructor(e,r,n,s=0){this.layer=e,this.skip=r,this.minPoint=n,this.rank=s}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,r=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,r,!1),this}gotoInner(e,r,n){for(;this.chunkIndex<this.layer.chunk.length;){let s=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(s)||this.layer.chunkEnd(this.chunkIndex)<e||s.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let s=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],r,!0);(!n||this.rangeIndex<s)&&this.setRangeIndex(s)}this.next()}forward(e,r){(this.to-e||this.endSide-r)<0&&this.gotoInner(e,r,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],r=this.layer.chunk[this.chunkIndex],n=e+r.from[this.rangeIndex];if(this.from=n,this.to=e+r.to[this.rangeIndex],this.value=r.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},Ra=class t{constructor(e){this.heap=e}static from(e,r=null,n=-1){let s=[];for(let o=0;o<e.length;o++)for(let i=e[o];!i.isEmpty;i=i.nextLayer)i.maxPoint>=n&&s.push(new Vl(i,r,n,o));return s.length==1?s[0]:new t(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,r=-1e9){for(let n of this.heap)n.goto(e,r);for(let n=this.heap.length>>1;n>=0;n--)rm(this.heap,n);return this.next(),this}forward(e,r){for(let n of this.heap)n.forward(e,r);for(let n=this.heap.length>>1;n>=0;n--)rm(this.heap,n);(this.to-e||this.value.endSide-r)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),rm(this.heap,0)}}};function rm(t,e){for(let r=t[e];;){let n=(e<<1)+1;if(n>=t.length)break;let s=t[n];if(n+1<t.length&&s.compare(t[n+1])>=0&&(s=t[n+1],n++),r.compare(s)<0)break;t[n]=r,t[e]=s,e=n}}var no=class{constructor(e,r,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Ra.from(e,r,n)}goto(e,r=-1e9){return this.cursor.goto(e,r),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=r,this.openStart=-1,this.next(),this}forward(e,r){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-r)<0;)this.removeActive(this.minActive);this.cursor.forward(e,r)}removeActive(e){Ol(this.active,e),Ol(this.activeTo,e),Ol(this.activeRank,e),this.minActive=Ly(this.active,this.activeTo)}addActive(e){let r=0,{value:n,to:s,rank:o}=this.cursor;for(;r<this.activeRank.length&&(o-this.activeRank[r]||s-this.activeTo[r])>0;)r++;Al(this.active,r,n),Al(this.activeTo,r,s),Al(this.activeRank,r,o),e&&Al(e,r,this.cursor.from),this.minActive=Ly(this.active,this.activeTo)}next(){let e=this.to,r=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),n&&Ol(n,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let o=this.cursor.value;if(!o.point)this.addActive(n),this.cursor.next();else if(r&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=o,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=o.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let s=n.length-1;s>=0&&n[s]<e;s--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let r=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&r.push(this.active[n]);return r.reverse()}openEnd(e){let r=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)r++;return r}};function Dy(t,e,r,n,s,o){t.goto(e),r.goto(n);let i=n+s,a=n,c=n-e,d=!!o.boundChange;for(let l=!1;;){let u=t.to+c-r.to,h=u||t.endSide-r.endSide,p=h<0?t.to+c:r.to,g=Math.min(p,i);if(t.point||r.point?(t.point&&r.point&&bm(t.point,r.point)&&mm(t.activeForPoint(t.to),r.activeForPoint(r.to))||o.comparePoint(a,g,t.point,r.point),l=!1):(l&&o.boundChange(a),g>a&&!mm(t.active,r.active)&&o.compareRange(a,g,t.active,r.active),d&&g<i&&(u||t.openEnd(p)!=r.openEnd(p))&&(l=!0)),p>i)break;a=p,h<=0&&t.next(),h>=0&&r.next()}}function mm(t,e){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!=e[r]&&!bm(t[r],e[r]))return!1;return!0}function Ol(t,e){for(let r=e,n=t.length-1;r<n;r++)t[r]=t[r+1];t.pop()}function Al(t,e,r){for(let n=t.length-1;n>=e;n--)t[n+1]=t[n];t[e]=r}function Ly(t,e){let r=-1,n=1e9;for(let s=0;s<e.length;s++)(e[s]-n||t[s].endSide-t[r].endSide)<0&&(r=s,n=e[s]);return r}var k$=350,S$=26,E$=60,T$=120,$$=600,R$=450;function P$(t){return Math.max(1,t.trim().split(/\s+/).length)}function M$(t){return Math.max(1500,P$(t)*k$)}function Wy(t){return t<=0?0:Math.min(6e3,Math.max(350,t*S$))}function Ky(t,e){let r=Math.min(t.length,e.length),n=0;for(;n<r&&t[n]===e[n];)n++;return n}function Jy(t,e,r){let n=Math.min(t.length,e.length)-r,s=0;for(;s<n&&t[t.length-1-s]===e[e.length-1-s];)s++;return s}function z$(t,e){let r=Math.max(1,Math.ceil(t.length/e)),n=[];for(let s=0;s<t.length;s+=r)n.push(t.slice(s,s+r));return n}function I$(t,e,r){let n=t.split(`
47
- `),s=Math.max(1,Math.min(e,n.length)),o=Math.max(s,Math.min(r,n.length)),i=0;for(let c=0;c<s-1;c++)i+=n[c].length+1;let a=i;for(let c=s-1;c<o;c++)a+=n[c].length+(c<n.length-1?1:0);return[i,a]}function O$(t,e,r){let n=t.trim().split(/\s+/).filter(Boolean);if(!n.length)return[];let s=r/n.length;return n.map((o,i)=>({t:Math.round(e+s*i),text:o}))}function Qy(t,e,r,n,s,o,i,a){let c=(x,S,k,_)=>tn.of([{from:x,to:S,insert:k}],_).toJSON(),d=(x,S)=>({t:S,type:"editor.selection",path:t,ranges:[[x,x]]});if(!a||s.length===0)return[{t:o,type:"editor.change",path:t,changes:c(r,n,s,e)},d(r+s.length,o)];let l=[d(r,o)],u=e;n>r&&(l.push({t:o,type:"editor.change",path:t,changes:c(r,n,"",u)}),u-=n-r);let h=z$(s,E$),p=i/h.length,g=r;return h.forEach((x,S)=>{let k=Math.round(o+p*(S+1));l.push({t:k,type:"editor.change",path:t,changes:c(g,g,x,u)}),g+=x.length,u+=x.length,l.push(d(g,k))}),l}function A$(t,e,r,n,s,o){let i=Ky(e,r),a=Jy(e,r,i);return Qy(t,e.length,i,e.length-a,r.slice(i,r.length-a),n,s,o)}function N$(t,e,r,n){let s=[];for(let i=t.indexOf(e);i>=0;i=t.indexOf(e,i+Math.max(1,e.length)))s.push(i);let o=e.length>40?`${e.slice(0,40)}\u2026`:e;if(s.length===0)throw new Error(`Step ${n}: edit \`find\` not found in the file: ${JSON.stringify(o)}. The snippet must match the current contents exactly (including whitespace).`);if(r==null){if(s.length>1)throw new Error(`Step ${n}: edit \`find\` ${JSON.stringify(o)} appears ${s.length} times \u2014 set \`occurrence\` (1-based) to pick one.`);return s[0]}if(r<1||r>s.length)throw new Error(`Step ${n}: edit \`occurrence\` ${r} is out of range \u2014 \`find\` ${JSON.stringify(o)} appears ${s.length} time(s).`);return s[r-1]}function C$(t,e,r){let n=t.indexOf(e),s=e.length>40?`${e.slice(0,40)}\u2026`:e;if(n<0)throw new Error(`Step ${r}: \`highlightCode\` snippet not found in the file: ${JSON.stringify(s)}. It must match the file's current contents exactly (including whitespace).`);if(t.indexOf(e,n+Math.max(1,e.length))>=0)throw new Error(`Step ${r}: \`highlightCode\` snippet ${JSON.stringify(s)} appears more than once \u2014 extend it until it is unique in the file.`);return n}function j$(t,e,r,n,s,o,i){let a=Math.max(1,r.reduce((p,g)=>p+g.replace.length,0)),c=[],d=e,l=n,u=null,h=0;for(let p of r){let g=N$(d,p.find,p.occurrence,i),x=Ky(p.find,p.replace),S=Jy(p.find,p.replace,x),k=p.replace.slice(x,p.replace.length-S),_=g+x,m=g+p.find.length-S,$=s*(Math.max(1,k.length)/a);c.push(...Qy(t,d.length,_,m,k,l,$,o)),d=d.slice(0,g)+p.replace+d.slice(g+p.find.length),l+=$,h+=k.length,u=k.length>0?[_,_+k.length]:null}return{events:c,content:d,lastRange:u,inserted:h}}function ev(t,e={}){let r={};for(let u of t.files??[])r[u.path]=u.content??"";let n=t.files?.[0]?.path??null,s={...r},o=new Set(Object.keys(r)),i=[],a=[],c=n,d=1;t.steps.forEach((u,h)=>{let p=u.file??c??void 0,g=!1;p&&(o.has(p)||(i.push({t:d,type:"fs.create",path:p}),o.add(p),s[p]=s[p]??""),c!==p&&(i.push({t:d,type:"editor.switch",path:p}),c=p,g=!0));let x=Math.max(g?$$:0,u.chapter?R$:0),S=d+x,k=h+1,_=p&&s[p]||"",m=p!=null&&u.code!=null,$=p!=null&&(u.edits?.length??0)>0;if(u.code!=null&&u.edits?.length)throw new Error(`Step ${k}: use either \`code\` or \`edits\`, not both.`);if(m&&_.length>0&&!u.rewrite)throw new Error(`Step ${k}: "${p}" already has code \u2014 use \`edits\` (small find/replace) to change it, or a \`say\`+\`highlight\` step (no code) to explain it. For a deliberate full rewrite set \`rewrite: true\`.`);if($&&_.length===0)throw new Error(`Step ${k}: \`edits\` target "${p}" which has no code yet \u2014 introduce it first with top-level \`files\` or a \`code\` step.`);let f=$?u.edits.reduce((C,q)=>C+q.replace.length,0):0,E=Math.max(u.say?M$(u.say):0,Wy(f),u.terminal?1400:0,1200),N=u.holdMs??e.sayDurationsMs?.[h]??E,B=f>0?Math.min(Wy(f),Math.round(N*.7)):0,U=null;if(m&&p)i.push(...A$(p,_,u.code,S,0,!1)),s[p]=u.code;else if($&&p){let C=j$(p,_,u.edits,S,B,u.typing!==!1,k);i.push(...C.events),s[p]=C.content,U=C.lastRange}if(p){let C;if(u.highlightCode!=null){let q=C$(s[p]??"",u.highlightCode,k);C=[q,q+u.highlightCode.length]}else u.highlight?C=I$(s[p]??"",u.highlight[0],u.highlight[1]):C=U;C&&i.push({t:Math.round(S+B),type:"editor.selection",path:p,ranges:[C]})}if(u.terminal){let C=u.terminal.replace(/\r?\n/g,`\r
48
- `);i.push({t:Math.round(S+Math.min(300,N*.2)),type:"term.data",data:C.endsWith(`\r
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),DR(r)}clear(){this._buffer=void 0}};function DR(t){return E_.parse(JSON.parse(t))}function _v(t){return JSON.stringify(t)+`
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]=bi(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}},mi=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]=bi(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]=bi(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 HR(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 yo=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 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 hI(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=uI(s,sI),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 fI(t,e,r,n,s,o){let i=Hv(e,r),a=Uv(e,r,i);return Gv(t,e.length,i,e.length-a,r.slice(i,r.length-a),n,s,o)}function pI(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 mI(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 gI(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=pI(d,p.find,p.occurrence,i),y=Hv(p.find,p.replace),k=Uv(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?iI:0,u.chapter?aI: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?lI(u.say):0,Fv(h),u.terminal?1400:0,1200),O=u.holdMs??e.sayDurationsMs?.[f]??$,L=h>0?Math.min(Fv(h),Math.round(O*.7)):0,q=null;if(g&&p)i.push(...fI(p,_,u.code,k,0,!1)),s[p]=u.code;else if(E&&p){let C=gI(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=mI(s[p]??"",u.highlightCode,x);C=[Z,Z+u.highlightCode.length]}else u.highlight?C=dI(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,O*.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:S,dur:N,text:u.say,words:O$(u.say,S,N)}),d=S+N+T$}),i.sort((u,h)=>u.t-h.t);let l=[{t:0,vfs:{...r},activeFile:n,terminalState:""}];return{manifest:{version:2,title:t.title,createdAt:e.createdAt??new Date().toISOString(),durationMs:Math.max(d,1e3)},events:i,snapshots:l,captions:a.length?a:void 0}}var tv=`Render an interactive code walkthrough into ONE self-contained .html file.
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
51
 
52
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
53
 
@@ -127,12 +127,12 @@ How to surface the result:
127
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
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
129
 
130
- Only pass outputPath if you specifically want the server to ALSO write the .html to a path (e.g. a local Claude Code workspace); a file:// link is returned only then.`;var D$={id:"code",tool:{name:"create_walkthrough",title:"Create interactive code walkthrough",description:tv},promptLine:"\u2022 CODE \u2014 real code types out in an editor with synced highlights \u2192 create_walkthrough",schema:Qp,makeBeat:t=>({say:t}),forceOutro:!1,compile:(t,e)=>ev(t,e)},rv=D$;var L$="TTS voice to narrate with \u2014 pick the one that best fits the topic/audience. Defaults to cedar (warm, natural). Options: "+Lr.map(t=>`${t} (${fs[t]})`).join(", ")+".",Z$=G.object({say:G.string().optional().describe("Narration for this beat \u2014 ONE short idea (4\u201314 words), spoken aloud. Write the beats so that, read in order, they form one continuous explanation."),show:G.union([G.string(),G.array(G.string())]).optional().describe("Mermaid node id(s) to REVEAL on the board this beat (drawn in, with any edges to already-shown nodes). The camera pans/zooms to it as you introduce it. Reveal one node per beat for a natural build-up."),point:G.union([G.string(),G.array(G.string())]).optional().describe("Mermaid node id(s) to highlight + zoom to this beat (already revealed) \u2014 like tapping the board when you refer back to something."),chapter:G.string().optional().describe("If set, starts a named chapter at this beat (timeline marker)."),holdMs:G.number().optional().describe("Beat duration in ms. Defaults to a duration derived from the narration.")}),ym={title:G.string().describe("Title of the whiteboard walkthrough (header + filename)."),outputPath:G.string().optional().describe("Optional path to also write the .html to (same mapping as create_walkthrough)."),voiceName:G.enum(Lr).optional().describe(L$),voiceTone:G.string().optional().describe("How the narrator should SOUND, matched to the topic \u2014 steers the TTS voice. One or two phrases describing affect/emotion, e.g. 'upbeat and encouraging, like a friendly bootcamp instructor' for a beginner concept, 'calm, precise, and reassuring' for a security or infra topic, 'energetic and curious' for a fun explainer. Leave unset for the default relaxed-senior-engineer tone. (A natural, human delivery is always applied on top.)"),intro:G.string().optional().describe("Opening line spoken BEFORE the diagram starts \u2014 a one- or two-sentence hook (greet + what this explains + why). The server shows it as a title card and adds it as the first beat (voiced), so DON'T write your own welcome step. Defaults to a title-based welcome; set to '' to skip."),outro:G.string().optional().describe("Closing line spoken AFTER the last beat \u2014 a short CONCLUSION that wraps up: one or two sentences recapping the big idea + a sign-off, while the camera pulls back to the whole diagram. EVERY whiteboard gets this wrap-up automatically (it can't be turned off), so DON'T write your own ending beat \u2014 just set the wording here. Defaults to a title-based wrap-up."),mermaid:G.string().describe("A Mermaid flowchart describing the diagram, e.g.:\n flowchart LR\n A[Browser] -->|request| B[Server]\n B -->|query| C[(Database)]\nSupports flowchart/graph with directions LR/RL/TB/BT, node shapes [], (), ([]), (()), {}, {{}}, [[]], [()], and edges -->, ---, -.->, ==> with |labels|.\nCOLOR (pastel): tint nodes with Mermaid styling \u2014 either `A[Label]:::pink` / `class A,B blue` using a built-in pastel tone (pink, rose, peach, amber, yellow, green, mint, teal, sky, blue, indigo, purple, lavender, gray, slate), or `style A fill:#dfe6fb,stroke:#8a9ef0,color:#2b3a80` for a custom soft fill. Use color to GROUP related nodes or flag ONE key node \u2014 sparingly, 2\u20133 tones max, never a different color per node (a rainbow board reads as noise). Default is clean WHITE shapes. Use clear node ids \u2014 the beats reference them."),theme:G.enum(["mono","pastel"]).default("mono").describe("'mono' (default, PREFERRED): clean white shapes \u2014 use this for almost every board. 'pastel': auto-tints EVERY node a rotating pastel \u2014 only for boards that genuinely ARE a color-coded category map; it usually looks like noise otherwise. Prefer leaving it 'mono' and adding color to a FEW nodes by hand. Per-node Mermaid colors always win over the theme."),appearance:G.enum(["system","light","dark"]).default("system").describe("Light/dark theme of the BOARD (separate from `theme`'s node coloring). 'system' (default) follows the viewer's OS and they can toggle; 'light'/'dark' pin it. Dark mode shows white/mono shapes as dark cards; your explicit colors are kept."),icons:G.record(G.string()).optional().describe("Optional map of node id \u2192 glyph drawn above the label, to make a node instantly recognizable. Value is a built-in icon name (database, server, cloud, user, users, lock, key, globe, gear, bolt, check, warning, file, folder, code, api, browser, mobile, mail, search, heart, star, clock, money, box, cart, shield, flag, send, rocket) OR a custom SVG path `d` string on a 24\xD724 grid (outline style). Only add icons when they aid recognition."),shapes:G.record(G.string()).optional().describe("Optional map of node id \u2192 SHAPE, overriding the node's bracket shape. Names: rect, round/rounded, stadium/pill, circle, diamond, hexagon, subroutine, cylinder/database, plus stack (offset stacked rectangles \u2014 collections/replicas/layers) and cloud (internet / cloud service). You can also set a shape inline in the mermaid via `id@{ shape: stack }`. Use a non-default shape only when it carries meaning."),images:G.record(G.string().url()).optional().describe("Optional map of node id \u2192 IMAGE URL (http/https). The server fetches each, downscales it (longest side ~520px), re-encodes to a compact WebP, and bakes it into the HTML as a data URI \u2014 so the node shows a real screenshot/diagram/logo with its label as a caption. Use only when a picture genuinely helps, and keep it to a FEW (each image still adds weight). A URL that fails to load just falls back to a normal box."),steps:G.array(Z$).min(1).describe("The ordered timeline as a LESSON: open on the problem/why, then reveal the diagram ONE node at a time while explaining, point back at earlier nodes, and recap. MANY short beats; the `say` lines must read as one continuous script.")},JZ=G.object(ym);var gv=Object.defineProperty,B$=(t,e,r)=>e in t?gv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,q$=(t,e)=>{for(var r in e)gv(t,r,{get:e[r],enumerable:!0})},V$=(t,e,r)=>B$(t,typeof e!="symbol"?e+"":e,r),_v={};q$(_v,{Graph:()=>rn,alg:()=>$m,json:()=>yv,version:()=>U$});var F$=Object.defineProperty,bv=(t,e)=>{for(var r in e)F$(t,r,{get:e[r],enumerable:!0})},rn=class{constructor(t){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},t&&(this._isDirected="directed"in t?t.directed:!0,this._isMultigraph="multigraph"in t?t.multigraph:!1,this._isCompound="compound"in t?t.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(t){return this._label=t,this}graph(){return this._label}setDefaultNodeLabel(t){return typeof t!="function"?this._defaultNodeLabelFn=()=>t:this._defaultNodeLabelFn=t,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(t=>Object.keys(this._in[t]).length===0)}sinks(){return this.nodes().filter(t=>Object.keys(this._out[t]).length===0)}setNodes(t,e){return t.forEach(r=>{e!==void 0?this.setNode(r,e):this.setNode(r)}),this}setNode(t,e){return t in this._nodes?(arguments.length>1&&(this._nodes[t]=e),this):(this._nodes[t]=arguments.length>1?e:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]="\0",this._children[t]={},this._children["\0"][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)}node(t){return this._nodes[t]}hasNode(t){return t in this._nodes}removeNode(t){if(t in this._nodes){let e=r=>this.removeEdge(this._edgeObjs[r]);delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],this.children(t).forEach(r=>{this.setParent(r)}),delete this._children[t]),Object.keys(this._in[t]).forEach(e),delete this._in[t],delete this._preds[t],Object.keys(this._out[t]).forEach(e),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this}setParent(t,e){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e===void 0)e="\0";else{e+="";for(let r=e;r!==void 0;r=this.parent(r))if(r===t)throw new Error("Setting "+e+" as parent of "+t+" would create a cycle");this.setNode(e)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=e,this._children[e][t]=!0,this}parent(t){if(this._isCompound){let e=this._parent[t];if(e!=="\0")return e}}children(t="\0"){if(this._isCompound){let e=this._children[t];if(e)return Object.keys(e)}else{if(t==="\0")return this.nodes();if(this.hasNode(t))return[]}return[]}predecessors(t){let e=this._preds[t];if(e)return Object.keys(e)}successors(t){let e=this._sucs[t];if(e)return Object.keys(e)}neighbors(t){let e=this.predecessors(t);if(e){let r=new Set(e);for(let n of this.successors(t))r.add(n);return Array.from(r.values())}}isLeaf(t){let e;return this.isDirected()?e=this.successors(t):e=this.neighbors(t),e.length===0}filterNodes(t){let e=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});e.setGraph(this.graph()),Object.entries(this._nodes).forEach(([s,o])=>{t(s)&&e.setNode(s,o)}),Object.values(this._edgeObjs).forEach(s=>{e.hasNode(s.v)&&e.hasNode(s.w)&&e.setEdge(s,this.edge(s))});let r={},n=s=>{let o=this.parent(s);return!o||e.hasNode(o)?(r[s]=o??void 0,o??void 0):o in r?r[o]:n(o)};return this._isCompound&&e.nodes().forEach(s=>e.setParent(s,n(s))),e}setDefaultEdgeLabel(t){return typeof t!="function"?this._defaultEdgeLabelFn=()=>t:this._defaultEdgeLabelFn=t,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(t,e){return t.reduce((r,n)=>(e!==void 0?this.setEdge(r,n,e):this.setEdge(r,n),n)),this}setEdge(t,e,r,n){let s,o,i,a,c=!1;typeof t=="object"&&t!==null&&"v"in t?(s=t.v,o=t.w,i=t.name,arguments.length===2&&(a=e,c=!0)):(s=t,o=e,i=n,arguments.length>2&&(a=r,c=!0)),s=""+s,o=""+o,i!==void 0&&(i=""+i);let d=Pa(this._isDirected,s,o,i);if(d in this._edgeLabels)return c&&(this._edgeLabels[d]=a),this;if(i!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(s),this.setNode(o),this._edgeLabels[d]=c?a:this._defaultEdgeLabelFn(s,o,i);let l=H$(this._isDirected,s,o,i);return s=l.v,o=l.w,Object.freeze(l),this._edgeObjs[d]=l,nv(this._preds[o],s),nv(this._sucs[s],o),this._in[o][d]=l,this._out[s][d]=l,this._edgeCount++,this}edge(t,e,r){let n=arguments.length===1?vm(this._isDirected,t):Pa(this._isDirected,t,e,r);return this._edgeLabels[n]}edgeAsObj(t,e,r){let n=arguments.length===1?this.edge(t):this.edge(t,e,r);return typeof n!="object"?{label:n}:n}hasEdge(t,e,r){return(arguments.length===1?vm(this._isDirected,t):Pa(this._isDirected,t,e,r))in this._edgeLabels}removeEdge(t,e,r){let n=arguments.length===1?vm(this._isDirected,t):Pa(this._isDirected,t,e,r),s=this._edgeObjs[n];if(s){let o=s.v,i=s.w;delete this._edgeLabels[n],delete this._edgeObjs[n],sv(this._preds[i],o),sv(this._sucs[o],i),delete this._in[i][n],delete this._out[o][n],this._edgeCount--}return this}inEdges(t,e){return this.isDirected()?this.filterEdges(this._in[t],t,e):this.nodeEdges(t,e)}outEdges(t,e){return this.isDirected()?this.filterEdges(this._out[t],t,e):this.nodeEdges(t,e)}nodeEdges(t,e){if(t in this._nodes)return this.filterEdges({...this._in[t],...this._out[t]},t,e)}_removeFromParentsChildList(t){delete this._children[this._parent[t]][t]}filterEdges(t,e,r){if(!t)return;let n=Object.values(t);return r?n.filter(s=>s.v===e&&s.w===r||s.v===r&&s.w===e):n}};function nv(t,e){t[e]?t[e]++:t[e]=1}function sv(t,e){t[e]!==void 0&&!--t[e]&&delete t[e]}function Pa(t,e,r,n){let s=""+e,o=""+r;if(!t&&s>o){let i=s;s=o,o=i}return s+""+o+""+(n===void 0?"\0":n)}function H$(t,e,r,n){let s=""+e,o=""+r;if(!t&&s>o){let a=s;s=o,o=a}let i={v:s,w:o};return n&&(i.name=n),i}function vm(t,e){return Pa(t,e.v,e.w,e.name)}var U$="4.0.1",yv={};bv(yv,{read:()=>W$,write:()=>G$});function G$(t){let e={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:Y$(t),edges:X$(t)},r=t.graph();return r!==void 0&&(e.value=structuredClone(r)),e}function Y$(t){return t.nodes().map(e=>{let r=t.node(e),n=t.parent(e),s={v:e};return r!==void 0&&(s.value=r),n!==void 0&&(s.parent=n),s})}function X$(t){return t.edges().map(e=>{let r=t.edge(e),n={v:e.v,w:e.w};return e.name!==void 0&&(n.name=e.name),r!==void 0&&(n.value=r),n})}function W$(t){let e=new rn(t.options);return t.value!==void 0&&e.setGraph(t.value),t.nodes.forEach(r=>{e.setNode(r.v,r.value),r.parent&&e.setParent(r.v,r.parent)}),t.edges.forEach(r=>{e.setEdge({v:r.v,w:r.w,name:r.name},r.value)}),e}var $m={};bv($m,{CycleException:()=>Hl,bellmanFord:()=>vv,components:()=>Q$,dijkstra:()=>Fl,dijkstraAll:()=>rR,findCycles:()=>nR,floydWarshall:()=>oR,isAcyclic:()=>aR,postorder:()=>lR,preorder:()=>uR,prim:()=>dR,shortestPaths:()=>fR,tarjan:()=>xv,topsort:()=>kv});var K$=()=>1;function vv(t,e,r,n){return J$(t,String(e),r||K$,n||function(s){return t.outEdges(s)})}function J$(t,e,r,n){let s={},o,i=0,a=t.nodes(),c=function(u){let h=r(u);s[u.v].distance+h<s[u.w].distance&&(s[u.w]={distance:s[u.v].distance+h,predecessor:u.v},o=!0)},d=function(){a.forEach(function(u){n(u).forEach(function(h){let p=h.v===u?h.v:h.w,g=p===h.v?h.w:h.v;c({v:p,w:g})})})};a.forEach(function(u){let h=u===e?0:Number.POSITIVE_INFINITY;s[u]={distance:h,predecessor:""}});let l=a.length;for(let u=1;u<l&&(o=!1,i++,d(),!!o);u++);if(i===l-1&&(o=!1,d(),o))throw new Error("The graph contains a negative weight cycle");return s}function Q$(t){let e={},r=[],n;function s(o){o in e||(e[o]=!0,n.push(o),t.successors(o).forEach(s),t.predecessors(o).forEach(s))}return t.nodes().forEach(function(o){n=[],s(o),n.length&&r.push(n)}),r}var wv=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(t=>t.key)}has(t){return t in this._keyIndices}priority(t){let e=this._keyIndices[t];if(e!==void 0)return this._arr[e].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(t,e){let r=this._keyIndices,n=String(t);if(!(n in r)){let s=this._arr,o=s.length;return r[n]=o,s.push({key:n,priority:e}),this._decrease(o),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key}decrease(t,e){let r=this._keyIndices[t];if(r===void 0)throw new Error(`Key not found: ${t}`);let n=this._arr[r].priority;if(e>n)throw new Error(`New priority is greater than current priority. Key: ${t} Old: ${n} New: ${e}`);this._arr[r].priority=e,this._decrease(r)}_heapify(t){let e=this._arr,r=2*t,n=r+1,s=t;r<e.length&&(s=e[r].priority<e[s].priority?r:s,n<e.length&&(s=e[n].priority<e[s].priority?n:s),s!==t&&(this._swap(t,s),this._heapify(s)))}_decrease(t){let e=this._arr,r=e[t].priority,n;for(;t!==0&&(n=t>>1,!(e[n].priority<r));)this._swap(t,n),t=n}_swap(t,e){let r=this._arr,n=this._keyIndices,s=r[t],o=r[e];r[t]=o,r[e]=s,n[o.key]=t,n[s.key]=e}},eR=()=>1;function Fl(t,e,r,n){let s=function(o){return t.outEdges(o)};return tR(t,String(e),r||eR,n||s)}function tR(t,e,r,n){let s={},o=new wv,i,a,c=function(d){let l=d.v!==i?d.v:d.w,u=s[l],h=r(d),p=a.distance+h;if(h<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+d+" Weight: "+h);p<u.distance&&(u.distance=p,u.predecessor=i,o.decrease(l,p))};for(t.nodes().forEach(function(d){let l=d===e?0:Number.POSITIVE_INFINITY;s[d]={distance:l,predecessor:""},o.add(d,l)});o.size()>0&&(i=o.removeMin(),a=s[i],a.distance!==Number.POSITIVE_INFINITY);)n(i).forEach(c);return s}function rR(t,e,r){return t.nodes().reduce(function(n,s){return n[s]=Fl(t,s,e,r),n},{})}function xv(t){let e=0,r=[],n={},s=[];function o(i){let a=n[i]={onStack:!0,lowlink:e,index:e++};if(r.push(i),t.successors(i).forEach(function(c){c in n?n[c].onStack&&(a.lowlink=Math.min(a.lowlink,n[c].index)):(o(c),a.lowlink=Math.min(a.lowlink,n[c].lowlink))}),a.lowlink===a.index){let c=[],d;do d=r.pop(),n[d].onStack=!1,c.push(d);while(i!==d);s.push(c)}}return t.nodes().forEach(function(i){i in n||o(i)}),s}function nR(t){return xv(t).filter(function(e){return e.length>1||e.length===1&&t.hasEdge(e[0],e[0])})}var sR=()=>1;function oR(t,e,r){return iR(t,e||sR,r||function(n){return t.outEdges(n)})}function iR(t,e,r){let n={},s=t.nodes();return s.forEach(function(o){n[o]={},n[o][o]={distance:0,predecessor:""},s.forEach(function(i){o!==i&&(n[o][i]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),r(o).forEach(function(i){let a=i.v===o?i.w:i.v,c=e(i);n[o][a]={distance:c,predecessor:o}})}),s.forEach(function(o){let i=n[o];s.forEach(function(a){let c=n[a];s.forEach(function(d){let l=c[o],u=i[d],h=c[d],p=l.distance+u.distance;p<h.distance&&(h.distance=p,h.predecessor=u.predecessor)})})}),n}var Hl=class extends Error{constructor(...t){super(...t)}};function kv(t){let e={},r={},n=[];function s(o){if(o in r)throw new Hl;o in e||(r[o]=!0,e[o]=!0,t.predecessors(o).forEach(s),delete r[o],n.push(o))}if(t.sinks().forEach(s),Object.keys(e).length!==t.nodeCount())throw new Hl;return n}function aR(t){try{kv(t)}catch(e){if(e instanceof Hl)return!1;throw e}return!0}function cR(t,e,r,n,s){Array.isArray(e)||(e=[e]);let o=a=>{var c;return(c=t.isDirected()?t.successors(a):t.neighbors(a))!=null?c:[]},i={};return e.forEach(function(a){if(!t.hasNode(a))throw new Error("Graph does not have node: "+a);s=Sv(t,a,r==="post",i,o,n,s)}),s}function Sv(t,e,r,n,s,o,i){return e in n||(n[e]=!0,r||(i=o(i,e)),s(e).forEach(function(a){i=Sv(t,a,r,n,s,o,i)}),r&&(i=o(i,e))),i}function Ev(t,e,r){return cR(t,e,r,function(n,s){return n.push(s),n},[])}function lR(t,e){return Ev(t,e,"post")}function uR(t,e){return Ev(t,e,"pre")}function dR(t,e){let r=new rn,n={},s=new wv,o;function i(c){let d=c.v===o?c.w:c.v,l=s.priority(d);if(l!==void 0){let u=e(c);u<l&&(n[d]=o,s.decrease(d,u))}}if(t.nodeCount()===0)return r;t.nodes().forEach(function(c){s.add(c,Number.POSITIVE_INFINITY),r.setNode(c)}),s.decrease(t.nodes()[0],0);let a=!1;for(;s.size()>0;){if(o=s.removeMin(),o in n)r.setEdge(o,n[o]);else{if(a)throw new Error("Input graph is not connected: "+t);a=!0}t.nodeEdges(o).forEach(i)}return r}function fR(t,e,r,n){return hR(t,e,r,n??(s=>{let o=t.outEdges(s);return o??[]}))}function hR(t,e,r,n){if(r===void 0)return Fl(t,e,r,n);let s=!1,o=t.nodes();for(let i=0;i<o.length;i++){let a=n(o[i]);for(let c=0;c<a.length;c++){let d=a[c],l=d.v===o[i]?d.v:d.w,u=l===d.v?d.w:d.v;r({v:l,w:u})<0&&(s=!0)}if(s)return vv(t,e,r,n)}return Fl(t,e,r,n)}function ii(t,e,r,n){let s=n;for(;t.hasNode(s);)s=Rm(n);return r.dummy=e,t.setNode(s,r),s}function pR(t){let e=new rn().setGraph(t.graph());return t.nodes().forEach(r=>e.setNode(r,t.node(r))),t.edges().forEach(r=>{let n=e.edge(r.v,r.w)||{weight:0,minlen:1},s=t.edge(r);e.setEdge(r.v,r.w,{weight:n.weight+s.weight,minlen:Math.max(n.minlen,s.minlen)})}),e}function Tv(t){let e=new rn({multigraph:t.isMultigraph()}).setGraph(t.graph());return t.nodes().forEach(r=>{t.children(r).length||e.setNode(r,t.node(r))}),t.edges().forEach(r=>{e.setEdge(r,t.edge(r))}),e}function ov(t,e){let r=t.x,n=t.y,s=e.x-r,o=e.y-n,i=t.width/2,a=t.height/2;if(!s&&!o)throw new Error("Not possible to find intersection inside of the rectangle");let c,d;return Math.abs(o)*i>Math.abs(s)*a?(o<0&&(a=-a),c=a*s/o,d=a):(s<0&&(i=-i),c=i,d=i*o/s),{x:r+c,y:n+d}}function za(t){let e=Ma(Rv(t)+1).map(()=>[]);return t.nodes().forEach(r=>{let n=t.node(r),s=n.rank;s!==void 0&&(e[s]||(e[s]=[]),e[s][n.order]=r)}),e}function mR(t){let e=t.nodes().map(n=>{let s=t.node(n).rank;return s===void 0?Number.MAX_VALUE:s}),r=On(Math.min,e);t.nodes().forEach(n=>{let s=t.node(n);Object.hasOwn(s,"rank")&&(s.rank-=r)})}function gR(t){let e=t.nodes().map(i=>t.node(i).rank).filter(i=>i!==void 0),r=On(Math.min,e),n=[];t.nodes().forEach(i=>{let a=t.node(i).rank-r;n[a]||(n[a]=[]),n[a].push(i)});let s=0,o=t.graph().nodeRankFactor;Array.from(n).forEach((i,a)=>{i===void 0&&a%o!==0?--s:i!==void 0&&s&&i.forEach(c=>t.node(c).rank+=s)})}function iv(t,e,r,n){let s={width:0,height:0};return arguments.length>=4&&(s.rank=r,s.order=n),ii(t,"border",s,e)}function _R(t,e=$v){let r=[];for(let n=0;n<t.length;n+=e){let s=t.slice(n,n+e);r.push(s)}return r}var $v=65535;function On(t,e){if(e.length>$v){let r=_R(e);return t(...r.map(n=>t(...n)))}else return t(...e)}function Rv(t){let e=t.nodes().map(r=>{let n=t.node(r).rank;return n===void 0?Number.MIN_VALUE:n});return On(Math.max,e)}function bR(t,e){let r={lhs:[],rhs:[]};return t.forEach(n=>{e(n)?r.lhs.push(n):r.rhs.push(n)}),r}function Pv(t,e){let r=Date.now();try{return e()}finally{console.log(t+" time: "+(Date.now()-r)+"ms")}}function Mv(t,e){return e()}var yR=0;function Rm(t){let e=++yR;return t+(""+e)}function Ma(t,e,r=1){e==null&&(e=t,t=0);let n=o=>o<e;r<0&&(n=o=>e<o);let s=[];for(let o=t;n(o);o+=r)s.push(o);return s}function Ul(t,e){let r={};for(let n of e)t[n]!==void 0&&(r[n]=t[n]);return r}function Gl(t,e){let r;return typeof e=="string"?r=n=>n[e]:r=e,Object.entries(t).reduce((n,[s,o])=>(n[s]=r(o,s),n),{})}function vR(t,e){return t.reduce((r,n,s)=>(r[n]=e[s],r),{})}var Yl="\0",wR="3.0.0",xR=class{constructor(){V$(this,"_sentinel");let t={};t._next=t._prev=t,this._sentinel=t}dequeue(){let t=this._sentinel,e=t._prev;if(e!==t)return av(e),e}enqueue(t){let e=this._sentinel;t._prev&&t._next&&av(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e}toString(){let t=[],e=this._sentinel,r=e._prev;for(;r!==e;)t.push(JSON.stringify(r,kR)),r=r._prev;return"["+t.join(", ")+"]"}};function av(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function kR(t,e){if(t!=="_next"&&t!=="_prev")return e}var SR=xR,ER=()=>1;function TR(t,e){if(t.nodeCount()<=1)return[];let r=RR(t,e||ER);return $R(r.graph,r.buckets,r.zeroIdx).flatMap(n=>t.outEdges(n.v,n.w)||[])}function $R(t,e,r){var n;let s=[],o=e[e.length-1],i=e[0],a;for(;t.nodeCount();){for(;a=i.dequeue();)wm(t,e,r,a);for(;a=o.dequeue();)wm(t,e,r,a);if(t.nodeCount()){for(let c=e.length-2;c>0;--c)if(a=(n=e[c])==null?void 0:n.dequeue(),a){s=s.concat(wm(t,e,r,a,!0)||[]);break}}}return s}function wm(t,e,r,n,s){let o=[],i=s?o:void 0;return(t.inEdges(n.v)||[]).forEach(a=>{let c=t.edge(a),d=t.node(a.v);s&&o.push({v:a.v,w:a.w}),d.out-=c,Tm(e,r,d)}),(t.outEdges(n.v)||[]).forEach(a=>{let c=t.edge(a),d=a.w,l=t.node(d);l.in-=c,Tm(e,r,l)}),t.removeNode(n.v),i}function RR(t,e){let r=new rn,n=0,s=0;t.nodes().forEach(a=>{r.setNode(a,{v:a,in:0,out:0})}),t.edges().forEach(a=>{let c=r.edge(a.v,a.w)||0,d=e(a),l=c+d;r.setEdge(a.v,a.w,l);let u=r.node(a.v),h=r.node(a.w);s=Math.max(s,u.out+=d),n=Math.max(n,h.in+=d)});let o=PR(s+n+3).map(()=>new SR),i=n+1;return r.nodes().forEach(a=>{Tm(o,i,r.node(a))}),{graph:r,buckets:o,zeroIdx:i}}function Tm(t,e,r){var n,s,o;r.out?r.in?(o=t[r.out-r.in+e])==null||o.enqueue(r):(s=t[t.length-1])==null||s.enqueue(r):(n=t[0])==null||n.enqueue(r)}function PR(t){let e=[];for(let r=0;r<t;r++)e.push(r);return e}function MR(t){(t.graph().acyclicer==="greedy"?TR(t,e(t)):zR(t)).forEach(r=>{let n=t.edge(r);t.removeEdge(r),n.forwardName=r.name,n.reversed=!0,t.setEdge(r.w,r.v,n,Rm("rev"))});function e(r){return n=>r.edge(n).weight}}function zR(t){let e=[],r={},n={};function s(o){Object.hasOwn(n,o)||(n[o]=!0,r[o]=!0,t.outEdges(o).forEach(i=>{Object.hasOwn(r,i.w)?e.push(i):s(i.w)}),delete r[o])}return t.nodes().forEach(s),e}function IR(t){t.edges().forEach(e=>{let r=t.edge(e);if(r.reversed){t.removeEdge(e);let n=r.forwardName;delete r.reversed,delete r.forwardName,t.setEdge(e.w,e.v,r,n)}})}function OR(t){t.graph().dummyChains=[],t.edges().forEach(e=>AR(t,e))}function AR(t,e){let r=e.v,n=t.node(r).rank,s=e.w,o=t.node(s).rank,i=e.name,a=t.edge(e),c=a.labelRank;if(o===n+1)return;t.removeEdge(e);let d,l,u;for(u=0,++n;n<o;++u,++n)a.points=[],l={width:0,height:0,edgeLabel:a,edgeObj:e,rank:n},d=ii(t,"edge",l,"_d"),n===c&&(l.width=a.width,l.height=a.height,l.dummy="edge-label",l.labelpos=a.labelpos),t.setEdge(r,d,{weight:a.weight},i),u===0&&t.graph().dummyChains.push(d),r=d;t.setEdge(r,s,{weight:a.weight},i)}function NR(t){t.graph().dummyChains.forEach(e=>{let r=t.node(e),n=r.edgeLabel,s;for(t.setEdge(r.edgeObj,n);r.dummy;)s=t.successors(e)[0],t.removeNode(e),n.points.push({x:r.x,y:r.y}),r.dummy==="edge-label"&&(n.x=r.x,n.y=r.y,n.width=r.width,n.height=r.height),e=s,r=t.node(e)})}function Pm(t){let e={};function r(n){let s=t.node(n);if(Object.hasOwn(e,n))return s.rank;e[n]=!0;let o=t.outEdges(n),i=o?o.map(c=>c==null?Number.POSITIVE_INFINITY:r(c.w)-t.edge(c).minlen):[],a=On(Math.min,i);return a===Number.POSITIVE_INFINITY&&(a=0),s.rank=a}t.sources().forEach(r)}function oi(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen}var zv=CR;function CR(t){let e=new rn({directed:!1}),r=t.nodes();if(r.length===0)throw new Error("Graph must have at least one node");let n=r[0],s=t.nodeCount();e.setNode(n,{});let o,i;for(;jR(e,t)<s&&(o=DR(e,t),!!o);)i=e.hasNode(o.v)?oi(t,o):-oi(t,o),LR(e,t,i);return e}function jR(t,e){function r(n){let s=e.nodeEdges(n);s&&s.forEach(o=>{let i=o.v,a=n===i?o.w:i;!t.hasNode(a)&&!oi(e,o)&&(t.setNode(a,{}),t.setEdge(n,a,{}),r(a))})}return t.nodes().forEach(r),t.nodeCount()}function DR(t,e){return e.edges().reduce((r,n)=>{let s=Number.POSITIVE_INFINITY;return t.hasNode(n.v)!==t.hasNode(n.w)&&(s=oi(e,n)),s<r[0]?[s,n]:r},[Number.POSITIVE_INFINITY,null])[1]}function LR(t,e,r){t.nodes().forEach(n=>e.node(n).rank+=r)}var{preorder:ZR,postorder:BR}=$m,qR=co;co.initLowLimValues=zm;co.initCutValues=Mm;co.calcCutValue=Iv;co.leaveEdge=Av;co.enterEdge=Nv;co.exchangeEdges=Cv;function co(t){t=pR(t),Pm(t);let e=zv(t);zm(e),Mm(e,t);let r,n;for(;r=Av(e);)n=Nv(e,t,r),Cv(e,t,r,n)}function Mm(t,e){let r=BR(t,t.nodes());r=r.slice(0,r.length-1),r.forEach(n=>VR(t,e,n))}function VR(t,e,r){let n=t.node(r).parent,s=t.edge(r,n);s.cutvalue=Iv(t,e,r)}function Iv(t,e,r){let n=t.node(r).parent,s=!0,o=e.edge(r,n),i=0;o||(s=!1,o=e.edge(n,r)),i=o.weight;let a=e.nodeEdges(r);return a&&a.forEach(c=>{let d=c.v===r,l=d?c.w:c.v;if(l!==n){let u=d===s,h=e.edge(c).weight;if(i+=u?h:-h,HR(t,r,l)){let p=t.edge(r,l).cutvalue;i+=u?-p:p}}}),i}function zm(t,e){arguments.length<2&&(e=t.nodes()[0]),Ov(t,{},1,e)}function Ov(t,e,r,n,s){let o=r,i=t.node(n);e[n]=!0;let a=t.neighbors(n);return a&&a.forEach(c=>{Object.hasOwn(e,c)||(r=Ov(t,e,r,c,n))}),i.low=o,i.lim=r++,s?i.parent=s:delete i.parent,r}function Av(t){return t.edges().find(e=>t.edge(e).cutvalue<0)}function Nv(t,e,r){let n=r.v,s=r.w;e.hasEdge(n,s)||(n=r.w,s=r.v);let o=t.node(n),i=t.node(s),a=o,c=!1;return o.lim>i.lim&&(a=i,c=!0),e.edges().filter(d=>c===cv(t,t.node(d.v),a)&&c!==cv(t,t.node(d.w),a)).reduce((d,l)=>oi(e,l)<oi(e,d)?l:d)}function Cv(t,e,r,n){let s=r.v,o=r.w;t.removeEdge(s,o),t.setEdge(n.v,n.w,{}),zm(t),Mm(t,e),FR(t,e)}function FR(t,e){let r=t.nodes().find(s=>!t.node(s).parent);if(!r)return;let n=ZR(t,[r]);n=n.slice(1),n.forEach(s=>{let o=t.node(s).parent,i=e.edge(s,o),a=!1;i||(i=e.edge(o,s),a=!0),e.node(s).rank=e.node(o).rank+(a?i.minlen:-i.minlen)})}function HR(t,e,r){return t.hasEdge(e,r)}function cv(t,e,r){return r.low<=e.lim&&e.lim<=r.lim}var UR=GR;function GR(t){let e=t.graph().ranker;if(typeof e=="function")return e(t);switch(e){case"network-simplex":lv(t);break;case"tight-tree":XR(t);break;case"longest-path":YR(t);break;case"none":break;default:lv(t)}}var YR=Pm;function XR(t){Pm(t),zv(t)}function lv(t){qR(t)}var WR=KR;function KR(t){let e=QR(t);t.graph().dummyChains.forEach(r=>{let n=t.node(r),s=n.edgeObj,o=JR(t,e,s.v,s.w),i=o.path,a=o.lca,c=0,d=i[c],l=!0;for(;r!==s.w;){if(n=t.node(r),l){for(;(d=i[c])!==a&&t.node(d).maxRank<n.rank;)c++;d===a&&(l=!1)}if(!l){for(;c<i.length-1&&t.node(i[c+1]).minRank<=n.rank;)c++;d=i[c]}d!==void 0&&t.setParent(r,d),r=t.successors(r)[0]}})}function JR(t,e,r,n){let s=[],o=[],i=Math.min(e[r].low,e[n].low),a=Math.max(e[r].lim,e[n].lim),c;c=r;do c=t.parent(c),s.push(c);while(c&&(e[c].low>i||a>e[c].lim));let d=c,l=n;for(;(l=t.parent(l))!==d;)o.push(l);return{path:s.concat(o.reverse()),lca:d}}function QR(t){let e={},r=0;function n(s){let o=r;t.children(s).forEach(n),e[s]={low:o,lim:r++}}return t.children(Yl).forEach(n),e}function eP(t){let e=ii(t,"root",{},"_root"),r=tP(t),n=Object.values(r),s=On(Math.max,n)-1,o=2*s+1;t.graph().nestingRoot=e,t.edges().forEach(a=>t.edge(a).minlen*=o);let i=rP(t)+1;t.children(Yl).forEach(a=>jv(t,e,o,i,s,r,a)),t.graph().nodeRankFactor=o}function jv(t,e,r,n,s,o,i){var a;let c=t.children(i);if(!c.length){i!==e&&t.setEdge(e,i,{weight:0,minlen:r});return}let d=iv(t,"_bt"),l=iv(t,"_bb"),u=t.node(i);t.setParent(d,i),u.borderTop=d,t.setParent(l,i),u.borderBottom=l,c.forEach(h=>{var p;jv(t,e,r,n,s,o,h);let g=t.node(h),x=g.borderTop?g.borderTop:h,S=g.borderBottom?g.borderBottom:h,k=g.borderTop?n:2*n,_=x!==S?1:s-((p=o[i])!=null?p:0)+1;t.setEdge(d,x,{weight:k,minlen:_,nestingEdge:!0}),t.setEdge(S,l,{weight:k,minlen:_,nestingEdge:!0})}),t.parent(i)||t.setEdge(e,d,{weight:0,minlen:s+((a=o[i])!=null?a:0)})}function tP(t){let e={};function r(n,s){let o=t.children(n);o&&o.length&&o.forEach(i=>r(i,s+1)),e[n]=s}return t.children(Yl).forEach(n=>r(n,1)),e}function rP(t){return t.edges().reduce((e,r)=>e+t.edge(r).weight,0)}function nP(t){let e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,t.edges().forEach(r=>{t.edge(r).nestingEdge&&t.removeEdge(r)})}var sP=oP;function oP(t){function e(r){let n=t.children(r),s=t.node(r);if(n.length&&n.forEach(e),Object.hasOwn(s,"minRank")){s.borderLeft=[],s.borderRight=[];for(let o=s.minRank,i=s.maxRank+1;o<i;++o)uv(t,"borderLeft","_bl",r,s,o),uv(t,"borderRight","_br",r,s,o)}}t.children(Yl).forEach(e)}function uv(t,e,r,n,s,o){let i={width:0,height:0,rank:o,borderType:e},a=s[e][o-1],c=ii(t,"border",i,r);s[e][o]=c,t.setParent(c,n),a&&t.setEdge(a,c,{weight:1})}function iP(t){var e;let r=(e=t.graph().rankdir)==null?void 0:e.toLowerCase();(r==="lr"||r==="rl")&&Dv(t)}function aP(t){var e;let r=(e=t.graph().rankdir)==null?void 0:e.toLowerCase();(r==="bt"||r==="rl")&&cP(t),(r==="lr"||r==="rl")&&(lP(t),Dv(t))}function Dv(t){t.nodes().forEach(e=>dv(t.node(e))),t.edges().forEach(e=>dv(t.edge(e)))}function dv(t){let e=t.width;t.width=t.height,t.height=e}function cP(t){t.nodes().forEach(e=>xm(t.node(e))),t.edges().forEach(e=>{var r;let n=t.edge(e);(r=n.points)==null||r.forEach(xm),Object.hasOwn(n,"y")&&xm(n)})}function xm(t){t.y=-t.y}function lP(t){t.nodes().forEach(e=>km(t.node(e))),t.edges().forEach(e=>{var r;let n=t.edge(e);(r=n.points)==null||r.forEach(km),Object.hasOwn(n,"x")&&km(n)})}function km(t){let e=t.x;t.x=t.y,t.y=e}function uP(t){let e={},r=t.nodes().filter(a=>!t.children(a).length),n=r.map(a=>t.node(a).rank),s=On(Math.max,n),o=Ma(s+1).map(()=>[]);function i(a){if(e[a])return;e[a]=!0;let c=t.node(a);o[c.rank].push(a);let d=t.successors(a);d&&d.forEach(i)}return r.sort((a,c)=>t.node(a).rank-t.node(c).rank).forEach(i),o}function dP(t,e){let r=0;for(let n=1;n<e.length;++n)r+=fP(t,e[n-1],e[n]);return r}function fP(t,e,r){let n=vR(r,r.map((d,l)=>l)),s=e.flatMap(d=>{let l=t.outEdges(d);return l?l.map(u=>({pos:n[u.w],weight:t.edge(u).weight})).sort((u,h)=>u.pos-h.pos):[]}),o=1;for(;o<r.length;)o<<=1;let i=2*o-1;o-=1;let a=new Array(i).fill(0),c=0;return s.forEach(d=>{let l=d.pos+o;a[l]+=d.weight;let u=0;for(;l>0;)l%2&&(u+=a[l+1]),l=l-1>>1,a[l]+=d.weight;c+=d.weight*u}),c}function hP(t,e=[]){return e.map(r=>{let n=t.inEdges(r);if(!n||!n.length)return{v:r};{let s=n.reduce((o,i)=>{let a=t.edge(i),c=t.node(i.v);return{sum:o.sum+a.weight*c.order,weight:o.weight+a.weight}},{sum:0,weight:0});return{v:r,barycenter:s.sum/s.weight,weight:s.weight}}})}function pP(t,e){let r={};t.forEach((s,o)=>{let i={indegree:0,in:[],out:[],vs:[s.v],i:o};s.barycenter!==void 0&&(i.barycenter=s.barycenter,i.weight=s.weight),r[s.v]=i}),e.edges().forEach(s=>{let o=r[s.v],i=r[s.w];o!==void 0&&i!==void 0&&(i.indegree++,o.out.push(i))});let n=Object.values(r).filter(s=>!s.indegree);return mP(n)}function mP(t){let e=[];function r(s){return o=>{o.merged||(o.barycenter===void 0||s.barycenter===void 0||o.barycenter>=s.barycenter)&&gP(s,o)}}function n(s){return o=>{o.in.push(s),--o.indegree===0&&t.push(o)}}for(;t.length;){let s=t.pop();e.push(s),s.in.reverse().forEach(r(s)),s.out.forEach(n(s))}return e.filter(s=>!s.merged).map(s=>Ul(s,["vs","i","barycenter","weight"]))}function gP(t,e){let r=0,n=0;t.weight&&(r+=t.barycenter*t.weight,n+=t.weight),e.weight&&(r+=e.barycenter*e.weight,n+=e.weight),t.vs=e.vs.concat(t.vs),t.barycenter=r/n,t.weight=n,t.i=Math.min(e.i,t.i),e.merged=!0}function _P(t,e){let r=bR(t,l=>Object.hasOwn(l,"barycenter")),n=r.lhs,s=r.rhs.sort((l,u)=>u.i-l.i),o=[],i=0,a=0,c=0;n.sort(bP(!!e)),c=fv(o,s,c),n.forEach(l=>{c+=l.vs.length,o.push(l.vs),i+=l.barycenter*l.weight,a+=l.weight,c=fv(o,s,c)});let d={vs:o.flat(1)};return a&&(d.barycenter=i/a,d.weight=a),d}function fv(t,e,r){let n;for(;e.length&&(n=e[e.length-1]).i<=r;)e.pop(),t.push(n.vs),r++;return r}function bP(t){return(e,r)=>e.barycenter<r.barycenter?-1:e.barycenter>r.barycenter?1:t?r.i-e.i:e.i-r.i}function Lv(t,e,r,n){let s=t.children(e),o=t.node(e),i=o?o.borderLeft:void 0,a=o?o.borderRight:void 0,c={};i&&(s=s.filter(h=>h!==i&&h!==a));let d=hP(t,s);d.forEach(h=>{if(t.children(h.v).length){let p=Lv(t,h.v,r,n);c[h.v]=p,Object.hasOwn(p,"barycenter")&&vP(h,p)}});let l=pP(d,r);yP(l,c);let u=_P(l,n);if(i&&a){u.vs=[i,u.vs,a].flat(1);let h=t.predecessors(i);if(h&&h.length){let p=t.node(h[0]),g=t.predecessors(a),x=t.node(g[0]);Object.hasOwn(u,"barycenter")||(u.barycenter=0,u.weight=0),u.barycenter=(u.barycenter*u.weight+p.order+x.order)/(u.weight+2),u.weight+=2}}return u}function yP(t,e){t.forEach(r=>{r.vs=r.vs.flatMap(n=>e[n]?e[n].vs:n)})}function vP(t,e){t.barycenter!==void 0?(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight):(t.barycenter=e.barycenter,t.weight=e.weight)}function wP(t,e,r,n){n||(n=t.nodes());let s=xP(t),o=new rn({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(i=>t.node(i));return n.forEach(i=>{let a=t.node(i),c=t.parent(i);if(a.rank===e||a.minRank<=e&&e<=a.maxRank){o.setNode(i),o.setParent(i,c||s);let d=t[r](i);d&&d.forEach(l=>{let u=l.v===i?l.w:l.v,h=o.edge(u,i),p=h!==void 0?h.weight:0;o.setEdge(u,i,{weight:t.edge(l).weight+p})}),Object.hasOwn(a,"minRank")&&o.setNode(i,{borderLeft:a.borderLeft[e],borderRight:a.borderRight[e]})}}),o}function xP(t){let e;for(;t.hasNode(e=Rm("_root")););return e}function kP(t,e,r){let n={},s;r.forEach(o=>{let i=t.parent(o),a,c;for(;i;){if(a=t.parent(i),a?(c=n[a],n[a]=i):(c=s,s=i),c&&c!==i){e.setEdge(c,i);return}i=a}})}function Zv(t,e={}){if(typeof e.customOrder=="function"){e.customOrder(t,Zv);return}let r=Rv(t),n=hv(t,Ma(1,r+1),"inEdges"),s=hv(t,Ma(r-1,-1,-1),"outEdges"),o=uP(t);if(pv(t,o),e.disableOptimalOrderHeuristic)return;let i=Number.POSITIVE_INFINITY,a,c=e.constraints||[];for(let d=0,l=0;l<4;++d,++l){SP(d%2?n:s,d%4>=2,c),o=za(t);let u=dP(t,o);u<i?(l=0,a=Object.assign({},o),i=u):u===i&&(a=structuredClone(o))}pv(t,a)}function hv(t,e,r){let n=new Map,s=(o,i)=>{n.has(o)||n.set(o,[]),n.get(o).push(i)};for(let o of t.nodes()){let i=t.node(o);if(typeof i.rank=="number"&&s(i.rank,o),typeof i.minRank=="number"&&typeof i.maxRank=="number")for(let a=i.minRank;a<=i.maxRank;a++)a!==i.rank&&s(a,o)}return e.map(function(o){return wP(t,o,r,n.get(o)||[])})}function SP(t,e,r){let n=new rn;t.forEach(function(s){r.forEach(a=>n.setEdge(a.left,a.right));let o=s.graph().root,i=Lv(s,o,n,e);i.vs.forEach((a,c)=>s.node(a).order=c),kP(s,n,i.vs)})}function pv(t,e){Object.values(e).forEach(r=>r.forEach((n,s)=>t.node(n).order=s))}function EP(t,e){let r={};function n(s,o){let i=0,a=0,c=s.length,d=o[o.length-1];return o.forEach((l,u)=>{let h=$P(t,l),p=h?t.node(h).order:c;(h||l===d)&&(o.slice(a,u+1).forEach(g=>{let x=t.predecessors(g);x&&x.forEach(S=>{let k=t.node(S),_=k.order;(_<i||p<_)&&!(k.dummy&&t.node(g).dummy)&&Bv(r,S,g)})}),a=u+1,i=p)}),o}return e.length&&e.reduce(n),r}function TP(t,e){let r={};function n(o,i,a,c,d){Ma(i,a).forEach(l=>{let u=o[l];if(u!==void 0&&t.node(u).dummy){let h=t.predecessors(u);h&&h.forEach(p=>{if(p===void 0)return;let g=t.node(p);g.dummy&&(g.order<c||g.order>d)&&Bv(r,p,u)})}})}function s(o,i){let a=-1,c=-1,d=0;return i.forEach((l,u)=>{if(t.node(l).dummy==="border"){let h=t.predecessors(l);if(h&&h.length){let p=h[0];if(p===void 0)return;c=t.node(p).order,n(i,d,u,a,c),d=u,a=c}}n(i,d,i.length,c,o.length)}),i}return e.length&&e.reduce(s),r}function $P(t,e){if(t.node(e).dummy){let r=t.predecessors(e);if(r)return r.find(n=>t.node(n).dummy)}}function Bv(t,e,r){if(e>r){let s=e;e=r,r=s}let n=t[e];n||(t[e]=n={}),n[r]=!0}function RP(t,e,r){if(e>r){let s=e;e=r,r=s}let n=t[e];return n!==void 0&&Object.hasOwn(n,r)}function PP(t,e,r,n){let s={},o={},i={};return e.forEach(a=>{a.forEach((c,d)=>{s[c]=c,o[c]=c,i[c]=d})}),e.forEach(a=>{let c=-1;a.forEach(d=>{let l=n(d);if(l&&l.length){let u=l.sort((p,g)=>{let x=i[p],S=i[g];return(x!==void 0?x:0)-(S!==void 0?S:0)}),h=(u.length-1)/2;for(let p=Math.floor(h),g=Math.ceil(h);p<=g;++p){let x=u[p];if(x===void 0)continue;let S=i[x];if(S!==void 0&&o[d]===d&&c<S&&!RP(r,d,x)){let k=s[x];k!==void 0&&(o[x]=d,o[d]=s[d]=k,c=S)}}}})}),{root:s,align:o}}function MP(t,e,r,n,s=!1){let o={},i=zP(t,e,r,s),a=s?"borderLeft":"borderRight";function c(p,g){let x=i.nodes().slice(),S={},k=x.pop();for(;k;){if(S[k])p(k);else{S[k]=!0,x.push(k);for(let _ of g(k))x.push(_)}k=x.pop()}}function d(p){let g=i.inEdges(p);g?o[p]=g.reduce((x,S)=>{var k;let _=(k=o[S.v])!=null?k:0,m=i.edge(S);return Math.max(x,_+(m!==void 0?m:0))},0):o[p]=0}function l(p){let g=i.outEdges(p),x=Number.POSITIVE_INFINITY;g&&(x=g.reduce((k,_)=>{let m=o[_.w],$=i.edge(_);return Math.min(k,(m!==void 0?m:0)-($!==void 0?$:0))},Number.POSITIVE_INFINITY));let S=t.node(p);x!==Number.POSITIVE_INFINITY&&S.borderType!==a&&(o[p]=Math.max(o[p]!==void 0?o[p]:0,x))}function u(p){return i.predecessors(p)||[]}function h(p){return i.successors(p)||[]}return c(d,u),c(l,h),Object.keys(n).forEach(p=>{var g;let x=r[p];x!==void 0&&(o[p]=(g=o[x])!=null?g:0)}),o}function zP(t,e,r,n){let s=new rn,o=t.graph(),i=CP(o.nodesep,o.edgesep,n);return e.forEach(a=>{let c;a.forEach(d=>{let l=r[d];if(l!==void 0){if(s.setNode(l),c!==void 0){let u=r[c];if(u!==void 0){let h=s.edge(u,l);s.setEdge(u,l,Math.max(i(t,d,c),h||0))}}c=d}})}),s}function IP(t,e){return Object.values(e).reduce((r,n)=>{let s=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;Object.entries(n).forEach(([a,c])=>{let d=jP(t,a)/2;s=Math.max(c+d,s),o=Math.min(c-d,o)});let i=s-o;return i<r[0]&&(r=[i,n]),r},[Number.POSITIVE_INFINITY,null])[1]}function OP(t,e){let r=Object.values(e),n=On(Math.min,r),s=On(Math.max,r);["u","d"].forEach(o=>{["l","r"].forEach(i=>{let a=o+i,c=t[a];if(!c||c===e)return;let d=Object.values(c),l=n-On(Math.min,d);i!=="l"&&(l=s-On(Math.max,d)),l&&(t[a]=Gl(c,u=>u+l))})})}function AP(t,e=void 0){let r=t.ul;return r?Gl(r,(n,s)=>{var o,i;if(e){let c=e.toLowerCase(),d=t[c];if(d&&d[s]!==void 0)return d[s]}let a=Object.values(t).map(c=>{let d=c[s];return d!==void 0?d:0}).sort((c,d)=>c-d);return(((o=a[1])!=null?o:0)+((i=a[2])!=null?i:0))/2}):{}}function NP(t){let e=za(t),r=Object.assign(EP(t,e),TP(t,e)),n={},s;["u","d"].forEach(i=>{s=i==="u"?e:Object.values(e).reverse(),["l","r"].forEach(a=>{a==="r"&&(s=s.map(l=>Object.values(l).reverse()));let c=PP(t,s,r,l=>(i==="u"?t.predecessors(l):t.successors(l))||[]),d=MP(t,s,c.root,c.align,a==="r");a==="r"&&(d=Gl(d,l=>-l)),n[i+a]=d})});let o=IP(t,n);return OP(n,o),AP(n,t.graph().align)}function CP(t,e,r){return(n,s,o)=>{let i=n.node(s),a=n.node(o),c=0,d;if(c+=i.width/2,Object.hasOwn(i,"labelpos"))switch(i.labelpos.toLowerCase()){case"l":d=-i.width/2;break;case"r":d=i.width/2;break}if(d&&(c+=r?d:-d),d=void 0,c+=(i.dummy?e:t)/2,c+=(a.dummy?e:t)/2,c+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":d=a.width/2;break;case"r":d=-a.width/2;break}return d&&(c+=r?d:-d),c}}function jP(t,e){return t.node(e).width}function DP(t){t=Tv(t),LP(t),Object.entries(NP(t)).forEach(([e,r])=>t.node(e).x=r)}function LP(t){let e=za(t),r=t.graph(),n=r.ranksep,s=r.rankalign,o=0;e.forEach(i=>{let a=i.reduce((c,d)=>{var l;let u=(l=t.node(d).height)!=null?l:0;return c>u?c:u},0);i.forEach(c=>{let d=t.node(c);s==="top"?d.y=o+d.height/2:s==="bottom"?d.y=o+a-d.height/2:d.y=o+a/2}),o+=a+n})}function ZP(t,e={}){let r=e.debugTiming?Pv:Mv;return r("layout",()=>{let n=r(" buildLayoutGraph",()=>WP(t));return r(" runLayout",()=>BP(n,r,e)),r(" updateInputGraph",()=>qP(t,n)),n})}function BP(t,e,r){e(" makeSpaceForEdgeLabels",()=>KP(t)),e(" removeSelfEdges",()=>iM(t)),e(" acyclic",()=>MR(t)),e(" nestingGraph.run",()=>eP(t)),e(" rank",()=>UR(Tv(t))),e(" injectEdgeLabelProxies",()=>JP(t)),e(" removeEmptyRanks",()=>gR(t)),e(" nestingGraph.cleanup",()=>nP(t)),e(" normalizeRanks",()=>mR(t)),e(" assignRankMinMax",()=>QP(t)),e(" removeEdgeLabelProxies",()=>eM(t)),e(" normalize.run",()=>OR(t)),e(" parentDummyChains",()=>WR(t)),e(" addBorderSegments",()=>sP(t)),e(" order",()=>Zv(t,r)),e(" insertSelfEdges",()=>aM(t)),e(" adjustCoordinateSystem",()=>iP(t)),e(" position",()=>DP(t)),e(" positionSelfEdges",()=>cM(t)),e(" removeBorderNodes",()=>oM(t)),e(" normalize.undo",()=>NR(t)),e(" fixupEdgeLabelCoords",()=>nM(t)),e(" undoCoordinateSystem",()=>aP(t)),e(" translateGraph",()=>tM(t)),e(" assignNodeIntersects",()=>rM(t)),e(" reversePoints",()=>sM(t)),e(" acyclic.undo",()=>IR(t))}function qP(t,e){t.nodes().forEach(r=>{let n=t.node(r),s=e.node(r);n&&(n.x=s.x,n.y=s.y,n.order=s.order,n.rank=s.rank,e.children(r).length&&(n.width=s.width,n.height=s.height))}),t.edges().forEach(r=>{let n=t.edge(r),s=e.edge(r);n.points=s.points,Object.hasOwn(s,"x")&&(n.x=s.x,n.y=s.y)}),t.graph().width=e.graph().width,t.graph().height=e.graph().height}var VP=["nodesep","edgesep","ranksep","marginx","marginy"],FP={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},HP=["acyclicer","ranker","rankdir","align","rankalign"],UP=["width","height","rank"],mv={width:0,height:0},GP=["minlen","weight","width","height","labeloffset"],YP={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},XP=["labelpos"];function WP(t){let e=new rn({multigraph:!0,compound:!0}),r=Em(t.graph());return e.setGraph(Object.assign({},FP,Sm(r,VP),Ul(r,HP))),t.nodes().forEach(n=>{let s=Em(t.node(n)),o=Sm(s,UP);Object.keys(mv).forEach(a=>{o[a]===void 0&&(o[a]=mv[a])}),e.setNode(n,o);let i=t.parent(n);i!==void 0&&e.setParent(n,i)}),t.edges().forEach(n=>{let s=Em(t.edge(n));e.setEdge(n,Object.assign({},YP,Sm(s,GP),Ul(s,XP)))}),e}function KP(t){let e=t.graph();e.ranksep/=2,t.edges().forEach(r=>{let n=t.edge(r);n.minlen*=2,n.labelpos.toLowerCase()!=="c"&&(e.rankdir==="TB"||e.rankdir==="BT"?n.width+=n.labeloffset:n.height+=n.labeloffset)})}function JP(t){t.edges().forEach(e=>{let r=t.edge(e);if(r.width&&r.height){let n=t.node(e.v),s={rank:(t.node(e.w).rank-n.rank)/2+n.rank,e};ii(t,"edge-proxy",s,"_ep")}})}function QP(t){let e=0;t.nodes().forEach(r=>{let n=t.node(r);n.borderTop&&(n.minRank=t.node(n.borderTop).rank,n.maxRank=t.node(n.borderBottom).rank,e=Math.max(e,n.maxRank))}),t.graph().maxRank=e}function eM(t){t.nodes().forEach(e=>{let r=t.node(e);if(r.dummy==="edge-proxy"){let n=r;t.edge(n.e).labelRank=r.rank,t.removeNode(e)}})}function tM(t){let e=Number.POSITIVE_INFINITY,r=0,n=Number.POSITIVE_INFINITY,s=0,o=t.graph(),i=o.marginx||0,a=o.marginy||0;function c(d){let l=d.x,u=d.y,h=d.width,p=d.height;e=Math.min(e,l-h/2),r=Math.max(r,l+h/2),n=Math.min(n,u-p/2),s=Math.max(s,u+p/2)}t.nodes().forEach(d=>c(t.node(d))),t.edges().forEach(d=>{let l=t.edge(d);Object.hasOwn(l,"x")&&c(l)}),e-=i,n-=a,t.nodes().forEach(d=>{let l=t.node(d);l.x-=e,l.y-=n}),t.edges().forEach(d=>{let l=t.edge(d);l.points.forEach(u=>{u.x-=e,u.y-=n}),Object.hasOwn(l,"x")&&(l.x-=e),Object.hasOwn(l,"y")&&(l.y-=n)}),o.width=r-e+i,o.height=s-n+a}function rM(t){t.edges().forEach(e=>{let r=t.edge(e),n=t.node(e.v),s=t.node(e.w),o,i;r.points?(o=r.points[0],i=r.points[r.points.length-1]):(r.points=[],o=s,i=n),r.points.unshift(ov(n,o)),r.points.push(ov(s,i))})}function nM(t){t.edges().forEach(e=>{let r=t.edge(e);if(Object.hasOwn(r,"x"))switch((r.labelpos==="l"||r.labelpos==="r")&&(r.width-=r.labeloffset),r.labelpos){case"l":r.x-=r.width/2+r.labeloffset;break;case"r":r.x+=r.width/2+r.labeloffset;break}})}function sM(t){t.edges().forEach(e=>{let r=t.edge(e);r.reversed&&r.points.reverse()})}function oM(t){t.nodes().forEach(e=>{if(t.children(e).length){let r=t.node(e),n=t.node(r.borderTop),s=t.node(r.borderBottom),o=t.node(r.borderLeft[r.borderLeft.length-1]),i=t.node(r.borderRight[r.borderRight.length-1]);r.width=Math.abs(i.x-o.x),r.height=Math.abs(s.y-n.y),r.x=o.x+r.width/2,r.y=n.y+r.height/2}}),t.nodes().forEach(e=>{t.node(e).dummy==="border"&&t.removeNode(e)})}function iM(t){t.edges().forEach(e=>{if(e.v===e.w){let r=t.node(e.v);r.selfEdges||(r.selfEdges=[]),r.selfEdges.push({e,label:t.edge(e)}),t.removeEdge(e)}})}function aM(t){za(t).forEach(e=>{let r=0;e.forEach((n,s)=>{let o=t.node(n);o.order=s+r,(o.selfEdges||[]).forEach(i=>{ii(t,"selfedge",{width:i.label.width,height:i.label.height,rank:o.rank,order:s+ ++r,e:i.e,label:i.label},"_se")}),delete o.selfEdges})})}function cM(t){t.nodes().forEach(e=>{let r=t.node(e);if(r.dummy==="selfedge"){let n=r,s=t.node(n.e.v),o=s.x+s.width/2,i=s.y,a=r.x-o,c=s.height/2;t.setEdge(n.e,n.label),t.removeNode(e),n.label.points=[{x:o+2*a/3,y:i-c},{x:o+5*a/6,y:i-c},{x:o+a,y:i},{x:o+5*a/6,y:i+c},{x:o+2*a/3,y:i+c}],n.label.x=r.x,n.label.y=r.y}})}function Sm(t,e){return Gl(Ul(t,e),Number)}function Em(t){let e={};return t&&Object.entries(t).forEach(([r,n])=>{typeof r=="string"&&(r=r.toLowerCase()),e[r]=n}),e}function lM(t){let e=za(t),r=new rn({compound:!0,multigraph:!0}).setGraph({});return t.nodes().forEach(n=>{r.setNode(n,{label:n}),r.setParent(n,"layer"+t.node(n).rank)}),t.edges().forEach(n=>r.setEdge(n.v,n.w,{},n.name)),e.forEach((n,s)=>{let o="layer"+s;r.setNode(o,{rank:"same"}),n.reduce((i,a)=>(r.setEdge(i,a,{style:"invis"}),a))}),r}var uM={graphlib:_v,version:wR,layout:ZP,debug:lM,util:{time:Pv,notime:Mv}},Im=uM;var dM={stack:"stack",layers:"stack",stacked:"stack",cloud:"cloud",rect:"rect",rectangle:"rect",box:"rect",round:"round",rounded:"round",stadium:"stadium",pill:"stadium",circle:"circle",diamond:"diamond",decision:"diamond",hexagon:"hexagon",hex:"hexagon",subroutine:"subroutine",module:"subroutine",cylinder:"cylinder",database:"cylinder",db:"cylinder"};function Nm(t){return t?dM[t.trim().toLowerCase()]:void 0}var Xl={pink:{fill:"#fde4ef",stroke:"#e57aa9",color:"#7d2950"},rose:{fill:"#ffe1e0",stroke:"#f0918c",color:"#7d2c2a"},peach:{fill:"#ffe7d4",stroke:"#f0a875",color:"#7d4a1f"},amber:{fill:"#fdeec3",stroke:"#e3bd6b",color:"#6f5314"},yellow:{fill:"#fbf3c9",stroke:"#dcc863",color:"#665b16"},green:{fill:"#d8f3df",stroke:"#7ec894",color:"#1f5b35"},mint:{fill:"#d4f3ea",stroke:"#76cdb6",color:"#1c5a4c"},teal:{fill:"#d3eef2",stroke:"#74c1cc",color:"#1c5057"},sky:{fill:"#d9ecfd",stroke:"#7db8ea",color:"#1d4d75"},blue:{fill:"#dfe6fb",stroke:"#8a9ef0",color:"#2b3a80"},indigo:{fill:"#e3e0fb",stroke:"#9b91ee",color:"#3a2f80"},purple:{fill:"#ecdffa",stroke:"#b58ee8",color:"#54287d"},lavender:{fill:"#eee9fb",stroke:"#b3a6ec",color:"#473a80"},gray:{fill:"#eceef1",stroke:"#aab2bd",color:"#3b424c"},slate:{fill:"#e6eaef",stroke:"#9aa6b4",color:"#33404f"}},qv=["sky","green","amber","pink","purple","teal","peach","indigo","mint","rose"];function Hv(t){return Xl[qv[t%qv.length]]}var fM=[["([","])","stadium"],["[[","]]","subroutine"],["[(",")]","cylinder"],["((","))","circle"],["{{","}}","hexagon"],["[","]","rect"],["(",")","round"],["{","}","diamond"]];function Om(t){let e=t.trim();return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function Am(t){return t.replace(/\\n/g,`
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,`
131
131
  `).replace(/\\t/g," ").replace(/<br\s*\/?>/gi,`
132
132
  `).replace(/<\/?(?:span|small|sub|sup|mark|font)\b[^>]*>/gi,"").replace(/[ \t]+\n/g,`
133
- `).trim()}function hM(t){return t.replace(/<\/?(?:b|strong|i|em|u|code)\b[^>]*>/gi,"").replace(/\t/g," ")}function Vv(t){let e=t.match(/^([A-Za-z0-9_.-]+)/);if(!e)return null;let r=e[1],n=t.slice(r.length),s={id:r,label:r,shape:"rect"};for(let[a,c,d]of fM)if(n.startsWith(a)){let l=n.indexOf(c,a.length);if(l>=0){let u=Am(Om(n.slice(a.length,l)));s={id:r,label:u||r,shape:d},n=n.slice(l+c.length);break}}let o=n.match(/^:::([A-Za-z0-9_-]+)/),i;return o&&(i=o[1],n=n.slice(o[0].length)),{node:s,className:i,rest:n}}function Fv(t){let e={};for(let r of t.split(",")){let[n,...s]=r.split(":"),o=n.trim().toLowerCase(),i=s.join(":").trim();i&&(o==="fill"?e.fill=i:o==="stroke"?e.stroke=i:o==="color"&&(e.color=i))}return e}var pM=/^\s*(-\.->|-->|---|-\.-|==>|===|--o|--x)\s*/;function Uv(t){let e=t.replace(/\r/g,"").split(/[\n;]/).map(l=>l.trim()).filter(l=>l&&!l.startsWith("%%")),r="LR",n=new Map,s=[],o=l=>{let u=n.get(l.id);(!u||u.label===u.id&&l.label!==l.id)&&n.set(l.id,l)},i=new Map(Object.entries(Xl)),a=new Map,c=new Map,d=new Map;for(let l of e){let u=l.match(/^(flowchart|graph)\s+(LR|RL|TB|TD|BT)/i);if(u){let m=u[2].toUpperCase();if(r=m==="TD"?"TB":m,l=l.slice(u[0].length).trim(),!l)continue}let h=l.match(/^classDef\s+([A-Za-z0-9_-]+)\s+(.+)$/i);if(h){i.set(h[1],{...i.get(h[1]),...Fv(h[2])});continue}let p=l.match(/^class\s+([A-Za-z0-9_.,\s-]+?)\s+([A-Za-z0-9_-]+)\s*$/i);if(p){for(let m of p[1].split(",").map($=>$.trim()).filter(Boolean))a.set(m,p[2]);continue}let g=l.match(/^style\s+([A-Za-z0-9_.-]+)\s+(.+)$/i);if(g){c.set(g[1],{...c.get(g[1]),...Fv(g[2])});continue}let x=l.match(/^([A-Za-z0-9_.-]+)@\{(.+)\}\s*$/);if(x){let m=x[2].match(/\bshape\s*:\s*["']?([A-Za-z0-9_-]+)/i),$=Nm(m?.[1]);$&&(d.set(x[1],$),o({id:x[1],label:x[1],shape:$}));continue}if(/^(subgraph|end|linkStyle|click)\b/i.test(l))continue;let S=l,k=Vv(S);if(!k)continue;o(k.node),k.className&&a.set(k.node.id,k.className);let _=k.node.id;for(S=k.rest.trim();S;){let m,$=S.match(/^(--|-\.|==)\s*([^->|]+?)\s*(--?>|\.->|==>|---)/);$&&(m=Am(Om($[2])),S="-"+S.slice($[1].length+$[2].length).replace(/^\s+/,""));let f=S.match(pM);if(!f)break;let E=f[1];S=S.slice(f[0].length);let N=S.match(/^\|([^|]*)\|\s*/);N&&(m=Am(Om(N[1])),S=S.slice(N[0].length));let B=Vv(S.trim());if(!B)break;o(B.node),B.className&&a.set(B.node.id,B.className),s.push({from:_,to:B.node.id,label:m,arrow:!/^---$|^-\.-$|^===$/.test(E),dashed:E.includes(".")}),_=B.node.id,S=B.rest.trim()}}for(let l of n.values()){let u=a.get(l.id),h=u?i.get(u):void 0,p=c.get(l.id),g={...h,...p};g.fill&&(l.fill=g.fill),g.stroke&&(l.stroke=g.stroke),g.color&&(l.color=g.color);let x=d.get(l.id);x&&(l.shape=x)}return{direction:r,nodes:[...n.values()],edges:s}}function mM(t){if(t.image){let i=Math.min(248,t.image.w),a=t.image.h/t.image.w*i,c=t.label&&t.label!==t.id;return{w:Math.round(i+16),h:Math.round(a+(c?28:0)+16)}}let e=hM(t.label),r=Math.max(...e.split(`
133
+ `).trim()}function UM(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 HM)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 GM=/^\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(GM);if(!h)break;let $=h[1];k=k.slice(h[0].length);let O=k.match(/^\|([^|]*)\|\s*/);O&&(g=f1(h1(O[1])),k=k.slice(O[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 WM(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=UM(t.label),r=Math.max(...e.split(`
134
134
  `).map(i=>i.length),1),n=e.split(`
135
- `).length,s=Math.max(70,r*8.6+34),o=Math.max(44,n*20+24);if(t.icon&&(o+=26),t.shape==="circle"){let i=Math.max(s,o);s=i,o=i}return(t.shape==="diamond"||t.shape==="hexagon")&&(s+=26,o+=14),t.shape==="stack"&&(s+=14,o+=16),t.shape==="cloud"&&(s+=36,o+=26),{w:s,h:o}}function Gv(t){let e=new Im.graphlib.Graph({multigraph:!0});e.setGraph({rankdir:t.direction,nodesep:46,ranksep:78,marginx:16,marginy:16}),e.setDefaultEdgeLabel(()=>({}));let r=new Map;for(let d of t.nodes){let l=mM(d);r.set(d.id,l),e.setNode(d.id,{width:l.w,height:l.h})}t.edges.forEach((d,l)=>e.setEdge(d.from,d.to,{labelpos:"c",width:d.label?d.label.length*7:0,height:d.label?16:0},`e${l}`)),Im.layout(e);let n=t.nodes.map(d=>{let l=e.node(d.id),u=r.get(d.id);return{...d,x:l.x-u.w/2,y:l.y-u.h/2,w:u.w,h:u.h}}),s=t.edges.map((d,l)=>{let h=(e.edge(d.from,d.to,`e${l}`)?.points??[]).map(p=>[p.x,p.y]);return{...d,points:h}}),o=1/0,i=1/0,a=-1/0,c=-1/0;for(let d of n)o=Math.min(o,d.x),i=Math.min(i,d.y),a=Math.max(a,d.x+d.w),c=Math.max(c,d.y+d.h);return isFinite(o)||(o=0,i=0,a=1,c=1),{nodes:n,edges:s,bounds:{minX:o,minY:i,maxX:a,maxY:c}}}var Cm={database:"M4 6c0-1.7 3.6-3 8-3s8 1.3 8 3-3.6 3-8 3-8-1.3-8-3M4 6v12c0 1.7 3.6 3 8 3s8-1.3 8-3V6M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3",server:"M3 4h18v6H3zM3 14h18v6H3zM7 7h.01M7 17h.01",cloud:"M17.5 19a4.5 4.5 0 0 0 .5-9 6 6 0 0 0-11.7-1.5A4 4 0 0 0 6 19z",user:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2M12 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8z",users:"M17 21v-2a4 4 0 0 0-3-3.87M9 21v-2a4 4 0 0 1 3-3.87M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM19 8a3 3 0 0 1 0 6",lock:"M5 11h14v10H5zM8 11V7a4 4 0 0 1 8 0v4",key:"M21 2l-2 2m-3 3 3-3M10.5 13.5a4.5 4.5 0 1 1-2-2l8-8 2 2-2 2 2 2-3 3-2-2-3 3z",globe:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM3 12h18M12 3c2.5 2.5 3.5 6 3.5 9s-1 6.5-3.5 9c-2.5-2.5-3.5-6-3.5-9s1-6.5 3.5-9z",gear:"M12 15.5a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7zM19.4 15a1.6 1.6 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.6 1.6 0 0 0-2.7 1.1V21a2 2 0 1 1-4 0v-.1A1.6 1.6 0 0 0 6.6 19.4l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.6 1.6 0 0 0-1.1-2.7H2a2 2 0 1 1 0-4h.1A1.6 1.6 0 0 0 4.6 6.6l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.6 1.6 0 0 0 1.8.3H9.4A1.6 1.6 0 0 0 10.5 2.6V2a2 2 0 1 1 4 0v.1a1.6 1.6 0 0 0 2.7 1.1l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.6 1.6 0 0 0-.3 1.8V9.4a1.6 1.6 0 0 0 1.5 1.1H21a2 2 0 1 1 0 4h-.1a1.6 1.6 0 0 0-1.5 1z",bolt:"M13 2 3 14h9l-1 8 10-12h-9z",zap:"M13 2 3 14h9l-1 8 10-12h-9z",check:"M20 6 9 17l-5-5",warning:"M12 2 2 20h20zM12 9v4M12 17h.01",alert:"M12 2 2 20h20zM12 9v4M12 17h.01",file:"M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9zM14 3v6h6",folder:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",code:"M16 18l6-6-6-6M8 6l-6 6 6 6",api:"M16 18l6-6-6-6M8 6l-6 6 6 6M13 4l-2 16",browser:"M3 4h18v16H3zM3 9h18M7 6.5h.01M10 6.5h.01",window:"M3 4h18v16H3zM3 9h18M7 6.5h.01M10 6.5h.01",mobile:"M7 3h10a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zM11 18h2",phone:"M7 3h10a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zM11 18h2",mail:"M3 5h18v14H3zM3 6l9 7 9-7",search:"M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16zM21 21l-4.3-4.3",heart:"M19 14c1.5-1.5 3-3.3 3-5.5A4.5 4.5 0 0 0 12 5 4.5 4.5 0 0 0 2 8.5c0 2.2 1.5 4 3 5.5l7 7z",star:"M12 2l3 7 7 .5-5.3 4.6L18.5 22 12 18l-6.5 4 1.8-7.9L2 9.5 9 9z",clock:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 7v5l3 2",time:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 7v5l3 2",money:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 7v10M9.5 9.5a2.5 2 0 0 1 2.5-1.5c1.4 0 2.5.7 2.5 1.8s-1.1 1.7-2.5 1.7-2.5.7-2.5 1.8S10.6 16 12 16a2.5 2 0 0 0 2.5-1.5",box:"M21 8 12 3 3 8v8l9 5 9-5zM3 8l9 5 9-5M12 13v8",cart:"M3 4h2l2.5 12h11l2-8H6M9 20a1 1 0 1 0 0 2 1 1 0 0 0 0-2zM18 20a1 1 0 1 0 0 2 1 1 0 0 0 0-2z",shield:"M12 2 4 5v6c0 5 3.4 8.5 8 10 4.6-1.5 8-5 8-10V5z",flag:"M5 21V4M5 4h12l-2 4 2 4H5",send:"M22 2 11 13M22 2l-7 20-4-9-9-4z",rocket:"M5 16c-1.5 1.5-2 5-2 5s3.5-.5 5-2a2.8 2.8 0 0 0-3-3zM12 15l-3-3a16 16 0 0 1 7-8c3 0 4 1 4 4a16 16 0 0 1-8 7zM15 9h.01"};function gM(t){let e=t.trim();return!e||e.length>4e3||!/^[MmLlHhVvCcSsQqTtAaZz0-9.,\-+eE\s]+$/.test(e)||!/^[Mm]/.test(e)?null:e}function Yv(t){if(!t)return null;let e=t.trim().toLowerCase();return Cm[e]?Cm[e]:gM(t)}var aB=Object.keys(Cm);var yn="board.wb",_M=285,jm=140,bM=320,yM=280,vM=400,wM={rect:"rectangle",round:"roundRectangle",stadium:"roundRectangle",circle:"ellipse",diamond:"diamond",hexagon:"hexagon",subroutine:"rectangle",cylinder:"cylinder",stack:"stack",cloud:"cloud"},Xv=Object.fromEntries(Object.entries(Xl).map(([t,e])=>[e.fill,t]));function xM(t){return Math.max(1,t.trim().split(/\s+/).length)}function kM(t){return Math.max(1500,xM(t)*_M)}function Ia(t){return{children:[{text:t}]}}function Dm(t,e,r){let n=t.trim().split(/\s+/).filter(Boolean);if(!n.length)return[];let s=r/n.length;return n.map((o,i)=>({t:Math.round(e+s*i),text:o}))}function SM(t,e,r){let n=t.nodes.find(o=>o.id===e),s=n.label&&n.label!==n.id;return n.image?{id:e,type:"image",points:[[n.x,n.y],[n.x+n.w,n.y+n.h]],href:n.image.href,text:Ia(s?n.label:""),revealAt:r}:{id:e,type:"geometry",shape:wM[n.shape]??"rectangle",points:[[n.x,n.y],[n.x+n.w,n.y+n.h]],...n.stroke?{strokeColor:n.stroke}:{},strokeWidth:2,...n.fill?{fill:n.fill}:{},...n.color?{textColor:n.color}:{},...n.fill&&Xv[n.fill]?{tone:Xv[n.fill]}:{},...n.icon?{icon:n.icon}:{},text:Ia(n.label),revealAt:r}}function EM(t,e){let r=e.length,n=e[r-1],s=e[r-2]??e[0],o=n[0]-s[0],i=n[1]-s[1],a=Math.hypot(o,i)||1,c=o/a,d=i/a,l=12,u=6.5,h=n[0]-c*l,p=n[1]-d*l,g=-d,x=c;return{id:t,type:"arrow-head",points:[n,[h+g*u,p+x*u],[h-g*u,p-x*u]]}}function Wv(t,e={}){let r=Uv(t.mermaid),n=t.icons??{},s=e.images??{},o=t.shapes??{};r.nodes.forEach((m,$)=>{if(s[m.id]){m.image=s[m.id];return}let f=Nm(o[m.id]);f&&(m.shape=f);let E=Yv(n[m.id]);if(E&&(m.icon=E),t.theme==="pastel"&&!m.fill){let N=Hv($);m.fill=N.fill,m.stroke=N.stroke,m.color=N.color}});let i=Gv(r),a=new Map(i.nodes.map(m=>[m.id,m])),c=new Set(i.nodes.map(m=>m.id)),d=i.edges.map((m,$)=>{let f=`${m.from}__${m.to}__${$}`,E=m.points.length>=2,N=[m.from,m.to],B={id:f,type:"arrow-line",points:E?m.points:[],strokeWidth:2,dashed:m.dashed,target:{marker:"none"},ends:N},U=m.arrow&&E?{...EM(f+"__h",m.points),ends:N}:null,C=null;if(m.label&&m.points.length){let q=m.points[Math.floor(m.points.length/2)];C={id:f+"__l",type:"edge-label",points:[[q[0],q[1]]],text:Ia(m.label),ends:N}}return{from:m.from,to:m.to,lineEl:B,headEl:U,labelEl:C}}),l=[],u=[],h=1;l.push({t:h,type:"editor.switch",path:yn});let p=i.bounds,g={id:"__frame",type:"frame",points:[[p.minX-24,p.minY-24],[p.maxX+24,p.maxY+24]]};l.push({t:h,type:"wb.snapshot",path:yn,scene:[g]});let x=new Set,S=new Set,k=m=>m==null?[]:Array.isArray(m)?m:[m];t.steps.forEach((m,$)=>{let f=m.card,E=m.chapter?bM:0,N=h+E,B=m.holdMs??e.sayDurationsMs?.[$]??Math.max(m.say?kM(m.say):0,1400);if(m.chapter&&l.push({t:h,type:"marker",label:m.chapter}),f==="intro"){let A=(p.minX+p.maxX)/2,b=(p.minY+p.maxY)/2,D=Math.max(280,t.title.length*17),I=92,Y={id:"__title",type:"geometry",shape:"text",fontSize:30,points:[[A-D/2,b-I/2],[A+D/2,b+I/2]],text:Ia(t.title)};l.push({t:Math.round(N),type:"wb.delta",path:yn,changed:[Y],deleted:[]}),l.push({t:Math.round(N),type:"wb.selection",path:yn,ids:["__title"]});let V=N+B;l.push({t:Math.round(V),type:"wb.delta",path:yn,changed:[],deleted:["__title"]}),l.push({t:Math.round(V),type:"wb.selection",path:yn,ids:[]}),m.say&&u.push({t:N,dur:B,text:m.say,words:Dm(m.say,N,B)}),h=V+jm;return}if(f==="outro"){l.push({t:Math.round(N),type:"wb.selection",path:yn,ids:["__recap"]}),m.say&&u.push({t:N,dur:B,text:m.say,words:Dm(m.say,N,B)}),h=N+B+jm;return}let U=N,C=(A,...b)=>{l.push({t:Math.round(A),type:"wb.delta",path:yn,changed:b,deleted:[]}),U=Math.max(U,A)},q=k(m.show).filter(A=>c.has(A)&&!x.has(A));for(let A of q)C(N,SM(i,A,N)),x.add(A);for(let A of d){if(S.has(A.lineEl.id)||!x.has(A.from)||!x.has(A.to))continue;S.add(A.lineEl.id);let b=N+yM;C(b,A.lineEl);let D=[A.headEl,A.labelEl].filter(Boolean);D.length&&C(b+vM,...D)}let de=(k(m.point).length?k(m.point):k(m.show)).filter(A=>c.has(A));l.push({t:Math.round(N),type:"wb.selection",path:yn,ids:de}),m.say&&u.push({t:N,dur:B,text:m.say,words:Dm(m.say,N,B)}),h=Math.max(N+B,U+90)+jm}),l.sort((m,$)=>m.t-$.t);let _=[{t:0,vfs:{[yn]:""},activeFile:yn,terminalState:""}];return{manifest:{version:2,title:t.title,createdAt:e.createdAt??new Date().toISOString(),durationMs:Math.max(h,1500),appearance:t.appearance??"system"},events:l,snapshots:_,captions:u.length?u:void 0}}var Kv='Render a WHITEBOARD walkthrough: the author draws a diagram on a board \u2014 boxes, arrows, labels \u2014 sketching it on piece by piece while NARRATING, like a teacher explaining a concept at a whiteboard. Produces ONE self-contained interactive HTML (scrubbable, with voice). Use this for CONCEPTUAL explanations \u2014 architecture, data flow, how something works, mental models \u2014 where a drawn diagram teaches better than code. (For code, use create_walkthrough.)\n\nYou describe the diagram as a MERMAID flowchart (which you\'re great at) \u2014 NO coordinates; the server lays it out automatically with dagre. Then an ordered list of `steps` (beats) reveals and explains it.\n\n- mermaid: a flowchart, e.g. `flowchart LR\\n browser[Browser] -->|request| server[Server]\\n server -->|query| db[(Database)]`\n - directions: LR / RL / TB / BT\n - node shapes: [box] (round) ([stadium]) ((circle)) {diamond} {{hexagon}} [[subroutine]] [(cylinder)]\n - extra shapes \u2014 set via `shapes:{ id:"stack" }` or inline `id@{ shape: stack }`: stack (offset stacked rectangles \u2014 collections/replicas/layers) and cloud (internet / cloud service). Use a non-default shape only when it carries meaning.\n - edges: `-->` `---` `-.->` (dashed) `==>` (thick), with `|label|` or `-- label -->`\n - give every node a clear id \u2014 the beats reference those ids.\n- steps: each beat has a short `say` plus usually one `show` (a node id to reveal now; its edges to already-shown nodes draw in automatically) or `point` (id(s) to zoom to / highlight). The camera pans + zooms to whatever the beat is about. Nodes and arrows fade in with subtle micro-animations automatically \u2014 you don\'t author motion, just reveal one node per beat.\n\nKEEP IT CLEAN AND STYLISH \u2014 restraint reads as polish. A cohesive, mostly-neutral board beats a noisy one:\n- SHAPE: stick to ONE consistent node shape (usually plain boxes). Only use a different shape when it carries real meaning \u2014 a diamond for a decision, a cylinder/database for storage. Don\'t mix shapes for variety.\n- COLOR: WHITE shapes are the DEFAULT and the right choice for almost every board. Use color RARELY and with intent \u2014 only to highlight the ONE most important node, or to GROUP a few genuinely-related nodes (same color = same group). NEVER tint every node or mix many colors: a rainbow board (like every box a different pastel) reads as noise, not meaning. Cap it at 2\u20133 tones total. Tints: `A[Label]:::blue` / `class A,B blue` (blue, sky, green, mint, amber, peach, purple, lavender, rose, pink, teal, indigo, gray, slate) or `style A fill:#\u2026,stroke:#\u2026,color:#\u2026`. Do NOT use `theme:"pastel"` unless the content genuinely IS a color-coded category map \u2014 it auto-tints EVERY node and usually looks worse.\n- ICONS: optional and RARE \u2014 only when a glyph truly aids recognition (e.g. a database or user node). `icons: { db: "database" }` (built-ins: database, server, cloud, user, lock, globe, gear, bolt, code, api, browser, mobile, mail, search, money, shield, rocket \u2026 or a custom 24\xD724 SVG path). Don\'t icon every node; an un-iconed clean box is fine.\n- IMAGES: when a real picture helps (a screenshot, UI mockup, photo, logo), give that node an image URL via `images: { nodeId: "https://\u2026" }`. The server downscales it and bakes a compact WebP into the file, captioned with the node\'s label. Use a FEW at most \u2014 each adds weight; a bad URL just falls back to a plain box.\n\nTeach it like a real lesson (same principles as create_walkthrough):\n- HOOK on the problem/why, then build the picture ONE node at a time, in a logical order, then recap.\n- MANY short beats. Each `say` is one short idea (4\u201314 words); read in order the beats must flow as one continuous spoken explanation.\n- Reveal the node you\'re talking about AS you talk about it (one `show` per beat), then `point` at earlier nodes when you refer back to them.\n\nWorked shape \u2014 read top to bottom it\'s one flowing explanation (clean boxes, no decoration):\n mermaid: |\n flowchart LR\n browser[Browser] -->|request| server[Server]\n server -->|query| db[(Database)]\n steps:\n - { chapter:"The flow", say:"Say we\'ve got a browser.", show:"browser" }\n - { say:"It sends a request to a server,", show:"server" } // the browser\u2192server arrow + its "request" label draw in automatically\n - { say:"which owns the database,", show:"db" }\n - { say:"and queries it for data.", point:"db" }\n - { say:"So the browser never touches the database directly.", point:["browser","db"] }\n\nVOICE: pick `voiceName` (the narrator\'s voice \u2014 cedar, nova, onyx, sage, shimmer \u2026; see the field for the full list) and set `voiceTone` to match the topic \u2014 e.g. "warm and clear, like a patient teacher at a whiteboard" for a concept, "calm and precise" for an architecture/security walk-through, "energetic and curious" for a fun explainer. The tone steers how the narrator sounds (a natural human delivery is always layered on top).\n\nINTRO & OUTRO: the server auto-frames the board with a spoken intro (shown as a title card) and ALWAYS ends with a short wrap-up CONCLUSION spoken over the finished diagram (camera pulls back to show the whole thing). So DON\'T author your own welcome/sign-off beats; begin your steps at the first real node and let the last content beat be the last real point. Customize the wording with `intro`/`outro` \u2014 the outro should be a one/two-sentence recap of the big idea plus a sign-off.\n\nDelivery is identical to create_walkthrough: the PRIMARY result is a http://127.0.0.1:<port>/<id>.html URL (a resource_link) \u2014 give that link to the user to open in their browser.';import TM from"sharp";var Jv=520,$M=70,RM=12*1024*1024,PM=15e3;async function Lm(t){if(!/^https?:\/\//i.test(t))return null;try{let e=await fetch(t,{signal:AbortSignal.timeout(PM),redirect:"follow"});if(!e.ok)return null;let r=e.headers.get("content-type")||"";if(r&&!/^image\//i.test(r))return null;let n=Buffer.from(await e.arrayBuffer());if(!n.length||n.length>RM)return null;let s=await TM(n,{failOn:"none",animated:!1}).rotate().resize({width:Jv,height:Jv,fit:"inside",withoutEnlargement:!0}).webp({quality:$M}).toBuffer({resolveWithObject:!0});return{href:`data:image/webp;base64,${s.data.toString("base64")}`,w:s.info.width,h:s.info.height}}catch{return null}}async function Qv(t){let e={};return await Promise.all(Object.entries(t).map(async([r,n])=>{let s=await Lm(n);s&&(e[r]=s)})),e}var MM={id:"whiteboard",tool:{name:"create_whiteboard_walkthrough",title:"Create a narrated whiteboard diagram",description:Kv},promptLine:"\u2022 WHITEBOARD \u2014 a diagram drawn on a board (concepts, architecture, data flow) \u2192 create_whiteboard_walkthrough",schema:ym,makeBeat:(t,e)=>({say:t,card:e}),forceOutro:!0,async prepare(t){let e=t.images&&Object.keys(t.images).length?await Qv(t.images):{};return Object.keys(e).length?{images:e}:{}},compile:(t,e)=>Wv(t,e)},ew=MM;var zM="TTS voice to narrate with. Defaults to cedar (warm, natural). Options: "+Lr.map(t=>`${t} (${fs[t]})`).join(", ")+".",IM=G.object({say:G.string().optional().describe("Narration for this beat \u2014 ONE short idea (4\u201314 words), spoken aloud. Read in order, the beats form one continuous explanation."),marker:G.string().optional().describe('A place name to drop a labeled pin on this beat (e.g. "Eiffel Tower, Paris"). The camera flies to it unless `goTo` overrides. Reveal one place per beat.'),goTo:G.string().optional().describe('A place/area name to FLY the camera to this beat without necessarily dropping a pin (e.g. "the Alps", "France") \u2014 for establishing/overview shots.'),zoom:G.number().min(1).max(19).optional().describe("Map zoom level for this beat (1 = whole world, ~5 = country, ~11 = city, ~15 = streets). Defaults to a sensible level for a marker vs an overview."),route:G.array(G.string()).min(2).optional().describe('Draw a road/route through these place names in order (2+), e.g. ["Paris","Lyon","Marseille"]. Drawn as an animated line; the camera frames it.'),region:G.array(G.string()).min(3).optional().describe('Highlight an area by connecting these place names into a polygon (3+ corners), e.g. ["Lisbon","Madrid","Barcelona"].'),chapter:G.string().optional().describe("If set, starts a named chapter at this beat (timeline marker)."),holdMs:G.number().optional().describe("Beat duration in ms. Defaults to a duration derived from the narration.")}),Zm={title:G.string().describe("Title of the map walkthrough (header + filename)."),outputPath:G.string().optional().describe("Optional path to also write the .html to (same mapping as create_walkthrough)."),voiceName:G.enum(Lr).optional().describe(zM),voiceTone:G.string().optional().describe('How the narrator should SOUND, matched to the topic (e.g. "warm and adventurous" for a travel story). A natural human delivery is always layered on top.'),intro:G.string().optional().describe("Opening line spoken before the tour. Defaults to a title-based welcome; set to '' to skip."),outro:G.string().optional().describe("Closing wrap-up line spoken at the end (always added). Customize the wording here."),tiles:G.enum(["streets","light","dark","satellite"]).default("streets").describe("Basemap style: 'streets' (default OSM), 'light'/'dark' (minimal Carto), or 'satellite' (Esri imagery). Pick what fits the topic."),steps:G.array(IM).min(1).describe("The ordered tour as a STORY: open on the big picture, then move place to place \u2014 drop a pin, draw a route, highlight a region \u2014 narrating throughout. MANY short beats; the `say` lines must read as one continuous script.")},xB=G.object(Zm);var OM=t=>Math.max(1,t.trim().split(/\s+/).length),AM=t=>Math.max(1600,OM(t)*350);function NM(t,e,r){let n=t.trim().split(/\s+/).filter(Boolean);if(!n.length)return[];let s=r/n.length;return n.map((o,i)=>({t:Math.round(e+s*i),text:o}))}function Bm(t){if(!t.length)return null;let e=1/0,r=1/0,n=-1/0,s=-1/0;for(let[o,i]of t)e=Math.min(e,o),n=Math.max(n,o),r=Math.min(r,i),s=Math.max(s,i);return[[e,r],[n,s]]}function CM(){return 13}function tw(t,e={}){let r=e.geo??{},n=e.routes??{},s=x=>x&&r[x]?r[x]:null,o=Object.values(r).map(x=>[x.lat,x.lng]),i=Bm(o),a=o.length?{lat:o.reduce((x,S)=>x+S[0],0)/o.length,lng:o.reduce((x,S)=>x+S[1],0)/o.length}:{lat:20,lng:0},c=i?{lat:a.lat,lng:a.lng,zoom:4,bounds:i}:{lat:20,lng:0,zoom:2},d=[],l=[],u=[],h=1;t.steps.forEach((x,S)=>{let k=x.chapter?450:0,_=h+k,m=x.holdMs??e.sayDurationsMs?.[S]??Math.max(x.say?AM(x.say):0,1600);x.chapter&&u.push({t:h,type:"marker",label:x.chapter});let $={t:Math.round(_)};if(x.card==="intro"||x.card==="outro")$.camera=c;else{let f=[],E=s(x.marker);if(E){let U={lat:E.lat,lng:E.lng,label:x.marker};f.push(U)}f.length&&($.markers=f);let N=n[S];if(N&&N.length>=2){$.route=N;let U=Bm(N);U&&($.camera={lat:(U[0][0]+U[1][0])/2,lng:(U[0][1]+U[1][1])/2,zoom:6,bounds:U})}if(x.region){let U=x.region.map(s).filter(Boolean).map(C=>[C.lat,C.lng]);if(U.length>=3){$.region=U;let C=Bm(U);C&&($.camera={lat:(C[0][0]+C[1][0])/2,lng:(C[0][1]+C[1][1])/2,zoom:6,bounds:C})}}let B=s(x.goTo);B?$.camera={lat:B.lat,lng:B.lng,zoom:x.zoom??7}:E&&!$.route&&!$.region?$.camera={lat:E.lat,lng:E.lng,zoom:x.zoom??CM()}:x.zoom&&$.camera&&($.camera.zoom=x.zoom)}d.push($),x.say&&l.push({t:_,dur:m,text:x.say,words:NM(x.say,_,m)}),h=_+m+250});let p={tiles:t.tiles??"streets",beats:d},g=[{t:0,vfs:{},activeFile:null,terminalState:""}];return{manifest:{version:2,title:t.title,createdAt:e.createdAt??new Date().toISOString(),durationMs:Math.max(h,1500),mode:"map"},events:u,snapshots:g,captions:l.length?l:void 0,map:p}}var rw=`Render a MAP walkthrough: a narrated tour over a real map \u2014 drop pins on places, draw routes between them, highlight regions, and fly the camera, like a travel/geography/history storyteller. Produces ONE self-contained interactive HTML (scrubbable, with voice; the map fetches tiles live, so it needs internet to view). Use this for anything geographic \u2014 travel, history, logistics, "where things are," expansion/spread over a map.
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.
136
136
 
137
137
  You write PLACE NAMES (your strength) \u2014 the server geocodes them to coordinates and routes roads automatically. Never write lat/long.
138
138
 
@@ -155,7 +155,7 @@ Worked shape:
155
155
  - { say:"then on to the coast at Marseille.", marker:"Marseille, France" }
156
156
  - { say:"This is the whole drive.", route:["Paris, France","Lyon, France","Marseille, France"] }
157
157
 
158
- Delivery is identical to the other tools: the PRIMARY result is a http://127.0.0.1:<port>/<id>.html URL (a resource_link) \u2014 give that link to the user.`;var jM="https://nominatim.openstreetmap.org/search",DM="https://router.project-osrm.org/route/v1/driving",nw="FlowCast/0.1 (map walkthrough generator)";var qm=new Map;async function LM(t){let e=t.trim().toLowerCase();if(!e)return null;if(qm.has(e))return qm.get(e);let r=null;try{let n=`${jM}?q=${encodeURIComponent(t)}&format=json&limit=1`,s=await fetch(n,{headers:{"user-agent":nw,accept:"application/json"},signal:AbortSignal.timeout(12e3)});if(s.ok){let o=await s.json();o?.length&&(r={lat:Number(o[0].lat),lng:Number(o[0].lon)})}}catch{}return qm.set(e,r),r}async function sw(t){let e={};return await Promise.all([...new Set(t)].map(async r=>{let n=await LM(r);n&&(e[r]=n)})),e}async function ow(t){if(t.length<2)return null;let e=t.map(r=>`${r.lng},${r.lat}`).join(";");try{let r=`${DM}/${e}?overview=full&geometries=geojson`,n=await fetch(r,{headers:{"user-agent":nw},signal:AbortSignal.timeout(12e3)});if(n.ok){let o=(await n.json()).routes?.[0]?.geometry?.coordinates;if(o?.length)return o.map(([i,a])=>[a,i])}}catch{}return t.map(r=>[r.lat,r.lng])}var ZM={id:"map",tool:{name:"create_map_walkthrough",title:"Map walkthrough",description:rw},promptLine:"\u2022 MAP \u2014 a narrated tour over a real map (travel, geography, history, logistics) \u2192 create_map_walkthrough",schema:Zm,mode:"map",makeBeat:(t,e)=>({say:t,card:e}),forceOutro:!0,async prepare(t){let e=new Set;for(let s of t.steps)s.marker&&e.add(s.marker),s.goTo&&e.add(s.goTo),(s.route??[]).forEach(o=>e.add(o)),(s.region??[]).forEach(o=>e.add(o));let r=await sw([...e]),n={};return await Promise.all(t.steps.map(async(s,o)=>{if(!s.route)return;let i=s.route.map(a=>r[a]).filter(Boolean);if(i.length>=2){let a=await ow(i);a&&(n[o]=a)}})),{geo:r,routes:n}},compile:(t,e)=>tw(t,e)},iw=ZM;var BM="TTS voice to narrate with. Defaults to cedar (warm, natural). Options: "+Lr.map(t=>`${t} (${fs[t]})`).join(", ")+".",aw=["box","sphere","cylinder","cone","plane","torus","icosahedron","pyramid","wedge","disc","ring","tube","dome"],cw="Primitives: box (rounded), sphere, cylinder, cone, pyramid, wedge, disc, ring, torus, tube, dome, icosahedron, plane. cylinder = database/tank/disk; sphere = node/user/planet; cone/pyramid = rocket-nose/tent/peak; disc = coin/plate/platform; ring/torus = loop/orbit/network; tube = pipe/connector; dome = hill/cap; icosahedron = crystal/core; box = service/building/block (and stat bars: box + tall Y scale).",qM=G.object({shape:G.enum(aw).default("box").describe("Primitive for this piece. "+cw),at:G.tuple([G.number(),G.number(),G.number()]).default([0,0,0]).describe("LOCAL offset [x,y,z] from the object center (x=right, y=up, z=depth). Stack/arrange parts to form the shape."),size:G.union([G.number(),G.tuple([G.number(),G.number(),G.number()])]).default(1).describe("Size of this piece \u2014 a single number or [x,y,z]. Relative to the object (parts ~0.2\u20132)."),color:G.string().optional().describe("CSS color for this piece. Defaults to the object color."),rotation:G.tuple([G.number(),G.number(),G.number()]).optional().describe("Optional local rotation [x,y,z] in RADIANS.")}),VM=G.object({id:G.string().describe("Unique id the beats reference."),shape:G.enum(aw).default("box").describe("A basic geometric PRIMITIVE \u2014 use ONLY when the object genuinely is one (a sphere node, a cylinder tank, a box/stat-bar). For anything recognizable or non-geometric, use `svg` instead (extruded), not a primitive. "+cw),parts:G.array(qM).max(10).optional().describe('FALLBACK only \u2014 prefer `svg` for custom objects (it looks far better). Use `parts` just for blocky/technical assemblies that are awkward as a 2D silhouette (e.g. a stack of server racks, a layered diagram). If you do use it: use 5\u20139 parts, NOT 2 \u2014 a 2-part object looks crude. Give it correct proportions, VARY the colors (a base color + 1\u20132 accents + dark detail), and add small DETAIL parts (windows, a door, a stripe, a light, trim) so it reads as a real object, not a blob. Stack parts precisely in LOCAL space (origin = its base on the floor). Examples: tree = tall cylinder trunk (brown) + 2\u20133 stacked cones of slightly different greens; house = box walls (light) + pyramid roof (terracotta) + small box door + 2 small box windows (blue); rocket = tall cylinder body (white) + cone nose (red) + 3 box fins + a small disc window + cone exhaust; server = box chassis (dark) + 3\u20134 thin box "slot" plates + 2 tiny glowing spheres (LEDs); person = sphere head + capsule torso + 2 thin cylinder arms + a small box base. Avoid: a single box, or 2 plain same-colored parts. The whole object is auto-scaled + grounded, so just lay parts around the origin.'),svg:G.string().optional().describe('Inline SVG for a SIMPLE SOLID ICON that the server extrudes into 3D \u2014 use it for a single recognizable silhouette (a pin, leaf, heart, arrow, gear, key, star, simple logo). Keep it ONE clean filled shape (a single `<path>`/`<polygon>` is ideal); the `fill` becomes the color. Do NOT build complex multi-color artwork (flags, detailed logos, scenes) as SVG \u2014 use `image` for those. Any viewBox is fine (auto-scaled/centered/grounded). Example: \'<svg viewBox="0 0 100 100"><path fill="#7cc6ff" d="M50 4 ... Z"/></svg>\'.'),image:G.string().optional().describe("An IMAGE URL (https://\u2026) for anything complex or detailed \u2014 a flag, photo, detailed logo, map, diagram, or real picture. The server fetches it, optimizes it (resized webp) and embeds it, then renders it as a clean textured panel standing in the scene with EXACT colors. Use this instead of `svg`/`parts` whenever the visual is intricate or must look real."),model:G.string().optional().describe("Advanced: a glTF/GLB URL (https://\u2026) or a local .glb/.gltf path to embed a REAL imported 3D model. Use for true volumetric objects."),label:G.string().optional().describe("Floating label shown next to the object (with a leader line pointing at it)."),value:G.number().optional().describe('A numeric value shown UNDER the label, counting up from 0 when the object appears. Great for stats/charts (pair with shape:"box" + scale:[1, value, 1]).'),valueSuffix:G.string().optional().describe('Unit appended to the counted value, e.g. "M", "%", "ms", "k". Prefix like "$" works too if you put it here as the suffix renders verbatim.'),color:G.string().optional().describe('CSS color (e.g. "#7cc6ff" or "tomato"). Defaults to a pleasant auto color.'),size:G.number().optional().describe("Relative size (default 1). 2 = twice as big."),scale:G.union([G.number(),G.tuple([G.number(),G.number(),G.number()])]).optional().describe('Non-uniform scale \u2014 a single number, or [x, y, z]. Use a tall Y for a STAT BAR (e.g. shape:"box", scale:[1, 4, 1] makes a bar 4\xD7 tall so HEIGHT encodes the value). Combines with `size`.'),finish:G.enum(["matte","glossy","metal","gradient","matcap","glass","iridescent"]).optional().describe("Surface material: 'matte', 'glossy', 'metal', 'gradient' (top-lit gradient), 'matcap' (baked sheen), 'glass' (frosted translucent), 'iridescent' (oil-slick sheen). Glass/iridescent catch the light beautifully."),path:G.array(G.tuple([G.number(),G.number(),G.number()])).optional().describe("CINEMATIC: a poly-line of [x,y,z] points the object travels along over the tour (e.g. a dot tracing a route, a probe flying a trajectory). 2+ points; the server smooths it into a curve."),pedestal:G.boolean().optional().describe("Place a subtle round platform under the object so it feels seated on the floor (nice for showcased items)."),reveal:G.enum(["grow","pop","fade","drop","rise"]).optional().describe("Entrance animation: 'grow' rises from the floor (stat bars/charts), 'pop' scales in, 'fade' fades in, 'drop' drops in with a bounce, 'rise' emerges upward. Default 'pop'."),motion:G.enum(["none","spin","bob","orbit"]).optional().describe("Idle motion. Default 'none' \u2014 the object rests still ON THE FLOOR. 'spin' = slow turntable (stays grounded), 'bob' = gentle float (lifts off the floor \u2014 use sparingly), 'orbit' = circle the scene center and float (e.g. a planet)."),at:G.tuple([G.number(),G.number(),G.number()]).optional().describe("Optional explicit position [x, y, z] (x=right, y=up, z=depth). Omit for an automatic presentation layout. Only set this when spatial arrangement carries meaning.")}),FM=G.object({say:G.string().optional().describe("Narration for this beat \u2014 ONE short idea (4\u201314 words), spoken aloud. Read in order, the beats form one continuous explanation."),show:G.union([G.string(),G.array(G.string())]).optional().describe("Object id(s) to REVEAL on this beat (they scale into the scene). Reveal one per beat for a natural build-up."),focus:G.string().optional().describe("Object id to move the camera to and frame this beat (like walking up to it)."),overview:G.boolean().optional().describe("Frame the whole staged scene this beat. Overview beats reveal the full model so the tour never opens on an empty canvas."),orbit:G.boolean().optional().describe("Slowly orbit around the focused object during this beat (a turntable look)."),showcase:G.string().optional().describe("Hero-SHOWCASE this object id (Apple product-reveal style): frame it on a plinth and slowly rotate it on a turntable while its label appears. Great for presenting one key object."),highlight:G.array(G.string()).optional().describe("Object/chart ids to SPOTLIGHT this beat while everything else recedes \u2014 great for comparing 2\u20133 items."),filter:G.array(G.string()).optional().describe("Object ids to KEEP this beat \u2014 everything else fades almost out (a stronger focus than highlight, for isolating a subset)."),callout:G.object({target:G.string(),text:G.string()}).optional().describe('Pin an annotation note (leader line + short text) onto an object/chart this beat, e.g. { target:"sales", text:"record high" }.'),set:G.object({target:G.string(),values:G.array(G.number())}).optional().describe("Change a CHART's data on this beat (before\u2192after): bars/segments animate to the new `values` and a delta badge (\u25B2/\u25BC) shows the change. `target` is the chart id; `values` matches its data length."),chapter:G.string().optional().describe("If set, starts a named chapter at this beat (timeline marker)."),holdMs:G.number().optional().describe("Beat duration in ms. Defaults to a duration derived from the narration.")}),HM=G.object({label:G.string().optional().describe("Category label (axis tick / segment label)."),value:G.number().describe("The numeric value."),color:G.string().optional().describe("Optional per-datum color (else the chart accent).")}),UM=G.object({id:G.string().describe("Unique id beats reference via show/focus (a chart behaves like an object)."),type:G.enum(["bar","line","area","pie","donut","ring"]).describe("Chart kind: 'bar' (columns grow + count up), 'line'/'area' (time-series drawn left\u2192right with point markers), 'pie'/'donut' (segments sweep in), 'ring' (a single % gauge \u2014 value vs max)."),data:G.array(HM).min(1).describe("The data points. For a ring use a single datum (value vs max = the %)."),at:G.tuple([G.number(),G.number(),G.number()]).optional().describe("Position [x,y,z]; omit to auto-place. The chart sits on the floor."),width:G.number().optional().describe("Horizontal extent (default ~6)."),height:G.number().optional().describe("Vertical extent \u2014 the value mapped to `max` (default ~4)."),max:G.number().optional().describe("Value mapped to full height/percent (defaults to the largest data value)."),unit:G.string().optional().describe('Unit appended to value labels (e.g. "%", "M", "ms").'),color:G.string().optional().describe("Accent color for series without their own color."),label:G.string().optional().describe("Chart title shown above it.")}),Vm={title:G.string().describe("Title of the 3D walkthrough (header + filename)."),pace:G.enum(["calm","normal","snappy"]).optional().describe("Animation tempo (default 'normal'): 'calm' = slower, cinematic; 'normal' = brisk, tight pacing; 'snappy' = fastest reveals + camera. Affects all entrance/transition/camera timings."),outputPath:G.string().optional().describe("Optional path to also write the .html to (same mapping as create_walkthrough)."),voiceName:G.enum(Lr).optional().describe(BM),voiceTone:G.string().optional().describe("How the narrator should SOUND, matched to the topic. A natural human delivery is always layered on top."),intro:G.string().optional().describe("Opening line spoken before the tour. Defaults to a title-based welcome; set to '' to skip."),outro:G.string().optional().describe("Closing wrap-up line spoken at the end (always added). Customize the wording here."),background:G.string().optional().describe('Solid scene background CSS color (default a dark studio backdrop). It is a clean solid color + a grid floor \u2014 a real 3D stage, not outer space. Prefer a deep, slightly-not-black color (e.g. "#0d1018", "#10131c").'),floor:G.string().optional().describe("Optional floor color (defaults to a shade just off the background so the ground/horizon reads). Use a related dark tone."),template:G.enum(["solar-system","molecule","network","stack"]).optional().describe("Optional ready-made scene the server builds for you: 'solar-system' (sun + planets that orbit, on a starfield), 'molecule' (atoms + bonds), 'network' (nodes + links), 'stack' (layered plates). When set, you can omit `objects` (the template generates them) or add a few of your own; your beats still drive the tour."),connections:G.array(G.object({from:G.string(),to:G.string(),label:G.string().optional()})).optional().describe('Relationships drawn as glowing beams between objects, with energy flowing from\u2192to. Great for showing how parts connect (e.g. { from:"gateway", to:"service" }).'),charts:G.array(UM).max(8).optional().describe("Animated CHARTS (infographic style). Each chart has an id beats reveal via `show`/`focus`. Bars grow + count up, lines/areas draw left\u2192right in story order, pie/donut sweep, ring fills. Add an axis automatically."),objects:G.array(VM).max(14).optional().describe("The objects in the scene. Keep it focused: 3-8 labeled objects usually works best. GEOMETRY PRIORITY: (1) basic geometric form \u2192 `shape` primitive; (2) a simple recognizable icon/silhouette \u2192 `svg` (single solid path, extruded); (3) anything complex/detailed/real (flag, photo, detailed logo, map) \u2192 `image` URL (embedded as a textured panel); (4) blocky technical assembly \u2192 `parts`; (5) true 3D mesh \u2192 `model` glTF. SPACING: omit `at` for auto layout; objects always sit on/above the floor."),steps:G.array(FM).min(1).describe("The ordered tour as a STORY: open with an overview, then reveal/focus ONE object at a time while explaining, orbit the important one, then recap. MANY short beats; the `say` lines must read as one continuous script.")},AB=G.object(Vm);import{readFile as GM,stat as YM}from"node:fs/promises";var XM=new Set(["planet","moon","sun","star","satellite","atom","molecule","server","database","db","cloud","gear","cog","rocket","building","tree","person","user","cube","box","ring","coin","pin"]);function Fm(t){return!!t&&XM.has(t.trim().toLowerCase())}var WM=16*1024*1024,KM=2e4,uw=t=>/\.(glb|gltf)(\?|$)/i.test(t);function lw(t,e){return!t.length||t.length>WM?null:`data:${/\.glb(\?|$)/i.test(e)||t.subarray(0,4).toString("binary")==="glTF"?"model/gltf-binary":"model/gltf+json"};base64,${t.toString("base64")}`}async function JM(t){let e=t.trim();try{if(/^https?:\/\//i.test(e)){let s=await fetch(e,{signal:AbortSignal.timeout(KM),redirect:"follow"});return s.ok?lw(Buffer.from(await s.arrayBuffer()),e):null}let r=e.startsWith("file://")?new URL(e).pathname:e;if(!uw(r))return null;let n=await YM(r).catch(()=>null);return!n||!n.isFile()?null:lw(await GM(r),r)}catch{return null}}function QM(t){return!t||Fm(t)?!1:/^https?:\/\//i.test(t)||t.startsWith("file://")||uw(t)}async function dw(t){let e={};return await Promise.all(t.map(async r=>{if(QM(r.model)){let n=await JM(r.model);n&&(e[r.id]=n)}})),e}var ez=285,tz={calm:{gap:250,chapter:450},normal:{gap:140,chapter:320},snappy:{gap:90,chapter:240}},Wl=["#7cc6ff","#9be08b","#ffd166","#ff8c69","#c89bff","#5ad1c4","#ff9ecb","#a0d8ef"],rz=t=>Math.max(1,t.trim().split(/\s+/).length),nz=t=>Math.max(1600,rz(t)*ez);function sz(t,e,r){let n=t.trim().split(/\s+/).filter(Boolean);if(!n.length)return[];let s=r/n.length;return n.map((o,i)=>({t:Math.round(e+s*i),text:o}))}var Oa=(t,e)=>[t[0]+e[0],t[1]+e[1],t[2]+e[2]],fw=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),oz=t=>t==null?[]:Array.isArray(t)?t:[t];function iz(t,e){if(e<=1)return[0,0,0];if(e<=5)return[(t-(e-1)/2)*5.2,0,0];let r=Math.ceil(Math.sqrt(e)),n=Math.ceil(e/r);return[(t%r-(r-1)/2)*5,0,(Math.floor(t/r)-(n-1)/2)*-4.2]}var Hm=(t,e,r,n=0)=>{let s=t/Math.max(1,e)*Math.PI*2;return[Math.cos(s)*r,n,Math.sin(s)*r]};function az(t,e){let r=u=>u.model?Fm(u.model)?u.model.trim().toLowerCase():e[u.id]:void 0,n=u=>u==null?[1,1,1]:typeof u=="number"?[u,u,u]:u,s=u=>u==null?[1,1,1]:typeof u=="number"?[u,u,u]:u,o=(u,h)=>u.parts?.length?u.parts.map(p=>({shape:p.shape??"box",pos:p.at??[0,0,0],size:s(p.size),color:p.color||h,...p.rotation?{rotation:p.rotation}:{}})):void 0,i=(u,h,p,g={})=>{let x=u.color||Wl[h%Wl.length],S=o(u,x);return{id:u.id,shape:u.shape??"box",pos:p,size:u.size??1,scale:n(u.scale),color:x,...u.label?{label:u.label}:{},...u.value!=null?{value:u.value}:{},...u.valueSuffix?{valueSuffix:u.valueSuffix}:{},...S?{parts:S}:{},...u.svg&&!S?{svg:u.svg}:{},...!S&&r(u)?{model:r(u)}:{},...u.reveal?{reveal:u.reveal}:{},...u.finish?{finish:u.finish}:{},...u.pedestal?{pedestal:!0}:{},...u.path?.length?{path:u.path}:{},motion:u.motion??"none",...g}},a=t.objects??[],c=[...t.connections??[]],d=!1;t.template==="solar-system"&&a.length===0?a=[{id:"sun",shape:"sphere",label:"Sun",color:"#ffcf5a",size:2.4},{id:"mercury",shape:"sphere",label:"Mercury",color:"#b7a18a",size:.5},{id:"venus",shape:"sphere",label:"Venus",color:"#e6c07a",size:.8},{id:"earth",shape:"sphere",label:"Earth",color:"#6bb6ff",size:.85},{id:"mars",shape:"sphere",label:"Mars",color:"#e07a5f",size:.7}]:t.template==="molecule"&&a.length===0&&(a=[{id:"o",shape:"sphere",label:"O",color:"#ff6b6b",size:1.2},{id:"h1",shape:"sphere",label:"H",color:"#dfe6ee",size:.7},{id:"h2",shape:"sphere",label:"H",color:"#dfe6ee",size:.7}]);let l;if(t.template==="solar-system")d=!0,l=a.map((u,h)=>{if(h===0)return i(u,h,[0,0,0],{glow:!0,motion:u.motion??"spin",shape:u.shape??"sphere"});let p=5+(h-1)*3.2;return i(u,h,Hm(h-1,Math.max(3,a.length-1),p),{shape:u.shape??"sphere",motion:"orbit",orbit:{radius:p,speed:.18/Math.sqrt(h),phase:h/a.length*Math.PI*2}})});else if(t.template==="molecule"){if(l=a.map((u,h)=>h===0?i(u,h,[0,0,0],{shape:u.shape??"sphere"}):i(u,h,Hm(h-1,a.length-1,2.6,(h%2?1:-1)*.6),{shape:u.shape??"sphere"})),c.length===0)for(let u=1;u<a.length;u++)c.push({from:a[0].id,to:a[u].id})}else t.template==="network"?l=a.map((u,h)=>i(u,h,Hm(h,a.length,Math.max(4,a.length*.9),(h%2?1:-1)*.8))):t.template==="stack"?l=a.map((u,h)=>i(u,h,[0,(a.length-1)/2-h,0],{shape:u.shape??"box",motion:u.motion??"none",size:u.size??1.6})):l=a.map((u,h)=>i(u,h,u.at?u.at:iz(h,a.length)));return{objects:l,connections:c,starfield:d}}function hw(t,e={}){let{objects:r,connections:n,starfield:s}=az(t,e.models??{}),o=new Map(r.map(I=>[I.id,I]));for(let I of r){let Y=e.images?.[I.id];Y&&(I.image=Y.href,I.imageAspect=Y.h>0?Y.w/Y.h:1)}let i=t.charts??[],a=4.5,c=i.map(I=>I.width??6),l=-(c.reduce((I,Y)=>I+Y,0)+a*Math.max(0,i.length-1))/2,u=r.map(I=>I.pos[2]),h=r.length?Math.min(0,...u)-9:0,p=i.map((I,Y)=>{let V=c[Y],ee=I.height??4,L=l+V/2;l+=V+a;let T=I.at?I.at:[L,0,h];return{id:I.id,type:I.type,pos:T,width:V,height:ee,data:I.data.map(y=>({...y.label?{label:y.label}:{},value:y.value,...y.color?{color:y.color}:{}})),max:I.max??Math.max(...I.data.map(y=>y.value),1),...I.unit?{unit:I.unit}:{},color:I.color||Wl[(r.length+Y)%Wl.length],...I.label?{label:I.label}:{}}}),g=new Map(p.map(I=>[I.id,I])),x=I=>o.has(I)||g.has(I),S=[...r.map(I=>I.pos),...p.map(I=>I.pos)],k=S.length,_=k?[S.reduce((I,Y)=>I+Y[0],0)/k,S.reduce((I,Y)=>I+Y[1],0)/k,S.reduce((I,Y)=>I+Y[2],0)/k]:[0,0,0],m=Math.max(5,...r.map(I=>fw(I.pos,_)+I.size*1.6),...p.map(I=>fw(I.pos,_)+Math.max(I.width,I.height))),$=()=>({pos:Oa(_,[0,m*.7,m*2.7]),look:_}),f=()=>({pos:Oa(_,[m*1.9,m*.55,m*1.9]),look:_}),E=(I,Y)=>{let V=o.get(I);if(V){let L=V.size*4.6+6;return{pos:Oa(V.pos,[L*.34,L*.3,L*1.05]),look:V.pos,...Y?{orbit:!0}:{}}}let ee=g.get(I);if(ee){let L=Math.max(ee.width,ee.height)*1.5+6;return{pos:Oa(ee.pos,[L*.2,L*.5,L*1.1]),look:Oa(ee.pos,[0,ee.height/2,0])}}return null},N=t.pace??"normal",{gap:B,chapter:U}=tz[N],C=[],q=[],de=[],A=1;t.steps.forEach((I,Y)=>{let V=I.chapter?U:0,ee=A+V,L=I.holdMs??e.sayDurationsMs?.[Y]??Math.max(I.say?nz(I.say):0,1600);I.chapter&&de.push({t:A,type:"marker",label:I.chapter});let T={t:Math.round(ee)};if(I.card==="intro")T.camera=f();else if(I.card==="outro")T.camera=$();else{let R=oz(I.show).filter(x);R.length&&(T.show=R),I.overview&&(T.camera=$());let O=I.focus??(R.length===1?R[0]:void 0);if(O&&!I.overview){T.focus=O;let K=E(O,I.orbit);K&&(T.camera=K)}}if(I.showcase&&o.has(I.showcase)){T.focus=I.showcase,T.showcase=!0;let R=E(I.showcase);R&&(T.camera=R);let O=o.get(I.showcase);O&&(O.pedestal=!0)}let y=(I.highlight??[]).filter(x);y.length&&(T.highlight=y);let v=(I.filter??[]).filter(x);v.length&&(T.filter=v),I.callout&&x(I.callout.target)&&(T.callout=I.callout),I.set&&g.has(I.set.target)&&(T.set=I.set),C.push(T),I.say&&q.push({t:ee,dur:L,text:I.say,words:sz(I.say,ee,L)}),A=ee+L+B});let b={objects:r,beats:C,...n.length?{connections:n}:{},...s?{starfield:!0}:{},...t.background?{background:t.background}:{},...t.floor?{floor:t.floor}:{},style:"infographic",...p.length?{charts:p}:{},pace:N},D=[{t:0,vfs:{},activeFile:null,terminalState:""}];return{manifest:{version:2,title:t.title,createdAt:e.createdAt??new Date().toISOString(),durationMs:Math.max(A,1500),mode:"3d"},events:de,snapshots:D,captions:q.length?q:void 0,scene3d:b}}var pw='Render a 3D walkthrough: a narrated, animated INFOGRAPHIC MOTION TOUR through a staged 3D model \u2014 primitive objects arranged in space, revealed and focused beat by beat with a spline camera glide, staggered reveals, kinetic narration, depth-of-field + grain, and animated `charts`/`callouts`. Produces ONE self-contained interactive HTML (scrubbable, with voice) in the same FlowCast player shell as code and whiteboard walkthroughs. Use this when SPATIAL/3D structure helps \u2014 comparing sizes, arrangement, layers, a showcase of parts, or a data story.\n\nYou list OBJECTS + beats; the server lays out the model and the player auto-frames visible/focused objects, so you never do camera math. There is a single visual style (the infographic motion tour) \u2014 you don\'t pick one.\n\n- `charts`: [{ id, type:"bar"|"line"|"area"|"pie"|"donut"|"ring", data:[{label,value,color?}], unit?, max?, label?, at? }] \u2014 referenced by beats via show/focus like objects. Bars grow+count, line/area draw in order, pie/donut sweep, ring is a % gauge. `pace`: "calm"|"snappy". Beats accept `highlight:[ids]` (spotlight a subset), `filter:[ids]` (fade everything else almost out), `callout:{target,text}` (annotation), and `set:{target,values}` (animate a chart to new values + \u25B2/\u25BC delta badges). Charts auto-layout in a non-overlapping row; honors `prefers-reduced-motion`.\n\n- objects: [{ id, shape | svg | parts | model, label?, color?, size?, scale?, finish?, pedestal?, reveal?, motion?, at? }]. Use 3-8 labeled objects. Omit `at` for auto layout with GENEROUS spacing (\u22485+ between neighbours). Objects sit on/above the floor.\n- GEOMETRY \u2014 PICK IN THIS ORDER:\n 1. `shape` PRIMITIVE \u2014 ONLY if the object genuinely is a basic form (sphere node, cylinder tank, box/stat-bar). box/sphere/cylinder/cone/pyramid/wedge/disc/ring/torus/tube/dome/icosahedron/plane.\n 2. `svg` \u2014 a SIMPLE SOLID ICON (single filled path/polygon): pin, leaf, heart, arrow, gear, key, star, simple logo. We extrude it; the `fill` is the color. Keep it ONE clean shape \u2014 not complex artwork.\n 3. `image` \u2014 an IMAGE URL for anything COMPLEX or detailed (a flag, photo, detailed logo, map, diagram). We fetch + optimize (webp) + embed it and render a textured panel with exact colors. Use this for flags/logos/photos instead of svg/parts.\n 4. `parts` (composed primitives) \u2014 fallback only, for blocky technical assemblies. 5\u20139 parts, varied colors.\n 5. `model` \u2014 a real glTF/GLB URL or local path (true 3D mesh).\n `finish`: matte/glossy/metal/gradient/matcap/glass/iridescent. `pedestal:true` seats it on a platform.\n- STAT BARS: `shape:"box"`, `scale:[1, value, 1]`, `reveal:"grow"`, plus `value` + `valueSuffix` (e.g. value:155, valueSuffix:"M") to show a number that COUNTS UP in a chip beside the bar. `reveal` also: "pop", "fade", "drop" (bounce), "rise"; `motion`: none/spin/bob/orbit.\n- The scene is a clean 3D STAGE: a solid `background` color + a grid floor + soft shadows (no starfield/space). Prefer a deep near-black background; set `floor` for the ground tone.\n- steps: each beat has a short `say` plus an action:\n - `show`: object id(s) to reveal now (they scale in)\n - `focus`: object id to move the camera to and frame\n - `overview`: frame the whole staged scene\n - `orbit`: slowly circle the focused object (turntable)\n - `showcase`: object id to HERO-showcase \u2014 frames it on a plinth and slowly rotates it (Apple-style product reveal)\n The viewer can also PAUSE to free-orbit the scene, hover objects for a tooltip, and click an object to jump to its beat. Imported glTF models play their built-in animations.\n- Teach it like a STORY: open with an overview of the model, focus ONE object per beat while explaining, orbit only a key object, recap with another overview. MANY short beats reading as one script.\n- Avoid huge size differences and avoid more than 8 objects unless the spatial grouping is essential; clutter makes the camera less useful.\n- VOICE: pick `voiceName` + `voiceTone` to fit the topic.\n- INTRO & OUTRO auto-added (opening overview + wrap-up) \u2014 don\'t author your own.\n\nWorked shape:\n objects:\n - { id:"core", shape:"icosahedron", label:"Core", color:"#7cc6ff" }\n - { id:"cache", shape:"box", label:"Cache", color:"#9be08b" }\n - { id:"db", shape:"cylinder", label:"Database", color:"#ffd166" }\n steps:\n - { chapter:"The system", say:"At the center is the core.", show:"core", focus:"core" }\n - { say:"It keeps a cache nearby.", show:"cache", focus:"cache" }\n - { say:"And persists to a database.", show:"db", focus:"db" }\n - { say:"Here\'s how it all sits together.", overview:true }\n\nDelivery is identical to the other tools: the PRIMARY result is a http://127.0.0.1:<port>/<id>.html URL (a resource_link) \u2014 give that link to the user.';var cz={id:"3d",tool:{name:"create_3d_walkthrough",aliases:["create_three_d_walkthrough"],title:"Create a narrated 3D tour",description:pw},promptLine:"\u2022 3D \u2014 a narrated tour through a 3D scene (spatial structure, a showcase of parts) \u2192 create_3d_walkthrough",schema:Vm,mode:"3d",makeBeat:(t,e)=>({say:t,card:e}),forceOutro:!0,async prepare(t){let e=await dw(t.objects??[]),r={};return await Promise.all((t.objects??[]).map(async n=>{if(!n.image||!/^https?:\/\//i.test(n.image))return;let s=await Lm(n.image);s&&(r[n.id]={href:s.href,w:s.w,h:s.h})})),{...Object.keys(e).length?{models:e}:{},...Object.keys(r).length?{images:r}:{}}},compile:(t,e)=>hw(t,e)},mw=cz;var Kl=[rv,ew,iw,mw];var lz=t=>`Welcome! In this walkthrough, we'll look at ${t}. Let's dive in.`,gw=t=>`And that's ${t}. Thanks for watching \u2014 see you in the next one.`;function _w(t,e,r,n,s,o=!1){let i=r===void 0?lz(e):r,a=n===void 0?gw(e):n;o&&!a.trim()&&(a=gw(e));let c=[...t];return a.trim()&&c.push(s(a,"outro")),i.trim()&&c.unshift(s(i,"intro")),c}import{gzipSync as uz}from"node:zlib";import{readFileSync as dz,existsSync as fz}from"node:fs";import{fileURLToPath as hz}from"node:url";import*as ai from"node:path";function bw(t,e,r,n){return`<!doctype html>
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>
159
159
  <html lang="en">
160
160
  <head>
161
161
  <meta charset="utf-8" />
@@ -166,9 +166,9 @@ Delivery is identical to the other tools: the PRIMARY result is a http://127.0.0
166
166
  </head>
167
167
  <body>
168
168
  <div id="app"></div>
169
- <script type="text/plain" id="blazy-data-gz">${e}</script>
170
- <script type="text/plain" id="blazy-audio">${r}</script>
171
- <script type="text/plain" id="blazy-player-gz">${n}</script>
169
+ <script type="text/plain" id="flow-data-gz">${e}</script>
170
+ <script type="text/plain" id="flow-audio">${r}</script>
171
+ <script type="text/plain" id="flow-player-gz">${n}</script>
172
172
  <script>
173
173
  (async function(){
174
174
  var app=document.getElementById('app');
@@ -179,20 +179,20 @@ Delivery is identical to the other tools: the PRIMARY result is a http://127.0.0
179
179
  return await new Response(new Blob([unb64(b64)]).stream().pipeThrough(ds)).text();
180
180
  }
181
181
  try{
182
- var js=await inflate(document.getElementById('blazy-player-gz').textContent.trim());
183
- new Function(js)(); // defines window.BlazyPlayer
184
- var data=JSON.parse(await inflate(document.getElementById('blazy-data-gz').textContent.trim()));
185
- var audio=document.getElementById('blazy-audio').textContent.trim();
182
+ var js=await inflate(document.getElementById('flow-player-gz').textContent.trim());
183
+ new Function(js)(); // defines window.FlowPlayer
184
+ var data=JSON.parse(await inflate(document.getElementById('flow-data-gz').textContent.trim()));
185
+ var audio=document.getElementById('flow-audio').textContent.trim();
186
186
  data.audio=audio||null;
187
- BlazyPlayer.mount(app, data);
187
+ FlowPlayer.mount(app, data);
188
188
  }catch(e){app.textContent='Failed to start player: '+e;}
189
189
  })();
190
190
  </script>
191
191
  </body>
192
- </html>`}function yw(t){return!!t.preview}function vw(t){return t.events.some(e=>e.type==="term.data"||e.type==="term.resize")}var pz=ai.dirname(hz(import.meta.url));function mz(t){let e=ai.join(t,"player");return fz(e)?e:ai.join(t,"../../../../packages/player/dist")}var ww=mz(pz);function gz(t){let e;if(t.manifest.mode)e=`_player-bundle.${t.manifest.mode}.gz.b64`;else{let r=yw(t),n=vw(t);e=r&&n?"_player-bundle.gz.b64":r?"_player-bundle.noterm.gz.b64":n?"_player-bundle.slim.gz.b64":"_player-bundle.min.gz.b64"}try{return dz(ai.join(ww,e),"utf8").trim()}catch{throw new Error(`Player bundle "${e}" not found in ${ww} (run pnpm build:player).`)}}function xw(t,e=""){let r=uz(Buffer.from(JSON.stringify({...t,audio:null}),"utf8"),{level:9}).toString("base64"),n=gz(t);return bw(t.manifest.title,r,e,n)}var Xw={};function _z(t){return new Int8Array(t)}function Ww(t){return new Int16Array(t)}function Kw(t){return new Int32Array(t)}function Jw(t){return new Float32Array(t)}function bz(t){return new Float64Array(t)}function Qw(t){if(t.length==1)return Jw(t[0]);var e=t[0];t=t.slice(1);for(var r=[],n=0;n<e;n++)r.push(Qw(t));return r}function e3(t){if(t.length==1)return Kw(t[0]);var e=t[0];t=t.slice(1);for(var r=[],n=0;n<e;n++)r.push(e3(t));return r}function t3(t){if(t.length==1)return Ww(t[0]);var e=t[0];t=t.slice(1);for(var r=[],n=0;n<e;n++)r.push(t3(t));return r}function r3(t){if(t.length==1)return new Array(t[0]);var e=t[0];t=t.slice(1);for(var r=[],n=0;n<e;n++)r.push(r3(t));return r}var n3={};n3.fill=function(t,e,r,n){if(arguments.length==2)for(var s=0;s<t.length;s++)t[s]=arguments[1];else for(var s=e;s<r;s++)t[s]=n};var ja={};ja.arraycopy=function(t,e,r,n,s){for(var o=e+s;e<o;)r[n++]=t[e++]};ja.out={};ja.out.println=function(t){console.log(t)};ja.out.printf=function(){console.log.apply(console,arguments)};var nu={};nu.SQRT2=1.4142135623730951;nu.FAST_LOG10=function(t){return Math.log10(t)};nu.FAST_LOG10_X=function(t,e){return Math.log10(t)*e};function Hn(t){this.ordinal=t}Hn.short_block_allowed=new Hn(0);Hn.short_block_coupled=new Hn(1);Hn.short_block_dispensed=new Hn(2);Hn.short_block_forced=new Hn(3);var s3={};s3.MAX_VALUE=34028235e31;function qr(t){this.ordinal=t}qr.vbr_off=new qr(0);qr.vbr_mt=new qr(1);qr.vbr_rh=new qr(2);qr.vbr_abr=new qr(3);qr.vbr_mtrh=new qr(4);qr.vbr_default=qr.vbr_mtrh;var yz=function(t){},Zt={System:ja,VbrMode:qr,Float:s3,ShortBlock:Hn,Util:nu,Arrays:n3,new_array_n:r3,new_byte:_z,new_double:bz,new_float:Jw,new_float_n:Qw,new_int:Kw,new_int_n:e3,new_short:Ww,new_short_n:t3,assert:yz},Um,kw;function vz(){if(kw)return Um;kw=1;var t=Zt,e=t.System,r=t.Util,n=t.Arrays,s=t.new_float,o=hr();function i(){var a=[-.1482523854003001,32.308141959636465,296.40344946382766,883.1344870032432,11113.947376231741,1057.2713659324597,305.7402417275812,30.825928907280012,3.8533188138216365,59.42900443849514,709.5899960123345,5281.91112291017,-5829.66483675846,-817.6293103748613,-76.91656988279972,-4.594269939176596,.9063471690191471,.1960342806591213,-.15466694054279598,34.324387823855965,301.8067566458425,817.599602898885,11573.795901679885,1181.2520595540152,321.59731579894424,31.232021761053772,3.7107095756221318,53.650946155329365,684.167428119626,5224.56624370173,-6366.391851890084,-908.9766368219582,-89.83068876699639,-5.411397422890401,.8206787908286602,.3901806440322567,-.16070888947830023,36.147034243915876,304.11815768187864,732.7429163887613,11989.60988270091,1300.012278487897,335.28490093152146,31.48816102859945,3.373875931311736,47.232241542899175,652.7371796173471,5132.414255594984,-6909.087078780055,-1001.9990371107289,-103.62185754286375,-6.104916304710272,.7416505462720353,.5805693545089249,-.16636367662261495,37.751650073343995,303.01103387567713,627.9747488785183,12358.763425278165,1412.2779918482834,346.7496836825721,31.598286663170416,3.1598635433980946,40.57878626349686,616.1671130880391,5007.833007176154,-7454.040671756168,-1095.7960341867115,-118.24411666465777,-6.818469345853504,.6681786379192989,.7653668647301797,-.1716176790982088,39.11551877123304,298.3413246578966,503.5259106886539,12679.589408408976,1516.5821921214542,355.9850766329023,31.395241710249053,2.9164211881972335,33.79716964664243,574.8943997801362,4853.234992253242,-7997.57021486075,-1189.7624067269965,-133.6444792601766,-7.7202770609839915,.5993769336819237,.9427934736519954,-.17645823955292173,40.21879108166477,289.9982036694474,359.3226160751053,12950.259102786438,1612.1013903507662,362.85067106591504,31.045922092242872,2.822222032597987,26.988862316190684,529.8996541764288,4671.371946949588,-8535.899136645805,-1282.5898586244496,-149.58553632943463,-8.643494270763135,.5345111359507916,1.111140466039205,-.36174739330527045,41.04429910497807,277.5463268268618,195.6386023135583,13169.43812144731,1697.6433561479398,367.40983966190305,30.557037410382826,2.531473372857427,20.070154905927314,481.50208566532336,4464.970341588308,-9065.36882077239,-1373.62841526722,-166.1660487028118,-9.58289321133207,.4729647758913199,1.268786568327291,-.36970682634889585,41.393213350082036,261.2935935556502,12.935476055240873,13336.131683328815,1772.508612059496,369.76534388639965,29.751323653701338,2.4023193045459172,13.304795348228817,430.5615775526625,4237.0568611071185,-9581.931701634761,-1461.6913552409758,-183.12733958476446,-10.718010163869403,.41421356237309503,1.414213562373095,-.37677560326535325,41.619486213528496,241.05423794991074,-187.94665032361226,13450.063605744153,1836.153896465782,369.4908799925761,29.001847876923147,2.0714759319987186,6.779591200894186,377.7767837205709,3990.386575512536,-10081.709459700915,-1545.947424837898,-200.3762958015653,-11.864482073055006,.3578057213145241,1.546020906725474,-.3829366947518991,41.1516456456653,216.47684307105183,-406.1569483347166,13511.136535077321,1887.8076599260432,367.3025214564151,28.136213436723654,1.913880671464418,.3829366947518991,323.85365704338597,3728.1472257487526,-10561.233882199509,-1625.2025997821418,-217.62525175416,-13.015432208941645,.3033466836073424,1.66293922460509,-.5822628872992417,40.35639251440489,188.20071124269245,-640.2706748618148,13519.21490106562,1927.6022433578062,362.8197642637487,26.968821921868447,1.7463817695935329,-5.62650678237171,269.3016715297017,3453.386536448852,-11016.145278780888,-1698.6569643425091,-234.7658734267683,-14.16351421663124,.2504869601913055,1.76384252869671,-.5887180101749253,39.23429103868072,155.76096234403798,-889.2492977967378,13475.470561874661,1955.0535223723712,356.4450994756727,25.894952980042156,1.5695032905781554,-11.181939564328772,214.80884394039484,3169.1640829158237,-11443.321309975563,-1765.1588461316153,-251.68908574481912,-15.49755935939164,.198912367379658,1.847759065022573,-.7912582233652842,37.39369355329111,119.699486012458,-1151.0956593239027,13380.446257078214,1970.3952110853447,348.01959814116185,24.731487364283044,1.3850130831637748,-16.421408865300393,161.05030052864092,2878.3322807850063,-11838.991423510031,-1823.985884688674,-268.2854986386903,-16.81724543849939,.1483359875383474,1.913880671464418,-.7960642926861912,35.2322109610459,80.01928065061526,-1424.0212633405113,13235.794061869668,1973.804052543835,337.9908651258184,23.289159354463873,1.3934255946442087,-21.099669467133474,108.48348407242611,2583.700758091299,-12199.726194855148,-1874.2780658979746,-284.2467154529415,-18.11369784385905,.09849140335716425,1.961570560806461,-.998795456205172,32.56307803611191,36.958364584370486,-1706.075448829146,13043.287458812016,1965.3831106103316,326.43182772364605,22.175018750622293,1.198638339011324,-25.371248002043963,57.53505923036915,2288.41886619975,-12522.674544337233,-1914.8400385312243,-299.26241273417224,-19.37805630698734,.04912684976946725,1.990369453344394,.035780907*r.SQRT2*.5/2384e-9,.017876148*r.SQRT2*.5/2384e-9,.003134727*r.SQRT2*.5/2384e-9,.002457142*r.SQRT2*.5/2384e-9,971317e-9*r.SQRT2*.5/2384e-9,218868e-9*r.SQRT2*.5/2384e-9,101566e-9*r.SQRT2*.5/2384e-9,13828e-9*r.SQRT2*.5/2384e-9,12804.797818791945,1945.5515939597317,313.4244966442953,20.801593959731544,1995.1556208053692,9.000838926174497,-29.20218120805369],c=12,d=36,l=[[2382191739347913e-28,6423305872147834e-28,9400849094049688e-28,1122435026096556e-27,1183840321267481e-27,1122435026096556e-27,940084909404969e-27,6423305872147839e-28,2382191739347918e-28,5456116108943412e-27,4878985199565852e-27,4240448995017367e-27,3559909094758252e-27,2858043359288075e-27,2156177623817898e-27,1475637723558783e-27,8371015190102974e-28,2599706096327376e-28,-5456116108943412e-27,-4878985199565852e-27,-4240448995017367e-27,-3559909094758252e-27,-2858043359288076e-27,-2156177623817898e-27,-1475637723558783e-27,-8371015190102975e-28,-2599706096327376e-28,-2382191739347923e-28,-6423305872147843e-28,-9400849094049696e-28,-1122435026096556e-27,-1183840321267481e-27,-1122435026096556e-27,-9400849094049694e-28,-642330587214784e-27,-2382191739347918e-28],[2382191739347913e-28,6423305872147834e-28,9400849094049688e-28,1122435026096556e-27,1183840321267481e-27,1122435026096556e-27,9400849094049688e-28,6423305872147841e-28,2382191739347918e-28,5456116108943413e-27,4878985199565852e-27,4240448995017367e-27,3559909094758253e-27,2858043359288075e-27,2156177623817898e-27,1475637723558782e-27,8371015190102975e-28,2599706096327376e-28,-5461314069809755e-27,-4921085770524055e-27,-4343405037091838e-27,-3732668368707687e-27,-3093523840190885e-27,-2430835727329465e-27,-1734679010007751e-27,-974825365660928e-27,-2797435120168326e-28,0,0,0,0,0,0,-2283748241799531e-28,-4037858874020686e-28,-2146547464825323e-28],[.1316524975873958,.414213562373095,.7673269879789602,1.091308501069271,1.303225372841206,1.56968557711749,1.920982126971166,2.414213562373094,3.171594802363212,4.510708503662055,7.595754112725146,22.90376554843115,.984807753012208,.6427876096865394,.3420201433256688,.9396926207859084,-.1736481776669303,-.7660444431189779,.8660254037844387,.5,-.5144957554275265,-.4717319685649723,-.3133774542039019,-.1819131996109812,-.09457419252642064,-.04096558288530405,-.01419856857247115,-.003699974673760037,.8574929257125442,.8817419973177052,.9496286491027329,.9833145924917901,.9955178160675857,.9991605581781475,.999899195244447,.9999931550702802],[0,0,0,0,0,0,2283748241799531e-28,4037858874020686e-28,2146547464825323e-28,5461314069809755e-27,4921085770524055e-27,4343405037091838e-27,3732668368707687e-27,3093523840190885e-27,2430835727329466e-27,1734679010007751e-27,974825365660928e-27,2797435120168326e-28,-5456116108943413e-27,-4878985199565852e-27,-4240448995017367e-27,-3559909094758253e-27,-2858043359288075e-27,-2156177623817898e-27,-1475637723558782e-27,-8371015190102975e-28,-2599706096327376e-28,-2382191739347913e-28,-6423305872147834e-28,-9400849094049688e-28,-1122435026096556e-27,-1183840321267481e-27,-1122435026096556e-27,-9400849094049688e-28,-6423305872147841e-28,-2382191739347918e-28]],u=l[o.SHORT_TYPE],h=l[o.SHORT_TYPE],p=l[o.SHORT_TYPE],g=l[o.SHORT_TYPE],x=[0,1,16,17,8,9,24,25,4,5,20,21,12,13,28,29,2,3,18,19,10,11,26,27,6,7,22,23,14,15,30,31];function S(m,$,f){for(var E=10,N=$+238-14-286,B=-15;B<0;B++){var U,C,q;U=a[E+-10],C=m[N+-224]*U,q=m[$+224]*U,U=a[E+-9],C+=m[N+-160]*U,q+=m[$+160]*U,U=a[E+-8],C+=m[N+-96]*U,q+=m[$+96]*U,U=a[E+-7],C+=m[N+-32]*U,q+=m[$+32]*U,U=a[E+-6],C+=m[N+32]*U,q+=m[$+-32]*U,U=a[E+-5],C+=m[N+96]*U,q+=m[$+-96]*U,U=a[E+-4],C+=m[N+160]*U,q+=m[$+-160]*U,U=a[E+-3],C+=m[N+224]*U,q+=m[$+-224]*U,U=a[E+-2],C+=m[$+-256]*U,q-=m[N+256]*U,U=a[E+-1],C+=m[$+-192]*U,q-=m[N+192]*U,U=a[E+0],C+=m[$+-128]*U,q-=m[N+128]*U,U=a[E+1],C+=m[$+-64]*U,q-=m[N+64]*U,U=a[E+2],C+=m[$+0]*U,q-=m[N+0]*U,U=a[E+3],C+=m[$+64]*U,q-=m[N+-64]*U,U=a[E+4],C+=m[$+128]*U,q-=m[N+-128]*U,U=a[E+5],C+=m[$+192]*U,q-=m[N+-192]*U,C*=a[E+6],U=q-C,f[30+B*2]=q+C,f[31+B*2]=a[E+7]*U,E+=18,$--,N++}{var C,q,de,A;q=m[$+-16]*a[E+-10],C=m[$+-32]*a[E+-2],q+=(m[$+-48]-m[$+16])*a[E+-9],C+=m[$+-96]*a[E+-1],q+=(m[$+-80]+m[$+48])*a[E+-8],C+=m[$+-160]*a[E+0],q+=(m[$+-112]-m[$+80])*a[E+-7],C+=m[$+-224]*a[E+1],q+=(m[$+-144]+m[$+112])*a[E+-6],C-=m[$+32]*a[E+2],q+=(m[$+-176]-m[$+144])*a[E+-5],C-=m[$+96]*a[E+3],q+=(m[$+-208]+m[$+176])*a[E+-4],C-=m[$+160]*a[E+4],q+=(m[$+-240]-m[$+208])*a[E+-3],C-=m[$+224],de=C-q,A=C+q,q=f[14],C=f[15]-q,f[31]=A+q,f[30]=de+C,f[15]=de-C,f[14]=A-q}{var b;b=f[28]-f[0],f[0]+=f[28],f[28]=b*a[E+-2*18+7],b=f[29]-f[1],f[1]+=f[29],f[29]=b*a[E+-2*18+7],b=f[26]-f[2],f[2]+=f[26],f[26]=b*a[E+-4*18+7],b=f[27]-f[3],f[3]+=f[27],f[27]=b*a[E+-4*18+7],b=f[24]-f[4],f[4]+=f[24],f[24]=b*a[E+-6*18+7],b=f[25]-f[5],f[5]+=f[25],f[25]=b*a[E+-6*18+7],b=f[22]-f[6],f[6]+=f[22],f[22]=b*r.SQRT2,b=f[23]-f[7],f[7]+=f[23],f[23]=b*r.SQRT2-f[7],f[7]-=f[6],f[22]-=f[7],f[23]-=f[22],b=f[6],f[6]=f[31]-b,f[31]=f[31]+b,b=f[7],f[7]=f[30]-b,f[30]=f[30]+b,b=f[22],f[22]=f[15]-b,f[15]=f[15]+b,b=f[23],f[23]=f[14]-b,f[14]=f[14]+b,b=f[20]-f[8],f[8]+=f[20],f[20]=b*a[E+-10*18+7],b=f[21]-f[9],f[9]+=f[21],f[21]=b*a[E+-10*18+7],b=f[18]-f[10],f[10]+=f[18],f[18]=b*a[E+-12*18+7],b=f[19]-f[11],f[11]+=f[19],f[19]=b*a[E+-12*18+7],b=f[16]-f[12],f[12]+=f[16],f[16]=b*a[E+-14*18+7],b=f[17]-f[13],f[13]+=f[17],f[17]=b*a[E+-14*18+7],b=-f[20]+f[24],f[20]+=f[24],f[24]=b*a[E+-12*18+7],b=-f[21]+f[25],f[21]+=f[25],f[25]=b*a[E+-12*18+7],b=f[4]-f[8],f[4]+=f[8],f[8]=b*a[E+-12*18+7],b=f[5]-f[9],f[5]+=f[9],f[9]=b*a[E+-12*18+7],b=f[0]-f[12],f[0]+=f[12],f[12]=b*a[E+-4*18+7],b=f[1]-f[13],f[1]+=f[13],f[13]=b*a[E+-4*18+7],b=f[16]-f[28],f[16]+=f[28],f[28]=b*a[E+-4*18+7],b=-f[17]+f[29],f[17]+=f[29],f[29]=b*a[E+-4*18+7],b=r.SQRT2*(f[2]-f[10]),f[2]+=f[10],f[10]=b,b=r.SQRT2*(f[3]-f[11]),f[3]+=f[11],f[11]=b,b=r.SQRT2*(-f[18]+f[26]),f[18]+=f[26],f[26]=b-f[18],b=r.SQRT2*(-f[19]+f[27]),f[19]+=f[27],f[27]=b-f[19],b=f[2],f[19]-=f[3],f[3]-=b,f[2]=f[31]-b,f[31]+=b,b=f[3],f[11]-=f[19],f[18]-=b,f[3]=f[30]-b,f[30]+=b,b=f[18],f[27]-=f[11],f[19]-=b,f[18]=f[15]-b,f[15]+=b,b=f[19],f[10]-=b,f[19]=f[14]-b,f[14]+=b,b=f[10],f[11]-=b,f[10]=f[23]-b,f[23]+=b,b=f[11],f[26]-=b,f[11]=f[22]-b,f[22]+=b,b=f[26],f[27]-=b,f[26]=f[7]-b,f[7]+=b,b=f[27],f[27]=f[6]-b,f[6]+=b,b=r.SQRT2*(f[0]-f[4]),f[0]+=f[4],f[4]=b,b=r.SQRT2*(f[1]-f[5]),f[1]+=f[5],f[5]=b,b=r.SQRT2*(f[16]-f[20]),f[16]+=f[20],f[20]=b,b=r.SQRT2*(f[17]-f[21]),f[17]+=f[21],f[21]=b,b=-r.SQRT2*(f[8]-f[12]),f[8]+=f[12],f[12]=b-f[8],b=-r.SQRT2*(f[9]-f[13]),f[9]+=f[13],f[13]=b-f[9],b=-r.SQRT2*(f[25]-f[29]),f[25]+=f[29],f[29]=b-f[25],b=-r.SQRT2*(f[24]+f[28]),f[24]-=f[28],f[28]=b-f[24],b=f[24]-f[16],f[24]=b,b=f[20]-b,f[20]=b,b=f[28]-b,f[28]=b,b=f[25]-f[17],f[25]=b,b=f[21]-b,f[21]=b,b=f[29]-b,f[29]=b,b=f[17]-f[1],f[17]=b,b=f[9]-b,f[9]=b,b=f[25]-b,f[25]=b,b=f[5]-b,f[5]=b,b=f[21]-b,f[21]=b,b=f[13]-b,f[13]=b,b=f[29]-b,f[29]=b,b=f[1]-f[0],f[1]=b,b=f[16]-b,f[16]=b,b=f[17]-b,f[17]=b,b=f[8]-b,f[8]=b,b=f[9]-b,f[9]=b,b=f[24]-b,f[24]=b,b=f[25]-b,f[25]=b,b=f[4]-b,f[4]=b,b=f[5]-b,f[5]=b,b=f[20]-b,f[20]=b,b=f[21]-b,f[21]=b,b=f[12]-b,f[12]=b,b=f[13]-b,f[13]=b,b=f[28]-b,f[28]=b,b=f[29]-b,f[29]=b,b=f[0],f[0]+=f[31],f[31]-=b,b=f[1],f[1]+=f[30],f[30]-=b,b=f[16],f[16]+=f[15],f[15]-=b,b=f[17],f[17]+=f[14],f[14]-=b,b=f[8],f[8]+=f[23],f[23]-=b,b=f[9],f[9]+=f[22],f[22]-=b,b=f[24],f[24]+=f[7],f[7]-=b,b=f[25],f[25]+=f[6],f[6]-=b,b=f[4],f[4]+=f[27],f[27]-=b,b=f[5],f[5]+=f[26],f[26]-=b,b=f[20],f[20]+=f[11],f[11]-=b,b=f[21],f[21]+=f[10],f[10]-=b,b=f[12],f[12]+=f[19],f[19]-=b,b=f[13],f[13]+=f[18],f[18]-=b,b=f[28],f[28]+=f[3],f[3]-=b,b=f[29],f[29]+=f[2],f[2]-=b}}function k(m,$){for(var f=0;f<3;f++){var E,N,B,U,C,q;U=m[$+2*3]*l[o.SHORT_TYPE][0]-m[$+5*3],E=m[$+0*3]*l[o.SHORT_TYPE][2]-m[$+3*3],N=U+E,B=U-E,U=m[$+5*3]*l[o.SHORT_TYPE][0]+m[$+2*3],E=m[$+3*3]*l[o.SHORT_TYPE][2]+m[$+0*3],C=U+E,q=-U+E,E=(m[$+1*3]*l[o.SHORT_TYPE][1]-m[$+4*3])*2069978111953089e-26,U=(m[$+4*3]*l[o.SHORT_TYPE][1]+m[$+1*3])*2069978111953089e-26,m[$+3*0]=N*190752519173728e-25+E,m[$+3*5]=-C*190752519173728e-25+U,B=B*.8660254037844387*1907525191737281e-26,C=C*.5*1907525191737281e-26+U,m[$+3*1]=B-C,m[$+3*2]=B+C,N=N*.5*1907525191737281e-26-E,q=q*.8660254037844387*1907525191737281e-26,m[$+3*3]=N+q,m[$+3*4]=N-q,$++}}function _(m,$,f){var E,N;{var B,U,C,q,de,A,b,D;B=f[17]-f[9],C=f[15]-f[11],q=f[14]-f[12],de=f[0]+f[8],A=f[1]+f[7],b=f[2]+f[6],D=f[3]+f[5],m[$+17]=de+b-D-(A-f[4]),N=(de+b-D)*h[19]+(A-f[4]),E=(B-C-q)*h[18],m[$+5]=E+N,m[$+6]=E-N,U=(f[16]-f[10])*h[18],A=A*h[19]+f[4],E=B*h[12]+U+C*h[13]+q*h[14],N=-de*h[16]+A-b*h[17]+D*h[15],m[$+1]=E+N,m[$+2]=E-N,E=B*h[13]-U-C*h[14]+q*h[12],N=-de*h[17]+A-b*h[15]+D*h[16],m[$+9]=E+N,m[$+10]=E-N,E=B*h[14]-U+C*h[12]-q*h[13],N=de*h[15]-A+b*h[16]-D*h[17],m[$+13]=E+N,m[$+14]=E-N}{var I,Y,V,ee,L,T,y,v;I=f[8]-f[0],V=f[6]-f[2],ee=f[5]-f[3],L=f[17]+f[9],T=f[16]+f[10],y=f[15]+f[11],v=f[14]+f[12],m[$+0]=L+y+v+(T+f[13]),E=(L+y+v)*h[19]-(T+f[13]),N=(I-V+ee)*h[18],m[$+11]=E+N,m[$+12]=E-N,Y=(f[7]-f[1])*h[18],T=f[13]-T*h[19],E=L*h[15]-T+y*h[16]+v*h[17],N=I*h[14]+Y+V*h[12]+ee*h[13],m[$+3]=E+N,m[$+4]=E-N,E=-L*h[17]+T-y*h[15]-v*h[16],N=I*h[13]+Y-V*h[14]-ee*h[12],m[$+7]=E+N,m[$+8]=E-N,E=-L*h[16]+T-y*h[17]-v*h[15],N=I*h[12]-Y+V*h[13]-ee*h[14],m[$+15]=E+N,m[$+16]=E-N}}this.mdct_sub48=function(m,$,f){for(var E=$,N=286,B=0;B<m.channels_out;B++){for(var U=0;U<m.mode_gr;U++){for(var C,q=m.l3_side.tt[U][B],de=q.xr,A=0,b=m.sb_sample[B][1-U],D=0,I=0;I<18/2;I++)for(S(E,N,b[D]),S(E,N+32,b[D+1]),D+=2,N+=64,C=1;C<32;C+=2)b[D-1][C]*=-1;for(C=0;C<32;C++,A+=18){var Y=q.block_type,V=m.sb_sample[B][U],ee=m.sb_sample[B][1-U];if(q.mixed_block_flag!=0&&C<2&&(Y=0),m.amp_filter[C]<1e-12)n.fill(de,A+0,A+18,0);else{if(m.amp_filter[C]<1)for(var I=0;I<18;I++)ee[I][x[C]]*=m.amp_filter[C];if(Y==o.SHORT_TYPE){for(var I=-c/4;I<0;I++){var L=l[o.SHORT_TYPE][I+3];de[A+I*3+9]=V[9+I][x[C]]*L-V[8-I][x[C]],de[A+I*3+18]=V[14-I][x[C]]*L+V[15+I][x[C]],de[A+I*3+10]=V[15+I][x[C]]*L-V[14-I][x[C]],de[A+I*3+19]=ee[2-I][x[C]]*L+ee[3+I][x[C]],de[A+I*3+11]=ee[3+I][x[C]]*L-ee[2-I][x[C]],de[A+I*3+20]=ee[8-I][x[C]]*L+ee[9+I][x[C]]}k(de,A)}else{for(var T=s(18),I=-d/4;I<0;I++){var y,v;y=l[Y][I+27]*ee[I+9][x[C]]+l[Y][I+36]*ee[8-I][x[C]],v=l[Y][I+9]*V[I+9][x[C]]-l[Y][I+18]*V[8-I][x[C]],T[I+9]=y-v*u[3+I+9],T[I+18]=y*u[3+I+9]+v}_(de,A,T)}}if(Y!=o.SHORT_TYPE&&C!=0)for(var I=7;I>=0;--I){var R,O;R=de[A+I]*p[20+I]+de[A+-1-I]*g[28+I],O=de[A+I]*g[28+I]-de[A+-1-I]*p[20+I],de[A+-1-I]=R,de[A+I]=O}}}if(E=f,N=286,m.mode_gr==1)for(var K=0;K<18;K++)e.arraycopy(m.sb_sample[B][1][K],0,m.sb_sample[B][0][K],0,32)}}}return Um=i,Um}var Gm,Sw;function o3(){if(Sw)return Gm;Sw=1;var t=hr(),e=Zt,r=e.System,n=e.new_float,s=e.new_float_n;function o(){this.l=n(t.SBMAX_l),this.s=s([t.SBMAX_s,3]);var i=this;this.assign=function(a){r.arraycopy(a.l,0,i.l,0,t.SBMAX_l);for(var c=0;c<t.SBMAX_s;c++)for(var d=0;d<3;d++)i.s[c][d]=a.s[c][d]}}return Gm=o,Gm}var Ym,Ew;function wz(){if(Ew)return Ym;Ew=1;var t=o3();function e(){this.thm=new t,this.en=new t}return Ym=e,Ym}function xn(t){var e=t;this.ordinal=function(){return e}}xn.STEREO=new xn(0);xn.JOINT_STEREO=new xn(1);xn.DUAL_CHANNEL=new xn(2);xn.MONO=new xn(3);xn.NOT_SET=new xn(4);var Da=xn,Xm,Tw;function hr(){if(Tw)return Xm;Tw=1;var t=Zt,e=t.System,r=t.VbrMode,n=t.new_array_n,s=t.new_float,o=t.new_float_n,i=t.new_int,a=t.assert;c.ENCDELAY=576,c.POSTDELAY=1152,c.MDCTDELAY=48,c.FFTOFFSET=224+c.MDCTDELAY,c.DECDELAY=528,c.SBLIMIT=32,c.CBANDS=64,c.SBPSY_l=21,c.SBPSY_s=12,c.SBMAX_l=22,c.SBMAX_s=13,c.PSFB21=6,c.PSFB12=6,c.BLKSIZE=1024,c.HBLKSIZE=c.BLKSIZE/2+1,c.BLKSIZE_s=256,c.HBLKSIZE_s=c.BLKSIZE_s/2+1,c.NORM_TYPE=0,c.START_TYPE=1,c.SHORT_TYPE=2,c.STOP_TYPE=3,c.MPG_MD_LR_LR=0,c.MPG_MD_LR_I=1,c.MPG_MD_MS_LR=2,c.MPG_MD_MS_I=3,c.fircoef=[-.0207887*5,-.0378413*5,-.0432472*5,-.031183*5,779609e-23*5,.0467745*5,.10091*5,.151365*5,.187098*5];function c(){var d=vz(),l=wz(),u=Da,h=c.FFTOFFSET,p=c.MPG_MD_MS_LR,g=null;this.psy=null;var x=null,S=null,k=null;this.setModules=function(E,N,B,U){g=E,this.psy=N,x=N,S=U,k=B};var _=new d;function m(E){var N,B;if(E.ATH.useAdjust==0){E.ATH.adjust=1;return}if(B=E.loudness_sq[0][0],N=E.loudness_sq[1][0],E.channels_out==2?(B+=E.loudness_sq[0][1],N+=E.loudness_sq[1][1]):(B+=B,N+=N),E.mode_gr==2&&(B=Math.max(B,N)),B*=.5,B*=E.ATH.aaSensitivityP,B>.03125)E.ATH.adjust>=1?E.ATH.adjust=1:E.ATH.adjust<E.ATH.adjustLimit&&(E.ATH.adjust=E.ATH.adjustLimit),E.ATH.adjustLimit=1;else{var U=31.98*B+625e-6;E.ATH.adjust>=U?(E.ATH.adjust*=U*.075+.925,E.ATH.adjust<U&&(E.ATH.adjust=U)):E.ATH.adjustLimit>=U?E.ATH.adjust=U:E.ATH.adjust<E.ATH.adjustLimit&&(E.ATH.adjust=E.ATH.adjustLimit),E.ATH.adjustLimit=U}}function $(E){var N,B;for(a(0<=E.bitrate_index&&E.bitrate_index<16),a(0<=E.mode_ext&&E.mode_ext<4),E.bitrate_stereoMode_Hist[E.bitrate_index][4]++,E.bitrate_stereoMode_Hist[15][4]++,E.channels_out==2&&(E.bitrate_stereoMode_Hist[E.bitrate_index][E.mode_ext]++,E.bitrate_stereoMode_Hist[15][E.mode_ext]++),N=0;N<E.mode_gr;++N)for(B=0;B<E.channels_out;++B){var U=E.l3_side.tt[N][B].block_type|0;E.l3_side.tt[N][B].mixed_block_flag!=0&&(U=4),E.bitrate_blockType_Hist[E.bitrate_index][U]++,E.bitrate_blockType_Hist[E.bitrate_index][5]++,E.bitrate_blockType_Hist[15][U]++,E.bitrate_blockType_Hist[15][5]++}}function f(E,N){var B=E.internal_flags,U,C;if(B.lame_encode_frame_init==0){var q,de,A=s(2014),b=s(2014);for(B.lame_encode_frame_init=1,q=0,de=0;q<286+576*(1+B.mode_gr);++q)q<576*B.mode_gr?(A[q]=0,B.channels_out==2&&(b[q]=0)):(A[q]=N[0][de],B.channels_out==2&&(b[q]=N[1][de]),++de);for(C=0;C<B.mode_gr;C++)for(U=0;U<B.channels_out;U++)B.l3_side.tt[C][U].block_type=c.SHORT_TYPE;_.mdct_sub48(B,A,b),a(576>=c.FFTOFFSET),a(B.mf_size>=c.BLKSIZE+E.framesize-c.FFTOFFSET),a(B.mf_size>=512+E.framesize-32)}}this.lame_encode_mp3_frame=function(E,N,B,U,C,q){var de,A=n([2,2]);A[0][0]=new l,A[0][1]=new l,A[1][0]=new l,A[1][1]=new l;var b=n([2,2]);b[0][0]=new l,b[0][1]=new l,b[1][0]=new l,b[1][1]=new l;var D,I=[null,null],Y=E.internal_flags,V=o([2,4]),ee=[.5,.5],L=[[0,0],[0,0]],T=[[0,0],[0,0]],y,v,R;if(I[0]=N,I[1]=B,Y.lame_encode_frame_init==0&&f(E,I),Y.padding=0,(Y.slot_lag-=Y.frac_SpF)<0&&(Y.slot_lag+=E.out_samplerate,Y.padding=1),Y.psymodel!=0){var O,K=[null,null],se=0,F=i(2);for(R=0;R<Y.mode_gr;R++){for(v=0;v<Y.channels_out;v++)K[v]=I[v],se=576+R*576-c.FFTOFFSET;if(E.VBR==r.vbr_mtrh||E.VBR==r.vbr_mt?O=x.L3psycho_anal_vbr(E,K,se,R,A,b,L[R],T[R],V[R],F):O=x.L3psycho_anal_ns(E,K,se,R,A,b,L[R],T[R],V[R],F),O!=0)return-4;for(E.mode==u.JOINT_STEREO&&(ee[R]=V[R][2]+V[R][3],ee[R]>0&&(ee[R]=V[R][3]/ee[R])),v=0;v<Y.channels_out;v++){var Q=Y.l3_side.tt[R][v];Q.block_type=F[v],Q.mixed_block_flag=0}}}else for(R=0;R<Y.mode_gr;R++)for(v=0;v<Y.channels_out;v++)Y.l3_side.tt[R][v].block_type=c.NORM_TYPE,Y.l3_side.tt[R][v].mixed_block_flag=0,T[R][v]=L[R][v]=700;if(m(Y),_.mdct_sub48(Y,I[0],I[1]),Y.mode_ext=c.MPG_MD_LR_LR,E.force_ms)Y.mode_ext=c.MPG_MD_MS_LR;else if(E.mode==u.JOINT_STEREO){var ue=0,ge=0;for(R=0;R<Y.mode_gr;R++)for(v=0;v<Y.channels_out;v++)ue+=T[R][v],ge+=L[R][v];if(ue<=1*ge){var ke=Y.l3_side.tt[0],Re=Y.l3_side.tt[Y.mode_gr-1];ke[0].block_type==ke[1].block_type&&Re[0].block_type==Re[1].block_type&&(Y.mode_ext=c.MPG_MD_MS_LR)}}if(Y.mode_ext==p?(D=b,y=T):(D=A,y=L),E.analysis&&Y.pinfo!=null)for(R=0;R<Y.mode_gr;R++)for(v=0;v<Y.channels_out;v++)Y.pinfo.ms_ratio[R]=Y.ms_ratio[R],Y.pinfo.ms_ener_ratio[R]=ee[R],Y.pinfo.blocktype[R][v]=Y.l3_side.tt[R][v].block_type,Y.pinfo.pe[R][v]=y[R][v],e.arraycopy(Y.l3_side.tt[R][v].xr,0,Y.pinfo.xr[R][v],0,576),Y.mode_ext==p&&(Y.pinfo.ers[R][v]=Y.pinfo.ers[R][v+2],e.arraycopy(Y.pinfo.energy[R][v+2],0,Y.pinfo.energy[R][v],0,Y.pinfo.energy[R][v].length));if(E.VBR==r.vbr_off||E.VBR==r.vbr_abr){var Te,Se;for(Te=0;Te<18;Te++)Y.nsPsy.pefirbuf[Te]=Y.nsPsy.pefirbuf[Te+1];for(Se=0,R=0;R<Y.mode_gr;R++)for(v=0;v<Y.channels_out;v++)Se+=y[R][v];for(Y.nsPsy.pefirbuf[18]=Se,Se=Y.nsPsy.pefirbuf[9],Te=0;Te<9;Te++)Se+=(Y.nsPsy.pefirbuf[Te]+Y.nsPsy.pefirbuf[18-Te])*c.fircoef[Te];for(Se=670*5*Y.mode_gr*Y.channels_out/Se,R=0;R<Y.mode_gr;R++)for(v=0;v<Y.channels_out;v++)y[R][v]*=Se}if(Y.iteration_loop.iteration_loop(E,y,ee,D),g.format_bitstream(E),de=g.copy_buffer(Y,U,C,q,1),E.bWriteVbrTag&&S.addVbrFrame(E),E.analysis&&Y.pinfo!=null){for(v=0;v<Y.channels_out;v++){var Ce;for(Ce=0;Ce<h;Ce++)Y.pinfo.pcmdata[v][Ce]=Y.pinfo.pcmdata[v][Ce+E.framesize];for(Ce=h;Ce<1600;Ce++)Y.pinfo.pcmdata[v][Ce]=I[v][Ce-h]}k.set_frame_pinfo(E,D)}return $(Y),de}}return Xm=c,Xm}var i3=Zt,$w=i3.Util,Rw=i3.new_float,Ut=hr();function xz(){var t=Rw(Ut.BLKSIZE),e=Rw(Ut.BLKSIZE_s/2),r=[.9238795325112867,.3826834323650898,.9951847266721969,.0980171403295606,.9996988186962042,.02454122852291229,.9999811752826011,.006135884649154475];function n(o,i,a){var c=0,d,l,u;a<<=1;var h=i+a;d=4;do{var p,g,x,S,k,_,m;m=d>>1,S=d,k=d<<1,_=k+S,d=k<<1,l=i,u=l+m;do{var $,f,E,N;f=o[l+0]-o[l+S],$=o[l+0]+o[l+S],N=o[l+k]-o[l+_],E=o[l+k]+o[l+_],o[l+k]=$-E,o[l+0]=$+E,o[l+_]=f-N,o[l+S]=f+N,f=o[u+0]-o[u+S],$=o[u+0]+o[u+S],N=$w.SQRT2*o[u+_],E=$w.SQRT2*o[u+k],o[u+k]=$-E,o[u+0]=$+E,o[u+_]=f-N,o[u+S]=f+N,u+=d,l+=d}while(l<h);for(g=r[c+0],p=r[c+1],x=1;x<m;x++){var B,U;B=1-2*p*p,U=2*p*g,l=i+x,u=i+S-x;do{var C,q,de,$,f,A,E,b,N,D;q=U*o[l+S]-B*o[u+S],C=B*o[l+S]+U*o[u+S],f=o[l+0]-C,$=o[l+0]+C,A=o[u+0]-q,de=o[u+0]+q,q=U*o[l+_]-B*o[u+_],C=B*o[l+_]+U*o[u+_],N=o[l+k]-C,E=o[l+k]+C,D=o[u+k]-q,b=o[u+k]+q,q=p*E-g*D,C=g*E+p*D,o[l+k]=$-C,o[l+0]=$+C,o[u+_]=A-q,o[u+S]=A+q,q=g*b-p*N,C=p*b+g*N,o[u+k]=de-C,o[u+0]=de+C,o[l+_]=f-q,o[l+S]=f+q,u+=d,l+=d}while(l<h);B=g,g=B*r[c+0]-p*r[c+1],p=B*r[c+1]+p*r[c+0]}c+=2}while(d<a)}var s=[0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240,8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248,4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244,12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254];this.fft_short=function(o,i,a,c,d){for(var l=0;l<3;l++){var u=Ut.BLKSIZE_s/2,h=65535&576/3*(l+1),p=Ut.BLKSIZE_s/8-1;do{var g,x,S,k,_,m=s[p<<2]&255;g=e[m]*c[a][d+m+h],_=e[127-m]*c[a][d+m+h+128],x=g-_,g=g+_,S=e[m+64]*c[a][d+m+h+64],_=e[63-m]*c[a][d+m+h+192],k=S-_,S=S+_,u-=4,i[l][u+0]=g+S,i[l][u+2]=g-S,i[l][u+1]=x+k,i[l][u+3]=x-k,g=e[m+1]*c[a][d+m+h+1],_=e[126-m]*c[a][d+m+h+129],x=g-_,g=g+_,S=e[m+65]*c[a][d+m+h+65],_=e[62-m]*c[a][d+m+h+193],k=S-_,S=S+_,i[l][u+Ut.BLKSIZE_s/2+0]=g+S,i[l][u+Ut.BLKSIZE_s/2+2]=g-S,i[l][u+Ut.BLKSIZE_s/2+1]=x+k,i[l][u+Ut.BLKSIZE_s/2+3]=x-k}while(--p>=0);n(i[l],u,Ut.BLKSIZE_s/2)}},this.fft_long=function(o,i,a,c,d){var l=Ut.BLKSIZE/8-1,u=Ut.BLKSIZE/2;do{var h,p,g,x,S,k=s[l]&255;h=t[k]*c[a][d+k],S=t[k+512]*c[a][d+k+512],p=h-S,h=h+S,g=t[k+256]*c[a][d+k+256],S=t[k+768]*c[a][d+k+768],x=g-S,g=g+S,u-=4,i[u+0]=h+g,i[u+2]=h-g,i[u+1]=p+x,i[u+3]=p-x,h=t[k+1]*c[a][d+k+1],S=t[k+513]*c[a][d+k+513],p=h-S,h=h+S,g=t[k+257]*c[a][d+k+257],S=t[k+769]*c[a][d+k+769],x=g-S,g=g+S,i[u+Ut.BLKSIZE/2+0]=h+g,i[u+Ut.BLKSIZE/2+2]=h-g,i[u+Ut.BLKSIZE/2+1]=p+x,i[u+Ut.BLKSIZE/2+3]=p-x}while(--l>=0);n(i,u,Ut.BLKSIZE/2)},this.init_fft=function(o){for(var i=0;i<Ut.BLKSIZE;i++)t[i]=.42-.5*Math.cos(2*Math.PI*(i+.5)/Ut.BLKSIZE)+.08*Math.cos(4*Math.PI*(i+.5)/Ut.BLKSIZE);for(var i=0;i<Ut.BLKSIZE_s/2;i++)e[i]=.5*(1-Math.cos(2*Math.PI*(i+.5)/Ut.BLKSIZE_s))}}var kz=xz,Un=Zt,ci=Un.VbrMode,Pw=Un.Float,li=Un.ShortBlock,Mr=Un.Util,Sz=Un.Arrays,Gt=Un.new_float,nn=Un.new_float_n,lo=Un.new_int,Qe=Un.assert,Ez=kz,ae=hr();function Tz(){var t=Da,e=new Ez,r=2.302585092994046,n=2,s=16,o=2,i=16,a=.34,c=1/(14752*14752)/(ae.BLKSIZE/2),d=.01,l=.8,u=.6,h=.3,p=3.5,g=21,x=.2302585093;function S(M){return M}function k(M,z){for(var Z=0,H=0;H<ae.BLKSIZE/2;++H)Z+=M[H]*z.ATH.eql_w[H];return Z*=c,Z}function _(M,z,Z,H,J,j,X,te,W,oe,re){var ie=M.internal_flags;if(W<2)e.fft_long(ie,H[J],W,oe,re),e.fft_short(ie,j[X],W,oe,re);else if(W==2){for(var ye=ae.BLKSIZE-1;ye>=0;--ye){var Be=H[J+0][ye],fe=H[J+1][ye];H[J+0][ye]=(Be+fe)*Mr.SQRT2*.5,H[J+1][ye]=(Be-fe)*Mr.SQRT2*.5}for(var De=2;De>=0;--De)for(var ye=ae.BLKSIZE_s-1;ye>=0;--ye){var Be=j[X+0][De][ye],fe=j[X+1][De][ye];j[X+0][De][ye]=(Be+fe)*Mr.SQRT2*.5,j[X+1][De][ye]=(Be-fe)*Mr.SQRT2*.5}}z[0]=H[J+0][0],z[0]*=z[0];for(var ye=ae.BLKSIZE/2-1;ye>=0;--ye){var ne=H[J+0][ae.BLKSIZE/2-ye],$e=H[J+0][ae.BLKSIZE/2+ye];z[ae.BLKSIZE/2-ye]=(ne*ne+$e*$e)*.5}for(var De=2;De>=0;--De){Z[De][0]=j[X+0][De][0],Z[De][0]*=Z[De][0];for(var ye=ae.BLKSIZE_s/2-1;ye>=0;--ye){var ne=j[X+0][De][ae.BLKSIZE_s/2-ye],$e=j[X+0][De][ae.BLKSIZE_s/2+ye];Z[De][ae.BLKSIZE_s/2-ye]=(ne*ne+$e*$e)*.5}}{for(var tt=0,ye=11;ye<ae.HBLKSIZE;ye++)tt+=z[ye];ie.tot_ener[W]=tt}if(M.analysis){for(var ye=0;ye<ae.HBLKSIZE;ye++)ie.pinfo.energy[te][W][ye]=ie.pinfo.energy_save[W][ye],ie.pinfo.energy_save[W][ye]=z[ye];ie.pinfo.pe[te][W]=ie.pe[W]}M.athaa_loudapprox==2&&W<2&&(ie.loudness_sq[te][W]=ie.loudness_sq_save[W],ie.loudness_sq_save[W]=k(z,ie))}var m=8,$=23,f=15,E,N,B,U=[1,.79433,.63096,.63096,.63096,.63096,.63096,.25119,.11749];function C(){E=Math.pow(10,(m+1)/16),N=Math.pow(10,($+1)/16),B=Math.pow(10,f/10)}var q=[3.3246*3.3246,3.23837*3.23837,3.15437*3.15437,3.00412*3.00412,2.86103*2.86103,2.65407*2.65407,2.46209*2.46209,2.284*2.284,2.11879*2.11879,1.96552*1.96552,1.82335*1.82335,1.69146*1.69146,1.56911*1.56911,1.46658*1.46658,1.37074*1.37074,1.31036*1.31036,1.25264*1.25264,1.20648*1.20648,1.16203*1.16203,1.12765*1.12765,1.09428*1.09428,1.0659*1.0659,1.03826*1.03826,1.01895*1.01895,1],de=[1.33352*1.33352,1.35879*1.35879,1.38454*1.38454,1.39497*1.39497,1.40548*1.40548,1.3537*1.3537,1.30382*1.30382,1.22321*1.22321,1.14758*1.14758,1],A=[2.35364*2.35364,2.29259*2.29259,2.23313*2.23313,2.12675*2.12675,2.02545*2.02545,1.87894*1.87894,1.74303*1.74303,1.61695*1.61695,1.49999*1.49999,1.39148*1.39148,1.29083*1.29083,1.19746*1.19746,1.11084*1.11084,1.03826*1.03826];function b(M,z,Z,H,J,j){var X;if(z>M)if(z<M*N)X=z/M;else return M+z;else{if(M>=z*N)return M+z;X=M/z}if(M+=z,H+3<=6){if(X>=E)return M;var te=0|Mr.FAST_LOG10_X(X,16);return M*de[te]}var te=0|Mr.FAST_LOG10_X(X,16);if(j!=0?z=J.ATH.cb_s[Z]*J.ATH.adjust:z=J.ATH.cb_l[Z]*J.ATH.adjust,M<B*z){if(M>z){var W,oe;return W=1,te<=13&&(W=A[te]),oe=Mr.FAST_LOG10_X(M/z,10/15),M*((q[te]-W)*oe+W)}return te>13?M:M*A[te]}return M*q[te]}var D=[1.33352*1.33352,1.35879*1.35879,1.38454*1.38454,1.39497*1.39497,1.40548*1.40548,1.3537*1.3537,1.30382*1.30382,1.22321*1.22321,1.14758*1.14758,1];function I(M,z,Z){var H;if(M<0&&(M=0),z<0&&(z=0),M<=0)return z;if(z<=0)return M;if(z>M?H=z/M:H=M/z,-2<=Z&&Z<=2){if(H>=E)return M+z;var J=0|Mr.FAST_LOG10_X(H,16);return(M+z)*D[J]}return H<N?M+z:(M<z&&(M=z),M)}function Y(M,z){var Z=M.internal_flags;if(Z.channels_out>1){for(var H=0;H<ae.SBMAX_l;H++){var J=Z.thm[0].l[H],j=Z.thm[1].l[H];Z.thm[0].l[H]+=j*z,Z.thm[1].l[H]+=J*z}for(var H=0;H<ae.SBMAX_s;H++)for(var X=0;X<3;X++){var J=Z.thm[0].s[H][X],j=Z.thm[1].s[H][X];Z.thm[0].s[H][X]+=j*z,Z.thm[1].s[H][X]+=J*z}}}function V(M){for(var z=0;z<ae.SBMAX_l;z++)if(!(M.thm[0].l[z]>1.58*M.thm[1].l[z]||M.thm[1].l[z]>1.58*M.thm[0].l[z])){var Z=M.mld_l[z]*M.en[3].l[z],H=Math.max(M.thm[2].l[z],Math.min(M.thm[3].l[z],Z));Z=M.mld_l[z]*M.en[2].l[z];var J=Math.max(M.thm[3].l[z],Math.min(M.thm[2].l[z],Z));M.thm[2].l[z]=H,M.thm[3].l[z]=J}for(var z=0;z<ae.SBMAX_s;z++)for(var j=0;j<3;j++)if(!(M.thm[0].s[z][j]>1.58*M.thm[1].s[z][j]||M.thm[1].s[z][j]>1.58*M.thm[0].s[z][j])){var Z=M.mld_s[z]*M.en[3].s[z][j],H=Math.max(M.thm[2].s[z][j],Math.min(M.thm[3].s[z][j],Z));Z=M.mld_s[z]*M.en[2].s[z][j];var J=Math.max(M.thm[3].s[z][j],Math.min(M.thm[2].s[z][j],Z));M.thm[2].s[z][j]=H,M.thm[3].s[z][j]=J}}function ee(M,z,Z){var H=z,J=Math.pow(10,Z);z*=2,H*=2;for(var j=0;j<ae.SBMAX_l;j++){var X,te,W,oe;if(oe=M.ATH.cb_l[M.bm_l[j]]*J,X=Math.min(Math.max(M.thm[0].l[j],oe),Math.max(M.thm[1].l[j],oe)),te=Math.max(M.thm[2].l[j],oe),W=Math.max(M.thm[3].l[j],oe),X*z<te+W){var re=X*H/(te+W);te*=re,W*=re}M.thm[2].l[j]=Math.min(te,M.thm[2].l[j]),M.thm[3].l[j]=Math.min(W,M.thm[3].l[j])}J*=ae.BLKSIZE_s/ae.BLKSIZE;for(var j=0;j<ae.SBMAX_s;j++)for(var ie=0;ie<3;ie++){var X,te,W,oe;if(oe=M.ATH.cb_s[M.bm_s[j]]*J,X=Math.min(Math.max(M.thm[0].s[j][ie],oe),Math.max(M.thm[1].s[j][ie],oe)),te=Math.max(M.thm[2].s[j][ie],oe),W=Math.max(M.thm[3].s[j][ie],oe),X*z<te+W){var re=X*z/(te+W);te*=re,W*=re}M.thm[2].s[j][ie]=Math.min(M.thm[2].s[j][ie],te),M.thm[3].s[j][ie]=Math.min(M.thm[3].s[j][ie],W)}}function L(M,z,Z,H,J){var j,X,te=0,W=0;for(j=X=0;j<ae.SBMAX_s;++X,++j){for(var oe=M.bo_s[j],re=M.npart_s,ie=oe<re?oe:re;X<ie;)Qe(z[X]>=0),Qe(Z[X]>=0),te+=z[X],W+=Z[X],X++;if(M.en[H].s[j][J]=te,M.thm[H].s[j][J]=W,X>=re){++j;break}Qe(z[X]>=0),Qe(Z[X]>=0);{var ye=M.PSY.bo_s_weight[j],Be=1-ye;te=ye*z[X],W=ye*Z[X],M.en[H].s[j][J]+=te,M.thm[H].s[j][J]+=W,te=Be*z[X],W=Be*Z[X]}}for(;j<ae.SBMAX_s;++j)M.en[H].s[j][J]=0,M.thm[H].s[j][J]=0}function T(M,z,Z,H){var J,j,X=0,te=0;for(J=j=0;J<ae.SBMAX_l;++j,++J){for(var W=M.bo_l[J],oe=M.npart_l,re=W<oe?W:oe;j<re;)Qe(z[j]>=0),Qe(Z[j]>=0),X+=z[j],te+=Z[j],j++;if(M.en[H].l[J]=X,M.thm[H].l[J]=te,j>=oe){++J;break}Qe(z[j]>=0),Qe(Z[j]>=0);{var ie=M.PSY.bo_l_weight[J],ye=1-ie;X=ie*z[j],te=ie*Z[j],M.en[H].l[J]+=X,M.thm[H].l[J]+=te,X=ye*z[j],te=ye*Z[j]}}for(;J<ae.SBMAX_l;++J)M.en[H].l[J]=0,M.thm[H].l[J]=0}function y(M,z,Z,H,J,j){var X=M.internal_flags,te,W;for(W=te=0;W<X.npart_s;++W){for(var oe=0,re=X.numlines_s[W],ie=0;ie<re;++ie,++te){var ye=z[j][te];oe+=ye}Z[W]=oe}for(Qe(W==X.npart_s),te=W=0;W<X.npart_s;W++){var Be=X.s3ind_s[W][0],fe=X.s3_ss[te++]*Z[Be];for(++Be;Be<=X.s3ind_s[W][1];)fe+=X.s3_ss[te]*Z[Be],++te,++Be;{var De=o*X.nb_s1[J][W];H[W]=Math.min(fe,De)}if(X.blocktype_old[J&1]==ae.SHORT_TYPE){var De=i*X.nb_s2[J][W],ne=H[W];H[W]=Math.min(De,ne)}X.nb_s2[J][W]=X.nb_s1[J][W],X.nb_s1[J][W]=fe,Qe(H[W]>=0)}for(;W<=ae.CBANDS;++W)Z[W]=0,H[W]=0}function v(M,z,Z,H){var J=M.internal_flags;M.short_blocks==li.short_block_coupled&&!(z[0]!=0&&z[1]!=0)&&(z[0]=z[1]=0);for(var j=0;j<J.channels_out;j++)H[j]=ae.NORM_TYPE,M.short_blocks==li.short_block_dispensed&&(z[j]=1),M.short_blocks==li.short_block_forced&&(z[j]=0),z[j]!=0?(Qe(J.blocktype_old[j]!=ae.START_TYPE),J.blocktype_old[j]==ae.SHORT_TYPE&&(H[j]=ae.STOP_TYPE)):(H[j]=ae.SHORT_TYPE,J.blocktype_old[j]==ae.NORM_TYPE&&(J.blocktype_old[j]=ae.START_TYPE),J.blocktype_old[j]==ae.STOP_TYPE&&(J.blocktype_old[j]=ae.SHORT_TYPE)),Z[j]=J.blocktype_old[j],J.blocktype_old[j]=H[j]}function R(M,z,Z){return Z>=1?M:Z<=0?z:z>0?Math.pow(M/z,Z)*z:0}var O=[11.8,13.6,17.2,32,46.5,51.3,57.5,67.1,71.5,84.6,97.6,130];function K(M,z){for(var Z=309.07,H=0;H<ae.SBMAX_s-1;H++)for(var J=0;J<3;J++){var j=M.thm.s[H][J];if(j>0){var X=j*z,te=M.en.s[H][J];te>X&&(te>X*1e10?Z+=O[H]*(10*r):Z+=O[H]*Mr.FAST_LOG10(te/X))}}return Z}var se=[6.8,5.8,5.8,6.4,6.5,9.9,12.1,14.4,15,18.9,21.6,26.9,34.2,40.2,46.8,56.5,60.7,73.9,85.7,93.4,126.1];function F(M,z){for(var Z=281.0575,H=0;H<ae.SBMAX_l-1;H++){var J=M.thm.l[H];if(J>0){var j=J*z,X=M.en.l[H];X>j&&(X>j*1e10?Z+=se[H]*(10*r):Z+=se[H]*Mr.FAST_LOG10(X/j))}}return Z}function Q(M,z,Z,H,J){var j,X;for(j=X=0;j<M.npart_l;++j){var te=0,W=0,oe;for(oe=0;oe<M.numlines_l[j];++oe,++X){var re=z[X];te+=re,W<re&&(W=re)}Z[j]=te,H[j]=W,J[j]=te*M.rnumlines_l[j],Qe(M.rnumlines_l[j]>=0),Qe(Z[j]>=0),Qe(H[j]>=0),Qe(J[j]>=0)}}function ue(M,z,Z,H){var J=U.length-1,j=0,X=Z[j]+Z[j+1];if(X>0){var te=z[j];te<z[j+1]&&(te=z[j+1]),Qe(M.numlines_l[j]+M.numlines_l[j+1]-1>0),X=20*(te*2-X)/(X*(M.numlines_l[j]+M.numlines_l[j+1]-1));var W=0|X;W>J&&(W=J),H[j]=W}else H[j]=0;for(j=1;j<M.npart_l-1;j++)if(X=Z[j-1]+Z[j]+Z[j+1],X>0){var te=z[j-1];te<z[j]&&(te=z[j]),te<z[j+1]&&(te=z[j+1]),Qe(M.numlines_l[j-1]+M.numlines_l[j]+M.numlines_l[j+1]-1>0),X=20*(te*3-X)/(X*(M.numlines_l[j-1]+M.numlines_l[j]+M.numlines_l[j+1]-1));var W=0|X;W>J&&(W=J),H[j]=W}else H[j]=0;if(Qe(j==M.npart_l-1),X=Z[j-1]+Z[j],X>0){var te=z[j-1];te<z[j]&&(te=z[j]),Qe(M.numlines_l[j-1]+M.numlines_l[j]-1>0),X=20*(te*2-X)/(X*(M.numlines_l[j-1]+M.numlines_l[j]-1));var W=0|X;W>J&&(W=J),H[j]=W}else H[j]=0;Qe(j==M.npart_l-1)}var ge=[-865163e-23*2,-.00851586*2,-674764e-23*2,.0209036*2,-336639e-22*2,-.0438162*2,-154175e-22*2,.0931738*2,-552212e-22*2,-.313819*2];this.L3psycho_anal_ns=function(M,z,Z,H,J,j,X,te,W,oe){var re=M.internal_flags,ie=nn([2,ae.BLKSIZE]),ye=nn([2,3,ae.BLKSIZE_s]),Be=Gt(ae.CBANDS+1),fe=Gt(ae.CBANDS+1),De=Gt(ae.CBANDS+2),ne=lo(2),$e=lo(2),tt,he,Me,pe,qe,Tt,we,Ke,rt=nn([2,576]),Ot,Or=lo(ae.CBANDS+2),Ft=lo(ae.CBANDS+2);for(Sz.fill(Ft,0),tt=re.channels_out,M.mode==t.JOINT_STEREO&&(tt=4),M.VBR==ci.vbr_off?Ot=re.ResvMax==0?0:re.ResvSize/re.ResvMax*.5:M.VBR==ci.vbr_rh||M.VBR==ci.vbr_mtrh||M.VBR==ci.vbr_mt?Ot=.6:Ot=1,he=0;he<re.channels_out;he++){var At=z[he],yr=Z+576-350-g+192;for(pe=0;pe<576;pe++){var Ar,Nr;for(Ar=At[yr+pe+10],Nr=0,qe=0;qe<(g-1)/2-1;qe+=2)Ar+=ge[qe]*(At[yr+pe+qe]+At[yr+pe+g-qe]),Nr+=ge[qe+1]*(At[yr+pe+qe+1]+At[yr+pe+g-qe-1]);rt[he][pe]=Ar+Nr}J[H][he].en.assign(re.en[he]),J[H][he].thm.assign(re.thm[he]),tt>2&&(j[H][he].en.assign(re.en[he+2]),j[H][he].thm.assign(re.thm[he+2]))}for(he=0;he<tt;he++){var an,cn,ar=Gt(12),kn=[0,0,0,0],go=Gt(12),fu=1,v1,w1=Gt(ae.CBANDS),x1=Gt(ae.CBANDS),Nt=[0,0,0,0],k1=Gt(ae.HBLKSIZE),S1=nn([3,ae.HBLKSIZE_s]);for(Qe(re.npart_s<=ae.CBANDS),Qe(re.npart_l<=ae.CBANDS),pe=0;pe<3;pe++)ar[pe]=re.nsPsy.last_en_subshort[he][pe+6],Qe(re.nsPsy.last_en_subshort[he][pe+4]>0),go[pe]=ar[pe]/re.nsPsy.last_en_subshort[he][pe+4],kn[0]+=ar[pe];if(he==2)for(pe=0;pe<576;pe++){var hu,pu;hu=rt[0][pe],pu=rt[1][pe],rt[0][pe]=hu+pu,rt[1][pe]=hu-pu}{var E1=rt[he&1],gi=0;for(pe=0;pe<9;pe++){for(var H3=gi+64,Qt=1;gi<H3;gi++)Qt<Math.abs(E1[gi])&&(Qt=Math.abs(E1[gi]));re.nsPsy.last_en_subshort[he][pe]=ar[pe+3]=Qt,kn[1+pe/3]+=Qt,Qt>ar[pe+3-2]?(Qe(ar[pe+3-2]>0),Qt=Qt/ar[pe+3-2]):ar[pe+3-2]>Qt*10?Qt=ar[pe+3-2]/(Qt*10):Qt=0,go[pe+3]=Qt}}if(M.analysis){var mu=go[0];for(pe=1;pe<12;pe++)mu<go[pe]&&(mu=go[pe]);re.pinfo.ers[H][he]=re.pinfo.ers_save[he],re.pinfo.ers_save[he]=mu}for(v1=he==3?re.nsPsy.attackthre_s:re.nsPsy.attackthre,pe=0;pe<12;pe++)Nt[pe/3]==0&&go[pe]>v1&&(Nt[pe/3]=pe%3+1);for(pe=1;pe<4;pe++){var gu;kn[pe-1]>kn[pe]?(Qe(kn[pe]>0),gu=kn[pe-1]/kn[pe]):(Qe(kn[pe-1]>0),gu=kn[pe]/kn[pe-1]),gu<1.7&&(Nt[pe]=0,pe==1&&(Nt[0]=0))}for(Nt[0]!=0&&re.nsPsy.lastAttacks[he]!=0&&(Nt[0]=0),(re.nsPsy.lastAttacks[he]==3||Nt[0]+Nt[1]+Nt[2]+Nt[3]!=0)&&(fu=0,Nt[1]!=0&&Nt[0]!=0&&(Nt[1]=0),Nt[2]!=0&&Nt[1]!=0&&(Nt[2]=0),Nt[3]!=0&&Nt[2]!=0&&(Nt[3]=0)),he<2?$e[he]=fu:fu==0&&($e[0]=$e[1]=0),W[he]=re.tot_ener[he],cn=ye,an=ie,_(M,k1,S1,an,he&1,cn,he&1,H,he,z,Z),Q(re,k1,Be,w1,x1),ue(re,w1,x1,Or),Ke=0;Ke<3;Ke++){var _u,vr;for(y(M,S1,fe,De,he,Ke),L(re,fe,De,he,Ke),we=0;we<ae.SBMAX_s;we++){if(vr=re.thm[he].s[we][Ke],vr*=l,Nt[Ke]>=2||Nt[Ke+1]==1){var _i=Ke!=0?Ke-1:2,Qt=R(re.thm[he].s[we][_i],vr,u*Ot);vr=Math.min(vr,Qt)}if(Nt[Ke]==1){var _i=Ke!=0?Ke-1:2,Qt=R(re.thm[he].s[we][_i],vr,h*Ot);vr=Math.min(vr,Qt)}else if(Ke!=0&&Nt[Ke-1]==3||Ke==0&&re.nsPsy.lastAttacks[he]==3){var _i=Ke!=2?Ke+1:0,Qt=R(re.thm[he].s[we][_i],vr,h*Ot);vr=Math.min(vr,Qt)}_u=ar[Ke*3+3]+ar[Ke*3+4]+ar[Ke*3+5],ar[Ke*3+5]*6<_u&&(vr*=.5,ar[Ke*3+4]*6<_u&&(vr*=.5)),re.thm[he].s[we][Ke]=vr}}for(re.nsPsy.lastAttacks[he]=Nt[2],Tt=0,Me=0;Me<re.npart_l;Me++){for(var vs=re.s3ind[Me][0],bu=Be[vs]*U[Or[vs]],ws=re.s3_ll[Tt++]*bu;++vs<=re.s3ind[Me][1];)bu=Be[vs]*U[Or[vs]],ws=b(ws,re.s3_ll[Tt++]*bu,vs,vs-Me,re,0);ws*=.158489319246111,re.blocktype_old[he&1]==ae.SHORT_TYPE?De[Me]=ws:De[Me]=R(Math.min(ws,Math.min(n*re.nb_1[he][Me],s*re.nb_2[he][Me])),ws,Ot),re.nb_2[he][Me]=re.nb_1[he][Me],re.nb_1[he][Me]=ws}for(;Me<=ae.CBANDS;++Me)Be[Me]=0,De[Me]=0;T(re,Be,De,he)}if((M.mode==t.STEREO||M.mode==t.JOINT_STEREO)&&M.interChRatio>0&&Y(M,M.interChRatio),M.mode==t.JOINT_STEREO){var yu;V(re),yu=M.msfix,Math.abs(yu)>0&&ee(re,yu,M.ATHlower*re.ATH.adjust)}for(v(M,$e,oe,ne),he=0;he<tt;he++){var bi,yi=0,Ba,qa;he>1?(bi=te,yi=-2,Ba=ae.NORM_TYPE,(oe[0]==ae.SHORT_TYPE||oe[1]==ae.SHORT_TYPE)&&(Ba=ae.SHORT_TYPE),qa=j[H][he-2]):(bi=X,yi=0,Ba=oe[he],qa=J[H][he]),Ba==ae.SHORT_TYPE?bi[yi+he]=K(qa,re.masking_lower):bi[yi+he]=F(qa,re.masking_lower),M.analysis&&(re.pinfo.pe[H][he]=bi[yi+he])}return 0};function ke(M,z,Z,H,J,j,X,te){var W=M.internal_flags;if(H<2)e.fft_long(W,X[te],H,z,Z);else if(H==2)for(var oe=ae.BLKSIZE-1;oe>=0;--oe){var re=X[te+0][oe],ie=X[te+1][oe];X[te+0][oe]=(re+ie)*Mr.SQRT2*.5,X[te+1][oe]=(re-ie)*Mr.SQRT2*.5}j[0]=X[te+0][0],j[0]*=j[0];for(var oe=ae.BLKSIZE/2-1;oe>=0;--oe){var ye=X[te+0][ae.BLKSIZE/2-oe],Be=X[te+0][ae.BLKSIZE/2+oe];j[ae.BLKSIZE/2-oe]=(ye*ye+Be*Be)*.5}{for(var fe=0,oe=11;oe<ae.HBLKSIZE;oe++)fe+=j[oe];W.tot_ener[H]=fe}if(M.analysis){for(var oe=0;oe<ae.HBLKSIZE;oe++)W.pinfo.energy[J][H][oe]=W.pinfo.energy_save[H][oe],W.pinfo.energy_save[H][oe]=j[oe];W.pinfo.pe[J][H]=W.pe[H]}}function Re(M,z,Z,H,J,j,X,te){var W=M.internal_flags;if(J==0&&H<2&&e.fft_short(W,X[te],H,z,Z),H==2)for(var oe=ae.BLKSIZE_s-1;oe>=0;--oe){var re=X[te+0][J][oe],ie=X[te+1][J][oe];X[te+0][J][oe]=(re+ie)*Mr.SQRT2*.5,X[te+1][J][oe]=(re-ie)*Mr.SQRT2*.5}j[J][0]=X[te+0][J][0],j[J][0]*=j[J][0];for(var oe=ae.BLKSIZE_s/2-1;oe>=0;--oe){var ye=X[te+0][J][ae.BLKSIZE_s/2-oe],Be=X[te+0][J][ae.BLKSIZE_s/2+oe];j[J][ae.BLKSIZE_s/2-oe]=(ye*ye+Be*Be)*.5}}function Te(M,z,Z,H){var J=M.internal_flags;M.athaa_loudapprox==2&&Z<2&&(J.loudness_sq[z][Z]=J.loudness_sq_save[Z],J.loudness_sq_save[Z]=k(H,J))}var Se=[-865163e-23*2,-.00851586*2,-674764e-23*2,.0209036*2,-336639e-22*2,-.0438162*2,-154175e-22*2,.0931738*2,-552212e-22*2,-.313819*2];function Ce(M,z,Z,H,J,j,X,te,W,oe){for(var re=nn([2,576]),ie=M.internal_flags,ye=ie.channels_out,Be=M.mode==t.JOINT_STEREO?4:ye,fe=0;fe<ye;fe++){firbuf=z[fe];for(var De=Z+576-350-g+192,ne=0;ne<576;ne++){var $e,tt;$e=firbuf[De+ne+10],tt=0;for(var he=0;he<(g-1)/2-1;he+=2)$e+=Se[he]*(firbuf[De+ne+he]+firbuf[De+ne+g-he]),tt+=Se[he+1]*(firbuf[De+ne+he+1]+firbuf[De+ne+g-he-1]);re[fe][ne]=$e+tt}J[H][fe].en.assign(ie.en[fe]),J[H][fe].thm.assign(ie.thm[fe]),Be>2&&(j[H][fe].en.assign(ie.en[fe+2]),j[H][fe].thm.assign(ie.thm[fe+2]))}for(var fe=0;fe<Be;fe++){var Me=Gt(12),pe=Gt(12),qe=[0,0,0,0],Tt=re[fe&1],we=0,Ke=fe==3?ie.nsPsy.attackthre_s:ie.nsPsy.attackthre,rt=1;if(fe==2)for(var ne=0,he=576;he>0;++ne,--he){var Ot=re[0][ne],Or=re[1][ne];re[0][ne]=Ot+Or,re[1][ne]=Ot-Or}for(var ne=0;ne<3;ne++)pe[ne]=ie.nsPsy.last_en_subshort[fe][ne+6],Qe(ie.nsPsy.last_en_subshort[fe][ne+4]>0),Me[ne]=pe[ne]/ie.nsPsy.last_en_subshort[fe][ne+4],qe[0]+=pe[ne];for(var ne=0;ne<9;ne++){for(var Ft=we+64,At=1;we<Ft;we++)At<Math.abs(Tt[we])&&(At=Math.abs(Tt[we]));ie.nsPsy.last_en_subshort[fe][ne]=pe[ne+3]=At,qe[1+ne/3]+=At,At>pe[ne+3-2]?(Qe(pe[ne+3-2]>0),At=At/pe[ne+3-2]):pe[ne+3-2]>At*10?At=pe[ne+3-2]/(At*10):At=0,Me[ne+3]=At}for(var ne=0;ne<3;++ne){var yr=pe[ne*3+3]+pe[ne*3+4]+pe[ne*3+5],Ar=1;pe[ne*3+5]*6<yr&&(Ar*=.5,pe[ne*3+4]*6<yr&&(Ar*=.5)),te[fe][ne]=Ar}if(M.analysis){for(var Nr=Me[0],ne=1;ne<12;ne++)Nr<Me[ne]&&(Nr=Me[ne]);ie.pinfo.ers[H][fe]=ie.pinfo.ers_save[fe],ie.pinfo.ers_save[fe]=Nr}for(var ne=0;ne<12;ne++)W[fe][ne/3]==0&&Me[ne]>Ke&&(W[fe][ne/3]=ne%3+1);for(var ne=1;ne<4;ne++){var an=qe[ne-1],cn=qe[ne],ar=Math.max(an,cn);ar<4e4&&an<1.7*cn&&cn<1.7*an&&(ne==1&&W[fe][0]<=W[fe][ne]&&(W[fe][0]=0),W[fe][ne]=0)}W[fe][0]<=ie.nsPsy.lastAttacks[fe]&&(W[fe][0]=0),(ie.nsPsy.lastAttacks[fe]==3||W[fe][0]+W[fe][1]+W[fe][2]+W[fe][3]!=0)&&(rt=0,W[fe][1]!=0&&W[fe][0]!=0&&(W[fe][1]=0),W[fe][2]!=0&&W[fe][1]!=0&&(W[fe][2]=0),W[fe][3]!=0&&W[fe][2]!=0&&(W[fe][3]=0)),fe<2?oe[fe]=rt:rt==0&&(oe[0]=oe[1]=0),X[fe]=ie.tot_ener[fe]}}function St(M,z,Z){if(Z==0)for(var H=0;H<M.npart_s;H++)M.nb_s2[z][H]=M.nb_s1[z][H],M.nb_s1[z][H]=0}function Fr(M,z){for(var Z=0;Z<M.npart_l;Z++)M.nb_2[z][Z]=M.nb_1[z][Z],M.nb_1[z][Z]=0}function w(M,z,Z,H){var J=U.length-1,j=0,X=Z[j]+Z[j+1];if(X>0){var te=z[j];te<z[j+1]&&(te=z[j+1]),Qe(M.numlines_s[j]+M.numlines_s[j+1]-1>0),X=20*(te*2-X)/(X*(M.numlines_s[j]+M.numlines_s[j+1]-1));var W=0|X;W>J&&(W=J),H[j]=W}else H[j]=0;for(j=1;j<M.npart_s-1;j++)if(X=Z[j-1]+Z[j]+Z[j+1],Qe(j+1<M.npart_s),X>0){var te=z[j-1];te<z[j]&&(te=z[j]),te<z[j+1]&&(te=z[j+1]),Qe(M.numlines_s[j-1]+M.numlines_s[j]+M.numlines_s[j+1]-1>0),X=20*(te*3-X)/(X*(M.numlines_s[j-1]+M.numlines_s[j]+M.numlines_s[j+1]-1));var W=0|X;W>J&&(W=J),H[j]=W}else H[j]=0;if(Qe(j==M.npart_s-1),X=Z[j-1]+Z[j],X>0){var te=z[j-1];te<z[j]&&(te=z[j]),Qe(M.numlines_s[j-1]+M.numlines_s[j]-1>0),X=20*(te*2-X)/(X*(M.numlines_s[j-1]+M.numlines_s[j]-1));var W=0|X;W>J&&(W=J),H[j]=W}else H[j]=0;Qe(j==M.npart_s-1)}function P(M,z,Z,H,J,j){var X=M.internal_flags,te=new float[ae.CBANDS],W=Gt(ae.CBANDS),oe,re,ie,ye=new int[ae.CBANDS];for(ie=re=0;ie<X.npart_s;++ie){var Be=0,fe=0,De=X.numlines_s[ie];for(oe=0;oe<De;++oe,++re){var ne=z[j][re];Be+=ne,fe<ne&&(fe=ne)}Z[ie]=Be,te[ie]=fe,W[ie]=Be/De,Qe(W[ie]>=0)}for(Qe(ie==X.npart_s);ie<ae.CBANDS;++ie)te[ie]=0,W[ie]=0;for(w(X,te,W,ye),re=ie=0;ie<X.npart_s;ie++){var $e=X.s3ind_s[ie][0],tt=X.s3ind_s[ie][1],he,Me,pe,qe,Tt;for(he=ye[$e],Me=1,qe=X.s3_ss[re]*Z[$e]*U[ye[$e]],++re,++$e;$e<=tt;)he+=ye[$e],Me+=1,pe=X.s3_ss[re]*Z[$e]*U[ye[$e]],qe=I(qe,pe,$e-ie),++re,++$e;he=(1+2*he)/(2*Me),Tt=U[he]*.5,qe*=Tt,H[ie]=qe,X.nb_s2[J][ie]=X.nb_s1[J][ie],X.nb_s1[J][ie]=qe,pe=te[ie],pe*=X.minval_s[ie],pe*=Tt,H[ie]>pe&&(H[ie]=pe),X.masking_lower>1&&(H[ie]*=X.masking_lower),H[ie]>Z[ie]&&(H[ie]=Z[ie]),X.masking_lower<1&&(H[ie]*=X.masking_lower),Qe(H[ie]>=0)}for(;ie<ae.CBANDS;++ie)Z[ie]=0,H[ie]=0}function xe(M,z,Z,H,J){var j=Gt(ae.CBANDS),X=Gt(ae.CBANDS),te=lo(ae.CBANDS+2),W;Q(M,z,Z,j,X),ue(M,j,X,te);var oe=0;for(W=0;W<M.npart_l;W++){var re,ie,ye,Be,fe=M.s3ind[W][0],De=M.s3ind[W][1],ne=0,$e=0;for(ne=te[fe],$e+=1,ie=M.s3_ll[oe]*Z[fe]*U[te[fe]],++oe,++fe;fe<=De;)ne+=te[fe],$e+=1,re=M.s3_ll[oe]*Z[fe]*U[te[fe]],Be=I(ie,re,fe-W),ie=Be,++oe,++fe;if(ne=(1+2*ne)/(2*$e),ye=U[ne]*.5,ie*=ye,M.blocktype_old[J&1]==ae.SHORT_TYPE){var tt=n*M.nb_1[J][W];tt>0?H[W]=Math.min(ie,tt):H[W]=Math.min(ie,Z[W]*h)}else{var he=s*M.nb_2[J][W],Me=n*M.nb_1[J][W],tt;he<=0&&(he=ie),Me<=0&&(Me=ie),M.blocktype_old[J&1]==ae.NORM_TYPE?tt=Math.min(Me,he):tt=Me,H[W]=Math.min(ie,tt)}M.nb_2[J][W]=M.nb_1[J][W],M.nb_1[J][W]=ie,re=j[W],re*=M.minval_l[W],re*=ye,H[W]>re&&(H[W]=re),M.masking_lower>1&&(H[W]*=M.masking_lower),H[W]>Z[W]&&(H[W]=Z[W]),M.masking_lower<1&&(H[W]*=M.masking_lower),Qe(H[W]>=0)}for(;W<ae.CBANDS;++W)Z[W]=0,H[W]=0}function Pe(M,z){var Z=M.internal_flags;M.short_blocks==li.short_block_coupled&&!(z[0]!=0&&z[1]!=0)&&(z[0]=z[1]=0);for(var H=0;H<Z.channels_out;H++)M.short_blocks==li.short_block_dispensed&&(z[H]=1),M.short_blocks==li.short_block_forced&&(z[H]=0)}function Ge(M,z,Z){for(var H=M.internal_flags,J=0;J<H.channels_out;J++){var j=ae.NORM_TYPE;z[J]!=0?(Qe(H.blocktype_old[J]!=ae.START_TYPE),H.blocktype_old[J]==ae.SHORT_TYPE&&(j=ae.STOP_TYPE)):(j=ae.SHORT_TYPE,H.blocktype_old[J]==ae.NORM_TYPE&&(H.blocktype_old[J]=ae.START_TYPE),H.blocktype_old[J]==ae.STOP_TYPE&&(H.blocktype_old[J]=ae.SHORT_TYPE)),Z[J]=H.blocktype_old[J],H.blocktype_old[J]=j}}function He(M,z,Z,H,J,j,X){for(var te=j*2,W=j>0?Math.pow(10,J):1,oe,re,ie=0;ie<X;++ie){var ye=M[2][ie],Be=M[3][ie],fe=z[0][ie],De=z[1][ie],ne=z[2][ie],$e=z[3][ie];if(fe<=1.58*De&&De<=1.58*fe){var tt=Z[ie]*Be,he=Z[ie]*ye;re=Math.max(ne,Math.min($e,tt)),oe=Math.max($e,Math.min(ne,he))}else re=ne,oe=$e;if(j>0){var Me,pe,qe=H[ie]*W;if(Me=Math.min(Math.max(fe,qe),Math.max(De,qe)),ne=Math.max(re,qe),$e=Math.max(oe,qe),pe=ne+$e,pe>0&&Me*te<pe){var Tt=Me*te/pe;ne*=Tt,$e*=Tt}re=Math.min(ne,re),oe=Math.min($e,oe)}re>ye&&(re=ye),oe>Be&&(oe=Be),z[2][ie]=re,z[3][ie]=oe}}this.L3psycho_anal_vbr=function(M,z,Z,H,J,j,X,te,W,oe){var re=M.internal_flags,ie,ye,Be=Gt(ae.HBLKSIZE),fe=nn([3,ae.HBLKSIZE_s]),De=nn([2,ae.BLKSIZE]),ne=nn([2,3,ae.BLKSIZE_s]),$e=nn([4,ae.CBANDS]),tt=nn([4,ae.CBANDS]),he=nn([4,3]),Me=.6,pe=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],qe=lo(2),Tt=M.mode==t.JOINT_STEREO?4:re.channels_out;Ce(M,z,Z,H,J,j,W,he,pe,qe),Pe(M,qe);{for(var we=0;we<Tt;we++){var Ke=we&1;ie=De,ke(M,z,Z,we,H,Be,ie,Ke),Te(M,H,we,Be),qe[Ke]!=0?xe(re,Be,$e[we],tt[we],we):Fr(re,we)}qe[0]+qe[1]==2&&M.mode==t.JOINT_STEREO&&He($e,tt,re.mld_cb_l,re.ATH.cb_l,M.ATHlower*re.ATH.adjust,M.msfix,re.npart_l);for(var we=0;we<Tt;we++){var Ke=we&1;qe[Ke]!=0&&T(re,$e[we],tt[we],we)}}{for(var rt=0;rt<3;rt++){for(var we=0;we<Tt;++we){var Ke=we&1;qe[Ke]!=0?St(re,we,rt):(ye=ne,Re(M,z,Z,we,rt,fe,ye,Ke),P(M,fe,$e[we],tt[we],we,rt))}qe[0]+qe[1]==0&&M.mode==t.JOINT_STEREO&&He($e,tt,re.mld_cb_s,re.ATH.cb_s,M.ATHlower*re.ATH.adjust,M.msfix,re.npart_s);for(var we=0;we<Tt;++we){var Ke=we&1;qe[Ke]==0&&L(re,$e[we],tt[we],we,rt)}}for(var we=0;we<Tt;we++){var Ke=we&1;if(qe[Ke]==0)for(var Ot=0;Ot<ae.SBMAX_s;Ot++){for(var Or=Gt(3),rt=0;rt<3;rt++){var Ft=re.thm[we].s[Ot][rt];if(Ft*=l,pe[we][rt]>=2||pe[we][rt+1]==1){var At=rt!=0?rt-1:2,yr=R(re.thm[we].s[Ot][At],Ft,u*Me);Ft=Math.min(Ft,yr)}else if(pe[we][rt]==1){var At=rt!=0?rt-1:2,yr=R(re.thm[we].s[Ot][At],Ft,h*Me);Ft=Math.min(Ft,yr)}else if(rt!=0&&pe[we][rt-1]==3||rt==0&&re.nsPsy.lastAttacks[we]==3){var At=rt!=2?rt+1:0,yr=R(re.thm[we].s[Ot][At],Ft,h*Me);Ft=Math.min(Ft,yr)}Ft*=he[we][rt],Or[rt]=Ft}for(var rt=0;rt<3;rt++)re.thm[we].s[Ot][rt]=Or[rt]}}}for(var we=0;we<Tt;we++)re.nsPsy.lastAttacks[we]=pe[we][2];Ge(M,qe,oe);for(var we=0;we<Tt;we++){var Ar,Nr,an,cn;we>1?(Ar=te,Nr=-2,an=ae.NORM_TYPE,(oe[0]==ae.SHORT_TYPE||oe[1]==ae.SHORT_TYPE)&&(an=ae.SHORT_TYPE),cn=j[H][we-2]):(Ar=X,Nr=0,an=oe[we],cn=J[H][we]),an==ae.SHORT_TYPE?Ar[Nr+we]=K(cn,re.masking_lower):Ar[Nr+we]=F(cn,re.masking_lower),M.analysis&&(re.pinfo.pe[H][we]=Ar[Nr+we])}return 0};function Ne(M,z){var Z=M,H;return Z>=0?H=-Z*27:H=Z*z,H<=-72?0:Math.exp(H*x)}function ze(M){var z=0,Z=0;{var H=0,J,j;for(H=0;Ne(H,M)>1e-20;H-=1);for(J=H,j=0;Math.abs(j-J)>1e-12;)H=(j+J)/2,Ne(H,M)>0?j=H:J=H;z=J}{var H=0,J,j;for(H=0;Ne(H,M)>1e-20;H+=1);for(J=0,j=H;Math.abs(j-J)>1e-12;)H=(j+J)/2,Ne(H,M)>0?J=H:j=H;Z=j}{var X=0,te=1e3,W;for(W=0;W<=te;++W){var H=z+W*(Z-z)/te,oe=Ne(H,M);X+=oe}{var re=(te+1)/(X*(Z-z));return re}}}function et(M){var z,Z,H,J;return z=M,z>=0?z*=3:z*=1.5,z>=.5&&z<=2.5?(J=z-.5,Z=8*(J*J-2*J)):Z=0,z+=.474,H=15.811389+7.5*z-17.5*Math.sqrt(1+z*z),H<=-60?0:(z=Math.exp((Z+H)*x),z/=.6609193,z)}function je(M){return M<0&&(M=0),M=M*.001,13*Math.atan(.76*M)+3.5*Math.atan(M*M/(7.5*7.5))}function ve(M,z,Z,H,J,j,X,te,W,oe,re,ie){var ye=Gt(ae.CBANDS+1),Be=te/(ie>15?2*576:2*192),fe=lo(ae.HBLKSIZE),De;te/=W;var ne=0,$e=0;for(De=0;De<ae.CBANDS;De++){var tt,he;for(tt=je(te*ne),ye[De]=te*ne,he=ne;je(te*he)-tt<a&&he<=W/2;he++);for(M[De]=he-ne,$e=De+1;ne<he;)Qe(ne<ae.HBLKSIZE),fe[ne++]=De;if(ne>W/2){ne=W/2,++De;break}}Qe(De<ae.CBANDS),ye[De]=te*ne;for(var Me=0;Me<ie;Me++){var pe,qe,Tt,we,Ke;Tt=oe[Me],we=oe[Me+1],pe=0|Math.floor(.5+re*(Tt-.5)),pe<0&&(pe=0),qe=0|Math.floor(.5+re*(we-.5)),qe>W/2&&(qe=W/2),Z[Me]=(fe[pe]+fe[qe])/2,z[Me]=fe[qe];var rt=Be*we;X[Me]=(rt-ye[z[Me]])/(ye[z[Me]+1]-ye[z[Me]]),X[Me]<0?X[Me]=0:X[Me]>1&&(X[Me]=1),Ke=je(te*oe[Me]*re),Ke=Math.min(Ke,15.5)/15.5,j[Me]=Math.pow(10,1.25*(1-Math.cos(Math.PI*Ke))-2.5)}ne=0;for(var Ot=0;Ot<$e;Ot++){var Or=M[Ot],tt,Ft;tt=je(te*ne),Ft=je(te*(ne+Or-1)),H[Ot]=.5*(tt+Ft),tt=je(te*(ne-.5)),Ft=je(te*(ne+Or-.5)),J[Ot]=Ft-tt,ne+=Or}return $e}function vt(M,z,Z,H,J,j){var X=nn([ae.CBANDS,ae.CBANDS]),te,W=0;if(j)for(var oe=0;oe<z;oe++)for(te=0;te<z;te++){var re=et(Z[oe]-Z[te])*H[te];X[oe][te]=re*J[oe]}else for(te=0;te<z;te++)for(var ie=15+Math.min(21/Z[te],12),ye=ze(ie),oe=0;oe<z;oe++){var re=ye*Ne(Z[oe]-Z[te],ie)*H[te];X[oe][te]=re*J[oe]}for(var oe=0;oe<z;oe++){for(te=0;te<z&&!(X[oe][te]>0);te++);for(M[oe][0]=te,te=z-1;te>0&&!(X[oe][te]>0);te--);M[oe][1]=te,W+=M[oe][1]-M[oe][0]+1}for(var Be=Gt(W),fe=0,oe=0;oe<z;oe++)for(te=M[oe][0];te<=M[oe][1];te++)Be[fe++]=X[oe][te];return Be}function Yt(M){var z=je(M);return z=Math.min(z,15.5)/15.5,Math.pow(10,1.25*(1-Math.cos(Math.PI*z))-2.5)}this.psymodel_init=function(M){var z=M.internal_flags,Z,H=!0,J=13,j=24,X=0,te=0,W=-8.25,oe=-4.5,re=Gt(ae.CBANDS),ie=Gt(ae.CBANDS),ye=Gt(ae.CBANDS),Be=M.out_samplerate;switch(M.experimentalZ){default:case 0:H=!0;break;case 1:H=!(M.VBR==ci.vbr_mtrh||M.VBR==ci.vbr_mt);break;case 2:H=!1;break;case 3:J=8,X=-1.75,te=-.0125,W=-8.25,oe=-2.25;break}for(z.ms_ener_ratio_old=.25,z.blocktype_old[0]=z.blocktype_old[1]=ae.NORM_TYPE,Z=0;Z<4;++Z){for(var ne=0;ne<ae.CBANDS;++ne)z.nb_1[Z][ne]=1e20,z.nb_2[Z][ne]=1e20,z.nb_s1[Z][ne]=z.nb_s2[Z][ne]=1;for(var fe=0;fe<ae.SBMAX_l;fe++)z.en[Z].l[fe]=1e20,z.thm[Z].l[fe]=1e20;for(var ne=0;ne<3;++ne){for(var fe=0;fe<ae.SBMAX_s;fe++)z.en[Z].s[fe][ne]=1e20,z.thm[Z].s[fe][ne]=1e20;z.nsPsy.lastAttacks[Z]=0}for(var ne=0;ne<9;ne++)z.nsPsy.last_en_subshort[Z][ne]=10}for(z.loudness_sq_save[0]=z.loudness_sq_save[1]=0,z.npart_l=ve(z.numlines_l,z.bo_l,z.bm_l,re,ie,z.mld_l,z.PSY.bo_l_weight,Be,ae.BLKSIZE,z.scalefac_band.l,ae.BLKSIZE/(2*576),ae.SBMAX_l),Qe(z.npart_l<ae.CBANDS),Z=0;Z<z.npart_l;Z++){var De=X;re[Z]>=J&&(De=te*(re[Z]-J)/(j-J)+X*(j-re[Z])/(j-J)),ye[Z]=Math.pow(10,De/10),z.numlines_l[Z]>0?z.rnumlines_l[Z]=1/z.numlines_l[Z]:z.rnumlines_l[Z]=0}z.s3_ll=vt(z.s3ind,z.npart_l,re,ie,ye,H);var ne=0;for(Z=0;Z<z.npart_l;Z++){var $e;$e=Pw.MAX_VALUE;for(var tt=0;tt<z.numlines_l[Z];tt++,ne++){var he=Be*ne/(1e3*ae.BLKSIZE),Me;Me=this.ATHformula(he*1e3,M)-20,Me=Math.pow(10,.1*Me),Me*=z.numlines_l[Z],$e>Me&&($e=Me)}z.ATH.cb_l[Z]=$e,$e=-20+re[Z]*20/10,$e>6&&($e=100),$e<-15&&($e=-15),$e-=8,z.minval_l[Z]=Math.pow(10,$e/10)*z.numlines_l[Z]}for(z.npart_s=ve(z.numlines_s,z.bo_s,z.bm_s,re,ie,z.mld_s,z.PSY.bo_s_weight,Be,ae.BLKSIZE_s,z.scalefac_band.s,ae.BLKSIZE_s/(2*192),ae.SBMAX_s),Qe(z.npart_s<ae.CBANDS),ne=0,Z=0;Z<z.npart_s;Z++){var $e,De=W;re[Z]>=J&&(De=oe*(re[Z]-J)/(j-J)+W*(j-re[Z])/(j-J)),ye[Z]=Math.pow(10,De/10),$e=Pw.MAX_VALUE;for(var tt=0;tt<z.numlines_s[Z];tt++,ne++){var he=Be*ne/(1e3*ae.BLKSIZE_s),Me;Me=this.ATHformula(he*1e3,M)-20,Me=Math.pow(10,.1*Me),Me*=z.numlines_s[Z],$e>Me&&($e=Me)}z.ATH.cb_s[Z]=$e,$e=-7+re[Z]*7/12,re[Z]>12&&($e*=1+Math.log(1+$e)*3.1),re[Z]<12&&($e*=1+Math.log(1-$e)*2.3),$e<-15&&($e=-15),$e-=8,z.minval_s[Z]=Math.pow(10,$e/10)*z.numlines_s[Z]}z.s3_ss=vt(z.s3ind_s,z.npart_s,re,ie,ye,H),C(),e.init_fft(z),z.decay=Math.exp(-1*r/(d*Be/192));{var pe;pe=p,M.exp_nspsytune&2&&(pe=1),Math.abs(M.msfix)>0&&(pe=M.msfix),M.msfix=pe;for(var qe=0;qe<z.npart_l;qe++)z.s3ind[qe][1]>z.npart_l-1&&(z.s3ind[qe][1]=z.npart_l-1)}var Tt=576*z.mode_gr/Be;if(z.ATH.decay=Math.pow(10,-12/10*Tt),z.ATH.adjust=.01,z.ATH.adjustLimit=1,Qe(z.bo_l[ae.SBMAX_l-1]<=z.npart_l),Qe(z.bo_s[ae.SBMAX_s-1]<=z.npart_s),M.ATHtype!=-1){var he,we=M.out_samplerate/ae.BLKSIZE,Ke=0;for(he=0,Z=0;Z<ae.BLKSIZE/2;++Z)he+=we,z.ATH.eql_w[Z]=1/Math.pow(10,this.ATHformula(he,M)/10),Ke+=z.ATH.eql_w[Z];for(Ke=1/Ke,Z=ae.BLKSIZE/2;--Z>=0;)z.ATH.eql_w[Z]*=Ke}{for(var qe=ne=0;qe<z.npart_s;++qe)for(Z=0;Z<z.numlines_s[qe];++Z)++ne;for(var qe=ne=0;qe<z.npart_l;++qe)for(Z=0;Z<z.numlines_l[qe];++Z)++ne}for(ne=0,Z=0;Z<z.npart_l;Z++){var he=Be*(ne+z.numlines_l[Z]/2)/(1*ae.BLKSIZE);z.mld_cb_l[Z]=Yt(he),ne+=z.numlines_l[Z]}for(;Z<ae.CBANDS;++Z)z.mld_cb_l[Z]=1;for(ne=0,Z=0;Z<z.npart_s;Z++){var he=Be*(ne+z.numlines_s[Z]/2)/(1*ae.BLKSIZE_s);z.mld_cb_s[Z]=Yt(he),ne+=z.numlines_s[Z]}for(;Z<ae.CBANDS;++Z)z.mld_cb_s[Z]=1;return 0};function pt(M,z){M<-.3&&(M=3410),M/=1e3,M=Math.max(.1,M);var Z=3.64*Math.pow(M,-.8)-6.8*Math.exp(-.6*Math.pow(M-3.4,2))+6*Math.exp(-.15*Math.pow(M-8.7,2))+(.6+.04*z)*.001*Math.pow(M,4);return Z}this.ATHformula=function(M,z){var Z;switch(z.ATHtype){case 0:Z=pt(M,9);break;case 1:Z=pt(M,-1);break;case 2:Z=pt(M,0);break;case 3:Z=pt(M,1)+6;break;case 4:Z=pt(M,z.ATHcurve);break;default:Z=pt(M,0);break}return Z}}var $z=Tz,Rz=Da;function Pz(){this.class_id=0,this.num_samples=0,this.num_channels=0,this.in_samplerate=0,this.out_samplerate=0,this.scale=0,this.scale_left=0,this.scale_right=0,this.analysis=!1,this.bWriteVbrTag=!1,this.decode_only=!1,this.quality=0,this.mode=Rz.STEREO,this.force_ms=!1,this.free_format=!1,this.findReplayGain=!1,this.decode_on_the_fly=!1,this.write_id3tag_automatic=!1,this.brate=0,this.compression_ratio=0,this.copyright=0,this.original=0,this.extension=0,this.emphasis=0,this.error_protection=0,this.strict_ISO=!1,this.disable_reservoir=!1,this.quant_comp=0,this.quant_comp_short=0,this.experimentalY=!1,this.experimentalZ=0,this.exp_nspsytune=0,this.preset=0,this.VBR=null,this.VBR_q_frac=0,this.VBR_q=0,this.VBR_mean_bitrate_kbps=0,this.VBR_min_bitrate_kbps=0,this.VBR_max_bitrate_kbps=0,this.VBR_hard_min=0,this.lowpassfreq=0,this.highpassfreq=0,this.lowpasswidth=0,this.highpasswidth=0,this.maskingadjust=0,this.maskingadjust_short=0,this.ATHonly=!1,this.ATHshort=!1,this.noATH=!1,this.ATHtype=0,this.ATHcurve=0,this.ATHlower=0,this.athaa_type=0,this.athaa_loudapprox=0,this.athaa_sensitivity=0,this.short_blocks=null,this.useTemporal=!1,this.interChRatio=0,this.msfix=0,this.tune=!1,this.tune_value_a=0,this.version=0,this.encoder_delay=0,this.encoder_padding=0,this.framesize=0,this.frameNum=0,this.lame_allocated_gfp=0,this.internal_flags=null}var Mz=Pz,zz=hr(),a3={};a3.SFBMAX=zz.SBMAX_s*3;var su=a3,c3=Zt,Iz=c3.new_float,uo=c3.new_int,Wm=su;function Oz(){this.xr=Iz(576),this.l3_enc=uo(576),this.scalefac=uo(Wm.SFBMAX),this.xrpow_max=0,this.part2_3_length=0,this.big_values=0,this.count1=0,this.global_gain=0,this.scalefac_compress=0,this.block_type=0,this.mixed_block_flag=0,this.table_select=uo(3),this.subblock_gain=uo(4),this.region0_count=0,this.region1_count=0,this.preflag=0,this.scalefac_scale=0,this.count1table_select=0,this.part2_length=0,this.sfb_lmax=0,this.sfb_smin=0,this.psy_lmax=0,this.sfbmax=0,this.psymax=0,this.sfbdivide=0,this.width=uo(Wm.SFBMAX),this.window=uo(Wm.SFBMAX),this.count1bits=0,this.sfb_partition_table=null,this.slen=uo(4),this.max_nonzero_coeff=0;var t=this;function e(n){return new Int32Array(n)}function r(n){return new Float32Array(n)}this.assign=function(n){t.xr=r(n.xr),t.l3_enc=e(n.l3_enc),t.scalefac=e(n.scalefac),t.xrpow_max=n.xrpow_max,t.part2_3_length=n.part2_3_length,t.big_values=n.big_values,t.count1=n.count1,t.global_gain=n.global_gain,t.scalefac_compress=n.scalefac_compress,t.block_type=n.block_type,t.mixed_block_flag=n.mixed_block_flag,t.table_select=e(n.table_select),t.subblock_gain=e(n.subblock_gain),t.region0_count=n.region0_count,t.region1_count=n.region1_count,t.preflag=n.preflag,t.scalefac_scale=n.scalefac_scale,t.count1table_select=n.count1table_select,t.part2_length=n.part2_length,t.sfb_lmax=n.sfb_lmax,t.sfb_smin=n.sfb_smin,t.psy_lmax=n.psy_lmax,t.sfbmax=n.sfbmax,t.psymax=n.psymax,t.sfbdivide=n.sfbdivide,t.width=e(n.width),t.window=e(n.window),t.count1bits=n.count1bits,t.sfb_partition_table=n.sfb_partition_table.slice(0),t.slen=e(n.slen),t.max_nonzero_coeff=n.max_nonzero_coeff}}var o1=Oz,Az=Zt,Mw=Az.new_int,Nz=o1;function Cz(){this.tt=[[null,null],[null,null]],this.main_data_begin=0,this.private_bits=0,this.resvDrain_pre=0,this.resvDrain_post=0,this.scfsi=[Mw(4),Mw(4)];for(var t=0;t<2;t++)for(var e=0;e<2;e++)this.tt[t][e]=new Nz}var jz=Cz,l3=Zt,Jl=l3.System,Ql=l3.new_int,eu=hr();function Dz(t,e,r,n){this.l=Ql(1+eu.SBMAX_l),this.s=Ql(1+eu.SBMAX_s),this.psfb21=Ql(1+eu.PSFB21),this.psfb12=Ql(1+eu.PSFB12);var s=this.l,o=this.s;arguments.length==4&&(this.arrL=arguments[0],this.arrS=arguments[1],this.arr21=arguments[2],this.arr12=arguments[3],Jl.arraycopy(this.arrL,0,s,0,Math.min(this.arrL.length,this.l.length)),Jl.arraycopy(this.arrS,0,o,0,Math.min(this.arrS.length,this.s.length)),Jl.arraycopy(this.arr21,0,this.psfb21,0,Math.min(this.arr21.length,this.psfb21.length)),Jl.arraycopy(this.arr12,0,this.psfb12,0,Math.min(this.arr12.length,this.psfb12.length)))}var u3=Dz,i1=Zt,Km=i1.new_float,Lz=i1.new_float_n,Zz=i1.new_int,zw=hr();function Bz(){this.last_en_subshort=Lz([4,9]),this.lastAttacks=Zz(4),this.pefirbuf=Km(19),this.longfact=Km(zw.SBMAX_l),this.shortfact=Km(zw.SBMAX_s),this.attackthre=0,this.attackthre_s=0}var qz=Bz;function Vz(){this.sum=0,this.seen=0,this.want=0,this.pos=0,this.size=0,this.bag=null,this.nVbrNumFrames=0,this.nBytesWritten=0,this.TotalFrameSize=0}var Fz=Vz,fi=Zt,Hz=fi.new_byte,Uz=fi.new_double,sn=fi.new_float,fo=fi.new_float_n,vn=fi.new_int,tu=fi.new_int_n,Gz=jz,Yz=u3,Xz=qz,Wz=Fz,Iw=o3(),qt=hr(),Kz=su;Fn.MFSIZE=3*1152+qt.ENCDELAY-qt.MDCTDELAY;Fn.MAX_HEADER_BUF=256;Fn.MAX_BITS_PER_CHANNEL=4095;Fn.MAX_BITS_PER_GRANULE=7680;Fn.BPC=320;function Fn(){var t=40;this.Class_ID=0,this.lame_encode_frame_init=0,this.iteration_init_init=0,this.fill_buffer_resample_init=0,this.mfbuf=fo([2,Fn.MFSIZE]),this.mode_gr=0,this.channels_in=0,this.channels_out=0,this.resample_ratio=0,this.mf_samples_to_encode=0,this.mf_size=0,this.VBR_min_bitrate=0,this.VBR_max_bitrate=0,this.bitrate_index=0,this.samplerate_index=0,this.mode_ext=0,this.lowpass1=0,this.lowpass2=0,this.highpass1=0,this.highpass2=0,this.noise_shaping=0,this.noise_shaping_amp=0,this.substep_shaping=0,this.psymodel=0,this.noise_shaping_stop=0,this.subblock_gain=0,this.use_best_huffman=0,this.full_outer_loop=0,this.l3_side=new Gz,this.ms_ratio=sn(2),this.padding=0,this.frac_SpF=0,this.slot_lag=0,this.tag_spec=null,this.nMusicCRC=0,this.OldValue=vn(2),this.CurrentStep=vn(2),this.masking_lower=0,this.bv_scf=vn(576),this.pseudohalf=vn(Kz.SFBMAX),this.sfb21_extra=!1,this.inbuf_old=new Array(2),this.blackfilt=new Array(2*Fn.BPC+1),this.itime=Uz(2),this.sideinfo_len=0,this.sb_sample=fo([2,2,18,qt.SBLIMIT]),this.amp_filter=sn(32);function e(){this.write_timing=0,this.ptr=0,this.buf=Hz(t)}this.header=new Array(Fn.MAX_HEADER_BUF),this.h_ptr=0,this.w_ptr=0,this.ancillary_flag=0,this.ResvSize=0,this.ResvMax=0,this.scalefac_band=new Yz,this.minval_l=sn(qt.CBANDS),this.minval_s=sn(qt.CBANDS),this.nb_1=fo([4,qt.CBANDS]),this.nb_2=fo([4,qt.CBANDS]),this.nb_s1=fo([4,qt.CBANDS]),this.nb_s2=fo([4,qt.CBANDS]),this.s3_ss=null,this.s3_ll=null,this.decay=0,this.thm=new Array(4),this.en=new Array(4),this.tot_ener=sn(4),this.loudness_sq=fo([2,2]),this.loudness_sq_save=sn(2),this.mld_l=sn(qt.SBMAX_l),this.mld_s=sn(qt.SBMAX_s),this.bm_l=vn(qt.SBMAX_l),this.bo_l=vn(qt.SBMAX_l),this.bm_s=vn(qt.SBMAX_s),this.bo_s=vn(qt.SBMAX_s),this.npart_l=0,this.npart_s=0,this.s3ind=tu([qt.CBANDS,2]),this.s3ind_s=tu([qt.CBANDS,2]),this.numlines_s=vn(qt.CBANDS),this.numlines_l=vn(qt.CBANDS),this.rnumlines_l=sn(qt.CBANDS),this.mld_cb_l=sn(qt.CBANDS),this.mld_cb_s=sn(qt.CBANDS),this.numlines_s_num1=0,this.numlines_l_num1=0,this.pe=sn(4),this.ms_ratio_s_old=0,this.ms_ratio_l_old=0,this.ms_ener_ratio_old=0,this.blocktype_old=vn(2),this.nsPsy=new Xz,this.VBR_seek_table=new Wz,this.ATH=null,this.PSY=null,this.nogap_total=0,this.nogap_current=0,this.decode_on_the_fly=!0,this.findReplayGain=!0,this.findPeakSample=!0,this.PeakSample=0,this.RadioGain=0,this.AudiophileGain=0,this.rgdata=null,this.noclipGainChange=0,this.noclipScale=0,this.bitrate_stereoMode_Hist=tu([16,5]),this.bitrate_blockType_Hist=tu([16,6]),this.pinfo=null,this.hip=null,this.in_buffer_nsamples=0,this.in_buffer_0=null,this.in_buffer_1=null,this.iteration_loop=null;for(var r=0;r<this.en.length;r++)this.en[r]=new Iw;for(var r=0;r<this.thm.length;r++)this.thm[r]=new Iw;for(var r=0;r<this.header.length;r++)this.header[r]=new e}var ou=Fn,Jz=Zt,ho=Jz.new_float,po=hr();function Qz(){this.useAdjust=0,this.aaSensitivityP=0,this.adjust=0,this.adjustLimit=0,this.decay=0,this.floor=0,this.l=ho(po.SBMAX_l),this.s=ho(po.SBMAX_s),this.psfb21=ho(po.PSFB21),this.psfb12=ho(po.PSFB12),this.cb_l=ho(po.CBANDS),this.cb_s=ho(po.CBANDS),this.eql_w=ho(po.BLKSIZE/2)}var eI=Qz,d3=Zt,zr=d3.System,Ow=d3.Arrays;Vt.STEPS_per_dB=100;Vt.MAX_dB=120;Vt.GAIN_NOT_ENOUGH_SAMPLES=-24601;Vt.GAIN_ANALYSIS_ERROR=0;Vt.GAIN_ANALYSIS_OK=1;Vt.INIT_GAIN_ANALYSIS_ERROR=0;Vt.INIT_GAIN_ANALYSIS_OK=1;Vt.YULE_ORDER=10;Vt.MAX_ORDER=Vt.YULE_ORDER;Vt.MAX_SAMP_FREQ=48e3;Vt.RMS_WINDOW_TIME_NUMERATOR=1;Vt.RMS_WINDOW_TIME_DENOMINATOR=20;Vt.MAX_SAMPLES_PER_WINDOW=Vt.MAX_SAMP_FREQ*Vt.RMS_WINDOW_TIME_NUMERATOR/Vt.RMS_WINDOW_TIME_DENOMINATOR+1;function Vt(){var t=64.82,e=.95,r=Vt.RMS_WINDOW_TIME_NUMERATOR,n=Vt.RMS_WINDOW_TIME_DENOMINATOR,s=[[.038575994352,-3.84664617118067,-.02160367184185,7.81501653005538,-.00123395316851,-11.34170355132042,-9291677959e-14,13.05504219327545,-.01655260341619,-12.28759895145294,.02161526843274,9.4829380631979,-.02074045215285,-5.87257861775999,.00594298065125,2.75465861874613,.00306428023191,-.86984376593551,.00012025322027,.13919314567432,.00288463683916],[.0541865640643,-3.47845948550071,-.02911007808948,6.36317777566148,-.00848709379851,-8.54751527471874,-.00851165645469,9.4769360780128,-.00834990904936,-8.81498681370155,.02245293253339,6.85401540936998,-.02596338512915,-4.39470996079559,.01624864962975,2.19611684890774,-.00240879051584,-.75104302451432,.00674613682247,.13149317958808,-.00187763777362],[.15457299681924,-2.37898834973084,-.09331049056315,2.84868151156327,-.06247880153653,-2.64577170229825,.02163541888798,2.23697657451713,-.05588393329856,-1.67148153367602,.04781476674921,1.00595954808547,.00222312597743,-.45953458054983,.03174092540049,.16378164858596,-.01390589421898,-.05032077717131,.00651420667831,.0234789740702,-.00881362733839],[.30296907319327,-1.61273165137247,-.22613988682123,1.0797749225997,-.08587323730772,-.2565625775407,.03282930172664,-.1627671912044,-.00915702933434,-.22638893773906,-.02364141202522,.39120800788284,-.00584456039913,-.22138138954925,.06276101321749,.04500235387352,-828086748e-14,.02005851806501,.00205861885564,.00302439095741,-.02950134983287],[.33642304856132,-1.49858979367799,-.2557224142557,.87350271418188,-.11828570177555,.12205022308084,.11921148675203,-.80774944671438,-.07834489609479,.47854794562326,-.0046997791438,-.12453458140019,-.0058950022444,-.04067510197014,.05724228140351,.08333755284107,.00832043980773,-.04237348025746,-.0163538138454,.02977207319925,-.0176017656815],[.4491525660845,-.62820619233671,-.14351757464547,.29661783706366,-.22784394429749,-.372563729424,-.01419140100551,.00213767857124,.04078262797139,-.42029820170918,-.12398163381748,.22199650564824,.04097565135648,.00613424350682,.10478503600251,.06747620744683,-.01863887810927,.05784820375801,-.03193428438915,.03222754072173,.00541907748707],[.56619470757641,-1.04800335126349,-.75464456939302,.29156311971249,.1624213774223,-.26806001042947,.16744243493672,.00819999645858,-.18901604199609,.45054734505008,.3093178284183,-.33032403314006,-.27562961986224,.0673936833311,.00647310677246,-.04784254229033,.08647503780351,.01639907836189,-.0378898455484,.01807364323573,-.00588215443421],[.58100494960553,-.51035327095184,-.53174909058578,-.31863563325245,-.14289799034253,-.20256413484477,.17520704835522,.1472815413433,.02377945217615,.38952639978999,.15558449135573,-.23313271880868,-.25344790059353,-.05246019024463,.01628462406333,-.02505961724053,.06920467763959,.02442357316099,-.03721611395801,.01818801111503,-.00749618797172],[.53648789255105,-.2504987195602,-.42163034350696,-.43193942311114,-.00275953611929,-.03424681017675,.04267842219415,-.04678328784242,-.10214864179676,.26408300200955,.14590772289388,.15113130533216,-.02459864859345,-.17556493366449,-.11202315195388,-.18823009262115,-.04060034127,.05477720428674,.0478866554818,.0470440968812,-.02217936801134]],o=[[.98621192462708,-1.97223372919527,-1.97242384925416,.97261396931306,.98621192462708],[.98500175787242,-1.96977855582618,-1.97000351574484,.9702284756635,.98500175787242],[.97938932735214,-1.95835380975398,-1.95877865470428,.95920349965459,.97938932735214],[.97531843204928,-1.95002759149878,-1.95063686409857,.95124613669835,.97531843204928],[.97316523498161,-1.94561023566527,-1.94633046996323,.94705070426118,.97316523498161],[.96454515552826,-1.92783286977036,-1.92909031105652,.93034775234268,.96454515552826],[.96009142950541,-1.91858953033784,-1.92018285901082,.92177618768381,.96009142950541],[.95856916599601,-1.9154210807478,-1.91713833199203,.91885558323625,.95856916599601],[.94597685600279,-1.88903307939452,-1.89195371200558,.89487434461664,.94597685600279]];function i(u,h,p,g,x,S){for(;x--!=0;)p[g]=1e-10+u[h+0]*S[0]-p[g-1]*S[1]+u[h-1]*S[2]-p[g-2]*S[3]+u[h-2]*S[4]-p[g-3]*S[5]+u[h-3]*S[6]-p[g-4]*S[7]+u[h-4]*S[8]-p[g-5]*S[9]+u[h-5]*S[10]-p[g-6]*S[11]+u[h-6]*S[12]-p[g-7]*S[13]+u[h-7]*S[14]-p[g-8]*S[15]+u[h-8]*S[16]-p[g-9]*S[17]+u[h-9]*S[18]-p[g-10]*S[19]+u[h-10]*S[20],++g,++h}function a(u,h,p,g,x,S){for(;x--!=0;)p[g]=u[h+0]*S[0]-p[g-1]*S[1]+u[h-1]*S[2]-p[g-2]*S[3]+u[h-2]*S[4],++g,++h}function c(u,h){for(var p=0;p<MAX_ORDER;p++)u.linprebuf[p]=u.lstepbuf[p]=u.loutbuf[p]=u.rinprebuf[p]=u.rstepbuf[p]=u.routbuf[p]=0;switch(0|h){case 48e3:u.reqindex=0;break;case 44100:u.reqindex=1;break;case 32e3:u.reqindex=2;break;case 24e3:u.reqindex=3;break;case 22050:u.reqindex=4;break;case 16e3:u.reqindex=5;break;case 12e3:u.reqindex=6;break;case 11025:u.reqindex=7;break;case 8e3:u.reqindex=8;break;default:return INIT_GAIN_ANALYSIS_ERROR}return u.sampleWindow=0|(h*r+n-1)/n,u.lsum=0,u.rsum=0,u.totsamp=0,Ow.ill(u.A,0),INIT_GAIN_ANALYSIS_OK}this.InitGainAnalysis=function(u,h){return c(u,h)!=INIT_GAIN_ANALYSIS_OK?INIT_GAIN_ANALYSIS_ERROR:(u.linpre=MAX_ORDER,u.rinpre=MAX_ORDER,u.lstep=MAX_ORDER,u.rstep=MAX_ORDER,u.lout=MAX_ORDER,u.rout=MAX_ORDER,Ow.fill(u.B,0),INIT_GAIN_ANALYSIS_OK)};function d(u){return u*u}this.AnalyzeSamples=function(u,h,p,g,x,S,k){var _,m,$,f,E,N,B;if(S==0)return GAIN_ANALYSIS_OK;switch(B=0,E=S,k){case 1:g=h,x=p;break;case 2:break;default:return GAIN_ANALYSIS_ERROR}for(S<MAX_ORDER?(zr.arraycopy(h,p,u.linprebuf,MAX_ORDER,S),zr.arraycopy(g,x,u.rinprebuf,MAX_ORDER,S)):(zr.arraycopy(h,p,u.linprebuf,MAX_ORDER,MAX_ORDER),zr.arraycopy(g,x,u.rinprebuf,MAX_ORDER,MAX_ORDER));E>0;){N=E>u.sampleWindow-u.totsamp?u.sampleWindow-u.totsamp:E,B<MAX_ORDER?(_=u.linpre+B,m=u.linprebuf,$=u.rinpre+B,f=u.rinprebuf,N>MAX_ORDER-B&&(N=MAX_ORDER-B)):(_=p+B,m=h,$=x+B,f=g),i(m,_,u.lstepbuf,u.lstep+u.totsamp,N,s[u.reqindex]),i(f,$,u.rstepbuf,u.rstep+u.totsamp,N,s[u.reqindex]),a(u.lstepbuf,u.lstep+u.totsamp,u.loutbuf,u.lout+u.totsamp,N,o[u.reqindex]),a(u.rstepbuf,u.rstep+u.totsamp,u.routbuf,u.rout+u.totsamp,N,o[u.reqindex]),_=u.lout+u.totsamp,m=u.loutbuf,$=u.rout+u.totsamp,f=u.routbuf;for(var U=N%8;U--!=0;)u.lsum+=d(m[_++]),u.rsum+=d(f[$++]);for(U=N/8;U--!=0;)u.lsum+=d(m[_+0])+d(m[_+1])+d(m[_+2])+d(m[_+3])+d(m[_+4])+d(m[_+5])+d(m[_+6])+d(m[_+7]),_+=8,u.rsum+=d(f[$+0])+d(f[$+1])+d(f[$+2])+d(f[$+3])+d(f[$+4])+d(f[$+5])+d(f[$+6])+d(f[$+7]),$+=8;if(E-=N,B+=N,u.totsamp+=N,u.totsamp==u.sampleWindow){var C=Vt.STEPS_per_dB*10*Math.log10((u.lsum+u.rsum)/u.totsamp*.5+1e-37),q=C<=0?0:0|C;q>=u.A.length&&(q=u.A.length-1),u.A[q]++,u.lsum=u.rsum=0,zr.arraycopy(u.loutbuf,u.totsamp,u.loutbuf,0,MAX_ORDER),zr.arraycopy(u.routbuf,u.totsamp,u.routbuf,0,MAX_ORDER),zr.arraycopy(u.lstepbuf,u.totsamp,u.lstepbuf,0,MAX_ORDER),zr.arraycopy(u.rstepbuf,u.totsamp,u.rstepbuf,0,MAX_ORDER),u.totsamp=0}if(u.totsamp>u.sampleWindow)return GAIN_ANALYSIS_ERROR}return S<MAX_ORDER?(zr.arraycopy(u.linprebuf,S,u.linprebuf,0,MAX_ORDER-S),zr.arraycopy(u.rinprebuf,S,u.rinprebuf,0,MAX_ORDER-S),zr.arraycopy(h,p,u.linprebuf,MAX_ORDER-S,S),zr.arraycopy(g,x,u.rinprebuf,MAX_ORDER-S,S)):(zr.arraycopy(h,p+S-MAX_ORDER,u.linprebuf,0,MAX_ORDER),zr.arraycopy(g,x+S-MAX_ORDER,u.rinprebuf,0,MAX_ORDER)),GAIN_ANALYSIS_OK};function l(u,h){var p,g=0;for(p=0;p<h;p++)g+=u[p];if(g==0)return GAIN_NOT_ENOUGH_SAMPLES;var x=0|Math.ceil(g*(1-e));for(p=h;p-- >0&&!((x-=u[p])<=0););return t-p/Vt.STEPS_per_dB}this.GetTitleGain=function(u){for(var h=l(u.A,u.A.length),p=0;p<u.A.length;p++)u.B[p]+=u.A[p],u.A[p]=0;for(var p=0;p<MAX_ORDER;p++)u.linprebuf[p]=u.lstepbuf[p]=u.loutbuf[p]=u.rinprebuf[p]=u.rstepbuf[p]=u.routbuf[p]=0;return u.totsamp=0,u.lsum=u.rsum=0,h}}var f3=Vt,h3=Zt,ui=h3.new_float,Aw=h3.new_int,Ir=f3;function tI(){this.linprebuf=ui(Ir.MAX_ORDER*2),this.linpre=0,this.lstepbuf=ui(Ir.MAX_SAMPLES_PER_WINDOW+Ir.MAX_ORDER),this.lstep=0,this.loutbuf=ui(Ir.MAX_SAMPLES_PER_WINDOW+Ir.MAX_ORDER),this.lout=0,this.rinprebuf=ui(Ir.MAX_ORDER*2),this.rinpre=0,this.rstepbuf=ui(Ir.MAX_SAMPLES_PER_WINDOW+Ir.MAX_ORDER),this.rstep=0,this.routbuf=ui(Ir.MAX_SAMPLES_PER_WINDOW+Ir.MAX_ORDER),this.rout=0,this.sampleWindow=0,this.totsamp=0,this.lsum=0,this.rsum=0,this.freqindex=0,this.first=0,this.A=Aw(0|Ir.STEPS_per_dB*Ir.MAX_dB),this.B=Aw(0|Ir.STEPS_per_dB*Ir.MAX_dB)}var rI=tI;function nI(t){this.bits=t}var p3=nI,a1=Zt,Nw=a1.new_float,sI=a1.new_int,Cw=a1.assert,oI=p3,jw=hr(),iI=su,aI=ou;function cI(t){var e=t;this.quantize=e,this.iteration_loop=function(r,n,s,o){var i=r.internal_flags,a=Nw(iI.SFBMAX),c=Nw(576),d=sI(2),l=0,u,h=i.l3_side,p=new oI(l);this.quantize.rv.ResvFrameBegin(r,p),l=p.bits;for(var g=0;g<i.mode_gr;g++){u=this.quantize.qupvt.on_pe(r,n,d,l,g,g),i.mode_ext==jw.MPG_MD_MS_LR&&(this.quantize.ms_convert(i.l3_side,g),this.quantize.qupvt.reduce_side(d,s[g],l,u));for(var x=0;x<i.channels_out;x++){var S,k,_=h.tt[g][x];_.block_type!=jw.SHORT_TYPE?(S=0,k=i.PSY.mask_adjust-S):(S=0,k=i.PSY.mask_adjust_short-S),i.masking_lower=Math.pow(10,k*.1),this.quantize.init_outer_loop(i,_),this.quantize.init_xrpow(i,_,c)&&(this.quantize.qupvt.calc_xmin(r,o[g][x],_,a),this.quantize.outer_loop(r,_,a,c,x,d[x])),this.quantize.iteration_finish_one(i,g,x),Cw(_.part2_3_length<=aI.MAX_BITS_PER_CHANNEL),Cw(_.part2_3_length<=d[x])}}this.quantize.rv.ResvFrameEnd(i,l)}}var lI=cI;function _t(t,e,r,n){this.xlen=t,this.linmax=e,this.table=r,this.hlen=n}var me={};me.t1HB=[1,1,1,0];me.t2HB=[1,2,1,3,1,1,3,2,0];me.t3HB=[3,2,1,1,1,1,3,2,0];me.t5HB=[1,2,6,5,3,1,4,4,7,5,7,1,6,1,1,0];me.t6HB=[7,3,5,1,6,2,3,2,5,4,4,1,3,3,2,0];me.t7HB=[1,2,10,19,16,10,3,3,7,10,5,3,11,4,13,17,8,4,12,11,18,15,11,2,7,6,9,14,3,1,6,4,5,3,2,0];me.t8HB=[3,4,6,18,12,5,5,1,2,16,9,3,7,3,5,14,7,3,19,17,15,13,10,4,13,5,8,11,5,1,12,4,4,1,1,0];me.t9HB=[7,5,9,14,15,7,6,4,5,5,6,7,7,6,8,8,8,5,15,6,9,10,5,1,11,7,9,6,4,1,14,4,6,2,6,0];me.t10HB=[1,2,10,23,35,30,12,17,3,3,8,12,18,21,12,7,11,9,15,21,32,40,19,6,14,13,22,34,46,23,18,7,20,19,33,47,27,22,9,3,31,22,41,26,21,20,5,3,14,13,10,11,16,6,5,1,9,8,7,8,4,4,2,0];me.t11HB=[3,4,10,24,34,33,21,15,5,3,4,10,32,17,11,10,11,7,13,18,30,31,20,5,25,11,19,59,27,18,12,5,35,33,31,58,30,16,7,5,28,26,32,19,17,15,8,14,14,12,9,13,14,9,4,1,11,4,6,6,6,3,2,0];me.t12HB=[9,6,16,33,41,39,38,26,7,5,6,9,23,16,26,11,17,7,11,14,21,30,10,7,17,10,15,12,18,28,14,5,32,13,22,19,18,16,9,5,40,17,31,29,17,13,4,2,27,12,11,15,10,7,4,1,27,12,8,12,6,3,1,0];me.t13HB=[1,5,14,21,34,51,46,71,42,52,68,52,67,44,43,19,3,4,12,19,31,26,44,33,31,24,32,24,31,35,22,14,15,13,23,36,59,49,77,65,29,40,30,40,27,33,42,16,22,20,37,61,56,79,73,64,43,76,56,37,26,31,25,14,35,16,60,57,97,75,114,91,54,73,55,41,48,53,23,24,58,27,50,96,76,70,93,84,77,58,79,29,74,49,41,17,47,45,78,74,115,94,90,79,69,83,71,50,59,38,36,15,72,34,56,95,92,85,91,90,86,73,77,65,51,44,43,42,43,20,30,44,55,78,72,87,78,61,46,54,37,30,20,16,53,25,41,37,44,59,54,81,66,76,57,54,37,18,39,11,35,33,31,57,42,82,72,80,47,58,55,21,22,26,38,22,53,25,23,38,70,60,51,36,55,26,34,23,27,14,9,7,34,32,28,39,49,75,30,52,48,40,52,28,18,17,9,5,45,21,34,64,56,50,49,45,31,19,12,15,10,7,6,3,48,23,20,39,36,35,53,21,16,23,13,10,6,1,4,2,16,15,17,27,25,20,29,11,17,12,16,8,1,1,0,1];me.t15HB=[7,12,18,53,47,76,124,108,89,123,108,119,107,81,122,63,13,5,16,27,46,36,61,51,42,70,52,83,65,41,59,36,19,17,15,24,41,34,59,48,40,64,50,78,62,80,56,33,29,28,25,43,39,63,55,93,76,59,93,72,54,75,50,29,52,22,42,40,67,57,95,79,72,57,89,69,49,66,46,27,77,37,35,66,58,52,91,74,62,48,79,63,90,62,40,38,125,32,60,56,50,92,78,65,55,87,71,51,73,51,70,30,109,53,49,94,88,75,66,122,91,73,56,42,64,44,21,25,90,43,41,77,73,63,56,92,77,66,47,67,48,53,36,20,71,34,67,60,58,49,88,76,67,106,71,54,38,39,23,15,109,53,51,47,90,82,58,57,48,72,57,41,23,27,62,9,86,42,40,37,70,64,52,43,70,55,42,25,29,18,11,11,118,68,30,55,50,46,74,65,49,39,24,16,22,13,14,7,91,44,39,38,34,63,52,45,31,52,28,19,14,8,9,3,123,60,58,53,47,43,32,22,37,24,17,12,15,10,2,1,71,37,34,30,28,20,17,26,21,16,10,6,8,6,2,0];me.t16HB=[1,5,14,44,74,63,110,93,172,149,138,242,225,195,376,17,3,4,12,20,35,62,53,47,83,75,68,119,201,107,207,9,15,13,23,38,67,58,103,90,161,72,127,117,110,209,206,16,45,21,39,69,64,114,99,87,158,140,252,212,199,387,365,26,75,36,68,65,115,101,179,164,155,264,246,226,395,382,362,9,66,30,59,56,102,185,173,265,142,253,232,400,388,378,445,16,111,54,52,100,184,178,160,133,257,244,228,217,385,366,715,10,98,48,91,88,165,157,148,261,248,407,397,372,380,889,884,8,85,84,81,159,156,143,260,249,427,401,392,383,727,713,708,7,154,76,73,141,131,256,245,426,406,394,384,735,359,710,352,11,139,129,67,125,247,233,229,219,393,743,737,720,885,882,439,4,243,120,118,115,227,223,396,746,742,736,721,712,706,223,436,6,202,224,222,218,216,389,386,381,364,888,443,707,440,437,1728,4,747,211,210,208,370,379,734,723,714,1735,883,877,876,3459,865,2,377,369,102,187,726,722,358,711,709,866,1734,871,3458,870,434,0,12,10,7,11,10,17,11,9,13,12,10,7,5,3,1,3];me.t24HB=[15,13,46,80,146,262,248,434,426,669,653,649,621,517,1032,88,14,12,21,38,71,130,122,216,209,198,327,345,319,297,279,42,47,22,41,74,68,128,120,221,207,194,182,340,315,295,541,18,81,39,75,70,134,125,116,220,204,190,178,325,311,293,271,16,147,72,69,135,127,118,112,210,200,188,352,323,306,285,540,14,263,66,129,126,119,114,214,202,192,180,341,317,301,281,262,12,249,123,121,117,113,215,206,195,185,347,330,308,291,272,520,10,435,115,111,109,211,203,196,187,353,332,313,298,283,531,381,17,427,212,208,205,201,193,186,177,169,320,303,286,268,514,377,16,335,199,197,191,189,181,174,333,321,305,289,275,521,379,371,11,668,184,183,179,175,344,331,314,304,290,277,530,383,373,366,10,652,346,171,168,164,318,309,299,287,276,263,513,375,368,362,6,648,322,316,312,307,302,292,284,269,261,512,376,370,364,359,4,620,300,296,294,288,282,273,266,515,380,374,369,365,361,357,2,1033,280,278,274,267,264,259,382,378,372,367,363,360,358,356,0,43,20,19,17,15,13,11,9,7,6,4,7,5,3,1,3];me.t32HB=[1,10,8,20,12,20,16,32,14,12,24,0,28,16,24,16];me.t33HB=[15,28,26,48,22,40,36,64,14,24,20,32,12,16,8,0];me.t1l=[1,4,3,5];me.t2l=[1,4,7,4,5,7,6,7,8];me.t3l=[2,3,7,4,4,7,6,7,8];me.t5l=[1,4,7,8,4,5,8,9,7,8,9,10,8,8,9,10];me.t6l=[3,4,6,8,4,4,6,7,5,6,7,8,7,7,8,9];me.t7l=[1,4,7,9,9,10,4,6,8,9,9,10,7,7,9,10,10,11,8,9,10,11,11,11,8,9,10,11,11,12,9,10,11,12,12,12];me.t8l=[2,4,7,9,9,10,4,4,6,10,10,10,7,6,8,10,10,11,9,10,10,11,11,12,9,9,10,11,12,12,10,10,11,11,13,13];me.t9l=[3,4,6,7,9,10,4,5,6,7,8,10,5,6,7,8,9,10,7,7,8,9,9,10,8,8,9,9,10,11,9,9,10,10,11,11];me.t10l=[1,4,7,9,10,10,10,11,4,6,8,9,10,11,10,10,7,8,9,10,11,12,11,11,8,9,10,11,12,12,11,12,9,10,11,12,12,12,12,12,10,11,12,12,13,13,12,13,9,10,11,12,12,12,13,13,10,10,11,12,12,13,13,13];me.t11l=[2,4,6,8,9,10,9,10,4,5,6,8,10,10,9,10,6,7,8,9,10,11,10,10,8,8,9,11,10,12,10,11,9,10,10,11,11,12,11,12,9,10,11,12,12,13,12,13,9,9,9,10,11,12,12,12,9,9,10,11,12,12,12,12];me.t12l=[4,4,6,8,9,10,10,10,4,5,6,7,9,9,10,10,6,6,7,8,9,10,9,10,7,7,8,8,9,10,10,10,8,8,9,9,10,10,10,11,9,9,10,10,10,11,10,11,9,9,9,10,10,11,11,12,10,10,10,11,11,11,11,12];me.t13l=[1,5,7,8,9,10,10,11,10,11,12,12,13,13,14,14,4,6,8,9,10,10,11,11,11,11,12,12,13,14,14,14,7,8,9,10,11,11,12,12,11,12,12,13,13,14,15,15,8,9,10,11,11,12,12,12,12,13,13,13,13,14,15,15,9,9,11,11,12,12,13,13,12,13,13,14,14,15,15,16,10,10,11,12,12,12,13,13,13,13,14,13,15,15,16,16,10,11,12,12,13,13,13,13,13,14,14,14,15,15,16,16,11,11,12,13,13,13,14,14,14,14,15,15,15,16,18,18,10,10,11,12,12,13,13,14,14,14,14,15,15,16,17,17,11,11,12,12,13,13,13,15,14,15,15,16,16,16,18,17,11,12,12,13,13,14,14,15,14,15,16,15,16,17,18,19,12,12,12,13,14,14,14,14,15,15,15,16,17,17,17,18,12,13,13,14,14,15,14,15,16,16,17,17,17,18,18,18,13,13,14,15,15,15,16,16,16,16,16,17,18,17,18,18,14,14,14,15,15,15,17,16,16,19,17,17,17,19,18,18,13,14,15,16,16,16,17,16,17,17,18,18,21,20,21,18];me.t15l=[3,5,6,8,8,9,10,10,10,11,11,12,12,12,13,14,5,5,7,8,9,9,10,10,10,11,11,12,12,12,13,13,6,7,7,8,9,9,10,10,10,11,11,12,12,13,13,13,7,8,8,9,9,10,10,11,11,11,12,12,12,13,13,13,8,8,9,9,10,10,11,11,11,11,12,12,12,13,13,13,9,9,9,10,10,10,11,11,11,11,12,12,13,13,13,14,10,9,10,10,10,11,11,11,11,12,12,12,13,13,14,14,10,10,10,11,11,11,11,12,12,12,12,12,13,13,13,14,10,10,10,11,11,11,11,12,12,12,12,13,13,14,14,14,10,10,11,11,11,11,12,12,12,13,13,13,13,14,14,14,11,11,11,11,12,12,12,12,12,13,13,13,13,14,15,14,11,11,11,11,12,12,12,12,13,13,13,13,14,14,14,15,12,12,11,12,12,12,13,13,13,13,13,13,14,14,15,15,12,12,12,12,12,13,13,13,13,14,14,14,14,14,15,15,13,13,13,13,13,13,13,13,14,14,14,14,15,15,14,15,13,13,13,13,13,13,13,14,14,14,14,14,15,15,15,15];me.t16_5l=[1,5,7,9,10,10,11,11,12,12,12,13,13,13,14,11,4,6,8,9,10,11,11,11,12,12,12,13,14,13,14,11,7,8,9,10,11,11,12,12,13,12,13,13,13,14,14,12,9,9,10,11,11,12,12,12,13,13,14,14,14,15,15,13,10,10,11,11,12,12,13,13,13,14,14,14,15,15,15,12,10,10,11,11,12,13,13,14,13,14,14,15,15,15,16,13,11,11,11,12,13,13,13,13,14,14,14,14,15,15,16,13,11,11,12,12,13,13,13,14,14,15,15,15,15,17,17,13,11,12,12,13,13,13,14,14,15,15,15,15,16,16,16,13,12,12,12,13,13,14,14,15,15,15,15,16,15,16,15,14,12,13,12,13,14,14,14,14,15,16,16,16,17,17,16,13,13,13,13,13,14,14,15,16,16,16,16,16,16,15,16,14,13,14,14,14,14,15,15,15,15,17,16,16,16,16,18,14,15,14,14,14,15,15,16,16,16,18,17,17,17,19,17,14,14,15,13,14,16,16,15,16,16,17,18,17,19,17,16,14,11,11,11,12,12,13,13,13,14,14,14,14,14,14,14,12];me.t16l=[1,5,7,9,10,10,11,11,12,12,12,13,13,13,14,10,4,6,8,9,10,11,11,11,12,12,12,13,14,13,14,10,7,8,9,10,11,11,12,12,13,12,13,13,13,14,14,11,9,9,10,11,11,12,12,12,13,13,14,14,14,15,15,12,10,10,11,11,12,12,13,13,13,14,14,14,15,15,15,11,10,10,11,11,12,13,13,14,13,14,14,15,15,15,16,12,11,11,11,12,13,13,13,13,14,14,14,14,15,15,16,12,11,11,12,12,13,13,13,14,14,15,15,15,15,17,17,12,11,12,12,13,13,13,14,14,15,15,15,15,16,16,16,12,12,12,12,13,13,14,14,15,15,15,15,16,15,16,15,13,12,13,12,13,14,14,14,14,15,16,16,16,17,17,16,12,13,13,13,13,14,14,15,16,16,16,16,16,16,15,16,13,13,14,14,14,14,15,15,15,15,17,16,16,16,16,18,13,15,14,14,14,15,15,16,16,16,18,17,17,17,19,17,13,14,15,13,14,16,16,15,16,16,17,18,17,19,17,16,13,10,10,10,11,11,12,12,12,13,13,13,13,13,13,13,10];me.t24l=[4,5,7,8,9,10,10,11,11,12,12,12,12,12,13,10,5,6,7,8,9,10,10,11,11,11,12,12,12,12,12,10,7,7,8,9,9,10,10,11,11,11,11,12,12,12,13,9,8,8,9,9,10,10,10,11,11,11,11,12,12,12,12,9,9,9,9,10,10,10,10,11,11,11,12,12,12,12,13,9,10,9,10,10,10,10,11,11,11,11,12,12,12,12,12,9,10,10,10,10,10,11,11,11,11,12,12,12,12,12,13,9,11,10,10,10,11,11,11,11,12,12,12,12,12,13,13,10,11,11,11,11,11,11,11,11,11,12,12,12,12,13,13,10,11,11,11,11,11,11,11,12,12,12,12,12,13,13,13,10,12,11,11,11,11,12,12,12,12,12,12,13,13,13,13,10,12,12,11,11,11,12,12,12,12,12,12,13,13,13,13,10,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,10,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,10,13,12,12,12,12,12,12,13,13,13,13,13,13,13,13,10,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,6];me.t32l=[1,5,5,7,5,8,7,9,5,7,7,9,7,9,9,10];me.t33l=[4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8];me.ht=[new _t(0,0,null,null),new _t(2,0,me.t1HB,me.t1l),new _t(3,0,me.t2HB,me.t2l),new _t(3,0,me.t3HB,me.t3l),new _t(0,0,null,null),new _t(4,0,me.t5HB,me.t5l),new _t(4,0,me.t6HB,me.t6l),new _t(6,0,me.t7HB,me.t7l),new _t(6,0,me.t8HB,me.t8l),new _t(6,0,me.t9HB,me.t9l),new _t(8,0,me.t10HB,me.t10l),new _t(8,0,me.t11HB,me.t11l),new _t(8,0,me.t12HB,me.t12l),new _t(16,0,me.t13HB,me.t13l),new _t(0,0,null,me.t16_5l),new _t(16,0,me.t15HB,me.t15l),new _t(1,1,me.t16HB,me.t16l),new _t(2,3,me.t16HB,me.t16l),new _t(3,7,me.t16HB,me.t16l),new _t(4,15,me.t16HB,me.t16l),new _t(6,63,me.t16HB,me.t16l),new _t(8,255,me.t16HB,me.t16l),new _t(10,1023,me.t16HB,me.t16l),new _t(13,8191,me.t16HB,me.t16l),new _t(4,15,me.t24HB,me.t24l),new _t(5,31,me.t24HB,me.t24l),new _t(6,63,me.t24HB,me.t24l),new _t(7,127,me.t24HB,me.t24l),new _t(8,255,me.t24HB,me.t24l),new _t(9,511,me.t24HB,me.t24l),new _t(11,2047,me.t24HB,me.t24l),new _t(13,8191,me.t24HB,me.t24l),new _t(0,0,me.t32HB,me.t32l),new _t(0,0,me.t33HB,me.t33l)];me.largetbl=[65540,327685,458759,589832,655369,655370,720906,720907,786443,786444,786444,851980,851980,851980,917517,655370,262149,393222,524295,589832,655369,720906,720906,720907,786443,786443,786444,851980,917516,851980,917516,655370,458759,524295,589832,655369,720905,720906,786442,786443,851979,786443,851979,851980,851980,917516,917517,720905,589832,589832,655369,720905,720906,786442,786442,786443,851979,851979,917515,917516,917516,983052,983052,786441,655369,655369,720905,720906,786442,786442,851978,851979,851979,917515,917516,917516,983052,983052,983053,720905,655370,655369,720906,720906,786442,851978,851979,917515,851979,917515,917516,983052,983052,983052,1048588,786441,720906,720906,720906,786442,851978,851979,851979,851979,917515,917516,917516,917516,983052,983052,1048589,786441,720907,720906,786442,786442,851979,851979,851979,917515,917516,983052,983052,983052,983052,1114125,1114125,786442,720907,786443,786443,851979,851979,851979,917515,917515,983051,983052,983052,983052,1048588,1048589,1048589,786442,786443,786443,786443,851979,851979,917515,917515,983052,983052,983052,983052,1048588,983053,1048589,983053,851978,786444,851979,786443,851979,917515,917516,917516,917516,983052,1048588,1048588,1048589,1114125,1114125,1048589,786442,851980,851980,851979,851979,917515,917516,983052,1048588,1048588,1048588,1048588,1048589,1048589,983053,1048589,851978,851980,917516,917516,917516,917516,983052,983052,983052,983052,1114124,1048589,1048589,1048589,1048589,1179661,851978,983052,917516,917516,917516,983052,983052,1048588,1048588,1048589,1179661,1114125,1114125,1114125,1245197,1114125,851978,917517,983052,851980,917516,1048588,1048588,983052,1048589,1048589,1114125,1179661,1114125,1245197,1114125,1048589,851978,655369,655369,655369,720905,720905,786441,786441,786441,851977,851977,851977,851978,851978,851978,851978,655366];me.table23=[65538,262147,458759,262148,327684,458759,393222,458759,524296];me.table56=[65539,262148,458758,524296,262148,327684,524294,589831,458757,524294,589831,655368,524295,524295,589832,655369];me.bitrate_table=[[0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,-1],[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],[0,8,16,24,32,40,48,56,64,-1,-1,-1,-1,-1,-1,-1]];me.samplerate_table=[[22050,24e3,16e3,-1],[44100,48e3,32e3,-1],[11025,12e3,8e3,-1]];me.scfsi_band=[0,6,11,16,21];var c1=me,Jm,Dw;function m3(){if(Dw)return Jm;Dw=1;var t=u3,e=Zt,r=e.VbrMode,n=e.Float,s=e.Util,o=e.new_float,i=e.new_int,a=e.assert,c=hr(),d=p3,l=ou;u.Q_MAX=257,u.Q_MAX2=116,u.LARGE_BITS=1e5,u.IXMAX_VAL=8206;function u(){var h=l1(),p=null,g=null,x=null;this.setModules=function(D,I,Y){p=D,g=I,x=Y};function S(D){return a(0<=D+u.Q_MAX2&&D<u.Q_MAX),B[D+u.Q_MAX2]}this.IPOW20=function(D){return a(0<=D&&D<u.Q_MAX),U[D]};var k=2220446049250313e-31,_=u.IXMAX_VAL,m=_+2,$=u.Q_MAX,f=u.Q_MAX2;u.LARGE_BITS;var E=100;this.nr_of_sfb_block=[[[6,5,5,5],[9,9,9,9],[6,9,9,9]],[[6,5,7,3],[9,9,12,6],[6,9,12,6]],[[11,10,0,0],[18,18,0,0],[15,18,0,0]],[[7,7,7,0],[12,12,12,0],[6,15,12,0]],[[6,6,6,3],[12,9,9,6],[6,12,9,6]],[[8,8,5,0],[15,12,9,0],[6,18,9,0]]];var N=[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,2,0];this.pretab=N,this.sfBandIndex=[new t([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0,4,8,12,18,24,32,42,56,74,100,132,174,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,6,12,18,24,30,36,44,54,66,80,96,114,136,162,194,232,278,332,394,464,540,576],[0,4,8,12,18,26,36,48,62,80,104,136,180,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0,4,8,12,18,26,36,48,62,80,104,134,174,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,4,8,12,16,20,24,30,36,44,52,62,74,90,110,134,162,196,238,288,342,418,576],[0,4,8,12,16,22,30,40,52,66,84,106,136,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,4,8,12,16,20,24,30,36,42,50,60,72,88,106,128,156,190,230,276,330,384,576],[0,4,8,12,16,22,28,38,50,64,80,100,126,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,4,8,12,16,20,24,30,36,44,54,66,82,102,126,156,194,240,296,364,448,550,576],[0,4,8,12,16,22,30,42,58,78,104,138,180,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0/3,12/3,24/3,36/3,54/3,78/3,108/3,144/3,186/3,240/3,312/3,402/3,522/3,576/3],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0/3,12/3,24/3,36/3,54/3,78/3,108/3,144/3,186/3,240/3,312/3,402/3,522/3,576/3],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,12,24,36,48,60,72,88,108,132,160,192,232,280,336,400,476,566,568,570,572,574,576],[0/3,24/3,48/3,72/3,108/3,156/3,216/3,288/3,372/3,480/3,486/3,492/3,498/3,576/3],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0])];var B=o($+f+1),U=o($),C=o(m),q=o(m);this.adj43=q;function de(D,I){var Y=x.ATHformula(I,D);return Y-=E,Y=Math.pow(10,Y/10+D.ATHlower),Y}function A(D){for(var I=D.internal_flags.ATH.l,Y=D.internal_flags.ATH.psfb21,V=D.internal_flags.ATH.s,ee=D.internal_flags.ATH.psfb12,L=D.internal_flags,T=D.out_samplerate,y=0;y<c.SBMAX_l;y++){var v=L.scalefac_band.l[y],R=L.scalefac_band.l[y+1];I[y]=n.MAX_VALUE;for(var O=v;O<R;O++){var K=O*T/1152,se=de(D,K);I[y]=Math.min(I[y],se)}}for(var y=0;y<c.PSFB21;y++){var v=L.scalefac_band.psfb21[y],R=L.scalefac_band.psfb21[y+1];Y[y]=n.MAX_VALUE;for(var O=v;O<R;O++){var K=O*T/1152,se=de(D,K);Y[y]=Math.min(Y[y],se)}}for(var y=0;y<c.SBMAX_s;y++){var v=L.scalefac_band.s[y],R=L.scalefac_band.s[y+1];V[y]=n.MAX_VALUE;for(var O=v;O<R;O++){var K=O*T/384,se=de(D,K);V[y]=Math.min(V[y],se)}V[y]*=L.scalefac_band.s[y+1]-L.scalefac_band.s[y]}for(var y=0;y<c.PSFB12;y++){var v=L.scalefac_band.psfb12[y],R=L.scalefac_band.psfb12[y+1];ee[y]=n.MAX_VALUE;for(var O=v;O<R;O++){var K=O*T/384,se=de(D,K);ee[y]=Math.min(ee[y],se)}ee[y]*=L.scalefac_band.s[13]-L.scalefac_band.s[12]}if(D.noATH){for(var y=0;y<c.SBMAX_l;y++)I[y]=1e-20;for(var y=0;y<c.PSFB21;y++)Y[y]=1e-20;for(var y=0;y<c.SBMAX_s;y++)V[y]=1e-20;for(var y=0;y<c.PSFB12;y++)ee[y]=1e-20}L.ATH.floor=10*Math.log10(de(D,-1))}this.iteration_init=function(D){var I=D.internal_flags,Y=I.l3_side,V;if(I.iteration_init_init==0){for(I.iteration_init_init=1,Y.main_data_begin=0,A(D),C[0]=0,V=1;V<m;V++)C[V]=Math.pow(V,4/3);for(V=0;V<m-1;V++)q[V]=V+1-Math.pow(.5*(C[V]+C[V+1]),.75);for(q[V]=.5,V=0;V<$;V++)U[V]=Math.pow(2,(V-210)*-.1875);for(V=0;V<=$+f;V++)B[V]=Math.pow(2,(V-210-f)*.25);p.huffman_init(I);{var ee,L,T,y;for(V=D.exp_nspsytune>>2&63,V>=32&&(V-=64),ee=Math.pow(10,V/4/10),V=D.exp_nspsytune>>8&63,V>=32&&(V-=64),L=Math.pow(10,V/4/10),V=D.exp_nspsytune>>14&63,V>=32&&(V-=64),T=Math.pow(10,V/4/10),V=D.exp_nspsytune>>20&63,V>=32&&(V-=64),y=T*Math.pow(10,V/4/10),V=0;V<c.SBMAX_l;V++){var v;V<=6?v=ee:V<=13?v=L:V<=20?v=T:v=y,I.nsPsy.longfact[V]=v}for(V=0;V<c.SBMAX_s;V++){var v;V<=5?v=ee:V<=10?v=L:V<=11?v=T:v=y,I.nsPsy.shortfact[V]=v}}}},this.on_pe=function(D,I,Y,V,ee,L){var T=D.internal_flags,y=0,v,R=i(2),O,K=new d(y),se=g.ResvMaxBits(D,V,K,L);y=K.bits;var F=y+se;for(F>l.MAX_BITS_PER_GRANULE&&(F=l.MAX_BITS_PER_GRANULE),v=0,O=0;O<T.channels_out;++O)Y[O]=Math.min(l.MAX_BITS_PER_CHANNEL,y/T.channels_out),R[O]=0|Y[O]*I[ee][O]/700-Y[O],R[O]>V*3/4&&(R[O]=V*3/4),R[O]<0&&(R[O]=0),R[O]+Y[O]>l.MAX_BITS_PER_CHANNEL&&(R[O]=Math.max(0,l.MAX_BITS_PER_CHANNEL-Y[O])),v+=R[O];if(v>se)for(O=0;O<T.channels_out;++O)R[O]=se*R[O]/v;for(O=0;O<T.channels_out;++O)Y[O]+=R[O],se-=R[O];for(v=0,O=0;O<T.channels_out;++O)v+=Y[O];if(v>l.MAX_BITS_PER_GRANULE){var Q=0;for(O=0;O<T.channels_out;++O)Y[O]*=l.MAX_BITS_PER_GRANULE,Y[O]/=v,Q+=Y[O]}return F},this.reduce_side=function(D,I,Y,V){a(D[0]+D[1]<=l.MAX_BITS_PER_GRANULE);var ee=.33*(.5-I)/.5;ee<0&&(ee=0),ee>.5&&(ee=.5);var L=0|ee*.5*(D[0]+D[1]);L>l.MAX_BITS_PER_CHANNEL-D[0]&&(L=l.MAX_BITS_PER_CHANNEL-D[0]),L<0&&(L=0),D[1]>=125&&(D[1]-L>125?(D[0]<Y&&(D[0]+=L),D[1]-=L):(D[0]+=D[1]-125,D[1]=125)),L=D[0]+D[1],L>V&&(D[0]=V*D[0]/L,D[1]=V*D[1]/L),a(D[0]<=l.MAX_BITS_PER_CHANNEL),a(D[1]<=l.MAX_BITS_PER_CHANNEL),a(D[0]+D[1]<=l.MAX_BITS_PER_GRANULE)},this.athAdjust=function(D,I,Y){var V=90.30873362,ee=94.82444863,L=s.FAST_LOG10_X(I,10),T=D*D,y=0;return L-=Y,T>1e-20&&(y=1+s.FAST_LOG10_X(T,10/V)),y<0&&(y=0),L*=y,L+=Y+V-ee,Math.pow(10,.1*L)},this.calc_xmin=function(D,I,Y,V){var ee=0,L=D.internal_flags,T,y=0,v=0,R=L.ATH,O=Y.xr,K=D.VBR==r.vbr_mtrh?1:0,se=L.masking_lower;for((D.VBR==r.vbr_mtrh||D.VBR==r.vbr_mt)&&(se=1),T=0;T<Y.psy_lmax;T++){var F,Q,ue,ge,ke,Re;D.VBR==r.vbr_rh||D.VBR==r.vbr_mtrh?Q=athAdjust(R.adjust,R.l[T],R.floor):Q=R.adjust*R.l[T],ke=Y.width[T],ue=Q/ke,ge=k,Re=ke>>1,F=0;do{var Te,Se;Te=O[y]*O[y],F+=Te,ge+=Te<ue?Te:ue,y++,Se=O[y]*O[y],F+=Se,ge+=Se<ue?Se:ue,y++}while(--Re>0);if(F>Q&&v++,T==c.SBPSY_l){var Ce=Q*L.nsPsy.longfact[T];ge<Ce&&(ge=Ce)}if(K!=0&&(Q=ge),!D.ATHonly){var St=I.en.l[T];if(St>0){var Ce;Ce=F*I.thm.l[T]*se/St,K!=0&&(Ce*=L.nsPsy.longfact[T]),Q<Ce&&(Q=Ce)}}K!=0?V[ee++]=Q:V[ee++]=Q*L.nsPsy.longfact[T]}var Fr=575;if(Y.block_type!=c.SHORT_TYPE)for(var w=576;w--!=0&&h.EQ(O[w],0);)Fr=w;Y.max_nonzero_coeff=Fr;for(var P=Y.sfb_smin;T<Y.psymax;P++,T+=3){var ke,xe,Pe;for(D.VBR==r.vbr_rh||D.VBR==r.vbr_mtrh?Pe=athAdjust(R.adjust,R.s[P],R.floor):Pe=R.adjust*R.s[P],ke=Y.width[T],xe=0;xe<3;xe++){var F=0,Q,ue,ge,Re=ke>>1;ue=Pe/ke,ge=k;do{var Te,Se;Te=O[y]*O[y],F+=Te,ge+=Te<ue?Te:ue,y++,Se=O[y]*O[y],F+=Se,ge+=Se<ue?Se:ue,y++}while(--Re>0);if(F>Pe&&v++,P==c.SBPSY_s){var Ce=Pe*L.nsPsy.shortfact[P];ge<Ce&&(ge=Ce)}if(K!=0?Q=ge:Q=Pe,!D.ATHonly&&!D.ATHshort){var St=I.en.s[P][xe];if(St>0){var Ce;Ce=F*I.thm.s[P][xe]*se/St,K!=0&&(Ce*=L.nsPsy.shortfact[P]),Q<Ce&&(Q=Ce)}}K!=0?V[ee++]=Q:V[ee++]=Q*L.nsPsy.shortfact[P]}D.useTemporal&&(V[ee-3]>V[ee-3+1]&&(V[ee-3+1]+=(V[ee-3]-V[ee-3+1])*L.decay),V[ee-3+1]>V[ee-3+2]&&(V[ee-3+2]+=(V[ee-3+1]-V[ee-3+2])*L.decay))}return v};function b(D){this.s=D}this.calc_noise_core=function(D,I,Y,V){var ee=0,L=I.s,T=D.l3_enc;if(L>D.count1)for(;Y--!=0;){var y;y=D.xr[L],L++,ee+=y*y,y=D.xr[L],L++,ee+=y*y}else if(L>D.big_values){var v=o(2);for(v[0]=0,v[1]=V;Y--!=0;){var y;y=Math.abs(D.xr[L])-v[T[L]],L++,ee+=y*y,y=Math.abs(D.xr[L])-v[T[L]],L++,ee+=y*y}}else for(;Y--!=0;){var y;y=Math.abs(D.xr[L])-C[T[L]]*V,L++,ee+=y*y,y=Math.abs(D.xr[L])-C[T[L]]*V,L++,ee+=y*y}return I.s=L,ee},this.calc_noise=function(D,I,Y,V,ee){var L=0,T=0,y,v,R=0,O=0,K=0,se=-20,F=0,Q=D.scalefac,ue=0;for(V.over_SSD=0,y=0;y<D.psymax;y++){var ge=D.global_gain-(Q[ue++]+(D.preflag!=0?N[y]:0)<<D.scalefac_scale+1)-D.subblock_gain[D.window[y]]*8,ke=0;if(ee!=null&&ee.step[y]==ge)ke=ee.noise[y],F+=D.width[y],Y[L++]=ke/I[T++],ke=ee.noise_log[y];else{var Re=S(ge);if(v=D.width[y]>>1,F+D.width[y]>D.max_nonzero_coeff){var Te;Te=D.max_nonzero_coeff-F+1,Te>0?v=Te>>1:v=0}var Se=new b(F);ke=this.calc_noise_core(D,Se,v,Re),F=Se.s,ee!=null&&(ee.step[y]=ge,ee.noise[y]=ke),ke=Y[L++]=ke/I[T++],ke=s.FAST_LOG10(Math.max(ke,1e-20)),ee!=null&&(ee.noise_log[y]=ke)}if(ee!=null&&(ee.global_gain=D.global_gain),K+=ke,ke>0){var Ce;Ce=Math.max(0|ke*10+.5,1),V.over_SSD+=Ce*Ce,R++,O+=ke}se=Math.max(se,ke)}return V.over_count=R,V.tot_noise=K,V.over_noise=O,V.max_noise=se,R},this.set_pinfo=function(D,I,Y,V,ee){var L=D.internal_flags,T,y,v,R,O,K=I.scalefac_scale==0?.5:1,se=I.scalefac,F=o(L3Side.SFBMAX),Q=o(L3Side.SFBMAX),ue=new CalcNoiseResult;calc_xmin(D,Y,I,F),calc_noise(I,F,Q,ue,null);var ge=0;for(y=I.sfb_lmax,I.block_type!=c.SHORT_TYPE&&I.mixed_block_flag==0&&(y=22),T=0;T<y;T++){var ke=L.scalefac_band.l[T],Re=L.scalefac_band.l[T+1],Te=Re-ke;for(R=0;ge<Re;ge++)R+=I.xr[ge]*I.xr[ge];R/=Te,O=1e15,L.pinfo.en[V][ee][T]=O*R,L.pinfo.xfsf[V][ee][T]=O*F[T]*Q[T]/Te,Y.en.l[T]>0&&!D.ATHonly?R=R/Y.en.l[T]:R=0,L.pinfo.thr[V][ee][T]=O*Math.max(R*Y.thm.l[T],L.ATH.l[T]),L.pinfo.LAMEsfb[V][ee][T]=0,I.preflag!=0&&T>=11&&(L.pinfo.LAMEsfb[V][ee][T]=-K*N[T]),T<c.SBPSY_l&&(a(se[T]>=0),L.pinfo.LAMEsfb[V][ee][T]-=K*se[T])}if(I.block_type==c.SHORT_TYPE)for(y=T,T=I.sfb_smin;T<c.SBMAX_s;T++)for(var ke=L.scalefac_band.s[T],Re=L.scalefac_band.s[T+1],Te=Re-ke,Se=0;Se<3;Se++){for(R=0,v=ke;v<Re;v++)R+=I.xr[ge]*I.xr[ge],ge++;R=Math.max(R/Te,1e-20),O=1e15,L.pinfo.en_s[V][ee][3*T+Se]=O*R,L.pinfo.xfsf_s[V][ee][3*T+Se]=O*F[y]*Q[y]/Te,Y.en.s[T][Se]>0?R=R/Y.en.s[T][Se]:R=0,(D.ATHonly||D.ATHshort)&&(R=0),L.pinfo.thr_s[V][ee][3*T+Se]=O*Math.max(R*Y.thm.s[T][Se],L.ATH.s[T]),L.pinfo.LAMEsfb_s[V][ee][3*T+Se]=-2*I.subblock_gain[Se],T<c.SBPSY_s&&(L.pinfo.LAMEsfb_s[V][ee][3*T+Se]-=K*se[y]),y++}L.pinfo.LAMEqss[V][ee]=I.global_gain,L.pinfo.LAMEmainbits[V][ee]=I.part2_3_length+I.part2_length,L.pinfo.LAMEsfbits[V][ee]=I.part2_length,L.pinfo.over[V][ee]=ue.over_count,L.pinfo.max_noise[V][ee]=ue.max_noise*10,L.pinfo.over_noise[V][ee]=ue.over_noise*10,L.pinfo.tot_noise[V][ee]=ue.tot_noise*10,L.pinfo.over_SSD[V][ee]=ue.over_SSD}}return Jm=u,Jm}var Qm,Lw;function g3(){if(Lw)return Qm;Lw=1;var t=Zt,e=t.System,r=t.Arrays,n=t.new_int,s=t.assert,o=hr(),i=c1,a=o1,c=m3();function d(){var l=null;this.qupvt=null,this.setModules=function(L){this.qupvt=L,l=L};function u(L){this.bits=0|L}var h=[[0,0],[0,0],[0,0],[0,0],[0,0],[0,1],[1,1],[1,1],[1,2],[2,2],[2,3],[2,3],[3,4],[3,4],[3,4],[4,5],[4,5],[4,6],[5,6],[5,6],[5,7],[6,7],[6,7]];function p(L,T,y,v,R,O){var K=.5946/T;for(L=L>>1;L--!=0;)R[O++]=K>y[v++]?0:1,R[O++]=K>y[v++]?0:1}function g(L,T,y,v,R,O){L=L>>1;var K=L%2;for(L=L>>1;L--!=0;){var se,F,Q,ue,ge,ke,Re,Te;se=y[v++]*T,F=y[v++]*T,ge=0|se,Q=y[v++]*T,ke=0|F,ue=y[v++]*T,Re=0|Q,se+=l.adj43[ge],Te=0|ue,F+=l.adj43[ke],R[O++]=0|se,Q+=l.adj43[Re],R[O++]=0|F,ue+=l.adj43[Te],R[O++]=0|Q,R[O++]=0|ue}if(K!=0){var se,F,ge,ke;se=y[v++]*T,F=y[v++]*T,ge=0|se,ke=0|F,se+=l.adj43[ge],F+=l.adj43[ke],R[O++]=0|se,R[O++]=0|F}}function x(L,T,y,v,R){var O,K,se=0,F,Q=0,ue=0,ge=0,ke=T,Re=0,Te=ke,Se=0,Ce=L,St=0;for(F=R!=null&&v.global_gain==R.global_gain,v.block_type==o.SHORT_TYPE?K=38:K=21,O=0;O<=K;O++){var Fr=-1;if((F||v.block_type==o.NORM_TYPE)&&(Fr=v.global_gain-(v.scalefac[O]+(v.preflag!=0?l.pretab[O]:0)<<v.scalefac_scale+1)-v.subblock_gain[v.window[O]]*8),s(v.width[O]>=0),F&&R.step[O]==Fr)Q!=0&&(g(Q,y,Ce,St,Te,Se),Q=0),ue!=0&&(p(ue,y,Ce,St,Te,Se),ue=0);else{var w=v.width[O];if(se+v.width[O]>v.max_nonzero_coeff){var P;P=v.max_nonzero_coeff-se+1,r.fill(T,v.max_nonzero_coeff,576,0),w=P,w<0&&(w=0),O=K+1}if(Q==0&&ue==0&&(Te=ke,Se=Re,Ce=L,St=ge),R!=null&&R.sfb_count1>0&&O>=R.sfb_count1&&R.step[O]>0&&Fr>=R.step[O]?(Q!=0&&(g(Q,y,Ce,St,Te,Se),Q=0,Te=ke,Se=Re,Ce=L,St=ge),ue+=w):(ue!=0&&(p(ue,y,Ce,St,Te,Se),ue=0,Te=ke,Se=Re,Ce=L,St=ge),Q+=w),w<=0){ue!=0&&(p(ue,y,Ce,St,Te,Se),ue=0),Q!=0&&(g(Q,y,Ce,St,Te,Se),Q=0);break}}O<=K&&(Re+=v.width[O],ge+=v.width[O],se+=v.width[O])}Q!=0&&(g(Q,y,Ce,St,Te,Se),Q=0),ue!=0&&(p(ue,y,Ce,St,Te,Se),ue=0)}function S(L,T,y){var v=0,R=0;do{var O=L[T++],K=L[T++];v<O&&(v=O),R<K&&(R=K)}while(T<y);return v<R&&(v=R),v}function k(L,T,y,v,R,O){var K=i.ht[v].xlen*65536+i.ht[R].xlen,se=0,F;do{var Q=L[T++],ue=L[T++];Q!=0&&(Q>14&&(Q=15,se+=K),Q*=16),ue!=0&&(ue>14&&(ue=15,se+=K),Q+=ue),se+=i.largetbl[Q]}while(T<y);return F=se&65535,se>>=16,se>F&&(se=F,v=R),O.bits+=se,v}function _(L,T,y,v){var R=0,O=i.ht[1].hlen;do{var K=L[T+0]*2+L[T+1];T+=2,R+=O[K]}while(T<y);return v.bits+=R,1}function m(L,T,y,v,R){var O=0,K,se=i.ht[v].xlen,F;v==2?F=i.table23:F=i.table56;do{var Q=L[T+0]*se+L[T+1];T+=2,O+=F[Q]}while(T<y);return K=O&65535,O>>=16,O>K&&(O=K,v++),R.bits+=O,v}function $(L,T,y,v,R){var O=0,K=0,se=0,F=i.ht[v].xlen,Q=i.ht[v].hlen,ue=i.ht[v+1].hlen,ge=i.ht[v+2].hlen;do{var ke=L[T+0]*F+L[T+1];T+=2,O+=Q[ke],K+=ue[ke],se+=ge[ke]}while(T<y);var Re=v;return O>K&&(O=K,Re++),O>se&&(O=se,Re=v+2),R.bits+=O,Re}var f=[1,2,5,7,7,10,10,13,13,13,13,13,13,13,13];function E(L,T,y,v){var R=S(L,T,y);switch(R){case 0:return R;case 1:return _(L,T,y,v);case 2:case 3:return m(L,T,y,f[R-1],v);case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:return $(L,T,y,f[R-1],v);default:if(R>c.IXMAX_VAL)return v.bits=c.LARGE_BITS,-1;R-=15;var O;for(O=24;O<32&&!(i.ht[O].linmax>=R);O++);var K;for(K=O-8;K<24&&!(i.ht[K].linmax>=R);K++);return k(L,T,y,K,O,v)}}this.noquant_count_bits=function(L,T,y){var v=T.l3_enc,R=Math.min(576,T.max_nonzero_coeff+2>>1<<1);for(y!=null&&(y.sfb_count1=0);R>1&&!(v[R-1]|v[R-2]);R-=2);T.count1=R;for(var O=0,K=0;R>3;R-=4){var se;if(((v[R-1]|v[R-2]|v[R-3]|v[R-4])&2147483647)>1)break;se=((v[R-4]*2+v[R-3])*2+v[R-2])*2+v[R-1],O+=i.t32l[se],K+=i.t33l[se]}var F=O;if(T.count1table_select=0,O>K&&(F=K,T.count1table_select=1),T.count1bits=F,T.big_values=R,R==0)return F;if(T.block_type==o.SHORT_TYPE)O=3*L.scalefac_band.s[3],O>T.big_values&&(O=T.big_values),K=T.big_values;else if(T.block_type==o.NORM_TYPE){if(O=T.region0_count=L.bv_scf[R-2],K=T.region1_count=L.bv_scf[R-1],s(O+K+2<o.SBPSY_l),K=L.scalefac_band.l[O+K+2],O=L.scalefac_band.l[O+1],K<R){var Q=new u(F);T.table_select[2]=E(v,K,R,Q),F=Q.bits}}else T.region0_count=7,T.region1_count=o.SBMAX_l-1-7-1,O=L.scalefac_band.l[8],K=R,O>K&&(O=K);if(O=Math.min(O,R),K=Math.min(K,R),0<O){var Q=new u(F);T.table_select[0]=E(v,0,O,Q),F=Q.bits}if(O<K){var Q=new u(F);T.table_select[1]=E(v,O,K,Q),F=Q.bits}if(L.use_best_huffman==2&&(T.part2_3_length=F,best_huffman_divide(L,T),F=T.part2_3_length),y!=null&&T.block_type==o.NORM_TYPE){for(var ue=0;L.scalefac_band.l[ue]<T.big_values;)ue++;y.sfb_count1=ue}return F},this.count_bits=function(L,T,y,v){var R=y.l3_enc,O=c.IXMAX_VAL/l.IPOW20(y.global_gain);if(y.xrpow_max>O)return c.LARGE_BITS;if(x(T,R,l.IPOW20(y.global_gain),y,v),L.substep_shaping&2)for(var K=0,se=y.global_gain+y.scalefac_scale,F=.634521682242439/l.IPOW20(se),Q=0;Q<y.sfbmax;Q++){var ue=y.width[Q];if(L.pseudohalf[Q]==0)K+=ue;else{var ge;for(ge=K,K+=ue;ge<K;++ge)R[ge]=T[ge]>=F?R[ge]:0}}return this.noquant_count_bits(L,y,v)};function N(L,T,y,v,R,O,K){for(var se=T.big_values,F=0;F<=22;F++)v[F]=c.LARGE_BITS;for(var F=0;F<16;F++){var Q=L.scalefac_band.l[F+1];if(Q>=se)break;var ue=0,ge=new u(ue),ke=E(y,0,Q,ge);ue=ge.bits;for(var Re=0;Re<8;Re++){var Te=L.scalefac_band.l[F+Re+2];if(Te>=se)break;var Se=ue;ge=new u(Se);var Ce=E(y,Q,Te,ge);Se=ge.bits,v[F+Re]>Se&&(v[F+Re]=Se,R[F+Re]=F,O[F+Re]=ke,K[F+Re]=Ce)}}}function B(L,T,y,v,R,O,K,se){for(var F=T.big_values,Q=2;Q<o.SBMAX_l+1;Q++){var ue=L.scalefac_band.l[Q];if(ue>=F)break;var ge=R[Q-2]+T.count1bits;if(y.part2_3_length<=ge)break;var ke=new u(ge),Re=E(v,ue,F,ke);ge=ke.bits,!(y.part2_3_length<=ge)&&(y.assign(T),y.part2_3_length=ge,y.region0_count=O[Q-2],y.region1_count=Q-2-O[Q-2],y.table_select[0]=K[Q-2],y.table_select[1]=se[Q-2],y.table_select[2]=Re)}}this.best_huffman_divide=function(L,T){var y=new a,v=T.l3_enc,R=n(23),O=n(23),K=n(23),se=n(23);if(!(T.block_type==o.SHORT_TYPE&&L.mode_gr==1)){y.assign(T),T.block_type==o.NORM_TYPE&&(N(L,T,v,R,O,K,se),B(L,y,T,v,R,O,K,se));var F=y.big_values;if(!(F==0||(v[F-2]|v[F-1])>1)&&(F=T.count1+2,!(F>576))){y.assign(T),y.count1=F;for(var Q=0,ue=0;F>y.big_values;F-=4){var ge=((v[F-4]*2+v[F-3])*2+v[F-2])*2+v[F-1];Q+=i.t32l[ge],ue+=i.t33l[ge]}if(y.big_values=F,y.count1table_select=0,Q>ue&&(Q=ue,y.count1table_select=1),y.count1bits=Q,y.block_type==o.NORM_TYPE)B(L,y,T,v,R,O,K,se);else{if(y.part2_3_length=Q,Q=L.scalefac_band.l[8],Q>F&&(Q=F),Q>0){var ke=new u(y.part2_3_length);y.table_select[0]=E(v,0,Q,ke),y.part2_3_length=ke.bits}if(F>Q){var ke=new u(y.part2_3_length);y.table_select[1]=E(v,Q,F,ke),y.part2_3_length=ke.bits}T.part2_3_length>y.part2_3_length&&T.assign(y)}}}};var U=[1,1,1,1,8,2,2,2,4,4,4,8,8,8,16,16],C=[1,2,4,8,1,2,4,8,2,4,8,2,4,8,4,8],q=[0,0,0,0,3,1,1,1,2,2,2,3,3,3,4,4],de=[0,1,2,3,0,1,2,3,1,2,3,1,2,3,2,3];d.slen1_tab=q,d.slen2_tab=de;function A(L,T){for(var y,v=T.tt[1][L],R=T.tt[0][L],O=0;O<i.scfsi_band.length-1;O++){for(y=i.scfsi_band[O];y<i.scfsi_band[O+1]&&!(R.scalefac[y]!=v.scalefac[y]&&v.scalefac[y]>=0);y++);if(y==i.scfsi_band[O+1]){for(y=i.scfsi_band[O];y<i.scfsi_band[O+1];y++)v.scalefac[y]=-1;T.scfsi[L][O]=1}}var K=0,se=0;for(y=0;y<11;y++)v.scalefac[y]!=-1&&(se++,K<v.scalefac[y]&&(K=v.scalefac[y]));for(var F=0,Q=0;y<o.SBPSY_l;y++)v.scalefac[y]!=-1&&(Q++,F<v.scalefac[y]&&(F=v.scalefac[y]));for(var O=0;O<16;O++)if(K<U[O]&&F<C[O]){var ue=q[O]*se+de[O]*Q;v.part2_length>ue&&(v.part2_length=ue,v.scalefac_compress=O)}}this.best_scalefac_store=function(L,T,y,v){var R=v.tt[T][y],O,K,se,F,Q=0;for(se=0,O=0;O<R.sfbmax;O++){var ue=R.width[O];for(se+=ue,F=-ue;F<0&&R.l3_enc[F+se]==0;F++);F==0&&(R.scalefac[O]=Q=-2)}if(R.scalefac_scale==0&&R.preflag==0){var ge=0;for(O=0;O<R.sfbmax;O++)R.scalefac[O]>0&&(ge|=R.scalefac[O]);if(!(ge&1)&&ge!=0){for(O=0;O<R.sfbmax;O++)R.scalefac[O]>0&&(R.scalefac[O]>>=1);R.scalefac_scale=Q=1}}if(R.preflag==0&&R.block_type!=o.SHORT_TYPE&&L.mode_gr==2){for(O=11;O<o.SBPSY_l&&!(R.scalefac[O]<l.pretab[O]&&R.scalefac[O]!=-2);O++);if(O==o.SBPSY_l){for(O=11;O<o.SBPSY_l;O++)R.scalefac[O]>0&&(R.scalefac[O]-=l.pretab[O]);R.preflag=Q=1}}for(K=0;K<4;K++)v.scfsi[y][K]=0;for(L.mode_gr==2&&T==1&&v.tt[0][y].block_type!=o.SHORT_TYPE&&v.tt[1][y].block_type!=o.SHORT_TYPE&&(A(y,v),Q=0),O=0;O<R.sfbmax;O++)R.scalefac[O]==-2&&(R.scalefac[O]=0);Q!=0&&(L.mode_gr==2?this.scale_bitcount(R):this.scale_bitcount_lsf(L,R))};function b(L,T){for(var y=0;y<T;++y)if(L[y]<0)return!1;return!0}var D=[0,18,36,54,54,36,54,72,54,72,90,72,90,108,108,126],I=[0,18,36,54,51,35,53,71,52,70,88,69,87,105,104,122],Y=[0,10,20,30,33,21,31,41,32,42,52,43,53,63,64,74];this.scale_bitcount=function(L){var T,y,v=0,R=0,O,K=L.scalefac;if(s(b(K,L.sfbmax)),L.block_type==o.SHORT_TYPE)O=D,L.mixed_block_flag!=0&&(O=I);else if(O=Y,L.preflag==0){for(y=11;y<o.SBPSY_l&&!(K[y]<l.pretab[y]);y++);if(y==o.SBPSY_l)for(L.preflag=1,y=11;y<o.SBPSY_l;y++)K[y]-=l.pretab[y]}for(y=0;y<L.sfbdivide;y++)v<K[y]&&(v=K[y]);for(;y<L.sfbmax;y++)R<K[y]&&(R=K[y]);for(L.part2_length=c.LARGE_BITS,T=0;T<16;T++)v<U[T]&&R<C[T]&&L.part2_length>O[T]&&(L.part2_length=O[T],L.scalefac_compress=T);return L.part2_length==c.LARGE_BITS};var V=[[15,15,7,7],[15,15,7,0],[7,3,0,0],[15,31,31,0],[7,7,7,0],[3,3,0,0]];this.scale_bitcount_lsf=function(L,T){var y,v,R,O,K,se,F,Q,ue=n(4),ge=T.scalefac;for(T.preflag!=0?y=2:y=0,F=0;F<4;F++)ue[F]=0;if(T.block_type==o.SHORT_TYPE){v=1;var ke=l.nr_of_sfb_block[y][v];for(Q=0,R=0;R<4;R++)for(O=ke[R]/3,F=0;F<O;F++,Q++)for(K=0;K<3;K++)ge[Q*3+K]>ue[R]&&(ue[R]=ge[Q*3+K])}else{v=0;var ke=l.nr_of_sfb_block[y][v];for(Q=0,R=0;R<4;R++)for(O=ke[R],F=0;F<O;F++,Q++)ge[Q]>ue[R]&&(ue[R]=ge[Q])}for(se=!1,R=0;R<4;R++)ue[R]>V[y][R]&&(se=!0);if(!se){var Re,Te,Se,Ce;for(T.sfb_partition_table=l.nr_of_sfb_block[y][v],R=0;R<4;R++)T.slen[R]=ee[ue[R]];switch(Re=T.slen[0],Te=T.slen[1],Se=T.slen[2],Ce=T.slen[3],y){case 0:T.scalefac_compress=(Re*5+Te<<4)+(Se<<2)+Ce;break;case 1:T.scalefac_compress=400+(Re*5+Te<<2)+Se;break;case 2:T.scalefac_compress=500+Re*3+Te;break;default:e.err.printf(`intensity stereo not implemented yet
193
- `);break}}if(!se)for(s(T.sfb_partition_table!=null),T.part2_length=0,R=0;R<4;R++)T.part2_length+=T.slen[R]*T.sfb_partition_table[R];return se};var ee=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];this.huffman_init=function(L){for(var T=2;T<=576;T+=2){for(var y=0,v;L.scalefac_band.l[++y]<T;);for(v=h[y][0];L.scalefac_band.l[v+1]>T;)v--;for(v<0&&(v=h[y][0]),L.bv_scf[T-2]=v,v=h[y][1];L.scalefac_band.l[v+L.bv_scf[T-2]+2]>T;)v--;v<0&&(v=h[y][1]),L.bv_scf[T-1]=v}}}return Qm=d,Qm}var e1,Zw;function l1(){if(Zw)return e1;Zw=1;var t=Zt,e=t.System,r=t.Arrays,n=t.new_byte,s=t.new_float_n,o=t.new_int,i=t.assert,a=g3(),c=c1,d=hr(),l=ou;u.EQ=function(h,p){return Math.abs(h)>Math.abs(p)?Math.abs(h-p)<=Math.abs(h)*1e-6:Math.abs(h-p)<=Math.abs(p)*1e-6},u.NEQ=function(h,p){return!u.EQ(h,p)};function u(){var h=u1(),p=this,g=32773,x=null,S=null,k=null,_=null;this.setModules=function(T,y,v,R){x=T,S=y,k=v,_=R};var m=null,$=0,f=0,E=0;this.getframebits=function(T){var y=T.internal_flags,v;y.bitrate_index!=0?v=c.bitrate_table[T.version][y.bitrate_index]:v=T.brate;var R=0|(T.version+1)*72e3*v/T.out_samplerate+y.padding;return 8*R};function N(T){e.arraycopy(T.header[T.w_ptr].buf,0,m,f,T.sideinfo_len),f+=T.sideinfo_len,$+=T.sideinfo_len*8,T.w_ptr=T.w_ptr+1&l.MAX_HEADER_BUF-1}function B(T,y,v){for(;v>0;){var R;E==0&&(E=8,f++,i(f<h.LAME_MAXMP3BUFFER),i(T.header[T.w_ptr].write_timing>=$),T.header[T.w_ptr].write_timing==$&&N(T),m[f]=0),R=Math.min(v,E),v-=R,E-=R,m[f]|=y>>v<<E,$+=R}}function U(T,y,v){for(;v>0;){var R;E==0&&(E=8,f++,i(f<h.LAME_MAXMP3BUFFER),m[f]=0),R=Math.min(v,E),v-=R,E-=R,m[f]|=y>>v<<E,$+=R}}function C(T,y){var v=T.internal_flags,R;if(y>=8&&(B(v,76,8),y-=8),y>=8&&(B(v,65,8),y-=8),y>=8&&(B(v,77,8),y-=8),y>=8&&(B(v,69,8),y-=8),y>=32){var O=k.getLameShortVersion();if(y>=32)for(R=0;R<O.length&&y>=8;++R)y-=8,B(v,O.charAt(R),8)}for(;y>=1;y-=1)B(v,v.ancillary_flag,1),v.ancillary_flag^=T.disable_reservoir?0:1}function q(T,y,v){for(var R=T.header[T.h_ptr].ptr;v>0;){var O=Math.min(v,8-(R&7));v-=O,T.header[T.h_ptr].buf[R>>3]|=y>>v<<8-(R&7)-O,R+=O}T.header[T.h_ptr].ptr=R}function de(T,y){T<<=8;for(var v=0;v<8;v++)T<<=1,y<<=1,(y^T)&65536&&(y^=g);return y}this.CRC_writeheader=function(T,y){var v=65535;v=de(y[2]&255,v),v=de(y[3]&255,v);for(var R=6;R<T.sideinfo_len;R++)v=de(y[R]&255,v);y[4]=byte(v>>8),y[5]=byte(v&255)};function A(T,y){var v=T.internal_flags,R,O,K;if(R=v.l3_side,v.header[v.h_ptr].ptr=0,r.fill(v.header[v.h_ptr].buf,0,v.sideinfo_len,0),T.out_samplerate<16e3?q(v,4094,12):q(v,4095,12),q(v,T.version,1),q(v,1,2),q(v,T.error_protection?0:1,1),q(v,v.bitrate_index,4),q(v,v.samplerate_index,2),q(v,v.padding,1),q(v,T.extension,1),q(v,T.mode.ordinal(),2),q(v,v.mode_ext,2),q(v,T.copyright,1),q(v,T.original,1),q(v,T.emphasis,2),T.error_protection&&q(v,0,16),T.version==1){for(i(R.main_data_begin>=0),q(v,R.main_data_begin,9),v.channels_out==2?q(v,R.private_bits,3):q(v,R.private_bits,5),K=0;K<v.channels_out;K++){var se;for(se=0;se<4;se++)q(v,R.scfsi[K][se],1)}for(O=0;O<2;O++)for(K=0;K<v.channels_out;K++){var F=R.tt[O][K];q(v,F.part2_3_length+F.part2_length,12),q(v,F.big_values/2,9),q(v,F.global_gain,8),q(v,F.scalefac_compress,4),F.block_type!=d.NORM_TYPE?(q(v,1,1),q(v,F.block_type,2),q(v,F.mixed_block_flag,1),F.table_select[0]==14&&(F.table_select[0]=16),q(v,F.table_select[0],5),F.table_select[1]==14&&(F.table_select[1]=16),q(v,F.table_select[1],5),q(v,F.subblock_gain[0],3),q(v,F.subblock_gain[1],3),q(v,F.subblock_gain[2],3)):(q(v,0,1),F.table_select[0]==14&&(F.table_select[0]=16),q(v,F.table_select[0],5),F.table_select[1]==14&&(F.table_select[1]=16),q(v,F.table_select[1],5),F.table_select[2]==14&&(F.table_select[2]=16),q(v,F.table_select[2],5),i(0<=F.region0_count&&F.region0_count<16),i(0<=F.region1_count&&F.region1_count<8),q(v,F.region0_count,4),q(v,F.region1_count,3)),q(v,F.preflag,1),q(v,F.scalefac_scale,1),q(v,F.count1table_select,1)}}else for(i(R.main_data_begin>=0),q(v,R.main_data_begin,8),q(v,R.private_bits,v.channels_out),O=0,K=0;K<v.channels_out;K++){var F=R.tt[O][K];q(v,F.part2_3_length+F.part2_length,12),q(v,F.big_values/2,9),q(v,F.global_gain,8),q(v,F.scalefac_compress,9),F.block_type!=d.NORM_TYPE?(q(v,1,1),q(v,F.block_type,2),q(v,F.mixed_block_flag,1),F.table_select[0]==14&&(F.table_select[0]=16),q(v,F.table_select[0],5),F.table_select[1]==14&&(F.table_select[1]=16),q(v,F.table_select[1],5),q(v,F.subblock_gain[0],3),q(v,F.subblock_gain[1],3),q(v,F.subblock_gain[2],3)):(q(v,0,1),F.table_select[0]==14&&(F.table_select[0]=16),q(v,F.table_select[0],5),F.table_select[1]==14&&(F.table_select[1]=16),q(v,F.table_select[1],5),F.table_select[2]==14&&(F.table_select[2]=16),q(v,F.table_select[2],5),i(0<=F.region0_count&&F.region0_count<16),i(0<=F.region1_count&&F.region1_count<8),q(v,F.region0_count,4),q(v,F.region1_count,3)),q(v,F.scalefac_scale,1),q(v,F.count1table_select,1)}T.error_protection&&CRC_writeheader(v,v.header[v.h_ptr].buf);{var Q=v.h_ptr;i(v.header[Q].ptr==v.sideinfo_len*8),v.h_ptr=Q+1&l.MAX_HEADER_BUF-1,v.header[v.h_ptr].write_timing=v.header[Q].write_timing+y,v.h_ptr==v.w_ptr&&e.err.println(`Error: MAX_HEADER_BUF too small in bitstream.c
194
- `)}}function b(T,y){var v=c.ht[y.count1table_select+32],R,O=0,K=y.big_values,se=y.big_values;for(i(y.count1table_select<2),R=(y.count1-y.big_values)/4;R>0;--R){var F=0,Q=0,ue;ue=y.l3_enc[K+0],ue!=0&&(Q+=8,y.xr[se+0]<0&&F++),ue=y.l3_enc[K+1],ue!=0&&(Q+=4,F*=2,y.xr[se+1]<0&&F++),ue=y.l3_enc[K+2],ue!=0&&(Q+=2,F*=2,y.xr[se+2]<0&&F++),ue=y.l3_enc[K+3],ue!=0&&(Q++,F*=2,y.xr[se+3]<0&&F++),K+=4,se+=4,B(T,F+v.table[Q],v.hlen[Q]),O+=v.hlen[Q]}return O}function D(T,y,v,R,O){var K=c.ht[y],se=0;if(y==0)return se;for(var F=v;F<R;F+=2){var Q=0,ue=0,ge=K.xlen,ke=K.xlen,Re=0,Te=O.l3_enc[F],Se=O.l3_enc[F+1];if(Te!=0&&(O.xr[F]<0&&Re++,Q--),y>15){if(Te>14){var Ce=Te-15;i(Ce<=K.linmax),Re|=Ce<<1,ue=ge,Te=15}if(Se>14){var St=Se-15;i(St<=K.linmax),Re<<=ge,Re|=St,ue+=ge,Se=15}ke=16}Se!=0&&(Re<<=1,O.xr[F+1]<0&&Re++,Q--),Te=Te*ke+Se,ue-=Q,Q+=K.hlen[Te],B(T,K.table[Te],Q),B(T,Re,ue),se+=Q+ue}return se}function I(T,y){var v=3*T.scalefac_band.s[3];v>y.big_values&&(v=y.big_values);var R=D(T,y.table_select[0],0,v,y);return R+=D(T,y.table_select[1],v,y.big_values,y),R}function Y(T,y){var v,R,O,K;v=y.big_values;var se=y.region0_count+1;return i(se<T.scalefac_band.l.length),O=T.scalefac_band.l[se],se+=y.region1_count+1,i(se<T.scalefac_band.l.length),K=T.scalefac_band.l[se],O>v&&(O=v),K>v&&(K=v),R=D(T,y.table_select[0],0,O,y),R+=D(T,y.table_select[1],O,K,y),R+=D(T,y.table_select[2],K,v,y),R}function V(T){var y,v,R,O,K=0,se=T.internal_flags,F=se.l3_side;if(T.version==1)for(y=0;y<2;y++)for(v=0;v<se.channels_out;v++){var Q=F.tt[y][v],ue=a.slen1_tab[Q.scalefac_compress],ge=a.slen2_tab[Q.scalefac_compress];for(O=0,R=0;R<Q.sfbdivide;R++)Q.scalefac[R]!=-1&&(B(se,Q.scalefac[R],ue),O+=ue);for(;R<Q.sfbmax;R++)Q.scalefac[R]!=-1&&(B(se,Q.scalefac[R],ge),O+=ge);i(O==Q.part2_length),Q.block_type==d.SHORT_TYPE?O+=I(se,Q):O+=Y(se,Q),O+=b(se,Q),i(O==Q.part2_3_length+Q.part2_length),K+=O}else for(y=0,v=0;v<se.channels_out;v++){var Q=F.tt[y][v],ke,Re,Te=0;if(i(Q.sfb_partition_table!=null),O=0,R=0,Re=0,Q.block_type==d.SHORT_TYPE){for(;Re<4;Re++){var Se=Q.sfb_partition_table[Re]/3,Ce=Q.slen[Re];for(ke=0;ke<Se;ke++,R++)B(se,Math.max(Q.scalefac[R*3+0],0),Ce),B(se,Math.max(Q.scalefac[R*3+1],0),Ce),B(se,Math.max(Q.scalefac[R*3+2],0),Ce),Te+=3*Ce}O+=I(se,Q)}else{for(;Re<4;Re++){var Se=Q.sfb_partition_table[Re],Ce=Q.slen[Re];for(ke=0;ke<Se;ke++,R++)B(se,Math.max(Q.scalefac[R],0),Ce),Te+=Ce}O+=Y(se,Q)}O+=b(se,Q),i(O==Q.part2_3_length),i(Te==Q.part2_length),K+=Te+O}return K}function ee(){this.total=0}function L(T,y){var v=T.internal_flags,R,O,K,se,F;return F=v.w_ptr,se=v.h_ptr-1,se==-1&&(se=l.MAX_HEADER_BUF-1),R=v.header[se].write_timing-$,y.total=R,R>=0&&(O=1+se-F,se<F&&(O=1+se-F+l.MAX_HEADER_BUF),R-=O*8*v.sideinfo_len),K=p.getframebits(T),R+=K,y.total+=K,y.total%8!=0?y.total=1+y.total/8:y.total=y.total/8,y.total+=f+1,R<0&&e.err.println(`strange error flushing buffer ...
195
- `),R}this.flush_bitstream=function(T){var y=T.internal_flags,v,R,O=y.h_ptr-1;if(O==-1&&(O=l.MAX_HEADER_BUF-1),v=y.l3_side,!((R=L(T,new ee))<0)){if(C(T,R),i(y.header[O].write_timing+this.getframebits(T)==$),y.ResvSize=0,v.main_data_begin=0,y.findReplayGain){var K=x.GetTitleGain(y.rgdata);i(NEQ(K,GainAnalysis.GAIN_NOT_ENOUGH_SAMPLES)),y.RadioGain=Math.floor(K*10+.5)|0}y.findPeakSample&&(y.noclipGainChange=Math.ceil(Math.log10(y.PeakSample/32767)*20*10)|0,y.noclipGainChange>0&&(EQ(T.scale,1)||EQ(T.scale,0))?y.noclipScale=Math.floor(32767/y.PeakSample*100)/100:y.noclipScale=-1)}},this.add_dummy_byte=function(T,y,v){for(var R=T.internal_flags,O;v-- >0;)for(U(R,y,8),O=0;O<l.MAX_HEADER_BUF;++O)R.header[O].write_timing+=8},this.format_bitstream=function(T){var y=T.internal_flags,v;v=y.l3_side;var R=this.getframebits(T);C(T,v.resvDrain_pre),A(T,R);var O=8*y.sideinfo_len;if(O+=V(T),C(T,v.resvDrain_post),O+=v.resvDrain_post,v.main_data_begin+=(R-O)/8,L(T,new ee)!=y.ResvSize&&e.err.println("Internal buffer inconsistency. flushbits <> ResvSize"),v.main_data_begin*8!=y.ResvSize&&(e.err.printf(`bit reservoir error:
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 O1=d,O1}var A1,z3;function V1(){if(z3)return A1;z3=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=u4(),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 O(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&&O(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 z(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 H=R.tt[N][K];Z(w,H.part2_3_length+H.part2_length,12),Z(w,H.big_values/2,9),Z(w,H.global_gain,8),Z(w,H.scalefac_compress,4),H.block_type!=d.NORM_TYPE?(Z(w,1,1),Z(w,H.block_type,2),Z(w,H.mixed_block_flag,1),H.table_select[0]==14&&(H.table_select[0]=16),Z(w,H.table_select[0],5),H.table_select[1]==14&&(H.table_select[1]=16),Z(w,H.table_select[1],5),Z(w,H.subblock_gain[0],3),Z(w,H.subblock_gain[1],3),Z(w,H.subblock_gain[2],3)):(Z(w,0,1),H.table_select[0]==14&&(H.table_select[0]=16),Z(w,H.table_select[0],5),H.table_select[1]==14&&(H.table_select[1]=16),Z(w,H.table_select[1],5),H.table_select[2]==14&&(H.table_select[2]=16),Z(w,H.table_select[2],5),i(0<=H.region0_count&&H.region0_count<16),i(0<=H.region1_count&&H.region1_count<8),Z(w,H.region0_count,4),Z(w,H.region1_count,3)),Z(w,H.preflag,1),Z(w,H.scalefac_scale,1),Z(w,H.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 H=R.tt[N][K];Z(w,H.part2_3_length+H.part2_length,12),Z(w,H.big_values/2,9),Z(w,H.global_gain,8),Z(w,H.scalefac_compress,9),H.block_type!=d.NORM_TYPE?(Z(w,1,1),Z(w,H.block_type,2),Z(w,H.mixed_block_flag,1),H.table_select[0]==14&&(H.table_select[0]=16),Z(w,H.table_select[0],5),H.table_select[1]==14&&(H.table_select[1]=16),Z(w,H.table_select[1],5),Z(w,H.subblock_gain[0],3),Z(w,H.subblock_gain[1],3),Z(w,H.subblock_gain[2],3)):(Z(w,0,1),H.table_select[0]==14&&(H.table_select[0]=16),Z(w,H.table_select[0],5),H.table_select[1]==14&&(H.table_select[1]=16),Z(w,H.table_select[1],5),H.table_select[2]==14&&(H.table_select[2]=16),Z(w,H.table_select[2],5),i(0<=H.region0_count&&H.region0_count<16),i(0<=H.region1_count&&H.region1_count<8),Z(w,H.region0_count,4),Z(w,H.region1_count,3)),Z(w,H.scalefac_scale,1),Z(w,H.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
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 H=0,ee=0,de;de=v.l3_enc[K+0],de!=0&&(ee+=8,v.xr[se+0]<0&&H++),de=v.l3_enc[K+1],de!=0&&(ee+=4,H*=2,v.xr[se+1]<0&&H++),de=v.l3_enc[K+2],de!=0&&(ee+=2,H*=2,v.xr[se+2]<0&&H++),de=v.l3_enc[K+3],de!=0&&(ee++,H*=2,v.xr[se+3]<0&&H++),K+=4,se+=4,L(T,H+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 H=w;H<R;H+=2){var ee=0,de=0,_e=K.xlen,ke=K.xlen,Ie=0,Te=N.l3_enc[H],$e=N.l3_enc[H+1];if(Te!=0&&(N.xr[H]<0&&Ie++,ee--),v>15){if(Te>14){var je=Te-15;i(je<=K.linmax),Ie|=je<<1,de=_e,Te=15}if($e>14){var Tt=$e-15;i(Tt<=K.linmax),Ie<<=_e,Ie|=Tt,de+=_e,$e=15}ke=16}$e!=0&&(Ie<<=1,N.xr[H+1]<0&&Ie++,ee--),Te=Te*ke+$e,de-=ee,ee+=K.hlen[Te],L(T,K.table[Te],ee),L(T,Ie,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,H=se.l3_side;if(T.version==1)for(v=0;v<2;v++)for(w=0;w<se.channels_out;w++){var ee=H.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=H.tt[v][w],ke,Ie,Te=0;if(i(ee.sfb_partition_table!=null),N=0,R=0,Ie=0,ee.block_type==d.SHORT_TYPE){for(;Ie<4;Ie++){var $e=ee.sfb_partition_table[Ie]/3,je=ee.slen[Ie];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(;Ie<4;Ie++){var $e=ee.sfb_partition_table[Ie],je=ee.slen[Ie];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,H;return H=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-H,se<H&&(N=1+se-H+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 ...
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),z(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
196
  l3_side.main_data_begin: %d
197
197
  Resvoir size: %d
198
198
  resv drain (post) %d
@@ -201,65 +201,123 @@ header and sideinfo: %d
201
201
  data bits: %d
202
202
  total bits: %d (remainder: %d)
203
203
  bitsperframe: %d
204
- `,8*v.main_data_begin,y.ResvSize,v.resvDrain_post,v.resvDrain_pre,8*y.sideinfo_len,O-v.resvDrain_post-8*y.sideinfo_len,O,O%8,R),e.err.println("This is a fatal error. It has several possible causes:"),e.err.println("90%% LAME compiled with buggy version of gcc using advanced optimizations"),e.err.println(" 9%% Your system is overclocked"),e.err.println(" 1%% bug in LAME encoding library"),y.ResvSize=v.main_data_begin*8),$>1e9){var K;for(K=0;K<l.MAX_HEADER_BUF;++K)y.header[K].write_timing-=$;$=0}return 0},this.copy_buffer=function(T,y,v,R,O){var K=f+1;if(K<=0)return 0;if(R!=0&&K>R)return-1;if(e.arraycopy(m,0,y,v,K),f=-1,E=0,O!=0){var se=o(1);if(se[0]=T.nMusicCRC,_.updateMusicCRC(se,y,v,K),T.nMusicCRC=se[0],K>0&&(T.VBR_seek_table.nBytesWritten+=K),T.decode_on_the_fly){for(var F=s([2,1152]),Q=K,ue=-1,ge;ue!=0;)if(ue=S.hip_decode1_unclipped(T.hip,y,v,Q,F[0],F[1]),Q=0,ue==-1&&(ue=0),ue>0){if(T.findPeakSample){for(ge=0;ge<ue;ge++)F[0][ge]>T.PeakSample?T.PeakSample=F[0][ge]:-F[0][ge]>T.PeakSample&&(T.PeakSample=-F[0][ge]);if(T.channels_out>1)for(ge=0;ge<ue;ge++)F[1][ge]>T.PeakSample?T.PeakSample=F[1][ge]:-F[1][ge]>T.PeakSample&&(T.PeakSample=-F[1][ge])}if(T.findReplayGain&&x.AnalyzeSamples(T.rgdata,F[0],0,F[1],0,ue,T.channels_out)==GainAnalysis.GAIN_ANALYSIS_ERROR)return-6}}}return K},this.init_bit_stream_w=function(T){m=n(h.LAME_MAXMP3BUFFER),T.h_ptr=T.w_ptr=0,T.header[T.h_ptr].write_timing=0,f=-1,E=0,$=0}}return e1=u,e1}var t1,Bw;function u1(){if(Bw)return t1;Bw=1;var t=Zt,e=t.System,r=t.VbrMode,n=t.ShortBlock,s=t.new_float,o=t.new_int_n,i=t.new_short_n,a=t.assert,c=$z,d=Mz,l=ou,u=eI,h=rI,p=lI,g=l1(),x=c1,S=hr();function k(){var _=Da,m=this,$=128*1024;k.V9=410,k.V8=420,k.V7=430,k.V6=440,k.V5=450,k.V4=460,k.V3=470,k.V2=480,k.V1=490,k.V0=500,k.R3MIX=1e3,k.STANDARD=1001,k.EXTREME=1002,k.INSANE=1003,k.STANDARD_FAST=1004,k.EXTREME_FAST=1005,k.MEDIUM=1006,k.MEDIUM_FAST=1007;var f=16384+$;k.LAME_MAXMP3BUFFER=f;var E,N,B,U,C,q=new c,de,A,b;this.enc=new S,this.setModules=function(w,P,xe,Pe,Ge,He,Ne,ze,et){E=w,N=P,B=xe,U=Pe,C=Ge,de=He,A=ze,b=et,this.enc.setModules(N,q,U,de)};function D(){this.mask_adjust=0,this.mask_adjust_short=0,this.bo_l_weight=s(S.SBMAX_l),this.bo_s_weight=s(S.SBMAX_s)}function I(){this.lowerlimit=0}function Y(w,P){this.lowpass=P}var V=4294479419;function ee(w){var P;return w.class_id=V,P=w.internal_flags=new l,w.mode=_.NOT_SET,w.original=1,w.in_samplerate=44100,w.num_channels=2,w.num_samples=-1,w.bWriteVbrTag=!0,w.quality=-1,w.short_blocks=null,P.subblock_gain=-1,w.lowpassfreq=0,w.highpassfreq=0,w.lowpasswidth=-1,w.highpasswidth=-1,w.VBR=r.vbr_off,w.VBR_q=4,w.ATHcurve=-1,w.VBR_mean_bitrate_kbps=128,w.VBR_min_bitrate_kbps=0,w.VBR_max_bitrate_kbps=0,w.VBR_hard_min=0,P.VBR_min_bitrate=1,P.VBR_max_bitrate=13,w.quant_comp=-1,w.quant_comp_short=-1,w.msfix=-1,P.resample_ratio=1,P.OldValue[0]=180,P.OldValue[1]=180,P.CurrentStep[0]=4,P.CurrentStep[1]=4,P.masking_lower=1,P.nsPsy.attackthre=-1,P.nsPsy.attackthre_s=-1,w.scale=-1,w.athaa_type=-1,w.ATHtype=-1,w.athaa_loudapprox=-1,w.athaa_sensitivity=0,w.useTemporal=null,w.interChRatio=-1,P.mf_samples_to_encode=S.ENCDELAY+S.POSTDELAY,w.encoder_padding=0,P.mf_size=S.ENCDELAY-S.MDCTDELAY,w.findReplayGain=!1,w.decode_on_the_fly=!1,P.decode_on_the_fly=!1,P.findReplayGain=!1,P.findPeakSample=!1,P.RadioGain=0,P.AudiophileGain=0,P.noclipGainChange=0,P.noclipScale=-1,w.preset=0,w.write_id3tag_automatic=!0,0}this.lame_init=function(){var w=new d;return ee(w),w.lame_allocated_gfp=1,w};function L(w){return w>1?0:w<=0?1:Math.cos(Math.PI/2*w)}this.nearestBitrateFullIndex=function(w){var P=[8,16,24,32,40,48,56,64,80,96,112,128,160,192,224,256,320],xe=0,Pe=0,Ge=0,He=0;He=P[16],Ge=16,Pe=P[16],xe=16;for(var Ne=0;Ne<16;Ne++)if(Math.max(w,P[Ne+1])!=w){He=P[Ne+1],Ge=Ne+1,Pe=P[Ne],xe=Ne;break}return He-w>w-Pe?xe:Ge};function T(w,P){var xe=44100;return P>=48e3?xe=48e3:P>=44100?xe=44100:P>=32e3?xe=32e3:P>=24e3?xe=24e3:P>=22050?xe=22050:P>=16e3?xe=16e3:P>=12e3?xe=12e3:P>=11025?xe=11025:P>=8e3&&(xe=8e3),w==-1?xe:(w<=15960&&(xe=44100),w<=15250&&(xe=32e3),w<=11220&&(xe=24e3),w<=9970&&(xe=22050),w<=7230&&(xe=16e3),w<=5420&&(xe=12e3),w<=4510&&(xe=11025),w<=3970&&(xe=8e3),P<xe?P>44100?48e3:P>32e3?44100:P>24e3?32e3:P>22050?24e3:P>16e3?22050:P>12e3?16e3:P>11025?12e3:P>8e3?11025:8e3:xe)}function y(w,P){switch(w){case 44100:return P.version=1,0;case 48e3:return P.version=1,1;case 32e3:return P.version=1,2;case 22050:return P.version=0,0;case 24e3:return P.version=0,1;case 16e3:return P.version=0,2;case 11025:return P.version=0,0;case 12e3:return P.version=0,1;case 8e3:return P.version=0,2;default:return P.version=0,-1}}function v(w,P,xe){xe<16e3&&(P=2);for(var Pe=x.bitrate_table[P][1],Ge=2;Ge<=14;Ge++)x.bitrate_table[P][Ge]>0&&Math.abs(x.bitrate_table[P][Ge]-w)<Math.abs(Pe-w)&&(Pe=x.bitrate_table[P][Ge]);return Pe}function R(w,P,xe){xe<16e3&&(P=2);for(var Pe=0;Pe<=14;Pe++)if(x.bitrate_table[P][Pe]>0&&x.bitrate_table[P][Pe]==w)return Pe;return-1}function O(w,P){var xe=[new Y(8,2e3),new Y(16,3700),new Y(24,3900),new Y(32,5500),new Y(40,7e3),new Y(48,7500),new Y(56,1e4),new Y(64,11e3),new Y(80,13500),new Y(96,15100),new Y(112,15600),new Y(128,17e3),new Y(160,17500),new Y(192,18600),new Y(224,19400),new Y(256,19700),new Y(320,20500)],Pe=m.nearestBitrateFullIndex(P);w.lowerlimit=xe[Pe].lowpass}function K(w){var P=w.internal_flags,xe=32,Pe=-1;if(P.lowpass1>0){for(var Ge=999,He=0;He<=31;He++){var Ne=He/31;Ne>=P.lowpass2&&(xe=Math.min(xe,He)),P.lowpass1<Ne&&Ne<P.lowpass2&&(Ge=Math.min(Ge,He))}Ge==999?P.lowpass1=(xe-.75)/31:P.lowpass1=(Ge-.75)/31,P.lowpass2=xe/31}if(P.highpass2>0&&P.highpass2<.9*(.75/31)&&(P.highpass1=0,P.highpass2=0,e.err.println(`Warning: highpass filter disabled. highpass frequency too small
205
- `)),P.highpass2>0){for(var ze=-1,He=0;He<=31;He++){var Ne=He/31;Ne<=P.highpass1&&(Pe=Math.max(Pe,He)),P.highpass1<Ne&&Ne<P.highpass2&&(ze=Math.max(ze,He))}P.highpass1=Pe/31,ze==-1?P.highpass2=(Pe+.75)/31:P.highpass2=(ze+.75)/31}for(var He=0;He<32;He++){var et,je,Ne=He/31;P.highpass2>P.highpass1?et=L((P.highpass2-Ne)/(P.highpass2-P.highpass1+1e-20)):et=1,P.lowpass2>P.lowpass1?je=L((Ne-P.lowpass1)/(P.lowpass2-P.lowpass1+1e-20)):je=1,P.amp_filter[He]=et*je}}function se(w){var P=w.internal_flags;switch(w.quality){default:case 9:P.psymodel=0,P.noise_shaping=0,P.noise_shaping_amp=0,P.noise_shaping_stop=0,P.use_best_huffman=0,P.full_outer_loop=0;break;case 8:w.quality=7;case 7:P.psymodel=1,P.noise_shaping=0,P.noise_shaping_amp=0,P.noise_shaping_stop=0,P.use_best_huffman=0,P.full_outer_loop=0;break;case 6:P.psymodel=1,P.noise_shaping==0&&(P.noise_shaping=1),P.noise_shaping_amp=0,P.noise_shaping_stop=0,P.subblock_gain==-1&&(P.subblock_gain=1),P.use_best_huffman=0,P.full_outer_loop=0;break;case 5:P.psymodel=1,P.noise_shaping==0&&(P.noise_shaping=1),P.noise_shaping_amp=0,P.noise_shaping_stop=0,P.subblock_gain==-1&&(P.subblock_gain=1),P.use_best_huffman=0,P.full_outer_loop=0;break;case 4:P.psymodel=1,P.noise_shaping==0&&(P.noise_shaping=1),P.noise_shaping_amp=0,P.noise_shaping_stop=0,P.subblock_gain==-1&&(P.subblock_gain=1),P.use_best_huffman=1,P.full_outer_loop=0;break;case 3:P.psymodel=1,P.noise_shaping==0&&(P.noise_shaping=1),P.noise_shaping_amp=1,P.noise_shaping_stop=1,P.subblock_gain==-1&&(P.subblock_gain=1),P.use_best_huffman=1,P.full_outer_loop=0;break;case 2:P.psymodel=1,P.noise_shaping==0&&(P.noise_shaping=1),P.substep_shaping==0&&(P.substep_shaping=2),P.noise_shaping_amp=1,P.noise_shaping_stop=1,P.subblock_gain==-1&&(P.subblock_gain=1),P.use_best_huffman=1,P.full_outer_loop=0;break;case 1:P.psymodel=1,P.noise_shaping==0&&(P.noise_shaping=1),P.substep_shaping==0&&(P.substep_shaping=2),P.noise_shaping_amp=2,P.noise_shaping_stop=1,P.subblock_gain==-1&&(P.subblock_gain=1),P.use_best_huffman=1,P.full_outer_loop=0;break;case 0:P.psymodel=1,P.noise_shaping==0&&(P.noise_shaping=1),P.substep_shaping==0&&(P.substep_shaping=2),P.noise_shaping_amp=2,P.noise_shaping_stop=1,P.subblock_gain==-1&&(P.subblock_gain=1),P.use_best_huffman=1,P.full_outer_loop=0;break}}function F(w){var P=w.internal_flags;w.frameNum=0,w.write_id3tag_automatic&&A.id3tag_write_v2(w),P.bitrate_stereoMode_Hist=o([16,5]),P.bitrate_blockType_Hist=o([16,6]),P.PeakSample=0,w.bWriteVbrTag&&de.InitVbrTag(w)}this.lame_init_params=function(w){var P=w.internal_flags;if(P.Class_ID=0,P.ATH==null&&(P.ATH=new u),P.PSY==null&&(P.PSY=new D),P.rgdata==null&&(P.rgdata=new h),P.channels_in=w.num_channels,P.channels_in==1&&(w.mode=_.MONO),P.channels_out=w.mode==_.MONO?1:2,P.mode_ext=S.MPG_MD_MS_LR,w.mode==_.MONO&&(w.force_ms=!1),w.VBR==r.vbr_off&&w.VBR_mean_bitrate_kbps!=128&&w.brate==0&&(w.brate=w.VBR_mean_bitrate_kbps),w.VBR==r.vbr_off||w.VBR==r.vbr_mtrh||w.VBR==r.vbr_mt||(w.free_format=!1),w.VBR==r.vbr_off&&w.brate==0&&g.EQ(w.compression_ratio,0)&&(w.compression_ratio=11.025),w.VBR==r.vbr_off&&w.compression_ratio>0&&(w.out_samplerate==0&&(w.out_samplerate=map2MP3Frequency(int(.97*w.in_samplerate))),w.brate=0|w.out_samplerate*16*P.channels_out/(1e3*w.compression_ratio),P.samplerate_index=y(w.out_samplerate,w),w.free_format||(w.brate=v(w.brate,w.version,w.out_samplerate))),w.out_samplerate!=0&&(w.out_samplerate<16e3?(w.VBR_mean_bitrate_kbps=Math.max(w.VBR_mean_bitrate_kbps,8),w.VBR_mean_bitrate_kbps=Math.min(w.VBR_mean_bitrate_kbps,64)):w.out_samplerate<32e3?(w.VBR_mean_bitrate_kbps=Math.max(w.VBR_mean_bitrate_kbps,8),w.VBR_mean_bitrate_kbps=Math.min(w.VBR_mean_bitrate_kbps,160)):(w.VBR_mean_bitrate_kbps=Math.max(w.VBR_mean_bitrate_kbps,32),w.VBR_mean_bitrate_kbps=Math.min(w.VBR_mean_bitrate_kbps,320))),w.lowpassfreq==0){var xe=16e3;switch(w.VBR){case r.vbr_off:{var Pe=new I;O(Pe,w.brate),xe=Pe.lowerlimit;break}case r.vbr_abr:{var Pe=new I;O(Pe,w.VBR_mean_bitrate_kbps),xe=Pe.lowerlimit;break}case r.vbr_rh:{var Ge=[19500,19e3,18600,18e3,17500,16e3,15600,14900,12500,1e4,3950];if(0<=w.VBR_q&&w.VBR_q<=9){var He=Ge[w.VBR_q],Ne=Ge[w.VBR_q+1],ze=w.VBR_q_frac;xe=linear_int(He,Ne,ze)}else xe=19500;break}default:{var Ge=[19500,19e3,18500,18e3,17500,16500,15500,14500,12500,9500,3950];if(0<=w.VBR_q&&w.VBR_q<=9){var He=Ge[w.VBR_q],Ne=Ge[w.VBR_q+1],ze=w.VBR_q_frac;xe=linear_int(He,Ne,ze)}else xe=19500}}w.mode==_.MONO&&(w.VBR==r.vbr_off||w.VBR==r.vbr_abr)&&(xe*=1.5),w.lowpassfreq=xe|0}if(w.out_samplerate==0&&(2*w.lowpassfreq>w.in_samplerate&&(w.lowpassfreq=w.in_samplerate/2),w.out_samplerate=T(w.lowpassfreq|0,w.in_samplerate)),w.lowpassfreq=Math.min(20500,w.lowpassfreq),w.lowpassfreq=Math.min(w.out_samplerate/2,w.lowpassfreq),w.VBR==r.vbr_off&&(w.compression_ratio=w.out_samplerate*16*P.channels_out/(1e3*w.brate)),w.VBR==r.vbr_abr&&(w.compression_ratio=w.out_samplerate*16*P.channels_out/(1e3*w.VBR_mean_bitrate_kbps)),w.bWriteVbrTag||(w.findReplayGain=!1,w.decode_on_the_fly=!1,P.findPeakSample=!1),P.findReplayGain=w.findReplayGain,P.decode_on_the_fly=w.decode_on_the_fly,P.decode_on_the_fly&&(P.findPeakSample=!0),P.findReplayGain&&E.InitGainAnalysis(P.rgdata,w.out_samplerate)==GainAnalysis.INIT_GAIN_ANALYSIS_ERROR)return w.internal_flags=null,-6;switch(P.decode_on_the_fly&&!w.decode_only&&(P.hip!=null&&b.hip_decode_exit(P.hip),P.hip=b.hip_decode_init()),P.mode_gr=w.out_samplerate<=24e3?1:2,w.framesize=576*P.mode_gr,w.encoder_delay=S.ENCDELAY,P.resample_ratio=w.in_samplerate/w.out_samplerate,w.VBR){case r.vbr_mt:case r.vbr_rh:case r.vbr_mtrh:{var et=[5.7,6.5,7.3,8.2,10,11.9,13,14,15,16.5];w.compression_ratio=et[w.VBR_q]}break;case r.vbr_abr:w.compression_ratio=w.out_samplerate*16*P.channels_out/(1e3*w.VBR_mean_bitrate_kbps);break;default:w.compression_ratio=w.out_samplerate*16*P.channels_out/(1e3*w.brate);break}if(w.mode==_.NOT_SET&&(w.mode=_.JOINT_STEREO),w.highpassfreq>0?(P.highpass1=2*w.highpassfreq,w.highpasswidth>=0?P.highpass2=2*(w.highpassfreq+w.highpasswidth):P.highpass2=1*2*w.highpassfreq,P.highpass1/=w.out_samplerate,P.highpass2/=w.out_samplerate):(P.highpass1=0,P.highpass2=0),w.lowpassfreq>0?(P.lowpass2=2*w.lowpassfreq,w.lowpasswidth>=0?(P.lowpass1=2*(w.lowpassfreq-w.lowpasswidth),P.lowpass1<0&&(P.lowpass1=0)):P.lowpass1=1*2*w.lowpassfreq,P.lowpass1/=w.out_samplerate,P.lowpass2/=w.out_samplerate):(P.lowpass1=0,P.lowpass2=0),K(w),P.samplerate_index=y(w.out_samplerate,w),P.samplerate_index<0)return w.internal_flags=null,-1;if(w.VBR==r.vbr_off){if(w.free_format)P.bitrate_index=0;else if(w.brate=v(w.brate,w.version,w.out_samplerate),P.bitrate_index=R(w.brate,w.version,w.out_samplerate),P.bitrate_index<=0)return w.internal_flags=null,-1}else P.bitrate_index=1;w.analysis&&(w.bWriteVbrTag=!1),P.pinfo!=null&&(w.bWriteVbrTag=!1),N.init_bit_stream_w(P);for(var je=P.samplerate_index+3*w.version+6*(w.out_samplerate<16e3?1:0),ve=0;ve<S.SBMAX_l+1;ve++)P.scalefac_band.l[ve]=U.sfBandIndex[je].l[ve];for(var ve=0;ve<S.PSFB21+1;ve++){var vt=(P.scalefac_band.l[22]-P.scalefac_band.l[21])/S.PSFB21,Yt=P.scalefac_band.l[21]+ve*vt;P.scalefac_band.psfb21[ve]=Yt}P.scalefac_band.psfb21[S.PSFB21]=576;for(var ve=0;ve<S.SBMAX_s+1;ve++)P.scalefac_band.s[ve]=U.sfBandIndex[je].s[ve];for(var ve=0;ve<S.PSFB12+1;ve++){var vt=(P.scalefac_band.s[13]-P.scalefac_band.s[12])/S.PSFB12,Yt=P.scalefac_band.s[12]+ve*vt;P.scalefac_band.psfb12[ve]=Yt}P.scalefac_band.psfb12[S.PSFB12]=192,w.version==1?P.sideinfo_len=P.channels_out==1?21:36:P.sideinfo_len=P.channels_out==1?13:21,w.error_protection&&(P.sideinfo_len+=2),F(w),P.Class_ID=V;{var pt;for(pt=0;pt<19;pt++)P.nsPsy.pefirbuf[pt]=700*P.mode_gr*P.channels_out;w.ATHtype==-1&&(w.ATHtype=4)}switch(a(w.VBR_q<=9),a(w.VBR_q>=0),w.VBR){case r.vbr_mt:w.VBR=r.vbr_mtrh;case r.vbr_mtrh:{w.useTemporal==null&&(w.useTemporal=!1),B.apply_preset(w,500-w.VBR_q*10,0),w.quality<0&&(w.quality=LAME_DEFAULT_QUALITY),w.quality<5&&(w.quality=0),w.quality>5&&(w.quality=5),P.PSY.mask_adjust=w.maskingadjust,P.PSY.mask_adjust_short=w.maskingadjust_short,w.experimentalY?P.sfb21_extra=!1:P.sfb21_extra=w.out_samplerate>44e3,P.iteration_loop=new VBRNewIterationLoop(C);break}case r.vbr_rh:{B.apply_preset(w,500-w.VBR_q*10,0),P.PSY.mask_adjust=w.maskingadjust,P.PSY.mask_adjust_short=w.maskingadjust_short,w.experimentalY?P.sfb21_extra=!1:P.sfb21_extra=w.out_samplerate>44e3,w.quality>6&&(w.quality=6),w.quality<0&&(w.quality=LAME_DEFAULT_QUALITY),P.iteration_loop=new VBROldIterationLoop(C);break}default:{var M;P.sfb21_extra=!1,w.quality<0&&(w.quality=LAME_DEFAULT_QUALITY),M=w.VBR,M==r.vbr_off&&(w.VBR_mean_bitrate_kbps=w.brate),B.apply_preset(w,w.VBR_mean_bitrate_kbps,0),w.VBR=M,P.PSY.mask_adjust=w.maskingadjust,P.PSY.mask_adjust_short=w.maskingadjust_short,M==r.vbr_off?P.iteration_loop=new p(C):P.iteration_loop=new ABRIterationLoop(C);break}}if(a(w.scale>=0),w.VBR!=r.vbr_off){if(P.VBR_min_bitrate=1,P.VBR_max_bitrate=14,w.out_samplerate<16e3&&(P.VBR_max_bitrate=8),w.VBR_min_bitrate_kbps!=0&&(w.VBR_min_bitrate_kbps=v(w.VBR_min_bitrate_kbps,w.version,w.out_samplerate),P.VBR_min_bitrate=R(w.VBR_min_bitrate_kbps,w.version,w.out_samplerate),P.VBR_min_bitrate<0)||w.VBR_max_bitrate_kbps!=0&&(w.VBR_max_bitrate_kbps=v(w.VBR_max_bitrate_kbps,w.version,w.out_samplerate),P.VBR_max_bitrate=R(w.VBR_max_bitrate_kbps,w.version,w.out_samplerate),P.VBR_max_bitrate<0))return-1;w.VBR_min_bitrate_kbps=x.bitrate_table[w.version][P.VBR_min_bitrate],w.VBR_max_bitrate_kbps=x.bitrate_table[w.version][P.VBR_max_bitrate],w.VBR_mean_bitrate_kbps=Math.min(x.bitrate_table[w.version][P.VBR_max_bitrate],w.VBR_mean_bitrate_kbps),w.VBR_mean_bitrate_kbps=Math.max(x.bitrate_table[w.version][P.VBR_min_bitrate],w.VBR_mean_bitrate_kbps)}return w.tune&&(P.PSY.mask_adjust+=w.tune_value_a,P.PSY.mask_adjust_short+=w.tune_value_a),se(w),a(w.scale>=0),w.athaa_type<0?P.ATH.useAdjust=3:P.ATH.useAdjust=w.athaa_type,P.ATH.aaSensitivityP=Math.pow(10,w.athaa_sensitivity/-10),w.short_blocks==null&&(w.short_blocks=n.short_block_allowed),w.short_blocks==n.short_block_allowed&&(w.mode==_.JOINT_STEREO||w.mode==_.STEREO)&&(w.short_blocks=n.short_block_coupled),w.quant_comp<0&&(w.quant_comp=1),w.quant_comp_short<0&&(w.quant_comp_short=0),w.msfix<0&&(w.msfix=0),w.exp_nspsytune=w.exp_nspsytune|1,w.internal_flags.nsPsy.attackthre<0&&(w.internal_flags.nsPsy.attackthre=c.NSATTACKTHRE),w.internal_flags.nsPsy.attackthre_s<0&&(w.internal_flags.nsPsy.attackthre_s=c.NSATTACKTHRE_S),a(w.scale>=0),w.scale<0&&(w.scale=1),w.ATHtype<0&&(w.ATHtype=4),w.ATHcurve<0&&(w.ATHcurve=4),w.athaa_loudapprox<0&&(w.athaa_loudapprox=2),w.interChRatio<0&&(w.interChRatio=0),w.useTemporal==null&&(w.useTemporal=!0),P.slot_lag=P.frac_SpF=0,w.VBR==r.vbr_off&&(P.slot_lag=P.frac_SpF=(w.version+1)*72e3*w.brate%w.out_samplerate|0),U.iteration_init(w),q.psymodel_init(w),a(w.scale>=0),0};function Q(w,P){(w.in_buffer_0==null||w.in_buffer_nsamples<P)&&(w.in_buffer_0=s(P),w.in_buffer_1=s(P),w.in_buffer_nsamples=P)}this.lame_encode_flush=function(w,P,xe,Pe){var Ge=w.internal_flags,He=i([2,1152]),Ne=0,ze,et,je,ve,vt=Ge.mf_samples_to_encode-S.POSTDELAY,Yt=ue(w);if(Ge.mf_samples_to_encode<1)return 0;for(ze=0,w.in_samplerate!=w.out_samplerate&&(vt+=16*w.out_samplerate/w.in_samplerate),je=w.framesize-vt%w.framesize,je<576&&(je+=w.framesize),w.encoder_padding=je,ve=(vt+je)/w.framesize;ve>0&&Ne>=0;){var pt=Yt-Ge.mf_size,M=w.frameNum;pt*=w.in_samplerate,pt/=w.out_samplerate,pt>1152&&(pt=1152),pt<1&&(pt=1),et=Pe-ze,Pe==0&&(et=0),Ne=this.lame_encode_buffer(w,He[0],He[1],pt,P,xe,et),xe+=Ne,ze+=Ne,ve-=M!=w.frameNum?1:0}if(Ge.mf_samples_to_encode=0,Ne<0||(et=Pe-ze,Pe==0&&(et=0),N.flush_bitstream(w),Ne=N.copy_buffer(Ge,P,xe,et,1),Ne<0))return Ne;if(xe+=Ne,ze+=Ne,et=Pe-ze,Pe==0&&(et=0),w.write_id3tag_automatic){if(A.id3tag_write_v1(w),Ne=N.copy_buffer(Ge,P,xe,et,0),Ne<0)return Ne;ze+=Ne}return ze},this.lame_encode_buffer=function(w,P,xe,Pe,Ge,He,Ne){var ze=w.internal_flags,et=[null,null];if(ze.Class_ID!=V)return-3;if(Pe==0)return 0;Q(ze,Pe),et[0]=ze.in_buffer_0,et[1]=ze.in_buffer_1;for(var je=0;je<Pe;je++)et[0][je]=P[je],ze.channels_in>1&&(et[1][je]=xe[je]);return ge(w,et[0],et[1],Pe,Ge,He,Ne)};function ue(w){var P=S.BLKSIZE+w.framesize-S.FFTOFFSET;return P=Math.max(P,512+w.framesize-32),P}function ge(w,P,xe,Pe,Ge,He,Ne){var ze=w.internal_flags,et=0,je,ve,vt,Yt,pt,M=[null,null],z=[null,null];if(ze.Class_ID!=V)return-3;if(Pe==0)return 0;if(pt=N.copy_buffer(ze,Ge,He,Ne,0),pt<0)return pt;if(He+=pt,et+=pt,z[0]=P,z[1]=xe,g.NEQ(w.scale,0)&&g.NEQ(w.scale,1))for(ve=0;ve<Pe;++ve)z[0][ve]*=w.scale,ze.channels_out==2&&(z[1][ve]*=w.scale);if(g.NEQ(w.scale_left,0)&&g.NEQ(w.scale_left,1))for(ve=0;ve<Pe;++ve)z[0][ve]*=w.scale_left;if(g.NEQ(w.scale_right,0)&&g.NEQ(w.scale_right,1))for(ve=0;ve<Pe;++ve)z[1][ve]*=w.scale_right;if(w.num_channels==2&&ze.channels_out==1)for(ve=0;ve<Pe;++ve)z[0][ve]=.5*(z[0][ve]+z[1][ve]),z[1][ve]=0;Yt=ue(w),M[0]=ze.mfbuf[0],M[1]=ze.mfbuf[1];for(var Z=0;Pe>0;){var H=[null,null],J=0,j=0;H[0]=z[0],H[1]=z[1];var X=new Re;if(Fr(w,M,H,Z,Pe,X),J=X.n_in,j=X.n_out,ze.findReplayGain&&!ze.decode_on_the_fly&&E.AnalyzeSamples(ze.rgdata,M[0],ze.mf_size,M[1],ze.mf_size,j,ze.channels_out)==GainAnalysis.GAIN_ANALYSIS_ERROR)return-6;if(Pe-=J,Z+=J,ze.channels_out==2,ze.mf_size+=j,a(ze.mf_size<=l.MFSIZE),ze.mf_samples_to_encode<1&&(ze.mf_samples_to_encode=S.ENCDELAY+S.POSTDELAY),ze.mf_samples_to_encode+=j,ze.mf_size>=Yt){var te=Ne-et;if(Ne==0&&(te=0),je=ke(w,M[0],M[1],Ge,He,te),je<0)return je;for(He+=je,et+=je,ze.mf_size-=w.framesize,ze.mf_samples_to_encode-=w.framesize,vt=0;vt<ze.channels_out;vt++)for(ve=0;ve<ze.mf_size;ve++)M[vt][ve]=M[vt][ve+w.framesize]}}return et}function ke(w,P,xe,Pe,Ge,He){var Ne=m.enc.lame_encode_mp3_frame(w,P,xe,Pe,Ge,He);return w.frameNum++,Ne}function Re(){this.n_in=0,this.n_out=0}function Te(){this.num_used=0}function Se(w,P){return P!=0?Se(P,w%P):w}function Ce(w,P,xe){var Pe=Math.PI*P;w/=xe,w<0&&(w=0),w>1&&(w=1);var Ge=w-.5,He=.42-.5*Math.cos(2*w*Math.PI)+.08*Math.cos(4*w*Math.PI);return Math.abs(Ge)<1e-9?Pe/Math.PI:He*Math.sin(xe*Pe*Ge)/(Math.PI*xe*Ge)}function St(w,P,xe,Pe,Ge,He,Ne,ze,et){var je=w.internal_flags,ve,vt=0,Yt,pt=w.out_samplerate/Se(w.out_samplerate,w.in_samplerate);pt>l.BPC&&(pt=l.BPC);var M=Math.abs(je.resample_ratio-Math.floor(.5+je.resample_ratio))<1e-4?1:0,z=1/je.resample_ratio;z>1&&(z=1);var Z=31;Z%2==0&&--Z,Z+=M;var H=Z+1;if(je.fill_buffer_resample_init==0){for(je.inbuf_old[0]=s(H),je.inbuf_old[1]=s(H),ve=0;ve<=2*pt;++ve)je.blackfilt[ve]=s(H);for(je.itime[0]=0,je.itime[1]=0,vt=0;vt<=2*pt;vt++){var J=0,j=(vt-pt)/(2*pt);for(ve=0;ve<=Z;ve++)J+=je.blackfilt[vt][ve]=Ce(ve-j,z,Z);for(ve=0;ve<=Z;ve++)je.blackfilt[vt][ve]/=J}je.fill_buffer_resample_init=1}var X=je.inbuf_old[et];for(Yt=0;Yt<Pe;Yt++){var te,W;if(te=Yt*je.resample_ratio,vt=0|Math.floor(te-je.itime[et]),Z+vt-Z/2>=Ne)break;var j=te-je.itime[et]-(vt+.5*(Z%2));W=0|Math.floor(j*2*pt+pt+.5);var oe=0;for(ve=0;ve<=Z;++ve){var re=0|ve+vt-Z/2,ie;ie=re<0?X[H+re]:Ge[He+re],oe+=ie*je.blackfilt[W][ve]}P[xe+Yt]=oe}if(ze.num_used=Math.min(Ne,Z+vt-Z/2),je.itime[et]+=ze.num_used-Yt*je.resample_ratio,ze.num_used>=H)for(ve=0;ve<H;ve++)X[ve]=Ge[He+ze.num_used+ve-H];else{var ye=H-ze.num_used;for(ve=0;ve<ye;++ve)X[ve]=X[ve+ze.num_used];for(vt=0;ve<H;++ve,++vt)X[ve]=Ge[He+vt];a(vt==ze.num_used)}return Yt}function Fr(w,P,xe,Pe,Ge,He){var Ne=w.internal_flags;if(Ne.resample_ratio<.9999||Ne.resample_ratio>1.0001)for(var ze=0;ze<Ne.channels_out;ze++){var et=new Te;He.n_out=St(w,P[ze],Ne.mf_size,w.framesize,xe[ze],Pe,Ge,et,ze),He.n_in=et.num_used}else{He.n_out=Math.min(w.framesize,Ge),He.n_in=He.n_out;for(var je=0;je<He.n_out;++je)P[0][Ne.mf_size+je]=xe[0][Pe+je],Ne.channels_out==2&&(P[1][Ne.mf_size+je]=xe[1][Pe+je])}}}return t1=k,t1}var uI=Zt,An=uI.VbrMode;function dI(){var t=u1();function e(l,u,h,p,g,x,S,k,_,m,$,f,E,N,B){this.vbr_q=l,this.quant_comp=u,this.quant_comp_s=h,this.expY=p,this.st_lrm=g,this.st_s=x,this.masking_adj=S,this.masking_adj_short=k,this.ath_lower=_,this.ath_curve=m,this.ath_sensitivity=$,this.interch=f,this.safejoint=E,this.sfb21mod=N,this.msfix=B}function r(l,u,h,p,g,x,S,k,_,m,$,f,E,N){this.quant_comp=u,this.quant_comp_s=h,this.safejoint=p,this.nsmsfix=g,this.st_lrm=x,this.st_s=S,this.nsbass=k,this.scale=_,this.masking_adj=m,this.ath_lower=$,this.ath_curve=f,this.interch=E,this.sfscale=N}var n;this.setModules=function(l){n=l};var s=[new e(0,9,9,0,5.2,125,-4.2,-6.3,4.8,1,0,0,2,21,.97),new e(1,9,9,0,5.3,125,-3.6,-5.6,4.5,1.5,0,0,2,21,1.35),new e(2,9,9,0,5.6,125,-2.2,-3.5,2.8,2,0,0,2,21,1.49),new e(3,9,9,1,5.8,130,-1.8,-2.8,2.6,3,-4,0,2,20,1.64),new e(4,9,9,1,6,135,-.7,-1.1,1.1,3.5,-8,0,2,0,1.79),new e(5,9,9,1,6.4,140,.5,.4,-7.5,4,-12,2e-4,0,0,1.95),new e(6,9,9,1,6.6,145,.67,.65,-14.7,6.5,-19,4e-4,0,0,2.3),new e(7,9,9,1,6.6,145,.8,.75,-19.7,8,-22,6e-4,0,0,2.7),new e(8,9,9,1,6.6,145,1.2,1.15,-27.5,10,-23,7e-4,0,0,0),new e(9,9,9,1,6.6,145,1.6,1.6,-36,11,-25,8e-4,0,0,0),new e(10,9,9,1,6.6,145,2,2,-36,12,-25,8e-4,0,0,0)],o=[new e(0,9,9,0,4.2,25,-7,-4,7.5,1,0,0,2,26,.97),new e(1,9,9,0,4.2,25,-5.6,-3.6,4.5,1.5,0,0,2,21,1.35),new e(2,9,9,0,4.2,25,-4.4,-1.8,2,2,0,0,2,18,1.49),new e(3,9,9,1,4.2,25,-3.4,-1.25,1.1,3,-4,0,2,15,1.64),new e(4,9,9,1,4.2,25,-2.2,.1,0,3.5,-8,0,2,0,1.79),new e(5,9,9,1,4.2,25,-1,1.65,-7.7,4,-12,2e-4,0,0,1.95),new e(6,9,9,1,4.2,25,-0,2.47,-7.7,6.5,-19,4e-4,0,0,2),new e(7,9,9,1,4.2,25,.5,2,-14.5,8,-22,6e-4,0,0,2),new e(8,9,9,1,4.2,25,1,2.4,-22,10,-23,7e-4,0,0,2),new e(9,9,9,1,4.2,25,1.5,2.95,-30,11,-25,8e-4,0,0,2),new e(10,9,9,1,4.2,25,2,2.95,-36,12,-30,8e-4,0,0,2)];function i(l,u,h){var p=l.VBR==An.vbr_rh?s:o,g=l.VBR_q_frac,x=p[u],S=p[u+1],k=x;x.st_lrm=x.st_lrm+g*(S.st_lrm-x.st_lrm),x.st_s=x.st_s+g*(S.st_s-x.st_s),x.masking_adj=x.masking_adj+g*(S.masking_adj-x.masking_adj),x.masking_adj_short=x.masking_adj_short+g*(S.masking_adj_short-x.masking_adj_short),x.ath_lower=x.ath_lower+g*(S.ath_lower-x.ath_lower),x.ath_curve=x.ath_curve+g*(S.ath_curve-x.ath_curve),x.ath_sensitivity=x.ath_sensitivity+g*(S.ath_sensitivity-x.ath_sensitivity),x.interch=x.interch+g*(S.interch-x.interch),x.msfix=x.msfix+g*(S.msfix-x.msfix),d(l,k.vbr_q),h!=0?l.quant_comp=k.quant_comp:Math.abs(l.quant_comp- -1)>0||(l.quant_comp=k.quant_comp),h!=0?l.quant_comp_short=k.quant_comp_s:Math.abs(l.quant_comp_short- -1)>0||(l.quant_comp_short=k.quant_comp_s),k.expY!=0&&(l.experimentalY=k.expY!=0),h!=0?l.internal_flags.nsPsy.attackthre=k.st_lrm:Math.abs(l.internal_flags.nsPsy.attackthre- -1)>0||(l.internal_flags.nsPsy.attackthre=k.st_lrm),h!=0?l.internal_flags.nsPsy.attackthre_s=k.st_s:Math.abs(l.internal_flags.nsPsy.attackthre_s- -1)>0||(l.internal_flags.nsPsy.attackthre_s=k.st_s),h!=0?l.maskingadjust=k.masking_adj:Math.abs(l.maskingadjust-0)>0||(l.maskingadjust=k.masking_adj),h!=0?l.maskingadjust_short=k.masking_adj_short:Math.abs(l.maskingadjust_short-0)>0||(l.maskingadjust_short=k.masking_adj_short),h!=0?l.ATHlower=-k.ath_lower/10:Math.abs(-l.ATHlower*10-0)>0||(l.ATHlower=-k.ath_lower/10),h!=0?l.ATHcurve=k.ath_curve:Math.abs(l.ATHcurve- -1)>0||(l.ATHcurve=k.ath_curve),h!=0?l.athaa_sensitivity=k.ath_sensitivity:Math.abs(l.athaa_sensitivity- -1)>0||(l.athaa_sensitivity=k.ath_sensitivity),k.interch>0&&(h!=0?l.interChRatio=k.interch:Math.abs(l.interChRatio- -1)>0||(l.interChRatio=k.interch)),k.safejoint>0&&(l.exp_nspsytune=l.exp_nspsytune|k.safejoint),k.sfb21mod>0&&(l.exp_nspsytune=l.exp_nspsytune|k.sfb21mod<<20),h!=0?l.msfix=k.msfix:Math.abs(l.msfix- -1)>0||(l.msfix=k.msfix),h==0&&(l.VBR_q=u,l.VBR_q_frac=g)}var a=[new r(8,9,9,0,0,6.6,145,0,.95,0,-30,11,.0012,1),new r(16,9,9,0,0,6.6,145,0,.95,0,-25,11,.001,1),new r(24,9,9,0,0,6.6,145,0,.95,0,-20,11,.001,1),new r(32,9,9,0,0,6.6,145,0,.95,0,-15,11,.001,1),new r(40,9,9,0,0,6.6,145,0,.95,0,-10,11,9e-4,1),new r(48,9,9,0,0,6.6,145,0,.95,0,-10,11,9e-4,1),new r(56,9,9,0,0,6.6,145,0,.95,0,-6,11,8e-4,1),new r(64,9,9,0,0,6.6,145,0,.95,0,-2,11,8e-4,1),new r(80,9,9,0,0,6.6,145,0,.95,0,0,8,7e-4,1),new r(96,9,9,0,2.5,6.6,145,0,.95,0,1,5.5,6e-4,1),new r(112,9,9,0,2.25,6.6,145,0,.95,0,2,4.5,5e-4,1),new r(128,9,9,0,1.95,6.4,140,0,.95,0,3,4,2e-4,1),new r(160,9,9,1,1.79,6,135,0,.95,-2,5,3.5,0,1),new r(192,9,9,1,1.49,5.6,125,0,.97,-4,7,3,0,0),new r(224,9,9,1,1.25,5.2,125,0,.98,-6,9,2,0,0),new r(256,9,9,1,.97,5.2,125,0,1,-8,10,1,0,0),new r(320,9,9,1,.9,5.2,125,0,1,-10,12,0,0,0)];function c(l,u,h){var p=u,g=n.nearestBitrateFullIndex(u);if(l.VBR=An.vbr_abr,l.VBR_mean_bitrate_kbps=p,l.VBR_mean_bitrate_kbps=Math.min(l.VBR_mean_bitrate_kbps,320),l.VBR_mean_bitrate_kbps=Math.max(l.VBR_mean_bitrate_kbps,8),l.brate=l.VBR_mean_bitrate_kbps,l.VBR_mean_bitrate_kbps>320&&(l.disable_reservoir=!0),a[g].safejoint>0&&(l.exp_nspsytune=l.exp_nspsytune|2),a[g].sfscale>0&&(l.internal_flags.noise_shaping=2),Math.abs(a[g].nsbass)>0){var x=int(a[g].nsbass*4);x<0&&(x+=64),l.exp_nspsytune=l.exp_nspsytune|x<<2}return h!=0?l.quant_comp=a[g].quant_comp:Math.abs(l.quant_comp- -1)>0||(l.quant_comp=a[g].quant_comp),h!=0?l.quant_comp_short=a[g].quant_comp_s:Math.abs(l.quant_comp_short- -1)>0||(l.quant_comp_short=a[g].quant_comp_s),h!=0?l.msfix=a[g].nsmsfix:Math.abs(l.msfix- -1)>0||(l.msfix=a[g].nsmsfix),h!=0?l.internal_flags.nsPsy.attackthre=a[g].st_lrm:Math.abs(l.internal_flags.nsPsy.attackthre- -1)>0||(l.internal_flags.nsPsy.attackthre=a[g].st_lrm),h!=0?l.internal_flags.nsPsy.attackthre_s=a[g].st_s:Math.abs(l.internal_flags.nsPsy.attackthre_s- -1)>0||(l.internal_flags.nsPsy.attackthre_s=a[g].st_s),h!=0?l.scale=a[g].scale:Math.abs(l.scale- -1)>0||(l.scale=a[g].scale),h!=0?l.maskingadjust=a[g].masking_adj:Math.abs(l.maskingadjust-0)>0||(l.maskingadjust=a[g].masking_adj),a[g].masking_adj>0?h!=0?l.maskingadjust_short=a[g].masking_adj*.9:Math.abs(l.maskingadjust_short-0)>0||(l.maskingadjust_short=a[g].masking_adj*.9):h!=0?l.maskingadjust_short=a[g].masking_adj*1.1:Math.abs(l.maskingadjust_short-0)>0||(l.maskingadjust_short=a[g].masking_adj*1.1),h!=0?l.ATHlower=-a[g].ath_lower/10:Math.abs(-l.ATHlower*10-0)>0||(l.ATHlower=-a[g].ath_lower/10),h!=0?l.ATHcurve=a[g].ath_curve:Math.abs(l.ATHcurve- -1)>0||(l.ATHcurve=a[g].ath_curve),h!=0?l.interChRatio=a[g].interch:Math.abs(l.interChRatio- -1)>0||(l.interChRatio=a[g].interch),u}this.apply_preset=function(l,u,h){switch(u){case t.R3MIX:{u=t.V3,l.VBR=An.vbr_mtrh;break}case t.MEDIUM:{u=t.V4,l.VBR=An.vbr_rh;break}case t.MEDIUM_FAST:{u=t.V4,l.VBR=An.vbr_mtrh;break}case t.STANDARD:{u=t.V2,l.VBR=An.vbr_rh;break}case t.STANDARD_FAST:{u=t.V2,l.VBR=An.vbr_mtrh;break}case t.EXTREME:{u=t.V0,l.VBR=An.vbr_rh;break}case t.EXTREME_FAST:{u=t.V0,l.VBR=An.vbr_mtrh;break}case t.INSANE:return u=320,l.preset=u,c(l,u,h),l.VBR=An.vbr_off,u}switch(l.preset=u,u){case t.V9:return i(l,9,h),u;case t.V8:return i(l,8,h),u;case t.V7:return i(l,7,h),u;case t.V6:return i(l,6,h),u;case t.V5:return i(l,5,h),u;case t.V4:return i(l,4,h),u;case t.V3:return i(l,3,h),u;case t.V2:return i(l,2,h),u;case t.V1:return i(l,1,h),u;case t.V0:return i(l,0,h),u}return 8<=u&&u<=320?c(l,u,h):(l.preset=0,u)};function d(l,u){var h=0;return 0>u&&(h=-1,u=0),9<u&&(h=-1,u=9),l.VBR_q=u,l.VBR_q_frac=0,h}}var fI=dI;function hI(){this.setModules=function(t,e){}}var pI=hI;function mI(){this.over_noise=0,this.tot_noise=0,this.max_noise=0,this.over_count=0,this.over_SSD=0,this.bits=0}var gI=mI,_3=Zt,qw=_3.new_float,_I=_3.new_int;function bI(){this.global_gain=0,this.sfb_count1=0,this.step=_I(39),this.noise=qw(39),this.noise_log=qw(39)}var yI=bI,hi=Zt,_s=hi.System,Vw=hi.VbrMode,r1=hi.Util,di=hi.Arrays,Aa=hi.new_float,Na=hi.assert,vI=pI,n1=gI,wI=yI,bt=hr(),Fw=o1,Hw=su;function xI(){var t;this.rv=null;var e;this.qupvt=null;var r,n=new vI,s;this.setModules=function(k,_,m,$){t=k,e=_,this.rv=_,r=m,this.qupvt=m,s=$,n.setModules(r,s)},this.ms_convert=function(k,_){for(var m=0;m<576;++m){var $=k.tt[_][0].xr[m],f=k.tt[_][1].xr[m];k.tt[_][0].xr[m]=($+f)*(r1.SQRT2*.5),k.tt[_][1].xr[m]=($-f)*(r1.SQRT2*.5)}};function o(k,_,m,$){$=0;for(var f=0;f<=m;++f){var E=Math.abs(k.xr[f]);$+=E,_[f]=Math.sqrt(E*Math.sqrt(E)),_[f]>k.xrpow_max&&(k.xrpow_max=_[f])}return $}this.init_xrpow=function(k,_,m){var $=0,f=0|_.max_nonzero_coeff;if(_.xrpow_max=0,di.fill(m,f,576,0),$=o(_,m,f,$),$>1e-20){var E=0;k.substep_shaping&2&&(E=1);for(var N=0;N<_.psymax;N++)k.pseudohalf[N]=E;return!0}return di.fill(_.l3_enc,0,576,0),!1};function i(k,_){var m=k.ATH,$=_.xr;if(_.block_type!=bt.SHORT_TYPE)for(var f=!1,E=bt.PSFB21-1;E>=0&&!f;E--){var N=k.scalefac_band.psfb21[E],B=k.scalefac_band.psfb21[E+1],U=r.athAdjust(m.adjust,m.psfb21[E],m.floor);k.nsPsy.longfact[21]>1e-12&&(U*=k.nsPsy.longfact[21]);for(var C=B-1;C>=N;C--)if(Math.abs($[C])<U)$[C]=0;else{f=!0;break}}else for(var q=0;q<3;q++)for(var f=!1,E=bt.PSFB12-1;E>=0&&!f;E--){var N=k.scalefac_band.s[12]*3+(k.scalefac_band.s[13]-k.scalefac_band.s[12])*q+(k.scalefac_band.psfb12[E]-k.scalefac_band.psfb12[0]),B=N+(k.scalefac_band.psfb12[E+1]-k.scalefac_band.psfb12[E]),de=r.athAdjust(m.adjust,m.psfb12[E],m.floor);k.nsPsy.shortfact[12]>1e-12&&(de*=k.nsPsy.shortfact[12]);for(var C=B-1;C>=N;C--)if(Math.abs($[C])<de)$[C]=0;else{f=!0;break}}}this.init_outer_loop=function(k,_){_.part2_3_length=0,_.big_values=0,_.count1=0,_.global_gain=210,_.scalefac_compress=0,_.table_select[0]=0,_.table_select[1]=0,_.table_select[2]=0,_.subblock_gain[0]=0,_.subblock_gain[1]=0,_.subblock_gain[2]=0,_.subblock_gain[3]=0,_.region0_count=0,_.region1_count=0,_.preflag=0,_.scalefac_scale=0,_.count1table_select=0,_.part2_length=0,_.sfb_lmax=bt.SBPSY_l,_.sfb_smin=bt.SBPSY_s,_.psy_lmax=k.sfb21_extra?bt.SBMAX_l:bt.SBPSY_l,_.psymax=_.psy_lmax,_.sfbmax=_.sfb_lmax,_.sfbdivide=11;for(var m=0;m<bt.SBMAX_l;m++)_.width[m]=k.scalefac_band.l[m+1]-k.scalefac_band.l[m],_.window[m]=3;if(_.block_type==bt.SHORT_TYPE){var $=Aa(576);_.sfb_smin=0,_.sfb_lmax=0,_.mixed_block_flag!=0&&(_.sfb_smin=3,_.sfb_lmax=k.mode_gr*2+4),_.psymax=_.sfb_lmax+3*((k.sfb21_extra?bt.SBMAX_s:bt.SBPSY_s)-_.sfb_smin),_.sfbmax=_.sfb_lmax+3*(bt.SBPSY_s-_.sfb_smin),_.sfbdivide=_.sfbmax-18,_.psy_lmax=_.sfb_lmax;var f=k.scalefac_band.l[_.sfb_lmax];_s.arraycopy(_.xr,0,$,0,576);for(var m=_.sfb_smin;m<bt.SBMAX_s;m++)for(var E=k.scalefac_band.s[m],N=k.scalefac_band.s[m+1],B=0;B<3;B++)for(var U=E;U<N;U++)_.xr[f++]=$[3*U+B];for(var C=_.sfb_lmax,m=_.sfb_smin;m<bt.SBMAX_s;m++)_.width[C]=_.width[C+1]=_.width[C+2]=k.scalefac_band.s[m+1]-k.scalefac_band.s[m],_.window[C]=0,_.window[C+1]=1,_.window[C+2]=2,C+=3}_.count1bits=0,_.sfb_partition_table=r.nr_of_sfb_block[0][0],_.slen[0]=0,_.slen[1]=0,_.slen[2]=0,_.slen[3]=0,_.max_nonzero_coeff=575,di.fill(_.scalefac,0),i(k,_)};function a(k){this.ordinal=k}a.BINSEARCH_NONE=new a(0),a.BINSEARCH_UP=new a(1),a.BINSEARCH_DOWN=new a(2);function c(k,_,m,$,f){var E,N=k.CurrentStep[$],B=!1,U=k.OldValue[$],C=a.BINSEARCH_NONE;for(_.global_gain=U,m-=_.part2_length;;){var q;if(E=s.count_bits(k,f,_,null),N==1||E==m)break;E>m?(C==a.BINSEARCH_DOWN&&(B=!0),B&&(N/=2),C=a.BINSEARCH_UP,q=N):(C==a.BINSEARCH_UP&&(B=!0),B&&(N/=2),C=a.BINSEARCH_DOWN,q=-N),_.global_gain+=q,_.global_gain<0&&(_.global_gain=0,B=!0),_.global_gain>255&&(_.global_gain=255,B=!0)}for(Na(_.global_gain>=0),Na(_.global_gain<256);E>m&&_.global_gain<255;)_.global_gain++,E=s.count_bits(k,f,_,null);return k.CurrentStep[$]=U-_.global_gain>=4?4:2,k.OldValue[$]=_.global_gain,_.part2_3_length=E,E}this.trancate_smallspectrums=function(k,_,m,$){var f=Aa(Hw.SFBMAX);if(!(!(k.substep_shaping&4)&&_.block_type==bt.SHORT_TYPE||k.substep_shaping&128)){r.calc_noise(_,m,f,new n1,null);for(var N=0;N<576;N++){var E=0;_.l3_enc[N]!=0&&(E=Math.abs(_.xr[N])),$[N]=E}var N=0,B=8;_.block_type==bt.SHORT_TYPE&&(B=6);do{var U,C,q,de,A=_.width[B];if(N+=A,!(f[B]>=1)&&(di.sort($,N-A,A),!BitStream.EQ($[N-1],0))){U=(1-f[B])*m[B],C=0,de=0;do{var b;for(q=1;de+q<A&&!BitStream.NEQ($[de+N-A],$[de+N+q-A]);q++);if(b=$[de+N-A]*$[de+N-A]*q,U<b){de!=0&&(C=$[de+N-A-1]);break}U-=b,de+=q}while(de<A);if(!BitStream.EQ(C,0))do Math.abs(_.xr[N-A])<=C&&(_.l3_enc[N-A]=0);while(--A>0)}}while(++B<_.psymax);_.part2_3_length=s.noquant_count_bits(k,_,null)}};function d(k){for(var _=0;_<k.sfbmax;_++)if(k.scalefac[_]+k.subblock_gain[k.window[_]]==0)return!1;return!0}function l(k){return r1.FAST_LOG10(.368+.632*k*k*k)}function u(k,_){for(var m=1e-37,$=0;$<_.psymax;$++)m+=l(k[$]);return Math.max(1e-20,m)}function h(k,_,m,$,f){var E;switch(k){default:case 9:{_.over_count>0?(E=m.over_SSD<=_.over_SSD,m.over_SSD==_.over_SSD&&(E=m.bits<_.bits)):E=m.max_noise<0&&m.max_noise*10+m.bits<=_.max_noise*10+_.bits;break}case 0:E=m.over_count<_.over_count||m.over_count==_.over_count&&m.over_noise<_.over_noise||m.over_count==_.over_count&&BitStream.EQ(m.over_noise,_.over_noise)&&m.tot_noise<_.tot_noise;break;case 8:m.max_noise=u(f,$);case 1:E=m.max_noise<_.max_noise;break;case 2:E=m.tot_noise<_.tot_noise;break;case 3:E=m.tot_noise<_.tot_noise&&m.max_noise<_.max_noise;break;case 4:E=m.max_noise<=0&&_.max_noise>.2||m.max_noise<=0&&_.max_noise<0&&_.max_noise>m.max_noise-.2&&m.tot_noise<_.tot_noise||m.max_noise<=0&&_.max_noise>0&&_.max_noise>m.max_noise-.2&&m.tot_noise<_.tot_noise+_.over_noise||m.max_noise>0&&_.max_noise>-.05&&_.max_noise>m.max_noise-.1&&m.tot_noise+m.over_noise<_.tot_noise+_.over_noise||m.max_noise>0&&_.max_noise>-.1&&_.max_noise>m.max_noise-.15&&m.tot_noise+m.over_noise+m.over_noise<_.tot_noise+_.over_noise+_.over_noise;break;case 5:E=m.over_noise<_.over_noise||BitStream.EQ(m.over_noise,_.over_noise)&&m.tot_noise<_.tot_noise;break;case 6:E=m.over_noise<_.over_noise||BitStream.EQ(m.over_noise,_.over_noise)&&(m.max_noise<_.max_noise||BitStream.EQ(m.max_noise,_.max_noise)&&m.tot_noise<=_.tot_noise);break;case 7:E=m.over_count<_.over_count||m.over_noise<_.over_noise;break}return _.over_count==0&&(E=E&&m.bits<_.bits),E}function p(k,_,m,$,f){var E=k.internal_flags,N;_.scalefac_scale==0?N=1.2968395546510096:N=1.6817928305074292;for(var B=0,U=0;U<_.sfbmax;U++)B<m[U]&&(B=m[U]);var C=E.noise_shaping_amp;switch(C==3&&(f?C=2:C=1),C){case 2:break;case 1:B>1?B=Math.pow(B,.5):B*=.95;break;case 0:default:B>1?B=1:B*=.95;break}for(var q=0,U=0;U<_.sfbmax;U++){var de=_.width[U],A;if(q+=de,!(m[U]<B)){if(E.substep_shaping&2&&(E.pseudohalf[U]=E.pseudohalf[U]==0?1:0,E.pseudohalf[U]==0&&E.noise_shaping_amp==2))return;for(_.scalefac[U]++,A=-de;A<0;A++)$[q+A]*=N,$[q+A]>_.xrpow_max&&(_.xrpow_max=$[q+A]);if(E.noise_shaping_amp==2)return}}}function g(k,_){for(var m=1.2968395546510096,$=0,f=0;f<k.sfbmax;f++){var E=k.width[f],N=k.scalefac[f];if(k.preflag!=0&&(N+=r.pretab[f]),$+=E,N&1){N++;for(var B=-E;B<0;B++)_[$+B]*=m,_[$+B]>k.xrpow_max&&(k.xrpow_max=_[$+B])}k.scalefac[f]=N>>1}k.preflag=0,k.scalefac_scale=1}function x(k,_,m){var $,f=_.scalefac;for($=0;$<_.sfb_lmax;$++)if(f[$]>=16)return!0;for(var E=0;E<3;E++){var N=0,B=0;for($=_.sfb_lmax+E;$<_.sfbdivide;$+=3)N<f[$]&&(N=f[$]);for(;$<_.sfbmax;$+=3)B<f[$]&&(B=f[$]);if(!(N<16&&B<8)){if(_.subblock_gain[E]>=7)return!0;_.subblock_gain[E]++;var U=k.scalefac_band.l[_.sfb_lmax];for($=_.sfb_lmax+E;$<_.sfbmax;$+=3){var C,q=_.width[$],de=f[$];if(de=de-(4>>_.scalefac_scale),de>=0){f[$]=de,U+=q*3;continue}f[$]=0;{var A=210+(de<<_.scalefac_scale+1);C=r.IPOW20(A)}U+=q*(E+1);for(var b=-q;b<0;b++)m[U+b]*=C,m[U+b]>_.xrpow_max&&(_.xrpow_max=m[U+b]);U+=q*(3-E-1)}{var C=r.IPOW20(202);U+=_.width[$]*(E+1);for(var b=-_.width[$];b<0;b++)m[U+b]*=C,m[U+b]>_.xrpow_max&&(_.xrpow_max=m[U+b])}}}return!1}function S(k,_,m,$,f){var E=k.internal_flags;p(k,_,m,$,f);var N=d(_);return N?!1:(E.mode_gr==2?N=s.scale_bitcount(_):N=s.scale_bitcount_lsf(E,_),N?(E.noise_shaping>1&&(di.fill(E.pseudohalf,0),_.scalefac_scale==0?(g(_,$),N=!1):_.block_type==bt.SHORT_TYPE&&E.subblock_gain>0&&(N=x(E,_,$)||d(_))),N||(E.mode_gr==2?N=s.scale_bitcount(_):N=s.scale_bitcount_lsf(E,_)),!N):!0)}this.outer_loop=function(k,_,m,$,f,E){var N=k.internal_flags,B=new Fw,U=Aa(576),C=Aa(Hw.SFBMAX),q=new n1,de,A=new wI,b=9999999,D=!1,I=!1,Y=0;if(c(N,_,E,f,$),N.noise_shaping==0)return 100;r.calc_noise(_,m,C,q,A),q.bits=_.part2_3_length,B.assign(_);var V=0;for(_s.arraycopy($,0,U,0,576);!D;){do{var ee=new n1,L,T=255;if(N.substep_shaping&2?L=20:L=3,N.sfb21_extra&&(C[B.sfbmax]>1||B.block_type==bt.SHORT_TYPE&&(C[B.sfbmax+1]>1||C[B.sfbmax+2]>1))||!S(k,B,C,$,I))break;B.scalefac_scale!=0&&(T=254);var y=E-B.part2_length;if(y<=0)break;for(;(B.part2_3_length=s.count_bits(N,$,B,A))>y&&B.global_gain<=T;)B.global_gain++;if(B.global_gain>T)break;if(q.over_count==0){for(;(B.part2_3_length=s.count_bits(N,$,B,A))>b&&B.global_gain<=T;)B.global_gain++;if(B.global_gain>T)break}if(r.calc_noise(B,m,C,ee,A),ee.bits=B.part2_3_length,_.block_type!=bt.SHORT_TYPE?de=k.quant_comp:de=k.quant_comp_short,de=h(de,q,ee,B,C)?1:0,de!=0)b=_.part2_3_length,q=ee,_.assign(B),V=0,_s.arraycopy($,0,U,0,576);else if(N.full_outer_loop==0&&(++V>L&&q.over_count==0||N.noise_shaping_amp==3&&I&&V>30||N.noise_shaping_amp==3&&I&&B.global_gain-Y>15))break}while(B.global_gain+B.scalefac_scale<255);N.noise_shaping_amp==3?I?D=!0:(B.assign(_),_s.arraycopy(U,0,$,0,576),V=0,Y=B.global_gain,I=!0):D=!0}return Na(_.global_gain+_.scalefac_scale<=255),k.VBR==Vw.vbr_rh||k.VBR==Vw.vbr_mtrh?_s.arraycopy(U,0,$,0,576):N.substep_shaping&1&&trancate_smallspectrums(N,_,m,$),q.over_count},this.iteration_finish_one=function(k,_,m){var $=k.l3_side,f=$.tt[_][m];s.best_scalefac_store(k,_,m,$),k.use_best_huffman==1&&s.best_huffman_divide(k,f),e.ResvAdjust(k,f)},this.VBR_encode_granule=function(k,_,m,$,f,E,N){var B=k.internal_flags,U=new Fw,C=Aa(576),q=N,de=N+1,A=(N+E)/2,b,D,I=0,Y=B.sfb21_extra;Na(q<=LameInternalFlags.MAX_BITS_PER_CHANNEL),di.fill(U.l3_enc,0);do A>q-42?B.sfb21_extra=!1:B.sfb21_extra=Y,D=outer_loop(k,_,m,$,f,A),D<=0?(I=1,de=_.part2_3_length,U.assign(_),_s.arraycopy($,0,C,0,576),N=de-32,b=N-E,A=(N+E)/2):(E=A+32,b=N-E,A=(N+E)/2,I!=0&&(I=2,_.assign(U),_s.arraycopy(C,0,$,0,576)));while(b>12);B.sfb21_extra=Y,I==2&&_s.arraycopy(U.l3_enc,0,_.l3_enc,0,576),Na(_.part2_3_length<=q)},this.get_framebits=function(k,_){var m=k.internal_flags;m.bitrate_index=m.VBR_min_bitrate;var $=t.getframebits(k);m.bitrate_index=1,$=t.getframebits(k);for(var f=1;f<=m.VBR_max_bitrate;f++){m.bitrate_index=f;var E=new MeanBits($);_[f]=e.ResvFrameBegin(k,E),$=E.bits}},this.VBR_old_prepare=function(k,_,m,$,f,E,N,B,U){var C=k.internal_flags,q,de=0,A=1,b=0;C.bitrate_index=C.VBR_max_bitrate;var D=e.ResvFrameBegin(k,new MeanBits(0))/C.mode_gr;get_framebits(k,E);for(var I=0;I<C.mode_gr;I++){var Y=r.on_pe(k,_,B[I],D,I,0);C.mode_ext==bt.MPG_MD_MS_LR&&(ms_convert(C.l3_side,I),r.reduce_side(B[I],m[I],D,Y));for(var V=0;V<C.channels_out;++V){var ee=C.l3_side.tt[I][V];ee.block_type!=bt.SHORT_TYPE?(de=1.28/(1+Math.exp(3.5-_[I][V]/300))-.05,q=C.PSY.mask_adjust-de):(de=2.56/(1+Math.exp(3.5-_[I][V]/300))-.14,q=C.PSY.mask_adjust_short-de),C.masking_lower=Math.pow(10,q*.1),init_outer_loop(C,ee),U[I][V]=r.calc_xmin(k,$[I][V],ee,f[I][V]),U[I][V]!=0&&(A=0),N[I][V]=126,b+=B[I][V]}}for(var I=0;I<C.mode_gr;I++)for(var V=0;V<C.channels_out;V++)b>E[C.VBR_max_bitrate]&&(B[I][V]*=E[C.VBR_max_bitrate],B[I][V]/=b),N[I][V]>B[I][V]&&(N[I][V]=B[I][V]);return A},this.bitpressure_strategy=function(k,_,m,$){for(var f=0;f<k.mode_gr;f++)for(var E=0;E<k.channels_out;E++){for(var N=k.l3_side.tt[f][E],B=_[f][E],U=0,C=0;C<N.psy_lmax;C++)B[U++]*=1+.029*C*C/bt.SBMAX_l/bt.SBMAX_l;if(N.block_type==bt.SHORT_TYPE)for(var C=N.sfb_smin;C<bt.SBMAX_s;C++)B[U++]*=1+.029*C*C/bt.SBMAX_s/bt.SBMAX_s,B[U++]*=1+.029*C*C/bt.SBMAX_s/bt.SBMAX_s,B[U++]*=1+.029*C*C/bt.SBMAX_s/bt.SBMAX_s;$[f][E]=0|Math.max(m[f][E],.9*$[f][E])}},this.VBR_new_prepare=function(k,_,m,$,f,E){var N=k.internal_flags,B=1,U=0,C=0,q;if(k.free_format){N.bitrate_index=0;var de=new MeanBits(U);q=e.ResvFrameBegin(k,de),U=de.bits,f[0]=q}else{N.bitrate_index=N.VBR_max_bitrate;var de=new MeanBits(U);e.ResvFrameBegin(k,de),U=de.bits,get_framebits(k,f),q=f[N.VBR_max_bitrate]}for(var A=0;A<N.mode_gr;A++){r.on_pe(k,_,E[A],U,A,0),N.mode_ext==bt.MPG_MD_MS_LR&&ms_convert(N.l3_side,A);for(var b=0;b<N.channels_out;++b){var D=N.l3_side.tt[A][b];N.masking_lower=Math.pow(10,N.PSY.mask_adjust*.1),init_outer_loop(N,D),r.calc_xmin(k,m[A][b],D,$[A][b])!=0&&(B=0),C+=E[A][b]}}for(var A=0;A<N.mode_gr;A++)for(var b=0;b<N.channels_out;b++)C>q&&(E[A][b]*=q,E[A][b]/=C);return B},this.calc_target_bits=function(k,_,m,$,f,E){var N=k.internal_flags,B=N.l3_side,U,C,q,de,A=0;N.bitrate_index=N.VBR_max_bitrate;var b=new MeanBits(A);for(E[0]=e.ResvFrameBegin(k,b),A=b.bits,N.bitrate_index=1,A=t.getframebits(k)-N.sideinfo_len*8,f[0]=A/(N.mode_gr*N.channels_out),A=k.VBR_mean_bitrate_kbps*k.framesize*1e3,N.substep_shaping&1&&(A*=1.09),A/=k.out_samplerate,A-=N.sideinfo_len*8,A/=N.mode_gr*N.channels_out,U=.93+.07*(11-k.compression_ratio)/(11-5.5),U<.9&&(U=.9),U>1&&(U=1),C=0;C<N.mode_gr;C++){var D=0;for(q=0;q<N.channels_out;q++){if($[C][q]=int(U*A),_[C][q]>700){var I=int((_[C][q]-700)/1.4),Y=B.tt[C][q];$[C][q]=int(U*A),Y.block_type==bt.SHORT_TYPE&&I<A/2&&(I=A/2),I>A*3/2?I=A*3/2:I<0&&(I=0),$[C][q]+=I}$[C][q]>LameInternalFlags.MAX_BITS_PER_CHANNEL&&($[C][q]=LameInternalFlags.MAX_BITS_PER_CHANNEL),D+=$[C][q]}if(D>LameInternalFlags.MAX_BITS_PER_GRANULE)for(q=0;q<N.channels_out;++q)$[C][q]*=LameInternalFlags.MAX_BITS_PER_GRANULE,$[C][q]/=D}if(N.mode_ext==bt.MPG_MD_MS_LR)for(C=0;C<N.mode_gr;C++)r.reduce_side($[C],m[C],A*N.channels_out,LameInternalFlags.MAX_BITS_PER_GRANULE);for(de=0,C=0;C<N.mode_gr;C++)for(q=0;q<N.channels_out;q++)$[C][q]>LameInternalFlags.MAX_BITS_PER_CHANNEL&&($[C][q]=LameInternalFlags.MAX_BITS_PER_CHANNEL),de+=$[C][q];if(de>E[0])for(C=0;C<N.mode_gr;C++)for(q=0;q<N.channels_out;q++)$[C][q]*=E[0],$[C][q]/=de}}var kI=xI,SI=Zt,Uw=SI.assert;function EI(){var t;this.setModules=function(e){t=e},this.ResvFrameBegin=function(e,r){var n=e.internal_flags,s,o=n.l3_side,i=t.getframebits(e);r.bits=(i-n.sideinfo_len*8)/n.mode_gr;var a=8*256*n.mode_gr-8;e.brate>320?s=8*int(e.brate*1e3/(e.out_samplerate/1152)/8+.5):(s=8*1440,e.strict_ISO&&(s=8*int(32e4/(e.out_samplerate/1152)/8+.5))),n.ResvMax=s-i,n.ResvMax>a&&(n.ResvMax=a),(n.ResvMax<0||e.disable_reservoir)&&(n.ResvMax=0);var c=r.bits*n.mode_gr+Math.min(n.ResvSize,n.ResvMax);return c>s&&(c=s),Uw(n.ResvMax%8==0),Uw(n.ResvMax>=0),o.resvDrain_pre=0,n.pinfo!=null&&(n.pinfo.mean_bits=r.bits/2,n.pinfo.resvsize=n.ResvSize),c},this.ResvMaxBits=function(e,r,n,s){var o=e.internal_flags,i,a=o.ResvSize,c=o.ResvMax;s!=0&&(a+=r),o.substep_shaping&1&&(c*=.9),n.bits=r,a*10>c*9?(i=a-c*9/10,n.bits+=i,o.substep_shaping|=128):(i=0,o.substep_shaping&=127,!e.disable_reservoir&&!(o.substep_shaping&1)&&(n.bits-=.1*r));var d=a<o.ResvMax*6/10?a:o.ResvMax*6/10;return d-=i,d<0&&(d=0),d},this.ResvAdjust=function(e,r){e.ResvSize-=r.part2_3_length+r.part2_length},this.ResvFrameEnd=function(e,r){var n,s=e.l3_side;e.ResvSize+=r*e.mode_gr;var o=0;s.resvDrain_post=0,s.resvDrain_pre=0,(n=e.ResvSize%8)!=0&&(o+=n),n=e.ResvSize-o-e.ResvMax,n>0&&(o+=n);{var i=Math.min(s.main_data_begin*8,o)/8;s.resvDrain_pre+=8*i,o-=8*i,e.ResvSize-=8*i,s.main_data_begin-=i}s.resvDrain_post+=o,e.ResvSize-=o}}var TI=EI;function $I(){var t="http://www.mp3dev.org/",e=3,r=98,n=4,s=0,o=93;this.getLameVersion=function(){return e+"."+r+"."+n},this.getLameShortVersion=function(){return e+"."+r+"."+n},this.getLameVeryShortVersion=function(){return"LAME"+e+"."+r+"r"},this.getPsyVersion=function(){return s+"."+o},this.getLameUrl=function(){return t},this.getLameOsBitness=function(){return"32bits"}}var RI=$I,pi=Zt,PI=pi.System,s1=pi.VbrMode,Gw=pi.ShortBlock,MI=pi.Arrays,ru=pi.new_byte,zI=pi.assert;Ca.NUMTOCENTRIES=100;Ca.MAXFRAMESIZE=2880;function Ca(){var t,e,r;this.setModules=function(A,b,D){t=A,e=b,r=D};var n=1,s=2,o=4,i=8,a=Ca.NUMTOCENTRIES,c=Ca.MAXFRAMESIZE,d=a+4+4+4+4+4,l=d+9+1+1+8+1+1+3+1+1+2+4+2+2,u=128,h=64,p=32,g=null,x="Xing",S="Info",k=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];function _(A,b){if(A.nVbrNumFrames++,A.sum+=b,A.seen++,!(A.seen<A.want)&&(A.pos<A.size&&(A.bag[A.pos]=A.sum,A.pos++,A.seen=0),A.pos==A.size)){for(var D=1;D<A.size;D+=2)A.bag[D/2]=A.bag[D];A.want*=2,A.pos/=2}}function m(A,b){if(!(A.pos<=0))for(var D=1;D<a;++D){var I=D/a,Y,V,ee=0|Math.floor(I*A.pos);ee>A.pos-1&&(ee=A.pos-1),Y=A.bag[ee],V=A.sum;var L=0|256*Y/V;L>255&&(L=255),b[D]=255&L}}this.addVbrFrame=function(A){var b=A.internal_flags,D=Tables.bitrate_table[A.version][b.bitrate_index];zI(b.VBR_seek_table.bag!=null),_(b.VBR_seek_table,D)};function $(A,b){var D=A[b+0]&255;return D<<=8,D|=A[b+1]&255,D<<=8,D|=A[b+2]&255,D<<=8,D|=A[b+3]&255,D}function f(A,b,D){A[b+0]=255&(D>>24&255),A[b+1]=255&(D>>16&255),A[b+2]=255&(D>>8&255),A[b+3]=255&(D&255)}function E(A,b,D){A[b+0]=255&(D>>8&255),A[b+1]=255&(D&255)}function N(A,b){return new String(A,b,x.length(),g).equals(x)||new String(A,b,S.length(),g).equals(S)}function B(A,b,D){return 255&(A<<b|D&~(-1<<b))}function U(A,b){var D=A.internal_flags;b[0]=B(b[0],8,255),b[1]=B(b[1],3,7),b[1]=B(b[1],1,A.out_samplerate<16e3?0:1),b[1]=B(b[1],1,A.version),b[1]=B(b[1],2,1),b[1]=B(b[1],1,A.error_protection?0:1),b[2]=B(b[2],4,D.bitrate_index),b[2]=B(b[2],2,D.samplerate_index),b[2]=B(b[2],1,0),b[2]=B(b[2],1,A.extension),b[3]=B(b[3],2,A.mode.ordinal()),b[3]=B(b[3],2,D.mode_ext),b[3]=B(b[3],1,A.copyright),b[3]=B(b[3],1,A.original),b[3]=B(b[3],2,A.emphasis),b[0]=255;var I=255&(b[1]&241),Y;A.version==1?Y=u:A.out_samplerate<16e3?Y=p:Y=h,A.VBR==s1.vbr_off&&(Y=A.brate);var V;A.free_format?V=0:V=255&16*t.BitrateIndex(Y,A.version,A.out_samplerate),A.version==1?(b[1]=255&(I|10),I=255&(b[2]&13),b[2]=255&(V|I)):(b[1]=255&(I|2),I=255&(b[2]&13),b[2]=255&(V|I))}this.getVbrTag=function(A){var b=new VBRTagData,D=0;b.flags=0;var I=A[D+1]>>3&1,Y=A[D+2]>>2&3,V=A[D+3]>>6&3,ee=A[D+2]>>4&15;if(ee=Tables.bitrate_table[I][ee],A[D+1]>>4==14?b.samprate=Tables.samplerate_table[2][Y]:b.samprate=Tables.samplerate_table[I][Y],I!=0?V!=3?D+=36:D+=21:V!=3?D+=21:D+=13,!N(A,D))return null;D+=4,b.hId=I;var L=b.flags=$(A,D);if(D+=4,L&n&&(b.frames=$(A,D),D+=4),L&s&&(b.bytes=$(A,D),D+=4),L&o){if(b.toc!=null)for(var T=0;T<a;T++)b.toc[T]=A[D+T];D+=a}b.vbrScale=-1,L&i&&(b.vbrScale=$(A,D),D+=4),b.headersize=(I+1)*72e3*ee/b.samprate,D+=21;var y=A[D+0]<<4;y+=A[D+1]>>4;var v=(A[D+1]&15)<<8;return v+=A[D+2]&255,(y<0||y>3e3)&&(y=-1),(v<0||v>3e3)&&(v=-1),b.encDelay=y,b.encPadding=v,b},this.InitVbrTag=function(A){var b=A.internal_flags,D;A.version==1?D=u:A.out_samplerate<16e3?D=p:D=h,A.VBR==s1.vbr_off&&(D=A.brate);var I=(A.version+1)*72e3*D/A.out_samplerate,Y=b.sideinfo_len+l;if(b.VBR_seek_table.TotalFrameSize=I,I<Y||I>c){A.bWriteVbrTag=!1;return}b.VBR_seek_table.nVbrNumFrames=0,b.VBR_seek_table.nBytesWritten=0,b.VBR_seek_table.sum=0,b.VBR_seek_table.seen=0,b.VBR_seek_table.want=1,b.VBR_seek_table.pos=0,b.VBR_seek_table.bag==null&&(b.VBR_seek_table.bag=new int[400],b.VBR_seek_table.size=400);var V=ru(c);U(A,V);for(var ee=b.VBR_seek_table.TotalFrameSize,L=0;L<ee;++L)e.add_dummy_byte(A,V[L]&255,1)};function C(A,b){var D=b^A;return b=b>>8^k[D&255],b}this.updateMusicCRC=function(A,b,D,I){for(var Y=0;Y<I;++Y)A[0]=C(b[D+Y],A[0])};function q(A,b,D,I,Y){var V=A.internal_flags,ee=0,L=A.encoder_delay,T=A.encoder_padding,y=100-10*A.VBR_q-A.quality,v=r.getLameVeryShortVersion(),R,O=0,K,se=[1,5,3,2,4,0,3],F=0|(A.lowpassfreq/100+.5>255?255:A.lowpassfreq/100+.5),Q=0,ue=0,ge=0,ke=A.internal_flags.noise_shaping,Re=0,Te=0,Se=0,Ce=0,St=0,Fr=(A.exp_nspsytune&1)!=0,w=(A.exp_nspsytune&2)!=0,P=!1,xe=!1,Pe=A.internal_flags.nogap_total,Ge=A.internal_flags.nogap_current,He=A.ATHtype,Ne=0,ze;switch(A.VBR){case vbr_abr:ze=A.VBR_mean_bitrate_kbps;break;case vbr_off:ze=A.brate;break;default:ze=A.VBR_min_bitrate_kbps}switch(A.VBR.ordinal()<se.length?R=se[A.VBR.ordinal()]:R=0,K=16*O+R,V.findReplayGain&&(V.RadioGain>510&&(V.RadioGain=510),V.RadioGain<-510&&(V.RadioGain=-510),ue=8192,ue|=3072,V.RadioGain>=0?ue|=V.RadioGain:(ue|=512,ue|=-V.RadioGain)),V.findPeakSample&&(Q=Math.abs(0|V.PeakSample/32767*Math.pow(2,23)+.5)),Pe!=-1&&(Ge>0&&(xe=!0),Ge<Pe-1&&(P=!0)),Ne=He+((Fr?1:0)<<4)+((w?1:0)<<5)+((P?1:0)<<6)+((xe?1:0)<<7),y<0&&(y=0),A.mode){case MONO:Re=0;break;case STEREO:Re=1;break;case DUAL_CHANNEL:Re=2;break;case JOINT_STEREO:A.force_ms?Re=4:Re=3;break;case NOT_SET:default:Re=7;break}A.in_samplerate<=32e3?Se=0:A.in_samplerate==48e3?Se=2:A.in_samplerate>48e3?Se=3:Se=1,(A.short_blocks==Gw.short_block_forced||A.short_blocks==Gw.short_block_dispensed||A.lowpassfreq==-1&&A.highpassfreq==-1||A.scale_left<A.scale_right||A.scale_left>A.scale_right||A.disable_reservoir&&A.brate<320||A.noATH||A.ATHonly||He==0||A.in_samplerate<=32e3)&&(Te=1),Ce=ke+(Re<<2)+(Te<<5)+(Se<<6),St=V.nMusicCRC,f(D,I+ee,y),ee+=4;for(var et=0;et<9;et++)D[I+ee+et]=255&v.charAt(et);ee+=9,D[I+ee]=255&K,ee++,D[I+ee]=255&F,ee++,f(D,I+ee,Q),ee+=4,E(D,I+ee,ue),ee+=2,E(D,I+ee,ge),ee+=2,D[I+ee]=255&Ne,ee++,ze>=255?D[I+ee]=255:D[I+ee]=255&ze,ee++,D[I+ee]=255&L>>4,D[I+ee+1]=255&(L<<4)+(T>>8),D[I+ee+2]=255&T,ee+=3,D[I+ee]=255&Ce,ee++,D[I+ee++]=0,E(D,I+ee,A.preset),ee+=2,f(D,I+ee,b),ee+=4,E(D,I+ee,St),ee+=2;for(var je=0;je<ee;je++)Y=C(D[I+je],Y);return E(D,I+ee,Y),ee+=2,ee}function de(A){A.seek(0);var b=ru(10);A.readFully(b);var D;return new String(b,"ISO-8859-1").startsWith("ID3")?D=0:D=((b[6]&127)<<21|(b[7]&127)<<14|(b[8]&127)<<7|b[9]&127)+b.length,D}this.getLameTagFrame=function(A,b){var D=A.internal_flags;if(!A.bWriteVbrTag||D.Class_ID!=Lame.LAME_ID||D.VBR_seek_table.pos<=0)return 0;if(b.length<D.VBR_seek_table.TotalFrameSize)return D.VBR_seek_table.TotalFrameSize;MI.fill(b,0,D.VBR_seek_table.TotalFrameSize,0),U(A,b);var I=ru(a);if(A.free_format)for(var Y=1;Y<a;++Y)I[Y]=255&255*Y/100;else m(D.VBR_seek_table,I);var V=D.sideinfo_len;A.error_protection&&(V-=2),A.VBR==s1.vbr_off?(b[V++]=255&S.charAt(0),b[V++]=255&S.charAt(1),b[V++]=255&S.charAt(2),b[V++]=255&S.charAt(3)):(b[V++]=255&x.charAt(0),b[V++]=255&x.charAt(1),b[V++]=255&x.charAt(2),b[V++]=255&x.charAt(3)),f(b,V,n+s+o+i),V+=4,f(b,V,D.VBR_seek_table.nVbrNumFrames),V+=4;var ee=D.VBR_seek_table.nBytesWritten+D.VBR_seek_table.TotalFrameSize;f(b,V,0|ee),V+=4,PI.arraycopy(I,0,b,V,I.length),V+=I.length,A.error_protection&&e.CRC_writeheader(D,b);for(var L=0,Y=0;Y<V;Y++)L=C(b[Y],L);return V+=q(A,ee,b,V,L),D.VBR_seek_table.TotalFrameSize},this.putVbrTag=function(A,b){var D=A.internal_flags;if(D.VBR_seek_table.pos<=0||(b.seek(b.length()),b.length()==0))return-1;var I=de(b);b.seek(I);var Y=ru(c),V=getLameTagFrame(A,Y);return V>Y.length?-1:(V<1||b.write(Y,0,V),0)}}var II=Ca,b3=Zt,Yw=b3.new_byte,OI=b3.assert,AI=u1(),NI=fI,CI=f3,jI=m3(),DI=kI,LI=g3(),ZI=TI,BI=Da,qI=l1();hr();var VI=RI,FI=II;function HI(){this.setModules=function(t,e){}}function UI(){this.setModules=function(t,e,r){}}function GI(){}function YI(){this.setModules=function(t,e){}}function XI(t,e,r){arguments.length!=3&&(console.error("WARN: Mp3Encoder(channels, samplerate, kbps) not specified"),t=1,e=44100,r=128);var n=new AI,s=new HI,o=new CI,i=new qI,a=new NI,c=new jI,d=new DI,l=new FI,u=new VI,h=new YI,p=new ZI,g=new LI,x=new UI,S=new GI;n.setModules(o,i,a,c,d,l,u,h,S),i.setModules(o,S,u,l),h.setModules(i,u),a.setModules(n),d.setModules(i,p,c,g),c.setModules(g,p,n.enc.psy),p.setModules(i),g.setModules(c),l.setModules(n,i,u),s.setModules(x,S),x.setModules(u,h,a);var k=n.lame_init();k.num_channels=t,k.in_samplerate=e,k.brate=r,k.mode=BI.STEREO,k.quality=3,k.bWriteVbrTag=!1,k.disable_reservoir=!0,k.write_id3tag_automatic=!1,n.lame_init_params(k);var _=1152,m=0|1.25*_+7200,$=Yw(m);this.encodeBuffer=function(f,E){t==1&&(E=f),OI(f.length==E.length),f.length>_&&(_=f.length,m=0|1.25*_+7200,$=Yw(m));var N=n.lame_encode_buffer(k,f,E,f.length,$,0,m);return new Int8Array($.subarray(0,N))},this.flush=function(){var f=n.lame_encode_flush(k,$,0,m);return new Int8Array($.subarray(0,f))}}function wn(){this.dataOffset=0,this.dataLen=0,this.channels=0,this.sampleRate=0}function iu(t){return t.charCodeAt(0)<<24|t.charCodeAt(1)<<16|t.charCodeAt(2)<<8|t.charCodeAt(3)}wn.RIFF=iu("RIFF");wn.WAVE=iu("WAVE");wn.fmt_=iu("fmt ");wn.data=iu("data");wn.readHeader=function(t){var e=new wn,r=t.getUint32(0,!1);if(wn.RIFF==r&&(t.getUint32(4,!0),wn.WAVE==t.getUint32(8,!1)&&wn.fmt_==t.getUint32(12,!1))){var n=t.getUint32(16,!0),s=20;switch(n){case 16:case 18:e.channels=t.getUint16(s+2,!0),e.sampleRate=t.getUint32(s+4,!0);break;default:throw"extended fmt chunk not implemented"}s+=n;for(var o=wn.data,i=0;o!=r&&(r=t.getUint32(s,!1),i=t.getUint32(s+4,!0),o!=r);)s+=i+8;return e.dataLen=i,e.dataOffset=s+8,e}};var y3=Xw.Mp3Encoder=XI,aq=Xw.WavHeader=wn;var mo=24e3;function d1(t){let e=Buffer.from(t);return new Int16Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/2))}function WI(t){let e=t.indexOf("data",0,"ascii"),r=e>=0?e+8:44;return d1(t.subarray(r))}var KI="Tone: friendly, clear, and natural \u2014 like a knowledgeable teacher explaining something they enjoy. Calm and encouraging, not theatrical.",JI="Delivery: a brisk, efficient speaking pace \u2014 energetic and moving forward, like a confident presenter who respects the listener's time. Clear pronunciation, but keep pauses between sentences short and don't linger. Keep ONE consistent voice throughout \u2014 the same character, gender, accent, and pitch on every line, as if it's one continuous recording by the same narrator. Do not change character or add dramatic, performative variation.";function QI(t){return process.env.FLOWCAST_TTS_INSTRUCTIONS?process.env.FLOWCAST_TTS_INSTRUCTIONS:`${t&&t.trim()?`Tone & delivery for this walkthrough: ${t.trim()}`:KI}
206
-
207
- ${JI}`}var eO={id:"openai",keyEnv:"OPENAI_API_KEY",hasKey:()=>!!process.env.OPENAI_API_KEY,async synth(t,e){let r=(process.env.OPENAI_BASE_URL||"https://api.openai.com/v1").replace(/\/$/,""),n=await fetch(`${r}/audio/speech`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${process.env.OPENAI_API_KEY}`},body:JSON.stringify({model:process.env.FLOWCAST_TTS_MODEL||"gpt-4o-mini-tts",voice:process.env.FLOWCAST_TTS_VOICE||Ey(e.voiceName),input:t,response_format:"pcm",instructions:QI(e.voiceTone)})});if(!n.ok)throw new Error(`OpenAI TTS ${n.status}: ${(await n.text().catch(()=>"")).slice(0,200)}`);return d1(Buffer.from(await n.arrayBuffer()))}},tO={id:"elevenlabs",keyEnv:"ELEVENLABS_API_KEY",hasKey:()=>!!process.env.ELEVENLABS_API_KEY,async synth(t){let e=process.env.ELEVENLABS_VOICE_ID||"21m00Tcm4TlvDq8ikWAM",r=process.env.ELEVENLABS_MODEL||"eleven_turbo_v2_5",n=await fetch(`https://api.elevenlabs.io/v1/text-to-speech/${e}?output_format=pcm_24000`,{method:"POST",headers:{"content-type":"application/json","xi-api-key":process.env.ELEVENLABS_API_KEY},body:JSON.stringify({text:t,model_id:r})});if(!n.ok)throw new Error(`ElevenLabs TTS ${n.status}: ${(await n.text().catch(()=>"")).slice(0,200)}`);return d1(Buffer.from(await n.arrayBuffer()))}},rO={id:"google",keyEnv:"GOOGLE_TTS_API_KEY",hasKey:()=>!!process.env.GOOGLE_TTS_API_KEY,async synth(t){let e=process.env.GOOGLE_TTS_VOICE||"en-US-Neural2-D",r=e.split("-").slice(0,2).join("-")||"en-US",n=await fetch(`https://texttospeech.googleapis.com/v1/text:synthesize?key=${process.env.GOOGLE_TTS_API_KEY}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({input:{text:t},voice:{languageCode:r,name:e},audioConfig:{audioEncoding:"LINEAR16",sampleRateHertz:mo}})});if(!n.ok)throw new Error(`Google TTS ${n.status}: ${(await n.text().catch(()=>"")).slice(0,200)}`);let{audioContent:s}=await n.json();if(!s)throw new Error("Google TTS: empty audioContent");return WI(Buffer.from(s,"base64"))}},au={openai:eO,elevenlabs:tO,google:rO};function v3(){let t=(process.env.VOICE_MODEL||"openai").trim().toLowerCase(),e=au[t];if(!e)throw new Error(`Unknown VOICE_MODEL "${t}". Use one of: ${Object.keys(au).join(", ")}.`);return e}async function nO(t){let e=v3();if(!e.hasKey())throw new Error(`Voice is required but no TTS key is configured. Set ${e.keyEnv} for the "${e.id}" provider, or choose another with VOICE_MODEL (openai | elevenlabs | google) and set that provider's key.`);let r={voiceName:t.voiceName,voiceTone:t.voiceTone},n=[],s=[];for(let o of t.steps){if(!o.say){s.push(void 0);continue}let i=await e.synth(o.say,r);n.push(i),s.push(Math.round(i.length/mo*1e3)+180)}return{clips:n,sayDurationsMs:s}}function w3(t,e,r){if(!e.length)return"";let n=Math.ceil(r/1e3*mo)+mo,s=new Int16Array(n);return t.forEach((o,i)=>{let a=e[i];if(!a)return;let c=Math.max(0,Math.round(o.t/1e3*mo));s.set(a.subarray(0,Math.max(0,Math.min(a.length,n-c))),c)}),"data:audio/mpeg;base64,"+iO(s)}var sO=40,oO=Math.max(sO,Math.min(128,Number(process.env.FLOWCAST_TTS_BITRATE)||48));function iO(t){let e=new y3(1,mo,oO),r=[],n=1152;for(let c=0;c<t.length;c+=n){let d=e.encodeBuffer(t.subarray(c,c+n));d.length&&r.push(d)}let s=e.flush();s.length&&r.push(s);let o=r.reduce((c,d)=>c+d.length,0),i=Buffer.allocUnsafe(o),a=0;for(let c of r)i.set(c,a),a+=c.length;return i.toString("base64")}async function x3(t){let e=await nO(t);return{clips:e.clips,sayDurationsMs:e.sayDurationsMs,voice:"embedded"}}async function f1(t,e){let r=t.makeBeat??(u=>({say:u})),n=_w(e.steps,e.title,e.intro,e.outro,r,t.forceOutro??!1),s={...e,steps:n},o=t.prepare?await t.prepare(s):{},{clips:i,sayDurationsMs:a,voice:c}=await x3(s),d=t.compile(s,{...a?{sayDurationsMs:a}:{},...o}),l=i?w3(d.captions??[],i,d.manifest.durationMs):"";return{html:xw(d,l),data:d,voice:c}}function k3(t){return t.trim().split(/\s+/).filter(Boolean).length}function cu(t){return t.length>40?`${t.slice(0,40)}\u2026`:t}function S3(t,e){let r=[];for(let n=t.indexOf(e);n>=0;n=t.indexOf(e,n+Math.max(1,e.length)))r.push(n);return r}function aO(t,e){t.forEach((r,n)=>{r.say&&k3(r.say)>18&&e.push({severity:"warn",code:"SAY_TOO_LONG",step:n+1,field:"say",message:`Narration is ${k3(r.say)} words \u2014 beats read best at 4\u201314 (one breath).`,suggestion:'Split it into two beats joined by a connector like "so" or "then".'})})}function cO(t,e){let r=t.files??[],n={},s=new Set;for(let a of r)n[a.path]=a.content??"",s.add(a.path);let o=r[0]?.path??null;t.steps.forEach((a,c)=>{let d=c+1,l=a.file??o??void 0;l&&(s.has(l)||(s.add(l),n[l]=n[l]??""),o=l);let u=l&&n[l]||"",h=l!=null&&a.code!=null,p=l!=null&&(a.edits?.length??0)>0;if(a.code!=null&&a.edits?.length&&e.push({severity:"error",code:"CODE_AND_EDITS",step:d,message:`Step ${d}: use either \`code\` or \`edits\`, not both.`}),h&&u.length>0&&!a.rewrite&&e.push({severity:"error",code:"CODE_ON_EXISTING",step:d,field:"code",message:`Step ${d}: "${l}" already has code \u2014 use \`edits\` to change it, or set \`rewrite: true\` for a deliberate full rewrite.`}),p&&u.length===0&&e.push({severity:"error",code:"EDITS_NO_TARGET",step:d,field:"edits",message:`Step ${d}: \`edits\` target "${l}" which has no code yet \u2014 introduce it first with \`files\` or a \`code\` step.`}),h&&l)n[l]=a.code;else if(p&&l){let g=u;for(let x of a.edits){let S=S3(g,x.find);if(S.length===0){e.push({severity:"error",code:"ANCHOR_NOT_FOUND",step:d,field:"edits",message:`Step ${d}: edit \`find\` not found: ${JSON.stringify(cu(x.find))}. It must match the file's current contents exactly.`});continue}let k=S[0];x.occurrence==null&&S.length>1?e.push({severity:"error",code:"ANCHOR_AMBIGUOUS",step:d,field:"edits",message:`Step ${d}: edit \`find\` ${JSON.stringify(cu(x.find))} appears ${S.length} times \u2014 set \`occurrence\` (1-based).`}):x.occurrence!=null&&(x.occurrence<1||x.occurrence>S.length?e.push({severity:"error",code:"ANCHOR_AMBIGUOUS",step:d,field:"edits",message:`Step ${d}: edit \`occurrence\` ${x.occurrence} is out of range \u2014 \`find\` appears ${S.length} time(s).`}):k=S[x.occurrence-1]),g=g.slice(0,k)+x.replace+g.slice(k+x.find.length)}n[l]=g}if(l&&a.highlightCode!=null){let g=S3(n[l]??"",a.highlightCode);g.length===0?e.push({severity:"error",code:"HIGHLIGHT_NOT_FOUND",step:d,field:"highlightCode",message:`Step ${d}: \`highlightCode\` snippet not found: ${JSON.stringify(cu(a.highlightCode))}.`}):g.length>1&&e.push({severity:"error",code:"HIGHLIGHT_AMBIGUOUS",step:d,field:"highlightCode",message:`Step ${d}: \`highlightCode\` snippet ${JSON.stringify(cu(a.highlightCode))} appears ${g.length} times \u2014 extend it until unique.`,suggestion:"Add surrounding characters until the snippet is unique in the file."})}})}function lu(t,e){let r=[];return t==="code"&&cO(e,r),aO(e.steps,r),r.sort((n,s)=>n.step-s.step||(n.severity===s.severity?0:n.severity==="error"?-1:1))}function lO(t,e,r){return t.split(e).join(r)}function E3(t,e){let r=t.steps.map((i,a)=>({step:{...i},order:a+1,deleted:!1})),n=i=>{let a=r.find(c=>c.order===i&&!c.deleted);if(!a)throw new Error(`No beat ${i} to edit (it may already be deleted or out of range).`);return a},s=0;for(let i of e)switch(i.op){case"updateStep":{Object.assign(n(i.step).step,i.set);break}case"deleteStep":{n(i.step).deleted=!0;break}case"replaceText":{let a=i.field??"say",c=i.step!=null?[n(i.step)]:r.filter(l=>!l.deleted),d=0;for(let l of c){let u=l.step[a];typeof u=="string"&&u.includes(i.find)&&(l.step[a]=lO(u,i.find,i.replace),d++)}if(d===0)throw new Error(`replaceText: ${JSON.stringify(i.find)} not found in ${i.step!=null?`beat ${i.step}`:"any beat"}'s \`${a}\`.`);break}case"insertStep":{r.push({step:{...i.value},order:i.after+ ++s*1e-6,deleted:!1});break}}let o=r.filter(i=>!i.deleted).sort((i,a)=>i.order-a.order).map(i=>i.step);return{...t,steps:o}}import{homedir as uO}from"node:os";import{join as T3}from"node:path";import{readFileSync as dO,writeFileSync as fO,mkdirSync as hO,chmodSync as pO}from"node:fs";function $3(){return process.env.FLOWCAST_CONFIG_DIR||T3(uO(),".flowcast")}function La(){return T3($3(),"config.json")}function h1(){try{let t=JSON.parse(dO(La(),"utf8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function R3(t){hO($3(),{recursive:!0}),fO(La(),JSON.stringify(t,null,2)+`
208
- `);try{pO(La(),384)}catch{}}function P3(){for(let[t,e]of Object.entries(h1()))typeof e=="string"&&process.env[t]===void 0&&(process.env[t]=e)}import{createInterface as wO}from"node:readline/promises";import{stdin as A3,stdout as Vr}from"node:process";import{spawnSync as g1}from"node:child_process";import{existsSync as mi,readFileSync as mO,writeFileSync as gO,copyFileSync as _O,mkdirSync as bO}from"node:fs";import{homedir as z3}from"node:os";import{join as on,dirname as I3}from"node:path";var yO={command:"npx",args:["-y","@flowcast/mcp@latest"]};function p1(t){let e=process.platform==="win32"?g1("where",[t],{stdio:"ignore"}):g1("sh",["-c",`command -v ${t}`],{stdio:"ignore"});return!e.error&&e.status===0}function m1(t,e){let r=g1(t,e,{stdio:"inherit"});return!r.error&&r.status===0}function Za(t,e="mcpServers"){let r={};if(mi(t)){_O(t,`${t}.bak`);try{let o=JSON.parse(mO(t,"utf8"));o&&typeof o=="object"&&!Array.isArray(o)&&(r=o)}catch{}}else bO(I3(t),{recursive:!0});let n=r[e]&&typeof r[e]=="object"?r[e]:{},s="flowcast"in n;return r[e]={...n,flowcast:yO},gO(t,JSON.stringify(r,null,2)+`
209
- `),s?"updated":"added"}function M3(){let t=z3();return process.platform==="darwin"?on(t,"Library","Application Support","Claude","claude_desktop_config.json"):process.platform==="win32"?on(process.env.APPDATA||on(t,"AppData","Roaming"),"Claude","claude_desktop_config.json"):on(t,".config","Claude","claude_desktop_config.json")}function vO(){let t=z3(),e=r=>{throw new Error(r)};return[{name:"Claude Code",detect:()=>p1("claude"),apply:()=>m1("claude",["mcp","add","-s","user","flowcast","--","npx","-y","@flowcast/mcp@latest"])?"added via `claude mcp add`":e("`claude mcp add` failed (already added? run it manually)")},{name:"Claude Desktop",detect:()=>mi(I3(M3())),apply:()=>`${Za(M3())} in claude_desktop_config.json`},{name:"Cursor",detect:()=>mi(on(t,".cursor")),apply:()=>`${Za(on(t,".cursor","mcp.json"))} in ~/.cursor/mcp.json`},{name:"Codex",detect:()=>p1("codex"),apply:()=>m1("codex",["mcp","add","flowcast","--","npx","-y","@flowcast/mcp@latest"])?"added via `codex mcp add`":e("`codex mcp add` failed (already added? run it manually)")},{name:"Kiro",detect:()=>mi(on(t,".kiro")),apply:()=>`${Za(on(t,".kiro","settings","mcp.json"))} in ~/.kiro/settings/mcp.json`},{name:"Windsurf",detect:()=>mi(on(t,".codeium")),apply:()=>`${Za(on(t,".codeium","windsurf","mcp_config.json"))} in ~/.codeium/windsurf/mcp_config.json`},{name:"Gemini CLI",detect:()=>mi(on(t,".gemini")),apply:()=>`${Za(on(t,".gemini","settings.json"))} in ~/.gemini/settings.json`},{name:"VS Code",detect:()=>p1("code"),apply:()=>m1("code",["--add-mcp",JSON.stringify({name:"flowcast",command:"npx",args:["-y","@flowcast/mcp@latest"]})])?"added via `code --add-mcp`":e("`code --add-mcp` failed (update VS Code, or add it manually)")}]}async function O3(t,e){let r=vO().filter(n=>n.detect());if(!r.length){e.write(`
210
- No known MCP clients detected. Add FlowCast to your client manually:
211
- `),e.write(` { "mcpServers": { "flowcast": { "command": "npx", "args": ["-y", "@flowcast/mcp@latest"] } } }
212
- `);return}e.write(`
213
- Register the FlowCast server with your tools (its config carries no secrets):
214
- `);for(let n of r){let s=(await t.question(` \u2022 ${n.name} detected \u2014 add it? [Y/n]: `)).trim().toLowerCase();if(s==="n"||s==="no"){e.write(` skipped
215
- `);continue}try{e.write(` \u2713 ${n.apply()}
216
- `)}catch(o){e.write(` \u26A0\uFE0F ${o instanceof Error?o.message:String(o)}
217
- `)}}}var N3={openai:{keyEnv:"OPENAI_API_KEY"},elevenlabs:{keyEnv:"ELEVENLABS_API_KEY",extra:[{env:"ELEVENLABS_VOICE_ID",prompt:"ElevenLabs voice id (leave blank for the account default)"}]},google:{keyEnv:"GOOGLE_TTS_API_KEY",extra:[{env:"GOOGLE_TTS_VOICE",prompt:"Google voice",default:"en-US-Neural2-D"}]}};function xO(t,e){return Promise.race([t,new Promise((r,n)=>setTimeout(()=>n(new Error(`timed out after ${e/1e3}s`)),e).unref())])}async function C3(){if(!A3.isTTY){Vr.write(`flowcast setup needs an interactive terminal.
218
- Either run it directly in your shell, or skip the wizard and set your key via your MCP
219
- client's \`env\` block (VOICE_MODEL + the provider key), or write ~/.flowcast/config.json.
220
- `);return}let t=wO({input:A3,output:Vr});try{Vr.write(`
221
- \u{1F399} FlowCast setup \u2014 configure spoken narration (voice is required).
222
-
223
- `);let e=Object.keys(N3);Vr.write(`Voice providers:
224
- `),e.forEach((d,l)=>Vr.write(` ${l+1}) ${d}
225
- `));let r=(await t.question(`
226
- Choose a provider [1-${e.length}] (1): `)).trim()||"1",n=e[Number(r)-1]??"openai",s=N3[n],o={...h1(),VOICE_MODEL:n},i=(await t.question(`
227
- Paste your ${s.keyEnv}: `)).trim();if(!i){Vr.write(`
228
- No key entered \u2014 nothing saved.
229
- `);return}o[s.keyEnv]=i;for(let d of s.extra??[]){let l=d.default?`${d.prompt} (${d.default})`:d.prompt,h=(await t.question(`${l}: `)).trim()||d.default;h&&(o[d.env]=h)}Vr.write(`
230
- Validating\u2026`);let a=!1,c="";try{for(let[l,u]of Object.entries(o))process.env[l]=u;a=(await xO(au[n].synth("Testing FlowCast voice.",{}),2e4)).length>0}catch(d){c=d instanceof Error?d.message:String(d)}if(a)Vr.write(` ok \u2713
231
- `);else{Vr.write(c?`
232
- \u26A0\uFE0F Could not validate the key: ${c}
233
- `:`
234
- \u26A0\uFE0F Got empty audio back.
235
- `);let d=(await t.question("Save anyway? [y/N]: ")).trim().toLowerCase();if(d!=="y"&&d!=="yes"){Vr.write(`Aborted \u2014 nothing saved.
236
- `);return}}R3(o),Vr.write(`
237
- \u2713 Saved to ${La()} (private, owner-only).
238
- `),await O3(t,Vr),Vr.write(`
239
- Done! Restart any client that was already running so it picks up FlowCast.
240
-
241
- `)}finally{t.close()}}process.argv[2]==="setup"&&(await C3(),process.exit(0));P3();function RO(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"walkthrough"}var PO=`Export a previously generated walkthrough HTML file to a caller-specified path.
242
-
243
- Use this when create_walkthrough returned a ui:// resource that the client cannot render/read, or when the generated HTML was too large to inline. If uri is omitted, this exports the most recently generated walkthrough. outputPath is required and should normally be an absolute path in the user's workspace. /mnt/user-data/outputs/<file> is accepted and mapped to a writable local path by the server.`,ys=new Rl({name:"flowcast",version:"0.1.0"}),bs=new Map,MO=50,zO=0,b1=null;function B3(t){let e=t?t.replace(/^ui:\/\/flowcast\//,""):b1;if(!e)return null;let r=bs.get(e);return r?{id:e,entry:r}:null}function y1(t){let e=t.severity==="error"?"\u2717":"\u26A0",r=t.field?` (${t.field})`:"";return` ${e} beat ${t.step}${r} [${t.code}] ${t.message}${t.suggestion?` \u2192 ${t.suggestion}`:""}`}var du="/mnt/user-data/outputs",IO=Jt.dirname(TO(import.meta.url)),OO=Jt.resolve(IO,"../../..");function AO(t){try{return L3(t,{recursive:!0}),kO(t,SO.W_OK),!0}catch{return!1}}function NO(){return[process.env.FLOWCAST_OUTPUT_DIR,process.cwd()!==Jt.parse(process.cwd()).root?process.cwd():void 0,OO,Jt.join(j3(),"flowcast")].filter(e=>!!e).find(AO)??j3()}function D3(t,e){let r=Jt.relative(Jt.resolve(t),e);return r===""||!r.startsWith("..")&&!Jt.isAbsolute(r)}function CO(t){if(t===du||t.startsWith(`${du}/`)){let r=Jt.relative(du,t),n=NO(),s=Jt.resolve(n,r===""?"walkthrough.html":r);if(!D3(n,s))throw new Error(`outputPath escapes the output directory: ${t}`);return s}if(Jt.isAbsolute(t))return Jt.resolve(t);let e=Jt.resolve(process.cwd(),t);if(!D3(process.cwd(),e))throw new Error(`relative outputPath escapes the working directory: ${t} \u2014 pass an absolute path to write elsewhere`);return e}function q3(t,e){let r=CO(t);return L3(Jt.dirname(r),{recursive:!0}),EO(r,e,"utf8"),r}var _1=null;function jO(t,e){let r=new URL(t.url??"/","http://127.0.0.1").pathname,n=decodeURIComponent(r.replace(/^\/+/,"").replace(/\.html$/i,"")),s=n?bs.get(n):void 0;if(!s){e.writeHead(404,{"content-type":"text/plain; charset=utf-8"}),e.end("Walkthrough not found \u2014 it may have expired from memory. Regenerate it.");return}let o=Buffer.from(s.html,"utf8");e.writeHead(200,{"content-type":"text/html; charset=utf-8","content-length":o.length,"cache-control":"no-store"}),e.end(o)}function DO(t,e){return new Promise(r=>{let n=$O(jO);n.once("error",()=>r(!1)),n.listen(e,t,()=>{_1=n,_1.unref(),r(!0)})})}var uu=null;function LO(){return uu||(uu=(async()=>{if(process.env.FLOWCAST_NO_HTTP==="1")return null;let t="127.0.0.1",e=Number(process.env.FLOWCAST_PORT)||7616;for(let r=e;r<e+8;r++)if(await DO(t,r))return`http://${t}:${r}`;return null})(),uu)}ys.registerResource("walkthrough",new Pl("ui://flowcast/{id}",{list:void 0}),{title:"FlowCast walkthrough",description:"A rendered interactive code walkthrough (self-contained HTML).",mimeType:"text/html"},async(t,e)=>{let r=String(e.id),n=bs.get(r);if(!n)throw new Error(`Unknown walkthrough id: ${r}`);return{contents:[{uri:t.href,mimeType:"text/html",text:n.html}]}});ys.registerTool("export_walkthrough",{title:"Export generated walkthrough HTML",description:PO,inputSchema:{outputPath:G.string().describe("Required destination for the .html file. Prefer an absolute path in the user-visible workspace. /mnt/user-data/outputs/<file> is accepted and mapped to a writable local server path."),uri:G.string().optional().describe("Optional ui://flowcast/<id> resource returned by create_walkthrough. If omitted, exports the latest generated walkthrough.")}},async t=>{let e=String(t.outputPath),r=typeof t.uri=="string"?t.uri:void 0,n=r?r.replace(/^ui:\/\/flowcast\//,""):b1;if(!n)return{isError:!0,content:[{type:"text",text:"No walkthrough has been generated yet. Call create_walkthrough first."}]};let s=bs.get(n);if(!s)return{isError:!0,content:[{type:"text",text:`Unknown walkthrough id: ${n}`}]};try{let o=q3(e,s.html),i=o!==e&&e.startsWith(du)?` Requested sandbox path ${e} was mapped to this local MCP server path.`:"";return{content:[{type:"text",text:`Exported walkthrough to ${o} (${(s.bytes/1024).toFixed(0)} KB).${i} Open this local HTML file to view the artifact.`},{type:"resource_link",uri:Z3(o).href,name:`${s.slug}.html`,title:s.title,mimeType:"text/html",size:s.bytes,description:`Local HTML artifact for FlowCast walkthrough: ${s.title}`}]}}catch(o){return{isError:!0,content:[{type:"text",text:`Failed to export walkthrough: ${o instanceof Error?o.message:String(o)}`}]}}});async function V3(t){let{title:e,outputPath:r,html:n,data:s,kind:o,typeId:i,spec:a,diagnostics:c=[]}=t,d=RO(e),l=Buffer.byteLength(n),u=(l/1024).toFixed(0),h=`${d}-${(++zO).toString(36)}`;for(bs.set(h,{html:n,title:e,slug:d,bytes:l,typeId:i,spec:a,diagnostics:c}),b1=h;bs.size>MO;)bs.delete(bs.keys().next().value);let p=`ui://flowcast/${h}`,g=null;if(r)try{g=q3(r,n)}catch{}let x=await LO(),S=x?`${x}/${h}.html`:null,k=!S&&l<=9e5,_=`${o} ready \u2014 ${u} KB, ${s.events.length} events, ${Math.round(s.manifest.durationMs/1e3)}s. Narration audio embedded.`;S?_+=`
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 H=s([2,1152]),ee=K,de=-1,_e;de!=0;)if(de=k.hip_decode1_unclipped(T.hip,v,w,ee,H[0],H[1]),ee=0,de==-1&&(de=0),de>0){if(T.findPeakSample){for(_e=0;_e<de;_e++)H[0][_e]>T.PeakSample?T.PeakSample=H[0][_e]:-H[0][_e]>T.PeakSample&&(T.PeakSample=-H[0][_e]);if(T.channels_out>1)for(_e=0;_e<de;_e++)H[1][_e]>T.PeakSample?T.PeakSample=H[1][_e]:-H[1][_e]>T.PeakSample&&(T.PeakSample=-H[1][_e])}if(T.findReplayGain&&y.AnalyzeSamples(T.rgdata,H[0],0,H[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 z1,N3;function q1(){if(N3)return z1;N3=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 _=tc,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 $,O,L,q,C,Z=new c,he,z,b;this.enc=new k,this.setModules=function(S,I,Se,Me,We,Ue,Ce,Ae,tt){$=S,O=I,L=Se,q=Me,C=We,he=Ue,z=Ae,b=tt,this.enc.setModules(O,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,I){this.lowpass=I}var F=4294479419;function Q(S){var I;return S.class_id=F,I=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,I.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,I.VBR_min_bitrate=1,I.VBR_max_bitrate=13,S.quant_comp=-1,S.quant_comp_short=-1,S.msfix=-1,I.resample_ratio=1,I.OldValue[0]=180,I.OldValue[1]=180,I.CurrentStep[0]=4,I.CurrentStep[1]=4,I.masking_lower=1,I.nsPsy.attackthre=-1,I.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,I.mf_samples_to_encode=k.ENCDELAY+k.POSTDELAY,S.encoder_padding=0,I.mf_size=k.ENCDELAY-k.MDCTDELAY,S.findReplayGain=!1,S.decode_on_the_fly=!1,I.decode_on_the_fly=!1,I.findReplayGain=!1,I.findPeakSample=!1,I.RadioGain=0,I.AudiophileGain=0,I.noclipGainChange=0,I.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 I=[8,16,24,32,40,48,56,64,80,96,112,128,160,192,224,256,320],Se=0,Me=0,We=0,Ue=0;Ue=I[16],We=16,Me=I[16],Se=16;for(var Ce=0;Ce<16;Ce++)if(Math.max(S,I[Ce+1])!=S){Ue=I[Ce+1],We=Ce+1,Me=I[Ce],Se=Ce;break}return Ue-S>S-Me?Se:We};function T(S,I){var Se=44100;return I>=48e3?Se=48e3:I>=44100?Se=44100:I>=32e3?Se=32e3:I>=24e3?Se=24e3:I>=22050?Se=22050:I>=16e3?Se=16e3:I>=12e3?Se=12e3:I>=11025?Se=11025:I>=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),I<Se?I>44100?48e3:I>32e3?44100:I>24e3?32e3:I>22050?24e3:I>16e3?22050:I>12e3?16e3:I>11025?12e3:I>8e3?11025:8e3:Se)}function v(S,I){switch(S){case 44100:return I.version=1,0;case 48e3:return I.version=1,1;case 32e3:return I.version=1,2;case 22050:return I.version=0,0;case 24e3:return I.version=0,1;case 16e3:return I.version=0,2;case 11025:return I.version=0,0;case 12e3:return I.version=0,1;case 8e3:return I.version=0,2;default:return I.version=0,-1}}function w(S,I,Se){Se<16e3&&(I=2);for(var Me=y.bitrate_table[I][1],We=2;We<=14;We++)y.bitrate_table[I][We]>0&&Math.abs(y.bitrate_table[I][We]-S)<Math.abs(Me-S)&&(Me=y.bitrate_table[I][We]);return Me}function R(S,I,Se){Se<16e3&&(I=2);for(var Me=0;Me<=14;Me++)if(y.bitrate_table[I][Me]>0&&y.bitrate_table[I][Me]==S)return Me;return-1}function N(S,I){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)],Me=g.nearestBitrateFullIndex(I);S.lowerlimit=Se[Me].lowpass}function K(S){var I=S.internal_flags,Se=32,Me=-1;if(I.lowpass1>0){for(var We=999,Ue=0;Ue<=31;Ue++){var Ce=Ue/31;Ce>=I.lowpass2&&(Se=Math.min(Se,Ue)),I.lowpass1<Ce&&Ce<I.lowpass2&&(We=Math.min(We,Ue))}We==999?I.lowpass1=(Se-.75)/31:I.lowpass1=(We-.75)/31,I.lowpass2=Se/31}if(I.highpass2>0&&I.highpass2<.9*(.75/31)&&(I.highpass1=0,I.highpass2=0,e.err.println(`Warning: highpass filter disabled. highpass frequency too small
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
+ ${Mz}`}var Az={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:Oz(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()))}},zz={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()))}},Nz={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:Io}})});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 Iz(Buffer.from(s,"base64"))}},Ru={openai:Az,elevenlabs:zz,google:Nz};function p4(){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 Cz(t){let e=p4();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/Io*1e3)+180)}return{clips:n,sayDurationsMs:s}}function m4(t,e,r){if(!e.length)return"";let n=Math.ceil(r/1e3*Io)+Io,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*Io));s.set(a.subarray(0,Math.max(0,Math.min(a.length,n-c))),c)}),"data:audio/mpeg;base64,"+Lz(s)}var jz=40,Dz=Math.max(jz,Math.min(128,Number(process.env.FLOWCAST_TTS_BITRATE)||48));function Lz(t){let e=new f4(1,Io,Dz),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 g4(t){let e=await Cz(t);return{clips:e.clips,sayDurationsMs:e.sayDurationsMs,voice:"embedded"}}async function H1(t,e){let r=t.makeBeat??(u=>({say:u})),n=d3(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 g4(s),d=t.compile(s,{...a?{sayDurationsMs:a}:{},...o}),l=i?m4(d.captions??[],i,d.manifest.durationMs):"";return{html:g3(d,l),data:d,voice:c}}function _4(t){return t.trim().split(/\s+/).filter(Boolean).length}function Iu(t){return t.length>40?`${t.slice(0,40)}\u2026`:t}function b4(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 Zz(t,e){t.forEach((r,n)=>{r.say&&_4(r.say)>18&&e.push({severity:"warn",code:"SAY_TOO_LONG",step:n+1,field:"say",message:`Narration is ${_4(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 Bz(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=b4(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(Iu(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(Iu(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=b4(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(Iu(a.highlightCode))}.`}):m.length>1&&e.push({severity:"error",code:"HIGHLIGHT_AMBIGUOUS",step:d,field:"highlightCode",message:`Step ${d}: \`highlightCode\` snippet ${JSON.stringify(Iu(a.highlightCode))} appears ${m.length} times \u2014 extend it until unique.`,suggestion:"Add surrounding characters until the snippet is unique in the file."})}})}function Pu(t,e){let r=[];return t==="code"&&Bz(e,r),Zz(e.steps,r),r.sort((n,s)=>n.step-s.step||(n.severity===s.severity?0:n.severity==="error"?-1:1))}function Vz(t,e,r){return t.split(e).join(r)}function y4(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]=Vz(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 qz}from"node:os";import{join as v4}from"node:path";import{readFileSync as Fz,writeFileSync as Hz,mkdirSync as Uz,chmodSync as Gz}from"node:fs";function w4(){return process.env.FLOWCAST_CONFIG_DIR||v4(qz(),".flowcast")}function rc(){return v4(w4(),"config.json")}function U1(){try{let t=JSON.parse(Fz(rc(),"utf8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function x4(t){Uz(w4(),{recursive:!0}),Hz(rc(),JSON.stringify(t,null,2)+`
208
+ `);try{Gz(rc(),384)}catch{}}function S4(){for(let[t,e]of Object.entries(U1()))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 Z4}from"node:process";import*as Is from"node:readline";import uN from"node:readline";var k4=(()=>{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}})(),$4=t=>t===12288||t>=65281&&t<=65376||t>=65504&&t<=65510,E4=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 Wz=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Yz=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,T4=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,Xz=/\t{1,1000}/y,R4=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"),Kz=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Jz=new RegExp("\\p{M}+","gu"),Qz={limit:1/0,ellipsis:""},I4=(t,e={},r={})=>{let n=e.limit??1/0,s=e.ellipsis??"",o=e?.ellipsisWidth??(s?I4(s,Qz,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=[[Kz,u],[Wz,i],[Yz,a],[Xz,c],[R4,d],[T4,f]],m=0,y=0,k=t.length,x=0,_=!1,g=k,E=Math.max(0,n-o),h=0,$=0,O=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(Jz,"")){let Z=C.codePointAt(0)||0;if($4(Z)?L=l:E4(Z)?L=f:L=u,O+L>E&&(g=Math.min(g,Math.max(h,m)+x)),O+L>n){_=!0;break e}x+=C.length,O+=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===T4?k4(t.slice(y,Z.lastIndex)):Z===R4?1:Z.lastIndex-y,L=x*he,O+L>E&&(g=Math.min(g,y+Math.floor((E-O)/he))),O+L>n){_=!0;break e}O+=L,h=m,$=y,y=m=Z.lastIndex;continue e}}y+=1}return{width:_?E:O,index:_?g:k,truncated:_,ellipsed:_&&n>=o}},P4=I4;var eN={limit:1/0,ellipsis:"",ellipsisWidth:0},tN=(t,e={})=>P4(t,eN,e).width,$r=tN;var Mu="\x1B",N4="\x9B",rN=39,W1="\x07",C4="[",nN="]",j4="m",Y1=`${nN}8;;`,M4=new RegExp(`(?:\\${C4}(?<code>\\d+)m|\\${Y1}(?<uri>.*)${W1})`,"y"),O4=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},A4=t=>`${Mu}${C4}${t}${j4}`,z4=t=>`${Mu}${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===Mu||u===N4)&&(s=!0,o=e.startsWith(Y1,l+1)),s?o?u===W1&&(s=!1,o=!1):u===j4&&(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(`
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===Mu||f===N4){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]===`
210
+ `){o&&(n+=z4(""));let p=s?O4(s):void 0;s&&p&&(n+=A4(p))}else f===`
211
+ `&&(s&&O4(s)&&(n+=A4(s)),o&&(n+=z4(o)))}return n},iN=/\r?\n/;function qn(t,e,r){return String(t).normalize().split(iN).map(n=>oN(n,e,r)).join(`
212
+ `)}var yr=Ci(J1(),1);import{ReadStream as L4}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
+ `),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 Ou(t,e){let r=t;r.isTTY&&r.setRawMode(e)}function B4({input:t=Z4,output:e=t0,overwrite:r=!0,hideCursor:n=!0}={}){let s=Is.createInterface({input:t,output:e,prompt:"",tabSize:1});Is.emitKeypressEvents(t,s),t instanceof L4&&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;Is.moveCursor(e,a==="return"?0:-1,a==="return"?-1:0,()=>{Is.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 L4&&t.isTTY&&!pN&&t.setRawMode(!1),s.terminal=!1,s.close()}}var nc=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=nc(t??t0);return qn(e,i-r.length,{hard:!0,trim:!1}).split(`
215
+ `).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 V4(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=Z4,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),Ou(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),Ou(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(yr.cursor.show),this.output.off("resize",this.render),Ou(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=V4(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(`
217
+ `),Ou(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
+ `).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
+ `);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
+ `).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 q4=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}})}},zu=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 _H}from"node:util";import fn from"node:process";var oc=Ci(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","*"),W4=Et("\u25A0","x"),Y4=Et("\u25B2","x"),Lu=Et("\u25C7","o"),bN=Et("\u250C","T"),nt=Et("\u2502","|"),ns=Et("\u2514","\u2014"),wH=Et("\u2510","T"),xH=Et("\u2518","\u2014"),o0=Et("\u25CF",">"),Du=Et("\u25CB"," "),yN=Et("\u25FB","[\u2022]"),F4=Et("\u25FC","[+]"),H4=Et("\u25FB","[ ]"),vN=Et("\u25AA","\u2022"),U4=Et("\u2500","-"),wN=Et("\u256E","+"),xN=Et("\u251C","+"),SN=Et("\u256F","+"),kN=Et("\u2570","+"),SH=Et("\u256D","+"),$N=Et("\u25CF","\u2022"),EN=Et("\u25C6","*"),TN=Et("\u25B2","!"),RN=Et("\u25A0","x"),ic=t=>{switch(t){case"initial":case"active":return ue("cyan",_N);case"cancel":return ue("red",W4);case"error":return ue("yellow",Y4);case"submit":return ue("green",Lu)}},X4=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 K4(t,e){let r=[`${e?`${ue("cyan",nt)} `:""}${t.join(" \u2022 ")}`];return e&&r.push(ue("cyan",ns)),r}var G4=(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=nc(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(`
222
+ `);k.push($),x+=$.length}if(x>l){let h=0,$=0,O=x,L=t-_,q=l,C=()=>G4(k,O,0,L,q),Z=()=>G4(k,O,L+1,k.length,q,!0);p?({lineCount:O,removals:h}=C(),O>q&&(m||(q-=1),{lineCount:O,removals:$}=Z())):(m||(q-=1),{lineCount:O,removals:$}=Z(),O>q&&(q-=1,{lineCount:O,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 J4=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=`${ic(this.state)} `,o=n?`${ue("gray",nt)} `:"",i=Ms(t.output,t.message,o,s),a=`${n?`${ue("gray",nt)}
223
+ `:""}${i}
224
+ `,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
+ ${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
+ ${ue("cyan",nt)} `:`
227
+ `:` ${ue("dim","/")} `}${this.value?`${ue("dim",Du)} ${ue("dim",r)}`:`${ue("green",o0)} ${r}`}
228
+ ${l}
229
+ `}}}}).prompt()};var IN=[`${ue("dim","\u2191/\u2193")} to navigate`,`${ue("dim","Space:")} select`,`${ue("dim","Enter:")} confirm`],sc=(t,e)=>t.split(`
230
+ `).map(r=>e(r)).join(`
231
+ `),Q4=t=>{let e=(n,s)=>{let o=n.label??String(n.value);return s==="disabled"?`${ue("gray",H4)} ${sc(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",F4)} ${sc(o,i=>ue("dim",i))}${n.hint?` ${ue("dim",`(${n.hint})`)}`:""}`:s==="cancelled"?`${sc(o,i=>ue(["strikethrough","dim"],i))}`:s==="active-selected"?`${ue("green",F4)} ${o}${n.hint?` ${ue("dim",`(${n.hint})`)}`:""}`:s==="submitted"?`${sc(o,i=>ue("dim",i))}`:`${ue("dim",H4)} ${sc(o,i=>ue("dim",i))}`},r=t.required??!0;return new q4({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.
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?`${X4(this.state)} `:"",`${ic(this.state)} `),o=`${n?`${ue("gray",nt)}
233
+ `:""}${s}
234
+ `,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
+ ${ue("gray",nt)}`:""}`}case"error":{let c=n?`${ue("yellow",nt)} `:"",d=this.error.split(`
236
+ `).map((f,p)=>p===0?`${n?`${ue("yellow",ns)} `:""}${ue("yellow",f)}`:` ${f}`).join(`
237
+ `),l=o.split(`
238
+ `).length,u=d.split(`
239
+ `).length+1;return`${o}${c}${i0({output:t.output,options:this.options,cursor:this.cursor,maxItems:t.maxItems,columnPadding:c.length,rowPadding:l+u,style:a}).join(`
240
+ ${c}`)}
241
+ ${d}
242
+ `}default:{let c=n?`${ue("cyan",nt)} `:"",d=o.split(`
243
+ `).length,l=K4(IN,n),u=l.join(`
244
+ `),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
+ ${c}`)}
246
+ ${u}
247
+ `}}}}).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
+ `);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
+ `)}
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)})}},ex=(t="",e)=>{let r=e?.output??process.stdout,n=e?.withGuide??rr.withGuide?`${ue("gray",ns)} `:"";r.write(`${n}${ue("red",t)}
251
+
252
+ `)},tx=(t="",e)=>{let r=e?.output??process.stdout,n=e?.withGuide??rr.withGuide?`${ue("gray",bN)} `:"";r.write(`${n}${t}
253
+ `)},rx=(t="",e)=>{let r=e?.output??process.stdout,n=e?.withGuide??rr.withGuide?`${ue("gray",nt)}
254
+ ${ue("gray",ns)} `:"";r.write(`${n}${t}
255
+
256
+ `)};var PN=t=>t,MN=(t,e,r)=>{let n={hard:!0,trim:!1},s=qn(t,e,n).split(`
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??PN,i=["",...MN(t,nc(n)-6,o).split(`
258
+ `).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
+ `),l=s?`${ue("gray",nt)}
260
+ `:"",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
+ ${d}
262
+ ${ue("gray",u+U4.repeat(c+2)+SN)}
263
+ `)},nx=t=>new zu({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)}
264
+ `:""}${ic(this.state)} ${t.message}
265
+ `,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
+ ${o}${a}
267
+ ${i}${ue("yellow",this.error)}
268
+ `}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
+ ${ue("gray",nt)}`:""}`}default:{let o=e?`${ue("cyan",nt)} `:"",i=e?ue("cyan",ns):"";return`${r}${o}${n}
270
+ ${i}
271
+ `}}}}).prompt();var ON=t=>ue("magenta",t),sx=({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=nc(r),_=c?.styleFrame??ON,g=b=>{let j=b>1?s??rr.messages.error:n??rr.messages.cancel;p=b===1,f&&(z(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)},O=()=>{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
+ `);let b=qn(y,x,{hard:!0,trim:!1}).split(`
273
+ `);b.length>1&&r.write(oc.cursor.up(b.length-1)),r.write(oc.cursor.to(0)),r.write(oc.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=B4({output:r}),m=q(b),k=performance.now(),Z&&r.write(`${ue("gray",nt)}
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)},z=(b="",j=0,A=!1)=>{if(!f)return;f=!1,clearInterval(u),L();let G=j===0?ue("green",Lu):j===1?ue("red",W4):ue("red",Y4);m=b??m,A||(t==="timer"?r.write(`${G} ${m} ${C(k)}
275
+ `):r.write(`${G} ${m}
276
+ `)),O(),l()};return{start:he,stop:(b="")=>z(b,0),message:(b="")=>{m=q(b??m)},cancel:(b="")=>z(b,1),error:(b="")=>z(b,2),clear:()=>z("",0,!0),get isCancelled(){return p}}},kH={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
+ `)?t.split(`
278
+ `).map(r=>e(r)).join(`
279
+ `):e(t),ox=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=`${ic(this.state)} `,s=`${X4(this.state)} `,o=Ms(t.output,t.message,s,n),i=`${r?`${ue("gray",nt)}
280
+ `:""}${o}
281
+ `;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
+ ${ue("gray",nt)}`:""}`}default:{let a=r?`${ue("cyan",nt)} `:"",c=i.split(`
283
+ `).length,d=K4(AN,r),l=d.join(`
284
+ `),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
+ ${a}`)}
286
+ ${l}
287
+ `}}}}).prompt()};var $H=`${ue("gray",nt)} `;var ix=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)}
288
+ `:""}${ic(this.state)} `}${t.message}
289
+ `,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
+ ${a}${s}
291
+ ${c}${i}
292
+ `}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
+ ${a}`:""}`}default:{let i=e?`${ue("cyan",nt)} `:"",a=e?ue("cyan",ns):"";return`${r}${i}${s}
294
+ ${a}
295
+ `}}}}).prompt();var Xr=Ci(lx(),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 dx}from"node:os";import{join as pn,dirname as hx}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 ac(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(hx(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)+`
296
+ `),s?"updated":"added"}function ux(){let t=dx();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=dx(),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(hx(ux())),apply:()=>`${ac(ux())} in claude_desktop_config.json`},{name:"Cursor",detect:()=>Mi(pn(t,".cursor")),apply:()=>`${ac(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:()=>`${ac(pn(t,".kiro","settings","mcp.json"))} in ~/.kiro/settings/mcp.json`},{name:"Windsurf",detect:()=>Mi(pn(t,".codeium")),apply:()=>`${ac(pn(t,".codeium","windsurf","mcp_config.json"))} in ~/.codeium/windsurf/mcp_config.json`},{name:"Gemini CLI",detect:()=>Mi(pn(t,".gemini")),apply:()=>`${ac(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 fx(){return qN().filter(t=>t.detect())}var d0=t=>`\x1B[38;2;255;91;52m${t}\x1B[39m`,px=[{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"}]}],HN="Use FlowCast to make a whiteboard walkthrough of how the water cycle works.";function UN(t,e){return Promise.race([t,new Promise((r,n)=>setTimeout(()=>n(new Error(`timed out after ${e/1e3}s`)),e).unref())])}async function mx(){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=()=>ex("Setup cancelled \u2014 nothing saved.");tx(`${d0("\u25C6 FlowCast")} ${Xr.default.dim("\xB7 setup")}`);let e=await ox({message:"Pick a voice provider for narration",options:px.map(l=>({value:l.id,label:l.label,hint:l.hint})),initialValue:"openai"});if(Ps(e))return t();let r=px.find(l=>l.id===e);Zu(Xr.default.cyan(Xr.default.underline(r.keyUrl)),`Get your ${r.label} key here`);let n=await nx({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={...U1(),VOICE_MODEL:r.id,[r.keyEnv]:n.trim()};for(let l of r.extra??[]){let u=await ix({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=sx();o.start("Testing your key with a quick voice sample");let i=!1,a="";try{i=(await UN(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 J4({message:a?`${a}
297
+ Save anyway?`:"No audio came back. Save anyway?",initialValue:!1});if(Ps(l)||!l)return t()}x4(s),Fn.success(`Saved your key to ${Xr.default.dim(rc())}`);let c=fx(),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 Q4({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
+
299
+ ${d0(`"${HN}"`)}`,"Make your first cast"),rx(`${d0("FlowCast is ready.")} ${Xr.default.dim("Restart any open client so it picks up the new server.")}`)}process.argv[2]==="setup"&&(await mx(),process.exit(0));S4();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
+
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.`,As=new Yl({name:"flowcast",version:"0.1.0"}),Os=new Map,eC=50,tC=0,f0=null;function vx(t){let e=t?t.replace(/^ui:\/\/flowcast\//,""):f0;if(!e)return null;let r=Os.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 bx(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(gx(),"flowcast")].filter(e=>!!e).find(sC)??gx()}function _x(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(!_x(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(!_x(process.cwd(),e))throw new Error(`relative outputPath escapes the working directory: ${t} \u2014 pass an absolute path to write elsewhere`);return e}function wx(t,e){let r=iC(t);return bx(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?Os.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)}As.registerResource("walkthrough",new Xl("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=Os.get(r);if(!n)throw new Error(`Unknown walkthrough id: ${r}`);return{contents:[{uri:t.href,mimeType:"text/html",text:n.html}]}});As.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=Os.get(n);if(!s)return{isError:!0,content:[{type:"text",text:`Unknown walkthrough id: ${n}`}]};try{let o=wx(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:yx(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 xx(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(Os.set(f,{html:n,title:e,slug:d,bytes:l,typeId:i,spec:a,diagnostics:c}),f0=f;Os.size>eC;)Os.delete(Os.keys().next().value);let p=`ui://flowcast/${f}`,m=null;if(r)try{m=wx(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?_+=`
244
302
 
245
303
  Give the user this link to open the interactive player in their browser (voice included):
246
- ${S}`:k?_+=`
304
+ ${k}`:x?_+=`
247
305
 
248
306
  No local server running. Save the self-contained HTML resource below to your outputs directory (e.g. /mnt/user-data/outputs/${d}.html) and present it as the artifact.`:_+=`
249
307
 
250
- No local server and the page is large: read ${p} via resources/read to get the self-contained HTML, save it to your outputs directory, and present it.`;let m=c.filter($=>$.severity==="warn");return m.length&&(_+=`
308
+ No local server and the page is large: read ${p} via resources/read to get the self-contained HTML, save it to your outputs directory, and present it.`;let g=c.filter(E=>E.severity==="warn");return g.length&&(_+=`
251
309
 
252
- ${m.length} quality note(s) \u2014 fix targeted beats with revise_walkthrough (uri: ${p}):
253
- ${m.map(y1).join(`
254
- `)}`),{content:[{type:"text",text:_},...S?[{type:"resource_link",uri:S,name:`${d}.html`,title:e,mimeType:"text/html",description:`Open in browser \u2014 interactive player on the user's machine: ${e}`}]:[],...k?[{type:"resource",resource:{uri:p,mimeType:"text/html",text:n}}]:[],...g?[{type:"resource_link",uri:Z3(g).href,name:`${d}.html`,title:e,mimeType:"text/html",size:l,description:`Saved HTML file: ${e}`}]:[],{type:"resource_link",uri:p,name:`${d}.html`,title:e,mimeType:"text/html",size:l,description:`FlowCast walkthrough (self-contained HTML via resources/read): ${e}`}]}}for(let t of Kl){let e=async n=>{let s=n;try{let{html:o,data:i,voice:a}=await f1(t,s),c=lu(t.id,s);return await V3({title:s.title,outputPath:s.outputPath,html:o,data:i,voice:a,kind:t.tool.title,typeId:t.id,spec:s,diagnostics:c})}catch(o){return{isError:!0,content:[{type:"text",text:`Failed to create ${t.id} cast: ${o instanceof Error?o.message:String(o)}`}]}}},r={title:t.tool.title,description:t.tool.description,inputSchema:t.schema};ys.registerTool(t.tool.name,r,e);for(let n of t.tool.aliases??[])ys.registerTool(n,r,e)}ys.registerTool("check_walkthrough",{title:"Check walkthrough quality",description:"Validate a previously generated walkthrough and return quality diagnostics \u2014 missing or ambiguous `highlightCode`/edit anchors, illegal code+edits combos, edits targeting an empty file, and over-long narration. Read-only: it produces no new file. Run it after create_* to see every issue at once, then fix the flagged beats with revise_walkthrough (cheaper than re-authoring the whole timeline).",inputSchema:{uri:G.string().optional().describe("ui://flowcast/<id> to check. Omit to check the most recently generated walkthrough."),severity:G.enum(["error","warn","all"]).optional().describe("Filter findings by severity (default 'all').")}},async t=>{let e=B3(typeof t.uri=="string"?t.uri:void 0);if(!e)return{isError:!0,content:[{type:"text",text:"No walkthrough found. Generate one with create_walkthrough first, or pass a valid ui://flowcast/<id>."}]};let{id:r,entry:n}=e,s=t.severity??"all",o=lu(n.typeId,n.spec).filter(d=>s==="all"||d.severity===s),i=o.filter(d=>d.severity==="error").length,a=o.filter(d=>d.severity==="warn").length,c=o.length?`${o.length} finding(s) in "${n.title}" \u2014 ${i} error(s), ${a} warning(s):
255
- ${o.map(y1).join(`
310
+ ${g.length} quality note(s) \u2014 fix targeted beats with revise_walkthrough (uri: ${p}):
311
+ ${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:yx(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 H1(t,s),c=Pu(t.id,s);return await xx({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};As.registerTool(t.tool.name,r,e);for(let n of t.tool.aliases??[])As.registerTool(n,r,e)}As.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=vx(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=Pu(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
+ ${o.map(p0).join(`
256
314
  `)}
257
315
 
258
- Fix the flagged beats with revise_walkthrough (uri: ui://flowcast/${r}).`:`\u2713 No issues found in "${n.title}".`;return{structuredContent:{uri:`ui://flowcast/${r}`,diagnostics:o},content:[{type:"text",text:c}]}});ys.registerTool("revise_walkthrough",{title:"Revise walkthrough",description:"Apply a handful of targeted edits to an existing walkthrough and re-render it, without re-sending the whole timeline. Ideal for fixing issues reported by check_walkthrough or tweaking a few beats. Edits use 1-based beat indices resolved against the ORIGINAL order, so numbers from a check pass stay valid across a batch. Ops: updateStep (overwrite fields on a beat), replaceText (find/replace in narration, one beat or all), deleteStep, insertStep. Returns a NEW ui:// id; the original is left intact. Rejected (without rendering) if the revised draft would have anchor errors.",inputSchema:{uri:G.string().optional().describe("ui://flowcast/<id> to revise. Omit to revise the most recent walkthrough."),outputPath:G.string().optional().describe("Optional path to also write the revised .html to (same mapping as create_*)."),edits:G.array(G.discriminatedUnion("op",[G.object({op:G.literal("updateStep"),step:G.number().int().min(1).describe("1-based beat index to modify."),set:G.object({say:G.string().optional(),highlightCode:G.string().optional(),holdMs:G.number().optional(),chapter:G.string().optional()}).describe("Fields to overwrite on the beat. Omitted fields are left untouched.")}),G.object({op:G.literal("replaceText"),find:G.string().min(1).describe("Exact text to find."),replace:G.string().describe("Replacement text."),step:G.number().int().min(1).optional().describe("Limit to one beat; omit to apply across all narration."),field:G.literal("say").optional().describe("Field to search (only 'say' for now).")}),G.object({op:G.literal("deleteStep"),step:G.number().int().min(1).describe("1-based beat index to remove.")}),G.object({op:G.literal("insertStep"),after:G.number().int().min(0).describe("Insert the new beat after this 1-based index (0 = before the first beat)."),value:G.record(G.any()).describe("A new step object, same shape as a create_* step.")})])).min(1).describe("Ordered patches applied to the stored authoring spec.")}},async t=>{let e=B3(typeof t.uri=="string"?t.uri:void 0);if(!e)return{isError:!0,content:[{type:"text",text:"No walkthrough found to revise. Generate one with create_walkthrough first, or pass a valid ui://flowcast/<id>."}]};let{entry:r}=e,n=Kl.find(a=>a.id===r.typeId);if(!n)return{isError:!0,content:[{type:"text",text:`Cannot revise: unknown cast type "${r.typeId}".`}]};let s;try{s=E3(r.spec,t.edits)}catch(a){return{isError:!0,content:[{type:"text",text:`Could not apply edits: ${a instanceof Error?a.message:String(a)}`}]}}let o=lu(n.id,s),i=o.filter(a=>a.severity==="error");if(i.length)return{isError:!0,content:[{type:"text",text:`Revision rejected \u2014 the edited draft has ${i.length} error(s). Fix these and retry:
259
- ${i.map(y1).join(`
260
- `)}`}]};try{let{html:a,data:c,voice:d}=await f1(n,s),l=typeof t.outputPath=="string"?t.outputPath:void 0;return await V3({title:s.title,outputPath:l,html:a,data:c,voice:d,kind:`${n.tool.title} (revised)`,typeId:n.id,spec:s,diagnostics:o})}catch(a){return{isError:!0,content:[{type:"text",text:`Failed to render revised walkthrough: ${a instanceof Error?a.message:String(a)}`}]}}});ys.registerPrompt("new_walkthrough",{title:"New FlowCast walkthrough",description:"Start a FlowCast walkthrough \u2014 choose a format (code / whiteboard / map / 3D) and voice on/off, then build it.",argsSchema:{topic:G.string().optional().describe("Optional subject of the walkthrough.")}},({topic:t})=>({messages:[{role:"user",content:{type:"text",text:`I'd like to create a FlowCast walkthrough${t?` about: ${t}`:""}.
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}]}});As.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=vx(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=y4(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=Pu(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
+ ${i.map(p0).join(`
318
+ `)}`}]};try{let{html:a,data:c,voice:d}=await H1(n,s),l=typeof t.outputPath=="string"?t.outputPath:void 0;return await xx({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)}`}]}}});As.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}`:""}.
261
319
 
262
320
  Before building it, ask me these two choices, then create it with the matching tool:
263
321
  1. FORMAT \u2014 pick the one that best fits the topic:
264
- `+Kl.map(e=>` ${e.promptLine}`).join(`
265
- `)+'\n2. VOICE \u2014 narration ON (spoken aloud; needs OPENAI_API_KEY on the server) or OFF (synced captions only; set voice:false)? If ON, pick a `voiceTone` that fits the topic (e.g. upbeat for a beginner tutorial, calm and precise for a security deep-dive).\n\nOnce I answer, gather the content yourself and call the right tool with `voice` set accordingly. If WHITEBOARD: make it visual, not a plain mono board \u2014 give it a pastel color scheme (tones via `:::tone`/`class`, or `theme:"pastel"`), add `icons` to recognizable nodes, and `underline`/`highlight` the few most important terms. Reveal one node per beat so it animates as it builds.'}}]}));function F3(){try{_1?.close()}catch{}process.exit(0)}process.once("SIGINT",F3);process.once("SIGTERM",F3);await ys.connect(new zl);
322
+ `+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 Sx(){try{h0?.close()}catch{}process.exit(0)}process.once("SIGINT",Sx);process.once("SIGTERM",Sx);await As.connect(new Jl);