var e=Object.defineProperty,t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},r=(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")});const i={assign:0,create:0,clone:0,discard:0,update:0};function a(e,t){return i.assign+=1,{...e,...t}}function o(e,t,n){return e>=t&&e<=n}function s(e){return e===8205}function c(e){return o(e,55296,56319)}function l(e){return o(e,127462,127487)}function u(e){return o(e,65024,65039)}function d(e){return o(e,768,879)||o(e,6832,6911)||o(e,7616,7679)||o(e,65056,65071)}function f(e){return e>65535?2:1}function p(e,t){for(;t=t)return!0;return!1}function v(e,t){let n=0,r=0;for(;rt)return!1;return!0}function y(e,t){if(t===0)return!0;let n=0;for(;n=t)return!0}return!1}function b(e,t){let n=0;for(;nt)return!1}return!0}var x=n({Entries:()=>_e,EntriesRegExp:()=>ge,Every:()=>fe,EveryAll:()=>pe,GraphemeCount:()=>le,HasPropertyKey:()=>P,IsArray:()=>S,IsBigInt:()=>C,IsBoolean:()=>w,IsClassInstance:()=>se,IsConstructor:()=>T,IsDeepEqual:()=>Se,IsEqual:()=>N,IsFunction:()=>E,IsGreaterEqualThan:()=>ae,IsGreaterThan:()=>ne,IsInteger:()=>D,IsLessEqualThan:()=>ie,IsLessThan:()=>re,IsMaxLength:()=>ue,IsMinLength:()=>de,IsMultipleOf:()=>oe,IsNull:()=>O,IsNumber:()=>k,IsObject:()=>j,IsObjectNotArray:()=>A,IsString:()=>M,IsSymbol:()=>ee,IsUndefined:()=>te,IsUnsafePropertyKey:()=>he,IsValueLike:()=>ce,Keys:()=>F,ShiftLeft:()=>me,Symbols:()=>ve,Values:()=>ye});function S(e){return Array.isArray(e)}function C(e){return N(typeof e,`bigint`)}function w(e){return N(typeof e,`boolean`)}function T(e){if(te(e)||!E(e))return!1;let t=Function.prototype.toString.call(e);return!!(/^class\s/.test(t)||/\[native code\]/.test(t))}function E(e){return N(typeof e,`function`)}function D(e){return Number.isInteger(e)}function O(e){return N(e,null)}function k(e){return Number.isFinite(e)}function A(e){return j(e)&&!S(e)}function j(e){return N(typeof e,`object`)&&!O(e)}function M(e){return N(typeof e,`string`)}function ee(e){return N(typeof e,`symbol`)}function te(e){return N(e,void 0)}function N(e,t){return e===t}function ne(e,t){return e>t}function re(e,t){return e=t}function oe(e,t){if(C(e)||C(t))return BigInt(e)%BigInt(t)===0n;if(!k(e)||D(e)&&1/t%1==0)return!0;let n=e%t;return Math.min(Math.abs(n),Math.abs(n-t),Math.abs(n+t))<1e-10}function se(e){if(!j(e))return!1;let t=globalThis.Object.getPrototypeOf(e);return!O(t)&&N(typeof t.constructor,`function`)&&!(N(t.constructor,globalThis.Object)||N(t.constructor.name,`Object`))}function ce(e){return C(e)||w(e)||O(e)||k(e)||M(e)||te(e)}function le(e){return g(e)}function ue(e,t){return b(e,t)}function de(e,t){return y(e,t)}function fe(e,t,n){for(let r=t;r[RegExp(`^${t}$`),e[t]])}function _e(e){return Object.entries(e)}function F(e){return Object.getOwnPropertyNames(e)}function ve(e){return Object.getOwnPropertySymbols(e)}function ye(e){return Object.values(e)}function be(e,t){if(!j(t))return!1;let n=F(e);return N(n.length,F(t).length)&&n.every(n=>Se(e[n],t[n]))}function xe(e,t){return S(t)&&N(e.length,t.length)&&e.every((n,r)=>Se(e[r],t[r]))}function Se(e,t){return S(e)?xe(e,t):j(e)?be(e,t):N(e,t)}const Ce=/^[\p{ID_Start}_$][\p{ID_Continue}_$\u200C\u200D]*$/u;function we(e){return Ce.test(e)}function Te(e,t){return`(${e} && ${t})`}function Ee(e,t){return`(${e} || ${t})`}function De(e){return`!(${e})`}function Oe(e){return`Array.isArray(${e})`}function ke(e){return`typeof ${e} === "bigint"`}function Ae(e){return`typeof ${e} === "boolean"`}function je(e){return`Number.isInteger(${e})`}function Me(e){return`${e} === null`}function Ne(e){return`Number.isFinite(${e})`}function Pe(e){return Te(Fe(e),De(Oe(e)))}function Fe(e){return`typeof ${e} === "object" && ${e} !== null`}function Ie(e){return`typeof ${e} === "string"`}function Le(e){return`typeof ${e} === "symbol"`}function Re(e){return`${e} === undefined`}function ze(e){return`typeof ${e} === "function"`}function Be(e){return`Guard.IsConstructor(${e})`}function Ve(e,t){return`${e} === ${t}`}function He(e,t){return`${e} > ${t}`}function Ue(e,t){return`${e} < ${t}`}function We(e,t){return`${e} <= ${t}`}function Ge(e,t){return`${e} >= ${t}`}function Ke(e,t){return`Guard.IsMinLength(${e}, ${t})`}function qe(e,t){return`Guard.IsMaxLength(${e}, ${t})`}function Je(e,t,n,r){return N(t,`0`)?`${e}.every((${n[0]}, ${n[1]}) => ${r})`:`((value, callback) => { for(let index = ${t}; index < value.length; index++) if (!callback(value[index], index)) return false; return true })(${e}, (${n[0]}, ${n[1]}) => ${r})`}function Ye(e){return`Object.entries(${e})`}function Xe(e){return`Object.getOwnPropertyNames(${e})`}function Ze(e,t){return N(t,`"__proto__"`)||N(t,`"constructor"`)?`Object.prototype.hasOwnProperty.call(${e}, ${t})`:`${t} in ${e}`}function Qe(e,t){return`Guard.IsDeepEqual(${e}, ${t})`}function $e(e){return`[${e.join(`, `)}]`}function et(e,t){return`((${e.join(`, `)}) => ${t})`}function tt(e,t){return`${e}(${t.join(`, `)})`}function nt(e,t){return`new ${e}(${t.join(`, `)})`}function rt(e,t){return`${e}${we(t)?`.${t}`:`[${it(t)}]`}`}function it(e){return M(e)?JSON.stringify(e):`${e}`}function at(e,t,n){return`(${e} ? ${t} : ${n})`}function ot(e){return`{ ${e.join(`; `)}; }`}function st(e,t){return`const ${e} = ${t}`}function ct(e,t){return`if(${e}) { ${t} }`}function lt(e){return`return ${e}`}function ut(e){return N(e.length,0)?`true`:e.reduce((e,t)=>Te(e,t))}function dt(e){return N(e.length,0)?`false`:e.reduce((e,t)=>Ee(e,t))}function ft(e){return`++${e}`}function pt(e,t){return`Guard.IsMultipleOf(${e}, ${t})`}function mt(e){return e instanceof Boolean}function ht(e){return e instanceof Number}function gt(e){return e instanceof String}function _t(e){return globalThis.ArrayBuffer.isView(e)}function vt(e){return e instanceof globalThis.RegExp}function yt(e){return e instanceof globalThis.Date}function bt(e){return e instanceof globalThis.Set}function xt(e){return e instanceof globalThis.Map}var St=x;function Ct(e){return e}function wt(e){return P(e,`~kind`)||P(e,`~unsafe`)}function Tt(e){let t={},n=Object.getOwnPropertyDescriptors(e);for(let e of Object.keys(n)){if(he(e))continue;let r=n[e];P(r,`value`)&&Object.defineProperty(t,e,{...r,value:Nt(r.value)})}return t}function Et(e){let t={};for(let n of F(e))he(n)||(t[n]=Nt(e[n]));for(let n of ve(e))t[n]=Nt(e[n]);return t}function Dt(e){return se(e)?Ct(e):wt(e)?Tt(e):Et(e)}function Ot(e){return e.map(e=>Nt(e))}function kt(e){return e.slice()}function At(e){return new RegExp(e.source,e.flags)}function jt(e){return new Map(Nt([...e.entries()]))}function Mt(e){return new Set(Nt([...e.values()]))}function Nt(e){return _t(e)?kt(e):vt(e)?At(e):xt(e)?jt(e):bt(e)?Mt(e):S(e)?Ot(e):j(e)?Dt(e):e}function Pt(e){return i.clone+=1,Nt(e)}const Ft={immutableTypes:!1,maxErrors:8,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1,unionPrioritySort:!0};function It(){return Ft}function Lt(e,t){for(let n of Object.keys(t))Object.defineProperty(e,n,{configurable:!0,writable:!0,enumerable:!1,value:t[n]});return e}function Rt(e,t){return{...e,...t}}function zt(e,t,n={}){i.create+=1;let r=It(),a=Rt(t,n),o=r.enumerableKind?Rt(a,e):Lt(a,e);return r.immutableTypes?Object.freeze(o):o}function Bt(e,t){i.discard+=1;let n={},r=Object.getOwnPropertyDescriptors(Pt(e)),a=new Set(t);for(let e of Object.keys(r))a.has(e)||Object.defineProperty(n,e,r[e]);return n}function Vt(e,t,n){i.update+=1;let r=It(),a=Pt(e);for(let e of Object.keys(t))Object.defineProperty(a,e,{configurable:!0,writable:!0,enumerable:r.enumerableKind,value:t[e]});for(let e of Object.keys(n))Object.defineProperty(a,e,{configurable:!0,enumerable:!0,writable:!0,value:n[e]});return a}function Ht(e,t){return j(e)&&P(e,`~kind`)&&N(e[`~kind`],t)}function Ut(e){return j(e)}function Wt(e,t,n){return zt({"~kind":`Deferred`},{type:`deferred`,action:e,parameters:t,options:n},{})}function Gt(e){return Ht(e,`Deferred`)}function Kt(e){return Vt(e,{"~readonly":!0},{})}function qt(e,t){return Vt(Kt(e),{},t)}function Jt(e,t,n,r){return qt(sl(e,t,n),r)}function Yt(e){return Vt(e,{"~optional":!0},{})}function Xt(e,t){return Vt(Yt(e),{},t)}function Zt(e,t,n,r){return Xt(sl(e,t,n),r)}function Qt(e,t){return zt({"~kind":`Array`},{type:`array`,items:e},t)}function $t(e){return Ht(e,`Array`)}function en(e){return Bt(e,[`~kind`,`type`,`items`])}function tn(e,t,n={}){return zt({"~kind":`Constructor`},{type:`constructor`,parameters:e,instanceType:t},n)}function nn(e){return Ht(e,`Constructor`)}function rn(e){return Bt(e,[`~kind`,`type`,`parameters`,`instanceType`])}function an(e,t,n={}){return zt({"~kind":`Function`},{type:`function`,parameters:e,returnType:t},n)}function on(e){return Ht(e,`Function`)}function sn(e){return Bt(e,[`~kind`,`type`,`parameters`,`returnType`])}function cn(e,t){return zt({"~kind":`Ref`},{$ref:e},t)}function ln(e){return Ht(e,`Ref`)}function un(e,t){return zt({"~kind":`Generic`},{type:`generic`,parameters:e,expression:t})}function dn(e){return Ht(e,`Generic`)}function fn(e){return zt({"~kind":`Any`},{},e)}function pn(e){return Ht(e,`Any`)}function mn(e){return zt({"~kind":`Never`},{not:{}},e)}function hn(e){return Ht(e,`Never`)}function gn(e,t={}){return Xt(e,t)}function _n(e){return gn(e)}function vn(e){return Ut(e)&&P(e,`~optional`)}function yn(e){return F(e).filter(t=>!vn(e[t]))}function bn(e){return F(e)}function xn(e){return ye(e)}function Sn(e,t={}){let n=yn(e);return zt({"~kind":`Object`},{type:`object`,...n.length>0?{required:n}:{},properties:e},t)}function Cn(e){return Ht(e,`Object`)}function wn(e){return Bt(e,[`~kind`,`type`,`properties`,`required`])}function Tn(e){return zt({"~kind":`Unknown`},{},e)}function En(e){return Ht(e,`Unknown`)}function Dn(e,t,n){return zt({"~kind":`Cyclic`},{$defs:F(e).reduce((t,n)=>({...t,[n]:Vt(e[n],{},{$id:n})}),{}),$ref:t},n)}function On(e){return Ht(e,`Cyclic`)}function kn(e){return A(e)&&P(e,`~unsafe`)&&O(e[`~unsafe`])}function An(e,t){return t[e.length]?.(...e)??(()=>{throw Error(`Invalid Arguments`)})()}function jn(e){return Ht(e,`Infer`)}function Mn(e,t,n,r={}){return zt({"~kind":`Dependent`},{if:e,then:t,else:n},r)}function Nn(e){return Ht(e,`Dependent`)}function Pn(e){return Bt(e,[`~kind`,`if`,`then`,`else`])}function Fn(e){return Ht(e,`Enum`)}function In(e,t={}){return zt({"~kind":`Intersect`},{allOf:e},t)}function Ln(e){return Ht(e,`Intersect`)}function Rn(e){return Bt(e,[`~kind`,`allOf`])}let zn;function Bn(){try{return Hn(`null`)(),!0}catch{return!1}}function Vn(){return te(zn)&&(zn=Bn()),zn&&It().useAcceleration}function Hn(...e){return new globalThis.Function(...e)}function Un(){throw Error(`Unreachable`)}var Wn=n({Hash:()=>yr,HashCode:()=>vr});function Gn(e){let t=new Set,n=e;for(;n&&n!==Object.prototype;){for(let e of Reflect.ownKeys(n))e!==`constructor`&&typeof e!=`symbol`&&t.add(e);n=Object.getPrototypeOf(n)}return[...t]}function Kn(e){return typeof e==`number`}var qn;(function(e){e[e.Array=0]=`Array`,e[e.BigInt=1]=`BigInt`,e[e.Boolean=2]=`Boolean`,e[e.Date=3]=`Date`,e[e.Constructor=4]=`Constructor`,e[e.Function=5]=`Function`,e[e.Null=6]=`Null`,e[e.Number=7]=`Number`,e[e.Object=8]=`Object`,e[e.RegExp=9]=`RegExp`,e[e.String=10]=`String`,e[e.Symbol=11]=`Symbol`,e[e.TypeArray=12]=`TypeArray`,e[e.Undefined=13]=`Undefined`})(qn||={});let Jn=BigInt(`14695981039346656037`);const[Yn,Xn]=[BigInt(`1099511628211`),BigInt(`18446744073709551616`)],Zn=Array.from({length:256}).map((e,t)=>BigInt(t)),Qn=new Float64Array(1),$n=new DataView(Qn.buffer),er=new Uint8Array(Qn.buffer);function tr(e){Jn^=Zn[e],Jn=Jn*Yn%Xn}function nr(e){tr(qn.Array);for(let t of e)_r(t)}function rr(e){tr(qn.BigInt),$n.setBigInt64(0,e);for(let e of er)tr(e)}function ir(e){tr(qn.Boolean),tr(+!!e)}function ar(e){tr(qn.Constructor),_r(e.toString())}function or(e){tr(qn.Date),_r(e.getTime())}function sr(e){tr(qn.Function),_r(e.toString())}function cr(e){tr(qn.Null)}function lr(e){tr(qn.Number),$n.setFloat64(0,e,!0);for(let e of er)tr(e)}function ur(e){tr(qn.Object);for(let t of Gn(e).sort())_r(t),_r(e[t])}function dr(e){tr(qn.RegExp),pr(e.toString())}const fr=new TextEncoder;function pr(e){tr(qn.String);for(let t of fr.encode(e))tr(t)}function mr(e){tr(qn.Symbol),_r(e.toString())}function hr(e){tr(qn.TypeArray);let t=new Uint8Array(e.buffer);for(let e=0;e{throw new Nr(e)})()}function Fr(e,t){return zt({"~kind":`Literal`},{type:Pr(e),const:e},t)}function Ir(e){return C(e)||w(e)||k(e)||M(e)}function Lr(e){return Vr(e)&&C(e.const)}function Rr(e){return Vr(e)&&w(e.const)}function zr(e){return Vr(e)&&k(e.const)}function Br(e){return Vr(e)&&M(e.const)}function Vr(e){return Ht(e,`Literal`)}function Hr(e){return zt({"~kind":`Null`},{type:`null`},e)}function Ur(e){return Ht(e,`Null`)}const Wr=`-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?`;function Gr(e){return zt({"~kind":`Number`},{type:`number`},e)}function Kr(e){return Ht(e,`Number`)}function qr(e){return zt({"~kind":`Symbol`},{type:`symbol`},e)}function Jr(e){return Ht(e,`Symbol`)}function Yr(e){return zt({"~kind":`String`},{type:`string`},e)}function Xr(e){return Ht(e,`String`)}function Zr(e,t={}){return zt({"~kind":`Union`},{anyOf:e},t)}function Qr(e){return Ht(e,`Union`)}function $r(e){return Bt(e,[`~kind`,`anyOf`])}function ei(e){let t=Eo(e);return N(t.length,2)?t[0]:[]}function ti(e){return!0}function ni(e){return me(e,(e,t)=>ii(e)?ni(t):!1,()=>!0)}function ri(e){return!N(e.length,0)&&ni(e)}function ii(e){return Qr(e)?ri(e.anyOf):Vr(e)?ti(e.const):!1}function ai(e){return ri(e)}function oi(e){return zt({"~kind":`TemplateLiteral`},{type:`string`,pattern:e},{})}function si(e,t,n=[]){return me(e,(e,r)=>si(r,t,[...n,`${e}${t}`]),()=>n)}function ci(e,t){return N(e.length,0)?[`${t}`]:si(e,t)}function li(e,t,n=[]){return me(t,(t,r)=>li(e,r,[...n,...ui(e,t)]),()=>n)}function ui(e,t){return Qr(t)?li(e,t.anyOf):Vr(t)?ci(e,t.const):Un()}function di(e,t){return me(t,(t,n)=>di(ui(e,t),n),()=>e)}function fi(e){return e.map(e=>Fr(e))}function pi(e){return Zr(fi(di([],e)))}function mi(e){return N(e.length,0)?Un():N(e.length,1)&&Vr(e[0])?e[0]:pi(e)}function hi(e){let t=ei(e);return N(t.length,0)?Yr():ai(t)?mi(t):oi(e)}function gi(e){let t=hi(e);return Ho(t)?Yr():t}function _i(e,t){return zt({"~kind":`Record`},{type:`object`,patternProperties:{[e]:t}})}function vi(e){return _i(Sa,e)}function yi(e){return Sn({true:e,false:e})}function bi(e,t={}){let[n,r,i]=[e,e.length,!1];return zt({"~kind":`Tuple`},{type:`array`,additionalItems:i,items:n,minItems:r},t)}function xi(e){return Ht(e,`Tuple`)}function Si(e){return Bt(e,[`~kind`,`type`,`items`,`minItems`,`additionalItems`])}function Ci(e){return Bt(e,[`~readonly`])}function wi(e,t){return Vt(Ci(e),{},t)}function Ti(e,t,n,r){return wi(sl(e,t,n),r)}function Ei(e,t={}){return wi(e,t)}function Di(e){return Bt(e,[`~optional`])}function Oi(e,t){return Vt(Di(e),{},t)}function ki(e,t,n,r){return Oi(sl(e,t,n),r)}function Ai(e,t={}){return Oi(e,t)}function ji(e){return e.reduceRight((e,t,n)=>({[n]:t,...e}),{})}function Mi(e){return Sn(ji(e.items))}function Ni(e,t){return Er(e)?!!Er(t):!1}function Pi(e,t){return vn(e)?!!vn(t):!1}function Fi(e,t){let n=Ni(e,t),r=Pi(e,t),i=Ei(Ai(Qi([e,t])));return n&&r?Tr(gn(i)):n&&!r?Tr(i):!n&&r?gn(i):i}function Ii(e,t,n){return n in e?n in t?Fi(e[n],t[n]):e[n]:n in t?t[n]:mn()}function Li(e,t){return[...new Set([...F(t),...F(e)])].reduce((n,r)=>({...n,[r]:Ii(e,t,r)}),{})}function Ri(e){return Cn(e)?e.properties:xi(e)?ji(e.items):Un()}function zi(e,t){return Sn(Li(Ri(e),Ri(t)))}function Bi(e,t){let n=qs(e,t);return N(n,`left-inside`)?e:N(n,`right-inside`)||N(n,`equal`)?t:mn()}function Vi(e){return Cn(e)||xi(e)}function Hi(e,t){let n=Qr(e),r=Qr(t);return n||r}function Ui(e,t){let n=ta(e),r=ta(t),i=Hi(n,r),a=Vi(n),o=Vi(r);return i?Qi([n,r]):a&&o?zi(n,r):a&&!o?n:!a&&o?r:Bi(n,r)}function Wi(e,t,n=[]){return me(t,(t,r)=>Wi(e,r,[...n,Ui(e,t)]),()=>N(n.length,0)?[e]:n)}function Gi(e,t,n=[]){return me(e,(e,r)=>Gi(r,t,[...n,...Ki([e],t)]),()=>n)}function Ki(e,t=[]){return me(e,(e,n)=>Qr(e)?Ki(n,Gi(e.anyOf,t)):Ki(n,Wi(e,t)),()=>t)}function qi(e,t){return Jo(Ks({},e,t))?[]:[e]}function Ji(e,t){return e.reduce((e,n)=>[...e,...qi(n,t)],[])}function Yi(e,t){let n=ta(e);return ea(Ji(Qr(n)?n.anyOf:[n],t))}function Xi(e,t,n){return ea([In([e,t]),Yi(n,e)])}function Zi(e){return ea(e.map(e=>Fr(e)))}function Qi(e){return na(Js(Ki(e)))}function $i(e){return ta(gi(e))}function ea(e){return na(Js(e))}function ta(e){return Nn(e)?Xi(e.if,e.then,e.else):Fn(e)?Zi(e.enum):Ln(e)?Qi(e.allOf):Ho(e)?$i(e.pattern):Qr(e)?ea(e.anyOf):e}function na(e){return N(e.length,1)?e[0]:N(e.length,0)?mn():Zr(e)}function ra(e,t){return _a(Zi(e),t)}function ia(e,t){return _i(ba,t)}function aa(e,t){return _a(Qi(e),t)}function oa(e,t){return M(e)||k(e)?Sn({[e]:t}):N(e,!1)?Sn({false:t}):N(e,!0)?Sn({true:t}):Sn({})}function sa(e,t){return _i(xa,t)}function ca(e,t){return P(e,`pattern`)&&(M(e.pattern)||e.pattern instanceof RegExp)?_i(e.pattern.toString(),t):_i(Sa,t)}function la(e,t){return ai(ei(e))?_a($i(e),t):_i(e,t)}function ua(e){return Qr(e)?da(e.anyOf):[e]}function da(e){return e.reduce((e,t)=>[...e,...ua(t)],[])}function fa(e){return e.some(e=>Xr(e)||Kr(e)||Mr(e))}function pa(e,t){return N(fa(e),!0)?_i(Sa,t):void 0}function ma(e,t){return e.reduce((e,n)=>Vr(n)&&(M(n.const)||k(n.const))?{...e,[n.const]:t}:e,{})}function ha(e,t){return Sn(ma(e,t))}function ga(e,t){let n=da(e),r=pa(n,t);return Ut(r)?r:ha(n,t)}function _a(e,t){return pn(e)?vi(t):kr(e)?yi(t):Fn(e)?ra(e.enum,t):Mr(e)?ia(e,t):Ln(e)?aa(e.allOf,t):Vr(e)?oa(e.const,t):Kr(e)?sa(e,t):Qr(e)?ga(e.anyOf,t):Xr(e)?ca(e,t):Ho(e)?la(e.pattern,t):Sn({})}function va(e,t,n){return el([e])?Vt(_a(e,t),{},n):Ca(e,t,n)}function ya(e,t,n,r,i){return va(sl(e,t,n),sl(e,t,r),i)}const ba=`^${Ar}$`,xa=`^${Wr}$`,Sa=`^.*$`;function Ca(e,t,n={}){return Wt(`Record`,[e,t],n)}function wa(e,t,n={}){return va(e,t,n)}function Ta(e,t){return _i(e,t)}function Ea(e){return N(e,Sa)?Yr():N(e,ba)?jr():N(e,xa)?Gr():hi(e)}function Da(e){return F(e.patternProperties)[0]}function Oa(e){return Ea(Da(e))}function ka(e){return e.patternProperties[Da(e)]}function Aa(e){return Ht(e,`Record`)}function ja(e){return zt({"~kind":`Rest`},{type:`rest`,items:e},{})}function Ma(e){return Ht(e,`Rest`)}function Na(e){return Ht(e,`This`)}function Pa(e){return zt({"~kind":`Undefined`},{type:`undefined`},e)}function Fa(e){return Ht(e,`Undefined`)}function Ia(e){return Ht(e,`Void`)}function La(e){return Dr()}function Ra(e){return Yr()}function za(e){return Gr()}function Ba(e){return jr()}function Va(e){return mn()}function Ha(e){return Fr(e)}function Ua(e){return e}function Wa(e){return Zr(e[1])}function Ga(e){return e.length===3?[...e[0],...e[2]]:e.length===1?[...e[0]]:[]}function Ka(e){return[e[0],...e[1]]}function qa(e){return e}function Ja(e){return e[1]}function Ya(e){return N(e.length,2)}function Xa(e,t,n){return Ya(e)?t(e[0],e[1]):n()}function Za(e,t){return N(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function Qa(e,t){for(let n=0;nString.fromCharCode(e+n))}const eo=[...$a(97,122),...$a(65,90)],to=[`0`,...$a(49,57)];function no(e){let t=e.indexOf(`*/`);return N(t,-1)?``:e.slice(t+2)}function ro(e){let t=e.indexOf(` `);return N(t,-1)?``:e.slice(t)}function io(e){return e.replace(/^[ \t\r\f\v]+/,``)}function ao(e){let t=io(e);return t.startsWith(`/*`)?ao(no(t.slice(2))):t.startsWith(`//`)?ao(ro(t.slice(2))):t}function oo(e){let t=e.trimStart();return t.startsWith(`/*`)?oo(no(t.slice(2))):t.startsWith(`//`)?oo(ro(t.slice(2))):t}[...to];function so(e,t){return Qa([e],t)}function co(e,t){return N(e,``)?[``,t]:e.startsWith(` `)?so(e,ao(t)):e.startsWith(` `)?so(e,t):so(e,oo(t))}[...eo,...to],[...to];function lo(e){return N(e,``)?[]:[e.slice(0,1),e.slice(1)]}function uo(e,t){return me(e,(e,n)=>t.startsWith(e)?!0:uo(n,t),()=>!1)}function fo(e,t,n=``){return Xa(lo(t),(r,i)=>uo(e,t)?[n,t]:fo(e,i,`${n}${r}`),()=>[])}function po(e,t){return Xa(fo(e,t),(e,t)=>N(e,``)?[]:[e,t],()=>[])}const mo=(e,t,n=()=>[])=>e.length===2?t(e):n(),ho=e=>mo(co(`-?(?:0|[1-9][0-9]*)n`,e),([e,t])=>[La(e),t]),go=e=>mo(co(`.*`,e),([e,t])=>[Ra(e),t]),_o=e=>mo(co(`-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?`,e),([e,t])=>[za(e),t]),vo=e=>mo(co(`-?(?:0|[1-9][0-9]*)`,e),([e,t])=>[Ba(e),t]),yo=e=>mo(co(`(?!)`,e),([e,t])=>[Va(e),t]),bo=e=>mo(po([`-?(?:0|[1-9][0-9]*)n`,`.*`,`-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?`,`-?(?:0|[1-9][0-9]*)`,`(?!)`,`(`,`)`,`$`,`|`],e),([e,t])=>[Ha(e),t]),xo=e=>mo(mo(ho(e),([e,t])=>[e,t],()=>mo(go(e),([e,t])=>[e,t],()=>mo(_o(e),([e,t])=>[e,t],()=>mo(vo(e),([e,t])=>[e,t],()=>mo(yo(e),([e,t])=>[e,t],()=>mo(So(e),([e,t])=>[e,t],()=>mo(bo(e),([e,t])=>[e,t],()=>[]))))))),([e,t])=>[Ua(e),t]),So=e=>mo(mo(co(`(`,e),([e,t])=>mo(To(t),([t,n])=>mo(co(`)`,n),([n,r])=>[[e,t,n],r]))),([e,t])=>[Wa(e),t]),Co=e=>mo(mo(mo(wo(e),([e,t])=>mo(co(`|`,t),([t,n])=>mo(Co(n),([n,r])=>[[e,t,n],r]))),([e,t])=>[e,t],()=>mo(mo(wo(e),([e,t])=>[[e],t]),([e,t])=>[e,t],()=>mo([[],e],([e,t])=>[e,t],()=>[]))),([e,t])=>[Ga(e),t]),wo=e=>mo(mo(xo(e),([e,t])=>mo(To(t),([t,n])=>[[e,t],n])),([e,t])=>[Ka(e),t]),To=e=>mo(mo(Co(e),([e,t])=>[e,t],()=>mo(wo(e),([e,t])=>[e,t],()=>[])),([e,t])=>[qa(e),t]),Eo=e=>mo(mo(co(`^`,e),([e,t])=>mo(To(t),([t,n])=>mo(co(`$`,n),([n,r])=>[[e,t,n],r]))),([e,t])=>[Ja(e),t]);function Do(e){return e.join(`|`)}function Oo(e){return e.slice(1,e.length-1)}function ko(e,t,n){return Bo(t,`${n}${e}`)}function Ao(e,t){return Bo(e,`${t}-?(?:0|[1-9][0-9]*)n`)}function jo(e,t){return Bo(e,`${t}${Ar}`)}function Mo(e,t){return Bo(e,`${t}${Wr}`)}function No(e,t){return zo(Zr([Fr(`false`),Fr(`true`)]),e,t)}function Po(e,t){return Bo(e,`${t}.*`)}function Fo(e,t,n){return Bo(t,`${n}${Oo(e)}`)}function Io(e,t,n){return zo(Vo(e,{}),t,n)}function Lo(e,t,n){return zo(Zi(e),t,n)}function Ro(e,t,n,r=[]){return me(e,(e,i)=>Ro(i,t,n,[...r,zo(e,[],``)]),()=>Bo(t,`${n}(${Do(r)})`))}function zo(e,t,n){return Fn(e)?Lo(e.enum,t,n):Mr(e)?jo(t,n):Vr(e)?ko(e.const,t,n):Or(e)?Ao(t,n):kr(e)?No(t,n):Kr(e)?Mo(t,n):Xr(e)?Po(t,n):Ho(e)?Fo(e.pattern,t,n):iee(e)?Io(e.parameters[0],t,n):Qr(e)?Ro(e.anyOf,t,n):`(?!)`}function Bo(e,t){return me(e,(e,n)=>zo(e,n,t),()=>t)}function eee(e){return`^${Bo(e,``)}$`}function tee(e){return oi(eee(e))}function Vo(e,t){return el(e)?Vt(tee(e),{},t):ree(e,t)}function nee(e,t,n,r){return Vo(rl(e,t,n),r)}function ree(e,t={}){return Wt(`TemplateLiteral`,[e],t)}function iee(e){return Ut(e)&&P(e,`action`)&&N(e.action,`TemplateLiteral`)}function Ho(e){return Ht(e,`TemplateLiteral`)}function aee(e){return zt({"~kind":`ExtendsUnion`},{inferred:e})}function Uo(e){return j(e)&&P(e,`~kind`)&&P(e,`inferred`)&&N(e[`~kind`],`ExtendsUnion`)&&j(e.inferred)}function Wo(e){return zt({"~kind":`ExtendsTrue`},{inferred:e})}function Go(e){return j(e)&&P(e,`~kind`)&&P(e,`inferred`)&&N(e[`~kind`],`ExtendsTrue`)&&j(e.inferred)}function Ko(){return zt({"~kind":`ExtendsFalse`},{})}function qo(e){return j(e)&&P(e,`~kind`)&&N(e[`~kind`],`ExtendsFalse`)}function Jo(e){return Uo(e)||Go(e)}function Yo(e,t,n){return Jo(e)?t(e.inferred):n()}function oee(e,t,n,r){return Yo(Ns(e,n,r),r=>Wo(a(a(e,r),{[t]:n})),()=>Ko())}function see(e,t){return Wo(e)}function cee(e,t,n,r,i){return Yo(Ns(e,t,n),e=>Yo(Ns(e,t,r),e=>Wo(e),()=>Ko()),()=>Yo(Ns(e,t,i),e=>Wo(e),()=>Ko()))}function lee(e,t,n){return Ns(e,t,Zi(n))}function Xo(e,t,n){return me(n,(n,r)=>Yo(Ns(e,t,n),e=>Xo(e,t,r),()=>Ko()),()=>Wo(e))}function uee(e,t,n){return Ns(e,t,$i(n))}function Zo(e,t,n){return me(n,(n,r)=>Yo(Ns(e,t,n),e=>Wo(e),()=>Zo(e,t,r)),()=>Ko())}function Qo(e,t,n){return pn(n)?see(e,t):Nn(n)?cee(e,t,n.if,n.then,n.else):Fn(n)?lee(e,t,n.enum):jn(n)?oee(e,n.name,t,n.extends):Ln(n)?Xo(e,t,n.allOf):Ho(n)?uee(e,t,n.pattern):Qr(n)?Zo(e,t,n.anyOf):En(n)?Wo(e):Ko()}function dee(e,t,n){return jn(n)?Qo(e,t,n):pn(n)||En(n)?Wo(e):aee(e)}function fee(e,t){let n=wr(e),r=wr(t);return n&&r||!n&&r?!0:!(n&&!r)}function pee(e,t,n,r){return $t(r)?fee(t,r)?Ns(e,n,r.items):Ko():Qo(e,t,r)}function mee(e,t,n){return Or(n)?Wo(e):Qo(e,t,n)}function hee(e,t,n){return kr(n)?Wo(e):Qo(e,t,n)}function gee(e,t,n,r,i){let a=jn(r)?t:r,o=jn(r)?r:t,s=vn(t),c=vn(r);return!s&&c?Ko():Yo(Ns(e,a,o),e=>$o(e,n,i),()=>Ko())}function _ee(e,t,n,r){return me(r,(r,i)=>gee(e,t,n,r,i),()=>vn(t)?Wo(e):Ko())}function vee(e,t,n){return me(t,(t,r)=>_ee(e,t,r,n),()=>Wo(e))}function $o(e,t,n){return vee(e,t,n)}function es(e,t,n){return Ia(n)?Wo(e):Ns(e,t,n)}function yee(e,t,n,r){return pn(r)||En(r)?Wo(e):nn(r)?Yo($o(e,t,r.parameters),e=>es(e,n,r.instanceType),()=>Ko()):Ko()}function bee(e,t,n,r,i){return Yo(Ns(e,t,i),()=>Ns(e,n,i),()=>Ns(e,r,i))}function xee(e,t,n){return Ns(e,Zi(t),n)}function See(e,t,n,r){return pn(r)||En(r)?Wo(e):on(r)?Yo($o(e,t,r.parameters),e=>es(e,n,r.returnType),()=>Ko()):Ko()}function Cee(e,t,n){return Mr(n)||Kr(n)?Wo(e):Qo(e,t,n)}function wee(e,t,n){return Ns(e,Qi(t),n)}function ts(e,t,n){return t===n?Wo(e):Ko()}function Tee(e,t,n){return Vr(n)?ts(e,t,n.const):Or(n)?Wo(e):Qo(e,Fr(t),n)}function Eee(e,t,n){return Vr(n)?ts(e,t,n.const):kr(n)?Wo(e):Qo(e,Fr(t),n)}function Dee(e,t,n){return Vr(n)?ts(e,t,n.const):Kr(n)?Wo(e):Qo(e,Fr(t),n)}function Oee(e,t,n){return Vr(n)?ts(e,t,n.const):Xr(n)?Wo(e):Qo(e,Fr(t),n)}function ns(e,t,n){return C(t.const)?Tee(e,t.const,n):w(t.const)?Eee(e,t.const,n):k(t.const)?Dee(e,t.const,n):M(t.const)?Oee(e,t.const,n):Un()}function rs(e,t,n){return jn(n)?Qo(e,t,n):Wo(e)}function is(e,t,n){return Ur(n)?Wo(e):Qo(e,t,n)}function as(e,t,n){return Kr(n)?Wo(e):Qo(e,t,n)}function os(e,t,n){return vn(t)?vn(n)?Wo(e):Ko():Wo(e)}function ss(e,t,n){return jn(n)&&hn(n.extends)?Ko():Yo(Ns(e,t,n),e=>os(e,t,n),()=>Ko())}function cs(e,t){return e.reduce((e,n)=>n in t&&Jo(t[n])?{...e,...t[n].inferred}:Un(),{})}function ls(e,t,n){let r={};for(let i of F(n))r[i]=i in t?ss({},t[i],n[i]):vn(n[i])?jn(n[i])?Wo(a(e,{[n[i].name]:n[i].extends})):Wo(e):Ko();let i=ye(r).every(e=>Jo(e)),o=i?cs(F(r),r):{};return i?Wo(o):Ko()}function us(e,t,n){let r=ls(e,t,n);return Jo(r)?Wo(a(e,r.inferred)):Ko()}function ds(e,t,n){return us(e,t,n)}function fs(e,t){return F(t).reduce((n,r)=>({...n,[r]:P(e,r)?Qr(n[r])?Zr([...n[r].anyOf,t[r]]):Zr([e[r],t[r]]):t[r]}),e)}function ps(e,t,n,r){return me(t,(t,i)=>Yo(Ns({},e[t],n),t=>ps(e,i,n,fs(r,t)),()=>Ko()),()=>Wo(r))}function ms(e,t,n,r){return ps(t,F(t),r,e)}function hs(e,t,n){return Aa(n)?ms(e,t,Da(n),ka(n)):Cn(n)?ds(e,t,n.properties):Qo(e,Sn(t),n)}function gs(e,t){return N(F(t).length,0)?Wo(e):Ko()}function _s(e,t,n,r,i){return Ns(e,n,i)}function vs(e,t,n,r){return Aa(r)?_s(e,Ea(t),n,Ea(Da(r)),ka(r)):Cn(r)?gs(e,r.properties):pn(r)||En(r)?Wo(e):Ko()}function ys(e,t,n){return Xr(n)?Wo(e):Qo(e,t,n)}function bs(e,t,n){return Jr(n)?Wo(e):Qo(e,t,n)}function xs(e,t,n){return Ns(e,$i(t),n)}function Ss(e,t){return zt({"~kind":`Inferrable`},{name:e,type:t},{})}function Cs(e){return j(e)&&P(e,`~kind`)&&P(e,`name`)&&P(e,`type`)&&N(e[`~kind`],`Inferrable`)&&M(e.name)&&j(e.type)}function ws(e){return Ma(e)?jn(e.items)?$t(e.items.extends)?Ss(e.items.name,e.items.extends.items):En(e.items.extends)?Ss(e.items.name,e.items.extends):void 0:Un():void 0}function Ts(e){return jn(e)?Ss(e.name,e.extends):void 0}function Es(e,t,n=[]){return me(e,(e,r)=>Yo(Ns({},e,t),()=>Es(r,t,[...n,e]),()=>void 0),()=>n)}function kee(e,t,n,r){let i=Es(n,r);return S(i)?Wo(a(e,{[t]:bi(i)})):Ko()}function Ds(e,t,n,r){let i=Es(n,r);return S(i)?Wo(a(e,{[t]:Zr(i)})):Ko()}function Aee(e){return[...e].reverse()}function Os(e,t){return t?Aee(e):e}function jee(e){let t=e.length>0?e[0]:void 0;return Ut(Ut(t)?ws(t):void 0)}function Mee(e,t,n,r,i,a){return Yo(Ns(e,n,i),e=>ks(e,t,r,a),()=>Ko())}function Nee(e,t,n,r,i){let a=ws(r);return Cs(a)?kee(e,a.name,Os(n,t),a.type):me(n,(n,a)=>Mee(e,t,n,a,r,i),()=>Ko())}function Pee(e,t,n,r){return me(r,(r,i)=>Nee(e,t,n,r,i),()=>N(n.length,0)?Wo(e):Ko())}function ks(e,t,n,r){return Pee(e,t,n,r)}function Fee(e,t,n){let r=nl(e,$c([],[]),n),i=jee(r);return ks(e,i,Os(t,i),Os(r,i))}function As(e,t,n){let r=Ts(n);return Cs(r)?Ds(e,r.name,t,r.type):me(t,(t,r)=>Yo(Ns(e,t,n),e=>As(e,r,n),()=>Ko()),()=>Wo(e))}function Iee(e,t,n){let r=nl(e,$c([],[]),t);return xi(n)?Fee(e,r,n.items):$t(n)?As(e,r,n.items):Qo(e,bi(r),n)}function Lee(e,t,n){return Ia(n)||Fa(n)?Wo(e):Qo(e,t,n)}function js(e,t,n){return me(n,(n,r)=>Yo(Ns(e,t,n),e=>Wo(e),()=>js(e,t,r)),()=>Ko())}function Ms(e,t,n){return me(t,(t,r)=>Yo(js(e,t,n),e=>Ms(e,r,n),()=>Ko()),()=>Wo(e))}function Ree(e,t,n){let r=Ts(n);return Cs(r)?Ds(e,r.name,t,r.type):Qr(n)?Ms(e,t,n.anyOf):Ms(e,t,[n])}function zee(e,t,n){return jn(n)?Qo(e,t,n):pn(n)||En(n)?Wo(e):Ko()}function Bee(e,t,n){return Ia(n)?Wo(e):Qo(e,t,n)}function Ns(e,t,n){return pn(t)?dee(e,t,n):$t(t)?pee(e,t,t.items,n):Or(t)?mee(e,t,n):kr(t)?hee(e,t,n):nn(t)?yee(e,t.parameters,t.instanceType,n):Nn(t)?bee(e,t.if,t.then,t.else,n):Fn(t)?xee(e,t.enum,n):on(t)?See(e,t.parameters,t.returnType,n):Mr(t)?Cee(e,t,n):Ln(t)?wee(e,t.allOf,n):Vr(t)?ns(e,t,n):hn(t)?rs(e,t,n):Ur(t)?is(e,t,n):Kr(t)?as(e,t,n):Cn(t)?hs(e,t.properties,n):Aa(t)?vs(e,Da(t),ka(t),n):Xr(t)?ys(e,t,n):Jr(t)?bs(e,t,n):Ho(t)?xs(e,t.pattern,n):xi(t)?Iee(e,t.items,n):Fa(t)?Lee(e,t,n):Qr(t)?Ree(e,t.anyOf,n):En(t)?zee(e,t,n):Ia(t)?Bee(e,t,n):Ko()}function Vee(e,t){return Qi([...e,Sn(t)])}function Hee(e,t,n){return el(e)?Vt(Vee(e,t),{},n):Wee(e,t,n)}function Uee(e,t,n,r,i){return Hee(rl(e,t,n),tl(e,t,r),i)}function Wee(e,t,n={}){return Wt(`Interface`,[e,t],n)}function Ps(e){return Ut(e)&&P(e,`action`)&&N(e.action,`Interface`)}function Gee(e,t,n){return e.includes(n)?!0:Ls([...e,n],t,t[n])}function Fs(e,t,n){return Is(e,t,xn(n))}function Is(e,t,n){return me(n,(n,r)=>Ls(e,t,n)?!0:Is(e,t,r),()=>!1)}function Ls(e,t,n){return ln(n)?Gee(e,t,n.$ref):$t(n)?Ls(e,t,n.items):nn(n)?Is(e,t,[...n.parameters,n.instanceType]):on(n)?Is(e,t,[...n.parameters,n.returnType]):Ps(n)?Fs(e,t,n.parameters[1]):Ln(n)?Is(e,t,n.allOf):Cn(n)?Fs(e,t,n.properties):Qr(n)?Is(e,t,n.anyOf):xi(n)?Is(e,t,n.items):Aa(n)?Ls(e,t,ka(n)):!1}function Kee(e,t,n){return Ls(e,t,n)}function qee(e,t){return t.reduce((t,n)=>Kee([n],e,e[n])?[...t,n]:t,[])}function Jee(e){return qee(e,bn(e))}function Yee(e,t,n){return n.includes(t)?n:t in e?Bs(e,e[t],[...n,t]):Un()}function Rs(e,t,n){return zs(e,xn(t),n)}function zs(e,t,n){return t.reduce((t,n)=>Bs(e,n,t),n)}function Bs(e,t,n){return ln(t)?Yee(e,t.$ref,n):$t(t)?Bs(e,t.items,n):nn(t)?zs(e,[...t.parameters,t.instanceType],n):on(t)?zs(e,[...t.parameters,t.returnType],n):Ps(t)?Rs(e,t.parameters[1],n):Ln(t)?zs(e,t.allOf,n):Cn(t)?Rs(e,t.properties,n):Qr(t)?zs(e,t.anyOf,n):xi(t)?zs(e,t.items,n):Aa(t)?Bs(e,ka(t),n):n}function Xee(e,t,n){return Bs(e,n,[t])}function Zee(e){return fn()}function Qee(e){return F(e).reduce((t,n)=>({...t,[n]:Hs(e[n])}),{})}function Vs(e){return e.reduce((e,t)=>[...e,Hs(t)],[])}function Hs(e){return ln(e)?Zee(e.$ref):$t(e)?Qt(Hs(e.items),en(e)):nn(e)?tn(Vs(e.parameters),Hs(e.instanceType)):on(e)?an(Vs(e.parameters),Hs(e.returnType)):Ln(e)?In(Vs(e.allOf)):Cn(e)?Sn(Qee(e.properties)):Aa(e)?wa(Oa(e),Hs(ka(e))):Qr(e)?Zr(Vs(e.anyOf)):xi(e)?bi(Vs(e.items)):e}function $ee(e,t){return t in e?Hs(e[t]):Tn()}function ete(e){return $ee(e.$defs,e.$ref)}function tte(e,t,n){let r=rl(e,$c([],[]),t),i=tl({},$c([],[]),n);return Qi([...r,Sn(i)])}function nte(e,t){return F(e).filter(e=>t.includes(e)).reduce((t,n)=>{let r=e[n],i=Ps(r)?tte(e,r.parameters[0],r.parameters[1]):r;return{...t,[n]:i}},{})}function rte(e,t,n){return Dn(nte(e,Xee(e,t,n)),t)}function Us(e,t){return t in e?ln(e[t])?Us(e,e[t].$ref):e[t]:mn()}function Ws(e,t){return Us(e,t)}function Gs(e){return On(e)?ete(e):kn(e)?Tn():e}function Ks(e,t,n){return Ns(e,Gs(t),Gs(n))}function qs(e,t){let n=[En(e)?Ko():Ks({},e,t),En(e)?Wo({}):Ks({},t,e)];return Jo(n[0])&&Jo(n[1])?`equal`:Jo(n[0])&&qo(n[1])?`left-inside`:qo(n[0])&&Jo(n[1])?`right-inside`:`disjoint`}function ite(e,t){return t.filter(t=>qs(e,t)!==`right-inside`)}function ate(e,t){return N(t.some(t=>{let n=qs(e,t);return N(n,`left-inside`)||N(n,`equal`)}),!1)}function ote(e,t){let n=ta(e);return pn(n)?[n]:ate(n,t)?[...ite(n,t),n]:t}function ste(e){return e.reduce((e,t)=>Cn(t)?[...e,t]:hn(t)?e:ote(t,e),[])}function Js(e){return da(ste(e))}function Ys(e,t){return Vt(ta(e),{},t)}function cte(e,t,n,r){return Ys(sl(e,t,n),r)}function Xs(e,t=[]){return Gt(e)&&N(e.action,`Conditional`)?ln(e.parameters[0])?Xs(e.parameters[2],Xs(e.parameters[3],[...t,e.parameters[0].$ref])):Xs(e.parameters[2],Xs(e.parameters[3],t)):Gt(e)&&N(e.action,`Mapped`)&&Gt(e.parameters[1])&&N(e.parameters[1].action,`KeyOf`)&&ln(e.parameters[1].parameters[0])?[...t,e.parameters[1].parameters[0].$ref]:t}function lte(e,t){return e.reduce((e,n)=>[...e,t.includes(n.name)],[])}function Zs(e,t,n=[]){return me(e,(e,r)=>me(t,(t,i)=>Zs(r,i,[...n,[t,e]]),()=>n),()=>n)}function ute(e){return Qr(e)?[...e.anyOf]:[e]}function dte(e,t){return e.reduce((e,n)=>[...e,[...n,t]],[])}function Qs(e,t){return t.reduce((t,n)=>[...t,...dte(e,n)],[])}function fte(e){return e.reduce((e,t)=>N(t[0],!0)?Qs(e,ute(t[1])):Qs(e,[t[1]]),[[]])}function pte(e,t,n){let r=Zs(t,lte(e,Xs(n)));return Gt(n)&&N(n.action,`Conditional`)||Gt(n)&&N(n.action,`Mapped`)?fte(r):[t]}function mte(){return[`(not-resolvable)`,mn()]}function hte(){return[`(not-generic)`,mn()]}function gte(e,t,n){return[e,un(t,n)]}function _te(e,t,n){return t in e?$s(e,t,e[t],n):mte()}function $s(e,t,n,r){return dn(n)?gte(t,n.parameters,n.expression):ln(n)?_te(e,n.$ref,r):hte()}function vte(e,t,n){return $s(e,`(anonymous)`,t,n)}function yte(e,t,n){if(jn(t)||rc(t)||Jo(Ks({},t,n)))return;let r={parameter:e,expect:n,actual:t};throw Error(`Argument for parameter ${e} does not satisfy constraint`,{cause:r})}function ec(e,t,n,r,i){let o=sl(e,t,i);return yte(n,o,r),a(e,{[n]:o})}function bte(e,t,n,r,i){let a=sl(e,t,n.extends),o=sl(e,t,n.equals);return me(i,(i,o)=>tc(ec(e,t,n.name,a,i),t,r,o),()=>tc(ec(e,t,n.name,a,o),t,r,[]))}function tc(e,t,n,r){return me(n,(n,i)=>bte(e,t,n,i,r),()=>e)}function xte(e,t,n,r){return tc(e,t,n,r)}function Ste(e){return ne(e.callstack.length,0)?e.callstack[e.callstack.length-1]:``}function Cte(e,t){return N(Ste(e),t)}function wte(e,t,n,r,i,a){let o=xte(e,t,r,a),s=sl(o,$c([...t.callstack,n.$ref],t.visited),i);return sl(o,$c([],[]),s)}function Tte(e,t,n,r,i,a){return a.reduce((a,o)=>[...a,wte(e,t,n,r,i,o)],[])}function Ete(e,t,n,r,i,a){let o=Tte(e,t,n,r,i,pte(r,a,i));return N(o.length,1)?o[0]:ea(o)}function Dte(e,t,n,r){let i=rl(e,t,r),a=vte(e,n,r),o=a[0],s=a[1];return dn(s)?Cte(t,o)?nc(cn(o),i):Ete(e,t,cn(o),s.parameters,s.expression,i):nc(n,i)}function nc(e,t){return zt({"~kind":`Call`},{type:`call`,target:e,arguments:t},{})}function rc(e){return Ht(e,`Call`)}function Ote(e){return Bt(e,[`~immutable`])}function kte(e,t){return Vt(Ote(e),{},t)}function Ate(e,t,n,r){return kte(sl(e,t,n),r)}function jte(e,t){return e(t)}function Mte(e,t){return M(t)?Fr(jte(e,t)):Fr(t)}function Nte(e,t){return ic(e,$i(t))}function Pte(e,t){return Zr(t.map(t=>ic(e,t)))}function ic(e,t){return Vr(t)?Mte(e,t.const):Ho(t)?Nte(e,t.pattern):Qr(t)?Pte(e,t.anyOf):t}function Fte(e,t={}){return Wt(`Capitalize`,[e],t)}function Ite(e,t={}){return Wt(`Lowercase`,[e],t)}function Lte(e,t={}){return Wt(`Uncapitalize`,[e],t)}function Rte(e,t={}){return Wt(`Uppercase`,[e],t)}const zte=e=>e[0].toUpperCase()+e.slice(1),Bte=e=>e.toLowerCase(),Vte=e=>e[0].toLowerCase()+e.slice(1),Hte=e=>e.toUpperCase();function Ute(e,t){return el([e])?Vt(ic(zte,e),{},t):Fte(e,t)}function Wte(e,t){return el([e])?Vt(ic(Bte,e),{},t):Ite(e,t)}function Gte(e,t){return el([e])?Vt(ic(Vte,e),{},t):Lte(e,t)}function Kte(e,t){return el([e])?Vt(ic(Hte,e),{},t):Rte(e,t)}function qte(e,t,n,r){return Ute(sl(e,t,n),r)}function Jte(e,t,n,r){return Wte(sl(e,t,n),r)}function Yte(e,t,n,r){return Gte(sl(e,t,n),r)}function Xte(e,t,n,r){return Kte(sl(e,t,n),r)}function Zte(e,t,n,r,i={}){return Wt(`Conditional`,[e,t,n,r],i)}function Qte(e,t,n,r,i,a){let o=Ks(e,n,r);return Uo(o)?Zr([sl(o.inferred,t,i),sl(e,t,a)]):Go(o)?sl(o.inferred,t,i):sl(e,t,a)}function $te(e,t,n,r,i,a,o){return el([n,r])?Vt(Qte(e,t,n,r,i,a),{},o):Zte(n,r,i,a,o)}function ene(e,t,n,r,i,a,o){return $te(e,t,sl(e,t,n),sl(e,t,r),i,a,o)}function tne(e,t={}){return Wt(`ConstructorParameters`,[e],t)}function nne(e){let t=nn(e)?e.parameters:[];return bi(nl({},$c([],[]),t))}function rne(e,t){return el([e])?Vt(nne(e),{},t):tne(e,t)}function ine(e,t,n,r){return rne(sl(e,t,n),r)}function ane(e,t,n={}){return Wt(`Exclude`,[e,t],n)}function ac(e,t,n){return el([e,t])?Vt(Yi(e,t),{},n):ane(e,t,n)}function one(e,t,n,r,i){return ac(sl(e,t,n),sl(e,t,r),i)}function sne(e,t,n={}){return Wt(`Extract`,[e,t],n)}function cne(e,t){return Jo(Ks({},e,t))?[e]:[]}function lne(e,t){return e.reduce((e,n)=>[...e,...cne(n,t)],[])}function une(e,t){let n=ta(e);return ea(lne(Qr(n)?n.anyOf:[n],t))}function dne(e,t,n){return el([e,t])?Vt(une(e,t),{},n):sne(e,t,n)}function fne(e,t,n,r,i){return dne(sl(e,t,n),sl(e,t,r),i)}function pne(e,t,n={}){return Wt(`Index`,[e,t],n)}function mne(e,t){return sc(Ws(e,t))}function hne(e,t,n){return sc(Xi(e,t,n))}function gne(e,t){let n=F(e).filter(e=>!P(t,e)),r=F(t).filter(t=>!P(e,t)),i=F(e).filter(e=>P(t,e)),o=n.reduce((t,n)=>({...t,[n]:e[n]}),{}),s=r.reduce((e,n)=>({...e,[n]:t[n]}),{}),c=i.reduce((n,r)=>({...n,[r]:Qi([e[r],t[r]])}),{});return a(a(o,s),c)}function _ne(e){return e.reduce((e,t)=>gne(e,sc(t)),{})}function vne(e){return e}function yne(e){return sc(Mi(bi(e)))}function bne(e,t){return F(e).filter(e=>e in t).reduce((n,r)=>({...n,[r]:ea([e[r],t[r]])}),{})}function oc(e,t){return me(e,(e,n)=>oc(n,bne(t,sc(e))),()=>t)}function xne(e){return me(e,(e,t)=>oc(t,sc(e)),()=>Un())}function sc(e){return On(e)?mne(e.$defs,e.$ref):Nn(e)?hne(e.if,e.then,e.else):Ln(e)?_ne(e.allOf):Qr(e)?xne(e.anyOf):xi(e)?yne(e.items):Cn(e)?vne(e.properties):{}}function cc(e){return Sn(sc(e))}const Sne=RegExp(`^(?:0|[1-9][0-9]*)$`);function lc(e){let t=`${e}`;return Sne.test(t)?parseInt(t):e}function Cne(e){return Fr(lc(e))}function uc(e){return e.map(e=>dc(e))}function dc(e){return Ln(e)?In(uc(e.allOf)):Qr(e)?Zr(uc(e.anyOf)):Vr(e)?Cne(e.const):e}function wne(e,t){return Jo(Ks({},dc(t),Gr()))?e:Vr(t)&&N(t.const,`length`)?Gr():mn()}function Tne(e,t){return fc(Ws(e,t))}function Ene(e,t,n){return fc(Xi(e,t,n))}function Dne(e){return fc(Zi(e))}function One(e){return fc(Qi(e))}function kne(e){return[`${e}`]}function Ane(e){return fc($i(e))}function jne(e){return e.reduce((e,t)=>[...e,...fc(t)],[])}function fc(e){return On(e)?Tne(e.$defs,e.$ref):Nn(e)?Ene(e.if,e.then,e.else):Fn(e)?Dne(e.enum):Ln(e)?One(e.allOf):Vr(e)?kne(e.const):Ho(e)?Ane(e.pattern):Qr(e)?jne(e.anyOf):[]}function pc(e){return fc(e)}function mc(e,t){return t.map(t=>hc(e,t))}function hc(e,t){return $t(t)?Qt(hc(e,t.items)):nn(t)?tn(mc(e,t.parameters),hc(e,t.instanceType)):on(t)?an(mc(e,t.parameters),hc(e,t.returnType)):xi(t)?bi(mc(e,t.items)):Qr(t)?Zr(mc(e,t.anyOf)):Ln(t)?In(mc(e,t.allOf)):Na(t)?Sn(e):t}function Mne(e,t){return hc(e,t)}function Nne(e,t){return Mne(e,t in e?e[t]:mn())}function gc(e,t){return t.reduce((t,n)=>[...t,Nne(e,n)],[])}function Pne(e,t){return ea(gc(e,pc(t)))}const Fne=new RegExp(ba);function Ine(e){return e.filter(e=>Fne.test(e))}function Lne(e){return ea(gc(e,Ine(bn(e))))}function Rne(e,t){return Kr(t)?Lne(e):Pne(e,t)}function zne(e){return Fr(lc(e))}function _c(e){return e.map(e=>vc(e))}function vc(e){return Ln(e)?In(_c(e.allOf)):Qr(e)?Zr(_c(e.anyOf)):Vr(e)?zne(e.const):e}function Bne(e,t){return e.reduceRight((e,n,r)=>Jo(Ks({},Fr(r),t))?[n,...e]:e,[])}function Vne(e,t){return na(Bne(e,vc(t)))}function Hne(e){return na(e)}function Une(e,t){return Vr(t)&&N(t.const,`length`)?Fr(e.length):Kr(t)||Mr(t)?Hne(e):Vne(e,t)}function Wne(e,t){return $t(e)?wne(e.items,t):Cn(e)?Rne(e.properties,t):xi(e)?Une(e.items,t):mn()}function Gne(e){return On(e)||Nn(e)||Ln(e)||Qr(e)?cc(e):e}function Kne(e,t,n){return el([e,t])?Vt(Wne(Gne(e),t),{},n):pne(e,t,n)}function qne(e,t,n,r,i){return Kne(sl(e,t,n),sl(e,t,r),i)}function yc(e,t={}){return Wt(`InstanceType`,[e],t)}function Jne(e){return nn(e)?e.instanceType:mn()}function Yne(e,t){return el([e])?Vt(Jne(e),{},t):yc(e,t)}function Xne(e,t,n,r={}){return Yne(sl(e,t,n),r)}function bc(e,t={}){return Wt(`KeyOf`,[e],t)}function xc(){return Zr([Gr(),Yr(),qr()])}function Sc(e){return Gr()}function Cc(e){return e.reduce((e,t)=>Ir(t)?[...e,Fr(lc(t))]:Un(),[])}function Zne(e){return na(Cc(F(e)))}function Qne(e){return Oa(e)}function $ne(e){return na(e.map((e,t)=>Fr(t)))}function ere(e){return pn(e)?xc():$t(e)?Sc(e.items):Cn(e)?Zne(e.properties):Aa(e)?Qne(e):xi(e)?$ne(e.items):mn()}function tre(e){return On(e)||Nn(e)||Ln(e)||Qr(e)?cc(e):e}function nre(e,t){return el([e])?Vt(ere(tre(e)),{},t):bc(e,t)}function rre(e,t,n,r){return nre(sl(e,t,n),r)}function ire(e,t,n,r,i={}){return Wt(`Mapped`,[e,t,n,r],i)}function are(e){return wc($i(e))}function ore(e){return e.reduce((e,t)=>[...e,...wc(t)],[])}function sre(e){return wc(Zi(e))}function cre(e){return k(e)?[Fr(`${e}`)]:[Fr(e)]}function wc(e){return Fn(e)?sre(e.enum):Vr(e)?cre(e.const):Ho(e)?are(e.pattern):Qr(e)?ore(e.anyOf):[e]}function Tc(e){return wc(e)}function Ec(e){return Ho(e)?$i(e.pattern):e}function Dc(e,t,n,r,i,o){let s=a(e,{[n.name]:r}),c=Ec(sl(s,t,i)),l=sl(s,t,o);return zr(c)||Br(c)?{[c.const]:l}:{}}function Oc(e,t,n,r,i,a){return r.reduce((r,o)=>[...r,Dc(e,t,n,o,i,a)],[])}function kc(e){return e.reduce((e,t)=>[...e,Sn(t)],[])}function Ac(e,t,n,r,i,a){return Qi(kc(Oc(e,t,n,Tc(r),i,a)))}function jc(e,t,n,r,i,a,o){return el([r])?Vt(Ac(e,t,n,r,i,a),{},o):ire(n,r,i,a,o)}function Mc(e,t,n,r,i,a,o){return jc(e,t,n,sl(e,t,r),i,a,o)}function Nc(e,t,n){let r=a(e,t);return F(t).filter(e=>n.includes(e)).reduce((e,n)=>({...e,[n]:rte(r,n,t[n])}),{})}function Pc(e,t,n){let r=a(e,t);return F(t).filter(e=>!n.includes(e)).reduce((e,n)=>({...e,[n]:sl(r,$c([],[]),t[n])}),{})}function Fc(e,t,n){let r=Jee(t),i=Nc(e,t,r),a=Pc(e,t,r);return Vt({...i,...a},{},n)}function Ic(e,t,n,r){return Fc(e,n,r)}function Lc(e,t={}){return Wt(`NonNullable`,[e],t)}function Rc(e){return ac(e,Zr([Hr(),Pa()]),{})}function zc(e,t){return el([e])?Vt(Rc(e),{},t):Lc(e,t)}function Bc(e,t,n,r){return zc(sl(e,t,n),r)}function Vc(e,t,n={}){return Wt(`Omit`,[e,t],n)}function Hc(e){let t=cc(e);return Cn(t)?t.properties:Un()}function lre(e,t){return F(e).reduce((n,r)=>t.includes(r)?n:{...n,[r]:e[r]},{})}function ure(e,t){return Sn(lre(Hc(e),pc(t)))}function dre(e,t,n){return el([e,t])?Vt(ure(e,t),{},n):Vc(e,t,n)}function fre(e,t,n,r,i){return dre(sl(e,t,n),sl(e,t,r),i)}function pre(e,t={}){return Wt(`Parameters`,[e],t)}function mre(e){let t=on(e)?e.parameters:[];return bi(nl({},$c([],[]),t))}function hre(e,t){return el([e])?Vt(mre(e),{},t):pre(e,t)}function gre(e,t,n,r){return hre(sl(e,t,n),r)}function _re(e,t={}){return Wt(`Partial`,[e],t)}function vre(e,t){let n=Uc(Ws(e,t));return Dn(a(e,{[t]:n}),t)}function yre(e,t,n){return Uc(Xi(e,t,n))}function bre(e){return Uc(Qi(e))}function xre(e){return Zr(e.map(e=>Uc(e)))}function Sre(e){return Sn(F(e).reduce((t,n)=>({...t,[n]:gn(e[n])}),{}))}function Uc(e){return On(e)?vre(e.$defs,e.$ref):Nn(e)?yre(e.if,e.then,e.else):Ln(e)?bre(e.allOf):Qr(e)?xre(e.anyOf):Cn(e)?Sre(e.properties):Sn({})}function Cre(e,t){return el([e])?Vt(Uc(e),{},t):_re(e,t)}function wre(e,t,n,r){return Cre(sl(e,t,n),r)}function Tre(e,t,n={}){return Wt(`Pick`,[e,t],n)}function Ere(e,t){return F(e).reduce((n,r)=>t.includes(r)?a(n,{[r]:e[r]}):n,{})}function Dre(e,t){return Sn(Ere(Hc(e),pc(t)))}function Ore(e,t,n){return el([e,t])?Vt(Dre(e,t),{},n):Tre(e,t,n)}function kre(e,t,n,r,i){return Ore(sl(e,t,n),sl(e,t,r),i)}function Are(e,t={}){return Wt(`ReadonlyObject`,[e],t)}function jre(e){return fl(Qt(e))}function Mre(e,t){let n=Wc(Ws(e,t));return Dn(a(e,{[t]:n}),t)}function Nre(e,t,n){return Wc(Xi(e,t,n))}function Pre(e){return Wc(Qi(e))}function Fre(e){return Sn(F(e).reduce((t,n)=>({...t,[n]:Tr(e[n])}),{}))}function Ire(e){return fl(bi(e))}function Lre(e){return Zr(e.map(e=>Wc(e)))}function Wc(e){return $t(e)?jre(e.items):On(e)?Mre(e.$defs,e.$ref):Nn(e)?Nre(e.if,e.then,e.else):Ln(e)?Pre(e.allOf):Cn(e)?Fre(e.properties):xi(e)?Ire(e.items):Qr(e)?Lre(e.anyOf):e}function Rre(e,t){return el([e])?Vt(Wc(e),{},t):Are(e)}function zre(e,t,n,r){return Rre(sl(e,t,n),r)}function Bre(e,t,n,r){return t.visited.includes(r)?n:r in e?sl(e,$c(t.callstack,[...t.visited,r]),e[r]):n}function Vre(e,t){let n=Gc(Ws(e,t));return Dn(a(e,{[t]:n}),t)}function Hre(e,t,n){return Gc(Xi(e,t,n))}function Ure(e){return Gc(Qi(e))}function Wre(e){return Zr(e.map(e=>Gc(e)))}function Gre(e){return Sn(F(e).reduce((t,n)=>({...t,[n]:Ai(e[n])}),{}))}function Gc(e){return On(e)?Vre(e.$defs,e.$ref):Nn(e)?Hre(e.if,e.then,e.else):Ln(e)?Ure(e.allOf):Qr(e)?Wre(e.anyOf):Cn(e)?Gre(e.properties):Sn({})}function Kre(e,t={}){return Wt(`Required`,[e],t)}function qre(e,t){return el([e])?Vt(Gc(e),{},t):Kre(e,t)}function Jre(e,t,n,r){return qre(sl(e,t,n),r)}function Yre(e,t={}){return Wt(`ReturnType`,[e],t)}function Xre(e){return on(e)?e.returnType:mn()}function Zre(e,t){return el([e])?Vt(Xre(e),{},t):Yre(e,t)}function Kc(e,t,n,r={}){return Zre(sl(e,t,n),r)}function qc(e,t){return Wt(`With`,[e,t],{})}function Jc(e,t){return Yc(e,t)}function Yc(e,t){return el([e])?Vt(e,{},t):qc(e,t)}function Xc(e,t,n,r){return Yc(sl(e,t,n),r)}function Zc(e){return Ma(e)?xi(e.items)?Qc(e.items.items):jn(e.items)||ln(e.items)?[e]:[mn()]:[e]}function Qc(e){return e.reduce((e,t)=>[...e,...Zc(t)],[])}function $c(e,t){return{callstack:e,visited:t}}function el(e){return me(e,(e,t)=>!ln(e)&&el(t),()=>!0)}function tl(e,t,n){return F(n).reduce((r,i)=>({...r,[i]:sl(e,t,n[i])}),{})}function nl(e,t,n){return Qc(rl(e,t,n))}function rl(e,t,n){return n.map(n=>sl(e,t,n))}function il(e,t){let n=vn(e)?Xt(t,{}):t,r=Er(e)?qt(n,{}):n;return wr(e)?ul(r,{}):r}function al(e,t,n,r,i){return N(n,`AddImmutable`)?dl(e,t,r[0],i):N(n,`RemoveImmutable`)?Ate(e,t,r[0],i):N(n,`AddReadonly`)?Jt(e,t,r[0],i):N(n,`RemoveReadonly`)?Ti(e,t,r[0],i):N(n,`AddOptional`)?Zt(e,t,r[0],i):N(n,`RemoveOptional`)?ki(e,t,r[0],i):N(n,`Capitalize`)?qte(e,t,r[0],i):N(n,`Conditional`)?ene(e,t,r[0],r[1],r[2],r[3],i):N(n,`ConstructorParameters`)?ine(e,t,r[0],i):N(n,`Evaluate`)?cte(e,t,r[0],i):N(n,`Exclude`)?one(e,t,r[0],r[1],i):N(n,`Extract`)?fne(e,t,r[0],r[1],i):N(n,`Index`)?qne(e,t,r[0],r[1],i):N(n,`InstanceType`)?Xne(e,t,r[0],i):N(n,`Interface`)?Uee(e,t,r[0],r[1],i):N(n,`KeyOf`)?rre(e,t,r[0],i):N(n,`Lowercase`)?Jte(e,t,r[0],i):N(n,`Mapped`)?Mc(e,t,r[0],r[1],r[2],r[3],i):N(n,`Module`)?Ic(e,t,r[0],i):N(n,`NonNullable`)?Bc(e,t,r[0],i):N(n,`Pick`)?kre(e,t,r[0],r[1],i):N(n,`Parameters`)?gre(e,t,r[0],i):N(n,`Partial`)?wre(e,t,r[0],i):N(n,`Omit`)?fre(e,t,r[0],r[1],i):N(n,`ReadonlyObject`)?zre(e,t,r[0],i):N(n,`Record`)?ya(e,t,r[0],r[1],i):N(n,`Required`)?Jre(e,t,r[0],i):N(n,`ReturnType`)?Kc(e,t,r[0],i):N(n,`TemplateLiteral`)?nee(e,t,r[0],i):N(n,`Uncapitalize`)?Yte(e,t,r[0],i):N(n,`Uppercase`)?Xte(e,t,r[0],i):N(n,`With`)?Xc(e,t,r[0],r[1]):Wt(n,r,i)}function ol(e,t,n){return il(n,ln(n)?Bre(e,t,n,n.$ref):$t(n)?Qt(sl(e,t,n.items),en(n)):rc(n)?Dte(e,t,n.target,n.arguments):nn(n)?tn(rl(e,t,n.parameters),sl(e,t,n.instanceType),rn(n)):on(n)?an(rl(e,t,n.parameters),sl(e,t,n.returnType),sn(n)):Nn(n)?Mn(sl(e,t,n.if),sl(e,t,n.then),sl(e,t,n.else),Pn(n)):Ln(n)?In(rl(e,t,n.allOf),Rn(n)):Cn(n)?Sn(tl(e,t,n.properties),wn(n)):Aa(n)?Ta(Da(n),sl(e,t,ka(n))):Ma(n)?ja(sl(e,t,n.items)):xi(n)?bi(nl(e,t,n.items),Si(n)):Qr(n)?Zr(rl(e,t,n.anyOf),$r(n)):n)}function sl(e,t,n){return Gt(n)?al(e,t,n.action,n.parameters,n.options):ol(e,t,n)}function cl(e,t){return sl(e,$c([],[]),t)}function ll(e){return Vt(e,{"~immutable":!0},{})}function ul(e,t){return Vt(ll(e),{},t)}function dl(e,t,n,r){return ul(sl(e,t,n),r)}function fl(e,t={}){return ul(e,t)}function pl(e,t={}){return Ys(e,t)}function ml(e,t){let n=qs(e,t);return N(n,`right-inside`)?1:+!!N(n,`disjoint`)}function hl(e,t,n=[]){return me(t,(r,i)=>N(ml(e,r),1)?hl(e,i,[...n,r]):[...n,e,...t],()=>[...n,e])}function gl(e,t=[]){return me(e,(e,n)=>gl(n,hl(e,t)),()=>t)}function _l(e){return gl(e)}var vl=class{queue=[];waiting=[];done=!1;finalResultPromise;resolveFinalResult;isComplete;extractResult;constructor(e,t){this.isComplete=e,this.extractResult=t,this.finalResultPromise=new Promise(e=>{this.resolveFinalResult=e})}push(e){if(this.done)return;this.isComplete(e)&&(this.done=!0,this.resolveFinalResult(this.extractResult(e)));let t=this.waiting.shift();t?t({value:e,done:!1}):this.queue.push(e)}end(e){for(this.done=!0,e!==void 0&&this.resolveFinalResult(e);this.waiting.length>0;)this.waiting.shift()({value:void 0,done:!0})}async*[Symbol.asyncIterator](){for(;;)if(this.queue.length>0)yield this.queue.shift();else if(this.done)return;else{let e=await new Promise(e=>this.waiting.push(e));if(e.done)return;yield e.value}}result(){return this.finalResultPromise}},yl=class extends vl{constructor(){super(e=>e.type===`done`||e.type===`error`,e=>{if(e.type===`done`)return e.message;if(e.type===`error`)return e.error;throw Error(`Unexpected event type for final result`)})}};function bl(e){return P(e,`~refine`)&&S(e[`~refine`])&&fe(e[`~refine`],0,e=>j(e)&&P(e,`check`)&&P(e,`error`)&&E(e.check)&&E(e.error))}function xl(e){return j(e)&&!S(e)}function Sl(e){return w(e)}function Cl(e){return xl(e)||Sl(e)}function wl(e){return P(e,`additionalItems`)&&Cl(e.additionalItems)}function Tl(e){return P(e,`additionalProperties`)&&Cl(e.additionalProperties)}function El(e){return P(e,`allOf`)&&S(e.allOf)&&e.allOf.every(e=>Cl(e))}function Dl(e){return P(e,`$anchor`)&&M(e.$anchor)}function Ol(e){return P(e,`anyOf`)&&S(e.anyOf)&&e.anyOf.every(e=>Cl(e))}function kl(e){return P(e,`const`)}function Al(e){return P(e,`contains`)&&Cl(e.contains)}function jl(e){return P(e,`default`)}function Ml(e){return P(e,`dependencies`)&&j(e.dependencies)&&Object.values(e.dependencies).every(e=>Cl(e)||S(e)&&e.every(e=>M(e)))}function Nl(e){return P(e,`dependentRequired`)&&j(e.dependentRequired)&&Object.values(e.dependentRequired).every(e=>S(e)&&e.every(e=>M(e)))}function Pl(e){return P(e,`dependentSchemas`)&&j(e.dependentSchemas)&&Object.values(e.dependentSchemas).every(e=>Cl(e))}function Fl(e){return P(e,`$dynamicAnchor`)&&M(e.$dynamicAnchor)}function Il(e){return P(e,`$dynamicRef`)&&M(e.$dynamicRef)}function Ll(e){return P(e,`else`)&&Cl(e.else)}function Rl(e){return P(e,`enum`)&&S(e.enum)}function zl(e){return P(e,`exclusiveMaximum`)&&(k(e.exclusiveMaximum)||C(e.exclusiveMaximum))}function Bl(e){return P(e,`exclusiveMinimum`)&&(k(e.exclusiveMinimum)||C(e.exclusiveMinimum))}function Vl(e){return P(e,`format`)&&M(e.format)}function Hl(e){return P(e,`$id`)&&M(e.$id)}function Ul(e){return P(e,`if`)&&Cl(e.if)}function Wl(e){return P(e,`items`)&&(Cl(e.items)||S(e.items)&&e.items.every(e=>Cl(e)))}function Gl(e){return Wl(e)&&S(e.items)}function Kl(e){return P(e,`maximum`)&&(k(e.maximum)||C(e.maximum))}function ql(e){return P(e,`maxContains`)&&k(e.maxContains)}function Jl(e){return P(e,`maxItems`)&&k(e.maxItems)}function Yl(e){return P(e,`maxLength`)&&k(e.maxLength)}function Xl(e){return P(e,`maxProperties`)&&k(e.maxProperties)}function Zl(e){return P(e,`minimum`)&&(k(e.minimum)||C(e.minimum))}function Ql(e){return P(e,`minContains`)&&k(e.minContains)}function $l(e){return P(e,`minItems`)&&k(e.minItems)}function eu(e){return P(e,`minLength`)&&k(e.minLength)}function tu(e){return P(e,`minProperties`)&&k(e.minProperties)}function nu(e){return P(e,`multipleOf`)&&(k(e.multipleOf)||C(e.multipleOf))}function ru(e){return P(e,`not`)&&Cl(e.not)}function iu(e){return P(e,`oneOf`)&&S(e.oneOf)&&e.oneOf.every(e=>Cl(e))}function au(e){return P(e,`pattern`)&&(M(e.pattern)||e.pattern instanceof RegExp)}function ou(e){return P(e,`patternProperties`)&&j(e.patternProperties)&&Object.values(e.patternProperties).every(e=>Cl(e))}function su(e){return P(e,`prefixItems`)&&S(e.prefixItems)&&e.prefixItems.every(e=>Cl(e))}function cu(e){return P(e,`properties`)&&j(e.properties)&&Object.values(e.properties).every(e=>Cl(e))}function lu(e){return P(e,`propertyNames`)&&(j(e.propertyNames)||Cl(e.propertyNames))}function Qre(e){return P(e,`$recursiveAnchor`)&&w(e.$recursiveAnchor)}function uu(e){return Qre(e)&&N(e.$recursiveAnchor,!0)}function du(e){return P(e,`$recursiveRef`)&&M(e.$recursiveRef)}function fu(e){return P(e,`$ref`)&&M(e.$ref)}function pu(e){return P(e,`required`)&&S(e.required)&&e.required.every(e=>M(e))}function mu(e){return P(e,`then`)&&Cl(e.then)}function hu(e){return P(e,`type`)&&(M(e.type)||S(e.type)&&e.type.every(e=>M(e)))}function gu(e){return P(e,`uniqueItems`)&&w(e.uniqueItems)}function _u(e){return P(e,`unevaluatedItems`)&&Cl(e.unevaluatedItems)}function vu(e){return P(e,`unevaluatedProperties`)&&Cl(e.unevaluatedProperties)}function $re(e){return _u(e)||vu(e)||F(e).some(t=>yu(e[t]))}function eie(e){return e.some(e=>yu(e))}function yu(e){return S(e)?eie(e):j(e)?$re(e):!1}function tie(e,t){return yu(t)||F(e).some(t=>yu(e[t]))}var nie=class{constructor(e){this.hasUnevaluated=e}UseUnevaluated(){return this.hasUnevaluated}Push(){return tt(rt(`context`,`Push`),[])}Pop(){return tt(rt(`context`,`Pop`),[])}AddIndex(e){return tt(rt(`context`,`AddIndex`),[e])}AddKey(e){return tt(rt(`context`,`AddKey`),[e])}Merge(e){return tt(rt(`context`,`Merge`),[e])}},bu=class{constructor(){let e=new Set,t=new Set;this.stack=[{indices:e,keys:t}]}Push(){let e=new Set,t=new Set;return this.stack.push({indices:e,keys:t}),!0}Pop(){return this.stack.pop(),!0}AddIndex(e){return this.GetIndices().add(e),!0}AddKey(e){return this.GetKeys().add(e),!0}GetIndices(){return this.stack[this.stack.length-1].indices}GetKeys(){return this.stack[this.stack.length-1].keys}Merge(e){for(let t of e)t.GetIndices().forEach(e=>this.GetIndices().add(e)),t.GetKeys().forEach(e=>this.GetKeys().add(e));return!0}},xu=class extends bu{constructor(e){super(),this.callback=e}AddError(e){return this.callback(e),!1}},Su=class extends xu{constructor(){super(e=>this.errors.push(e)),this.errors=[]}AddError(e){return this.errors.push(e),!1}GetErrors(){return this.errors}};const Cu={identifier:`External`,variables:[]};function wu(e){let t=`External[${Cu.variables.length}]`;return Cu.variables.push(e),t}function rie(){Cu.variables=[]}function iie(){return{...Cu}}function aie(e,t,n,r){return Je(wu(n[`~refine`].map(e=>e)),it(0),[`refinement`,`_`],tt(rt(`refinement`,`check`),[r]))}function oie(e,t,n,r){return fe(n[`~refine`],0,(e,t)=>e.check(r))}function sie(e,t,n,r,i,a){return pe(i[`~refine`],0,(e,i)=>e.check(a)||t.AddError({keyword:`~refine`,schemaPath:n,instancePath:r,params:{index:i,message:e.error(a)}}))}let cie=0;function Tu(){return`var_${cie++}`}function Eu(e){return Wl(e)&&S(e.items)}function lie(e,t,n,r){if(!Eu(n))return it(!0);let[i,a]=[Tu(),Tu()],o=vp(e,t,n.additionalItems,i),s=Ue(a,it(n.items.length)),c=t.AddIndex(a),l=t.UseUnevaluated()?Ee(s,Te(o,c)):Ee(s,o);return tt(rt(r,`every`),[et([i,a],l)])}function uie(e,t,n,r){return!Eu(n)||r.every((r,i)=>re(i,n.items.length)||bp(e,t,n.additionalItems,r)&&t.AddIndex(i))}function die(e,t,n,r,i,a){return!Eu(i)||a.every((a,o)=>{let s=`${n}/additionalItems`,c=`${r}/${o}`;return re(o,i.items.length)||Sp(e,t,s,c,i.additionalItems,a)&&t.AddIndex(o)})}function fie(e){return`^${e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}$`}function Du(e){let t=[];return ou(e)&&t.push(...F(e.patternProperties)),cu(e)&&t.push(...F(e.properties).map(fie)),N(t.length,0)?`(?!)`:`(${t.join(`|`)})`}function pie(e,t,n){return pu(t)&&cu(t)&&!ou(t)&&N(t.additionalProperties,!1)&&N(F(t.properties).length,t.required.length)}function mie(e,t,n){return Ve(rt(tt(rt(`Object`,`getOwnPropertyNames`),[n]),`length`),it(t.required.length))}function hie(e,t,n,r){let[i,a]=[Tu(),Tu()],o=wu(new RegExp(Du(n))),s=vp(e,t,n.additionalProperties,`${r}[${i}]`),c=tt(rt(o,`test`),[i]),l=t.AddKey(i),u=t.UseUnevaluated()?Ee(c,Te(s,l)):Ee(c,s);return Je(Xe(r),it(0),[i,a],u)}function gie(e,t,n,r){return pie(t,n,r)?mie(t,n,r):hie(e,t,n,r)}function _ie(e,t,n,r){let i=new RegExp(Du(n));return fe(F(r),0,(a,o)=>i.test(a)||bp(e,t,n.additionalProperties,r[a])&&t.AddKey(a))}function vie(e,t,n,r,i,a){let o=new RegExp(Du(i)),s=[];return pe(F(a),0,(c,l)=>{let u=`${n}/additionalProperties`,d=`${r}/${c}`,f=new Su,p=o.test(c)||Sp(e,f,u,d,i.additionalProperties,a[c])&&t.AddKey(c);return p||s.push(c),p})||t.AddError({keyword:`additionalProperties`,schemaPath:n,instancePath:r,params:{additionalProperties:s}})}function Ou(e,t,n,r,i){let a=st(`results`,`[]`),o=n.map((e,t)=>st(`context_${t}`,nt(`CheckContext`,[]))),s=n.map((n,i)=>st(`condition_${i}`,tt(et([`context`],yp(e,t,n,r)),[`context_${i}`]))),c=n.map((e,t)=>ct(`condition_${t}`,tt(rt(`results`,`push`),[`context_${t}`]))),l=lt(Te(i,t.Merge(`results`)));return tt(et([],ot([a,...o,...s,...c,l])),[])}function yie(e,t,n,r){return Ou(e,t,n.allOf,r,Ve(rt(`results`,`length`),it(n.allOf.length)))}function bie(e,t,n,r){return ut(n.allOf.map(n=>yp(e,t,n,r)))}function xie(e,t,n,r){return t.UseUnevaluated()?yie(e,t,n,r):bie(e,t,n,r)}function Sie(e,t,n,r){let i=n.allOf.reduce((t,n)=>{let i=new bu;return xp(e,i,n,r)?[...t,i]:t},[]);return N(i.length,n.allOf.length)&&t.Merge(i)}function Cie(e,t,n,r,i,a){let o=[],s=i.allOf.reduce((t,i,s)=>{let c=`${n}/allOf/${s}`,l=new Su,u=Cp(e,l,c,r,i,a);return u||o.push(l),u?[...t,l]:t},[]),c=N(s.length,i.allOf.length)&&t.Merge(s);return c||o.forEach(e=>e.GetErrors().forEach(e=>t.AddError(e))),c}function wie(e,t,n,r){return Ou(e,t,n.anyOf,r,He(rt(`results`,`length`),it(0)))}function Tie(e,t,n,r){return dt(n.anyOf.map(n=>yp(e,t,n,r)))}function Eie(e,t,n,r){return t.UseUnevaluated()?wie(e,t,n,r):Tie(e,t,n,r)}function Die(e,t,n,r){let i=n.anyOf.reduce((t,n)=>{let i=new bu;return xp(e,i,n,r)?[...t,i]:t},[]);return ne(i.length,0)&&t.Merge(i)}function Oie(e,t,n,r,i,a){let o=[],s=i.anyOf.reduce((t,i,s)=>{let c=new Su,l=Cp(e,c,`${n}/anyOf/${s}`,r,i,a);return l||o.push(c),l?[...t,c]:t},[]),c=ne(s.length,0)&&t.Merge(s);return c||o.forEach(e=>e.GetErrors().forEach(e=>t.AddError(e))),c||t.AddError({keyword:`anyOf`,schemaPath:n,instancePath:r,params:{}})}function kie(e,t,n,r){return it(!!n)}function ku(e,t,n,r){return n}function Aie(e,t,n,r,i,a){return ku(e,t,i,a)||t.AddError({keyword:`boolean`,schemaPath:n,instancePath:r,params:{}})}function jie(e,t,n,r){return ce(n.const)?Ve(r,it(n.const)):Qe(r,wu(n.const))}function Au(e,t,n,r){return ce(n.const)?N(r,n.const):Se(r,n.const)}function Mie(e,t,n,r,i,a){return Au(e,t,i,a)||t.AddError({keyword:`const`,schemaPath:n,instancePath:r,params:{allowedValue:i.const}})}function ju(e){return!(Ql(e)&&N(e.minContains,0))}function Nie(e,t,n,r){if(!ju(n))return it(!0);let i=Tu();return Te(De(Ve(rt(r,`length`),it(0))),tt(rt(r,`some`),[et([i],yp(e,t,n.contains,i))]))}function Mu(e,t,n,r){return!ju(n)||!N(r.length,0)&&r.some(r=>xp(e,t,n.contains,r))}function Pie(e,t,n,r,i,a){return Mu(e,t,i,a)||t.AddError({keyword:`contains`,schemaPath:n,instancePath:r,params:{minContains:1}})}function Fie(e,t,n,r){return Ee(Ve(rt(Xe(r),`length`),it(0)),ut(_e(n.dependencies).map(([n,i])=>{let a=De(Ze(r,it(n))),o=yp(e,t,i,r);return Ee(a,S(i)?(e=>ut(e.map(e=>Ze(r,it(e)))))(i):o)})))}function Iie(e,t,n,r){let i=N(F(r).length,0),a=fe(_e(n.dependencies),0,([n,i])=>!P(r,n)||(S(i)?i.every(e=>P(r,e)):xp(e,t,i,r)));return i||a}function Lie(e,t,n,r,i,a){let o=N(F(a).length,0),s=pe(_e(i.dependencies),0,([i,o])=>{let s=`${n}/dependencies/${i}`;return!P(a,i)||(S(o)?o.every(e=>P(a,e)||t.AddError({keyword:`dependencies`,schemaPath:n,instancePath:r,params:{property:i,dependencies:o}})):Cp(e,t,s,r,o,a))});return o||s}function Rie(e,t,n,r){return Ee(Ve(rt(Xe(r),`length`),it(0)),ut(_e(n.dependentRequired).map(([e,t])=>Ee(De(Ze(r,it(e))),ut(t.map(e=>Ze(r,it(e))))))))}function zie(e,t,n,r){let i=N(F(r).length,0),a=fe(_e(n.dependentRequired),0,([e,t])=>!P(r,e)||t.every(e=>P(r,e)));return i||a}function Bie(e,t,n,r,i,a){let o=N(F(a).length,0),s=pe(_e(i.dependentRequired),0,([e,i])=>!P(a,e)||pe(i,0,o=>P(a,o)||t.AddError({keyword:`dependentRequired`,schemaPath:n,instancePath:r,params:{property:e,dependencies:i}})));return o||s}function Vie(e,t,n,r){return Ee(Ve(rt(Xe(r),`length`),it(0)),ut(_e(n.dependentSchemas).map(([n,i])=>Ee(De(Ze(r,it(n))),yp(e,t,i,r)))))}function Hie(e,t,n,r){let i=N(F(r).length,0),a=fe(_e(n.dependentSchemas),0,([n,i])=>!P(r,n)||xp(e,t,i,r));return i||a}function Uie(e,t,n,r,i,a){let o=N(F(a).length,0),s=pe(_e(i.dependentSchemas),0,([i,o])=>{let s=`${n}/dependentSchemas/${i}`;return!P(a,i)||Cp(e,t,s,r,o,a)});return o||s}function Wie(e,t,n,r){return Np(e,t,e.DynamicRef(n)??!1,r)}function Gie(e,t,n,r){let i=e.DynamicRef(n)??!1;return Cl(i)&&xp(e,t,i,r)}function Kie(e,t,n,r,i,a){let o=e.DynamicRef(i)??!1;return Cl(o)&&Cp(e,t,`#`,r,o,a)}function qie(e,t,n,r){return dt(n.enum.map(e=>ce(e)?Ve(r,it(e)):Qe(r,wu(e))))}function Nu(e,t,n,r){return n.enum.some(e=>ce(e)?N(r,e):Se(r,e))}function Jie(e,t,n,r,i,a){return Nu(e,t,i,a)||t.AddError({keyword:`enum`,schemaPath:n,instancePath:r,params:{allowedValues:i.enum}})}function Yie(e,t,n,r){return Ue(r,it(n.exclusiveMaximum))}function Pu(e,t,n,r){return re(r,n.exclusiveMaximum)}function Xie(e,t,n,r,i,a){return Pu(e,t,i,a)||t.AddError({keyword:`exclusiveMaximum`,schemaPath:n,instancePath:r,params:{comparison:`<`,limit:i.exclusiveMaximum}})}function Zie(e,t,n,r){return He(r,it(n.exclusiveMinimum))}function Fu(e,t,n,r){return ne(r,n.exclusiveMinimum)}function Qie(e,t,n,r,i,a){return Fu(e,t,i,a)||t.AddError({keyword:`exclusiveMinimum`,schemaPath:n,instancePath:r,params:{comparison:`>`,limit:i.exclusiveMinimum}})}const $ie=[0,31,28,31,30,31,30,31,31,30,31,30,31],eae=/^(\d\d\d\d)-(\d\d)-(\d\d)$/;function tae(e){return e%4==0&&(e%100!=0||e%400==0)}function Iu(e){let t=eae.exec(e);if(!t)return!1;let n=+t[1],r=+t[2],i=+t[3];return r>=1&&r<=12&&i>=1&&i<=(r===2&&tae(n)?29:$ie[r])}const nae=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(?:Z|([+-])(\d\d):(\d\d))?$/i;function Lu(e,t=!0){let n=nae.exec(e);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=n[4]===`-`?-1:1,s=+(n[5]||0),c=+(n[6]||0);if(s>23||c>59||t&&!n[4]&&e.toLowerCase().indexOf(`z`)===-1)return!1;if(r<=23&&i<=59&&a<60)return!0;let l=i-c*o,u=r-s*o-+(l<0);return(u===23||u===-1)&&(l===59||l===-1)&&a<61}function Ru(e,t=!0){let n=e.split(/T/i);return n.length===2&&Iu(n[0])&&Lu(n[1],t)}const rae=/^P((\d+Y(\d+M(\d+D)?)?|\d+M(\d+D)?|\d+D)(T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S))?|T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S)|\d+W)$/;function zu(e){return rae.test(e)}const iae=/^(?!.*\.\.)[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[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;function Bu(e){return iae.test(e)}function aae(e,t,n){e=n?Math.floor(e/700):e>>1,e+=Math.floor(e/t);let r=0;for(;e>455;)e=Math.floor(e/35),r+=36;return r+Math.floor(36*e/(e+38))}function oae(e){let t=[],n=128,r=0,i=72,a=e.lastIndexOf(`-`);if(a>0)for(let n=0;n=128)throw Error(`Invalid punycode: non-basic before delimiter`);t.push(r)}let o=a<0?0:a+1;for(;o=e.length)throw Error(`Invalid punycode: unexpected end of input`);let t=e.charCodeAt(o++),n;if(t>=97&&t<=122)n=t-97;else if(t>=48&&t<=57)n=t-48+26;else if(t>=65&&t<=90)Un();else throw Error(`Invalid punycode: bad digit character`);r+=n*s;let a=c<=i?1:c>=i+26?26:c-i;if(n=1632&&e<=1641}function yae(e){return e>=1776&&e<=1785}function Vu(e){return fae.has(e)}function Hu(e){if(e.length===0)return Un();let t=[...e].map(e=>e.codePointAt(0)),n=t.length;if(t[0]===45||t[n-1]===45||n>=4&&t[2]===45&&t[3]===45||uae(t[0]))return!1;let r=!1,i=!1,a=!1;for(let e=0;e=4&&e.charCodeAt(2)===45&&e.charCodeAt(3)===45)return!1;for(let t=0;t=97&&n<=122||n>=65&&n<=90||n>=48&&n<=57||n===45))return!1}return!0}function Uu(e){return e.toLowerCase().startsWith(`xn--`)}function Wu(e){try{let t=e.slice(4).toLowerCase();if(t.lastIndexOf(`-`)===0)return!1;let n=oae(t);return n?Hu(n):!1}catch{return!1}}function xae(e){return e.length===0||e.length>63?!1:Uu(e)?Wu(e):Hu(e)}function Sae(e){return e.length===0||e.length>63?!1:Uu(e)?Wu(e):bae(e)}function Gu(e){if(e.length===0||e.length>253||e.charCodeAt(e.length-1)===46)return!1;for(let t of e.split(`.`))if(!Sae(t))return!1;return!0}const Cae=/^(?!.*\.\.)[\p{L}\p{N}!#$%&'*+/=?^_`{|}~-]+(?:\.[\p{L}\p{N}!#$%&'*+/=?^_`{|}~-]+)*@[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,61}[\p{L}\p{N}])?(?:\.[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,61}[\p{L}\p{N}])?)*$/iu;function Ku(e){return Cae.test(e)}function qu(e){if(e.length===0||e.includes(` `))return!1;let t=e.normalize(`NFC`).replace(/[\u002E\u3002\uFF0E\uFF61]/g,`.`);if(t.length>253)return!1;for(let e of t.split(`.`))if(!xae(e))return!1;return!0}function Ju(e,t,n){let r=0,i=0,a=0,o=0;for(let s=t;s255||o===48&&a>1)return!1;r++,i=0,a=0,o=0}else if(t>=48&&t<=57)a===0&&(o=t),i=i*10+(t-48),a++;else return!1}return r===3&&a>0&&i<=255&&!(o===48&&a>1)}function Yu(e){return Ju(e,0,e.length)}function wae(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Xu(e){let t=e.length;if(t===0)return!1;let n=0,r=!1,i=0;if(e.charCodeAt(0)===58&&e.charCodeAt(1)===58){if(t===2)return!0;r=!0,i=2}for(;i4)return!1;if(n++,i===t)break;if(s!==58)return!1;if(i++,e.charCodeAt(i)===58){if(r||e.charCodeAt(i+1)===58)return!1;if(r=!0,i++,i===t)break}}return r?n<=7:n===8}function Zu(e){try{return new URL(e,`http://example.com`),!0}catch{return!1}}function Qu(e){if(e.includes(` `)||e.includes(`\\`)||/[\x00-\x1F\x7F]/.test(e)||/%(?![0-9a-fA-F]{2})/.test(e))return!1;if(e===``)return!0;let t=e.indexOf(`:`);return t>0&&/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(e.substring(0,t))?Zu(e):e.match(/^([a-zA-Z][a-zA-Z0-9+\-.]*)(\/\/)/)&&t===-1?!1:Zu(e)}function $u(e){try{return new URL(e),!0}catch{return!1}}const Tae=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;function ed(e){return Tae.test(e)}const Eae=/^(?:\/(?:[^~/]|~0|~1)*)*$/;function td(e){return Eae.test(e)}function nd(e){if(e.length===0)return!1;try{return new RegExp(e),!0}catch{return!1}}const Dae=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;function rd(e){return Dae.test(e)}const Oae=/^(?!.*[^\x00-\x7F])(?!.*\\)(?:(?:[a-z][a-z0-9+\-.]*:)?(?:\/\/[^\s[\]{}<>^`|]*)?|[^\s[\]{}<>^`|]*)(?:\?[^\s[\]{}<>^`|]*)?(?:#[^\s[\]{}<>^`|]*)?$/i;function id(e){return Oae.test(e)}const kae=/^(?:(?:[^\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;function ad(e){return kae.test(e)}function od(e){return e>=97&&e<=122||e>=65&&e<=90}function sd(e){return od(e)||e>=48&&e<=57}function cd(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Aae(e){return sd(e)||e===43||e===45||e===46}function ld(e){return sd(e)||e===45||e===46||e===95||e===126}function ud(e){return e===33||e===36||e===38||e===39||e===40||e===41||e===42||e===43||e===44||e===59||e===61}function jae(e){return ld(e)||ud(e)||e===58||e===64}function dd(e){let t=e.length;if(t===0||!od(e.charCodeAt(0)))return!1;let n=1;for(;n=i||!cd(e.charCodeAt(t+1))||!cd(e.charCodeAt(t+2)))return!1;t+=2}else if(!ld(n)&&!ud(n)&&n!==58)return!1}n=i+1}if(e.charCodeAt(n)===91){for(n++;n57)return!1;n++}}for(;n=t||!cd(e.charCodeAt(n+1))||!cd(e.charCodeAt(n+2)))return!1;n+=2}else if(r>127)return!1;else if(!(jae(r)||r===47||r===63||r===35))return!1;n++}return!0}const Mae=/^(?: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;function fd(e){return Mae.test(e)}const Nae=/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;function pd(e){return Nae.test(e)}const md=new Map;function hd(){md.clear()}function Pae(){return[...md.entries()]}function Fae(e,t){md.set(e,t)}function Iae(e){return md.has(e)}function Lae(e){return md.get(e)}function gd(e,t){return md.get(e)?.(t)??!0}function _d(){hd(),md.set(`date-time`,Ru),md.set(`date`,Iu),md.set(`duration`,zu),md.set(`email`,Bu),md.set(`hostname`,Gu),md.set(`idn-email`,Ku),md.set(`idn-hostname`,qu),md.set(`ipv4`,Yu),md.set(`ipv6`,Xu),md.set(`iri-reference`,Qu),md.set(`iri`,$u),md.set(`json-pointer-uri-fragment`,ed),md.set(`json-pointer`,td),md.set(`regex`,nd),md.set(`relative-json-pointer`,rd),md.set(`time`,Lu),md.set(`uri-reference`,id),md.set(`uri-template`,ad),md.set(`uri`,dd),md.set(`url`,fd),md.set(`uuid`,pd)}_d();var Rae=n({Clear:()=>hd,Entries:()=>Pae,Get:()=>Lae,Has:()=>Iae,IsDate:()=>Iu,IsDateTime:()=>Ru,IsDuration:()=>zu,IsEmail:()=>Bu,IsHostname:()=>Gu,IsIPv4:()=>Yu,IsIPv6:()=>Xu,IsIdnEmail:()=>Ku,IsIdnHostname:()=>qu,IsIri:()=>$u,IsIriReference:()=>Qu,IsJsonPointer:()=>td,IsJsonPointerUriFragment:()=>ed,IsRegex:()=>nd,IsRelativeJsonPointer:()=>rd,IsTime:()=>Lu,IsUri:()=>dd,IsUriReference:()=>id,IsUriTemplate:()=>ad,IsUrl:()=>fd,IsUuid:()=>pd,Reset:()=>_d,Set:()=>Fae,Test:()=>gd});function zae(e,t,n,r){return tt(rt(`Format`,`Test`),[it(n.format),r])}function vd(e,t,n,r){return gd(n.format,r)}function Bae(e,t,n,r,i,a){return vd(e,t,i,a)||t.AddError({keyword:`format`,schemaPath:n,instancePath:r,params:{format:i.format}})}function Vae(e,t,n,r){let i=!mu(n)||n.then,a=!Ll(n)||n.else;return at(yp(e,t,n.if,r),yp(e,t,i,r),yp(e,t,a,r))}function Hae(e,t,n,r){let i=!mu(n)||n.then,a=!Ll(n)||n.else;return xp(e,t,n.if,r)?xp(e,t,i,r):xp(e,t,a,r)}function Uae(e,t,n,r,i,a){let o=!mu(i)||i.then,s=!Ll(i)||i.else,c=new Su,l=Cp(e,c,`${n}/if`,r,i.if,a)?Cp(e,c,`${n}/then`,r,o,a)||t.AddError({keyword:`if`,schemaPath:n,instancePath:r,params:{failingKeyword:`then`}}):Cp(e,t,`${n}/else`,r,s,a)||t.AddError({keyword:`if`,schemaPath:n,instancePath:r,params:{failingKeyword:`else`}});return l&&t.Merge([c]),l}function Wae(e,t,n,r){return ut(n.items.map((n,i)=>{let a=We(rt(r,`length`),it(i)),o=vp(e,t,n,`${r}[${i}]`),s=t.AddIndex(it(i));return Ee(a,t.UseUnevaluated()?Te(o,s):o)}))}function Gae(e,t,n,r){return fe(n.items,0,(n,i)=>ie(r.length,i)||bp(e,t,n,r[i])&&t.AddIndex(i))}function Kae(e,t,n,r,i,a){return pe(i.items,0,(i,o)=>{let s=`${n}/items/${o}`,c=`${r}/${o}`;return ie(a.length,o)||Sp(e,t,s,c,i,a[o])&&t.AddIndex(o)})}function yd(e,t,n,r){let i=su(n)?n.prefixItems.length:0,a=vp(e,t,n.items,`element`),o=t.AddIndex(`index`),s=t.UseUnevaluated()?Te(a,o):a;return Je(r,it(i),[`element`,`index`],s)}function bd(e,t,n,r){return fe(r,su(n)?n.prefixItems.length:0,(r,i)=>bp(e,t,n.items,r)&&t.AddIndex(i))}function xd(e,t,n,r,i,a){return pe(a,su(i)?i.prefixItems.length:0,(a,o)=>Sp(e,t,`${n}/items`,`${r}/${o}`,i.items,a)&&t.AddIndex(o))}function Sd(e,t,n,r){return Gl(n)?Wae(e,t,n,r):yd(e,t,n,r)}function Cd(e,t,n,r){return Gl(n)?Gae(e,t,n,r):bd(e,t,n,r)}function wd(e,t,n,r,i,a){return Gl(i)?Kae(e,t,n,r,i,a):xd(e,t,n,r,i,a)}function Td(e){return Al(e)}function Ed(e,t,n,r){if(!Td(n))return it(!0);let[i,a]=[Tu(),Tu()];return We(tt(rt(r,`reduce`),[et([i,a],at(yp(e,t,n.contains,a),ft(i),i)),it(0)]),it(n.maxContains))}function Dd(e,t,n,r){return!Td(n)||ie(r.reduce((r,i)=>xp(e,t,n.contains,i)?++r:r,0),n.maxContains)}function Od(e,t,n,r,i,a){let o=Ql(i)?i.minContains:1;return Dd(e,t,i,a)||t.AddError({keyword:`contains`,schemaPath:n,instancePath:r,params:{minContains:o,maxContains:i.maxContains}})}function kd(e,t,n,r){return We(r,it(n.maximum))}function Ad(e,t,n,r){return ie(r,n.maximum)}function jd(e,t,n,r,i,a){return Ad(e,t,i,a)||t.AddError({keyword:`maximum`,schemaPath:n,instancePath:r,params:{comparison:`<=`,limit:i.maximum}})}function Md(e,t,n,r){return We(rt(r,`length`),it(n.maxItems))}function Nd(e,t,n,r){return ie(r.length,n.maxItems)}function Pd(e,t,n,r,i,a){return Nd(e,t,i,a)||t.AddError({keyword:`maxItems`,schemaPath:n,instancePath:r,params:{limit:i.maxItems}})}function Fd(e,t,n,r){return qe(r,it(n.maxLength))}function Id(e,t,n,r){return ue(r,n.maxLength)}function Ld(e,t,n,r,i,a){return Id(e,t,i,a)||t.AddError({keyword:`maxLength`,schemaPath:n,instancePath:r,params:{limit:i.maxLength}})}function Rd(e,t,n,r){return We(rt(Xe(r),`length`),it(n.maxProperties))}function zd(e,t,n,r){return ie(F(r).length,n.maxProperties)}function Bd(e,t,n,r,i,a){return zd(e,t,i,a)||t.AddError({keyword:`maxProperties`,schemaPath:n,instancePath:r,params:{limit:i.maxProperties}})}function Vd(e){return Al(e)}function Hd(e,t,n,r){if(!Vd(n))return it(!0);let[i,a]=[Tu(),Tu()];return Ge(tt(rt(r,`reduce`),[et([i,a],at(yp(e,t,n.contains,a),ft(i),i)),it(0)]),it(n.minContains))}function Ud(e,t,n,r){return!Vd(n)||ae(r.reduce((r,i)=>xp(e,t,n.contains,i)?++r:r,0),n.minContains)}function Wd(e,t,n,r,i,a){return Ud(e,t,i,a)||t.AddError({keyword:`contains`,schemaPath:n,instancePath:r,params:{minContains:i.minContains}})}function Gd(e,t,n,r){return Ge(r,it(n.minimum))}function Kd(e,t,n,r){return ae(r,n.minimum)}function qd(e,t,n,r,i,a){return Kd(e,t,i,a)||t.AddError({keyword:`minimum`,schemaPath:n,instancePath:r,params:{comparison:`>=`,limit:i.minimum}})}function Jd(e,t,n,r){return Ge(rt(r,`length`),it(n.minItems))}function Yd(e,t,n,r){return ae(r.length,n.minItems)}function Xd(e,t,n,r,i,a){return Yd(e,t,i,a)||t.AddError({keyword:`minItems`,schemaPath:n,instancePath:r,params:{limit:i.minItems}})}function Zd(e,t,n,r){return Ke(r,it(n.minLength))}function Qd(e,t,n,r){return de(r,n.minLength)}function $d(e,t,n,r,i,a){return Qd(e,t,i,a)||t.AddError({keyword:`minLength`,schemaPath:n,instancePath:r,params:{limit:i.minLength}})}function ef(e,t,n,r){return Ge(rt(Xe(r),`length`),it(n.minProperties))}function tf(e,t,n,r){return ae(F(r).length,n.minProperties)}function nf(e,t,n,r,i,a){return tf(e,t,i,a)||t.AddError({keyword:`minProperties`,schemaPath:n,instancePath:r,params:{limit:i.minProperties}})}function rf(e,t,n,r){return pt(r,it(n.multipleOf))}function af(e,t,n,r){return oe(r,n.multipleOf)}function of(e,t,n,r,i,a){return af(e,t,i,a)||t.AddError({keyword:`multipleOf`,schemaPath:n,instancePath:r,params:{multipleOf:i.multipleOf}})}function sf(e,t,n,r){return Ou(e,t,[n.not],r,De(Ve(rt(`results`,`length`),it(1))))}function cf(e,t,n,r){return De(yp(e,t,n.not,r))}function lf(e,t,n,r){return t.UseUnevaluated()?sf(e,t,n,r):cf(e,t,n,r)}function uf(e,t,n,r){let i=new bu;return!xp(e,i,n.not,r)&&t.Merge([i])}function df(e,t,n,r,i,a){return uf(e,t,i,a)||t.AddError({keyword:`not`,schemaPath:n,instancePath:r,params:{}})}function ff(e,t,n,r){return Ou(e,t,n.oneOf,r,Ve(rt(`results`,`length`),it(1)))}function pf(e,t,n,r){return Ve(tt(rt($e(n.oneOf.map(n=>yp(e,t,n,r))),`reduce`),[et([`count`,`result`],at(Ve(`result`,it(!0)),ft(`count`),`count`)),it(0)]),it(1))}function mf(e,t,n,r){return t.UseUnevaluated()?ff(e,t,n,r):pf(e,t,n,r)}function hf(e,t,n,r){let i=n.oneOf.reduce((t,n)=>{let i=new bu;return xp(e,i,n,r)?[...t,i]:t},[]);return N(i.length,1)&&t.Merge(i)}function gf(e,t,n,r,i,a){let o=[],s=[],c=i.oneOf.reduce((t,i,c)=>{let l=new Su,u=Cp(e,l,`${n}/oneOf/${c}`,r,i,a);return u&&s.push(c),u||o.push(l),u?[...t,l]:t},[]),l=N(c.length,1)&&t.Merge(c);return!l&&N(s.length,0)&&o.forEach(e=>e.GetErrors().forEach(e=>t.AddError(e))),l||t.AddError({keyword:`oneOf`,schemaPath:n,instancePath:r,params:{passingSchemas:s}})}function _f(e,t,n,r){return tt(rt(wu(M(n.pattern)?new RegExp(n.pattern,`u`):n.pattern),`test`),[r])}function vf(e,t,n,r){return(M(n.pattern)?new RegExp(n.pattern,`u`):n.pattern).test(r)}function yf(e,t,n,r,i,a){return vf(e,t,i,a)||t.AddError({keyword:`pattern`,schemaPath:n,instancePath:r,params:{pattern:i.pattern}})}function bf(e,t,n,r){return ut(_e(n.patternProperties).map(([n,i])=>{let[a,o]=[Tu(),Tu()],s=De(tt(rt(wu(new RegExp(n,`u`)),`test`),[a])),c=vp(e,t,i,o),l=t.AddKey(a),u=t.UseUnevaluated()?Ee(s,Te(c,l)):Ee(s,c);return Je(Ye(r),it(0),[`[${a}, ${o}]`,`_`],u)}))}function xf(e,t,n,r){return fe(_e(n.patternProperties),0,([n,i])=>{let a=new RegExp(n,`u`);return fe(_e(r),0,([n,r])=>!a.test(n)||bp(e,t,i,r)&&t.AddKey(n))})}function Sf(e,t,n,r,i,a){return pe(_e(i.patternProperties),0,([i,o])=>{let s=`${n}/patternProperties/${i}`,c=new RegExp(i,`u`);return pe(_e(a),0,([n,i])=>{let a=`${r}/${n}`;return!c.test(n)||Sp(e,t,s,a,o,i)&&t.AddKey(n)})})}function Cf(e,t,n,r){return ut(n.prefixItems.map((n,i)=>{let a=We(rt(r,`length`),it(i)),o=vp(e,t,n,`${r}[${i}]`),s=t.AddIndex(it(i));return Ee(a,t.UseUnevaluated()?Te(o,s):o)}))}function wf(e,t,n,r){return N(r.length,0)||fe(n.prefixItems,0,(n,i)=>ie(r.length,i)||bp(e,t,n,r[i])&&t.AddIndex(i))}function Tf(e,t,n,r,i,a){return N(a.length,0)||pe(i.prefixItems,0,(i,o)=>{let s=`${n}/prefixItems/${o}`,c=`${r}/${o}`;return ie(a.length,o)||Sp(e,t,s,c,i,a[o])&&t.AddIndex(o)})}function Ef(e,t){return e.includes(t)||It().exactOptionalPropertyTypes}function Df(e,t){return Re(rt(e,t))}function Of(e,t){return te(e[t])}function kf(e,t,n,r){let i=pu(n)?n.required:[];return ut(_e(n.properties).map(([n,a])=>{let o=De(Ze(r,it(n))),s=vp(e,t,a,rt(r,n)),c=t.AddKey(it(n)),l=t.UseUnevaluated()?Te(s,c):s,u=i.includes(n)?l:Ee(o,l);return Ef(i,n)?u:Ee(Df(r,n),u)}))}function Af(e,t,n,r){let i=pu(n)?n.required:[];return fe(_e(n.properties),0,([n,a])=>{let o=!P(r,n)||bp(e,t,a,r[n])&&t.AddKey(n);return Ef(i,n)?o:Of(r,n)||o})}function jf(e,t,n,r,i,a){let o=pu(i)?i.required:[];return pe(_e(i.properties),0,([i,s])=>{let c=`${n}/properties/${i}`,l=`${r}/${i}`,u=()=>!P(a,i)||Sp(e,t,c,l,s,a[i])&&t.AddKey(i);return Ef(o,i)?u():Of(a,i)||u()})}function Mf(e,t,n,r){let[i,a]=[Tu(),Tu()];return Je(Xe(r),it(0),[i,a],yp(e,t,n.propertyNames,i))}function Nf(e,t,n,r){return fe(F(r),0,(r,i)=>xp(e,t,n.propertyNames,r))}function Pf(e,t,n,r,i,a){let o=[];return pe(F(a),0,(t,a)=>{let s=`${r}/${t}`,c=`${n}/propertyNames`,l=Cp(e,new Su,c,s,i.propertyNames,t);return l||o.push(t),l})||t.AddError({keyword:`propertyNames`,schemaPath:n,instancePath:r,params:{propertyNames:o}})}function Ff(e,t,n,r){return Np(e,t,e.RecursiveRef(n)??!1,r)}function If(e,t,n,r){let i=e.RecursiveRef(n)??!1;return Cl(i)&&xp(e,t,i,r)}function Lf(e,t,n,r,i,a){let o=e.RecursiveRef(i)??!1;return Cl(o)&&Cp(e,t,`#`,r,o,a)}function Rf(e,t,n,r){let i=et([`context`,`value`],Np(e,t,n,`value`));return tt(et([`context`,`value`],ot([st(`nextContext`,nt(`CheckContext`,[])),st(`result`,tt(i,[`nextContext`,`value`])),ct(`result`,t.Merge(`[nextContext]`)),lt(`result`)])),[`context`,r])}function zf(e,t,n,r){return Np(e,t,n,r)}function Bf(e,t,n,r){let i=e.Ref(n)??!1;return t.UseUnevaluated()?Rf(e,t,i,r):zf(e,t,i,r)}function Vf(e,t,n,r){let i=e.Ref(n)??!1,a=new bu,o=Cl(i)&&xp(e,a,i,r);return o&&t.Merge([a]),o}function Hf(e,t,n,r,i,a){let o=e.Ref(i)??!1,s=new Su,c=Cl(o)&&Cp(e,s,`#`,r,o,a);return c&&t.Merge([s]),c||s.GetErrors().forEach(e=>t.AddError(e)),c}function Uf(e,t,n,r){return ut(n.required.map(e=>Ze(r,it(e))))}function Wf(e,t,n,r){return fe(n.required,0,e=>P(r,e))}function Gf(e,t,n,r,i,a){let o=[];return pe(i.required,0,e=>{let t=P(a,e);return t||o.push(e),t})||t.AddError({keyword:`required`,schemaPath:n,instancePath:r,params:{requiredProperties:o}})}function Kf(e,t,n,r){return N(n,`object`)?Pe(r):N(n,`array`)?Oe(r):N(n,`boolean`)?Ae(r):N(n,`integer`)?je(r):N(n,`number`)?Ne(r):N(n,`null`)?Me(r):N(n,`string`)?Ie(r):N(n,`bigint`)?ke(r):N(n,`constructor`)?Be(r):N(n,`function`)?ze(r):N(n,`symbol`)?Le(r):N(n,`undefined`)||N(n,`void`)?Re(r):it(!0)}function qf(e,t,n,r,i){return N(n,`object`)?A(i):N(n,`array`)?S(i):N(n,`boolean`)?w(i):N(n,`integer`)?D(i):N(n,`number`)?k(i):N(n,`null`)?O(i):N(n,`string`)?M(i):N(n,`bigint`)?C(i):N(n,`constructor`)?T(i):N(n,`function`)?E(i):N(n,`symbol`)?ee(i):N(n,`undefined`)?te(i):!N(n,`void`)||te(i)}function Jf(e,t,n,r){return dt(n.map(n=>Kf(e,t,n,r)))}function Yf(e,t,n,r,i){return n.some(n=>qf(e,t,n,r,i))}function Xf(e,t,n,r){return S(n.type)?Jf(e,t,n.type,r):Kf(e,t,n.type,r)}function Zf(e,t,n,r){return S(n.type)?Yf(e,t,n.type,n,r):qf(e,t,n.type,n,r)}function Qf(e,t,n,r,i,a){return(S(i.type)?Yf(e,t,i.type,i,a):qf(e,t,i.type,i,a))||t.AddError({keyword:`type`,schemaPath:n,instancePath:r,params:{type:i.type}})}function $f(e,t,n,r){let[i,a]=[Tu(),Tu()],o=tt(rt(`context`,`GetIndices`),[]),s=tt(rt(`indices`,`has`),[i]),c=yp(e,t,n.unevaluatedItems,a),l=tt(rt(`context`,`AddIndex`),[i]),u=Je(r,it(0),[a,i],Te(Ee(s,c),l));return tt(et([`context`],ot([st(`indices`,o),lt(u)])),[`context`])}function ep(e,t,n,r){let i=t.GetIndices();return fe(r,0,(r,a)=>(i.has(a)||xp(e,t,n.unevaluatedItems,r))&&t.AddIndex(a))}function tp(e,t,n,r,i,a){let o=t.GetIndices(),s=[];return pe(a,0,(a,c)=>{let l=new Su,u=(o.has(c)||Cp(e,l,n,r,i.unevaluatedItems,a))&&t.AddIndex(c);return u||s.push(c),u})||t.AddError({keyword:`unevaluatedItems`,schemaPath:n,instancePath:r,params:{unevaluatedItems:s}})}function np(e,t,n,r){let[i,a]=[Tu(),Tu()],o=tt(rt(`context`,`GetKeys`),[]),s=tt(rt(`keys`,`has`),[i]),c=tt(rt(`context`,`AddKey`),[i]),l=yp(e,t,n.unevaluatedProperties,a),u=Je(Ye(r),it(0),[`[${i}, ${a}]`,`_`],Ee(s,Te(l,c)));return tt(et([`context`],ot([st(`keys`,o),lt(u)])),[`context`])}function rp(e,t,n,r){let i=t.GetKeys();return fe(_e(r),0,([r,a])=>i.has(r)||xp(e,t,n.unevaluatedProperties,a)&&t.AddKey(r))}function ip(e,t,n,r,i,a){let o=t.GetKeys(),s=[];return pe(_e(a),0,([a,c])=>{let l=new Su,u=o.has(a)||Cp(e,l,n,r,i.unevaluatedProperties,c)&&t.AddKey(a);return u||s.push(a),u})||t.AddError({keyword:`unevaluatedProperties`,schemaPath:n,instancePath:r,params:{unevaluatedProperties:s}})}function ap(e){return!N(e.uniqueItems,!1)}function op(e,t,n,r){return ap(n)?Ve(rt(nt(`Set`,[tt(rt(r,`map`),[rt(`Hashing`,`Hash`)])]),`size`),rt(r,`length`)):it(!0)}function sp(e,t,n,r){if(!ap(n))return!0;let i=new Set(r.map(yr)).size,a=r.length;return N(i,a)}function cp(e,t,n,r,i,a){if(!ap(i))return!0;let o=new Set,s=a.reduce((e,t,n)=>{let r=yr(t);return o.has(r)?[...e,n]:(o.add(r),e)},[]);return N(s.length,0)||t.AddError({keyword:`uniqueItems`,schemaPath:n,instancePath:r,params:{duplicateItems:s}})}function lp(e,t){return hu(e)&&(S(e.type)&&ne(e.type.length,0)&&fe(e.type,0,e=>N(e,t))||N(e.type,t))}function up(e){return lp(e,`object`)}function dp(e){return xl(e)&&(Tl(e)||Ml(e)||Nl(e)||Pl(e)||cu(e)||ou(e)||lu(e)||tu(e)||Xl(e)||pu(e)||vu(e))}function fp(e){return lp(e,`array`)}function pp(e){return xl(e)&&(wl(e)||Wl(e)||Al(e)||ql(e)||Jl(e)||Ql(e)||$l(e)||su(e)||_u(e)||gu(e))}function mp(e){return lp(e,`string`)}function hp(e){return xl(e)&&(eu(e)||Yl(e)||Vl(e)||au(e))}function gp(e){return lp(e,`number`)||lp(e,`bigint`)}function _p(e){return xl(e)&&(Zl(e)||Kl(e)||zl(e)||Bl(e)||nu(e))}function vp(e,t,n,r){return t.UseUnevaluated()?Te(Te(t.Push(),yp(e,t,n,r)),t.Pop()):yp(e,t,n,r)}function yp(e,t,n,r){e.Push(n);let i=[];if(Sl(n))return kie(e,t,n,r);if(hu(n)&&i.push(Xf(e,t,n,r)),dp(n)){let a=[];pu(n)&&a.push(Uf(e,t,n,r)),Tl(n)&&a.push(gie(e,t,n,r)),Ml(n)&&a.push(Fie(e,t,n,r)),Nl(n)&&a.push(Rie(e,t,n,r)),Pl(n)&&a.push(Vie(e,t,n,r)),ou(n)&&a.push(bf(e,t,n,r)),cu(n)&&a.push(kf(e,t,n,r)),lu(n)&&a.push(Mf(e,t,n,r)),tu(n)&&a.push(ef(e,t,n,r)),Xl(n)&&a.push(Rd(e,t,n,r));let o=ut(a),s=Ee(De(Pe(r)),o);i.push(up(n)?o:s)}if(pp(n)){let a=[];wl(n)&&a.push(lie(e,t,n,r)),Al(n)&&a.push(Nie(e,t,n,r)),Wl(n)&&a.push(Sd(e,t,n,r)),ql(n)&&a.push(Ed(e,t,n,r)),Jl(n)&&a.push(Md(e,t,n,r)),Ql(n)&&a.push(Hd(e,t,n,r)),$l(n)&&a.push(Jd(e,t,n,r)),su(n)&&a.push(Cf(e,t,n,r)),gu(n)&&a.push(op(e,t,n,r));let o=ut(a),s=Ee(De(Oe(r)),o);i.push(fp(n)?o:s)}if(hp(n)){let a=[];Yl(n)&&a.push(Fd(e,t,n,r)),eu(n)&&a.push(Zd(e,t,n,r)),Vl(n)&&a.push(zae(e,t,n,r)),au(n)&&a.push(_f(e,t,n,r));let o=ut(a),s=Ee(De(Ie(r)),o);i.push(mp(n)?o:s)}if(_p(n)){let a=[];zl(n)&&a.push(Yie(e,t,n,r)),Bl(n)&&a.push(Zie(e,t,n,r)),Kl(n)&&a.push(kd(e,t,n,r)),Zl(n)&&a.push(Gd(e,t,n,r)),nu(n)&&a.push(rf(e,t,n,r));let o=ut(a),s=Ee(De(Ee(Ne(r),ke(r))),o);i.push(gp(n)?o:s)}fu(n)&&i.push(Bf(e,t,n,r)),du(n)&&i.push(Ff(e,t,n,r)),Il(n)&&i.push(Wie(e,t,n,r)),kl(n)&&i.push(jie(e,t,n,r)),Rl(n)&&i.push(qie(e,t,n,r)),Ul(n)&&i.push(Vae(e,t,n,r)),ru(n)&&i.push(lf(e,t,n,r)),El(n)&&i.push(xie(e,t,n,r)),Ol(n)&&i.push(Eie(e,t,n,r)),iu(n)&&i.push(mf(e,t,n,r)),_u(n)&&i.push(Ee(De(Oe(r)),$f(e,t,n,r))),vu(n)&&i.push(Ee(De(Fe(r)),np(e,t,n,r))),bl(n)&&i.push(aie(e,t,n,r));let a=ut(i);return e.Pop(n),a}function bp(e,t,n,r){return t.Push()&&xp(e,t,n,r)&&t.Pop()}function xp(e,t,n,r){e.Push(n);let i=Sl(n)?ku(e,t,n,r):(!hu(n)||Zf(e,t,n,r))&&(!(j(r)&&!S(r))||(!pu(n)||Wf(e,t,n,r))&&(!Tl(n)||_ie(e,t,n,r))&&(!Ml(n)||Iie(e,t,n,r))&&(!Nl(n)||zie(e,t,n,r))&&(!Pl(n)||Hie(e,t,n,r))&&(!ou(n)||xf(e,t,n,r))&&(!cu(n)||Af(e,t,n,r))&&(!lu(n)||Nf(e,t,n,r))&&(!tu(n)||tf(e,t,n,r))&&(!Xl(n)||zd(e,t,n,r)))&&(!S(r)||(!wl(n)||uie(e,t,n,r))&&(!Al(n)||Mu(e,t,n,r))&&(!Wl(n)||Cd(e,t,n,r))&&(!ql(n)||Dd(e,t,n,r))&&(!Jl(n)||Nd(e,t,n,r))&&(!Ql(n)||Ud(e,t,n,r))&&(!$l(n)||Yd(e,t,n,r))&&(!su(n)||wf(e,t,n,r))&&(!gu(n)||sp(e,t,n,r)))&&(!M(r)||(!Yl(n)||Id(e,t,n,r))&&(!eu(n)||Qd(e,t,n,r))&&(!Vl(n)||vd(e,t,n,r))&&(!au(n)||vf(e,t,n,r)))&&(!(k(r)||C(r))||(!zl(n)||Pu(e,t,n,r))&&(!Bl(n)||Fu(e,t,n,r))&&(!Kl(n)||Ad(e,t,n,r))&&(!Zl(n)||Kd(e,t,n,r))&&(!nu(n)||af(e,t,n,r)))&&(!fu(n)||Vf(e,t,n,r))&&(!du(n)||If(e,t,n,r))&&(!Il(n)||Gie(e,t,n,r))&&(!kl(n)||Au(e,t,n,r))&&(!Rl(n)||Nu(e,t,n,r))&&(!Ul(n)||Hae(e,t,n,r))&&(!ru(n)||uf(e,t,n,r))&&(!El(n)||Sie(e,t,n,r))&&(!Ol(n)||Die(e,t,n,r))&&(!iu(n)||hf(e,t,n,r))&&(!_u(n)||!S(r)||ep(e,t,n,r))&&(!vu(n)||!j(r)||rp(e,t,n,r))&&(!bl(n)||oie(e,t,n,r));return e.Pop(n),i}function Sp(e,t,n,r,i,a){return t.Push()&&Cp(e,t,n,r,i,a)&&t.Pop()}function Cp(e,t,n,r,i,a){e.Push(i);let o=Sl(i)?Aie(e,t,n,r,i,a):!!(+(!hu(i)||Qf(e,t,n,r,i,a))&(!(j(a)&&!S(a))||!!(+(!pu(i)||Gf(e,t,n,r,i,a))&(!Tl(i)||vie(e,t,n,r,i,a))&(!Ml(i)||Lie(e,t,n,r,i,a))&(!Nl(i)||Bie(e,t,n,r,i,a))&(!Pl(i)||Uie(e,t,n,r,i,a))&(!ou(i)||Sf(e,t,n,r,i,a))&(!cu(i)||jf(e,t,n,r,i,a))&(!lu(i)||Pf(e,t,n,r,i,a))&(!tu(i)||nf(e,t,n,r,i,a))&(!Xl(i)||Bd(e,t,n,r,i,a))))&(!S(a)||!!(+(!wl(i)||die(e,t,n,r,i,a))&(!Al(i)||Pie(e,t,n,r,i,a))&(!Wl(i)||wd(e,t,n,r,i,a))&(!ql(i)||Od(e,t,n,r,i,a))&(!Jl(i)||Pd(e,t,n,r,i,a))&(!Ql(i)||Wd(e,t,n,r,i,a))&(!$l(i)||Xd(e,t,n,r,i,a))&(!su(i)||Tf(e,t,n,r,i,a))&(!gu(i)||cp(e,t,n,r,i,a))))&(!M(a)||!!(+(!Yl(i)||Ld(e,t,n,r,i,a))&(!eu(i)||$d(e,t,n,r,i,a))&(!Vl(i)||Bae(e,t,n,r,i,a))&(!au(i)||yf(e,t,n,r,i,a))))&(!(k(a)||C(a))||!!(+(!zl(i)||Xie(e,t,n,r,i,a))&(!Bl(i)||Qie(e,t,n,r,i,a))&(!Kl(i)||jd(e,t,n,r,i,a))&(!Zl(i)||qd(e,t,n,r,i,a))&(!nu(i)||of(e,t,n,r,i,a))))&(!fu(i)||Hf(e,t,n,r,i,a))&(!du(i)||Lf(e,t,n,r,i,a))&(!Il(i)||Kie(e,t,n,r,i,a))&(!kl(i)||Mie(e,t,n,r,i,a))&(!Rl(i)||Jie(e,t,n,r,i,a))&(!Ul(i)||Uae(e,t,n,r,i,a))&(!ru(i)||df(e,t,n,r,i,a))&(!El(i)||Cie(e,t,n,r,i,a))&(!Ol(i)||Oie(e,t,n,r,i,a))&(!iu(i)||gf(e,t,n,r,i,a))&(!_u(i)||!S(a)||tp(e,t,n,r,i,a))&(!vu(i)||!j(a)||ip(e,t,n,r,i,a)))&&(!bl(i)||sie(e,t,n,r,i,a));return e.Pop(i),o}const wp=[0],Tp=new Map,Ep=new Map;function Dp(){return yr(wp[0]++)}function Op(e,t){Tp.has(e)||Tp.set(e,new Map);let n=Tp.get(e);if(n.has(t))return n.get(t);let r=Dp();return n.set(t,r),r}function kp(e,t,n,r){return e.UseUnevaluated()?tt(`check_${n}`,[`context`,r]):tt(`check_${n}`,[r])}function Ap(e,t,n,r){let i=yp(e,t,n,`value`);return t.UseUnevaluated()?st(`check_${r}`,et([`context`,`value`],i)):st(`check_${r}`,et([`value`],i))}function jp(){wp[0]=0,Tp.clear(),Ep.clear()}function Mp(){return[...Ep.values()]}function Np(e,t,n,r){let i=Op(n,e.BaseURL().href),a=kp(t,n,i,r);return Ep.has(i)?a:(Ep.set(i,``),Ep.set(i,Ap(e,t,n,i)),a)}function Pp(e,t){return j(t)&&!he(e)?t[e]:void 0}function Fp(e,t){return e.reduce((e,t)=>Pp(t,e),t)}function Ip(e){if(N(e.length,0))return[];let t=e.split(`/`).map(e=>e.replace(/~1/g,`/`).replace(/~0/g,`~`));return t.length>0&&t[0]===``?t.slice(1):t}function Lp(e,t){return Fp(Ip(t),e)}function Rp(e,t,n){if(e.$id===n.hash)return e;let r=new URL(e.$id,t.href),i=new URL(n.href,t.href);if(N(r.pathname,i.pathname))return n.hash.startsWith(`#`)?Vp(e,t,n):e}function zp(e,t,n){let r=new URL(`#${e.$anchor}`,t.href),i=new URL(n.href,t.href);return N(r.href,i.href)?e:void 0}function Bp(e,t,n){let r=new URL(`#${e.$dynamicAnchor}`,t.href),i=new URL(n.href,t.href);return N(r.href,i.href)?e:void 0}function Vp(e,t,n){if(n.href.endsWith(`#`))return e;if(!n.hash.startsWith(`#`))return;let r=decodeURIComponent(n.hash.slice(1));if(r.startsWith(`/`))return Lp(e,r)}function Hp(e,t,n){if(Hl(e)){let r=Rp(e,t,n);if(!te(r))return r}if(Dl(e)){let r=zp(e,t,n);if(!te(r))return r}if(Fl(e)){let r=Bp(e,t,n);if(!te(r))return r}return Vp(e,t,n)}function Up(e,t,n){return e.reduce((e,r)=>{let i=Gp(r,t,n);return te(i)?e:i},void 0)}function Wp(e,t,n){return F(e).reduce((r,i)=>{let a=Gp(e[i],t,n);return te(a)?r:a},void 0)}function Gp(e,t,n){let r=xl(e)&&Hl(e)?new URL(e.$id,t.href):t;if(xl(e)){let t=Hp(e,r,n);if(!te(t))return t}if(S(e))return Up(e,r,n);if(j(e))return Wp(e,r,n)}function Kp(e,t){let n=new URL(`http://unknown/`),r=Hl(e)?new URL(e.$id,n.href):n;return Gp(e,r,new URL(t,r.href))}function qp(e,t,n,r){let i=n.$dynamicRef.startsWith(`#`)?Kp(t,n.$dynamicRef):Kp(e,n.$dynamicRef);if(!te(i))return!xl(i)||!Fl(i)||new URL(n.$dynamicRef,`http://unknown/`).hash.startsWith(`#/`)?i:r.find(e=>e.$dynamicAnchor===i.$dynamicAnchor)??i}var Jp=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},Yp,Xp,Zp,Qp,$p,em=class{constructor(e,t){Yp.add(this),this.context=e,this.schema=t,this.ids=[],this.anchors=[],this.recursiveAnchors=[],this.dynamicAnchors=[]}BaseURL(){return this.ids.reduce((e,t)=>new URL(t.$id,e),new URL(`http://unknown`))}Base(){return this.ids[this.ids.length-1]??this.schema}Push(e){xl(e)&&(Hl(e)&&(this.ids.push(e),Jp(this,Yp,`m`,Xp).call(this,e)),Dl(e)&&this.anchors.push(e),uu(e)&&this.recursiveAnchors.push(e),Fl(e)&&this.dynamicAnchors.push(e))}Pop(e){xl(e)&&(Hl(e)&&(this.ids.pop(),Jp(this,Yp,`m`,Zp).call(this,e)),Dl(e)&&this.anchors.pop(),uu(e)&&this.recursiveAnchors.pop(),Fl(e)&&this.dynamicAnchors.pop())}Ref(e){return Jp(this,Yp,`m`,Qp).call(this,e)??Jp(this,Yp,`m`,$p).call(this,e)}RecursiveRef(e){return uu(this.Base())?Kp(this.recursiveAnchors[0],e.$recursiveRef):Kp(this.Base(),e.$recursiveRef)}DynamicRef(e){let t=this.schema;return qp(t,this.Base(),e,this.dynamicAnchors)}};Yp=new WeakSet,Xp=function e(t,n=!0){if(!xl(t))return;let r=t;if(n||!Hl(r)){!n&&Fl(r)&&this.dynamicAnchors.push(r);for(let t of F(r))Jp(this,Yp,`m`,e).call(this,r[t],!1)}},Zp=function e(t,n=!0){if(!xl(t))return;let r=t;if(n||!Hl(r)){!n&&Fl(r)&&this.dynamicAnchors.pop();for(let t of F(r))Jp(this,Yp,`m`,e).call(this,r[t],!1)}},Qp=function(e){return P(this.context,e.$ref)?this.context[e.$ref]:void 0},$p=function(e){let t=this.schema;return e.$ref.startsWith(`#`)?Kp(this.Base(),e.$ref):Kp(t,e.$ref)};function tm(e){return`${e.Functions().join(`; `)}; return (value) => { ${(e.UseUnevaluated()?[`const context = new CheckContext({}, {})`,`return ${e.Entry()}`]:[`return ${e.Entry()}`]).join(`; `)} }`}function nm(e,t){return Hn(`CheckContext`,`Guard`,`Format`,`Hashing`,e.External().identifier,t)(bu,x,Rae,Wn,e.External().variables)}function rm(e){let t=new em(e.Context(),e.Schema()),n=new bu;return r=>xp(t,n,e.Schema(),r)}function im(e,t){return Vn()?nm(e,t):rm(e)}var am=class{constructor(e,t,n){this.isAccelerated=e,this.code=t,this.check=n}IsAccelerated(){return this.isAccelerated}Code(){return this.code}Check(e){return this.check(e)}},om=class{constructor(e,t,n,r,i,a){this.context=e,this.schema=t,this.external=n,this.functions=r,this.entry=i,this.useUnevaluated=a}Context(){return this.context}Schema(){return this.schema}UseUnevaluated(){return this.useUnevaluated}External(){return this.external}Functions(){return this.functions}Entry(){return this.entry}Evaluate(){let e=tm(this),t=im(this,e);return new am(Vn(),e,t)}};function sm(...e){let[t,n]=An(e,{2:(e,t)=>[e,t],1:e=>[{},e]});rie(),jp();let r=new em(t,n),i=new nie(tie(t,n)),a=Np(r,i,n,`value`),o=Mp();return new om(t,n,iie(),o,a,i.UseUnevaluated())}function cm(...e){let[t,n,r]=An(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]}),i=It(),a=Sr(),o=[];return[Cp(new em(t,n),new xu(e=>{if(!ae(o.length,i.maxErrors))return o.push({...e,message:a(e)})}),`#`,``,n,r),o]}function lm(...e){let[t,n,r]=An(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return xp(new em(t,n),new bu,n,r)}function um(...e){let[t,n,r]=An(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return lm(t,n,r)}function dm(...e){let[t,n,r]=An(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]}),[i,a]=cm(t,n,r);return a}var fm=class extends Error{constructor(e,t,n){super(e),Object.defineProperty(this,"cause",{value:{source:e,errors:n,value:t},writable:!1,configurable:!1,enumerable:!1})}};function pm(e,t,n){return S(n)?n.map(n=>ym(e,t.items,n)):n}function mm(e,t,n){return ym({...e,...t.$defs},cn(t.$ref),n)}function hm(e,t){let n=P(t,`unevaluatedProperties`)?{additionalProperties:t.unevaluatedProperties}:{},r=pl(cl(e,t));return Cn(r)?Jc(r,n):r}function gm(e,t,n){return ym(e,hm(e,t),n)}function _m(e){return P(e,`additionalProperties`)?e.additionalProperties:void 0}function qae(e,t,n){if(!j(n)||S(n))return n;let r=_m(t);for(let i of F(n)){if(P(t.properties,i)){n[i]=ym(e,t.properties[i],n[i]);continue}if(w(r)&&N(r,!0)||Ut(r)&&um(e,r,n[i])){n[i]=ym(e,r,n[i]);continue}delete n[i]}return n}function Jae(e,t,n){if(!j(n))return n;let r=_m(t),[i,a]=[new RegExp(Da(t)),ka(t)];for(let t of F(n)){if(i.test(t)){n[t]=ym(e,a,n[t]);continue}if(w(r)&&N(r,!0)||Ut(r)&&um(e,r,n[t])){n[t]=ym(e,r,n[t]);continue}delete n[t]}return n}function Yae(e,t,n){return P(e,t.$ref)?ym(e,e[t.$ref],n):n}function Xae(e,t,n){if(!S(n))return n;let r=Math.min(n.length,t.items.length);for(let i=0;ixm(e))}function xm(e){return Qae(e,$t(e)?Qt(xm(e.items),en(e)):Ln(e)?In(bm(e.allOf)):Qr(e)?Zr(eoe(e.anyOf)):Cn(e)?Sn($ae(e.properties)):Aa(e)?wa(Oa(e),xm(ka(e))):xi(e)?bi(bm(e.items)):e)}function Sm(e){return xm(e)}function Cm(...e){let[t,n,r]=An(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return ym(t,It().unionPrioritySort?Sm(n):n,r)}function wm(e){return j(e)&&P(e,`value`)}function Tm(e){return{value:e}}function toe(e){return S(e)?Tm(e):Tm([e])}function noe(e){return N(e,!0)?Tm(BigInt(1)):Tm(BigInt(0))}const roe=/^-?(0|[1-9]\d*)n$/,ioe=/^-?(0|[1-9]\d*)\.\d+$/,aoe=/^-?(0|[1-9]\d*)$/;function ooe(e){return roe.test(e)}function soe(e){return ioe.test(e)}function coe(e){return aoe.test(e)}function loe(e){let t=e.toLowerCase();return ooe(e)?Tm(BigInt(e.slice(0,e.length-1))):soe(e)?Tm(BigInt(e.split(`.`)[0])):coe(e)?Tm(BigInt(e)):N(t,`false`)?Tm(BigInt(0)):N(t,`true`)?Tm(BigInt(1)):void 0}function Em(e){return C(e)?Tm(e):w(e)?noe(e):k(e)?Tm(BigInt(Math.trunc(e))):O(e)?Tm(BigInt(0)):M(e)?loe(e):te(e)?Tm(BigInt(0)):void 0}function uoe(e){return N(e,BigInt(0))?Tm(!1):N(e,BigInt(1))?Tm(!0):void 0}function doe(e){return N(e,0)?Tm(!1):N(e,1)?Tm(!0):void 0}function foe(e){return N(e.toLowerCase(),`false`)?Tm(!1):N(e.toLowerCase(),`true`)?Tm(!0):N(e,`0`)?Tm(!1):N(e,`1`)?Tm(!0):void 0}function Dm(e){return C(e)?uoe(e):w(e)?Tm(e):k(e)?doe(e):O(e)?Tm(!1):M(e)?foe(e):te(e)?Tm(!1):void 0}function poe(e){return N(e,BigInt(0))?Tm(null):void 0}function moe(e){return N(e,!1)?Tm(null):void 0}function hoe(e){return N(e,0)?Tm(null):void 0}function goe(e){let t=e.toLowerCase();return N(t,`undefined`)||N(t,`null`)||N(e,``)||N(e,`0`)?Tm(null):void 0}function _oe(e){return C(e)?poe(e):w(e)?moe(e):k(e)?hoe(e):O(e)?Tm(null):M(e)?goe(e):te(e)?Tm(null):void 0}const Om=BigInt(2**53-1),km=BigInt(-(2**53-1));function voe(e){return e<=Om&&e>=km?Tm(Number(e)):void 0}function yoe(e){return Tm(+!!e)}function boe(e){let t=+e;if(k(t))return Tm(t);let n=e.toLowerCase();if(N(n,`false`))return Tm(0);if(N(n,`true`))return Tm(1);let r=Em(e);if(wm(r))return r.value<=Om&&r.value>=km?Tm(Number(r.value)):void 0}function Am(e){return C(e)?voe(e):w(e)?yoe(e):k(e)?Tm(e):O(e)?Tm(0):M(e)?boe(e):te(e)?Tm(0):void 0}function jm(e){return C(e)||w(e)||k(e)?Tm(e.toString()):O(e)?Tm(`null`):M(e)?Tm(e):te(e)?Tm(``):void 0}function xoe(e){return N(e,BigInt(0))?Tm(void 0):void 0}function Soe(e){return N(e,!1)?Tm(void 0):void 0}function Coe(e){return N(e,0)?Tm(void 0):void 0}function woe(e){let t=e.toLowerCase();return N(t,`undefined`)||N(t,`null`)||N(e,``)||N(e,`0`)?Tm(void 0):void 0}function Mm(e){return C(e)?xoe(e):w(e)?Soe(e):k(e)?Coe(e):O(e)?Tm(void 0):M(e)?woe(e):te(e)?Tm(e):void 0}function Toe(e,t,n){return toe(n).value.map(n=>Fm(e,t.items,n))}function Eoe(e,t,n){let r=Em(n);return wm(r)?r.value:n}function Doe(e,t,n){let r=Dm(n);return wm(r)?r.value:n}function Ooe(e,t,n){return Fm({...e,...t.$defs},cn(t.$ref),n)}function koe(e,t,n){return Fm(e,pl(t),n)}function Aoe(e,t,n){let r=Am(n);return wm(r)?Math.trunc(r.value):n}function joe(e,t,n){return Fm(e,pl(cl(e,t)),n)}function Moe(e,t,n){let r=Em(n);return wm(r)&&N(t.const,r.value)?r.value:n}function Noe(e,t,n){let r=Dm(n);return wm(r)&&N(t.const,r.value)?r.value:n}function Poe(e,t,n){let r=Am(n);return wm(r)&&N(t.const,r.value)?r.value:n}function Foe(e,t,n){let r=jm(n);return wm(r)&&N(t.const,r.value)?r.value:n}function Ioe(e,t,n){return N(t.const,n)?n:Lr(t)?Moe(e,t,n):Rr(t)?Noe(e,t,n):zr(t)?Poe(e,t,n):Br(t)?Foe(e,t,n):Un()}function Loe(e,t,n){let r=_oe(n);return wm(r)?r.value:n}function Roe(e,t,n){let r=Am(n);return wm(r)?r.value:n}function Nm(e,t,n,r){let i=F(r);for(let[a,o]of t)for(let t of i)a.test(t)||(r[t]=Fm(e,n,r[t]));return r}function Pm(e,t,n){return vn(e)&&te(n[t])}function zoe(e,t,n){let r=ge(t.properties),i=F(n);for(let[t,a]of r)for(let r of i)t.test(r)&&!Pm(a,r,n)&&(n[r]=Fm(e,a,n[r]));return P(t,`additionalProperties`)&&j(t.additionalProperties)?Nm(e,r,t.additionalProperties,n):n}function Boe(e,t,n){return A(n)?zoe(e,t,n):n}function Voe(e,t,n){let r=ge(t.patternProperties),i=F(n);for(let[t,a]of r)for(let r of i)t.test(r)&&(n[r]=Fm(e,a,n[r]));return P(t,`additionalProperties`)&&j(t.additionalProperties)?Nm(e,r,t.additionalProperties,n):n}function Hoe(e,t,n){return A(n)?Voe(e,t,n):n}function Uoe(e,t,n){return P(e,t.$ref)?Fm(e,e[t.$ref],n):n}function Woe(e,t,n){let r=jm(n);return wm(r)?r.value:n}function Goe(e,t,n){return Fm(e,pl(t),n)}function Koe(e,t,n){if(!S(n))return n;for(let r=0;rum(e,t,n)))return n;let r=t.anyOf.map(t=>Fm(e,t,vm(n))).find(n=>um(e,t,n));return te(r)?n:r}function Yoe(e,t,n){return wm(Mm(n))?void 0:n}function Fm(e,t,n){return $t(t)?Toe(e,t,n):Or(t)?Eoe(e,t,n):kr(t)?Doe(e,t,n):On(t)?Ooe(e,t,n):Fn(t)?koe(e,t,n):Mr(t)?Aoe(e,t,n):Ln(t)?joe(e,t,n):Vr(t)?Ioe(e,t,n):Ur(t)?Loe(e,t,n):Kr(t)?Roe(e,t,n):Cn(t)?Boe(e,t,n):Aa(t)?Hoe(e,t,n):ln(t)?Uoe(e,t,n):Xr(t)?Woe(e,t,n):Ho(t)?Goe(e,t,n):xi(t)?Koe(e,t,n):Fa(t)?qoe(e,t,n):Qr(t)?Joe(e,t,n):Ia(t)?Yoe(e,t,n):n}function Im(...e){let[t,n,r]=An(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return Fm(t,n,r)}function Xoe(e,t,n){if(!S(n))return n;for(let r=0;r[e,t,n],2:(e,t)=>[{},e,t]});return Lm(t,n,r)}function zm(e){return(...t)=>{let[n,r,i]=An(t,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return e.reduce((e,t)=>t(n,r,e),i)}}function ase(e,t,n){return t[`~codec`].decode(n)}function ose(e,t,n){return t[`~codec`].encode(n)}function Bm(e,t,n,r){return Cr(n)?N(e,`Decode`)?ase(t,n,r):ose(t,n,r):r}function sse(e,t,n,r){if(!S(r))return r;for(let i=0;i({...e,...t}),{})}function Hm(e,t){for(let n of t)if(!Se(e,n))return n;return e}function dse(e,t,n,r){if(N(n.allOf.length,0))return Bm(e,t,n,r);let i=n.allOf.map(n=>Wm(e,t,n,Cm(n,vm(r))));return Bm(e,t,n,i.every(e=>j(e))?Vm(i):Hm(r,i))}function fse(e,t,n,r){if(N(n.allOf.length,0))return Bm(e,t,n,r);let i=Bm(e,t,n,r),a=n.allOf.map(n=>Wm(e,t,n,Cm(n,vm(i))));return a.every(e=>j(e))?Vm(a):Hm(i,a)}function pse(e,t,n,r){return N(e,`Decode`)?dse(e,t,n,r):fse(e,t,n,r)}function mse(e,t,n,r){if(!A(r))return r;for(let i of F(n.properties))P(r,i)&&!Pm(n.properties[i],i,r)&&(r[i]=Wm(e,t,n.properties[i],r[i]));return Bm(e,t,n,r)}function hse(e,t,n,r){let i=Bm(e,t,n,r);if(!A(i))return i;for(let r of F(n.properties))P(i,r)&&!Pm(n.properties[r],r,i)&&(i[r]=Wm(e,t,n.properties[r],i[r]));return i}function gse(e,t,n,r){return N(e,`Decode`)?mse(e,t,n,r):hse(e,t,n,r)}function _se(e,t,n,r){if(!A(r))return r;let i=new RegExp(Da(n));for(let a of F(r))i.test(a)&&(r[a]=Wm(e,t,ka(n),r[a]));return Bm(e,t,n,r)}function vse(e,t,n,r){let i=Bm(e,t,n,r);if(!A(i))return i;let a=new RegExp(Da(n));for(let r of F(i))a.test(r)&&(i[r]=Wm(e,t,ka(n),i[r]));return i}function yse(e,t,n,r){return N(e,`Decode`)?_se(e,t,n,r):vse(e,t,n,r)}function Um(e,t,n,r){return P(t,n.$ref)?Wm(e,t,t[n.$ref],r):r}function bse(e,t,n,r){return N(e,`Decode`)?Bm(e,t,n,Um(e,t,n,r)):Um(e,t,n,Bm(e,t,n,r))}function xse(e,t,n,r){if(!S(r))return r;for(let i=0;ivm(n),(e,t,n)=>Rm(e,t,n),(e,t,n)=>Im(e,t,n),(e,t,n)=>Cm(e,t,n),(e,t,n)=>Ose(e,t,n),(e,t,n)=>kse(e,t,n)]);function jse(...e){let[t,n,r]=An(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return Ase(t,n,r)}var Mse=class extends fm{constructor(e,t){super(`Encode`,e,t)}};function Nse(e,t,n){if(!um(e,t,n))throw new Mse(n,dm(e,t,n));return n}function Pse(e,t,n){return Wm(`Encode`,e,It().unionPrioritySort?Sm(t):t,n)}const Fse=zm([(e,t,n)=>vm(n),(e,t,n)=>Pse(e,t,n),(e,t,n)=>Rm(e,t,n),(e,t,n)=>Im(e,t,n),(e,t,n)=>Cm(e,t,n),(e,t,n)=>Nse(e,t,n)]);function Ise(...e){let[t,n,r]=An(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return Fse(t,n,r)}function Lse(e,t){return Cr(t)||Km(e,t.items)}function Rse(e,t){return Cr(t)||Gm({...e,...t.$defs},cn(t.$ref))}function zse(e,t){return Cr(t)||t.allOf.some(t=>Km(e,t))}function Bse(e,t){return Cr(t)||F(t.properties).some(n=>Km(e,t.properties[n]))}function Vse(e,t){return Cr(t)||Km(e,ka(t))}function Gm(e,t){return!qm.has(t.$ref)&&(qm.add(t.$ref),Cr(t)||P(e,t.$ref)&&Km(e,e[t.$ref]))}function Hse(e,t){return Cr(t)||t.items.some(t=>Km(e,t))}function Use(e,t){return Cr(t)||t.anyOf.some(t=>Km(e,t))}function Km(e,t){return $t(t)?Lse(e,t):On(t)?Rse(e,t):Ln(t)?zse(e,t):Cn(t)?Bse(e,t):Aa(t)?Vse(e,t):ln(t)?Gm(e,t):xi(t)?Hse(e,t):Qr(t)?Use(e,t):Cr(t)}const qm=new Set;function Wse(...e){let[t,n]=An(e,{2:(e,t)=>[e,t],1:e=>[{},e]});return qm.clear(),Km(t,n)}var Jm=class extends Error{constructor(e,t){super(t),this.type=e}};function Gse(e,t){return E(t.default)?t.default(t):j(t.default)?vm(t.default):t.default}function Kse(e,t){if(gu(t)&&!jl(t))throw new Jm(t,`Arrays with uniqueItems constraints must specify a default annotation`);let n=$l(t)?t.minItems:0;return Array.from({length:n},()=>Ym(e,t.items))}function qse(e,t){return Bl(t)?BigInt(t.exclusiveMinimum)+BigInt(1):Zl(t)?BigInt(t.minimum):BigInt(0)}function Jse(e,t){return!1}function Yse(e,t){let n=Ym(e,t.instanceType);return class{constructor(){Object.assign(this,n)}}}function Xse(e,t){return Ym({...e,...t.$defs},cn(t.$ref))}function Zse(e,t){return Ym(e,pl(t))}function Qse(e,t){let n=Ym(e,t.returnType);return()=>n}function $se(e,t){return Bl(t)&&k(t.exclusiveMinimum)?t.exclusiveMinimum+1:Zl(t)?t.minimum:0}function ece(e,t){return Ym(e,pl(cl(e,t)))}function tce(e,t){return t.const}function nce(e,t){throw new Jm(t,`Cannot create TNever types`)}function rce(e,t){return null}function ice(e,t){return Bl(t)&&k(t.exclusiveMinimum)?t.exclusiveMinimum+1:Zl(t)?t.minimum:0}function ace(e,t){return(te(t.required)?[]:t.required).reduce((n,r)=>({...n,[r]:Ym(e,t.properties[r])}),{})}function oce(e,t){if(tu(t)&&!jl(t))throw new Jm(t,`Record with the minProperties constraint must have a default annotation`);return{}}function sce(e,t){return P(e,t.$ref)?Ym(e,e[t.$ref]):(()=>{throw new Jm(t,`Unable to deref Ref`)})()}function cce(e,t){if((au(t)||Vl(t))&&!jl(t))throw Error(`Strings with format or pattern constraints must specify default`);let n=eu(t)?t.minLength:0;return``.padEnd(n)}function lce(e,t){return Symbol()}function uce(e,t){let n=gi(t.pattern);if(Xr(n))throw new Jm(t,`Unable to create TemplateLiteral due to infinite type expansion`);return Ym(e,n)}function dce(e,t){return Array.from({length:t.minItems},(n,r)=>Ym(e,t.items[r]))}function fce(e,t){if(N(t.anyOf.length,0))throw Error(`Unable to create Union with no variants`);return Ym(e,t.anyOf[0])}function Ym(e,t){return jl(t)?Gse(e,t):$t(t)?Kse(e,t):Or(t)?qse(e,t):kr(t)?Jse(e,t):nn(t)?Yse(e,t):On(t)?Xse(e,t):Fn(t)?Zse(e,t):on(t)?Qse(e,t):Mr(t)?$se(e,t):Ln(t)?ece(e,t):Vr(t)?tce(e,t):hn(t)?nce(e,t):Ur(t)?rce(e,t):Kr(t)?ice(e,t):Cn(t)?ace(e,t):Aa(t)?oce(e,t):ln(t)?sce(e,t):Xr(t)?cce(e,t):Jr(t)?lce(e,t):Ho(t)?uce(e,t):xi(t)?dce(e,t):Fa(t)?void 0:Qr(t)?fce(e,t):(Ia(t),void 0)}function pce(...e){let[t,n]=An(e,{2:(e,t)=>[e,t],1:e=>[{},e]});return Ym(t,n)}var Xm=class extends fm{constructor(e,t){super(`Parse`,e,t)}};function mce(e,t,n){if(!um(e,t,n))throw new Xm(n,dm(e,t,n));return n}const hce=zm([(e,t,n)=>vm(n),(e,t,n)=>Rm(e,t,n),(e,t,n)=>Im(e,t,n),(e,t,n)=>Cm(e,t,n),(e,t,n)=>mce(e,t,n)]);Zr([Sn({type:Fr(`insert`),path:Yr(),value:Tn()}),Object({type:Fr(`update`),path:Yr(),value:Tn()}),Sn({type:Fr(`delete`),path:Yr()})]);var gce=class{constructor(e,t){this.hasCodec=Wse(e,t),this.buildResult=sm(e,t),this.evaluateResult=this.buildResult.Evaluate()}IsAccelerated(){return this.evaluateResult.IsAccelerated()}Context(){return this.buildResult.Context()}Type(){return this.buildResult.Schema()}Code(){return this.evaluateResult.Code()}Check(e){return this.evaluateResult.Check(e)}Parse(e){if(this.Check(e))return e;if(It().correctiveParse)return hce(this.Context(),this.Type(),e);throw new Xm(e,this.Errors(e))}Errors(e){return this.IsAccelerated()&&this.Check(e)?[]:dm(this.Context(),this.Type(),e)}Clean(e){return Cm(this.Context(),this.Type(),e)}Convert(e){return Im(this.Context(),this.Type(),e)}Create(){return pce(this.Context(),this.Type())}Default(e){return Rm(this.Context(),this.Type(),e)}Decode(e){return this.hasCodec?jse(this.Context(),this.Type(),e):this.Parse(e)}Encode(e){return this.hasCodec?Ise(this.Context(),this.Type(),e):this.Parse(e)}};function _ce(...e){let[t,n]=An(e,{2:(e,t)=>[e,t],1:e=>[{},e]});return new gce(t,n)}const Zm=new WeakMap,vce=Symbol.for(`TypeBox.Kind`);function yce(e){return typeof e.type==`string`?[e.type]:Array.isArray(e.type)?e.type.filter(e=>typeof e==`string`):[]}function bce(e,t){switch(t){case`number`:return typeof e==`number`;case`integer`:return typeof e==`number`&&Number.isInteger(e);case`boolean`:return typeof e==`boolean`;case`string`:return typeof e==`string`;case`null`:return e===null;case`array`:return Array.isArray(e);case`object`:return typeof e==`object`&&!!e&&!Array.isArray(e);default:return!1}}function Qm(e){try{return nh(e)}catch{return}}function xce(e,t){switch(t){case`number`:if(e===null)return 0;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);if(Number.isFinite(t))return t}return typeof e==`boolean`?+!!e:e;case`integer`:if(e===null)return 0;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);if(Number.isInteger(t))return t}return typeof e==`boolean`?+!!e:e;case`boolean`:if(e===null)return!1;if(typeof e==`string`){if(e===`true`)return!0;if(e===`false`)return!1}if(typeof e==`number`){if(e===1)return!0;if(e===0)return!1}return e;case`string`:return e===null?``:typeof e==`number`||typeof e==`boolean`?String(e):e;case`null`:return e===``||e===0||e===!1?null:e;default:return e}}function Sce(e,t){let n=t.properties,r=new Set(n?Object.keys(n):[]);if(n)for(let[t,r]of Object.entries(n))t in e&&(e[t]=eh(e[t],r));if(t.additionalProperties&&typeof t.additionalProperties==`object`)for(let[n,i]of Object.entries(e))r.has(n)||(e[n]=eh(i,t.additionalProperties))}function Cce(e,t){if(Array.isArray(t.items)){for(let n=0;n1&&r.some(e=>bce(n,e));if(r.length>0&&!i)for(let e of r){let t=xce(n,e);if(t!==n){n=t;break}}return r.includes(`object`)&&typeof n==`object`&&n&&!Array.isArray(n)&&Sce(n,t),r.includes(`array`)&&Array.isArray(n)&&Cce(n,t),n}function th(e,t){if(Array.isArray(e)){if(Array.isArray(t.items))for(let n=0;n` - ${wce(e)}: ${e.message}`).join(` `)||`Unknown validation error`,a=`Validation failed for tool "${t.name}":\n${i}\n\nReceived arguments:\n${JSON.stringify(t.arguments,null,2)}`;throw Error(a)}function Ece(e,t){try{return Promise.resolve(t(rh))}catch(e){return Promise.reject(e)}}const rh={startSpan:Ece,addEvent:()=>{},setAttributes:()=>{},setStatus:()=>{}};Object.freeze(rh);function ih(){throw Error(`No default stream function configured. Pass streamFn explicitly or call setDefaultStreamFn().`)}async function Dce(e,t,n,r,i,a){let o=[...e],s={...t,messages:[...t.messages,...e]};await r({type:`agent_start`}),await r({type:`turn_start`});for(let t of e)await r({type:`message_start`,message:t}),await r({type:`message_end`,message:t});return await ah(s,o,n,i,r,a??ih()),o}async function Oce(e,t,n,r,i){if(e.messages.length===0)throw Error(`Cannot continue: no messages in context`);if(e.messages[e.messages.length-1].role===`assistant`)throw Error(`Cannot continue from message role: assistant`);let a=[],o={...e};return await n({type:`agent_start`}),await n({type:`turn_start`}),await ah(o,a,t,r,n,i??ih()),a}async function ah(e,t,n,r,i,a){let o=e,s=n,c,l=await s.getSteeringMessages?.()||[];for(;;){let e=!0;for(;e||l.length>0;){if(c){let e=await s.prepareNextTurn?.(c);e&&(o=e.context??o,s={...s,model:e.model??s.model,reasoning:e.thinkingLevel===void 0?s.reasoning:e.thinkingLevel===`off`?void 0:e.thinkingLevel}),l.length===0&&(l=await s.getSteeringMessages?.()||[]),await i({type:`turn_start`})}if(l.length>0){for(let e of l)await i({type:`message_start`,message:e}),await i({type:`message_end`,message:e}),o.messages.push(e),t.push(e);l=[]}let n=await kce(o,s,r,i,a);if(t.push(n),n.stopReason===`error`||n.stopReason===`aborted`){await i({type:`turn_end`,message:n,toolResults:[]}),await i({type:`agent_end`,messages:t});return}let u=n.content.filter(e=>e.type===`toolCall`),d=[];if(e=!1,u.length>0){let a=n.stopReason===`length`?await Ace(u,i):await jce(o,n,s,r,i);d.push(...a.messages),e=!a.terminate;for(let e of d)o.messages.push(e),t.push(e)}if(await i({type:`turn_end`,message:n,toolResults:d}),c={message:n,toolResults:d,context:o,newMessages:t},await s.shouldStopAfterTurn?.(c)){await i({type:`agent_end`,messages:t});return}l=await s.getSteeringMessages?.()||[]}let n=await s.getFollowUpMessages?.()||[];if(n.length>0){l=n;continue}break}await i({type:`agent_end`,messages:t})}async function kce(e,t,n,r,i){let a=e.messages;t.transformContext&&(a=await t.transformContext(a,n));let o=await t.convertToLlm(a),s={systemPrompt:e.systemPrompt,messages:o,tools:e.tools},c=(t.getApiKey?await t.getApiKey(t.model.provider):void 0)||t.apiKey,l=await i(t.model,s,{...t,apiKey:c,signal:n}),u=null,d=!1;for await(let t of l)switch(t.type){case`start`:u=t.partial,e.messages.push(u),d=!0,await r({type:`message_start`,message:{...u}});break;case`text_start`:case`text_delta`:case`text_end`:case`thinking_start`:case`thinking_delta`:case`thinking_end`:case`toolcall_start`:case`toolcall_delta`:case`toolcall_end`:u&&(u=t.partial,e.messages[e.messages.length-1]=u,await r({type:`message_update`,assistantMessageEvent:t,message:{...u}}));break;case`done`:case`error`:{let t=await l.result();return d?e.messages[e.messages.length-1]=t:e.messages.push(t),d||await r({type:`message_start`,message:{...t}}),await r({type:`message_end`,message:t}),t}}let f=await l.result();return d?e.messages[e.messages.length-1]=f:(e.messages.push(f),await r({type:`message_start`,message:{...f}})),await r({type:`message_end`,message:f}),f}async function Ace(e,t){let n=[];for(let r of e){await t({type:`tool_execution_start`,toolCallId:r.id,toolName:r.name,args:r.arguments});let e={toolCall:r,result:uh(`Tool call "${r.name}" was not executed: the response hit the output token limit, so its arguments may be truncated. Re-issue the tool call with complete arguments.`),isError:!0};await dh(e,t);let i=fh(e);await ph(i,t),n.push(i)}return{messages:n,terminate:!1}}async function jce(e,t,n,r,i){let a=t.content.filter(e=>e.type===`toolCall`),o=a.some(t=>e.tools?.find(e=>e.name===t.name)?.executionMode===`sequential`);return n.toolExecution===`sequential`||o?Mce(e,t,a,n,r,i):Nce(e,t,a,n,r,i)}async function Mce(e,t,n,r,i,a){let o=[],s=[];for(let c of n){await a({type:`tool_execution_start`,toolCallId:c.id,toolName:c.name,args:c.arguments});let n=await sh(e,t,c,r,i),l;l=n.kind===`immediate`?{toolCall:c,result:n.result,isError:n.isError}:await lh(e,t,n,await ch(n,i,a),r,i),await dh(l,a);let u=fh(l);if(await ph(u,a),o.push(l),s.push(u),i?.aborted)break}return{messages:s,terminate:oh(o)}}async function Nce(e,t,n,r,i,a){let o=[];for(let s of n){await a({type:`tool_execution_start`,toolCallId:s.id,toolName:s.name,args:s.arguments});let n=await sh(e,t,s,r,i);if(n.kind===`immediate`){let e={toolCall:s,result:n.result,isError:n.isError};if(await dh(e,a),o.push(e),i?.aborted)break;continue}if(o.push(async()=>{if(i?.aborted){let e={toolCall:s,result:uh(`Operation aborted`),isError:!0};return await dh(e,a),e}let o=await ch(n,i,a),c=await lh(e,t,n,o,r,i);return await dh(c,a),c}),i?.aborted)break}let s=await Promise.all(o.map(e=>typeof e==`function`?e():Promise.resolve(e))),c=[];for(let e of s){let t=fh(e);await ph(t,a),c.push(t)}return{messages:c,terminate:oh(s)}}function oh(e){return e.length>0&&e.every(e=>e.result.terminate===!0)}function Pce(e,t){if(!e.prepareArguments)return t;let n=e.prepareArguments(t.arguments);return n===t.arguments?t:{...t,arguments:n}}async function sh(e,t,n,r,i){let a=e.tools?.find(e=>e.name===n.name);if(!a)return{kind:`immediate`,result:uh(`Tool ${n.name} not found`),isError:!0};try{let o=Tce(a,Pce(a,n));if(r.beforeToolCall){let a=await r.beforeToolCall({assistantMessage:t,toolCall:n,args:o,context:e},i);if(i?.aborted)return{kind:`immediate`,result:uh(`Operation aborted`),isError:!0};if(a?.block){let e=uh(a.reason||`Tool execution was blocked`);return a.terminate===!0&&(e.terminate=!0),{kind:`immediate`,result:e,isError:!0}}}return i?.aborted?{kind:`immediate`,result:uh(`Operation aborted`),isError:!0}:{kind:`prepared`,toolCall:n,tool:a,args:o}}catch(e){return{kind:`immediate`,result:uh(e instanceof Error?e.message:String(e)),isError:!0}}}async function ch(e,t,n){let r=[],i=!0;try{let a=await e.tool.execute(e.toolCall.id,e.args,t,t=>{i&&r.push(Promise.resolve(n({type:`tool_execution_update`,toolCallId:e.toolCall.id,toolName:e.toolCall.name,args:e.toolCall.arguments,partialResult:t})))});return i=!1,await Promise.all(r),{result:a,isError:!1}}catch(e){return i=!1,await Promise.all(r),{result:uh(e instanceof Error?e.message:String(e)),isError:!0}}finally{i=!1}}async function lh(e,t,n,r,i,a){let o=r.result,s=r.isError;if(i.afterToolCall)try{let r=await i.afterToolCall({assistantMessage:t,toolCall:n.toolCall,args:n.args,result:o,isError:s,context:e},a);r&&(o={...o,content:r.content??o.content,details:r.details??o.details,usage:r.usage??o.usage,terminate:r.terminate??o.terminate},s=r.isError??s)}catch(e){o=uh(e instanceof Error?e.message:String(e)),s=!0}return{toolCall:n.toolCall,result:o,isError:s}}function uh(e){return{content:[{type:`text`,text:e}],details:{}}}async function dh(e,t){await t({type:`tool_execution_end`,toolCallId:e.toolCall.id,toolName:e.toolCall.name,result:e.result,isError:e.isError})}function fh(e){return{role:`toolResult`,toolCallId:e.toolCall.id,toolName:e.toolCall.name,content:e.result.content??[],details:e.result.details,usage:e.result.usage,...e.result.addedToolNames?.length?{addedToolNames:e.result.addedToolNames}:{},isError:e.isError,timestamp:Date.now()}}async function ph(e,t){await t({type:`message_start`,message:e}),await t({type:`message_end`,message:e})}function Fce(e){return e.filter(e=>e.role===`user`||e.role===`assistant`||e.role===`toolResult`)}const Ice={input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},Lce={id:`unknown`,name:`unknown`,api:`unknown`,provider:`unknown`,baseUrl:``,reasoning:!1,input:[],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:0,maxTokens:0};function Rce(e){let t=e?.tools?.slice()??[],n=e?.messages?.slice()??[];return{systemPrompt:e?.systemPrompt??``,model:e?.model??Lce,thinkingLevel:e?.thinkingLevel??`off`,get tools(){return t},set tools(e){t=e.slice()},get messages(){return n},set messages(e){n=e.slice()},isStreaming:!1,streamingMessage:void 0,pendingToolCalls:new Set,errorMessage:void 0}}var mh=class{messages=[];mode;constructor(e){this.mode=e}enqueue(e){this.messages.push(e)}hasItems(){return this.messages.length>0}drain(){if(this.mode===`all`){let e=this.messages.slice();return this.messages=[],e}let e=this.messages[0];return e?(this.messages=this.messages.slice(1),[e]):[]}clear(){this.messages=[]}},zce=class{_state;listeners=new Set;steeringQueue;followUpQueue;convertToLlm;transformContext;streamFunction;getApiKey;onPayload;onResponse;beforeToolCall;afterToolCall;shouldStopAfterTurn;prepareNextTurn;prepareNextTurnWithContext;activeRun;sessionId;thinkingBudgets;transport;maxRetryDelayMs;toolExecution;constructor(e){let t=e??{};this._state=Rce(t.initialState),this.convertToLlm=t.convertToLlm??Fce,this.transformContext=t.transformContext,this.streamFunction=t.streamFn??ih(),this.getApiKey=t.getApiKey,this.onPayload=t.onPayload,this.onResponse=t.onResponse,this.beforeToolCall=t.beforeToolCall,this.afterToolCall=t.afterToolCall,this.shouldStopAfterTurn=t.shouldStopAfterTurn,this.prepareNextTurn=t.prepareNextTurn,this.prepareNextTurnWithContext=t.prepareNextTurnWithContext,this.steeringQueue=new mh(t.steeringMode??`one-at-a-time`),this.followUpQueue=new mh(t.followUpMode??`one-at-a-time`),this.sessionId=t.sessionId,this.thinkingBudgets=t.thinkingBudgets,this.transport=t.transport??`auto`,this.maxRetryDelayMs=t.maxRetryDelayMs,this.toolExecution=t.toolExecution??`parallel`}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}get state(){return this._state}set steeringMode(e){this.steeringQueue.mode=e}get steeringMode(){return this.steeringQueue.mode}set followUpMode(e){this.followUpQueue.mode=e}get followUpMode(){return this.followUpQueue.mode}steer(e){this.steeringQueue.enqueue(e)}followUp(e){this.followUpQueue.enqueue(e)}clearSteeringQueue(){this.steeringQueue.clear()}clearFollowUpQueue(){this.followUpQueue.clear()}clearAllQueues(){this.clearSteeringQueue(),this.clearFollowUpQueue()}hasQueuedMessages(){return this.steeringQueue.hasItems()||this.followUpQueue.hasItems()}get signal(){return this.activeRun?.abortController.signal}abort(){this.activeRun?.abortController.abort()}waitForIdle(){return this.activeRun?.promise??Promise.resolve()}reset(){if(this.activeRun)throw Error(`Agent is already processing. Wait for completion before resetting.`);this._state.messages=[],this._state.isStreaming=!1,this._state.streamingMessage=void 0,this._state.pendingToolCalls=new Set,this._state.errorMessage=void 0,this.clearFollowUpQueue(),this.clearSteeringQueue()}async prompt(e,t){if(this.activeRun)throw Error(`Agent is already processing a prompt. Use steer() or followUp() to queue messages, or wait for completion.`);let n=this.normalizePromptInput(e,t);await this.runPromptMessages(n)}async continue(){if(this.activeRun)throw Error(`Agent is already processing. Wait for completion before continuing.`);let e=this._state.messages[this._state.messages.length-1];if(!e)throw Error(`No messages to continue from`);if(e.role===`assistant`){let e=this.steeringQueue.drain();if(e.length>0){await this.runPromptMessages(e,{skipInitialSteeringPoll:!0});return}let t=this.followUpQueue.drain();if(t.length>0){await this.runPromptMessages(t);return}throw Error(`Cannot continue from message role: assistant`)}await this.runContinuation()}normalizePromptInput(e,t){if(Array.isArray(e))return e;if(typeof e!=`string`)return[e];let n=[{type:`text`,text:e}];return t&&t.length>0&&n.push(...t),[{role:`user`,content:n,timestamp:Date.now()}]}async runPromptMessages(e,t={}){await this.runWithLifecycle(async n=>{await Dce(e,this.createContextSnapshot(),this.createLoopConfig(t),e=>this.processEvents(e),n,this.streamFunction)})}async runContinuation(){await this.runWithLifecycle(async e=>{await Oce(this.createContextSnapshot(),this.createLoopConfig(),e=>this.processEvents(e),e,this.streamFunction)})}createContextSnapshot(){return{systemPrompt:this._state.systemPrompt,messages:this._state.messages.slice(),tools:this._state.tools.slice()}}createLoopConfig(e={}){let t=e.skipInitialSteeringPoll===!0,n=this.shouldStopAfterTurn;return{model:this._state.model,reasoning:this._state.thinkingLevel===`off`?void 0:this._state.thinkingLevel,sessionId:this.sessionId,onPayload:this.onPayload,onResponse:this.onResponse,transport:this.transport,thinkingBudgets:this.thinkingBudgets,maxRetryDelayMs:this.maxRetryDelayMs,toolExecution:this.toolExecution,beforeToolCall:this.beforeToolCall,afterToolCall:this.afterToolCall,shouldStopAfterTurn:n?async e=>await n(e,this.signal):void 0,prepareNextTurn:this.prepareNextTurnWithContext||this.prepareNextTurn?async e=>this.prepareNextTurnWithContext?await this.prepareNextTurnWithContext(e,this.signal):await this.prepareNextTurn?.(this.signal):void 0,convertToLlm:this.convertToLlm,transformContext:this.transformContext,getApiKey:this.getApiKey,getSteeringMessages:async()=>t?(t=!1,[]):this.steeringQueue.drain(),getFollowUpMessages:async()=>this.followUpQueue.drain()}}async runWithLifecycle(e){if(this.activeRun)throw Error(`Agent is already processing.`);let t=new AbortController,n=()=>{},r=new Promise(e=>{n=e});this.activeRun={promise:r,resolve:n,abortController:t},this._state.isStreaming=!0,this._state.streamingMessage=void 0,this._state.errorMessage=void 0;try{await e(t.signal)}catch(e){await this.handleRunFailure(e,t.signal.aborted)}finally{this.finishRun()}}async handleRunFailure(e,t){let n={role:`assistant`,content:[{type:`text`,text:``}],api:this._state.model.api,provider:this._state.model.provider,model:this._state.model.id,usage:Ice,stopReason:t?`aborted`:`error`,errorMessage:e instanceof Error?e.message:String(e),timestamp:Date.now()};await this.processEvents({type:`message_start`,message:n}),await this.processEvents({type:`message_end`,message:n}),await this.processEvents({type:`turn_end`,message:n,toolResults:[]}),await this.processEvents({type:`agent_end`,messages:[n]})}finishRun(){this._state.isStreaming=!1,this._state.streamingMessage=void 0,this._state.pendingToolCalls=new Set,this.activeRun?.resolve(),this.activeRun=void 0}async processEvents(e){switch(e.type){case`message_start`:this._state.streamingMessage=e.message;break;case`message_update`:this._state.streamingMessage=e.message;break;case`message_end`:this._state.streamingMessage=void 0,this._state.messages.push(e.message);break;case`tool_execution_start`:{let t=new Set(this._state.pendingToolCalls);t.add(e.toolCallId),this._state.pendingToolCalls=t;break}case`tool_execution_end`:{let t=new Set(this._state.pendingToolCalls);t.delete(e.toolCallId),this._state.pendingToolCalls=t;break}case`turn_end`:e.message.role===`assistant`&&e.message.errorMessage&&(this._state.errorMessage=e.message.errorMessage);break;case`agent_end`:this._state.streamingMessage=void 0}let t=this.activeRun?.abortController.signal;if(!t)throw Error(`Agent listener invoked outside active run`);for(let n of this.listeners)await n(e,t)}};const Bce=Object.freeze({token:Symbol(`chord.abortSignal`)});var Vce=class{get abortSignal(){return this.value(Bce)}},hh=class extends Vce{#e;constructor(e){super(),this.#e=e}value(e){}toString(){return this.#e}};new hh(`[Context BACKGROUND_CONTEXT]`),new hh(`[Context TODO_CONTEXT]`);function Hce(e){return Object.freeze({token:Symbol(e)})}Hce(`pi.telemetryContext`);const gh={"pi.session.id":{type:`string`,required:!0,cardinality:`high`,description:`Session id`},"pi.lane.name":{type:`string`,required:!0,cardinality:`high`,description:`Lane name`},"pi.operation.id":{type:`string`,required:!0,cardinality:`high`,description:`Durable operation id`},"pi.operation.recovery":{type:`boolean`,required:!0,description:`Whether this invocation resumes durable work`}},_h={"pi.error.code":{type:`string`,cardinality:`low`,description:`Stable operation error code`},"pi.error.type":{type:`string`,cardinality:`low`,description:`Low-cardinality operation error class`}};({...gh}),{..._h},{...gh},{..._h},{...gh},{..._h};function Uce(e,t){if(e.length===0)throw TypeError(`Value namespace must not be empty`);if(e.includes(`\0`))throw TypeError(`Value namespace must not contain \\u0000`);if(t.includes(`\0`))throw TypeError(`Value key must not contain \\u0000`)}function Wce(e,t=``){return Uce(e,t),Object.freeze({namespace:e,key:t,kind:`value`})}Wce(`pi.session.name`);const vh=Symbol.for(`yaml.alias`),Gce=Symbol.for(`yaml.document`),yh=Symbol.for(`yaml.map`),bh=Symbol.for(`yaml.pair`),xh=Symbol.for(`yaml.scalar`),Sh=Symbol.for(`yaml.seq`),Ch=Symbol.for(`yaml.node.type`),wh=e=>!!e&&typeof e==`object`&&e[Ch]===vh,Th=e=>!!e&&typeof e==`object`&&e[Ch]===Gce,Eh=e=>!!e&&typeof e==`object`&&e[Ch]===yh,Dh=e=>!!e&&typeof e==`object`&&e[Ch]===bh,Oh=e=>!!e&&typeof e==`object`&&e[Ch]===xh,kh=e=>!!e&&typeof e==`object`&&e[Ch]===Sh;function Ah(e){if(e&&typeof e==`object`)switch(e[Ch]){case yh:case Sh:return!0}return!1}function jh(e){if(e&&typeof e==`object`)switch(e[Ch]){case vh:case yh:case xh:case Sh:return!0}return!1}const Mh=e=>(Oh(e)||Ah(e))&&!!e.anchor,Nh=Symbol(`break visit`),Kce=Symbol(`skip children`),Ph=Symbol(`remove node`);function Fh(e,t){let n=qce(t);Th(e)?Ih(null,e.contents,n,Object.freeze([e]))===Ph&&(e.contents=null):Ih(null,e,n,Object.freeze([]))}Fh.BREAK=Nh,Fh.SKIP=Kce,Fh.REMOVE=Ph;function Ih(e,t,n,r){let i=Jce(e,t,n,r);if(jh(i)||Dh(i))return Yce(e,r,i),Ih(e,i,n,r);if(typeof i!=`symbol`){if(Ah(t)){r=Object.freeze(r.concat(t));for(let e=0;ezh(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!Mh(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var Bh=class{constructor(e){Object.defineProperty(this,Ch,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!Th(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=zh(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?Rh(i,{"":o},``,o):o}},Xce=class extends Bh{constructor(e){super(vh),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],Fh(e,{Node:(e,t)=>{(wh(t)||Mh(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}return r}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,a=this.resolve(r,t);if(!a){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let o=n.get(a);if(o||=(zh(a,null,t),n.get(a)),o?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(o.count+=1,o.aliasCount===0&&(o.aliasCount=Vh(r,a,n)),o.count*o.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return o.res}toString(e,t,n){let r=`*${this.source}`;if(e){if(Lh(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function Vh(e,t,n){if(wh(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(Ah(t)){let r=0;for(let i of t.items){let t=Vh(e,i,n);t>r&&(r=t)}return r}if(Dh(t)){let r=Vh(e,t.key,n),i=Vh(e,t.value,n);return Math.max(r,i)}return 1}const Hh=e=>!e||typeof e!=`function`&&typeof e!=`object`;var Uh=class extends Bh{constructor(e){super(xh),this.value=e}toJSON(e,t){return t?.keep?this.value:zh(this.value,e,t)}toString(){return String(this.value)}};Uh.BLOCK_FOLDED=`BLOCK_FOLDED`,Uh.BLOCK_LITERAL=`BLOCK_LITERAL`,Uh.PLAIN=`PLAIN`,Uh.QUOTE_DOUBLE=`QUOTE_DOUBLE`,Uh.QUOTE_SINGLE=`QUOTE_SINGLE`;function Zce(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function Wh(e,t,n){if(Th(e)&&(e=e.contents),jh(e))return e;if(Dh(e)){let t=n.schema[yh].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??(c.anchor=i(e)),new Xce(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=`tag:yaml.org,2002:`+t.slice(2));let l=Zce(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new Uh(e);return c&&(c.node=t),t}l=e instanceof Map?o[yh]:Symbol.iterator in Object(e)?o[Sh]:o[yh]}a&&(a(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==`function`?l.nodeClass.from(n.schema,e,n):new Uh(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function Gh(e,t,n){let r=n;for(let e=t.length-1;e>=0;--e){let n=t[e];if(typeof n==`number`&&Number.isInteger(n)&&n>=0){let e=[];e[n]=r,r=e}else r=new Map([[n,r]])}return Wh(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}const Qce=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;var Kh=class extends Bh{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>jh(t)||Dh(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Qce(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(Ah(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,Gh(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(Ah(r))return r.deleteIn(n);throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);return r.length===0?!t&&Oh(i)?i.value:i:Ah(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!Dh(t))return!1;let n=t.value;return n==null||e&&Oh(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return Ah(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let e=this.get(n,!0);if(Ah(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,Gh(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}};const $ce=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function qh(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}const Jh=(e,t,n)=>e.endsWith(` `)?qh(n,t):n.includes(` `)?` `+qh(n,t):(e.endsWith(` `)?``:` `)+n,Yh=`flow`;function Xh(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;ii-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=Zh(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===` `)n===`block`&&(h=Zh(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==` `&&p!==` `){let t=e[h+1];t&&t!==` `&&t!==` `&&t!==` `&&(f=h)}if(h>=d){if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),$h=e=>/^(%|---|\.\.\.)/m.test(e);function ele(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;tr)return!0;if(n=t+1,i-n<=r)return!1}return!0}function eg(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||($h(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length `;let d,f;for(f=n.length;f>0;--f){let e=n[f-1];if(e!==` `&&e!==` `&&e!==` `)break}let p=n.substring(f),m=p.indexOf(` `);m===-1?d=`-`:n===p||m!==p.length-1?(d=`+`,a&&a()):d=``,p&&=(n=n.slice(0,-p.length),p[p.length-1]===` `&&(p=p.slice(0,-1)),p.replace(rg,`$&${l}`));let h=!1,g,_=-1;for(g=0;g{i=!0});let s=Xh(`${v}${e}${p}`,l,`block`,a);if(!i)return`>${y}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}\n${l}${v}${n}${p}`}function tle(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(` `)||u&&/[[\]{},]/.test(a))return ng(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(` `)?ng(a,t):ig(e,t,n,r);if(!s&&!u&&i!==Uh.PLAIN&&a.includes(` `))return ig(e,t,n,r);if($h(a)){if(c===``)return t.forceBlockIndent=!0,ig(e,t,n,r);if(s&&c===l)return ng(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return ng(a,t)}return s?d:Xh(d,c,Yh,Qh(t,!1))}function nle(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==Uh.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=Uh.QUOTE_DOUBLE);let c=e=>{switch(e){case Uh.BLOCK_FOLDED:case Uh.BLOCK_LITERAL:return i||a?ng(o.value,t):ig(o,t,n,r);case Uh.QUOTE_DOUBLE:return eg(o.value,t);case Uh.QUOTE_SINGLE:return tg(o.value,t);case Uh.PLAIN:return tle(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function rle(e,t){let n=Object.assign({blockQuote:!0,commentString:$ce,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function ile(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(Oh(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(r===null?`null`:typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}function ale(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(Oh(e)||Ah(e))&&e.anchor;a&&Lh(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&i.push(r.directives.tagString(o)),i.join(` `)}function ag(e,t,n,r){if(Dh(e))return e.toString(t,n,r);if(wh(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=jh(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=ile(t.doc.schema.tags,a);let o=ale(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):Oh(a)?nle(a,t,n,r):a.toString(t,n,r);return o?Oh(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function ole({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=jh(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(Ah(e)||!jh(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||Ah(e)||(Oh(e)?e.type===Uh.BLOCK_FOLDED||e.type===Uh.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=ag(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=Jh(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=Jh(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=Jh(g,n.indent,l(f))));let _,v,y;jh(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&Oh(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&kh(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=ag(t,n,()=>b=!0,()=>h=!0),S=` `;if(f||_||v){if(S=_?` `:``,v){let e=l(v);S+=`\n${qh(e,n.indent)}`}x===``&&!n.inFlow?S===` `&&y&&(S=` `):S+=`\n${n.indent}`}else if(!p&&Ah(t)){let e=x[0],r=x.indexOf(` `),i=r!==-1,a=n.inFlow??t.flow??t.items.length===0;if(i||!a){let t=!1;if(i&&(e===`&`||e===`!`)){let n=x.indexOf(` `);e===`&`&&n!==-1&&ne===`<<`||typeof e==`symbol`&&e.description===`<<`,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new Uh(Symbol(`<<`)),{addToJSMap:sg}),stringify:()=>`<<`},cle=(e,t)=>(og.identify(t)||Oh(t)&&(!t.type||t.type===Uh.PLAIN)&&og.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===og.tag&&e.default);function sg(e,t,n){let r=lg(e,n);if(kh(r))for(let n of r.items)cg(e,t,n);else if(Array.isArray(r))for(let n of r)cg(e,t,n);else cg(e,t,r)}function cg(e,t,n){let r=lg(e,n);if(!Eh(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function lg(e,t){return e&&wh(t)?t.resolve(e.doc,e):t}function ug(e,t,{key:n,value:r}){if(jh(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(cle(e,n))sg(e,t,r);else{let i=zh(n,``,e);if(t instanceof Map)t.set(i,zh(r,i,e));else if(t instanceof Set)t.add(i);else{let a=lle(n,i,e),o=zh(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function lle(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(jh(e)&&n?.doc){let t=rle(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),sle(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function dg(e,t,n){return new fg(Wh(e,void 0,n),Wh(t,void 0,n))}var fg=class e{constructor(e,t=null){Object.defineProperty(this,Ch,{value:bh}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return jh(n)&&(n=n.clone(t)),jh(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return ug(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?ole(this,e,t,n):JSON.stringify(this)}};function pg(e,t,n){return(t.inFlow??e.flow?dle:ule)(e,t,n)}function ule({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;eo=null,()=>d=!0);o&&(s+=Jh(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;ea=null);l||=d.length>u||o.includes(` `),n0&&(l||=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth),l&&(o+=`,`)),a&&(o+=Jh(o,r,s(a))),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:` `;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function mg({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=qh(t(r),e);n.push(i.trimStart())}}function hg(e,t){let n=Oh(t)?t.value:t;for(let r of e)if(Dh(r)&&(r.key===t||r.key===n||Oh(r.key)&&r.key.value===n))return r}var gg=class extends Kh{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(yh,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(dg(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=Dh(e)?e:!e||typeof e!=`object`||!(`key`in e)?new fg(e,e?.value):new fg(e.key,e.value);let r=hg(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);Oh(r.value)&&Hh(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=hg(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=hg(this.items,e)?.value;return(!t&&Oh(n)?n.value:n)??void 0}has(e){return!!hg(this.items,e)}set(e,t){this.add(new fg(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)ug(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!Dh(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),pg(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}};const fle={collection:`map`,default:!0,nodeClass:gg,tag:`tag:yaml.org,2002:map`,resolve(e,t){return Eh(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>gg.from(e,t,n)};var _g=class extends Kh{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(Sh,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=vg(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=vg(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&Oh(r)?r.value:r}has(e){let t=vg(e);return typeof t==`number`&&t=0?t:null}const ple={collection:`seq`,default:!0,nodeClass:_g,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return kh(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>_g.from(e,t,n)};function yg(e){return typeof e==`bigint`||Number.isInteger(e)}const bg=({value:e})=>JSON.stringify(e),mle=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:bg},{identify:e=>e==null,createNode:()=>new Uh(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:bg},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:bg},{identify:yg,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>yg(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:bg}];[fle,ple].concat(mle,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}});function hle(e,t,n){let{replacer:r}=n,i=new _g(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(dg(o,s,n))}return i}var gle=class e extends _g{constructor(){super(),this.add=gg.prototype.add.bind(this),this.delete=gg.prototype.delete.bind(this),this.get=gg.prototype.get.bind(this),this.has=gg.prototype.has.bind(this),this.set=gg.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(Dh(e)?(r=zh(e.key,``,t),i=zh(e.value,r,t)):r=zh(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=hle(e,t,n),i=new this;return i.items=r.items,i}};gle.tag=`tag:yaml.org,2002:omap`;var _le=class e extends gg{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=Dh(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new fg(e.key,null):new fg(e,null),hg(this.items,t.key)||this.items.push(t)}get(e,t){let n=hg(this.items,e);return!t&&Dh(n)?Oh(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=hg(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new fg(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof r==`function`&&(e=r.call(t,e,e)),i.items.push(dg(e,null,n));return i}};_le.tag=`tag:yaml.org,2002:set`;const xg=Symbol(`break visit`),vle=Symbol(`skip children`),Sg=Symbol(`remove item`);function Cg(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),wg(Object.freeze([]),e,t)}Cg.BREAK=xg,Cg.SKIP=vle,Cg.REMOVE=Sg,Cg.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},Cg.parentCollection=(e,t)=>{let n=Cg.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function wg(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t{function n(e){return Array.isArray(e)?e:[e]}let r=/^\s+$/,i=/(?:[^\\]|^)\\$/,a=/^\\!/,o=/^\\#/,s=/\r?\n/g,c=/^\.{0,2}\/|^\.{1,2}$/,l=/\/$/,u=`node-ignore`;typeof Symbol<`u`&&(u=Symbol.for(`node-ignore`));let d=u,f=(e,t,n)=>(Object.defineProperty(e,t,{value:n}),n),p=/([0-z])-([0-z])/g,m=()=>!1,h=e=>e.replace(p,(e,t,n)=>t.charCodeAt(0)<=n.charCodeAt(0)?e:``),g=e=>{let{length:t}=e;return e.slice(0,t-t%2)},_=[[/^\uFEFF/,()=>``],[/((?:\\\\)*?)(\\?\s+)$/,(e,t,n)=>t+(n.indexOf(`\\`)===0?` `:``)],[/(\\+?)\s/g,(e,t)=>{let{length:n}=t;return t.slice(0,n-n%2)+` `}],[/[\\$.|*+(){^]/g,e=>`\\${e}`],[/(?!\\)\?/g,()=>`[^/]`],[/^\//,()=>`^`],[/\//g,()=>`\\/`],[/^\^*\\\*\\\*\\\//,()=>`^(?:.*\\/)?`],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?`^`:`(?:^|\\/)`}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(e,t,n)=>t+6t+n.replace(/\\\*/g,`[^\\/]*`)],[/\\\\\\(?=[$.|*+(){^])/g,()=>`\\`],[/\\\\/g,()=>`\\`],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(e,t,n,r,i)=>t===`\\`?`\\[${n}${g(r)}${i}`:i===`]`&&r.length%2==0?`[${h(n)}${r}]`:`[]`],[/(?:[^*])$/,e=>/\/$/.test(e)?`${e}$`:`${e}(?=$|\\/$)`]],v=/(^|\\\/)?\\\*$/,y=`regex`,b=`checkRegex`,x={[y](e,t){return`${t?`${t}[^/]+`:`[^/]*`}(?=$|\\/$)`},[b](e,t){return`${t?`${t}[^/]*`:`[^/]*`}(?=$|\\/$)`}},S=e=>_.reduce((t,[n,r])=>t.replace(n,r.bind(e)),e),C=e=>typeof e==`string`,w=e=>e&&C(e)&&!r.test(e)&&!i.test(e)&&e.indexOf(`#`)!==0,T=e=>e.split(s).filter(Boolean);var E=class{constructor(e,t,n,r,i,a){this.pattern=e,this.mark=t,this.negative=i,f(this,`body`,n),f(this,`ignoreCase`,r),f(this,`regexPrefix`,a)}get regex(){let e=`_regex`;return this[e]?this[e]:this._make(y,e)}get checkRegex(){let e=`_checkRegex`;return this[e]?this[e]:this._make(b,e)}_make(e,t){let n=this.regexPrefix.replace(v,x[e]),r=this.ignoreCase?new RegExp(n,`i`):new RegExp(n);return f(this,t,r)}};let D=({pattern:e,mark:t},n)=>{let r=!1,i=e;i.indexOf(`!`)===0&&(r=!0,i=i.substr(1)),i=i.replace(a,`!`).replace(o,`#`);let s=S(i);return new E(e,t,i,n,r,s)};var O=class{constructor(e){this._ignoreCase=e,this._rules=[]}_add(e){if(e&&e[d]){this._rules=this._rules.concat(e._rules._rules),this._added=!0;return}if(C(e)&&(e={pattern:e}),w(e.pattern)){let t=D(e,this._ignoreCase);this._added=!0,this._rules.push(t)}}add(e){return this._added=!1,n(C(e)?T(e):e).forEach(this._add,this),this._added}test(e,t,n){let r=!1,i=!1,a;this._rules.forEach(o=>{let{negative:s}=o;i===s&&r!==i||s&&!r&&!i&&!t||o[n].test(e)&&(r=!s,i=s,a=s?void 0:o)});let o={ignored:r,unignored:i};return a&&(o.rule=a),o}};let k=(e,t)=>{throw new t(e)},A=(e,t,n)=>C(e)?e?!A.isNotRelative(e)||n(`path should be a \`path.relative()\`d string, but got "${t}"`,RangeError):n(`path must not be empty`,TypeError):n(`path must be a string, but got \`${t}\``,TypeError),j=e=>c.test(e);A.isNotRelative=j,A.convert=e=>e;var M=class{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:n=!1}={}){f(this,d,!0),this._rules=new O(t),this._strictPathCheck=!n,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(e){return this._rules.add(e)&&this._initCache(),this}addPattern(e){return this.add(e)}_test(e,t,n,r){let i=e&&A.convert(e);return A(i,e,this._strictPathCheck?k:m),this._t(i,t,n,r)}checkIgnore(e){if(!l.test(e))return this.test(e);let t=e.split(`/`).filter(Boolean);if(t.pop(),t.length){let e=this._t(t.join(`/`)+`/`,this._testCache,!0,t);if(e.ignored)return e}return this._rules.test(e,!1,b)}_t(e,t,n,r){if(e in t)return t[e];if(r||=e.split(`/`).filter(Boolean),r.pop(),!r.length)return t[e]=this._rules.test(e,n,y);let i=this._t(r.join(`/`)+`/`,t,n,r);return t[e]=i.ignored?i:this._rules.test(e,n,y)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return n(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}};let ee=e=>new M(e),te=e=>A(e&&A.convert(e),e,m),N=()=>{A.convert=e=>/^\\\\\?\\/.test(e)||/["<>|\u0000-\u001F]+/u.test(e)?e:e.replace(/\\/g,`/`);let e=/^[a-z]:\//i;A.isNotRelative=t=>e.test(t)||j(t)};typeof process<`u`&&process.platform===`win32`&&N(),t.exports=ee,ee.default=ee,t.exports.isPathValid=te,f(t.exports,Symbol.for(`setupWindows`),N)}))(),globalThis.Buffer,new TextEncoder,new TextDecoder,Sn({command:Yr({description:`Bash command to execute`}),timeout:_n(Gr({description:`Timeout in seconds (optional, no default timeout)`}))});var Tg=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}};new class extends Tg{};function Eg(e,t){let n=0;for(;nt.length&&(n=e.length-t.length);let r=t.length;e.length0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function Ng(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function Pg(e,t){if(t)return Ig(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function Fg(e,t){if(t)return Ig(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function Ig(e,t){if(!t)return[Fg(e),Pg(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=Ng(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}const Lg=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,ble=RegExp(`[${Lg}]+|\\s+|[^${Lg}]`,`ug`);new class extends Tg{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=Ng(e,r)}else n=e.match(ble)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&Rg(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&Rg(n,i,r,null,t.intlSegmenter),e}};function Rg(e,t,n,r,i){if(t&&n){let[a,o]=Ig(t.value,i),[s,c]=Ig(n.value,i);if(e){let r=Eg(a,s);e.value=kg(e.value,s,r),t.value=Ag(t.value,r),n.value=Ag(n.value,r)}if(r){let e=Dg(o,c);r.value=Og(r.value,c,e),t.value=jg(t.value,e),n.value=jg(n.value,e)}}else if(n){if(e){let e=Fg(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=Fg(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=Fg(r.value,i),[a,o]=Ig(t.value,i),s=Eg(n,a);t.value=Ag(t.value,s);let c=Dg(Ag(n,s),o);t.value=jg(t.value,c),r.value=Og(r.value,n,c),e.value=kg(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=Fg(r.value,i),n=Mg(Pg(t.value,i),e);t.value=jg(t.value,n)}else if(e){let n=Mg(Pg(e.value,i),Fg(t.value,i));t.value=Ag(t.value,n)}}new class extends Tg{tokenize(e){let t=RegExp(`(\\r?\\n)|[${Lg}]+|[^\\S\\n\\r]+|[^${Lg}]`,`ug`);return e.match(t)||[]}};const xle=new class extends Tg{constructor(){super(...arguments),this.tokenize=Bg}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(` `))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(` `))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(` `)&&(e=e.slice(0,-1)),t.endsWith(` `)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function zg(e,t,n){return xle.diff(e,t,n)}function Bg(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,` `));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;et===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify(Vg(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};function Vg(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a=0;for(;a{let n=l(t);e(n)}}))}else return l(zg(n,r,s));function l(n){if(!n)return;n.push({value:``,lines:[]});function r(e){return e.map(function(e){return` `+e})}let o=[],s=0,l=0,u=[],d=1,f=1;for(let e=0;e0?r(t.lines.slice(-c)):[],s-=u.length,l-=u.length)}for(let e of i)u.push((t.added?`+`:`-`)+e);t.added?f+=i.length:d+=i.length}else{if(s){if(i.length<=c*2&&e1&&!t.includeFileHeaders)throw Error(`Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)`);return e.map(e=>Ug(e,t)).join(` `)}let n=[];t.includeIndex&&e.oldFileName==e.newFileName&&n.push(`Index: `+e.oldFileName),t.includeUnderline&&n.push(`===================================================================`),t.includeFileHeaders&&(n.push(`--- `+e.oldFileName+(e.oldHeader===void 0?``:` `+e.oldHeader)),n.push(`+++ `+e.newFileName+(e.newHeader===void 0?``:` `+e.newHeader)));for(let t=0;t{s(e?Ug(e,o.headerOptions):void 0)}}))}else{let s=Hg(e,t,n,r,i,a,o);return s?Ug(s,o?.headerOptions):void 0}}function Tle(e){let t=e.endsWith(` `),n=e.split(` `).map(e=>e+` `);return t?n.pop():n.push(n.pop().slice(0,-1)),n}const Ele=Sn({oldText:Yr({description:`Exact text for one targeted replacement. It must be unique in the original file and must not overlap with any other edits[].oldText in the same call.`}),newText:Yr({description:`Replacement text for this targeted edit.`})},{});Sn({path:Yr({description:`Path to the file to edit (relative or absolute)`}),edits:Qt(Ele,{description:`One or more targeted replacements. Each edit is matched against the original file, not incrementally. Do not include overlapping or nested edits. If two changes touch the same block or nearby lines, merge them into one edit instead.`})},{}),Sn({path:Yr({description:`Path to the file to read (relative or absolute)`}),offset:_n(Gr({description:`Line number to start reading from (1-indexed)`})),limit:_n(Gr({description:`Maximum number of lines to read`}))}),Sn({path:Yr({description:`Path to the file to write (relative or absolute)`}),content:Yr({description:`Content to write to the file`})});var Dle=n({InferenceSession:()=>j_,TRACE:()=>C_,TRACE_EVENT_BEGIN:()=>D_,TRACE_EVENT_END:()=>O_,TRACE_FUNC_BEGIN:()=>T_,TRACE_FUNC_END:()=>E_,Tensor:()=>x_,default:()=>Yy,env:()=>i_,registerBackend:()=>Xg}),Wg=Object.defineProperty,Ole=Object.getOwnPropertyDescriptor,kle=Object.getOwnPropertyNames,Ale=Object.prototype.hasOwnProperty,jle=(e=>typeof r<`u`?r:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof r<`u`?r:e)[t]}):e)(function(e){ /*! * ONNX Runtime Web v1.26.0-dev.20260416-b7804b056c * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ if(typeof r<`u`)return r.apply(this,arguments);throw Error(`Dynamic require of "`+e+`" is not supported`)}),Gg=(e,t)=>()=>(e&&(t=e(e=0)),t),Kg=(e,t)=>{for(var n in t)Wg(e,n,{get:t[n],enumerable:!0})},Mle=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of kle(t))!Ale.call(e,i)&&i!==n&&Wg(e,i,{get:()=>t[i],enumerable:!(r=Ole(t,i))||r.enumerable});return e},qg=e=>Mle(Wg({},`__esModule`,{value:!0}),e),Jg,Yg,Xg,Zg,Qg,$g=Gg(()=>{Jg=new Map,Yg=[],Xg=(e,t,n)=>{if(t&&typeof t.init==`function`&&typeof t.createInferenceSessionHandler==`function`){let r=Jg.get(e);if(r===void 0)Jg.set(e,{backend:t,priority:n});else{if(r.priority>n)return;if(r.priority===n&&r.backend!==t)throw Error(`cannot register backend "${e}" using priority ${n}`)}if(n>=0){let t=Yg.indexOf(e);t!==-1&&Yg.splice(t,1);for(let t=0;t{let t=Jg.get(e);if(!t)return`backend not found.`;if(t.initialized)return t.backend;if(t.aborted)return t.error;{let n=!!t.initPromise;try{return n||(t.initPromise=t.backend.init(e)),await t.initPromise,t.initialized=!0,t.backend}catch(e){return n||(t.error=`${e}`,t.aborted=!0),t.error}finally{delete t.initPromise}}},Qg=async e=>{let t=e.executionProviders||[],n=t.map(e=>typeof e==`string`?e:e.name),r=n.length===0?Yg:n,i,a=[],o=new Set;for(let e of r){let t=await Zg(e);typeof t==`string`?a.push({name:e,err:t}):(i||=t,i===t&&o.add(e))}if(!i)throw Error(`no available backend found. ERR: ${a.map(e=>`[${e.name}] ${e.err}`).join(`, `)}`);for(let{name:e,err:t}of a)n.includes(e)&&console.warn(`removing requested execution provider "${e}" from session options because it is not available: ${t}`);let s=t.filter(e=>o.has(typeof e==`string`?e:e.name));return[i,new Proxy(e,{get:(e,t)=>t===`executionProviders`?s:Reflect.get(e,t)})]}}),Nle=Gg(()=>{$g()}),e_,Ple=Gg(()=>{e_=`1.24.0-dev.20251116-b39e144322`}),t_,n_,r_=Gg(()=>{Ple(),t_=`warning`,n_={wasm:{},webgl:{},webgpu:{},versions:{common:e_},set logLevel(e){if(e!==void 0){if(typeof e!=`string`||[`verbose`,`info`,`warning`,`error`,`fatal`].indexOf(e)===-1)throw Error(`Unsupported logging level: ${e}`);t_=e}},get logLevel(){return t_}},Object.defineProperty(n_,"logLevel",{enumerable:!0})}),i_,Fle=Gg(()=>{r_(),i_=n_}),a_,o_,Ile=Gg(()=>{a_=(e,t)=>{let n=typeof document<`u`?document.createElement(`canvas`):new OffscreenCanvas(1,1);n.width=e.dims[3],n.height=e.dims[2];let r=n.getContext(`2d`);if(r!=null){let i,a;t?.tensorLayout!==void 0&&t.tensorLayout===`NHWC`?(i=e.dims[2],a=e.dims[3]):(i=e.dims[3],a=e.dims[2]);let o=t?.format===void 0?`RGB`:t.format,s=t?.norm,c,l;s===void 0||s.mean===void 0?c=[255,255,255,255]:typeof s.mean==`number`?c=[s.mean,s.mean,s.mean,s.mean]:(c=[s.mean[0],s.mean[1],s.mean[2],0],s.mean[3]!==void 0&&(c[3]=s.mean[3])),s===void 0||s.bias===void 0?l=[0,0,0,0]:typeof s.bias==`number`?l=[s.bias,s.bias,s.bias,s.bias]:(l=[s.bias[0],s.bias[1],s.bias[2],0],s.bias[3]!==void 0&&(l[3]=s.bias[3]));let u=a*i,d=0,f=u,p=u*2,m=-1;o===`RGBA`?(d=0,f=u,p=u*2,m=u*3):o===`RGB`?(d=0,f=u,p=u*2):o===`RBG`&&(d=0,p=u,f=u*2);for(let t=0;t{let n=typeof document<`u`?document.createElement(`canvas`).getContext(`2d`):new OffscreenCanvas(1,1).getContext(`2d`),r;if(n!=null){let i,a,o;t?.tensorLayout!==void 0&&t.tensorLayout===`NHWC`?(i=e.dims[2],a=e.dims[1],o=e.dims[3]):(i=e.dims[3],a=e.dims[2],o=e.dims[1]);let s=t!==void 0&&t.format!==void 0?t.format:`RGB`,c=t?.norm,l,u;c===void 0||c.mean===void 0?l=[255,255,255,255]:typeof c.mean==`number`?l=[c.mean,c.mean,c.mean,c.mean]:(l=[c.mean[0],c.mean[1],c.mean[2],255],c.mean[3]!==void 0&&(l[3]=c.mean[3])),c===void 0||c.bias===void 0?u=[0,0,0,0]:typeof c.bias==`number`?u=[c.bias,c.bias,c.bias,c.bias]:(u=[c.bias[0],c.bias[1],c.bias[2],0],c.bias[3]!==void 0&&(u[3]=c.bias[3]));let d=a*i;if(t!==void 0&&(t.format!==void 0&&o===4&&t.format!==`RGBA`||o===3&&t.format!==`RGB`&&t.format!==`BGR`))throw Error(`Tensor format doesn't match input tensor dims`);let f=0,p=1,m=2,h=3,g=0,_=d,v=d*2,y=-1;s===`RGBA`?(g=0,_=d,v=d*2,y=d*3):s===`RGB`?(g=0,_=d,v=d*2):s===`RBG`&&(g=0,v=d,_=d*2),r=n.createImageData(i,a);for(let t=0;t{b_(),s_=(e,t)=>{if(e===void 0)throw Error(`Image buffer must be defined`);if(t.height===void 0||t.width===void 0)throw Error(`Image height and width must be defined`);if(t.tensorLayout===`NHWC`)throw Error(`NHWC Tensor layout is not supported yet`);let{height:n,width:r}=t,i=t.norm??{mean:255,bias:0},a,o;a=typeof i.mean==`number`?[i.mean,i.mean,i.mean,i.mean]:[i.mean[0],i.mean[1],i.mean[2],i.mean[3]??255],o=typeof i.bias==`number`?[i.bias,i.bias,i.bias,i.bias]:[i.bias[0],i.bias[1],i.bias[2],i.bias[3]??0];let s=t.format===void 0?`RGBA`:t.format,c=t.tensorFormat!==void 0&&t.tensorFormat!==void 0?t.tensorFormat:`RGB`,l=n*r,u=c===`RGBA`?new Float32Array(l*4):new Float32Array(l*3),d=4,f=0,p=1,m=2,h=3,g=0,_=l,v=l*2,y=-1;s===`RGB`&&(d=3,f=0,p=1,m=2,h=-1),c===`RGBA`?y=l*3:c===`RBG`?(g=0,v=l,_=l*2):c===`BGR`&&(v=0,_=l,g=l*2);for(let t=0;t{let n=typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement,r=typeof ImageData<`u`&&e instanceof ImageData,i=typeof ImageBitmap<`u`&&e instanceof ImageBitmap,a=typeof e==`string`,o,s=t??{},c=()=>{if(typeof document<`u`)return document.createElement(`canvas`);if(typeof OffscreenCanvas<`u`)return new OffscreenCanvas(1,1);throw Error(`Canvas is not supported`)},l=e=>typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||e instanceof OffscreenCanvas?e.getContext(`2d`):null;if(n){let n=c();n.width=e.width,n.height=e.height;let r=l(n);if(r!=null){let n=e.height,i=e.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(n=t.resizedHeight,i=t.resizedWidth),t!==void 0){if(s=t,t.tensorFormat!==void 0)throw Error(`Image input config format must be RGBA for HTMLImageElement`);s.tensorFormat=`RGBA`,s.height=n,s.width=i}else s.tensorFormat=`RGBA`,s.height=n,s.width=i;r.drawImage(e,0,0),o=r.getImageData(0,0,i,n).data}else throw Error(`Can not access image data`)}else if(r){let n,r;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(n=t.resizedHeight,r=t.resizedWidth):(n=e.height,r=e.width),t!==void 0&&(s=t),s.format=`RGBA`,s.height=n,s.width=r,t!==void 0){let t=c();t.width=r,t.height=n;let i=l(t);if(i!=null)i.putImageData(e,0,0),o=i.getImageData(0,0,r,n).data;else throw Error(`Can not access image data`)}else o=e.data}else if(i){if(t===void 0)throw Error(`Please provide image config with format for Imagebitmap`);let n=c();n.width=e.width,n.height=e.height;let r=l(n);if(r!=null){let t=e.height,n=e.width;return r.drawImage(e,0,0,n,t),o=r.getImageData(0,0,n,t).data,s.height=t,s.width=n,s_(o,s)}throw Error(`Can not access image data`)}else{if(a)return new Promise((t,n)=>{let r=c(),i=l(r);if(!e||!i)return n();let a=new Image;a.crossOrigin=`Anonymous`,a.src=e,a.onload=()=>{r.width=a.width,r.height=a.height,i.drawImage(a,0,0,r.width,r.height);let e=i.getImageData(0,0,r.width,r.height);s.height=r.height,s.width=r.width,t(s_(e.data,s))}});throw Error(`Input data provided is not supported - aborted tensor creation`)}if(o!==void 0)return s_(o,s);throw Error(`Input data provided is not supported - aborted tensor creation`)},l_=(e,t)=>{let{width:n,height:r,download:i,dispose:a}=t;return new y_({location:`texture`,type:`float32`,texture:e,dims:[1,r,n,4],download:i,dispose:a})},u_=(e,t)=>{let{dataType:n,dims:r,download:i,dispose:a}=t;return new y_({location:`gpu-buffer`,type:n??`float32`,gpuBuffer:e,dims:r,download:i,dispose:a})},d_=(e,t)=>{let{dataType:n,dims:r,download:i,dispose:a}=t;return new y_({location:`ml-tensor`,type:n??`float32`,mlTensor:e,dims:r,download:i,dispose:a})},f_=(e,t,n)=>new y_({location:`cpu-pinned`,type:e,data:t,dims:n??[t.length]})}),p_,m_,h_,g_,Rle=Gg(()=>{p_=new Map([[`float32`,Float32Array],[`uint8`,Uint8Array],[`int8`,Int8Array],[`uint16`,Uint16Array],[`int16`,Int16Array],[`int32`,Int32Array],[`bool`,Uint8Array],[`float64`,Float64Array],[`uint32`,Uint32Array],[`int4`,Uint8Array],[`uint4`,Uint8Array]]),m_=new Map([[Float32Array,`float32`],[Uint8Array,`uint8`],[Int8Array,`int8`],[Uint16Array,`uint16`],[Int16Array,`int16`],[Int32Array,`int32`],[Float64Array,`float64`],[Uint32Array,`uint32`]]),h_=!1,g_=()=>{if(!h_){h_=!0;let e=typeof BigInt64Array<`u`&&BigInt64Array.from,t=typeof BigUint64Array<`u`&&BigUint64Array.from,n=globalThis.Float16Array,r=typeof n<`u`&&n.from;e&&(p_.set(`int64`,BigInt64Array),m_.set(BigInt64Array,`int64`)),t&&(p_.set(`uint64`,BigUint64Array),m_.set(BigUint64Array,`uint64`)),r?(p_.set(`float16`,n),m_.set(n,`float16`)):p_.set(`float16`,Uint16Array)}}}),__,v_,zle=Gg(()=>{b_(),__=e=>{let t=1;for(let n=0;n{switch(e.location){case`cpu`:return new y_(e.type,e.data,t);case`cpu-pinned`:return new y_({location:`cpu-pinned`,data:e.data,type:e.type,dims:t});case`texture`:return new y_({location:`texture`,texture:e.texture,type:e.type,dims:t});case`gpu-buffer`:return new y_({location:`gpu-buffer`,gpuBuffer:e.gpuBuffer,type:e.type,dims:t});case`ml-tensor`:return new y_({location:`ml-tensor`,mlTensor:e.mlTensor,type:e.type,dims:t});default:throw Error(`tensorReshape: tensor location ${e.location} is not supported`)}}}),y_,b_=Gg(()=>{Ile(),Lle(),Rle(),zle(),y_=class{constructor(e,t,n){g_();let r,i;if(typeof e==`object`&&`location`in e)switch(this.dataLocation=e.location,r=e.type,i=e.dims,e.location){case`cpu-pinned`:{let t=p_.get(r);if(!t)throw TypeError(`unsupported type "${r}" to create tensor from pinned buffer`);if(!(e.data instanceof t))throw TypeError(`buffer should be of type ${t.name}`);this.cpuData=e.data;break}case`texture`:if(r!==`float32`)throw TypeError(`unsupported type "${r}" to create tensor from texture`);this.gpuTextureData=e.texture,this.downloader=e.download,this.disposer=e.dispose;break;case`gpu-buffer`:if(r!==`float32`&&r!==`float16`&&r!==`int32`&&r!==`int64`&&r!==`uint32`&&r!==`uint8`&&r!==`bool`&&r!==`uint4`&&r!==`int4`)throw TypeError(`unsupported type "${r}" to create tensor from gpu buffer`);this.gpuBufferData=e.gpuBuffer,this.downloader=e.download,this.disposer=e.dispose;break;case`ml-tensor`:if(r!==`float32`&&r!==`float16`&&r!==`int32`&&r!==`int64`&&r!==`uint32`&&r!==`uint64`&&r!==`int8`&&r!==`uint8`&&r!==`bool`&&r!==`uint4`&&r!==`int4`)throw TypeError(`unsupported type "${r}" to create tensor from MLTensor`);this.mlTensorData=e.mlTensor,this.downloader=e.download,this.disposer=e.dispose;break;default:throw Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let a,o;if(typeof e==`string`){if(r=e,o=n,e===`string`){if(!Array.isArray(t))throw TypeError(`A string tensor's data must be a string array.`);a=t}else{let n=p_.get(e);if(n===void 0)throw TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(t)){if(e===`float16`&&n===Uint16Array||e===`uint4`||e===`int4`)throw TypeError(`Creating a ${e} tensor from number array is not supported. Please use ${n.name} as data.`);a=e===`uint64`||e===`int64`?n.from(t,BigInt):n.from(t)}else if(t instanceof n)a=t;else if(t instanceof Uint8ClampedArray){if(e===`uint8`)a=Uint8Array.from(t);else throw TypeError(`A Uint8ClampedArray tensor's data must be type of uint8`)}else if(e===`float16`&&t instanceof Uint16Array&&n!==Uint16Array)a=new globalThis.Float16Array(t.buffer,t.byteOffset,t.length);else throw TypeError(`A ${r} tensor's data must be type of ${n}`)}}else if(o=t,Array.isArray(e)){if(e.length===0)throw TypeError(`Tensor type cannot be inferred from an empty array.`);let t=typeof e[0];if(t===`string`)r=`string`,a=e;else if(t===`boolean`)r=`bool`,a=Uint8Array.from(e);else throw TypeError(`Invalid element type of data array: ${t}.`)}else if(e instanceof Uint8ClampedArray)r=`uint8`,a=Uint8Array.from(e);else{let t=m_.get(e.constructor);if(t===void 0)throw TypeError(`Unsupported type for tensor data: ${e.constructor}.`);r=t,a=e}if(o===void 0)o=[a.length];else if(!Array.isArray(o))throw TypeError(`A tensor's dims must be a number array`);i=o,this.cpuData=a,this.dataLocation=`cpu`}let a=__(i);if(this.cpuData&&a!==this.cpuData.length&&(r!==`uint4`&&r!==`int4`||Math.ceil(a/2)!==this.cpuData.length))throw Error(`Tensor's size(${a}) does not match data length(${this.cpuData.length}).`);this.type=r,this.dims=i,this.size=a}static async fromImage(e,t){return c_(e,t)}static fromTexture(e,t){return l_(e,t)}static fromGpuBuffer(e,t){return u_(e,t)}static fromMLTensor(e,t){return d_(e,t)}static fromPinnedBuffer(e,t,n){return f_(e,t,n)}toDataURL(e){return a_(this,e)}toImageData(e){return o_(this,e)}get data(){if(this.ensureValid(),!this.cpuData)throw Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw Error(`The data is not stored as a WebGL texture.`);return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw Error(`The data is not stored as a WebGPU buffer.`);return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw Error(`The data is not stored as a WebNN MLTensor.`);return this.mlTensorData}async getData(e){switch(this.ensureValid(),this.dataLocation){case`cpu`:case`cpu-pinned`:return this.data;case`texture`:case`gpu-buffer`:case`ml-tensor`:if(!this.downloader)throw Error(`The current tensor is not created with a specified data downloader.`);if(this.isDownloading)throw Error(`The current tensor is being downloaded.`);try{this.isDownloading=!0;let t=await this.downloader();return this.downloader=void 0,this.dataLocation=`cpu`,this.cpuData=t,e&&this.disposer&&(this.disposer(),this.disposer=void 0),t}finally{this.isDownloading=!1}default:throw Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw Error(`The current tensor is being downloaded.`);this.disposer&&=(this.disposer(),void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation=`none`}ensureValid(){if(this.dataLocation===`none`)throw Error(`The tensor is disposed.`)}reshape(e){if(this.ensureValid(),this.downloader||this.disposer)throw Error(`Cannot reshape a tensor that owns GPU resource.`);return v_(this,e)}}}),x_,S_=Gg(()=>{b_(),x_=y_}),C_,w_,T_,E_,D_,O_,k_=Gg(()=>{r_(),C_=(e,t)=>{(typeof n_.trace>`u`?!n_.wasm.trace:!n_.trace)||console.timeStamp(`${e}::ORT::${t}`)},w_=(e,t)=>{let n=Error().stack?.split(/\r\n|\r|\n/g)||[],r=!1;for(let i=0;i{(typeof n_.trace>`u`?!n_.wasm.trace:!n_.trace)||w_(`BEGIN`,e)},E_=e=>{(typeof n_.trace>`u`?!n_.wasm.trace:!n_.trace)||w_(`END`,e)},D_=e=>{(typeof n_.trace>`u`?!n_.wasm.trace:!n_.trace)||console.time(`ORT::${e}`)},O_=e=>{(typeof n_.trace>`u`?!n_.wasm.trace:!n_.trace)||console.timeEnd(`ORT::${e}`)}}),A_,Ble=Gg(()=>{$g(),S_(),k_(),A_=class e{constructor(e){this.handler=e}async run(e,t,n){T_(),D_(`InferenceSession.run`);let r={},i={};if(typeof e!=`object`||!e||e instanceof x_||Array.isArray(e))throw TypeError(`'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.`);let a=!0;if(typeof t==`object`){if(t===null)throw TypeError(`Unexpected argument[1]: cannot be null.`);if(t instanceof x_)throw TypeError(`'fetches' cannot be a Tensor`);if(Array.isArray(t)){if(t.length===0)throw TypeError(`'fetches' cannot be an empty array.`);a=!1;for(let e of t){if(typeof e!=`string`)throw TypeError(`'fetches' must be a string array or an object.`);if(this.outputNames.indexOf(e)===-1)throw RangeError(`'fetches' contains invalid output name: ${e}.`);r[e]=null}if(typeof n==`object`&&n)i=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else{let e=!1,o=Object.getOwnPropertyNames(t);for(let n of this.outputNames)if(o.indexOf(n)!==-1){let i=t[n];(i===null||i instanceof x_)&&(e=!0,a=!1,r[n]=i)}if(e){if(typeof n==`object`&&n)i=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else i=t}}else if(typeof t<`u`)throw TypeError(`Unexpected argument[1]: must be 'fetches' or 'options'.`);for(let t of this.inputNames)if(typeof e[t]>`u`)throw Error(`input '${t}' is missing in 'feeds'.`);if(a)for(let e of this.outputNames)r[e]=null;let o=await this.handler.run(e,r,i),s={};for(let e in o)if(Object.hasOwnProperty.call(o,e)){let t=o[e];s[e]=t instanceof x_?t:new x_(t.type,t.data,t.dims)}return O_(`InferenceSession.run`),E_(),s}async release(){return this.handler.dispose()}static async create(t,n,r,i){T_(),D_(`InferenceSession.create`);let a,o={};if(typeof t==`string`){if(a=t,typeof n==`object`&&n)o=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else if(t instanceof Uint8Array){if(a=t,typeof n==`object`&&n)o=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&t instanceof SharedArrayBuffer){let e=t,s=0,c=t.byteLength;if(typeof n==`object`&&n)o=n;else if(typeof n==`number`){if(s=n,!Number.isSafeInteger(s))throw RangeError(`'byteOffset' must be an integer.`);if(s<0||s>=e.byteLength)throw RangeError(`'byteOffset' is out of range [0, ${e.byteLength}).`);if(c=t.byteLength-s,typeof r==`number`){if(c=r,!Number.isSafeInteger(c))throw RangeError(`'byteLength' must be an integer.`);if(c<=0||s+c>e.byteLength)throw RangeError(`'byteLength' is out of range (0, ${e.byteLength-s}].`);if(typeof i==`object`&&i)o=i;else if(typeof i<`u`)throw TypeError(`'options' must be an object.`)}else if(typeof r<`u`)throw TypeError(`'byteLength' must be a number.`)}else if(typeof n<`u`)throw TypeError(`'options' must be an object.`);a=new Uint8Array(e,s,c)}else throw TypeError(`Unexpected argument[0]: must be 'path' or 'buffer'.`);let[s,c]=await Qg(o),l=await s.createInferenceSessionHandler(a,c);return O_(`InferenceSession.create`),E_(),new e(l)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}get inputMetadata(){return this.handler.inputMetadata}get outputMetadata(){return this.handler.outputMetadata}}}),j_,Vle=Gg(()=>{Ble(),j_=A_}),Hle=Gg(()=>{}),Ule=Gg(()=>{}),Wle=Gg(()=>{}),Gle=Gg(()=>{}),M_={};Kg(M_,{InferenceSession:()=>j_,TRACE:()=>C_,TRACE_EVENT_BEGIN:()=>D_,TRACE_EVENT_END:()=>O_,TRACE_FUNC_BEGIN:()=>T_,TRACE_FUNC_END:()=>E_,Tensor:()=>x_,env:()=>i_,registerBackend:()=>Xg});var N_=Gg(()=>{Nle(),Fle(),Vle(),S_(),Hle(),Ule(),k_(),Wle(),Gle()}),P_=Gg(()=>{}),F_={};Kg(F_,{default:()=>R_});var I_,L_,R_,Kle=Gg(()=>{by(),pv(),rv(),I_=`ort-wasm-proxy-worker`,L_=globalThis.self?.name===I_,L_&&(self.onmessage=e=>{let{type:t,in:n}=e.data;try{switch(t){case`init-wasm`:dv(n.wasm).then(()=>{cy(n).then(()=>{postMessage({type:t})},e=>{postMessage({type:t,err:e})})},e=>{postMessage({type:t,err:e})});break;case`init-ep`:{let{epName:e,env:r}=n;ly(r,e).then(()=>{postMessage({type:t})},e=>{postMessage({type:t,err:e})});break}case`copy-from`:{let{buffer:e}=n,r=py(e);postMessage({type:t,out:r});break}case`create`:{let{model:e,options:r}=n;my(e,r).then(e=>{postMessage({type:t,out:e})},e=>{postMessage({type:t,err:e})});break}case`release`:hy(n),postMessage({type:t});break;case`run`:{let{sessionId:e,inputIndices:r,inputs:i,outputIndices:a,options:o}=n;_y(e,r,i,a,Array(a.length).fill(null),o).then(e=>{e.some(e=>e[3]!==`cpu`)?postMessage({type:t,err:`Proxy does not support non-cpu tensor location.`}):postMessage({type:t,out:e},yy([...i,...e]))},e=>{postMessage({type:t,err:e})});break}case`end-profiling`:vy(n),postMessage({type:t})}}catch(e){postMessage({type:t,err:e})}}),R_=L_?null:e=>new Worker(e??K_,{type:`module`,name:I_})}),z_={};Kg(z_,{default:()=>V_});async function B_(e={}){var t=e,n=!!globalThis.window,r=!!globalThis.WorkerGlobalScope,i=r&&self.name?.startsWith(`em-pthread`);t.mountExternalData=(e,n)=>{e.startsWith(`./`)&&(e=e.substring(2)),(t.Uc||=new Map).set(e,n)},t.unmountExternalData=()=>{delete t.Uc},globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,shared:!0}).buffer.constructor;let a=()=>{let e=e=>(...t)=>{let n=rn;return t=e(...t),rn==n?t:new Promise((e,t)=>{dn={resolve:e,reject:t}})};(()=>{for(let n of[`_OrtAppendExecutionProvider`,`_OrtCreateSession`,`_OrtRun`,`_OrtRunWithBinding`,`_OrtBindInput`])t[n]=e(t[n])})(),typeof jsepRunAsync<`u`&&(t._OrtRun=jsepRunAsync(t._OrtRun),t._OrtRunWithBinding=jsepRunAsync(t._OrtRunWithBinding)),a=void 0};t.asyncInit=()=>{a?.()};var o,s,c=(e,t)=>{throw t},l=import.meta.url,u=``;if(n||r){try{u=new URL(`.`,l).href}catch{}r&&(s=e=>{var t=new XMLHttpRequest;return t.open(`GET`,e,!1),t.responseType=`arraybuffer`,t.send(null),new Uint8Array(t.response)}),o=async e=>{if(S(e))return new Promise((t,n)=>{var r=new XMLHttpRequest;r.open(`GET`,e,!0),r.responseType=`arraybuffer`,r.onload=()=>{r.status==200||r.status==0&&r.response?t(r.response):n(r.status)},r.onerror=n,r.send(null)});var t=await fetch(e,{credentials:`same-origin`});if(t.ok)return t.arrayBuffer();throw Error(t.status+` : `+t.url)}}var d,f,p,m,h,g,_=console.log.bind(console),v=console.error.bind(console),y=_,b=v,x=!1,S=e=>e.startsWith(`file://`);function C(){Te.buffer!=T.buffer&&re()}if(i){let e=function(n){try{var r=n.data,i=r.Oc;if(i===`load`){let n=[];self.onmessage=e=>n.push(e),g=()=>{postMessage({Oc:`loaded`});for(let t of n)e(t);self.onmessage=e};for(let e of r.ce)t[e]&&!t[e].proxy||(t[e]=(...t)=>{postMessage({Oc:`callHandler`,be:e,args:t})},e==`print`&&(y=t[e]),e==`printErr`&&(b=t[e]));Te=r.ie,re(),f=r.je,se(),zo()}else if(i===`run`){(function(e){var t=(C(),A)[e+52>>>2>>>0];e=(C(),A)[e+56>>>2>>>0],aa(t,t-e),oa(t)})(r.Nc),Yi(r.Nc,0,0,1,0,0),Se(),Kt(r.Nc),w||=(Ei(),!0);try{Ee(r.ge,r.Wc)}catch(e){if(e!=`unwind`)throw e}}else r.target!==`setimmediate`&&(i===`checkMailbox`?w&&qt():i&&(b(`worker: received unknown command ${i}`),b(r)))}catch(e){throw Xi(),e}};var w=!1;self.onunhandledrejection=e=>{throw e.reason||e},self.onmessage=e}var T,E,D,O,k,A,j,M,ee,te,N,ne=!1;function re(){var e=Te.buffer;t.HEAP8=T=new Int8Array(e),D=new Int16Array(e),t.HEAPU8=E=new Uint8Array(e),O=new Uint16Array(e),t.HEAP32=k=new Int32Array(e),t.HEAPU32=A=new Uint32Array(e),j=new Float32Array(e),M=new Float64Array(e),ee=new BigInt64Array(e),te=new BigUint64Array(e)}function ie(){ne=!0,i?g():$a._b()}function ae(e){throw b(e=`Aborted(`+e+`)`),x=!0,e=new WebAssembly.RuntimeError(e+`. Build with -sASSERTIONS for more info.`),h?.(e),e}function oe(){return{a:{f:Ae,J:Me,k:Le,p:Re,l:ze,sa:Be,b:Ve,ca:He,Ja:We,q:Ge,da:Xe,Za:Ze,Fa:Qe,Ha:$e,_a:et,Xa:tt,Qa:nt,Wa:rt,oa:it,Ga:at,Xb:ot,Ya:st,Yb:ct,db:lt,Da:_t,Sb:vt,Qb:Et,Ca:Ot,M:kt,I:At,Rb:Nt,ja:Vt,Tb:Ht,Ta:Ut,Vb:Jt,Ka:Xt,Ob:Zt,ka:Qt,Sa:Kt,ab:$t,U:mn,n:xn,c:xt,rb:Sn,w:Cn,L:wn,z:Tn,j:En,o:Dn,sb:On,G:kn,T:An,h:jn,u:Mn,m:Nn,i:Pn,Na:Fn,Oa:zn,Pa:Bn,La:Vn,Ma:Hn,Pb:Gn,eb:Kn,cb:Yn,Y:Qn,qb:$n,la:er,bb:qn,fb:tr,$a:nr,Wb:rr,N:Wn,gb:ir,X:ar,Ub:or,nb:Or,C:kr,ra:Ar,qa:jr,pb:Mr,W:Nr,v:Pr,mb:Fr,lb:Ir,kb:Lr,ob:Rr,jb:zr,ib:Br,hb:Vr,Ua:Gr,Va:Kr,Ia:_e,V:qr,na:Jr,Ra:Yr,ma:Zr,Cb:Lo,xa:jo,Db:Io,ya:Ao,F:yo,e:ao,s:ro,x:no,B:go,Fb:Do,ba:Eo,D:co,za:Oo,$:Mo,ga:To,Gb:wo,Hb:Co,Ba:bo,Aa:So,Ib:xo,wa:Fo,aa:ko,d:io,A:so,r:oo,Bb:Ro,t:uo,y:_o,H:lo,E:fo,K:vo,R:No,ia:ho,_:Po,Jb:mo,Kb:po,g:Qr,a:Te,Nb:P,Eb:$r,ha:ei,O:ti,pa:ni,Lb:ri,ta:ii,Q:ai,yb:oi,zb:si,ua:ci,ea:li,P:ui,Ea:di,va:fi,Z:pi,wb:mi,Zb:hi,S:gi,Ab:_i,tb:vi,ub:bi,vb:xi,fa:Si,xb:Ci,Mb:wi}}}async function se(){function e(e,n){var r=$a=e.exports;e={};for(let[t,n]of Object.entries(r))typeof n==`function`?(r=tn(n),e[t]=r):e[t]=n;return $a=e,$a=function(){var e=$a,t=e=>t=>e(t)>>>0,n=e=>()=>e()>>>0;return(e=Object.assign({},e)).$b=t(e.$b),e.Cc=n(e.Cc),e.Ec=t(e.Ec),e.rd=(e=>(t,n)=>e(t,n)>>>0)(e.rd),e.wd=t(e.wd),e.xd=n(e.xd),e.Bd=t(e.Bd),e}(),ye.push($a.id),Ti=(e=$a).$b,Ei=e.ac,t._OrtInit=e.bc,t._OrtGetLastError=e.cc,t._OrtCreateSessionOptions=e.dc,t._OrtAppendExecutionProvider=e.ec,t._OrtAddFreeDimensionOverride=e.fc,t._OrtAddSessionConfigEntry=e.gc,t._OrtReleaseSessionOptions=e.hc,t._OrtCreateSession=e.ic,t._OrtReleaseSession=e.jc,t._OrtGetInputOutputCount=e.kc,t._OrtGetInputOutputMetadata=e.lc,t._OrtFree=e.mc,t._OrtCreateTensor=e.nc,t._OrtGetTensorData=e.oc,t._OrtReleaseTensor=e.pc,t._OrtCreateRunOptions=e.qc,t._OrtAddRunConfigEntry=e.rc,t._OrtReleaseRunOptions=e.sc,t._OrtCreateBinding=e.tc,t._OrtBindInput=e.uc,t._OrtBindOutput=e.vc,t._OrtClearBoundOutputs=e.wc,t._OrtReleaseBinding=e.xc,t._OrtRunWithBinding=e.yc,t._OrtRun=e.zc,t._OrtEndProfiling=e.Ac,Di=t._OrtGetWebGpuDevice=e.Bc,Oi=e.Cc,ki=t._free=e.Dc,Ai=t._malloc=e.Ec,ji=t._wgpuBufferRelease=e.Fc,Mi=t._wgpuCreateInstance=e.Gc,Ni=e.Hc,Pi=e.Ic,Fi=e.Jc,Ii=e.Kc,Li=e.Lc,Ri=e.Pc,zi=e.Zc,Bi=e._c,Vi=e.$c,Hi=e.bd,Ui=e.cd,Wi=e.dd,Gi=e.ed,Ki=e.fd,qi=e.gd,Ji=e.hd,Yi=e.kd,Xi=e.ld,Zi=e.md,Qi=e.nd,$i=e.od,ea=e.pd,ta=e.qd,na=e.rd,ra=e.sd,ia=e.td,aa=e.ud,oa=e.vd,sa=e.wd,ca=e.xd,la=e.yd,ua=e.zd,da=e.Ad,fa=e.Bd,pa=e.Cd,ma=e.Dd,ha=e.Ed,ga=e.Fd,_a=e.Gd,va=e.Hd,ya=e.Id,ba=e.Jd,xa=e.Kd,Sa=e.Ld,Ca=e.Md,wa=e.Nd,Ta=e.Od,Ea=e.Pd,Da=e.Qd,Oa=e.Rd,ka=e.Td,Aa=e.Ud,ja=e.Vd,Ma=e.Wd,Na=e.Yd,Pa=e.Zd,Fa=e._d,Ia=e.$d,La=e.ae,Ra=e.oe,za=e.pe,Ba=e.qe,Va=e.re,Ha=e.se,Ua=e.te,Wa=e.ue,Ga=e.ve,Ka=e.we,qa=e.xe,Ja=e.ye,Ya=e.Ye,Xa=e.Ze,Za=e._e,Qa=e.$e,f=n,$a}var n,r=oe();return t.instantiateWasm?new Promise(n=>{t.instantiateWasm(r,(t,r)=>{n(e(t,r))})}):i?e(new WebAssembly.Instance(f,oe()),f):(N??=t.locateFile?t.locateFile?t.locateFile(`ort-wasm-simd-threaded.asyncify.wasm`,u):u+`ort-wasm-simd-threaded.asyncify.wasm`:new URL(new URL(`ort-wasm-simd-threaded.asyncify-DMmc6YqF.wasm`,import.meta.url).href,``+import.meta.url).href,n=await async function(e){var t=N;if(!d&&!S(t))try{var n=fetch(t,{credentials:`same-origin`});return await WebAssembly.instantiateStreaming(n,e)}catch(e){b(`wasm streaming compile failed: ${e}`),b(`falling back to ArrayBuffer instantiation`)}return async function(e,t){try{var n=await async function(e){if(!d)try{var t=await o(e);return new Uint8Array(t)}catch{}if(e==N&&d)e=new Uint8Array(d);else{if(!s)throw`both async and sync fetching of the wasm failed`;e=s(e)}return e}(e);return await WebAssembly.instantiate(n,t)}catch(e){b(`failed to asynchronously prepare wasm: ${e}`),ae(e)}}(t,e)}(r),e(n.instance,n.module))}class ce{name=`ExitStatus`;constructor(e){this.message=`Program terminated with exit(${e})`,this.status=e}}var le=e=>{e.terminate(),e.onmessage=()=>{}},ue=[],de=0,fe=null,pe=e=>{F.length==0&&(we(),Ce(F[0]));var t=F.pop();if(!t)return 6;ve.push(t),be[e.Nc]=t,t.Nc=e.Nc;var n={Oc:`run`,ge:e.fe,Wc:e.Wc,Nc:e.Nc};return t.postMessage(n,e.Yc),0},me=0,he=(e,t,...n)=>{var r,i=16*n.length,a=ca(),o=sa(i),s=o>>>3;for(r of n)typeof r==`bigint`?((C(),ee)[s++>>>0]=1n,(C(),ee)[s++>>>0]=r):((C(),ee)[s++>>>0]=0n,(C(),M)[s++>>>0]=r);return e=Zi(e,0,i,o,t),oa(a),e};function P(e){if(i)return he(0,1,e);if(p=e,!(0{if(p=e,i)throw ge(e),`unwind`;P(e)},F=[],ve=[],ye=[],be={},xe=e=>{var t=e.Nc;delete be[t],F.push(e),ve.splice(ve.indexOf(e),1),e.Nc=0,Qi(t)};function Se(){ye.forEach(e=>e())}var Ce=e=>new Promise(n=>{e.onmessage=r=>{var i=r.data;if(r=i.Oc,i.Vc&&i.Vc!=Oi()){var a=be[i.Vc];a?a.postMessage(i,i.Yc):b(`Internal error! Worker sent a message "${r}" to target pthread ${i.Vc}, but that thread no longer exists!`)}else r===`checkMailbox`?qt():r===`spawnThread`?pe(i):r===`cleanupThread`?Wt(()=>{xe(be[i.he])}):r===`loaded`?(e.loaded=!0,n(e)):i.target===`setimmediate`?e.postMessage(i):r===`uncaughtException`?e.onerror(i.error):r===`callHandler`?t[i.be](...i.args):r&&b(`worker sent an unknown command ${r}`)},e.onerror=e=>{throw b(`worker sent an error! ${e.filename}:${e.lineno}: ${e.message}`),e};var r,i=[];for(r of[])t.propertyIsEnumerable(r)&&i.push(r);e.postMessage({Oc:`load`,ce:i,ie:Te,je:f})});function we(){var e=new Worker((()=>{let e=URL;return import.meta.url>`file:`&&import.meta.url<`file;`?new e(`ort.webgpu.bundle.min.mjs`,import.meta.url):new URL(import.meta.url)})(),{type:`module`,workerData:`em-pthread`,name:`em-pthread`});F.push(e)}var Te,Ee=(e,t)=>{me=0,e=ma(e,t),0-9007199254740992>e||9007199254740992>>=0);return(C(),T)[t.Qc+12>>>0]==0&&(Ne(t,!0),Oe--),Pe(t,!1),De.push(t),fa(e)}var je=0,Me=()=>{ra(0,0);var e=De.pop();la(e.Xc),je=0};function Ne(e,t){t=+!!t,(C(),T)[e.Qc+12>>>0]=t}function Pe(e,t){t=+!!t,(C(),T)[e.Qc+13>>>0]=t}class Fe{constructor(e){this.Xc=e,this.Qc=e-24}}var Ie=e=>{var t=je;if(!t)return ia(0),0;var n=new Fe(t);(C(),A)[n.Qc+16>>>2>>>0]=t;var r=(C(),A)[n.Qc+4>>>2>>>0];if(!r)return ia(0),t;for(var i of e){if(i===0||i===r)break;if(da(i,r,n.Qc+16))return ia(i),t}return ia(r),t};function Le(){return Ie([])}function Re(e){return Ie([e>>>0])}function ze(e,t,n,r){return Ie([e>>>0,t>>>0,n>>>0,r>>>0])}var Be=()=>{var e=De.pop();e||ae(`no exception to throw`);var t=e.Xc;throw(C(),T)[e.Qc+13>>>0]==0&&(De.push(e),Pe(e,!0),Ne(e,!1),Oe++),ua(t),je=t};function Ve(e,t,n){var r=new Fe(e>>>=0);throw t>>>=0,n>>>=0,(C(),A)[r.Qc+16>>>2>>>0]=0,(C(),A)[r.Qc+4>>>2>>>0]=t,(C(),A)[r.Qc+8>>>2>>>0]=n,ua(e),Oe++,je=e}var He=()=>Oe;function Ue(e,t,n,r){return i?he(2,1,e,t,n,r):We(e,t,n,r)}function We(e,t,n,r){if(e>>>=0,t>>>=0,n>>>=0,r>>>=0,!globalThis.SharedArrayBuffer)return 6;var a=[];return i&&a.length===0?Ue(e,t,n,r):(e={fe:n,Nc:e,Wc:r,Yc:a},i?(e.Oc=`spawnThread`,postMessage(e,a),0):pe(e))}function Ge(e){throw je||=e>>>0,je}var Ke=globalThis.TextDecoder&&new TextDecoder,qe=(e,t,n,r)=>{if(n=t+n,r)return n;for(;e[t]&&!(t>=n);)++t;return t},Je=(e,t=0,n,r)=>{if(16<(n=qe(e,t>>>=0,n,r))-t&&e.buffer&&Ke)return Ke.decode(e.buffer instanceof ArrayBuffer?e.subarray(t,n):e.slice(t,n));for(r=``;t(i=(240&i)==224?(15&i)<<12|a<<6|o:(7&i)<<18|a<<12|o<<6|63&e[t++])?r+=String.fromCharCode(i):(i-=65536,r+=String.fromCharCode(55296|i>>10,56320|1023&i))}}else r+=String.fromCharCode(i)}return r},Ye=(e,t,n)=>(e>>>=0)?Je((C(),E),e,t,n):``;function Xe(e,t,n){return i?he(3,1,e,t,n):0}function Ze(e,t){if(i)return he(4,1,e,t)}function Qe(e,t){if(i)return he(5,1,e,t)}function $e(e,t,n){if(i)return he(6,1,e,t,n)}function et(e,t,n){return i?he(7,1,e,t,n):0}function tt(e,t){if(i)return he(8,1,e,t)}function nt(e,t,n){if(i)return he(9,1,e,t,n)}function rt(e,t,n,r){if(i)return he(10,1,e,t,n,r)}function it(e,t,n,r){if(i)return he(11,1,e,t,n,r)}function at(e,t,n,r){if(i)return he(12,1,e,t,n,r)}function ot(e){if(i)return he(13,1,e)}function st(e,t){if(i)return he(14,1,e,t)}function ct(e,t,n){if(i)return he(15,1,e,t,n)}var lt=()=>ae(``),ut=e=>{e>>>=0;for(var t=``;;){var n=(C(),E)[e++>>>0];if(!n)return t;t+=String.fromCharCode(n)}},dt={},ft={},pt={},mt=class extends Error{constructor(e){super(e),this.name=`BindingError`}};function ht(e,t,n={}){return function(e,t,n={}){var r=t.name;if(!e)throw new mt(`type "${r}" must have a positive integer typeid pointer`);if(ft.hasOwnProperty(e)){if(n.de)return;throw new mt(`Cannot register type '${r}' twice`)}ft[e]=t,delete pt[e],dt.hasOwnProperty(e)&&(t=dt[e],delete dt[e],t.forEach(e=>e()))}(e,t,n)}var gt=(e,t,n)=>{switch(t){case 1:return n?e=>(C(),T)[e>>>0]:e=>(C(),E)[e>>>0];case 2:return n?e=>(C(),D)[e>>>1>>>0]:e=>(C(),O)[e>>>1>>>0];case 4:return n?e=>(C(),k)[e>>>2>>>0]:e=>(C(),A)[e>>>2>>>0];case 8:return n?e=>(C(),ee)[e>>>3>>>0]:e=>(C(),te)[e>>>3>>>0];default:throw TypeError(`invalid integer width (${t}): ${e}`)}};function _t(e,t,n,r,i){e>>>=0,n>>>=0,t=ut(t>>>0);let a=e=>e;if(r=r===0n){let e=8*n;a=t=>BigInt.asUintN(e,t),i=a(i)}ht(e,{name:t,Mc:a,Sc:(e,t)=>(typeof t==`number`&&(t=BigInt(t)),t),Rc:gt(t,n,!r),Tc:null})}function vt(e,t,n,r){ht(e>>>=0,{name:t=ut(t>>>0),Mc:function(e){return!!e},Sc:function(e,t){return t?n:r},Rc:function(e){return this.Mc((C(),E)[e>>>0])},Tc:null})}var yt=[],bt=[0,1,,1,null,1,!0,1,!1,1];function xt(e){9<(e>>>=0)&&--bt[e+1]==0&&(bt[e]=void 0,yt.push(e))}var St=e=>{if(!e)throw new mt(`Cannot use deleted val. handle = ${e}`);return bt[e]},Ct=e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let t=yt.pop()||bt.length;return bt[t]=e,bt[t+1]=1,t}};function wt(e){return this.Mc((C(),A)[e>>>2>>>0])}var Tt={name:`emscripten::val`,Mc:e=>{var t=St(e);return xt(e),t},Sc:(e,t)=>Ct(t),Rc:wt,Tc:null};function Et(e){return ht(e>>>0,Tt)}var Dt=(e,t)=>{switch(t){case 4:return function(e){return this.Mc((C(),j)[e>>>2>>>0])};case 8:return function(e){return this.Mc((C(),M)[e>>>3>>>0])};default:throw TypeError(`invalid float width (${t}): ${e}`)}};function Ot(e,t,n){n>>>=0,ht(e>>>=0,{name:t=ut(t>>>0),Mc:e=>e,Sc:(e,t)=>t,Rc:Dt(t,n),Tc:null})}function kt(e,t,n,r,i){e>>>=0,n>>>=0,t=ut(t>>>0);let a=e=>e;if(r===0){var o=32-8*n;a=e=>e<>>o,i=a(i)}ht(e,{name:t,Mc:a,Sc:(e,t)=>t,Rc:gt(t,n,r!==0),Tc:null})}function At(e,t,n){function r(e){var t=(C(),A)[e>>>2>>>0];return e=(C(),A)[e+4>>>2>>>0],new i((C(),T).buffer,e,t)}var i=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][t];ht(e>>>=0,{name:n=ut(n>>>0),Mc:r,Rc:r},{de:!0})}var jt=(e,t,n)=>{var r=(C(),E);if(t>>>=0,0=o){if(t>=n)break;r[t++>>>0]=o}else if(2047>=o){if(t+1>=n)break;r[t++>>>0]=192|o>>6,r[t++>>>0]=128|63&o}else if(65535>=o){if(t+2>=n)break;r[t++>>>0]=224|o>>12,r[t++>>>0]=128|o>>6&63,r[t++>>>0]=128|63&o}else{if(t+3>=n)break;r[t++>>>0]=240|o>>18,r[t++>>>0]=128|o>>12&63,r[t++>>>0]=128|o>>6&63,r[t++>>>0]=128|63&o,a++}}r[t>>>0]=0,e=t-i}else e=0;return e},Mt=e=>{for(var t=0,n=0;n=r?t++:2047>=r?t+=2:55296<=r&&57343>=r?(t+=4,++n):t+=3}return t};function Nt(e,t){ht(e>>>=0,{name:t=ut(t>>>0),Mc(e){var t=(C(),A)[e>>>2>>>0];return t=Ye(e+4,t,!0),ki(e),t},Sc(e,t){t instanceof ArrayBuffer&&(t=new Uint8Array(t));var n=typeof t==`string`;if(!(n||ArrayBuffer.isView(t)&&t.BYTES_PER_ELEMENT==1))throw new mt(`Cannot pass non-string to std::string`);var r=n?Mt(t):t.length,i=Ai(4+r+1),a=i+4;return(C(),A)[i>>>2>>>0]=r,n?jt(t,a,r+1):(C(),E).set(t,a>>>0),e!==null&&e.push(ki,i),i},Rc:wt,Tc(e){ki(e)}})}var Pt=globalThis.TextDecoder?new TextDecoder(`utf-16le`):void 0,Ft=(e,t,n)=>{if(e>>>=1,16<(t=qe((C(),O),e,t/2,n))-e&&Pt)return Pt.decode((C(),O).slice(e,t));for(n=``;e>>0];n+=String.fromCharCode(r)}return n},It=(e,t,n)=>{if(n??=2147483647,2>n)return 0;var r=t;n=(n-=2)<2*e.length?n/2:e.length;for(var i=0;i>>1>>>0]=a,t+=2}return(C(),D)[t>>>1>>>0]=0,t-r},Lt=e=>2*e.length,Rt=(e,t,n)=>{var r=``;e>>>=2;for(var i=0;!(i>=t/4);i++){var a=(C(),A)[e+i>>>0];if(!a&&!n)break;r+=String.fromCodePoint(a)}return r},zt=(e,t,n)=>{if(t>>>=0,n??=2147483647,4>n)return 0;var r=t;n=r+n-4;for(var i=0;i>>2>>>0]=a,(t+=4)+4>n)break}return(C(),k)[t>>>2>>>0]=0,t-r},Bt=e=>{for(var t=0,n=0;n>>=0,t>>>=0,n=ut(n>>>=0),t===2)var r=Ft,i=It,a=Lt;else r=Rt,i=zt,a=Bt;ht(e,{name:n,Mc:e=>{var n=(C(),A)[e>>>2>>>0];return n=r(e+4,n*t,!0),ki(e),n},Sc:(e,r)=>{if(typeof r!=`string`)throw new mt(`Cannot pass non-string to C++ string type ${n}`);var o=a(r),s=Ai(4+o+t);return(C(),A)[s>>>2>>>0]=o/t,i(r,s+4,o+t),e!==null&&e.push(ki,s),s},Rc:wt,Tc(e){ki(e)}})}function Ht(e,t){ht(e>>>=0,{ee:!0,name:t=ut(t>>>0),Mc:()=>{},Sc:()=>{}})}function Ut(e){Yi(e>>>0,!r,1,!n,131072,!1),Se()}var Wt=e=>{if(!x)try{if(e(),!(0Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2]);function Kt(e){e>>>=0,Gt||(Atomics.waitAsync((C(),k),e>>>2,e).value.then(qt),e+=128,Atomics.store((C(),k),e>>>2,1))}var qt=()=>Wt(()=>{var e=Oi();e&&(Kt(e),ta())});function Jt(e,t){(e>>>=0)==t>>>0?setTimeout(qt):i?postMessage({Vc:e,Oc:`checkMailbox`}):(e=be[e])&&e.postMessage({Oc:`checkMailbox`})}var Yt=[];function Xt(e,t,n,r,i){for(t>>>=0,i>>>=0,Yt.length=0,n=i>>>3,r=i+r>>>3;n>>0]?(C(),ee)[n++>>>0]:(C(),M)[n++>>>0];Yt.push(a)}return(t?to[t]:eo[e])(...Yt)}var Zt=()=>{me=0};function Qt(e){e>>>=0,i?postMessage({Oc:`cleanupThread`,he:e}):xe(be[e])}function $t(e){}var en=e=>{try{e()}catch(e){ae(e)}};function tn(e){var t=(...t)=>{on.push(e);try{return e(...t)}finally{x||(on.pop(),rn&&nn===1&&on.length===0&&(nn=0,me+=1,en(Xa),typeof Fibers<`u`&&Fibers.Be()))}};return ln.set(e,t),t}var nn=0,rn=null,an=0,on=[],sn=new Map,cn=new Map,ln=new Map,un=0,dn=null,fn=[],pn=e=>function(e){if(!x){if(nn===0){var t=!1,n=!1;e((e=0)=>{if(!x&&(an=e,t=!0,n)){nn=2,en(()=>Za(rn)),typeof MainLoop<`u`&&MainLoop.Xd&&MainLoop.resume(),e=!1;try{var r=function(){var e=(C(),k)[rn+8>>>2>>>0];return e=cn.get(e),e=ln.get(e),--me,e()}()}catch(t){r=t,e=!0}var i=!1;if(!rn){var a=dn;a&&(dn=null,(e?a.reject:a.resolve)(r),i=!0)}if(e&&!i)throw r}}),n=!0,t||(nn=1,rn=function(){var e=Ai(65548),t=e+12;if((C(),A)[e>>>2>>>0]=t,(C(),A)[e+4>>>2>>>0]=t+65536,t=on[0],!sn.has(t)){var n=un++;sn.set(t,n),cn.set(n,t)}return t=sn.get(t),(C(),k)[e+8>>>2>>>0]=t,e}(),typeof MainLoop<`u`&&MainLoop.Xd&&MainLoop.pause(),en(()=>Ya(rn)))}else nn===2?(nn=0,en(Qa),ki(rn),rn=null,fn.forEach(Wt)):ae(`invalid state: ${nn}`);return an}}(t=>{e().then(t)});function mn(e){return e>>>=0,pn(async()=>Ct(await St(e)))}var hn=[],gn=e=>{var t=hn.length;return hn.push(e),t},_n=(e,t)=>{for(var n=Array(e),r=0;r>>2>>>0],o=ft[a];if(o===void 0)throw e=`parameter ${r}`,a=Ti(a),t=ut(a),ki(a),new mt(`${e} has unknown type ${t}`);n[i]=o}return n},vn=(e,t,n)=>{var r=[];return e=e(r,n),r.length&&((C(),A)[t>>>2>>>0]=Ct(r)),e},yn={},bn=e=>{var t=yn[e];return t===void 0?ut(e):t};function xn(e,t,n){var[r,...i]=_n(e,t>>>0);t=r.Sc.bind(r);var a=i.map(e=>e.Rc.bind(e));e--;var o={toValue:St};switch(e=a.map((e,t)=>{var n=`argFromPtr${t}`;return o[n]=e,`${n}(args${t?`+`+8*t:``})`}),n){case 0:var s=`toValue(handle)`;break;case 2:s=`new (toValue(handle))`;break;case 3:s=``;break;case 1:o.getStringOrSymbol=bn,s=`toValue(handle)[getStringOrSymbol(methodName)]`}return s+=`(${e})`,r.ee||(o.toReturnWire=t,o.emval_returnValue=vn,s=`return emval_returnValue(toReturnWire, destructorsRef, ${s})`),s=`return function (handle, methodName, destructorsRef, args) { ${s} }`,n=Function(Object.keys(o),s)(...Object.values(o)),s=`methodCaller<(${i.map(e=>e.name)}) => ${r.name}>`,gn(Object.defineProperty(n,"name",{value:s}))}function Sn(e,t){return t>>>=0,(e=St(e>>>0))==St(t)}function Cn(e){return(e>>>=0)?(e=bn(e),Ct(globalThis[e])):Ct(globalThis)}function wn(e){return e=bn(e>>>0),Ct(t[e])}function Tn(e,t){return t>>>=0,e=St(e>>>0),t=St(t),Ct(e[t])}function En(e){9<(e>>>=0)&&(bt[e+1]+=1)}function Dn(e,t,n,r,i){return hn[e>>>0](t>>>0,n>>>0,r>>>0,i>>>0)}function On(e,t,n,r,i){return Dn(e>>>0,t>>>0,n>>>0,r>>>0,i>>>0)}function kn(){return Ct([])}function An(e){e=St(e>>>0);for(var t=Array(e.length),n=0;n>>0))}function Mn(){return Ct({})}function Nn(e){for(var t=St(e>>>=0);t.length;){var n=t.pop();t.pop()(n)}xt(e)}function Pn(e,t,n){t>>>=0,n>>>=0,e=St(e>>>0),t=St(t),n=St(n),e[t]=n}function Fn(e,t){e=ke(e),t>>>=0,e=new Date(1e3*e),(C(),k)[t>>>2>>>0]=e.getUTCSeconds(),(C(),k)[t+4>>>2>>>0]=e.getUTCMinutes(),(C(),k)[t+8>>>2>>>0]=e.getUTCHours(),(C(),k)[t+12>>>2>>>0]=e.getUTCDate(),(C(),k)[t+16>>>2>>>0]=e.getUTCMonth(),(C(),k)[t+20>>>2>>>0]=e.getUTCFullYear()-1900,(C(),k)[t+24>>>2>>>0]=e.getUTCDay(),e=(e.getTime()-Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,(C(),k)[t+28>>>2>>>0]=e}var In=e=>e%4==0&&(e%100!=0||e%400==0),Ln=[0,31,60,91,121,152,182,213,244,274,305,335],Rn=[0,31,59,90,120,151,181,212,243,273,304,334];function zn(e,t){e=ke(e),t>>>=0,e=new Date(1e3*e),(C(),k)[t>>>2>>>0]=e.getSeconds(),(C(),k)[t+4>>>2>>>0]=e.getMinutes(),(C(),k)[t+8>>>2>>>0]=e.getHours(),(C(),k)[t+12>>>2>>>0]=e.getDate(),(C(),k)[t+16>>>2>>>0]=e.getMonth(),(C(),k)[t+20>>>2>>>0]=e.getFullYear()-1900,(C(),k)[t+24>>>2>>>0]=e.getDay();var n=(In(e.getFullYear())?Ln:Rn)[e.getMonth()]+e.getDate()-1|0;(C(),k)[t+28>>>2>>>0]=n,(C(),k)[t+36>>>2>>>0]=-60*e.getTimezoneOffset(),n=new Date(e.getFullYear(),6,1).getTimezoneOffset();var r=new Date(e.getFullYear(),0,1).getTimezoneOffset();e=0|(n!=r&&e.getTimezoneOffset()==Math.min(r,n)),(C(),k)[t+32>>>2>>>0]=e}function Bn(e){e>>>=0;var t=new Date((C(),k)[e+20>>>2>>>0]+1900,(C(),k)[e+16>>>2>>>0],(C(),k)[e+12>>>2>>>0],(C(),k)[e+8>>>2>>>0],(C(),k)[e+4>>>2>>>0],(C(),k)[e>>>2>>>0],0),n=(C(),k)[e+32>>>2>>>0],r=t.getTimezoneOffset(),i=new Date(t.getFullYear(),6,1).getTimezoneOffset(),a=new Date(t.getFullYear(),0,1).getTimezoneOffset(),o=Math.min(a,i);return 0>n?(C(),k)[e+32>>>2>>>0]=+(i!=a&&o==r):0>>2>>>0]=t.getDay(),n=(In(t.getFullYear())?Ln:Rn)[t.getMonth()]+t.getDate()-1|0,(C(),k)[e+28>>>2>>>0]=n,(C(),k)[e>>>2>>>0]=t.getSeconds(),(C(),k)[e+4>>>2>>>0]=t.getMinutes(),(C(),k)[e+8>>>2>>>0]=t.getHours(),(C(),k)[e+12>>>2>>>0]=t.getDate(),(C(),k)[e+16>>>2>>>0]=t.getMonth(),(C(),k)[e+20>>>2>>>0]=t.getYear(),e=t.getTime(),BigInt(isNaN(e)?-1:e/1e3)}function Vn(e,t,n,r,a,o,s){return i?he(16,1,e,t,n,r,a,o,s):-52}function Hn(e,t,n,r,a,o){if(i)return he(17,1,e,t,n,r,a,o)}var Un={},Wn=()=>performance.timeOrigin+performance.now();function Gn(e,t){return i?he(18,1,e,t):(Un[e]&&(clearTimeout(Un[e].id),delete Un[e]),t&&(Un[e]={id:setTimeout(()=>{delete Un[e],Wt(()=>ea(e,performance.timeOrigin+performance.now()))},t),Ae:t}),0)}function Kn(e,t,n,r){e>>>=0,t>>>=0,n>>>=0,r>>>=0;var i=new Date().getFullYear(),a=new Date(i,0,1).getTimezoneOffset();i=new Date(i,6,1).getTimezoneOffset();var o=Math.max(a,i);(C(),A)[e>>>2>>>0]=60*o,(C(),k)[t>>>2>>>0]=+(a!=i),e=(t=e=>{var t=Math.abs(e);return`UTC${0<=e?`-`:`+`}${String(Math.floor(t/60)).padStart(2,`0`)}${String(t%60).padStart(2,`0`)}`})(a),t=t(i),iDate.now(),Jn=1;function Yn(e,t,n){if(n>>>=0,!(0<=e&&3>=e))return 28;if(e===0)e=Date.now();else{if(!Jn)return 52;e=performance.timeOrigin+performance.now()}return e=Math.round(1e6*e),(C(),ee)[n>>>3>>>0]=BigInt(e),0}var Xn=[],Zn=(e,t)=>{Xn.length=0;for(var n;n=(C(),E)[e++>>>0];){var r=n!=105;t+=(r&=n!=112)&&t%8?4:0,Xn.push(n==112?(C(),A)[t>>>2>>>0]:n==106?(C(),ee)[t>>>3>>>0]:n==105?(C(),k)[t>>>2>>>0]:(C(),M)[t>>>3>>>0]),t+=r?8:4}return Xn};function Qn(e,t,n){return e>>>=0,t=Zn(t>>>0,n>>>0),to[e](...t)}function $n(e,t,n){return e>>>=0,t=Zn(t>>>0,n>>>0),to[e](...t)}var er=()=>{};function tr(e,t){return b(Ye(e>>>0,t>>>0))}var nr=()=>{throw me+=1,`unwind`};function rr(){return 4294901760}var ir=()=>1,ar=()=>navigator.hardwareConcurrency;function or(e){e>>>=0;var t=(C(),E).length;if(e<=t||4294901760=n;n*=2){var r=t*(1+.2/n);r=Math.min(r,e+100663296);e:{r=(Math.min(4294901760,65536*Math.ceil(Math.max(e,r)/65536))-Te.buffer.byteLength+65535)/65536|0;try{Te.grow(r),re();var i=1;break e}catch{}i=void 0}if(i)return!0}return!1}var sr=e=>{var t=Mt(e)+1,n=sa(t);return jt(e,n,t),n},cr=(e,t)=>{(C(),A)[e>>>2>>>0]=t;var n=(C(),A)[e>>>2>>>0];(C(),A)[e+4>>>2>>>0]=(t-n)/4294967296},lr=e=>(C(),A)[e>>>2>>>0]+4294967296*(C(),k)[e+4>>>2>>>0],ur=[],dr=(e,t)=>{ur[e>>>0]=t},fr=[],pr=[],mr=(e,t)=>{pr[e]=new Promise(n=>t.finally(()=>n(e)))},hr=e=>{if(e)return ur[e>>>0]},gr=(e,t)=>{for(e=(C(),A)[e>>>2>>>0];e;e=(C(),A)[e>>>2>>>0])t[(C(),k)[e+4>>>2>>>0]](e)},_r=(e,t,n)=>{(C(),A)[e>>>2>>>0]=t,(C(),A)[e+4>>>2>>>0]=n},vr=e=>{var t=(C(),A)[e>>>2>>>0];return e=(C(),A)[e+4>>>2>>>0],Ye(t,e)},yr=e=>{var t=(C(),A)[e>>>2>>>0];return e=(C(),A)[e+4>>>2>>>0],t?Ye(t,e):e===0?``:void 0},br=e=>{var t=yr(e+4),n=(n=(C(),A)[e+12>>>2>>>0])?hr(n):`auto`;if(e+=16){var r=hr((C(),A)[e+4>>>2>>>0]),i=(C(),A)[e+16>>>2>>>0],a=(C(),A)[e+20>>>2>>>0];if(i){for(var o={},s=0;s>>3>>>0]}i=o}else i=void 0;e={module:r,constants:i,entryPoint:yr(e+8)}}else e=void 0;return{label:t,layout:n,compute:e}},xr=(e,t)=>{function n(n,r){n=e[n],(C(),A)[t+r>>>2>>>0]=n}n(`maxTextureDimension1D`,4),n(`maxTextureDimension2D`,8),n(`maxTextureDimension3D`,12),n(`maxTextureArrayLayers`,16),n(`maxBindGroups`,20),n(`maxBindGroupsPlusVertexBuffers`,24),n(`maxBindingsPerBindGroup`,28),n(`maxDynamicUniformBuffersPerPipelineLayout`,32),n(`maxDynamicStorageBuffersPerPipelineLayout`,36),n(`maxSampledTexturesPerShaderStage`,40),n(`maxSamplersPerShaderStage`,44),n(`maxStorageBuffersPerShaderStage`,48),n(`maxStorageTexturesPerShaderStage`,52),n(`maxUniformBuffersPerShaderStage`,56),n(`minUniformBufferOffsetAlignment`,80),n(`minStorageBufferOffsetAlignment`,84),cr(t+64,e.maxUniformBufferBindingSize),cr(t+72,e.maxStorageBufferBindingSize),n(`maxVertexBuffers`,88),cr(t+96,e.maxBufferSize),n(`maxVertexAttributes`,104),n(`maxVertexBufferArrayStride`,108),n(`maxInterStageShaderVariables`,112),n(`maxColorAttachments`,116),n(`maxColorAttachmentBytesPerSample`,120),n(`maxComputeWorkgroupStorageSize`,124),n(`maxComputeInvocationsPerWorkgroup`,128),n(`maxComputeWorkgroupSizeX`,132),n(`maxComputeWorkgroupSizeY`,136),n(`maxComputeWorkgroupSizeZ`,140),n(`maxComputeWorkgroupsPerDimension`,144),e.ze!==void 0&&n(`maxImmediateSize`,148)},Sr=[,`validation`,`out-of-memory`,`internal`],Cr=[,`compatibility`,`core`],wr={1:`core-features-and-limits`,2:`depth-clip-control`,3:`depth32float-stencil8`,4:`texture-compression-bc`,5:`texture-compression-bc-sliced-3d`,6:`texture-compression-etc2`,7:`texture-compression-astc`,8:`texture-compression-astc-sliced-3d`,9:`timestamp-query`,10:`indirect-first-instance`,11:`shader-f16`,12:`rg11b10ufloat-renderable`,13:`bgra8unorm-storage`,14:`float32-filterable`,15:`float32-blendable`,16:`clip-distances`,17:`dual-source-blending`,18:`subgroups`,19:`texture-formats-tier1`,20:`texture-formats-tier2`,21:`primitive-index`,22:`texture-component-swizzle`,327692:`chromium-experimental-unorm16-texture-formats`,327729:`chromium-experimental-multi-draw-indirect`},Tr=[,`low-power`,`high-performance`],Er=[,`occlusion`,`timestamp`],Dr={undefined:1,unknown:1,destroyed:2};function Or(e,t,n,r,i,a){t=ke(t),n=ke(n),r>>>=0,i>>>=0,a>>>=0;var o=hr(e>>>0);if(e={},a){var s=(C(),A)[a+12>>>2>>>0];if(s){var c=(C(),A)[a+16>>>2>>>0];e.requiredFeatures=Array.from((C(),A).subarray(c>>>2>>>0,c+4*s>>>2>>>0),e=>wr[e])}var l=(C(),A)[a+20>>>2>>>0];if(l){let t=function(e,t,n=!1){t=l+t,(t=(C(),A)[t>>>2>>>0])==4294967295||n&&t==0||(u[e]=t)},n=function(e,t){t=l+t;var n=(C(),A)[t>>>2>>>0],r=(C(),A)[t+4>>>2>>>0];n==4294967295&&r==4294967295||(u[e]=lr(t))};var u={};t(`maxTextureDimension1D`,4),t(`maxTextureDimension2D`,8),t(`maxTextureDimension3D`,12),t(`maxTextureArrayLayers`,16),t(`maxBindGroups`,20),t(`maxBindGroupsPlusVertexBuffers`,24),t(`maxDynamicUniformBuffersPerPipelineLayout`,32),t(`maxDynamicStorageBuffersPerPipelineLayout`,36),t(`maxSampledTexturesPerShaderStage`,40),t(`maxSamplersPerShaderStage`,44),t(`maxStorageBuffersPerShaderStage`,48),t(`maxStorageTexturesPerShaderStage`,52),t(`maxUniformBuffersPerShaderStage`,56),t(`minUniformBufferOffsetAlignment`,80),t(`minStorageBufferOffsetAlignment`,84),n(`maxUniformBufferBindingSize`,64),n(`maxStorageBufferBindingSize`,72),t(`maxVertexBuffers`,88),n(`maxBufferSize`,96),t(`maxVertexAttributes`,104),t(`maxVertexBufferArrayStride`,108),t(`maxInterStageShaderVariables`,112),t(`maxColorAttachments`,116),t(`maxColorAttachmentBytesPerSample`,120),t(`maxComputeWorkgroupStorageSize`,124),t(`maxComputeInvocationsPerWorkgroup`,128),t(`maxComputeWorkgroupSizeX`,132),t(`maxComputeWorkgroupSizeY`,136),t(`maxComputeWorkgroupSizeZ`,140),t(`maxComputeWorkgroupsPerDimension`,144),t(`maxImmediateSize`,148,!0),e.requiredLimits=u}(s=(C(),A)[a+24>>>2>>>0])&&(s={label:yr(s+4)},e.defaultQueue=s),e.label=yr(a+4)}me+=1,mr(t,o.requestDevice(e).then(e=>{--me,Wt(()=>{ur[i>>>0]=e.queue,ur[r>>>0]=e,me+=1,mr(n,e.lost.then(t=>{Wt(()=>{e.onuncapturederror=()=>{};var r=ca(),i=sr(t.message);Ui(n,Dr[t.reason],i),oa(r)}),--me})),e.onuncapturederror=e=>{var t=5;e.error instanceof GPUValidationError?t=2:e.error instanceof GPUOutOfMemoryError?t=3:e.error instanceof GPUInternalError&&(t=4);var n=ca();e=sr(e.error.message),Ji(r,t,e),oa(n)},`adapterInfo`in e||(e.adapterInfo=o.info),qi(t,1,r,0)})},e=>{--me,Wt(()=>{var i=ca(),a=sr(e.message);qi(t,3,r,a),n&&Ui(n,4,a),oa(i)})}))}function kr(e){var t=hr(e>>>=0),n=fr[e];if(n){for(var r=0;r>>=0;var r=hr(e>>>=0);n==4294967295&&(n=void 0);try{var i=r.getMappedRange(t>>>0,n)}catch{return 0}var a=na(16,i.byteLength);return(C(),E).set(new Uint8Array(i),a>>>0),fr[e].push(()=>ki(a)),a}function jr(e,t,n){n>>>=0;var r=hr(e>>>=0);n==4294967295&&(n=void 0);try{var i=r.getMappedRange(t>>>0,n)}catch{return 0}var a=na(16,i.byteLength);return(C(),E).fill(0,a,i.byteLength),fr[e].push(()=>{new Uint8Array(i).set((C(),E).subarray(a>>>0,a+i.byteLength>>>0)),ki(a)}),a}function Mr(e,t,n,r,i){e>>>=0,t=ke(t),n=ke(n),i>>>=0;var a=hr(e);fr[e]=[],i==4294967295&&(i=void 0),me+=1,mr(t,a.mapAsync(n,r>>>0,i).then(()=>{--me,Wt(()=>{Wi(t,1,0)})},n=>{--me,Wt(()=>{ca();var r=sr(n.message);Wi(t,n.name===`AbortError`?4:n.name===`OperationError`?3:0,r),delete fr[e]})}))}function Nr(e){var t=hr(e>>>=0),n=fr[e];if(n){for(var r=0;r>>0]}function Fr(e,t,n){e>>>=0,t>>>=0,n>>>=0;var r=!!(C(),A)[t+32>>>2>>>0];t={label:yr(t+4),usage:(C(),A)[t+16>>>2>>>0],size:lr(t+24),mappedAtCreation:r},e=hr(e);try{var i=e.createBuffer(t)}catch{return!1}return ur[n>>>0]=i,r&&(fr[n]=[]),!0}function Ir(e,t,n,r){e>>>=0,t=ke(t),r>>>=0,n=br(n>>>0),e=hr(e),me+=1,mr(t,e.createComputePipelineAsync(n).then(e=>{--me,Wt(()=>{ur[r>>>0]=e,Hi(t,1,r,0)})},e=>{--me,Wt(()=>{var n=ca(),i=sr(e.message);Hi(t,e.reason===`validation`?3:e.reason===`internal`?4:0,r,i),oa(n)})}))}function Lr(e,t,n){e>>>=0,t>>>=0,n>>>=0;var r=(C(),A)[t>>>2>>>0],i=(C(),k)[r+4>>>2>>>0];t={label:yr(t+4),code:``},i===2&&(t.code=vr(r+8)),e=hr(e).createShaderModule(t),ur[n>>>0]=e}var Rr=e=>{(e=hr(e)).onuncapturederror=null,e.destroy()};function zr(e,t){t=ke(t),e=hr(e>>>0),me+=1,mr(t,e.popErrorScope().then(e=>{--me,Wt(()=>{var n=5;e?e instanceof GPUValidationError?n=2:e instanceof GPUOutOfMemoryError?n=3:e instanceof GPUInternalError&&(n=4):n=1;var r=ca(),i=e?sr(e.message):0;Gi(t,1,n,i),oa(r)})},e=>{--me,Wt(()=>{var n=ca(),r=sr(e.message);Gi(t,1,5,r),oa(n)})}))}function Br(e,t,n,r){if(t=ke(t),r>>>=0,n>>>=0){var i={featureLevel:Cr[(C(),k)[n+4>>>2>>>0]],powerPreference:Tr[(C(),k)[n+8>>>2>>>0]],forceFallbackAdapter:!!(C(),A)[n+12>>>2>>>0]};(e=(C(),A)[n>>>2>>>0])!==0&&(C(),i.De=!!(C(),A)[e+8>>>2>>>0])}`gpu`in navigator?(me+=1,mr(t,navigator.gpu.requestAdapter(i).then(e=>{--me,Wt(()=>{if(e)ur[r>>>0]=e,Ki(t,1,r,0);else{var n=ca(),i=sr(`WebGPU not available on this browser (requestAdapter returned null)`);Ki(t,3,r,i),oa(n)}})},e=>{--me,Wt(()=>{var n=ca(),i=sr(e.message);Ki(t,4,r,i),oa(n)})}))):(i=ca(),e=sr(`WebGPU not available on this browser (navigator.gpu is not available)`),Ki(t,3,r,e),oa(i))}function Vr(e,t,n){return e>>>=0,t>>>=0,n>>>=0,pn(async()=>{var r=[];if(n){var i=(C(),k)[n>>>2>>>0];r.length=t+1,r[t]=new Promise(e=>setTimeout(e,i,0))}else r.length=t;for(var a=0;a{if(!Hr){var e,t={USER:`web_user`,LOGNAME:`web_user`,PATH:`/`,PWD:`/`,HOME:`/home/web_user`,LANG:(globalThis.navigator?.language??`C`).replace(`-`,`_`)+`.UTF-8`,_:`./this.program`};for(e in Ur)Ur[e]===void 0?delete t[e]:t[e]=Ur[e];var n=[];for(e in t)n.push(`${e}=${t[e]}`);Hr=n}return Hr};function Gr(e,t){if(i)return he(19,1,e,t);e>>>=0,t>>>=0;var n,r=0,a=0;for(n of Wr()){var o=t+r;(C(),A)[e+a>>>2>>>0]=o,r+=jt(n,o,1/0)+1,a+=4}return 0}function Kr(e,t){if(i)return he(20,1,e,t);e>>>=0,t>>>=0;var n=Wr();for(var r of((C(),A)[e>>>2>>>0]=n.length,e=0,n))e+=Mt(r)+1;return(C(),A)[t>>>2>>>0]=e,0}function qr(e){return i?he(21,1,e):52}function Jr(e,t,n,r){return i?he(22,1,e,t,n,r):52}function Yr(e,t,n,r){return i?he(23,1,e,t,n,r):70}var Xr=[null,[],[]];function Zr(e,t,n,r){if(i)return he(24,1,e,t,n,r);t>>>=0,n>>>=0,r>>>=0;for(var a=0,o=0;o>>2>>>0],c=(C(),A)[t+4>>>2>>>0];t+=8;for(var l=0;l>>0],f=Xr[u];d===0||d===10?((u===1?y:b)(Je(f)),f.length=0):f.push(d)}a+=c}return(C(),A)[r>>>2>>>0]=a,0}function Qr(e){return e>>>0}function $r(e,t){return xr(hr(e>>>0).limits,t>>>0),1}function ei(e,t){return hr(e>>>0).features.has(wr[t])}function ti(e){return BigInt(hr(e>>>0).size)}function ni(e){return BigInt(hr(e>>>0).usage)}function ri(e,t){if(e>>>=0,t>>>=0){var n=yr(t+4);n={label:n,timestampWrites:t=(t=(C(),A)[t+12>>>2>>>0])===0?void 0:{querySet:hr((C(),A)[t+4>>>2>>>0]),beginningOfPassWriteIndex:(C(),A)[t+8>>>2>>>0],endOfPassWriteIndex:(C(),A)[t+12>>>2>>>0]}}}return t=hr(e),e=Li(0),n=t.beginComputePass(n),ur[e>>>0]=n,e}function ii(e,t,n,r){n=ke(n),(r=ke(r))==-1&&(r=void 0),(e=hr(e>>>0)).clearBuffer(hr(t>>>0),n,r)}function ai(e,t,n,r,i,a){n=ke(n),i=ke(i),a=ke(a),hr(e>>>0).copyBufferToBuffer(hr(t>>>0),n,hr(r>>>0),i,a)}function oi(e){var t=hr(e>>>0);return e=Fi(0),t=t.finish(),ur[e>>>0]=t,e}function si(e,t,n,r,i,a){a=ke(a),hr(e>>>0).resolveQuerySet(hr(t>>>0),n,r,hr(i>>>0),a)}function ci(e,t,n,r){hr(e>>>0).dispatchWorkgroups(t,n,r)}function li(e,t,n){n=ke(n),hr(e>>>0).dispatchWorkgroupsIndirect(hr(t>>>0),n)}function ui(e){hr(e>>>0).end()}function di(e,t,n,r,i){r>>>=0,i>>>=0,e=hr(e>>>0),n=hr(n>>>0),r==0?e.setBindGroup(t,n):e.setBindGroup(t,n,(C(),A),i>>>2,r)}function fi(e,t){hr(e>>>0).setPipeline(hr(t>>>0))}function pi(e,t,n){hr(e>>>0).Ce(hr(t>>>0),n)}function mi(e,t){var n=hr(e>>>0);return e=Pi(0),t=n.getBindGroupLayout(t),ur[e>>>0]=t,e}function hi(e,t){function n(e){var t=(C(),A)[e+8>>>2>>>0],n=(C(),A)[e+32>>>2>>>0],r=(C(),A)[e+36>>>2>>>0],i=0;return gr(e,{327681:e=>{i=(C(),A)[e+8>>>2>>>0]}}),t?((n=lr(e+24))==-1&&(n=void 0),t={buffer:hr(t),offset:lr(e+16),size:n}):t=hr(n||r||i),{binding:(C(),A)[e+4>>>2>>>0],resource:t}}e>>>=0,t={label:yr(4+(t>>>=0)),layout:hr((C(),A)[t+12>>>2>>>0]),entries:function(e,t){for(var r=[],i=0;i>>2>>>0],(C(),A)[t+20>>>2>>>0])},e=hr(e);var r=Ni(0);return dr(r,e.createBindGroup(t)),r}function gi(e,t){var n;return e>>>=0,(t>>>=0)&&(n={label:yr(t+4)}),t=hr(e),e=Ii(0),n=t.createCommandEncoder(n),ur[e>>>0]=n,e}function _i(e,t){e>>>=0,t>>>=0,t={type:Er[(C(),k)[t+12>>>2>>>0]],count:(C(),A)[t+16>>>2>>>0]};var n=hr(e);return e=Ri(0),t=n.createQuerySet(t),ur[e>>>0]=t,e}function vi(e,t){e=hr(e>>>0).adapterInfo,t>>>=0,(C(),A)[t+52>>>2>>>0]=e.subgroupMinSize,(C(),A)[t+56>>>2>>>0]=e.subgroupMaxSize;var n=e.vendor+e.architecture+e.device+e.description,r=Mt(n)+1,i=Ai(r);return i&&jt(n,i,r),n=i,r=Mt(e.vendor),_r(t+4,n,r),n+=r,r=Mt(e.architecture),_r(t+12,n,r),n+=r,r=Mt(e.device),_r(t+20,n,r),_r(t+28,n+r,Mt(e.description)),(C(),k)[t+36>>>2>>>0]=2,e=e.isFallbackAdapter?3:4,(C(),k)[t+40>>>2>>>0]=e,(C(),A)[t+44>>>2>>>0]=0,(C(),A)[t+48>>>2>>>0]=0,1}var yi={"core-features-and-limits":1,"depth-clip-control":2,"depth32float-stencil8":3,"texture-compression-bc":4,"texture-compression-bc-sliced-3d":5,"texture-compression-etc2":6,"texture-compression-astc":7,"texture-compression-astc-sliced-3d":8,"timestamp-query":9,"indirect-first-instance":10,"shader-f16":11,"rg11b10ufloat-renderable":12,"bgra8unorm-storage":13,"float32-filterable":14,"float32-blendable":15,"clip-distances":16,"dual-source-blending":17,subgroups:18,"texture-formats-tier1":19,"texture-formats-tier2":20,"primitive-index":21,"texture-component-swizzle":22,"chromium-experimental-unorm16-texture-formats":327692,"chromium-experimental-multi-draw-indirect":327729};function bi(e,t){t>>>=0;var n=hr(e>>>0);e=Ai(4*n.features.size);var r=0,i=0;for(let t of n.features)0<=(n=yi[t])&&((C(),k)[e+r>>>2>>>0]=n,r+=4,i++);(C(),A)[t+4>>>2>>>0]=e,(C(),A)[t>>>2>>>0]=i}function xi(e,t){return xr(hr(e>>>0).limits,t>>>0),1}function Si(e,t){hr(e>>>0).pushErrorScope(Sr[t])}function Ci(e,t,n){t>>>=0,n>>>=0,e=hr(e>>>0),t=Array.from((C(),k).subarray(n>>>2>>>0,n+4*t>>>2>>>0),e=>hr(e)),e.submit(t)}function wi(e,t,n,r,i){n=ke(n),r>>>=0,i>>>=0,e=hr(e>>>0),t=hr(t>>>0),r=(C(),E).subarray(r>>>0,r+i>>>0),e.writeBuffer(t,n,r,0,i)}i||function(){for(var e=t.numThreads-1;e--;)we();ue.push(async()=>{var e=async function(){if(!i)return Promise.all(F.map(Ce))}();de++,await e,--de==0&&fe&&(e=fe,fe=null,e())})}(),i||(Te=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0}),re()),t.wasmBinary&&(d=t.wasmBinary),t.stackSave=()=>ca(),t.stackRestore=e=>oa(e),t.stackAlloc=e=>sa(e),t.setValue=function(e,t,n=`i8`){switch(n.endsWith(`*`)&&(n=`*`),n){case`i1`:case`i8`:(C(),T)[e>>>0]=t;break;case`i16`:(C(),D)[e>>>1>>>0]=t;break;case`i32`:(C(),k)[e>>>2>>>0]=t;break;case`i64`:(C(),ee)[e>>>3>>>0]=BigInt(t);break;case`float`:(C(),j)[e>>>2>>>0]=t;break;case`double`:(C(),M)[e>>>3>>>0]=t;break;case`*`:(C(),A)[e>>>2>>>0]=t;break;default:ae(`invalid type for setValue: ${n}`)}},t.getValue=function(e,t=`i8`){switch(t.endsWith(`*`)&&(t=`*`),t){case`i1`:case`i8`:return(C(),T)[e>>>0];case`i16`:return(C(),D)[e>>>1>>>0];case`i32`:return(C(),k)[e>>>2>>>0];case`i64`:return(C(),ee)[e>>>3>>>0];case`float`:return(C(),j)[e>>>2>>>0];case`double`:return(C(),M)[e>>>3>>>0];case`*`:return(C(),A)[e>>>2>>>0];default:ae(`invalid type for getValue: ${t}`)}},t.UTF8ToString=Ye,t.stringToUTF8=jt,t.lengthBytesUTF8=Mt;var Ti,Ei,Di,Oi,ki,Ai,ji,Mi,Ni,Pi,Fi,Ii,Li,Ri,zi,Bi,Vi,Hi,Ui,Wi,Gi,Ki,qi,Ji,Yi,Xi,Zi,Qi,$i,ea,ta,na,ra,ia,aa,oa,sa,ca,la,ua,da,fa,pa,ma,ha,ga,_a,va,ya,ba,xa,Sa,Ca,wa,Ta,Ea,Da,Oa,ka,Aa,ja,Ma,Na,Pa,Fa,Ia,La,Ra,za,Ba,Va,Ha,Ua,Wa,Ga,Ka,qa,Ja,Ya,Xa,Za,Qa,$a,eo=[P,ge,Ue,Xe,Ze,Qe,$e,et,tt,nt,rt,it,at,ot,st,ct,Vn,Hn,Gn,Gr,Kr,qr,Jr,Yr,Zr],to={970348:(e,n,r,i,a)=>{if(t===void 0||!t.Uc)return 1;if((e=Ye(Number(e>>>0))).startsWith(`./`)&&(e=e.substring(2)),!(e=t.Uc.get(e)))return 2;if(n=Number(n>>>0),r=Number(r>>>0),i=Number(i>>>0),n+r>e.byteLength)return 3;try{let o=e.subarray(n,n+r);switch(a){case 0:(C(),E).set(o,i>>>0);break;case 1:t.ad?t.ad(i,o):t.ne(i,o);break;default:return 4}return 0}catch{return 4}},971172:(e,n,r)=>{t.Sd(e,(C(),E).subarray(n>>>0,n+r>>>0))},971236:()=>t.le(),971278:e=>{t.jd(e)},971315:()=>typeof wasmOffsetConverter<`u`};function no(e,t,n,r){var i=ca();try{return Sa(e,t,n,r)}catch(e){if(oa(i),e!==e+0)throw e;ra(1,0)}}function ro(e,t,n){var r=ca();try{return ya(e,t,n)}catch(e){if(oa(r),e!==e+0)throw e;ra(1,0)}}function io(e){var t=ca();try{ha(e)}catch(e){if(oa(t),e!==e+0)throw e;ra(1,0)}}function ao(e,t){var n=ca();try{return ma(e,t)}catch(e){if(oa(n),e!==e+0)throw e;ra(1,0)}}function oo(e,t,n){var r=ca();try{pa(e,t,n)}catch(e){if(oa(r),e!==e+0)throw e;ra(1,0)}}function so(e,t){var n=ca();try{Ca(e,t)}catch(e){if(oa(n),e!==e+0)throw e;ra(1,0)}}function co(e,t,n,r,i,a,o){var s=ca();try{return va(e,t,n,r,i,a,o)}catch(e){if(oa(s),e!==e+0)throw e;ra(1,0)}}function lo(e,t,n,r,i,a){var o=ca();try{ga(e,t,n,r,i,a)}catch(e){if(oa(o),e!==e+0)throw e;ra(1,0)}}function uo(e,t,n,r){var i=ca();try{xa(e,t,n,r)}catch(e){if(oa(i),e!==e+0)throw e;ra(1,0)}}function fo(e,t,n,r,i,a,o){var s=ca();try{Ta(e,t,n,r,i,a,o)}catch(e){if(oa(s),e!==e+0)throw e;ra(1,0)}}function po(e,t,n,r,i,a,o){var s=ca();try{Ea(e,t,n,r,i,a,o)}catch(e){if(oa(s),e!==e+0)throw e;ra(1,0)}}function mo(e,t,n,r,i,a,o,s){var c=ca();try{Fa(e,t,n,r,i,a,o,s)}catch(e){if(oa(c),e!==e+0)throw e;ra(1,0)}}function ho(e,t,n,r,i,a,o,s,c,l,u,d){var f=ca();try{Da(e,t,n,r,i,a,o,s,c,l,u,d)}catch(e){if(oa(f),e!==e+0)throw e;ra(1,0)}}function go(e,t,n,r,i){var a=ca();try{return wa(e,t,n,r,i)}catch(e){if(oa(a),e!==e+0)throw e;ra(1,0)}}function _o(e,t,n,r,i){var a=ca();try{_a(e,t,n,r,i)}catch(e){if(oa(a),e!==e+0)throw e;ra(1,0)}}function vo(e,t,n,r,i,a,o,s){var c=ca();try{ba(e,t,n,r,i,a,o,s)}catch(e){if(oa(c),e!==e+0)throw e;ra(1,0)}}function yo(e){var t=ca();try{return Ia(e)}catch(e){if(oa(t),e!==e+0)throw e;ra(1,0)}}function bo(e,t,n){var r=ca();try{return La(e,t,n)}catch(e){if(oa(r),e!==e+0)throw e;ra(1,0)}}function xo(e,t){var n=ca();try{return Ja(e,t)}catch(e){if(oa(n),e!==e+0)throw e;return ra(1,0),0n}}function So(e){var t=ca();try{return Oa(e)}catch(e){if(oa(t),e!==e+0)throw e;return ra(1,0),0n}}function Co(e,t,n,r){var i=ca();try{return Ra(e,t,n,r)}catch(e){if(oa(i),e!==e+0)throw e;ra(1,0)}}function wo(e,t,n,r,i){var a=ca();try{return za(e,t,n,r,i)}catch(e){if(oa(a),e!==e+0)throw e;ra(1,0)}}function To(e,t,n,r,i,a){var o=ca();try{return Ba(e,t,n,r,i,a)}catch(e){if(oa(o),e!==e+0)throw e;ra(1,0)}}function Eo(e,t,n,r,i,a){var o=ca();try{return Na(e,t,n,r,i,a)}catch(e){if(oa(o),e!==e+0)throw e;ra(1,0)}}function Do(e,t,n,r,i,a){var o=ca();try{return Va(e,t,n,r,i,a)}catch(e){if(oa(o),e!==e+0)throw e;ra(1,0)}}function Oo(e,t,n,r,i,a,o,s){var c=ca();try{return Pa(e,t,n,r,i,a,o,s)}catch(e){if(oa(c),e!==e+0)throw e;ra(1,0)}}function ko(e,t,n,r,i){var a=ca();try{return Ha(e,t,n,r,i)}catch(e){if(oa(a),e!==e+0)throw e;return ra(1,0),0n}}function Ao(e,t,n,r){var i=ca();try{return Ua(e,t,n,r)}catch(e){if(oa(i),e!==e+0)throw e;ra(1,0)}}function jo(e,t,n,r){var i=ca();try{return Wa(e,t,n,r)}catch(e){if(oa(i),e!==e+0)throw e;ra(1,0)}}function Mo(e,t,n,r,i,a,o,s,c,l,u,d){var f=ca();try{return Ga(e,t,n,r,i,a,o,s,c,l,u,d)}catch(e){if(oa(f),e!==e+0)throw e;ra(1,0)}}function No(e,t,n,r,i,a,o,s,c,l,u){var d=ca();try{Ka(e,t,n,r,i,a,o,s,c,l,u)}catch(e){if(oa(d),e!==e+0)throw e;ra(1,0)}}function Po(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){var g=ca();try{qa(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}catch(e){if(oa(g),e!==e+0)throw e;ra(1,0)}}function Fo(e,t,n){var r=ca();try{return Aa(e,t,n)}catch(e){if(oa(r),e!==e+0)throw e;return ra(1,0),0n}}function Io(e,t,n){var r=ca();try{return ka(e,t,n)}catch(e){if(oa(r),e!==e+0)throw e;ra(1,0)}}function Lo(e,t,n){var r=ca();try{return ja(e,t,n)}catch(e){if(oa(r),e!==e+0)throw e;ra(1,0)}}function Ro(e,t,n,r){var i=ca();try{Ma(e,t,n,r)}catch(e){if(oa(i),e!==e+0)throw e;ra(1,0)}}function zo(){if(0{let n=new WeakMap,r,i,a=1;t.webgpuRegisterDevice=e=>{if(i!==void 0)throw Error(`another WebGPU EP inference session is being created.`);if(e){var t=n.get(e);if(!t){let r=((e,t=0)=>{var n=Vi(t);return t=Bi(t,n),ur[n>>>0]=e.queue,ur[t>>>0]=e,t})(e,t=Mi(0));t=[a++,t,r],n.set(e,t)}return r=e,i=t[0],t}r=void 0,i=0};let o=new Map;t.webgpuOnCreateSession=t=>{if(i!==void 0){var n=i;if(i=void 0,t){let i=Di(n);o.set(t,i),n===0&&e(r??hr(i))}r=void 0}},t.webgpuOnReleaseSession=e=>{o.delete(e)};let s=Symbol(`gpuBufferMetadata`);t.webgpuRegisterBuffer=(e,t,n)=>{if(n)return e[s]=[n,NaN],n;if(n=e[s])return n[1]++,n[0];if((t=o.get(t))===void 0)throw Error(`Invalid session handle passed to webgpuRegisterBuffer`);return t=((e,t=0)=>(e.mapState===`unmapped`||ae(),t=zi(t),ur[t>>>0]=e,t))(e,t),e[s]=[t,1],t},t.webgpuUnregisterBuffer=e=>{let t=e[s];if(!t)throw Error(`Buffer is not registered`);t[1]--,t[1]===0&&(ji(t[0]),delete e[s])},t.webgpuGetBuffer=e=>hr(e),t.webgpuCreateDownloader=(e,t,n)=>{if((n=o.get(n))===void 0)throw Error(`Invalid session handle passed to webgpuRegisterBuffer`);let r=hr(n),i=16*Math.ceil(Number(t)/16);return async()=>{let n=r.createBuffer({size:i,usage:9});try{let a=r.createCommandEncoder();return a.copyBufferToBuffer(e,0,n,0,i),r.queue.submit([a.finish()]),await n.mapAsync(GPUMapMode.READ),n.getMappedRange().slice(0,t)}finally{n.destroy()}}},t.ad=(e,t)=>{var n=t.buffer;let a=t.byteOffset,o=t.byteLength;if(t=16*Math.ceil(Number(o)/16),e=hr(e),!r){var s=Di(i);r=hr(s)}let c=(s=r.createBuffer({mappedAtCreation:!0,size:t,usage:6})).getMappedRange();new Uint8Array(c).set(new Uint8Array(n,a,o)),s.unmap(),(n=r.createCommandEncoder()).copyBufferToBuffer(s,0,e,0,t),r.queue.submit([n.finish()]),s.destroy()}},t.webnnInit=e=>{let n=e[0];[t.le,t.jd,t.webnnEnsureTensor,t.Sd,t.webnnDownloadTensor,t.ke,t.webnnEnableTraceEvent]=e.slice(1),t.webnnReleaseTensorId=t.jd,t.webnnUploadTensor=t.Sd,t.webnnRegisterMLContext=t.ke,t.webnnOnRunStart=e=>n.onRunStart(e),t.webnnOnRunEnd=n.onRunEnd.bind(n),t.webnnOnReleaseSession=e=>{n.onReleaseSession(e)},t.webnnCreateMLTensorDownloader=(e,t)=>n.createMLTensorDownloader(e,t),t.webnnRegisterMLTensor=(e,t,r,i)=>n.registerMLTensor(e,t,r,i),t.webnnCreateMLContext=e=>n.createMLContext(e),t.webnnRegisterMLConstant=(e,r,i,a,o,s)=>n.registerMLConstant(e,r,i,a,o,t.Uc,s),t.webnnRegisterGraphInput=n.registerGraphInput.bind(n),t.webnnIsGraphInput=n.isGraphInput.bind(n),t.webnnRegisterGraphOutput=n.registerGraphOutput.bind(n),t.webnnIsGraphOutput=n.isGraphOutput.bind(n),t.webnnCreateTemporaryTensor=n.createTemporaryTensor.bind(n),t.webnnIsGraphInputOutputTypeSupported=n.isGraphInputOutputTypeSupported.bind(n)},ne?t:new Promise((e,t)=>{m=e,h=t})}var V_,H_,qle=Gg(()=>{V_=B_,H_=globalThis.self?.name?.startsWith(`em-pthread`),H_&&B_()}),U_,W_,G_,K_,q_,J_,Y_,X_,Z_,Q_,$_,ev,tv,nv,rv=Gg(()=>{P_(),U_=typeof location>`u`?void 0:location.origin,W_=import.meta.url>`file:`&&import.meta.url<`file;`,G_=()=>W_?new URL(new URL(`ort.webgpu.bundle.min.mjs`,import.meta.url).href,U_).href:import.meta.url,K_=G_(),q_=()=>{if(K_&&!K_.startsWith(`blob:`))return K_.substring(0,K_.lastIndexOf(`/`)+1)},J_=(e,t)=>{try{let n=t??K_;return(n?new URL(e,n):new URL(e)).origin===U_}catch{return!1}},Y_=(e,t)=>{let n=t??K_;try{return(n?new URL(e,n):new URL(e)).href}catch{return}},X_=(e,t)=>`${t??`./`}${e}`,Z_=async e=>{let t=await(await fetch(e,{credentials:`same-origin`})).blob();return URL.createObjectURL(t)},Q_=async e=>(await import(e)).default,$_=(Kle(),qg(F_)).default,ev=async()=>{if(!K_)throw Error(`Failed to load proxy worker: cannot determine the script source URL.`);if(J_(K_))return[void 0,$_()];let e=await Z_(K_);return[e,$_(e)]},tv=(qle(),qg(z_)).default,nv=async(e,t,n,r)=>{let i=tv&&!(e||t);if(i){if(K_)i=J_(K_)||r&&!n;else if(r&&!n)i=!0;else throw Error(`cannot determine the script source URL.`)}if(i)return[void 0,tv];{let r=`ort-wasm-simd-threaded.asyncify.mjs`,i=e??Y_(r,t),a=n&&i&&!J_(i,t),o=a?await Z_(i):i??X_(r,t);return[a?o:void 0,await Q_(o)]}}}),iv,av,ov,sv,cv,lv,uv,dv,fv,pv=Gg(()=>{rv(),av=!1,ov=!1,sv=!1,cv=()=>{if(typeof SharedArrayBuffer>`u`)return!1;try{return typeof MessageChannel<`u`&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},lv=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},uv=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,19,1,17,0,65,1,253,15,65,2,253,15,65,3,253,15,253,147,2,11]))}catch{return!1}},dv=async e=>{if(av)return Promise.resolve();if(ov)throw Error(`multiple calls to 'initializeWebAssembly()' detected.`);if(sv)throw Error(`previous call to 'initializeWebAssembly()' failed.`);ov=!0;let t=e.initTimeout,n=e.numThreads;if(e.simd!==!1){if(e.simd===`relaxed`){if(!uv())throw Error(`Relaxed WebAssembly SIMD is not supported in the current environment.`)}else if(!lv())throw Error(`WebAssembly SIMD is not supported in the current environment.`)}let r=cv();n>1&&!r&&(typeof self<`u`&&!self.crossOriginIsolated&&console.warn(`env.wasm.numThreads is set to `+n+`, but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info.`),console.warn(`WebAssembly multi-threading is not supported in the current environment. Falling back to single-threading.`),e.numThreads=n=1);let i=e.wasmPaths,a=typeof i==`string`?i:void 0,o=i?.mjs,s=o?.href??o,c=i?.wasm,l=c?.href??c,u=e.wasmBinary,[d,f]=await nv(s,a,n>1,!!u||!!l),p=!1,m=[];if(t>0&&m.push(new Promise(e=>{setTimeout(()=>{p=!0,e()},t)})),m.push(new Promise((e,t)=>{let r={numThreads:n};if(u)r.wasmBinary=u,r.locateFile=e=>e;else if(l||a)r.locateFile=e=>l??a+e;else if(s&&s.indexOf(`blob:`)!==0)r.locateFile=e=>new URL(e,s).href;else if(d){let e=q_();e&&(r.locateFile=t=>e+t)}f(r).then(t=>{ov=!1,av=!0,iv=t,e(),d&&URL.revokeObjectURL(d)},e=>{ov=!1,sv=!0,t(e)})})),await Promise.race(m),p)throw Error(`WebAssembly backend initializing failed due to timeout: ${t}ms`)},fv=()=>{if(av&&iv)return iv;throw Error(`WebAssembly is not initialized yet.`)}}),mv,hv,gv,_v=Gg(()=>{pv(),mv=(e,t)=>{let n=fv(),r=n.lengthBytesUTF8(e)+1,i=n._malloc(r);return n.stringToUTF8(e,i,r),t.push(i),i},hv=(e,t,n,r)=>{if(typeof e==`object`&&e){if(n.has(e))throw Error(`Circular reference in options`);n.add(e)}Object.entries(e).forEach(([e,i])=>{let a=t?t+e:e;if(typeof i==`object`)hv(i,a+`.`,n,r);else if(typeof i==`string`||typeof i==`number`)r(a,i.toString());else if(typeof i==`boolean`)r(a,i?`1`:`0`);else throw Error(`Can't handle extra config type: ${typeof i}`)})},gv=e=>{let t=fv(),n=t.stackSave();try{let n=t.PTR_SIZE,r=t.stackAlloc(2*n);t._OrtGetLastError(r,r+n);let i=Number(t.getValue(r,n===4?`i32`:`i64`)),a=t.getValue(r+n,`*`),o=a?t.UTF8ToString(a):``;throw Error(`${e} ERROR_CODE: ${i}, ERROR_MESSAGE: ${o}`)}finally{t.stackRestore(n)}}}),vv,Jle=Gg(()=>{pv(),_v(),vv=e=>{let t=fv(),n=0,r=[],i=e||{};try{if(e?.logSeverityLevel===void 0)i.logSeverityLevel=2;else if(typeof e.logSeverityLevel!=`number`||!Number.isInteger(e.logSeverityLevel)||e.logSeverityLevel<0||e.logSeverityLevel>4)throw Error(`log severity level is not valid: ${e.logSeverityLevel}`);if(e?.logVerbosityLevel===void 0)i.logVerbosityLevel=0;else if(typeof e.logVerbosityLevel!=`number`||!Number.isInteger(e.logVerbosityLevel))throw Error(`log verbosity level is not valid: ${e.logVerbosityLevel}`);e?.terminate===void 0&&(i.terminate=!1);let a=0;return e?.tag!==void 0&&(a=mv(e.tag,r)),n=t._OrtCreateRunOptions(i.logSeverityLevel,i.logVerbosityLevel,!!i.terminate,a),n===0&&gv(`Can't create run options.`),e?.extra!==void 0&&hv(e.extra,``,new WeakSet,(e,i)=>{let a=mv(e,r),o=mv(i,r);t._OrtAddRunConfigEntry(n,a,o)!==0&&gv(`Can't set a run config entry: ${e} - ${i}.`)}),[n,r]}catch(e){throw n!==0&&t._OrtReleaseRunOptions(n),r.forEach(e=>t._free(e)),e}}}),yv,bv,xv,Sv,Cv,wv,Tv,Yle=Gg(()=>{pv(),_v(),yv=e=>{switch(e){case`disabled`:return 0;case`basic`:return 1;case`extended`:return 2;case`layout`:return 3;case`all`:return 99;default:throw Error(`unsupported graph optimization level: ${e}`)}},bv=e=>{switch(e){case`sequential`:return 0;case`parallel`:return 1;default:throw Error(`unsupported execution mode: ${e}`)}},xv=e=>{e.extra||={},e.extra.session||(e.extra.session={});let t=e.extra.session;t.use_ort_model_bytes_directly||=`1`,e.executionProviders&&e.executionProviders.some(e=>(typeof e==`string`?e:e.name)===`webgpu`)&&(e.enableMemPattern=!1)},Sv=(e,t,n,r)=>{let i=mv(t,r),a=mv(n,r);fv()._OrtAddSessionConfigEntry(e,i,a)!==0&&gv(`Can't set a session config entry: ${t} - ${n}.`)},Cv=(e,t,n,r)=>{let i=mv(t,r),a=mv(n,r);e.push([i,a])},wv=async(e,t,n)=>{let r=t.executionProviders;for(let i of r){let r=typeof i==`string`?i:i.name,a=[];switch(r){case`webnn`:if(r=`WEBNN`,typeof i!=`string`){let t=i?.deviceType;t&&Sv(e,`deviceType`,t,n)}break;case`webgpu`:{r=`WebGPU`;let e;if(typeof i!=`string`){let r=i;if(r.device){if(typeof GPUDevice<`u`&&r.device instanceof GPUDevice)e=r.device;else throw Error(`Invalid GPU device set in WebGPU EP options.`)}let{enableGraphCapture:o}=t;if(typeof o==`boolean`&&o&&Cv(a,`enableGraphCapture`,`1`,n),typeof r.preferredLayout==`string`&&Cv(a,`preferredLayout`,r.preferredLayout,n),r.forceCpuNodeNames){let e=Array.isArray(r.forceCpuNodeNames)?r.forceCpuNodeNames:[r.forceCpuNodeNames];Cv(a,`forceCpuNodeNames`,e.join(` `),n)}r.validationMode&&Cv(a,`validationMode`,r.validationMode,n)}let o=fv().webgpuRegisterDevice(e);if(o){let[e,t,r]=o;Cv(a,`deviceId`,e.toString(),n),Cv(a,`webgpuInstance`,t.toString(),n),Cv(a,`webgpuDevice`,r.toString(),n)}}break;case`wasm`:case`cpu`:continue;default:throw Error(`not supported execution provider: ${r}`)}let o=mv(r,n),s=a.length,c=0,l=0;if(s>0){c=fv()._malloc(s*fv().PTR_SIZE),n.push(c),l=fv()._malloc(s*fv().PTR_SIZE),n.push(l);for(let e=0;e{let t=fv(),n=0,r=[],i=e||{};xv(i);try{let e=yv(i.graphOptimizationLevel??`all`),a=bv(i.executionMode??`sequential`),o=typeof i.logId==`string`?mv(i.logId,r):0,s=i.logSeverityLevel??2;if(!Number.isInteger(s)||s<0||s>4)throw Error(`log severity level is not valid: ${s}`);let c=i.logVerbosityLevel??0;if(!Number.isInteger(c)||c<0||c>4)throw Error(`log verbosity level is not valid: ${c}`);let l=typeof i.optimizedModelFilePath==`string`?mv(i.optimizedModelFilePath,r):0;if(n=t._OrtCreateSessionOptions(e,!!i.enableCpuMemArena,!!i.enableMemPattern,a,!!i.enableProfiling,0,o,s,c,l),n===0&&gv(`Can't create session options.`),i.executionProviders&&await wv(n,i,r),i.enableGraphCapture!==void 0){if(typeof i.enableGraphCapture!=`boolean`)throw Error(`enableGraphCapture must be a boolean value: ${i.enableGraphCapture}`);Sv(n,`enableGraphCapture`,i.enableGraphCapture.toString(),r)}if(i.freeDimensionOverrides)for(let[e,a]of Object.entries(i.freeDimensionOverrides)){if(typeof e!=`string`)throw Error(`free dimension override name must be a string: ${e}`);if(typeof a!=`number`||!Number.isInteger(a)||a<0)throw Error(`free dimension override value must be a non-negative integer: ${a}`);let i=mv(e,r);t._OrtAddFreeDimensionOverride(n,i,a)!==0&&gv(`Can't set a free dimension override: ${e} - ${a}.`)}return i.extra!==void 0&&hv(i.extra,``,new WeakSet,(e,t)=>{Sv(n,e,t,r)}),[n,r]}catch(e){throw n!==0&&t._OrtReleaseSessionOptions(n)!==0&&gv(`Can't release session options.`),r.forEach(e=>t._free(e)),e}}}),Ev,Dv,Ov,kv,Av,jv,Mv,Nv,Pv=Gg(()=>{Ev=e=>{switch(e){case`int8`:return 3;case`uint8`:return 2;case`bool`:return 9;case`int16`:return 5;case`uint16`:return 4;case`int32`:return 6;case`uint32`:return 12;case`float16`:return 10;case`float32`:return 1;case`float64`:return 11;case`string`:return 8;case`int64`:return 7;case`uint64`:return 13;case`int4`:return 22;case`uint4`:return 21;default:throw Error(`unsupported data type: ${e}`)}},Dv=e=>{switch(e){case 3:return`int8`;case 2:return`uint8`;case 9:return`bool`;case 5:return`int16`;case 4:return`uint16`;case 6:return`int32`;case 12:return`uint32`;case 10:return`float16`;case 1:return`float32`;case 11:return`float64`;case 8:return`string`;case 7:return`int64`;case 13:return`uint64`;case 22:return`int4`;case 21:return`uint4`;default:throw Error(`unsupported data type: ${e}`)}},Ov=(e,t)=>{let n=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][e],r=typeof t==`number`?t:t.reduce((e,t)=>e*t,1);return n>0?Math.ceil(r*n):void 0},kv=e=>{switch(e){case`float16`:return typeof Float16Array<`u`&&Float16Array.from?Float16Array:Uint16Array;case`float32`:return Float32Array;case`uint8`:return Uint8Array;case`int8`:return Int8Array;case`uint16`:return Uint16Array;case`int16`:return Int16Array;case`int32`:return Int32Array;case`bool`:return Uint8Array;case`float64`:return Float64Array;case`uint32`:return Uint32Array;case`int64`:return BigInt64Array;case`uint64`:return BigUint64Array;default:throw Error(`unsupported type: ${e}`)}},Av=e=>{switch(e){case`verbose`:return 0;case`info`:return 1;case`warning`:return 2;case`error`:return 3;case`fatal`:return 4;default:throw Error(`unsupported logging level: ${e}`)}},jv=e=>e===`float32`||e===`float16`||e===`int32`||e===`int64`||e===`uint32`||e===`uint8`||e===`bool`||e===`uint4`||e===`int4`,Mv=e=>e===`float32`||e===`float16`||e===`int32`||e===`int64`||e===`uint32`||e===`uint64`||e===`int8`||e===`uint8`||e===`bool`||e===`uint4`||e===`int4`,Nv=e=>{switch(e){case`none`:return 0;case`cpu`:return 1;case`cpu-pinned`:return 2;case`texture`:return 3;case`gpu-buffer`:return 4;case`ml-tensor`:return 5;default:throw Error(`unsupported data location: ${e}`)}}}),Fv,Iv=Gg(()=>{P_(),Fv=async e=>{if(typeof e==`string`){let t=await fetch(e);if(!t.ok)throw Error(`failed to load external data file: ${e}`);let n=t.headers.get(`Content-Length`),r=n?parseInt(n,10):0;if(r<1073741824)return new Uint8Array(await t.arrayBuffer());{if(!t.body)throw Error(`failed to load external data file: ${e}, no response body.`);let n=t.body.getReader(),i;try{i=new ArrayBuffer(r)}catch(e){if(e instanceof RangeError){let e=Math.ceil(r/65536);i=new WebAssembly.Memory({initial:e,maximum:e}).buffer}else throw e}let a=0;for(;;){let{done:e,value:t}=await n.read();if(e)break;let r=t.byteLength;new Uint8Array(i,a,r).set(t),a+=r}return new Uint8Array(i,0,r)}}return e instanceof Blob?new Uint8Array(await e.arrayBuffer()):e instanceof Uint8Array?e:new Uint8Array(e)}}),Lv,Xle=Gg(()=>{Pv(),Lv=(e,t)=>new(kv(t))(e)}),Rv,zv,Bv,Vv,Hv,Uv,Wv,Gv=Gg(()=>{Pv(),Rv=[`V`,`I`,`W`,`E`,`F`],zv=(e,t)=>{console.log(`[${Rv[e]},${new Date().toISOString()}]${t}`)},Hv=(e,t)=>{Bv=e,Vv=t},Uv=(e,t)=>{let n=Av(e);n>=Av(Bv)&&zv(n,typeof t==`function`?t():t)},Wv=(...e)=>{Vv&&Uv(...e)}}),Kv,qv,Jv,Yv,Xv,Zv,Qv,$v,ey,ty,ny,Zle=Gg(()=>{Pv(),Gv(),Kv=new Map([[`float32`,32],[`float16`,16],[`int32`,32],[`uint32`,32],[`int64`,64],[`uint64`,64],[`int8`,8],[`uint8`,8],[`int4`,4],[`uint4`,4]]),qv=(e,t)=>{if(t===`int32`)return e;let n=Kv.get(t);if(!n)throw Error(`WebNN backend does not support data type: ${t}`);let r=n/8;if(e.byteLength%r!==0)throw Error(`Invalid Uint8Array length - must be a multiple of ${r}.`);let i=e.byteLength/r,a=new(kv(t))(e.buffer,e.byteOffset,i);switch(t){case`int64`:case`uint64`:{let e=new Int32Array(i);for(let t=0;t2147483647n||n<-2147483648n)throw Error(`Can not convert int64 data to int32 - value out of range.`);e[t]=Number(n)}return new Uint8Array(e.buffer)}case`int8`:case`uint8`:case`uint32`:{if(t===`uint32`&&a.some(e=>e>2147483647))throw Error(`Can not convert uint32 data to int32 - value out of range.`);let e=Int32Array.from(a,Number);return new Uint8Array(e.buffer)}default:throw Error(`Unsupported data conversion from ${t} to 'int32'`)}},Jv=(e,t)=>{if(t===`int32`)return e;if(e.byteLength%4!=0)throw Error(`Invalid Uint8Array length - must be a multiple of 4 (int32).`);let n=e.byteLength/4,r=new Int32Array(e.buffer,e.byteOffset,n);switch(t){case`int64`:{let e=BigInt64Array.from(r,BigInt);return new Uint8Array(e.buffer)}case`uint64`:{if(r.some(e=>e<0))throw Error(`Can not convert int32 data to uin64 - negative value found.`);let e=BigUint64Array.from(r,BigInt);return new Uint8Array(e.buffer)}case`int8`:{if(r.some(e=>e<-128||e>127))throw Error(`Can not convert int32 data to int8 - value out of range.`);let e=Int8Array.from(r,Number);return new Uint8Array(e.buffer)}case`uint8`:if(r.some(e=>e<0||e>255))throw Error(`Can not convert int32 data to uint8 - value out of range.`);return Uint8Array.from(r,Number);case`uint32`:{if(r.some(e=>e<0))throw Error(`Can not convert int32 data to uint32 - negative value found.`);let e=Uint32Array.from(r,Number);return new Uint8Array(e.buffer)}default:throw Error(`Unsupported data conversion from 'int32' to ${t}`)}},Yv=1,Xv=()=>Yv++,Zv=new Map([[`int8`,`int32`],[`uint8`,`int32`],[`uint32`,`int32`],[`int64`,`int32`]]),Qv=(e,t)=>{let n=Kv.get(e);if(!n)throw Error(`WebNN backend does not support data type: ${e}`);return t.length>0?Math.ceil(t.reduce((e,t)=>e*t)*n/8):0},$v=class{constructor(e){this.isDataConverted=!1;let{sessionId:t,context:n,tensor:r,dataType:i,shape:a,fallbackDataType:o}=e;this.sessionId=t,this.mlContext=n,this.mlTensor=r,this.dataType=i,this.tensorShape=a,this.fallbackDataType=o}get tensor(){return this.mlTensor}get type(){return this.dataType}get fallbackType(){return this.fallbackDataType}get shape(){return this.tensorShape}get byteLength(){return Qv(this.dataType,this.tensorShape)}destroy(){Wv(`verbose`,()=>`[WebNN] TensorWrapper.destroy`),this.mlTensor.destroy()}write(e){this.mlContext.writeTensor(this.mlTensor,e)}async read(e){if(this.fallbackDataType){let t=await this.mlContext.readTensor(this.mlTensor),n=Jv(new Uint8Array(t),this.dataType);if(e){(e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)).set(n);return}return n.buffer}return e?this.mlContext.readTensor(this.mlTensor,e):this.mlContext.readTensor(this.mlTensor)}canReuseTensor(e,t,n){return this.mlContext===e&&this.dataType===t&&this.tensorShape.length===n.length&&this.tensorShape.every((e,t)=>e===n[t])}setIsDataConverted(e){this.isDataConverted=e}},ey=class{constructor(e,t){this.tensorManager=e,this.wrapper=t}get tensorWrapper(){return this.wrapper}releaseTensor(){this.tensorWrapper&&(this.tensorManager.releaseTensor(this.tensorWrapper),this.wrapper=void 0)}async ensureTensor(e,t,n,r){let i=this.tensorManager.getMLContext(e),a=this.tensorManager.getMLOpSupportLimits(e),o;if(!a?.input.dataTypes.includes(t)){if(o=Zv.get(t),!o||a?.input.dataTypes.includes(o))throw Error(`WebNN backend does not support data type: ${t}`);Wv(`verbose`,()=>`[WebNN] TensorIdTracker.ensureTensor: fallback dataType from ${t} to ${o}`)}if(this.wrapper){if(this.wrapper.canReuseTensor(i,t,n))return this.wrapper.tensor;if(r){if(this.wrapper.byteLength!==Qv(t,n))throw Error(`Unable to copy data to tensor with different size.`);this.activeUpload=new Uint8Array(await this.wrapper.read())}this.tensorManager.releaseTensor(this.wrapper)}let s=typeof MLTensorUsage>`u`?void 0:MLTensorUsage.READ|MLTensorUsage.WRITE;return this.wrapper=await this.tensorManager.getCachedTensor(e,t,n,s,!0,!0,o),r&&this.activeUpload&&(this.wrapper.write(this.activeUpload),this.activeUpload=void 0),this.wrapper.tensor}upload(e){let t=e;if(this.wrapper){if(this.wrapper.fallbackType){if(this.wrapper.fallbackType===`int32`)t=qv(e,this.wrapper.type),this.wrapper.setIsDataConverted(!0);else throw Error(`Unsupported fallback data type: ${this.wrapper.fallbackType}`)}if(e.byteLength===this.wrapper.byteLength){this.wrapper.write(t);return}Wv(`verbose`,()=>`Data size does not match tensor size. Releasing tensor.`),this.releaseTensor()}this.activeUpload?this.activeUpload.set(t):this.activeUpload=new Uint8Array(t)}async download(e){if(this.activeUpload){let t=this.wrapper?.isDataConverted?Jv(this.activeUpload,this.wrapper?.type):this.activeUpload;if(e){e instanceof ArrayBuffer?new Uint8Array(e).set(t):new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(t);return}return t.buffer}if(!this.wrapper)throw Error(`Tensor has not been created.`);return e?this.wrapper.read(e):this.wrapper.read()}},ty=class{constructor(e){this.backend=e,this.tensorTrackersById=new Map,this.freeTensors=[],this.externalTensors=new Set}getMLContext(e){let t=this.backend.getMLContext(e);if(!t)throw Error(`MLContext not found for session.`);return t}getMLOpSupportLimits(e){return this.backend.getMLOpSupportLimits(e)}reserveTensorId(){let e=Xv();return this.tensorTrackersById.set(e,new ey(this)),e}releaseTensorId(e){let t=this.tensorTrackersById.get(e);t&&(this.tensorTrackersById.delete(e),t.tensorWrapper&&this.releaseTensor(t.tensorWrapper))}async ensureTensor(e,t,n,r,i){Wv(`verbose`,()=>`[WebNN] TensorManager.ensureTensor {tensorId: ${t}, dataType: ${n}, shape: ${r}, copyOld: ${i}}`);let a=this.tensorTrackersById.get(t);if(!a)throw Error(`Tensor not found.`);return a.ensureTensor(e,n,r,i)}upload(e,t){let n=this.tensorTrackersById.get(e);if(!n)throw Error(`Tensor not found.`);n.upload(t)}async download(e,t){Wv(`verbose`,()=>`[WebNN] TensorManager.download {tensorId: ${e}, dstBuffer: ${t?.byteLength}}`);let n=this.tensorTrackersById.get(e);if(!n)throw Error(`Tensor not found.`);return n.download(t)}releaseTensorsForSession(e){for(let t of this.freeTensors)t.sessionId===e&&t.destroy();this.freeTensors=this.freeTensors.filter(t=>t.sessionId!==e)}registerTensor(e,t,n,r){let i=this.getMLContext(e),a=Xv(),o=new $v({sessionId:e,context:i,tensor:t,dataType:n,shape:r});return this.tensorTrackersById.set(a,new ey(this,o)),this.externalTensors.add(o),a}async getCachedTensor(e,t,n,r,i,a,o){let s=this.getMLContext(e);for(let[r,i]of this.freeTensors.entries())if(i.canReuseTensor(s,t,n)){Wv(`verbose`,()=>`[WebNN] Reusing tensor {dataType: ${t}, ${o?`fallbackDataType: ${o},`:``} shape: ${n}`);let i=this.freeTensors.splice(r,1)[0];return i.sessionId=e,i}Wv(`verbose`,()=>`[WebNN] MLContext.createTensor {dataType: ${t}, ${o?`fallbackDataType: ${o},`:``} shape: ${n}}`);let c=await s.createTensor({dataType:o??t,shape:n,dimensions:n,usage:r,writable:i,readable:a});return new $v({sessionId:e,context:s,tensor:c,dataType:t,shape:n,fallbackDataType:o})}releaseTensor(e){this.externalTensors.has(e)&&this.externalTensors.delete(e),this.freeTensors.push(e)}},ny=(...e)=>new ty(...e)}),ry={};Kg(ry,{WebNNBackend:()=>oy});var iy,ay,oy,Qle=Gg(()=>{Pv(),pv(),Xle(),Zle(),Gv(),iy=new Map([[1,`float32`],[10,`float16`],[6,`int32`],[12,`uint32`],[7,`int64`],[13,`uint64`],[22,`int4`],[21,`uint4`],[3,`int8`],[2,`uint8`],[9,`uint8`]]),ay=(e,t)=>{if(e===t)return!0;if(e===void 0||t===void 0)return!1;let n=Object.keys(e).sort(),r=Object.keys(t).sort();return n.length===r.length&&n.every((n,i)=>n===r[i]&&e[n]===t[n])},oy=class{constructor(e){this.tensorManager=ny(this),this.mlContextBySessionId=new Map,this.sessionIdsByMLContext=new Map,this.mlContextCache=[],this.sessionGraphInputs=new Map,this.sessionGraphOutputs=new Map,this.temporaryGraphInputs=[],this.temporaryGraphOutputs=[],this.temporarySessionTensorIds=new Map,this.mlOpSupportLimitsBySessionId=new Map,Hv(e.logLevel,!!e.debug)}get currentSessionId(){if(this.activeSessionId===void 0)throw Error(`No active session`);return this.activeSessionId}onRunStart(e){Wv(`verbose`,()=>`[WebNN] onRunStart {sessionId: ${e}}`),this.activeSessionId=e}onRunEnd(e){Wv(`verbose`,()=>`[WebNN] onRunEnd {sessionId: ${e}}`);let t=this.temporarySessionTensorIds.get(e);if(t){for(let e of t)Wv(`verbose`,()=>`[WebNN] releasing temporary tensor {tensorId: ${e}}`),this.tensorManager.releaseTensorId(e);this.temporarySessionTensorIds.delete(e),this.activeSessionId=void 0}}async createMLContext(e){if(e instanceof GPUDevice){let t=this.mlContextCache.findIndex(t=>t.gpuDevice===e);if(t!==-1)return this.mlContextCache[t].mlContext;{let t=await navigator.ml.createContext(e);return this.mlContextCache.push({gpuDevice:e,mlContext:t}),t}}if(e===void 0){let e=this.mlContextCache.findIndex(e=>e.options===void 0&&e.gpuDevice===void 0);if(e!==-1)return this.mlContextCache[e].mlContext;{let e=await navigator.ml.createContext();return this.mlContextCache.push({mlContext:e}),e}}let t=this.mlContextCache.findIndex(t=>ay(t.options,e));if(t!==-1)return this.mlContextCache[t].mlContext;{let t=await navigator.ml.createContext(e);return this.mlContextCache.push({options:e,mlContext:t}),t}}registerMLContext(e,t){this.mlContextBySessionId.set(e,t);let n=this.sessionIdsByMLContext.get(t);n||(n=new Set,this.sessionIdsByMLContext.set(t,n)),n.add(e),this.mlOpSupportLimitsBySessionId.has(e)||this.mlOpSupportLimitsBySessionId.set(e,t.opSupportLimits()),this.temporaryGraphInputs.length>0&&(this.sessionGraphInputs.set(e,this.temporaryGraphInputs),this.temporaryGraphInputs=[]),this.temporaryGraphOutputs.length>0&&(this.sessionGraphOutputs.set(e,this.temporaryGraphOutputs),this.temporaryGraphOutputs=[])}onReleaseSession(e){this.sessionGraphInputs.delete(e),this.sessionGraphOutputs.delete(e);let t=this.mlContextBySessionId.get(e);if(!t)return;this.tensorManager.releaseTensorsForSession(e),this.mlContextBySessionId.delete(e),this.mlOpSupportLimitsBySessionId.delete(e);let n=this.sessionIdsByMLContext.get(t);if(n.delete(e),n.size===0){this.sessionIdsByMLContext.delete(t);let e=this.mlContextCache.findIndex(e=>e.mlContext===t);e!==-1&&this.mlContextCache.splice(e,1)}}getMLContext(e){return this.mlContextBySessionId.get(e)}getMLOpSupportLimits(e){return this.mlOpSupportLimitsBySessionId.get(e)}reserveTensorId(){return this.tensorManager.reserveTensorId()}releaseTensorId(e){Wv(`verbose`,()=>`[WebNN] releaseTensorId {tensorId: ${e}}`),this.tensorManager.releaseTensorId(e)}async ensureTensor(e,t,n,r,i){let a=iy.get(n);if(!a)throw Error(`Unsupported ONNX data type: ${n}`);return this.tensorManager.ensureTensor(e??this.currentSessionId,t,a,r,i)}async createTemporaryTensor(e,t,n){Wv(`verbose`,()=>`[WebNN] createTemporaryTensor {onnxDataType: ${t}, shape: ${n}}`);let r=iy.get(t);if(!r)throw Error(`Unsupported ONNX data type: ${t}`);let i=this.tensorManager.reserveTensorId();await this.tensorManager.ensureTensor(e,i,r,n,!1);let a=this.temporarySessionTensorIds.get(e);return a?a.push(i):this.temporarySessionTensorIds.set(e,[i]),i}uploadTensor(e,t){if(!fv().shouldTransferToMLTensor)throw Error(`Trying to upload to a MLTensor while shouldTransferToMLTensor is false`);Wv(`verbose`,()=>`[WebNN] uploadTensor {tensorId: ${e}, data: ${t.byteLength}}`),this.tensorManager.upload(e,t)}async downloadTensor(e,t){return this.tensorManager.download(e,t)}createMLTensorDownloader(e,t){return async()=>{let n=await this.tensorManager.download(e);return Lv(n,t)}}registerMLTensor(e,t,n,r){let i=iy.get(n);if(!i)throw Error(`Unsupported ONNX data type: ${n}`);let a=this.tensorManager.registerTensor(e,t,i,r);return Wv(`verbose`,()=>`[WebNN] registerMLTensor {tensor: ${t}, dataType: ${i}, dimensions: ${r}} -> {tensorId: ${a}}`),a}registerMLConstant(e,t,n,r,i,a,o=!1){if(!a)throw Error(`External mounted files are not available.`);let s=e;e.startsWith(`./`)&&(s=e.substring(2));let c=a.get(s);if(!c)throw Error(`File with name ${s} not found in preloaded files.`);if(t+n>c.byteLength)throw Error(`Out of bounds: data offset and length exceed the external file data size.`);let l=c.slice(t,t+n).buffer,u;switch(i.dataType){case`float32`:u=new Float32Array(l);break;case`float16`:u=typeof Float16Array<`u`&&Float16Array.from?new Float16Array(l):new Uint16Array(l);break;case`int32`:u=new Int32Array(l);break;case`uint32`:u=new Uint32Array(l);break;case`int64`:if(o){let e=qv(new Uint8Array(l),`int64`);u=new Int32Array(e.buffer),i.dataType=`int32`}else u=new BigInt64Array(l);break;case`uint64`:u=new BigUint64Array(l);break;case`int8`:u=new Int8Array(l);break;case`int4`:case`uint4`:case`uint8`:u=new Uint8Array(l);break;default:throw Error(`Unsupported data type: ${i.dataType} in creating WebNN Constant from external data.`)}return Wv(`verbose`,()=>`[WebNN] registerMLConstant {dataType: ${i.dataType}, shape: ${i.shape}}} ${o?`(Note: it was int64 data type and registered to int32 as workaround)`:``}`),r.constant(i,u)}registerGraphInput(e){this.temporaryGraphInputs.push(e)}registerGraphOutput(e){this.temporaryGraphOutputs.push(e)}isGraphInput(e,t){let n=this.sessionGraphInputs.get(e);return n?n.includes(t):!1}isGraphOutput(e,t){let n=this.sessionGraphOutputs.get(e);return n?n.includes(t):!1}isGraphInputOutputTypeSupported(e,t,n=!0){let r=iy.get(Ev(t)),i=this.mlOpSupportLimitsBySessionId.get(e);return typeof r>`u`?!1:n?!!i?.input.dataTypes.includes(r):!!i?.output.dataTypes.includes(r)}flush(){}}}),sy,cy,ly,uy,dy,fy,py,my,hy,gy,_y,vy,yy,by=Gg(()=>{N_(),Jle(),Yle(),Pv(),pv(),_v(),Iv(),sy=(e,t)=>{fv()._OrtInit(e,t)!==0&&gv(`Can't initialize onnxruntime.`)},cy=async e=>{sy(e.wasm.numThreads,Av(e.logLevel))},ly=async(e,t)=>{fv().asyncInit?.();let n=e.webgpu.adapter;if(t===`webgpu`){if(typeof navigator>`u`||!navigator.gpu)throw Error(`WebGPU is not supported in current environment`);if(n){if(typeof n.limits!=`object`||typeof n.features!=`object`||typeof n.requestDevice!=`function`)throw Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let t=e.webgpu.powerPreference;if(t!==void 0&&t!==`low-power`&&t!==`high-performance`)throw Error(`Invalid powerPreference setting: "${t}"`);let r=e.webgpu.forceFallbackAdapter;if(r!==void 0&&typeof r!=`boolean`)throw Error(`Invalid forceFallbackAdapter setting: "${r}"`);if(n=await navigator.gpu.requestAdapter({powerPreference:t,forceFallbackAdapter:r}),!n)throw Error(`Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.`)}}if(t===`webnn`&&(typeof navigator>`u`||!navigator.ml))throw Error(`WebNN is not supported in current environment`);if(t===`webgpu`&&fv().webgpuInit(t=>{e.webgpu.device=t}),t===`webnn`){let t=new(Qle(),qg(ry)).WebNNBackend(e);fv().webnnInit([t,()=>t.reserveTensorId(),e=>t.releaseTensorId(e),async(e,n,r,i,a)=>t.ensureTensor(e,n,r,i,a),(e,n)=>{t.uploadTensor(e,n)},async(e,n)=>t.downloadTensor(e,n),(e,n)=>t.registerMLContext(e,n),!!e.trace])}},uy=new Map,dy=e=>{let t=fv(),n=t.stackSave();try{let n=t.PTR_SIZE,r=t.stackAlloc(2*n);t._OrtGetInputOutputCount(e,r,r+n)!==0&&gv(`Can't get session input/output count.`);let i=n===4?`i32`:`i64`;return[Number(t.getValue(r,i)),Number(t.getValue(r+n,i))]}finally{t.stackRestore(n)}},fy=(e,t)=>{let n=fv(),r=n.stackSave(),i=0;try{let r=n.PTR_SIZE,a=n.stackAlloc(2*r);n._OrtGetInputOutputMetadata(e,t,a,a+r)!==0&&gv(`Can't get session input/output metadata.`);let o=Number(n.getValue(a,`*`));i=Number(n.getValue(a+r,`*`));let s=n.HEAP32[i/4];if(s===0)return[o,0];let c=n.HEAPU32[i/4+1],l=[];for(let e=0;e{let t=fv(),n=t._malloc(e.byteLength);if(n===0)throw Error(`Can't create a session. failed to allocate a buffer of size ${e.byteLength}.`);return t.HEAPU8.set(e,n),[n,e.byteLength]},my=async(e,t)=>{let n,r,i=fv();Array.isArray(e)?[n,r]=e:e.buffer===i.HEAPU8.buffer?[n,r]=[e.byteOffset,e.byteLength]:[n,r]=py(e);let a=0,o=0,s=0,c=[],l=[],u=[];try{if([o,c]=await Tv(t),t?.externalData&&i.mountExternalData){let e=[];for(let n of t.externalData){let t=typeof n==`string`?n:n.path;e.push(Fv(typeof n==`string`?n:n.data).then(e=>{i.mountExternalData(t,e)}))}await Promise.all(e)}for(let e of t?.executionProviders??[])if((typeof e==`string`?e:e.name)===`webnn`){if(i.shouldTransferToMLTensor=!1,typeof e!=`string`){let t=e,n=t?.context,r=t?.gpuDevice,a=t?.deviceType,o=t?.powerPreference;i.currentContext=n||(r?await i.webnnCreateMLContext(r):await i.webnnCreateMLContext({deviceType:a,powerPreference:o}))}else i.currentContext=await i.webnnCreateMLContext();break}a=await i._OrtCreateSession(n,r,o),i.webgpuOnCreateSession?.(a),a===0&&gv(`Can't create a session.`),i.jsepOnCreateSession?.(),i.currentContext&&(i.webnnRegisterMLContext(a,i.currentContext),i.currentContext=void 0,i.shouldTransferToMLTensor=!0);let[e,d]=dy(a),f=!!t?.enableGraphCapture,p=[],m=[],h=[],g=[],_=[];for(let t=0;te===`gpu-buffer`||e===`ml-tensor`||e===`ml-tensor-cpu-output`)&&(s=i._OrtCreateBinding(a),s===0&&gv(`Can't create IO binding.`),v={handle:s,outputPreferredLocations:_,outputPreferredLocationsEncoded:_.map(e=>e===`ml-tensor-cpu-output`?`ml-tensor`:e).map(e=>Nv(e))}),uy.set(a,[a,l,u,v,f,!1]),[a,p,m,h,g]}catch(e){throw l.forEach(e=>i._OrtFree(e)),u.forEach(e=>i._OrtFree(e)),s!==0&&i._OrtReleaseBinding(s)!==0&&gv(`Can't release IO binding.`),a!==0&&i._OrtReleaseSession(a)!==0&&gv(`Can't release session.`),e}finally{i._free(n),o!==0&&i._OrtReleaseSessionOptions(o)!==0&&gv(`Can't release session options.`),c.forEach(e=>i._free(e)),i.unmountExternalData?.()}},hy=e=>{let t=fv(),n=uy.get(e);if(!n)throw Error(`cannot release session. invalid session id: ${e}`);let[r,i,a,o,s]=n;o&&(s&&t._OrtClearBoundOutputs(o.handle)!==0&&gv(`Can't clear bound outputs.`),t._OrtReleaseBinding(o.handle)!==0&&gv(`Can't release IO binding.`)),t.jsepOnReleaseSession?.(e),t.webnnOnReleaseSession?.(e),t.webgpuOnReleaseSession?.(e),i.forEach(e=>t._OrtFree(e)),a.forEach(e=>t._OrtFree(e)),t._OrtReleaseSession(r)!==0&&gv(`Can't release session.`),uy.delete(e)},gy=async(e,t,n,r,i,a,o=!1)=>{if(!e){t.push(0);return}let s=fv(),c=s.PTR_SIZE,l=e[0],u=e[1],d=e[3],f=d,p,m;if(l===`string`&&(d===`gpu-buffer`||d===`ml-tensor`))throw Error(`String tensor is not supported on GPU.`);if(o&&d!==`gpu-buffer`)throw Error(`External buffer must be provided for input/output index ${a} when enableGraphCapture is true.`);if(d===`gpu-buffer`){let t=e[2].gpuBuffer;m=Ov(Ev(l),u);{let e=s.webgpuRegisterBuffer;if(!e)throw Error(`Tensor location "gpu-buffer" is not supported without using WebGPU.`);p=e(t,r)}}else if(d===`ml-tensor`){let t=e[2].mlTensor;m=Ov(Ev(l),u);let n=s.webnnRegisterMLTensor;if(!n)throw Error(`Tensor location "ml-tensor" is not supported without using WebNN.`);p=n(r,t,Ev(l),u)}else{let t=e[2];if(Array.isArray(t)){m=c*t.length,p=s._malloc(m),n.push(p);for(let e=0;es.setValue(g+t*c,e,c===4?`i32`:`i64`));let e=s._OrtCreateTensor(Ev(l),p,m,g,u.length,Nv(f));e===0&&gv(`Can't create tensor for input/output. session=${r}, index=${a}.`),t.push(e)}finally{s.stackRestore(h)}},_y=async(e,t,n,r,i,a)=>{let o=fv(),s=o.PTR_SIZE,c=uy.get(e);if(!c)throw Error(`cannot run inference. invalid session id: ${e}`);let l=c[0],u=c[1],d=c[2],f=c[3],p=c[4],m=c[5],h=t.length,g=r.length,_=0,v=[],y=[],b=[],x=[],S=[],C=o.stackSave(),w=o.stackAlloc(h*s),T=o.stackAlloc(h*s),E=o.stackAlloc(g*s),D=o.stackAlloc(g*s);try{[_,v]=vv(a),D_(`wasm prepareInputOutputTensor`);for(let r=0;re*t,1);u=Dv(a);let _=f?.outputPreferredLocations[r[t]];if(u===`string`){if(_===`gpu-buffer`||_===`ml-tensor`)throw Error(`String tensor is not supported on GPU.`);let e=[];for(let t=0;t0){let t=o.webgpuGetBuffer;if(!t)throw Error(`preferredLocation "gpu-buffer" is not supported without using WebGPU.`);let r=t(d),i=Ov(a,g);if(i===void 0||!jv(u))throw Error(`Unsupported data type: ${u}`);l=!0;{o.webgpuRegisterBuffer(r,e,d);let t=o.webgpuCreateDownloader(r,i,e);C.push([u,h,{gpuBuffer:r,download:async()=>{let e=await t();return new(kv(u))(e)},dispose:()=>{o._OrtReleaseTensor(n)!==0&&gv(`Can't release tensor.`)}},`gpu-buffer`])}}else if(_===`ml-tensor`&&g>0){let t=o.webnnEnsureTensor,r=o.webnnIsGraphInputOutputTypeSupported;if(!t||!r)throw Error(`preferredLocation "ml-tensor" is not supported without using WebNN.`);if(Ov(a,g)===void 0||!Mv(u))throw Error(`Unsupported data type: ${u}`);if(!r(e,u,!1))throw Error(`preferredLocation "ml-tensor" for ${u} output is not supported by current WebNN Context.`);let i=await t(e,d,a,h,!1);l=!0,C.push([u,h,{mlTensor:i,download:o.webnnCreateMLTensorDownloader(d,u),dispose:()=>{o.webnnReleaseTensorId(d),o._OrtReleaseTensor(n)}},`ml-tensor`])}else if(_===`ml-tensor-cpu-output`&&g>0){let e=o.webnnCreateMLTensorDownloader(d,u)(),t=C.length;l=!0,O.push((async()=>{let r=[t,await e];return o.webnnReleaseTensorId(d),o._OrtReleaseTensor(n),r})()),C.push([u,h,[],`cpu`])}else{let e=new(kv(u))(g);new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(o.HEAPU8.subarray(d,d+e.byteLength)),C.push([u,h,e,`cpu`])}}finally{o.stackRestore(a),u===`string`&&d&&o._free(d),l||o._OrtReleaseTensor(n)}}f&&!p&&(o._OrtClearBoundOutputs(f.handle)!==0&&gv(`Can't clear bound outputs.`),uy.set(e,[l,u,d,f,p,!1]));for(let[e,t]of await Promise.all(O))C[e][2]=t;return O_(`wasm ProcessOutputTensor`),C}finally{o.webnnOnRunEnd?.(l),o.stackRestore(C),n.forEach(e=>{e&&e[3]===`gpu-buffer`&&o.webgpuUnregisterBuffer(e[2].gpuBuffer)}),i.forEach(e=>{e&&e[3]===`gpu-buffer`&&o.webgpuUnregisterBuffer(e[2].gpuBuffer)}),y.forEach(e=>o._OrtReleaseTensor(e)),b.forEach(e=>o._OrtReleaseTensor(e)),x.forEach(e=>o._free(e)),_!==0&&o._OrtReleaseRunOptions(_),v.forEach(e=>o._free(e))}},vy=e=>{let t=fv(),n=uy.get(e);if(!n)throw Error(`invalid session id`);let r=n[0],i=t._OrtEndProfiling(r);i===0&&gv(`Can't get an profile file name.`),t._OrtFree(i)},yy=e=>{let t=[];for(let n of e){let e=n[2];!Array.isArray(e)&&`buffer`in e&&t.push(e.buffer)}return t}}),xy,Sy,Cy,wy,Ty,Ey,Dy,Oy,ky,Ay,jy,My,Ny,Py,Fy,Iy,Ly,Ry,zy=Gg(()=>{N_(),by(),pv(),rv(),xy=()=>!!i_.wasm.proxy&&typeof document<`u`,Cy=!1,wy=!1,Ty=!1,Oy=new Map,ky=(e,t)=>{let n=Oy.get(e);n?n.push(t):Oy.set(e,[t])},Ay=()=>{if(Cy||!wy||Ty||!Sy)throw Error(`worker not ready`)},jy=e=>{switch(e.data.type){case`init-wasm`:Cy=!1,e.data.err?(Ty=!0,Dy[1](e.data.err)):(wy=!0,Dy[0]()),Ey&&=(URL.revokeObjectURL(Ey),void 0);break;case`init-ep`:case`copy-from`:case`create`:case`release`:case`run`:case`end-profiling`:{let t=Oy.get(e.data.type);e.data.err?t.shift()[1](e.data.err):t.shift()[0](e.data.out);break}}},My=async()=>{if(!wy){if(Cy)throw Error(`multiple calls to 'initWasm()' detected.`);if(Ty)throw Error(`previous call to 'initWasm()' failed.`);if(Cy=!0,xy())return new Promise((e,t)=>{Sy?.terminate(),ev().then(([n,r])=>{try{Sy=r,Sy.onerror=e=>t(e),Sy.onmessage=jy,Dy=[e,t];let i={type:`init-wasm`,in:i_};!i.in.wasm.wasmPaths&&(n||W_)&&(i.in.wasm.wasmPaths={wasm:new URL(new URL(`ort-wasm-simd-threaded.asyncify-DMmc6YqF.wasm`,import.meta.url).href,``+import.meta.url).href}),Sy.postMessage(i),Ey=n}catch(e){t(e)}},t)});try{await dv(i_.wasm),await cy(i_),wy=!0}catch(e){throw Ty=!0,e}finally{Cy=!1}}},Ny=async e=>{if(xy())return Ay(),new Promise((t,n)=>{ky(`init-ep`,[t,n]);let r={type:`init-ep`,in:{epName:e,env:i_}};Sy.postMessage(r)});await ly(i_,e)},Py=async e=>xy()?(Ay(),new Promise((t,n)=>{ky(`copy-from`,[t,n]);let r={type:`copy-from`,in:{buffer:e}};Sy.postMessage(r,[e.buffer])})):py(e),Fy=async(e,t)=>{if(xy()){if(t?.preferredOutputLocation)throw Error(`session option "preferredOutputLocation" is not supported for proxy.`);return Ay(),new Promise((n,r)=>{ky(`create`,[n,r]);let i={type:`create`,in:{model:e,options:{...t}}},a=[];e instanceof Uint8Array&&a.push(e.buffer),Sy.postMessage(i,a)})}return my(e,t)},Iy=async e=>{if(xy())return Ay(),new Promise((t,n)=>{ky(`release`,[t,n]);let r={type:`release`,in:e};Sy.postMessage(r)});hy(e)},Ly=async(e,t,n,r,i,a)=>{if(xy()){if(n.some(e=>e[3]!==`cpu`))throw Error(`input tensor on GPU is not supported for proxy.`);if(i.some(e=>e))throw Error(`pre-allocated output tensor is not supported for proxy.`);return Ay(),new Promise((i,o)=>{ky(`run`,[i,o]);let s=n,c={type:`run`,in:{sessionId:e,inputIndices:t,inputs:s,outputIndices:r,options:a}};Sy.postMessage(c,yy(s))})}return _y(e,t,n,r,i,a)},Ry=async e=>{if(xy())return Ay(),new Promise((t,n)=>{ky(`end-profiling`,[t,n]);let r={type:`end-profiling`,in:e};Sy.postMessage(r)});vy(e)}}),By,Vy,Hy,Uy=Gg(()=>{N_(),zy(),Pv(),P_(),Iv(),By=(e,t)=>{switch(e.location){case`cpu`:return[e.type,e.dims,e.data,`cpu`];case`gpu-buffer`:return[e.type,e.dims,{gpuBuffer:e.gpuBuffer},`gpu-buffer`];case`ml-tensor`:return[e.type,e.dims,{mlTensor:e.mlTensor},`ml-tensor`];default:throw Error(`invalid data location: ${e.location} for ${t()}`)}},Vy=e=>{switch(e[3]){case`cpu`:return new x_(e[0],e[2],e[1]);case`gpu-buffer`:{let t=e[0];if(!jv(t))throw Error(`not supported data type: ${t} for deserializing GPU tensor`);let{gpuBuffer:n,download:r,dispose:i}=e[2];return x_.fromGpuBuffer(n,{dataType:t,dims:e[1],download:r,dispose:i})}case`ml-tensor`:{let t=e[0];if(!Mv(t))throw Error(`not supported data type: ${t} for deserializing MLTensor tensor`);let{mlTensor:n,download:r,dispose:i}=e[2];return x_.fromMLTensor(n,{dataType:t,dims:e[1],download:r,dispose:i})}default:throw Error(`invalid data location: ${e[3]}`)}},Hy=class{async fetchModelAndCopyToWasmMemory(e){return Py(await Fv(e))}async loadModel(e,t){T_();let n;n=typeof e==`string`?await this.fetchModelAndCopyToWasmMemory(e):e,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await Fy(n,t),E_()}async dispose(){return Iy(this.sessionId)}async run(e,t,n){T_();let r=[],i=[];Object.entries(e).forEach(e=>{let t=e[0],n=e[1],a=this.inputNames.indexOf(t);if(a===-1)throw Error(`invalid input '${t}'`);r.push(n),i.push(a)});let a=[],o=[];Object.entries(t).forEach(e=>{let t=e[0],n=e[1],r=this.outputNames.indexOf(t);if(r===-1)throw Error(`invalid output '${t}'`);a.push(n),o.push(r)});let s=r.map((e,t)=>By(e,()=>`input "${this.inputNames[i[t]]}"`)),c=a.map((e,t)=>e?By(e,()=>`output "${this.outputNames[o[t]]}"`):null),l=await Ly(this.sessionId,i,s,o,c,n),u={};for(let e=0;eKy,initializeFlags:()=>Gy,wasmBackend:()=>qy});var Gy,Ky,qy,$le=Gg(()=>{N_(),zy(),Uy(),Gy=()=>{(typeof i_.wasm.initTimeout!=`number`||i_.wasm.initTimeout<0)&&(i_.wasm.initTimeout=0);let e=i_.wasm.simd;if(typeof e!=`boolean`&&e!==void 0&&e!==`fixed`&&e!==`relaxed`&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${e}". Reset it to \`false\` and ignore SIMD feature checking.`),i_.wasm.simd=!1),typeof i_.wasm.proxy!=`boolean`&&(i_.wasm.proxy=!1),typeof i_.wasm.trace!=`boolean`&&(i_.wasm.trace=!1),typeof i_.wasm.numThreads!=`number`||!Number.isInteger(i_.wasm.numThreads)||i_.wasm.numThreads<=0){if(typeof self<`u`&&!self.crossOriginIsolated)i_.wasm.numThreads=1;else{let e=typeof navigator>`u`?jle(`node:os`).cpus().length:navigator.hardwareConcurrency;i_.wasm.numThreads=Math.min(4,Math.ceil((e||1)/2))}}},Ky=class{async init(e){Gy(),await My(),await Ny(e)}async createInferenceSessionHandler(e,t){let n=new Hy;return await n.loadModel(e,t),n}},qy=new Ky});N_(),N_(),N_();var Jy=`1.26.0-dev.20260416-b7804b056c`,Yy=M_;{let e=($le(),qg(Wy)).wasmBackend;Xg(`webgpu`,e,5),Xg(`webnn`,e,5),Xg(`cpu`,e,10),Xg(`wasm`,e,10)}Object.defineProperty(i_.versions,"web",{value:Jy,enumerable:!0});let Xy=`warning`;Object.defineProperty({wasm:{},webgl:{},webgpu:{},versions:{common:`1.24.3`},set logLevel(e){if(e!==void 0){if(typeof e!=`string`||[`verbose`,`info`,`warning`,`error`,`fatal`].indexOf(e)===-1)throw Error(`Unsupported logging level: ${e}`);Xy=e}},get logLevel(){return Xy}},"logLevel",{enumerable:!0});const Zy=(e,t)=>{let n=typeof document<`u`?document.createElement(`canvas`):new OffscreenCanvas(1,1);n.width=e.dims[3],n.height=e.dims[2];let r=n.getContext(`2d`);if(r!=null){let i,a;t?.tensorLayout!==void 0&&t.tensorLayout===`NHWC`?(i=e.dims[2],a=e.dims[3]):(i=e.dims[3],a=e.dims[2]);let o=t?.format===void 0?`RGB`:t.format,s=t?.norm,c,l;s===void 0||s.mean===void 0?c=[255,255,255,255]:typeof s.mean==`number`?c=[s.mean,s.mean,s.mean,s.mean]:(c=[s.mean[0],s.mean[1],s.mean[2],0],s.mean[3]!==void 0&&(c[3]=s.mean[3])),s===void 0||s.bias===void 0?l=[0,0,0,0]:typeof s.bias==`number`?l=[s.bias,s.bias,s.bias,s.bias]:(l=[s.bias[0],s.bias[1],s.bias[2],0],s.bias[3]!==void 0&&(l[3]=s.bias[3]));let u=a*i,d=0,f=u,p=u*2,m=-1;o===`RGBA`?(d=0,f=u,p=u*2,m=u*3):o===`RGB`?(d=0,f=u,p=u*2):o===`RBG`&&(d=0,p=u,f=u*2);for(let t=0;t{let n=typeof document<`u`?document.createElement(`canvas`).getContext(`2d`):new OffscreenCanvas(1,1).getContext(`2d`),r;if(n!=null){let i,a,o;t?.tensorLayout!==void 0&&t.tensorLayout===`NHWC`?(i=e.dims[2],a=e.dims[1],o=e.dims[3]):(i=e.dims[3],a=e.dims[2],o=e.dims[1]);let s=t===void 0||t.format===void 0?`RGB`:t.format,c=t?.norm,l,u;c===void 0||c.mean===void 0?l=[255,255,255,255]:typeof c.mean==`number`?l=[c.mean,c.mean,c.mean,c.mean]:(l=[c.mean[0],c.mean[1],c.mean[2],255],c.mean[3]!==void 0&&(l[3]=c.mean[3])),c===void 0||c.bias===void 0?u=[0,0,0,0]:typeof c.bias==`number`?u=[c.bias,c.bias,c.bias,c.bias]:(u=[c.bias[0],c.bias[1],c.bias[2],0],c.bias[3]!==void 0&&(u[3]=c.bias[3]));let d=a*i;if(t!==void 0&&(t.format!==void 0&&o===4&&t.format!==`RGBA`||o===3&&t.format!==`RGB`&&t.format!==`BGR`))throw Error(`Tensor format doesn't match input tensor dims`);let f=0,p=1,m=2,h=3,g=0,_=d,v=d*2,y=-1;s===`RGBA`?(g=0,_=d,v=d*2,y=d*3):s===`RGB`?(g=0,_=d,v=d*2):s===`RBG`&&(g=0,v=d,_=d*2),r=n.createImageData(i,a);for(let t=0;t{if(e===void 0)throw Error(`Image buffer must be defined`);if(t.height===void 0||t.width===void 0)throw Error(`Image height and width must be defined`);if(t.tensorLayout===`NHWC`)throw Error(`NHWC Tensor layout is not supported yet`);let{height:n,width:r}=t,i=t.norm??{mean:255,bias:0},a,o;a=typeof i.mean==`number`?[i.mean,i.mean,i.mean,i.mean]:[i.mean[0],i.mean[1],i.mean[2],i.mean[3]??255],o=typeof i.bias==`number`?[i.bias,i.bias,i.bias,i.bias]:[i.bias[0],i.bias[1],i.bias[2],i.bias[3]??0];let s=t.format===void 0?`RGBA`:t.format,c=t.tensorFormat===void 0||t.tensorFormat===void 0?`RGB`:t.tensorFormat,l=n*r,u=c===`RGBA`?new Float32Array(l*4):new Float32Array(l*3),d=4,f=0,p=1,m=2,h=3,g=0,_=l,v=l*2,y=-1;s===`RGB`&&(d=3,f=0,p=1,m=2,h=-1),c===`RGBA`?y=l*3:c===`RBG`?(g=0,v=l,_=l*2):c===`BGR`&&(v=0,_=l,g=l*2);for(let t=0;t{let n=typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement,r=typeof ImageData<`u`&&e instanceof ImageData,i=typeof ImageBitmap<`u`&&e instanceof ImageBitmap,a=typeof e==`string`,o,s=t??{},c=()=>{if(typeof document<`u`)return document.createElement(`canvas`);if(typeof OffscreenCanvas<`u`)return new OffscreenCanvas(1,1);throw Error(`Canvas is not supported`)},l=e=>typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||e instanceof OffscreenCanvas?e.getContext(`2d`):null;if(n){let n=c();n.width=e.width,n.height=e.height;let r=l(n);if(r!=null){let n=e.height,i=e.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(n=t.resizedHeight,i=t.resizedWidth),t!==void 0){if(s=t,t.tensorFormat!==void 0)throw Error(`Image input config format must be RGBA for HTMLImageElement`);s.tensorFormat=`RGBA`,s.height=n,s.width=i}else s.tensorFormat=`RGBA`,s.height=n,s.width=i;r.drawImage(e,0,0),o=r.getImageData(0,0,i,n).data}else throw Error(`Can not access image data`)}else if(r){let n,r;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(n=t.resizedHeight,r=t.resizedWidth):(n=e.height,r=e.width),t!==void 0&&(s=t),s.format=`RGBA`,s.height=n,s.width=r,t!==void 0){let t=c();t.width=r,t.height=n;let i=l(t);if(i!=null)i.putImageData(e,0,0),o=i.getImageData(0,0,r,n).data;else throw Error(`Can not access image data`)}else o=e.data}else if(i){if(t===void 0)throw Error(`Please provide image config with format for Imagebitmap`);let n=c();n.width=e.width,n.height=e.height;let r=l(n);if(r!=null){let t=e.height,n=e.width;return r.drawImage(e,0,0,n,t),o=r.getImageData(0,0,n,t).data,s.height=t,s.width=n,$y(o,s)}throw Error(`Can not access image data`)}else if(a)return new Promise((t,n)=>{let r=c(),i=l(r);if(!e||!i)return n();let a=new Image;a.crossOrigin=`Anonymous`,a.src=e,a.onload=()=>{r.width=a.width,r.height=a.height,i.drawImage(a,0,0,r.width,r.height);let e=i.getImageData(0,0,r.width,r.height);s.height=r.height,s.width=r.width,t($y(e.data,s))}});else throw Error(`Input data provided is not supported - aborted tensor creation`);if(o!==void 0)return $y(o,s);throw Error(`Input data provided is not supported - aborted tensor creation`)},tb=(e,t)=>{let{width:n,height:r,download:i,dispose:a}=t;return new db({location:`texture`,type:`float32`,texture:e,dims:[1,r,n,4],download:i,dispose:a})},nb=(e,t)=>{let{dataType:n,dims:r,download:i,dispose:a}=t;return new db({location:`gpu-buffer`,type:n??`float32`,gpuBuffer:e,dims:r,download:i,dispose:a})},rb=(e,t)=>{let{dataType:n,dims:r,download:i,dispose:a}=t;return new db({location:`ml-tensor`,type:n??`float32`,mlTensor:e,dims:r,download:i,dispose:a})},ib=(e,t,n)=>new db({location:`cpu-pinned`,type:e,data:t,dims:n??[t.length]}),ab=new Map([[`float32`,Float32Array],[`uint8`,Uint8Array],[`int8`,Int8Array],[`uint16`,Uint16Array],[`int16`,Int16Array],[`int32`,Int32Array],[`bool`,Uint8Array],[`float64`,Float64Array],[`uint32`,Uint32Array],[`int4`,Uint8Array],[`uint4`,Uint8Array]]),ob=new Map([[Float32Array,`float32`],[Uint8Array,`uint8`],[Int8Array,`int8`],[Uint16Array,`uint16`],[Int16Array,`int16`],[Int32Array,`int32`],[Float64Array,`float64`],[Uint32Array,`uint32`]]);let sb=!1;const cb=()=>{if(!sb){sb=!0;let e=typeof BigInt64Array<`u`&&BigInt64Array.from,t=typeof BigUint64Array<`u`&&BigUint64Array.from,n=globalThis.Float16Array,r=n!==void 0&&n.from;e&&(ab.set(`int64`,BigInt64Array),ob.set(BigInt64Array,`int64`)),t&&(ab.set(`uint64`,BigUint64Array),ob.set(BigUint64Array,`uint64`)),r?(ab.set(`float16`,n),ob.set(n,`float16`)):ab.set(`float16`,Uint16Array)}},lb=e=>{let t=1;for(let n=0;n{switch(e.location){case`cpu`:return new db(e.type,e.data,t);case`cpu-pinned`:return new db({location:`cpu-pinned`,data:e.data,type:e.type,dims:t});case`texture`:return new db({location:`texture`,texture:e.texture,type:e.type,dims:t});case`gpu-buffer`:return new db({location:`gpu-buffer`,gpuBuffer:e.gpuBuffer,type:e.type,dims:t});case`ml-tensor`:return new db({location:`ml-tensor`,mlTensor:e.mlTensor,type:e.type,dims:t});default:throw Error(`tensorReshape: tensor location ${e.location} is not supported`)}};var db=class{constructor(e,t,n){cb();let r,i;if(typeof e==`object`&&`location`in e)switch(this.dataLocation=e.location,r=e.type,i=e.dims,e.location){case`cpu-pinned`:{let t=ab.get(r);if(!t)throw TypeError(`unsupported type "${r}" to create tensor from pinned buffer`);if(!(e.data instanceof t))throw TypeError(`buffer should be of type ${t.name}`);this.cpuData=e.data;break}case`texture`:if(r!==`float32`)throw TypeError(`unsupported type "${r}" to create tensor from texture`);this.gpuTextureData=e.texture,this.downloader=e.download,this.disposer=e.dispose;break;case`gpu-buffer`:if(r!==`float32`&&r!==`float16`&&r!==`int32`&&r!==`int64`&&r!==`uint32`&&r!==`uint8`&&r!==`bool`&&r!==`uint4`&&r!==`int4`)throw TypeError(`unsupported type "${r}" to create tensor from gpu buffer`);this.gpuBufferData=e.gpuBuffer,this.downloader=e.download,this.disposer=e.dispose;break;case`ml-tensor`:if(r!==`float32`&&r!==`float16`&&r!==`int32`&&r!==`int64`&&r!==`uint32`&&r!==`uint64`&&r!==`int8`&&r!==`uint8`&&r!==`bool`&&r!==`uint4`&&r!==`int4`)throw TypeError(`unsupported type "${r}" to create tensor from MLTensor`);this.mlTensorData=e.mlTensor,this.downloader=e.download,this.disposer=e.dispose;break;default:throw Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let a,o;if(typeof e==`string`){if(r=e,o=n,e===`string`){if(!Array.isArray(t))throw TypeError(`A string tensor's data must be a string array.`);a=t}else{let n=ab.get(e);if(n===void 0)throw TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(t)){if(e===`float16`&&n===Uint16Array||e===`uint4`||e===`int4`)throw TypeError(`Creating a ${e} tensor from number array is not supported. Please use ${n.name} as data.`);a=e===`uint64`||e===`int64`?n.from(t,BigInt):n.from(t)}else if(t instanceof n)a=t;else if(t instanceof Uint8ClampedArray){if(e===`uint8`)a=Uint8Array.from(t);else throw TypeError(`A Uint8ClampedArray tensor's data must be type of uint8`)}else if(e===`float16`&&t instanceof Uint16Array&&n!==Uint16Array)a=new globalThis.Float16Array(t.buffer,t.byteOffset,t.length);else throw TypeError(`A ${r} tensor's data must be type of ${n}`)}}else if(o=t,Array.isArray(e)){if(e.length===0)throw TypeError(`Tensor type cannot be inferred from an empty array.`);let t=typeof e[0];if(t===`string`)r=`string`,a=e;else if(t===`boolean`)r=`bool`,a=Uint8Array.from(e);else throw TypeError(`Invalid element type of data array: ${t}.`)}else if(e instanceof Uint8ClampedArray)r=`uint8`,a=Uint8Array.from(e);else{let t=ob.get(e.constructor);if(t===void 0)throw TypeError(`Unsupported type for tensor data: ${e.constructor}.`);r=t,a=e}if(o===void 0)o=[a.length];else if(!Array.isArray(o))throw TypeError(`A tensor's dims must be a number array`);i=o,this.cpuData=a,this.dataLocation=`cpu`}let a=lb(i);if(this.cpuData&&a!==this.cpuData.length&&(r!==`uint4`&&r!==`int4`||Math.ceil(a/2)!==this.cpuData.length))throw Error(`Tensor's size(${a}) does not match data length(${this.cpuData.length}).`);this.type=r,this.dims=i,this.size=a}static async fromImage(e,t){return eb(e,t)}static fromTexture(e,t){return tb(e,t)}static fromGpuBuffer(e,t){return nb(e,t)}static fromMLTensor(e,t){return rb(e,t)}static fromPinnedBuffer(e,t,n){return ib(e,t,n)}toDataURL(e){return Zy(this,e)}toImageData(e){return Qy(this,e)}get data(){if(this.ensureValid(),!this.cpuData)throw Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw Error(`The data is not stored as a WebGL texture.`);return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw Error(`The data is not stored as a WebGPU buffer.`);return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw Error(`The data is not stored as a WebNN MLTensor.`);return this.mlTensorData}async getData(e){switch(this.ensureValid(),this.dataLocation){case`cpu`:case`cpu-pinned`:return this.data;case`texture`:case`gpu-buffer`:case`ml-tensor`:if(!this.downloader)throw Error(`The current tensor is not created with a specified data downloader.`);if(this.isDownloading)throw Error(`The current tensor is being downloaded.`);try{this.isDownloading=!0;let t=await this.downloader();return this.downloader=void 0,this.dataLocation=`cpu`,this.cpuData=t,e&&this.disposer&&(this.disposer(),this.disposer=void 0),t}finally{this.isDownloading=!1}default:throw Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw Error(`The current tensor is being downloaded.`);this.disposer&&=(this.disposer(),void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation=`none`}ensureValid(){if(this.dataLocation===`none`)throw Error(`The tensor is disposed.`)}reshape(e){if(this.ensureValid(),this.downloader||this.disposer)throw Error(`Cannot reshape a tensor that owns GPU resource.`);return ub(this,e)}};const eue=db;var tue=Object.defineProperty,fb=(e,t)=>{for(var n in t)tue(e,n,{get:t[n],enumerable:!0})},pb={},mb={},nue={},rue=`4.2.0`,hb=typeof self<`u`,gb=!Mb(pb),_b=!Mb(mb),vb=hb&&`caches`in self,iue=globalThis.Deno!==void 0;globalThis.Bun;var yb=iue&&vb&&!gb,bb=typeof process<`u`,xb=bb&&process?.release?.name===`node`&&!yb,Sb=typeof window<`u`&&window.document!==void 0,Cb=hb&&[`DedicatedWorkerGlobalScope`,`ServiceWorkerGlobalScope`,`SharedWorkerGlobalScope`].includes(self.constructor?.name),aue=Sb||Cb||yb,oue=xb||typeof navigator<`u`&&`gpu`in navigator,sue=typeof navigator<`u`&&`ml`in navigator,cue=typeof crypto<`u`&&typeof crypto.getRandomValues==`function`,lue=typeof chrome<`u`&&chrome.runtime!==void 0&&typeof chrome.runtime.id==`string`,uue=typeof ServiceWorkerGlobalScope<`u`&&hb&&self instanceof ServiceWorkerGlobalScope,due=(()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgent,t=(navigator.vendor||``).indexOf(`Apple`)>-1,n=!e.match(/CriOS|FxiOS|EdgiOS|OPiOS|mercury|brave/i)&&!e.includes(`Chrome`)&&!e.includes(`Android`);return t&&n})(),wb=Object.freeze({IS_BROWSER_ENV:Sb,IS_WEBWORKER_ENV:Cb,IS_WEB_ENV:aue,IS_SERVICE_WORKER_ENV:uue,IS_DENO_WEB_RUNTIME:yb,IS_WEB_CACHE_AVAILABLE:vb,IS_WEBGPU_AVAILABLE:oue,IS_WEBNN_AVAILABLE:sue,IS_SAFARI:due,IS_PROCESS_AVAILABLE:bb,IS_NODE_ENV:xb,IS_FS_AVAILABLE:gb,IS_PATH_AVAILABLE:_b,IS_CRYPTO_AVAILABLE:cue,IS_CHROME_AVAILABLE:lue}),Tb=gb&&_b,Eb=`./`;if(Tb){let e=Object(import.meta).url;e?Eb=mb.dirname(mb.dirname(nue.fileURLToPath(e))):typeof __dirname<`u`&&(Eb=mb.dirname(__dirname))}var fue=Tb?mb.join(Eb,`/.cache/`):null,Db=`/models/`,pue=Tb?mb.join(Eb,Db):Db,Ob=typeof globalThis.fetch==`function`?globalThis.fetch.bind(globalThis):void 0,kb=Object.freeze({DEBUG:10,INFO:20,WARNING:30,ERROR:40,NONE:50}),Ab=kb.WARNING,jb={version:rue,backends:{onnx:{}},get logLevel(){return Ab},set logLevel(e){Ab=e,jb.backends.onnx?.setLogLevel?.(e)},allowRemoteModels:!0,remoteHost:`https://huggingface.co/`,remotePathTemplate:`{model}/resolve/{revision}/`,allowLocalModels:!(Sb||Cb||yb),localModelPath:pue,useFS:gb,useBrowserCache:vb,useFSCache:gb,cacheDir:fue,useCustomCache:!1,customCache:null,useWasmCache:vb||gb,cacheKey:`transformers-cache`,experimental_useCrossOriginStorage:!1,fetch:Ob};function Mb(e){return Object.keys(e).length===0}var Nb=class{constructor(){let e=function(...t){return e._call(...t)};return Object.setPrototypeOf(e,new.target.prototype)}_call(...e){throw Error(`Must implement _call method in subclass`)}};function Pb(e,t){e&&e(t)}var Fb=class extends Nb{constructor(e,t){super(),this.callback=e,this.files_loading=t}_call(e){if(e.status===`progress`){this.files_loading[e.file]={loaded:e.loaded,total:e.total};let t=Object.values(this.files_loading).reduce((e,t)=>e+t.loaded,0),n=Object.values(this.files_loading).reduce((e,t)=>e+t.total,0),r=n>0?t/n*100:0;this.callback({status:`progress_total`,name:e.name,progress:r,loaded:t,total:n,files:structuredClone(this.files_loading)})}this.callback(e)}};function Ib(e){return Number.isInteger(e)||typeof e==`bigint`}function Lb(e){return e==null||e===-1}function Rb(e){let t=[],n=e;for(;Array.isArray(n);)t.push(n.length),n=n[0];return t}function zb(...e){return Array.prototype.concat.apply([],e)}function Bb(...e){return e.reduce((e,t)=>e.flatMap(e=>t.map(t=>[e,t])))}function Vb(e,t){return Math.abs((e+t)%(2*t)-t)}function Hb(e,t){return Object.assign({},...t.map(t=>{if(e[t]!==void 0)return{[t]:e[t]}}))}function Ub(e,t){let n=0;for(let r of e)r===t&&++n;return n}var Wb={error(...e){jb.logLevel<=kb.ERROR&&console.error(...e)},warn(...e){jb.logLevel<=kb.WARNING&&console.warn(...e)},info(...e){jb.logLevel<=kb.INFO&&console.log(...e)},debug(...e){jb.logLevel<=kb.DEBUG&&console.log(...e)},log(...e){this.info(...e)}},Gb=class{constructor(e){this.trie=this._build_trie(e)}_build_trie(e){let t=Object.create(null);for(let n of e){let e=t;for(let t=0;tr&&t.push(e.slice(r,i)),t.push(o),i+=o.length,r=i):++i}return r{let e=[...Array.from({length:94},(e,t)=>t+33),...Array.from({length:12},(e,t)=>t+161),...Array.from({length:82},(e,t)=>t+174)],t=e.slice(),n=0;for(let r=0;r<256;++r)e.includes(r)||(e.push(r),t.push(256+n),n+=1);let r=t.map(e=>String.fromCharCode(e));return Object.fromEntries(e.map((e,t)=>[e,r[t]]))})(),Jb=(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[t,e])))(qb),Yb=`.,!?…。,、।۔،`,Xb=new Map([[`(?i:'s|'t|'re|'ve|'m|'ll|'d)`,`(?:'([sS]|[tT]|[rR][eE]|[vV][eE]|[mM]|[lL][lL]|[dD]))`],[`(?i:[sdmt]|ll|ve|re)`,`(?:[sS]|[dD]|[mM]|[tT]|[lL][lL]|[vV][eE]|[rR][eE])`],[`[^\\r\\n\\p{L}\\p{N}]?+`,`[^\\r\\n\\p{L}\\p{N}]?`],[`[^\\s\\p{L}\\p{N}]++`,`[^\\s\\p{L}\\p{N}]+`],[`(?>\\p{Nd}{510})`,`(?:\\p{Nd}{510})`],[`\\p{Nd}{3}+`,`(?:\\p{Nd}{3})+`],[`\\G`,``],[` ?[^(\\s|[${Yb}])]+`,` ?[^\\s${Yb}]+`]]),Zb=`\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E`,Qb=e=>e.replace(/ \./g,`.`).replace(/ \?/g,`?`).replace(/ \!/g,`!`).replace(/ ,/g,`,`).replace(/ \' /g,`'`).replace(/ n't/g,`n't`).replace(/ 'm/g,`'m`).replace(/ 's/g,`'s`).replace(/ 've/g,`'ve`).replace(/ 're/g,`'re`),$b=(e,t=!0)=>{if(e.Regex!==void 0){let t=e.Regex.replace(/\\([#&~])/g,`$1`);t=t.replace(/\\A/g,`^`).replace(/\\z/g,`$`).replace(/\\Z/g,`(?=\\r?\\n?$)`);for(let[e,n]of Xb)t=t.replaceAll(e,n);try{return new RegExp(t,`gu`)}catch(e){if(!(e instanceof SyntaxError)||!e.message.toLowerCase().includes(`invalid property name`))throw e;let n=!1,r=t.replace(/(\\[pP])\{([^}=]+)\}/g,(e,t,r)=>{try{return RegExp(`\\p{${r}}`,`u`),`${t}{${r}}`}catch{return n=!0,`${t}{Script=${r}}`}});if(!n)throw e;try{return new RegExp(r,`gu`)}catch{throw e}}}if(e.String!==void 0){let n=ex(e.String);return new RegExp(t?n:`(${n})`,`gu`)}return console.warn(`Unknown pattern type:`,e),null},ex=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),tx=(e,t,n)=>{let r=[],i=0;for(;ie>=19968&&e<=40959||e>=13312&&e<=19903||e>=131072&&e<=173791||e>=173824&&e<=177983||e>=177984&&e<=178207||e>=178208&&e<=183983||e>=63744&&e<=64255||e>=194560&&e<=195103,rx=e=>Number.isInteger(e)||typeof e==`bigint`,ix=e=>{let t=0;for(let n of e)++t;return t},ax=e=>lx(e.toLowerCase()),ox=(...e)=>Array.prototype.concat.apply([],e),sx=e=>new Map(Object.entries(e)),cx=(e,t)=>{let n=[],r=0;for(let i of e.matchAll(t)){let t=i[0];r0&&n.push(t),r=i.index+t.length}return re.replace(/\p{M}/gu,``),ux=(e,t,n=[])=>{if(!e||Array.isArray(e)||typeof e!=`object`)return`${t} must be a valid object`;for(let r of n)if(!(r in e))return`${t} must contain a "${r}" property`;return null},dx=e=>e.match(/\S+/g)||[],fx=class{constructor(){let e=function(...t){return e._call(...t)};return Object.setPrototypeOf(e,new.target.prototype)}},px=class extends fx{constructor(e){super(),this.config=e}_call(e){return this.normalize(e)}},mx=class extends px{tokenize_chinese_chars(e){let t=[];for(let n=0;ne.normalize(`NFKC`)).join(`~`):e.normalize(`NFKC`),e}},gx=class extends px{constructor(e){super(e),this.normalizers=(e.normalizers??[]).map(e=>Ox(e))}normalize(e){return this.normalizers.reduce((e,t)=>t?t.normalize(e):e,e)}},_x=class extends px{normalize(e){let t=$b(this.config.pattern??{});return t===null?e:e.replaceAll(t,this.config.content??``)}},vx=class extends px{constructor(){super(...arguments),this.form=`NFC`}normalize(e){return e=e.normalize(this.form),e}},yx=class extends vx{constructor(){super(...arguments),this.form=`NFC`}},bx=class extends vx{constructor(){super(...arguments),this.form=`NFD`}},xx=class extends vx{constructor(){super(...arguments),this.form=`NFKC`}},Sx=class extends vx{constructor(){super(...arguments),this.form=`NFKD`}},Cx=class extends px{normalize(e){return this.config.strip_left&&this.config.strip_right?e=e.trim():(this.config.strip_left&&(e=e.trimStart()),this.config.strip_right&&(e=e.trimEnd())),e}},wx=class extends px{normalize(e){return lx(e)}},Tx=class extends px{normalize(e){return e.toLowerCase()}},Ex=class extends px{normalize(e){return e=this.config.prepend+e,e}};function Dx(e){if(e===null)return null;switch(e.type){case`BertNormalizer`:return new mx(e);case`Precompiled`:return new hx(e);case`Sequence`:return new gx(e);case`Replace`:return new _x(e);case`NFC`:return new yx(e);case`NFD`:return new bx(e);case`NFKC`:return new xx(e);case`NFKD`:return new Sx(e);case`Strip`:return new Cx(e);case`StripAccents`:return new wx(e);case`Lowercase`:return new Tx(e);case`Prepend`:return new Ex(e);default:throw Error(`Unknown Normalizer type: ${e.type}`)}}var Ox=Dx,kx=class extends fx{pre_tokenize(e,t){return(Array.isArray(e)?e.map(e=>this.pre_tokenize_text(e,t)):this.pre_tokenize_text(e,t)).flat()}_call(e,t){return this.pre_tokenize(e,t)}},Ax=class extends kx{constructor(e){super(),this.config=e,this.add_prefix_space=this.config.add_prefix_space??!1,this.trim_offsets=this.config.trim_offsets??!1,this.use_regex=this.config.use_regex??!0,this.pattern=/'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+/gu,this.byte_encoder=qb,this.text_encoder=new TextEncoder}pre_tokenize_text(e,t){return this.add_prefix_space&&!e.startsWith(` `)&&(e=` `+e),(this.use_regex?e.match(this.pattern)||[]:[e]).map(e=>Array.from(this.text_encoder.encode(e),e=>this.byte_encoder[e]).join(``))}},jx=class extends kx{pre_tokenize_text(e,t){return e.match(/\w+|[^\w\s]+/g)||[]}},Mx=class extends kx{constructor(e){super(),this.replacement=e.replacement??`▁`,this.str_rep=e.str_rep||this.replacement,this.prepend_scheme=e.prepend_scheme??`always`}pre_tokenize_text(e,t){let{section_index:n=void 0}=t??{},r=e.replaceAll(` `,this.str_rep);return!r.startsWith(this.replacement)&&(this.prepend_scheme===`always`||this.prepend_scheme===`first`&&n===0)&&(r=this.str_rep+r),[r]}},Nx=class extends kx{constructor(e){super(),this.config=e,this.pattern=$b(this.config.pattern??{},this.config.invert??!0)}pre_tokenize_text(e){return this.pattern===null?[]:this.config.invert?e.match(this.pattern)||[]:this.config.behavior?.toLowerCase()===`removed`?e.split(this.pattern).filter(e=>e):cx(e,this.pattern)}},Px=class extends kx{constructor(e){super(),this.config=e,this.pattern=RegExp(`[^${Zb}]+|[${Zb}]+`,`gu`)}pre_tokenize_text(e){return e.match(this.pattern)||[]}},Fx=class extends kx{constructor(e){super(),this.config=e;let t=`[^\\d]+|\\d${this.config.individual_digits?``:`+`}`;this.pattern=new RegExp(t,`gu`)}pre_tokenize_text(e){return e.match(this.pattern)||[]}},Ix=class extends kx{constructor(){super(),this.pattern=RegExp(`[^\\s${Zb}]+|[${Zb}]`,`gu`)}pre_tokenize_text(e,t){return e.trim().match(this.pattern)||[]}},Lx=class extends kx{constructor(e){super(),this.config=e,this.pattern=$b(this.config.pattern??{}),this.content=this.config.content??``}pre_tokenize_text(e){return this.pattern===null?[e]:[e.replaceAll(this.pattern,this.config.content??``)]}},Rx=class extends kx{constructor(e){super(),this.tokenizers=(e.pretokenizers??[]).map(e=>Hx(e))}pre_tokenize_text(e,t){return this.tokenizers.reduce((e,n)=>n?n.pre_tokenize(e,t):e,[e])}},zx=class extends kx{pre_tokenize_text(e){return dx(e)}},Bx=class extends kx{constructor(e){super(),this.config=e,this._length=e.length}pre_tokenize_text(e){let t=[];for(let n=0;nthis.max_input_chars_per_word){t.push(this.unk_token);continue}let r=!1,i=0,a=[];for(;i0&&(r=this.config.continuing_subword_prefix+r),this.tokens_to_ids.has(r)){n=r;break}--t}if(n===null){r=!0;break}a.push(n),i=t}r?t.push(this.unk_token):t.push(...a)}return t}},Gx=class e{constructor(e,t){this.is_leaf=e,this.children=t}static default(){return new e(!1,new Map)}},Kx=class{constructor(){this.root=Gx.default()}extend(e){for(let t of e)this.push(t)}push(e){let t=this.root;for(let n of e){let e=t.children.get(n);e===void 0&&(e=Gx.default(),t.children.set(n,e)),t=e}t.is_leaf=!0}*common_prefix_search(e){let t=this.root;if(t===void 0)return;let n=``;for(let r of e){if(n+=r,t=t.children.get(r),t===void 0)return;t.is_leaf&&(yield n)}}},qx=class e{constructor(e,t,n,r,i){this.token_id=e,this.node_id=t,this.pos=n,this.length=r,this.score=i,this.prev=null,this.backtrace_score=0}clone(){let t=new e(this.token_id,this.node_id,this.pos,this.length,this.score);return t.prev=this.prev,t.backtrace_score=this.backtrace_score,t}},Jx=class{constructor(e,t,n){this.chars=Array.from(e),this.len=this.chars.length,this.bos_token_id=t,this.eos_token_id=n,this.nodes=[],this.begin_nodes=Array.from({length:this.len+1},()=>[]),this.end_nodes=Array.from({length:this.len+1},()=>[]);let r=new qx(this.bos_token_id??0,0,0,0,0),i=new qx(this.eos_token_id??0,1,this.len,0,0);this.nodes.push(r.clone()),this.nodes.push(i.clone()),this.begin_nodes[this.len].push(i),this.end_nodes[0].push(r)}insert(e,t,n,r){let i=this.nodes.length,a=new qx(r,i,e,t,n);this.begin_nodes[e].push(a),this.end_nodes[e+t].push(a),this.nodes.push(a)}viterbi(){let e=this.len,t=0;for(;t<=e;){if(this.begin_nodes[t].length==0)return[];for(let e of this.begin_nodes[t]){e.prev=null;let n=0,r=null;for(let i of this.end_nodes[t]){let t=i.backtrace_score+e.score;(r===null||t>n)&&(r=i.clone(),n=t)}if(r!==null)e.prev=r,e.backtrace_score=n;else return[]}++t}let n=[],r=this.begin_nodes[e][0].prev;if(r===null)return[];let i=r.clone();for(;i.prev!==null;)n.push(i.clone()),i=i.clone().prev.clone();return n.reverse(),n}piece(e){return this.chars.slice(e.pos,e.pos+e.length).join(``)}tokens(){return this.viterbi().map(e=>this.piece(e))}token_ids(){return this.viterbi().map(e=>e.token_id)}};function Yx(e){if(e.length===0)throw Error(`Array must not be empty`);let t=e[0],n=0;for(let r=1;r[e,t])),this.bos_token=` `,this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=t,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.unk_token=this.vocab[this.unk_token_id],this.min_score=Yx(this.scores)[0],this.unk_score=this.min_score-10,this.scores[this.unk_token_id]=this.unk_score,this.trie=new Kx,this.trie.extend(this.vocab),this.fuse_unk=!0}populate_nodes(e){let t=e.chars,n=0;for(;ne>t,t=1/0){this._heap=[],this._comparator=e,this._max_size=t}get size(){return this._heap.length}is_empty(){return this.size===0}peek(){return this._heap[0]}push(...e){return this.extend(e)}extend(e){for(let t of e)if(this.size0&&this._swap(0,t),this._heap.pop(),this._sift_down(),e}replace(e){let t=this.peek();return this._heap[0]=e,this._sift_down(),t}_parent(e){return(e+1>>>1)-1}_left(e){return(e<<1)+1}_right(e){return e+1<<1}_greater(e,t){return this._comparator(this._heap[e],this._heap[t])}_swap(e,t){let n=this._heap[e];this._heap[e]=this._heap[t],this._heap[t]=n}_sift_up(){this._sift_up_from(this.size-1)}_sift_up_from(e){for(;e>0&&this._greater(e,this._parent(e));)this._swap(e,this._parent(e)),e=this._parent(e)}_sift_down(){let e=0;for(;this._left(e)this.capacity&&this.cache.delete(this.cache.keys().next().value)}clear(){this.cache.clear()}},$x=class extends Ux{constructor(e){super(e),this.tokens_to_ids=sx(e.vocab),this.unk_token_id=this.tokens_to_ids.get(e.unk_token),this.unk_token=e.unk_token,this.vocab=Array(this.tokens_to_ids.size);for(let[e,t]of this.tokens_to_ids)this.vocab[t]=e;let t=Array.isArray(e.merges[0]);this.merges=t?e.merges:e.merges.map(e=>e.split(` `,2)),this.bpe_ranks=new Map(this.merges.map((e,t)=>[JSON.stringify(e),t])),this.end_of_word_suffix=e.end_of_word_suffix,this.continuing_subword_suffix=e.continuing_subword_suffix??null,this.byte_fallback=this.config.byte_fallback??!1,this.byte_fallback&&(this.text_encoder=new TextEncoder),this.ignore_merges=this.config.ignore_merges??!1,this.max_length_to_cache=256,this.cache_capacity=1e4,this.cache=new Qx(this.cache_capacity)}clear_cache(){this.cache.clear()}bpe(e){if(e.length===0)return[];let t=this.cache.get(e);if(t!==void 0)return t;let n=Array.from(e);this.end_of_word_suffix&&(n[n.length-1]+=this.end_of_word_suffix);let r=[];if(n.length>1){let e=new Zx((e,t)=>e.score`<0x${e.toString(16).toUpperCase().padStart(2,`0`)}>`);e.every(e=>this.tokens_to_ids.has(e))?t.push(...e):this.unk_token!=null&&t.push(this.unk_token)}else this.unk_token!=null&&t.push(this.unk_token)}return t}},eS=class extends Ux{constructor(e,t){super(e);let n=e.vocab;this.tokens_to_ids=sx(t.target_lang?n[t.target_lang]:n),this.bos_token=t.bos_token,this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=t.eos_token,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.pad_token=t.pad_token,this.pad_token_id=this.tokens_to_ids.get(this.pad_token),this.unk_token=t.unk_token,this.unk_token_id=this.tokens_to_ids.get(this.unk_token),this.vocab=Array(this.tokens_to_ids.size);for(let[e,t]of this.tokens_to_ids)this.vocab[t]=e}encode(e){return e}};function tS(e,t){switch(e.type){case`WordPiece`:return new Wx(e);case`Unigram`:return new Xx(e,t.eos_token);case`BPE`:return new $x(e);default:if(e.vocab)return Array.isArray(e.vocab)?new Xx(e,t.eos_token):Object.hasOwn(e,`continuing_subword_prefix`)&&Object.hasOwn(e,`unk_token`)?Object.hasOwn(e,`merges`)?new $x(e):new Wx(e):new eS(e,{target_lang:t.target_lang,bos_token:t.bos_token,eos_token:t.eos_token,pad_token:t.pad_token,unk_token:t.unk_token});throw Error(`Unknown TokenizerModel type: ${e?.type}`)}}var mue=tS,nS=class extends fx{constructor(e){super(),this.config=e}_call(e,...t){return this.post_process(e,...t)}},hue=class extends nS{post_process(e,t=null,n=!0){let r=t===null?this.config.single:this.config.pair,i=[],a=[];for(let o of r)`SpecialToken`in o?n&&(i.push(o.SpecialToken.id),a.push(o.SpecialToken.type_id)):`Sequence`in o&&(o.Sequence.id===`A`?(i=ox(i,e),a=ox(a,Array(e.length).fill(o.Sequence.type_id))):o.Sequence.id===`B`&&(i=ox(i,t),a=ox(a,Array(t.length).fill(o.Sequence.type_id))));return{tokens:i,token_type_ids:a}}},gue=class extends nS{post_process(e,t=null){return{tokens:e,tokens_pair:t}}},_ue=class extends nS{constructor(e){super(e),this.sep=e.sep,this.cls=e.cls}post_process(e,t=null,n=!0){n&&(e=ox([this.cls[0]],e,[this.sep[0]]));let r=Array(e.length).fill(0);if(t){let i=[],a=n?[this.sep[0]]:[];e=ox(e,i,t,a),r=ox(r,Array(t.length+i.length+a.length).fill(1))}return{tokens:e,token_type_ids:r}}},vue=class extends nS{constructor(e){super(e),this.sep=e.sep,this.cls=e.cls}post_process(e,t,n=!0){n&&(e=ox([this.cls[0]],e,[this.sep[0]]));let r=Array(e.length).fill(0);if(t){let i=n?[this.sep[0]]:[],a=n?[this.sep[0]]:[];e=ox(e,i,t,a),r=ox(r,Array(t.length+i.length+a.length).fill(1))}return{tokens:e,token_type_ids:r}}},yue=class extends nS{constructor(e){super(e),this.processors=(e.processors??[]).map(e=>rS(e))}post_process(e,t=null,n=!0){let r={tokens:e,tokens_pair:t};for(let e of this.processors)r=e.post_process(r.tokens,r.tokens_pair,n);return r}};function bue(e){if(e===null)return null;switch(e.type){case`TemplateProcessing`:return new hue(e);case`ByteLevel`:return new gue(e);case`BertProcessing`:return new _ue(e);case`RobertaProcessing`:return new vue(e);case`Sequence`:return new yue(e);default:throw Error(`Unknown PostProcessor type: ${e.type}`)}}var rS=bue,iS=class extends fx{constructor(e){super(),this.config=e,this.added_tokens=[],this.end_of_word_suffix=null,this.trim_offsets=`trim_offsets`in e&&e.trim_offsets}_call(e){return this.decode(e)}decode(e){return this.decode_chain(e).join(``)}},xue=class extends iS{constructor(e){super(e),this.byte_decoder=Jb,this.text_decoder=new TextDecoder(`utf-8`,{fatal:!1,ignoreBOM:!0}),this.end_of_word_suffix=null}convert_tokens_to_string(e){let t=e.join(``),n=new Uint8Array([...t].map(e=>this.byte_decoder[e]));return this.text_decoder.decode(n)}decode_chain(e){let t=[],n=[];for(let r of e)this.added_tokens.find(e=>e.content===r)===void 0?n.push(r):(n.length>0&&(t.push(this.convert_tokens_to_string(n)),n=[]),t.push(r));return n.length>0&&t.push(this.convert_tokens_to_string(n)),t}},Sue=class extends iS{constructor(e){super(e),this.cleanup=e.cleanup}decode_chain(e){return e.map((e,t)=>{if(t!==0){let t=this.config.prefix;e=t&&e.startsWith(t)?e.replace(t,``):` `+e}return this.cleanup&&(e=Qb(e)),e})}},Cue=class extends iS{constructor(e){super(e),this.replacement=e.replacement??`▁`}decode_chain(e){let t=[];for(let n=0;nt.replaceAll(this.suffix,n===e.length-1?``:` `))}},Tue=class extends iS{constructor(e){super(e),this.pad_token=e.pad_token??``,this.word_delimiter_token=e.word_delimiter_token??``,this.cleanup=e.cleanup}convert_tokens_to_string(e){if(e.length===0)return``;let t=[e[0]];for(let n=1;ne!==this.pad_token).join(``);return this.cleanup&&(n=Qb(n).replaceAll(this.word_delimiter_token,` `).trim()),n}decode_chain(e){return[this.convert_tokens_to_string(e)]}},Eue=class extends iS{constructor(e){super(e),this.decoders=(e.decoders??[]).map(e=>aS(e))}decode_chain(e){return this.decoders.reduce((e,t)=>t.decode_chain(e),e)}},Due=class extends iS{decode_chain(e){let t=$b(this.config.pattern),n=this.config.content??``;return t===null?e:e.map(e=>e.replaceAll(t,n))}},Oue=class extends iS{decode_chain(e){return[e.join(``)]}},kue=class extends iS{constructor(e){super(e),this.content=e.content??``,this.start=e.start??0,this.stop=e.stop??0}decode_chain(e){return e.map(e=>{let t=0;for(let n=0;n`)){let t=parseInt(r.slice(3,5),16);isNaN(t)||(e=t)}if(e!==null)n.push(e);else{if(n.length>0){let e=this.text_decoder.decode(Uint8Array.from(n));t.push(e),n=[]}t.push(r)}}if(n.length>0){let e=this.text_decoder.decode(Uint8Array.from(n));t.push(e),n=[]}return t}};function jue(e){if(e===null)return null;switch(e.type){case`ByteLevel`:return new xue(e);case`WordPiece`:return new Sue(e);case`Metaspace`:return new Cue(e);case`BPEDecoder`:return new wue(e);case`CTC`:return new Tue(e);case`Sequence`:return new Eue(e);case`Replace`:return new Due(e);case`Fuse`:return new Oue(e);case`Strip`:return new kue(e);case`ByteFallback`:return new Aue(e);default:throw Error(`Unknown Decoder type: ${e.type}`)}}var aS=jue,Mue=class{constructor(e,t){let n=ux(e,`Tokenizer`,[`model`,`decoder`,`post_processor`,`pre_tokenizer`,`normalizer`]);if(n)throw Error(n);let r=ux(t,`Config`);if(r)throw Error(r);this.tokenizer=e,this.config=t,this.normalizer=Ox(this.tokenizer.normalizer),this.pre_tokenizer=Hx(this.tokenizer.pre_tokenizer),this.model=mue(this.tokenizer.model,this.config),this.post_processor=rS(this.tokenizer.post_processor),this.decoder=aS(this.tokenizer.decoder),this.special_tokens=[],this.all_special_ids=[],this.added_tokens=[];let i=[],a=[];this.added_tokens_map=new Map;for(let e of this.tokenizer.added_tokens){let t=new Kb(e);if(this.added_tokens.push(t),this.model.tokens_to_ids.set(t.content,t.id),this.model.vocab[t.id]=t.content,t.special&&(this.special_tokens.push(t.content),this.all_special_ids.push(t.id)),this.added_tokens_map.set(t.content,t),t.normalized&&this.normalizer!==null){let e=this.normalizer(t.content);a.push(e),this.added_tokens_map.set(e,t)}else i.push(t.content)}(this.config.additional_special_tokens??[]).forEach(e=>{this.special_tokens.includes(e)||this.special_tokens.push(e)}),this.decoder&&(this.decoder.added_tokens=this.added_tokens,this.decoder.end_of_word_suffix=this.model.end_of_word_suffix),this.splitter_unnormalized=new Gb(i),this.splitter_normalized=new Gb(a),this.remove_space=this.config.remove_space,this.clean_up_tokenization_spaces=this.config.clean_up_tokenization_spaces??!0,this.do_lowercase_and_remove_accent=this.config.do_lowercase_and_remove_accent??!1}encode(e,{text_pair:t=null,add_special_tokens:n=!0,return_token_type_ids:r=null}={}){let{tokens:i,token_type_ids:a}=this.tokenize_helper(e,{text_pair:t,add_special_tokens:n}),o=i.map(e=>this.added_tokens_map.get(e)?.id??this.model.tokens_to_ids.get(e)??this.model.unk_token_id),s={ids:o,tokens:i,attention_mask:Array(o.length).fill(1)};return r&&a&&(s.token_type_ids=a),s}decode(e,t={}){if(!Array.isArray(e)||e.length===0||!rx(e[0]))throw Error(`token_ids must be a non-empty array of integers.`);let n=e.map(e=>this.model.vocab[Number(e)]??this.model.unk_token);t.skip_special_tokens&&(n=n.filter(e=>!this.special_tokens.includes(e)));let r=this.decoder?this.decoder(n):n.join(` `);return this.decoder&&this.decoder.end_of_word_suffix&&(r=r.replaceAll(this.decoder.end_of_word_suffix,` `),t.skip_special_tokens&&(r=r.trim())),(t.clean_up_tokenization_spaces??this.clean_up_tokenization_spaces)&&(r=Qb(r)),r}tokenize(e,{text_pair:t=null,add_special_tokens:n=!1}={}){return this.tokenize_helper(e,{text_pair:t,add_special_tokens:n}).tokens}encode_text(e){if(e===null)return null;let t=this.splitter_unnormalized.split(e);return t.forEach((e,n)=>{let r=this.added_tokens_map.get(e);r&&(r.lstrip&&n>0&&(t[n-1]=t[n-1].trimEnd()),r.rstrip&&n{if(e.length===0)return[];if(this.added_tokens_map.has(e))return[e];if(this.remove_space===!0&&(e=e.trim().split(/\s+/).join(` `)),this.do_lowercase_and_remove_accent&&(e=ax(e)),this.normalizer!==null&&(e=this.normalizer(e)),e.length===0)return[];let n=this.splitter_normalized.split(e);return n.forEach((e,t)=>{let r=this.added_tokens_map.get(e);r&&(r.lstrip&&t>0&&(n[t-1]=n[t-1].trimEnd()),r.rstrip&&t{if(e.length===0)return[];if(this.added_tokens_map.has(e))return[e];let n=this.pre_tokenizer===null?[e]:this.pre_tokenizer(e,{section_index:t});return this.model(n)})})}tokenize_helper(e,{text_pair:t=null,add_special_tokens:n=!0}){let r=this.encode_text(e),i=this.encode_text(t||null);return this.post_processor?this.post_processor(r,i,n):{tokens:ox(r??[],i??[])}}token_to_id(e){return this.model.tokens_to_ids.get(e)}id_to_token(e){return this.model.vocab[e]}get_added_tokens_decoder(){let e=new Map;for(let t of this.added_tokens)e.set(t.id,t);return e}get_vocab(e=!0){let t=new Map;for(let n=0;n=`,I.ComparisonBinaryOperator],[`==`,I.ComparisonBinaryOperator],[`!=`,I.ComparisonBinaryOperator],[`<`,I.ComparisonBinaryOperator],[`>`,I.ComparisonBinaryOperator],[`+`,I.AdditiveBinaryOperator],[`-`,I.AdditiveBinaryOperator],[`~`,I.AdditiveBinaryOperator],[`*`,I.MultiplicativeBinaryOperator],[`/`,I.MultiplicativeBinaryOperator],[`%`,I.MultiplicativeBinaryOperator],[`=`,I.Equals]],Pue=new Map([[`n`,` `],[`t`,` `],[`r`,`\r`],[`b`,`\b`],[`f`,`\f`],[`v`,`\v`],[`'`,`'`],[`"`,`"`],[`\\`,`\\`]]);function Fue(e,t={}){return e.endsWith(` `)&&(e=e.slice(0,-1)),t.lstrip_blocks&&(e=e.replace(/^[ \t]*({[#%-])/gm,`$1`)),t.trim_blocks&&(e=e.replace(/([#%-]})\n/g,`$1`)),e.replace(/{%\s*(end)?generation\s*%}/gs,``)}function Iue(e,t={}){let n=[],r=Fue(e,t),i=0,a=0,o=e=>{let t=``;for(;e(r[i]);){if(r[i]===`\\`){if(++i,i>=r.length)throw SyntaxError(`Unexpected end of input`);let e=r[i++],n=Pue.get(e);if(n===void 0)throw SyntaxError(`Unexpected escaped character: ${e}`);t+=n;continue}if(t+=r[i++],i>=r.length)throw SyntaxError(`Unexpected end of input`)}return t},s=()=>{let e=n.at(-1);e&&e.type===I.Text&&(e.value=e.value.trimEnd(),e.value===``&&n.pop())},c=()=>{for(;i0){n.push(new oS(e,I.Text));continue}}if(r[i]===`{`&&r[i+1]===`#`){i+=2;let e=r[i]===`-`;e&&++i;let t=``;for(;r[i]!==`#`||r[i+1]!==`}`;){if(i+2>=r.length)throw SyntaxError(`Missing end of comment tag`);t+=r[i++]}let a=t.endsWith(`-`);a&&(t=t.slice(0,-1)),e&&s(),n.push(new oS(t,I.Comment)),i+=2,a&&c();continue}if(r.slice(i,i+3)===`{%-`){s(),n.push(new oS(`{%`,I.OpenStatement)),i+=3;continue}if(r.slice(i,i+3)===`{{-`){s(),n.push(new oS(`{{`,I.OpenExpression)),a=0,i+=3;continue}if(o(lS),r.slice(i,i+3)===`-%}`){n.push(new oS(`%}`,I.CloseStatement)),i+=3,c();continue}if(r.slice(i,i+3)===`-}}`){n.push(new oS(`}}`,I.CloseExpression)),i+=3,c();continue}let t=r[i];if(t===`-`||t===`+`){let e=n.at(-1)?.type;if(e===I.Text||e===void 0)throw SyntaxError(`Unexpected character: ${t}`);switch(e){case I.Identifier:case I.NumericLiteral:case I.StringLiteral:case I.CloseParen:case I.CloseSquareBracket:break;default:{++i;let e=o(cS);n.push(new oS(`${t}${e}`,e.length>0?I.NumericLiteral:I.UnaryOperator));continue}}}for(let[e,t]of Nue)if(!(e===`}}`&&a>0)&&r.slice(i,i+e.length)===e){n.push(new oS(e,t)),t===I.OpenExpression?a=0:t===I.OpenCurlyBracket?++a:t===I.CloseCurlyBracket&&--a,i+=e.length;continue main}if(t===`'`||t===`"`){++i;let e=o(e=>e!==t);n.push(new oS(e,I.StringLiteral)),++i;continue}if(cS(t)){let e=o(cS);if(r[i]===`.`&&cS(r[i+1])){++i;let t=o(cS);e=`${e}.${t}`}n.push(new oS(e,I.NumericLiteral));continue}if(sS(t)){let e=o(sS);n.push(new oS(e,I.Identifier));continue}throw SyntaxError(`Unexpected character: ${t}`)}return n}var uS=class{type=`Statement`},Lue=class extends uS{constructor(e){super(),this.body=e}type=`Program`},Rue=class extends uS{constructor(e,t,n){super(),this.test=e,this.body=t,this.alternate=n}type=`If`},zue=class extends uS{constructor(e,t,n,r){super(),this.loopvar=e,this.iterable=t,this.body=n,this.defaultBlock=r}type=`For`},Bue=class extends uS{type=`Break`},Vue=class extends uS{type=`Continue`},Hue=class extends uS{constructor(e,t,n){super(),this.assignee=e,this.value=t,this.body=n}type=`Set`},Uue=class extends uS{constructor(e,t,n){super(),this.name=e,this.args=t,this.body=n}type=`Macro`},Wue=class extends uS{constructor(e){super(),this.value=e}type=`Comment`},dS=class extends uS{type=`Expression`},Gue=class extends dS{constructor(e,t,n){super(),this.object=e,this.property=t,this.computed=n}type=`MemberExpression`},fS=class extends dS{constructor(e,t){super(),this.callee=e,this.args=t}type=`CallExpression`},pS=class extends dS{constructor(e){super(),this.value=e}type=`Identifier`},mS=class extends dS{constructor(e){super(),this.value=e}type=`Literal`},Kue=class extends mS{type=`IntegerLiteral`},que=class extends mS{type=`FloatLiteral`},hS=class extends mS{type=`StringLiteral`},Jue=class extends mS{type=`ArrayLiteral`},gS=class extends mS{type=`TupleLiteral`},Yue=class extends mS{type=`ObjectLiteral`},_S=class extends dS{constructor(e,t,n){super(),this.operator=e,this.left=t,this.right=n}type=`BinaryExpression`},Xue=class extends dS{constructor(e,t){super(),this.operand=e,this.filter=t}type=`FilterExpression`},Zue=class extends uS{constructor(e,t){super(),this.filter=e,this.body=t}type=`FilterStatement`},Que=class extends dS{constructor(e,t){super(),this.lhs=e,this.test=t}type=`SelectExpression`},$ue=class extends dS{constructor(e,t,n){super(),this.operand=e,this.negate=t,this.test=n}type=`TestExpression`},ede=class extends dS{constructor(e,t){super(),this.operator=e,this.argument=t}type=`UnaryExpression`},tde=class extends dS{constructor(e=void 0,t=void 0,n=void 0){super(),this.start=e,this.stop=t,this.step=n}type=`SliceExpression`},nde=class extends dS{constructor(e,t){super(),this.key=e,this.value=t}type=`KeywordArgumentExpression`},rde=class extends dS{constructor(e){super(),this.argument=e}type=`SpreadExpression`},ide=class extends uS{constructor(e,t,n){super(),this.call=e,this.callerArgs=t,this.body=n}type=`CallStatement`},ade=class extends dS{constructor(e,t,n){super(),this.condition=e,this.trueExpr=t,this.falseExpr=n}type=`Ternary`};function ode(e){let t=new Lue([]),n=0;function r(t,r){let i=e[n++];if(!i||i.type!==t)throw Error(`Parser Error: ${r}. ${i.type} !== ${t}.`);return i}function i(e){if(!c(e))throw SyntaxError(`Expected ${e}`);++n}function a(){switch(e[n].type){case I.Comment:return new Wue(e[n++].value);case I.Text:return l();case I.OpenStatement:return u();case I.OpenExpression:return d();default:throw SyntaxError(`Unexpected token type: ${e[n].type}`)}}function o(...t){return n+t.length<=e.length&&t.every((t,r)=>t===e[n+r].type)}function s(...t){return e[n]?.type===I.OpenStatement&&e[n+1]?.type===I.Identifier&&t.includes(e[n+1]?.value)}function c(...t){return n+t.length<=e.length&&t.every((t,r)=>e[n+r].type===`Identifier`&&t===e[n+r].value)}function l(){return new hS(r(I.Text,`Expected text token`).value)}function u(){if(r(I.OpenStatement,`Expected opening statement token`),e[n].type!==I.Identifier)throw SyntaxError(`Unknown statement, got ${e[n].type}`);let t=e[n].value,c;switch(t){case`set`:++n,c=f();break;case`if`:++n,c=p(),r(I.OpenStatement,`Expected {% token`),i(`endif`),r(I.CloseStatement,`Expected %} token`);break;case`macro`:++n,c=m(),r(I.OpenStatement,`Expected {% token`),i(`endmacro`),r(I.CloseStatement,`Expected %} token`);break;case`for`:++n,c=g(),r(I.OpenStatement,`Expected {% token`),i(`endfor`),r(I.CloseStatement,`Expected %} token`);break;case`call`:{++n;let e=null;o(I.OpenParen)&&(e=E());let t=ee();if(t.type!==`Identifier`)throw SyntaxError(`Expected identifier following call statement`);let l=E();r(I.CloseStatement,`Expected closing statement token`);let u=[];for(;!s(`endcall`);)u.push(a());r(I.OpenStatement,`Expected '{%'`),i(`endcall`),r(I.CloseStatement,`Expected closing statement token`),c=new ide(new fS(t,l),e,u);break}case`break`:++n,r(I.CloseStatement,`Expected closing statement token`),c=new Bue;break;case`continue`:++n,r(I.CloseStatement,`Expected closing statement token`),c=new Vue;break;case`filter`:{++n;let e=ee();e instanceof pS&&o(I.OpenParen)&&(e=T(e)),r(I.CloseStatement,`Expected closing statement token`);let t=[];for(;!s(`endfilter`);)t.push(a());r(I.OpenStatement,`Expected '{%'`),i(`endfilter`),r(I.CloseStatement,`Expected '%}'`),c=new Zue(e,t);break}default:throw SyntaxError(`Unknown statement type: ${t}`)}return c}function d(){r(I.OpenExpression,`Expected opening expression token`);let e=_();return r(I.CloseExpression,`Expected closing expression token`),e}function f(){let e=h(),t=null,c=[];if(o(I.Equals))++n,t=h();else{for(r(I.CloseStatement,`Expected %} token`);!s(`endset`);)c.push(a());r(I.OpenStatement,`Expected {% token`),i(`endset`)}return r(I.CloseStatement,`Expected closing statement token`),new Hue(e,t,c)}function p(){let e=_();r(I.CloseStatement,`Expected closing statement token`);let t=[],i=[];for(;!s(`elif`,`else`,`endif`);)t.push(a());if(s(`elif`)){++n,++n;let e=p();i.push(e)}else if(s(`else`))for(++n,++n,r(I.CloseStatement,`Expected closing statement token`);!s(`endif`);)i.push(a());return new Rue(e,t,i)}function m(){let e=ee();if(e.type!==`Identifier`)throw SyntaxError(`Expected identifier following macro statement`);let t=E();r(I.CloseStatement,`Expected closing statement token`);let n=[];for(;!s(`endmacro`);)n.push(a());return new Uue(e,t,n)}function h(e=!1){let t=e?ee:_,r=[t()],i=o(I.Comma);for(;i&&(++n,r.push(t()),o(I.Comma)););return i?new gS(r):r[0]}function g(){let e=h(!0);if(!(e instanceof pS||e instanceof gS))throw SyntaxError(`Expected identifier/tuple for the loop variable, got ${e.type} instead`);if(!c(`in`))throw SyntaxError("Expected `in` keyword following loop variable");++n;let t=_();r(I.CloseStatement,`Expected closing statement token`);let i=[];for(;!s(`endfor`,`else`);)i.push(a());let o=[];if(s(`else`))for(++n,++n,r(I.CloseStatement,`Expected closing statement token`);!s(`endfor`);)o.push(a());return new zue(e,t,i,o)}function _(){return v()}function v(){let e=y();if(c(`if`)){++n;let t=y();return c(`else`)?(++n,new ade(t,e,v())):new Que(e,t)}return e}function y(){let t=b();for(;c(`or`);){let r=e[n];++n;let i=b();t=new _S(r,t,i)}return t}function b(){let t=x();for(;c(`and`);){let r=e[n];++n;let i=x();t=new _S(r,t,i)}return t}function x(){let t;for(;c(`not`);){let r=e[n];++n,t=new ede(r,x())}return t??S()}function S(){let t=C();for(;;){let r;if(c(`not`,`in`))r=new oS(`not in`,I.Identifier),n+=2;else if(c(`in`))r=e[n++];else if(o(I.ComparisonBinaryOperator))r=e[n++];else break;let i=C();t=new _S(r,t,i)}return t}function C(){let t=A();for(;o(I.AdditiveBinaryOperator);){let r=e[n];++n;let i=A();t=new _S(r,t,i)}return t}function w(){let e=k(ee());return o(I.OpenParen)?T(e):e}function T(e){let t=new fS(e,E());return t=k(t),o(I.OpenParen)&&(t=T(t)),t}function E(){r(I.OpenParen,`Expected opening parenthesis for arguments list`);let e=D();return r(I.CloseParen,`Expected closing parenthesis for arguments list`),e}function D(){let t=[];for(;!o(I.CloseParen);){let r;if(e[n].type===I.MultiplicativeBinaryOperator&&e[n].value===`*`)++n,r=new rde(_());else if(r=_(),o(I.Equals)){if(++n,!(r instanceof pS))throw SyntaxError(`Expected identifier for keyword argument`);let e=_();r=new nde(r,e)}t.push(r),o(I.Comma)&&++n}return t}function O(){let e=[],t=!1;for(;!o(I.CloseSquareBracket);)o(I.Colon)?(e.push(void 0),++n,t=!0):(e.push(_()),o(I.Colon)&&(++n,t=!0));if(e.length===0)throw SyntaxError(`Expected at least one argument for member/slice expression`);if(t){if(e.length>3)throw SyntaxError(`Expected 0-3 arguments for slice expression`);return new tde(...e)}return e[0]}function k(t){for(;o(I.Dot)||o(I.OpenSquareBracket);){let i=e[n];++n;let a,o=i.type===I.OpenSquareBracket;if(o)a=O(),r(I.CloseSquareBracket,`Expected closing square bracket`);else if(a=ee(),a.type!==`Identifier`)throw SyntaxError(`Expected identifier following dot operator`);t=new Gue(t,a,o)}return t}function A(){let t=j();for(;o(I.MultiplicativeBinaryOperator);){let r=e[n++],i=j();t=new _S(r,t,i)}return t}function j(){let e=M();for(;c(`is`);){++n;let t=c(`not`);t&&++n;let r=ee();if(!(r instanceof pS))throw SyntaxError(`Expected identifier for the test`);e=new $ue(e,t,r)}return e}function M(){let e=w();for(;o(I.Pipe);){++n;let t=ee();if(!(t instanceof pS))throw SyntaxError(`Expected identifier for the filter`);o(I.OpenParen)&&(t=T(t)),e=new Xue(e,t)}return e}function ee(){let t=e[n++];switch(t.type){case I.NumericLiteral:{let e=t.value;return e.includes(`.`)?new que(Number(e)):new Kue(Number(e))}case I.StringLiteral:{let r=t.value;for(;o(I.StringLiteral);)r+=e[n++].value;return new hS(r)}case I.Identifier:return new pS(t.value);case I.OpenParen:{let e=h();return r(I.CloseParen,"Expected closing parenthesis, got ${tokens[current].type} instead."),e}case I.OpenSquareBracket:{let e=[];for(;!o(I.CloseSquareBracket);)e.push(_()),o(I.Comma)&&++n;return++n,new Jue(e)}case I.OpenCurlyBracket:{let e=new Map;for(;!o(I.CloseCurlyBracket);){let t=_();r(I.Colon,`Expected colon between key and value in object literal`);let i=_();e.set(t,i),o(I.Comma)&&++n}return++n,new Yue(e)}default:throw SyntaxError(`Unexpected token: ${t.type}`)}}for(;n0)for(let i=e;it;i+=n)r.push(i);return r}function vS(e,t,n,r=1){let i=Math.sign(r);i>=0?(t=(t??=0)<0?Math.max(e.length+t,0):Math.min(t,e.length),n=(n??=e.length)<0?Math.max(e.length+n,0):Math.min(n,e.length)):(t=(t??=e.length-1)<0?Math.max(e.length+t,-1):Math.min(t,e.length-1),n=(n??=-1)<-1?Math.max(e.length+n,-1):Math.min(n,e.length-1));let a=[];for(let o=t;i*oe.toUpperCase())}function lde(e){return ude(new Date,e)}function ude(e,t){let n=new Intl.DateTimeFormat(void 0,{month:`long`}),r=new Intl.DateTimeFormat(void 0,{month:`short`}),i=e=>e<10?`0`+e:e.toString();return t.replace(/%[YmdbBHM%]/g,t=>{switch(t){case`%Y`:return e.getFullYear().toString();case`%m`:return i(e.getMonth()+1);case`%d`:return i(e.getDate());case`%b`:return r.format(e);case`%B`:return n.format(e);case`%H`:return i(e.getHours());case`%M`:return i(e.getMinutes());case`%%`:return`%`;default:return t}})}function dde(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function fde(e,t,n,r){if(r===0)return e;let i=r==null||r<0?1/0:r,a=t.length===0?RegExp(`(?=)`,`gu`):new RegExp(dde(t),`gu`);return e.replaceAll(a,e=>i>0?(--i,n):e)}var yS=class extends Error{},bS=class extends Error{},xS=class{type=`RuntimeValue`;value;builtins=new Map;constructor(e=void 0){this.value=e}__bool__(){return new TS(!!this.value)}toString(){return String(this.value)}},SS=class extends xS{type=`IntegerValue`},CS=class extends xS{type=`FloatValue`;toString(){return this.value%1==0?this.value.toFixed(1):this.value.toString()}},wS=class extends xS{type=`StringValue`;builtins=new Map([[`upper`,new MS(()=>new wS(this.value.toUpperCase()))],[`lower`,new MS(()=>new wS(this.value.toLowerCase()))],[`strip`,new MS(()=>new wS(this.value.trim()))],[`title`,new MS(()=>new wS(cde(this.value)))],[`capitalize`,new MS(()=>new wS(this.value.charAt(0).toUpperCase()+this.value.slice(1)))],[`length`,new SS(this.value.length)],[`rstrip`,new MS(()=>new wS(this.value.trimEnd()))],[`lstrip`,new MS(()=>new wS(this.value.trimStart()))],[`startswith`,new MS(e=>{if(e.length===0)throw Error(`startswith() requires at least one argument`);let t=e[0];if(t instanceof wS)return new TS(this.value.startsWith(t.value));if(t instanceof AS){for(let e of t.value){if(!(e instanceof wS))throw Error(`startswith() tuple elements must be strings`);if(this.value.startsWith(e.value))return new TS(!0)}return new TS(!1)}throw Error(`startswith() argument must be a string or tuple of strings`)})],[`endswith`,new MS(e=>{if(e.length===0)throw Error(`endswith() requires at least one argument`);let t=e[0];if(t instanceof wS)return new TS(this.value.endsWith(t.value));if(t instanceof AS){for(let e of t.value){if(!(e instanceof wS))throw Error(`endswith() tuple elements must be strings`);if(this.value.endsWith(e.value))return new TS(!0)}return new TS(!1)}throw Error(`endswith() argument must be a string or tuple of strings`)})],[`split`,new MS(e=>{let t=e[0]??new NS;if(!(t instanceof wS||t instanceof NS))throw Error(`sep argument must be a string or null`);let n=e[1]??new SS(-1);if(!(n instanceof SS))throw Error(`maxsplit argument must be a number`);let r=[];if(t instanceof NS){let e=this.value.trimStart();for(let{0:t,index:i}of e.matchAll(/\S+/g)){if(n.value!==-1&&r.length>=n.value&&i!==void 0){r.push(t+e.slice(i+t.length));break}r.push(t)}}else{if(t.value===``)throw Error(`empty separator`);r=this.value.split(t.value),n.value!==-1&&r.length>n.value&&r.push(r.splice(n.value).join(t.value))}return new AS(r.map(e=>new wS(e)))})],[`replace`,new MS(e=>{if(e.length<2)throw Error(`replace() requires at least two arguments`);let t=e[0],n=e[1];if(!(t instanceof wS&&n instanceof wS))throw Error(`replace() arguments must be strings`);let r;if(r=e.length>2?e[2].type===`KeywordArgumentsValue`?e[2].value.get(`count`)??new NS:e[2]:new NS,!(r instanceof SS||r instanceof NS))throw Error(`replace() count argument must be a number or null`);return new wS(fde(this.value,t.value,n.value,r.value))})]])},TS=class extends xS{type=`BooleanValue`},pde=/[\x7f-\uffff]/g;function ES(e){return e.replace(pde,e=>`\\u`+e.charCodeAt(0).toString(16).padStart(4,`0`))}function DS(e,t={},n=0,r=!0){let{indent:i=null,ensureAscii:a=!1,separators:o=null,sortKeys:s=!1}=t,c,l;switch(o?[c,l]=o:i?(c=`,`,l=`: `):(c=`, `,l=`: `),e.type){case`NullValue`:return`null`;case`UndefinedValue`:return r?`null`:`undefined`;case`IntegerValue`:case`FloatValue`:case`BooleanValue`:return JSON.stringify(e.value);case`StringValue`:{let t=JSON.stringify(e.value);return a&&(t=ES(t)),t}case`ArrayValue`:case`ObjectValue`:{let o=i?` `.repeat(i):``,u=` `+o.repeat(n),d=u+o;if(e.type===`ArrayValue`){let a=e.value.map(e=>DS(e,t,n+1,r));return i?`[${d}${a.join(`${c}${d}`)}${u}]`:`[${a.join(c)}]`}{let o=Array.from(e.value.entries());s&&(o=o.sort(([e],[t])=>e.localeCompare(t)));let f=o.map(([e,o])=>{let s=JSON.stringify(e);a&&(s=ES(s));let c=`${s}${l}${DS(o,t,n+1,r)}`;return i?`${d}${c}`:c});return i?`{${f.join(c)}${u}}`:`{${f.join(c)}}`}}default:throw Error(`Cannot convert to JSON: ${e.type}`)}}var OS=class extends xS{type=`ObjectValue`;__bool__(){return new TS(this.value.size>0)}builtins=new Map([[`get`,new MS(([e,t])=>{if(!(e instanceof wS))throw Error(`Object key must be a string: got ${e.type}`);return this.value.get(e.value)??t??new NS})],[`items`,new MS(()=>this.items())],[`keys`,new MS(()=>this.keys())],[`values`,new MS(()=>this.values())],[`dictsort`,new MS(e=>{let t=new Map,n=e.filter(e=>e instanceof kS?(t=e.value,!1):!0),r=n.at(0)??t.get(`case_sensitive`)??new TS(!1);if(!(r instanceof TS))throw Error(`case_sensitive must be a boolean`);let i=n.at(1)??t.get(`by`)??new wS(`key`);if(!(i instanceof wS))throw Error(`by must be a string`);if(![`key`,`value`].includes(i.value))throw Error(`by must be either 'key' or 'value'`);let a=n.at(2)??t.get(`reverse`)??new TS(!1);if(!(a instanceof TS))throw Error(`reverse must be a boolean`);return new AS(Array.from(this.value.entries()).map(([e,t])=>new AS([new wS(e),t])).sort((e,t)=>{let n=i.value===`key`?0:1,o=e.value[n],s=t.value[n],c=LS(o,s,r.value);return a.value?-c:c}))})]]);items(){return new AS(Array.from(this.value.entries()).map(([e,t])=>new AS([new wS(e),t])))}keys(){return new AS(Array.from(this.value.keys()).map(e=>new wS(e)))}values(){return new AS(Array.from(this.value.values()))}toString(){return DS(this,{},0,!1)}},kS=class extends OS{type=`KeywordArgumentsValue`},AS=class extends xS{type=`ArrayValue`;builtins=new Map([[`length`,new SS(this.value.length)]]);__bool__(){return new TS(this.value.length>0)}toString(){return DS(this,{},0,!1)}},jS=class extends AS{type=`TupleValue`},MS=class extends xS{type=`FunctionValue`},NS=class extends xS{type=`NullValue`},PS=class extends xS{type=`UndefinedValue`},FS=class{constructor(e){this.parent=e}variables=new Map([[`namespace`,new MS(e=>{if(e.length===0)return new OS(new Map);if(e.length!==1||!(e[0]instanceof OS))throw Error("`namespace` expects either zero arguments or a single object argument");return e[0]})]]);tests=new Map([[`boolean`,e=>e.type===`BooleanValue`],[`callable`,e=>e instanceof MS],[`odd`,e=>{if(!(e instanceof SS))throw Error(`cannot odd on ${e.type}`);return e.value%2!=0}],[`even`,e=>{if(!(e instanceof SS))throw Error(`cannot even on ${e.type}`);return e.value%2==0}],[`false`,e=>e.type===`BooleanValue`&&!e.value],[`true`,e=>e.type===`BooleanValue`&&e.value],[`none`,e=>e.type===`NullValue`],[`string`,e=>e.type===`StringValue`],[`number`,e=>e instanceof SS||e instanceof CS],[`integer`,e=>e instanceof SS],[`iterable`,e=>e.type===`ArrayValue`||e.type===`StringValue`],[`mapping`,e=>e instanceof OS],[`sequence`,e=>e instanceof AS||e instanceof OS||e instanceof wS],[`lower`,e=>{let t=e.value;return e.type===`StringValue`&&t===t.toLowerCase()}],[`upper`,e=>{let t=e.value;return e.type===`StringValue`&&t===t.toUpperCase()}],[`none`,e=>e.type===`NullValue`],[`defined`,e=>e.type!==`UndefinedValue`],[`undefined`,e=>e.type===`UndefinedValue`],[`equalto`,(e,t)=>e.value===t.value],[`eq`,(e,t)=>e.value===t.value]]);set(e,t){return this.declareVariable(e,RS(t))}declareVariable(e,t){if(this.variables.has(e))throw SyntaxError(`Variable already declared: ${e}`);return this.variables.set(e,t),t}setVariable(e,t){return this.variables.set(e,t),t}resolve(e){if(this.variables.has(e))return this;if(this.parent)return this.parent.resolve(e);throw Error(`Unknown variable: ${e}`)}lookupVariable(e){try{return this.resolve(e).variables.get(e)??new PS}catch{return new PS}}};function mde(e){e.set(`false`,!1),e.set(`true`,!0),e.set(`none`,null),e.set(`raise_exception`,e=>{throw Error(e)}),e.set(`range`,sde),e.set(`strftime_now`,lde),e.set(`True`,!0),e.set(`False`,!1),e.set(`None`,null)}function IS(e,t){let n=t.split(`.`),r=e;for(let e of n)if(r instanceof OS)r=r.value.get(e)??new PS;else if(r instanceof AS){let t=parseInt(e,10);if(!isNaN(t)&&t>=0&&te instanceof SS||e instanceof CS||e instanceof TS,i=e=>e instanceof TS?+!!e.value:e.value;if(r(e)&&r(t)){let n=i(e),r=i(t);return nr)}if(e.type!==t.type)throw Error(`Cannot compare different types: ${e.type} and ${t.type}`);switch(e.type){case`StringValue`:{let r=e.value,i=t.value;return n||(r=r.toLowerCase(),i=i.toLowerCase()),ri)}default:throw Error(`Cannot compare type: ${e.type}`)}}var hde=class{global;constructor(e){this.global=e??new FS}run(e){return this.evaluate(e,this.global)}evaluateBinaryExpression(e,t){let n=this.evaluate(e.left,t);switch(e.operator.value){case`and`:return n.__bool__().value?this.evaluate(e.right,t):n;case`or`:return n.__bool__().value?n:this.evaluate(e.right,t)}let r=this.evaluate(e.right,t);switch(e.operator.value){case`==`:return new TS(n.value==r.value);case`!=`:return new TS(n.value!=r.value)}if(n instanceof PS||r instanceof PS){if(r instanceof PS&&[`in`,`not in`].includes(e.operator.value))return new TS(e.operator.value===`not in`);throw Error(`Cannot perform operation ${e.operator.value} on undefined values`)}if(n instanceof NS||r instanceof NS)throw Error(`Cannot perform operation on null values`);if(e.operator.value===`~`)return new wS(n.value.toString()+r.value.toString());if((n instanceof SS||n instanceof CS)&&(r instanceof SS||r instanceof CS)){let t=n.value,i=r.value;switch(e.operator.value){case`+`:case`-`:case`*`:{let a=e.operator.value===`+`?t+i:e.operator.value===`-`?t-i:t*i;return n instanceof CS||r instanceof CS?new CS(a):new SS(a)}case`/`:return new CS(t/i);case`%`:{let e=t%i;return n instanceof CS||r instanceof CS?new CS(e):new SS(e)}case`<`:return new TS(t`:return new TS(t>i);case`>=`:return new TS(t>=i);case`<=`:return new TS(t<=i)}}else if(n instanceof AS&&r instanceof AS)switch(e.operator.value){case`+`:return new AS(n.value.concat(r.value))}else if(r instanceof AS){let t=r.value.find(e=>e.value===n.value)!==void 0;switch(e.operator.value){case`in`:return new TS(t);case`not in`:return new TS(!t)}}if(n instanceof wS||r instanceof wS)switch(e.operator.value){case`+`:return new wS(n.value.toString()+r.value.toString())}if(n instanceof wS&&r instanceof wS)switch(e.operator.value){case`in`:return new TS(r.value.includes(n.value));case`not in`:return new TS(!r.value.includes(n.value))}if(n instanceof wS&&r instanceof OS)switch(e.operator.value){case`in`:return new TS(r.value.has(n.value));case`not in`:return new TS(!r.value.has(n.value))}throw SyntaxError(`Unknown operator "${e.operator.value}" between ${n.type} and ${r.type}`)}evaluateArguments(e,t){let n=[],r=new Map;for(let i of e)if(i.type===`SpreadExpression`){let e=i,r=this.evaluate(e.argument,t);if(!(r instanceof AS))throw Error(`Cannot unpack non-iterable type: ${r.type}`);for(let e of r.value)n.push(e)}else if(i.type===`KeywordArgumentExpression`){let e=i;r.set(e.key.value,this.evaluate(e.value,t))}else{if(r.size>0)throw Error(`Positional arguments must come before keyword arguments`);n.push(this.evaluate(i,t))}return[n,r]}applyFilter(e,t,n){if(t.type===`Identifier`){let r=t;if(r.value===`safe`)return e;if(r.value===`tojson`)return new wS(DS(e,{}));if(e instanceof AS)switch(r.value){case`list`:return e;case`first`:return e.value[0];case`last`:return e.value[e.value.length-1];case`length`:return new SS(e.value.length);case`reverse`:return new AS(e.value.slice().reverse());case`sort`:return new AS(e.value.slice().sort((e,t)=>LS(e,t,!1)));case`join`:return new wS(e.value.map(e=>e.value).join(``));case`string`:return new wS(DS(e,{},0,!1));case`unique`:{let t=new Set,n=[];for(let r of e.value)t.has(r.value)||(t.add(r.value),n.push(r));return new AS(n)}default:throw Error(`Unknown ArrayValue filter: ${r.value}`)}else if(e instanceof wS)switch(r.value){case`length`:case`upper`:case`lower`:case`title`:case`capitalize`:{let t=e.builtins.get(r.value);if(t instanceof MS)return t.value([],n);if(t instanceof SS)return t;throw Error(`Unknown StringValue filter: ${r.value}`)}case`trim`:return new wS(e.value.trim());case`indent`:return new wS(e.value.split(` `).map((e,t)=>t===0||e.length===0?e:` `+e).join(` `));case`join`:case`string`:return e;case`int`:{let t=parseInt(e.value,10);return new SS(isNaN(t)?0:t)}case`float`:{let t=parseFloat(e.value);return new CS(isNaN(t)?0:t)}default:throw Error(`Unknown StringValue filter: ${r.value}`)}else if(e instanceof SS||e instanceof CS)switch(r.value){case`abs`:return e instanceof SS?new SS(Math.abs(e.value)):new CS(Math.abs(e.value));case`int`:return new SS(Math.floor(e.value));case`float`:return new CS(e.value);case`string`:return new wS(e.toString());default:throw Error(`Unknown NumericValue filter: ${r.value}`)}else if(e instanceof OS)switch(r.value){case`items`:return new AS(Array.from(e.value.entries()).map(([e,t])=>new AS([new wS(e),t])));case`length`:return new SS(e.value.size);default:{let t=e.builtins.get(r.value);if(t)return t instanceof MS?t.value([],n):t;throw Error(`Unknown ObjectValue filter: ${r.value}`)}}else if(e instanceof TS)switch(r.value){case`bool`:return new TS(e.value);case`int`:return new SS(+!!e.value);case`float`:return new CS(+!!e.value);case`string`:return new wS(e.value?`true`:`false`);default:throw Error(`Unknown BooleanValue filter: ${r.value}`)}throw Error(`Cannot apply filter "${r.value}" to type: ${e.type}`)}if(t.type===`CallExpression`){let r=t;if(r.callee.type!==`Identifier`)throw Error(`Unknown filter: ${r.callee.type}`);let i=r.callee.value;if(i===`tojson`){let[,t]=this.evaluateArguments(r.args,n),i=t.get(`indent`)??new NS;if(!(i instanceof SS||i instanceof NS))throw Error(`If set, indent must be a number`);let a=t.get(`ensure_ascii`)??new TS(!1);if(!(a instanceof TS))throw Error(`If set, ensure_ascii must be a boolean`);let o=t.get(`sort_keys`)??new TS(!1);if(!(o instanceof TS))throw Error(`If set, sort_keys must be a boolean`);let s=t.get(`separators`)??new NS,c=null;if(s instanceof AS||s instanceof jS){if(s.value.length!==2)throw Error(`separators must be a tuple of two strings`);let[e,t]=s.value;if(!(e instanceof wS)||!(t instanceof wS))throw Error(`separators must be a tuple of two strings`);c=[e.value,t.value]}else if(!(s instanceof NS))throw Error(`If set, separators must be a tuple of two strings`);return new wS(DS(e,{indent:i.value,ensureAscii:a.value,sortKeys:o.value,separators:c}))}if(i===`join`){let t;if(e instanceof wS)t=Array.from(e.value);else if(e instanceof AS)t=e.value.map(e=>e.value);else throw Error(`Cannot apply filter "${i}" to type: ${e.type}`);let[a,o]=this.evaluateArguments(r.args,n),s=a.at(0)??o.get(`separator`)??new wS(``);if(!(s instanceof wS))throw Error(`separator must be a string`);return new wS(t.join(s.value))}if(i===`int`||i===`float`){let[t,a]=this.evaluateArguments(r.args,n),o=t.at(0)??a.get(`default`)??(i===`int`?new SS(0):new CS(0));if(e instanceof wS){let t=i===`int`?parseInt(e.value,10):parseFloat(e.value);return isNaN(t)?o:i===`int`?new SS(t):new CS(t)}if(e instanceof SS||e instanceof CS)return e;if(e instanceof TS)return i===`int`?new SS(+!!e.value):new CS(+!!e.value);throw Error(`Cannot apply filter "${i}" to type: ${e.type}`)}if(i==="default"){let[t,i]=this.evaluateArguments(r.args,n),a=t[0]??new wS(``),o=t[1]??i.get(`boolean`)??new TS(!1);if(!(o instanceof TS))throw Error("`default` filter flag must be a boolean");return e instanceof PS||o.value&&!e.__bool__().value?a:e}if(e instanceof AS){switch(i){case`sort`:{let[t,i]=this.evaluateArguments(r.args,n),a=t.at(0)??i.get(`reverse`)??new TS(!1);if(!(a instanceof TS))throw Error(`reverse must be a boolean`);let o=t.at(1)??i.get(`case_sensitive`)??new TS(!1);if(!(o instanceof TS))throw Error(`case_sensitive must be a boolean`);let s=t.at(2)??i.get(`attribute`)??new NS;if(!(s instanceof wS||s instanceof SS||s instanceof NS))throw Error(`attribute must be a string, integer, or null`);let c=e=>s instanceof NS?e:IS(e,s instanceof SS?String(s.value):s.value);return new AS(e.value.slice().sort((e,t)=>{let n=LS(c(e),c(t),o.value);return a.value?-n:n}))}case`selectattr`:case`rejectattr`:{let t=i===`selectattr`;if(e.value.some(e=>!(e instanceof OS)))throw Error(`\`${i}\` can only be applied to array of objects`);if(r.args.some(e=>e.type!==`StringLiteral`))throw Error(`arguments of \`${i}\` must be strings`);let[a,o,s]=r.args.map(e=>this.evaluate(e,n)),c;if(o){let e=n.tests.get(o.value);if(!e)throw Error(`Unknown test: ${o.value}`);c=e}else c=(...e)=>e[0].__bool__().value;return new AS(e.value.filter(e=>{let n=e.value.get(a.value),r=n?c(n,s):!1;return t?r:!r}))}case`map`:{let[,t]=this.evaluateArguments(r.args,n);if(t.has(`attribute`)){let n=t.get(`attribute`);if(!(n instanceof wS))throw Error(`attribute must be a string`);let r=t.get(`default`);return new AS(e.value.map(e=>{if(!(e instanceof OS))throw Error(`items in map must be an object`);let t=IS(e,n.value);return t instanceof PS?r??new PS:t}))}throw Error("`map` expressions without `attribute` set are not currently supported.")}}throw Error(`Unknown ArrayValue filter: ${i}`)}if(e instanceof wS){switch(i){case`indent`:{let[t,i]=this.evaluateArguments(r.args,n),a=t.at(0)??i.get(`width`)??new SS(4);if(!(a instanceof SS))throw Error(`width must be a number`);let o=t.at(1)??i.get(`first`)??new TS(!1),s=t.at(2)??i.get(`blank`)??new TS(!1),c=e.value.split(` `),l=` `.repeat(a.value);return new wS(c.map((e,t)=>!o.value&&t===0||!s.value&&e.length===0?e:l+e).join(` `))}case`replace`:{let t=e.builtins.get(`replace`);if(!(t instanceof MS))throw Error(`replace filter not available`);let[i,a]=this.evaluateArguments(r.args,n);return t.value([...i,new kS(a)],n)}}throw Error(`Unknown StringValue filter: ${i}`)}if(e instanceof OS){let t=e.builtins.get(i);if(t&&t instanceof MS){let[e,i]=this.evaluateArguments(r.args,n);return i.size>0&&e.push(new kS(i)),t.value(e,n)}throw Error(`Unknown ObjectValue filter: ${i}`)}throw Error(`Cannot apply filter "${i}" to type: ${e.type}`)}throw Error(`Unknown filter: ${t.type}`)}evaluateFilterExpression(e,t){let n=this.evaluate(e.operand,t);return this.applyFilter(n,e.filter,t)}evaluateTestExpression(e,t){let n=this.evaluate(e.operand,t),r=t.tests.get(e.test.value);if(!r)throw Error(`Unknown test: ${e.test.value}`);let i=r(n);return new TS(e.negate?!i:i)}evaluateSelectExpression(e,t){return this.evaluate(e.test,t).__bool__().value?this.evaluate(e.lhs,t):new PS}evaluateUnaryExpression(e,t){let n=this.evaluate(e.argument,t);switch(e.operator.value){case`not`:return new TS(!n.value);default:throw SyntaxError(`Unknown operator: ${e.operator.value}`)}}evaluateTernaryExpression(e,t){return this.evaluate(e.condition,t).__bool__().value?this.evaluate(e.trueExpr,t):this.evaluate(e.falseExpr,t)}evalProgram(e,t){return this.evaluateBlock(e.body,t)}evaluateBlock(e,t){let n=``;for(let r of e){let e=this.evaluate(r,t);e.type!==`NullValue`&&e.type!==`UndefinedValue`&&(n+=e.toString())}return new wS(n)}evaluateIdentifier(e,t){return t.lookupVariable(e.value)}evaluateCallExpression(e,t){let[n,r]=this.evaluateArguments(e.args,t);r.size>0&&n.push(new kS(r));let i=this.evaluate(e.callee,t);if(i.type!==`FunctionValue`)throw Error(`Cannot call something that is not a function: got ${i.type}`);return i.value(n,t)}evaluateSliceExpression(e,t,n){if(!(e instanceof AS||e instanceof wS))throw Error(`Slice object must be an array or string`);let r=this.evaluate(t.start,n),i=this.evaluate(t.stop,n),a=this.evaluate(t.step,n);if(!(r instanceof SS||r instanceof PS))throw Error(`Slice start must be numeric or undefined`);if(!(i instanceof SS||i instanceof PS))throw Error(`Slice stop must be numeric or undefined`);if(!(a instanceof SS||a instanceof PS))throw Error(`Slice step must be numeric or undefined`);return e instanceof AS?new AS(vS(e.value,r.value,i.value,a.value)):new wS(vS(Array.from(e.value),r.value,i.value,a.value).join(``))}evaluateMemberExpression(e,t){let n=this.evaluate(e.object,t),r;if(e.computed){if(e.property.type===`SliceExpression`)return this.evaluateSliceExpression(n,e.property,t);r=this.evaluate(e.property,t)}else r=new wS(e.property.value);let i;if(n instanceof OS){if(!(r instanceof wS))throw Error(`Cannot access property with non-string: got ${r.type}`);i=n.value.get(r.value)??n.builtins.get(r.value)}else if(n instanceof AS||n instanceof wS){if(r instanceof SS)i=n.value.at(r.value),n instanceof wS&&(i=new wS(n.value.at(r.value)));else if(r instanceof wS)i=n.builtins.get(r.value);else throw Error(`Cannot access property with non-string/non-number: got ${r.type}`)}else{if(!(r instanceof wS))throw Error(`Cannot access property with non-string: got ${r.type}`);i=n.builtins.get(r.value)}return i instanceof xS?i:new PS}evaluateSet(e,t){let n=e.value?this.evaluate(e.value,t):this.evaluateBlock(e.body,t);if(e.assignee.type===`Identifier`){let r=e.assignee.value;t.setVariable(r,n)}else if(e.assignee.type===`TupleLiteral`){let r=e.assignee;if(!(n instanceof AS))throw Error(`Cannot unpack non-iterable type in set: ${n.type}`);let i=n.value;if(i.length!==r.value.length)throw Error(`Too ${r.value.length>i.length?`few`:`many`} items to unpack in set`);for(let e=0;et.setVariable(e.loopvar.value,c);else if(e.loopvar.type===`TupleLiteral`){let t=e.loopvar;if(c.type!==`ArrayValue`)throw Error(`Cannot unpack non-iterable type: ${c.type}`);let n=c;if(t.value.length!==n.value.length)throw Error(`Too ${t.value.length>n.value.length?`few`:`many`} items to unpack`);l=e=>{for(let r=0;r0?a[t-1]:new PS],[`nextitem`,t{let r=new FS(n);t=t.slice();let i;t.at(-1)?.type===`KeywordArgumentsValue`&&(i=t.pop());for(let n=0;n{let r=new FS(n);if(e.callerArgs)for(let n=0;nthis.evaluate(e,t)));case`TupleLiteral`:return new jS(e.value.map(e=>this.evaluate(e,t)));case`ObjectLiteral`:{let n=new Map;for(let[r,i]of e.value){let e=this.evaluate(r,t);if(!(e instanceof wS))throw Error(`Object keys must be strings: got ${e.type}`);n.set(e.value,this.evaluate(i,t))}return new OS(n)}case`Identifier`:return this.evaluateIdentifier(e,t);case`CallExpression`:return this.evaluateCallExpression(e,t);case`MemberExpression`:return this.evaluateMemberExpression(e,t);case`UnaryExpression`:return this.evaluateUnaryExpression(e,t);case`BinaryExpression`:return this.evaluateBinaryExpression(e,t);case`FilterExpression`:return this.evaluateFilterExpression(e,t);case`FilterStatement`:return this.evaluateFilterStatement(e,t);case`TestExpression`:return this.evaluateTestExpression(e,t);case`SelectExpression`:return this.evaluateSelectExpression(e,t);case`Ternary`:return this.evaluateTernaryExpression(e,t);case`Comment`:return new NS;default:throw SyntaxError(`Unknown node type: ${e.type}`)}}};function RS(e){switch(typeof e){case`number`:return Number.isInteger(e)?new SS(e):new CS(e);case`string`:return new wS(e);case`boolean`:return new TS(e);case`undefined`:return new PS;case`object`:return e===null?new NS:Array.isArray(e)?new AS(e.map(RS)):new OS(new Map(Object.entries(e).map(([e,t])=>[e,RS(t)])));case`function`:return new MS((t,n)=>RS(e(...t.map(e=>e.value))??null));default:throw Error(`Cannot convert to runtime value: ${e}`)}}var zS=` `,gde=`{%- `,_de=` -%}`;function vde(e){switch(e.operator.type){case`MultiplicativeBinaryOperator`:return 4;case`AdditiveBinaryOperator`:return 3;case`ComparisonBinaryOperator`:return 2;case`Identifier`:return e.operator.value===`and`?1:e.operator.value===`in`||e.operator.value===`not in`?2:0}return 0}function yde(e,t=` `){let n=typeof t==`number`?` `.repeat(t):t;return VS(e.body,0,n).replace(/\n$/,``)}function BS(...e){return gde+e.join(` `)+_de}function VS(e,t,n){return e.map(e=>bde(e,t,n)).join(zS)}function bde(e,t,n){let r=n.repeat(t);switch(e.type){case`Program`:return VS(e.body,t,n);case`If`:return xde(e,t,n);case`For`:return Sde(e,t,n);case`Set`:return Cde(e,t,n);case`Macro`:return wde(e,t,n);case`Break`:return r+BS(`break`);case`Continue`:return r+BS(`continue`);case`CallStatement`:return Tde(e,t,n);case`FilterStatement`:return Ede(e,t,n);case`Comment`:return r+`{# `+e.value+` #}`;default:return r+`{{- `+HS(e)+` -}}`}}function xde(e,t,n){let r=n.repeat(t),i=[],a=e;for(;a&&(i.push({test:a.test,body:a.body}),a.alternate.length===1&&a.alternate[0].type===`If`);)a=a.alternate[0];let o=r+BS(`if`,HS(i[0].test))+zS+VS(i[0].body,t+1,n);for(let e=1;e0&&(o+=zS+r+BS(`else`)+zS+VS(a.alternate,t+1,n)),o+=zS+r+BS(`endif`),o}function Sde(e,t,n){let r=n.repeat(t),i=``;if(e.iterable.type===`SelectExpression`){let t=e.iterable;i=`${HS(t.lhs)} if ${HS(t.test)}`}else i=HS(e.iterable);let a=r+BS(`for`,HS(e.loopvar),`in`,i)+zS+VS(e.body,t+1,n);return e.defaultBlock.length>0&&(a+=zS+r+BS(`else`)+zS+VS(e.defaultBlock,t+1,n)),a+=zS+r+BS(`endfor`),a}function Cde(e,t,n){let r=n.repeat(t),i=HS(e.assignee),a=e.value?HS(e.value):``,o=r+BS(`set`,`${i}${e.value?` = `+a:``}`);return e.body.length===0?o:o+zS+VS(e.body,t+1,n)+zS+r+BS(`endset`)}function wde(e,t,n){let r=n.repeat(t),i=e.args.map(HS).join(`, `);return r+BS(`macro`,`${e.name.value}(${i})`)+zS+VS(e.body,t+1,n)+zS+r+BS(`endmacro`)}function Tde(e,t,n){let r=n.repeat(t),i=e.callerArgs&&e.callerArgs.length>0?`(${e.callerArgs.map(HS).join(`, `)})`:``,a=HS(e.call),o=r+BS(`call${i}`,a)+zS;return o+=VS(e.body,t+1,n)+zS,o+=r+BS(`endcall`),o}function Ede(e,t,n){let r=n.repeat(t),i=r+BS(`filter`,e.filter.type===`Identifier`?e.filter.value:HS(e.filter))+zS;return i+=VS(e.body,t+1,n)+zS,i+=r+BS(`endfilter`),i}function HS(e,t=-1){switch(e.type){case`SpreadExpression`:return`*${HS(e.argument)}`;case`Identifier`:return e.value;case`IntegerLiteral`:return`${e.value}`;case`FloatLiteral`:return`${e.value}`;case`StringLiteral`:return JSON.stringify(e.value);case`BinaryExpression`:{let n=e,r=vde(n),i=HS(n.left,r),a=HS(n.right,r+1),o=`${i} ${n.operator.value} ${a}`;return r`${HS(e)}: ${HS(t)}`).join(`, `)}}`;case`SliceExpression`:{let t=e;return`${t.start?HS(t.start):``}:${t.stop?HS(t.stop):``}${t.step?`:${HS(t.step)}`:``}`}case`KeywordArgumentExpression`:{let t=e;return`${t.key.value}=${HS(t.value)}`}case`Ternary`:{let n=e,r=`${HS(n.trueExpr)} if ${HS(n.condition,0)} else ${HS(n.falseExpr)}`;return t>-1?`(${r})`:r}default:throw Error(`Unknown expression type: ${e.type}`)}}var Dde=class{parsed;constructor(e){let t=Iue(e,{lstrip_blocks:!0,trim_blocks:!0});this.parsed=ode(t)}render(e){let t=new FS;if(mde(t),e)for(let[n,r]of Object.entries(e))t.set(n,r);return new hde(t).run(this.parsed).value}format(e){return yde(this.parsed,e?.indent||` `)}},Ode={txt:`text/plain`,html:`text/html`,css:`text/css`,js:`text/javascript`,json:`application/json`,png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`},US=class e{constructor(e){if(this.filePath=e,this.headers=new Headers,this.exists=pb.existsSync(e),this.exists){this.status=200,this.statusText=`OK`;let t=pb.statSync(e);this.headers.set(`content-length`,t.size.toString()),this.updateContentType();let n=pb.createReadStream(e);this.body=new ReadableStream({start(e){n.on(`data`,t=>e.enqueue(t)),n.on(`end`,()=>e.close()),n.on(`error`,t=>e.error(t))},cancel(){n.destroy()}})}else this.status=404,this.statusText=`Not Found`,this.body=null}updateContentType(){let e=this.filePath.toString().split(`.`).pop().toLowerCase();this.headers.set(`content-type`,Ode[e]??`application/octet-stream`)}clone(){let t=new e(this.filePath);return t.exists=this.exists,t.status=this.status,t.statusText=this.statusText,t.headers=new Headers(this.headers),t}async arrayBuffer(){return(await pb.promises.readFile(this.filePath)).buffer}async blob(){let e=await pb.promises.readFile(this.filePath);return new Blob([e],{type:this.headers.get(`content-type`)})}async text(){return await pb.promises.readFile(this.filePath,`utf8`)}async json(){return JSON.parse(await this.text())}},WS=class{constructor(e){this._mt=new Uint32Array(624),this._idx=625,this._gauss_next=null,this._random_fn=this.random.bind(this),this.seed(e)}seed(e){if(e==null){if(wb.IS_CRYPTO_AVAILABLE){let t=new Uint32Array(1);crypto.getRandomValues(t),e=t[0]}else e=Date.now()>>>0}let t=this._mt,n=(e,t)=>Math.imul(e,t)>>>0,r=[];for(let t=e||0;t>0;t=Math.floor(t/4294967296))r.push(t&4294967295);r.length||r.push(0),t[0]=19650218;for(let e=1;e<624;++e)t[e]=n(1812433253,t[e-1]^t[e-1]>>>30)+e>>>0;let i=1,a=0;for(let e=Math.max(624,r.length);e>0;--e,++i,++a)i>=624&&(t[0]=t[623],i=1),a>=r.length&&(a=0),t[i]=(t[i]^n(t[i-1]^t[i-1]>>>30,1664525))+r[a]+a>>>0;for(let e=623;e>0;--e,++i)i>=624&&(t[0]=t[623],i=1),t[i]=(t[i]^n(t[i-1]^t[i-1]>>>30,1566083941))-i>>>0;t[0]=2147483648,this._idx=624,this._gauss_next=null}_int32(){let e=this._mt;if(this._idx>=624){for(let t=0;t<624;++t){let n=e[t]&2147483648|e[(t+1)%624]&2147483647;e[t]=(e[(t+397)%624]^n>>>1^(n&1?2567483615:0))>>>0}this._idx=0}let t=e[this._idx++];return t^=t>>>11,t^=t<<7&2636928640,t^=t<<15&4022730752,t^=t>>>18,t>>>0}random(){return((this._int32()>>>5)*67108864+(this._int32()>>>6))/9007199254740992}gauss(e=0,t=1){let n=this._gauss_next;if(this._gauss_next=null,n===null){let e=this.random()*2*Math.PI,t=Math.sqrt(-2*Math.log(1-this.random()));n=Math.cos(e)*t,this._gauss_next=Math.sin(e)*t}return e+n*t}shuffle(e){for(let t=e.length-1;t>0;--t){let n=32-Math.clz32(t+1),r=this._int32()>>>32-n;for(;r>t;)r=this._int32()>>>32-n;let i=e[t];e[t]=e[r],e[r]=i}}choices(e,t){return e[GS(this._random_fn,t)]}};function GS(e,t){let n=0;for(let e=0;eGS(qS.random,e),Ade=new WS,JS=class{constructor(e){this.path=e}async match(e){let t=new US(mb.join(this.path,e));if(t.exists)return t}async put(e,t,n=void 0){let r=mb.join(this.path,e),i=r+`.tmp.${wb.IS_PROCESS_AVAILABLE?process.pid:Date.now()}.${Ade._int32().toString(36)}`;try{let e=t.headers.get(`Content-Length`),a=parseInt(e??`0`),o=0;await pb.promises.mkdir(mb.dirname(r),{recursive:!0});let s=pb.createWriteStream(i),c=t.body.getReader();for(;;){let{done:e,value:t}=await c.read();if(e)break;await new Promise((e,n)=>{s.write(t,t=>{if(t){n(t);return}e()})}),o+=t.length;let r=a?o/a*100:0;n?.({progress:r,loaded:o,total:a})}await new Promise((e,t)=>{s.close(n=>n?t(n):e())}),await pb.promises.rename(i,r)}catch(e){try{await pb.promises.unlink(i)}catch{}throw e}}async delete(e){let t=mb.join(this.path,e);try{return await pb.promises.unlink(t),!0}catch{return!1}}},jde={400:`Bad request error occurred while trying to load file`,401:`Unauthorized access to file`,403:`Forbidden access to file`,404:`Could not locate file`,408:`Request timeout error occurred while trying to load file`,500:`Internal server error error occurred while trying to load file`,502:`Bad gateway error occurred while trying to load file`,503:`Service unavailable error occurred while trying to load file`,504:`Gateway timeout error occurred while trying to load file`},YS=100,Mde=/^(\b[\w\-.]+\b\/)?\b[\w\-.]{1,96}\b$/;function XS(...e){return e=e.map((t,n)=>(n&&(t=t.replace(RegExp(`^/`),``)),n!==e.length-1&&(t=t.replace(RegExp(`/$`),``)),t)),e.join(`/`)}function ZS(e,t=null,n=null){let r;try{r=new URL(e)}catch{return!1}return!(t&&!t.includes(r.protocol)||n&&!n.includes(r.hostname))}function Nde(e){return!(!Mde.test(e)||e.includes(`..`)||e.includes(`--`)||e.endsWith(`.git`)||e.endsWith(`.ipynb`))}function Pde(e,t,n){if(!n)return null;let r=jde[e]??`Error (${e}) occurred while trying to load file`;throw Error(`${r}: "${t}".`)}async function Fde(e,t,n){let r=e.headers.get(`Content-Length`),i=r?parseInt(r,10):n??0;r===null&&!n&&Wb.warn(`Unable to determine content-length from response headers. Will expand buffer when needed.`);let a=new Uint8Array(i),o=0,s=e.body.getReader();async function c(){let{done:e,value:n}=await s.read();if(e)return;let r=o+n.length;if(r>i){i=r;let e=new Uint8Array(i);e.set(a),a=e}return a.set(n,o),o=r,t({progress:o/i*100,loaded:o,total:i}),c()}return await c(),a}function QS(e){return ZS(e,[`blob:`])}function $S(e){let t;if(typeof location<`u`&&location.href)t=location.href;else if(import.meta.url)t=import.meta.url;else return e;return new URL(e,t).href}var eC=`SHA-256`,Ide=`experimental_transformers-hash-cache`,tC=e=>({algorithm:eC,value:e}),nC=class{#e=null;_getHashCache=()=>(this.#e??=caches.open(Ide),this.#e);static isAvailable=()=>typeof navigator<`u`&&`crossOriginStorage`in navigator;match=async e=>{let t=await this._getFileHash(e);if(t)try{let[e]=await navigator.crossOriginStorage.requestFileHandles([tC(t)]),n=await e.getFile();return new Response(n,{headers:{"Content-Length":String(n.size)}})}catch{return}};put=async(e,t)=>{let n=await this._getFileHash(e);if(n){let e=await t.blob();await this._storeBlobInCOS(e,n)}else this._processAndStore(e,t.body)};_storeBlobInCOS=async(e,t)=>{let[n]=await navigator.crossOriginStorage.requestFileHandles([tC(t)],{create:!0}),r=await n.createWritable();await r.write(e),await r.close()};_processAndStore=async(e,t)=>{try{let n=[];for await(let e of t)n.push(e);let r=new Blob(n),i=await this._getBlobHash(r);await this._storeBlobInCOS(r,i);try{await(await this._getHashCache()).put(e,new Response(i))}catch{}}catch{}};delete=async e=>{try{return await(await this._getHashCache()).delete(e)}catch{return!1}};_getFileHash=async e=>{try{let t=await this._getHashCache(),n=await t.match(e);if(n)return n.text();let r=await this._getLfsFileHash(e);return r?(await t.put(e,new Response(r)),r):null}catch{return null}};_getLfsFileHash=async e=>{if(!e.includes(`/resolve/`))return null;let t=e.replace(`/resolve/`,`/raw/`);try{let e=(await fetch(t).then(e=>e.text())).match(/^oid sha256:([0-9a-f]+)$/m);return e?e[1]:null}catch{return null}};_getBlobHash=async e=>{let t=await e.arrayBuffer(),n=await crypto.subtle.digest(eC,t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}};async function rC(e=null){let t=null;if(jb.useCustomCache){if(!jb.customCache)throw Error("`env.useCustomCache=true`, but `env.customCache` is not defined.");if(!jb.customCache.match||!jb.customCache.put)throw Error("`env.customCache` must be an object which implements the `match` and `put` functions of the Web Cache API. For more information, see https://developer.mozilla.org/en-US/docs/Web/API/Cache");t=jb.customCache}if(!t&&jb.experimental_useCrossOriginStorage&&nC.isAvailable()&&(t=new nC),!t&&jb.useBrowserCache){if(typeof caches>`u`)throw Error(`Browser cache is not available in this environment.`);try{t=await caches.open(jb.cacheKey)}catch(e){Wb.warn(`An error occurred while opening the browser cache:`,e)}}if(!t&&jb.useFSCache){if(!wb.IS_FS_AVAILABLE)throw Error(`File System Cache is not available in this environment.`);t=new JS(e??jb.cacheDir)}return t}async function Lde(e,...t){for(let n of t)try{let t=await e.match(n);if(t)return t}catch{continue}}var iC=new class{#e;#t;constructor(e){this.#e=e,this.#t=new Map}get(e){if(!this.#t.has(e))return;let t=this.#t.get(e);return this.#t.delete(e),this.#t.set(e,t),t}put(e,t){this.#t.has(e)&&this.#t.delete(e),this.#t.set(e,t),this.#t.size>this.#e&&this.#t.delete(this.#t.keys().next().value)}delete(e){return this.#t.delete(e)}clear(){this.#t.clear()}}(100);function aC(e,t){let n=iC.get(e);if(n!==void 0)return n;let r=t().then(e=>e,t=>(iC.delete(e),Promise.reject(t)));return iC.put(e,r),r}async function Rde(e){if(!ZS(e,[`http:`,`https:`]))return null;let t=cC(e);return t.set(`Range`,`bytes=0-0`),jb.fetch(e,{method:`GET`,headers:t,cache:`no-store`})}function oC(e,t,n={}){return aC(JSON.stringify([e,t,n?.revision,n?.cache_dir,n?.local_files_only]),()=>zde(e,t,n))}async function zde(e,t,n){let r=await rC(n?.cache_dir),{localPath:i,remoteURL:a,proposedCacheKey:o,validModelId:s}=lC(e,t,n,r),c=await uC(r,i,o);if(c!==void 0&&typeof c!=`string`){let e=c.headers.get(`content-length`),t=c.headers.get(`content-type`);return{exists:!0,size:e?parseInt(e,10):void 0,contentType:t||void 0,fromCache:!0}}if(jb.allowLocalModels&&!ZS(i,[`http:`,`https:`]))try{let e=await sC(i);if(typeof e!=`string`&&e.status!==404){let t=e.headers.get(`content-length`),n=e.headers.get(`content-type`);return{exists:!0,size:t?parseInt(t,10):void 0,contentType:n||void 0,fromCache:!1}}}catch{}if(jb.allowRemoteModels&&!n.local_files_only&&s)try{let e=await Rde(a);if(e&&e.status>=200&&e.status<300){let t,n=e.headers.get(`content-type`);if(e.status===206){let n=e.headers.get(`content-range`);if(n){let e=n.match(/bytes \d+-\d+\/(\d+)/);e&&(t=parseInt(e[1],10))}}else if(e.status===200)try{await e.body?.cancel()}catch{}if(t===void 0){let n=e.headers.get(`content-length`);t=n?parseInt(n,10):void 0}return{exists:!0,size:t,contentType:n||void 0,fromCache:!1}}}catch(e){Wb.warn(`Unable to fetch file metadata for "${a}": ${e}`)}return{exists:!1,fromCache:!1}}async function sC(e){return jb.useFS&&!ZS(e,[`http:`,`https:`,`blob:`])?new US(e instanceof URL?e.protocol===`file:`?e.pathname:e.toString():e):jb.fetch(e,{headers:cC(e)})}function cC(e){let t=typeof process<`u`&&process?.release?.name===`node`,n=new Headers;if(t){let t=!!{}.TESTING_REMOTELY,r=jb.version;if(n.set(`User-Agent`,`transformers.js/${r}; is_ci/${t};`),ZS(e,[`http:`,`https:`],[`huggingface.co`,`hf.co`])){let e={}.HF_TOKEN??{}.HF_ACCESS_TOKEN;e&&n.set(`Authorization`,`Bearer ${e}`)}}return n}function lC(e,t,n={},r=null){let i=n.revision??`main`,a=XS(e,t),o=Nde(e),s=o?XS(jb.localModelPath,a):a,c=XS(jb.remoteHost,jb.remotePathTemplate.replaceAll(`{model}`,e).replaceAll(`{revision}`,encodeURIComponent(i)),t);return{requestURL:a,localPath:s,remoteURL:c,proposedCacheKey:r instanceof JS?i===`main`?a:XS(e,i,t):c,validModelId:o}}async function uC(e,t,n){if(e)return await Lde(e,t,n)}async function Bde(e,t,n,r,i,a,o={}){if(await n.match(r)===void 0){if(!a){let a=o.progress_callback?n=>Pb(o.progress_callback,{status:`progress`,name:e,file:t,...n}):void 0;await n.put(r,i,a)}else if(typeof i!=`string`){let e=new Headers(i.headers);e.set(`content-length`,a.byteLength.toString()),await n.put(r,new Response(a,{headers:e})).catch(e=>{Wb.warn(`Unable to add response to browser cache: ${e}.`)})}}}async function Vde(e,t,n=!0,r={},i=!1,a=null){let{requestURL:o,localPath:s,remoteURL:c,proposedCacheKey:l,validModelId:u}=lC(e,t,r,a),d,f=!1,p;p=await uC(a,s,l);let m=p!==void 0;if(m)d=l;else{if(jb.allowLocalModels){if(!ZS(o,[`http:`,`https:`]))try{p=await sC(s),d=s}catch(e){Wb.warn(`Unable to load from local path "${s}": "${e}"`)}else if(r.local_files_only)throw Error(`\`local_files_only=true\`, but attempted to load a remote file from: ${o}.`);else if(!jb.allowRemoteModels)throw Error(`\`env.allowRemoteModels=false\`, but attempted to load a remote file from: ${o}.`)}if(p===void 0||typeof p!=`string`&&p.status===404){if(r.local_files_only||!jb.allowRemoteModels){if(n)throw Error(`\`local_files_only=true\` or \`env.allowRemoteModels=false\` and file was not found locally at "${s}".`);return null}if(!u)throw Error(`Local file missing at "${s}" and download aborted due to invalid model ID "${e}".`);if(p=await sC(c),p.status!==200)return Pde(p.status,c,n);d=l}f=a&&typeof Response<`u`&&p instanceof Response&&p.status===200}Pb(r.progress_callback,{status:`download`,name:e,file:t});let h;if(!(wb.IS_NODE_ENV&&i)){let n;if(typeof p!=`string`){if(!r.progress_callback)n=new Uint8Array(await p.arrayBuffer());else if(m&&typeof navigator<`u`&&/firefox/i.test(navigator.userAgent))n=new Uint8Array(await p.arrayBuffer()),Pb(r.progress_callback,{status:`progress`,name:e,file:t,progress:100,loaded:n.length,total:n.length});else{let i,a=p.headers.get(`content-length`);if(a)i=parseInt(a,10);else try{let n=await oC(e,t,r);n.size&&(i=n.size)}catch{}n=await Fde(p,n=>{Pb(r.progress_callback,{status:`progress`,name:e,file:t,...n})},i)}}h=n}if(f&&d&&typeof p!=`string`&&await Bde(e,t,a,d,p,h,r),wb.IS_NODE_ENV&&i&&r.progress_callback&&typeof p!=`string`){let n=parseInt(p.headers.get(`content-length`),10)||0;Pb(r.progress_callback,{status:`progress`,name:e,file:t,progress:100,loaded:n,total:n})}if(Pb(r.progress_callback,{status:`done`,name:e,file:t}),h){if(!wb.IS_NODE_ENV&&i)throw Error(`Cannot return path in a browser environment.`);return h}if(p instanceof US)return p.filePath;let g=await a?.match(d);if(g instanceof US)return g.filePath;if(g instanceof Response)return new Uint8Array(await g.arrayBuffer());if(typeof g==`string`)return g;throw Error(`Unable to get model file path or buffer.`)}var dC=new Map;async function fC(e,t,n=!0,r={},i=!1){if(!jb.allowLocalModels){if(r.local_files_only)throw Error("Invalid configuration detected: local models are disabled (`env.allowLocalModels=false`) but you have requested to only use local models (`local_files_only=true`).");if(!jb.allowRemoteModels)throw Error("Invalid configuration detected: both local and remote models are disabled. Fix by setting `env.allowLocalModels` or `env.allowRemoteModels` to `true`.")}Pb(r.progress_callback,{status:`initiate`,name:e,file:t});let a=`${e}::${t}`,o=dC.get(a);return o||(o=Vde(e,t,n,r,i,await rC(r?.cache_dir)).then(e=>(dC.delete(a),e),e=>{throw dC.delete(a),e}),dC.set(a,o)),await o}async function pC(e,t,n=!0,r={}){let i=await fC(e,t,n,r,!1);return i===null?null:new TextDecoder(`utf-8`).decode(i)}async function mC(e,t,n=!0,r={}){let i=await pC(e,t,n,r);return i===null?{}:JSON.parse(i)}function Hde(e,[t,n,r],[i,a],o=`bilinear`,s=!1){let c=a/r,l=i/n,u=new e.constructor(i*a*t),d=n*r,f=i*a;for(let o=0;o=0;--e)i[e]=a,r[e]=t[n[e]],a*=r[e];let a=n.map((e,t)=>i[n.indexOf(t)]),o=new e.constructor(e.length);for(let n=0;n=0;--e)r+=i%t[e]*a[e],i=Math.floor(i/t[e]);o[r]=e[n]}return[o,r]}function hC(e){let t=_C(e)[0],n=e.map(e=>Math.exp(e-t)),r=n.reduce((e,t)=>e+t,0);return n.map(e=>e/r)}function Wde(e){let t=_C(e)[0],n=0;for(let r=0;re-t-r)}function gC(e){if(e.length===0)throw Error(`Array must not be empty`);let t=e[0],n=0;for(let r=1;rt&&(t=e[r],n=r);return[t,n]}function vC(e){return e>0&&!(e&e-1)}var yC=class{constructor(e){if(this.size=e|0,this.size<=1||!vC(this.size))throw Error(`FFT size must be a power of two larger than 1`);this._csize=e<<1,this.table=new Float64Array(this.size*2);for(let e=0;ee;e<<=1)++t;this._width=t%2==0?t-1:t,this._bitrev=new Int32Array(1<>>t&3)<>>1);for(let t=0;t>>1]=e[t];return n}toComplexArray(e,t){let n=t||this.createComplexArray();for(let t=0;t>>1],n[t+1]=0;return n}transform(e,t){if(e===t)throw Error(`Input and output buffers must be different`);this._transform4(e,t,1)}realTransform(e,t){if(e===t)throw Error(`Input and output buffers must be different`);this._realTransform4(e,t,1)}inverseTransform(e,t){if(e===t)throw Error(`Input and output buffers must be different`);this._transform4(e,t,-1);for(let t=0;t>=2;i>=2;i>>=2){a=r/i<<1;let t=a>>>2;for(o=0;o>>1,i>>>1)}else for(o=0,s=0;o>>1,i>>>1,n)}let l=this.table;for(i>>=2;i>=2;i>>=2){a=r/i<<1;let t=a>>>1,s=t>>>1,c=s>>>1;for(o=0;o>>1;for(let t=2;t>1;++t){let n=(t+1-e)**2/2,r=Math.sqrt(s**2+c**2)**n,o=n*Math.atan2(c,s),l=2*t;i[l]=r*Math.cos(o),i[l+1]=r*Math.sin(o),a[l]=i[l],a[l+1]=-i[l+1]}this._slicedChirpBuffer=i.subarray(t,n),this._f=new yC(r>>1),this._f.transform(this._chirpBuffer,a)}_transform(e,t,n){let r=this._buffer1,i=this._buffer2,a=this._outBuffer1,o=this._outBuffer2,s=this._chirpBuffer,c=this._slicedChirpBuffer,l=this._a;if(n)for(let e=0;e>1];r[e]=i*c[e],r[n]=i*c[n]}else for(let e=0;e=e.length&&(i=2*(e.length-1)-i),r[a++]=e[i]}r.sort(),n[t]=r[i]}return n}function CC(e,t){let n=10**t;return Math.round(e*n)/n}function wC(e){let t=Math.round(e);return Math.abs(e)%1==.5?t%2==0?t:t-1:t}function TC(e){let t=e.length,n=e[0].length,r=[t+1,n+1],i=Array.from({length:r[0]},()=>Array(r[1]).fill(1/0));i[0][0]=0;let a=Array.from({length:r[0]},()=>Array(r[1]).fill(-1));for(let t=1;t0||s>0;)switch(c.push(o-1),l.push(s-1),a[o][s]){case 0:--o,--s;break;case 1:--o;break;case 2:--s;break;default:throw Error(`Internal error in dynamic time warping. Unexpected trace[${o}, ${s}]. Please file a bug report.`)}return c.reverse(),l.reverse(),[c,l]}var EC=(function(){let e=null;return function(t){if(!e){e=new Float32Array(65536);let t=new ArrayBuffer(4),n=new Uint32Array(t),r=new Float32Array(t);for(let t=0;t>10,s=t&1023;if(o===31)i=a|2139095040|s<<13;else if(o===0){if(s===0)i=a;else{let e=113;for(;!(s&1024);)s<<=1,--e;s&=-1025,i=a|e<<23|s<<13}}else i=a|o+112<<23|s<<13;n[0]=i,e[t]=r[0]}}let n=t.length,r=e,i=new Float32Array(n);for(let e=0;eOC});var OC={};async function kC(e){let t=e.split(`/`).pop(),n;try{if(n=await rC(),n){let t=await n.match(e);if(t)return t}}catch(e){Wb.warn(`Failed to load ${t} from cache:`,e)}let r=await jb.fetch(e);if(!r.ok)throw Error(`Failed to fetch ${t}: ${r.status} ${r.statusText}`);if(n)try{await n.put(e,r.clone())}catch(e){Wb.warn(`Failed to cache ${t}:`,e)}return r}async function AC(e){let t=await kC(e);if(!t||typeof t==`string`)return null;try{return await t.arrayBuffer()}catch(e){return Wb.warn(`Failed to read WASM binary:`,e),null}}async function jC(e){if(wb.IS_SERVICE_WORKER_ENV||wb.IS_CHROME_AVAILABLE)return e;let t=await kC(e);if(!t||typeof t==`string`)return null;try{let e=await t.text();e=e.replaceAll(`globalThis.process?.versions?.node`,`false`);let n=new Blob([e],{type:`text/javascript`});return URL.createObjectURL(n)}catch(e){return Wb.warn(`Failed to read WASM factory:`,e),null}}var MC=Object.freeze({auto:null,gpu:null,cpu:`cpu`,wasm:`wasm`,webgpu:`webgpu`,cuda:`cuda`,dml:`dml`,coreml:`coreml`,webnn:{name:`webnn`,deviceType:`cpu`},"webnn-npu":{name:`webnn`,deviceType:`npu`},"webnn-gpu":{name:`webnn`,deviceType:`gpu`},"webnn-cpu":{name:`webnn`,deviceType:`cpu`}});function NC(e){return e<=kb.DEBUG?0:e<=kb.INFO?2:e<=kb.WARNING||e<=kb.ERROR?3:4}var PC={0:`verbose`,1:`info`,2:`warning`,3:`error`,4:`fatal`},FC=[],IC,LC,RC=Symbol.for(`onnxruntime`);if(RC in globalThis)LC=globalThis[RC];else if(wb.IS_NODE_ENV){switch(LC=DC,process.platform){case`win32`:FC.push(`dml`);break;case`linux`:process.arch===`x64`&&FC.push(`cuda`);break;case`darwin`:FC.push(`coreml`)}FC.push(`webgpu`),FC.push(`cpu`),IC=[`cpu`]}else LC=Dle,wb.IS_WEBNN_AVAILABLE&&FC.push(`webnn-npu`,`webnn-gpu`,`webnn-cpu`,`webnn`),wb.IS_WEBGPU_AVAILABLE&&FC.push(`webgpu`),FC.push(`wasm`),IC=[`wasm`];var zC=LC.InferenceSession;function BC(e=null){if(!e)return IC;switch(e){case`auto`:return FC;case`gpu`:return FC.filter(e=>[`webgpu`,`cuda`,`dml`,`webnn-gpu`].includes(e))}if(FC.includes(e))return[MC[e]??e];throw Error(`Unsupported device: "${e}". Should be one of: ${FC.join(`, `)}.`)}var VC=Promise.resolve(),HC=null;async function UC(){if(HC)return HC;if(!(jb.useWasmCache&&typeof JC?.wasm?.wasmPaths==`object`&&JC?.wasm?.wasmPaths?.wasm&&JC?.wasm?.wasmPaths?.mjs)){if(wb.IS_DENO_WEB_RUNTIME)throw Error(`env.useWasmCache=false is not supported in Deno's web runtime. Remove the useWasmCache override.`);return HC=Promise.resolve(),HC}return HC=(async()=>{let e=JC.wasm.wasmPaths,t=!1;await Promise.all([e.wasm&&!QS(e.wasm)?(async()=>{try{let n=await AC($S(e.wasm));n&&(JC.wasm.wasmBinary=n,t=!0)}catch(e){Wb.warn(`Failed to pre-load WASM binary:`,e)}})():Promise.resolve(),e.mjs&&!QS(e.mjs)?(async()=>{try{let t=await jC($S(e.mjs));t&&(JC.wasm.wasmPaths.mjs=t)}catch(e){Wb.warn(`Failed to pre-load WASM factory:`,e)}})():Promise.resolve()]),t||(JC.wasm.wasmPaths.mjs=e.mjs)})(),HC}async function WC(e,t,n){await UC();let r=NC(jb.logLevel??kb.WARNING),i=()=>zC.create(e,{logSeverityLevel:r,...t}),a=await(wb.IS_WEB_ENV?VC=VC.then(i):i());return a.config=n,a}var GC=Promise.resolve();async function KC(e,t){let n=()=>e.run(t);return wb.IS_WEB_ENV?GC=GC.then(n):n()}function qC(e){return e instanceof LC.Tensor}var JC=LC?.env;function YC(){return JC?.wasm?.proxy}if(JC){let e=function(e){JC.logLevel=PC[NC(e)]};if(JC.wasm){if(!(typeof ServiceWorkerGlobalScope<`u`&&self instanceof ServiceWorkerGlobalScope)&&JC.versions?.web&&!JC.wasm.wasmPaths){let e=`https://cdn.jsdelivr.net/npm/onnxruntime-web@${JC.versions.web}/dist/`;JC.wasm.wasmPaths=wb.IS_SAFARI?{mjs:`${e}ort-wasm-simd-threaded.mjs`,wasm:`${e}ort-wasm-simd-threaded.wasm`}:{mjs:`${e}ort-wasm-simd-threaded.asyncify.mjs`,wasm:`${e}ort-wasm-simd-threaded.asyncify.wasm`}}JC.wasm.proxy=!1}JC.webgpu&&(JC.webgpu.powerPreference=`high-performance`),e(jb.logLevel??kb.WARNING),jb.backends.onnx={...JC,setLogLevel:e}}var XC=async(e,t,n)=>{let r=await WC(new Uint8Array(e),t);return(async e=>{let t=YC(),i=Object.fromEntries(Object.entries(e).map(([e,n])=>[e,(t?n.clone():n).ort_tensor])),a=await KC(r,i);return Array.isArray(n)?n.map(e=>new L(a[e])):new L(a[n])})},ZC=class{static session_options={};static get nearest_interpolate_4d(){return this._nearest_interpolate_4d||=XC([8,10,18,0,58,129,1,10,41,10,1,120,10,0,10,0,10,1,115,18,1,121,34,6,82,101,115,105,122,101,42,18,10,4,109,111,100,101,34,7,110,101,97,114,101,115,116,160,1,3,18,1,114,90,31,10,1,120,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,90,15,10,1,115,18,10,10,8,8,7,18,4,10,2,8,4,98,31,10,1,121,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,66,2,16,21],this.session_options,`y`),this._nearest_interpolate_4d}static get bilinear_interpolate_4d(){return this._bilinear_interpolate_4d||=XC([8,9,18,0,58,128,1,10,40,10,1,120,10,0,10,0,10,1,115,18,1,121,34,6,82,101,115,105,122,101,42,17,10,4,109,111,100,101,34,6,108,105,110,101,97,114,160,1,3,18,1,114,90,31,10,1,120,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,90,15,10,1,115,18,10,10,8,8,7,18,4,10,2,8,4,98,31,10,1,121,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,66,2,16,20],this.session_options,`y`),this._bilinear_interpolate_4d}static get bicubic_interpolate_4d(){return this._bicubic_interpolate_4d||=XC([8,9,18,0,58,127,10,39,10,1,120,10,0,10,0,10,1,115,18,1,121,34,6,82,101,115,105,122,101,42,16,10,4,109,111,100,101,34,5,99,117,98,105,99,160,1,3,18,1,114,90,31,10,1,120,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,90,15,10,1,115,18,10,10,8,8,7,18,4,10,2,8,4,98,31,10,1,121,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,66,2,16,20],this.session_options,`y`),this._bicubic_interpolate_4d}static get matmul(){return this._matmul||=XC([8,9,18,0,58,55,10,17,10,1,97,10,1,98,18,1,99,34,6,77,97,116,77,117,108,18,1,114,90,9,10,1,97,18,4,10,2,8,1,90,9,10,1,98,18,4,10,2,8,1,98,9,10,1,99,18,4,10,2,8,1,66,2,16,20],this.session_options,`c`),this._matmul}static get stft(){return this._stft||=XC([8,7,18,0,58,148,1,10,38,10,1,115,10,1,106,10,1,119,10,1,108,18,1,111,34,4,83,84,70,84,42,15,10,8,111,110,101,115,105,100,101,100,24,1,160,1,2,18,1,115,90,26,10,1,115,18,21,10,19,8,1,18,15,10,3,18,1,98,10,3,18,1,115,10,3,18,1,99,90,11,10,1,106,18,6,10,4,8,7,18,0,90,16,10,1,119,18,11,10,9,8,1,18,5,10,3,18,1,119,90,11,10,1,108,18,6,10,4,8,7,18,0,98,31,10,1,111,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,102,10,3,18,1,100,10,3,18,1,99,66,2,16,17],this.session_options,`o`),this._stft}static get rfft(){return this._rfft||=XC([8,9,18,0,58,97,10,33,10,1,120,10,0,10,1,97,18,1,121,34,3,68,70,84,42,15,10,8,111,110,101,115,105,100,101,100,24,1,160,1,2,18,1,100,90,21,10,1,120,18,16,10,14,8,1,18,10,10,3,18,1,115,10,3,18,1,99,90,11,10,1,97,18,6,10,4,8,7,18,0,98,21,10,1,121,18,16,10,14,8,1,18,10,10,3,18,1,115,10,3,18,1,99,66,2,16,20],this.session_options,`y`),this._rfft}static get top_k(){return this._top_k||=XC([8,10,18,0,58,73,10,18,10,1,120,10,1,107,18,1,118,18,1,105,34,4,84,111,112,75,18,1,116,90,9,10,1,120,18,4,10,2,8,1,90,15,10,1,107,18,10,10,8,8,7,18,4,10,2,8,1,98,9,10,1,118,18,4,10,2,8,1,98,9,10,1,105,18,4,10,2,8,7,66,2,16,21],this.session_options,[`v`,`i`]),this._top_k}static get slice(){return this._slice||=XC([8,7,18,0,58,96,10,25,10,1,120,10,1,115,10,1,101,10,1,97,10,1,116,18,1,121,34,5,83,108,105,99,101,18,1,114,90,9,10,1,120,18,4,10,2,8,1,90,9,10,1,115,18,4,10,2,8,7,90,9,10,1,101,18,4,10,2,8,7,90,9,10,1,97,18,4,10,2,8,7,90,9,10,1,116,18,4,10,2,8,7,98,9,10,1,121,18,4,10,2,8,1,66,2,16,13],this.session_options,`y`),this._slice}},QC=Object.freeze({auto:`auto`,gpu:`gpu`,cpu:`cpu`,wasm:`wasm`,webgpu:`webgpu`,cuda:`cuda`,dml:`dml`,coreml:`coreml`,webnn:`webnn`,"webnn-npu":`webnn-npu`,"webnn-gpu":`webnn-gpu`,"webnn-cpu":`webnn-cpu`}),$C=wb.IS_NODE_ENV?`cpu`:`wasm`;function ew(e,t,{warn:n}={}){return e?typeof e==`string`?e:e.hasOwnProperty(t)?e[t]:(n&&n(`device not specified for "${t}". Using the default device (${$C}).`),$C):$C}var tw=(function(){let e;return async function(){if(e===void 0){if(!wb.IS_WEBGPU_AVAILABLE)e=!1;else try{e=(await navigator.gpu.requestAdapter()).features.has(`shader-f16`)}catch{e=!1}}return e}})(),nw=Object.freeze({auto:`auto`,fp32:`fp32`,fp16:`fp16`,q8:`q8`,int8:`int8`,uint8:`uint8`,q4:`q4`,bnb4:`bnb4`,q4f16:`q4f16`,q2:`q2`,q2f16:`q2f16`,q1:`q1`,q1f16:`q1f16`}),rw=nw.fp32,iw=Object.freeze({[QC.wasm]:nw.q8}),aw=Object.freeze({[nw.fp32]:``,[nw.fp16]:`_fp16`,[nw.int8]:`_int8`,[nw.uint8]:`_uint8`,[nw.q8]:`_quantized`,[nw.q4]:`_q4`,[nw.q2]:`_q2`,[nw.q1]:`_q1`,[nw.q4f16]:`_q4f16`,[nw.q2f16]:`_q2f16`,[nw.q1f16]:`_q1f16`,[nw.bnb4]:`_bnb4`});function ow(e,t,n,{configDtype:r=null,warn:i}={}){let a,o=!1;e&&typeof e!=`string`?e.hasOwnProperty(t)?a=e[t]:(a=null,o=!0):a=e;let s;if(a===nw.auto){if(r){let e=typeof r==`string`?r:r?.[t];if(e&&e!==nw.auto&&nw.hasOwnProperty(e))return e}s=iw[n]??rw}else s=a&&nw.hasOwnProperty(a)?a:iw[n]??rw;return o&&i&&i(`dtype not specified for "${t}". Using the default dtype (${s}) for this device (${n}).`),s}var sw=Object.freeze({float32:Float32Array,float16:typeof Float16Array<`u`?Float16Array:Uint16Array,float64:Float64Array,string:Array,int8:Int8Array,uint8:Uint8Array,int16:Int16Array,uint16:Uint16Array,int32:Int32Array,uint32:Uint32Array,int64:BigInt64Array,uint64:BigUint64Array,bool:Uint8Array,uint4:Uint8Array,int4:Int8Array}),L=class e{get dims(){return this.ort_tensor.dims}set dims(e){this.ort_tensor.dims=e}get type(){return this.ort_tensor.type}get data(){return this.ort_tensor.data}get size(){return this.ort_tensor.size}get location(){return this.ort_tensor.location}ort_tensor;constructor(...e){return this.ort_tensor=qC(e[0])?e[0]:new eue(e[0],e[1],e[2]),new Proxy(this,{get:(e,t)=>{if(typeof t==`string`){let n=Number(t);if(Number.isInteger(n))return e._getitem(n)}return e[t]},set:(e,t,n)=>e[t]=n})}dispose(){this.ort_tensor.dispose()}*[Symbol.iterator](){let[e,...t]=this.dims;if(t.length>0){let n=t.reduce((e,t)=>e*t);for(let r=0;r0){let e=r.reduce((e,t)=>e*t);return this._subarray(t,e,r)}return new e(this.type,[this.data[t]],r)}indexOf(e){let t=this.data;for(let n=0;na)throw Error(`Invalid slice: ${i}`);let o=[Math.max(t,0),Math.min(a,this.dims[e])];r.push(o),n.push(o[1]-o[0])}else throw Error(`Invalid slice: ${i}`)}let i=r.map(([e,t])=>t-e),a=i.reduce((e,t)=>e*t),o=this.data,s=new o.constructor(a),c=this.stride(),l=!0;for(let e=1;e=0;--n){let e=i[n];t+=(a%e+r[n][0])*c[n],a=Math.floor(a/e)}s[e]=o[t]}return new e(this.type,s,n)}permute(...e){return lw(this,e)}transpose(...e){return this.permute(...e)}sum(e=null,t=!1){return this.norm(1,e,t)}norm(t=`fro`,n=null,r=!1){if(t===`fro`)t=2;else if(typeof t==`string`)throw Error(`Unsupported norm: ${t}`);let i=this.data,a=i instanceof BigInt64Array||i instanceof BigUint64Array;if(a&&t!==1)throw Error(`Expected a floating point tensor as input. Got ${this.type}`);let o,s;if(a?(o=(e,t)=>e+t,s=0n):(o=(e,n)=>e+n**t,s=0),n===null){let n=i.reduce(o,s);return t!==1&&(n**=1/t),new e(this.type,[n],[])}let[c,l,u]=Sw(o,this,n,r);if(t!==1)for(let e=0;e=0;--r){let e=this.dims[r];if(r!==t){let t=i%e;n+=t*a,a*=this.dims[r]}i=Math.floor(i/e)}r[e]/=i[n]}return this}normalize(e=2,t=1){return this.clone().normalize_(e,t)}stride(){return Tw(this.dims)}squeeze(t=null){return new e(this.type,this.data,_w(this.dims,t))}squeeze_(e=null){return this.dims=_w(this.dims,e),this}unsqueeze(t){return new e(this.type,this.data,vw(this.dims,t))}unsqueeze_(e){return this.dims=vw(this.dims,e),this}flatten_(e=0,t=-1){t=(t+this.dims.length)%this.dims.length;let n=this.dims.slice(0,e),r=this.dims.slice(e,t+1),i=this.dims.slice(t+1);return this.dims=[...n,r.reduce((e,t)=>e*t,1),...i],this}flatten(e=0,t=-1){return this.clone().flatten_(e,t)}view(...t){let n=-1;for(let e=0;er===n?e:e*t,1);t[n]=r.length/e}return new e(this.type,r,t)}neg_(){let e=this.data;for(let t=0;tt);return new e(`bool`,n,this.dims)}lt(t){let n=new Uint8Array(this.data.length),r=this.data;for(let e=0;eMath.min(e,t),this,t,n,1/0);return new e(r,i,a)}max(t=null,n=!1){if(t===null){let t=_C(this.data)[0];return new e(this.type,[t],[])}let[r,i,a]=Sw((e,t)=>Math.max(e,t),this,t,n,-1/0);return new e(r,i,a)}argmin(t=null,n=!1){if(t!==null)throw Error("`dim !== null` not yet implemented.");let r=gC(this.data)[1];return new e(`int64`,[BigInt(r)],[])}argmax(t=null,n=!1){if(t!==null)throw Error("`dim !== null` not yet implemented.");let r=_C(this.data)[1];return new e(`int64`,[BigInt(r)],[])}repeat(...t){if(t.lengthe===1)){if(t.length===this.dims.length)return this.clone();let n=t.length-this.dims.length,r=Array(n).fill(1).concat(this.dims);return new e(this.type,this.data.slice(),r)}let n=t.length-this.dims.length,r=Array(n).fill(1).concat(this.dims),i=r.map((e,n)=>e*t[n]),a=i.reduce((e,t)=>e*t,1),o=this.data,s=new o.constructor(a),c=Tw(r),l=Tw(i);for(let e=0;eBigInt(Math.floor(e)):BigInt;else if(this.type===`float16`&&t==`float32`&&this.data instanceof Uint16Array)return new e(t,EC(this.data),this.dims);return new e(t,sw[t].from(this.data,n),this.dims)}};function cw(e,t){let n=e.length;if(n!==t.reduce((e,t)=>e*t))throw Error(`cannot reshape array of size ${n} into shape (${t})`);let r=e;for(let e=t.length-1;e>=0;e--)r=r.reduce((n,r)=>{let i=n[n.length-1];return i.lengthnew L(`int64`,e,[e.length]);async function hw(e,t,n,r,i){return await(await ZC.slice)({x:e,s:mw(t),e:mw(n),a:mw(r),t:mw(i??Array(r.length).fill(1))})}function gw(e,t){let n=e.data,r=t.data,i=[e.dims[0],e.dims[2]],a=new n.constructor(i[0]*i[1]),[o,s,c]=e.dims,l=0;for(let e=0;ee!==1):typeof t==`number`?e[t]===1&&e.splice(t,1):Array.isArray(t)&&(e=e.filter((e,n)=>e!==1||!t.includes(n))),e}function vw(e,t){return t=yw(t,e.length+1),e=e.slice(),e.splice(t,0,1),e}function yw(e,t,n=null,r=!0){if(e<-t||e>=t){if(r)throw Error(`IndexError: index ${e} is out of bounds for dimension${n===null?``:` `+n} with size ${t}`);return e<-t?0:t}return e<0&&(e=(e%t+t)%t),e}function bw(e,t=0){t=yw(t,e[0].dims.length);let n=e[0].dims.slice();n[t]=e.reduce((e,n)=>e+n.dims[t],0);let r=n.reduce((e,t)=>e*t,1),i=new e[0].data.constructor(r),a=e[0].type;if(t===0){let t=0;for(let n of e){let e=n.data;i.set(e,t),t+=e.length}}else{let r=0;for(let a=0;a=0;--i){let e=s[i],l=o%e;i===t&&(l+=r),a+=l*c,c*=n[i],o=Math.floor(o/e)}i[a]=o[e]}r+=s[t]}}return new L(a,i,n)}function xw(e,t=0){return bw(e.map(e=>e.unsqueeze(t)),t)}function Sw(e,t,n,r=!1,i=null){let a=t.data,o=t.dims;n=yw(n,o.length);let s=o.slice();s[n]=1;let c=new a.constructor(a.length/o[n]);i!==null&&c.fill(i);for(let t=0;t=0;--e){let t=o[e];if(e!==n){let n=i%t;r+=n*a,a*=s[e]}i=Math.floor(i/t)}c[r]=e(c[r],a[t],t,r)}return r||s.splice(n,1),[t.type,c,s]}function Cw(e,t=null,n=1,r=!1){let i=e.data,a=e.dims;if(t===null){let t=i.reduce((e,t)=>e+t,0)/i.length,r=Math.sqrt(i.reduce((e,n)=>e+(n-t)**2,0)/(i.length-n)),a=new L(e.type,[t],[]);return[new L(e.type,[r],[]),a]}t=yw(t,a.length);let o=ww(e,t,r),s=o.data,[c,l,u]=Sw((e,t,n,r)=>e+(t-s[r])**2,e,t,r);for(let e=0;ee+t,0);return new L(e.type,[t/i.length],[])}t=yw(t,r.length);let[a,o,s]=Sw((e,t)=>e+t,e,t,n);if(r[t]!==1)for(let e=0;e=0;--n)t[n]=r,r*=e[n];return t}function Ew(e,t,n,r){return new L(n,new r(e.reduce((e,t)=>e*t,1)).fill(t),e)}function Dw(e,t){let n,r;if(typeof t==`number`)n=`float32`,r=Float32Array;else if(typeof t==`bigint`)n=`int64`,r=BigInt64Array;else if(typeof t==`boolean`)n=`bool`,r=Uint8Array;else throw Error(`Unsupported data type: ${typeof t}`);return Ew(e,t,n,r)}function Ow(e,t){return Dw(e.dims,t)}function kw(e){return Ew(e,1n,`int64`,BigInt64Array)}function Aw(e){return kw(e.dims)}function jw(e){return Ew(e,0n,`int64`,BigInt64Array)}function Mw(e){return jw(e.dims)}function Nw(e){let t=e.reduce((e,t)=>e*t,1);return new L(`float32`,Float32Array.from({length:t},()=>qS.gauss()),e)}function Pw(e,t){if(e.dims.length!==2)throw Error(`The tensor must have 2 dimensions`);if(e.dims.at(-1)%8!=0)throw Error(`The last dimension of the tensor must be a multiple of 8`);if(![`binary`,`ubinary`].includes(t))throw Error(`The precision must be either 'binary' or 'ubinary'`);let n=t===`binary`,r=n?`int8`:`uint8`,i=n?Int8Array:Uint8Array,a=e.data,o=new i(a.length/8);for(let e=0;e0),r=Math.floor(e/8),i=e%8;o[r]|=t<<7-i,n&&i===0&&(o[r]-=128)}return new L(r,o,[e.dims[0],e.dims[1]/8])}async function Fw(e){if(!e)throw Error(`modelId is required for get_tokenizer_files`);return(await oC(e,`tokenizer_config.json`,{})).exists?[`tokenizer.json`,`tokenizer_config.json`]:[]}async function Iw(e,t){let n=await Fw(e);return await Promise.all(n.map(n=>mC(e,n,!0,t)))}function Lw(e){let t=e.dims;switch(t.length){case 1:return e.tolist();case 2:if(t[0]!==1)throw Error("Unable to decode tensor with `batch size !== 1`. Use `tokenizer.batch_decode(...)` for batched inputs.");return e.tolist()[0];default:throw Error(`Expected tensor to have 1-2 dimensions, got ${t.length}.`)}}var Rw=[`bos_token`,`eos_token`,`unk_token`,`sep_token`,`pad_token`,`cls_token`,`mask_token`];function zw(e,t,n,r){for(let i of Object.keys(e)){let a=t-e[i].length,o=n(i),s=Array(a).fill(o);e[i]=r===`right`?zb(e[i],s):zb(s,e[i])}}function Bw(e,t){for(let n of Object.keys(e))e[n].length=t}function Vw(e,...t){for(let n of t){if(!Object.hasOwn(e,n))continue;let t=e[n];if(t){if(typeof t==`object`){if(t.__type===`AddedToken`)return t.content;throw Error(`Unknown token: ${t}`)}return t}}return null}function Hw(e){let t=[];for(let n of e.get_added_tokens_decoder().values())n.special&&t.push(n);return t}var Uw=class extends Nb{return_token_type_ids=!1;padding_side=`right`;constructor(e,t){if(super(),this._tokenizerJSON=e,this._tokenizerConfig=t,this._tokenizer=new Mue(e,t),this.config=t,this.padding_side=t.padding_side??this.padding_side,this.mask_token=Vw(t,`mask_token`),this.mask_token_id=this._tokenizer.token_to_id(this.mask_token),this.pad_token=Vw(t,`pad_token`,`eos_token`),this.pad_token_id=this._tokenizer.token_to_id(this.pad_token),this.sep_token=Vw(t,`sep_token`),this.sep_token_id=this._tokenizer.token_to_id(this.sep_token),this.unk_token=Vw(t,`unk_token`),this.unk_token_id=this._tokenizer.token_to_id(this.unk_token),this.bos_token=Vw(t,`bos_token`),this.bos_token_id=this._tokenizer.token_to_id(this.bos_token),this.eos_token=Vw(t,`eos_token`),this.eos_token_id=this._tokenizer.token_to_id(this.eos_token),this.chat_template=t.chat_template??null,Array.isArray(this.chat_template)){let e=Object.create(null);for(let{name:t,template:n}of this.chat_template){if(typeof t!=`string`||typeof n!=`string`)throw Error(`Chat template must be a list of objects with "name" and "template" properties`);e[t]=n}this.chat_template=e}this._compiled_template_cache=new Map;let n=Hw(this._tokenizer);this.all_special_ids=n.map(e=>e.id),this.all_special_tokens=n.map(e=>e.content)}static async from_pretrained(e,{progress_callback:t=null,config:n=null,cache_dir:r=null,local_files_only:i=!1,revision:a=`main`}={}){let o=await Iw(e,{progress_callback:t,config:n,cache_dir:r,local_files_only:i,revision:a});return new this(...o)}get_vocab(){return this._tokenizer.get_vocab()}get model_max_length(){return this._tokenizerConfig.model_max_length??1/0}get add_eos_token(){return this._tokenizerConfig.add_eos_token}get add_bos_token(){return this._tokenizerConfig.add_bos_token}convert_tokens_to_ids(e){return typeof e==`string`?this._tokenizer.token_to_id(e):e.map(e=>this._tokenizer.token_to_id(e))}_call(e,t={}){let{text_pair:n=null,add_special_tokens:r=!0,padding:i=!1,return_token_type_ids:a=null}=t,{truncation:o=null,max_length:s=null}=t,c=t.return_tensor??!0,l=Array.isArray(e),u;if(l){if(e.length===0)throw Error(`text array must be non-empty`);if(n!==null){if(!Array.isArray(n))throw Error(`text_pair must also be an array`);if(e.length!==n.length)throw Error(`text and text_pair must have the same length`);u=e.map((e,t)=>this._encode_plus(e,{text_pair:n[t],add_special_tokens:r,return_token_type_ids:a}))}else u=e.map(e=>this._encode_plus(e,{add_special_tokens:r,return_token_type_ids:a}))}else{if(e==null)throw Error(`text may not be null or undefined`);if(Array.isArray(n))throw Error("When specifying `text_pair`, since `text` is a string, `text_pair` must also be a string (i.e., not an array).");u=[this._encode_plus(e,{text_pair:n,add_special_tokens:r,return_token_type_ids:a})]}if(s===null?s=this.model_max_length:o===null&&(i===!0?(Wb.warn("`max_length` is ignored when `padding: true` and there is no truncation strategy. To pad to max length, use `padding: 'max_length'`."),s=this.model_max_length):i===!1&&(Wb.warn("Truncation was not explicitly activated but `max_length` is provided a specific value, please use `truncation: true` to explicitly truncate examples to max length."),o=!0)),i===!0&&(s=Math.min(_C(u.map(e=>e.input_ids.length))[0],s??1/0)),s=Math.min(s,this.model_max_length??1/0),i||o)for(let e=0;es?o&&Bw(u[e],s):i&&zw(u[e],s,e=>e===`input_ids`?this.pad_token_id:0,this.padding_side);let d={};if(c){if(!(i&&o)&&u.some(e=>{for(let t of Object.keys(e))if(e[t].length!==u[0][t]?.length)return!0;return!1}))throw Error(`Unable to create tensor, you should probably activate truncation and/or padding with 'padding=true' and 'truncation=true' to have batched tensors with the same length.`);let e=[u.length,u[0].input_ids.length];for(let t of Object.keys(u[0]))d[t]=new L(`int64`,BigInt64Array.from(u.flatMap(e=>e[t]).map(BigInt)),e)}else{for(let e of Object.keys(u[0]))d[e]=u.map(t=>t[e]);if(!l)for(let e of Object.keys(d))d[e]=d[e][0]}return d}_encode_text(e){return e===null?null:this._tokenizer.encode(e).tokens}_encode_plus(e,{text_pair:t=null,add_special_tokens:n=!0,return_token_type_ids:r=null}={}){let{ids:i,attention_mask:a,token_type_ids:o}=this._tokenizer.encode(e,{text_pair:t,add_special_tokens:n,return_token_type_ids:r??this.return_token_type_ids});return{input_ids:i,attention_mask:a,...o?{token_type_ids:o}:{}}}tokenize(e,{pair:t=null,add_special_tokens:n=!1}={}){return this._tokenizer.tokenize(e,{text_pair:t,add_special_tokens:n})}encode(e,{text_pair:t=null,add_special_tokens:n=!0,return_token_type_ids:r=null}={}){return this._tokenizer.encode(e,{text_pair:t,add_special_tokens:n,return_token_type_ids:r}).ids}batch_decode(e,t={}){return e instanceof L&&(e=e.tolist()),e.map(e=>this.decode(e,t))}decode(e,t={}){if(e instanceof L&&(e=Lw(e)),!Array.isArray(e)||e.length===0||!Ib(e[0]))throw Error(`token_ids must be a non-empty array of integers.`);return this.decode_single(e,t)}decode_single(e,{skip_special_tokens:t=!1,clean_up_tokenization_spaces:n=null}){return this._tokenizer.decode(e,{skip_special_tokens:t,clean_up_tokenization_spaces:n})}get_chat_template({chat_template:e=null,tools:t=null}={}){if(this.chat_template&&typeof this.chat_template==`object`){let n=this.chat_template;if(e!==null&&Object.hasOwn(n,e))e=n[e];else if(e===null){if(t!==null&&`tool_use`in n)e=n.tool_use;else if(`default`in n)e=n.default;else throw Error(`This model has multiple chat templates with no default specified! Please either pass a chat template or the name of the template you wish to use to the 'chat_template' argument. Available template names are ${Object.keys(n).sort()}.`)}}else if(e===null){if(this.chat_template)e=this.chat_template;else throw Error(`Cannot use apply_chat_template() because tokenizer.chat_template is not set and no template argument was passed! For information about writing templates and setting the tokenizer.chat_template attribute, please see the documentation at https://huggingface.co/docs/transformers/main/en/chat_templating`)}return e}apply_chat_template(e,t={}){let{tools:n=null,documents:r=null,chat_template:i=null,add_generation_prompt:a=!1,tokenize:o=!0,padding:s=!1,truncation:c=!1,max_length:l=null,return_tensor:u=!0,return_dict:d=!0,tokenizer_kwargs:f={},...p}=t;if(i=this.get_chat_template({chat_template:i,tools:n}),typeof i!=`string`)throw Error(`chat_template must be a string, but got ${typeof i}`);let m=this._compiled_template_cache.get(i);m===void 0&&(m=new Dde(i),this._compiled_template_cache.set(i,m));let h=Object.create(null);for(let e of Rw){let t=Vw(this.config,e);t&&(h[e]=t)}let g=m.render({messages:e,add_generation_prompt:a,tools:n,documents:r,...h,...p});if(o){let e=this._call(g,{add_special_tokens:!1,padding:s,truncation:c,max_length:l,return_tensor:u,...f});return d?e:e.input_ids}return g}};function Ww(e,t,n,r){if(!(`language_codes`in e)||!Array.isArray(e.language_codes))throw Error("Tokenizer must have `language_codes` attribute set and it should be an array of language ids.");if(!(`languageRegex`in e)||!(e.languageRegex instanceof RegExp))throw Error("Tokenizer must have `languageRegex` attribute set and it should be a regular expression.");if(!(`lang_to_token`in e)||typeof e.lang_to_token!=`function`)throw Error("Tokenizer must have `lang_to_token` attribute set and it should be a function.");let i=r.src_lang,a=r.tgt_lang;if(!e.language_codes.includes(a))throw Error(`Target language code "${a}" is not valid. Must be one of: {${e.language_codes.join(`, `)}}`);if(i!==void 0){if(!e.language_codes.includes(i))throw Error(`Source language code "${i}" is not valid. Must be one of: {${e.language_codes.join(`, `)}}`);for(let t of e._tokenizer.post_processor.config.single)if(`SpecialToken`in t&&e.languageRegex.test(t.SpecialToken.id)){t.SpecialToken.id=e.lang_to_token(i);break}}return r.forced_bos_token_id=e._tokenizer.token_to_id(e.lang_to_token(a)),e._call(t,n)}var Gw={};fb(Gw,{AlbertTokenizer:()=>Kw,AutoTokenizer:()=>WT,BartTokenizer:()=>qw,BertTokenizer:()=>Jw,BlenderbotSmallTokenizer:()=>Yw,BlenderbotTokenizer:()=>Xw,BloomTokenizer:()=>Zw,CLIPTokenizer:()=>$w,CamembertTokenizer:()=>Qw,CodeGenTokenizer:()=>tT,CodeLlamaTokenizer:()=>eT,CohereAsrTokenizer:()=>rT,CohereTokenizer:()=>nT,ConvBertTokenizer:()=>iT,DebertaTokenizer:()=>oT,DebertaV2Tokenizer:()=>aT,DistilBertTokenizer:()=>sT,ElectraTokenizer:()=>cT,EsmTokenizer:()=>lT,FalconTokenizer:()=>uT,GPT2Tokenizer:()=>pT,GPTNeoXTokenizer:()=>fT,GemmaTokenizer:()=>dT,HerbertTokenizer:()=>mT,LlamaTokenizer:()=>hT,M2M100Tokenizer:()=>gT,MBart50Tokenizer:()=>yT,MBartTokenizer:()=>vT,MPNetTokenizer:()=>ST,MarianTokenizer:()=>_T,MgpstrTokenizer:()=>bT,MobileBertTokenizer:()=>xT,NllbTokenizer:()=>CT,NougatTokenizer:()=>wT,PreTrainedTokenizer:()=>Uw,Qwen2Tokenizer:()=>TT,RoFormerTokenizer:()=>DT,RobertaTokenizer:()=>ET,SiglipTokenizer:()=>OT,SpeechT5Tokenizer:()=>kT,SqueezeBertTokenizer:()=>AT,T5Tokenizer:()=>jT,TokenizersBackend:()=>Uw,VitsTokenizer:()=>NT,Wav2Vec2CTCTokenizer:()=>PT,WhisperTokenizer:()=>VT,XLMRobertaTokenizer:()=>HT,XLMTokenizer:()=>UT});var Kw=class extends Uw{return_token_type_ids=!0},qw=class extends Uw{},Jw=class extends Uw{return_token_type_ids=!0},Yw=class extends Uw{},Xw=class extends Uw{},Zw=class extends Uw{},Qw=class extends Uw{},$w=class extends Uw{},eT=class extends Uw{},tT=class extends Uw{},nT=class extends Uw{},rT=class extends Uw{},iT=class extends Uw{return_token_type_ids=!0},aT=class extends Uw{return_token_type_ids=!0},oT=class extends Uw{return_token_type_ids=!0},sT=class extends Uw{},cT=class extends Uw{return_token_type_ids=!0},lT=class extends Uw{},uT=class extends Uw{},dT=class extends Uw{},fT=class extends Uw{},pT=class extends Uw{},mT=class extends Uw{return_token_type_ids=!0},hT=class extends Uw{padding_side=`left`},gT=class extends Uw{constructor(e,t){super(e,t),this.languageRegex=/^__[a-z]{2,3}__$/,this.language_codes=this.all_special_tokens.filter(e=>this.languageRegex.test(e)).map(e=>e.slice(2,-2)),this.lang_to_token=e=>`__${e}__`}_build_translation_inputs(e,t,n){return Ww(this,e,t,n)}},_T=class extends Uw{constructor(e,t){super(e,t),this.languageRegex=/^(>>\w+<<)\s*/g,this.supported_language_codes=Array.from(this.get_vocab().keys()).filter(e=>this.languageRegex.test(e)),Wb.warn('WARNING: `MarianTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}_encode_text(e){if(e===null)return null;let[t,...n]=e.trim().split(this.languageRegex);if(n.length===0)return super._encode_text(t);if(n.length===2){let[e,t]=n;return this.supported_language_codes.includes(e)||Wb.warn(`Unsupported language code "${e}" detected, which may lead to unexpected behavior. Should be one of: ${JSON.stringify(this.supported_language_codes)}`),zb([e],super._encode_text(t))}}},vT=class extends Uw{constructor(e,t){super(e,t),this.languageRegex=/^[a-z]{2}_[A-Z]{2}$/,this.language_codes=this.all_special_tokens.filter(e=>this.languageRegex.test(e)).map(e=>e),this.lang_to_token=e=>e}_build_translation_inputs(e,t,n){return Ww(this,e,t,n)}},yT=class extends vT{},bT=class extends Uw{},xT=class extends Uw{return_token_type_ids=!0},ST=class extends Uw{},CT=class extends Uw{constructor(e,t){super(e,t),this.languageRegex=/^[a-z]{3}_[A-Z][a-z]{3}$/,this.language_codes=this.all_special_tokens.filter(e=>this.languageRegex.test(e)),this.lang_to_token=e=>e}_build_translation_inputs(e,t,n){return Ww(this,e,t,n)}},wT=class extends Uw{},TT=class extends Uw{},ET=class extends Uw{},DT=class extends Uw{return_token_type_ids=!0},OT=class extends Uw{},kT=class extends Uw{},AT=class extends Uw{return_token_type_ids=!0},jT=class extends Uw{},MT=class extends iS{decode_chain(e){let t=``;for(let n=1;n[t,e]),[`burmese`,`my`],[`valencian`,`ca`],[`flemish`,`nl`],[`haitian`,`ht`],[`letzeburgesch`,`lb`],[`pushto`,`ps`],[`panjabi`,`pa`],[`moldavian`,`ro`],[`moldovan`,`ro`],[`sinhalese`,`si`],[`castilian`,`es`]]);function RT(e){e=e.toLowerCase();let t=LT.get(e);if(t===void 0){let n=e.match(/^<\|([a-z]{2})\|>$/);if(n&&(e=n[1]),IT.has(e))t=e;else{let t=e.length===2?IT.keys():IT.values();throw Error(`Language "${e}" is not supported. Must be one of: ${JSON.stringify(Array.from(t))}`)}}return t}var zT=RegExp(`^[\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E]+$`,`gu`),BT=.1,VT=class extends Uw{get timestamp_begin(){return this._tokenizer.token_to_id(`<|notimestamps|>`)+1}_decode_asr(e,{return_timestamps:t=!1,return_language:n=!1,time_precision:r=null,force_full_sequences:i=!0}={}){if(r===null)throw Error(`Must specify time_precision`);let a=null,o=t===`word`;function s(){return{language:a,timestamp:[null,null],text:``}}let c=[],l=s(),u=0,d=this.timestamp_begin,f=d+1500,p=[],m=[],h=!1,g=null,_=new Set(this.all_special_ids);for(let n of e){let e=n.tokens,i=o?n.token_timestamps:null,v=null,y=d;if(`stride`in n){let[t,i,a]=n.stride;if(u-=i,g=t-a,i&&(y=i/r+d),a)for(let t=e.length-1;t>=0;--t){let n=Number(e[t]);if(n>=d){if(v!==null&&(n-d)*r=d&&g<=f){let e=CC((g-d)*r+u,2);if(v!==null&&g>=v)h=!0;else if(h||p.length>0&&g0&&l.timestamp[1]!==null))for(let e of l.words)e.timestamp[1]>l.timestamp[1]&&l.timestamp[1]>=e.timestamp[0]&&(e.timestamp[1]=l.timestamp[1]);c.push(l),p=[],b=[],m=[],x=[],l=s()}}else if(b.push(g),o){let e=CC(i[n]+u,2),t;if(n+10?(p.push(b),o&&m.push(x)):p.every(e=>e.length===0)&&(l=s(),p=[],b=[],m=[],x=[])}if(p.length>0){if(i&&t)throw Error(`Whisper did not predict an ending timestamp, which can happen if audio is cut off in the middle of a word. Also make sure WhisperTimeStampLogitsProcessor was used during generation.`);let[e,n]=this.findLongestCommonSequence(p,m),r=this.decode(e);l.text=r,o&&(l.words=this.collateWordTimestamps(e,n,a)),c.push(l)}let v=Object.create(null),y=c.map(e=>e.text).join(``);if(t||n){for(let e=0;e0,o=a?[]:null,s=a?t[0]:null;for(let c=1;ce===g[n]&&s[i+n][0]-BT<=t[c][m+n][0]).length:p.filter((e,t)=>e===g[t]).length;let v=e/1e4,y=_/e+v;_>1&&y>u&&(u=y,d=[i,o,m,h])}let[p,m,h,g]=d,_=Math.floor((m+p)/2),v=Math.floor((g+h)/2);if(a&&u===0&&r>0){let e=s[r-1][0],n=t[c].findIndex(t=>t[0]>=e);v=n===-1?l.length:n}i.push(...n.slice(0,_)),n=l.slice(v),r=n.length,a&&(o.push(...s.slice(0,_)),s=t[c].slice(v))}return i.push(...n),a?(o.push(...s),[i,o]):[i,[]]}collateWordTimestamps(e,t,n){let[r,i,a]=this.combineTokensIntoWords(e,n),o=[];for(let e=0;e=r){let e=((t-r)*n).toFixed(2);i.push(`<|${e}|>`),i.push([])}else i[i.length-1].push(t);return i=i.map(e=>typeof e==`string`?e:super.decode(e,t)),i.join(``)}splitTokensOnUnicode(e){let t=this.decode(e,{decode_with_timestamps:!0}),n=[],r=[],i=[],a=[],o=[],s=0;for(let c=0;c=this._tokenizer.token_to_id(`<|endoftext|>`),d=s.startsWith(` `),f=s.trim(),p=zT.test(f);if(u||d||p||i.length===0)i.push(s),a.push(c),o.push(l);else{let e=i.length-1;i[e]+=s,a[e].push(...c),o[e].push(...l)}}return[i,a,o]}mergePunctuations(e,t,n,r,i){let a=structuredClone(e),o=structuredClone(t),s=structuredClone(n),c=a.length-2,l=a.length-1;for(;c>=0;)a[c].startsWith(` `)&&r.includes(a[c].trim())?(a[l]=a[c]+a[l],o[l]=zb(o[c],o[l]),s[l]=zb(s[c],s[l]),a[c]=``,o[c]=[],s[c]=[]):l=c,--c;for(c=0,l=1;le),o.filter(e=>e.length>0),s.filter(e=>e.length>0)]}},HT=class extends Uw{},UT=class extends Uw{return_token_type_ids=!0;constructor(e,t){super(e,t),Wb.warn('WARNING: `XLMTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}},WT=class{static async from_pretrained(e,{progress_callback:t=null,config:n=null,cache_dir:r=null,local_files_only:i=!1,revision:a=`main`}={}){let[o,s]=await Iw(e,{progress_callback:t,config:n,cache_dir:r,local_files_only:i,revision:a}),c=s.tokenizer_class?.replace(/Fast$/,``)??`PreTrainedTokenizer`,l=Gw[c];return l||=(Wb.warn(`Unknown tokenizer class "${c}", attempting to construct from base class.`),Uw),new l(o,s)}},GT=`https://github.com/huggingface/transformers.js/issues/new/choose`,KT=`preprocessor_config.json`,qT=KT,JT=`processor_config.json`,YT=`chat_template.jinja`,XT=class extends Nb{static classes=[`image_processor_class`,`tokenizer_class`,`feature_extractor_class`];static uses_processor_config=!1;static uses_chat_template_file=!1;constructor(e,t,n){super(),this.config=e,this.components=t,this.chat_template=n}get image_processor(){return this.components.image_processor}get tokenizer(){return this.components.tokenizer}get feature_extractor(){return this.components.feature_extractor}apply_chat_template(e,t={}){if(!this.tokenizer)throw Error(`Unable to apply chat template without a tokenizer.`);return this.tokenizer.apply_chat_template(e,{tokenize:!1,chat_template:this.chat_template??void 0,...t})}batch_decode(...e){if(!this.tokenizer)throw Error(`Unable to decode without a tokenizer.`);return this.tokenizer.batch_decode(...e)}decode(...e){if(!this.tokenizer)throw Error(`Unable to decode without a tokenizer.`);return this.tokenizer.decode(...e)}async _call(e,...t){for(let n of[this.image_processor,this.feature_extractor,this.tokenizer])if(n)return n(e,...t);throw Error(`No image processor, feature extractor, or tokenizer found.`)}static async from_pretrained(e,t={}){let[n,r,i]=await Promise.all([this.uses_processor_config?mC(e,JT,!0,t):{},Promise.all(this.classes.filter(e=>e in this).map(async n=>{let r=await this[n].from_pretrained(e,t);return[n.replace(/_class$/,``),r]})).then(Object.fromEntries),this.uses_chat_template_file?pC(e,YT,!0,t):null]);return new this(n,r,i)}};fb({},{ChatterboxProcessor:()=>WE,CohereAsrProcessor:()=>KE,Florence2Processor:()=>Bfe,Gemma3Processor:()=>Vfe,Gemma3nProcessor:()=>Hfe,Gemma4Processor:()=>Ufe,Glm46VProcessor:()=>Wfe,GraniteSpeechProcessor:()=>Gfe,GroundingDinoProcessor:()=>qfe,Idefics3Processor:()=>VD,JinaCLIPProcessor:()=>Qfe,Lfm2VlProcessor:()=>$fe,LlavaProcessor:()=>epe,MgpstrProcessor:()=>tpe,MoonshineProcessor:()=>npe,OwlViTProcessor:()=>rpe,PaliGemmaProcessor:()=>ape,Phi3VProcessor:()=>spe,PixtralProcessor:()=>cpe,Processor:()=>XT,PyAnnoteProcessor:()=>lpe,Qwen2VLProcessor:()=>BD,Qwen2_5_VLProcessor:()=>GD,Qwen3VLProcessor:()=>upe,Sam2Processor:()=>qD,Sam2VideoProcessor:()=>dpe,SamProcessor:()=>KD,SmolVLMProcessor:()=>VD,SpeechT5Processor:()=>fpe,UltravoxProcessor:()=>ppe,VLChatProcessor:()=>Zfe,VoxtralProcessor:()=>_pe,VoxtralRealtimeProcessor:()=>bpe,Wav2Vec2Processor:()=>xpe,Wav2Vec2ProcessorWithLM:()=>Spe,WhisperProcessor:()=>Cpe});var ZT=class extends Nb{constructor(e){super(),this.config=e}static async from_pretrained(e,t={}){let n=await mC(e,KT,!0,t);return new this(n)}};function QT(e,t){if(!(e instanceof Float32Array||e instanceof Float64Array))throw Error(`${t} expects input to be a Float32Array or a Float64Array, but got ${e?.constructor?.name??typeof e} instead. If using the feature extractor directly, remember to use \`read_audio(url, sampling_rate)\` to obtain the raw audio data of the file/url.`)}var $T={};fb($T,{ASTFeatureExtractor:()=>CE,ChatterboxFeatureExtractor:()=>TE,ClapFeatureExtractor:()=>EE,CohereAsrFeatureExtractor:()=>kE,DacFeatureExtractor:()=>AE,EncodecFeatureExtractor:()=>wE,FeatureExtractor:()=>ZT,Gemma3nAudioFeatureExtractor:()=>jE,Gemma4AudioFeatureExtractor:()=>ME,GraniteSpeechFeatureExtractor:()=>NE,MoonshineFeatureExtractor:()=>PE,ParakeetFeatureExtractor:()=>OE,PyAnnoteFeatureExtractor:()=>FE,SeamlessM4TFeatureExtractor:()=>IE,SnacFeatureExtractor:()=>LE,SpeechT5FeatureExtractor:()=>RE,VoxtralRealtimeFeatureExtractor:()=>VE,Wav2Vec2FeatureExtractor:()=>zE,WeSpeakerFeatureExtractor:()=>BE,WhisperFeatureExtractor:()=>HE});var eE={fromWeb:()=>{}};async function tE(e,t){if(wb.IS_BROWSER_ENV){if(wb.IS_WEBWORKER_ENV)throw Error(`Unable to save a file from a Web Worker.`);let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e,r.click(),r.remove(),URL.revokeObjectURL(n)}else if(wb.IS_FS_AVAILABLE){let n=t.stream();eE.fromWeb(n),pb.createWriteStream(e),await void 0}else throw Error(`Unable to save because filesystem is disabled in this environment.`)}async function nE(e,t){if(typeof AudioContext>`u`)throw Error("Unable to load audio from path/URL since `AudioContext` is not available in your environment. Instead, audio data should be passed directly to the pipeline/processor. For more information and some example code, see https://huggingface.co/docs/transformers.js/guides/node-audio-processing.");let n=await(await sC(e)).arrayBuffer(),r=new AudioContext({sampleRate:t});t===void 0&&Wb.warn(`No sampling rate provided, using default of ${r.sampleRate}Hz.`);let i=await r.decodeAudioData(n),a;if(i.numberOfChannels===2){let e=Math.sqrt(2),t=i.getChannelData(0),n=i.getChannelData(1);a=new Float32Array(t.length);for(let r=0;r2595*Math.log10(1+e/700),kaldi:e=>1127*Math.log(1+e/700),slaney:(e,t=1e3,n=15,r=27/Math.log(6.4))=>e>=t?n+Math.log(e/t)*r:3*e/200};function cE(e,t=`htk`){let n=sE[t];if(!n)throw Error(`mel_scale should be one of "htk", "slaney" or "kaldi".`);return typeof e==`number`?n(e):e.map(e=>n(e))}var lE={htk:e=>700*(10**(e/2595)-1),kaldi:e=>700*(Math.exp(e/1127)-1),slaney:(e,t=1e3,n=15,r=Math.log(6.4)/27)=>e>=n?t*Math.exp(r*(e-n)):200*e/3};function uE(e,t=`htk`){let n=lE[t];if(!n)throw Error(`mel_scale should be one of "htk", "slaney" or "kaldi".`);return typeof e==`number`?n(e):e.map(e=>n(e))}function dE(e,t){let n=Float64Array.from({length:t.length-1},(e,n)=>t[n+1]-t[n]),r=Array.from({length:e.length},()=>Array(t.length));for(let n=0;nArray(e.length));for(let t=0;te+r*n)}function pE(e,t,n,r,i,a=null,o=`htk`,s=!1){if(a!==null&&a!==`slaney`)throw Error(`norm must be one of null or "slaney"`);if(e<2)throw Error(`Require num_frequency_bins: ${e} >= 2`);if(n>r)throw Error(`Require min_frequency: ${n} <= max_frequency: ${r}`);let c=fE(cE(n,o),cE(r,o),t+2),l=uE(c,o),u;if(s){let t=i/((e-1)*2);u=cE(Float64Array.from({length:e},(e,n)=>n*t),o),l=c}else u=fE(0,Math.floor(i/2),e);let d=dE(u,l);if(a!==null&&a===`slaney`)for(let n=0;ni)throw Error(`frame_length (${n}) may not be larger than fft_length (${i})`);if(T!==n)throw Error(`Length of the window (${T}) must equal frame_length (${n})`);if(r<=0)throw Error(`hop_length must be greater than zero`);if(a===null&&d!==null)throw Error("You have provided `mel_filters` but `power` is `None`. Mel spectrogram computation is not yet supported for complex-valued spectrogram. Specify `power` to fix this issue.");if(!u)throw Error("`preemphasis_htk_flavor=false` is not currently supported.");if(o){let t=Math.floor(n/2);switch(s){case`reflect`:e=mE(e,t,t);break;case`constant`:{let n=new e.constructor(e.length+2*t);n.set(e,t),e=n;break}case`semicausal`:{let n=new e.constructor(e.length+t);n.set(e,t),e=n;break}default:throw Error(`pad_mode="${s}" not implemented yet.`)}}let E=Math.floor(1+Math.floor((e.length-n)/r));y!==null&&EE?x&&(k=b):k=O=b);let A=new xC(i),j=new Float64Array(i),M=new Float64Array(A.outputBufferSize),ee=new Float32Array(D*k);for(let i=0;i=1;--e)j[e]-=l*j[e-1];j[0]*=1-l}for(let e=0;ee**.85);break;default:throw Error(`Unknown window type ${t}.`)}if(n&&(o=o.subarray(0,e)),r===null||e===r)return o;if(e>r)throw Error(`Length of the window (${e}) may not be larger than frame_length (${r})`);let s=new Float64Array(r),c=i?Math.floor((r-e)/2):0;return s.set(o,c),s}function bE(e,t){let n=e.reduce((e,t)=>e+t.length,0),r=new ArrayBuffer(44),i=new DataView(r);return xE(i,0,`RIFF`),i.setUint32(4,36+n*4,!0),xE(i,8,`WAVE`),xE(i,12,`fmt `),i.setUint32(16,16,!0),i.setUint16(20,3,!0),i.setUint16(22,1,!0),i.setUint32(24,t,!0),i.setUint32(28,t*4,!0),i.setUint16(32,4,!0),i.setUint16(34,32,!0),xE(i,36,`data`),i.setUint32(40,n*4,!0),new Blob([r,...e.map(e=>e.buffer)],{type:`audio/wav`})}function xE(e,t,n){for(let r=0;re+t.length,0),t=new Float32Array(e),n=0;for(let e of this.audio)t.set(e,n),n+=e.length;return t}return this.audio}toBlob(){let e=this.audio;return e instanceof Float32Array&&(e=[e]),bE(e,this.sampling_rate)}async save(e){return tE(e,this.toBlob())}},CE=class extends ZT{constructor(e){super(e);let t=this.config.sampling_rate,n=pE(257,this.config.num_mel_bins,20,Math.floor(t/2),t,null,`kaldi`,!0);this.mel_filters=n,this.window=yE(400,`hann`,{periodic:!1}),this.mean=this.config.mean,this.std=this.config.std}async _extract_fbank_features(e,t){return vE(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:`log`,mel_floor:1.192092955078125e-7,remove_dc_offset:!0,max_num_frames:t,transpose:!0})}async _call(e){QT(e,`ASTFeatureExtractor`);let t=await this._extract_fbank_features(e,this.config.max_length);if(this.config.do_normalize){let e=this.std*2,n=t.data;for(let t=0;t0){if(n===`rand_trunc`){let n=Math.floor(qS.random()*(a+1));e=e.subarray(n,n+t),i=await this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)}else throw Error(`Truncation strategy "${n}" not implemented`)}else{if(a<0){let n=new Float64Array(t);if(n.set(e),r===`repeat`)for(let r=e.length;r=1;--n)e[n]-=t*e[n-1];return await vE(e,this.window,this.window.length,this.config.hop_length,{fft_length:this.config.n_fft,power:2,mel_filters:this.config.mel_filters,log_mel:`log`,mel_floor:-1/0,pad_mode:`constant`,center:!0,transpose:!0,mel_offset:2**-24})}async _call(e){QT(e,`ParakeetFeatureExtractor`);let t=await this._extract_fbank_features(e),n=Math.floor((e.length+Math.floor(this.config.n_fft/2)*2-this.config.n_fft)/this.config.hop_length),r=t.data;r.fill(0,n*t.dims[1]);let[i,a]=t.dims,o=new Float64Array(a),s=new Float64Array(a);for(let e=0;e1?n-1:1;for(let e=0;e=l){s.push(e.slice(c,l));break}let t=Math.max(c,c+a-o),n=Math.min(c+a,l),i;i=n<=t?c+a:this._find_split_point_energy(e,t,n,r),i=Math.max(c+1,Math.min(i,l)),s.push(e.slice(c,i)),c=i}return s}_find_split_point_energy(e,t,n,r){let i=n-t;if(i<=r)return Math.floor((t+n)/2);let a=1/0,o=t,s=i-r;for(let n=0;n<=s;n+=r){let i=0;for(let a=0;at&&(e=e.slice(0,t)),r&&e.length%i!==0){let t=i-e.length%i,n=new Float64Array(e.length+t);n.set(e),this.config.padding_value!==0&&n.fill(this.config.padding_value,e.length),e=n}let a=await this._extract_fbank_features(e,this.config.max_length),o=Dw([1,a.dims[0]],!0);return{input_features:a.unsqueeze_(0),input_features_mask:o}}},ME=class extends jE{async _extract_fbank_features(e,t){let{frame_length:n,hop_length:r,fft_length:i}=this.config,a=Math.floor(n/2),o=Math.floor((e.length+a-(n+1))/r)+1;return vE(e,this.window,n,r,{fft_length:i,center:!0,pad_mode:`semicausal`,onesided:!0,preemphasis:this.config.preemphasis,preemphasis_htk_flavor:this.config.preemphasis_htk_flavor,mel_filters:this.mel_filters,log_mel:`log`,mel_floor:this.config.mel_floor,mel_floor_mode:`add`,remove_dc_offset:!1,transpose:!0,max_num_frames:o})}async _call(e,t={}){QT(e,`Gemma4AudioFeatureExtractor`);let n=e.length,r=await super._call(e,t),{input_features:i}=r,[,a,o]=i.dims,{frame_length:s,hop_length:c}=this.config,l=Math.floor(s/2),u=s+1,d=new Uint8Array(n+l+(t.pad_to_multiple_of??128));d.fill(1,l,l+n);let f=new Uint8Array(a);for(let e=0;e({id:e,start:t*n,end:r*n,confidence:i/(r-t)})))}return r}},IE=class extends ZT{constructor(e){super(e);let t=this.config.sampling_rate,n=pE(257,this.config.num_mel_bins,20,Math.floor(t/2),t,null,`kaldi`,!0);this.mel_filters=n,this.window=yE(400,`povey`,{periodic:!1})}async _extract_fbank_features(e,t){return e=e.map(e=>e*32768),vE(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:`log`,mel_floor:1.192092955078125e-7,remove_dc_offset:!0,max_num_frames:t,transpose:!0})}async _call(e,{padding:t=!0,pad_to_multiple_of:n=2,do_normalize_per_mel_bins:r=!0,return_attention_mask:i=!0}={}){QT(e,`SeamlessM4TFeatureExtractor`);let a=await this._extract_fbank_features(e,this.config.max_length);if(r){let[e,t]=a.dims,n=a.data;for(let r=0;r0){let n=new Float32Array(t*(e+s));n.set(r),n.fill(this.config.padding_value,r.length);let c=e+s;a=new L(a.type,n,[c,t]),i&&(o=new L(`int64`,new BigInt64Array(c),[1,c]),o.data.fill(1n,0,e))}}let[s,c]=a.dims,l=this.config.stride;if(s%l!==0)throw Error(`The number of frames (${s}) must be a multiple of the stride (${l}).`);let u=a.view(1,Math.floor(s/l),c*l),d={input_features:u};if(i){let e=u.dims[1],t=new BigInt64Array(e);if(o){let e=o.data;for(let n=1,r=0;ne+t,0)/e.length,n=e.reduce((e,n)=>e+(n-t)**2,0)/e.length;return e.map(e=>(e-t)/Math.sqrt(n+1e-7))}async _call(e){QT(e,`Wav2Vec2FeatureExtractor`),e instanceof Float64Array&&(e=new Float32Array(e));let t=e;this.config.do_normalize&&(t=this._zero_mean_unit_var_norm(t));let n=[1,t.length];return{input_values:new L(`float32`,t,n),attention_mask:new L(`int64`,new BigInt64Array(t.length).fill(1n),n)}}},BE=class extends ZT{constructor(e){super(e);let t=this.config.sampling_rate,n=pE(257,this.config.num_mel_bins,20,Math.floor(t/2),t,null,`kaldi`,!0);this.mel_filters=n,this.window=yE(400,`hamming`,{periodic:!1}),this.min_num_frames=this.config.min_num_frames}async _extract_fbank_features(e){return e=e.map(e=>e*32768),vE(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:`log`,mel_floor:1.192092955078125e-7,remove_dc_offset:!0,transpose:!0,min_num_frames:this.min_num_frames})}async _call(e){QT(e,`WeSpeakerFeatureExtractor`);let t=(await this._extract_fbank_features(e)).unsqueeze_(0);if(this.config.fbank_centering_span===null){let e=t.mean(1).data,n=t.data,[r,i,a]=t.dims;for(let t=0;tr?(e.length>this.config.n_samples&&Wb.warn("Attempting to extract features for audio longer than 30 seconds. If using a pipeline to extract transcript from a long audio clip, remember to specify `chunk_length_s` and/or `stride_length_s`."),n=e.slice(0,r)):(n=new Float32Array(r),n.set(e)),{input_features:(await this._extract_fbank_features(n)).unsqueeze_(0)}}},UE=class{static async from_pretrained(e,t={}){let n=await mC(e,KT,!0,t),r=n.feature_extractor_type,i=$T[r];if(!i)throw Error(`Unknown feature_extractor_type: '${r}'. Please report this at ${GT}.`);return new i(n)}},WE=class extends XT{static tokenizer_class=WT;static feature_extractor_class=UE;async _call(e,t=null){let n=this.tokenizer(e),r=t?await this.feature_extractor(t):{};return{...n,...r}}},GE=new Set([`ja`,`zh`]),KE=class extends XT{static tokenizer_class=WT;static feature_extractor_class=UE;static uses_processor_config=!0;get_decoder_prompt_ids(e=`en`){let t=[`▁`,`<|startofcontext|>`,`<|startoftranscript|>`,`<|emo:undefined|>`,`<|${e}|>`,`<|${e}|>`,`<|pnc|>`,`<|noitn|>`,`<|notimestamp|>`,`<|nodiarize|>`];return this.tokenizer.convert_tokens_to_ids(t)}static join_chunks(e,t=`en`){let n=e.filter(e=>e&&e.trim());if(n.length===0)return``;let r=GE.has(t)?``:` `;return[n[0].trimEnd(),...n.slice(1).map(e=>e.trim())].join(r)}async _call(e){return await this.feature_extractor(e)}},qE={},JE,YE,XE;if(wb.IS_WEB_ENV)JE=(e,t)=>{if(!self.OffscreenCanvas)throw Error(`OffscreenCanvas not supported by this environment.`);return new self.OffscreenCanvas(e,t)},XE=self.createImageBitmap,YE=self.ImageData;else if(qE)XE=async e=>{let t=(await e.metadata()).channels,{data:n,info:r}=await e.rotate().raw().toBuffer({resolveWithObject:!0}),i=new $E(new Uint8ClampedArray(n),r.width,r.height,r.channels);return t!==void 0&&t!==r.channels&&i.convert(t),i};else throw Error(`Unable to load image processing library.`);var ZE={0:`nearest`,1:`lanczos`,2:`bilinear`,3:`bicubic`,4:`box`,5:`hamming`},QE=new Map([[`png`,`image/png`],[`jpg`,`image/jpeg`],[`jpeg`,`image/jpeg`],[`gif`,`image/gif`]]),$E=class e{constructor(e,t,n,r){this.data=e,this.width=t,this.height=n,this.channels=r}get size(){return[this.width,this.height]}static async read(t){if(t instanceof e)return t;if(typeof t==`string`||t instanceof URL)return await this.fromURL(t);if(t instanceof Blob)return await this.fromBlob(t);if(typeof HTMLCanvasElement<`u`&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&t instanceof OffscreenCanvas)return this.fromCanvas(t);throw Error(`Unsupported input type: ${typeof t}`)}static fromCanvas(t){if(!wb.IS_WEB_ENV)throw Error(`fromCanvas() is only supported in browser environments.`);let n=t.getContext(`2d`).getImageData(0,0,t.width,t.height).data;return new e(n,t.width,t.height,4)}static async fromURL(e){let t=await sC(e);if(t.status!==200)throw Error(`Unable to read image from "${e}" (${t.status} ${t.statusText})`);let n=await t.blob();return this.fromBlob(n)}static async fromBlob(e){if(wb.IS_WEB_ENV){let t=await XE(e),n=JE(t.width,t.height).getContext(`2d`);return n.drawImage(t,0,0),new this(n.getImageData(0,0,t.width,t.height).data,t.width,t.height,4)}{let t=qE(await e.arrayBuffer());return await XE(t)}}static fromTensor(t,n=`CHW`){if(t.dims.length!==3)throw Error(`Tensor should have 3 dimensions, but has ${t.dims.length} dimensions.`);if(n===`CHW`)t=t.transpose(1,2,0);else if(n!==`HWC`)throw Error(`Unsupported channel format: ${n}`);if(!(t.data instanceof Uint8ClampedArray||t.data instanceof Uint8Array))throw Error(`Unsupported tensor type: ${t.type}`);switch(t.dims[2]){case 1:case 2:case 3:case 4:return new e(t.data,t.dims[1],t.dims[0],t.dims[2]);default:throw Error(`Unsupported number of channels: ${t.dims[2]}`)}}grayscale(){if(this.channels===1)return this;let e=new Uint8ClampedArray(this.width*this.height*1);switch(this.channels){case 3:case 4:for(let t=0,n=0;t=0?c=r:u=-r,i>=0?l=i:d=-i,s.drawImage(o,c,l,t,n,u,d,t,n),new e(s.getImageData(0,0,t,n).data,t,n,4).convert(a)}{let e=this.toSharp();if(r>=0&&i>=0)e=e.extract({left:Math.floor(r),top:Math.floor(i),width:t,height:n});else if(r<=0&&i<=0){let a=Math.floor(-i),o=Math.floor(-r);e=e.extend({top:a,left:o,right:t-this.width-o,bottom:n-this.height-a})}else{let a=[0,0],o=0;i<0?(a[0]=Math.floor(-i),a[1]=n-this.height-a[0]):o=Math.floor(i);let s=[0,0],c=0;r<0?(s[0]=Math.floor(-r),s[1]=t-this.width-s[0]):c=Math.floor(r),e=e.extend({top:a[0],bottom:a[1],left:s[0],right:s[1]}).extract({left:c,top:o,width:t,height:n})}return await XE(e)}}async toBlob(e=`image/png`,t=1){if(!wb.IS_WEB_ENV)throw Error(`toBlob() is only supported in browser environments.`);return await this.toCanvas().convertToBlob({type:e,quality:t})}toTensor(e=`CHW`){let t=new L(`uint8`,new Uint8Array(this.data),[this.height,this.width,this.channels]);if(e!==`HWC`){if(e===`CHW`)t=t.permute(2,0,1);else throw Error(`Unsupported channel format: ${e}`)}return t}toCanvas(){if(!wb.IS_WEB_ENV)throw Error(`toCanvas() is only supported in browser environments.`);let e=this.clone().rgba(),t=JE(e.width,e.height),n=new YE(e.data,e.width,e.height);return t.getContext(`2d`).putImageData(n,0,0),t}split(){let{data:t,width:n,height:r,channels:i}=this,a=t.constructor,o=t.length/i,s=Array.from({length:i},()=>new a(o));for(let e=0;enew e(t,n,r,1))}_update(e,t,n,r=null){return this.data=e,this.width=t,this.height=n,r!==null&&(this.channels=r),this}clone(){return new e(this.data.slice(),this.width,this.height,this.channels)}convert(e){if(this.channels===e)return this;switch(e){case 1:this.grayscale();break;case 3:this.rgb();break;case 4:this.rgba();break;default:throw Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this}async save(e){if(wb.IS_WEB_ENV){if(wb.IS_WEBWORKER_ENV)throw Error(`Unable to save an image from a Web Worker.`);let t=e.split(`.`).pop().toLowerCase(),n=QE.get(t)??`image/png`;return tE(e,await this.toBlob(n))}if(wb.IS_FS_AVAILABLE)await this.toSharp().toFile(e);else throw Error(`Unable to save the image because filesystem is disabled in this environment.`)}toSharp(){if(wb.IS_WEB_ENV)throw Error(`toSharp() is only supported in server-side environments.`);return qE(this.data,{raw:{width:this.width,height:this.height,channels:this.channels}})}};$E.read.bind($E);function eD(e,t,n=0,r=null){let i=e/t,a=wC(i)*t;return r!==null&&a>r&&(a=Math.floor(i)*t),at&&i.push(e)}else{let e=_C(n.data)[1];if(e===c-1||(a=hC(n.data),a[e]e*o[(t+1)%2])),u.boxes.push(n),u.classes.push(t),u.scores.push(a[t])}}l.push(u)}return l}function iD(e,t=null){let n=e.logits,r=n.dims[0];if(t!==null&&t.length!==r)throw Error(`Make sure that you pass in as many target sizes as the batch dimension of the logits`);let i=[];for(let e=0;el[n]&&(l[n]=t[n],u[n]=e)}let d=Array(a.dims[0]);for(let e=0;ee!==void 0);i.push({segmentation:c,labels:f})}return i}function aD(e,t,n,r){let i=[],a=[],o=[];for(let s=0;sn&&(i.push(l),a.push(d),o.push(u))}return[i,a,o]}function oD(e,t,n,r=.5,i=.8){let a=[],o=0,s=0,c=t[n].data;for(let t=0;t=r&&++s;let l=o>0&&s>0;return l&&=o/s>i,[l,a]}function sD(e,t,n,r,i,a=null,o=null){let[s,c]=o??e[0].dims,l=new L(`int32`,new Int32Array(s*c),[s,c]),u=[];if(o!==null)for(let t=0;tf[e]&&(d[e]=n,f[e]=i[e])}let p=0,m=l.data;for(let a=0;a200)throw Error(`absolute aspect ratio must be smaller than 200, got ${Math.max(e,t)/Math.min(e,t)}`);let o=Math.round(e/n)*n,s=Math.round(t/n)*n;if(a*o*s>i){let r=Math.sqrt(a*e*t/i);o=Math.max(n,Math.floor(e/r/n)*n),s=Math.max(n,Math.floor(t/r/n)*n)}else if(a*o*si?c=Math.floor(i*s/r):i>r&&(s=Math.floor(r*c/i)),await e.resize(c,s,{resample:n}))}async crop_margin(e,t=200){let n=e.clone().grayscale(),r=gC(n.data)[0],i=_C(n.data)[0]-r;if(i===0)return e;let a=t/255,o=n.width,s=n.height,c=0,l=0,u=n.data;for(let e=0;ethis.preprocess(e)));return{pixel_values:xw(n.map(e=>e.pixel_values),0),original_sizes:n.map(e=>e.original_size),reshaped_input_sizes:n.map(e=>e.reshaped_input_size)}}static async from_pretrained(e,t={}){let n=await mC(e,qT,!0,t);return new this(n)}},fD={};fb(fD,{BeitFeatureExtractor:()=>Gde,BitImageProcessor:()=>Kde,CHMv2ImageProcessor:()=>Jde,CLIPFeatureExtractor:()=>Yde,CLIPImageProcessor:()=>pD,ChineseCLIPFeatureExtractor:()=>qde,ConvNextFeatureExtractor:()=>Xde,ConvNextImageProcessor:()=>mD,DINOv3ViTImageProcessor:()=>$de,DPTFeatureExtractor:()=>tfe,DPTImageProcessor:()=>vD,DeiTFeatureExtractor:()=>Zde,DeiTImageProcessor:()=>hD,DetrFeatureExtractor:()=>Qde,DetrImageProcessor:()=>gD,DonutFeatureExtractor:()=>efe,DonutImageProcessor:()=>_D,EfficientNetImageProcessor:()=>nfe,GLPNFeatureExtractor:()=>sfe,Gemma3ImageProcessor:()=>rfe,Gemma4ImageProcessor:()=>yD,Glm46VImageProcessor:()=>ofe,GroundingDinoImageProcessor:()=>cfe,Idefics3ImageProcessor:()=>xD,ImageFeatureExtractor:()=>dD,ImageProcessor:()=>dD,JinaCLIPImageProcessor:()=>ufe,Lfm2VlImageProcessor:()=>hfe,LlavaOnevisionImageProcessor:()=>gfe,Mask2FormerImageProcessor:()=>vfe,MaskFormerFeatureExtractor:()=>_fe,MaskFormerImageProcessor:()=>CD,MobileNetV1FeatureExtractor:()=>yfe,MobileNetV1ImageProcessor:()=>wD,MobileNetV2FeatureExtractor:()=>bfe,MobileNetV2ImageProcessor:()=>TD,MobileNetV3FeatureExtractor:()=>xfe,MobileNetV3ImageProcessor:()=>ED,MobileNetV4FeatureExtractor:()=>Sfe,MobileNetV4ImageProcessor:()=>DD,MobileViTFeatureExtractor:()=>Cfe,MobileViTImageProcessor:()=>OD,NougatImageProcessor:()=>wfe,OwlViTFeatureExtractor:()=>Tfe,OwlViTImageProcessor:()=>kD,Owlv2ImageProcessor:()=>Efe,Phi3VImageProcessor:()=>Ofe,PixtralImageProcessor:()=>kfe,PvtImageProcessor:()=>Afe,Qwen2VLImageProcessor:()=>bD,RTDetrImageProcessor:()=>jfe,Sam2ImageProcessor:()=>PD,Sam3ImageProcessor:()=>PD,SamImageProcessor:()=>PD,SapiensFeatureExtractor:()=>Mfe,SapiensImageProcessor:()=>FD,SegformerFeatureExtractor:()=>Nfe,SegformerImageProcessor:()=>ID,SiglipImageProcessor:()=>Pfe,SmolVLMImageProcessor:()=>xD,Swin2SRImageProcessor:()=>Ffe,VLMImageProcessor:()=>lfe,ViTFeatureExtractor:()=>Ife,ViTImageProcessor:()=>LD,VitMatteImageProcessor:()=>Lfe,VitPoseImageProcessor:()=>Rfe,YolosFeatureExtractor:()=>zfe,YolosImageProcessor:()=>RD});var Gde=class extends dD{},Kde=class extends dD{},qde=class extends dD{},Jde=class extends dD{},pD=class extends dD{},Yde=class extends pD{},mD=class extends dD{constructor(e){super(e),this.crop_pct=this.config.crop_pct??224/256}async resize(e){let t=this.size?.shortest_edge;if(t===void 0)throw Error(`Size dictionary must contain 'shortest_edge' key.`);if(t<384){let n=Math.floor(t/this.crop_pct),[r,i]=this.get_resize_output_image_size(e,{shortest_edge:n});e=await e.resize(r,i,{resample:this.resample}),e=await e.center_crop(t,t)}else e=await e.resize(t,t,{resample:this.resample});return e}},Xde=class extends mD{},hD=class extends dD{},Zde=class extends hD{},gD=class extends dD{async _call(e){let t=await super._call(e),n=Dw([t.pixel_values.dims[0],64,64],1n);return{...t,pixel_mask:n}}post_process_object_detection(...e){return rD(...e)}post_process_panoptic_segmentation(...e){return lD(...e)}post_process_instance_segmentation(...e){return uD(...e)}},Qde=class extends gD{},$de=class extends dD{},_D=class extends dD{pad_image(e,t,n,r={}){let[i,a,o]=t,s=this.image_mean;Array.isArray(this.image_mean)||(s=Array(o).fill(s));let c=this.image_std;Array.isArray(c)||(c=Array(o).fill(s));let l=s.map((e,t)=>-e/c[t]);return super.pad_image(e,t,n,{center:!0,constant_values:l,...r})}},efe=class extends _D{},vD=class extends dD{},tfe=class extends vD{},nfe=class extends dD{constructor(e){super(e),this.include_top=this.config.include_top??!0,this.include_top&&(this.image_std=this.image_std.map(e=>e*e))}},rfe=class extends dD{};function ife(e,t,n,r,i){let a=r*n**2,o=Math.sqrt(a/(e*t)),s=i*n,c=Math.floor(o*e/s)*s,l=Math.floor(o*t/s)*s;if(c===0&&l===0)throw Error(`Attempting to resize to a 0 x 0 image. Resized height should be divisible by \`pooling_kernel_size * patch_size\`=${s}.`);let u=Math.floor(r/i**2)*s;return c===0?(c=s,l=Math.min(Math.floor(t/e)*s,u)):l===0&&(l=s,c=Math.min(Math.floor(e/t)*s,u)),[c,l]}function afe(e,t,n,r,i,a,o){let s=Math.floor(t/i),c=Math.floor(n/i),l=s*c,u=i*i*r,d=new Float32Array(a*u),f=0;for(let t=0;ta),0));let l=a.dims[0]/o,u=a.dims[1],d=Math.floor(a.dims[2]/c),f=Math.floor(a.dims[3]/c);return{pixel_values:a.view(l,o,u,Math.floor(d/s),s,c,Math.floor(f/s),s,c).permute(0,3,6,4,7,2,1,5,8).view(l*d*f,u*o*c*c),image_grid_thw:new L(`int64`,[l,d,f],[1,3]),original_sizes:r,reshaped_input_sizes:i}}},ofe=class extends bD{get_resize_output_image_size(e,t){let n=this.patch_size*this.merge_size,r=this.config.temporal_patch_size??2;return cD(e.height,e.width,n,this.min_pixels,this.max_pixels,r)}},sfe=class extends dD{},cfe=class extends dD{async _call(e){let t=await super._call(e),n=t.pixel_values.dims,r=kw([n[0],n[2],n[3]]);return{...t,pixel_mask:r}}},xD=class extends dD{constructor(e){super(e),this.do_image_splitting=e.do_image_splitting??!0,this.max_image_size=e.max_image_size}get_resize_for_vision_encoder(e,t){let[n,r]=e.dims.slice(-2),i=r/n;return r>=n?(r=Math.ceil(r/t)*t,n=Math.floor(r/i),n=Math.ceil(n/t)*t):(n=Math.ceil(n/t)*t,r=Math.floor(n*i),r=Math.ceil(r/t)*t),{height:n,width:r}}async _call(e,{do_image_splitting:t=null,return_row_col_info:n=!1}={}){let r;if(!Array.isArray(e))r=[[e]];else{if(e.length===0||!e[0])throw Error(`No images provided.`);r=Array.isArray(e[0])?e:[e]}let i=[],a=[],o=[],s=[],c=[];for(let e of r){let n=await Promise.all(e.map(e=>this.preprocess(e)));s.push(...n.map(e=>e.original_size)),c.push(...n.map(e=>e.reshaped_input_size)),n.forEach(e=>e.pixel_values.unsqueeze_(0));let{longest_edge:r}=this.max_image_size,l;if(t??this.do_image_splitting){let e=Array(n.length),t=Array(n.length);l=await Promise.all(n.map(async(n,i)=>{let a=this.get_resize_for_vision_encoder(n.pixel_values,r),o=await dw(n.pixel_values,{size:[a.height,a.width]}),{frames:s,num_splits_h:c,num_splits_w:l}=await this.split_image(o,this.max_image_size);return e[i]=c,t[i]=l,bw(s,0)})),a.push(e),o.push(t)}else{let e=[r,r];l=await Promise.all(n.map(t=>dw(t.pixel_values,{size:e}))),a.push(Array(n.length).fill(0)),o.push(Array(n.length).fill(0))}i.push(bw(l,0))}let l=i.length,[u,d,f,p]=i[0].dims,m,h;if(l===1)m=i[0].unsqueeze_(0),h=Dw([l,u,f,p],!0);else{let e=Math.max(...i.map(e=>e.dims.at(0)));h=Dw([l,e,f,p],!0);let t=h.data,n=e*f*p;for(let r=0;rn||o>r){s=Math.ceil(a/n),c=Math.ceil(o/r);let t=Math.ceil(a/s),l=Math.ceil(o/c);for(let n=0;ne*this.rescale_factor)}pad_image(e,t,n,r){return super.pad_image(e,t,n,{constant_values:this.constant_values,center:!0,...r})}},ufe=class extends dD{constructor(e){let{resize_mode:t,fill_color:n,interpolation:r,size:i,...a}=e,o=t===`squash`?{width:i,height:i}:t===`shortest`?{shortest_edge:i}:{longest_edge:i},s=r===`bicubic`?3:2;super({...a,size:o,resample:s,do_center_crop:!0,crop_size:i,do_normalize:!0})}};function SD(e,t){return Math.round(e/t)*t}function dfe(e,t,n,r,i){let a=1/0,o=[1,1],s=n*r;for(let n of t){let t=Math.abs(e-n[0]/n[1]);t.5*i*i*n[0]*n[1]&&(o=n)}return o}function ffe(e,t){let n=[],r=new Set;for(let i=e;i<=t;++i)for(let a=1;a<=i;++a)for(let o=1;o<=i;++o){let i=a*o;if(i>=e&&i<=t){let e=a<<16|o;r.has(e)||(r.add(e),n.push([a,o]))}}return n.sort((e,t)=>e[0]*e[1]-t[0]*t[1])}function pfe(e,t){let[n,r,i,a]=e.dims,o=Math.floor(i/t),s=Math.floor(a/t),c=t*t*r,l=e.data,u=new Float32Array(n*o*s*c),d=i*a;for(let e=0;ethis.max_image_tokens*(this.encoder_patch_size*this.downsample_factor)**2*this.max_pixels_tolerance}_get_grid_layout(e,t){let n=ffe(this.min_tiles,this.max_tiles),[r,i]=dfe(t/e,n,t,e,this.tile_size);return{grid_width:r,grid_height:i,target_width:this.tile_size*r,target_height:this.tile_size*i}}async _call(e,{return_row_col_info:t=null}={}){let n;n=Array.isArray(e)?Array.isArray(e[0])?e:[e]:[[e]];let r=[],i=[],a=[],o=[],s=[],c=[];for(let e of n){let t=await Promise.all(e.map(e=>this.preprocess(e,{do_pad:!1})));for(let{pixel_values:e}of t){let[,t,n]=e.dims,l=e.unsqueeze_(0),u=this.encoder_patch_size*this.downsample_factor,d=u**2,[f,p]=cD(Math.max(u,t),Math.max(u,n),u,this.min_image_tokens*d,this.max_image_tokens*d).map(e=>Math.max(u,e)),m,h=1,g=1,_=this._is_image_too_large(t,n),v=this.do_image_splitting&&(this.min_tiles!==1||this.max_tiles!==1);if(_&&v){let{grid_width:e,grid_height:r,target_width:i,target_height:a}=this._get_grid_layout(t,n);h=r,g=e;let o=await dw(l,{size:[a,i]});m=[];for(let t=0;t(e-this.image_mean[t])/this.image_std[t]);return super.pad_image(e,t,{width:s,height:o},{center:!0,constant_values:c,...r})}async _call(e,{num_crops:t=null}={}){if(this._num_crops=t??=this.config.num_crops,t<4||ND(t)%1!=0)throw Error(`num_crops must be a square number >= 4`);Array.isArray(e)||(e=[e]);let n=e.length,r=await Promise.all(e.map(e=>this.preprocess(e))),i=r.map(e=>e.original_size),a=r.map(e=>e.reshaped_input_size),o=[];for(let{pixel_values:e}of r){e.unsqueeze_(0);let[n,r]=e.dims.slice(-2),i=await dw(e,{size:[AD,AD],mode:`bicubic`});if(t>0){let a=[],s=ND(t),c=MD(r/s),l=MD(n/s);for(let t=0;te.map(e=>AD*jD(e/AD)));return{pixel_values:s,original_sizes:i,reshaped_input_sizes:a,image_sizes:new L(`int64`,c.flat(),[n,2]),num_img_tokens:c.map(([e,t])=>this.calc_num_image_tokens_from_image_size(t,e))}}},kfe=class extends dD{get_resize_output_image_size(e,t){let{longest_edge:n}=t;if(n===void 0)throw Error(`size must contain 'longest_edge'`);let[r,i]=e.size,a=Math.max(r,i)/n,o=r,s=i;a>1&&(o=Math.floor(r/a),s=Math.floor(i/a));let{patch_size:c,spatial_merge_size:l}=this.config;if(!l)throw Error(`config must contain 'spatial_merge_size'`);let u=c*l,d=Math.floor((o-1)/u)+1,f=Math.floor((s-1)/u)+1;return[d*u,f*u]}},Afe=class extends dD{},jfe=class extends dD{post_process_object_detection(...e){return rD(...e)}},PD=class extends dD{reshape_input_points(e,t,n,r=!1){e=structuredClone(e);let i=Rb(e);if(i.length===3)r||(i=[1,...i]),e=[e];else if(i.length!==4)throw Error("The input_points must be a 4D tensor of shape `batch_size`, `point_batch_size`, `nb_points_per_image`, `2`.");for(let r=0;re!==t.dims[n]))throw Error(`The first ${n.length} dimensions of 'input_points' and 'input_labels' must be the same.`);return new L(`int64`,e.flat(1/0).map(BigInt),n)}async _call(e,{input_points:t=null,input_labels:n=null,input_boxes:r=null}={}){let i=await super._call(e);if(t&&(i.input_points=this.reshape_input_points(t,i.original_sizes,i.reshaped_input_sizes)),n){if(!i.input_points)throw Error("`input_points` must be provided if `input_labels` are provided.");i.input_labels=this.add_input_labels(n,i.input_points)}return r&&(i.input_boxes=this.reshape_input_points(r,i.original_sizes,i.reshaped_input_sizes,!0)),i}async post_process_masks(e,t,n,{mask_threshold:r=0,binarize:i=!0,pad_size:a=null}={}){let o=[];a=a??this.pad_size??this.size;let s=[a.height,a.width];for(let a=0;ar&&(t[n]=1);u=new L(`bool`,t,u.dims)}o.push(u)}return o}generate_crop_boxes(e,t,{crop_n_layers:n=0,overlap_ratio:r=512/1500,points_per_crop:i=32,crop_n_points_downscale_factor:a=1}={}){}},FD=class extends dD{post_process_semantic_segmentation(...e){return iD(...e)}},Mfe=class extends FD{},ID=class extends dD{post_process_semantic_segmentation(...e){return iD(...e)}},Nfe=class extends ID{},Pfe=class extends dD{},Ffe=class extends dD{pad_image(e,t,n,r={}){let[i,a,o]=t;return super.pad_image(e,t,{width:a+(n-a%n)%n,height:i+(n-i%n)%n},{mode:`symmetric`,center:!1,constant_values:-1,...r})}},LD=class extends dD{},Ife=class extends LD{},Lfe=class extends dD{async _call(e,t){Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]);let n=await Promise.all(e.map(e=>this.preprocess(e))),r=await Promise.all(t.map(e=>this.preprocess(e,{do_normalize:!1,do_convert_rgb:!1,do_convert_grayscale:!0})));return{pixel_values:xw(n.map((e,t)=>bw([e.pixel_values,r[t].pixel_values],0)),0),original_sizes:n.map(e=>e.original_size),reshaped_input_sizes:n.map(e=>e.reshaped_input_size)}}},Rfe=class extends dD{post_process_pose_estimation(e,t,{threshold:n=null}={}){let r=e.tolist(),[i,a,o,s]=e.dims,c=[];for(let e=0;e/gm,bboxes:/([^<]+)?/gm},this.size_per_bin=1e3}construct_prompts(e){typeof e==`string`&&(e=[e]);let t=[];for(let n of e)if(this.task_prompts_without_inputs.has(n))t.push(this.task_prompts_without_inputs.get(n));else{for(let[e,r]of this.task_prompts_with_input)if(n.includes(e)){t.push(r.replaceAll(`{input}`,n).replaceAll(e,``));break}t.length!==e.length&&t.push(n)}return t}post_process_generation(e,t,n){let r=this.tasks_answer_post_processing_type.get(t)??`pure_text`;e=e.replaceAll(``,``).replaceAll(``,``);let i;switch(r){case`pure_text`:i=e;break;case`description_with_bboxes`:case`bboxes`:case`phrase_grounding`:case`ocr`:let a=r===`ocr`?`quad_boxes`:`bboxes`,o=e.matchAll(this.regexes[a]),s=[],c=[];for(let[e,t,...r]of o)s.push(t?t.trim():s.at(-1)??``),c.push(r.map((e,t)=>(Number(e)+.5)/this.size_per_bin*n[t%2]));i={labels:s,[a]:c};break;default:throw Error(`Task "${t}" (of type "${r}") not yet implemented.`)}return{[t]:i}}async _call(e,t=null,n={}){if(!e&&!t)throw Error(`Either text or images must be provided`);let r=await this.image_processor(e,n),i=t?this.tokenizer(this.construct_prompts(t),n):{};return{...r,...i}}},Vfe=class extends XT{static tokenizer_class=WT;static image_processor_class=zD;static uses_processor_config=!0;static uses_chat_template_file=!0;constructor(e,t,n){super(e,t,n),this.image_seq_length=this.config.image_seq_length;let{boi_token:r,image_token:i,eoi_token:a}=this.tokenizer.config;this.boi_token=r,this.image_token=i,this.eoi_token=a;let o=i.repeat(this.image_seq_length);this.full_image_sequence=` ${r}${o}${a} `}async _call(e,t=null,n={}){typeof e==`string`&&(e=[e]);let r;return t&&(r=await this.image_processor(t,n),e=e.map(e=>e.replaceAll(this.boi_token,this.full_image_sequence))),{...this.tokenizer(e,n),...r}}},Hfe=class extends XT{static image_processor_class=zD;static feature_extractor_class=UE;static tokenizer_class=WT;static uses_processor_config=!0;static uses_chat_template_file=!0;constructor(e,t,n){super(e,t,n),this.audio_seq_length=this.config.audio_seq_length,this.image_seq_length=this.config.image_seq_length;let{audio_token_id:r,boa_token:i,audio_token:a,eoa_token:o,image_token_id:s,boi_token:c,image_token:l,eoi_token:u}=this.tokenizer.config;this.audio_token_id=r,this.boa_token=i,this.audio_token=a;let d=a.repeat(this.audio_seq_length);this.full_audio_sequence=` ${i}${d}${o} `,this.image_token_id=s,this.boi_token=c,this.image_token=l;let f=l.repeat(this.image_seq_length);this.full_image_sequence=` ${c}${f}${u} `}async _call(e,t=null,n=null,r={}){typeof e==`string`&&(e=[e]);let i;n&&(i=await this.feature_extractor(n,r),e=e.map(e=>e.replaceAll(this.audio_token,this.full_audio_sequence)));let a;return t&&(a=await this.image_processor(t,r),e=e.map(e=>e.replaceAll(this.image_token,this.full_image_sequence))),{...this.tokenizer(e,r),...a,...i}}},Ufe=class extends XT{static uses_processor_config=!0;static uses_chat_template_file=!0;constructor(e,t,n){super(e,t,n),this.audio_ms_per_token=this.config.audio_ms_per_token??40,this.audio_seq_length=this.config.audio_seq_length??750,this.image_seq_length=this.config.image_seq_length??280;let{audio_token:r,boa_token:i,eoa_token:a,image_token:o,boi_token:s,eoi_token:c}=this.tokenizer.config;this.audio_token=r,this.boa_token=i,this.eoa_token=a,this.image_token=o,this.boi_token=s,this.eoi_token=c}static async from_pretrained(e,t={}){let[n,r,i]=await Promise.all([mC(e,JT,!0,t),WT.from_pretrained(e,t),pC(e,YT,!1,t)]),a={tokenizer:r};return n.image_processor&&(a.image_processor=new yD(n.image_processor)),n.feature_extractor&&(a.feature_extractor=new ME(n.feature_extractor)),new this(n,a,i)}_compute_audio_num_tokens(e,t){let n=Math.round(t*20/1e3),r=Math.round(t*10/1e3),i=Math.floor(n/2),a=Math.floor((e+i-n-1)/r)+1;if(a<=0)return 0;for(let e=0;e<2;++e)a=Math.floor((a-1)/2)+1;return Math.min(a,this.audio_seq_length)}async _call(e,t=null,n=null,r={}){typeof e==`string`&&(e=[e]);let i;if(t){i=await this.image_processor(t,r);let n=i.num_soft_tokens_per_image,a=0;e=e.map(e=>e.replaceAll(this.image_token,()=>` ${this.boi_token}${this.image_token.repeat(n[a++])}${this.eoi_token} `))}let a;if(n){let t=Array.isArray(n)?n:[n];a=await this.feature_extractor(t[0],r);let i=this.feature_extractor.config.sampling_rate??16e3,o=0;e=e.map(e=>e.replaceAll(this.audio_token,()=>` ${this.boa_token}${this.audio_token.repeat(this._compute_audio_num_tokens(t[o++].length,i))}${this.eoa_token} `))}return{...this.tokenizer(e,r),...i,...a}}},BD=class extends XT{static image_processor_class=zD;static tokenizer_class=WT;static image_token=`<|image_pad|>`;async _call(e,t=null,...n){Array.isArray(e)||(e=[e]);let r,i;if(t&&(r=await this.image_processor(t),i=r.image_grid_thw),i){let t=this.image_processor.config.merge_size**2,n=0,r=this.constructor.image_token,a=i.tolist();e=e.map(e=>{for(;e.includes(r);){let i=Number(a[n++].reduce((e,t)=>e*t,1n));e=e.replace(r,`<|placeholder|>`.repeat(Math.floor(i/t)))}return e.replaceAll(`<|placeholder|>`,r)})}return{...this.tokenizer(e),...r}}},Wfe=class extends BD{static image_token=`<|image|>`},Gfe=class extends XT{static tokenizer_class=WT;static feature_extractor_class=UE;static uses_processor_config=!0;_get_num_audio_features(e){let{hop_length:t}=this.feature_extractor.config.melspec_kwargs,{projector_window_size:n,projector_downsample_rate:r}=this.feature_extractor.config,i=Math.floor(n/r),a=Math.floor(e/t)+1,o=Math.floor(a/2);return Math.ceil(o/n)*i}async _call(e,t=null,n={}){if(Array.isArray(e))throw Error(`Batched inputs are not supported yet.`);let r={};if(t){let{input_features:n}=await this.feature_extractor(t);r.input_features=n;let i=this._get_num_audio_features(t.length);r.input_features_mask=new L(`bool`,new Uint8Array(i).fill(1),[1,i]);let a=this.config.audio_token??`<|audio|>`;if(!e.includes(a))throw Error(`The input text does not contain the audio token ${a}.`);e=e.replaceAll(a,a.repeat(i))}return{...this.tokenizer(e,{add_special_tokens:!1,...n}),...r}}};function Kfe(e,t){let n=e.dims.at(-1)-1,r=e.tolist();r.fill(!1,0,1),r.fill(!1,n);let i=t.tolist();return r.map((e,t)=>e?t:null).filter(e=>e!==null).map(e=>i[e])}var qfe=class extends XT{static tokenizer_class=WT;static image_processor_class=zD;async _call(e,t,n={}){let r=e?await this.image_processor(e,n):{};return{...t?this.tokenizer(t,n):{},...r}}post_process_grounded_object_detection(e,t,{box_threshold:n=.25,text_threshold:r=.25,target_sizes:i=null}={}){let{logits:a,pred_boxes:o}=e,s=a.dims[0];if(i!==null&&i.length!==s)throw Error(`Make sure that you pass in as many target sizes as the batch dimension of the logits`);let c=a.dims.at(1),l=a.sigmoid(),u=l.max(-1).tolist(),d=o.tolist().map(e=>e.map(e=>nD(e))),f=[];for(let e=0;ee.map((e,t)=>e*a[(t+1)%2])));let o=u[e],s=[],p=[],m=[];for(let i=0;i`+i.repeat(e);o+=` `}return o+=` ${r}${a}`+i.repeat(e)+`${r}`,o}function Yfe(e,t,n,r){return`${t}${r}`+n.repeat(e)+`${t}`}function Xfe(e,t,n,r,i,a){return e===0&&t===0?Yfe(n,r,i,a):Jfe(n,e,t,r,i,a)}var VD=class extends XT{static image_processor_class=zD;static tokenizer_class=WT;static uses_processor_config=!0;fake_image_token=``;image_token=``;global_img_token=``;async _call(e,t=null,n={}){n.return_row_col_info??=!0;let r;t&&(r=await this.image_processor(t,n)),Array.isArray(e)||(e=[e]);let i=r.rows??[Array(e.length).fill(0)],a=r.cols??[Array(e.length).fill(0)],o=this.config.image_seq_len,s=[],c=[];for(let t=0;tXfe(e,l[t],o,this.fake_image_token,this.image_token,this.global_img_token)),d=n.split(this.image_token);if(d.length===0)throw Error(`The image token should be present in the text.`);let f=d[0];for(let e=0;ee.images).flatMap(e=>e.images).map(e=>$E.read(e)));let r=this.tokenizer,i=r.apply_chat_template(e,{tokenize:!1,add_generation_prompt:!0,chat_template:n}),a=e=>r.encode(e,{add_special_tokens:!1}),o=i.split(this.image_tag),s=o.length-1;if(t.length!==s)throw Error(`Number of images provided (${t.length}) does not match number of "${this.image_tag}" image tags (${s})`);let[c,l,u]=r.convert_tokens_to_ids([this.image_tag,this.image_start_tag,this.image_end_tag]),d=a(o[0]),f=Array(d.length).fill(!1);for(let e=1;e0){let e=await this.image_processor(t);return e.pixel_values.unsqueeze_(0),{...m,...e}}return m}},Qfe=class extends XT{static tokenizer_class=WT;static image_processor_class=zD;async _call(e=null,t=null,n={}){if(!e&&!t)throw Error(`Either text or images must be provided`);let r=e?this.tokenizer(e,n):{},i=t?await this.image_processor(t,n):{};return{...r,...i}}},$fe=class extends XT{static tokenizer_class=WT;static image_processor_class=zD;async _call(e,t=null,n={}){let{image_rows:r,image_cols:i,image_sizes:a,...o}=await this.image_processor(e,{...n,return_row_col_info:!0});if(t){let e=this.config.image_token??``,{tile_size:n=512,downsample_factor:o=2,encoder_patch_size:s=16,use_thumbnail:c=!0}=this.image_processor.config,l=e=>Math.ceil(Math.floor(e/s)/o),u=l(n)**2,d=this.config.image_start_token??`<|image_start|>`,f=this.config.image_end_token??`<|image_end|>`,p=this.config.image_thumbnail??`<|img_thumbnail|>`;Array.isArray(t)||(t=[t]);let m=0;t=t.map(t=>{let n=t.split(e);return n[0]+n.slice(1).map(t=>{let n=m++,[o,s]=a[n],h=r[n],g=i[n],_=l(o)*l(s),v=d;if(h>1||g>1){let t=e.repeat(u);for(let e=0;e`+t;c&&(v+=p+e.repeat(_))}else v+=e.repeat(_);return v+f+t}).join(``)})}return{...o,...t?this.tokenizer(t,n):{}}}},epe=class extends XT{static tokenizer_class=WT;static image_processor_class=zD;static uses_processor_config=!0;async _call(e,t=null,n={}){let r=await this.image_processor(e,n);if(t){let[e,n]=r.pixel_values.dims.slice(-2),{image_token:i,patch_size:a,num_additional_image_tokens:o}=this.config,s=Math.floor(e/a)*Math.floor(n/a)+o;t=structuredClone(t),Array.isArray(t)||(t=[t]);for(let e=0;e0?i.reduce((e,t)=>e*t,1):0;c.push(n),s.push(a)}return[i(c),s]}char_decode(e){return this.char_tokenizer.batch_decode(e).map(e=>e.replaceAll(` `,``))}bpe_decode(e){return this.bpe_tokenizer.batch_decode(e)}wp_decode(e){return this.wp_tokenizer.batch_decode(e).map(e=>e.replaceAll(` `,``))}batch_decode([e,t,n]){let[r,i]=this._decode_helper(e,`char`),[a,o]=this._decode_helper(t,`bpe`),[s,c]=this._decode_helper(n,`wp`),l=[],u=[];for(let e=0;e`;function ipe(e,t,n,r,i){return`${r.repeat(n*i)}${t}${e} `}var ape=class extends XT{static tokenizer_class=WT;static image_processor_class=zD;static uses_processor_config=!1;async _call(e,t=null,n={}){t||=(Wb.warn(`You are using PaliGemma without a text prefix. It will perform as a picture-captioning model.`),``),Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]);let r=this.tokenizer.bos_token,i=this.image_processor.config.image_seq_length,a;t.some(e=>e.includes(UD))?a=t.map(e=>{let t=e.replaceAll(UD,UD.repeat(i)),n=t.lastIndexOf(UD),a=n===-1?0:n+UD.length;return t.slice(0,a)+r+t.slice(a)+` `}):(Wb.warn("You are passing both `text` and `images` to `PaliGemmaProcessor`. The processor expects special image tokens in the text, as many tokens as there are images per each text. It is recommended to add `` tokens in the very beginning of your text. For this call, we will infer how many images each text has and add special tokens."),a=t.map(t=>ipe(t,r,i,UD,e.length)));let o=this.tokenizer(a,n);return{...await this.image_processor(e,n),...o}}},WD=`<|image|>`,ope=/<\|image_\d+\|>/g,spe=class extends XT{static image_processor_class=zD;static tokenizer_class=WT;async _call(e,t=null,{padding:n=!0,truncation:r=!0,num_crops:i=null}={}){Array.isArray(e)||(e=[e]);let a,o;if(t){o=await this.image_processor(t,{num_crops:i});let{num_img_tokens:s}=o,c=e.map((e,t)=>e.split(ope).join(WD.repeat(s[t])));a=this.tokenizer(c,{padding:n,truncation:r});let l=this.tokenizer._tokenizer.token_to_id(WD);a.input_ids.map_(e=>e==l?-e:e)}else a=this.tokenizer(e);return{...a,...o}}},cpe=class extends XT{static tokenizer_class=WT;static image_processor_class=zD;static uses_processor_config=!0;async _call(e,t=null,n={}){let r=await this.image_processor(e,n);if(t){let[e,n]=r.pixel_values.dims.slice(-2),{image_token:i,image_break_token:a,image_end_token:o,patch_size:s,spatial_merge_size:c}=this.config,l=s*c,u=Math.floor(e/l),d=Math.floor(n/l);t=structuredClone(t),Array.isArray(t)||(t=[t]);for(let e=0;egpe(e,o)),c=s.map(e=>e.length),l=s.flat(),u=(await Promise.all(l.map(e=>this.feature_extractor(e,n)))).map(e=>e.input_features);r.audio_values=u.length>1?bw(u,0):u[0];let d=i[0];for(let e=0;e0){if(l>YS)throw Error(`The number of external data chunks (${l}) exceeds the maximum allowed value (${YS}).`);let t=rO(o,l);for(let n of t){let t=`${r.subfolder??``}/${n}`;c.push(new Promise(async(i,a)=>{let o=await fC(e,t,!0,r,s);i(o instanceof Uint8Array?{path:n,data:o}:n)}))}}else a.externalData!==void 0&&(c=a.externalData.map(async t=>{if(typeof t.data==`string`){let n=await fC(e,t.data,!0,r);return{...t,data:n}}return t}));return Promise.all(c)}async function Ope(e,t,n,r=!1,i=void 0){let a=n.config?.[`transformers.js_config`]??{},o=ew(n.device??a.device,t,{warn:e=>Wb.info(e)}),s=BC(o),c=a.device_config??{};c.hasOwnProperty(o)&&(a={...a,...c[o]});let l=ow(n.dtype??a.dtype,t,o,{configDtype:a.dtype,warn:e=>Wb.info(e)});if(!aw.hasOwnProperty(l))throw Error(`Invalid dtype: ${l}. Should be one of: ${Object.keys(nw).join(`, `)}`);if(o===`webgpu`&&!wb.IS_NODE_ENV&&l===nw.fp16&&!await tw())throw Error(`The device (${o}) does not support fp16.`);let u=aw[l],d={...n.session_options};d.executionProviders??=s;let f=a.free_dimension_overrides;f?d.freeDimensionOverrides??=f:o.startsWith(`webnn`)&&!d.freeDimensionOverrides&&Wb.warn(`WebNN does not currently support dynamic shapes and requires 'free_dimension_overrides' to be set in config.json, preferably as a field within config["transformers.js_config"]["device_config"]["${o}"]. When 'free_dimension_overrides' is not set, you may experience significant performance degradation.`);let p=Epe(e,t,n,u),m=await Dpe(e,t,u,n,n.use_external_data_format??a.use_external_data_format,d);if(m.length>0&&(!wb.IS_NODE_ENV||m.some(e=>typeof e!=`string`))&&(d.externalData=m),r&&o===`webgpu`){let e=$D(n.config,{prefix:`present`,session_name:i});if(e.size>0&&!YC()){let t={};for(let n of e)t[n]=`gpu-buffer`;d.preferredOutputLocation=t}}return{buffer_or_path:await p,session_options:d,session_config:{dtype:l,device:o}}}async function kpe(e,t,n,r=void 0){return Object.fromEntries(await Promise.all(Object.keys(t).map(async i=>{let a=r?.[i]??!1,{buffer_or_path:o,session_options:s,session_config:c}=await Ope(e,t[i],n,a,i);return[i,await WC(o,s,c)]})))}function iO(e){for(let t in e)qC(e[t])?e[t]=new L(e[t]):typeof e[t]==`object`&&iO(e[t]);return e}async function aO(e,t){let n=Ape(e,t);try{return iO(await KC(e,Object.fromEntries(Object.entries(n).map(([e,t])=>{let n=t.ort_tensor;return wb.IS_NODE_ENV&&typeof Float16Array<`u`&&n.cpuData instanceof Float16Array&&(n.cpuData=new Uint16Array(n.cpuData.buffer)),[e,n]}))))}catch(e){let t=Object.fromEntries(Object.entries(n).map(([e,t])=>{let n={type:t.type,dims:t.dims,location:t.location};return n.location!==`gpu-buffer`&&(n.data=t.data),[e,n]}));throw Wb.error(`An error occurred during model execution: "${e}".`),Wb.error(`Inputs given to model:`,t),e}}function Ape(e,t){let n=Object.create(null),r=[];for(let i of e.inputNames){let e=t[i];if(!(e instanceof L)){r.push(i);continue}n[i]=YC()?e.clone():e}if(r.length>0)throw Error(`An error occurred during model execution: "Missing the following inputs: ${r.join(`, `)}.`);let i=Object.keys(t).length,a=e.inputNames.length;if(i>a){let n=Object.keys(t).filter(t=>!e.inputNames.includes(t));Wb.warn(`WARNING: Too many inputs were provided (${i} > ${a}). The following inputs will be ignored: "${n.join(`, `)}".`)}return n}var oO=class{},sO=class extends oO{constructor({logits:e,...t}){super(),this.logits=e;let n=Object.values(t);n.length>0&&(this.attentions=n)}},cO=class extends oO{constructor({logits:e}){super(),this.logits=e}},lO=class extends oO{constructor({logits:e}){super(),this.logits=e}},uO=class extends oO{constructor({start_logits:e,end_logits:t}){super(),this.start_logits=e,this.end_logits=t}},dO=class extends oO{constructor({logits:e}){super(),this.logits=e}},jpe=class extends oO{constructor({alphas:e}){super(),this.alphas=e}},fO=class extends Nb{_call(e,t){throw Error("`_call` should be implemented in a subclass")}},Mpe=class extends Nb{_call(e,t){throw Error("`_call` should be implemented in a subclass")}},pO=class extends Nb{constructor(){super(),this.processors=[]}push(e){this.processors.push(e)}extend(e){this.processors.push(...e)}_call(e,t){let n=t;for(let t of this.processors)n=t(e,n);return n}[Symbol.iterator](){return this.processors.values()}},Npe=class extends fO{constructor(e){super(),this.bos_token_id=e}_call(e,t){for(let n=0;n=1&&i[i.length-1]>=this.timestamp_begin,o=i.length<2||i[i.length-2]>=this.timestamp_begin;if(a&&(o?r.subarray(this.timestamp_begin).fill(-1/0):r.subarray(0,this.eos_token_id).fill(-1/0)),e[n].length===this.begin_index&&this.max_initial_timestamp_index!==null){let e=this.timestamp_begin+this.max_initial_timestamp_index;r.subarray(e+1).fill(-1/0)}let s=Wde(r);Math.log(s.subarray(this.timestamp_begin).map(Math.exp).reduce((e,t)=>e+t))>_C(s.subarray(0,this.timestamp_begin))[0]&&r.subarray(0,this.timestamp_begin).fill(-1/0)}return t}},Lpe=class extends fO{constructor(e){super(),this.no_repeat_ngram_size=e}getNgrams(e){let t=e.length,n=[];for(let r=0;r1 to use the classifier free guidance processor, got guidance scale ${e}.`);this.guidance_scale=e}_call(e,t){if(t.dims[0]!==2*e.length)throw Error(`Logits should have twice the batch size of the input ids, the first half of batches corresponding to the conditional inputs, and the second half of batches corresponding to the unconditional inputs. Got batch size ${t.dims[0]} for the logits and ${e.length} for the input ids.`);let n=e.length,r=t.slice([0,n],null),i=t.slice([n,t.dims[0]],null);for(let e=0;ee.length>=this.max_length)}},Gpe=class extends gO{constructor(e){super(),Array.isArray(e)||(e=[e]),this.eos_token_id=e}_call(e,t){return e.map(e=>{let t=e.at(-1);return this.eos_token_id.some(e=>t==e)})}},Kpe=class extends gO{constructor(){super(),this.interrupted=!1}interrupt(){this.interrupted=!0}reset(){this.interrupted=!1}_call(e,t){return Array(e.length).fill(this.interrupted)}},vO=class extends Nb{constructor(e){super(),this.generation_config=e}async _call(e){return this.sample(e)}async sample(e){throw Error(`sample should be implemented in subclasses.`)}getLogits(e,t){let n=e.dims.at(-1),r=e.data;if(t===-1)r=r.slice(-n);else{let e=t*n;r=r.slice(e,e+n)}return r}randomSelect(e){return kde(e)}static getSampler(e){if(e.do_sample)return new Jpe(e);if(e.num_beams>1)return new Ype(e);if(e.num_return_sequences>1)throw Error(`num_return_sequences has to be 1 when doing greedy search, but is ${e.num_return_sequences}.`);return new qpe(e)}},qpe=class extends vO{async sample(e){let t=_C(e.data)[1];return[[BigInt(t),0]]}},Jpe=class extends vO{async sample(e){let t=e.dims.at(-1);this.generation_config.top_k>0&&(t=Math.min(this.generation_config.top_k,t));let[n,r]=await pw(e,t),i=hC(n.data);return Array.from({length:this.generation_config.num_beams},()=>{let e=this.randomSelect(i);return[r.data[e],Math.log(i[e])]})}},Ype=class extends vO{async sample(e){let t=e.dims.at(-1);this.generation_config.top_k>0&&(t=Math.min(this.generation_config.top_k,t));let[n,r]=await pw(e,t),i=hC(n.data);return Array.from({length:this.generation_config.num_beams},(e,t)=>[r.data[t],Math.log(i[t])])}},yO=class{constructor(e){if(e)for(let t in e){if(t in this)throw TypeError(`Key "${t}" conflicts with an existing property on DynamicCache`);let n=e[t];if(!(n instanceof L))throw TypeError(`Expected a Tensor for key "${t}", got ${typeof n}`);this[t]=n}}get_seq_length(){let e=this;if(Object.keys(e).length===0)return 0;for(let t in e)if(t.startsWith(`past_key_values.`))return e[t].dims.at(-2);throw Error(`Unable to determine sequence length from the cache.`)}update(e){for(let t in e){let n=this[t],r=e[t];n&&n!==r&&n.location===`gpu-buffer`&&n.dispose(),this[t]=r}}async dispose(){let e=[];for(let t of Object.values(this))t.location===`gpu-buffer`&&e.push(t.dispose());await Promise.all(e)}},R={EncoderOnly:0,EncoderDecoder:1,Seq2Seq:2,Vision2Seq:3,DecoderOnly:4,DecoderOnlyWithoutHead:5,MaskGeneration:6,ImageTextToText:7,Musicgen:8,MultiModality:9,Phi3V:10,AudioTextToText:11,AutoEncoder:12,ImageAudioTextToText:13,Supertonic:14,Chatterbox:15,VoxtralRealtime:16},bO={[R.DecoderOnly]:{sessions:(e,t)=>({model:t.model_file_name??`model`}),cache_sessions:{model:!0},optional_configs:{generation_config:`generation_config.json`}},[R.DecoderOnlyWithoutHead]:{sessions:(e,t)=>({model:t.model_file_name??`model`})},[R.Seq2Seq]:{sessions:()=>({model:`encoder_model`,decoder_model_merged:`decoder_model_merged`}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:`generation_config.json`}},[R.Vision2Seq]:{sessions:()=>({model:`encoder_model`,decoder_model_merged:`decoder_model_merged`}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:`generation_config.json`}},[R.Musicgen]:{sessions:()=>({model:`text_encoder`,decoder_model_merged:`decoder_model_merged`,encodec_decode:`encodec_decode`}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:`generation_config.json`}},[R.EncoderDecoder]:{sessions:()=>({model:`encoder_model`,decoder_model_merged:`decoder_model_merged`}),cache_sessions:{decoder_model_merged:!0}},[R.MaskGeneration]:{sessions:()=>({model:`vision_encoder`,prompt_encoder_mask_decoder:`prompt_encoder_mask_decoder`})},[R.ImageTextToText]:{text_only_sessions:{embed_tokens:`embed_tokens`,decoder_model_merged:`decoder_model_merged`},sessions:(e,t,n)=>{let r={...bO[R.ImageTextToText].text_only_sessions};return n||(r.vision_encoder=`vision_encoder`),e.is_encoder_decoder&&(r.model=`encoder_model`),r},cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:`generation_config.json`}},[R.AudioTextToText]:{text_only_sessions:{embed_tokens:`embed_tokens`,decoder_model_merged:`decoder_model_merged`},sessions:(e,t,n)=>{let r={...bO[R.AudioTextToText].text_only_sessions};return n||(r.audio_encoder=`audio_encoder`),r},cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:`generation_config.json`}},[R.ImageAudioTextToText]:{text_only_sessions:{embed_tokens:`embed_tokens`,decoder_model_merged:`decoder_model_merged`},sessions:(e,t,n)=>{let r={...bO[R.ImageAudioTextToText].text_only_sessions};return n||(r.audio_encoder=`audio_encoder`,r.vision_encoder=`vision_encoder`),r},optional_configs:{generation_config:`generation_config.json`}},[R.Phi3V]:{sessions:()=>({prepare_inputs_embeds:`prepare_inputs_embeds`,model:`model`,vision_encoder:`vision_encoder`}),cache_sessions:{model:!0},optional_configs:{generation_config:`generation_config.json`}},[R.MultiModality]:{sessions:()=>({prepare_inputs_embeds:`prepare_inputs_embeds`,model:`language_model`,lm_head:`lm_head`,gen_head:`gen_head`,gen_img_embeds:`gen_img_embeds`,image_decode:`image_decode`}),cache_sessions:{model:!0},optional_configs:{generation_config:`generation_config.json`}},[R.AutoEncoder]:{sessions:()=>({encoder_model:`encoder_model`,decoder_model:`decoder_model`})},[R.Supertonic]:{sessions:()=>({text_encoder:`text_encoder`,latent_denoiser:`latent_denoiser`,voice_decoder:`voice_decoder`})},[R.Chatterbox]:{sessions:()=>({embed_tokens:`embed_tokens`,speech_encoder:`speech_encoder`,model:`language_model`,conditional_decoder:`conditional_decoder`}),cache_sessions:{model:!0},optional_configs:{generation_config:`generation_config.json`}},[R.VoxtralRealtime]:{text_only_sessions:{embed_tokens:`embed_tokens`,decoder_model_merged:`decoder_model_merged`},sessions:(e,t,n)=>{let r={...bO[R.VoxtralRealtime].text_only_sessions};return n||(r.audio_encoder=`audio_encoder`),r},cache_sessions:{decoder_model_merged:!0,audio_encoder:!0},optional_configs:{generation_config:`generation_config.json`}},default:{sessions:(e,t)=>({model:t.model_file_name??`model`})}};function Xpe(e,t,n={}){let r=bO[e]??bO.default;return{sessions:r.sessions(t,n,n.textOnly??!1),cache_sessions:r.cache_sessions,optional_configs:r.optional_configs}}function Zpe(e,{warn:t=!0}={}){let n=e.architectures||[];for(let e of n){let t=EO.get(e);if(t!==void 0)return t}if(e.model_type){let t=EO.get(e.model_type);if(t!==void 0)return t;for(let t of Object.values(xO))if(t.has(e.model_type)){let n=EO.get(t.get(e.model_type));if(n!==void 0)return n}}if(t){let t=n.length>0?n.join(`, `):`(none)`;Wb.warn(`[resolve_model_type] Architecture(s) not found in MODEL_TYPE_MAPPING: [${t}] for model type '${e.model_type}'. Falling back to EncoderOnly (single model.onnx file). If you encounter issues, please report at: ${GT}`)}return R.EncoderOnly}function Qpe(e,{config:t=null,cache_dir:n=null,local_files_only:r=!1,revision:i=`main`}={}){return t===null?aC(JSON.stringify([e,n,r,i]),()=>tO.from_pretrained(e,{config:t,cache_dir:n,local_files_only:r,revision:i})):tO.from_pretrained(e,{config:t,cache_dir:n,local_files_only:r,revision:i})}async function $pe(e,{config:t=null,dtype:n=null,device:r=null,model_file_name:i=null}={}){t=await Qpe(e,{config:t});let a=[`config.json`],o=t[`transformers.js_config`]??{},s=o.use_external_data_format,c=`onnx`,l=r??o.device,u=n??o.dtype,d=Zpe(t),f=(e,t=null)=>{t??=e;let n=ew(l,e),r=aw[ow(u,e,n)]??``,i=`${t}${r}.onnx`,o=`${c}/${i}`;a.push(o);let d=nO(s,i,e);for(let e of rO(i,d)){let t=`${c}/${e}`;a.push(t)}},{sessions:p,optional_configs:m}=Xpe(d,t,{model_file_name:i});for(let[e,t]of Object.entries(p))f(e,t);if(m)for(let e of Object.values(m))a.push(e);return a}var xO=null;function eme(e){xO=e}function SO(e){if(e instanceof L)return e;if(e.length===0)throw Error(`items must be non-empty`);if(Array.isArray(e[0])){if(e.some(t=>t.length!==e[0].length))throw Error(`Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' and/or 'truncation=True' to have batched tensors with the same length.`);return new L(`int64`,BigInt64Array.from(e.flat().map(e=>BigInt(e))),[e.length,e[0].length])}return new L(`int64`,BigInt64Array.from(e.map(e=>BigInt(e))),[1,e.length])}function CO(e){return new L(`bool`,[e],[1])}var wO={[R.DecoderOnly]:{can_generate:!0,forward:PO,prepare_inputs:LO},[R.DecoderOnlyWithoutHead]:{can_generate:!1,forward:PO,prepare_inputs:LO},[R.Seq2Seq]:{can_generate:!0,forward:kO,prepare_inputs:RO},[R.Vision2Seq]:{can_generate:!0,forward:kO,prepare_inputs:RO},[R.Musicgen]:{can_generate:!0,forward:kO},[R.EncoderDecoder]:{can_generate:!1,forward:kO},[R.ImageTextToText]:{can_generate:!0,forward:ime,prepare_inputs:zO},[R.AudioTextToText]:{can_generate:!0,forward:rme,prepare_inputs:zO},[R.ImageAudioTextToText]:{can_generate:!0,prepare_inputs:zO},[R.Phi3V]:{can_generate:!0,prepare_inputs:zO},[R.MultiModality]:{can_generate:!0},[R.AutoEncoder]:{can_generate:!1,forward:tme},[R.Chatterbox]:{can_generate:!0,forward:AO},[R.VoxtralRealtime]:{can_generate:!0,prepare_inputs:LO},default:{can_generate:!1,forward:AO}};function TO(e,t){let n=EO.get(e),r=!1,i=t?.architectures?.[0];if(i&&i!==e&&e?.endsWith(`ForCausalLM`)&&i.endsWith(`ForConditionalGeneration`)){let e=EO.get(i);e!==void 0&&(n=e,r=!0)}let a=wO[n]??wO.default,o=bO[n]??bO.default;return{typeConfig:{...a,...o},textOnly:r,modelType:n}}var EO=new Map,DO=new Map,OO=new Map,z=class extends Nb{main_input_name=`input_ids`;forward_params=[`input_ids`,`attention_mask`];_return_dict_in_generate_keys=null;constructor(e,t,n){super(),this.config=e,this.sessions=t,this.configs=n;let{typeConfig:r}=TO(OO.get(this.constructor),e);this.can_generate=r.can_generate,this._forward=r.forward,this._prepare_inputs_for_generation=r.prepare_inputs,this.can_generate&&this.forward_params.push(`past_key_values`),this.custom_config=this.config[`transformers.js_config`]??{}}async dispose(){let e=[];for(let t of Object.values(this.sessions))e.push(t.release?.());return await Promise.all(e)}static async from_pretrained(e,{progress_callback:t=null,config:n=null,cache_dir:r=null,local_files_only:i=!1,revision:a=`main`,model_file_name:o=null,subfolder:s=`onnx`,device:c=null,dtype:l=null,use_external_data_format:u=null,session_options:d={}}={}){let f={progress_callback:t,config:n,cache_dir:r,local_files_only:i,revision:a,model_file_name:o,subfolder:s,device:c,dtype:l,use_external_data_format:u,session_options:d},p=OO.get(this);n=f.config=await tO.from_pretrained(e,f);let{typeConfig:m,textOnly:h,modelType:g}=TO(p,n);if(g===void 0){let e=p??n?.model_type;e!==`custom`&&Wb.warn(`Model type for '${e}' not found, assuming encoder-only architecture. Please report this at ${GT}.`)}if(t&&!(t instanceof Fb)){let r={};try{let t=await $pe(e,{config:n,dtype:l,device:c,model_file_name:o});(await Promise.all(t.map(t=>oC(e,t,f)))).forEach((e,n)=>{if(e.exists){let i=t[n]===`config.json`;r[t[n]]={loaded:i?e.size??0:0,total:e.size??0}}})}catch(e){Wb.warn(`Unable to fetch model file metadata for total progress tracking: ${e}`)}Object.keys(r).length>0&&(f.progress_callback=new Fb(t,r))}let _=[kpe(e,m.sessions(n,f,h),f,m.cache_sessions)];m.optional_configs&&_.push(ome(e,m.optional_configs,f));let v=await Promise.all(_);return new this(n,...v)}async _call(e){return await this.forward(e)}async forward(e){return await this._forward(this,e)}get generation_config(){return this.configs?.generation_config??null}_get_logits_processor(e,t,n=null){let r=new pO;if(e.repetition_penalty!==null&&e.repetition_penalty!==1&&r.push(new Rpe(e.repetition_penalty)),e.no_repeat_ngram_size!==null&&e.no_repeat_ngram_size>0&&r.push(new Lpe(e.no_repeat_ngram_size)),e.bad_words_ids!==null&&r.push(new Vpe(e.bad_words_ids,e.eos_token_id)),e.min_length!==null&&e.eos_token_id!==null&&e.min_length>0&&r.push(new zpe(e.min_length,e.eos_token_id)),e.min_new_tokens!==null&&e.eos_token_id!==null&&e.min_new_tokens>0&&r.push(new Bpe(t,e.min_new_tokens,e.eos_token_id)),e.forced_bos_token_id!==null&&r.push(new Npe(e.forced_bos_token_id)),e.forced_eos_token_id!==null&&r.push(new Ppe(e.max_length,e.forced_eos_token_id)),e.suppress_tokens!==null&&r.push(new Fpe(e.suppress_tokens)),e.begin_suppress_tokens!==null){let n=t>1||e.forced_bos_token_id===null?t:t+1;r.push(new mO(e.begin_suppress_tokens,n))}return e.guidance_scale!==null&&e.guidance_scale>1&&r.push(new Hpe(e.guidance_scale)),e.temperature===0&&e.do_sample&&(Wb.warn("`do_sample` changed to false because `temperature: 0` implies greedy sampling (always selecting the most likely token), which is incompatible with `do_sample: true`."),e.do_sample=!1),e.do_sample&&e.temperature!==null&&e.temperature!==1&&r.push(new Upe(e.temperature)),n!==null&&r.extend(n),r}_prepare_generation_config(e,t,n=hO){let r={...this.config};for(let e of[`decoder`,`generator`,`text_config`])e in r&&Object.assign(r,r[e]);let i=new n(r);return Object.assign(i,this.generation_config??{}),e&&Object.assign(i,e),t&&Object.assign(i,Hb(t,Object.getOwnPropertyNames(i))),i}_get_stopping_criteria(e,t=null){let n=new _O;return e.max_length!==null&&n.push(new Wpe(e.max_length,this.config.max_position_embeddings??null)),e.eos_token_id!==null&&n.push(new Gpe(e.eos_token_id)),t&&n.extend(t),n}_validate_model_class(){if(!this.can_generate){let e=[xO.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES,xO.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES,xO.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES,xO.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES].filter(Boolean),t=OO.get(this.constructor),n=new Set,r=this.config.model_type;for(let t of e){let e=t?.get(r);e&&n.add(e)}let i=`The current model class (${t}) is not compatible with \`.generate()\`, as it doesn't have a language model head.`;throw n.size>0&&(i+=` Please use the following class instead: ${[...n].join(`, `)}`),Error(i)}}prepare_inputs_for_generation(...e){if(!this._prepare_inputs_for_generation)throw Error(`prepare_inputs_for_generation is not implemented for this model.`);return this._prepare_inputs_for_generation(this,...e)}_update_model_kwargs_for_generation({generated_input_ids:e,outputs:t,model_inputs:n,is_encoder_decoder:r}){return n.past_key_values=jO(t,n.past_key_values),n.input_ids=new L(`int64`,e.flat(),[e.length,1]),r?`decoder_attention_mask`in n&&(n.decoder_attention_mask=bw([n.decoder_attention_mask,kw([n.decoder_attention_mask.dims[0],1])],1)):n.attention_mask=bw([n.attention_mask,kw([n.attention_mask.dims[0],1])],1),n.position_ids=null,n}_prepare_model_inputs({inputs:e,bos_token_id:t,model_kwargs:n}){let r=Hb(n,this.forward_params),i=this.main_input_name;if(i in r){if(e)throw Error("`inputs`: {inputs}` were passed alongside {input_name} which is not allowed. Make sure to either pass {inputs} or {input_name}=...")}else r[i]=e;return{inputs_tensor:r[i],model_inputs:r,model_input_name:i}}async _prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:e,model_inputs:t,model_input_name:n,generation_config:r}){if(this.sessions.model.inputNames.includes(`inputs_embeds`)&&!t.inputs_embeds&&`_prepare_inputs_embeds`in this){let{input_ids:e,pixel_values:n,attention_mask:r,...i}=t,a=await this._prepare_inputs_embeds(t);t={...i,...Hb(a,[`inputs_embeds`,`attention_mask`])}}let{last_hidden_state:i}=await AO(this,t);if(r.guidance_scale!==null&&r.guidance_scale>1)i=bw([i,Ow(i,0)],0),`attention_mask`in t&&(t.attention_mask=bw([t.attention_mask,Mw(t.attention_mask)],0));else if(t.decoder_input_ids){let e=SO(t.decoder_input_ids).dims[0];if(e!==i.dims[0]){if(i.dims[0]!==1)throw Error(`The encoder outputs have a different batch size (${i.dims[0]}) than the decoder inputs (${e}).`);i=bw(Array.from({length:e},()=>i),0)}}return t.encoder_outputs=i,t}_prepare_decoder_input_ids_for_generation({batch_size:e,model_input_name:t,model_kwargs:n,decoder_start_token_id:r,bos_token_id:i,generation_config:a}){let{decoder_input_ids:o,...s}=n;if(!(o instanceof L)){if(o)Array.isArray(o[0])||(o=Array.from({length:e},()=>o));else if(r??=i,this.config.model_type===`musicgen`)o=Array.from({length:e*this.config.decoder.num_codebooks},()=>[r]);else if(Array.isArray(r)){if(r.length!==e)throw Error(`\`decoder_start_token_id\` expcted to have length ${e} but got ${r.length}`);o=r}else o=Array.from({length:e},()=>[r]);o=SO(o)}return s.decoder_attention_mask=Aw(o),{input_ids:o,model_inputs:s}}async generate({inputs:e=null,generation_config:t=null,logits_processor:n=null,stopping_criteria:r=null,streamer:i=null,...a}){this._validate_model_class(),t=this._prepare_generation_config(t,a);let{inputs_tensor:o,model_inputs:s,model_input_name:c}=this._prepare_model_inputs({inputs:e,model_kwargs:a}),l=this.config.is_encoder_decoder;l&&(`encoder_outputs`in s||(s=await this._prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:o,model_inputs:s,model_input_name:c,generation_config:t})));let u;l?{input_ids:u,model_inputs:s}=this._prepare_decoder_input_ids_for_generation({batch_size:s[c].dims.at(0),model_input_name:c,model_kwargs:s,decoder_start_token_id:t.decoder_start_token_id,bos_token_id:t.bos_token_id,generation_config:t}):u=s[c];let d=u.dims.at(-1);t.max_new_tokens!==null&&(t.max_length=d+t.max_new_tokens);let f=this._get_logits_processor(t,d,n),p=this._get_stopping_criteria(t,r),m=s[c].dims.at(0),h=vO.getSampler(t),g=Array(m).fill(0),_=u.tolist();i&&i.put(_);let v,y={},b={};for(;;){if(s=this.prepare_inputs_for_generation(_,s,t),v=await this.forward(s),t.return_dict_in_generate){if(t.output_attentions){let e=nme(v);for(let t in e)t in y||(y[t]=[]),y[t].push(e[t])}else this._return_dict_in_generate_keys&&Object.assign(b,Hb(v,this._return_dict_in_generate_keys))}let e=f(_,v.logits.slice(null,-1,null).to(`float32`)),n=[];for(let t=0;te))break;s=this._update_model_kwargs_for_generation({generated_input_ids:n,outputs:v,model_inputs:s,is_encoder_decoder:l})}i&&i.end();let x=new L(`int64`,_.flat(),[_.length,_[0].length]),S=jO(v,s.past_key_values),C=new Set(Object.values(S));for(let e of Object.values(v))e.location===`gpu-buffer`&&!C.has(e)&&e.dispose();return`past_key_values`in a||t.return_dict_in_generate||await S.dispose(),t.return_dict_in_generate?{sequences:x,past_key_values:S,...y,...b}:x}async _encode_input(e,t,n){if(!Object.hasOwn(this.sessions,e))throw Error(`Model does not have a ${e} session.`);let r=this.sessions[e];return(await aO(r,Hb(t,r.inputNames)))[n]}async encode_image(e){return this._encode_input(`vision_encoder`,e,`image_features`)}async encode_text(e){return this._encode_input(`embed_tokens`,e,`inputs_embeds`)}async encode_audio(e){return this._encode_input(`audio_encoder`,e,`audio_features`)}};async function kO(e,t){let{encoder_outputs:n,input_ids:r,decoder_input_ids:i,decoder_attention_mask:a,...o}=t;return n||=(await AO(e,Hb(t,e.sessions.model.inputNames))).last_hidden_state,o.input_ids=i,o.encoder_hidden_states=n,e.sessions.decoder_model_merged.inputNames.includes(`encoder_attention_mask`)&&(o.encoder_attention_mask=t.attention_mask),a&&!o.attention_mask&&(o.attention_mask=a),await PO(e,o,!0)}async function AO(e,t){let n=e.sessions.model,r=Hb(t,n.inputNames);if(n.inputNames.includes(`inputs_embeds`)&&!r.inputs_embeds){if(!t.input_ids)throw Error("Both `input_ids` and `inputs_embeds` are missing in the model inputs.");r.inputs_embeds=await e.encode_text({input_ids:t.input_ids})}if(n.inputNames.includes(`token_type_ids`)&&!r.token_type_ids){if(!r.input_ids)throw Error("Both `input_ids` and `token_type_ids` are missing in the model inputs.");r.token_type_ids=Mw(r.input_ids)}if(n.inputNames.includes(`pixel_mask`)&&!r.pixel_mask){if(!r.pixel_values)throw Error("Both `pixel_values` and `pixel_mask` are missing in the model inputs.");let e=r.pixel_values.dims;r.pixel_mask=kw([e[0],e[2],e[3]])}return await aO(n,r)}async function tme(e,t){let n=await e.encode(t);return await e.decode(n)}function jO(e,t){let n=Object.create(null);for(let r in e)if(r.startsWith(`present`)){let i=r.replace(`present_ssm`,`past_ssm`).replace(`present_conv`,`past_conv`).replace(`present_recurrent`,`past_recurrent`).replace(`present`,`past_key_values`);n[i]=r.includes(`encoder`)&&t?t[i]:e[r]}return t?(t.update(n),t):new yO(n)}function nme(e){let t={};for(let n of[`cross_attentions`,`encoder_attentions`,`decoder_attentions`])for(let r in e)r.startsWith(n)&&(n in t||(t[n]=[]),t[n].push(e[r]));return t}function MO(e,t){return e.map(e=>typeof e==`number`?e:t[e]??0)}function NO(e,t,n){if(n&&Object.keys(n).length>0)return Object.assign(t,n),n;let r=e.sessions.decoder_model_merged??e.sessions.model,i=(t[e.main_input_name]??t.attention_mask)?.dims?.[0]??1,a=$D(e.config),o=e.config?.normalized_config?.num_heads,s={batch_size:i};typeof o==`number`&&(s[`batch_size x num_heads`]=i*o);let c=Object.create(null);for(let e of r.inputMetadata){if(!a.has(e.name))continue;let n=MO(e.shape,s),r=n.reduce((e,t)=>e*t,1),i=sw[e.type],o=new L(e.type,new i(r),n);t[e.name]=o,c[e.name]=o}return n?(n.update(c),n):new yO(c)}async function PO(e,t,n=!1){let r=e.sessions[n?`decoder_model_merged`:`model`],{past_key_values:i,...a}=t;return r.inputNames.includes(`use_cache_branch`)&&(a.use_cache_branch=CO(i!=null&&Object.keys(i).length>0)),r.inputNames.includes(`position_ids`)&&a.attention_mask&&!a.position_ids&&(a.position_ids=ame(a,i,+!![`paligemma`,`gemma3_text`,`gemma3`].includes(e.config.model_type))),r.inputNames.includes(`num_logits_to_keep`)&&!a.num_logits_to_keep&&(a.num_logits_to_keep=new L(`int64`,[0n],[])),NO(e,a,i),await aO(r,Hb(a,r.inputNames))}async function FO(e,{encode_function:t,merge_function:n,modality_input_names:r,modality_output_name:i,input_ids:a=null,attention_mask:o=null,position_ids:s=null,inputs_embeds:c=null,past_key_values:l=null,generation_config:u=null,logits_processor:d=null,...f}){if(!c){c=await e.encode_text({input_ids:a,...f});let s=Hb(f,r);if(Object.keys(s).length>0){if(a.dims[1]!==1){let e=await t({...s,...f});({inputs_embeds:c,attention_mask:o}=n({[i]:e,inputs_embeds:c,input_ids:a,attention_mask:o}))}else if(l&&a.dims[1]===1){let e=a.dims[1],t=l.get_seq_length();o=bw([kw([a.dims[0],t]),o.slice(null,[o.dims[1]-e,o.dims[1]])],1)}}}if(!s&&[`qwen2_vl`,`qwen2_vl_text`,`qwen2_5_vl`,`qwen2_5_vl_text`,`qwen3_vl`,`qwen3_vl_text`,`qwen3_vl_moe`,`qwen3_vl_moe_text`,`qwen3_5`,`qwen3_5_text`,`qwen3_5_moe`,`qwen3_5_moe_text`,`glm_ocr`,`glm_ocr_text`].includes(e.config.model_type)){let{image_grid_thw:t,video_grid_thw:n}=f;[s]=e.get_rope_index(a,t,n,o)}return await PO(e,{inputs_embeds:c,past_key_values:l,attention_mask:o,position_ids:s,generation_config:u,logits_processor:d},!0)}async function rme(e,t){return await FO(e,{...t,modality_input_names:[`audio_values`,`input_features`],modality_output_name:`audio_features`,encode_function:e.encode_audio.bind(e),merge_function:e._merge_input_ids_with_audio_features.bind(e)})}async function ime(e,t){return await FO(e,{...t,modality_input_names:[`pixel_values`],modality_output_name:`image_features`,encode_function:e.encode_image.bind(e),merge_function:e._merge_input_ids_with_image_features.bind(e)})}function IO(e,t=0){let[n,r]=e.dims,i=e.data,a=new BigInt64Array(i.length);for(let e=0;ee.dims[1]||i[e.at(-1)])),{...n,decoder_input_ids:SO(t)}}function zO(e,...t){return e.config.is_encoder_decoder?RO(e,...t):LO(e,...t)}function BO({modality_token_id:e,inputs_embeds:t,modality_features:n,input_ids:r,attention_mask:i}){let a=r.tolist().map(t=>t.reduce((t,n,r)=>(n==e&&t.push(r),t),[])),o=a.reduce((e,t)=>e+t.length,0),s=n.dims[0];if(o!==s)throw Error(`Number of tokens and features do not match: tokens: ${o}, features ${s}`);let c=0;for(let e=0;e[r,await mC(e,t[r],!1,n)])))}var UO={};fb(UO,{ASTForAudioClassification:()=>vme,ASTModel:()=>_me,ASTPreTrainedModel:()=>JO,AfmoeForCausalLM:()=>mme,AfmoeModel:()=>pme,AfmoePreTrainedModel:()=>KO,AlbertForMaskedLM:()=>ume,AlbertForQuestionAnswering:()=>lme,AlbertForSequenceClassification:()=>cme,AlbertModel:()=>sme,AlbertPreTrainedModel:()=>WO,ApertusForCausalLM:()=>fme,ApertusModel:()=>dme,ApertusPreTrainedModel:()=>GO,ArceeForCausalLM:()=>gme,ArceeModel:()=>hme,ArceePreTrainedModel:()=>qO,BartForConditionalGeneration:()=>bme,BartForSequenceClassification:()=>xme,BartModel:()=>yme,BartPretrainedModel:()=>YO,BeitForImageClassification:()=>Cme,BeitModel:()=>Sme,BeitPreTrainedModel:()=>XO,BertForMaskedLM:()=>Tme,BertForQuestionAnswering:()=>Ome,BertForSequenceClassification:()=>Eme,BertForTokenClassification:()=>Dme,BertModel:()=>wme,BertPreTrainedModel:()=>ZO,BlenderbotForConditionalGeneration:()=>Ame,BlenderbotModel:()=>kme,BlenderbotPreTrainedModel:()=>QO,BlenderbotSmallForConditionalGeneration:()=>Mme,BlenderbotSmallModel:()=>jme,BlenderbotSmallPreTrainedModel:()=>$O,BloomForCausalLM:()=>Pme,BloomModel:()=>Nme,BloomPreTrainedModel:()=>ek,CHMv2ForDepthEstimation:()=>Hme,CHMv2PreTrainedModel:()=>ok,CLIPModel:()=>Wme,CLIPPreTrainedModel:()=>uk,CLIPSegForImageSegmentation:()=>Yme,CLIPSegModel:()=>Jme,CLIPSegPreTrainedModel:()=>fk,CLIPTextModel:()=>Gme,CLIPTextModelWithProjection:()=>dk,CLIPVisionModel:()=>Kme,CLIPVisionModelWithProjection:()=>qme,CamembertForMaskedLM:()=>Ime,CamembertForQuestionAnswering:()=>zme,CamembertForSequenceClassification:()=>Lme,CamembertForTokenClassification:()=>Rme,CamembertModel:()=>Fme,CamembertPreTrainedModel:()=>tk,ChatterboxModel:()=>ik,ChatterboxPreTrainedModel:()=>rk,ChineseCLIPModel:()=>Vme,ChineseCLIPPreTrainedModel:()=>ak,ClapAudioModelWithProjection:()=>lk,ClapModel:()=>Ume,ClapPreTrainedModel:()=>sk,ClapTextModelWithProjection:()=>ck,CodeGenForCausalLM:()=>Zme,CodeGenModel:()=>Xme,CodeGenPreTrainedModel:()=>pk,Cohere2ForCausalLM:()=>the,Cohere2Model:()=>ehe,Cohere2PreTrainedModel:()=>hk,CohereAsrForConditionalGeneration:()=>rhe,CohereAsrModel:()=>nhe,CohereAsrPreTrainedModel:()=>gk,CohereForCausalLM:()=>$me,CohereModel:()=>Qme,CoherePreTrainedModel:()=>mk,ConvBertForMaskedLM:()=>ahe,ConvBertForQuestionAnswering:()=>che,ConvBertForSequenceClassification:()=>ohe,ConvBertForTokenClassification:()=>she,ConvBertModel:()=>ihe,ConvBertPreTrainedModel:()=>_k,ConvNextForImageClassification:()=>uhe,ConvNextModel:()=>lhe,ConvNextPreTrainedModel:()=>vk,ConvNextV2ForImageClassification:()=>fhe,ConvNextV2Model:()=>dhe,ConvNextV2PreTrainedModel:()=>yk,DFineForObjectDetection:()=>ghe,DFineModel:()=>hhe,DFinePreTrainedModel:()=>Sk,DINOv3ConvNextModel:()=>Hhe,DINOv3ConvNextPreTrainedModel:()=>Bk,DINOv3ViTModel:()=>Uhe,DINOv3ViTPreTrainedModel:()=>Vk,DPTForDepthEstimation:()=>Zhe,DPTModel:()=>Xhe,DPTPreTrainedModel:()=>Wk,DacDecoderModel:()=>Dk,DacDecoderOutput:()=>wk,DacEncoderModel:()=>Ek,DacEncoderOutput:()=>Ck,DacModel:()=>_he,DacPreTrainedModel:()=>Tk,DebertaForMaskedLM:()=>yhe,DebertaForQuestionAnswering:()=>She,DebertaForSequenceClassification:()=>bhe,DebertaForTokenClassification:()=>xhe,DebertaModel:()=>vhe,DebertaPreTrainedModel:()=>Ok,DebertaV2ForMaskedLM:()=>Ehe,DebertaV2ForQuestionAnswering:()=>khe,DebertaV2ForSequenceClassification:()=>Dhe,DebertaV2ForTokenClassification:()=>Ohe,DebertaV2Model:()=>The,DebertaV2PreTrainedModel:()=>Ak,DecisionTransformerModel:()=>Ahe,DecisionTransformerPreTrainedModel:()=>jk,DeepseekV3ForCausalLM:()=>whe,DeepseekV3Model:()=>Che,DeepseekV3PreTrainedModel:()=>kk,DeiTForImageClassification:()=>Mhe,DeiTModel:()=>jhe,DeiTPreTrainedModel:()=>Mk,DepthAnythingForDepthEstimation:()=>Nhe,DepthAnythingPreTrainedModel:()=>Nk,DepthProForDepthEstimation:()=>Phe,DepthProPreTrainedModel:()=>Pk,DetrForObjectDetection:()=>Ihe,DetrForSegmentation:()=>Lhe,DetrModel:()=>Fhe,DetrObjectDetectionOutput:()=>Ik,DetrPreTrainedModel:()=>Fk,DetrSegmentationOutput:()=>Lk,Dinov2ForImageClassification:()=>zhe,Dinov2Model:()=>Rhe,Dinov2PreTrainedModel:()=>Rk,Dinov2WithRegistersForImageClassification:()=>Vhe,Dinov2WithRegistersModel:()=>Bhe,Dinov2WithRegistersPreTrainedModel:()=>zk,DistilBertForMaskedLM:()=>Jhe,DistilBertForQuestionAnswering:()=>qhe,DistilBertForSequenceClassification:()=>Ghe,DistilBertForTokenClassification:()=>Khe,DistilBertModel:()=>Whe,DistilBertPreTrainedModel:()=>Hk,DonutSwinModel:()=>Yhe,DonutSwinPreTrainedModel:()=>Uk,EdgeTamModel:()=>cbe,EfficientNetForImageClassification:()=>$he,EfficientNetModel:()=>Qhe,EfficientNetPreTrainedModel:()=>Gk,ElectraForMaskedLM:()=>tge,ElectraForQuestionAnswering:()=>ige,ElectraForSequenceClassification:()=>nge,ElectraForTokenClassification:()=>rge,ElectraModel:()=>ege,ElectraPreTrainedModel:()=>Kk,Ernie4_5ForCausalLM:()=>oge,Ernie4_5Model:()=>age,Ernie4_5PretrainedModel:()=>qk,EsmForMaskedLM:()=>cge,EsmForSequenceClassification:()=>lge,EsmForTokenClassification:()=>uge,EsmModel:()=>sge,EsmPreTrainedModel:()=>Jk,EuroBertForMaskedLM:()=>fge,EuroBertForSequenceClassification:()=>pge,EuroBertForTokenClassification:()=>mge,EuroBertModel:()=>dge,EuroBertPreTrainedModel:()=>Yk,ExaoneForCausalLM:()=>gge,ExaoneModel:()=>hge,ExaonePreTrainedModel:()=>Xk,FalconForCausalLM:()=>vge,FalconH1ForCausalLM:()=>bge,FalconH1Model:()=>yge,FalconH1PreTrainedModel:()=>Qk,FalconModel:()=>_ge,FalconPreTrainedModel:()=>Zk,FastViTForImageClassification:()=>Sge,FastViTModel:()=>xge,FastViTPreTrainedModel:()=>$k,Florence2ForConditionalGeneration:()=>Cge,Florence2PreTrainedModel:()=>eA,GLPNForDepthEstimation:()=>Bge,GLPNModel:()=>zge,GLPNPreTrainedModel:()=>_A,GPT2LMHeadModel:()=>Xge,GPT2Model:()=>Yge,GPT2PreTrainedModel:()=>SA,GPTBigCodeForCausalLM:()=>Hge,GPTBigCodeModel:()=>Vge,GPTBigCodePreTrainedModel:()=>vA,GPTJForCausalLM:()=>Qge,GPTJModel:()=>Zge,GPTJPreTrainedModel:()=>CA,GPTNeoForCausalLM:()=>Wge,GPTNeoModel:()=>Uge,GPTNeoPreTrainedModel:()=>yA,GPTNeoXForCausalLM:()=>Kge,GPTNeoXModel:()=>Gge,GPTNeoXPreTrainedModel:()=>bA,Gemma2ForCausalLM:()=>Dge,Gemma2Model:()=>Ege,Gemma2PreTrainedModel:()=>nA,Gemma3ForCausalLM:()=>jge,Gemma3ForConditionalGeneration:()=>oA,Gemma3Model:()=>Age,Gemma3PreTrainedModel:()=>aA,Gemma3nForCausalLM:()=>Mge,Gemma3nForConditionalGeneration:()=>cA,Gemma3nPreTrainedModel:()=>sA,Gemma4ForCausalLM:()=>Nge,Gemma4ForConditionalGeneration:()=>lA,GemmaForCausalLM:()=>Tge,GemmaModel:()=>wge,GemmaPreTrainedModel:()=>tA,GlmForCausalLM:()=>Fge,GlmModel:()=>Pge,GlmMoeDsaForCausalLM:()=>Lge,GlmMoeDsaModel:()=>Ige,GlmMoeDsaPreTrainedModel:()=>dA,GlmOcrForConditionalGeneration:()=>Rge,GlmPreTrainedModel:()=>uA,GptOssForCausalLM:()=>Jge,GptOssModel:()=>qge,GptOssPreTrainedModel:()=>xA,GraniteForCausalLM:()=>e_e,GraniteModel:()=>$ge,GraniteMoeHybridForCausalLM:()=>n_e,GraniteMoeHybridModel:()=>t_e,GraniteMoeHybridPreTrainedModel:()=>TA,GranitePreTrainedModel:()=>wA,GraniteSpeechForConditionalGeneration:()=>r_e,GroundingDinoForObjectDetection:()=>i_e,GroundingDinoPreTrainedModel:()=>OA,GroupViTModel:()=>a_e,GroupViTPreTrainedModel:()=>kA,HeliumForCausalLM:()=>s_e,HeliumModel:()=>o_e,HeliumPreTrainedModel:()=>AA,HieraForImageClassification:()=>l_e,HieraModel:()=>c_e,HieraPreTrainedModel:()=>jA,HubertForCTC:()=>g_e,HubertForSequenceClassification:()=>__e,HubertModel:()=>h_e,HubertPreTrainedModel:()=>m_e,HunYuanDenseV1ForCausalLM:()=>y_e,HunYuanDenseV1Model:()=>v_e,HunYuanDenseV1PreTrainedModel:()=>NA,IJepaForImageClassification:()=>x_e,IJepaModel:()=>b_e,IJepaPreTrainedModel:()=>FA,Idefics3ForConditionalGeneration:()=>PA,JAISLMHeadModel:()=>C_e,JAISModel:()=>S_e,JAISPreTrainedModel:()=>IA,JinaCLIPModel:()=>w_e,JinaCLIPPreTrainedModel:()=>LA,JinaCLIPTextModel:()=>RA,JinaCLIPVisionModel:()=>T_e,Lfm2ForCausalLM:()=>D_e,Lfm2Model:()=>E_e,Lfm2MoeForCausalLM:()=>A_e,Lfm2MoeModel:()=>k_e,Lfm2MoePreTrainedModel:()=>BA,Lfm2PreTrainedModel:()=>zA,Lfm2VlForConditionalGeneration:()=>j_e,LightOnOcrForConditionalGeneration:()=>O_e,LiteWhisperForConditionalGeneration:()=>UN,Llama4ForCausalLM:()=>P_e,Llama4PreTrainedModel:()=>HA,LlamaForCausalLM:()=>N_e,LlamaModel:()=>M_e,LlamaPreTrainedModel:()=>VA,LlavaForConditionalGeneration:()=>iA,LlavaOnevisionForConditionalGeneration:()=>iA,LlavaPreTrainedModel:()=>rA,LlavaQwen2ForCausalLM:()=>kge,LongT5ForConditionalGeneration:()=>I_e,LongT5Model:()=>F_e,LongT5PreTrainedModel:()=>UA,M2M100ForConditionalGeneration:()=>R_e,M2M100Model:()=>L_e,M2M100PreTrainedModel:()=>WA,MBartForCausalLM:()=>K_e,MBartForConditionalGeneration:()=>W_e,MBartForSequenceClassification:()=>G_e,MBartModel:()=>U_e,MBartPreTrainedModel:()=>qA,MPNetForMaskedLM:()=>Mve,MPNetForQuestionAnswering:()=>Fve,MPNetForSequenceClassification:()=>Nve,MPNetForTokenClassification:()=>Pve,MPNetModel:()=>jve,MPNetPreTrainedModel:()=>gj,MT5ForConditionalGeneration:()=>zve,MT5Model:()=>Rve,MT5PreTrainedModel:()=>vj,MarianMTModel:()=>B_e,MarianModel:()=>z_e,MarianPreTrainedModel:()=>GA,MaskFormerForInstanceSegmentation:()=>H_e,MaskFormerModel:()=>V_e,MaskFormerPreTrainedModel:()=>KA,Metric3DForDepthEstimation:()=>q_e,Metric3DPreTrainedModel:()=>JA,Metric3Dv2ForDepthEstimation:()=>J_e,Metric3Dv2PreTrainedModel:()=>YA,MgpstrForSceneTextRecognition:()=>Y_e,MgpstrModelOutput:()=>XA,MgpstrPreTrainedModel:()=>ZA,MimiDecoderModel:()=>nj,MimiDecoderOutput:()=>$A,MimiEncoderModel:()=>tj,MimiEncoderOutput:()=>QA,MimiModel:()=>X_e,MimiPreTrainedModel:()=>ej,Mistral4ForCausalLM:()=>eve,Mistral4Model:()=>$_e,Mistral4PreTrainedModel:()=>ij,MistralForCausalLM:()=>Q_e,MistralModel:()=>Z_e,MistralPreTrainedModel:()=>rj,MobileBertForMaskedLM:()=>nve,MobileBertForQuestionAnswering:()=>ive,MobileBertForSequenceClassification:()=>rve,MobileBertModel:()=>tve,MobileBertPreTrainedModel:()=>aj,MobileLLMForCausalLM:()=>ove,MobileLLMModel:()=>ave,MobileLLMPreTrainedModel:()=>oj,MobileNetV1ForImageClassification:()=>cve,MobileNetV1ForSemanticSegmentation:()=>lve,MobileNetV1Model:()=>sve,MobileNetV1PreTrainedModel:()=>sj,MobileNetV2ForImageClassification:()=>dve,MobileNetV2ForSemanticSegmentation:()=>fve,MobileNetV2Model:()=>uve,MobileNetV2PreTrainedModel:()=>cj,MobileNetV3ForImageClassification:()=>mve,MobileNetV3ForSemanticSegmentation:()=>hve,MobileNetV3Model:()=>pve,MobileNetV3PreTrainedModel:()=>lj,MobileNetV4ForImageClassification:()=>_ve,MobileNetV4ForSemanticSegmentation:()=>vve,MobileNetV4Model:()=>gve,MobileNetV4PreTrainedModel:()=>uj,MobileViTForImageClassification:()=>bve,MobileViTModel:()=>yve,MobileViTPreTrainedModel:()=>dj,MobileViTV2ForImageClassification:()=>Sve,MobileViTV2Model:()=>xve,MobileViTV2PreTrainedModel:()=>fj,ModernBertDecoderForCausalLM:()=>Ove,ModernBertDecoderModel:()=>Dve,ModernBertDecoderPreTrainedModel:()=>mj,ModernBertForMaskedLM:()=>wve,ModernBertForSequenceClassification:()=>Tve,ModernBertForTokenClassification:()=>Eve,ModernBertModel:()=>Cve,ModernBertPreTrainedModel:()=>pj,Moondream1ForConditionalGeneration:()=>Oge,MoonshineForConditionalGeneration:()=>Ave,MoonshineModel:()=>kve,MoonshinePreTrainedModel:()=>hj,MptForCausalLM:()=>Lve,MptModel:()=>Ive,MptPreTrainedModel:()=>_j,MultiModalityCausalLM:()=>Bve,MultiModalityPreTrainedModel:()=>yj,MusicgenForCausalLM:()=>Hve,MusicgenForConditionalGeneration:()=>xj,MusicgenModel:()=>Vve,MusicgenPreTrainedModel:()=>bj,NanoChatForCausalLM:()=>Wve,NanoChatModel:()=>Uve,NanoChatPreTrainedModel:()=>Sj,NemotronHForCausalLM:()=>Kve,NemotronHModel:()=>Gve,NemotronHPreTrainedModel:()=>Cj,NeoBertForMaskedLM:()=>Jve,NeoBertForQuestionAnswering:()=>Zve,NeoBertForSequenceClassification:()=>Yve,NeoBertForTokenClassification:()=>Xve,NeoBertModel:()=>qve,NeoBertPreTrainedModel:()=>wj,NomicBertModel:()=>Qve,NomicBertPreTrainedModel:()=>Tj,OPTForCausalLM:()=>fye,OPTModel:()=>dye,OPTPreTrainedModel:()=>Mj,Olmo2ForCausalLM:()=>nye,Olmo2Model:()=>tye,Olmo2PreTrainedModel:()=>Dj,Olmo3ForCausalLM:()=>iye,Olmo3Model:()=>rye,Olmo3PreTrainedModel:()=>Oj,OlmoForCausalLM:()=>eye,OlmoHybridForCausalLM:()=>oye,OlmoHybridModel:()=>aye,OlmoHybridPreTrainedModel:()=>kj,OlmoModel:()=>$ve,OlmoPreTrainedModel:()=>Ej,OpenAIPrivacyFilterForTokenClassification:()=>cye,OpenAIPrivacyFilterModel:()=>sye,OpenAIPrivacyFilterPreTrainedModel:()=>Aj,OpenELMForCausalLM:()=>uye,OpenELMModel:()=>lye,OpenELMPreTrainedModel:()=>jj,OwlViTForObjectDetection:()=>gye,OwlViTModel:()=>hye,OwlViTPreTrainedModel:()=>Pj,Owlv2ForObjectDetection:()=>mye,Owlv2Model:()=>pye,Owlv2PreTrainedModel:()=>Nj,PaliGemmaForConditionalGeneration:()=>_ye,ParakeetForCTC:()=>vye,ParakeetPreTrainedModel:()=>Fj,PatchTSMixerForPrediction:()=>bye,PatchTSMixerModel:()=>yye,PatchTSMixerPreTrainedModel:()=>Ij,PatchTSTForPrediction:()=>Sye,PatchTSTModel:()=>xye,PatchTSTPreTrainedModel:()=>Lj,Phi3ForCausalLM:()=>Eye,Phi3Model:()=>Tye,Phi3PreTrainedModel:()=>zj,Phi3VForCausalLM:()=>Vj,Phi3VPreTrainedModel:()=>Bj,PhiForCausalLM:()=>wye,PhiModel:()=>Cye,PhiPreTrainedModel:()=>Rj,PreTrainedModel:()=>z,PvtForImageClassification:()=>Oye,PvtModel:()=>Dye,PvtPreTrainedModel:()=>Hj,PyAnnoteForAudioFrameClassification:()=>Aye,PyAnnoteModel:()=>kye,PyAnnotePreTrainedModel:()=>Uj,Qwen2ForCausalLM:()=>Mye,Qwen2Model:()=>jye,Qwen2MoeForCausalLM:()=>Pye,Qwen2MoeModel:()=>Nye,Qwen2MoePreTrainedModel:()=>Gj,Qwen2PreTrainedModel:()=>Wj,Qwen2VLForCausalLM:()=>mA,Qwen2VLForConditionalGeneration:()=>pA,Qwen2VLPreTrainedModel:()=>fA,Qwen2_5_VLForCausalLM:()=>gA,Qwen2_5_VLForConditionalGeneration:()=>hA,Qwen3ForCausalLM:()=>Iye,Qwen3Model:()=>Fye,Qwen3MoeForCausalLM:()=>Rye,Qwen3MoeModel:()=>Lye,Qwen3MoePreTrainedModel:()=>qj,Qwen3NextForCausalLM:()=>Bye,Qwen3NextModel:()=>zye,Qwen3NextPreTrainedModel:()=>Jj,Qwen3PreTrainedModel:()=>Kj,Qwen3VLForCausalLM:()=>Xj,Qwen3VLForConditionalGeneration:()=>Yj,Qwen3VLMoeForCausalLM:()=>Hye,Qwen3VLMoeForConditionalGeneration:()=>Vye,Qwen3_5ForCausalLM:()=>Qj,Qwen3_5ForConditionalGeneration:()=>Zj,Qwen3_5MoeForCausalLM:()=>Wye,Qwen3_5MoeForConditionalGeneration:()=>Uye,RFDetrForObjectDetection:()=>Jye,RFDetrModel:()=>qye,RFDetrObjectDetectionOutput:()=>tM,RFDetrPreTrainedModel:()=>eM,RTDetrForObjectDetection:()=>mhe,RTDetrModel:()=>phe,RTDetrObjectDetectionOutput:()=>xk,RTDetrPreTrainedModel:()=>bk,RTDetrV2ForObjectDetection:()=>obe,RTDetrV2Model:()=>abe,RTDetrV2ObjectDetectionOutput:()=>aM,RTDetrV2PreTrainedModel:()=>iM,ResNetForImageClassification:()=>Kye,ResNetModel:()=>Gye,ResNetPreTrainedModel:()=>$j,RoFormerForMaskedLM:()=>tbe,RoFormerForQuestionAnswering:()=>ibe,RoFormerForSequenceClassification:()=>nbe,RoFormerForTokenClassification:()=>rbe,RoFormerModel:()=>ebe,RoFormerPreTrainedModel:()=>rM,RobertaForMaskedLM:()=>Xye,RobertaForQuestionAnswering:()=>$ye,RobertaForSequenceClassification:()=>Zye,RobertaForTokenClassification:()=>Qye,RobertaModel:()=>Yye,RobertaPreTrainedModel:()=>nM,Sam2ImageSegmentationOutput:()=>cM,Sam2Model:()=>uM,Sam2PreTrainedModel:()=>lM,Sam3TrackerModel:()=>lbe,SamImageSegmentationOutput:()=>oM,SamModel:()=>sbe,SamPreTrainedModel:()=>sM,SapiensForDepthEstimation:()=>dbe,SapiensForNormalEstimation:()=>fbe,SapiensForSemanticSegmentation:()=>ube,SapiensPreTrainedModel:()=>dM,SegformerForImageClassification:()=>mbe,SegformerForSemanticSegmentation:()=>hbe,SegformerModel:()=>pbe,SegformerPreTrainedModel:()=>fM,SiglipModel:()=>gbe,SiglipPreTrainedModel:()=>pM,SiglipTextModel:()=>mM,SiglipVisionModel:()=>_be,SmolLM3ForCausalLM:()=>ybe,SmolLM3Model:()=>vbe,SmolLM3PreTrainedModel:()=>hM,SmolVLMForConditionalGeneration:()=>bbe,SnacDecoderModel:()=>vM,SnacEncoderModel:()=>_M,SnacModel:()=>xbe,SnacPreTrainedModel:()=>gM,SolarOpenForCausalLM:()=>Cbe,SolarOpenModel:()=>Sbe,SolarOpenPreTrainedModel:()=>yM,SpeechT5ForSpeechToText:()=>Tbe,SpeechT5ForTextToSpeech:()=>Ebe,SpeechT5HifiGan:()=>Dbe,SpeechT5Model:()=>wbe,SpeechT5PreTrainedModel:()=>bM,SqueezeBertForMaskedLM:()=>kbe,SqueezeBertForQuestionAnswering:()=>jbe,SqueezeBertForSequenceClassification:()=>Abe,SqueezeBertModel:()=>Obe,SqueezeBertPreTrainedModel:()=>xM,StableLmForCausalLM:()=>Nbe,StableLmModel:()=>Mbe,StableLmPreTrainedModel:()=>SM,Starcoder2ForCausalLM:()=>Fbe,Starcoder2Model:()=>Pbe,Starcoder2PreTrainedModel:()=>CM,StyleTextToSpeech2Model:()=>Ibe,StyleTextToSpeech2PreTrainedModel:()=>wM,SupertonicForConditionalGeneration:()=>EM,SupertonicPreTrainedModel:()=>TM,Swin2SRForImageSuperResolution:()=>jM,Swin2SRModel:()=>AM,Swin2SRPreTrainedModel:()=>kM,SwinForImageClassification:()=>Rbe,SwinForSemanticSegmentation:()=>OM,SwinModel:()=>Lbe,SwinPreTrainedModel:()=>DM,T5ForConditionalGeneration:()=>PM,T5Model:()=>NM,T5PreTrainedModel:()=>MM,TableTransformerForObjectDetection:()=>LM,TableTransformerModel:()=>IM,TableTransformerObjectDetectionOutput:()=>RM,TableTransformerPreTrainedModel:()=>FM,TrOCRForCausalLM:()=>BM,TrOCRPreTrainedModel:()=>zM,UltravoxModel:()=>DA,UltravoxPreTrainedModel:()=>EA,UniSpeechForCTC:()=>UM,UniSpeechForSequenceClassification:()=>WM,UniSpeechModel:()=>HM,UniSpeechPreTrainedModel:()=>VM,UniSpeechSatForAudioFrameClassification:()=>YM,UniSpeechSatForCTC:()=>qM,UniSpeechSatForSequenceClassification:()=>JM,UniSpeechSatModel:()=>KM,UniSpeechSatPreTrainedModel:()=>GM,VaultGemmaForCausalLM:()=>QM,VaultGemmaModel:()=>ZM,VaultGemmaPreTrainedModel:()=>XM,ViTForImageClassification:()=>nN,ViTMAEModel:()=>iN,ViTMAEPreTrainedModel:()=>rN,ViTMSNForImageClassification:()=>sN,ViTMSNModel:()=>oN,ViTMSNPreTrainedModel:()=>aN,ViTModel:()=>tN,ViTPreTrainedModel:()=>eN,VisionEncoderDecoderModel:()=>$M,VitMatteForImageMatting:()=>lN,VitMattePreTrainedModel:()=>cN,VitPoseForPoseEstimation:()=>dN,VitPosePreTrainedModel:()=>uN,VitsModel:()=>mN,VitsModelOutput:()=>fN,VitsPreTrainedModel:()=>pN,VoxtralForConditionalGeneration:()=>hN,VoxtralRealtimeForConditionalGeneration:()=>TN,VoxtralRealtimePreTrainedModel:()=>wN,Wav2Vec2BertForCTC:()=>ON,Wav2Vec2BertForSequenceClassification:()=>kN,Wav2Vec2BertModel:()=>DN,Wav2Vec2BertPreTrainedModel:()=>EN,Wav2Vec2ForAudioFrameClassification:()=>p_e,Wav2Vec2ForCTC:()=>d_e,Wav2Vec2ForSequenceClassification:()=>f_e,Wav2Vec2Model:()=>u_e,Wav2Vec2PreTrainedModel:()=>MA,WavLMForAudioFrameClassification:()=>IN,WavLMForCTC:()=>NN,WavLMForSequenceClassification:()=>PN,WavLMForXVector:()=>FN,WavLMModel:()=>MN,WavLMPreTrainedModel:()=>jN,WeSpeakerResNetModel:()=>RN,WeSpeakerResNetPreTrainedModel:()=>LN,WhisperForConditionalGeneration:()=>HN,WhisperModel:()=>VN,WhisperPreTrainedModel:()=>BN,XLMForQuestionAnswering:()=>YN,XLMForSequenceClassification:()=>qN,XLMForTokenClassification:()=>JN,XLMModel:()=>GN,XLMPreTrainedModel:()=>WN,XLMRobertaForMaskedLM:()=>QN,XLMRobertaForQuestionAnswering:()=>tP,XLMRobertaForSequenceClassification:()=>$N,XLMRobertaForTokenClassification:()=>eP,XLMRobertaModel:()=>ZN,XLMRobertaPreTrainedModel:()=>XN,XLMWithLMHeadModel:()=>KN,XVectorOutput:()=>AN,YolosForObjectDetection:()=>iP,YolosModel:()=>rP,YolosObjectDetectionOutput:()=>aP,YolosPreTrainedModel:()=>nP,YoutuForCausalLM:()=>cP,YoutuModel:()=>sP,YoutuPreTrainedModel:()=>oP});var WO=class extends z{},sme=class extends WO{},cme=class extends WO{async _call(e){return new sO(await super._call(e))}},lme=class extends WO{async _call(e){return new uO(await super._call(e))}},ume=class extends WO{async _call(e){return new lO(await super._call(e))}},GO=class extends z{},dme=class extends GO{},fme=class extends GO{},KO=class extends z{},pme=class extends KO{},mme=class extends KO{},qO=class extends z{},hme=class extends qO{},gme=class extends qO{},JO=class extends z{},_me=class extends JO{},vme=class extends JO{},YO=class extends z{},yme=class extends YO{},bme=class extends YO{},xme=class extends YO{async _call(e){return new sO(await super._call(e))}},XO=class extends z{},Sme=class extends XO{},Cme=class extends XO{async _call(e){return new sO(await super._call(e))}},ZO=class extends z{},wme=class extends ZO{},Tme=class extends ZO{async _call(e){return new lO(await super._call(e))}},Eme=class extends ZO{async _call(e){return new sO(await super._call(e))}},Dme=class extends ZO{async _call(e){return new cO(await super._call(e))}},Ome=class extends ZO{async _call(e){return new uO(await super._call(e))}},QO=class extends z{},kme=class extends QO{},Ame=class extends QO{},$O=class extends z{},jme=class extends $O{},Mme=class extends $O{},ek=class extends z{},Nme=class extends ek{},Pme=class extends ek{},tk=class extends z{},Fme=class extends tk{},Ime=class extends tk{async _call(e){return new lO(await super._call(e))}},Lme=class extends tk{async _call(e){return new sO(await super._call(e))}},Rme=class extends tk{async _call(e){return new cO(await super._call(e))}},zme=class extends tk{async _call(e){return new uO(await super._call(e))}},Bme=4299n,nk=6561n,rk=class extends z{forward_params=[`input_ids`,`inputs_embeds`,`attention_mask`,`position_ids`,`audio_values`,`exaggeration`,`audio_features`,`audio_tokens`,`speaker_embeddings`,`speaker_features`,`past_key_values`];main_input_name=`input_ids`;_return_dict_in_generate_keys=[`audio_tokens`,`speaker_embeddings`,`speaker_features`]},ik=class extends rk{async encode_speech(e){return aO(this.sessions.speech_encoder,{audio_values:e})}async forward({input_ids:e=null,attention_mask:t=null,audio_values:n=null,exaggeration:r=null,position_ids:i=null,inputs_embeds:a=null,past_key_values:o=null,generation_config:s=null,logits_processor:c=null,audio_features:l=null,audio_tokens:u=null,speaker_embeddings:d=null,speaker_features:f=null,...p}){let m;if(!a){let s=this.sessions.embed_tokens.inputNames,c={input_ids:e};if(s.includes(`exaggeration`)){if(!(r instanceof L)){let t=e.dims[0];if(r==null)r=Dw([t],.5);else if(typeof r==`number`)r=Dw([t],r);else if(Array.isArray(r))r=new L(`float32`,r,[t]);else throw Error("Unsupported type for `exaggeration` input")}c.exaggeration=r}if(s.includes(`position_ids`)&&(c.position_ids=i),{inputs_embeds:a}=await aO(this.sessions.embed_tokens,c),l&&u&&d&&f&&(m={audio_features:l,audio_tokens:u,speaker_embeddings:d,speaker_features:f}),m||n)m??=await this.encode_speech(n),a=bw([m.audio_features,a],1),t=kw([a.dims[0],a.dims[1]]);else{let e=a.dims[1];if(!o||e!==1)throw Error(`Incorrect state encountered during generation.`);let n=o.get_seq_length();t=kw([a.dims[0],n+e])}}return{...await PO(this,{inputs_embeds:a,past_key_values:o,attention_mask:t,generation_config:s,logits_processor:c},!1),...m}}prepare_inputs_for_generation(e,t,n){return!t.position_ids&&this.sessions.embed_tokens.inputNames.includes(`position_ids`)&&(t.position_ids=t.input_ids.dims[1]===1?new L(`int64`,Array.from({length:e.length},(t,n)=>e[n].length-e[n].findLastIndex(e=>e==nk)-1),[e.length,1]):new L(`int64`,t.input_ids.tolist().map(e=>{let t=0;return e.map(e=>e>=nk?0:t++)}).flat(),t.input_ids.dims)),t.input_ids.dims[1]===1&&(delete t.audio_values,delete t.audio_features,delete t.audio_tokens,delete t.speaker_embeddings,delete t.speaker_features),LO(this,e,t,n)}async generate(e){let{sequences:t,audio_tokens:n,speaker_embeddings:r,speaker_features:i}=await super.generate({...e,return_dict_in_generate:!0}),a=t.slice(null,[e.input_ids.dims[1],-1]),o=bw([n,a,Dw([a.dims[0],3],Bme)],1),{waveform:s}=await aO(this.sessions.conditional_decoder,{speech_tokens:o,speaker_features:i,speaker_embeddings:r});return s}},ak=class extends z{},Vme=class extends ak{},ok=class extends z{},Hme=class extends ok{},sk=class extends z{},Ume=class extends sk{},ck=class extends sk{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`text_model`})}},lk=class extends sk{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`audio_model`})}},uk=class extends z{},Wme=class extends uk{},Gme=class extends uk{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`text_model`})}},dk=class extends uk{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`text_model`})}},Kme=class extends uk{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`vision_model`})}},qme=class extends uk{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`vision_model`})}},fk=class extends z{},Jme=class extends fk{},Yme=class extends fk{},pk=class extends z{},Xme=class extends pk{},Zme=class extends pk{},mk=class extends z{},Qme=class extends mk{},$me=class extends mk{},hk=class extends z{},ehe=class extends hk{},the=class extends hk{},gk=class extends z{requires_attention_mask=!1;main_input_name=`input_features`;forward_params=[`input_features`,`decoder_input_ids`,`decoder_attention_mask`,`past_key_values`]},nhe=class extends gk{},rhe=class extends gk{},_k=class extends z{},ihe=class extends _k{},ahe=class extends _k{async _call(e){return new lO(await super._call(e))}},ohe=class extends _k{async _call(e){return new sO(await super._call(e))}},she=class extends _k{async _call(e){return new cO(await super._call(e))}},che=class extends _k{async _call(e){return new uO(await super._call(e))}},vk=class extends z{},lhe=class extends vk{},uhe=class extends vk{async _call(e){return new sO(await super._call(e))}},yk=class extends z{},dhe=class extends yk{},fhe=class extends yk{async _call(e){return new sO(await super._call(e))}},bk=class extends z{},phe=class extends bk{},mhe=class extends bk{async _call(e){return new xk(await super._call(e))}},xk=class extends oO{constructor({logits:e,pred_boxes:t}){super(),this.logits=e,this.pred_boxes=t}},Sk=class extends z{},hhe=class extends Sk{},ghe=class extends Sk{async _call(e){return new xk(await super._call(e))}},Ck=class extends oO{constructor({audio_codes:e}){super(),this.audio_codes=e}},wk=class extends oO{constructor({audio_values:e}){super(),this.audio_values=e}},Tk=class extends z{main_input_name=`input_values`;forward_params=[`input_values`]},_he=class extends Tk{async encode(e){return new Ck(await aO(this.sessions.encoder_model,e))}async decode(e){return new wk(await aO(this.sessions.decoder_model,e))}},Ek=class extends Tk{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`encoder_model`})}},Dk=class extends Tk{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`decoder_model`})}},Ok=class extends z{},vhe=class extends Ok{},yhe=class extends Ok{async _call(e){return new lO(await super._call(e))}},bhe=class extends Ok{async _call(e){return new sO(await super._call(e))}},xhe=class extends Ok{async _call(e){return new cO(await super._call(e))}},She=class extends Ok{async _call(e){return new uO(await super._call(e))}},kk=class extends z{},Che=class extends kk{},whe=class extends kk{},Ak=class extends z{},The=class extends Ak{},Ehe=class extends Ak{async _call(e){return new lO(await super._call(e))}},Dhe=class extends Ak{async _call(e){return new sO(await super._call(e))}},Ohe=class extends Ak{async _call(e){return new cO(await super._call(e))}},khe=class extends Ak{async _call(e){return new uO(await super._call(e))}},jk=class extends z{},Ahe=class extends jk{},Mk=class extends z{},jhe=class extends Mk{},Mhe=class extends Mk{async _call(e){return new sO(await super._call(e))}},Nk=class extends z{},Nhe=class extends Nk{},Pk=class extends z{},Phe=class extends Pk{},Fk=class extends z{},Fhe=class extends Fk{},Ihe=class extends Fk{async _call(e){return new Ik(await super._call(e))}},Lhe=class extends Fk{async _call(e){return new Lk(await super._call(e))}},Ik=class extends oO{constructor({logits:e,pred_boxes:t}){super(),this.logits=e,this.pred_boxes=t}},Lk=class extends oO{constructor({logits:e,pred_boxes:t,pred_masks:n}){super(),this.logits=e,this.pred_boxes=t,this.pred_masks=n}},Rk=class extends z{},Rhe=class extends Rk{},zhe=class extends Rk{async _call(e){return new sO(await super._call(e))}},zk=class extends z{},Bhe=class extends zk{},Vhe=class extends zk{async _call(e){return new sO(await super._call(e))}},Bk=class extends z{},Hhe=class extends Bk{},Vk=class extends z{},Uhe=class extends Vk{},Hk=class extends z{},Whe=class extends Hk{},Ghe=class extends Hk{async _call(e){return new sO(await super._call(e))}},Khe=class extends Hk{async _call(e){return new cO(await super._call(e))}},qhe=class extends Hk{async _call(e){return new uO(await super._call(e))}},Jhe=class extends Hk{async _call(e){return new lO(await super._call(e))}},Uk=class extends z{},Yhe=class extends Uk{},Wk=class extends z{},Xhe=class extends Wk{},Zhe=class extends Wk{},Gk=class extends z{},Qhe=class extends Gk{},$he=class extends Gk{async _call(e){return new sO(await super._call(e))}},Kk=class extends z{},ege=class extends Kk{},tge=class extends Kk{async _call(e){return new lO(await super._call(e))}},nge=class extends Kk{async _call(e){return new sO(await super._call(e))}},rge=class extends Kk{async _call(e){return new cO(await super._call(e))}},ige=class extends Kk{async _call(e){return new uO(await super._call(e))}},qk=class extends z{},age=class extends qk{},oge=class extends qk{},Jk=class extends z{},sge=class extends Jk{},cge=class extends Jk{async _call(e){return new lO(await super._call(e))}},lge=class extends Jk{async _call(e){return new sO(await super._call(e))}},uge=class extends Jk{async _call(e){return new cO(await super._call(e))}},Yk=class extends z{},dge=class extends Yk{},fge=class extends Yk{async _call(e){return new lO(await super._call(e))}},pge=class extends Yk{async _call(e){return new sO(await super._call(e))}},mge=class extends Yk{async _call(e){return new cO(await super._call(e))}},Xk=class extends z{},hge=class extends Xk{},gge=class extends Xk{},Zk=class extends z{},_ge=class extends Zk{},vge=class extends Zk{},Qk=class extends z{},yge=class extends Qk{},bge=class extends Qk{},$k=class extends z{},xge=class extends $k{},Sge=class extends $k{async _call(e){return new sO(await super._call(e))}},eA=class extends z{forward_params=[`input_ids`,`inputs_embeds`,`attention_mask`,`pixel_values`,`encoder_outputs`,`decoder_input_ids`,`decoder_inputs_embeds`,`decoder_attention_mask`,`past_key_values`];main_input_name=`inputs_embeds`},Cge=class extends eA{_merge_input_ids_with_image_features({inputs_embeds:e,image_features:t,input_ids:n,attention_mask:r}){return{inputs_embeds:bw([t,e],1),attention_mask:bw([kw(t.dims.slice(0,2)),r],1)}}async _prepare_inputs_embeds({input_ids:e,pixel_values:t,inputs_embeds:n,attention_mask:r}){if(!e&&!t)throw Error("Either `input_ids` or `pixel_values` should be provided.");let i,a;return e&&(i=await this.encode_text({input_ids:e})),t&&(a=await this.encode_image({pixel_values:t})),i&&a?{inputs_embeds:n,attention_mask:r}=this._merge_input_ids_with_image_features({inputs_embeds:i,image_features:a,input_ids:e,attention_mask:r}):n=i||a,{inputs_embeds:n,attention_mask:r}}async forward({input_ids:e,pixel_values:t,attention_mask:n,decoder_input_ids:r,decoder_attention_mask:i,encoder_outputs:a,past_key_values:o,inputs_embeds:s,decoder_inputs_embeds:c}){if(s||({inputs_embeds:s,attention_mask:n}=await this._prepare_inputs_embeds({input_ids:e,pixel_values:t,inputs_embeds:s,attention_mask:n})),!a){let{last_hidden_state:e}=await AO(this,{inputs_embeds:s,attention_mask:n});a=e}if(!c){if(!r)throw Error("Either `decoder_input_ids` or `decoder_inputs_embeds` should be provided.");c=await this.encode_text({input_ids:r})}let l={inputs_embeds:c,attention_mask:i,encoder_attention_mask:n,encoder_hidden_states:a,past_key_values:o};return await PO(this,l,!0)}},tA=class extends z{},wge=class extends tA{},Tge=class extends tA{},nA=class extends z{},Ege=class extends nA{},Dge=class extends nA{},rA=class extends z{forward_params=[`input_ids`,`attention_mask`,`pixel_values`,`position_ids`,`past_key_values`]},iA=class extends rA{_merge_input_ids_with_image_features(e){let t=e.image_features.dims.at(-1),n=e.image_features.view(-1,t);return VO({image_token_id:this.config.image_token_index??this.config.image_token_id,...e,image_features:n})}},Oge=class extends iA{},kge=class extends iA{},aA=class extends z{},Age=class extends aA{},oA=class extends iA{},jge=class extends oA{},sA=class extends z{forward_params=[`input_ids`,`attention_mask`,`inputs_embeds`,`per_layer_inputs`,`position_ids`,`pixel_values`,`input_features`,`input_features_mask`,`past_key_values`]},cA=class extends sA{async forward({input_ids:e=null,attention_mask:t=null,pixel_values:n=null,input_features:r=null,input_features_mask:i=null,position_ids:a=null,inputs_embeds:o=null,per_layer_inputs:s=null,past_key_values:c=null,generation_config:l=null,logits_processor:u=null,...d}){if((!o||!s)&&({inputs_embeds:o,per_layer_inputs:s}=await aO(this.sessions.embed_tokens,{input_ids:e}),e.dims[1]!==1)){if(n){let{image_features:r}=await this._encode_vision({pixel_values:n,...d});({inputs_embeds:o,attention_mask:t}=this._merge_input_ids_with_image_features({image_features:r,inputs_embeds:o,input_ids:e,attention_mask:t}))}if(r){let{audio_features:n}=await aO(this.sessions.audio_encoder,{input_features:r,input_features_mask:i});({inputs_embeds:o,attention_mask:t}=this._merge_input_ids_with_audio_features({audio_features:n,inputs_embeds:o,input_ids:e,attention_mask:t}))}}return await PO(this,{inputs_embeds:o,per_layer_inputs:s,past_key_values:c,attention_mask:t,position_ids:a,generation_config:l,logits_processor:u},!0)}_encode_vision(e){return aO(this.sessions.vision_encoder,{pixel_values:e.pixel_values})}_merge_input_ids_with_image_features(e){let t=e.image_features.dims.at(-1),n=e.image_features.view(-1,t);return VO({image_token_id:this.config.image_token_id,...e,image_features:n})}_merge_input_ids_with_audio_features(e){let t=e.audio_features.dims.at(-1),n=e.audio_features.view(-1,t);return HO({audio_token_id:this.config.audio_token_id,...e,audio_features:n})}},Mge=class extends cA{},lA=class extends cA{forward_params=[`input_ids`,`attention_mask`,`inputs_embeds`,`per_layer_inputs`,`position_ids`,`pixel_values`,`image_position_ids`,`input_features`,`input_features_mask`,`past_key_values`];_encode_vision(e){return aO(this.sessions.vision_encoder,{pixel_values:e.pixel_values,pixel_position_ids:e.image_position_ids})}},Nge=class extends lA{},uA=class extends z{},Pge=class extends uA{},Fge=class extends uA{},dA=class extends z{},Ige=class extends dA{},Lge=class extends dA{},fA=class extends z{forward_params=[`input_ids`,`attention_mask`,`position_ids`,`past_key_values`,`pixel_values`,`image_grid_thw`]},pA=class extends fA{image_grid_thw_name=`grid_thw`;_get_text_only_rope_index(e,t){if(t){let{data:e,dims:n}=IO(t),r=BigInt64Array.from({length:3*e.length},(t,n)=>e[n%e.length]),i=Array.from({length:n[0]},(t,r)=>_C(e.subarray(n[1]*r,n[1]*(r+1)))[0]+1n+BigInt(n[1]));return[new L(`int64`,r,[3,...n]),new L(`int64`,i,[i.length,1])]}{let[t,n]=e.dims;return[new L(`int64`,BigInt64Array.from({length:3*t*n},(e,r)=>BigInt(Math.floor(r%n/t))),[3,...e.dims]),jw([t,1])]}}_reorder_and_write_positions(e,t,n,r){let i=e.reduce((e,t)=>e+t.length,0),a=Array(i),o=0;for(let t=0;t<3;++t)for(let n of e){let e=n.length/3;for(let r=t*e;r<(t+1)*e;++r)a[o++]=n[r]}let s=0;for(let e=0;e(t==s&&e.push(n),e),[]).map(e=>c[e+1]),u=l.filter(e=>e==a).length,d=l.filter(e=>e==o).length,f=[],p=0,m=u,h=d;for(let e=0;et>p&&e==a),s=c.findIndex((e,t)=>t>p&&e==o),l=m>0&&e!==-1?e:c.length+1,u=h>0&&s!==-1?s:c.length+1,d,g,_,v;l0?_C(f.at(-1))[0]+1:0;f.push(Array.from({length:3*S},(e,t)=>C+t%S));let w=S+C,T=y*b*x,E=Array.from({length:T},(e,t)=>w+Math.floor(t/(b*x))),D=Array.from({length:T},(e,t)=>w+Math.floor(t/x)%b),O=Array.from({length:T},(e,t)=>w+t%x);f.push([E,D,O].flat()),p=d+T}if(p0?_C(f.at(-1))[0]+1:0,t=c.length-p;f.push(Array.from({length:3*t},(n,r)=>e+r%t))}return f}get_rope_index(e,t,n,r){let{vision_config:i}=this.config,a=i.spatial_merge_size??2;if(t||n){let i=e.tolist();r||=Aw(e);let o=r.tolist(),s=Array.from({length:3},()=>Array.from({length:e.dims[0]},()=>Array.from({length:e.dims[1]},()=>0))),c=t?t.tolist():[],l=n?n.tolist():[],u={image_index:0,video_index:0},d=[];for(let e=0;eo[e][n]==1),n=this._get_multimodal_rope_positions({filtered_ids:t,image_grid_thw_list:c,video_grid_thw_list:l,spatial_merge_size:a,state:u}),r=this._reorder_and_write_positions(n,o[e],s,e);d.push(_C(r)[0]+1-i[e].length)}return[new L(`int64`,s.flat(1/0),[3,e.dims[0],e.dims[1]]),new L(`int64`,d,[d.length,1])]}return this._get_text_only_rope_index(e,r)}async encode_image({pixel_values:e,image_grid_thw:t}){return(await aO(this.sessions.vision_encoder,{pixel_values:e,[this.image_grid_thw_name]:t})).image_features}_merge_input_ids_with_image_features(e){return VO({image_token_id:this.config.image_token_id,...e})}prepare_inputs_for_generation(e,t,n){if(!t.attention_mask||t.position_ids||!(this.sessions.decoder_model_merged??this.sessions.model).inputNames.includes(`position_ids`))return t;if(!t.past_key_values)[t.position_ids,t.rope_deltas]=this.get_rope_index(t.input_ids,t.image_grid_thw,t.video_grid_thw,t.attention_mask);else{t.pixel_values=null;let e=t.past_key_values.get_seq_length();if(en+e);t.position_ids=xw([r,r,r],0)}}return t}},mA=class extends pA{},hA=class extends pA{image_grid_thw_name=`image_grid_thw`},gA=class extends mA{image_grid_thw_name=`image_grid_thw`},Rge=class extends hA{get_vision_position_ids(e,t,n,r){let i=Math.floor(t[0]/n),a=Math.floor(t[1]/r),o=Math.floor(t[2]/r),s=a*o*i,c=Array.from({length:s},()=>e),l=Array.from({length:s},(t,n)=>e+Math.floor(n/(o*i))),u=Array.from({length:s},(t,n)=>e+n%o);return[...c,...l,...u]}_get_multimodal_rope_positions({filtered_ids:e,image_grid_thw_list:t,video_grid_thw_list:n,spatial_merge_size:r,state:i}){let{image_token_id:a}=this.config,o=[],s=0,c=+(e[0]==a);for(let t=1;t<=e.length;++t){let n=tl+n%e)),l+=e}else{let e=t[i.image_index++].map(Number),n=e[0];u.push(this.get_vision_position_ids(l,e,n,r)),l+=Math.max(e[1],e[2])/r}return u}},_A=class extends z{},zge=class extends _A{},Bge=class extends _A{},vA=class extends z{},Vge=class extends vA{},Hge=class extends vA{},yA=class extends z{},Uge=class extends yA{},Wge=class extends yA{},bA=class extends z{},Gge=class extends bA{},Kge=class extends bA{},xA=class extends z{},qge=class extends xA{},Jge=class extends xA{},SA=class extends z{},Yge=class extends SA{},Xge=class extends SA{},CA=class extends z{},Zge=class extends CA{},Qge=class extends CA{},wA=class extends z{},$ge=class extends wA{},e_e=class extends wA{},TA=class extends z{},t_e=class extends TA{},n_e=class extends TA{},EA=class extends z{forward_params=[`input_ids`,`attention_mask`,`position_ids`,`audio_values`,`past_key_values`]},DA=class extends EA{_merge_input_ids_with_audio_features(e){let t=e.audio_features.dims.at(-1),n=e.audio_features.view(-1,t);return HO({audio_token_id:this.config.ignore_index??this.config.audio_token_id??this.config.audio_token_index,...e,audio_features:n})}},r_e=class extends DA{forward_params=[`input_ids`,`attention_mask`,`input_features`,`past_key_values`]},OA=class extends z{},i_e=class extends OA{},kA=class extends z{},a_e=class extends kA{},AA=class extends z{},o_e=class extends AA{},s_e=class extends AA{},jA=class extends z{},c_e=class extends jA{},l_e=class extends jA{async _call(e){return new sO(await super._call(e))}},MA=class extends z{},u_e=class extends MA{},d_e=class extends MA{async _call(e){return new dO(await super._call(e))}},f_e=class extends MA{async _call(e){return new sO(await super._call(e))}},p_e=class extends MA{async _call(e){return new cO(await super._call(e))}},m_e=class extends z{},h_e=class extends MA{},g_e=class extends MA{async _call(e){return new dO(await super._call(e))}},__e=class extends MA{async _call(e){return new sO(await super._call(e))}},NA=class extends z{},v_e=class extends NA{},y_e=class extends NA{},PA=class extends iA{forward_params=[`input_ids`,`attention_mask`,`pixel_values`,`pixel_attention_mask`,`position_ids`,`past_key_values`]},FA=class extends z{},b_e=class extends FA{},x_e=class extends FA{async _call(e){return new sO(await super._call(e))}},IA=class extends z{},S_e=class extends IA{},C_e=class extends IA{},LA=class extends z{},w_e=class extends LA{async forward(e){let t=!e.input_ids,n=!e.pixel_values;if(t&&n)throw Error("Either `input_ids` or `pixel_values` should be provided.");if(t&&(e.input_ids=kw([e.pixel_values.dims[0],1])),n){let{image_size:t}=this.config.vision_config;e.pixel_values=Dw([0,3,t,t],0)}let{text_embeddings:r,image_embeddings:i,l2norm_text_embeddings:a,l2norm_image_embeddings:o}=await super.forward(e),s={};return t||(s.text_embeddings=r,s.l2norm_text_embeddings=a),n||(s.image_embeddings=i,s.l2norm_image_embeddings=o),s}},RA=class extends LA{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`text_model`})}},T_e=class extends LA{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`vision_model`})}},zA=class extends z{},E_e=class extends zA{},D_e=class extends zA{},O_e=class extends iA{},BA=class extends z{},k_e=class extends BA{},A_e=class extends BA{},j_e=class extends iA{forward_params=[`input_ids`,`attention_mask`,`pixel_values`,`pixel_attention_mask`,`spatial_shapes`,`position_ids`,`past_key_values`]},VA=class extends z{},M_e=class extends VA{},N_e=class extends VA{},HA=class extends z{},P_e=class extends HA{},UA=class extends z{},F_e=class extends UA{},I_e=class extends UA{},WA=class extends z{},L_e=class extends WA{},R_e=class extends WA{},GA=class extends z{},z_e=class extends GA{},B_e=class extends GA{},KA=class extends z{},V_e=class extends KA{},H_e=class extends KA{},qA=class extends z{},U_e=class extends qA{},W_e=class extends qA{},G_e=class extends qA{async _call(e){return new sO(await super._call(e))}},K_e=class extends qA{},JA=class extends z{},q_e=class extends JA{},YA=class extends z{},J_e=class extends YA{},XA=class extends oO{constructor({char_logits:e,bpe_logits:t,wp_logits:n}){super(),this.char_logits=e,this.bpe_logits=t,this.wp_logits=n}get logits(){return[this.char_logits,this.bpe_logits,this.wp_logits]}},ZA=class extends z{},Y_e=class extends ZA{async _call(e){return new XA(await super._call(e))}},QA=class extends oO{constructor({audio_codes:e}){super(),this.audio_codes=e}},$A=class extends oO{constructor({audio_values:e}){super(),this.audio_values=e}},ej=class extends z{main_input_name=`input_values`;forward_params=[`input_values`]},X_e=class extends ej{async encode(e){return new QA(await aO(this.sessions.encoder_model,e))}async decode(e){return new $A(await aO(this.sessions.decoder_model,e))}},tj=class extends ej{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`encoder_model`})}},nj=class extends ej{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`decoder_model`})}},rj=class extends z{},Z_e=class extends rj{},Q_e=class extends rj{},ij=class extends z{},$_e=class extends ij{},eve=class extends ij{},aj=class extends z{},tve=class extends aj{},nve=class extends aj{async _call(e){return new lO(await super._call(e))}},rve=class extends aj{async _call(e){return new sO(await super._call(e))}},ive=class extends aj{async _call(e){return new uO(await super._call(e))}},oj=class extends z{},ave=class extends oj{},ove=class extends oj{},sj=class extends z{},sve=class extends sj{},cve=class extends sj{async _call(e){return new sO(await super._call(e))}},lve=class extends sj{},cj=class extends z{},uve=class extends cj{},dve=class extends cj{async _call(e){return new sO(await super._call(e))}},fve=class extends cj{},lj=class extends z{},pve=class extends lj{},mve=class extends lj{async _call(e){return new sO(await super._call(e))}},hve=class extends lj{},uj=class extends z{},gve=class extends uj{},_ve=class extends uj{async _call(e){return new sO(await super._call(e))}},vve=class extends uj{},dj=class extends z{},yve=class extends dj{},bve=class extends dj{async _call(e){return new sO(await super._call(e))}},fj=class extends z{},xve=class extends fj{},Sve=class extends fj{async _call(e){return new sO(await super._call(e))}},pj=class extends z{},Cve=class extends pj{},wve=class extends pj{async _call(e){return new lO(await super._call(e))}},Tve=class extends pj{async _call(e){return new sO(await super._call(e))}},Eve=class extends pj{async _call(e){return new cO(await super._call(e))}},mj=class extends z{},Dve=class extends mj{},Ove=class extends mj{},hj=class extends z{requires_attention_mask=!1;main_input_name=`input_values`;forward_params=[`input_values`,`decoder_input_ids`,`past_key_values`]},kve=class extends hj{},Ave=class extends hj{},gj=class extends z{},jve=class extends gj{},Mve=class extends gj{async _call(e){return new lO(await super._call(e))}},Nve=class extends gj{async _call(e){return new sO(await super._call(e))}},Pve=class extends gj{async _call(e){return new cO(await super._call(e))}},Fve=class extends gj{async _call(e){return new uO(await super._call(e))}},_j=class extends z{},Ive=class extends _j{},Lve=class extends _j{},vj=class extends z{},Rve=class extends vj{},zve=class extends vj{},yj=class extends z{},Bve=class extends yj{forward_params=[`input_ids`,`pixel_values`,`images_seq_mask`,`images_emb_mask`,`attention_mask`,`position_ids`,`past_key_values`];constructor(...e){super(...e),this._generation_mode=`text`}async forward(e){let t=this._generation_mode??`text`,n;if(t===`text`||!e.past_key_values){let t=this.sessions.prepare_inputs_embeds;n=await aO(t,Hb(e,t.inputNames))}else{let t=this.sessions.gen_img_embeds;n=await aO(t,Hb({image_ids:e.input_ids},t.inputNames))}let r={...e,...n},i=await PO(this,r),a=this.sessions[t===`text`?`lm_head`:`gen_head`];if(!a)throw Error(`Unable to find "${a}" generation head`);let o=await aO(a,Hb(i,a.inputNames));return{...n,...i,...o}}prepare_inputs_for_generation(e,t,n){let r=!!t.past_key_values;return n.guidance_scale!==null&&n.guidance_scale>1&&(r?t.input_ids=bw([t.input_ids,t.input_ids],0):(t.input_ids=bw([t.input_ids,Ow(t.input_ids,BigInt(n.pad_token_id))],0),t.attention_mask=bw([t.attention_mask,Ow(t.attention_mask,0n)],0))),(r||!t.pixel_values)&&(t.pixel_values=Dw([0,0,3,384,384],1)),r&&(t.images_seq_mask=new L(`bool`,[,].fill(!0).fill(!1,0,1),[1,1]),t.images_emb_mask=new L(`bool`,[].fill(!1),[1,1,0])),t}async generate(e){return this._generation_mode=`text`,super.generate(e)}async generate_images(e){this._generation_mode=`image`;let t=(e.inputs??e[this.main_input_name]).dims[1],n=(await super.generate(e)).slice(null,[t,null]),r=this.sessions.image_decode,{decoded_image:i}=await aO(r,{generated_tokens:n}),a=i.add_(1).mul_(255/2).clamp_(0,255).to(`uint8`),o=[];for(let e of a){let t=$E.fromTensor(e);o.push(t)}return o}},bj=class extends z{},Vve=class extends bj{},Hve=class extends bj{},xj=class extends z{forward_params=[`input_ids`,`attention_mask`,`encoder_outputs`,`decoder_input_ids`,`decoder_attention_mask`,`past_key_values`];_apply_and_filter_by_delay_pattern_mask(e){let[t,n]=e.dims,r=this.config.decoder.num_codebooks,i=n-r,a=0;for(let t=0;t0&&o<=i&&(e.data[a++]=e.data[t])}let o=Math.floor(t/r),s=a/(o*r);return new L(e.type,e.data.slice(0,a),[o,r,s])}prepare_inputs_for_generation(e,t,n){let r=BigInt(this.config.decoder.pad_token_id),i=structuredClone(e);for(let e=0;e=t&&(i[e][t]=r);return n.guidance_scale!==null&&n.guidance_scale>1&&(i=i.concat(i)),RO(this,i,t,n)}async generate(e){let t=await super.generate(e),n=this._apply_and_filter_by_delay_pattern_mask(t).unsqueeze_(0),{audio_values:r}=await aO(this.sessions.encodec_decode,{audio_codes:n});return r}},Sj=class extends z{},Uve=class extends Sj{},Wve=class extends Sj{},Cj=class extends z{},Gve=class extends Cj{},Kve=class extends Cj{},wj=class extends z{},qve=class extends wj{},Jve=class extends wj{async _call(e){return new lO(await super._call(e))}},Yve=class extends wj{async _call(e){return new sO(await super._call(e))}},Xve=class extends wj{async _call(e){return new cO(await super._call(e))}},Zve=class extends wj{async _call(e){return new uO(await super._call(e))}},Tj=class extends z{},Qve=class extends Tj{},Ej=class extends z{},$ve=class extends Ej{},eye=class extends Ej{},Dj=class extends z{},tye=class extends Dj{},nye=class extends Dj{},Oj=class extends z{},rye=class extends Oj{},iye=class extends Oj{},kj=class extends z{},aye=class extends kj{},oye=class extends kj{},Aj=class extends z{},sye=class extends Aj{},cye=class extends Aj{async _call(e){return new sO(await super._call(e))}},jj=class extends z{},lye=class extends jj{},uye=class extends jj{},Mj=class extends z{},dye=class extends Mj{},fye=class extends Mj{},Nj=class extends z{},pye=class extends Nj{},mye=class extends Nj{},Pj=class extends z{},hye=class extends Pj{},gye=class extends Pj{},_ye=class extends iA{},Fj=class extends z{},vye=class extends Fj{async _call(e){return new dO(await super._call(e))}},Ij=class extends z{},yye=class extends Ij{},bye=class extends Ij{},Lj=class extends z{},xye=class extends Lj{},Sye=class extends Lj{},Rj=class extends z{},Cye=class extends Rj{},wye=class extends Rj{},zj=class extends z{},Tye=class extends zj{},Eye=class extends zj{},Bj=class extends z{forward_params=[`input_ids`,`inputs_embeds`,`attention_mask`,`position_ids`,`pixel_values`,`image_sizes`,`past_key_values`]},Vj=class extends Bj{async forward({input_ids:e=null,attention_mask:t=null,pixel_values:n=null,image_sizes:r=null,position_ids:i=null,inputs_embeds:a=null,past_key_values:o=null,generation_config:s=null,logits_processor:c=null,...l}){if(!a){let t;if(n&&e.dims[1]!==1){if(!r)throw Error("`image_sizes` must be provided when `pixel_values` is provided.");({image_features:t}=await aO(this.sessions.vision_encoder,{pixel_values:n,image_sizes:r}))}else{let e=this.config.normalized_config.hidden_size;t=new L(`float32`,[],[0,e])}({inputs_embeds:a}=await aO(this.sessions.prepare_inputs_embeds,{input_ids:e,image_features:t}))}return await PO(this,{inputs_embeds:a,past_key_values:o,attention_mask:t,position_ids:i,generation_config:s,logits_processor:c},!1)}},Hj=class extends z{},Dye=class extends Hj{},Oye=class extends Hj{async _call(e){return new sO(await super._call(e))}},Uj=class extends z{},kye=class extends Uj{},Aye=class extends Uj{async _call(e){return new cO(await super._call(e))}},Wj=class extends z{},jye=class extends Wj{},Mye=class extends Wj{},Gj=class extends z{},Nye=class extends Gj{},Pye=class extends Gj{},Kj=class extends z{},Fye=class extends Kj{},Iye=class extends Kj{},qj=class extends z{},Lye=class extends qj{},Rye=class extends qj{},Jj=class extends z{},zye=class extends Jj{},Bye=class extends Jj{},Yj=class extends hA{},Xj=class extends gA{},Vye=class extends Yj{},Hye=class extends Xj{},Zj=class extends Yj{},Qj=class extends Zj{},Uye=class extends Zj{},Wye=class extends Qj{},$j=class extends z{},Gye=class extends $j{},Kye=class extends $j{async _call(e){return new sO(await super._call(e))}},eM=class extends z{},qye=class extends eM{},Jye=class extends eM{async _call(e){return new tM(await super._call(e))}},tM=class extends xk{},nM=class extends z{},Yye=class extends nM{},Xye=class extends nM{async _call(e){return new lO(await super._call(e))}},Zye=class extends nM{async _call(e){return new sO(await super._call(e))}},Qye=class extends nM{async _call(e){return new cO(await super._call(e))}},$ye=class extends nM{async _call(e){return new uO(await super._call(e))}},rM=class extends z{},ebe=class extends rM{},tbe=class extends rM{async _call(e){return new lO(await super._call(e))}},nbe=class extends rM{async _call(e){return new sO(await super._call(e))}},rbe=class extends rM{async _call(e){return new cO(await super._call(e))}},ibe=class extends rM{async _call(e){return new uO(await super._call(e))}},iM=class extends z{},abe=class extends iM{},obe=class extends iM{async _call(e){return new aM(await super._call(e))}},aM=class extends xk{},oM=class extends oO{constructor({iou_scores:e,pred_masks:t}){super(),this.iou_scores=e,this.pred_masks=t}},sM=class extends z{},sbe=class extends sM{async get_image_embeddings({pixel_values:e}){return await AO(this,{pixel_values:e})}async forward(e){e=!e.image_embeddings||!e.image_positional_embeddings?{...e,...await this.get_image_embeddings(e)}:{...e},e.input_labels??=kw(e.input_points.dims.slice(0,-1));let t={image_embeddings:e.image_embeddings,image_positional_embeddings:e.image_positional_embeddings};return e.input_points&&(t.input_points=e.input_points),e.input_labels&&(t.input_labels=e.input_labels),e.input_boxes&&(t.input_boxes=e.input_boxes),await aO(this.sessions.prompt_encoder_mask_decoder,t)}async _call(e){return new oM(await super._call(e))}},cM=class extends oO{constructor({iou_scores:e,pred_masks:t,object_score_logits:n}){super(),this.iou_scores=e,this.pred_masks=t,this.object_score_logits=n}},lM=class extends z{},uM=class extends lM{async get_image_embeddings({pixel_values:e}){return await AO(this,{pixel_values:e})}async forward(e){let{num_feature_levels:t}=this.config.vision_config;if(e=Array.from({length:t},(e,t)=>`image_embeddings.${t}`).some(t=>!e[t])?{...e,...await this.get_image_embeddings(e)}:{...e},e.input_points){if(e.input_boxes&&e.input_boxes.dims[1]!==1)throw Error("When both `input_points` and `input_boxes` are provided, the number of boxes per image must be 1.");let t=e.input_points.dims;e.input_labels??=kw(t.slice(0,-1)),e.input_boxes??=Dw([t[0],0,4],0)}else if(e.input_boxes){let t=e.input_boxes.dims;e.input_labels=Dw([t[0],t[1],0],-1n),e.input_points=Dw([t[0],1,0,2],0)}else throw Error("At least one of `input_points` or `input_boxes` must be provided.");let n=this.sessions.prompt_encoder_mask_decoder;return await aO(n,Hb(e,n.inputNames))}async _call(e){return new cM(await super._call(e))}},cbe=class extends uM{},lbe=class extends uM{},dM=class extends z{},ube=class extends dM{},dbe=class extends dM{},fbe=class extends dM{},fM=class extends z{},pbe=class extends fM{},mbe=class extends fM{},hbe=class extends fM{},pM=class extends z{},gbe=class extends pM{},mM=class extends pM{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`text_model`})}},_be=class extends uk{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`vision_model`})}},hM=class extends z{},vbe=class extends hM{},ybe=class extends hM{},bbe=class extends PA{},gM=class extends z{main_input_name=`input_values`;forward_params=[`input_values`]},xbe=class extends gM{async encode(e){return await aO(this.sessions.encoder_model,e)}async decode(e){return await aO(this.sessions.decoder_model,e)}},_M=class extends gM{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`encoder_model`})}},vM=class extends gM{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`decoder_model`})}},yM=class extends z{},Sbe=class extends yM{},Cbe=class extends yM{},bM=class extends z{},wbe=class extends bM{},Tbe=class extends bM{},Ebe=class extends bM{async generate_speech(e,t,{threshold:n=.5,minlenratio:r=0,maxlenratio:i=20,vocoder:a=null}={}){let o={input_ids:e},{encoder_outputs:s,encoder_attention_mask:c}=await AO(this,o),l=s.dims[1]/this.config.reduction_factor,u=Math.floor(l*i),d=Math.floor(l*r),f=this.config.num_mel_bins,p=[],m=null,h=null,g=0;for(;;){++g;let e=CO(!!h),r;r=h?h.output_sequence_out:new L(`float32`,new Float32Array(f),[1,1,f]);let i={use_cache_branch:e,output_sequence:r,encoder_attention_mask:c,speaker_embeddings:t,encoder_hidden_states:s};NO(this,i,m),h=await aO(this.sessions.decoder_model_merged,i),m=jO(h,m);let{prob:a,spectrum:o}=h;if(p.push(o),g>=d&&(Array.from(a.data).filter(e=>e>=n).length>0||g>=u))break}let _=bw(p),{waveform:v}=await aO(a.sessions.model,{spectrogram:_});return{spectrogram:_,waveform:v}}},Dbe=class extends z{main_input_name=`spectrogram`},xM=class extends z{},Obe=class extends xM{},kbe=class extends xM{async _call(e){return new lO(await super._call(e))}},Abe=class extends xM{async _call(e){return new sO(await super._call(e))}},jbe=class extends xM{async _call(e){return new uO(await super._call(e))}},SM=class extends z{},Mbe=class extends SM{},Nbe=class extends SM{},CM=class extends z{},Pbe=class extends CM{},Fbe=class extends CM{},wM=class extends z{},Ibe=class extends wM{},TM=class extends z{},EM=class extends TM{async generate_speech({input_ids:e,attention_mask:t,style:n,num_inference_steps:r=5,speed:i=1.05}){let{sampling_rate:a,chunk_compress_factor:o,base_chunk_size:s,latent_dim:c}=this.config,{last_hidden_state:l,durations:u}=await aO(this.sessions.text_encoder,{input_ids:e,attention_mask:t,style:n}),d=u.div(i).mul_(a),f=s*o,p=d.data,m=Int32Array.from(p,e=>Math.ceil(e/f)),h=Math.max(...m),g=e.dims[0],_=new BigInt64Array(g*h);for(let e=0;ee*t,1),r=sw[e.type];c[e.name]=new L(e.type,new r(n),t)}let f=sw[d],p=new L(d,new f(s*gN),[1,s,gN]),m=t[Symbol.asyncIterator]?.()??t[Symbol.iterator]?.();if(!m)throw Error(`input_features must be iterable or async iterable`);return{encoder_session:i,enc_kv_cache:c,enc_padding_cache:p,enc_past_seq_len:0,audio_embed_queue:[],audio_embed_total_tokens:0,audio_queue_offset:0,audio_consumed:0,stream_exhausted:!1,chunks_iter:m,text_hidden_size:n.hidden_size}}async function bN(e,t){let n=t.dims[2],r=Math.floor((_N+n-3)/2)+1,i=new L(`int64`,BigInt64Array.from({length:r},(t,n)=>BigInt(e.enc_past_seq_len+n)),[1,r]),a=e.enc_past_seq_len+r,o=kw([1,a]),{audio_embeds:s,present_padding_cache:c,...l}=await aO(e.encoder_session,{input_features:t,attention_mask:o,position_ids:i,past_padding_cache:e.enc_padding_cache,...e.enc_kv_cache});e.enc_padding_cache.location===`gpu-buffer`&&e.enc_padding_cache.dispose(),e.enc_padding_cache=c;for(let t in l)if(t.startsWith(`present.`)){let n=t.replace(`present`,`past_key_values`),r=e.enc_kv_cache[n];r?.location===`gpu-buffer`&&r.dispose(),e.enc_kv_cache[n]=l[t]}return e.enc_past_seq_len=a,s}async function xN(e,t){for(;e.audio_embed_total_tokens0&&e.audio_embed_queue.length>0;){let t=e.audio_embed_queue[0],n=t.tokens-e.audio_queue_offset,o=Math.min(a,n),s=e.audio_queue_offset*e.text_hidden_size;for(let n=0;n=t.tokens&&(e.audio_embed_queue.shift(),e.audio_queue_offset=0)}e.audio_consumed+=n-a}var CN=class extends gO{constructor(e){super(),this._s=e}_call(e){let t=this._s.stream_exhausted&&this._s.audio_embed_queue.length===0;return e.map(()=>t)}},wN=class extends z{forward_params=[`input_ids`,`attention_mask`,`position_ids`,`past_key_values`]},TN=class extends wN{async forward({input_ids:e,past_key_values:t,...n}){let r=e.dims[1],i=vN.get(this);i&&await xN(i,i.audio_consumed+r);let{inputs_embeds:a}=await aO(this.sessions.embed_tokens,{input_ids:e});i&&SN(i,a,r);let o={inputs_embeds:a,...n};NO(this,o,t);let s=this.sessions.decoder_model_merged;return await aO(s,Hb(o,s.inputNames))}async generate({input_features:e,stopping_criteria:t,...n}){if(!e)throw Error(`input_features (generator/iterable) must be provided`);let r=yN(this,e);vN.set(this,r);let i=new _O;i.push(new CN(r)),t&&i.extend(t);try{return await super.generate({...n,stopping_criteria:i})}finally{r.enc_kv_cache.dispose(),vN.delete(this)}}},EN=class extends z{},DN=class extends EN{},ON=class extends EN{async _call(e){return new dO(await super._call(e))}},kN=class extends EN{async _call(e){return new sO(await super._call(e))}},AN=class extends oO{constructor({logits:e,embeddings:t}){super(),this.logits=e,this.embeddings=t}},jN=class extends z{},MN=class extends jN{},NN=class extends jN{async _call(e){return new dO(await super._call(e))}},PN=class extends jN{async _call(e){return new sO(await super._call(e))}},FN=class extends jN{async _call(e){return new AN(await super._call(e))}},IN=class extends jN{async _call(e){return new cO(await super._call(e))}},LN=class extends z{},RN=class extends LN{},zN=class extends hO{return_timestamps=null;return_token_timestamps=null;num_frames=null;alignment_heads=null;task=null;language=null;no_timestamps_token_id=null;prompt_ids=null;is_multilingual=null;lang_to_id=null;task_to_id=null;max_initial_timestamp_index=1},BN=class extends z{requires_attention_mask=!1;main_input_name=`input_features`;forward_params=[`input_features`,`attention_mask`,`decoder_input_ids`,`decoder_attention_mask`,`past_key_values`]},VN=class extends BN{},HN=class extends BN{_prepare_generation_config(e,t){return super._prepare_generation_config(e,t,zN)}_retrieve_init_tokens(e){let t=[e.decoder_start_token_id],n=e.language,r=e.task;if(e.is_multilingual){n||=(Wb.warn(`No language specified - defaulting to English (en).`),`en`);let i=`<|${RT(n)}|>`;t.push(e.lang_to_id[i]),t.push(e.task_to_id[r??`transcribe`])}else if(n||r)throw Error("Cannot specify `task` or `language` for an English-only model. If the model is intended to be multilingual, pass `is_multilingual=true` to generate, or update the generation config.");return!e.return_timestamps&&e.no_timestamps_token_id&&t.at(-1)!==e.no_timestamps_token_id?t.push(e.no_timestamps_token_id):e.return_timestamps&&t.at(-1)===e.no_timestamps_token_id&&(Wb.warn("<|notimestamps|> prompt token is removed from generation_config since `return_timestamps` is set to `true`."),t.pop()),t.filter(e=>e!=null)}async generate({inputs:e=null,generation_config:t=null,logits_processor:n=null,stopping_criteria:r=null,...i}){t=this._prepare_generation_config(t,i);let a=i.decoder_input_ids instanceof L?Lw(i.decoder_input_ids):i.decoder_input_ids??this._retrieve_init_tokens(t);if(t.return_timestamps&&(n??=new pO,n.push(new Ipe(t,a))),t.begin_suppress_tokens&&(n??=new pO,n.push(new mO(t.begin_suppress_tokens,a.length))),t.return_token_timestamps){if(!t.alignment_heads)throw Error("Model generation config has no `alignment_heads`, token-level timestamps not available. See https://gist.github.com/hollance/42e32852f24243b748ae6bc1f985b13a on how to add this property to the generation config.");t.task===`translate`&&Wb.warn(`Token-level timestamps may not be reliable for task 'translate'.`),t.output_attentions=!0,t.return_dict_in_generate=!0}if(t.return_timestamps&&!i.max_new_tokens)return this._generate_with_seek({inputs:e,generation_config:t,logits_processor:n,init_tokens:a,kwargs:i});let o=await super.generate({inputs:e,generation_config:t,logits_processor:n,decoder_input_ids:a,...i});return t.return_token_timestamps&&(o.token_timestamps=this._extract_token_timestamps(o,t.alignment_heads,t.num_frames,.02,a.length)),o}async _generate_with_seek({inputs:e,generation_config:t,logits_processor:n,init_tokens:r,kwargs:i}){let a=t.no_timestamps_token_id+1,o=Array.isArray(t.eos_token_id)?t.eos_token_id[0]:t.eos_token_id,s=t.return_token_timestamps,c=e,l=c.dims[2],u=2*this.config.max_source_positions,d=0,f=[],p=[];for(;de+n)}if(v.length>0&&v.at(-1)===o&&v.pop(),v.length===0)break;let b=v.map(e=>e>=a),x=v.length>=2&&b[v.length-1]&&!b[v.length-2],S=[];for(let e=0;e0){if(x)C=e-d;else{let e=S.at(-1);C=(v[e-1]-a)*2,w=e}}else C=e-d;let T=Math.floor(d/2),E=a+1500;for(let e=0;e=a&&(v[e]=Math.min(v[e]+T,E));f.push(...v.slice(0,w)),y&&p.push(...y.slice(0,w)),d+=C}f.push(o);let m=[...r,...f];if(s){let e=new L(`int64`,m.map(BigInt),[1,m.length]),t=[...Array(r.length).fill(0),...p,0];return{sequences:e,token_timestamps:new L(`float32`,new Float32Array(t),[1,t.length])}}return new L(`int64`,m.map(BigInt),[1,m.length])}_extract_token_timestamps(e,t,n=null,r=.02,i=0){if(!e.cross_attentions)throw Error("Model outputs must contain cross attentions to extract timestamps. This is most likely because the model was not exported with `output_attentions=True`.");n??Wb.warn("`num_frames` has not been set, meaning the entire audio will be analyzed. This may lead to inaccurate token-level timestamps for short audios (< 30 seconds).");let a=this.config.median_filter_width;a===void 0&&(Wb.warn("Model config has no `median_filter_width`, using default value of 7."),a=7);let o=e.cross_attentions,s=Array.from({length:this.config.decoder_layers},(e,t)=>bw(o.map(e=>e[t]),2)),c=xw(t.map(([e,t])=>{if(e>=s.length)throw Error(`Layer index ${e} is out of bounds for cross attentions (length ${s.length}).`);return n?s[e].slice(null,t,null,[0,n]):s[e].slice(null,t)})).transpose(1,0,2,3),[l,u]=Cw(c,-2,0,!0),d=c.clone();for(let e=0;e0?d.slice(null,null,[i,d.dims[2]],null):d,1)],p=e.sequences.dims,m=new L(`float32`,new Float32Array(p[0]*p[1]),p);for(let e=0;et[n+1]-t[n])).map(e=>!!e),o=[];for(let e=0;e0&&s.push(o.at(-1)),m[e].data.set(s)}return m}},UN=class extends HN{},WN=class extends z{},GN=class extends WN{},KN=class extends WN{async _call(e){return new lO(await super._call(e))}},qN=class extends WN{async _call(e){return new sO(await super._call(e))}},JN=class extends WN{async _call(e){return new cO(await super._call(e))}},YN=class extends WN{async _call(e){return new uO(await super._call(e))}},XN=class extends z{},ZN=class extends XN{},QN=class extends XN{async _call(e){return new lO(await super._call(e))}},$N=class extends XN{async _call(e){return new sO(await super._call(e))}},eP=class extends XN{async _call(e){return new cO(await super._call(e))}},tP=class extends XN{async _call(e){return new uO(await super._call(e))}},nP=class extends z{},rP=class extends nP{},iP=class extends nP{async _call(e){return new aP(await super._call(e))}},aP=class extends oO{constructor({logits:e,pred_boxes:t}){super(),this.logits=e,this.pred_boxes=t}},oP=class extends z{},sP=class extends oP{},cP=class extends oP{},lP=new Map([[`bert`,`BertModel`],[`eurobert`,`EuroBertModel`],[`neobert`,`NeoBertModel`],[`modernbert`,`ModernBertModel`],[`nomic_bert`,`NomicBertModel`],[`roformer`,`RoFormerModel`],[`electra`,`ElectraModel`],[`esm`,`EsmModel`],[`convbert`,`ConvBertModel`],[`camembert`,`CamembertModel`],[`deberta`,`DebertaModel`],[`deberta-v2`,`DebertaV2Model`],[`mpnet`,`MPNetModel`],[`albert`,`AlbertModel`],[`distilbert`,`DistilBertModel`],[`roberta`,`RobertaModel`],[`xlm`,`XLMModel`],[`xlm-roberta`,`XLMRobertaModel`],[`clap`,`ClapModel`],[`clip`,`CLIPModel`],[`clipseg`,`CLIPSegModel`],[`chinese_clip`,`ChineseCLIPModel`],[`siglip`,`SiglipModel`],[`jina_clip`,`JinaCLIPModel`],[`mobilebert`,`MobileBertModel`],[`squeezebert`,`SqueezeBertModel`],[`wav2vec2`,`Wav2Vec2Model`],[`wav2vec2-bert`,`Wav2Vec2BertModel`],[`unispeech`,`UniSpeechModel`],[`unispeech-sat`,`UniSpeechSatModel`],[`hubert`,`HubertModel`],[`wavlm`,`WavLMModel`],[`audio-spectrogram-transformer`,`ASTModel`],[`vits`,`VitsModel`],[`pyannote`,`PyAnnoteModel`],[`wespeaker-resnet`,`WeSpeakerResNetModel`],[`detr`,`DetrModel`],[`rt_detr`,`RTDetrModel`],[`rt_detr_v2`,`RTDetrV2Model`],[`rf_detr`,`RFDetrModel`],[`d_fine`,`DFineModel`],[`table-transformer`,`TableTransformerModel`],[`vit`,`ViTModel`],[`ijepa`,`IJepaModel`],[`pvt`,`PvtModel`],[`vit_msn`,`ViTMSNModel`],[`vit_mae`,`ViTMAEModel`],[`groupvit`,`GroupViTModel`],[`fastvit`,`FastViTModel`],[`mobilevit`,`MobileViTModel`],[`mobilevitv2`,`MobileViTV2Model`],[`owlvit`,`OwlViTModel`],[`owlv2`,`Owlv2Model`],[`beit`,`BeitModel`],[`deit`,`DeiTModel`],[`hiera`,`HieraModel`],[`convnext`,`ConvNextModel`],[`convnextv2`,`ConvNextV2Model`],[`dinov2`,`Dinov2Model`],[`dinov2_with_registers`,`Dinov2WithRegistersModel`],[`dinov3_vit`,`DINOv3ViTModel`],[`dinov3_convnext`,`DINOv3ConvNextModel`],[`resnet`,`ResNetModel`],[`swin`,`SwinModel`],[`swin2sr`,`Swin2SRModel`],[`donut-swin`,`DonutSwinModel`],[`yolos`,`YolosModel`],[`dpt`,`DPTModel`],[`glpn`,`GLPNModel`],[`hifigan`,`SpeechT5HifiGan`],[`efficientnet`,`EfficientNetModel`],[`decision_transformer`,`DecisionTransformerModel`],[`patchtst`,`PatchTSTModel`],[`patchtsmixer`,`PatchTSMixerModel`],[`mobilenet_v1`,`MobileNetV1Model`],[`mobilenet_v2`,`MobileNetV2Model`],[`mobilenet_v3`,`MobileNetV3Model`],[`mobilenet_v4`,`MobileNetV4Model`],[`maskformer`,`MaskFormerModel`],[`mgp-str`,`MgpstrForSceneTextRecognition`],[`style_text_to_speech_2`,`StyleTextToSpeech2Model`],[`openai_privacy_filter`,`OpenAIPrivacyFilterModel`]]),uP=new Map([[`t5`,`T5Model`],[`longt5`,`LongT5Model`],[`mt5`,`MT5Model`],[`bart`,`BartModel`],[`mbart`,`MBartModel`],[`marian`,`MarianModel`],[`whisper`,`WhisperModel`],[`cohere_asr`,`CohereAsrModel`],[`m2m_100`,`M2M100Model`],[`blenderbot`,`BlenderbotModel`],[`blenderbot-small`,`BlenderbotSmallModel`]]),dP=new Map([[`mimi`,`MimiModel`],[`dac`,`DacModel`],[`snac`,`SnacModel`]]),fP=new Map([[`bloom`,`BloomModel`],[`jais`,`JAISModel`],[`gpt2`,`GPT2Model`],[`gpt_oss`,`GptOssModel`],[`gptj`,`GPTJModel`],[`gpt_bigcode`,`GPTBigCodeModel`],[`gpt_neo`,`GPTNeoModel`],[`gpt_neox`,`GPTNeoXModel`],[`codegen`,`CodeGenModel`],[`llama`,`LlamaModel`],[`apertus`,`ApertusModel`],[`nanochat`,`NanoChatModel`],[`arcee`,`ArceeModel`],[`afmoe`,`AfmoeModel`],[`lfm2`,`Lfm2Model`],[`lfm2_moe`,`Lfm2MoeModel`],[`smollm3`,`SmolLM3Model`],[`exaone`,`ExaoneModel`],[`olmo`,`OlmoModel`],[`olmo2`,`Olmo2Model`],[`olmo3`,`Olmo3Model`],[`olmo_hybrid`,`OlmoHybridModel`],[`mobilellm`,`MobileLLMModel`],[`granite`,`GraniteModel`],[`granitemoehybrid`,`GraniteMoeHybridModel`],[`cohere`,`CohereModel`],[`cohere2`,`Cohere2Model`],[`gemma`,`GemmaModel`],[`gemma2`,`Gemma2Model`],[`vaultgemma`,`VaultGemmaModel`],[`gemma3_text`,`Gemma3Model`],[`helium`,`HeliumModel`],[`glm`,`GlmModel`],[`glm_moe_dsa`,`GlmMoeDsaModel`],[`openelm`,`OpenELMModel`],[`qwen2`,`Qwen2Model`],[`qwen2_moe`,`Qwen2MoeModel`],[`qwen3`,`Qwen3Model`],[`qwen3_moe`,`Qwen3MoeModel`],[`qwen3_next`,`Qwen3NextModel`],[`phi`,`PhiModel`],[`phi3`,`Phi3Model`],[`mpt`,`MptModel`],[`opt`,`OPTModel`],[`mistral`,`MistralModel`],[`mistral4`,`Mistral4Model`],[`ministral`,`MinistralModel`],[`ministral3`,`Ministral3Model`],[`ernie4_5`,`Ernie4_5ForCausalLM`],[`starcoder2`,`Starcoder2Model`],[`deepseek_v3`,`DeepseekV3Model`],[`falcon`,`FalconModel`],[`falcon_h1`,`FalconH1Model`],[`nemotron_h`,`NemotronHModel`],[`solar_open`,`SolarOpenModel`],[`stablelm`,`StableLmModel`],[`modernbert-decoder`,`ModernBertDecoderModel`],[`hunyuan_v1_dense`,`HunYuanDenseV1Model`],[`youtu`,`YoutuModel`]]),pP=new Map([[`speecht5`,`SpeechT5ForSpeechToText`],[`whisper`,`WhisperForConditionalGeneration`],[`lite-whisper`,`LiteWhisperForConditionalGeneration`],[`moonshine`,`MoonshineForConditionalGeneration`],[`cohere_asr`,`CohereAsrForConditionalGeneration`]]),mP=new Map([[`speecht5`,`SpeechT5ForTextToSpeech`]]),hP=new Map([[`vits`,`VitsModel`],[`musicgen`,`MusicgenForConditionalGeneration`],[`supertonic`,`SupertonicForConditionalGeneration`]]),gP=new Map([[`bert`,`BertForSequenceClassification`],[`eurobert`,`EuroBertForSequenceClassification`],[`neobert`,`NeoBertForSequenceClassification`],[`modernbert`,`ModernBertForSequenceClassification`],[`roformer`,`RoFormerForSequenceClassification`],[`electra`,`ElectraForSequenceClassification`],[`esm`,`EsmForSequenceClassification`],[`convbert`,`ConvBertForSequenceClassification`],[`camembert`,`CamembertForSequenceClassification`],[`deberta`,`DebertaForSequenceClassification`],[`deberta-v2`,`DebertaV2ForSequenceClassification`],[`mpnet`,`MPNetForSequenceClassification`],[`albert`,`AlbertForSequenceClassification`],[`distilbert`,`DistilBertForSequenceClassification`],[`roberta`,`RobertaForSequenceClassification`],[`xlm`,`XLMForSequenceClassification`],[`xlm-roberta`,`XLMRobertaForSequenceClassification`],[`bart`,`BartForSequenceClassification`],[`mbart`,`MBartForSequenceClassification`],[`mobilebert`,`MobileBertForSequenceClassification`],[`squeezebert`,`SqueezeBertForSequenceClassification`]]),_P=new Map([[`bert`,`BertForTokenClassification`],[`eurobert`,`EuroBertForTokenClassification`],[`neobert`,`NeoBertForTokenClassification`],[`modernbert`,`ModernBertForTokenClassification`],[`roformer`,`RoFormerForTokenClassification`],[`electra`,`ElectraForTokenClassification`],[`esm`,`EsmForTokenClassification`],[`convbert`,`ConvBertForTokenClassification`],[`camembert`,`CamembertForTokenClassification`],[`deberta`,`DebertaForTokenClassification`],[`deberta-v2`,`DebertaV2ForTokenClassification`],[`mpnet`,`MPNetForTokenClassification`],[`distilbert`,`DistilBertForTokenClassification`],[`roberta`,`RobertaForTokenClassification`],[`xlm`,`XLMForTokenClassification`],[`xlm-roberta`,`XLMRobertaForTokenClassification`],[`openai_privacy_filter`,`OpenAIPrivacyFilterForTokenClassification`]]),vP=new Map([[`t5`,`T5ForConditionalGeneration`],[`longt5`,`LongT5ForConditionalGeneration`],[`mt5`,`MT5ForConditionalGeneration`],[`bart`,`BartForConditionalGeneration`],[`mbart`,`MBartForConditionalGeneration`],[`marian`,`MarianMTModel`],[`m2m_100`,`M2M100ForConditionalGeneration`],[`blenderbot`,`BlenderbotForConditionalGeneration`],[`blenderbot-small`,`BlenderbotSmallForConditionalGeneration`]]),yP=new Map([[`bloom`,`BloomForCausalLM`],[`gpt2`,`GPT2LMHeadModel`],[`gpt_oss`,`GptOssForCausalLM`],[`jais`,`JAISLMHeadModel`],[`gptj`,`GPTJForCausalLM`],[`gpt_bigcode`,`GPTBigCodeForCausalLM`],[`gpt_neo`,`GPTNeoForCausalLM`],[`gpt_neox`,`GPTNeoXForCausalLM`],[`codegen`,`CodeGenForCausalLM`],[`llama`,`LlamaForCausalLM`],[`nanochat`,`NanoChatForCausalLM`],[`apertus`,`ApertusForCausalLM`],[`llama4_text`,`Llama4ForCausalLM`],[`arcee`,`ArceeForCausalLM`],[`afmoe`,`AfmoeForCausalLM`],[`lfm2`,`Lfm2ForCausalLM`],[`lfm2_moe`,`Lfm2MoeForCausalLM`],[`smollm3`,`SmolLM3ForCausalLM`],[`exaone`,`ExaoneForCausalLM`],[`olmo`,`OlmoForCausalLM`],[`olmo2`,`Olmo2ForCausalLM`],[`olmo3`,`Olmo3ForCausalLM`],[`olmo_hybrid`,`OlmoHybridForCausalLM`],[`mobilellm`,`MobileLLMForCausalLM`],[`granite`,`GraniteForCausalLM`],[`granitemoehybrid`,`GraniteMoeHybridForCausalLM`],[`cohere`,`CohereForCausalLM`],[`cohere2`,`Cohere2ForCausalLM`],[`gemma`,`GemmaForCausalLM`],[`gemma2`,`Gemma2ForCausalLM`],[`vaultgemma`,`VaultGemmaForCausalLM`],[`gemma3_text`,`Gemma3ForCausalLM`],[`gemma3`,`Gemma3ForCausalLM`],[`helium`,`HeliumForCausalLM`],[`glm`,`GlmForCausalLM`],[`glm_moe_dsa`,`GlmMoeDsaForCausalLM`],[`openelm`,`OpenELMForCausalLM`],[`qwen2`,`Qwen2ForCausalLM`],[`qwen2_moe`,`Qwen2MoeForCausalLM`],[`qwen3`,`Qwen3ForCausalLM`],[`qwen3_moe`,`Qwen3MoeForCausalLM`],[`qwen3_next`,`Qwen3NextForCausalLM`],[`qwen2_vl`,`Qwen2VLForCausalLM`],[`qwen2_5_vl`,`Qwen2_5_VLForCausalLM`],[`qwen3_vl`,`Qwen3VLForCausalLM`],[`qwen3_vl_moe`,`Qwen3VLMoeForCausalLM`],[`qwen3_5`,`Qwen3_5ForCausalLM`],[`qwen3_5_text`,`Qwen3_5ForCausalLM`],[`qwen3_5_moe`,`Qwen3_5MoeForCausalLM`],[`gemma3n`,`Gemma3nForCausalLM`],[`gemma4`,`Gemma4ForCausalLM`],[`phi`,`PhiForCausalLM`],[`phi3`,`Phi3ForCausalLM`],[`mpt`,`MptForCausalLM`],[`opt`,`OPTForCausalLM`],[`mbart`,`MBartForCausalLM`],[`mistral`,`MistralForCausalLM`],[`mistral4`,`Mistral4ForCausalLM`],[`ministral`,`MinistralForCausalLM`],[`ministral3`,`Ministral3ForCausalLM`],[`ernie4_5`,`Ernie4_5ForCausalLM`],[`starcoder2`,`Starcoder2ForCausalLM`],[`deepseek_v3`,`DeepseekV3ForCausalLM`],[`falcon`,`FalconForCausalLM`],[`falcon_h1`,`FalconH1ForCausalLM`],[`nemotron_h`,`NemotronHForCausalLM`],[`trocr`,`TrOCRForCausalLM`],[`solar_open`,`SolarOpenForCausalLM`],[`stablelm`,`StableLmForCausalLM`],[`modernbert-decoder`,`ModernBertDecoderForCausalLM`],[`hunyuan_v1_dense`,`HunYuanDenseV1ForCausalLM`],[`youtu`,`YoutuForCausalLM`],[`phi3_v`,`Phi3VForCausalLM`]]),bP=new Map([[`multi_modality`,`MultiModalityCausalLM`]]),xP=new Map([[`bert`,`BertForMaskedLM`],[`eurobert`,`EuroBertForMaskedLM`],[`neobert`,`NeoBertForMaskedLM`],[`modernbert`,`ModernBertForMaskedLM`],[`roformer`,`RoFormerForMaskedLM`],[`electra`,`ElectraForMaskedLM`],[`esm`,`EsmForMaskedLM`],[`convbert`,`ConvBertForMaskedLM`],[`camembert`,`CamembertForMaskedLM`],[`deberta`,`DebertaForMaskedLM`],[`deberta-v2`,`DebertaV2ForMaskedLM`],[`mpnet`,`MPNetForMaskedLM`],[`albert`,`AlbertForMaskedLM`],[`distilbert`,`DistilBertForMaskedLM`],[`roberta`,`RobertaForMaskedLM`],[`xlm`,`XLMWithLMHeadModel`],[`xlm-roberta`,`XLMRobertaForMaskedLM`],[`mobilebert`,`MobileBertForMaskedLM`],[`squeezebert`,`SqueezeBertForMaskedLM`]]),SP=new Map([[`bert`,`BertForQuestionAnswering`],[`neobert`,`NeoBertForQuestionAnswering`],[`roformer`,`RoFormerForQuestionAnswering`],[`electra`,`ElectraForQuestionAnswering`],[`convbert`,`ConvBertForQuestionAnswering`],[`camembert`,`CamembertForQuestionAnswering`],[`deberta`,`DebertaForQuestionAnswering`],[`deberta-v2`,`DebertaV2ForQuestionAnswering`],[`mpnet`,`MPNetForQuestionAnswering`],[`albert`,`AlbertForQuestionAnswering`],[`distilbert`,`DistilBertForQuestionAnswering`],[`roberta`,`RobertaForQuestionAnswering`],[`xlm`,`XLMForQuestionAnswering`],[`xlm-roberta`,`XLMRobertaForQuestionAnswering`],[`mobilebert`,`MobileBertForQuestionAnswering`],[`squeezebert`,`SqueezeBertForQuestionAnswering`]]),CP=new Map([[`vision-encoder-decoder`,`VisionEncoderDecoderModel`],[`idefics3`,`Idefics3ForConditionalGeneration`],[`smolvlm`,`SmolVLMForConditionalGeneration`]]),wP=new Map([[`llava`,`LlavaForConditionalGeneration`],[`llava_onevision`,`LlavaOnevisionForConditionalGeneration`],[`moondream1`,`Moondream1ForConditionalGeneration`],[`florence2`,`Florence2ForConditionalGeneration`],[`qwen2_vl`,`Qwen2VLForConditionalGeneration`],[`qwen2_5_vl`,`Qwen2_5_VLForConditionalGeneration`],[`qwen3_vl`,`Qwen3VLForConditionalGeneration`],[`qwen3_vl_moe`,`Qwen3VLMoeForConditionalGeneration`],[`qwen3_5`,`Qwen3_5ForConditionalGeneration`],[`qwen3_5_moe`,`Qwen3_5MoeForConditionalGeneration`],[`lfm2_vl`,`Lfm2VlForConditionalGeneration`],[`idefics3`,`Idefics3ForConditionalGeneration`],[`smolvlm`,`SmolVLMForConditionalGeneration`],[`paligemma`,`PaliGemmaForConditionalGeneration`],[`llava_qwen2`,`LlavaQwen2ForCausalLM`],[`gemma3`,`Gemma3ForConditionalGeneration`],[`gemma3n`,`Gemma3nForConditionalGeneration`],[`gemma4`,`Gemma4ForConditionalGeneration`],[`mistral3`,`Mistral3ForConditionalGeneration`],[`lighton_ocr`,`LightOnOcrForConditionalGeneration`],[`glm_ocr`,`GlmOcrForConditionalGeneration`]]),TP=new Map([[`granite_speech`,`GraniteSpeechForConditionalGeneration`],[`ultravox`,`UltravoxModel`],[`voxtral`,`VoxtralForConditionalGeneration`],[`voxtral_realtime`,`VoxtralRealtimeForConditionalGeneration`]]),EP=new Map([[`vision-encoder-decoder`,`VisionEncoderDecoderModel`]]),DP=new Map([[`vit`,`ViTForImageClassification`],[`ijepa`,`IJepaForImageClassification`],[`pvt`,`PvtForImageClassification`],[`vit_msn`,`ViTMSNForImageClassification`],[`fastvit`,`FastViTForImageClassification`],[`mobilevit`,`MobileViTForImageClassification`],[`mobilevitv2`,`MobileViTV2ForImageClassification`],[`beit`,`BeitForImageClassification`],[`deit`,`DeiTForImageClassification`],[`hiera`,`HieraForImageClassification`],[`convnext`,`ConvNextForImageClassification`],[`convnextv2`,`ConvNextV2ForImageClassification`],[`dinov2`,`Dinov2ForImageClassification`],[`dinov2_with_registers`,`Dinov2WithRegistersForImageClassification`],[`resnet`,`ResNetForImageClassification`],[`swin`,`SwinForImageClassification`],[`segformer`,`SegformerForImageClassification`],[`efficientnet`,`EfficientNetForImageClassification`],[`mobilenet_v1`,`MobileNetV1ForImageClassification`],[`mobilenet_v2`,`MobileNetV2ForImageClassification`],[`mobilenet_v3`,`MobileNetV3ForImageClassification`],[`mobilenet_v4`,`MobileNetV4ForImageClassification`]]),OP=new Map([[`detr`,`DetrForObjectDetection`],[`rt_detr`,`RTDetrForObjectDetection`],[`rt_detr_v2`,`RTDetrV2ForObjectDetection`],[`rf_detr`,`RFDetrForObjectDetection`],[`d_fine`,`DFineForObjectDetection`],[`table-transformer`,`TableTransformerForObjectDetection`],[`yolos`,`YolosForObjectDetection`]]),kP=new Map([[`owlvit`,`OwlViTForObjectDetection`],[`owlv2`,`Owlv2ForObjectDetection`],[`grounding-dino`,`GroundingDinoForObjectDetection`]]),AP=new Map([[`detr`,`DetrForSegmentation`],[`clipseg`,`CLIPSegForImageSegmentation`]]),jP=new Map([[`segformer`,`SegformerForSemanticSegmentation`],[`sapiens`,`SapiensForSemanticSegmentation`],[`swin`,`SwinForSemanticSegmentation`],[`mobilenet_v1`,`MobileNetV1ForSemanticSegmentation`],[`mobilenet_v2`,`MobileNetV2ForSemanticSegmentation`],[`mobilenet_v3`,`MobileNetV3ForSemanticSegmentation`],[`mobilenet_v4`,`MobileNetV4ForSemanticSegmentation`]]),MP=new Map([[`detr`,`DetrForSegmentation`],[`maskformer`,`MaskFormerForInstanceSegmentation`]]),NP=new Map([[`sam`,`SamModel`],[`sam2`,`Sam2Model`],[`edgetam`,`EdgeTamModel`],[`sam3_tracker`,`Sam3TrackerModel`]]),PP=new Map([[`wav2vec2`,`Wav2Vec2ForCTC`],[`wav2vec2-bert`,`Wav2Vec2BertForCTC`],[`unispeech`,`UniSpeechForCTC`],[`unispeech-sat`,`UniSpeechSatForCTC`],[`wavlm`,`WavLMForCTC`],[`hubert`,`HubertForCTC`],[`parakeet_ctc`,`ParakeetForCTC`]]),FP=new Map([[`wav2vec2`,`Wav2Vec2ForSequenceClassification`],[`wav2vec2-bert`,`Wav2Vec2BertForSequenceClassification`],[`unispeech`,`UniSpeechForSequenceClassification`],[`unispeech-sat`,`UniSpeechSatForSequenceClassification`],[`wavlm`,`WavLMForSequenceClassification`],[`hubert`,`HubertForSequenceClassification`],[`audio-spectrogram-transformer`,`ASTForAudioClassification`]]),IP=new Map([[`wavlm`,`WavLMForXVector`]]),LP=new Map([[`unispeech-sat`,`UniSpeechSatForAudioFrameClassification`],[`wavlm`,`WavLMForAudioFrameClassification`],[`wav2vec2`,`Wav2Vec2ForAudioFrameClassification`],[`pyannote`,`PyAnnoteForAudioFrameClassification`]]),RP=new Map([[`vitmatte`,`VitMatteForImageMatting`]]),zP=new Map([[`patchtst`,`PatchTSTForPrediction`],[`patchtsmixer`,`PatchTSMixerForPrediction`]]),BP=new Map([[`swin2sr`,`Swin2SRForImageSuperResolution`]]),VP=new Map([[`chmv2`,`CHMv2ForDepthEstimation`],[`dpt`,`DPTForDepthEstimation`],[`depth_anything`,`DepthAnythingForDepthEstimation`],[`glpn`,`GLPNForDepthEstimation`],[`sapiens`,`SapiensForDepthEstimation`],[`depth_pro`,`DepthProForDepthEstimation`],[`metric3d`,`Metric3DForDepthEstimation`],[`metric3dv2`,`Metric3Dv2ForDepthEstimation`]]),HP=new Map([[`sapiens`,`SapiensForNormalEstimation`]]),UP=new Map([[`vitpose`,`VitPoseForPoseEstimation`]]),WP=new Map([[`clip`,`CLIPVisionModelWithProjection`],[`siglip`,`SiglipVisionModel`],[`jina_clip`,`JinaCLIPVisionModel`]]),GP=[[lP,R.EncoderOnly],[uP,R.EncoderDecoder],[fP,R.DecoderOnlyWithoutHead],[dP,R.AutoEncoder],[gP,R.EncoderOnly],[_P,R.EncoderOnly],[vP,R.Seq2Seq],[pP,R.Seq2Seq],[yP,R.DecoderOnly],[bP,R.MultiModality],[xP,R.EncoderOnly],[SP,R.EncoderOnly],[CP,R.Vision2Seq],[wP,R.ImageTextToText],[TP,R.AudioTextToText],[DP,R.EncoderOnly],[AP,R.EncoderOnly],[MP,R.EncoderOnly],[jP,R.EncoderOnly],[RP,R.EncoderOnly],[zP,R.EncoderOnly],[BP,R.EncoderOnly],[VP,R.EncoderOnly],[HP,R.EncoderOnly],[UP,R.EncoderOnly],[OP,R.EncoderOnly],[kP,R.EncoderOnly],[NP,R.MaskGeneration],[PP,R.EncoderOnly],[FP,R.EncoderOnly],[mP,R.Seq2Seq],[hP,R.EncoderOnly],[IP,R.EncoderOnly],[LP,R.EncoderOnly],[WP,R.EncoderOnly]];for(let[e,t]of GP)for(let n of e.values()){EO.set(n,t);let e=UO[n];OO.set(e,n),DO.set(n,e)}var KP=[[`MusicgenForConditionalGeneration`,xj,R.Musicgen],[`Phi3VForCausalLM`,Vj,R.Phi3V],[`CLIPTextModelWithProjection`,dk,R.EncoderOnly],[`SiglipTextModel`,mM,R.EncoderOnly],[`JinaCLIPTextModel`,RA,R.EncoderOnly],[`ClapTextModelWithProjection`,ck,R.EncoderOnly],[`ClapAudioModelWithProjection`,lk,R.EncoderOnly],[`DacEncoderModel`,Ek,R.EncoderOnly],[`DacDecoderModel`,Dk,R.EncoderOnly],[`MimiEncoderModel`,tj,R.EncoderOnly],[`MimiDecoderModel`,nj,R.EncoderOnly],[`SnacEncoderModel`,_M,R.EncoderOnly],[`SnacDecoderModel`,vM,R.EncoderOnly],[`Gemma3nForConditionalGeneration`,cA,R.ImageAudioTextToText],[`Gemma4ForConditionalGeneration`,lA,R.ImageAudioTextToText],[`SupertonicForConditionalGeneration`,EM,R.Supertonic],[`ChatterboxModel`,ik,R.Chatterbox],[`VoxtralRealtimeForConditionalGeneration`,TN,R.VoxtralRealtime]];for(let[e,t,n]of KP)EO.set(e,n),OO.set(t,e),DO.set(e,t);var qP=new Map([[`modnet`,AP],[`birefnet`,AP],[`isnet`,AP],[`ben`,AP]]);for(let[e,t]of qP.entries())t.set(e,`PreTrainedModel`),EO.set(e,R.EncoderOnly),DO.set(e,z);var JP=new Set(qP.keys());EO.set(`PreTrainedModel`,R.EncoderOnly),OO.set(z,`PreTrainedModel`);var YP={MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES:gP,MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES:_P,MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES:mP,MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES:hP,MODEL_FOR_MASKED_LM_MAPPING_NAMES:xP,MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES:SP,MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES:DP,MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES:AP,MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES:jP,MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES:MP,MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES:OP,MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES:kP,MODEL_FOR_MASK_GENERATION_MAPPING_NAMES:NP,MODEL_FOR_CTC_MAPPING_NAMES:PP,MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES:FP,MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES:IP,MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES:LP,MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES:EP,MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES:RP,MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES:BP,MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES:VP,MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES:HP,MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES:UP,MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES:WP,MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES:wP,MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES:TP,MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES:vP,MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES:pP,MODEL_FOR_CAUSAL_LM_MAPPING_NAMES:yP,MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES:CP};eme(YP);var XP=class{static MODEL_CLASS_MAPPINGS=null;static BASE_IF_FAIL=!1;static supports(e){if(!this.MODEL_CLASS_MAPPINGS)return!1;for(let t of this.MODEL_CLASS_MAPPINGS)if(t.has(e))return!0;return this.BASE_IF_FAIL}static async from_pretrained(e,{progress_callback:t=null,config:n=null,cache_dir:r=null,local_files_only:i=!1,revision:a=`main`,model_file_name:o=null,subfolder:s=`onnx`,device:c=null,dtype:l=null,use_external_data_format:u=null,session_options:d={}}={}){let f={progress_callback:t,config:n,cache_dir:r,local_files_only:i,revision:a,model_file_name:o,subfolder:s,device:c,dtype:l,use_external_data_format:u,session_options:d};if(f.config=await tO.from_pretrained(e,f),!this.MODEL_CLASS_MAPPINGS)throw Error("`MODEL_CLASS_MAPPINGS` not implemented for this type of `AutoClass`: "+this.name);let{model_type:p}=f.config;for(let t of this.MODEL_CLASS_MAPPINGS){let n=t.get(p);if(!n){for(let e of t.values())if(e[0]===p){n=e;break}if(!n)continue}return await UO[n].from_pretrained(e,f)}if(this.BASE_IF_FAIL)return JP.has(p)||Wb.warn(`Unknown model class "${p}", attempting to construct from base class.`),await z.from_pretrained(e,f);throw Error(`Unsupported model type: ${p}`)}},ZP=class extends XP{static MODEL_CLASS_MAPPINGS=GP.map(e=>e[0]);static BASE_IF_FAIL=!0},QP=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES]},$P=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES]},eF=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES]},tF=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES]},nF=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES]},rF=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES]},iF=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES]},aF=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_MASKED_LM_MAPPING_NAMES]},oF=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES]},sF=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES]},cF=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES]},lF=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES]},uF=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES]},dF=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES]},fF=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES]},pF=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES]};(class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_MASK_GENERATION_MAPPING_NAMES]});var mF=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_CTC_MAPPING_NAMES]},hF=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES]};(class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES]}),class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES]};var gF=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES]};(class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES]});var _F=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES]},vF=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES]};(class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES]}),class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES]};var yF=class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES]};(class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES]}),class extends XP{static MODEL_CLASS_MAPPINGS=[YP.MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES]};async function bF(e){return Array.isArray(e)||(e=[e]),await Promise.all(e.map(e=>$E.read(e)))}async function xF(e,t){return Array.isArray(e)||(e=[e]),await Promise.all(e.map(e=>typeof e==`string`||e instanceof URL?rE(e,t):e instanceof Float64Array?new Float32Array(e):e))}function SF(e,t){t&&(e=e.map(e=>e|0));let[n,r,i,a]=e;return{xmin:n,ymin:r,xmax:i,ymax:a}}var CF=class extends Nb{constructor({task:e,model:t,tokenizer:n=null,processor:r=null}){super(),this.task=e,this.model=t,this.tokenizer=n,this.processor=r}async dispose(){await this.model.dispose()}},wF=class extends CF{async _call(e,{top_k:t=1}={}){let n=this.tokenizer(e,{padding:!0,truncation:!0}),r=await this.model(n),{problem_type:i,id2label:a}=this.model.config,o=i===`multi_label_classification`?e=>e.sigmoid():e=>new L(`float32`,hC(e.data),e.dims),s=[];for(let e of r.logits){let n=await pw(o(e),t),r=n[0].tolist(),i=n[1].tolist().map((e,t)=>({label:a?a[e]:`LABEL_${e}`,score:r[t]}));t===1?s.push(...i):s.push(i)}return Array.isArray(e)||t===1?s:s[0]}},TF=class extends CF{async _call(e,{ignore_labels:t=[`O`],aggregation_strategy:n=`none`}={}){if(n!==`none`&&n!==`simple`)throw Error(`Invalid aggregation_strategy: "${n}". Must be one of "none" or "simple".`);let r=Array.isArray(e),i=this.tokenizer(r?e:[e],{padding:!0,truncation:!0}),a=(await this.model(i)).logits,o=this.model.config.id2label,s=[];for(let e=0;e{let o=0,s=[];for(let n=i;ne==u),i=a[e].tolist(),f=o[e].tolist();for(let n=1;ne==t[n])!==-1)&&(i[n]=-1/0,f[n]=-1/0);let p=hC(i).map((e,t)=>[e,t]),m=hC(f).map((e,t)=>[e,t]);p[0][0]=0,m[0][0]=0;let h=Bb(p,m).filter(e=>e[0][1]<=e[1][1]).map(e=>[e[0][1],e[1][1],e[0][0]*e[1][0]]).sort((e,t)=>t[2]-e[2]),g=[];for(let e=0;ee==n);if(c===-1)throw Error(`Mask token (${r}) not found in text.`);let l=a[e][c],u=await pw(new L(`float32`,hC(l.data),l.dims),t),d=u[0].tolist(),f=u[1].tolist();o.push(f.map((e,t)=>{let n=i.slice();return n[c]=e,{score:d[t],token:Number(e),token_str:this.tokenizer.decode([e]),sequence:this.tokenizer.decode(n,{skip_special_tokens:!0})}}))}return Array.isArray(e)?o:o[0]}},AF=class extends CF{_default_generation_config={max_new_tokens:256};_key=`generated_text`;async _call(e,t={}){Array.isArray(e)||(e=[e]),this.model.config.prefix&&(e=e.map(e=>this.model.config.prefix+e));let n=this.model.config.task_specific_params;n&&n[this.task]&&n[this.task].prefix&&(e=e.map(e=>n[this.task].prefix+e));let r=this.tokenizer,i={padding:!0,truncation:!0},a;a=this.task===`translation`&&`_build_translation_inputs`in r?r._build_translation_inputs(e,i,t):r(e,i);let o=await this.model.generate({...a,...this._default_generation_config,...t});return r.batch_decode(o,{skip_special_tokens:!0}).map(e=>({[this._key]:e}))}},jF=class extends AF{_key=`summary_text`},MF=class extends AF{_key=`translation_text`};function NF(e){return Array.isArray(e)&&e.every(e=>`role`in e&&`content`in e)}var PF=class extends CF{_default_generation_config={max_new_tokens:256};async _call(e,t={}){let{add_special_tokens:n,return_full_text:r,tools:i,documents:a,chat_template:o,tokenizer_encode_kwargs:s,...c}=t,l=!1,u=!1,d=n??(this.tokenizer.add_bos_token||this.tokenizer.add_eos_token)??!1,f=s,p;if(typeof e==`string`)p=e=[e];else if(Array.isArray(e)&&e.every(e=>typeof e==`string`))l=!0,p=e;else{if(NF(e))e=[e];else if(Array.isArray(e)&&e.every(NF))l=!0;else throw Error(`Input must be a string, an array of strings, a Chat, or an array of Chats`);u=!0;let t={tokenize:!1,add_generation_prompt:!0,...Hb({tools:i,documents:a,chat_template:o},[`tools`,`documents`,`chat_template`]),...f};p=e.map(e=>this.tokenizer.apply_chat_template(e,t)),d=!1,f=void 0}let m=u?!1:r??!0;this.tokenizer.padding_side=`left`;let h=this.tokenizer(p,{add_special_tokens:d,padding:!0,truncation:!0,...f}),g=await this.model.generate({...h,...this._default_generation_config,...c}),_=this.tokenizer.batch_decode(g,{skip_special_tokens:!0}),v;!m&&h.input_ids.dims.at(-1)>0&&(v=this.tokenizer.batch_decode(h.input_ids,{skip_special_tokens:!0}).map(e=>e.length));let y=Array.from({length:e.length},e=>[]);for(let t=0;t<_.length;++t){let n=Math.floor(t/g.dims[0]*e.length);v&&(_[t]=_[t].slice(v[n])),y[n].push({generated_text:u?[...e[n],{role:`assistant`,content:_[t]}]:_[t]})}return!l&&y.length===1?y[0]:y}},FF=class extends CF{constructor(e){super(e),this.label2id=Object.fromEntries(Object.entries(this.model.config.label2id).map(([e,t])=>[e.toLowerCase(),t])),this.entailment_id=this.label2id.entailment,this.entailment_id===void 0&&(Wb.warn(`Could not find 'entailment' in label2id mapping. Using 2 as entailment_id.`),this.entailment_id=2),this.contradiction_id=this.label2id.contradiction??this.label2id.not_entailment,this.contradiction_id===void 0&&(Wb.warn(`Could not find 'contradiction' in label2id mapping. Using 0 as contradiction_id.`),this.contradiction_id=0)}async _call(e,t,{hypothesis_template:n=`This example is {}.`,multi_label:r=!1}={}){let i=Array.isArray(e);i||(e=[e]),Array.isArray(t)||(t=[t]);let a=t.map(e=>n.replace(`{}`,e)),o=r||t.length===1,s=[];for(let n of e){let e=[];for(let t of a){let r=this.tokenizer(n,{text_pair:t,padding:!0,truncation:!0}),i=await this.model(r);o?e.push([i.logits.data[this.contradiction_id],i.logits.data[this.entailment_id]]):e.push(i.logits.data[this.entailment_id])}let r=(o?e.map(e=>hC(e)[1]):hC(e)).map((e,t)=>[e,t]).sort((e,t)=>t[0]-e[0]);s.push({sequence:n,labels:r.map(e=>t[e[1]]),scores:r.map(e=>e[0])})}return i?s:s[0]}},IF=class extends CF{async _call(e,{top_k:t=5}={}){let n=this.processor.feature_extractor.config.sampling_rate,r=await xF(e,n),i=this.model.config.id2label,a=[];for(let e of r){let n=await this.processor(e),r=(await this.model(n)).logits[0],o=await pw(new L(`float32`,hC(r.data),r.dims),t),s=o[0].tolist(),c=o[1].tolist().map((e,t)=>({label:i?i[e]:`LABEL_${e}`,score:s[t]}));a.push(c)}return Array.isArray(e)?a:a[0]}},LF=class extends CF{async _call(e,t,{hypothesis_template:n=`This is a sound of {}.`}={}){let r=!Array.isArray(e);r&&(e=[e]);let i=t.map(e=>n.replace(`{}`,e)),a=this.tokenizer(i,{padding:!0,truncation:!0}),o=this.processor.feature_extractor.config.sampling_rate,s=await xF(e,o),c=[];for(let e of s){let n=await this.processor(e),r=hC((await this.model({...a,...n})).logits_per_audio.data);c.push([...r].map((e,n)=>({score:e,label:t[n]})))}return r?c[0]:c}},RF=class extends CF{_default_generation_config={};async _call(e,t={}){switch(t={...this._default_generation_config,...t},this.model.config.model_type){case`whisper`:case`lite-whisper`:return this._call_whisper(e,t);case`wav2vec2`:case`wav2vec2-bert`:case`unispeech`:case`unispeech-sat`:case`hubert`:case`parakeet_ctc`:return this._call_wav2vec2(e,t);case`moonshine`:return this._call_moonshine(e,t);case`cohere_asr`:return this._call_cohere_asr(e,t);default:throw Error(`AutomaticSpeechRecognitionPipeline does not support model type '${this.model.config.model_type}'.`)}}async _call_wav2vec2(e,t){t.language&&Wb.warn('`language` parameter is not yet supported for `wav2vec2` models, defaulting to "English".'),t.task&&Wb.warn('`task` parameter is not yet supported for `wav2vec2` models, defaulting to "transcribe".');let n=!Array.isArray(e),r=n?[e]:e,i=this.processor.feature_extractor.config.sampling_rate,a=await xF(r,i),o=[];for(let e of a){let t=await this.processor(e),n=(await this.model(t)).logits[0],r=[];for(let e of n)r.push(_C(e.data)[1]);let i=this.tokenizer.decode(r,{skip_special_tokens:!0}).trim();o.push({text:i})}return n?o[0]:o}async _call_whisper(e,t){let n=t.return_timestamps??!1,r=t.chunk_length_s??0,i=t.force_full_sequences??!1,a=t.stride_length_s??null,o={...t};n===`word`&&(o.return_token_timestamps=!0,o.return_timestamps=!0);let s=!Array.isArray(e),c=s?[e]:e,l=this.processor.feature_extractor.config,u=l.chunk_length/this.model.config.max_source_positions,d=l.hop_length,f=l.sampling_rate,p=await xF(c,f),m=[];for(let e of p){let t=[];if(r>0){if(a===null)a=r/6;else if(r<=a)throw Error("`chunk_length_s` must be larger than `stride_length_s`.");let n=f*r,i=f*a,o=n-2*i,s=0;for(;;){let r=s+n,a=e.subarray(s,r),c=await this.processor(a),l=s===0,u=r>=e.length;if(t.push({stride:[a.length,l?0:i,u?0:i],input_features:c.input_features,is_last:u}),u)break;s+=o}}else t=[{stride:[e.length,0,0],input_features:(await this.processor(e)).input_features,is_last:!0}];for(let e of t){o.num_frames=Math.floor(e.stride[0]/d);let t=await this.model.generate({inputs:e.input_features,...o});if(n===`word`){let n=t.sequences.tolist()[0],r=t.token_timestamps.tolist()[0],i=this.tokenizer.timestamp_begin,a=Math.max(n.findIndex(e=>Number(e)>=i),0);e.tokens=n.slice(a),e.token_timestamps=r.slice(a).map(e=>CC(e,2))}else e.tokens=t[0].tolist();e.stride=e.stride.map(e=>e/f)}let[s,c]=this.tokenizer._decode_asr(t,{time_precision:u,return_timestamps:n,force_full_sequences:i});m.push({text:s,...c})}return s?m[0]:m}async _call_moonshine(e,t){let n=!Array.isArray(e),r=n?[e]:e,i=this.processor.feature_extractor.config.sampling_rate,a=await xF(r,i),o=[];for(let e of a){let n=await this.processor(e),r=Math.floor(e.length/i)*6,a=await this.model.generate({max_new_tokens:r,...t,...n}),s=this.processor.batch_decode(a,{skip_special_tokens:!0})[0];o.push({text:s})}return n?o[0]:o}async _call_cohere_asr(e,t){let n=!Array.isArray(e),r=n?[e]:e,i=this.processor.feature_extractor,a=i.config.sampling_rate,o=await xF(r,a),s=t.language??`en`,c=this.processor.get_decoder_prompt_ids(s),l=[];for(let e of o){let n=i.split_audio(e),r=[];for(let e of n){let n=await this.processor(e),i=await this.model.generate({...n,decoder_input_ids:c,...t}),a=this.tokenizer.decode(i[0].tolist(),{skip_special_tokens:!0}).trim();r.push(a)}let a=this.processor.constructor.join_chunks(r,s);l.push({text:a})}return n?l[0]:l}},zF=class extends CF{DEFAULT_VOCODER_ID=`Xenova/speecht5_hifigan`;constructor(e){super(e),this.vocoder=e.vocoder??null}async _prepare_speaker_embeddings(e,t){if((typeof e==`string`||e instanceof URL)&&(e=new Float32Array(await(await jb.fetch(e)).arrayBuffer())),e instanceof Float32Array)e=new L(`float32`,e,[e.length]);else if(!(e instanceof L))throw Error("Speaker embeddings must be a `Tensor`, `Float32Array`, `string`, or `URL`.");if(t>1){if(e.dims[0]===1)e=e.repeat(t,1);else if(e.dims[0]!==t)throw Error(`Expected speaker embeddings batch size to be 1 or ${t}, but got ${e.dims[0]}.`)}return e}_postprocess_waveform(e,t,n,r=null){let i=t.data,[a,o]=t.dims,s=r?r.data:null,c=[];for(let e=0;e({generated_text:e.trim()}));a.push(r)}return n?a:a[0]}},VF=class extends CF{async _call(e,{top_k:t=5}={}){let n=await bF(e),{pixel_values:r}=await this.processor(n),i=await this.model({pixel_values:r}),{id2label:a}=this.model.config,o=[];for(let e of i.logits){let n=await pw(new L(`float32`,hC(e.data),e.dims),t),r=n[0].tolist(),i=n[1].tolist().map((e,t)=>({label:a?a[e]:`LABEL_${e}`,score:r[t]}));o.push(i)}return Array.isArray(e)?o:o[0]}},HF={panoptic:`post_process_panoptic_segmentation`,instance:`post_process_instance_segmentation`,semantic:`post_process_semantic_segmentation`},UF=class extends CF{async _call(e,{threshold:t=.5,mask_threshold:n=.5,overlap_mask_area_threshold:r=.8,label_ids_to_fuse:i=null,target_sizes:a=null,subtask:o=null}={}){if(Array.isArray(e)&&e.length!==1)throw Error(`Image segmentation pipeline currently only supports a batch size of 1.`);let s=await bF(e),c=s.map(e=>[e.height,e.width]),l=await this.processor(s),{inputNames:u,outputNames:d}=this.model.sessions.model;if(!u.includes(`pixel_values`)){if(u.length!==1)throw Error(`Expected a single input name, but got ${u.length} inputs: ${u}.`);let e=u[0];if(e in l)throw Error(`Input name ${e} already exists in the inputs.`);l[e]=l.pixel_values}let f=await this.model(l),p=null;if(o!==null)p=HF[o];else if(this.processor.image_processor){for(let[e,t]of Object.entries(HF))if(t in this.processor.image_processor){p=this.processor.image_processor[t].bind(this.processor.image_processor),o=e;break}}let m=this.model.config.id2label,h=[];if(!o){let e=f[d[0]];for(let t=0;te<-1e-5||e>1.00001)&&r.sigmoid_();let i=await $E.fromTensor(r.mul_(255).to(`uint8`)).resize(n[1],n[0]);h.push({label:null,score:null,mask:i})}}else if(o===`panoptic`||o===`instance`){let e=p(f,t,n,r,i,a??c)[0],o=e.segmentation;for(let t of e.segments_info){let e=new Uint8ClampedArray(o.data.length);for(let n=0;n{let n=e.clone();return n.putAlpha(r[t].mask),n});return Array.isArray(e)?i:i[0]}},model:[lF,uF,dF],default:{model:`Xenova/modnet`},type:`image`},"zero-shot-image-classification":{pipeline:class extends CF{async _call(e,t,{hypothesis_template:n=`This is a photo of {}`}={}){let r=Array.isArray(e),i=await bF(e),a=t.map(e=>n.replace(`{}`,e)),o=this.tokenizer(a,{padding:this.model.config.model_type!==`siglip`||`max_length`,truncation:!0}),{pixel_values:s}=await this.processor(i),c=await this.model({...o,pixel_values:s}),l=this.model.config.model_type===`siglip`?e=>e.sigmoid().data:e=>hC(e.data),u=[];for(let e of c.logits_per_image){let n=[...l(e)].map((e,n)=>({score:e,label:t[n]}));n.sort((e,t)=>t.score-e.score),u.push(n)}return r?u:u[0]}},model:ZP,default:{model:`Xenova/clip-vit-base-patch32`},type:`multimodal`},"object-detection":{pipeline:class extends CF{async _call(e,{threshold:t=.9,percentage:n=!1}={}){let r=Array.isArray(e);if(r&&e.length!==1)throw Error(`Object detection pipeline currently only supports a batch size of 1.`);let i=await bF(e),a=n?null:i.map(e=>[e.height,e.width]),{pixel_values:o,pixel_mask:s}=await this.processor(i),c=await this.model({pixel_values:o,pixel_mask:s}),l=this.processor.image_processor.post_process_object_detection(c,t,a),{id2label:u}=this.model.config,d=l.map(e=>e.boxes.map((t,r)=>({score:e.scores[r],label:u[e.classes[r]],box:SF(t,!n)})));return r?d:d[0]}},model:fF,default:{model:`Xenova/detr-resnet-50`},type:`multimodal`},"zero-shot-object-detection":{pipeline:class extends CF{async _call(e,t,{threshold:n=.1,top_k:r=null,percentage:i=!1}={}){let a=Array.isArray(e),o=await bF(e),s=this.tokenizer(t,{padding:!0,truncation:!0}),c=await this.processor(o),l=[];for(let e=0;e({score:e.scores[n],label:e.labels[n],box:SF(t,!i)}))}else{let e=this.processor.image_processor.post_process_object_detection(f,n,u,!0)[0];p=e.boxes.map((n,r)=>({score:e.scores[r],label:t[e.classes[r]],box:SF(n,!i)}))}p.sort((e,t)=>t.score-e.score),r!==null&&(p=p.slice(0,r)),l.push(p)}return a?l:l[0]}},model:pF,default:{model:`Xenova/owlvit-base-patch32`},type:`multimodal`},"document-question-answering":{pipeline:class extends CF{_default_generation_config={max_new_tokens:256};async _call(e,t,n={}){if(Array.isArray(e)){if(e.length!==1)throw Error(`Document Question Answering pipeline currently only supports a batch size of 1.`);e=e[0]}let r=(await bF(e))[0],{pixel_values:i}=await this.processor(r),a=`${t}`,o=this.tokenizer(a,{add_special_tokens:!1,padding:!0,truncation:!0}).input_ids,s=await this.model.generate({inputs:i,max_length:this.model.config.decoder.max_position_embeddings,decoder_input_ids:o,...this._default_generation_config,...n}),c=this.tokenizer.batch_decode(s)[0].match(/(.*?)<\/s_answer>/),l=null;return c&&c.length>=2&&(l=c[1].trim()),[{answer:l}]}},model:gF,default:{model:`Xenova/donut-base-finetuned-docvqa`},type:`multimodal`},"image-to-image":{pipeline:class extends CF{async _call(e){let t=await bF(e),n=await this.processor(t),r=await this.model(n),i=[];for(let e of r.reconstruction){let t=e.squeeze().clamp_(0,1).mul_(255).round_().to(`uint8`);i.push($E.fromTensor(t))}return Array.isArray(e)?i:i[0]}},model:_F,default:{model:`Xenova/swin2SR-classical-sr-x2-64`},type:`image`},"depth-estimation":{pipeline:class extends CF{async _call(e){let t=await bF(e),n=await this.processor(t),{predicted_depth:r}=await this.model(n),i=[];for(let e=0;ee>=19968&&e<=40959||e>=13312&&e<=19903||e>=131072&&e<=173791||e>=173824&&e<=177983||e>=177984&&e<=178207||e>=178208&&e<=183983||e>=63744&&e<=64255||e>=194560&&e<=195103,GF=class{put(e){throw Error(`Not implemented`)}end(){throw Error(`Not implemented`)}},KF=wb.IS_PROCESS_AVAILABLE?e=>process.stdout.write(e):e=>console.log(e),qF=class extends GF{constructor(e,{skip_prompt:t=!1,callback_function:n=null,token_callback_function:r=null,skip_special_tokens:i=!0,decode_kwargs:a={},...o}={}){super(),this.tokenizer=e,this.skip_prompt=t,this.callback_function=n??KF,this.token_callback_function=r,this.decode_kwargs={skip_special_tokens:i,...a,...o},this.token_cache=[],this.print_len=0,this.next_tokens_are_prompt=!0,this.special_ids=new Set(this.tokenizer.all_special_ids.map(BigInt))}put(e){if(e.length>1)throw Error(`TextStreamer only supports batch size of 1`);let t=this.next_tokens_are_prompt;if(t&&(this.next_tokens_are_prompt=!1,this.skip_prompt))return;let n=e[0];if(this.token_callback_function?.(n),n.length===1&&this.special_ids.has(n[0])){if(this.decode_kwargs.skip_special_tokens)return;if(this.token_cache.length>0){let e=this.tokenizer.decode(this.token_cache,this.decode_kwargs).slice(this.print_len);this.on_finalized_text(e,!1),this.token_cache=[],this.print_len=0}let e=this.tokenizer.decode(n,this.decode_kwargs);this.on_finalized_text(e,!1);return}this.token_cache=zb(this.token_cache,n);let r=this.tokenizer.decode(this.token_cache,this.decode_kwargs),i;t||r.endsWith(` `)?(i=r.slice(this.print_len),this.token_cache=[],this.print_len=0):r.length>0&&WF(r.charCodeAt(r.length-1))?(i=r.slice(this.print_len),this.print_len+=i.length):(i=r.slice(this.print_len,r.lastIndexOf(` `)+1),this.print_len+=i.length),this.on_finalized_text(i,!1)}end(){let e;this.token_cache.length>0?(e=this.tokenizer.decode(this.token_cache,this.decode_kwargs).slice(this.print_len),this.token_cache=[],this.print_len=0):e=``,this.next_tokens_are_prompt=!0,this.on_finalized_text(e,!0)}on_finalized_text(e,t){e.length>0&&this.callback_function?.(e),t&&this.callback_function===KF&&wb.IS_PROCESS_AVAILABLE&&this.callback_function?.(` `)}};Object.keys(aw); /*! * hash-wasm (https://www.npmjs.com/package/hash-wasm) * (c) Dani Biro * @license MIT */ function JF(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}var YF=class{constructor(){this.mutex=Promise.resolve()}lock(){let e=()=>{};return this.mutex=this.mutex.then(()=>new Promise(e)),new Promise(t=>{e=t})}dispatch(e){return JF(this,void 0,void 0,function*(){let t=yield this.lock();try{return yield Promise.resolve(e())}finally{t()}})}};function XF(){return typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:global}const ZF=XF(),QF=ZF.Buffer??null,$F=ZF.TextEncoder?new ZF.TextEncoder:null;function eI(e,t){return(e&15)+(e>>6|e>>3&8)<<4|(t&15)+(t>>6|t>>3&8)}function tI(e,t){let n=t.length>>1;for(let r=0;r>>4;e[r++]=n>9?n+87:n+48,n=t[i]&15,e[r++]=n>9?n+87:n+48}return String.fromCharCode.apply(null,e)}const iI=QF===null?e=>{if(typeof e==`string`)return $F.encode(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw Error(`Invalid data type!`)}:e=>{if(typeof e==`string`){let t=QF.from(e,`utf8`);return new Uint8Array(t.buffer,t.byteOffset,t.length)}if(QF.isBuffer(e))return new Uint8Array(e.buffer,e.byteOffset,e.length);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw Error(`Invalid data type!`)},aI=new Uint8Array(256);for(let e=0;e<64;e++)aI[`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.charCodeAt(e)]=e;function oI(e){let t=Math.floor(e.length*.75),n=e.length;return e[n-1]===`=`&&(--t,e[n-2]===`=`&&--t),t}function sI(e){let t=oI(e),n=e.length,r=new Uint8Array(t),i=0;for(let t=0;t>4,i+=1,r[i]=(a&15)<<4|o>>2,i+=1,r[i]=(o&3)<<6|s&63,i+=1}return r}const cI=16384,lI=new YF,uI=new Map;function dI(e,t){return JF(this,void 0,void 0,function*(){let n=null,r=null,i=!1;if(typeof WebAssembly>`u`)throw Error(`WebAssembly is not supported in this environment!`);let a=(e,t=0)=>{r.set(e,t)},o=()=>r,s=()=>n.exports,c=e=>{n.exports.Hash_SetMemorySize(e);let t=n.exports.Hash_GetBuffer(),i=n.exports.memory.buffer;r=new Uint8Array(i,t,e)},l=()=>new DataView(n.exports.memory.buffer).getUint32(n.exports.STATE_SIZE,!0),u=lI.dispatch(()=>JF(this,void 0,void 0,function*(){if(!uI.has(e.name)){let t=sI(e.data),n=WebAssembly.compile(t);uI.set(e.name,n)}let t=yield uI.get(e.name);n=yield WebAssembly.instantiate(t,{})})),d=()=>JF(this,void 0,void 0,function*(){n||(yield u);let e=n.exports.Hash_GetBuffer(),t=n.exports.memory.buffer;r=new Uint8Array(t,e,cI)}),f=(e=null)=>{i=!0,n.exports.Hash_Init(e)},p=e=>{let t=0;for(;t{if(!i)throw Error(`update() called before init()`);let t=iI(e);p(t)},h=new Uint8Array(t*2),g=(e,a=null)=>{if(!i)throw Error(`digest() called before init()`);return i=!1,n.exports.Hash_Final(a),e===`binary`?r.slice(0,t):rI(h,r,t)},_=()=>{if(!i)throw Error(`save() can only be called after init() and before digest()`);let t=n.exports.Hash_GetState(),r=l(),a=n.exports.memory.buffer,o=new Uint8Array(a,t,r),s=new Uint8Array(4+r);return tI(s,e.hash),s.set(o,4),s},v=t=>{if(!(t instanceof Uint8Array))throw Error(`load() expects an Uint8Array generated by save()`);let r=n.exports.Hash_GetState(),a=l(),o=4+a,s=n.exports.memory.buffer;if(t.length!==o)throw Error(`Bad state length (expected ${o} bytes, got ${t.length})`);if(!nI(e.hash,t.subarray(0,4)))throw Error(`This state was written by an incompatible hash implementation`);let c=t.subarray(4);new Uint8Array(s,r,a).set(c),i=!0},y=e=>typeof e==`string`?e.length!0;break;case`blake2b`:case`blake2s`:b=(e,t)=>t<=512&&y(e);break;case`blake3`:b=(e,t)=>t===0&&y(e);break;case`xxhash64`:case`xxhash3`:case`xxhash128`:case`crc64`:b=()=>!1}return yield d(),{getMemory:o,writeMemory:a,getExports:s,setMemorySize:c,init:f,update:m,digest:g,save:_,load:v,calculate:(e,i=null,a=null)=>{if(!b(e,i))return f(i),m(e),g(`hex`,a);let o=iI(e);return r.set(o),n.exports.Hash_Calculate(o.length,i,a),rI(h,r,t)},hashLength:t}})}new YF,new YF,new YF,new YF,new YF,new YF,new YF,new YF,new YF,new YF,new YF;var fI={name:`sha256`,data:`AGFzbQEAAAABEQRgAAF/YAF/AGAAAGACf38AAwgHAAEBAQIAAwUEAQECAgYOAn8BQfCJBQt/AEGACAsHcAgGbWVtb3J5AgAOSGFzaF9HZXRCdWZmZXIAAAlIYXNoX0luaXQAAQtIYXNoX1VwZGF0ZQACCkhhc2hfRmluYWwABA1IYXNoX0dldFN0YXRlAAUOSGFzaF9DYWxjdWxhdGUABgpTVEFURV9TSVpFAwEKnEoHBQBBgAkLnQEAQQBCADcDwIkBQQBBHEEgIABB4AFGIgAbNgLoiQFBAEKnn+anxvST/b5/Qquzj/yRo7Pw2wAgABs3A+CJAUEAQrGWgP6fooWs6ABC/6S5iMWR2oKbfyAAGzcD2IkBQQBCl7rDg5Onlod3QvLmu+Ojp/2npX8gABs3A9CJAUEAQti9loj8oLW+NkLnzKfQ1tDrs7t/IAAbNwPIiQEL7wICAX4Gf0EAQQApA8CJASIBIACtfDcDwIkBAkACQAJAIAGnQT9xIgINAEGACSEDDAELAkBBwAAgAmsiBCAAIAQgAEkbIgNFDQAgA0EDcSEFIAJBgIkBaiEGQQAhAgJAIANBBEkNACADQfwAcSEHQQAhAgNAIAYgAmoiAyACQYAJai0AADoAACADQQFqIAJBgQlqLQAAOgAAIANBAmogAkGCCWotAAA6AAAgA0EDaiACQYMJai0AADoAACAHIAJBBGoiAkcNAAsLIAVFDQADQCAGIAJqIAJBgAlqLQAAOgAAIAJBAWohAiAFQX9qIgUNAAsLIAAgBEkNAUGAiQEQAyAAIARrIQAgBEGACWohAwsCQCAAQcAASQ0AA0AgAxADIANBwABqIQMgAEFAaiIAQT9LDQALCyAARQ0AQQAhAkEAIQUDQCACQYCJAWogAyACai0AADoAACACQQFqIQIgACAFQQFqIgVB/wFxSw0ACwsLoz4BRX9BACAAKAI8IgFBGHQgAUGA/gNxQQh0ciABQQh2QYD+A3EgAUEYdnJyIgFBGXcgAUEOd3MgAUEDdnMgACgCOCICQRh0IAJBgP4DcUEIdHIgAkEIdkGA/gNxIAJBGHZyciICaiAAKAIgIgNBGHQgA0GA/gNxQQh0ciADQQh2QYD+A3EgA0EYdnJyIgRBGXcgBEEOd3MgBEEDdnMgACgCHCIDQRh0IANBgP4DcUEIdHIgA0EIdkGA/gNxIANBGHZyciIFaiAAKAIEIgNBGHQgA0GA/gNxQQh0ciADQQh2QYD+A3EgA0EYdnJyIgZBGXcgBkEOd3MgBkEDdnMgACgCACIDQRh0IANBgP4DcUEIdHIgA0EIdkGA/gNxIANBGHZyciIHaiAAKAIkIgNBGHQgA0GA/gNxQQh0ciADQQh2QYD+A3EgA0EYdnJyIghqIAJBD3cgAkENd3MgAkEKdnNqIgNqIAAoAhgiCUEYdCAJQYD+A3FBCHRyIAlBCHZBgP4DcSAJQRh2cnIiCkEZdyAKQQ53cyAKQQN2cyAAKAIUIglBGHQgCUGA/gNxQQh0ciAJQQh2QYD+A3EgCUEYdnJyIgtqIAJqIAAoAhAiCUEYdCAJQYD+A3FBCHRyIAlBCHZBgP4DcSAJQRh2cnIiDEEZdyAMQQ53cyAMQQN2cyAAKAIMIglBGHQgCUGA/gNxQQh0ciAJQQh2QYD+A3EgCUEYdnJyIg1qIAAoAjAiCUEYdCAJQYD+A3FBCHRyIAlBCHZBgP4DcSAJQRh2cnIiDmogACgCCCIJQRh0IAlBgP4DcUEIdHIgCUEIdkGA/gNxIAlBGHZyciIPQRl3IA9BDndzIA9BA3ZzIAZqIAAoAigiCUEYdCAJQYD+A3FBCHRyIAlBCHZBgP4DcSAJQRh2cnIiEGogAUEPdyABQQ13cyABQQp2c2oiCUEPdyAJQQ13cyAJQQp2c2oiEUEPdyARQQ13cyARQQp2c2oiEkEPdyASQQ13cyASQQp2c2oiE2ogACgCNCIUQRh0IBRBgP4DcUEIdHIgFEEIdkGA/gNxIBRBGHZyciIVQRl3IBVBDndzIBVBA3ZzIA5qIBJqIAAoAiwiAEEYdCAAQYD+A3FBCHRyIABBCHZBgP4DcSAAQRh2cnIiFkEZdyAWQQ53cyAWQQN2cyAQaiARaiAIQRl3IAhBDndzIAhBA3ZzIARqIAlqIAVBGXcgBUEOd3MgBUEDdnMgCmogAWogC0EZdyALQQ53cyALQQN2cyAMaiAVaiANQRl3IA1BDndzIA1BA3ZzIA9qIBZqIANBD3cgA0ENd3MgA0EKdnNqIhRBD3cgFEENd3MgFEEKdnNqIhdBD3cgF0ENd3MgF0EKdnNqIhhBD3cgGEENd3MgGEEKdnNqIhlBD3cgGUENd3MgGUEKdnNqIhpBD3cgGkENd3MgGkEKdnNqIhtBD3cgG0ENd3MgG0EKdnNqIhxBGXcgHEEOd3MgHEEDdnMgAkEZdyACQQ53cyACQQN2cyAVaiAYaiAOQRl3IA5BDndzIA5BA3ZzIBZqIBdqIBBBGXcgEEEOd3MgEEEDdnMgCGogFGogE0EPdyATQQ13cyATQQp2c2oiHUEPdyAdQQ13cyAdQQp2c2oiHkEPdyAeQQ13cyAeQQp2c2oiH2ogE0EZdyATQQ53cyATQQN2cyAYaiADQRl3IANBDndzIANBA3ZzIAFqIBlqIB9BD3cgH0ENd3MgH0EKdnNqIiBqIBJBGXcgEkEOd3MgEkEDdnMgF2ogH2ogEUEZdyARQQ53cyARQQN2cyAUaiAeaiAJQRl3IAlBDndzIAlBA3ZzIANqIB1qIBxBD3cgHEENd3MgHEEKdnNqIiFBD3cgIUENd3MgIUEKdnNqIiJBD3cgIkENd3MgIkEKdnNqIiNBD3cgI0ENd3MgI0EKdnNqIiRqIBtBGXcgG0EOd3MgG0EDdnMgHmogI2ogGkEZdyAaQQ53cyAaQQN2cyAdaiAiaiAZQRl3IBlBDndzIBlBA3ZzIBNqICFqIBhBGXcgGEEOd3MgGEEDdnMgEmogHGogF0EZdyAXQQ53cyAXQQN2cyARaiAbaiAUQRl3IBRBDndzIBRBA3ZzIAlqIBpqICBBD3cgIEENd3MgIEEKdnNqIiVBD3cgJUENd3MgJUEKdnNqIiZBD3cgJkENd3MgJkEKdnNqIidBD3cgJ0ENd3MgJ0EKdnNqIihBD3cgKEENd3MgKEEKdnNqIilBD3cgKUENd3MgKUEKdnNqIipBD3cgKkENd3MgKkEKdnNqIitBGXcgK0EOd3MgK0EDdnMgH0EZdyAfQQ53cyAfQQN2cyAbaiAnaiAeQRl3IB5BDndzIB5BA3ZzIBpqICZqIB1BGXcgHUEOd3MgHUEDdnMgGWogJWogJEEPdyAkQQ13cyAkQQp2c2oiLEEPdyAsQQ13cyAsQQp2c2oiLUEPdyAtQQ13cyAtQQp2c2oiLmogJEEZdyAkQQ53cyAkQQN2cyAnaiAgQRl3ICBBDndzICBBA3ZzIBxqIChqIC5BD3cgLkENd3MgLkEKdnNqIi9qICNBGXcgI0EOd3MgI0EDdnMgJmogLmogIkEZdyAiQQ53cyAiQQN2cyAlaiAtaiAhQRl3ICFBDndzICFBA3ZzICBqICxqICtBD3cgK0ENd3MgK0EKdnNqIjBBD3cgMEENd3MgMEEKdnNqIjFBD3cgMUENd3MgMUEKdnNqIjJBD3cgMkENd3MgMkEKdnNqIjNqICpBGXcgKkEOd3MgKkEDdnMgLWogMmogKUEZdyApQQ53cyApQQN2cyAsaiAxaiAoQRl3IChBDndzIChBA3ZzICRqIDBqICdBGXcgJ0EOd3MgJ0EDdnMgI2ogK2ogJkEZdyAmQQ53cyAmQQN2cyAiaiAqaiAlQRl3ICVBDndzICVBA3ZzICFqIClqIC9BD3cgL0ENd3MgL0EKdnNqIjRBD3cgNEENd3MgNEEKdnNqIjVBD3cgNUENd3MgNUEKdnNqIjZBD3cgNkENd3MgNkEKdnNqIjdBD3cgN0ENd3MgN0EKdnNqIjhBD3cgOEENd3MgOEEKdnNqIjlBD3cgOUENd3MgOUEKdnNqIjogOCA0IC4gLCAhIBsgGSADIA4gBEEAKALYiQEiO0EadyA7QRV3cyA7QQd3c0EAKALkiQEiPGpBACgC4IkBIj1BACgC3IkBIj5zIDtxID1zaiAHakGY36iUBGoiB0EAKALUiQEiP2oiACAMaiA7IA1qID4gD2ogPSAGaiAAID4gO3NxID5zaiAAQRp3IABBFXdzIABBB3dzakGRid2JB2oiQEEAKALQiQEiQWoiDCAAIDtzcSA7c2ogDEEadyAMQRV3cyAMQQd3c2pBz/eDrntqIkJBACgCzIkBIkNqIg0gDCAAc3EgAHNqIA1BGncgDUEVd3MgDUEHd3NqQaW3181+aiJEQQAoAsiJASIAaiIPIA0gDHNxIAxzaiAPQRp3IA9BFXdzIA9BB3dzakHbhNvKA2oiRSBBIEMgAHNxIEMgAHFzIABBHncgAEETd3MgAEEKd3NqIAdqIgZqIgdqIAUgD2ogCiANaiALIAxqIAcgDyANc3EgDXNqIAdBGncgB0EVd3MgB0EHd3NqQfGjxM8FaiIKIAYgAHMgQ3EgBiAAcXMgBkEedyAGQRN3cyAGQQp3c2ogQGoiDGoiBCAHIA9zcSAPc2ogBEEadyAEQRV3cyAEQQd3c2pBpIX+kXlqIgsgDCAGcyAAcSAMIAZxcyAMQR53IAxBE3dzIAxBCndzaiBCaiINaiIPIAQgB3NxIAdzaiAPQRp3IA9BFXdzIA9BB3dzakHVvfHYemoiQCANIAxzIAZxIA0gDHFzIA1BHncgDUETd3MgDUEKd3NqIERqIgZqIgcgDyAEc3EgBHNqIAdBGncgB0EVd3MgB0EHd3NqQZjVnsB9aiJCIAYgDXMgDHEgBiANcXMgBkEedyAGQRN3cyAGQQp3c2ogRWoiDGoiBWogFiAHaiAQIA9qIAggBGogBSAHIA9zcSAPc2ogBUEadyAFQRV3cyAFQQd3c2pBgbaNlAFqIgggDCAGcyANcSAMIAZxcyAMQR53IAxBE3dzIAxBCndzaiAKaiINaiIPIAUgB3NxIAdzaiAPQRp3IA9BFXdzIA9BB3dzakG+i8ahAmoiDiANIAxzIAZxIA0gDHFzIA1BHncgDUETd3MgDUEKd3NqIAtqIgZqIgcgDyAFc3EgBXNqIAdBGncgB0EVd3MgB0EHd3NqQcP7sagFaiIQIAYgDXMgDHEgBiANcXMgBkEedyAGQRN3cyAGQQp3c2ogQGoiDGoiBCAHIA9zcSAPc2ogBEEadyAEQRV3cyAEQQd3c2pB9Lr5lQdqIhYgDCAGcyANcSAMIAZxcyAMQR53IAxBE3dzIAxBCndzaiBCaiINaiIFaiABIARqIAIgB2ogFSAPaiAFIAQgB3NxIAdzaiAFQRp3IAVBFXdzIAVBB3dzakH+4/qGeGoiByANIAxzIAZxIA0gDHFzIA1BHncgDUETd3MgDUEKd3NqIAhqIgFqIgYgBSAEc3EgBHNqIAZBGncgBkEVd3MgBkEHd3NqQaeN8N55aiIEIAEgDXMgDHEgASANcXMgAUEedyABQRN3cyABQQp3c2ogDmoiAmoiDCAGIAVzcSAFc2ogDEEadyAMQRV3cyAMQQd3c2pB9OLvjHxqIgUgAiABcyANcSACIAFxcyACQR53IAJBE3dzIAJBCndzaiAQaiIDaiINIAwgBnNxIAZzaiANQRp3IA1BFXdzIA1BB3dzakHB0+2kfmoiCCADIAJzIAFxIAMgAnFzIANBHncgA0ETd3MgA0EKd3NqIBZqIgFqIg8gF2ogESANaiAUIAxqIAkgBmogDyANIAxzcSAMc2ogD0EadyAPQRV3cyAPQQd3c2pBho/5/X5qIgYgASADcyACcSABIANxcyABQR53IAFBE3dzIAFBCndzaiAHaiICaiIJIA8gDXNxIA1zaiAJQRp3IAlBFXdzIAlBB3dzakHGu4b+AGoiDCACIAFzIANxIAIgAXFzIAJBHncgAkETd3MgAkEKd3NqIARqIgNqIhEgCSAPc3EgD3NqIBFBGncgEUEVd3MgEUEHd3NqQczDsqACaiINIAMgAnMgAXEgAyACcXMgA0EedyADQRN3cyADQQp3c2ogBWoiAWoiFCARIAlzcSAJc2ogFEEadyAUQRV3cyAUQQd3c2pB79ik7wJqIg8gASADcyACcSABIANxcyABQR53IAFBE3dzIAFBCndzaiAIaiICaiIXaiATIBRqIBggEWogEiAJaiAXIBQgEXNxIBFzaiAXQRp3IBdBFXdzIBdBB3dzakGqidLTBGoiGCACIAFzIANxIAIgAXFzIAJBHncgAkETd3MgAkEKd3NqIAZqIgNqIgkgFyAUc3EgFHNqIAlBGncgCUEVd3MgCUEHd3NqQdzTwuUFaiIUIAMgAnMgAXEgAyACcXMgA0EedyADQRN3cyADQQp3c2ogDGoiAWoiESAJIBdzcSAXc2ogEUEadyARQRV3cyARQQd3c2pB2pHmtwdqIhcgASADcyACcSABIANxcyABQR53IAFBE3dzIAFBCndzaiANaiICaiISIBEgCXNxIAlzaiASQRp3IBJBFXdzIBJBB3dzakHSovnBeWoiGSACIAFzIANxIAIgAXFzIAJBHncgAkETd3MgAkEKd3NqIA9qIgNqIhNqIB4gEmogGiARaiAdIAlqIBMgEiARc3EgEXNqIBNBGncgE0EVd3MgE0EHd3NqQe2Mx8F6aiIaIAMgAnMgAXEgAyACcXMgA0EedyADQRN3cyADQQp3c2ogGGoiAWoiCSATIBJzcSASc2ogCUEadyAJQRV3cyAJQQd3c2pByM+MgHtqIhggASADcyACcSABIANxcyABQR53IAFBE3dzIAFBCndzaiAUaiICaiIRIAkgE3NxIBNzaiARQRp3IBFBFXdzIBFBB3dzakHH/+X6e2oiFCACIAFzIANxIAIgAXFzIAJBHncgAkETd3MgAkEKd3NqIBdqIgNqIhIgESAJc3EgCXNqIBJBGncgEkEVd3MgEkEHd3NqQfOXgLd8aiIXIAMgAnMgAXEgAyACcXMgA0EedyADQRN3cyADQQp3c2ogGWoiAWoiE2ogICASaiAcIBFqIB8gCWogEyASIBFzcSARc2ogE0EadyATQRV3cyATQQd3c2pBx6KerX1qIhkgASADcyACcSABIANxcyABQR53IAFBE3dzIAFBCndzaiAaaiICaiIJIBMgEnNxIBJzaiAJQRp3IAlBFXdzIAlBB3dzakHRxqk2aiIaIAIgAXMgA3EgAiABcXMgAkEedyACQRN3cyACQQp3c2ogGGoiA2oiESAJIBNzcSATc2ogEUEadyARQRV3cyARQQd3c2pB59KkoQFqIhggAyACcyABcSADIAJxcyADQR53IANBE3dzIANBCndzaiAUaiIBaiISIBEgCXNxIAlzaiASQRp3IBJBFXdzIBJBB3dzakGFldy9AmoiFCABIANzIAJxIAEgA3FzIAFBHncgAUETd3MgAUEKd3NqIBdqIgJqIhMgI2ogJiASaiAiIBFqICUgCWogEyASIBFzcSARc2ogE0EadyATQRV3cyATQQd3c2pBuMLs8AJqIhcgAiABcyADcSACIAFxcyACQR53IAJBE3dzIAJBCndzaiAZaiIDaiIJIBMgEnNxIBJzaiAJQRp3IAlBFXdzIAlBB3dzakH827HpBGoiGSADIAJzIAFxIAMgAnFzIANBHncgA0ETd3MgA0EKd3NqIBpqIgFqIhEgCSATc3EgE3NqIBFBGncgEUEVd3MgEUEHd3NqQZOa4JkFaiIaIAEgA3MgAnEgASADcXMgAUEedyABQRN3cyABQQp3c2ogGGoiAmoiEiARIAlzcSAJc2ogEkEadyASQRV3cyASQQd3c2pB1OapqAZqIhggAiABcyADcSACIAFxcyACQR53IAJBE3dzIAJBCndzaiAUaiIDaiITaiAoIBJqICQgEWogJyAJaiATIBIgEXNxIBFzaiATQRp3IBNBFXdzIBNBB3dzakG7laizB2oiFCADIAJzIAFxIAMgAnFzIANBHncgA0ETd3MgA0EKd3NqIBdqIgFqIgkgEyASc3EgEnNqIAlBGncgCUEVd3MgCUEHd3NqQa6Si454aiIXIAEgA3MgAnEgASADcXMgAUEedyABQRN3cyABQQp3c2ogGWoiAmoiESAJIBNzcSATc2ogEUEadyARQRV3cyARQQd3c2pBhdnIk3lqIhkgAiABcyADcSACIAFxcyACQR53IAJBE3dzIAJBCndzaiAaaiIDaiISIBEgCXNxIAlzaiASQRp3IBJBFXdzIBJBB3dzakGh0f+VemoiGiADIAJzIAFxIAMgAnFzIANBHncgA0ETd3MgA0EKd3NqIBhqIgFqIhNqICogEmogLSARaiApIAlqIBMgEiARc3EgEXNqIBNBGncgE0EVd3MgE0EHd3NqQcvM6cB6aiIYIAEgA3MgAnEgASADcXMgAUEedyABQRN3cyABQQp3c2ogFGoiAmoiCSATIBJzcSASc2ogCUEadyAJQRV3cyAJQQd3c2pB8JauknxqIhQgAiABcyADcSACIAFxcyACQR53IAJBE3dzIAJBCndzaiAXaiIDaiIRIAkgE3NxIBNzaiARQRp3IBFBFXdzIBFBB3dzakGjo7G7fGoiFyADIAJzIAFxIAMgAnFzIANBHncgA0ETd3MgA0EKd3NqIBlqIgFqIhIgESAJc3EgCXNqIBJBGncgEkEVd3MgEkEHd3NqQZnQy4x9aiIZIAEgA3MgAnEgASADcXMgAUEedyABQRN3cyABQQp3c2ogGmoiAmoiE2ogMCASaiAvIBFqICsgCWogEyASIBFzcSARc2ogE0EadyATQRV3cyATQQd3c2pBpIzktH1qIhogAiABcyADcSACIAFxcyACQR53IAJBE3dzIAJBCndzaiAYaiIDaiIJIBMgEnNxIBJzaiAJQRp3IAlBFXdzIAlBB3dzakGF67igf2oiGCADIAJzIAFxIAMgAnFzIANBHncgA0ETd3MgA0EKd3NqIBRqIgFqIhEgCSATc3EgE3NqIBFBGncgEUEVd3MgEUEHd3NqQfDAqoMBaiIUIAEgA3MgAnEgASADcXMgAUEedyABQRN3cyABQQp3c2ogF2oiAmoiEiARIAlzcSAJc2ogEkEadyASQRV3cyASQQd3c2pBloKTzQFqIhcgAiABcyADcSACIAFxcyACQR53IAJBE3dzIAJBCndzaiAZaiIDaiITIDZqIDIgEmogNSARaiAxIAlqIBMgEiARc3EgEXNqIBNBGncgE0EVd3MgE0EHd3NqQYjY3fEBaiIZIAMgAnMgAXEgAyACcXMgA0EedyADQRN3cyADQQp3c2ogGmoiAWoiCSATIBJzcSASc2ogCUEadyAJQRV3cyAJQQd3c2pBzO6hugJqIhogASADcyACcSABIANxcyABQR53IAFBE3dzIAFBCndzaiAYaiICaiIRIAkgE3NxIBNzaiARQRp3IBFBFXdzIBFBB3dzakG1+cKlA2oiGCACIAFzIANxIAIgAXFzIAJBHncgAkETd3MgAkEKd3NqIBRqIgNqIhIgESAJc3EgCXNqIBJBGncgEkEVd3MgEkEHd3NqQbOZ8MgDaiIUIAMgAnMgAXEgAyACcXMgA0EedyADQRN3cyADQQp3c2ogF2oiAWoiE2ogLEEZdyAsQQ53cyAsQQN2cyAoaiA0aiAzQQ93IDNBDXdzIDNBCnZzaiIXIBJqIDcgEWogMyAJaiATIBIgEXNxIBFzaiATQRp3IBNBFXdzIBNBB3dzakHK1OL2BGoiGyABIANzIAJxIAEgA3FzIAFBHncgAUETd3MgAUEKd3NqIBlqIgJqIgkgEyASc3EgEnNqIAlBGncgCUEVd3MgCUEHd3NqQc+U89wFaiIZIAIgAXMgA3EgAiABcXMgAkEedyACQRN3cyACQQp3c2ogGmoiA2oiESAJIBNzcSATc2ogEUEadyARQRV3cyARQQd3c2pB89+5wQZqIhogAyACcyABcSADIAJxcyADQR53IANBE3dzIANBCndzaiAYaiIBaiISIBEgCXNxIAlzaiASQRp3IBJBFXdzIBJBB3dzakHuhb6kB2oiHCABIANzIAJxIAEgA3FzIAFBHncgAUETd3MgAUEKd3NqIBRqIgJqIhNqIC5BGXcgLkEOd3MgLkEDdnMgKmogNmogLUEZdyAtQQ53cyAtQQN2cyApaiA1aiAXQQ93IBdBDXdzIBdBCnZzaiIUQQ93IBRBDXdzIBRBCnZzaiIYIBJqIDkgEWogFCAJaiATIBIgEXNxIBFzaiATQRp3IBNBFXdzIBNBB3dzakHvxpXFB2oiCSACIAFzIANxIAIgAXFzIAJBHncgAkETd3MgAkEKd3NqIBtqIgNqIhEgEyASc3EgEnNqIBFBGncgEUEVd3MgEUEHd3NqQZTwoaZ4aiIbIAMgAnMgAXEgAyACcXMgA0EedyADQRN3cyADQQp3c2ogGWoiAWoiEiARIBNzcSATc2ogEkEadyASQRV3cyASQQd3c2pBiISc5nhqIhkgASADcyACcSABIANxcyABQR53IAFBE3dzIAFBCndzaiAaaiICaiITIBIgEXNxIBFzaiATQRp3IBNBFXdzIBNBB3dzakH6//uFeWoiGiACIAFzIANxIAIgAXFzIAJBHncgAkETd3MgAkEKd3NqIBxqIgNqIhQgPGo2AuSJAUEAID8gAyACcyABcSADIAJxcyADQR53IANBE3dzIANBCndzaiAJaiIBIANzIAJxIAEgA3FzIAFBHncgAUETd3MgAUEKd3NqIBtqIgIgAXMgA3EgAiABcXMgAkEedyACQRN3cyACQQp3c2ogGWoiAyACcyABcSADIAJxcyADQR53IANBE3dzIANBCndzaiAaaiIJajYC1IkBQQAgPSAvQRl3IC9BDndzIC9BA3ZzICtqIDdqIBhBD3cgGEENd3MgGEEKdnNqIhggEWogFCATIBJzcSASc2ogFEEadyAUQRV3cyAUQQd3c2pB69nBonpqIhkgAWoiEWo2AuCJAUEAIEEgCSADcyACcSAJIANxcyAJQR53IAlBE3dzIAlBCndzaiAZaiIBajYC0IkBQQAgPiAwQRl3IDBBDndzIDBBA3ZzIC9qIBdqIDpBD3cgOkENd3MgOkEKdnNqIBJqIBEgFCATc3EgE3NqIBFBGncgEUEVd3MgEUEHd3NqQffH5vd7aiIXIAJqIhJqNgLciQFBACBDIAEgCXMgA3EgASAJcXMgAUEedyABQRN3cyABQQp3c2ogF2oiAmo2AsyJAUEAIDsgNEEZdyA0QQ53cyA0QQN2cyAwaiA4aiAYQQ93IBhBDXdzIBhBCnZzaiATaiASIBEgFHNxIBRzaiASQRp3IBJBFXdzIBJBB3dzakHy8cWzfGoiESADamo2AtiJAUEAIAAgAiABcyAJcSACIAFxcyACQR53IAJBE3dzIAJBCndzaiARamo2AsiJAQuyBgIEfwF+QQAoAsCJASIAQQJ2QQ9xIgFBAnRBgIkBaiICIAIoAgBBfyAAQQN0IgB0QX9zcUGAASAAdHM2AgACQAJAAkAgAUEOSQ0AAkAgAUEORw0AQQBBADYCvIkBC0GAiQEQA0EAIQIMAQsgAUENRg0BIAFBAWohAgsgAiEDAkBBBiACa0EHcSIARQ0AIAIgAGohAyACQQJ0QYCJAWohAQNAIAFBADYCACABQQRqIQEgAEF/aiIADQALCyACQXlqQQdJDQAgA0ECdCEBA0AgAUGYiQFqQgA3AgAgAUGQiQFqQgA3AgAgAUGIiQFqQgA3AgAgAUGAiQFqQgA3AgAgAUEgaiIBQThHDQALC0EAIQFBAEEAKQPAiQEiBKciAEEbdCAAQQt0QYCA/AdxciAAQQV2QYD+A3EgAEEDdEEYdnJyNgK8iQFBACAEQh2IpyIAQRh0IABBgP4DcUEIdHIgAEEIdkGA/gNxIABBGHZycjYCuIkBQYCJARADQQBBACgC5IkBIgBBGHQgAEGA/gNxQQh0ciAAQQh2QYD+A3EgAEEYdnJyNgLkiQFBAEEAKALgiQEiAEEYdCAAQYD+A3FBCHRyIABBCHZBgP4DcSAAQRh2cnI2AuCJAUEAQQAoAtyJASIAQRh0IABBgP4DcUEIdHIgAEEIdkGA/gNxIABBGHZycjYC3IkBQQBBACgC2IkBIgBBGHQgAEGA/gNxQQh0ciAAQQh2QYD+A3EgAEEYdnJyNgLYiQFBAEEAKALUiQEiAEEYdCAAQYD+A3FBCHRyIABBCHZBgP4DcSAAQRh2cnI2AtSJAUEAQQAoAtCJASIAQRh0IABBgP4DcUEIdHIgAEEIdkGA/gNxIABBGHZycjYC0IkBQQBBACgCzIkBIgBBGHQgAEGA/gNxQQh0ciAAQQh2QYD+A3EgAEEYdnJyNgLMiQFBAEEAKALIiQEiAEEYdCAAQYD+A3FBCHRyIABBCHZBgP4DcSAAQRh2cnI2AsiJAQJAQQAoAuiJASICRQ0AQQAhAANAIAFBgAlqIAFByIkBai0AADoAACABQQFqIQEgAiAAQQFqIgBB/wFxSw0ACwsLBgBBgIkBC6MBAEEAQgA3A8CJAUEAQRxBICABQeABRiIBGzYC6IkBQQBCp5/mp8b0k/2+f0Krs4/8kaOz8NsAIAEbNwPgiQFBAEKxloD+n6KFrOgAQv+kuYjFkdqCm38gARs3A9iJAUEAQpe6w4OTp5aHd0Ly5rvjo6f9p6V/IAEbNwPQiQFBAELYvZaI/KC1vjZC58yn0NbQ67O7fyABGzcDyIkBIAAQAhAECwsLAQBBgAgLBHAAAAA=`,hash:`8c18dd94`};new YF,new YF;function pI(){return dI(fI,32).then(e=>{e.init(256);let t={init:()=>(e.init(256),t),update:n=>(e.update(n),t),digest:t=>e.digest(t),save:()=>e.save(),load:n=>(e.load(n),t),blockSize:64,digestSize:32};return t})}new YF,new YF,new YF,new YF,new YF,new YF,new YF,new YF,new YF;var mI={source:{repo:`openbmb/MiniCPM5-2B`,revision:`abe115e887989b14f05e64a3b260648329324c3f`,files:{"config.json":{bytes:704,sha256:`59613157e5357d62bcb121e04cb90f2170b43d789b142380c12c3d4277d95180`},"generation_config.json":{bytes:213,sha256:`9ac4f32e5f32358697a9f438a3ea89ef80e6ba786c72c49e932f9f21c122fdb1`},"tokenizer.json":{bytes:9894271,sha256:`3e065a558a034185fe299917b398685c1facd0169a9eea1e629eb30c171fed81`},"tokenizer_config.json":{bytes:94391,sha256:`e9b1064649e771d7a8e15637c68b2d2749724877ba3648bd74a4ece31c26303b`},"special_tokens_map.json":{bytes:551,sha256:`82d96d7a9e6ced037f12394b7ea6a5b02e6ca87e0d11edaa8d60d9be857ce7db`},"chat_template.jinja":{bytes:9060,sha256:`cc945752db555d60949b16989df4ccfeb52a313d6b4b5c5229dd786e2e9fcf1c`},"model.safetensors.index.json":{bytes:31378,sha256:`6d839cd76e8395de548a0e6cc310386f66d1ecbb2c75d198a8dfd3d70892b756`},"model-00000-of-00001.safetensors":{bytes:5033557096,sha256:`14fb8e7f0a18d53d1f239773758bf581cee7e456a4523a54622c3a245b64402c`}}},changes:[`last-position LM head at export`,`four lossless embedding column shards`,`concrete cache head dimensions`,`template serialization and compatibility`],graph_nodes:480,external_chunks:7,files:{"chat_template.jinja":{bytes:8154,sha256:`48636abac6ea1ae7442893ee234e55cce5d45c770ddcc87476555fbf4efde8fe`},"config.json":{bytes:822,sha256:`9103173d5af7567b80f15914f95205652f6475f459e843fdc47a4bbb5bdadade`},"generation_config.json":{bytes:213,sha256:`9ac4f32e5f32358697a9f438a3ea89ef80e6ba786c72c49e932f9f21c122fdb1`},"onnx/model_q4f16.onnx":{bytes:318519,sha256:`d83a86b8ae2566b5bdde23fae366f94a35383f3aefdf3300f138e6dde4ad9d57`},"onnx/model_q4f16.onnx_data":{bytes:265703424,sha256:`57ad7c0aef4bdb7ea57ae34f5f2327b88de701c65b52a45b5dc94ff9af1bb985`},"onnx/model_q4f16.onnx_data_1":{bytes:265420800,sha256:`19e766345e32a1f1162ab1d418583d94643c01c5ea89b4160c1e68afeca5cfe4`},"onnx/model_q4f16.onnx_data_2":{bytes:265420800,sha256:`a83508febe793e70a5c2ce13d7fe029ee5116f33d69863c75a17343caf72ca56`},"onnx/model_q4f16.onnx_data_3":{bytes:265420800,sha256:`5d5e46728e6101139e5e8527a0d192a5552393d74f6075f7ffee28fd5881ef0b`},"onnx/model_q4f16.onnx_data_4":{bytes:237109248,sha256:`62fe730b14bc33fce8fafa4797b43579abc9b366ec30fb966ba9daad8243be5a`},"onnx/model_q4f16.onnx_data_5":{bytes:267386880,sha256:`87c6ba0cd37a3bbbbcba46f33a4adf44214ad9d06854e6cd49e67a03769c1df1`},"onnx/model_q4f16.onnx_data_6":{bytes:267386880,sha256:`1b054f4046373d1a4f8c4a70421472e4f6b8fc419151e6911ffe33f8614bb77c`},"special_tokens_map.json":{bytes:551,sha256:`82d96d7a9e6ced037f12394b7ea6a5b02e6ca87e0d11edaa8d60d9be857ce7db`},"tokenizer.json":{bytes:9894271,sha256:`3e065a558a034185fe299917b398685c1facd0169a9eea1e629eb30c171fed81`},"tokenizer_config.json":{bytes:102804,sha256:`36b50abe63f32fc16e21a2ab30af359601915c6d2e58d7466629458adc2492a1`}}};const hI=`04a6c49fcba3a65a0351c92644c3a7e9d4343059`,gI=`Mike0021/MiniCPM5-2B-ONNX`,_I=Object.values(mI.files).reduce((e,t)=>e+t.bytes,0),vI=32*1024**2,yI=(e,t)=>new Promise((n,r)=>{t?.throwIfAborted();let i=()=>{clearTimeout(a),r(t.reason)},a=setTimeout(()=>{t?.removeEventListener(`abort`,i),n()},e);t?.addEventListener(`abort`,i,{once:!0})});async function bI(e,t,n,r,i){for(let a=0;;a++)try{let a=r>vI,o=await fetch(e,{headers:a?{Range:`bytes=${t}-${n}`}:{},signal:AbortSignal.any([i,AbortSignal.timeout(9e4)]),cache:`no-store`});if(!o.ok)throw Error(`Download returned HTTP ${o.status}`);if(a&&o.status!==206)throw await o.body?.cancel(),Error(`The model host did not honor byte ranges.`);let s=o.headers.get(`Content-Range`);if(s&&s!==`bytes ${t}-${n}/${r}`)throw await o.body?.cancel(),Error(`Incorrect download range.`);let c=new Uint8Array(await o.arrayBuffer());if(c.length!==n-t+1)throw Error(`Incomplete download chunk.`);return c}catch(e){if(i.throwIfAborted(),a===2)throw e;await yI(500*2**a,i)}}async function xI(e,t){return navigator.locks?navigator.locks.request(`pi-minicpm5-download-`+hI,{signal:t.signal},()=>TI(e,t)):TI(e,t)}async function SI(e=!1){if(!navigator.storage?.getDirectory)throw Error(`This app needs browser file storage (OPFS) to cache the 1.84 GB model. Open it in a regular browser tab.`);let t=await(await navigator.storage.getDirectory()).getDirectoryHandle(`pi-minicpm5-`+hI,{create:e}),n=await t.getFileHandle(`verified.json`,{create:e}),r;try{r=JSON.parse(await(await n.getFile()).text())}catch{r={}}(!r||typeof r!=`object`||Array.isArray(r))&&(r={});let i=0,a=[],o=e=>encodeURIComponent(e);for(let[e,n]of Object.entries(mI.files)){try{let a=await(await t.getFileHandle(o(e))).getFile(),s=r[e];if(a.size===n.bytes&&s?.sha256===n.sha256&&s.modified===a.lastModified){i+=n.bytes;continue}}catch(e){if(e.name!==`NotFoundError`)throw e}a.push([e,n])}return{root:t,receiptsFile:n,receipts:r,pending:a,cached:i}}async function CI(){try{return(await SI()).pending.length===0}catch{return!1}}function wI(){return Object.assign(Error(`The saved model is incomplete. Confirm the download to restore it.`),{code:`MODEL_CACHE_MISS`})}async function TI(e,{signal:t,cachedOnly:n=!1,onProgress:r=()=>{}}){let i;try{i=await SI(!n)}catch(e){throw n&&e.name===`NotFoundError`?wI():e}let{root:a,receiptsFile:o,receipts:s,pending:c,cached:l}=i;if(n&&c.length)throw wI();let u=l,d=e=>encodeURIComponent(e);if(r({phase:`download`,loaded:u,total:_I,cached:l}),c.length){let e=await navigator.storage.estimate();if(e.quota&&e.quota-e.usage<_I-u+vI)throw Error(`Not enough browser storage for the model. Free at least 2 GB and retry.`)}let f=new AbortController,p=AbortSignal.any([t,f.signal]),m=Promise.resolve(),h=()=>{let e=JSON.stringify(s),t=m.then(async()=>{let t=await o.createWritable();await t.write(e),await t.close()});return m=t.catch(()=>{}),t};async function g(){for(;c.length;){p.throwIfAborted();let[t,n]=c.shift(),i=await a.getFileHandle(d(t),{create:!0}),o=await i.createWritable();try{let a=await pI();a.init();for(let i=0;i{}),f.abort(e),e}}}let _=(await Promise.allSettled(Array.from({length:6},g))).find(e=>e.status===`rejected`);if(_)throw _.reason;return await m,{cachedBytes:l,async match(t){let n=typeof t==`string`?t:t.url;if(!n.startsWith(e))return;let r=n.slice(e.length);if(!Object.hasOwn(mI.files,r))return;let i=await(await a.getFileHandle(d(r))).getFile();return new Response(i,{headers:{"Content-Length":String(i.size)}})},async put(){}}}var EI=t((e=>{function t(e,t,n){if(n===void 0&&(n=Array.prototype),e&&typeof n.find==`function`)return n.find.call(e,t);for(var i=0;i-1}var _=n({HTML:`http://www.w3.org/1999/xhtml`,SVG:`http://www.w3.org/2000/svg`,XML:`http://www.w3.org/XML/1998/namespace`,XMLNS:`http://www.w3.org/2000/xmlns/`});e.assign=i,e.find=t,e.freeze=n,e.HTML_BOOLEAN_ATTRIBUTES=a,e.HTML_RAW_TEXT_ELEMENTS=l,e.HTML_VOID_ELEMENTS=s,e.hasDefaultHTMLNamespace=p,e.hasOwn=r,e.isHTMLBooleanAttribute=o,e.isHTMLRawTextElement=u,e.isHTMLEscapableRawTextElement=d,e.isHTMLMimeType=f,e.isHTMLVoidElement=c,e.isValidMimeType=g,e.MIME_TYPE=m,e.NAMESPACE=_})),DI=t((e=>{var t=EI();function n(e,t){e.prototype=Object.create(Error.prototype,{constructor:{value:e},name:{value:e.name,enumerable:!0,writable:t}})}var r=t.freeze({Error:`Error`,IndexSizeError:`IndexSizeError`,DomstringSizeError:`DomstringSizeError`,HierarchyRequestError:`HierarchyRequestError`,WrongDocumentError:`WrongDocumentError`,InvalidCharacterError:`InvalidCharacterError`,NoDataAllowedError:`NoDataAllowedError`,NoModificationAllowedError:`NoModificationAllowedError`,NotFoundError:`NotFoundError`,NotSupportedError:`NotSupportedError`,InUseAttributeError:`InUseAttributeError`,InvalidStateError:`InvalidStateError`,SyntaxError:`SyntaxError`,InvalidModificationError:`InvalidModificationError`,NamespaceError:`NamespaceError`,InvalidAccessError:`InvalidAccessError`,ValidationError:`ValidationError`,TypeMismatchError:`TypeMismatchError`,SecurityError:`SecurityError`,NetworkError:`NetworkError`,AbortError:`AbortError`,URLMismatchError:`URLMismatchError`,QuotaExceededError:`QuotaExceededError`,TimeoutError:`TimeoutError`,InvalidNodeTypeError:`InvalidNodeTypeError`,DataCloneError:`DataCloneError`,EncodingError:`EncodingError`,NotReadableError:`NotReadableError`,UnknownError:`UnknownError`,ConstraintError:`ConstraintError`,DataError:`DataError`,TransactionInactiveError:`TransactionInactiveError`,ReadOnlyError:`ReadOnlyError`,VersionError:`VersionError`,OperationError:`OperationError`,NotAllowedError:`NotAllowedError`,OptOutError:`OptOutError`}),i=Object.keys(r);function a(e){return typeof e==`number`&&e>=1&&e<=25}function o(e){return typeof e==`string`&&e.substring(e.length-r.Error.length)===r.Error}function s(e,t){a(e)?(this.name=i[e],this.message=t||``):(this.message=e,this.name=o(t)?t:r.Error),Error.captureStackTrace&&Error.captureStackTrace(this,s)}n(s,!0),Object.defineProperties(s.prototype,{code:{enumerable:!0,get:function(){var e=i.indexOf(this.name);return a(e)?e:0}}});for(var c={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25},l=Object.entries(c),u=0;u{function t(e){try{typeof e!=`function`&&(e=RegExp);var t=new e(`𝌆`,`u`).exec(`𝌆`);return!!t&&t[0].length===2}catch{}return!1}var n=t();function r(e){if(e.source[0]!==`[`)throw Error(e+` can not be used with chars`);return e.source.slice(1,e.source.lastIndexOf(`]`))}function i(e,t){if(e.source[0]!==`[`)throw Error(`/`+e.source+`/ can not be used with chars_without`);if(!t||typeof t!=`string`)throw Error(JSON.stringify(t)+` is not a valid search`);if(e.source.indexOf(t)===-1)throw Error(`"`+t+`" is not is /`+e.source+`/`);if(t===`-`&&e.source.indexOf(t)!==1)throw Error(`"`+t+`" is not at the first postion of /`+e.source+`/`);return new RegExp(e.source.replace(t,``),n?`u`:``)}function a(e){var t=this;return new RegExp(Array.prototype.slice.call(arguments).map(function(e){var n=typeof e==`string`;if(n&&t===void 0&&e===`|`)throw Error("use regg instead of reg to wrap expressions with `|`!");return n?e:e.source}).join(``),n?`u`:``)}function o(e){if(arguments.length===0)throw Error(`no parameters provided`);return a.apply(o,[`(?:`].concat(Array.prototype.slice.call(arguments),[`)`]))}var s=`�`,c=/[-\x09\x0A\x0D\x20-\x2C\x2E-\uD7FF\uE000-\uFFFD]/;n&&(c=a(`[`,r(c),`\\u{10000}-\\u{10FFFF}`,`]`));var l=RegExp(`[^`+r(c)+`]`,n?`u`:``),u=/[\x20\x09\x0D\x0A]/,d=r(u),f=a(u,`+`),p=a(u,`*`),m=/[:_a-zA-Z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;n&&(m=a(`[`,r(m),`\\u{10000}-\\u{10FFFF}`,`]`));var h=a(`[`,r(m),r(/[-.0-9\xB7]/),r(/[\u0300-\u036F\u203F-\u2040]/),`]`),g=a(m,h,`*`),_=a(`^`,g,`$`),v=a(h,`+`),y=o(a(`&`,g,`;`),`|`,o(/&#[0-9]+;|&#x[0-9a-fA-F]+;/)),b=a(`%`,g,`;`),x=o(a(`"`,o(/[^%&"]/,`|`,b,`|`,y),`*`,`"`),`|`,a(`'`,o(/[^%&']/,`|`,b,`|`,y),`*`,`'`)),S=o(`"`,o(/[^<&"]/,`|`,y),`*`,`"`,`|`,`'`,o(/[^<&']/,`|`,y),`*`,`'`),C=a(i(m,`:`),i(h,`:`),`*`),w=a(`^`,C,`$`),T=a(C,o(`:`,C),`?`),E=a(`^`,T,`$`),D=a(`(`,T,`)`),O=o(/"[^"]*"|'[^']*'/),k=a(/^<\?/,`(`,g,`)`,o(f,`(?!`,u,`)(`,c,`*?)`),`?`,/\?>/),A=/[\x20\x0D\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/,j=o(`"`,A,`*"`,`|`,`'`,i(A,`'`),`*'`),M=``,te=a(M,o(i(c,`-`),`|`,a(`-`,i(c,`-`))),`*`,ee),N=`#PCDATA`,ne=o(`EMPTY`,`|`,`ANY`,`|`,o(a(/\(/,p,N,o(p,/\|/,p,T),`*`,p,/\)\*/),`|`,a(/\(/,p,N,p,/\)/)),`|`,a(/\([^>]+\)/,/[?*+]?/)),re=a(``),ie=a(``),ae=`about:legacy-compat`,oe=o(`"`+ae+`"`,`|`,`'`+ae+`'`),se=`SYSTEM`,ce=`PUBLIC`,le=o(o(se,f,O),`|`,o(ce,f,j,f,O)),ue=a(`^`,o(o(se,f,`(?`,O,`)`),`|`,o(ce,f,`(?`,j,`)`,f,`(?`,O,`)`))),de=a(`^`,j,`$`),fe=a(`^`,O,`$`),pe=o(x,`|`,o(le,o(f,`NDATA`,f,g),`?`)),me=``),`|`,a(me,f,`%`,f,g,f,o(x,`|`,le),p,`>`)),P=a(``),ge=a(p,`=`,p),_e=/1[.]\d+/,F=a(f,`version`,ge,o(`'`,_e,`'`,`|`,`"`,_e,`"`)),ve=/[A-Za-z][-A-Za-z0-9._]*/,ye=a(/^<\?xml/,F,o(f,`encoding`,ge,o(`"`,ve,`"`,`|`,`'`,ve,`'`)),`?`,o(f,`standalone`,ge,o(`'`,o(`yes`,`|`,`no`),`'`,`|`,`"`,o(`yes`,`|`,`no`),`"`)),`?`,p,/\?>/),be=``,Ce=a(//));e.chars=r,e.chars_without=i,e.detectUnicodeSupport=t,e.reg=a,e.regg=o,e.ABOUT_LEGACY_COMPAT=ae,e.ABOUT_LEGACY_COMPAT_SystemLiteral=oe,e.AttlistDecl=ie,e.CDATA_START=xe,e.CDATA_END=Se,e.CDSect=Ce,e.Char=c,e.Comment=te,e.COMMENT_START=M,e.COMMENT_END=ee,e.DOCTYPE_DECL_START=be,e.elementdecl=re,e.EntityDecl=he,e.EntityValue=x,e.ExternalID=le,e.ExternalID_match=ue,e.Name=g,e.Name_exact=_,e.NCName_exact=w,e.NotationDecl=P,e.Reference=y,e.PEReference=b,e.PI=k,e.PUBLIC=ce,e.PubidLiteral=j,e.PubidLiteral_match=de,e.QName=T,e.QName_exact=E,e.QName_group=D,e.S=f,e.SChar_s=d,e.S_OPT=p,e.SYSTEM=se,e.SystemLiteral=O,e.SystemLiteral_match=fe,e.InvalidChar=l,e.UNICODE_REPLACEMENT_CHARACTER=s,e.UNICODE_SUPPORT=n,e.XMLDecl=ye})),kI=t((e=>{var t=EI(),n=t.find,r=t.hasDefaultHTMLNamespace,i=t.hasOwn,a=t.isHTMLMimeType,o=t.isHTMLRawTextElement,s=t.isHTMLVoidElement,c=t.MIME_TYPE,l=t.NAMESPACE,u=Symbol(),d=DI(),f=d.DOMException,p=d.DOMExceptionName,m=OI();function h(e){if(e!==u)throw TypeError(`Illegal constructor`)}function g(e){return e!==``}function _(e){return e?e.split(/[\t\n\f\r ]+/).filter(g):[]}function v(e,t){return i(e,t)||(e[t]=!0),e}function y(e){if(!e)return[];var t=_(e);return Object.keys(t.reduce(v,{}))}function b(e){return function(t){return e&&e.indexOf(t)!==-1}}function x(e){if(!m.QName_exact.test(e))throw new f(f.INVALID_CHARACTER_ERR,`invalid character in qualified name "`+e+`"`)}function S(e,n){x(n),e||=null;var r=null,i=n;if(n.indexOf(`:`)>=0){var a=n.split(`:`);r=a[0],i=a[1]}if(r!==null&&e===null)throw new f(f.NAMESPACE_ERR,`prefix is non-null and namespace is null`);if(r===`xml`&&e!==t.NAMESPACE.XML)throw new f(f.NAMESPACE_ERR,`prefix is "xml" and namespace is not the XML namespace`);if((r===`xmlns`||n===`xmlns`)&&e!==t.NAMESPACE.XMLNS)throw new f(f.NAMESPACE_ERR,`either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace`);if(e===t.NAMESPACE.XMLNS&&r!==`xmlns`&&n!==`xmlns`)throw new f(f.NAMESPACE_ERR,`namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns"`);return[e,r,i]}function C(e,t){for(var n in e)i(e,n)&&(t[n]=e[n])}function w(e,t){var n=e.prototype;if(!(n instanceof t)){function r(){}r.prototype=t.prototype,r=new r,C(n,r),e.prototype=n=r}n.constructor!=e&&(typeof e!=`function`&&console.error(`unknown Class:`+e),n.constructor=e)}var T={},E=T.ELEMENT_NODE=1,D=T.ATTRIBUTE_NODE=2,O=T.TEXT_NODE=3,k=T.CDATA_SECTION_NODE=4,A=T.ENTITY_REFERENCE_NODE=5,j=T.ENTITY_NODE=6,M=T.PROCESSING_INSTRUCTION_NODE=7,ee=T.COMMENT_NODE=8,te=T.DOCUMENT_NODE=9,N=T.DOCUMENT_TYPE_NODE=10,ne=T.DOCUMENT_FRAGMENT_NODE=11,re=T.NOTATION_NODE=12,ie=t.freeze({DOCUMENT_POSITION_DISCONNECTED:1,DOCUMENT_POSITION_PRECEDING:2,DOCUMENT_POSITION_FOLLOWING:4,DOCUMENT_POSITION_CONTAINS:8,DOCUMENT_POSITION_CONTAINED_BY:16,DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:32});function ae(e,t){if(t.length=0&&e=0){for(var i=t.length-1;r<=i;)t[r]=t[++r];if(t.length=i,he(t,n),e){var a=e.ownerDocument;a&&Ce(a,e,n),n.ownerElement=null}}}ue.prototype={length:0,item:se.prototype.item,getNamedItem:function(e){this._ownerElement&&this._ownerElement._isInHTMLDocumentAndNamespace()&&(e=e.toLowerCase());for(var t=0;t0;){var n=t.pop(),r=n.node,i=n.other;if(r.nodeType!==i.nodeType)return!1;switch(r.nodeType){case r.DOCUMENT_TYPE_NODE:if(r.name!==i.name||r.publicId!==i.publicId||r.systemId!==i.systemId)return!1;break;case r.ELEMENT_NODE:if(r.namespaceURI!==i.namespaceURI||r.prefix!==i.prefix||r.localName!==i.localName||r.attributes.length!==i.attributes.length)return!1;for(var a=0;a=0;a--)t.push({node:r.childNodes[a],other:i.childNodes[a]})}return!0},isSameNode:function(e){return this===e},insertBefore:function(e,t){return Ie(this,e,t)},replaceChild:function(e,t){Ie(this,e,t,Fe),t&&this.removeChild(t)},removeChild:function(e){return Te(this,e)},appendChild:function(e){return this.insertBefore(e,null)},hasChildNodes:function(){return this.firstChild!=null},cloneNode:function(e){return tt(this.ownerDocument||this,this,e)},normalize:function(){be(this,null,{enter:function(e){for(var t=e.firstChild;t;){var n=t.nextSibling;if(n!==null&&n.nodeType===O&&t.nodeType===O){for(var r=[],i=n;i!==null&&i.nodeType===O;)r.push(i.data),i=i.nextSibling;for(var a=t.nextSibling;a!==i;){var o=a.nextSibling;a.parentNode=null,a.previousSibling=null,a.nextSibling=null,a=o}t.nextSibling=i,i===null?e.lastChild=t:i.previousSibling=t,t.appendData(r.join(``)),we(e.ownerDocument,e),t=i}else t=n}return!0}})},isSupported:function(e,t){return this.ownerDocument.implementation.hasFeature(e,t)},lookupPrefix:function(e){for(var t=this;t;){var n=t._nsMap;if(n){for(var r in n)if(i(n,r)&&n[r]===e)return r}t=t.nodeType==D?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){for(var t=this;t;){var n=t._nsMap;if(n&&i(n,e))return n[e];t=t.nodeType==D?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){return this.lookupPrefix(e)==null},compareDocumentPosition:function(e){if(this===e)return 0;var t=e,n=this,r=null,i=null;if(t instanceof Re&&(r=t,t=r.ownerElement),n instanceof Re&&(i=n,n=i.ownerElement,r&&t&&n===t))for(var a=0,o;o=n.attributes[a];a++){if(o===r)return ie.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+ie.DOCUMENT_POSITION_PRECEDING;if(o===i)return ie.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+ie.DOCUMENT_POSITION_FOLLOWING}if(!t||!n||n.ownerDocument!==t.ownerDocument)return ie.DOCUMENT_POSITION_DISCONNECTED+ie.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+(oe(n.ownerDocument)>oe(t.ownerDocument)?ie.DOCUMENT_POSITION_FOLLOWING:ie.DOCUMENT_POSITION_PRECEDING);if(i&&t===n)return ie.DOCUMENT_POSITION_CONTAINS+ie.DOCUMENT_POSITION_PRECEDING;if(r&&t===n)return ie.DOCUMENT_POSITION_CONTAINED_BY+ie.DOCUMENT_POSITION_FOLLOWING;for(var s=[],c=t.parentNode;c;){if(!i&&c===n)return ie.DOCUMENT_POSITION_CONTAINED_BY+ie.DOCUMENT_POSITION_FOLLOWING;s.push(c),c=c.parentNode}s.reverse();for(var l=[],u=n.parentNode;u;){if(!r&&u===t)return ie.DOCUMENT_POSITION_CONTAINS+ie.DOCUMENT_POSITION_PRECEDING;l.push(u),u=u.parentNode}l.reverse();var d=ae(s,l);for(var f in d.childNodes){var p=d.childNodes[f];if(p===n)return ie.DOCUMENT_POSITION_FOLLOWING;if(p===t)return ie.DOCUMENT_POSITION_PRECEDING;if(l.indexOf(p)>=0)return ie.DOCUMENT_POSITION_FOLLOWING;if(s.indexOf(p)>=0)return ie.DOCUMENT_POSITION_PRECEDING}return 0}};function ve(e){return e==`<`&&`<`||e==`>`&&`>`||e==`&`&&`&`||e==`"`&&`"`||`&#`+e.charCodeAt()+`;`}C(T,F),C(T,F.prototype),C(ie,F),C(ie,F.prototype);function ye(e,t){be(e,null,{enter:function(e){return!t(e)||be.STOP}})}function be(e,t,n){for(var r=[{node:e,context:t,phase:be.ENTER}];r.length>0;){var i=r.pop();if(i.phase===be.ENTER){var a=n.enter(i.node,i.context);if(a===be.STOP)return be.STOP;if(r.push({node:i.node,context:a,phase:be.EXIT}),a==null)continue;for(var o=i.node.lastChild;o;)r.push({node:o,context:a,phase:be.ENTER}),o=o.previousSibling}else n.exit&&n.exit(i.node,i.context)}}be.STOP=Symbol(`walkDOM.STOP`),be.ENTER=0,be.EXIT=1;function xe(e,t){h(e);var n=t||{};this.ownerDocument=this,this.contentType=n.contentType||c.XML_APPLICATION,this.type=a(this.contentType)?`html`:`xml`}function Se(e,t,n){e&&e._inc++,n.namespaceURI===l.XMLNS&&(t._nsMap[n.prefix?n.localName:``]=n.value)}function Ce(e,t,n,r){e&&e._inc++,n.namespaceURI===l.XMLNS&&delete t._nsMap[n.prefix?n.localName:``]}function we(e,t,n){if(e&&e._inc){e._inc++;var r=t.childNodes;if(n&&!n.nextSibling)r[r.length++]=n;else{for(var i=t.firstChild,a=0;i;)r[a++]=i,i=i.nextSibling;r.length=a,delete r[r.length]}}}function Te(e,t){if(e!==t.parentNode)throw new f(f.NOT_FOUND_ERR,`child's parent is not parent`);var n=t.previousSibling,r=t.nextSibling;return n?n.nextSibling=r:e.firstChild=r,r?r.previousSibling=n:e.lastChild=n,we(e.ownerDocument,e),t.parentNode=null,t.previousSibling=null,t.nextSibling=null,t}function Ee(e){return e&&(e.nodeType===F.DOCUMENT_NODE||e.nodeType===F.DOCUMENT_FRAGMENT_NODE||e.nodeType===F.ELEMENT_NODE)}function De(e){return e&&(e.nodeType===F.CDATA_SECTION_NODE||e.nodeType===F.COMMENT_NODE||e.nodeType===F.DOCUMENT_FRAGMENT_NODE||e.nodeType===F.DOCUMENT_TYPE_NODE||e.nodeType===F.ELEMENT_NODE||e.nodeType===F.PROCESSING_INSTRUCTION_NODE||e.nodeType===F.TEXT_NODE)}function Oe(e){return e&&e.nodeType===F.DOCUMENT_TYPE_NODE}function ke(e){return e&&e.nodeType===F.ELEMENT_NODE}function Ae(e){return e&&e.nodeType===F.TEXT_NODE}function je(e,t){var r=e.childNodes||[];if(n(r,ke)||Oe(t))return!1;var i=n(r,Oe);return!(t&&i&&r.indexOf(i)>r.indexOf(t))}function Me(e,t){var r=e.childNodes||[];function i(e){return ke(e)&&e!==t}if(n(r,i))return!1;var a=n(r,Oe);return!(t&&a&&r.indexOf(a)>r.indexOf(t))}function Ne(e,t,n){if(!Ee(e))throw new f(f.HIERARCHY_REQUEST_ERR,`Unexpected parent node type `+e.nodeType);if(n&&n.parentNode!==e)throw new f(f.NOT_FOUND_ERR,`child not in parent`);if(!De(t)||Oe(t)&&e.nodeType!==F.DOCUMENT_NODE)throw new f(f.HIERARCHY_REQUEST_ERR,`Unexpected node type `+t.nodeType+` for parent node type `+e.nodeType)}function Pe(e,t,r){var i=e.childNodes||[],a=t.childNodes||[];if(t.nodeType===F.DOCUMENT_FRAGMENT_NODE){var o=a.filter(ke);if(o.length>1||n(a,Ae))throw new f(f.HIERARCHY_REQUEST_ERR,`More than one element or text in fragment`);if(o.length===1&&!je(e,r))throw new f(f.HIERARCHY_REQUEST_ERR,`Element in fragment can not be inserted before doctype`)}if(ke(t)&&!je(e,r))throw new f(f.HIERARCHY_REQUEST_ERR,`Only one element can be added and only after doctype`);if(Oe(t)){if(n(i,Oe))throw new f(f.HIERARCHY_REQUEST_ERR,`Only one doctype is allowed`);var s=n(i,ke);if(r&&i.indexOf(s)1||n(a,Ae))throw new f(f.HIERARCHY_REQUEST_ERR,`More than one element or text in fragment`);if(o.length===1&&!Me(e,r))throw new f(f.HIERARCHY_REQUEST_ERR,`Element in fragment can not be inserted before doctype`)}if(ke(t)&&!Me(e,r))throw new f(f.HIERARCHY_REQUEST_ERR,`Only one element can be added and only after doctype`);if(Oe(t)){function e(e){return Oe(e)&&e!==r}if(n(i,e))throw new f(f.HIERARCHY_REQUEST_ERR,`Only one doctype is allowed`);var s=n(i,ke);if(r&&i.indexOf(s)`)!==-1)throw new f(f.INVALID_CHARACTER_ERR,`data contains "]]>"`);var t=new He(u);return t.ownerDocument=this,t.childNodes=new se,t.appendData(e),t},createProcessingInstruction:function(e,t){var n=new Je(u);return n.ownerDocument=this,n.childNodes=new se,n.nodeName=n.target=e,n.nodeValue=n.data=t,n},createAttribute:function(e){if(!m.QName_exact.test(e))throw new f(f.INVALID_CHARACTER_ERR,`invalid character in name "`+e+`"`);return this.type===`html`&&(e=e.toLowerCase()),this._createAttribute(e)},_createAttribute:function(e){var t=new Re(u);return t.ownerDocument=this,t.childNodes=new se,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){if(!m.Name_exact.test(e))throw new f(f.INVALID_CHARACTER_ERR,`not a valid xml name "`+e+`"`);if(this.type===`html`)throw new f(`document is an html document`,p.NotSupportedError);var t=new Ke(u);return t.ownerDocument=this,t.childNodes=new se,t.nodeName=e,t},createElementNS:function(e,t){var n=S(e,t),r=new Le(u),i=r.attributes=new ue;return r.childNodes=new se,r.ownerDocument=this,r.nodeName=t,r.tagName=t,r.namespaceURI=n[0],r.prefix=n[1],r.localName=n[2],i._ownerElement=r,r},createAttributeNS:function(e,t){var n=S(e,t),r=new Re(u);return r.ownerDocument=this,r.childNodes=new se,r.nodeName=t,r.name=t,r.specified=!0,r.namespaceURI=n[0],r.prefix=n[1],r.localName=n[2],r}},w(xe,F);function Le(e){h(e),this._nsMap=Object.create(null)}Le.prototype={nodeType:E,attributes:null,getQualifiedName:function(){return this.prefix?this.prefix+`:`+this.localName:this.localName},_isInHTMLDocumentAndNamespace:function(){return this.ownerDocument.type===`html`&&this.namespaceURI===l.HTML},hasAttributes:function(){return!!(this.attributes&&this.attributes.length)},hasAttribute:function(e){return!!this.getAttributeNode(e)},getAttribute:function(e){var t=this.getAttributeNode(e);return t?t.value:null},getAttributeNode:function(e){return this._isInHTMLDocumentAndNamespace()&&(e=e.toLowerCase()),this.attributes.getNamedItem(e)},setAttribute:function(e,t){this._isInHTMLDocumentAndNamespace()&&(e=e.toLowerCase());var n=this.getAttributeNode(e);n?n.value=n.nodeValue=``+t:(n=this.ownerDocument._createAttribute(e),n.value=n.nodeValue=``+t,this.setAttributeNode(n))},removeAttribute:function(e){var t=this.getAttributeNode(e);t&&this.removeAttributeNode(t)},setAttributeNode:function(e){return this.attributes.setNamedItem(e)},setAttributeNodeNS:function(e){return this.attributes.setNamedItemNS(e)},removeAttributeNode:function(e){return this.attributes.removeNamedItem(e.nodeName)},removeAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);n&&this.removeAttributeNode(n)},hasAttributeNS:function(e,t){return this.getAttributeNodeNS(e,t)!=null},getAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);return n?n.value:null},setAttributeNS:function(e,t,n){var r=S(e,t)[2],i=this.getAttributeNodeNS(e,r);i?i.value=i.nodeValue=``+n:(i=this.ownerDocument.createAttributeNS(e,t),i.value=i.nodeValue=``+n,this.setAttributeNode(i))},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByClassName:function(e){var t=y(e);return new ce(this,function(n){var r=[];return t.length>0&&ye(n,function(i){if(i!==n&&i.nodeType===E){var a=i.getAttribute(`class`);if(a){var o=e===a;if(!o){var s=y(a);o=t.every(b(s))}o&&r.push(i)}}}),r})},getElementsByTagName:function(e){var t=(this.nodeType===te?this:this.ownerDocument).type===`html`,n=e.toLowerCase();return new ce(this,function(r){var i=[];return ye(r,function(a){a!==r&&a.nodeType===E&&(e===`*`||a.getQualifiedName()===(t&&a.namespaceURI===l.HTML?n:e))&&i.push(a)}),i})},getElementsByTagNameNS:function(e,t){return new ce(this,function(n){var r=[];return ye(n,function(i){i!==n&&i.nodeType===E&&(e===`*`||i.namespaceURI===e)&&(t===`*`||i.localName==t)&&r.push(i)}),r})}},xe.prototype.getElementsByClassName=Le.prototype.getElementsByClassName,xe.prototype.getElementsByTagName=Le.prototype.getElementsByTagName,xe.prototype.getElementsByTagNameNS=Le.prototype.getElementsByTagNameNS,w(Le,F);function Re(e){h(e),this.namespaceURI=null,this.prefix=null,this.ownerElement=null}Re.prototype.nodeType=D,w(Re,F);function ze(e){h(e)}ze.prototype={data:``,substringData:function(e,t){return this.data.substring(e,e+t)},appendData:function(e){e=this.data+e,this.nodeValue=this.data=e,this.length=e.length},insertData:function(e,t){this.replaceData(e,0,t)},deleteData:function(e,t){this.replaceData(e,t,``)},replaceData:function(e,t,n){var r=this.data.substring(0,e),i=this.data.substring(e+t);n=r+n+i,this.nodeValue=this.data=n,this.length=n.length}},w(ze,F);function Be(e){h(e)}Be.prototype={nodeName:`#text`,nodeType:O,splitText:function(e){var t=this.data,n=t.substring(e);t=t.substring(0,e),this.data=this.nodeValue=t,this.length=t.length;var r=this.ownerDocument.createTextNode(n);return this.parentNode&&this.parentNode.insertBefore(r,this.nextSibling),r}},w(Be,ze);function Ve(e){h(e)}Ve.prototype={nodeName:`#comment`,nodeType:ee},w(Ve,ze);function He(e){h(e)}He.prototype={nodeName:`#cdata-section`,nodeType:k},w(He,Be);function Ue(e){h(e)}Ue.prototype.nodeType=N,w(Ue,F);function We(e){h(e)}We.prototype.nodeType=re,w(We,F);function Ge(e){h(e)}Ge.prototype.nodeType=j,w(Ge,F);function Ke(e){h(e)}Ke.prototype.nodeType=A,w(Ke,F);function qe(e){h(e)}qe.prototype.nodeName=`#document-fragment`,qe.prototype.nodeType=ne,w(qe,F);function Je(e){h(e)}Je.prototype.nodeType=M,w(Je,ze);function Ye(){}Ye.prototype.serializeToString=function(e,t){return Xe.call(e,t)},F.prototype.toString=Xe;function Xe(e){var t=typeof e==`function`?{requireWellFormed:!1,splitCDATASections:!0,nodeFilter:e}:e==null?{requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null}:{requireWellFormed:!!e.requireWellFormed,splitCDATASections:e.splitCDATASections!==!1,nodeFilter:e.nodeFilter||null},n=[],r=this.nodeType===te&&this.documentElement||this,i=r.prefix,a=r.namespaceURI;if(a&&i==null){var i=r.lookupPrefix(a);if(i==null)var o=[{namespace:a,prefix:null}]}return $e(this,n,o,t),n.join(``)}function Ze(e,t,n){var r=e.prefix||``,i=e.namespaceURI;if(!i||r===`xml`&&i===l.XML||i===l.XMLNS)return!1;for(var a=n.length;a--;){var o=n[a];if(o.prefix===r)return o.namespace!==i}return!0}function Qe(e,t,n,r){if(r&&!m.QName_exact.test(t))throw new f(`The attribute name "`+t+`" is not a valid XML QName`,p.InvalidStateError);e.push(` `,t,`="`,n.replace(/[<>&"\t\n\r]/g,ve),`"`)}function $e(e,t,n,r){n||=[];var i=r.nodeFilter,a=r.requireWellFormed,c=r.splitCDATASections,u=(e.nodeType===te?e:e.ownerDocument).type===`html`;be(e,{ns:n},{enter:function(e,n){var d=n.ns;if(i){if(e=i(e),e){if(typeof e==`string`)return t.push(e),null}else return null}switch(e.nodeType){case E:var h=e.attributes,g=h.length,_=e.tagName,v=_;if(!u&&!e.prefix&&e.namespaceURI){for(var y,b=0;b=0;x--){var S=d[x];if(S.prefix===``&&S.namespace===e.namespaceURI){y=S.namespace;break}}if(y!==e.namespaceURI)for(var x=d.length-1;x>=0;x--){var S=d[x];if(S.namespace===e.namespaceURI){S.prefix&&(v=S.prefix+`:`+_);break}}}if(a&&!m.QName_exact.test(v))throw new f(`The element name "`+v+`" is not a valid XML QName`,p.InvalidStateError);t.push(`<`,v);for(var C=d.slice(),w=0;w`),null;if(t.push(`>`),u&&o(_)){for(var se=e.firstChild;se;)se.data?t.push(se.data):$e(se,t,C.slice(),r),se=se.nextSibling;return t.push(``),null}return{ns:C,tag:v};case te:case ne:if(a&&e.nodeType===te&&e.documentElement==null)throw new f(`The Document has no documentElement`,p.InvalidStateError);return{ns:d};case D:return Qe(t,e.name,e.value,a),null;case O:if(a&&m.InvalidChar.test(e.data))throw new f(`The Text node data contains characters outside the XML Char production`,p.InvalidStateError);return t.push(e.data.replace(/[<&>]/g,ve)),null;case k:if(a&&e.data.indexOf(`]]>`)!==-1)throw new f(`The CDATASection data contains "]]>"`,p.InvalidStateError);return c?t.push(m.CDATA_START,e.data.replace(/]]>/g,`]]]]>`),m.CDATA_END):t.push(m.CDATA_START,e.data,m.CDATA_END),null;case ee:if(a){if(m.InvalidChar.test(e.data))throw new f(`The comment node data contains characters outside the XML Char production`,p.InvalidStateError);if(e.data.indexOf(`--`)!==-1||e.data[e.data.length-1]===`-`)throw new f(`The comment node data contains "--" or ends with "-"`,p.InvalidStateError)}return t.push(m.COMMENT_START,e.data,m.COMMENT_END),null;case N:var ce=e.publicId,le=e.systemId;if(a){if(!m.Name_exact.test(e.name))throw new f(`The doctype name "`+e.name+`" is not a valid XML Name`,p.InvalidStateError);if(ce&&!m.PubidLiteral_match.test(ce))throw new f(`DocumentType publicId is not a valid PubidLiteral`,p.InvalidStateError);if(le&&le!==`.`&&!m.SystemLiteral_match.test(le))throw new f(`DocumentType systemId is not a valid SystemLiteral`,p.InvalidStateError);if(e.internalSubset&&e.internalSubset.indexOf(`]>`)!==-1)throw new f(`DocumentType internalSubset contains "]>"`,p.InvalidStateError)}return t.push(m.DOCTYPE_DECL_START,` `,e.name),ce?(t.push(` `,m.PUBLIC,` `,ce),le&&le!==`.`&&t.push(` `,le)):le&&le!==`.`&&t.push(` `,m.SYSTEM,` `,le),e.internalSubset&&t.push(` [`,e.internalSubset,`]`),t.push(`>`),null;case M:if(a){if(!m.NCName_exact.test(e.target)||e.target.toLowerCase()===`xml`)throw new f(`The processing instruction target "`+e.target+`" is not a valid XML NCName or is reserved`,p.InvalidStateError);if(m.InvalidChar.test(e.data))throw new f(`The ProcessingInstruction data contains characters outside the XML Char production`,p.InvalidStateError);if(e.data.indexOf(`?>`)!==-1)throw new f(`The ProcessingInstruction data contains "?>"`,p.InvalidStateError)}return t.push(``),null;case A:if(a&&!m.Name_exact.test(e.nodeName))throw new f(`The entity reference name "`+e.nodeName+`" is not a valid XML Name`,p.InvalidStateError);return t.push(`&`,e.nodeName,`;`),null;default:return t.push(`??`,e.nodeName),null}},exit:function(e,n){n&&n.tag&&t.push(``)}})}function et(e,t,n){var r;return be(t,null,{enter:function(t,i){var a=t.cloneNode(!1);return a.ownerDocument=e,a.parentNode=null,i===null?r=a:i.appendChild(a),t.nodeType===D||n?a:null}}),r}function tt(e,t,n){var r;return be(t,null,{enter:function(t,a){var o=new t.constructor(u);for(var s in t)if(i(t,s)){var c=t[s];typeof c!=`object`&&c!=o[s]&&(o[s]=c)}t.childNodes&&(o.childNodes=new se),o.ownerDocument=e;var l=n;switch(o.nodeType){case E:var d=t.attributes,f=o.attributes=new ue,p=d.length;f._ownerElement=o;for(var m=0;m{var t=EI().freeze;e.XML_ENTITIES=t({amp:`&`,apos:`'`,gt:`>`,lt:`<`,quot:`"`}),e.HTML_ENTITIES=t({Aacute:`Á`,aacute:`á`,Abreve:`Ă`,abreve:`ă`,ac:`∾`,acd:`∿`,acE:`∾̳`,Acirc:`Â`,acirc:`â`,acute:`´`,Acy:`А`,acy:`а`,AElig:`Æ`,aelig:`æ`,af:`⁡`,Afr:`𝔄`,afr:`𝔞`,Agrave:`À`,agrave:`à`,alefsym:`ℵ`,aleph:`ℵ`,Alpha:`Α`,alpha:`α`,Amacr:`Ā`,amacr:`ā`,amalg:`⨿`,AMP:`&`,amp:`&`,And:`⩓`,and:`∧`,andand:`⩕`,andd:`⩜`,andslope:`⩘`,andv:`⩚`,ang:`∠`,ange:`⦤`,angle:`∠`,angmsd:`∡`,angmsdaa:`⦨`,angmsdab:`⦩`,angmsdac:`⦪`,angmsdad:`⦫`,angmsdae:`⦬`,angmsdaf:`⦭`,angmsdag:`⦮`,angmsdah:`⦯`,angrt:`∟`,angrtvb:`⊾`,angrtvbd:`⦝`,angsph:`∢`,angst:`Å`,angzarr:`⍼`,Aogon:`Ą`,aogon:`ą`,Aopf:`𝔸`,aopf:`𝕒`,ap:`≈`,apacir:`⩯`,apE:`⩰`,ape:`≊`,apid:`≋`,apos:`'`,ApplyFunction:`⁡`,approx:`≈`,approxeq:`≊`,Aring:`Å`,aring:`å`,Ascr:`𝒜`,ascr:`𝒶`,Assign:`≔`,ast:`*`,asymp:`≈`,asympeq:`≍`,Atilde:`Ã`,atilde:`ã`,Auml:`Ä`,auml:`ä`,awconint:`∳`,awint:`⨑`,backcong:`≌`,backepsilon:`϶`,backprime:`‵`,backsim:`∽`,backsimeq:`⋍`,Backslash:`∖`,Barv:`⫧`,barvee:`⊽`,Barwed:`⌆`,barwed:`⌅`,barwedge:`⌅`,bbrk:`⎵`,bbrktbrk:`⎶`,bcong:`≌`,Bcy:`Б`,bcy:`б`,bdquo:`„`,becaus:`∵`,Because:`∵`,because:`∵`,bemptyv:`⦰`,bepsi:`϶`,bernou:`ℬ`,Bernoullis:`ℬ`,Beta:`Β`,beta:`β`,beth:`ℶ`,between:`≬`,Bfr:`𝔅`,bfr:`𝔟`,bigcap:`⋂`,bigcirc:`◯`,bigcup:`⋃`,bigodot:`⨀`,bigoplus:`⨁`,bigotimes:`⨂`,bigsqcup:`⨆`,bigstar:`★`,bigtriangledown:`▽`,bigtriangleup:`△`,biguplus:`⨄`,bigvee:`⋁`,bigwedge:`⋀`,bkarow:`⤍`,blacklozenge:`⧫`,blacksquare:`▪`,blacktriangle:`▴`,blacktriangledown:`▾`,blacktriangleleft:`◂`,blacktriangleright:`▸`,blank:`␣`,blk12:`▒`,blk14:`░`,blk34:`▓`,block:`█`,bne:`=⃥`,bnequiv:`≡⃥`,bNot:`⫭`,bnot:`⌐`,Bopf:`𝔹`,bopf:`𝕓`,bot:`⊥`,bottom:`⊥`,bowtie:`⋈`,boxbox:`⧉`,boxDL:`╗`,boxDl:`╖`,boxdL:`╕`,boxdl:`┐`,boxDR:`╔`,boxDr:`╓`,boxdR:`╒`,boxdr:`┌`,boxH:`═`,boxh:`─`,boxHD:`╦`,boxHd:`╤`,boxhD:`╥`,boxhd:`┬`,boxHU:`╩`,boxHu:`╧`,boxhU:`╨`,boxhu:`┴`,boxminus:`⊟`,boxplus:`⊞`,boxtimes:`⊠`,boxUL:`╝`,boxUl:`╜`,boxuL:`╛`,boxul:`┘`,boxUR:`╚`,boxUr:`╙`,boxuR:`╘`,boxur:`└`,boxV:`║`,boxv:`│`,boxVH:`╬`,boxVh:`╫`,boxvH:`╪`,boxvh:`┼`,boxVL:`╣`,boxVl:`╢`,boxvL:`╡`,boxvl:`┤`,boxVR:`╠`,boxVr:`╟`,boxvR:`╞`,boxvr:`├`,bprime:`‵`,Breve:`˘`,breve:`˘`,brvbar:`¦`,Bscr:`ℬ`,bscr:`𝒷`,bsemi:`⁏`,bsim:`∽`,bsime:`⋍`,bsol:`\\`,bsolb:`⧅`,bsolhsub:`⟈`,bull:`•`,bullet:`•`,bump:`≎`,bumpE:`⪮`,bumpe:`≏`,Bumpeq:`≎`,bumpeq:`≏`,Cacute:`Ć`,cacute:`ć`,Cap:`⋒`,cap:`∩`,capand:`⩄`,capbrcup:`⩉`,capcap:`⩋`,capcup:`⩇`,capdot:`⩀`,CapitalDifferentialD:`ⅅ`,caps:`∩︀`,caret:`⁁`,caron:`ˇ`,Cayleys:`ℭ`,ccaps:`⩍`,Ccaron:`Č`,ccaron:`č`,Ccedil:`Ç`,ccedil:`ç`,Ccirc:`Ĉ`,ccirc:`ĉ`,Cconint:`∰`,ccups:`⩌`,ccupssm:`⩐`,Cdot:`Ċ`,cdot:`ċ`,cedil:`¸`,Cedilla:`¸`,cemptyv:`⦲`,cent:`¢`,CenterDot:`·`,centerdot:`·`,Cfr:`ℭ`,cfr:`𝔠`,CHcy:`Ч`,chcy:`ч`,check:`✓`,checkmark:`✓`,Chi:`Χ`,chi:`χ`,cir:`○`,circ:`ˆ`,circeq:`≗`,circlearrowleft:`↺`,circlearrowright:`↻`,circledast:`⊛`,circledcirc:`⊚`,circleddash:`⊝`,CircleDot:`⊙`,circledR:`®`,circledS:`Ⓢ`,CircleMinus:`⊖`,CirclePlus:`⊕`,CircleTimes:`⊗`,cirE:`⧃`,cire:`≗`,cirfnint:`⨐`,cirmid:`⫯`,cirscir:`⧂`,ClockwiseContourIntegral:`∲`,CloseCurlyDoubleQuote:`”`,CloseCurlyQuote:`’`,clubs:`♣`,clubsuit:`♣`,Colon:`∷`,colon:`:`,Colone:`⩴`,colone:`≔`,coloneq:`≔`,comma:`,`,commat:`@`,comp:`∁`,compfn:`∘`,complement:`∁`,complexes:`ℂ`,cong:`≅`,congdot:`⩭`,Congruent:`≡`,Conint:`∯`,conint:`∮`,ContourIntegral:`∮`,Copf:`ℂ`,copf:`𝕔`,coprod:`∐`,Coproduct:`∐`,COPY:`©`,copy:`©`,copysr:`℗`,CounterClockwiseContourIntegral:`∳`,crarr:`↵`,Cross:`⨯`,cross:`✗`,Cscr:`𝒞`,cscr:`𝒸`,csub:`⫏`,csube:`⫑`,csup:`⫐`,csupe:`⫒`,ctdot:`⋯`,cudarrl:`⤸`,cudarrr:`⤵`,cuepr:`⋞`,cuesc:`⋟`,cularr:`↶`,cularrp:`⤽`,Cup:`⋓`,cup:`∪`,cupbrcap:`⩈`,CupCap:`≍`,cupcap:`⩆`,cupcup:`⩊`,cupdot:`⊍`,cupor:`⩅`,cups:`∪︀`,curarr:`↷`,curarrm:`⤼`,curlyeqprec:`⋞`,curlyeqsucc:`⋟`,curlyvee:`⋎`,curlywedge:`⋏`,curren:`¤`,curvearrowleft:`↶`,curvearrowright:`↷`,cuvee:`⋎`,cuwed:`⋏`,cwconint:`∲`,cwint:`∱`,cylcty:`⌭`,Dagger:`‡`,dagger:`†`,daleth:`ℸ`,Darr:`↡`,dArr:`⇓`,darr:`↓`,dash:`‐`,Dashv:`⫤`,dashv:`⊣`,dbkarow:`⤏`,dblac:`˝`,Dcaron:`Ď`,dcaron:`ď`,Dcy:`Д`,dcy:`д`,DD:`ⅅ`,dd:`ⅆ`,ddagger:`‡`,ddarr:`⇊`,DDotrahd:`⤑`,ddotseq:`⩷`,deg:`°`,Del:`∇`,Delta:`Δ`,delta:`δ`,demptyv:`⦱`,dfisht:`⥿`,Dfr:`𝔇`,dfr:`𝔡`,dHar:`⥥`,dharl:`⇃`,dharr:`⇂`,DiacriticalAcute:`´`,DiacriticalDot:`˙`,DiacriticalDoubleAcute:`˝`,DiacriticalGrave:"`",DiacriticalTilde:`˜`,diam:`⋄`,Diamond:`⋄`,diamond:`⋄`,diamondsuit:`♦`,diams:`♦`,die:`¨`,DifferentialD:`ⅆ`,digamma:`ϝ`,disin:`⋲`,div:`÷`,divide:`÷`,divideontimes:`⋇`,divonx:`⋇`,DJcy:`Ђ`,djcy:`ђ`,dlcorn:`⌞`,dlcrop:`⌍`,dollar:`$`,Dopf:`𝔻`,dopf:`𝕕`,Dot:`¨`,dot:`˙`,DotDot:`⃜`,doteq:`≐`,doteqdot:`≑`,DotEqual:`≐`,dotminus:`∸`,dotplus:`∔`,dotsquare:`⊡`,doublebarwedge:`⌆`,DoubleContourIntegral:`∯`,DoubleDot:`¨`,DoubleDownArrow:`⇓`,DoubleLeftArrow:`⇐`,DoubleLeftRightArrow:`⇔`,DoubleLeftTee:`⫤`,DoubleLongLeftArrow:`⟸`,DoubleLongLeftRightArrow:`⟺`,DoubleLongRightArrow:`⟹`,DoubleRightArrow:`⇒`,DoubleRightTee:`⊨`,DoubleUpArrow:`⇑`,DoubleUpDownArrow:`⇕`,DoubleVerticalBar:`∥`,DownArrow:`↓`,Downarrow:`⇓`,downarrow:`↓`,DownArrowBar:`⤓`,DownArrowUpArrow:`⇵`,DownBreve:`̑`,downdownarrows:`⇊`,downharpoonleft:`⇃`,downharpoonright:`⇂`,DownLeftRightVector:`⥐`,DownLeftTeeVector:`⥞`,DownLeftVector:`↽`,DownLeftVectorBar:`⥖`,DownRightTeeVector:`⥟`,DownRightVector:`⇁`,DownRightVectorBar:`⥗`,DownTee:`⊤`,DownTeeArrow:`↧`,drbkarow:`⤐`,drcorn:`⌟`,drcrop:`⌌`,Dscr:`𝒟`,dscr:`𝒹`,DScy:`Ѕ`,dscy:`ѕ`,dsol:`⧶`,Dstrok:`Đ`,dstrok:`đ`,dtdot:`⋱`,dtri:`▿`,dtrif:`▾`,duarr:`⇵`,duhar:`⥯`,dwangle:`⦦`,DZcy:`Џ`,dzcy:`џ`,dzigrarr:`⟿`,Eacute:`É`,eacute:`é`,easter:`⩮`,Ecaron:`Ě`,ecaron:`ě`,ecir:`≖`,Ecirc:`Ê`,ecirc:`ê`,ecolon:`≕`,Ecy:`Э`,ecy:`э`,eDDot:`⩷`,Edot:`Ė`,eDot:`≑`,edot:`ė`,ee:`ⅇ`,efDot:`≒`,Efr:`𝔈`,efr:`𝔢`,eg:`⪚`,Egrave:`È`,egrave:`è`,egs:`⪖`,egsdot:`⪘`,el:`⪙`,Element:`∈`,elinters:`⏧`,ell:`ℓ`,els:`⪕`,elsdot:`⪗`,Emacr:`Ē`,emacr:`ē`,empty:`∅`,emptyset:`∅`,EmptySmallSquare:`◻`,emptyv:`∅`,EmptyVerySmallSquare:`▫`,emsp:` `,emsp13:` `,emsp14:` `,ENG:`Ŋ`,eng:`ŋ`,ensp:` `,Eogon:`Ę`,eogon:`ę`,Eopf:`𝔼`,eopf:`𝕖`,epar:`⋕`,eparsl:`⧣`,eplus:`⩱`,epsi:`ε`,Epsilon:`Ε`,epsilon:`ε`,epsiv:`ϵ`,eqcirc:`≖`,eqcolon:`≕`,eqsim:`≂`,eqslantgtr:`⪖`,eqslantless:`⪕`,Equal:`⩵`,equals:`=`,EqualTilde:`≂`,equest:`≟`,Equilibrium:`⇌`,equiv:`≡`,equivDD:`⩸`,eqvparsl:`⧥`,erarr:`⥱`,erDot:`≓`,Escr:`ℰ`,escr:`ℯ`,esdot:`≐`,Esim:`⩳`,esim:`≂`,Eta:`Η`,eta:`η`,ETH:`Ð`,eth:`ð`,Euml:`Ë`,euml:`ë`,euro:`€`,excl:`!`,exist:`∃`,Exists:`∃`,expectation:`ℰ`,ExponentialE:`ⅇ`,exponentiale:`ⅇ`,fallingdotseq:`≒`,Fcy:`Ф`,fcy:`ф`,female:`♀`,ffilig:`ffi`,fflig:`ff`,ffllig:`ffl`,Ffr:`𝔉`,ffr:`𝔣`,filig:`fi`,FilledSmallSquare:`◼`,FilledVerySmallSquare:`▪`,fjlig:`fj`,flat:`♭`,fllig:`fl`,fltns:`▱`,fnof:`ƒ`,Fopf:`𝔽`,fopf:`𝕗`,ForAll:`∀`,forall:`∀`,fork:`⋔`,forkv:`⫙`,Fouriertrf:`ℱ`,fpartint:`⨍`,frac12:`½`,frac13:`⅓`,frac14:`¼`,frac15:`⅕`,frac16:`⅙`,frac18:`⅛`,frac23:`⅔`,frac25:`⅖`,frac34:`¾`,frac35:`⅗`,frac38:`⅜`,frac45:`⅘`,frac56:`⅚`,frac58:`⅝`,frac78:`⅞`,frasl:`⁄`,frown:`⌢`,Fscr:`ℱ`,fscr:`𝒻`,gacute:`ǵ`,Gamma:`Γ`,gamma:`γ`,Gammad:`Ϝ`,gammad:`ϝ`,gap:`⪆`,Gbreve:`Ğ`,gbreve:`ğ`,Gcedil:`Ģ`,Gcirc:`Ĝ`,gcirc:`ĝ`,Gcy:`Г`,gcy:`г`,Gdot:`Ġ`,gdot:`ġ`,gE:`≧`,ge:`≥`,gEl:`⪌`,gel:`⋛`,geq:`≥`,geqq:`≧`,geqslant:`⩾`,ges:`⩾`,gescc:`⪩`,gesdot:`⪀`,gesdoto:`⪂`,gesdotol:`⪄`,gesl:`⋛︀`,gesles:`⪔`,Gfr:`𝔊`,gfr:`𝔤`,Gg:`⋙`,gg:`≫`,ggg:`⋙`,gimel:`ℷ`,GJcy:`Ѓ`,gjcy:`ѓ`,gl:`≷`,gla:`⪥`,glE:`⪒`,glj:`⪤`,gnap:`⪊`,gnapprox:`⪊`,gnE:`≩`,gne:`⪈`,gneq:`⪈`,gneqq:`≩`,gnsim:`⋧`,Gopf:`𝔾`,gopf:`𝕘`,grave:"`",GreaterEqual:`≥`,GreaterEqualLess:`⋛`,GreaterFullEqual:`≧`,GreaterGreater:`⪢`,GreaterLess:`≷`,GreaterSlantEqual:`⩾`,GreaterTilde:`≳`,Gscr:`𝒢`,gscr:`ℊ`,gsim:`≳`,gsime:`⪎`,gsiml:`⪐`,Gt:`≫`,GT:`>`,gt:`>`,gtcc:`⪧`,gtcir:`⩺`,gtdot:`⋗`,gtlPar:`⦕`,gtquest:`⩼`,gtrapprox:`⪆`,gtrarr:`⥸`,gtrdot:`⋗`,gtreqless:`⋛`,gtreqqless:`⪌`,gtrless:`≷`,gtrsim:`≳`,gvertneqq:`≩︀`,gvnE:`≩︀`,Hacek:`ˇ`,hairsp:` `,half:`½`,hamilt:`ℋ`,HARDcy:`Ъ`,hardcy:`ъ`,hArr:`⇔`,harr:`↔`,harrcir:`⥈`,harrw:`↭`,Hat:`^`,hbar:`ℏ`,Hcirc:`Ĥ`,hcirc:`ĥ`,hearts:`♥`,heartsuit:`♥`,hellip:`…`,hercon:`⊹`,Hfr:`ℌ`,hfr:`𝔥`,HilbertSpace:`ℋ`,hksearow:`⤥`,hkswarow:`⤦`,hoarr:`⇿`,homtht:`∻`,hookleftarrow:`↩`,hookrightarrow:`↪`,Hopf:`ℍ`,hopf:`𝕙`,horbar:`―`,HorizontalLine:`─`,Hscr:`ℋ`,hscr:`𝒽`,hslash:`ℏ`,Hstrok:`Ħ`,hstrok:`ħ`,HumpDownHump:`≎`,HumpEqual:`≏`,hybull:`⁃`,hyphen:`‐`,Iacute:`Í`,iacute:`í`,ic:`⁣`,Icirc:`Î`,icirc:`î`,Icy:`И`,icy:`и`,Idot:`İ`,IEcy:`Е`,iecy:`е`,iexcl:`¡`,iff:`⇔`,Ifr:`ℑ`,ifr:`𝔦`,Igrave:`Ì`,igrave:`ì`,ii:`ⅈ`,iiiint:`⨌`,iiint:`∭`,iinfin:`⧜`,iiota:`℩`,IJlig:`IJ`,ijlig:`ij`,Im:`ℑ`,Imacr:`Ī`,imacr:`ī`,image:`ℑ`,ImaginaryI:`ⅈ`,imagline:`ℐ`,imagpart:`ℑ`,imath:`ı`,imof:`⊷`,imped:`Ƶ`,Implies:`⇒`,in:`∈`,incare:`℅`,infin:`∞`,infintie:`⧝`,inodot:`ı`,Int:`∬`,int:`∫`,intcal:`⊺`,integers:`ℤ`,Integral:`∫`,intercal:`⊺`,Intersection:`⋂`,intlarhk:`⨗`,intprod:`⨼`,InvisibleComma:`⁣`,InvisibleTimes:`⁢`,IOcy:`Ё`,iocy:`ё`,Iogon:`Į`,iogon:`į`,Iopf:`𝕀`,iopf:`𝕚`,Iota:`Ι`,iota:`ι`,iprod:`⨼`,iquest:`¿`,Iscr:`ℐ`,iscr:`𝒾`,isin:`∈`,isindot:`⋵`,isinE:`⋹`,isins:`⋴`,isinsv:`⋳`,isinv:`∈`,it:`⁢`,Itilde:`Ĩ`,itilde:`ĩ`,Iukcy:`І`,iukcy:`і`,Iuml:`Ï`,iuml:`ï`,Jcirc:`Ĵ`,jcirc:`ĵ`,Jcy:`Й`,jcy:`й`,Jfr:`𝔍`,jfr:`𝔧`,jmath:`ȷ`,Jopf:`𝕁`,jopf:`𝕛`,Jscr:`𝒥`,jscr:`𝒿`,Jsercy:`Ј`,jsercy:`ј`,Jukcy:`Є`,jukcy:`є`,Kappa:`Κ`,kappa:`κ`,kappav:`ϰ`,Kcedil:`Ķ`,kcedil:`ķ`,Kcy:`К`,kcy:`к`,Kfr:`𝔎`,kfr:`𝔨`,kgreen:`ĸ`,KHcy:`Х`,khcy:`х`,KJcy:`Ќ`,kjcy:`ќ`,Kopf:`𝕂`,kopf:`𝕜`,Kscr:`𝒦`,kscr:`𝓀`,lAarr:`⇚`,Lacute:`Ĺ`,lacute:`ĺ`,laemptyv:`⦴`,lagran:`ℒ`,Lambda:`Λ`,lambda:`λ`,Lang:`⟪`,lang:`⟨`,langd:`⦑`,langle:`⟨`,lap:`⪅`,Laplacetrf:`ℒ`,laquo:`«`,Larr:`↞`,lArr:`⇐`,larr:`←`,larrb:`⇤`,larrbfs:`⤟`,larrfs:`⤝`,larrhk:`↩`,larrlp:`↫`,larrpl:`⤹`,larrsim:`⥳`,larrtl:`↢`,lat:`⪫`,lAtail:`⤛`,latail:`⤙`,late:`⪭`,lates:`⪭︀`,lBarr:`⤎`,lbarr:`⤌`,lbbrk:`❲`,lbrace:`{`,lbrack:`[`,lbrke:`⦋`,lbrksld:`⦏`,lbrkslu:`⦍`,Lcaron:`Ľ`,lcaron:`ľ`,Lcedil:`Ļ`,lcedil:`ļ`,lceil:`⌈`,lcub:`{`,Lcy:`Л`,lcy:`л`,ldca:`⤶`,ldquo:`“`,ldquor:`„`,ldrdhar:`⥧`,ldrushar:`⥋`,ldsh:`↲`,lE:`≦`,le:`≤`,LeftAngleBracket:`⟨`,LeftArrow:`←`,Leftarrow:`⇐`,leftarrow:`←`,LeftArrowBar:`⇤`,LeftArrowRightArrow:`⇆`,leftarrowtail:`↢`,LeftCeiling:`⌈`,LeftDoubleBracket:`⟦`,LeftDownTeeVector:`⥡`,LeftDownVector:`⇃`,LeftDownVectorBar:`⥙`,LeftFloor:`⌊`,leftharpoondown:`↽`,leftharpoonup:`↼`,leftleftarrows:`⇇`,LeftRightArrow:`↔`,Leftrightarrow:`⇔`,leftrightarrow:`↔`,leftrightarrows:`⇆`,leftrightharpoons:`⇋`,leftrightsquigarrow:`↭`,LeftRightVector:`⥎`,LeftTee:`⊣`,LeftTeeArrow:`↤`,LeftTeeVector:`⥚`,leftthreetimes:`⋋`,LeftTriangle:`⊲`,LeftTriangleBar:`⧏`,LeftTriangleEqual:`⊴`,LeftUpDownVector:`⥑`,LeftUpTeeVector:`⥠`,LeftUpVector:`↿`,LeftUpVectorBar:`⥘`,LeftVector:`↼`,LeftVectorBar:`⥒`,lEg:`⪋`,leg:`⋚`,leq:`≤`,leqq:`≦`,leqslant:`⩽`,les:`⩽`,lescc:`⪨`,lesdot:`⩿`,lesdoto:`⪁`,lesdotor:`⪃`,lesg:`⋚︀`,lesges:`⪓`,lessapprox:`⪅`,lessdot:`⋖`,lesseqgtr:`⋚`,lesseqqgtr:`⪋`,LessEqualGreater:`⋚`,LessFullEqual:`≦`,LessGreater:`≶`,lessgtr:`≶`,LessLess:`⪡`,lesssim:`≲`,LessSlantEqual:`⩽`,LessTilde:`≲`,lfisht:`⥼`,lfloor:`⌊`,Lfr:`𝔏`,lfr:`𝔩`,lg:`≶`,lgE:`⪑`,lHar:`⥢`,lhard:`↽`,lharu:`↼`,lharul:`⥪`,lhblk:`▄`,LJcy:`Љ`,ljcy:`љ`,Ll:`⋘`,ll:`≪`,llarr:`⇇`,llcorner:`⌞`,Lleftarrow:`⇚`,llhard:`⥫`,lltri:`◺`,Lmidot:`Ŀ`,lmidot:`ŀ`,lmoust:`⎰`,lmoustache:`⎰`,lnap:`⪉`,lnapprox:`⪉`,lnE:`≨`,lne:`⪇`,lneq:`⪇`,lneqq:`≨`,lnsim:`⋦`,loang:`⟬`,loarr:`⇽`,lobrk:`⟦`,LongLeftArrow:`⟵`,Longleftarrow:`⟸`,longleftarrow:`⟵`,LongLeftRightArrow:`⟷`,Longleftrightarrow:`⟺`,longleftrightarrow:`⟷`,longmapsto:`⟼`,LongRightArrow:`⟶`,Longrightarrow:`⟹`,longrightarrow:`⟶`,looparrowleft:`↫`,looparrowright:`↬`,lopar:`⦅`,Lopf:`𝕃`,lopf:`𝕝`,loplus:`⨭`,lotimes:`⨴`,lowast:`∗`,lowbar:`_`,LowerLeftArrow:`↙`,LowerRightArrow:`↘`,loz:`◊`,lozenge:`◊`,lozf:`⧫`,lpar:`(`,lparlt:`⦓`,lrarr:`⇆`,lrcorner:`⌟`,lrhar:`⇋`,lrhard:`⥭`,lrm:`‎`,lrtri:`⊿`,lsaquo:`‹`,Lscr:`ℒ`,lscr:`𝓁`,Lsh:`↰`,lsh:`↰`,lsim:`≲`,lsime:`⪍`,lsimg:`⪏`,lsqb:`[`,lsquo:`‘`,lsquor:`‚`,Lstrok:`Ł`,lstrok:`ł`,Lt:`≪`,LT:`<`,lt:`<`,ltcc:`⪦`,ltcir:`⩹`,ltdot:`⋖`,lthree:`⋋`,ltimes:`⋉`,ltlarr:`⥶`,ltquest:`⩻`,ltri:`◃`,ltrie:`⊴`,ltrif:`◂`,ltrPar:`⦖`,lurdshar:`⥊`,luruhar:`⥦`,lvertneqq:`≨︀`,lvnE:`≨︀`,macr:`¯`,male:`♂`,malt:`✠`,maltese:`✠`,Map:`⤅`,map:`↦`,mapsto:`↦`,mapstodown:`↧`,mapstoleft:`↤`,mapstoup:`↥`,marker:`▮`,mcomma:`⨩`,Mcy:`М`,mcy:`м`,mdash:`—`,mDDot:`∺`,measuredangle:`∡`,MediumSpace:` `,Mellintrf:`ℳ`,Mfr:`𝔐`,mfr:`𝔪`,mho:`℧`,micro:`µ`,mid:`∣`,midast:`*`,midcir:`⫰`,middot:`·`,minus:`−`,minusb:`⊟`,minusd:`∸`,minusdu:`⨪`,MinusPlus:`∓`,mlcp:`⫛`,mldr:`…`,mnplus:`∓`,models:`⊧`,Mopf:`𝕄`,mopf:`𝕞`,mp:`∓`,Mscr:`ℳ`,mscr:`𝓂`,mstpos:`∾`,Mu:`Μ`,mu:`μ`,multimap:`⊸`,mumap:`⊸`,nabla:`∇`,Nacute:`Ń`,nacute:`ń`,nang:`∠⃒`,nap:`≉`,napE:`⩰̸`,napid:`≋̸`,napos:`ʼn`,napprox:`≉`,natur:`♮`,natural:`♮`,naturals:`ℕ`,nbsp:`\xA0`,nbump:`≎̸`,nbumpe:`≏̸`,ncap:`⩃`,Ncaron:`Ň`,ncaron:`ň`,Ncedil:`Ņ`,ncedil:`ņ`,ncong:`≇`,ncongdot:`⩭̸`,ncup:`⩂`,Ncy:`Н`,ncy:`н`,ndash:`–`,ne:`≠`,nearhk:`⤤`,neArr:`⇗`,nearr:`↗`,nearrow:`↗`,nedot:`≐̸`,NegativeMediumSpace:`​`,NegativeThickSpace:`​`,NegativeThinSpace:`​`,NegativeVeryThinSpace:`​`,nequiv:`≢`,nesear:`⤨`,nesim:`≂̸`,NestedGreaterGreater:`≫`,NestedLessLess:`≪`,NewLine:` `,nexist:`∄`,nexists:`∄`,Nfr:`𝔑`,nfr:`𝔫`,ngE:`≧̸`,nge:`≱`,ngeq:`≱`,ngeqq:`≧̸`,ngeqslant:`⩾̸`,nges:`⩾̸`,nGg:`⋙̸`,ngsim:`≵`,nGt:`≫⃒`,ngt:`≯`,ngtr:`≯`,nGtv:`≫̸`,nhArr:`⇎`,nharr:`↮`,nhpar:`⫲`,ni:`∋`,nis:`⋼`,nisd:`⋺`,niv:`∋`,NJcy:`Њ`,njcy:`њ`,nlArr:`⇍`,nlarr:`↚`,nldr:`‥`,nlE:`≦̸`,nle:`≰`,nLeftarrow:`⇍`,nleftarrow:`↚`,nLeftrightarrow:`⇎`,nleftrightarrow:`↮`,nleq:`≰`,nleqq:`≦̸`,nleqslant:`⩽̸`,nles:`⩽̸`,nless:`≮`,nLl:`⋘̸`,nlsim:`≴`,nLt:`≪⃒`,nlt:`≮`,nltri:`⋪`,nltrie:`⋬`,nLtv:`≪̸`,nmid:`∤`,NoBreak:`⁠`,NonBreakingSpace:`\xA0`,Nopf:`ℕ`,nopf:`𝕟`,Not:`⫬`,not:`¬`,NotCongruent:`≢`,NotCupCap:`≭`,NotDoubleVerticalBar:`∦`,NotElement:`∉`,NotEqual:`≠`,NotEqualTilde:`≂̸`,NotExists:`∄`,NotGreater:`≯`,NotGreaterEqual:`≱`,NotGreaterFullEqual:`≧̸`,NotGreaterGreater:`≫̸`,NotGreaterLess:`≹`,NotGreaterSlantEqual:`⩾̸`,NotGreaterTilde:`≵`,NotHumpDownHump:`≎̸`,NotHumpEqual:`≏̸`,notin:`∉`,notindot:`⋵̸`,notinE:`⋹̸`,notinva:`∉`,notinvb:`⋷`,notinvc:`⋶`,NotLeftTriangle:`⋪`,NotLeftTriangleBar:`⧏̸`,NotLeftTriangleEqual:`⋬`,NotLess:`≮`,NotLessEqual:`≰`,NotLessGreater:`≸`,NotLessLess:`≪̸`,NotLessSlantEqual:`⩽̸`,NotLessTilde:`≴`,NotNestedGreaterGreater:`⪢̸`,NotNestedLessLess:`⪡̸`,notni:`∌`,notniva:`∌`,notnivb:`⋾`,notnivc:`⋽`,NotPrecedes:`⊀`,NotPrecedesEqual:`⪯̸`,NotPrecedesSlantEqual:`⋠`,NotReverseElement:`∌`,NotRightTriangle:`⋫`,NotRightTriangleBar:`⧐̸`,NotRightTriangleEqual:`⋭`,NotSquareSubset:`⊏̸`,NotSquareSubsetEqual:`⋢`,NotSquareSuperset:`⊐̸`,NotSquareSupersetEqual:`⋣`,NotSubset:`⊂⃒`,NotSubsetEqual:`⊈`,NotSucceeds:`⊁`,NotSucceedsEqual:`⪰̸`,NotSucceedsSlantEqual:`⋡`,NotSucceedsTilde:`≿̸`,NotSuperset:`⊃⃒`,NotSupersetEqual:`⊉`,NotTilde:`≁`,NotTildeEqual:`≄`,NotTildeFullEqual:`≇`,NotTildeTilde:`≉`,NotVerticalBar:`∤`,npar:`∦`,nparallel:`∦`,nparsl:`⫽⃥`,npart:`∂̸`,npolint:`⨔`,npr:`⊀`,nprcue:`⋠`,npre:`⪯̸`,nprec:`⊀`,npreceq:`⪯̸`,nrArr:`⇏`,nrarr:`↛`,nrarrc:`⤳̸`,nrarrw:`↝̸`,nRightarrow:`⇏`,nrightarrow:`↛`,nrtri:`⋫`,nrtrie:`⋭`,nsc:`⊁`,nsccue:`⋡`,nsce:`⪰̸`,Nscr:`𝒩`,nscr:`𝓃`,nshortmid:`∤`,nshortparallel:`∦`,nsim:`≁`,nsime:`≄`,nsimeq:`≄`,nsmid:`∤`,nspar:`∦`,nsqsube:`⋢`,nsqsupe:`⋣`,nsub:`⊄`,nsubE:`⫅̸`,nsube:`⊈`,nsubset:`⊂⃒`,nsubseteq:`⊈`,nsubseteqq:`⫅̸`,nsucc:`⊁`,nsucceq:`⪰̸`,nsup:`⊅`,nsupE:`⫆̸`,nsupe:`⊉`,nsupset:`⊃⃒`,nsupseteq:`⊉`,nsupseteqq:`⫆̸`,ntgl:`≹`,Ntilde:`Ñ`,ntilde:`ñ`,ntlg:`≸`,ntriangleleft:`⋪`,ntrianglelefteq:`⋬`,ntriangleright:`⋫`,ntrianglerighteq:`⋭`,Nu:`Ν`,nu:`ν`,num:`#`,numero:`№`,numsp:` `,nvap:`≍⃒`,nVDash:`⊯`,nVdash:`⊮`,nvDash:`⊭`,nvdash:`⊬`,nvge:`≥⃒`,nvgt:`>⃒`,nvHarr:`⤄`,nvinfin:`⧞`,nvlArr:`⤂`,nvle:`≤⃒`,nvlt:`<⃒`,nvltrie:`⊴⃒`,nvrArr:`⤃`,nvrtrie:`⊵⃒`,nvsim:`∼⃒`,nwarhk:`⤣`,nwArr:`⇖`,nwarr:`↖`,nwarrow:`↖`,nwnear:`⤧`,Oacute:`Ó`,oacute:`ó`,oast:`⊛`,ocir:`⊚`,Ocirc:`Ô`,ocirc:`ô`,Ocy:`О`,ocy:`о`,odash:`⊝`,Odblac:`Ő`,odblac:`ő`,odiv:`⨸`,odot:`⊙`,odsold:`⦼`,OElig:`Œ`,oelig:`œ`,ofcir:`⦿`,Ofr:`𝔒`,ofr:`𝔬`,ogon:`˛`,Ograve:`Ò`,ograve:`ò`,ogt:`⧁`,ohbar:`⦵`,ohm:`Ω`,oint:`∮`,olarr:`↺`,olcir:`⦾`,olcross:`⦻`,oline:`‾`,olt:`⧀`,Omacr:`Ō`,omacr:`ō`,Omega:`Ω`,omega:`ω`,Omicron:`Ο`,omicron:`ο`,omid:`⦶`,ominus:`⊖`,Oopf:`𝕆`,oopf:`𝕠`,opar:`⦷`,OpenCurlyDoubleQuote:`“`,OpenCurlyQuote:`‘`,operp:`⦹`,oplus:`⊕`,Or:`⩔`,or:`∨`,orarr:`↻`,ord:`⩝`,order:`ℴ`,orderof:`ℴ`,ordf:`ª`,ordm:`º`,origof:`⊶`,oror:`⩖`,orslope:`⩗`,orv:`⩛`,oS:`Ⓢ`,Oscr:`𝒪`,oscr:`ℴ`,Oslash:`Ø`,oslash:`ø`,osol:`⊘`,Otilde:`Õ`,otilde:`õ`,Otimes:`⨷`,otimes:`⊗`,otimesas:`⨶`,Ouml:`Ö`,ouml:`ö`,ovbar:`⌽`,OverBar:`‾`,OverBrace:`⏞`,OverBracket:`⎴`,OverParenthesis:`⏜`,par:`∥`,para:`¶`,parallel:`∥`,parsim:`⫳`,parsl:`⫽`,part:`∂`,PartialD:`∂`,Pcy:`П`,pcy:`п`,percnt:`%`,period:`.`,permil:`‰`,perp:`⊥`,pertenk:`‱`,Pfr:`𝔓`,pfr:`𝔭`,Phi:`Φ`,phi:`φ`,phiv:`ϕ`,phmmat:`ℳ`,phone:`☎`,Pi:`Π`,pi:`π`,pitchfork:`⋔`,piv:`ϖ`,planck:`ℏ`,planckh:`ℎ`,plankv:`ℏ`,plus:`+`,plusacir:`⨣`,plusb:`⊞`,pluscir:`⨢`,plusdo:`∔`,plusdu:`⨥`,pluse:`⩲`,PlusMinus:`±`,plusmn:`±`,plussim:`⨦`,plustwo:`⨧`,pm:`±`,Poincareplane:`ℌ`,pointint:`⨕`,Popf:`ℙ`,popf:`𝕡`,pound:`£`,Pr:`⪻`,pr:`≺`,prap:`⪷`,prcue:`≼`,prE:`⪳`,pre:`⪯`,prec:`≺`,precapprox:`⪷`,preccurlyeq:`≼`,Precedes:`≺`,PrecedesEqual:`⪯`,PrecedesSlantEqual:`≼`,PrecedesTilde:`≾`,preceq:`⪯`,precnapprox:`⪹`,precneqq:`⪵`,precnsim:`⋨`,precsim:`≾`,Prime:`″`,prime:`′`,primes:`ℙ`,prnap:`⪹`,prnE:`⪵`,prnsim:`⋨`,prod:`∏`,Product:`∏`,profalar:`⌮`,profline:`⌒`,profsurf:`⌓`,prop:`∝`,Proportion:`∷`,Proportional:`∝`,propto:`∝`,prsim:`≾`,prurel:`⊰`,Pscr:`𝒫`,pscr:`𝓅`,Psi:`Ψ`,psi:`ψ`,puncsp:` `,Qfr:`𝔔`,qfr:`𝔮`,qint:`⨌`,Qopf:`ℚ`,qopf:`𝕢`,qprime:`⁗`,Qscr:`𝒬`,qscr:`𝓆`,quaternions:`ℍ`,quatint:`⨖`,quest:`?`,questeq:`≟`,QUOT:`"`,quot:`"`,rAarr:`⇛`,race:`∽̱`,Racute:`Ŕ`,racute:`ŕ`,radic:`√`,raemptyv:`⦳`,Rang:`⟫`,rang:`⟩`,rangd:`⦒`,range:`⦥`,rangle:`⟩`,raquo:`»`,Rarr:`↠`,rArr:`⇒`,rarr:`→`,rarrap:`⥵`,rarrb:`⇥`,rarrbfs:`⤠`,rarrc:`⤳`,rarrfs:`⤞`,rarrhk:`↪`,rarrlp:`↬`,rarrpl:`⥅`,rarrsim:`⥴`,Rarrtl:`⤖`,rarrtl:`↣`,rarrw:`↝`,rAtail:`⤜`,ratail:`⤚`,ratio:`∶`,rationals:`ℚ`,RBarr:`⤐`,rBarr:`⤏`,rbarr:`⤍`,rbbrk:`❳`,rbrace:`}`,rbrack:`]`,rbrke:`⦌`,rbrksld:`⦎`,rbrkslu:`⦐`,Rcaron:`Ř`,rcaron:`ř`,Rcedil:`Ŗ`,rcedil:`ŗ`,rceil:`⌉`,rcub:`}`,Rcy:`Р`,rcy:`р`,rdca:`⤷`,rdldhar:`⥩`,rdquo:`”`,rdquor:`”`,rdsh:`↳`,Re:`ℜ`,real:`ℜ`,realine:`ℛ`,realpart:`ℜ`,reals:`ℝ`,rect:`▭`,REG:`®`,reg:`®`,ReverseElement:`∋`,ReverseEquilibrium:`⇋`,ReverseUpEquilibrium:`⥯`,rfisht:`⥽`,rfloor:`⌋`,Rfr:`ℜ`,rfr:`𝔯`,rHar:`⥤`,rhard:`⇁`,rharu:`⇀`,rharul:`⥬`,Rho:`Ρ`,rho:`ρ`,rhov:`ϱ`,RightAngleBracket:`⟩`,RightArrow:`→`,Rightarrow:`⇒`,rightarrow:`→`,RightArrowBar:`⇥`,RightArrowLeftArrow:`⇄`,rightarrowtail:`↣`,RightCeiling:`⌉`,RightDoubleBracket:`⟧`,RightDownTeeVector:`⥝`,RightDownVector:`⇂`,RightDownVectorBar:`⥕`,RightFloor:`⌋`,rightharpoondown:`⇁`,rightharpoonup:`⇀`,rightleftarrows:`⇄`,rightleftharpoons:`⇌`,rightrightarrows:`⇉`,rightsquigarrow:`↝`,RightTee:`⊢`,RightTeeArrow:`↦`,RightTeeVector:`⥛`,rightthreetimes:`⋌`,RightTriangle:`⊳`,RightTriangleBar:`⧐`,RightTriangleEqual:`⊵`,RightUpDownVector:`⥏`,RightUpTeeVector:`⥜`,RightUpVector:`↾`,RightUpVectorBar:`⥔`,RightVector:`⇀`,RightVectorBar:`⥓`,ring:`˚`,risingdotseq:`≓`,rlarr:`⇄`,rlhar:`⇌`,rlm:`‏`,rmoust:`⎱`,rmoustache:`⎱`,rnmid:`⫮`,roang:`⟭`,roarr:`⇾`,robrk:`⟧`,ropar:`⦆`,Ropf:`ℝ`,ropf:`𝕣`,roplus:`⨮`,rotimes:`⨵`,RoundImplies:`⥰`,rpar:`)`,rpargt:`⦔`,rppolint:`⨒`,rrarr:`⇉`,Rrightarrow:`⇛`,rsaquo:`›`,Rscr:`ℛ`,rscr:`𝓇`,Rsh:`↱`,rsh:`↱`,rsqb:`]`,rsquo:`’`,rsquor:`’`,rthree:`⋌`,rtimes:`⋊`,rtri:`▹`,rtrie:`⊵`,rtrif:`▸`,rtriltri:`⧎`,RuleDelayed:`⧴`,ruluhar:`⥨`,rx:`℞`,Sacute:`Ś`,sacute:`ś`,sbquo:`‚`,Sc:`⪼`,sc:`≻`,scap:`⪸`,Scaron:`Š`,scaron:`š`,sccue:`≽`,scE:`⪴`,sce:`⪰`,Scedil:`Ş`,scedil:`ş`,Scirc:`Ŝ`,scirc:`ŝ`,scnap:`⪺`,scnE:`⪶`,scnsim:`⋩`,scpolint:`⨓`,scsim:`≿`,Scy:`С`,scy:`с`,sdot:`⋅`,sdotb:`⊡`,sdote:`⩦`,searhk:`⤥`,seArr:`⇘`,searr:`↘`,searrow:`↘`,sect:`§`,semi:`;`,seswar:`⤩`,setminus:`∖`,setmn:`∖`,sext:`✶`,Sfr:`𝔖`,sfr:`𝔰`,sfrown:`⌢`,sharp:`♯`,SHCHcy:`Щ`,shchcy:`щ`,SHcy:`Ш`,shcy:`ш`,ShortDownArrow:`↓`,ShortLeftArrow:`←`,shortmid:`∣`,shortparallel:`∥`,ShortRightArrow:`→`,ShortUpArrow:`↑`,shy:`­`,Sigma:`Σ`,sigma:`σ`,sigmaf:`ς`,sigmav:`ς`,sim:`∼`,simdot:`⩪`,sime:`≃`,simeq:`≃`,simg:`⪞`,simgE:`⪠`,siml:`⪝`,simlE:`⪟`,simne:`≆`,simplus:`⨤`,simrarr:`⥲`,slarr:`←`,SmallCircle:`∘`,smallsetminus:`∖`,smashp:`⨳`,smeparsl:`⧤`,smid:`∣`,smile:`⌣`,smt:`⪪`,smte:`⪬`,smtes:`⪬︀`,SOFTcy:`Ь`,softcy:`ь`,sol:`/`,solb:`⧄`,solbar:`⌿`,Sopf:`𝕊`,sopf:`𝕤`,spades:`♠`,spadesuit:`♠`,spar:`∥`,sqcap:`⊓`,sqcaps:`⊓︀`,sqcup:`⊔`,sqcups:`⊔︀`,Sqrt:`√`,sqsub:`⊏`,sqsube:`⊑`,sqsubset:`⊏`,sqsubseteq:`⊑`,sqsup:`⊐`,sqsupe:`⊒`,sqsupset:`⊐`,sqsupseteq:`⊒`,squ:`□`,Square:`□`,square:`□`,SquareIntersection:`⊓`,SquareSubset:`⊏`,SquareSubsetEqual:`⊑`,SquareSuperset:`⊐`,SquareSupersetEqual:`⊒`,SquareUnion:`⊔`,squarf:`▪`,squf:`▪`,srarr:`→`,Sscr:`𝒮`,sscr:`𝓈`,ssetmn:`∖`,ssmile:`⌣`,sstarf:`⋆`,Star:`⋆`,star:`☆`,starf:`★`,straightepsilon:`ϵ`,straightphi:`ϕ`,strns:`¯`,Sub:`⋐`,sub:`⊂`,subdot:`⪽`,subE:`⫅`,sube:`⊆`,subedot:`⫃`,submult:`⫁`,subnE:`⫋`,subne:`⊊`,subplus:`⪿`,subrarr:`⥹`,Subset:`⋐`,subset:`⊂`,subseteq:`⊆`,subseteqq:`⫅`,SubsetEqual:`⊆`,subsetneq:`⊊`,subsetneqq:`⫋`,subsim:`⫇`,subsub:`⫕`,subsup:`⫓`,succ:`≻`,succapprox:`⪸`,succcurlyeq:`≽`,Succeeds:`≻`,SucceedsEqual:`⪰`,SucceedsSlantEqual:`≽`,SucceedsTilde:`≿`,succeq:`⪰`,succnapprox:`⪺`,succneqq:`⪶`,succnsim:`⋩`,succsim:`≿`,SuchThat:`∋`,Sum:`∑`,sum:`∑`,sung:`♪`,Sup:`⋑`,sup:`⊃`,sup1:`¹`,sup2:`²`,sup3:`³`,supdot:`⪾`,supdsub:`⫘`,supE:`⫆`,supe:`⊇`,supedot:`⫄`,Superset:`⊃`,SupersetEqual:`⊇`,suphsol:`⟉`,suphsub:`⫗`,suplarr:`⥻`,supmult:`⫂`,supnE:`⫌`,supne:`⊋`,supplus:`⫀`,Supset:`⋑`,supset:`⊃`,supseteq:`⊇`,supseteqq:`⫆`,supsetneq:`⊋`,supsetneqq:`⫌`,supsim:`⫈`,supsub:`⫔`,supsup:`⫖`,swarhk:`⤦`,swArr:`⇙`,swarr:`↙`,swarrow:`↙`,swnwar:`⤪`,szlig:`ß`,Tab:` `,target:`⌖`,Tau:`Τ`,tau:`τ`,tbrk:`⎴`,Tcaron:`Ť`,tcaron:`ť`,Tcedil:`Ţ`,tcedil:`ţ`,Tcy:`Т`,tcy:`т`,tdot:`⃛`,telrec:`⌕`,Tfr:`𝔗`,tfr:`𝔱`,there4:`∴`,Therefore:`∴`,therefore:`∴`,Theta:`Θ`,theta:`θ`,thetasym:`ϑ`,thetav:`ϑ`,thickapprox:`≈`,thicksim:`∼`,ThickSpace:`  `,thinsp:` `,ThinSpace:` `,thkap:`≈`,thksim:`∼`,THORN:`Þ`,thorn:`þ`,Tilde:`∼`,tilde:`˜`,TildeEqual:`≃`,TildeFullEqual:`≅`,TildeTilde:`≈`,times:`×`,timesb:`⊠`,timesbar:`⨱`,timesd:`⨰`,tint:`∭`,toea:`⤨`,top:`⊤`,topbot:`⌶`,topcir:`⫱`,Topf:`𝕋`,topf:`𝕥`,topfork:`⫚`,tosa:`⤩`,tprime:`‴`,TRADE:`™`,trade:`™`,triangle:`▵`,triangledown:`▿`,triangleleft:`◃`,trianglelefteq:`⊴`,triangleq:`≜`,triangleright:`▹`,trianglerighteq:`⊵`,tridot:`◬`,trie:`≜`,triminus:`⨺`,TripleDot:`⃛`,triplus:`⨹`,trisb:`⧍`,tritime:`⨻`,trpezium:`⏢`,Tscr:`𝒯`,tscr:`𝓉`,TScy:`Ц`,tscy:`ц`,TSHcy:`Ћ`,tshcy:`ћ`,Tstrok:`Ŧ`,tstrok:`ŧ`,twixt:`≬`,twoheadleftarrow:`↞`,twoheadrightarrow:`↠`,Uacute:`Ú`,uacute:`ú`,Uarr:`↟`,uArr:`⇑`,uarr:`↑`,Uarrocir:`⥉`,Ubrcy:`Ў`,ubrcy:`ў`,Ubreve:`Ŭ`,ubreve:`ŭ`,Ucirc:`Û`,ucirc:`û`,Ucy:`У`,ucy:`у`,udarr:`⇅`,Udblac:`Ű`,udblac:`ű`,udhar:`⥮`,ufisht:`⥾`,Ufr:`𝔘`,ufr:`𝔲`,Ugrave:`Ù`,ugrave:`ù`,uHar:`⥣`,uharl:`↿`,uharr:`↾`,uhblk:`▀`,ulcorn:`⌜`,ulcorner:`⌜`,ulcrop:`⌏`,ultri:`◸`,Umacr:`Ū`,umacr:`ū`,uml:`¨`,UnderBar:`_`,UnderBrace:`⏟`,UnderBracket:`⎵`,UnderParenthesis:`⏝`,Union:`⋃`,UnionPlus:`⊎`,Uogon:`Ų`,uogon:`ų`,Uopf:`𝕌`,uopf:`𝕦`,UpArrow:`↑`,Uparrow:`⇑`,uparrow:`↑`,UpArrowBar:`⤒`,UpArrowDownArrow:`⇅`,UpDownArrow:`↕`,Updownarrow:`⇕`,updownarrow:`↕`,UpEquilibrium:`⥮`,upharpoonleft:`↿`,upharpoonright:`↾`,uplus:`⊎`,UpperLeftArrow:`↖`,UpperRightArrow:`↗`,Upsi:`ϒ`,upsi:`υ`,upsih:`ϒ`,Upsilon:`Υ`,upsilon:`υ`,UpTee:`⊥`,UpTeeArrow:`↥`,upuparrows:`⇈`,urcorn:`⌝`,urcorner:`⌝`,urcrop:`⌎`,Uring:`Ů`,uring:`ů`,urtri:`◹`,Uscr:`𝒰`,uscr:`𝓊`,utdot:`⋰`,Utilde:`Ũ`,utilde:`ũ`,utri:`▵`,utrif:`▴`,uuarr:`⇈`,Uuml:`Ü`,uuml:`ü`,uwangle:`⦧`,vangrt:`⦜`,varepsilon:`ϵ`,varkappa:`ϰ`,varnothing:`∅`,varphi:`ϕ`,varpi:`ϖ`,varpropto:`∝`,vArr:`⇕`,varr:`↕`,varrho:`ϱ`,varsigma:`ς`,varsubsetneq:`⊊︀`,varsubsetneqq:`⫋︀`,varsupsetneq:`⊋︀`,varsupsetneqq:`⫌︀`,vartheta:`ϑ`,vartriangleleft:`⊲`,vartriangleright:`⊳`,Vbar:`⫫`,vBar:`⫨`,vBarv:`⫩`,Vcy:`В`,vcy:`в`,VDash:`⊫`,Vdash:`⊩`,vDash:`⊨`,vdash:`⊢`,Vdashl:`⫦`,Vee:`⋁`,vee:`∨`,veebar:`⊻`,veeeq:`≚`,vellip:`⋮`,Verbar:`‖`,verbar:`|`,Vert:`‖`,vert:`|`,VerticalBar:`∣`,VerticalLine:`|`,VerticalSeparator:`❘`,VerticalTilde:`≀`,VeryThinSpace:` `,Vfr:`𝔙`,vfr:`𝔳`,vltri:`⊲`,vnsub:`⊂⃒`,vnsup:`⊃⃒`,Vopf:`𝕍`,vopf:`𝕧`,vprop:`∝`,vrtri:`⊳`,Vscr:`𝒱`,vscr:`𝓋`,vsubnE:`⫋︀`,vsubne:`⊊︀`,vsupnE:`⫌︀`,vsupne:`⊋︀`,Vvdash:`⊪`,vzigzag:`⦚`,Wcirc:`Ŵ`,wcirc:`ŵ`,wedbar:`⩟`,Wedge:`⋀`,wedge:`∧`,wedgeq:`≙`,weierp:`℘`,Wfr:`𝔚`,wfr:`𝔴`,Wopf:`𝕎`,wopf:`𝕨`,wp:`℘`,wr:`≀`,wreath:`≀`,Wscr:`𝒲`,wscr:`𝓌`,xcap:`⋂`,xcirc:`◯`,xcup:`⋃`,xdtri:`▽`,Xfr:`𝔛`,xfr:`𝔵`,xhArr:`⟺`,xharr:`⟷`,Xi:`Ξ`,xi:`ξ`,xlArr:`⟸`,xlarr:`⟵`,xmap:`⟼`,xnis:`⋻`,xodot:`⨀`,Xopf:`𝕏`,xopf:`𝕩`,xoplus:`⨁`,xotime:`⨂`,xrArr:`⟹`,xrarr:`⟶`,Xscr:`𝒳`,xscr:`𝓍`,xsqcup:`⨆`,xuplus:`⨄`,xutri:`△`,xvee:`⋁`,xwedge:`⋀`,Yacute:`Ý`,yacute:`ý`,YAcy:`Я`,yacy:`я`,Ycirc:`Ŷ`,ycirc:`ŷ`,Ycy:`Ы`,ycy:`ы`,yen:`¥`,Yfr:`𝔜`,yfr:`𝔶`,YIcy:`Ї`,yicy:`ї`,Yopf:`𝕐`,yopf:`𝕪`,Yscr:`𝒴`,yscr:`𝓎`,YUcy:`Ю`,yucy:`ю`,Yuml:`Ÿ`,yuml:`ÿ`,Zacute:`Ź`,zacute:`ź`,Zcaron:`Ž`,zcaron:`ž`,Zcy:`З`,zcy:`з`,Zdot:`Ż`,zdot:`ż`,zeetrf:`ℨ`,ZeroWidthSpace:`​`,Zeta:`Ζ`,zeta:`ζ`,Zfr:`ℨ`,zfr:`𝔷`,ZHcy:`Ж`,zhcy:`ж`,zigrarr:`⇝`,Zopf:`ℤ`,zopf:`𝕫`,Zscr:`𝒵`,zscr:`𝓏`,zwj:`‍`,zwnj:`‌`}),e.entityMap=e.HTML_ENTITIES})),jI=t((e=>{var t=EI(),n=OI(),r=DI(),i=t.isHTMLEscapableRawTextElement,a=t.isHTMLMimeType,o=t.isHTMLRawTextElement,s=t.hasOwn,c=t.NAMESPACE,l=r.ParseError,u=r.DOMException,d=0,f=1,p=2,m=3,h=4,g=5,_=6,v=7;function y(){}y.prototype={parse:function(e,t,n){var r=this.domBuilder;r.startDocument(),E(t,t=Object.create(null)),x(e,t,n,r,this.errorHandler),r.endDocument()}};var b=/&#?\w+;?/g;function x(e,r,i,o,c){var d=a(o.mimeType);e.indexOf(n.UNICODE_REPLACEMENT_CHARACTER)>=0&&c.warning(`Unicode replacement character detected, source encoding issues?`);function f(e){if(e>65535){e-=65536;var t=55296+(e>>10),n=56320+(e&1023);return String.fromCharCode(t,n)}return String.fromCharCode(e)}function p(e){var t=e[e.length-1]===`;`?e:e+`;`;if(!d&&t!==e)return c.error(`EntityRef: expecting ;`),e;var r=n.Reference.exec(t);if(!r||r[0].length!==t.length)return c.error(`entity not matching Reference production: `+e),e;var a=t.slice(1,-1);return s(i,a)?i[a]:a.charAt(0)===`#`?f(parseInt(a.substring(1).replace(`x`,`0x`))):(c.error(`entity not found:`+e),e)}function m(t){if(t>D){var n=e.substring(D,t).replace(b,p);v&&y(D),o.characters(n,0,t-D),D=t}}var h=0,g=0,_=/\r\n?|\n|$/g,v=o.locator;function y(t,n){for(;t>=g&&(n=_.exec(e));)h=g,g=n.index+n[0].length,v.lineNumber++;v.columnNumber=t-h+1}for(var x=[{currentNSMap:r}],E=[],D=0;;){try{var O=e.indexOf(`<`,D);if(O<0){if(!d&&E.length>0)return c.fatalError(`unclosed xml tag(s): `+E.join(`, `));if(!e.substring(D).match(/^\s*$/)){var M=o.doc,ee=M.createTextNode(e.substring(D));if(M.documentElement)return c.error(`Extra content at the end of the document`);M.appendChild(ee),o.currentElement=ee}return}if(O>D){var te=e.substring(D,O);!d&&E.length===0&&(te=te.replace(new RegExp(n.S_OPT.source,`g`),``),te&&c.error(`Unexpected content outside root element: '`+te+`'`)),m(O)}switch(e.charAt(O+1)){case`/`:var N=e.indexOf(`>`,O+2),ne=e.substring(O+2,N>0?N:void 0);if(!ne)return c.fatalError(`end tag name missing`);var re=n.reg(`^`,n.QName_group,n.S_OPT,`$`),ie=N>0&&re.exec(ne);if(!ie){var ae=N>0&&n.reg(`^`,n.QName_group).exec(ne);if(d&&ae)c.warning(`end tag name contains invalid trailing characters: "`+ne+`"`),ie=ae;else if(ae&&new RegExp(re.source,re.flags+`m`).test(ne))c.error(`end tag name is followed by a line break and trailing content: "`+ne+`"`),ie=ae;else return c.fatalError(`end tag name contains invalid characters: "`+ne+`"`)}if(!o.currentElement&&!o.doc.documentElement)return;var oe=E[E.length-1]||o.currentElement.tagName||o.doc.documentElement.tagName||``;if(oe!==ie[1]){var se=ie[1].toLowerCase();if(!d||oe.toLowerCase()!==se)return c.fatalError(`Opening and ending tag mismatch: "`+oe+`" != "`+ne+`"`)}var ce=x.pop();E.pop();var le=ce.localNSMap;if(o.endElement(ce.uri,ce.localName,oe),le)for(var ue in le)s(le,ue)&&o.endPrefixMapping(ue);N++;break;case`?`:v&&y(O),N=A(e,O,o,c);break;case`!`:v&&y(O),N=k(e,O,o,c,d);break;default:v&&y(O);var de=new j,fe=x[x.length-1].currentNSMap,N=C(e,O,de,fe,p,c,d),pe=de.length;if(de.closed||(d&&t.isHTMLVoidElement(de.tagName)?de.closed=!0:E.push(de.tagName)),v&&pe){for(var me=S(v,{}),he=0;heD?D=N:m(Math.max(O,D)+1)}}function S(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function C(e,t,n,r,i,a,o){function c(e,t,r){if(s(n.attributeNames,e))return a.fatalError(`Attribute `+e+` redefined`);if(!o&&t.indexOf(`<`)>=0)return a.fatalError(`Unescaped '<' not allowed in attributes values`);n.addValue(e,t.replace(/[\t\n\r]/g,` `).replace(b,i),r)}for(var l,u,y=++t,x=d;;){var S=e.charAt(y);if(x===d&&S===`<`)throw Error(`unexpected < in tag name: `+e.slice(t,y));switch(S){case`=`:if(x===f)l=e.slice(t,y),x=m;else if(x===p)x=m;else throw Error(`attribute equal must after attrName`);break;case`'`:case`"`:if(x===m||x===f){if(x===f&&(a.warning(`attribute value must after "="`),l=e.slice(t,y)),t=y+1,y=e.indexOf(S,t),y>0)u=e.slice(t,y),c(l,u,t-1),x=g;else throw Error(`attribute value no end '`+S+`' match`)}else if(x==h)u=e.slice(t,y),c(l,u,t),a.warning(`attribute "`+l+`" missed start quot(`+S+`)!!`),t=y+1,x=g;else throw Error(`attribute value must after "="`);break;case`/`:switch(x){case d:n.setTagName(e.slice(t,y));case g:case _:case v:x=v,n.closed=!0;case h:case f:break;case p:n.closed=!0;break;default:throw Error(`attribute invalid close char('/')`)}break;case``:return a.error(`unexpected end of input`),x==d&&n.setTagName(e.slice(t,y)),y;case`>`:switch(x){case d:n.setTagName(e.slice(t,y));case g:case _:case v:break;case h:case f:u=e.slice(t,y),u.slice(-1)===`/`&&(n.closed=!0,u=u.slice(0,-1));case p:x===p&&(u=l),x==h?(a.warning(`attribute "`+u+`" missed quot(")!`),c(l,u,t)):(o||a.warning(`attribute "`+u+`" missed value!! "`+u+`" instead!!`),c(u,u,t));break;case m:if(!o)return a.fatalError(`AttValue: ' or " expected`)}return y;case`€`:S=` `;default:if(S<=` `)switch(x){case d:n.setTagName(e.slice(t,y)),x=_;break;case f:l=e.slice(t,y),x=p;break;case h:var u=e.slice(t,y);a.warning(`attribute "`+u+`" missed quot(")!!`),c(l,u,t);case g:x=_}else switch(x){case p:o||a.warning(`attribute "`+l+`" missed value!! "`+l+`" instead2!!`),c(l,l,t),t=y,x=f;break;case g:a.warning(`attribute space is required"`+l+`"!!`);case _:x=f,t=y;break;case m:x=h,t=y;break;case v:throw Error(`elements closed character '/' and '>' must be connected to`)}}y++}}function w(e,t,n){for(var r=e.tagName,i=null,a=e.length;a--;){var o=e[a],l=o.qName,u=o.value,d=l.indexOf(`:`);if(d>0)var f=o.prefix=l.slice(0,d),p=l.slice(d+1),m=f===`xmlns`&&p;else p=l,f=null,m=l===`xmlns`&&``;o.localName=p,m!==!1&&(i??(i=Object.create(null),n=Object.create(n)),n[m]=i[m]=u,o.uri=c.XMLNS,t.startPrefixMapping(m,u))}for(var a=e.length;a--;)o=e[a],o.prefix&&(o.prefix===`xml`&&(o.uri=c.XML),o.prefix!==`xmlns`&&(o.uri=n[o.prefix]));var d=r.indexOf(`:`);d>0?(f=e.prefix=r.slice(0,d),p=e.localName=r.slice(d+1)):(f=null,p=e.localName=r);var h=e.uri=n[f||``];if(t.startElement(h,p,r,e),e.closed){if(t.endElement(h,p,r),i)for(f in i)s(i,f)&&t.endPrefixMapping(f)}else return e.currentNSMap=n,e.localNSMap=i,!0}function T(e,t,n,r,a){var s=i(n);if(s||o(n)){var c=RegExp(``,`ig`);c.lastIndex=t;var l=c.exec(e),u=l?l.index:-1;if(u<0)return t+1;var d=e.substring(t+1,u);return s&&(d=d.replace(b,r)),a.characters(d,0,d.length),u}return t+1}function E(e,t){for(var n in e)s(e,n)&&(t[n]=e[n])}function D(e,t){var r=t;function i(t){return t||=0,e.charAt(r+t)}function a(e){e||=1,r+=e}function o(){for(var t=0;r`?(o.skip(1),r.startDTD(l.name,l.publicId,l.systemId,l.internalSubset),r.endDTD(),o.getIndex()):i.fatalError(`doctype not terminated with > at position `+o.getIndex());default:return i.fatalError(`Not well-formed XML starting with "0)return i.fatalError(`processing instruction at position `+t+` is an xml declaration which is only at the start of the document`);if(!n.XMLDecl.test(e.substring(t)))return i.fatalError(`xml declaration is not well-formed`)}return r.processingInstruction(a[1],a[2]),t+a[0].length}function j(){this.attributeNames=Object.create(null)}j.prototype={setTagName:function(e){if(!n.QName_exact.test(e))throw Error(`invalid tagName:`+e);this.tagName=e},addValue:function(e,t,r){if(!n.QName_exact.test(e))throw Error(`invalid attribute:`+e);this.attributeNames[e]=this.length,this[this.length++]={qName:e,value:t,offset:r}},length:0,getLocalName:function(e){return this[e].localName},getLocator:function(e){return this[e].locator},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}},e.XMLReader=y,e.parseUtils=D,e.parseDoctypeCommentOrCData=k})),MI=t((e=>{var t=EI(),n=kI(),r=DI(),i=AI(),a=jI(),o=n.DOMImplementation,s=t.hasDefaultHTMLNamespace,c=t.isHTMLMimeType,l=t.isValidMimeType,u=t.MIME_TYPE,d=t.NAMESPACE,f=r.ParseError,p=a.XMLReader;function m(e){return e.replace(/\r[\n\u0085]/g,` `).replace(/[\r\u0085\u2028\u2029]/g,` `)}function h(e){if(e||={},e.locator===void 0&&(e.locator=!0),this.assign=e.assign||t.assign,this.domHandler=e.domHandler||g,this.onError=e.onError||e.errorHandler,e.errorHandler&&typeof e.errorHandler!=`function`)throw TypeError(`errorHandler object is no longer supported, switch to onError!`);e.errorHandler&&e.errorHandler(`warning`,"The `errorHandler` option has been deprecated, use `onError` instead!",this),this.normalizeLineEndings=e.normalizeLineEndings||m,this.locator=!!e.locator,this.xmlns=this.assign(Object.create(null),e.xmlns)}h.prototype.parseFromString=function(e,n){if(!l(n))throw TypeError(`DOMParser.parseFromString: the provided mimeType "`+n+`" is not valid.`);var r=this.assign(Object.create(null),this.xmlns),a=i.XML_ENTITIES,o=r[``]||null;s(n)?(a=i.HTML_ENTITIES,o=d.HTML):n===u.XML_SVG_IMAGE&&(o=d.SVG),r[``]=o,r.xml=r.xml||d.XML;var c=new this.domHandler({mimeType:n,defaultNamespace:o,onError:this.onError}),f=this.locator?{}:void 0;this.locator&&c.setDocumentLocator(f);var m=new p;return m.errorHandler=c,m.domBuilder=c,!t.isHTMLMimeType(n)&&typeof e!=`string`&&m.errorHandler.fatalError(`source is not a string`),m.parse(this.normalizeLineEndings(String(e)),r,a),c.doc.documentElement||m.errorHandler.fatalError(`missing root element`),c.doc};function g(e){var t=e||{};this.mimeType=t.mimeType||u.XML_APPLICATION,this.defaultNamespace=t.defaultNamespace||null,this.cdata=!1,this.currentElement=void 0,this.doc=void 0,this.locator=void 0,this.onError=t.onError}function _(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}g.prototype={startDocument:function(){var e=new o;this.doc=c(this.mimeType)?e.createHTMLDocument(!1):e.createDocument(this.defaultNamespace,``)},startElement:function(e,t,n,r){var i=this.doc,a=i.createElementNS(e,n||t),o=r.length;b(this,a),this.currentElement=a,this.locator&&_(this.locator,a);for(var s=0;s=t+n||t?new java.lang.String(e,t,n)+``:e}`endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl`.replace(/\w+/g,function(e){g.prototype[e]=function(){return null}});function b(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}function x(e){if(e===`error`)throw`onErrorStopParsing`}function S(){throw`onWarningStopParsing`}e.__DOMHandler=g,e.DOMParser=h,e.normalizeLineEndings=m,e.onErrorStopParsing=x,e.onWarningStopParsing=S})),NI=t((e=>{var t=EI();e.assign=t.assign,e.hasDefaultHTMLNamespace=t.hasDefaultHTMLNamespace,e.isHTMLMimeType=t.isHTMLMimeType,e.isValidMimeType=t.isValidMimeType,e.MIME_TYPE=t.MIME_TYPE,e.NAMESPACE=t.NAMESPACE;var n=DI();e.DOMException=n.DOMException,e.DOMExceptionName=n.DOMExceptionName,e.ExceptionCode=n.ExceptionCode,e.ParseError=n.ParseError;var r=kI();e.Attr=r.Attr,e.CDATASection=r.CDATASection,e.CharacterData=r.CharacterData,e.Comment=r.Comment,e.Document=r.Document,e.DocumentFragment=r.DocumentFragment,e.DocumentType=r.DocumentType,e.DOMImplementation=r.DOMImplementation,e.Element=r.Element,e.Entity=r.Entity,e.EntityReference=r.EntityReference,e.LiveNodeList=r.LiveNodeList,e.NamedNodeMap=r.NamedNodeMap,e.Node=r.Node,e.NodeList=r.NodeList,e.Notation=r.Notation,e.ProcessingInstruction=r.ProcessingInstruction,e.Text=r.Text,e.XMLSerializer=r.XMLSerializer;var i=MI();e.DOMParser=i.DOMParser,e.normalizeLineEndings=i.normalizeLineEndings,e.onErrorStopParsing=i.onErrorStopParsing,e.onWarningStopParsing=i.onWarningStopParsing}))();const PI=e=>typeof e==`string`?e:(e??[]).filter(e=>e.type===`text`).map(e=>e.text).join(` `);function FI(e){let t=e.messages.filter(e=>e.role!==`assistant`||![`error`,`aborted`].includes(e.stopReason));return[{role:`system`,content:e.systemPrompt},...t.map(e=>e.role===`toolResult`?{role:`tool`,content:JSON.stringify({name:e.toolName,isError:e.isError,output:PI(e.content)})}:e.role===`assistant`?{role:`assistant`,reasoning_content:e.content.filter(e=>e.type===`thinking`).map(e=>e.thinking).join(` `),content:e.content.map(e=>e.type===`text`?e.text:e.type===`toolCall`?``:``).join(``),tool_calls:e.content.filter(e=>e.type===`toolCall`).map(e=>({type:`function`,function:{name:e.name,arguments:e.arguments}}))}:{role:`user`,content:PI(e.content)})]}function II(e,t){let n=t;for(;n`,n);if(r<0)throw Error(`Incomplete tool call. No command was executed. Try again with a shorter task.`);if(t<0||t>r)return r+11;let i=e.indexOf(`]]>`,t+9);if(i<0)throw Error(`Incomplete CDATA in tool call. No command was executed.`);n=i+3}}function LI(e,t){let n=null,r=0;for(let i=t;i=n.length&&(n=null):n=r,i+=t.length+1;continue}}if(n){i++;continue}if(e[i]==="`"){let t=/^`+/.exec(e.slice(i))[0].length;r?r===t&&(r=0):r=t,i+=t;continue}if(!r&&/^\n?/.exec(e);if(!t&&!n)return{thinking:``,answer:e,complete:!0};let r=n?.[0].length??0,i=e.indexOf(``,r);return i<0?{thinking:e.slice(r),answer:``,complete:!1}:{thinking:e.slice(r,i),answer:e.slice(i+8),complete:!0}}function zI(e,t,n){e=e.replace(/<\|im_end\|>$|<\/s>$/,``);let r=RI(e,n);if(!r.complete)throw Error(`The model used its response budget before finishing its thoughts. Try a smaller task.`);e=r.answer;let i=r.thinking.trim()?[{type:`thinking`,thinking:r.thinking.trim()}]:[],a=0;for(;ao.push(t)}).parseFromString(e.slice(n,r),`application/xml`);if(o.length||s.doctype||s.documentElement.tagName!==`function`)throw Error(`Malformed model tool call.`);let c=s.documentElement,l=c.getAttribute(`name`),u=t.find(e=>e.name===l);if(!u)throw Error(`Unknown model tool: `+l);let d=Object.create(null);for(let e of Array.from(c.childNodes)){if(e.nodeType===3&&!e.textContent.trim())continue;if(e.nodeType!==1||e.tagName!==`param`)throw Error(`Unexpected content in tool call.`);let t=e.getAttribute(`name`);if(Object.hasOwn(d,t)||!Object.hasOwn(u.parameters.properties,t))throw Error(`Unknown or duplicate tool parameter: `+t);if(Array.from(e.childNodes).some(e=>![3,4].includes(e.nodeType)))throw Error(`Tool values containing XML must use CDATA.`);d[t]=u.parameters.properties[t].type===`string`?e.textContent:JSON.parse(e.textContent)}i.push({type:`toolCall`,id:crypto.randomUUID(),name:l,arguments:d}),a=r}return i}function BI(e,t,n){let r=[...e.messages],i=0;for(;;){let a=t(FI({...e,messages:r}));if(a.input_ids.dims[1]<=n)return{inputs:a,dropped:i};let o=r.findIndex((e,t)=>t>0&&e.role===`user`);if(o<0)throw Error(`This task exceeds the browser context budget. Start a new chat or use smaller files and shorter tool output.`);r.splice(0,o),i+=o}}const VI=8192;function HI(e=.95){if(!(e>0&&e<=1))throw Error(`topP must be in (0, 1].`);let t;return(n,r)=>{if(e===1)return r;let i=r.dims.at(-1);t??=new Float32Array(i),t.length!==i&&(t=new Float32Array(i));for(let n=0;n=l?t[u++]=a[e]:d+=Math.exp(a[e]-o);if(d<=c)break;l-=8}while(1);t.subarray(0,u).sort();let f=0;for(;fc)break;d=e,f++}let p=f?t[f-1]:l,m=0;for(let e=f-1;e>=0&&t[e]===p;e--)m++;for(let e=0;e0)&&(a[e]=-1/0)}return r}}var UI=class{constructor(e=1e3,t=250){this.windowMs=e,this.minimumMs=t,this.total=0,this.firstAt=null,this.points=[]}add(e,t){e>0&&(this.firstAt??=t,this.total+=e,this.points.push({at:t,total:this.total}),this.prune(t))}prune(e){let t=e-this.windowMs;for(;this.points.length>1&&this.points[1].at<=t;)this.points.shift()}rate(e){if(this.firstAt===null||e-this.firstAt{let i=await navigator.gpu?.requestAdapter({powerPreference:`high-performance`});if(!i)throw Error(`WebGPU is unavailable. Try an up-to-date browser with GPU acceleration enabled.`);if(!i.features.has(`shader-f16`))throw Error(`This model requires WebGPU shader-f16 support on your device.`);if(c){let e=GPUAdapter.prototype.requestDevice;GPUAdapter.prototype.requestDevice=function(t={}){return e.call(this,{...t,requiredLimits:{...t.requiredLimits,maxStorageBufferBindingSize:128*1024**2,maxBufferSize:256*1024**2}})}}r={vendor:i.info.vendor,architecture:i.info.architecture,maxStorageBufferBindingSize:i.limits.maxStorageBufferBindingSize,features:[...i.features]},e({type:`device`,device:r});let d=o&&[`localhost`,`127.0.0.1`].includes(new URL(s).hostname);jb.allowRemoteModels=!0,jb.allowLocalModels=!1,jb.remoteHost=d?s+`/`:`https://huggingface.co/`,jb.remotePathTemplate=d?`models/{model}/`:`{model}/resolve/${hI}/`;let f=d?`minicpm5-webgpu`:gI;jb.customCache=await xI(jb.remoteHost+jb.remotePathTemplate.replace(`{model}`,f),{signal:u,cachedOnly:l,onProgress:t=>e({type:`load_progress`,...t})}),jb.useCustomCache=!0,jb.useBrowserCache=!1,jb.backends.onnx.wasm.wasmPaths=a,jb.backends.onnx.wasm.numThreads=1,u.throwIfAborted(),e({type:`load_progress`,phase:`compile`}),[n,t]=await Promise.all([WT.from_pretrained(f),iF.from_pretrained(f,{device:`webgpu`,dtype:`q4f16`})]),u.throwIfAborted(),e({type:`load_progress`,phase:`warmup`});let p=n(`Hello`);await t.generate({...p,max_new_tokens:1,do_sample:!1,top_k:0}),u.throwIfAborted();let m=jb.backends.onnx.webgpu.device;r.actualLimits={maxStorageBufferBindingSize:m?.limits.maxStorageBufferBindingSize,maxBufferSize:m?.limits.maxBufferSize},m?.lost.then(t=>{t.reason!==`destroyed`&&e({type:`fatal`,error:`GPU device was lost. Reload this page to reload the cached model.`})}),e({type:`loaded`,device:r,cachedBytes:jb.customCache.cachedBytes})})().catch(async e=>{throw await t?.dispose().catch(()=>{}),t=void 0,n=void 0,u.aborted?new DOMException(`Stopped.`,`AbortError`):e}).finally(()=>{i=void 0}),i)}function s(r,i,o={}){let s=new yl,c={role:`assistant`,api:r.api,provider:r.provider,model:r.id,timestamp:Date.now(),content:[],usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}};return(async()=>{let r=()=>a.interrupt(),l=new UI,u,d=0,f=(t=!1)=>{let n=performance.now();!t&&n-d<80||(d=n,e({type:`context_usage`,inputTokens:c.usage.input,outputTokens:c.usage.output}))};try{if(!t)throw Error(`Load the model first.`);a.reset(),o.signal?.throwIfAborted(),o.signal?.addEventListener(`abort`,r,{once:!0}),e({type:`inference_activity`,phase:`prefill`});let d=Math.min(o.maxTokens??WI,WI),p=i.tools??[],m=p.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.parameters}})),{inputs:h,dropped:g}=BI(i,e=>n.apply_chat_template(e,{tools:m,enable_thinking:!0,add_generation_prompt:!0,return_dict:!0}),VI-d);g&&e({type:`context_trim`,dropped:g}),c.usage.input=h.input_ids.dims[1],c.usage.totalTokens=c.usage.input,f(!0),s.push({type:`start`,partial:structuredClone(c)});let _=``,v=``,y=!1,b=``,x=!1,S=!1,C=0,w=performance.now(),T,E=new qF(n,{skip_prompt:!0,skip_special_tokens:!1,token_callback_function:t=>{if(!t.length)return;let n=performance.now();T??=n-w,l.add(t.length,n),u===void 0&&(e({type:`inference_activity`,phase:`decode`,rate:null,outputTokens:l.total}),u=setInterval(()=>e({type:`inference_activity`,phase:`decode`,rate:l.rate(performance.now()),outputTokens:l.total}),250)),c.usage.output+=t.length,c.usage.totalTokens=c.usage.input+c.usage.output,f()},callback_function:e=>{_+=e;let t=RI(_,{thinkingPrefilled:!0}),n=t.complete?t.thinking:t.thinking.slice(0,Math.max(0,t.thinking.length-8));if(n.length>b.length&&(x||(c.content=[{type:`thinking`,thinking:``}],s.push({type:`thinking_start`,contentIndex:0,partial:structuredClone(c)}),x=!0,C=1),c.content[0].thinking=n,s.push({type:`thinking_delta`,contentIndex:0,delta:n.slice(b.length),partial:structuredClone(c)}),b=n),!t.complete)return;x&&!S&&(s.push({type:`thinking_end`,contentIndex:0,content:b,partial:structuredClone(c)}),S=!0);let r=t.answer.split(`<`)[0];r.length<=v.length||(y||=(c.content.push({type:`text`,text:``}),s.push({type:`text_start`,contentIndex:C,partial:structuredClone(c)}),!0),c.content[C].text=r,s.push({type:`text_delta`,contentIndex:C,delta:r.slice(v.length),partial:structuredClone(c)}),v=r)}}),D=(await t.generate({...h,max_new_tokens:d,do_sample:!0,temperature:1,top_p:.95,top_k:0,repetition_penalty:1,logits_processor:[HI(.95)],eos_token_id:[1,130073],streamer:E,stopping_criteria:a})).tolist()[0].slice(h.input_ids.dims[1]).map(Number);c.usage.output=D.length,c.usage.totalTokens=c.usage.input+D.length,f(!0),o.signal?.throwIfAborted(),_=n.decode(D,{skip_special_tokens:!1});let O=zI(_,p,{thinkingPrefilled:!0});y&&s.push({type:`text_end`,contentIndex:C,content:v,partial:structuredClone(c)}),c.content=O;let k=O.some(e=>e.type===`toolCall`),A=[1,130073].includes(D.at(-1));if(k&&!A)throw Error(`The tool response exceeded the output limit. No tool was executed. Try a smaller edit.`);c.stopReason=k?`toolUse`:A?`stop`:`length`;for(let[e,t]of O.entries())t.type===`toolCall`&&(s.push({type:`toolcall_start`,contentIndex:e,partial:structuredClone(c)}),s.push({type:`toolcall_end`,contentIndex:e,toolCall:t,partial:structuredClone(c)}));e({type:`generation`,raw:_,thinking:!0,sampling:{temperature:1,topP:.95,topK:0,minP:0,repetitionPenalty:1},inputTokens:c.usage.input,outputTokens:D.length,elapsedMs:performance.now()-w,firstTokenMs:T,stopReason:c.stopReason}),s.push({type:`done`,reason:c.stopReason,message:c}),s.end(c)}catch(e){c.usage.input&&f(!0),c.content=c.content.filter(e=>e.type!==`toolCall`),c.stopReason=o.signal?.aborted?`aborted`:`error`,c.errorMessage=o.signal?.aborted?`Stopped.`:String(e.message??e),s.push({type:`error`,reason:c.stopReason,error:c}),s.end(c)}finally{clearInterval(u),e({type:`inference_activity`,phase:`end`}),o.signal?.removeEventListener(`abort`,r)}})(),s}return{load:o,streamFn:s,stop:()=>a.interrupt(),get device(){return r}}}var qI=t((e=>{(function(){var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function n(e){return i(o(e),arguments)}function r(e,t){return n.apply(null,[e].concat(t||[]))}function i(e,r){for(var i=1,a=e.length,o,s=``,c=0,l,u,d,f,p,m,h;c=0),u.type){case`b`:o=parseInt(o,10).toString(2);break;case`c`:o=String.fromCharCode(parseInt(o,10));break;case`d`:case`i`:o=parseInt(o,10);break;case`j`:o=JSON.stringify(o,null,u.width?parseInt(u.width):0);break;case`e`:o=u.precision?parseFloat(o).toExponential(u.precision):parseFloat(o).toExponential();break;case`f`:o=u.precision?parseFloat(o).toFixed(u.precision):parseFloat(o);break;case`g`:o=u.precision?String(Number(o.toPrecision(u.precision))):parseFloat(o);break;case`o`:o=(parseInt(o,10)>>>0).toString(8);break;case`s`:o=String(o),o=u.precision?o.substring(0,u.precision):o;break;case`t`:o=String(!!o),o=u.precision?o.substring(0,u.precision):o;break;case`T`:o=Object.prototype.toString.call(o).slice(8,-1).toLowerCase(),o=u.precision?o.substring(0,u.precision):o;break;case`u`:o=parseInt(o,10)>>>0;break;case`v`:o=o.valueOf(),o=u.precision?o.substring(0,u.precision):o;break;case`x`:o=(parseInt(o,10)>>>0).toString(16);break;case`X`:o=(parseInt(o,10)>>>0).toString(16).toUpperCase()}t.json.test(u.type)?s+=o:(t.number.test(u.type)&&(!m||u.sign)?(h=m?`+`:`-`,o=o.toString().replace(t.sign,``)):h=``,f=u.pad_char?u.pad_char===`0`?`0`:u.pad_char.charAt(1):` `,p=u.width-(h+o).length,d=u.width&&p>0?f.repeat(p):``,s+=u.align?h+o+d:f===`0`?h+d+o:d+h+o)}return s}var a=Object.create(null);function o(e){if(a[e])return a[e];for(var n=e,r,i=[],o=0;n;){if((r=t.text.exec(n))!==null)i.push(r[0]);else if((r=t.modulo.exec(n))!==null)i.push(`%`);else if((r=t.placeholder.exec(n))!==null){if(r[2]){o|=1;var s=[],c=r[2],l=[];if((l=t.key.exec(c))!==null)for(s.push(l[1]);(c=c.substring(l[0].length))!==``;)if((l=t.key_access.exec(c))!==null)s.push(l[1]);else if((l=t.index_access.exec(c))!==null)s.push(l[1]);else throw SyntaxError(`[sprintf] failed to parse named argument key`);else throw SyntaxError(`[sprintf] failed to parse named argument key`);r[2]=s}else o|=2;if(o===3)throw Error(`[sprintf] mixing positional and named placeholders is not (yet) supported`);i.push({placeholder:r[0],param_no:r[1],keys:r[2],sign:r[3],pad_char:r[4],align:r[5],width:r[6],precision:r[7],type:r[8]})}else throw SyntaxError(`[sprintf] unexpected placeholder`);n=n.substring(r[0].length)}return a[e]=i}e!==void 0&&(e.sprintf=n,e.vsprintf=r),typeof window<`u`&&(window.sprintf=n,window.vsprintf=r,typeof define==`function`&&define.amd&&define(function(){return{sprintf:n,vsprintf:r}}))})()}))();const JI=(e,t,n)=>{let r=e instanceof RegExp?YI(e,n):e,i=t instanceof RegExp?YI(t,n):t,a=r!==null&&i!=null&&XI(r,i,n);return a&&{start:a[0],end:a[1],pre:n.slice(0,a[0]),body:n.slice(a[0]+r.length,a[1]),post:n.slice(a[1]+i.length)}},YI=(e,t)=>{let n=t.match(e);return n?n[0]:null},XI=(e,t,n)=>{let r,i,a,o,s,c=n.indexOf(e),l=n.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(r=[],a=n.length;u>=0&&!s;){if(u===c)r.push(u),c=n.indexOf(e,u+1);else if(r.length===1){let e=r.pop();e!==void 0&&(s=[e,l])}else i=r.pop(),i!==void 0&&i=0?c:l}r.length&&o!==void 0&&(s=[a,o])}return s},ZI=`\0SLASH`+Math.random()+`\0`,QI=`\0OPEN`+Math.random()+`\0`,$I=`\0CLOSE`+Math.random()+`\0`,eL=`\0COMMA`+Math.random()+`\0`,tL=`\0PERIOD`+Math.random()+`\0`,nL=new RegExp(ZI,`g`),rL=new RegExp(QI,`g`),iL=new RegExp($I,`g`),aL=new RegExp(eL,`g`),oL=new RegExp(tL,`g`),sL=/\\\\/g,cL=/\\{/g,lL=/\\}/g,uL=/\\,/g,dL=/\\\./g;function fL(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function pL(e){return e.replace(sL,ZI).replace(cL,QI).replace(lL,$I).replace(uL,eL).replace(dL,tL)}function mL(e){return e.replace(nL,`\\`).replace(rL,`{`).replace(iL,`}`).replace(aL,`,`).replace(oL,`.`)}function hL(e){if(!e)return[``];let t=[],n=JI(`{`,`}`,e);if(!n)return e.split(`,`);let{pre:r,body:i,post:a}=n,o=r.split(`,`);o[o.length-1]+=`{`+i+`}`;let s=hL(a);return a.length&&(o[o.length-1]+=s.shift(),o.push.apply(o,s)),t.push.apply(t,o),t}function gL(e,t={}){if(!e)return[];let{max:n=1e5,maxLength:r=4e6}=t;return e.slice(0,2)===`{}`&&(e=`\\{\\}`+e.slice(2)),CL(pL(e),n,r,!0).map(mL)}function _L(e){return`{`+e+`}`}function vL(e){return/^-?0\d/.test(e)}function yL(e,t){return e<=t}function bL(e,t){return e>=t}function xL(e,t,n,r,i,a){let o=[],s=0;for(let c=0;c=r)return o;let u=e[c]+t+n[l];if(!a||u){if(s+u.length>i)return o;o.push(u),s+=u.length}}return o}function SL(e,t,n,r){let i=e.split(/\.\./),a=[];if(i[0]===void 0||i[1]===void 0)return a;let o=fL(i[0]),s=fL(i[1]),c=Math.max(i[0].length,i[1].length),l=i.length===3&&i[2]!==void 0?Math.max(Math.abs(fL(i[2])),1):1,u=yL;s0){let r=Array(t+1).join(`0`);n=e<0?`-`+r+n.slice(1):r+n}}if(f+n.length>r)break;a.push(n),f+=n.length}return a}function CL(e,t,n,r){let i=[``],a=!1,o=!0;for(;;){let s=JI(`{`,`}`,e);if(!s)return xL(i,e,[``],t,n,a);let c=s.pre;if(/\$$/.test(c)){if(i=xL(i,c+`{`+s.body+`}`,[``],t,n,a&&!s.post.length),o=!1,!s.post.length)break;e=s.post;continue}let l=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(s.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(s.body),d=l||u,f=s.body.indexOf(`,`)>=0;if(!d&&!f){if(s.post.match(/,(?!,).*\}/)){e=s.pre+`{`+s.body+$I+s.post,r=!0;continue}return xL(i,c+`{`+s.body+`}`+s.post,[``],t,n,a)}o&&=(a=r&&!d,!1);let p;if(d)p=SL(s.body,u,t,n);else{let r=hL(s.body);if(r.length===1&&r[0]!==void 0&&(r=CL(r[0],t,n,!1).map(_L),r.length===1)){if(i=xL(i,c+r[0],[``],t,n,a&&!s.post.length),!s.post.length)break;e=s.post;continue}let o=a&&!s.post.length&&!c;for(let e=0;o&&e=t||l+r.length>n)break outer;p.push(r),l+=r.length}}}}if(i=xL(i,c,p,t,n,a&&!s.post.length),!s.post.length)break;e=s.post}return i}const wL=e=>{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>65536)throw TypeError(`pattern is too long`)},TL={"[:alnum:]":[`\\p{L}\\p{Nl}\\p{Nd}`,!0],"[:alpha:]":[`\\p{L}\\p{Nl}`,!0],"[:ascii:]":[`\\x00-\\x7f`,!1],"[:blank:]":[`\\p{Zs}\\t`,!0],"[:cntrl:]":[`\\p{Cc}`,!0],"[:digit:]":[`\\p{Nd}`,!0],"[:graph:]":[`\\p{Z}\\p{C}`,!0,!0],"[:lower:]":[`\\p{Ll}`,!0],"[:print:]":[`\\p{C}`,!0],"[:punct:]":[`\\p{P}`,!0],"[:space:]":[`\\p{Z}\\t\\r\\n\\v\\f`,!0],"[:upper:]":[`\\p{Lu}`,!0],"[:word:]":[`\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}`,!0],"[:xdigit:]":[`A-Fa-f0-9`,!1]},EL=e=>e.replace(/[[\]\\-]/g,`\\$&`),DL=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),OL=e=>e.join(``),kL=(e,t)=>{let n=t;if(e.charAt(n)!==`[`)throw Error(`not in a brace expression`);let r=[],i=[],a=n+1,o=!1,s=!1,c=!1,l=!1,u=n,d=``;WHILE:for(;ad?r.push(EL(d)+`-`+EL(t)):t===d&&r.push(EL(t)),d=``,a++;continue}if(e.startsWith(`-]`,a+1)){r.push(EL(t+`-`)),a+=2;continue}if(e.startsWith(`-`,a+1)){d=t,a+=2;continue}r.push(EL(t)),a++}if(un?t?e.replace(/\[([^/\\])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^/\\])\]/g,`$1$2`).replace(/\\([^/])/g,`$1`):t?e.replace(/\[([^/\\{}])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,`$1$2`).replace(/\\([^/{}])/g,`$1`);var jL;const ML=new Set([`!`,`?`,`+`,`*`,`@`]),NL=e=>ML.has(e),PL=e=>NL(e.type),FL=new Map([[`!`,[`@`]],[`?`,[`?`,`@`]],[`@`,[`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`]]]),IL=new Map([[`!`,[`?`]],[`@`,[`?`]],[`+`,[`?`,`*`]]]),LL=new Map([[`!`,[`?`,`@`]],[`?`,[`?`,`@`]],[`@`,[`?`,`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`,`?`,`*`]]]),RL=new Map([[`!`,new Map([[`!`,`@`]])],[`?`,new Map([[`*`,`*`],[`+`,`*`]])],[`@`,new Map([[`!`,`!`],[`?`,`?`],[`@`,`@`],[`*`,`*`],[`+`,`+`]])],[`+`,new Map([[`?`,`*`],[`*`,`*`]])]]),zL=`(?!\\.)`,BL=new Set([`[`,`.`]),VL=new Set([`..`,`.`]),HL=new Set(`().*{}+?[]^$\\!`),UL=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),WL=`[^/]+?`;let GL=0;var KL=class{type;#e;#t;#n=!1;#r=[];#i;#a;#o;#s=!1;#c;#l;#u=!1;id=++GL;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for(`nodejs.util.inspect.custom`)](){return{"@@type":`AST`,id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(e,t,n={}){this.type=e,e&&(this.#t=!0),this.#i=t,this.#e=this.#i?this.#i.#e:this,this.#c=this.#e===this?n:this.#e.#c,this.#o=this.#e===this?[]:this.#e.#o,e===`!`&&!this.#e.#s&&this.#o.push(this),this.#a=this.#i?this.#i.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#r)if(typeof e!=`string`&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#l===void 0?this.#l=this.type?this.type+`(`+this.#r.map(e=>String(e)).join(`|`)+`)`:this.#r.map(e=>String(e)).join(``):this.#l}#d(){if(this!==this.#e)throw Error(`should only call on root`);if(this.#s)return this;this.toString(),this.#s=!0;let e;for(;e=this.#o.pop();){if(e.type!==`!`)continue;let t=e,n=t.#i;for(;n;){for(let r=t.#a+1;!n.type&&rtypeof e==`string`?e:e.toJSON()):[this.type,...this.#r.map(e=>e.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#i?.type===`!`)&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#a===0)return!0;let e=this.#i;for(let t=0;ttypeof e!=`string`),r=this.#r.map(t=>{let[r,i,a,o]=typeof t==`string`?jL.#C(t,this.#t,n):t.toRegExpSource(e);return this.#t=this.#t||a,this.#n=this.#n||o,r}).join(``),i=``;if(this.isStart()&&typeof this.#r[0]==`string`&&!(this.#r.length===1&&VL.has(this.#r[0]))){let n=BL,a=t&&n.has(r.charAt(0))||r.startsWith(`\\.`)&&n.has(r.charAt(2))||r.startsWith(`\\.\\.`)&&n.has(r.charAt(4)),o=!t&&!e&&n.has(r.charAt(0));i=a?`(?!(?:^|/)\\.\\.?(?:$|/))`:o?zL:``}let a=``;return this.isEnd()&&this.#e.#s&&this.#i?.type===`!`&&(a=`(?:$|\\/)`),[i+r+a,AL(r),this.#t=!!this.#t,this.#n]}let n=this.type===`*`||this.type===`+`,r=this.type===`!`?`(?:(?!(?:`:`(?:`,i=this.#S(t);if(this.isStart()&&this.isEnd()&&!i&&this.type!==`!`){let e=this.toString(),t=this;return t.#r=[e],t.type=null,t.#t=void 0,[e,AL(this.toString()),!1,!1]}let a=!n||e||t?``:this.#S(!0);a===i&&(a=``),a&&(i=`(?:${i})(?:${a})*?`);let o=``;if(this.type===`!`&&this.#u)o=(this.isStart()&&!t?zL:``)+WL;else{let n=this.type===`!`?`))`+(this.isStart()&&!t&&!e?zL:``)+`[^/]*?)`:this.type===`@`?`)`:this.type===`?`?`)?`:this.type===`+`&&a?`)`:this.type===`*`&&a?`)?`:`)${this.type}`;o=r+i+n}return[o,AL(i),this.#t=!!this.#t,this.#n]}#x(){if(PL(this)){let e=0,t=!1;do{t=!0;for(let e=0;e{if(typeof t==`string`)throw Error(`string type in extglob ast??`);let[n,r,i,a]=t.toRegExpSource(e);return this.#n=this.#n||a,n}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join(`|`)}static#C(e,t,n=!1){let r=!1,i=``,a=!1,o=!1;for(let s=0;sn?t?e.replace(/[?*()[\]{}]/g,`[$&]`):e.replace(/[?*()[\]\\{}]/g,`\\$&`):t?e.replace(/[?*()[\]]/g,`[$&]`):e.replace(/[?*()[\]\\]/g,`\\$&`),JL=(e,t,n={})=>(wL(t),!n.nocomment&&t.charAt(0)===`#`?!1:new SR(t,n).match(e)),YL=/^\*+([^+@!?*[(]*)$/,XL=e=>t=>!t.startsWith(`.`)&&t.endsWith(e),ZL=e=>t=>t.endsWith(e),QL=e=>(e=e.toLowerCase(),t=>!t.startsWith(`.`)&&t.toLowerCase().endsWith(e)),$L=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),eR=/^\*+\.\*+$/,tR=e=>!e.startsWith(`.`)&&e.includes(`.`),nR=e=>e!==`.`&&e!==`..`&&e.includes(`.`),rR=/^\.\*+$/,iR=e=>e!==`.`&&e!==`..`&&e.startsWith(`.`),aR=/^\*+$/,oR=e=>e.length!==0&&!e.startsWith(`.`),sR=e=>e.length!==0&&e!==`.`&&e!==`..`,cR=/^\?+([^+@!?*[(]*)?$/,lR=([e,t=``])=>{let n=pR([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},uR=([e,t=``])=>{let n=mR([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},dR=([e,t=``])=>{let n=mR([e]);return t?e=>n(e)&&e.endsWith(t):n},fR=([e,t=``])=>{let n=pR([e]);return t?e=>n(e)&&e.endsWith(t):n},pR=([e])=>{let t=e.length;return e=>e.length===t&&!e.startsWith(`.`)},mR=([e])=>{let t=e.length;return e=>e.length===t&&e!==`.`&&e!==`..`},hR=typeof process==`object`&&process?{}.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,gR={win32:{sep:`\\`},posix:{sep:`/`}};JL.sep=hR===`win32`?gR.win32.sep:gR.posix.sep;const _R=Symbol(`globstar **`);JL.GLOBSTAR=_R,JL.filter=(e,t={})=>n=>JL(n,e,t);const vR=(e,t={})=>Object.assign({},e,t);JL.defaults=e=>{if(!e||typeof e!=`object`||!Object.keys(e).length)return JL;let t=JL;return Object.assign((n,r,i={})=>t(n,r,vR(e,i)),{Minimatch:class extends t.Minimatch{constructor(t,n={}){super(t,vR(e,n))}static defaults(n){return t.defaults(vR(e,n)).Minimatch}},AST:class extends t.AST{constructor(t,n,r={}){super(t,n,vR(e,r))}static fromGlob(n,r={}){return t.AST.fromGlob(n,vR(e,r))}},unescape:(n,r={})=>t.unescape(n,vR(e,r)),escape:(n,r={})=>t.escape(n,vR(e,r)),filter:(n,r={})=>t.filter(n,vR(e,r)),defaults:n=>t.defaults(vR(e,n)),makeRe:(n,r={})=>t.makeRe(n,vR(e,r)),braceExpand:(n,r={})=>t.braceExpand(n,vR(e,r)),match:(n,r,i={})=>t.match(n,r,vR(e,i)),sep:t.sep,GLOBSTAR:_R})};const yR=(e,t={})=>(wL(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:gL(e,{max:t.braceExpandMax}));JL.braceExpand=yR,JL.makeRe=(e,t={})=>new SR(e,t).makeRe(),JL.match=(e,t,n={})=>{let r=new SR(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};const bR=/[?*]|[+@!]\(.*?\)|\[|\]/,xR=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`);var SR=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){wL(e),t||={},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||hR,this.isWindows=this.platform===`win32`,this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,`/`)),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot===void 0?!!(this.isWindows&&this.nocase):t.windowsNoMagicRoot,this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!=`string`)return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)===`#`){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...e)=>console.error(...e)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(e=>this.slashSplit(e));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((e,t,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let t=e[0]===``&&e[1]===``&&(e[2]===`?`||!bR.test(e[2]))&&!bR.test(e[3]),n=/^[a-z]:/i.test(e[0]);if(t)return[...e.slice(0,4),...e.slice(4).map(e=>this.parse(e))];if(n)return[e[0],...e.slice(1).map(e=>this.parse(e))]}return e.map(e=>this.parse(e))});if(this.debug(this.pattern,r),this.set=r.filter(e=>e.indexOf(!1)===-1),this.isWindows)for(let e=0;e=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):e=t>=1?this.levelOneOptimize(e):this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(e=>{let t=-1;for(;(t=e.indexOf(`**`,t+1))!==-1;){let n=t;for(;e[n+1]===`**`;)n++;n!==t&&e.splice(t,n-t)}return e})}levelOneOptimize(e){return e.map(e=>(e=e.reduce((e,t)=>{let n=e[e.length-1];return t===`**`&&n===`**`?e:t===`..`&&n&&n!==`..`&&n!==`.`&&n!==`**`?(e.pop(),e):(e.push(t),e)},[]),e.length===0?[``]:e))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let n=1;nr&&n.splice(r+1,i-r);let a=n[r+1],o=n[r+2],s=n[r+3];if(a!==`..`||!o||o===`.`||o===`..`||!s||s===`.`||s===`..`)continue;t=!0,n.splice(r,1);let c=n.slice(0);c[r]=`**`,e.push(c),r--}if(!this.preserveMultipleSlashes){for(let e=1;ee.length)}partsMatch(e,t,n=!1){let r=0,i=0,a=[],o=``;for(;r=2&&(e=this.levelTwoFileOptimize(e)),t.includes(_R)?this.#e(e,t,n,r,i):this.#n(e,t,n,r,i)}#e(e,t,n,r,i){let a=t.indexOf(_R,i),o=t.lastIndexOf(_R),[s,c,l]=n?[t.slice(i,a),t.slice(a+1),[]]:[t.slice(i,a),t.slice(a+1,o),t.slice(o+1)];if(s.length){let t=e.slice(r,r+s.length);if(!this.#n(t,s,n,0,0))return!1;r+=s.length,i+=s.length}let u=0;if(l.length){if(l.length+r>e.length)return!1;let t=e.length-l.length;if(this.#n(e,l,n,t,0))u=l.length;else{if(e[e.length-1]!==``||r+l.length===e.length||(t--,!this.#n(e,l,n,t,0)))return!1;u=l.length+1}}if(!c.length){let t=!!u;for(let n=r;n{let t=e.map(e=>{if(e instanceof RegExp)for(let t of e.flags.split(``))r.add(t);return typeof e==`string`?xR(e):e===_R?_R:e._src});t.forEach((e,r)=>{let i=t[r+1],a=t[r-1];e===_R&&a!==_R&&(a===void 0?i!==void 0&&i!==_R?t[r+1]=`(?:\\/|`+n+`\\/)?`+i:t[r]=n:i===void 0?t[r-1]=a+`(?:\\/|\\/`+n+`)?`:i!==_R&&(t[r-1]=a+`(?:\\/|\\/`+n+`\\/)`+i,t[r+1]=_R))});let i=t.filter(e=>e!==_R);if(this.partial&&i.length>=1){let e=[];for(let t=1;t<=i.length;t++)e.push(i.slice(0,t).join(`/`));return`(?:`+e.join(`|`)+`)`}return i.join(`/`)}).join(`|`),[a,o]=e.length>1?[`(?:`,`)`]:[``,``];i=`^`+a+i+o+`$`,this.partial&&(i=`^(?:\\/|`+a+i.slice(1,-1)+o+`)$`),this.negate&&(i=`^(?!`+i+`).+$`);try{this.regexp=new RegExp(i,[...r].join(``))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split(`/`):this.isWindows&&/^\/\/[^/]+/.test(e)?[``,...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug(`match`,e,this.pattern),this.comment)return!1;if(this.empty)return e===``;if(e===`/`&&t)return!0;let n=this.options;this.isWindows&&(e=e.split(`\\`).join(`/`));let r=this.slashSplit(e);this.debug(this.pattern,`split`,r);let i=this.set;this.debug(this.pattern,`set`,i);let a=r[r.length-1];if(!a)for(let e=r.length-2;!a&&e>=0;e--)a=r[e];for(let e of i){let i=r;if(n.matchBase&&e.length===1&&(i=[a]),this.matchOne(i,e,t))return n.flipNegate?!0:!this.negate}return!n.flipNegate&&this.negate}static defaults(e){return JL.defaults(e).Minimatch}};JL.AST=KL,JL.Minimatch=SR,JL.escape=qL,JL.unescape=AL;var CR=t(((e,t)=>{t.exports={}}))();function wR(e){for(var t=1;t0&&e[t-1]===` `;)t--;return e.substring(0,t)}function OR(e){return DR(ER(e))}var kR=`ADDRESS.ARTICLE.ASIDE.AUDIO.BLOCKQUOTE.BODY.CANVAS.CENTER.DD.DIR.DIV.DL.DT.FIELDSET.FIGCAPTION.FIGURE.FOOTER.FORM.FRAMESET.H1.H2.H3.H4.H5.H6.HEADER.HGROUP.HR.HTML.ISINDEX.LI.MAIN.MENU.NAV.NOFRAMES.NOSCRIPT.OL.OUTPUT.P.PRE.SECTION.TABLE.TBODY.TD.TFOOT.TH.THEAD.TR.UL`.split(`.`);function AR(e){return LR(e,kR)}var jR=[`AREA`,`BASE`,`BR`,`COL`,`COMMAND`,`EMBED`,`HR`,`IMG`,`INPUT`,`KEYGEN`,`LINK`,`META`,`PARAM`,`SOURCE`,`TRACK`,`WBR`];function MR(e){return LR(e,jR)}function NR(e){return RR(e,jR)}var PR=[`A`,`TABLE`,`THEAD`,`TBODY`,`TFOOT`,`TH`,`TD`,`IFRAME`,`SCRIPT`,`AUDIO`,`VIDEO`];function FR(e){return LR(e,PR)}function IR(e){return RR(e,PR)}function LR(e,t){return t.indexOf(e.nodeName)>=0}function RR(e,t){return e.getElementsByTagName&&t.some(function(t){return e.getElementsByTagName(t).length})}var zR=[[/\\/g,`\\\\`],[/\*/g,`\\*`],[/^-/g,`\\-`],[/^\+ /g,`\\+ `],[/^(=+)/g,`\\$1`],[/^(#{1,6}) /g,`\\$1 `],[/`/g,"\\`"],[/^~~~/g,`\\~~~`],[/\[/g,`\\[`],[/\]/g,`\\]`],[/^>/g,`\\>`],[/_/g,`\\_`],[/^(\d+)\. /g,`$1\\. `]];function BR(e){return zR.reduce(function(e,t){return e.replace(t[0],t[1])},e)}var VR={};VR.paragraph={filter:`p`,replacement:function(e){return` `+e+` `}},VR.lineBreak={filter:`br`,replacement:function(e,t,n){return n.br+` `}},VR.heading={filter:[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`],replacement:function(e,t,n){var r=Number(t.nodeName.charAt(1));if(n.headingStyle===`setext`&&r<3){var i=TR(r===1?`=`:`-`,e.length);return` `+e+` `+i+` `}return` `+TR(`#`,r)+` `+e+` `}},VR.blockquote={filter:`blockquote`,replacement:function(e){return e=OR(e).replace(/^/gm,`> `),` `+e+` `}},VR.list={filter:[`ul`,`ol`],replacement:function(e,t){var n=t.parentNode;return n.nodeName===`LI`&&n.lastElementChild===t?` `+e:` `+e+` `}},VR.listItem={filter:`li`,replacement:function(e,t,n){var r=n.bulletListMarker+` `,i=t.parentNode;if(i.nodeName===`OL`){var a=i.getAttribute(`start`),o=Array.prototype.indexOf.call(i.children,t);r=(a?Number(a)+o:o+1)+`. `}var s=/\n$/.test(e);return e=OR(e)+(s?` `:``),e=e.replace(/\n/gm,` `+` `.repeat(r.length)),r+e+(t.nextSibling?` `:``)}},VR.indentedCodeBlock={filter:function(e,t){return t.codeBlockStyle===`indented`&&e.nodeName===`PRE`&&e.firstChild&&e.firstChild.nodeName===`CODE`},replacement:function(e,t,n){return` `+t.firstChild.textContent.replace(/\n/g,` `)+` `}},VR.fencedCodeBlock={filter:function(e,t){return t.codeBlockStyle===`fenced`&&e.nodeName===`PRE`&&e.firstChild&&e.firstChild.nodeName===`CODE`},replacement:function(e,t,n){for(var r=((t.firstChild.getAttribute(`class`)||``).match(/language-(\S+)/)||[null,``])[1],i=t.firstChild.textContent,a=n.fence.charAt(0),o=3,s=RegExp(`^`+a+`{3,}`,`gm`),c;c=s.exec(i);)c[0].length>=o&&(o=c[0].length+1);var l=TR(a,o);return` `+l+r+` `+i.replace(/\n$/,``)+` `+l+` `}},VR.horizontalRule={filter:`hr`,replacement:function(e,t,n){return` `+n.hr+` `}},VR.inlineLink={filter:function(e,t){return t.linkStyle===`inlined`&&e.nodeName===`A`&&e.getAttribute(`href`)},replacement:function(e,t){var n=UR(t.getAttribute(`href`)),r=WR(HR(t.getAttribute(`title`))),i=r?` "`+r+`"`:``;return`[`+e+`](`+n+i+`)`}},VR.referenceLink={filter:function(e,t){return t.linkStyle===`referenced`&&e.nodeName===`A`&&e.getAttribute(`href`)},replacement:function(e,t,n){var r=UR(t.getAttribute(`href`)),i=HR(t.getAttribute(`title`));i&&=` "`+WR(i)+`"`;var a,o;switch(n.linkReferenceStyle){case`collapsed`:a=`[`+e+`][]`,o=`[`+e+`]: `+r+i;break;case`shortcut`:a=`[`+e+`]`,o=`[`+e+`]: `+r+i;break;default:var s=this.references.length+1;a=`[`+e+`][`+s+`]`,o=`[`+s+`]: `+r+i}return this.references.push(o),a},references:[],append:function(e){var t=``;return this.references.length&&(t=` `+this.references.join(` `)+` `,this.references=[]),t}},VR.emphasis={filter:[`em`,`i`],replacement:function(e,t,n){return e.trim()?n.emDelimiter+e+n.emDelimiter:``}},VR.strong={filter:[`strong`,`b`],replacement:function(e,t,n){return e.trim()?n.strongDelimiter+e+n.strongDelimiter:``}},VR.code={filter:function(e){var t=e.previousSibling||e.nextSibling,n=e.parentNode.nodeName===`PRE`&&!t;return e.nodeName===`CODE`&&!n},replacement:function(e){if(!e)return``;e=e.replace(/\r?\n|\r/g,` `);for(var t=/^`|^ .*?[^ ].* $|`$/.test(e)?` `:``,n="`",r=e.match(/`+/gm)||[];r.indexOf(n)!==-1;)n+="`";return n+t+e+t+n}},VR.image={filter:`img`,replacement:function(e,t){var n=BR(HR(t.getAttribute(`alt`))),r=UR(t.getAttribute(`src`)||``),i=HR(t.getAttribute(`title`)),a=i?` "`+WR(i)+`"`:``;return r?`![`+n+`](`+r+a+`)`:``}};function HR(e){return e?e.replace(/(\n+\s*)+/g,` `):``}function UR(e){var t=e.replace(/([<>()])/g,`\\$1`);return t.indexOf(` `)>=0?`<`+t+`>`:t}function WR(e){return e.replace(/"/g,`\\"`)}function GR(e){for(var t in this.options=e,this._keep=[],this._remove=[],this.blankRule={replacement:e.blankReplacement},this.keepReplacement=e.keepReplacement,this.defaultRule={replacement:e.defaultReplacement},this.array=[],e.rules)this.array.push(e.rules[t])}GR.prototype={add:function(e,t){this.array.unshift(t)},keep:function(e){this._keep.unshift({filter:e,replacement:this.keepReplacement})},remove:function(e){this._remove.unshift({filter:e,replacement:function(){return``}})},forNode:function(e){if(e.isBlank)return this.blankRule;var t;return(t=KR(this.array,e,this.options))||(t=KR(this._keep,e,this.options))||(t=KR(this._remove,e,this.options))?t:this.defaultRule},forEach:function(e){for(var t=0;t-1)return!0}else if(typeof r==`function`){if(r.call(e,t,n))return!0}else throw TypeError("`filter` needs to be a string, array, or function")}function JR(e){var t=e.element,n=e.isBlock,r=e.isVoid,i=e.isPre||function(e){return e.nodeName===`PRE`};if(t.firstChild&&!i(t)){for(var a=null,o=!1,s=null,c=XR(s,t,i);c!==t;){if(c.nodeType===3||c.nodeType===4){var l=c.data.replace(/[ \r\n\t]+/g,` `);if((!a||/ $/.test(a.data))&&!o&&l[0]===` `&&(l=l.substr(1)),!l){c=YR(c);continue}c.data=l,a=c}else if(c.nodeType===1)n(c)||c.nodeName===`BR`?(a&&(a.data=a.data.replace(/ $/,``)),a=null,o=!1):r(c)||i(c)?(a=null,o=!0):a&&(o=!1);else{c=YR(c);continue}var u=XR(s,c,i);s=c,c=u}a&&(a.data=a.data.replace(/ $/,``),a.data||YR(a))}}function YR(e){var t=e.nextSibling||e.parentNode;return e.parentNode.removeChild(e),t}function XR(e,t,n){return e&&e.parentNode===t||n(t)?t.nextSibling||t.parentNode:t.firstChild||t.nextSibling||t.parentNode}var ZR=typeof window<`u`?window:{};function QR(){var e=ZR.DOMParser,t=!1;try{new e().parseFromString(``,`text/html`)&&(t=!0)}catch{}return t}function $R(){var e=function(){};return ez()?e.prototype.parseFromString=function(e){var t=new window.ActiveXObject(`htmlfile`);return t.designMode=`on`,t.open(),t.write(e),t.close(),t}:e.prototype.parseFromString=function(e){var t=document.implementation.createHTMLDocument(``);return t.open(),t.write(e),t.close(),t},e}function ez(){var e=!1;try{document.implementation.createHTMLDocument(``).open()}catch{ZR.ActiveXObject&&(e=!0)}return e}var tz=QR()?ZR.DOMParser:$R();function nz(e,t){var n=typeof e==`string`?iz().parseFromString(``+e+``,`text/html`).getElementById(`turndown-root`):e.cloneNode(!0);return JR({element:n,isBlock:AR,isVoid:MR,isPre:t.preformattedCode?az:null}),n}var rz;function iz(){return rz||=new tz,rz}function az(e){return e.nodeName===`PRE`||e.nodeName===`CODE`}function oz(e,t){return e.isBlock=AR(e),e.isCode=e.nodeName===`CODE`||e.parentNode.isCode,e.isBlank=sz(e),e.flankingWhitespace=cz(e,t),e}function sz(e){return!MR(e)&&!FR(e)&&/^\s*$/i.test(e.textContent)&&!NR(e)&&!IR(e)}function cz(e,t){if(e.isBlock||t.preformattedCode&&e.isCode)return{leading:``,trailing:``};var n=lz(e.textContent);return n.leadingAscii&&uz(`left`,e,t)&&(n.leading=n.leadingNonAscii),n.trailingAscii&&uz(`right`,e,t)&&(n.trailing=n.trailingNonAscii),{leading:n.leading,trailing:n.trailing}}function lz(e){var t=e.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);return{leading:t[1],leadingAscii:t[2],leadingNonAscii:t[3],trailing:t[4],trailingNonAscii:t[5],trailingAscii:t[6]}}function uz(e,t,n){var r,i,a;return e===`left`?(r=t.previousSibling,i=/ $/):(r=t.nextSibling,i=/^ /),r&&(r.nodeType===3?a=i.test(r.nodeValue):n.preformattedCode&&r.nodeName===`CODE`?a=!1:r.nodeType===1&&!AR(r)&&(a=i.test(r.textContent))),a}var dz=Array.prototype.reduce;function fz(e){if(!(this instanceof fz))return new fz(e);var t={rules:VR,headingStyle:`setext`,hr:`* * *`,bulletListMarker:`*`,codeBlockStyle:`indented`,fence:"```",emDelimiter:`_`,strongDelimiter:`**`,linkStyle:`inlined`,linkReferenceStyle:`full`,br:` `,preformattedCode:!1,blankReplacement:function(e,t){return t.isBlock?` `:``},keepReplacement:function(e,t){return t.isBlock?` `+t.outerHTML+` `:t.outerHTML},defaultReplacement:function(e,t){return t.isBlock?` `+e+` `:e}};this.options=wR({},t,e),this.rules=new GR(this.options)}fz.prototype={turndown:function(e){if(!_z(e))throw TypeError(e+` is not a string, or an element/document/fragment node.`);if(e===``)return``;var t=pz.call(this,new nz(e,this.options));return mz.call(this,t)},use:function(e){if(Array.isArray(e))for(var t=0;t()=>(e&&(t=e(e=0)),t),wz=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Tz=(e,t)=>{for(var n in t)yz(e,n,{get:t[n],enumerable:!0})},Ez=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of xz(t))!Cz.call(e,i)&&i!==n&&yz(e,i,{get:()=>t[i],enumerable:!(r=bz(t,i))||r.enumerable});return e},Dz=(e,t,n)=>(n=e==null?{}:vz(Sz(e)),Ez(t||!e||!e.__esModule?yz(n,`default`,{value:e,enumerable:!0}):n,e)),Oz={};Tz(Oz,{AsyncLocalStorage:()=>Az,Module:()=>jz,lookup:()=>kz});function kz(){throw Error(`node:dns is not available in browser environments`)}var Az,jz,Mz=B(()=>{Az=void 0,jz=void 0});function Nz(){return Fz||Pz(),Fz}function Pz(){let e=[{prop:`Function`,target:globalThis,violationType:`function_constructor`,strategy:`throw`,reason:`Function constructor allows arbitrary code execution`},{prop:`eval`,target:globalThis,violationType:`eval`,strategy:`throw`,reason:`eval() allows arbitrary code execution`},{prop:`setTimeout`,target:globalThis,violationType:`setTimeout`,strategy:`throw`,reason:`setTimeout with string argument allows code execution`},{prop:`setInterval`,target:globalThis,violationType:`setInterval`,strategy:`throw`,reason:`setInterval with string argument allows code execution`},{prop:`setImmediate`,target:globalThis,violationType:`setImmediate`,strategy:`throw`,reason:`setImmediate could be used to escape sandbox context`},{prop:`env`,target:process,violationType:`process_env`,strategy:`throw`,reason:`process.env could leak sensitive environment variables`,allowedKeys:new Set([`NODE_V8_COVERAGE`,`NODE_DEBUG`,`NODE_DEBUG_NATIVE`,`NODE_COMPILE_CACHE`,`NODE_ENV`,`WATCH_REPORT_DEPENDENCIES`,`FORCE_COLOR`,`DEBUG`,`UNDICI_NO_FG`,`JEST_WORKER_ID`,`__MINIMATCH_TESTING_PLATFORM__`,`LOG_TOKENS`,`LOG_STREAM`])},{prop:`binding`,target:process,violationType:`process_binding`,strategy:`throw`,reason:`process.binding provides access to native Node.js modules`},{prop:`_linkedBinding`,target:process,violationType:`process_binding`,strategy:`throw`,reason:`process._linkedBinding provides access to native Node.js modules`},{prop:`dlopen`,target:process,violationType:`process_dlopen`,strategy:`throw`,reason:`process.dlopen allows loading native addons`},{prop:`getBuiltinModule`,target:process,violationType:`process_get_builtin_module`,strategy:`throw`,reason:`process.getBuiltinModule allows loading native Node.js modules (fs, child_process, vm)`},{prop:`exit`,target:process,violationType:`process_exit`,strategy:`throw`,reason:`process.exit could terminate the interpreter`},{prop:`abort`,target:process,violationType:`process_exit`,strategy:`throw`,reason:`process.abort could crash the interpreter`},{prop:`kill`,target:process,violationType:`process_kill`,strategy:`throw`,reason:`process.kill could signal other processes`},{prop:`setuid`,target:process,violationType:`process_setuid`,strategy:`throw`,reason:`process.setuid could escalate privileges`},{prop:`setgid`,target:process,violationType:`process_setuid`,strategy:`throw`,reason:`process.setgid could escalate privileges`},{prop:`seteuid`,target:process,violationType:`process_setuid`,strategy:`throw`,reason:`process.seteuid could escalate effective user privileges`},{prop:`setegid`,target:process,violationType:`process_setuid`,strategy:`throw`,reason:`process.setegid could escalate effective group privileges`},{prop:`initgroups`,target:process,violationType:`process_setuid`,strategy:`throw`,reason:`process.initgroups could modify supplementary group IDs`},{prop:`setgroups`,target:process,violationType:`process_setuid`,strategy:`throw`,reason:`process.setgroups could modify supplementary group IDs`},{prop:`umask`,target:process,violationType:`process_umask`,strategy:`throw`,reason:`process.umask could modify file creation permissions`},{prop:`argv`,target:process,violationType:`process_argv`,strategy:`throw`,reason:`process.argv may contain secrets in CLI arguments`},{prop:`cwd`,target:process,violationType:`process_chdir`,strategy:`throw`,reason:`process.cwd could disclose real host working directory path`},{prop:`chdir`,target:process,violationType:`process_chdir`,strategy:`throw`,reason:`process.chdir could confuse the interpreter's CWD tracking`},{prop:`report`,target:process,violationType:`process_report`,strategy:`throw`,reason:`process.report could disclose full environment, host paths, and system info`},{prop:`loadEnvFile`,target:process,violationType:`process_env`,strategy:`throw`,reason:`process.loadEnvFile could load env files bypassing env proxy`},{prop:`setUncaughtExceptionCaptureCallback`,target:process,violationType:`process_exception_handler`,strategy:`throw`,reason:`setUncaughtExceptionCaptureCallback could intercept security errors`},...[`on`,`once`,`addListener`,`prependListener`,`prependOnceListener`].map(e=>({prop:e,target:process,violationType:`process_exception_handler`,strategy:`throw`,reason:`process-global listeners can outlive the sandbox and lose its security context`})),{prop:`send`,target:process,violationType:`process_send`,strategy:`throw`,reason:`process.send could communicate with parent process in IPC contexts`},{prop:`channel`,target:process,violationType:`process_channel`,strategy:`throw`,reason:`process.channel could access IPC channel to parent process`},{prop:`cpuUsage`,target:process,violationType:`process_timing`,strategy:`throw`,reason:`process.cpuUsage could enable timing side-channel attacks`},{prop:`memoryUsage`,target:process,violationType:`process_timing`,strategy:`throw`,reason:`process.memoryUsage could enable timing side-channel attacks`},{prop:`hrtime`,target:process,violationType:`process_timing`,strategy:`throw`,reason:`process.hrtime could enable timing side-channel attacks`},{prop:`WeakRef`,target:globalThis,violationType:`weak_ref`,strategy:`throw`,reason:`WeakRef could be used to leak references outside sandbox`},{prop:`FinalizationRegistry`,target:globalThis,violationType:`finalization_registry`,strategy:`throw`,reason:`FinalizationRegistry could be used to leak references outside sandbox`},{prop:`Reflect`,target:globalThis,violationType:`reflect`,strategy:`freeze`,reason:`Reflect provides introspection capabilities`},{prop:`Proxy`,target:globalThis,violationType:`proxy`,strategy:`throw`,reason:`Proxy allows intercepting and modifying object behavior`},{prop:`WebAssembly`,target:globalThis,violationType:`webassembly`,strategy:`throw`,reason:`WebAssembly allows executing arbitrary compiled code`},{prop:`SharedArrayBuffer`,target:globalThis,violationType:`shared_array_buffer`,strategy:`throw`,reason:`SharedArrayBuffer could enable side-channel communication or timing attacks`},{prop:`Atomics`,target:globalThis,violationType:`atomics`,strategy:`throw`,reason:`Atomics could enable side-channel communication or timing attacks`},{prop:`performance`,target:globalThis,violationType:`performance_timing`,strategy:`throw`,reason:`performance.now() provides sub-millisecond timing for side-channel attacks`},{prop:`stdout`,target:process,violationType:`process_stdout`,strategy:`throw`,reason:`process.stdout could bypass interpreter output to write to host stdout`},{prop:`stderr`,target:process,violationType:`process_stderr`,strategy:`throw`,reason:`process.stderr could bypass interpreter output to write to host stderr`},{prop:`__defineGetter__`,target:Object.prototype,violationType:`prototype_mutation`,strategy:`throw`,reason:`__defineGetter__ allows prototype pollution via getter injection`},{prop:`__defineSetter__`,target:Object.prototype,violationType:`prototype_mutation`,strategy:`throw`,reason:`__defineSetter__ allows prototype pollution via setter injection`},{prop:`__lookupGetter__`,target:Object.prototype,violationType:`prototype_mutation`,strategy:`throw`,reason:`__lookupGetter__ enables introspection for prototype pollution attacks`},{prop:`__lookupSetter__`,target:Object.prototype,violationType:`prototype_mutation`,strategy:`throw`,reason:`__lookupSetter__ enables introspection for prototype pollution attacks`},{prop:`JSON`,target:globalThis,violationType:`json_mutation`,strategy:`freeze`,reason:`Freeze JSON to prevent mutation of parsing/serialization`},{prop:`Math`,target:globalThis,violationType:`math_mutation`,strategy:`freeze`,reason:`Freeze Math to prevent mutation of math utilities`}];try{let t=Object.getPrototypeOf(async()=>{}).constructor;t&&t!==Function&&e.push({prop:`constructor`,target:Object.getPrototypeOf(async()=>{}),violationType:`async_function_constructor`,strategy:`throw`,reason:`AsyncFunction constructor allows arbitrary async code execution`})}catch{}try{let t=Object.getPrototypeOf(function*(){}).constructor;t&&t!==Function&&e.push({prop:`constructor`,target:Object.getPrototypeOf(function*(){}),violationType:`generator_function_constructor`,strategy:`throw`,reason:`GeneratorFunction constructor allows arbitrary generator code execution`})}catch{}try{let t=Object.getPrototypeOf(async function*(){}).constructor;t&&t!==Function&&t!==Object.getPrototypeOf(async()=>{}).constructor&&e.push({prop:`constructor`,target:Object.getPrototypeOf(async function*(){}),violationType:`async_generator_function_constructor`,strategy:`throw`,reason:`AsyncGeneratorFunction constructor allows arbitrary async generator code execution`})}catch{}let t=e.filter(e=>{try{return e.target[e.prop]!==void 0}catch{return!1}});return Fz??=new Set(t.map(({violationType:e})=>e)),t}var Fz,Iz=B(()=>{});function Lz(){return Math.floor(Rz+zz())}var Rz,zz,Bz=B(()=>{Rz=performance.timeOrigin,zz=performance.now.bind(performance)});function Vz(e){let t=e?.find(e=>Uz.has(e));if(t)throw RangeError(`defenseInDepth.excludeViolationTypes cannot disable the non-excludable "${t}" protection`)}function Hz(e,t,n){let r=n&&!Uz.has(t)?` If this access is required by trusted host-runtime code, add "${t}" to defenseInDepth.excludeViolationTypes.`:``;return e+Wz+r}var Uz,Wz,Gz=B(()=>{Uz=new Set([`function_constructor`,`async_function_constructor`,`generator_function_constructor`,`async_generator_function_constructor`]),Wz=` This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`});function Kz(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function qz(e,t,...n){return nB.run(e,()=>t(...n))}function Jz(){return!Zz&&typeof $z?.registerHooks==`function`}function Yz(e){let t=typeof e==`boolean`?{enabled:e}:e??{};if(Vz(t.excludeViolationTypes),t.enabled!==void 0&&t.enabled!==!0&&t.enabled!==!1&&t.enabled!==`auto`)throw RangeError(`defenseInDepth.enabled must be true, false, or "auto"`);let n={...iB,...t},r=n.enabled===`auto`?`auto`:n.enabled?`enabled`:`disabled`,i={...n,enabled:r!==`disabled`,requested:r};return i.excludeViolationTypes&&=[...new Set(i.excludeViolationTypes)].sort(),i}function Xz(e,t){if(e.enabled!==t.enabled||e.auditMode!==t.auditMode||e.processLifetimeIntrinsicHardening!==t.processLifetimeIntrinsicHardening||e.onViolation!==t.onViolation)return!1;let n=e.excludeViolationTypes??[],r=t.excludeViolationTypes??[];return n.length===r.length&&n.every((e,t)=>e===r[t])}var Zz,Qz,$z,eB,tB,nB,rB,iB,aB,oB=B(()=>{if(Mz(),Mz(),Iz(),Bz(),Gz(),Zz=!0,Qz=null,$z=null,eB=null,!Zz)try{Qz=void 0,$z=Oz,eB=$z.Module??$z.default??null}catch{}tB=class extends Error{violation;constructor(e,t){super(Hz(e,t.type,t.type===`error_prepare_stack_trace`||Nz().has(t.type))),this.violation=t,this.name=`SecurityViolationError`}},nB=!Zz&&Qz?new Qz:null,rB=1e3,iB={enabled:!0,auditMode:!1,processLifetimeIntrinsicHardening:!1},aB=class e{static instance=null;static importHooksRegistered=!1;static trustedExecutionDepth=new Map;config;refCount=0;patchFailures=[];activeExecutionIds=new Set;contextCache=new Map;originalDescriptors=[];temporaryIntrinsicDescriptors=[];violations=[];activationTime=0;totalActiveTimeMs=0;constructor(e){this.config=e}static getInstance(t){let n=Yz(t);if(!e.instance)e.instance=new e(n);else{let t=e.instance.config;if(!Xz(n,t))throw Error(`DefenseInDepthBox config conflict: all resolved defense options, including exclusions and the violation callback, must match across Bash instances. Call DefenseInDepthBox.resetInstance() between incompatible configurations.`)}return e.instance}static resetInstance(){e.instance&&=(e.instance.forceDeactivate(),null),e.trustedExecutionDepth.clear()}static isInSandboxedContext(){return nB?nB?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(nB)return nB?.getStore()?.executionId}static enterTrustedScope(t){let n=e.trustedExecutionDepth.get(t)??0;e.trustedExecutionDepth.set(t,n+1)}static leaveTrustedScope(t){let n=e.trustedExecutionDepth.get(t);if(n){if(n===1){e.trustedExecutionDepth.delete(t);return}e.trustedExecutionDepth.set(t,n-1)}}static isTrustedScopeActive(t){return t?(e.trustedExecutionDepth.get(t)??0)>0:!1}static isTrustedContext(t){return!t||t.forceUntrusted?!1:t.trusted===!0||e.isTrustedScopeActive(t.executionId)}isExecutionIdActive(e){return this.activeExecutionIds.has(e)}getCachedContext(e){let t=this.contextCache.get(e);return t||(t={sandboxActive:!0,executionId:e},this.contextCache.set(e,t)),t}static bindCurrentContext(t){if(!nB)return t;let n=nB.getStore(),r=n?.sandboxActive===!0?n.executionId:void 0;if(!r)return t;let i=e.instance?.getCachedContext(r)??{sandboxActive:!0,executionId:r},a=n?.forceUntrusted?{...i,forceUntrusted:!0}:i;return((...n)=>{let i=e.instance;if(!(i&&!i.isExecutionIdActive(r)&&(i.recordViolation(`bound_callback_after_deactivate`,`bound callback`,`Bound callback blocked after originating execution was deactivated`),!i.config.auditMode)))return qz(a,t,...n)})}isEnabled(){return this.getStatus().state===`enabled`}getStatus(){let e=Jz();return this.config.requested===`disabled`?{requested:`disabled`,state:`disabled`,level:`none`,contextualDynamicImportProtection:e,processLifetimeIntrinsicHardening:this.config.processLifetimeIntrinsicHardening===!0,intrinsicProtection:this.config.processLifetimeIntrinsicHardening?`process-lifetime`:`scoped-best-effort`}:!nB||Zz?{requested:this.config.requested,state:`unsupported`,level:`none`,contextualDynamicImportProtection:!1,processLifetimeIntrinsicHardening:this.config.processLifetimeIntrinsicHardening===!0,intrinsicProtection:this.config.processLifetimeIntrinsicHardening?`process-lifetime`:`scoped-best-effort`,reason:`context-aware ESM loader hooks (node:module.registerHooks) are unavailable`}:{requested:this.config.requested,state:`enabled`,level:this.config.auditMode?`none`:e?`full`:`best-effort`,contextualDynamicImportProtection:e,processLifetimeIntrinsicHardening:this.config.processLifetimeIntrinsicHardening===!0,intrinsicProtection:this.config.processLifetimeIntrinsicHardening?`process-lifetime`:`scoped-best-effort`,reason:this.config.auditMode?`audit mode records violations but does not block them`:e?void 0:`best-effort protection; context-aware ESM loader hooks are unavailable`}}updateConfig(e){if(this.refCount>0)throw Error(`DefenseInDepthBox configuration cannot change while protection is active`);this.config=Yz({...this.config,...e})}activate(){if(!Zz&&this.config.enabled&&!nB)throw Error(`DefenseInDepthBox: enabled protection requires node:async_hooks and node:module`);if(Zz||!this.config.enabled){let e=Kz(),t=!1;return{run:e=>t?Promise.reject(Error(`DefenseInDepthBox handle is deactivated and cannot run new work`)):e(),deactivate:()=>{t=!0},executionId:e}}if(this.refCount++,this.refCount===1){try{this.applyPatches()}catch(e){throw this.restorePatches(),this.activeExecutionIds.clear(),this.contextCache.clear(),this.refCount=0,e}this.activationTime=Date.now()}let e=Kz(),t=!1;return{run:n=>t?Promise.reject(Error(`DefenseInDepthBox handle is deactivated and cannot run new work`)):(this.activeExecutionIds.add(e),nB.run({sandboxActive:!0,executionId:e},n)),deactivate:()=>{t||(t=!0,this.activeExecutionIds.delete(e),this.contextCache.delete(e),this.refCount--,this.refCount===0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount<0&&(this.refCount=0))},executionId:e}}forceDeactivate(){this.refCount>0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.activeExecutionIds.clear(),this.contextCache.clear(),this.refCount=0}isActive(){return this.refCount>0}getStats(){return{violationsBlocked:this.violations.length,violations:[...this.violations],activeTimeMs:this.totalActiveTimeMs+(this.refCount>0?Date.now()-this.activationTime:0),refCount:this.refCount}}getPatchFailures(){return[...this.patchFailures]}clearViolations(){this.violations=[]}getPathForTarget(e,t){return e===globalThis?`globalThis.${t}`:e===process?`process.${t}`:e===Error?`Error.${t}`:e===Function.prototype?`Function.prototype.${t}`:e===Object.prototype?`Object.prototype.${t}`:`.${t}`}static runTrusted(t){if(!nB)return t();let n=nB.getStore();if(!n)return t();let{executionId:r}=n;return nB.run({...n,trusted:!0,forceUntrusted:!1},()=>{e.enterTrustedScope(r);try{let n=t();return typeof n==`object`&&n&&`finally`in n&&typeof n.finally==`function`?n.finally(()=>{e.leaveTrustedScope(r)}):(e.leaveTrustedScope(r),n)}catch(t){throw e.leaveTrustedScope(r),t}})}static async runTrustedAsync(t){if(!nB)return t();let n=nB.getStore();if(!n)return t();let{executionId:r}=n;return nB.run({...n,trusted:!0,forceUntrusted:!1},async()=>{e.enterTrustedScope(r);try{return await t()}finally{e.leaveTrustedScope(r)}})}static async runUntrustedAsync(e){if(!nB)return e();let t=nB.getStore();return t?nB.run({...t,trusted:!1,forceUntrusted:!0},e):e()}shouldBlock(){if(Zz||this.config.auditMode||!nB)return!1;let t=nB?.getStore();return!(t?.sandboxActive!==!0||e.isTrustedContext(t))}shouldAudit(){if(!this.config.auditMode||!nB)return!1;let t=nB.getStore();return t?.sandboxActive===!0&&!e.isTrustedContext(t)}recordViolation(e,t,n){let r={timestamp:Lz(),type:e,message:n,path:t,stack:Error().stack,executionId:nB?.getStore()?.executionId};if(this.violations.length{let i=`${t} ${e} is blocked during script execution`,a=r.recordViolation(n,t,i);throw new tB(i,a)};return new Proxy(e,{set(e,t,n,a){return r.shouldBlock()&&i(`modification`),Reflect.set(e,t,n,a)},defineProperty(e,t,n){return r.shouldBlock()&&i(`defineProperty`),Reflect.defineProperty(e,t,n)},deleteProperty(e,t){return r.shouldBlock()&&i(`deletion`),Reflect.deleteProperty(e,t)},setPrototypeOf(e,t){return r.shouldBlock()&&i(`setPrototypeOf`),Reflect.setPrototypeOf(e,t)},preventExtensions(e){return r.shouldBlock()&&i(`preventExtensions`),Reflect.preventExtensions(e)}})}applyPatches(){this.patchFailures=[];let e=Pz(),t=new Set(this.config.excludeViolationTypes??[]),n=new Set([`process_send`,`process_channel`,`process_stdout`,`process_stderr`]),r=[];for(let i of e)if(!t.has(i.violationType)&&!n.has(i.violationType)){if(i.strategy===`freeze`){r.push(i);continue}this.applyPatch(i)}this.protectConstructorChain(),t.has(`error_prepare_stack_trace`)||this.protectErrorPrepareStackTrace(),this.protectPromiseThen(),Jz()&&this.protectDynamicImport(),this.protectModuleLoad(),this.protectModuleResolveFilename(),this.protectProcessMainModule(),this.protectProcessExecPath(),this.protectProxyRevocable();let i=[`Function.prototype.constructor`,`Module._load`,`Module._resolveFilename`],a=this.patchFailures.filter(e=>i.includes(e));if(a.length>0)throw this.restorePatches(),Error(`DefenseInDepthBox: critical patches failed: ${a.join(`, `)}`);this.config.processLifetimeIntrinsicHardening||this.protectReversibleIntrinsics(r);for(let e of r)this.applyPatch(e,this.config.processLifetimeIntrinsicHardening===!0);this.config.processLifetimeIntrinsicHardening&&this.lockWellKnownSymbols()}protectReversibleIntrinsics(e){let t=new Set,n=(e,t)=>{let n=Object.getOwnPropertyDescriptor(e,t);!n||!(`value`in n)||n.writable!==!0||n.configurable!==!0||(this.temporaryIntrinsicDescriptors.push({target:e,prop:t,descriptor:n}),Object.defineProperty(e,t,{...n,writable:!1}))};for(let{target:r,prop:i}of e){let e=r[i];if(typeof e==`object`&&e){t.add(e);for(let t of Reflect.ownKeys(e))n(e,t)}}let r=[];for(let e of[Array,Map,Set,RegExp,Promise])r.push([e,Symbol.species]);for(let e of[Array.prototype,String.prototype,Map.prototype,Set.prototype])r.push([e,Symbol.iterator]);r.push([Symbol.prototype,Symbol.toPrimitive],[Date.prototype,Symbol.toPrimitive],[Function.prototype,Symbol.hasInstance],[Array.prototype,Symbol.unscopables]);for(let e of[Symbol.match,Symbol.matchAll,Symbol.replace,Symbol.search,Symbol.split])r.push([RegExp.prototype,e]);for(let e of[Map.prototype,Set.prototype,Promise.prototype,ArrayBuffer.prototype])r.push([e,Symbol.toStringTag]);for(let[e,i]of r)t.add(e),n(e,i);let i=(e,n,r)=>{let i=Object.getOwnPropertyDescriptor(e,n);if(!i||!(`value`in i)||typeof i.value!=`function`||i.configurable!==!0)return;let a=i.value,o=this,s=function(...e){let i=e[0];if(o.shouldBlock()&&typeof i==`object`&&i&&t.has(i)){let e=`${r}.${n}`,t=`${e} is blocked for protected intrinsics during script execution`,i=o.recordViolation(`prototype_mutation`,e,t);throw new tB(t,i)}return Reflect.apply(a,this,e)};this.temporaryIntrinsicDescriptors.push({target:e,prop:n,descriptor:i}),Object.defineProperty(e,n,{...i,value:s,writable:!1})};for(let e of[`assign`,`defineProperties`,`defineProperty`,`freeze`,`preventExtensions`,`seal`,`setPrototypeOf`])i(Object,e,`Object`);for(let e of[`defineProperty`,`deleteProperty`,`preventExtensions`,`set`,`setPrototypeOf`])i(Reflect,e,`Reflect`)}protectConstructorChain(){this.patchPrototypeConstructor(Function.prototype,`Function.prototype.constructor`,`function_constructor`);try{let e=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,`AsyncFunction.prototype.constructor`,`async_function_constructor`)}catch(e){this.patchFailures.push(`AsyncFunction.prototype.constructor`),console.debug(`[DefenseInDepthBox] Could not patch AsyncFunction.prototype.constructor:`,e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(function*(){}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,`GeneratorFunction.prototype.constructor`,`generator_function_constructor`)}catch(e){this.patchFailures.push(`GeneratorFunction.prototype.constructor`),console.debug(`[DefenseInDepthBox] Could not patch GeneratorFunction.prototype.constructor:`,e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(async function*(){}).constructor,t=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&e!==t&&this.patchPrototypeConstructor(e.prototype,`AsyncGeneratorFunction.prototype.constructor`,`async_generator_function_constructor`)}catch(e){this.patchFailures.push(`AsyncGeneratorFunction.prototype.constructor`),console.debug(`[DefenseInDepthBox] Could not patch AsyncGeneratorFunction.prototype.constructor:`,e instanceof Error?e.message:e)}}protectErrorPrepareStackTrace(){let e=this;try{let t=Object.getOwnPropertyDescriptor(Error,`prepareStackTrace`);this.originalDescriptors.push({target:Error,prop:`prepareStackTrace`,descriptor:t});let n=t?.value;Object.defineProperty(Error,"prepareStackTrace",{get(){return n},set(t){if(e.shouldBlock()){let t=`Error.prepareStackTrace modification is blocked during script execution`,n=e.recordViolation(`error_prepare_stack_trace`,`Error.prepareStackTrace`,t);throw new tB(t,n)}e.shouldAudit()&&e.recordViolation(`error_prepare_stack_trace`,`Error.prepareStackTrace`,`Error.prepareStackTrace set (audit mode)`),n=t},configurable:!0})}catch(e){this.patchFailures.push(`Error.prepareStackTrace`),console.debug(`[DefenseInDepthBox] Could not protect Error.prepareStackTrace:`,e instanceof Error?e.message:e)}}protectPromiseThen(){let e=this;try{let t=function(...e){return nB.run(this.captured,()=>{if(!this.box.isExecutionIdActive(this.executionId)){if(this.box.recordViolation(`promise_then_after_deactivate`,`Promise.then`,`Promise.then callback is blocked after defense deactivation`),this.box.config.auditMode)return Reflect.apply(this.cb,void 0,e);if(this.kind===`fulfilled`)return e[0];throw e[0]}return Reflect.apply(this.cb,void 0,e)})},n=Object.getOwnPropertyDescriptor(Promise.prototype,`then`);this.originalDescriptors.push({target:Promise.prototype,prop:`then`,descriptor:n});let r=n?.value;if(typeof r!=`function`)return;Object.defineProperty(Promise.prototype,"then",{value:function(n,i){if(!nB)return Reflect.apply(r,this,[n,i]);let a=nB.getStore(),o=a?.sandboxActive===!0&&a.trusted!==!0?a.executionId:void 0;if(!o)return Reflect.apply(r,this,[n,i]);let s=e.getCachedContext(o),c=a?.forceUntrusted?{...s,forceUntrusted:!0}:s,l=(n,r)=>typeof n==`function`?t.bind({box:e,executionId:o,captured:c,cb:n,kind:r}):n;return Reflect.apply(r,this,[l(n,`fulfilled`),l(i,`rejected`)])},writable:!0,configurable:!0})}catch(e){this.patchFailures.push(`Promise.prototype.then`),console.debug(`[DefenseInDepthBox] Could not protect Promise.prototype.then:`,e instanceof Error?e.message:e)}}patchPrototypeConstructor(e,t,n){let r=this;try{let i=Object.getOwnPropertyDescriptor(e,`constructor`);this.originalDescriptors.push({target:e,prop:`constructor`,descriptor:i});let a=i?.value;Object.defineProperty(e,"constructor",{get(){if(r.shouldBlock()){let e=`${t} access is blocked during script execution`,i=r.recordViolation(n,t,e);throw new tB(e,i)}return r.shouldAudit()&&r.recordViolation(n,t,`${t} accessed (audit mode)`),a},set(e){if(r.shouldBlock()){let e=`${t} modification is blocked during script execution`,i=r.recordViolation(n,t,e);throw new tB(e,i)}Object.defineProperty(this,"constructor",{value:e,writable:!0,configurable:!0})},configurable:!0})}catch(e){this.patchFailures.push(t),console.debug(`[DefenseInDepthBox] Could not patch ${t}:`,e instanceof Error?e.message:e)}}protectProcessMainModule(){if(typeof process>`u`)return;let e=this;try{let t=Object.getOwnPropertyDescriptor(process,`mainModule`);this.originalDescriptors.push({target:process,prop:`mainModule`,descriptor:t});let n=t?.value;n!==void 0&&Object.defineProperty(process,"mainModule",{get(){if(e.shouldBlock()){let t=`process.mainModule access is blocked during script execution`,n=e.recordViolation(`process_main_module`,`process.mainModule`,t);throw new tB(t,n)}return e.shouldAudit()&&e.recordViolation(`process_main_module`,`process.mainModule`,`process.mainModule accessed (audit mode)`),n},set(t){if(e.shouldBlock()){let t=`process.mainModule modification is blocked during script execution`,n=e.recordViolation(`process_main_module`,`process.mainModule`,t);throw new tB(t,n)}Object.defineProperty(process,"mainModule",{value:t,writable:!0,configurable:!0})},configurable:!0})}catch(e){this.patchFailures.push(`process.mainModule`),console.debug(`[DefenseInDepthBox] Could not protect process.mainModule:`,e instanceof Error?e.message:e)}}protectProcessExecPath(){if(typeof process>`u`)return;let e=this;try{let t=Object.getOwnPropertyDescriptor(process,`execPath`);this.originalDescriptors.push({target:process,prop:`execPath`,descriptor:t});let n=t?.value??process.execPath;Object.defineProperty(process,"execPath",{get(){if(e.shouldBlock()){let t=`process.execPath access is blocked during script execution`,n=e.recordViolation(`process_exec_path`,`process.execPath`,t);throw new tB(t,n)}return e.shouldAudit()&&e.recordViolation(`process_exec_path`,`process.execPath`,`process.execPath accessed (audit mode)`),n},set(t){if(e.shouldBlock()){let t=`process.execPath modification is blocked during script execution`,n=e.recordViolation(`process_exec_path`,`process.execPath`,t);throw new tB(t,n)}Object.defineProperty(process,"execPath",{value:t,writable:!0,configurable:!0})},configurable:!0})}catch(e){this.patchFailures.push(`process.execPath`),console.debug(`[DefenseInDepthBox] Could not protect process.execPath:`,e instanceof Error?e.message:e)}}lockWellKnownSymbols(){let e=(e,t)=>{try{let n=Object.getOwnPropertyDescriptor(e,t);if(n?.configurable){if(`value`in n){Object.defineProperty(e,t,{...n,configurable:!1,writable:!1});return}Object.defineProperty(e,t,{...n,configurable:!1})}}catch{}};for(let t of[Array,Map,Set,RegExp,Promise])e(t,Symbol.species);for(let t of[Array.prototype,String.prototype,Map.prototype,Set.prototype])e(t,Symbol.iterator);e(Symbol.prototype,Symbol.toPrimitive),e(Date.prototype,Symbol.toPrimitive);for(let t of[Symbol.match,Symbol.matchAll,Symbol.replace,Symbol.search,Symbol.split])e(RegExp.prototype,t);e(Function.prototype,Symbol.hasInstance),e(Array.prototype,Symbol.unscopables);for(let t of[Map.prototype,Set.prototype,Promise.prototype,ArrayBuffer.prototype])e(t,Symbol.toStringTag)}protectProxyRevocable(){let e=this;try{let t=Proxy.revocable;if(typeof t!=`function`)return;let n=Object.getOwnPropertyDescriptor(Proxy,`revocable`);this.originalDescriptors.push({target:Proxy,prop:`revocable`,descriptor:n}),Object.defineProperty(Proxy,"revocable",{value:function(n,r){if(e.shouldBlock()){let t=`Proxy.revocable is blocked during script execution`,n=e.recordViolation(`proxy`,`Proxy.revocable`,t);throw new tB(t,n)}return e.shouldAudit()&&e.recordViolation(`proxy`,`Proxy.revocable`,`Proxy.revocable called (audit mode)`),t(n,r)},writable:!1,configurable:!0})}catch(e){this.patchFailures.push(`Proxy.revocable`),console.debug(`[DefenseInDepthBox] Could not protect Proxy.revocable:`,e instanceof Error?e.message:e)}}protectDynamicImport(){if(!(Zz||e.importHooksRegistered))try{let t=$z;if(!t)throw Error(`node:module is unavailable`);let n=new Set;for(let e of t.builtinModules??[]){let t=e.startsWith(`node:`)?e.slice(5):e;n.add(t);let r=t.indexOf(`/`);r>0&&n.add(t.slice(0,r))}let r=e=>{if(e.startsWith(`./`)||e.startsWith(`../`)||e.startsWith(`/`)||e.startsWith(`file:`)||e.startsWith(`data:`)||e.startsWith(`blob:`)||e.startsWith(`http:`)||e.startsWith(`https:`))return!1;let r=e.startsWith(`node:`)?e.slice(5):e;if(!r)return!1;if(typeof t.isBuiltin==`function`&&t.isBuiltin(r)||n.has(r))return!0;let i=r.indexOf(`/`);return i>0&&n.has(r.slice(0,i))},i=t=>{let n=nB?.getStore();return t.config.auditMode===!0&&n?.sandboxActive===!0&&!e.isTrustedContext(n)};if(typeof t.registerHooks==`function`){t.registerHooks({resolve(t,n,a){let o=e.instance;if(!o)return a(t,n);if((t.startsWith(`data:`)||t.startsWith(`blob:`))&&o.shouldBlock()){let e=`import(${t.startsWith(`data:`)?`data:`:`blob:`})`,n=`dynamic import of ${t.startsWith(`data:`)?`data:`:`blob:`} URLs is blocked by defense-in-depth`,r=o.recordViolation(`dynamic_import_builtin`,e,n);throw new tB(n,r)}if(r(t)){let e=`import(${t})`,n=`dynamic import of Node.js builtin '${t}' is blocked during script execution`;if(o.shouldBlock()){let t=o.recordViolation(`dynamic_import_builtin`,e,n);throw new tB(n,t)}i(o)&&o.recordViolation(`dynamic_import_builtin`,e,`dynamic import of Node.js builtin '${t}' called (audit mode)`)}return a(t,n)}}),e.importHooksRegistered=!0;return}throw Error(`context-aware ESM loader hooks (node:module.registerHooks) are unavailable`)}catch(e){throw Error(`DefenseInDepthBox: could not register dynamic-import hooks: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}protectModuleLoad(){this.protectModuleMethod(`_load`,`module_load`)}protectModuleResolveFilename(){this.protectModuleMethod(`_resolveFilename`,`module_resolve_filename`)}protectModuleMethod(e,t){if(Zz)return;let n=`Module.${e}`;try{let r=eB,i=r?.[e];if(!r||typeof i!=`function`)throw Error(`node:module Module class or method is unavailable`);let a=Object.getOwnPropertyDescriptor(r,e);if(!a)throw Error(`method has no own property descriptor`);if(a.configurable===!1&&a.writable===!1)throw Error(`method is non-configurable and non-writable`);let o=this.createBlockingProxy(i,n,t);this.originalDescriptors.push({target:r,prop:e,descriptor:a}),Object.defineProperty(r,e,{...a,value:o});let s=Object.getOwnPropertyDescriptor(r,e);if(r[e]!==o||s?.value!==o)throw Error(`installed patch failed verification`)}catch{this.patchFailures.push(n)}}applyPatch(e,t=!1){let{target:n,prop:r,violationType:i,strategy:a}=e;try{let o=n[r];if(o===void 0)return;let s=Object.getOwnPropertyDescriptor(n,r);if(this.originalDescriptors.push({target:n,prop:r,descriptor:s}),a===`freeze`){if(typeof o==`object`&&o){t&&Object.freeze(o);let e=this.getPathForTarget(n,r),a=this.createReadonlyObjectProxy(o,e,i);Object.defineProperty(n,r,{...s,value:a})}}else{let t=this.getPathForTarget(n,r),a=typeof o==`function`?this.createBlockingProxy(o,t,i):this.createBlockingObjectProxy(o,t,i,e.allowedKeys);Object.defineProperty(n,r,{value:a,writable:!0,configurable:!0})}}catch(e){let t=this.getPathForTarget(n,r);this.patchFailures.push(t),console.debug(`[DefenseInDepthBox] Could not patch ${t}:`,e instanceof Error?e.message:e)}}restorePatches(){for(let e=this.temporaryIntrinsicDescriptors.length-1;e>=0;e--){let{target:t,prop:n,descriptor:r}=this.temporaryIntrinsicDescriptors[e];try{Object.defineProperty(t,n,r)}catch(e){console.debug(`[DefenseInDepthBox] Could not restore temporary intrinsic ${String(n)}:`,e instanceof Error?e.message:e)}}this.temporaryIntrinsicDescriptors=[];for(let e=this.originalDescriptors.length-1;e>=0;e--){let{target:t,prop:n,descriptor:r}=this.originalDescriptors[e];try{r?Object.defineProperty(t,n,r):delete t[n]}catch(e){let r=this.getPathForTarget(t,n);console.debug(`[DefenseInDepthBox] Could not restore ${r}:`,e instanceof Error?e.message:e)}}this.originalDescriptors=[]}}});function sB(e){return typeof e==`function`?aB.bindCurrentContext(e):e}function cB(e,t){if(t===1/0)return;let n=sB(e),r={cleared:!1,remainingMs:Math.max(0,t),timer:void 0},i=()=>{if(r.cleared)return;let e=Math.min(r.remainingMs,mB);r.timer=uB(()=>{r.cleared||(r.remainingMs-=e,r.remainingMs>0?i():n())},e)};return i(),r}function lB(e){e&&(e.cleared=!0,e.timer!==void 0&&dB(e.timer))}var uB,dB,fB,pB,mB,hB=B(()=>{oB(),uB=globalThis.setTimeout.bind(globalThis),dB=globalThis.clearTimeout.bind(globalThis),globalThis.setInterval.bind(globalThis),globalThis.clearInterval.bind(globalThis),fB=((e,t,...n)=>uB(sB(e),t,...n)),pB=dB,mB=2147483647});function gB(...e){let t=[...new Set(e.filter(e=>e!==void 0))];if(t.length===0)return{signal:void 0,cleanup(){}};if(t.length===1)return{signal:t[0],cleanup(){}};let n=new AbortController,r=[];for(let e of t){if(e.aborted){n.abort(e.reason);break}let t=()=>n.abort(e.reason);e.addEventListener(`abort`,t,{once:!0}),r.push([e,t])}return{signal:n.signal,cleanup(){for(let[e,t]of r)e.removeEventListener(`abort`,t)}}}var _B=B(()=>{});function vB(e,t,n){if(!Number.isSafeInteger(e)||e<0||!Number.isSafeInteger(t)||t<0||e>t)throw RangeError(`${n}: byte conversion limit exceeded (${t} bytes)`)}function V(e){let t=0;for(let n=0;n=55296&&r<=56319&&n+1=56320&&r<=57343?(t+=4,n++):t+=3}else t+=3}return t}function yB(e,t=OB){let n=e;if(!n)return n;vB(n.length,t,`UTF-8 decode`);let r=!1;for(let e=0;e255)return n;t>127&&(r=!0)}if(!r)return n;let i=new Uint8Array(n.length);for(let e=0;e{EB=new TextDecoder(`utf-8`,{fatal:!0}),DB=new TextEncoder,OB=536870912,kB=``});function jB(e){return e instanceof NB||e instanceof PB||e instanceof FB}var MB,NB,PB,FB,IB,LB,RB,zB,BB,VB,HB,H,UB,WB,GB,U=B(()=>{AB(),MB=class extends Error{stdout;stderr;internalOutputAccounting={stdout:0,stderr:0};constructor(e,t=``,n=``){super(e),this.stdout=t,this.stderr=n}prependOutput(e,t){this.stdout=e+this.stdout,this.stderr=t+this.stderr,this.internalOutputAccounting.stdout+=V(e),this.internalOutputAccounting.stderr+=V(t)}},NB=class extends MB{levels;name=`BreakError`;constructor(e=1,t=``,n=``){super(`break`,t,n),this.levels=e}},PB=class extends MB{levels;name=`ContinueError`;constructor(e=1,t=``,n=``){super(`continue`,t,n),this.levels=e}},FB=class extends MB{exitCode;name=`ReturnError`;constructor(e=0,t=``,n=``){super(`return`,t,n),this.exitCode=e}},IB=class extends MB{exitCode;name=`ErrexitError`;constructor(e,t=``,n=``){super(`errexit: command exited with status ${e}`,t,n),this.exitCode=e}},LB=class extends MB{varName;name=`NounsetError`;constructor(e,t=``){super(`${e}: unbound variable`,t,`bash: ${e}: unbound variable `),this.varName=e}},RB=class extends MB{exitCode;name=`ExitError`;constructor(e,t=``,n=``){super(`exit`,t,n),this.exitCode=e}},zB=class extends MB{name=`ArithmeticError`;fatal;constructor(e,t=``,n=``,r=!1){super(e,t,n),this.stderr=n||`bash: ${e} `,this.fatal=r}},BB=class extends MB{name=`BadSubstitutionError`;constructor(e,t=``,n=``){super(e,t,n),this.stderr=n||`bash: ${e}: bad substitution `}},VB=class extends MB{name=`GlobError`;constructor(e,t=``,n=``){super(`no match: ${e}`,t,n),this.stderr=n||`bash: no match: ${e} `}},HB=class extends MB{name=`BraceExpansionError`;constructor(e,t=``,n=``){super(e,t,n),this.stderr=n||`bash: ${e} `}},H=class extends MB{limitType;name=`ExecutionLimitError`;static EXIT_CODE=126;constructor(e,t,n=``,r=``){super(e,n,r),this.limitType=t,this.stderr=r||`bash: ${e} `}},UB=class extends MB{name=`ExecutionAbortedError`;constructor(e=``,t=``){super(`execution aborted`,e,t)}},WB=class extends MB{name=`SubshellExitError`;constructor(e=``,t=``){super(`subshell exit`,e,t)}},GB=class extends MB{exitCode;name=`PosixFatalError`;constructor(e,t=``,n=``){super(`posix fatal error`,t,n),this.exitCode=e}}});function KB(e,t,n){let r=n===`width`?Math.abs(e):e;if(!Number.isFinite(e)||!Number.isSafeInteger(e)||r<0||r>t)throw new H(`format ${n} limit exceeded (${t} bytes)`,`string_length`)}function qB(e,t,n,r=XB){KB(t,r,`width`),n!==-1&&KB(n,r,`precision`);let i=e;n>=0&&i.length>n&&(i=i.slice(0,n));let a=Math.abs(t);if(a>i.length){if(V(i)+a-i.length>r)throw new H(`formatted value size limit exceeded (${r} bytes)`,`string_length`);i=t<0?i.padEnd(a,` `):i.padStart(a,` `)}if(V(i)>r)throw new H(`formatted value size limit exceeded (${r} bytes)`,`string_length`);return i}function JB(e,t,n=XB){let r=t,i=0,a=-1,o=!1;for(r0&&(i=-i),KB(i,n,`width`),a!==-1&&KB(a,n,`precision`),[i,a,r-t]}function YB(e,t=XB){if(V(e)>t)throw new H(`escaped string size limit exceeded (${t} bytes)`,`string_length`);let n=``,r=0;for(;r0){try{let e=new TextDecoder(`utf-8`,{fatal:!0});n+=e.decode(new Uint8Array(t))}catch{for(let e of t)n+=String.fromCharCode(e)}r=i}else n+=e[r],r++;break}case`u`:{let t=``,i=r+2;for(;i{AB(),U(),AB(),XB=10485760}),QB={};Tz(QB,{echoCommand:()=>eV,flagsForFuzzing:()=>tV});function $B(e){let t=``,n=0;for(;n=e.length){t+=`\\`;break}let r=e[n+1];switch(r){case`\\`:t+=`\\`,n+=2;break;case`n`:t+=` `,n+=2;break;case`t`:t+=` `,n+=2;break;case`r`:t+=`\r`,n+=2;break;case`a`:t+=`\x07`,n+=2;break;case`b`:t+=`\b`,n+=2;break;case`f`:t+=`\f`,n+=2;break;case`v`:t+=`\v`,n+=2;break;case`e`:case`E`:t+=`\x1B`,n+=2;break;case`c`:return{output:t,stop:!0};case`0`:{let r=``,i=n+2;for(;i{eV={name:`echo`,async execute(e,t){let n=!1,r=t.xpgEcho??!1,i=0;for(;i{U(),oB()});function aV(e){let t=`${e.name} - ${e.summary} `;if(t+=`Usage: ${e.usage} `,e.description){if(t+=` Description: `,typeof e.description==`string`)for(let n of e.description.split(` `))t+=n?` ${n} `:` `;else if(e.description.length>0)for(let n of e.description)t+=n?` ${n} `:` `}if(e.options&&e.options.length>0){t+=` Options: `;for(let n of e.options)t+=` ${n} `}if(e.examples&&e.examples.length>0){t+=` Examples: `;for(let n of e.examples)t+=` ${n} `}if(e.notes&&e.notes.length>0){t+=` Notes: `;for(let n of e.notes)t+=` ${n} `}return{stdout:t,stderr:``,exitCode:0}}function oV(e){return e.includes(`--help`)}function sV(e,t){return{stdout:``,stderr:t.startsWith(`--`)?`${e}: unrecognized option '${t}' `:`${e}: invalid option -- '${t.replace(/^-/,``)}' `,exitCode:1}}var cV=B(()=>{});function lV(e,t,n){let r=new Map,i=new Map;for(let[e,t]of Object.entries(n)){let n={name:e,type:t.type};t.short&&r.set(t.short,n),t.long&&i.set(t.long,n)}let a=Object.create(null);for(let[e,t]of Object.entries(n))t.default===void 0?t.type===`boolean`&&(a[e]=!1):a[e]=t.default;let o=[],s=!1;for(let n=0;n=t.length)return{ok:!1,error:{stdout:``,stderr:`${e}: option '--${o}' requires an argument `,exitCode:1}};s=t[++n]}a[u]=d===`number`?parseInt(s,10):s}}else{let i=c.slice(1);for(let o=0;o{cV()}),dV=B(()=>{});function fV(e,t,n){if(!Number.isSafeInteger(t)||t<0||t>e.limits.maxInputBytes)throw new H(`${n}: input size limit exceeded (${e.limits.maxInputBytes} bytes)`,`string_length`);e.executionScope?.consumeInput(t,n)}async function pV(e,t,n){let{cmdName:r,allowStdinMarker:i=!0,stopOnError:a=!1,batchSize:o=100}=n;if(t.length===0)return{files:[{filename:``,content:e.stdin}],stderr:``,exitCode:0};let s=[],c=``,l=0;for(let n=0;n{if(i&&t===`-`)return{filename:`-`,content:e.stdin,error:null};try{let n=e.fs.resolvePath(e.cwd,t);return{filename:t,content:await SB(e.fs,n),error:null}}catch{return{filename:t,content:kB,error:`${r}: ${t}: No such file or directory `}}}));for(let e of d)if(e.error){if(c+=e.error,l=1,a)return{files:s,stderr:c,exitCode:l}}else s.push({filename:e.filename,content:e.content})}return{files:s,stderr:c,exitCode:l}}async function mV(e,t,n){let r=await pV(e,t,{...n,stopOnError:!0});return r.exitCode===0?{ok:!0,content:r.files.map(e=>e.content).join(``)}:{ok:!1,error:{stdout:``,stderr:r.stderr,exitCode:r.exitCode}}}var hV=B(()=>{AB(),U(),dV()}),gV={};Tz(gV,{catCommand:()=>SV,flagsForFuzzing:()=>CV});function _V(e){if(e>=32){if(e<127)return String.fromCharCode(e);if(e===127)return`^?`;let t=e-128;return t>=32?t===127?`M-^?`:`M-${String.fromCharCode(t)}`:`M-^${String.fromCharCode(t+64)}`}return`^${String.fromCharCode(e+64)}`}function vV(e,t,n){if(!t.showNonprinting&&!t.showTabs)return e;let r=``,i=e=>{if(e.length>n-r.length)throw new H(`cat: output size limit exceeded`,`output_size`);r+=e};for(let n=0;nr)throw new H(`cat: array element limit exceeded (${r})`,`array_elements`);let a=e.split(` `),o=``,s=1,c=!1,l=e=>{if(e.length>n-o.length)throw new H(`cat: output size limit exceeded (${n} bytes)`,`output_size`);o+=e};for(let e=0;e{AB(),iV(),U(),uV(),hV(),cV(),bV={name:`cat`,summary:`concatenate files and print on the standard output`,usage:`cat [OPTION]... [FILE]...`,options:[`-A, --show-all equivalent to -vET`,`-b, --number-nonblank number nonempty output lines, overrides -n`,`-e equivalent to -vE`,`-E, --show-ends display $ at end of each line`,`-n, --number number all output lines`,`-s, --squeeze-blank suppress repeated empty output lines`,`-t equivalent to -vT`,`-T, --show-tabs display TAB characters as ^I`,`-u (ignored)`,`-v, --show-nonprinting use ^ and M- notation, except for LFD and TAB`,` --help display this help and exit`]},xV={number:{short:`n`,long:`number`,type:`boolean`},numberNonblank:{short:`b`,long:`number-nonblank`,type:`boolean`},showEnds:{short:`E`,long:`show-ends`,type:`boolean`},showTabs:{short:`T`,long:`show-tabs`,type:`boolean`},showNonprinting:{short:`v`,long:`show-nonprinting`,type:`boolean`},showAll:{short:`A`,long:`show-all`,type:`boolean`},squeeze:{short:`s`,long:`squeeze-blank`,type:`boolean`},vE:{short:`e`,type:`boolean`},vT:{short:`t`,type:`boolean`},ignored:{short:`u`,type:`boolean`}},SV={name:`cat`,async execute(e,t){if(oV(e))return aV(bV);let n=lV(`cat`,e,xV);if(!n.ok)return n.error;let r=n.result.flags,i=r.showEnds||r.showAll||r.vE,a=r.showTabs||r.showAll||r.vT,o=r.showNonprinting||r.showAll||r.vE||r.vT,s=r.squeeze,c=r.numberNonblank,l=r.number&&!c,u={numberAll:l,numberNonblank:c,showEnds:i,showTabs:a,showNonprinting:o,squeeze:s},d=n.result.positional,f=t.limits.maxStringLength,p=Math.min(f,t.limits.maxOutputSize),m=d.length===0?[`-`]:d,h=``,g=0,_=0,v,y=i||a||o||s||l||c,b=``;for(let e of m)try{let n=e===`-`?t.stdin:await SB(t.fs,t.fs.resolvePath(t.cwd,e)),r=n.length,i=Math.min(y?f:p,t.limits.maxInputBytes);if(r>i-_)throw new H(`cat: ${y?`input`:`output`} size limit exceeded (${i} bytes)`,y?`string_length`:`output_size`);e!==`-`&&fV(t,r,`cat`),_+=r,b+=n}catch(t){rV(t),h+=`cat: ${e}: No such file or directory `,g=1}return v=y?yV(b,u,p,t.limits.maxArrayElements):b,{stdout:v,stderr:h,exitCode:g,stdoutEncoding:`binary`}}},CV={name:`cat`,flags:[{flag:`-n`,type:`boolean`},{flag:`-A`,type:`boolean`},{flag:`-b`,type:`boolean`},{flag:`-s`,type:`boolean`},{flag:`-v`,type:`boolean`},{flag:`-e`,type:`boolean`},{flag:`-t`,type:`boolean`}],stdinType:`text`,needsFiles:!0}});function TV(e){return e instanceof Error?e.message:String(e)}var EV=B(()=>{});function DV(e,t,n,r={}){let i=new Date(t*1e3),a=OV(i,n),o=``,s=0,c=0,l=0,u=new Map,d=e=>{let t=V(e);if(r.maxOutputBytes!==void 0&&t>r.maxOutputBytes-s)throw new H(`strftime: output size limit exceeded (${r.maxOutputBytes} bytes)`,`output_size`);o+=e,s+=t};for(;cr.maxOperations)throw new H(`strftime: iteration limit exceeded (${r.maxOperations})`,`iterations`);if(e[c]===`%`&&c+1t.find(t=>t.type===e)?.value??``,i=new Map([[`Sun`,0],[`Mon`,1],[`Tue`,2],[`Wed`,3],[`Thu`,4],[`Fri`,5],[`Sat`,6]]),a=r(`weekday`),o=(e,t)=>{let n=Number.parseInt(e,10);return Number.isNaN(n)?t:n};return{year:o(r(`year`),e.getFullYear()),month:o(r(`month`),e.getMonth()+1),day:o(r(`day`),e.getDate()),hour:o(r(`hour`),e.getHours())%24,minute:o(r(`minute`),e.getMinutes()),second:o(r(`second`),e.getSeconds()),weekday:i.get(a)??e.getDay()}}catch{return{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),weekday:e.getDay()}}}function kV(e,t,n,r){let i=(e,t=2)=>String(e).padStart(t,`0`),a=MV(t.year,t.month,t.day),o=NV(t.year,t.month,t.day,t.weekday,0),s=NV(t.year,t.month,t.day,t.weekday,1);switch(n){case`a`:return[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`][t.weekday];case`A`:return[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`][t.weekday];case`b`:case`h`:return[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][t.month-1];case`B`:return[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`][t.month-1];case`c`:return`${[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`][t.weekday]} ${[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][t.month-1]} ${String(t.day).padStart(2,` `)} ${i(t.hour)}:${i(t.minute)}:${i(t.second)} ${t.year}`;case`C`:return i(Math.floor(t.year/100));case`d`:return i(t.day);case`D`:return`${i(t.month)}/${i(t.day)}/${i(t.year%100)}`;case`e`:return String(t.day).padStart(2,` `);case`F`:return`${t.year}-${i(t.month)}-${i(t.day)}`;case`g`:return i(FV(t.year,t.month,t.day)%100);case`G`:return String(FV(t.year,t.month,t.day));case`H`:return i(t.hour);case`I`:return i(t.hour%12||12);case`j`:return String(a).padStart(3,`0`);case`k`:return String(t.hour).padStart(2,` `);case`l`:return String(t.hour%12||12).padStart(2,` `);case`m`:return i(t.month);case`M`:return i(t.minute);case`n`:return` `;case`N`:return`000000000`;case`p`:return t.hour<12?`AM`:`PM`;case`P`:return t.hour<12?`am`:`pm`;case`r`:return`${i(t.hour%12||12)}:${i(t.minute)}:${i(t.second)} ${t.hour<12?`AM`:`PM`}`;case`R`:return`${i(t.hour)}:${i(t.minute)}`;case`s`:return String(Math.floor(e.getTime()/1e3));case`S`:return i(t.second);case`t`:return` `;case`T`:return`${i(t.hour)}:${i(t.minute)}:${i(t.second)}`;case`u`:return String(t.weekday===0?7:t.weekday);case`U`:return i(o);case`V`:return i(PV(t.year,t.month,t.day));case`w`:return String(t.weekday);case`W`:return i(s);case`x`:return`${i(t.month)}/${i(t.day)}/${i(t.year%100)}`;case`X`:return`${i(t.hour)}:${i(t.minute)}:${i(t.second)}`;case`y`:return i(t.year%100);case`Y`:return String(t.year);case`z`:return AV(e,r);case`Z`:return jV(e,r);case`%`:return`%`;default:return null}}function AV(e,t){if(!t){let t=-e.getTimezoneOffset(),n=t>=0?`+`:`-`,r=Math.floor(Math.abs(t)/60),i=Math.abs(t)%60;return`${n}${String(r).padStart(2,`0`)}${String(i).padStart(2,`0`)}`}try{let n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,timeZoneName:`longOffset`}).formatToParts(e).find(e=>e.type===`timeZoneName`);if(n){let e=n.value.match(/GMT([+-])(\d{2}):(\d{2})/);if(e)return`${e[1]}${e[2]}${e[3]}`;if(n.value===`GMT`||n.value===`UTC`)return`+0000`}}catch{}let n=-e.getTimezoneOffset(),r=n>=0?`+`:`-`,i=Math.floor(Math.abs(n)/60),a=Math.abs(n)%60;return`${r}${String(i).padStart(2,`0`)}${String(a).padStart(2,`0`)}`}function jV(e,t){try{return new Intl.DateTimeFormat(`en-US`,{timeZone:t,timeZoneName:`short`}).formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??`UTC`}catch{return`UTC`}}function MV(e,t,n){let r=[31,28,31,30,31,30,31,31,30,31,30,31];(e%4==0&&e%100!=0||e%400==0)&&(r[1]=29);let i=n;for(let e=0;e{U(),ZB()}),LV={};Tz(LV,{flagsForFuzzing:()=>eH,printfCommand:()=>QV});function RV(e){let t=``,n=0;for(;n=194){let i=(r&31)<<6|e[n+1]&63;t+=String.fromCharCode(i),n+=2;continue}t+=String.fromCharCode(r),n++;continue}if((r&240)==224){if(n+2=55296&&i<=57343){t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(i),n+=3;continue}t+=String.fromCharCode(r),n++;continue}if((r&248)==240&&r<=244){if(n+31114111){t+=String.fromCharCode(r),n++;continue}t+=String.fromCodePoint(i),n+=4;continue}t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(r),n++}return t}function zV(e,t,n,r,i=10485760){let a=``,o=0,s=0,c=!1,l=``,u=0,d=e=>{let t=V(e);if(t>i-u)throw new H(`printf: output size limit exceeded (${i} bytes)`,`string_length`);a+=e,u+=t};for(;o=0?KB(e,i-u,`precision`):Number.isSafeInteger(e)||KB(e,i-u,`precision`),s++,_=_.replace(`.*`,`.${e}`)}VV(_,i-u);let v=t[n+s]||``;s++;let{value:y,parseError:b,parseErrMsg:x,stopped:S}=BV(_,g,v,i-u);if(d(y),b&&(c=!0,x&&(l=x)),S)return{result:a,argsConsumed:s,error:c,errMsg:l,stopped:!0}}else d(e[o]),o++;return{result:a,argsConsumed:s,error:c,errMsg:l,stopped:!1}}function BV(e,t,n,r){let i=!1,a=``;switch(t){case`d`:case`i`:{let t=HV(n);return i=$V,i&&(a=`printf: ${n}: invalid number `),{value:UV(e,t),parseError:i,parseErrMsg:a}}case`o`:{let t=HV(n);return i=$V,i&&(a=`printf: ${n}: invalid number `),{value:WV(e,t),parseError:i,parseErrMsg:a}}case`u`:{let t=HV(n);i=$V,i&&(a=`printf: ${n}: invalid number `);let r=t<0?t>>>0:t;return{value:UV(e.replace(`u`,`d`),r),parseError:i,parseErrMsg:a}}case`x`:case`X`:{let t=HV(n);return i=$V,i&&(a=`printf: ${n}: invalid number `),{value:GV(e,t),parseError:i,parseErrMsg:a}}case`e`:case`E`:case`f`:case`F`:case`g`:case`G`:return{value:YV(e,t,parseFloat(n)||0),parseError:!1,parseErrMsg:``};case`c`:{if(n===``)return{value:``,parseError:!1,parseErrMsg:``};let e=new TextEncoder().encode(n)[0];return{value:String.fromCharCode(e),parseError:!1,parseErrMsg:``}}case`s`:return{value:qV(e,n,r),parseError:!1,parseErrMsg:``};case`q`:return{value:JV(e,n,r),parseError:!1,parseErrMsg:``};case`b`:{let e=XV(n,r);return{value:e.value,parseError:!1,parseErrMsg:``,stopped:e.stopped}}default:try{return{value:(0,qI.sprintf)(e,n),parseError:!1,parseErrMsg:``}}catch{return{value:``,parseError:!0,parseErrMsg:`printf: [sprintf] unexpected placeholder `}}}}function VV(e,t){let n=e.match(/^%[-+0 #' ]*(\d*)(?:\.(\d*))?/);if(!n)return;let r=n[1]?Number(n[1]):0,i=n[2]===void 0?-1:Number(n[2]);KB(r,t,`width`),i!==-1&&KB(i,t,`precision`)}function HV(e){$V=!1;let t=e.trimStart(),n=t!==t.trimEnd();if(e=t.trimEnd(),e.startsWith(`'`)&&e.length>=2||e.startsWith(`"`)&&e.length>=2)return e.charCodeAt(1);if(e.startsWith(`\\'`)&&e.length>=3||e.startsWith(`\\"`)&&e.length>=3)return e.charCodeAt(2);if(e.startsWith(`+`)&&(e=e.slice(1)),e.startsWith(`0x`)||e.startsWith(`0X`)){let t=parseInt(e,16);return Number.isNaN(t)?($V=!0,0):(n&&($V=!0),t)}if(e.startsWith(`0`)&&e.length>1&&/^-?0[0-7]+$/.test(e))return n&&($V=!0),parseInt(e,8)||0;if(/^\d+#/.test(e)){$V=!0;let t=e.match(/^(\d+)#/);return t?parseInt(t[1],10):0}if(e!==``&&!/^-?\d+$/.test(e)){$V=!0;let t=parseInt(e,10);return Number.isNaN(t)?0:t}return n&&($V=!0),parseInt(e,10)||0}function UV(e,t){let n=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[diu]$/);if(!n)return(0,qI.sprintf)(e.replace(/\.\d*/,``),t);let r=n[1]||``,i=n[2]?parseInt(n[2],10):0,a=n[3]===void 0?-1:n[4]?parseInt(n[4],10):0,o=t<0,s=String(Math.abs(t));a>=0&&(s=s.padStart(a,`0`));let c=``;o?c=`-`:r.includes(`+`)?c=`+`:r.includes(` `)&&(c=` `);let l=c+s;return i>l.length&&(l=r.includes(`-`)?l.padEnd(i,` `):r.includes(`0`)&&a<0?c+s.padStart(i-c.length,`0`):l.padStart(i,` `)),l}function WV(e,t){let n=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?o$/);if(!n)return(0,qI.sprintf)(e,t);let r=n[1]||``,i=n[2]?parseInt(n[2],10):0,a=n[3]===void 0?-1:n[4]?parseInt(n[4],10):0,o=Math.abs(t).toString(8);a>=0&&(o=o.padStart(a,`0`)),r.includes(`#`)&&!o.startsWith(`0`)&&(o=`0${o}`);let s=o;return i>s.length&&(s=r.includes(`-`)?s.padEnd(i,` `):r.includes(`0`)&&a<0?s.padStart(i,`0`):s.padStart(i,` `)),s}function GV(e,t){let n=e.includes(`X`),r=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[xX]$/);if(!r)return(0,qI.sprintf)(e,t);let i=r[1]||``,a=r[2]?parseInt(r[2],10):0,o=r[3]===void 0?-1:r[4]?parseInt(r[4],10):0,s=Math.abs(t).toString(16);n&&(s=s.toUpperCase()),o>=0&&(s=s.padStart(o,`0`));let c=``;i.includes(`#`)&&t!==0&&(c=n?`0X`:`0x`);let l=c+s;return a>l.length&&(l=i.includes(`-`)?l.padEnd(a,` `):i.includes(`0`)&&o<0?c+s.padStart(a-c.length,`0`):l.padStart(a,` `)),l}function KV(e,t){if(e===``){if(t<2)throw new H(`printf: output size limit exceeded (${t} bytes)`,`string_length`);return`''`}if(/^[a-zA-Z0-9_./-]+$/.test(e)){if(V(e)>t)throw new H(`printf: output size limit exceeded (${t} bytes)`,`string_length`);return e}let n=/[\x00-\x1f\x7f-\xff]/.test(e),r=n?3:0;for(let i of e){let e=i.charCodeAt(0);if(r+=n?i===`'`||i===`\\`||i===` `||i===` `||i===`\r`||i===`\x07`||i===`\b`||i===`\f`||i===`\v`||i===`\x1B`||i===`"`?2:e<32||e>=127&&e<=255?4:V(i):V(i)+ +!!` |&;<>()$\`\\"'*?[#~=%!{}`.includes(i),r>t)throw new H(`printf: output size limit exceeded (${t} bytes)`,`string_length`)}if(n){let t=`$'`;for(let n of e){let e=n.charCodeAt(0);t+=n===`'`?`\\'`:n===`\\`?`\\\\`:n===` `?`\\n`:n===` `?`\\t`:n===`\r`?`\\r`:n===`\x07`?`\\a`:n===`\b`?`\\b`:n===`\f`?`\\f`:n===`\v`?`\\v`:n===`\x1B`?`\\E`:e<32||e>=127&&e<=255?`\\${e.toString(8).padStart(3,`0`)}`:n===`"`?`\\"`:n}return t+=`'`,t}let i=``;for(let t of e)` |&;<>()$\`\\"'*?[#~=%!{}`.includes(t)?i+=`\\${t}`:i+=t;return i}function qV(e,t,n){let r=e.match(/^%(-?)(\d*)(\.(\d*))?s$/);if(!r)return(0,qI.sprintf)(e.replace(/0+(?=\d)/,``),t);let i=r[1]===`-`,a=r[2]?parseInt(r[2],10):0,o=r[3]===void 0?-1:r[4]?parseInt(r[4],10):0;return qB(t,i?-a:a,o,n)}function JV(e,t,n){let r=KV(t,n),i=e.match(/^%(-?)(\d*)q$/);if(!i)return r;let a=i[1]===`-`,o=i[2]?parseInt(i[2],10):0;return qB(r,a?-o:o,-1,n)}function YV(e,t,n){let r=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[eEfFgG]$/);if(!r)return(0,qI.sprintf)(e,n);let i=r[1]||``,a=r[2]?parseInt(r[2],10):0,o=r[3]===void 0?6:r[4]?parseInt(r[4],10):0,s,c=t.toLowerCase();if(c===`e`?(s=n.toExponential(o),s=s.replace(/e([+-])(\d)$/,`e$10$2`),t===`E`&&(s=s.toUpperCase())):c===`f`?(s=n.toFixed(o),i.includes(`#`)&&o===0&&!s.includes(`.`)&&(s+=`.`)):c===`g`?(s=n.toPrecision(o||1),i.includes(`#`)||(s=s.replace(/\.?0+$/,``),s=s.replace(/\.?0+e/,`e`)),s=s.replace(/e([+-])(\d)$/,`e$10$2`),t===`G`&&(s=s.toUpperCase())):s=n.toString(),n>=0&&(i.includes(`+`)?s=`+${s}`:i.includes(` `)&&(s=` ${s}`)),a>s.length){if(i.includes(`-`))s=s.padEnd(a,` `);else if(i.includes(`0`)){let e=s.match(/^[+ -]/)?.[0]||``;s=e+(e?s.slice(1):s).padStart(a-e.length,`0`)}else s=s.padStart(a,` `)}return s}function XV(e,t){if(V(e)>t)throw new H(`printf: output size limit exceeded (${t} bytes)`,`string_length`);let n=``,r=0;for(;r0?(n+=RV(t),r=i):(n+=`\\x`,r+=2);break}case`u`:{let t=``,i=r+2;for(;i{U(),EV(),cV(),ZB(),IV(),ZV={name:`printf`,summary:`format and print data`,usage:`printf [-v var] FORMAT [ARGUMENT...]`,options:[` -v var assign the output to shell variable VAR rather than display it`,` --help display this help and exit`],notes:[`FORMAT controls the output like in C printf.`,`Escape sequences: \\n (newline), \\t (tab), \\\\ (backslash)`,`Format specifiers: %s (string), %d (integer), %f (float), %x (hex), %o (octal), %% (literal %)`,`Width and precision: %10s (width 10), %.2f (2 decimal places), %010d (zero-padded)`,`Flags: %- (left-justify), %+ (show sign), %0 (zero-pad)`]},QV={name:`printf`,async execute(e,t){if(oV(e))return aV(ZV);if(e.length===0)return{stdout:``,stderr:`printf: usage: printf format [arguments] `,exitCode:2,internalStdinConsumed:0};let n=null,r=0;for(;r=e.length)return{stdout:``,stderr:`printf: -v: option requires an argument `,exitCode:1,internalStdinConsumed:0};if(n=e[r+1],!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\[[^\]\n]+\])?$/.test(n)||/[;\r\\]/.test(n)||n.includes(`..`))return{stdout:``,stderr:`printf: \`${n}': not a valid identifier `,exitCode:2,internalStdinConsumed:0};r+=2}else{if(t.startsWith(`-`)&&t!==`-`)break;break}}if(r>=e.length)return{stdout:``,stderr:`printf: usage: printf format [arguments] `,exitCode:1,internalStdinConsumed:0};let i=e[r],a=e.slice(r+1);try{let e=Math.min(t.limits.maxStringLength,t.limits.maxOutputSize),r=YB(i,e),o=``,s=0,c=0,l=!1,u=``,d=t.env.get(`TZ`);do{let{result:t,argsConsumed:n,error:i,errMsg:f,stopped:p}=zV(r,a,c,d,e-s),m=V(t);if(m>e-s)throw new H(`printf: output size limit exceeded (${e} bytes)`,`string_length`);if(o+=t,s+=m,c+=n,i&&(l=!0,f&&(u=f)),p)break}while(c0);if(c===0&&a.length,n){let e=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(['"]?)(.+?)\2\]$/);if(e){let n=e[1],r=e[3];if(r=r.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(e,n)=>t.env.get(n)??``),t.assignShellVariable)await t.assignShellVariable(n,o,r);else throw Error(`printf -v array assignment requires an interpreter assignment gateway`)}else if(t.assignShellVariable)await t.assignShellVariable(n,o);else{if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n))throw Error(`${n}: not a valid identifier`);t.env.set(n,o)}return{stdout:``,stderr:u,exitCode:+!!l,internalStdinConsumed:0}}return{stdout:o,stderr:u,exitCode:+!!l,internalStdinConsumed:0}}catch(e){if(e instanceof H||typeof e==`object`&&e&&`name`in e&&e.name===`ExitError`)throw e;return{stdout:``,stderr:`printf: ${TV(e)} `,exitCode:1,internalStdinConsumed:0}}}},$V=!1,eH={name:`printf`,flags:[{flag:`-v`,type:`value`,valueHint:`string`}],stdinType:`none`,needsArgs:!0}});function nH(e,t){if(!Number.isSafeInteger(e)||e<0)throw new H(`${t}: invalid bounded allocation count`,`array_elements`)}function rH(e){return new H(`${e}: invalid bounded allocation count`,`array_elements`)}function iH(e,t,n){nH(e,n),nH(t,n);let r=e+t;if(!Number.isSafeInteger(r))throw rH(n);return r}function aH(e,t,n){if(nH(e,n),nH(t,n),e!==0&&t>Math.floor((2**53-1)/e))throw rH(n);return e*t}function oH(e,t,n,r){let i=new sH(n,r);for(let n=0;n0&&i.append(t),i.append(e[n]);return i.build()}var sH,cH=B(()=>{AB(),U(),sH=class{maxBytes;label;createLimitError;reservedBytes;chunks=[];usedBytes=0;constructor(e,t,n=void 0,r=0){this.maxBytes=e,this.label=t,this.createLimitError=n,this.reservedBytes=r,nH(e,t),nH(r,t),r>e&&this.fail()}fail(){throw this.createLimitError?.()??new H(`${this.label}: output size limit exceeded (${this.maxBytes} bytes)`,`output_size`)}get byteLength(){return this.usedBytes}get remainingBytes(){return this.maxBytes-this.reservedBytes-this.usedBytes}reserve(e){nH(e,this.label),e>this.remainingBytes&&this.fail()}append(e){let t=V(e);return this.reserve(t),e&&this.chunks.push(e),this.usedBytes+=t,this}repeat(e,t){nH(t,this.label);let n=V(e);return n!==0&&t>Math.floor(this.remainingBytes/n)&&this.fail(),this.append(e.repeat(t))}reset(){this.chunks.length=0,this.usedBytes=0}build(){return this.chunks.join(``)}}});function lH(e){if(!e||e===`/`)return`/`;let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e;t.startsWith(`/`)||(t=`/${t}`);let n=t.split(`/`).filter(e=>e&&e!==`.`),r=[];for(let e of n)e===`..`?r.pop():r.push(e);return`/${r.join(`/`)}`||`/`}function uH(e,t){let n=lH(e),r=lH(t);return r===n||n===`/`||r.startsWith(`${n}/`)}function dH(e,t){if(e.includes(`\0`))throw Error(`ENOENT: path contains null byte, ${t} '${e}'`)}function fH(e){let t=lH(e);if(t===`/`)return`/`;let n=t.lastIndexOf(`/`);return n===0?`/`:t.slice(0,n)}function pH(e,t){return t.startsWith(`/`)?lH(t):lH(e===`/`?`/${t}`:`${e}/${t}`)}function mH(e,t){return e===`/`?`/${t}`:`${e}/${t}`}function hH(e,t){return t.startsWith(`/`)?lH(t):lH(mH(fH(e),t))}var gH=B(()=>{});function _H(e,t,n){if(!e)return e;let r=e.replace(/\n\s+at\s.*/g,``);return n&&(r=r.replace(/\bfile:\/\/\/?[^\s'",)}\]:]+/g,``)),r=r.replace(t?/(?:\/(?:Users|home|private|var|opt|Library|System|usr|etc|tmp|nix|snap|workspace|root|srv|mnt|app))\b[^\s'",)}\]:]*/g:/(?:\/(?:Users|home|private|var|opt|Library|System|usr|etc|tmp|nix|snap))\b[^\s'",)}\]:]*/g,``),r=r.replace(/node:internal\/[^\s'",)}\]:]+/g,``),r=r.replace(/[A-Z]:\\[^\s'",)}\]:]+/g,``),n&&(r=r.replace(/\\\\[^\s\\]+\\[^\s'",)}\]:]+/g,``)),r}function vH(e){return _H(e,!1,!1)}var yH=B(()=>{});function bH(e){if(e.identity!==void 0)return`identity:${e.identity}`;if(e.dev!==void 0&&e.ino!==void 0)return`inode:${String(e.dev)}:${String(e.ino)}`}function xH(e){let t=e instanceof Error?e.message:String(e);return t.includes(`ENOENT`)||t.includes(`no such file`)}async function SH(e,t,n){let r=lH(t),i;try{i=await e.stat(r)}catch(e){if(!xH(e))return{existence:`unknown`}}if(i!==void 0){let t=bH(i);try{return{existence:`existing`,canonicalPath:lH(await e.realpath(r)),stableIdentity:t}}catch{return t===void 0?{existence:`unknown`}:{existence:`existing`,stableIdentity:t}}}let a=[],o=r;for(;;){n?.checkpoint();let t=fH(o);if(t===o)return{existence:`unknown`};a.unshift(o.slice(t===`/`?1:t.length+1)),o=t;try{let t=lH(await e.realpath(o));return{existence:`missing`,canonicalPath:a.reduce((e,t)=>mH(e,t),t)}}catch(e){if(!xH(e))return{existence:`missing`}}}}async function CH(e,t,n){let[r,i]=await Promise.all([SH(e,t),SH(e,n)]);return r.existence===`unknown`||i.existence===`unknown`?`unknown`:r.existence===`missing`||i.existence===`missing`?r.existence===i.existence?r.canonicalPath!==void 0&&r.canonicalPath===i.canonicalPath?`same`:`unknown`:`different`:r.stableIdentity!==void 0&&i.stableIdentity!==void 0?r.stableIdentity===i.stableIdentity?`same`:`different`:r.canonicalPath!==void 0&&r.canonicalPath===i.canonicalPath?`same`:`unknown`}async function wH(e,t,n,r){let[i,a]=await Promise.all([SH(e,t,r),SH(e,n,r)]);return i.existence!==`existing`||i.canonicalPath===void 0||a.existence===`unknown`||a.canonicalPath===void 0?`unknown`:uH(i.canonicalPath,a.canonicalPath)?`inside`:`outside`}async function TH(e,t){let n=e.budget??new DH(e),r=[{kind:`enter`,path:lH(e.root),depth:0}],i=new Set;for(;r.length>0;){n.checkpoint(0);let a=r.pop();if(!a)break;if(a.kind===`leave`){e.includeLeave&&await t({path:a.path,depth:a.depth,stat:a.stat,isSymlink:a.isSymlink,phase:`leave`}),a.identity&&i.delete(a.identity);continue}n.visit(a.depth);let o=await e.fs.lstat(a.path),s=o.isSymbolicLink,c=s&&e.symlinks===`follow`?await e.fs.stat(a.path):o;if(await t({path:a.path,depth:a.depth,stat:c,isSymlink:s,phase:`enter`}),!c.isDirectory||s&&e.symlinks!==`follow`)continue;let l=bH(c)??await e.fs.realpath(a.path).then(lH).catch(()=>{});if(l!==void 0){if(i.has(l))throw new EH(e.site,a.path,`symbolic-link directory cycle detected`);i.add(l)}r.push({kind:`leave`,path:a.path,depth:a.depth,stat:c,isSymlink:s,identity:l});let u=await e.fs.readdir(a.path);n.checkpoint(),u.sort((e,t)=>e.localeCompare(t));for(let e=u.length-1;e>=0;e--)r.push({kind:`enter`,path:mH(a.path,u[e]),depth:a.depth+1})}}var EH,DH,OH=B(()=>{U(),gH(),yH(),EH=class extends Error{operation;virtualPath;name=`FileSystemPolicyError`;constructor(e,t,n){super(`${e}: ${vH(n)}`),this.operation=e,this.virtualPath=t}},DH=class{options;entries=0;discoveredEntries=1;work=0;constructor(e){this.options=e}checkpoint(e=1){if(this.options.signal?.aborted)throw new UB;if(this.options.executionScope?.throwIfAborted(this.options.site),!Number.isSafeInteger(e)||e<0||e>this.options.limits.maxTraversalWork-this.work)throw new H(`${this.options.site}: ${this.options.label??`filesystem traversal work`} limit exceeded (${this.options.limits.maxTraversalWork})`,`iterations`);this.work+=e,this.options.executionScope?.consumeWork(e,`${this.options.site} filesystem traversal`)}visit(e){if(this.checkpoint(),e>this.options.limits.maxTraversalDepth)throw new H(`${this.options.site}: ${this.options.label??`filesystem traversal`} depth limit exceeded (${this.options.limits.maxTraversalDepth})`,`recursion`);if(++this.entries>this.options.limits.maxTraversalEntries)throw new H(`${this.options.site}: ${this.options.label??`filesystem traversal`} entry limit exceeded (${this.options.limits.maxTraversalEntries})`,`iterations`)}discover(e){if(!Number.isSafeInteger(e)||e<0||e>this.options.limits.maxTraversalEntries-this.discoveredEntries)throw new H(`${this.options.site}: ${this.options.label??`filesystem traversal`} entry limit exceeded (${this.options.limits.maxTraversalEntries})`,`iterations`);this.checkpoint(e),this.discoveredEntries+=e}}}),kH={};Tz(kH,{flagsForFuzzing:()=>BH,lsCommand:()=>zH});function AH(e,t,n){if(V(n)>e.limits.maxOutputSize-V(t))throw new H(`ls: output size limit exceeded (${e.limits.maxOutputSize} bytes)`,`output_size`);return t+n}function jH(e,t){let n=new sH(e.limits.maxOutputSize,`ls`);for(let e=0;e0&&n.append(` `),n.append(t[e]);return t.length>0&&n.append(` `),n.build()}function MH(e){if(e<1024)return String(e);if(e<1048576){let t=e/1024;return t<10?`${t.toFixed(1)}K`:`${Math.round(t)}K`}if(e<1073741824){let t=e/1048576;return t<10?`${t.toFixed(1)}M`:`${Math.round(t)}M`}let t=e/1073741824;return t<10?`${t.toFixed(1)}G`:`${Math.round(t)}G`}function NH(e){let t=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][e.getMonth()],n=String(e.getDate()).padStart(2,` `);return e>new Date(new Date().getTime()-15552e6)?`${t} ${n} ${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}`:`${t} ${n} ${e.getFullYear()}`}function PH(e){return e.isDirectory?`/`:e.isSymbolicLink?`@`:e.mode&73?`*`:``}async function FH(e,t,n,r,i,a=!1,o=!1,s=!1,c=!1,l){let u=n||r,d=t.fs.getAllPaths(),f=t.fs.resolvePath(t.cwd,`.`),p=[];for(let t of d){l?.visit(t.split(`/`).length-1);let n=(t===f||f===`/`||t.startsWith(`${f}/`))&&t.slice(f===`/`?1:f.length+1)||t;if(JL(n,e)||JL(t,e)){let e=n.split(`/`).pop()||n;if(!u&&e.startsWith(`.`))continue;p.push(n||t)}}if(p.length===0)return{stdout:``,stderr:`ls: ${e}: No such file or directory `,exitCode:2};if(s){let e=[];for(let n of p){let r=t.fs.resolvePath(t.cwd,n);try{let i=await t.fs.stat(r);e.push({path:n,size:i.size??0})}catch{e.push({path:n,size:0})}}e.sort((e,t)=>t.size-e.size),p.length=0,p.push(...e.map(e=>e.path))}else p.sort();if(a&&p.reverse(),i){let e=[];for(let n of p){let r=t.fs.resolvePath(t.cwd,n);try{let i=await t.fs.stat(r),a=i.isDirectory?`drwxr-xr-x`:`-rw-r--r--`,s=c?PH(await t.fs.lstat(r)):i.isDirectory?`/`:``,l=i.size??0,u=o?MH(l).padStart(5):String(l).padStart(5),d=NH(i.mtime??new Date(0));e.push(`${a} 1 user user ${u} ${d} ${n}${s}`)}catch{e.push(`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${n}`)}}return{stdout:jH(t,e),stderr:``,exitCode:0}}if(c){let e=[];for(let n of p){let r=t.fs.resolvePath(t.cwd,n);try{let i=await t.fs.lstat(r);e.push(`${n}${PH(i)}`)}catch{e.push(n)}}return{stdout:jH(t,e),stderr:``,exitCode:0}}return{stdout:jH(t,p),stderr:``,exitCode:0}}async function IH(e,t,n,r,i,a,o,s=!1,c=!1,l=!1,u=!1,d=!1,f=new DH({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:`ls`}),p=0,m=new Set){let h=n||r,g=t.fs.resolvePath(t.cwd,e);try{f.visit(p);let d=await t.fs.stat(g);if(!d.isDirectory){let n=u?PH(await t.fs.lstat(g)):``;if(i){let t=d.size??0;return{stdout:`-rw-r--r-- 1 user user ${c?MH(t).padStart(5):String(t).padStart(5)} ${NH(d.mtime??new Date(0))} ${e}${n} `,stderr:``,exitCode:0}}return{stdout:`${e}${n} `,stderr:``,exitCode:0}}let _=d.identity??(d.dev!==void 0&&d.ino!==void 0?`${String(d.dev)}:${String(d.ino)}`:await t.fs.realpath(g).catch(()=>{}));if(_!==void 0&&m.has(_))return{stdout:``,stderr:`ls: ${e}: symbolic link cycle detected `,exitCode:2};let v=new Set(m);_!==void 0&&v.add(_);let y=await t.fs.readdir(g);if(f.checkpoint(),h||(y=y.filter(e=>!e.startsWith(`.`))),l){let e=[];for(let n of y){let r=g===`/`?`/${n}`:`${g}/${n}`;try{let i=await t.fs.stat(r);e.push({name:n,size:i.size??0})}catch{e.push({name:n,size:0})}}e.sort((e,t)=>t.size-e.size),y=e.map(e=>e.name)}else y.sort();n&&(y=[`.`,`..`,...y]),s&&y.reverse();let b=``,x=``,S=0;if((a||o)&&(b=AH(t,b,`${e}: `)),i){b=AH(t,b,`total ${y.length} `);let e=y.filter(e=>e===`.`||e===`..`),n=y.filter(e=>e!==`.`&&e!==`..`);for(let n of e)b=AH(t,b,`drwxr-xr-x 1 user user 0 Jan 1 00:00 ${n} `);let r=[];for(let e=0;e{let n=g===`/`?`/${e}`:`${g}/${e}`;try{let r=await t.fs.stat(n),i=r.isDirectory?`drwxr-xr-x`:`-rw-r--r--`,a=u?PH(await t.fs.lstat(n)):r.isDirectory?`/`:``,o=r.size??0;return{name:e,line:`${i} 1 user user ${c?MH(o).padStart(5):String(o).padStart(5)} ${NH(r.mtime??new Date(0))} ${e}${a} `}}catch{return{name:e,line:`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${e} `}}}));r.push(...a)}let i=new Map(n.map((e,t)=>[e,t]));r.sort((e,t)=>(i.get(e.name)??0)-(i.get(t.name)??0));for(let{line:e}of r)b=AH(t,b,e)}else if(u){let e=[],n=y.filter(e=>e!==`.`&&e!==`..`),r=y.filter(e=>e===`.`||e===`..`);for(let t of r)e.push(`${t}/`);for(let r=0;r{let n=g===`/`?`/${e}`:`${g}/${e}`;try{return`${e}${PH(await t.fs.lstat(n))}`}catch{return e}}));e.push(...a)}b=AH(t,b,jH(t,e))}else b=AH(t,b,jH(t,y));if(a){let o=y.filter(e=>e!==`.`&&e!==`..`),d=[];if(t.fs.readdirWithFileTypes)d=(await t.fs.readdirWithFileTypes(g)).filter(e=>e.isDirectory&&o.includes(e.name)).map(e=>({name:e.name,isDirectory:!0}));else for(let e=0;e{let n=g===`/`?`/${e}`:`${g}/${e}`;try{return{name:e,isDirectory:(await t.fs.stat(n)).isDirectory}}catch{return{name:e,isDirectory:!1}}}));d.push(...r.filter(e=>e.isDirectory))}d.sort((e,t)=>e.name.localeCompare(t.name)),s&&d.reverse();let m=[];for(let o=0;o{let d=await IH(e===`.`?`./${o.name}`:`${e}/${o.name}`,t,n,r,i,a,!1,s,c,l,u,!0,f,p+1,v);return{name:o.name,result:d}}));m.push(...g)}m.sort((e,t)=>e.name.localeCompare(t.name)),s&&m.reverse();for(let{result:e}of m)b=AH(t,b,` `),b=AH(t,b,e.stdout),x=AH(t,x,e.stderr),e.exitCode!==0&&(S=e.exitCode)}return{stdout:b,stderr:x,exitCode:S}}catch(t){if(t instanceof H||t instanceof UB)throw t;return{stdout:``,stderr:`ls: ${e}: No such file or directory `,exitCode:2}}}var LH,RH,zH,BH,VH=B(()=>{cH(),AB(),OH(),U(),uV(),dV(),cV(),LH={name:`ls`,summary:`list directory contents`,usage:`ls [OPTION]... [FILE]...`,options:[`-a, --all do not ignore entries starting with .`,`-A, --almost-all do not list . and ..`,`-d, --directory list directories themselves, not their contents`,`-F, --classify append indicator (one of */=>@) to entries`,`-h, --human-readable with -l, print sizes like 1K 234M 2G etc.`,`-l use a long listing format`,`-r, --reverse reverse order while sorting`,`-R, --recursive list subdirectories recursively`,`-S sort by file size, largest first`,`-t sort by time, newest first`,`-1 list one file per line`,` --help display this help and exit`]},RH={showAll:{short:`a`,long:`all`,type:`boolean`},showAlmostAll:{short:`A`,long:`almost-all`,type:`boolean`},longFormat:{short:`l`,type:`boolean`},humanReadable:{short:`h`,long:`human-readable`,type:`boolean`},recursive:{short:`R`,long:`recursive`,type:`boolean`},reverse:{short:`r`,long:`reverse`,type:`boolean`},sortBySize:{short:`S`,type:`boolean`},classifyFiles:{short:`F`,long:`classify`,type:`boolean`},directoryOnly:{short:`d`,long:`directory`,type:`boolean`},sortByTime:{short:`t`,type:`boolean`},onePerLine:{short:`1`,type:`boolean`}},zH={name:`ls`,async execute(e,t){if(oV(e))return aV(LH);let n=lV(`ls`,e,RH);if(!n.ok)return n.error;let r=n.result.flags.showAll,i=n.result.flags.showAlmostAll,a=n.result.flags.longFormat,o=n.result.flags.humanReadable,s=n.result.flags.recursive,c=n.result.flags.reverse,l=n.result.flags.sortBySize,u=n.result.flags.classifyFiles,d=n.result.flags.directoryOnly;n.result.flags.sortByTime,n.result.flags.onePerLine;let f=n.result.positional;f.length===0&&f.push(`.`);let p=``,m=``,h=0,g=new DH({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:`ls`});for(let e=0;e0&&p&&!p.endsWith(` `)&&(p=AH(t,p,` `)),d){let e=t.fs.resolvePath(t.cwd,n);try{let r=await t.fs.stat(e);if(a){let i=r.isDirectory?`drwxr-xr-x`:`-rw-r--r--`,a=u?PH(await t.fs.lstat(e)):r.isDirectory?`/`:``,s=r.size??0,c=o?MH(s).padStart(5):String(s).padStart(5),l=NH(r.mtime??new Date(0));p=AH(t,p,`${i} 1 user user ${c} ${l} ${n}${a} `)}else{let r=u?PH(await t.fs.lstat(e)):``;p=AH(t,p,`${n}${r} `)}}catch{m=AH(t,m,`ls: cannot access '${n}': No such file or directory `),h=2}continue}if(n.includes(`*`)||n.includes(`?`)||n.includes(`[`)){let e=await FH(n,t,r,i,a,c,o,l,u,g);p=AH(t,p,e.stdout),m=AH(t,m,e.stderr),e.exitCode!==0&&(h=e.exitCode)}else{let e=await IH(n,t,r,i,a,s,f.length>1,c,o,l,u,!1,g,0,new Set);p=AH(t,p,e.stdout),m=AH(t,m,e.stderr),e.exitCode!==0&&(h=e.exitCode)}}return{stdout:p,stderr:m,exitCode:h}}},BH={name:`ls`,flags:[{flag:`-a`,type:`boolean`},{flag:`-A`,type:`boolean`},{flag:`-l`,type:`boolean`},{flag:`-h`,type:`boolean`},{flag:`-R`,type:`boolean`},{flag:`-r`,type:`boolean`},{flag:`-S`,type:`boolean`},{flag:`-F`,type:`boolean`},{flag:`-d`,type:`boolean`},{flag:`-t`,type:`boolean`},{flag:`-1`,type:`boolean`}],needsFiles:!0}}),HH={};Tz(HH,{flagsForFuzzing:()=>GH,mkdirCommand:()=>WH});var UH,WH,GH,KH=B(()=>{yH(),EV(),uV(),UH={recursive:{short:`p`,long:`parents`,type:`boolean`},verbose:{short:`v`,long:`verbose`,type:`boolean`}},WH={name:`mkdir`,async execute(e,t){let n=lV(`mkdir`,e,UH);if(!n.ok)return n.error;let r=n.result.flags.recursive,i=n.result.flags.verbose,a=n.result.positional;if(a.length===0)return{stdout:``,stderr:`mkdir: missing operand `,exitCode:1};let o=``,s=``,c=0;for(let e of a)try{let n=t.fs.resolvePath(t.cwd,e);await t.fs.mkdir(n,{recursive:r}),i&&(o+=`mkdir: created directory '${e}' `)}catch(t){let n=TV(t);n.includes(`ENOENT`)||n.includes(`no such file`)?s+=`mkdir: cannot create directory '${e}': No such file or directory `:n.includes(`EEXIST`)||n.includes(`already exists`)?s+=`mkdir: cannot create directory '${e}': File exists `:s+=`mkdir: cannot create directory '${e}': ${vH(n)} `,c=1}return{stdout:o,stderr:s,exitCode:c}}},GH={name:`mkdir`,flags:[{flag:`-p`,type:`boolean`},{flag:`-v`,type:`boolean`}],needsArgs:!0}}),qH={};Tz(qH,{flagsForFuzzing:()=>eU,rmdirCommand:()=>$H});async function JH(e,t,n,r,i){let a=``,o=``,s=e.fs.resolvePath(e.cwd,t),c=await YH(e,s,t,r);if(a+=c.stdout,o+=c.stderr,c.exitCode!==0)return{stdout:a,stderr:o,exitCode:c.exitCode};if(n){let n=s,o=t;for(;;){i.visit(0);let t=XH(n),s=XH(o);if(t===n||t===`/`||t===`.`||s===`.`||s===``)break;let c=await YH(e,t,s,r);if(a+=c.stdout,c.exitCode!==0)break;n=t,o=s}}return{stdout:a,stderr:o,exitCode:0}}async function YH(e,t,n,r){try{if(!await e.fs.exists(t))return{stdout:``,stderr:`rmdir: failed to remove '${n}': No such file or directory `,exitCode:1};if(!(await e.fs.stat(t)).isDirectory)return{stdout:``,stderr:`rmdir: failed to remove '${n}': Not a directory `,exitCode:1};if((await e.fs.readdir(t)).length>0)return{stdout:``,stderr:`rmdir: failed to remove '${n}': Directory not empty `,exitCode:1};await e.fs.rm(t,{recursive:!1,force:!1});let i=``;return r&&(i=`rmdir: removing directory, '${n}' `),{stdout:i,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`rmdir: failed to remove '${n}': ${TV(e)} `,exitCode:1}}}function XH(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n===-1?`.`:n===0?`/`:t.substring(0,n)}var ZH,QH,$H,eU,tU=B(()=>{OH(),EV(),uV(),ZH=`Usage: rmdir [-pv] DIRECTORY... Remove empty directories. Options: -p, --parents Remove DIRECTORY and its ancestors -v, --verbose Output a diagnostic for every directory processed`,QH={parents:{short:`p`,long:`parents`,type:`boolean`},verbose:{short:`v`,long:`verbose`,type:`boolean`},help:{long:`help`,type:`boolean`}},$H={name:`rmdir`,async execute(e,t){let n=lV(`rmdir`,e,QH);if(!n.ok)return n.error;if(n.result.flags.help)return{stdout:`${ZH} `,stderr:``,exitCode:0};let r=n.result.flags.parents,i=n.result.flags.verbose,a=n.result.positional;if(a.length===0)return{stdout:``,stderr:`rmdir: missing operand `,exitCode:1};let o=``,s=``,c=0,l=new DH({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:`rmdir`,label:`parent traversal`});for(let e of a){let n=await JH(t,e,r,i,l);o+=n.stdout,s+=n.stderr,n.exitCode!==0&&(c=n.exitCode)}return{stdout:o,stderr:s,exitCode:c}}},eU={name:`rmdir`,flags:[{flag:`-p`,type:`boolean`},{flag:`-v`,type:`boolean`}],needsArgs:!0}}),nU={};Tz(nU,{flagsForFuzzing:()=>aU,touchCommand:()=>iU});function rU(e){let t=e.replace(/\//g,`-`),n=new Date(t);if(!Number.isNaN(n.getTime()))return n;let r=t.match(/^(\d{4})-(\d{2})-(\d{2})$/);if(r){let[,e,t,i]=r;if(n=new Date(Number.parseInt(e,10),Number.parseInt(t,10)-1,Number.parseInt(i,10)),!Number.isNaN(n.getTime()))return n}let i=t.match(/^(\d{4})-(\d{2})-(\d{2})\s+(\d{2}):(\d{2}):(\d{2})$/);if(i){let[,e,t,r,a,o,s]=i;if(n=new Date(Number.parseInt(e,10),Number.parseInt(t,10)-1,Number.parseInt(r,10),Number.parseInt(a,10),Number.parseInt(o,10),Number.parseInt(s,10)),!Number.isNaN(n.getTime()))return n}return null}var iU,aU,oU=B(()=>{EV(),cV(),iU={name:`touch`,async execute(e,t){let n=[],r=null,i=!1;for(let t=0;t=e.length)return{stdout:``,stderr:`touch: option requires an argument -- 'd' `,exitCode:1};r=e[++t]}else if(a.startsWith(`--date=`))r=a.slice(7);else if(a===`-c`||a===`--no-create`)i=!0;else if(a===`-a`||a===`-m`||a===`-r`||a===`-t`)(a===`-r`||a===`-t`)&&t++;else{if(a.startsWith(`--`))return sV(`touch`,a);if(a.startsWith(`-`)&&a.length>1){let n=!1;for(let o of a.slice(1))if(o===`c`)i=!0;else if(o!==`a`&&o!==`m`){if(o===`d`){if(t+1>=e.length)return{stdout:``,stderr:`touch: option requires an argument -- 'd' `,exitCode:1};r=e[++t],n=!0;break}if(o===`r`||o===`t`){t++,n=!0;break}return sV(`touch`,`-${o}`)}if(n)continue}else n.push(a)}}if(n.length===0)return{stdout:``,stderr:`touch: missing file operand `,exitCode:1};let a=null;if(r!==null&&(a=rU(r),a===null))return{stdout:``,stderr:`touch: invalid date format '${r}' `,exitCode:1};let o=``,s=0;for(let e of n)try{let n=t.fs.resolvePath(t.cwd,e);if(!await t.fs.exists(n)){if(i)continue;await t.fs.writeFile(n,``)}let r=a??new Date;await t.fs.utimes(n,r,r)}catch(t){o+=`touch: cannot touch '${e}': ${TV(t)} `,s=1}return{stdout:``,stderr:o,exitCode:s}}},aU={name:`touch`,flags:[{flag:`-c`,type:`boolean`},{flag:`-a`,type:`boolean`},{flag:`-m`,type:`boolean`},{flag:`-d`,type:`value`,valueHint:`string`}],needsArgs:!0}}),sU={};Tz(sU,{flagsForFuzzing:()=>uU,rmCommand:()=>lU});var cU,lU,uU,dU=B(()=>{yH(),EV(),uV(),cU={recursive:{short:`r`,long:`recursive`,type:`boolean`},recursiveUpper:{short:`R`,type:`boolean`},force:{short:`f`,long:`force`,type:`boolean`},verbose:{short:`v`,long:`verbose`,type:`boolean`}},lU={name:`rm`,async execute(e,t){let n=lV(`rm`,e,cU);if(!n.ok)return n.error;let r=n.result.flags.recursive||n.result.flags.recursiveUpper,i=n.result.flags.force,a=n.result.flags.verbose,o=n.result.positional;if(o.length===0)return i?{stdout:``,stderr:``,exitCode:0}:{stdout:``,stderr:`rm: missing operand `,exitCode:1};let s=``,c=``,l=0;for(let e of o)try{let n=t.fs.resolvePath(t.cwd,e);if((await t.fs.stat(n)).isDirectory&&!r){c+=`rm: cannot remove '${e}': Is a directory `,l=1;continue}await t.fs.rm(n,{recursive:r,force:i}),a&&(s+=`removed '${e}' `)}catch(t){if(!i){let n=TV(t);n.includes(`ENOENT`)||n.includes(`no such file`)?c+=`rm: cannot remove '${e}': No such file or directory `:n.includes(`ENOTEMPTY`)||n.includes(`not empty`)?c+=`rm: cannot remove '${e}': Directory not empty `:c+=`rm: cannot remove '${e}': ${vH(n)} `,l=1}}return{stdout:s,stderr:c,exitCode:l}}},uU={name:`rm`,flags:[{flag:`-r`,type:`boolean`},{flag:`-R`,type:`boolean`},{flag:`-f`,type:`boolean`},{flag:`-v`,type:`boolean`}],needsArgs:!0}}),fU={};Tz(fU,{cpCommand:()=>hU,flagsForFuzzing:()=>gU});var pU,mU,hU,gU,_U=B(()=>{gH(),OH(),U(),EV(),uV(),cV(),pU={name:`cp`,summary:`copy files and directories`,usage:`cp [OPTION]... SOURCE... DEST`,options:[`-r, -R, --recursive copy directories recursively`,`-n, --no-clobber do not overwrite an existing file`,`-p, --preserve preserve file attributes`,`-v, --verbose explain what is being done`,` --help display this help and exit`]},mU={recursive:{short:`r`,long:`recursive`,type:`boolean`},recursiveUpper:{short:`R`,type:`boolean`},noClobber:{short:`n`,long:`no-clobber`,type:`boolean`},preserve:{short:`p`,long:`preserve`,type:`boolean`},verbose:{short:`v`,long:`verbose`,type:`boolean`}},hU={name:`cp`,async execute(e,t){if(oV(e))return aV(pU);let n=lV(`cp`,e,mU);if(!n.ok)return n.error;let r=n.result.flags.recursive||n.result.flags.recursiveUpper,i=n.result.flags.noClobber;n.result.flags.preserve;let a=n.result.flags.verbose,o=n.result.positional;if(o.length<2)return{stdout:``,stderr:`cp: missing destination file operand `,exitCode:1};let s=o.pop()??``,c=o,l=t.fs.resolvePath(t.cwd,s),u=``,d=``,f=0,p=new DH({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:`cp`}),m=!1;try{m=(await t.fs.stat(l)).isDirectory}catch{}if(c.length>1&&!m)return{stdout:``,stderr:`cp: target '${s}' is not a directory `,exitCode:1};for(let e of c)try{let n=t.fs.resolvePath(t.cwd,e),o=await t.fs.stat(n),s=l;if(m){let t=e.split(`/`).pop()||e;s=l===`/`?`/${t}`:`${l}/${t}`}if(o.isDirectory&&!r){d+=`cp: -r not specified; omitting directory '${e}' `,f=1;continue}if(o.isDirectory){let r=await wH(t.fs,n,s,p);if(uH(n,s)||r===`inside`){d+=`cp: cannot copy '${e}' into itself, '${s}' `,f=1;continue}if(r===`unknown`){d+=`cp: cannot safely determine whether '${s}' is inside '${e}' `,f=1;continue}}if(i)try{await t.fs.stat(s);continue}catch{}let c=await CH(t.fs,n,s);if(c===`same`){d+=`cp: '${e}' and '${s}' are the same file `,f=1;continue}if(c===`unknown`){d+=`cp: cannot safely determine whether '${e}' and '${s}' are the same file `,f=1;continue}o.isDirectory&&await TH({fs:t.fs,root:n,limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:`cp`,symlinks:`never`,budget:p},()=>{}),await t.fs.cp(n,s,{recursive:r}),a&&(u+=`'${e}' -> '${s}' `)}catch(t){if(t instanceof H||t instanceof UB)throw t;let n=TV(t);n.includes(`ENOENT`)||n.includes(`no such file`)?d+=`cp: cannot stat '${e}': No such file or directory `:d+=`cp: cannot copy '${e}': ${n} `,f=1}return{stdout:u,stderr:d,exitCode:f}}},gU={name:`cp`,flags:[{flag:`-r`,type:`boolean`},{flag:`-R`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-p`,type:`boolean`},{flag:`-v`,type:`boolean`}],needsArgs:!0,minArgs:2}}),vU={};Tz(vU,{flagsForFuzzing:()=>SU,mvCommand:()=>xU});var yU,bU,xU,SU,CU=B(()=>{gH(),OH(),U(),EV(),uV(),cV(),yU={name:`mv`,summary:`move (rename) files`,usage:`mv [OPTION]... SOURCE... DEST`,options:[`-f, --force do not prompt before overwriting`,`-n, --no-clobber do not overwrite an existing file`,`-v, --verbose explain what is being done`,` --help display this help and exit`]},bU={force:{short:`f`,long:`force`,type:`boolean`},noClobber:{short:`n`,long:`no-clobber`,type:`boolean`},verbose:{short:`v`,long:`verbose`,type:`boolean`}},xU={name:`mv`,async execute(e,t){if(oV(e))return aV(yU);let n=lV(`mv`,e,bU);if(!n.ok)return n.error;n.result.flags.force;let r=n.result.flags.noClobber,i=n.result.flags.verbose,a=n.result.positional;if(a.length<2)return{stdout:``,stderr:`mv: missing destination file operand `,exitCode:1};let o=a.pop()??``,s=a,c=t.fs.resolvePath(t.cwd,o),l=``,u=``,d=0,f=new DH({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:`mv`}),p=!1;try{p=(await t.fs.stat(c)).isDirectory}catch{}if(s.length>1&&!p)return{stdout:``,stderr:`mv: target '${o}' is not a directory `,exitCode:1};for(let e of s)try{let n=t.fs.resolvePath(t.cwd,e),a=await t.fs.stat(n),s=c;if(p){let t=e.split(`/`).pop()||e;s=c===`/`?`/${t}`:`${c}/${t}`}if(a.isDirectory){let r=await wH(t.fs,n,s,f);if(uH(n,s)||r===`inside`){u+=`mv: cannot move '${e}' into itself, '${s}' `,d=1;continue}if(r===`unknown`){u+=`mv: cannot safely determine whether '${s}' is inside '${e}' `,d=1;continue}}if(r)try{await t.fs.stat(s);continue}catch{}let m=await CH(t.fs,n,s);if(m===`same`)continue;if(m===`unknown`){u+=`mv: cannot safely determine whether '${e}' and '${s}' are the same file `,d=1;continue}if(a.isDirectory&&await TH({fs:t.fs,root:n,limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:`mv`,symlinks:`never`,budget:f},()=>{}),await t.fs.mv(n,s),i){let t=p?`${o}/${e.split(`/`).pop()||e}`:o;l+=`renamed '${e}' -> '${t}' `}}catch(t){if(t instanceof H||t instanceof UB)throw t;let n=TV(t);n.includes(`ENOENT`)||n.includes(`no such file`)?u+=`mv: cannot stat '${e}': No such file or directory `:u+=`mv: cannot move '${e}': ${n} `,d=1}return{stdout:l,stderr:u,exitCode:d}}},SU={name:`mv`,flags:[{flag:`-f`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-v`,type:`boolean`}],needsArgs:!0,minArgs:2}}),wU={};Tz(wU,{flagsForFuzzing:()=>DU,lnCommand:()=>EU});var TU,EU,DU,zbe=B(()=>{yH(),cV(),TU={name:`ln`,summary:`make links between files`,usage:`ln [OPTIONS] TARGET LINK_NAME`,options:[`-s create a symbolic link instead of a hard link`,`-f remove existing destination files`,`-n treat LINK_NAME as a normal file if it is a symbolic link to a directory`,`-v print name of each linked file`,` --help display this help and exit`]},EU={name:`ln`,async execute(e,t){if(oV(e))return aV(TU);let n=!1,r=!1,i=!1,a=0;for(;a2)return{stdout:``,stderr:`ln: extra operand '${o[2]}' `,exitCode:1};let s=o[0],c=o[1],l=t.fs.resolvePath(t.cwd,c);if(await t.fs.exists(l)){if(r)try{await t.fs.rm(l,{force:!0})}catch{return{stdout:``,stderr:`ln: cannot remove '${c}': Permission denied `,exitCode:1}}else return{stdout:``,stderr:`ln: failed to create ${n?`symbolic `:``}link '${c}': File exists `,exitCode:1}}try{if(n)await t.fs.symlink(s,l);else{let e=t.fs.resolvePath(t.cwd,s);if(!await t.fs.exists(e))return{stdout:``,stderr:`ln: failed to access '${s}': No such file or directory `,exitCode:1};await t.fs.link(e,l)}}catch(e){let t=e;return t.message.includes(`EPERM`)?{stdout:``,stderr:`ln: '${s}': hard link not allowed for directory `,exitCode:1}:{stdout:``,stderr:`ln: ${vH(t.message)} `,exitCode:1}}let u=``;return i&&(u=`'${c}' -> '${s}' `),{stdout:u,stderr:``,exitCode:0}}},DU={name:`ln`,flags:[{flag:`-s`,type:`boolean`},{flag:`-f`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-v`,type:`boolean`}],needsArgs:!0,minArgs:2}}),OU={};Tz(OU,{chmodCommand:()=>jU,flagsForFuzzing:()=>MU});async function Bbe(e,t,n,r,i,a){let o=new DH({limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:`chmod`});await TH({fs:e.fs,root:t,symlinks:`never`,budget:o,limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:`chmod`},async t=>{if(t.depth===0||t.phase!==`enter`)return;let o=n===void 0?r===void 0?420:kU(r,t.stat.mode):n;await e.fs.chmod(t.path,o),i&&a.append(`mode of '${t.path}' changed to ${o.toString(8).padStart(4,`0`)} `)})}function kU(e,t=420){if(/^[0-7]+$/.test(e))return parseInt(e,8);let n=t&4095,r=e.split(`,`);for(let t of r){let r=t.match(/^([ugoa]*)([+\-=])([rwxXst]*)$/);if(!r)throw Error(`Invalid mode: ${e}`);let i=r[1]||`a`,a=r[2],o=r[3];(i===`a`||i===``)&&(i=`ugo`);let s=0;o.includes(`r`)&&(s|=4),o.includes(`w`)&&(s|=2),(o.includes(`x`)||o.includes(`X`))&&(s|=1);let c=0;o.includes(`s`)&&(i.includes(`u`)&&(c|=2048),i.includes(`g`)&&(c|=1024)),o.includes(`t`)&&(c|=512);for(let e of i){let t=0;e===`u`?t=6:e===`g`?t=3:e===`o`&&(t=0);let r=s<{cH(),iV(),OH(),cV(),AU={name:`chmod`,summary:`change file mode bits`,usage:`chmod [OPTIONS] MODE FILE...`,options:[`-R change files recursively`,`-v output a diagnostic for every file processed`,` --help display this help and exit`]},jU={name:`chmod`,async execute(e,t){if(oV(e))return aV(AU);if(e.length<2)return{stdout:``,stderr:`chmod: missing operand `,exitCode:1};let n=!1,r=!1,i=0;for(;iFU,pwdCommand:()=>PU});var PU,FU,Hbe=B(()=>{PU={name:`pwd`,async execute(e,t){let n=!1;for(let t of e)if(t===`-P`)n=!0;else if(t===`-L`)n=!1;else{if(t===`--`)break;t.startsWith(`-`)}let r=t.cwd;if(n)try{r=await t.fs.realpath(t.cwd)}catch{}return{stdout:`${r} `,stderr:``,exitCode:0}}},FU={name:`pwd`,flags:[{flag:`-P`,type:`boolean`},{flag:`-L`,type:`boolean`}]}}),IU={};Tz(IU,{flagsForFuzzing:()=>zU,readlinkCommand:()=>RU});var LU,RU,zU,Ube=B(()=>{OH(),U(),cV(),LU={name:`readlink`,summary:`print resolved symbolic links or canonical file names`,usage:`readlink [OPTIONS] FILE...`,options:[`-f canonicalize by following every symlink in every component of the given name recursively`,` --help display this help and exit`]},RU={name:`readlink`,async execute(e,t){if(oV(e))return aV(LU);let n=!1,r=0;for(;re.limits.maxArrayElements)throw new H(`${n}: file operand limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);if(o.length===0)return{stdout:r(e.stdin),stderr:``,exitCode:0,stdoutEncoding:`binary`};let s=Math.min(e.limits.maxOutputSize,e.limits.maxStringLength),c=new sH(s,n),l=new sH(s,n),u=0,d=0,f=a||!i&&o.length>1,p=0;for(let t=0;te.limits.maxInputBytes-d)throw new H(`${n}: aggregate input size limit exceeded (${e.limits.maxInputBytes} bytes)`,`string_length`);let a=await SB(e.fs,t);if(a.length>e.limits.maxInputBytes-d)throw new H(`${n}: aggregate input size limit exceeded (${e.limits.maxInputBytes} bytes)`,`string_length`);d+=a.length,e.executionScope?.consumeInput(a.length,n),f&&(p>0&&c.append(` `),c.append(bB(`==> ${i} <== `))),c.append(r(a)),p++}catch(e){rV(e),l.append(`${n}: ${i}: No such file or directory `),u=1}}return{stdout:c.build(),stderr:l.build(),exitCode:u,stdoutEncoding:`binary`}}function Wbe(e,t,n){if(n!==null)return e.slice(0,n);if(t===0)return``;let r=0,i=0,a=e.length;for(;r0?e.slice(0,r):``}function Gbe(e,t,n,r){if(n!==null)return n===0?``:e.slice(-n);let i=e.length;if(i===0)return``;if(r){let n=0,r=1;for(;n=0&&o{cH(),AB(),iV(),U(),cV()}),UU={};Tz(UU,{flagsForFuzzing:()=>KU,headCommand:()=>GU});var WU,GU,KU,Kbe=B(()=>{cV(),HU(),WU={name:`head`,summary:`output the first part of files`,usage:`head [OPTION]... [FILE]...`,options:[`-c, --bytes=NUM print the first NUM bytes`,`-n, --lines=NUM print the first NUM lines (default 10)`,`-q, --quiet never print headers giving file names`,`-v, --verbose always print headers giving file names`,` --help display this help and exit`]},GU={name:`head`,async execute(e,t){if(oV(e))return aV(WU);let n=BU(e,`head`);if(!n.ok)return n.error;let{lines:r,bytes:i}=n.options;return VU(t,n.options,`head`,e=>Wbe(e,r,i))}},KU={name:`head`,flags:[{flag:`-n`,type:`value`,valueHint:`number`},{flag:`-c`,type:`value`,valueHint:`number`},{flag:`-q`,type:`boolean`},{flag:`-v`,type:`boolean`}],stdinType:`text`,needsFiles:!0}}),qU={};Tz(qU,{flagsForFuzzing:()=>XU,tailCommand:()=>YU});var JU,YU,XU,qbe=B(()=>{HU(),cV(),JU={name:`tail`,summary:`output the last part of files`,usage:`tail [OPTION]... [FILE]...`,options:[`-c, --bytes=NUM print the last NUM bytes`,`-n, --lines=NUM print the last NUM lines (default 10)`,`-n +NUM print starting from line NUM`,`-q, --quiet never print headers giving file names`,`-v, --verbose always print headers giving file names`,` --help display this help and exit`]},YU={name:`tail`,async execute(e,t){if(oV(e))return aV(JU);let n=BU(e,`tail`);if(!n.ok)return n.error;let{lines:r,bytes:i,fromLine:a}=n.options;return VU(t,n.options,`tail`,e=>Gbe(e,r,i,a??!1))}},XU={name:`tail`,flags:[{flag:`-n`,type:`value`,valueHint:`number`},{flag:`-c`,type:`value`,valueHint:`number`},{flag:`-q`,type:`boolean`},{flag:`-v`,type:`boolean`}],stdinType:`text`,needsFiles:!0}}),ZU={};Tz(ZU,{flagsForFuzzing:()=>rW,wcCommand:()=>nW});function QU(e,t){let n=e,r=n.length,i=t?Array.from(yB(e)).length:r,a=0,o=0,s=!1;for(let e=0;e{AB(),uV(),hV(),cV(),eW={name:`wc`,summary:`print newline, word, and byte counts for each file`,usage:`wc [OPTION]... [FILE]...`,options:[`-c, --bytes print the byte counts`,`-m, --chars print the character counts`,`-l, --lines print the newline counts`,`-w, --words print the word counts`,` --help display this help and exit`]},tW={lines:{short:`l`,long:`lines`,type:`boolean`},words:{short:`w`,long:`words`,type:`boolean`},bytes:{short:`c`,long:`bytes`,type:`boolean`},chars:{short:`m`,long:`chars`,type:`boolean`}},nW={name:`wc`,async execute(e,t){if(oV(e))return aV(eW);let n=lV(`wc`,e,tW);if(!n.ok)return n.error;let{lines:r,words:i}=n.result.flags,a=n.result.flags.bytes,o=n.result.flags.chars,s=n.result.positional;!r&&!i&&!a&&!o&&(r=i=a=!0);let c=a||o,l=await pV(t,s,{cmdName:`wc`,stopOnError:!1});if(s.length===0)return{stdout:`${$U(QU(l.files[0].content,o),r,i,c,``,0)} `,stderr:``,exitCode:0};let u=[],d=0,f=0,p=0;for(let{filename:e,content:t}of l.files){let n=QU(t,o);d+=n.lines,f+=n.words,p+=n.third,u.push({filename:e,stats:n})}let m=s.length>1?d:Math.max(...u.map(e=>e.stats.lines)),h=s.length>1?f:Math.max(...u.map(e=>e.stats.words)),g=s.length>1?p:Math.max(...u.map(e=>e.stats.third)),_=s.length>1?3:0;r&&(_=Math.max(_,String(m).length)),i&&(_=Math.max(_,String(h).length)),c&&(_=Math.max(_,String(g).length));let v=``;for(let{filename:e,stats:t}of u)v+=`${$U(t,r,i,c,e,_)} `;return s.length>1&&(v+=`${$U({lines:d,words:f,third:p},r,i,c,`total`,_)} `),{stdout:v,stderr:l.stderr,exitCode:l.exitCode}}},rW={name:`wc`,flags:[{flag:`-l`,type:`boolean`},{flag:`-w`,type:`boolean`},{flag:`-c`,type:`boolean`},{flag:`-m`,type:`boolean`}],stdinType:`text`,needsFiles:!0}});function iW(e,t){return(t?`d`:`-`)+[e&256?`r`:`-`,e&128?`w`:`-`,e&64?`x`:`-`,e&32?`r`:`-`,e&16?`w`:`-`,e&8?`x`:`-`,e&4?`r`:`-`,e&2?`w`:`-`,e&1?`x`:`-`].join(``)}var aW=B(()=>{}),oW={};Tz(oW,{flagsForFuzzing:()=>uW,statCommand:()=>lW});var sW,cW,lW,uW,Ybe=B(()=>{AB(),iV(),U(),uV(),aW(),cV(),sW={name:`stat`,summary:`display file or file system status`,usage:`stat [OPTION]... FILE...`,options:[`-c FORMAT use the specified FORMAT instead of the default`,` --help display this help and exit`]},cW={format:{short:`c`,type:`string`}},lW={name:`stat`,async execute(e,t){if(oV(e))return aV(sW);let n=lV(`stat`,e,cW);if(!n.ok)return n.error;let r=n.result.flags.format??null,i=n.result.positional;if(i.length===0)return{stdout:``,stderr:`stat: missing operand `,exitCode:1};let a=``,o=``,s=!1,c=0,l=Math.min(t.limits.maxOutputSize,t.limits.maxStringLength),u=e=>{let t=V(e);if(t>l-c)throw new H(`stat: output size limit exceeded (${l} bytes)`,`output_size`);a+=e,c+=t};for(let e of i){let n=t.fs.resolvePath(t.cwd,e);try{let i=await t.fs.stat(n);if(r){let t=i.mode.toString(8),n=iW(i.mode,i.isDirectory),a=new Map([[`%n`,e],[`%N`,`'${e}'`],[`%s`,String(i.size)],[`%F`,i.isDirectory?`directory`:`regular file`],[`%a`,t],[`%A`,n],[`%u`,`1000`],[`%U`,`user`],[`%g`,`1000`],[`%G`,`group`]]);u(`${r.replace(/%[nNsFaAuUgG]/g,e=>a.get(e)??e)} `)}else{let t=i.mode.toString(8).padStart(4,`0`),n=iW(i.mode,i.isDirectory);u(` File: ${e} Size: ${i.size} Blocks: ${Math.ceil(i.size/512)} Access: (${t}/${n}) Modify: ${i.mtime.toISOString()} `)}}catch(t){rV(t),o+=`stat: cannot stat '${e}': No such file or directory `,s=!0}}return{stdout:a,stderr:o,exitCode:+!!s}}},uW={name:`stat`,flags:[{flag:`-c`,type:`value`,valueHint:`format`},{flag:`-L`,type:`boolean`}],needsArgs:!0}}),W,G,K,dW,fW,pW,mW,hW,gW,_W,vW,yW,bW,xW,SW,CW,wW,TW,EW,DW,OW,kW,AW,jW,MW,NW,PW,FW,IW,q,LW,RW,zW,BW,VW,HW,UW,WW,GW,KW,qW,JW,YW,XW,ZW,QW,$W,eG,tG,nG,rG,iG,aG,oG,sG,cG,lG,uG,dG,fG,pG,mG,Xbe=B(()=>{W=class e{static FOLD_CASE=1;static LITERAL=2;static CLASS_NL=4;static DOT_NL=8;static ONE_LINE=16;static NON_GREEDY=32;static PERL_X=64;static UNICODE_GROUPS=128;static WAS_DOLLAR=256;static MATCH_NL=e.CLASS_NL|e.DOT_NL;static PERL=e.CLASS_NL|e.ONE_LINE|e.PERL_X|e.UNICODE_GROUPS;static POSIX=0;static UNANCHORED=0;static ANCHOR_START=1;static ANCHOR_BOTH=2},G=class{static CODES=new Map([[`\x07`,7],[`\b`,8],[` `,9],[` `,10],[`\v`,11],[`\f`,12],[`\r`,13],[` `,32],[`"`,34],[`$`,36],[`&`,38],[`(`,40],[`)`,41],[`*`,42],[`+`,43],[`-`,45],[`.`,46],[`0`,48],[`1`,49],[`2`,50],[`3`,51],[`4`,52],[`5`,53],[`6`,54],[`7`,55],[`8`,56],[`9`,57],[`:`,58],[`<`,60],[`>`,62],[`?`,63],[`A`,65],[`B`,66],[`C`,67],[`F`,70],[`P`,80],[`Q`,81],[`U`,85],[`Z`,90],[`[`,91],[`\\`,92],[`]`,93],[`^`,94],[`_`,95],[`a`,97],[`b`,98],[`f`,102],[`i`,105],[`m`,109],[`n`,110],[`r`,114],[`s`,115],[`t`,116],[`v`,118],[`x`,120],[`z`,122],[`{`,123],[`|`,124],[`}`,125]]);static toUpperCase(e){let t=String.fromCodePoint(e).toUpperCase();if(t.length>1)return e;let n=String.fromCodePoint(t.codePointAt(0)).toLowerCase();return n.length>1||n.codePointAt(0)!==e?e:t.codePointAt(0)}static toLowerCase(e){let t=String.fromCodePoint(e).toLowerCase();if(t.length>1)return e;let n=String.fromCodePoint(t.codePointAt(0)).toUpperCase();return n.length>1||n.codePointAt(0)!==e?e:t.codePointAt(0)}},K=class{SIZE=3;constructor(e){this.data=e}getLo(e){return this.data[e*this.SIZE]}getHi(e){return this.data[e*this.SIZE+1]}getStride(e){return this.data[e*this.SIZE+2]}get(e){let t=e*this.SIZE;return[this.data[t],this.data[t+1],this.data[t+2]]}get length(){return this.data.length/this.SIZE}},dW=class e{static CASE_ORBIT=new Map([[75,107],[107,8490],[8490,75],[83,115],[115,383],[383,83],[181,924],[924,956],[956,181],[197,229],[229,8491],[8491,197],[452,453],[453,454],[454,452],[455,456],[456,457],[457,455],[458,459],[459,460],[460,458],[497,498],[498,499],[499,497],[837,921],[921,953],[953,8126],[8126,837],[914,946],[946,976],[976,914],[917,949],[949,1013],[1013,917],[920,952],[952,977],[977,1012],[1012,920],[922,954],[954,1008],[1008,922],[928,960],[960,982],[982,928],[929,961],[961,1009],[1009,929],[931,962],[962,963],[963,931],[934,966],[966,981],[981,934],[937,969],[969,8486],[8486,937],[1042,1074],[1074,7296],[7296,1042],[1044,1076],[1076,7297],[7297,1044],[1054,1086],[1086,7298],[7298,1054],[1057,1089],[1089,7299],[7299,1057],[1058,1090],[1090,7300],[7300,7301],[7301,1058],[1066,1098],[1098,7302],[7302,1066],[1122,1123],[1123,7303],[7303,1122],[7304,42570],[42570,42571],[42571,7304],[7776,7777],[7777,7835],[7835,7776],[223,7838],[7838,223],[8064,8072],[8072,8064],[8065,8073],[8073,8065],[8066,8074],[8074,8066],[8067,8075],[8075,8067],[8068,8076],[8076,8068],[8069,8077],[8077,8069],[8070,8078],[8078,8070],[8071,8079],[8079,8071],[8080,8088],[8088,8080],[8081,8089],[8089,8081],[8082,8090],[8090,8082],[8083,8091],[8091,8083],[8084,8092],[8092,8084],[8085,8093],[8093,8085],[8086,8094],[8094,8086],[8087,8095],[8095,8087],[8096,8104],[8104,8096],[8097,8105],[8105,8097],[8098,8106],[8106,8098],[8099,8107],[8107,8099],[8100,8108],[8108,8100],[8101,8109],[8109,8101],[8102,8110],[8110,8102],[8103,8111],[8111,8103],[8115,8124],[8124,8115],[8131,8140],[8140,8131],[912,8147],[8147,912],[944,8163],[8163,944],[8179,8188],[8188,8179],[64261,64262],[64262,64261],[66560,66600],[66600,66560],[66561,66601],[66601,66561],[66562,66602],[66602,66562],[66563,66603],[66603,66563],[66564,66604],[66604,66564],[66565,66605],[66605,66565],[66566,66606],[66606,66566],[66567,66607],[66607,66567],[66568,66608],[66608,66568],[66569,66609],[66609,66569],[66570,66610],[66610,66570],[66571,66611],[66611,66571],[66572,66612],[66612,66572],[66573,66613],[66613,66573],[66574,66614],[66614,66574],[66575,66615],[66615,66575],[66576,66616],[66616,66576],[66577,66617],[66617,66577],[66578,66618],[66618,66578],[66579,66619],[66619,66579],[66580,66620],[66620,66580],[66581,66621],[66621,66581],[66582,66622],[66622,66582],[66583,66623],[66623,66583],[66584,66624],[66624,66584],[66585,66625],[66625,66585],[66586,66626],[66626,66586],[66587,66627],[66627,66587],[66588,66628],[66628,66588],[66589,66629],[66629,66589],[66590,66630],[66630,66590],[66591,66631],[66631,66591],[66592,66632],[66632,66592],[66593,66633],[66633,66593],[66594,66634],[66634,66594],[66595,66635],[66635,66595],[66596,66636],[66636,66596],[66597,66637],[66637,66597],[66598,66638],[66638,66598],[66599,66639],[66639,66599],[66736,66776],[66776,66736],[66737,66777],[66777,66737],[66738,66778],[66778,66738],[66739,66779],[66779,66739],[66740,66780],[66780,66740],[66741,66781],[66781,66741],[66742,66782],[66782,66742],[66743,66783],[66783,66743],[66744,66784],[66784,66744],[66745,66785],[66785,66745],[66746,66786],[66786,66746],[66747,66787],[66787,66747],[66748,66788],[66788,66748],[66749,66789],[66789,66749],[66750,66790],[66790,66750],[66751,66791],[66791,66751],[66752,66792],[66792,66752],[66753,66793],[66793,66753],[66754,66794],[66794,66754],[66755,66795],[66795,66755],[66756,66796],[66796,66756],[66757,66797],[66797,66757],[66758,66798],[66798,66758],[66759,66799],[66799,66759],[66760,66800],[66800,66760],[66761,66801],[66801,66761],[66762,66802],[66802,66762],[66763,66803],[66803,66763],[66764,66804],[66804,66764],[66765,66805],[66805,66765],[66766,66806],[66806,66766],[66767,66807],[66807,66767],[66768,66808],[66808,66768],[66769,66809],[66809,66769],[66770,66810],[66810,66770],[66771,66811],[66811,66771],[66928,66967],[66967,66928],[66929,66968],[66968,66929],[66930,66969],[66969,66930],[66931,66970],[66970,66931],[66932,66971],[66971,66932],[66933,66972],[66972,66933],[66934,66973],[66973,66934],[66935,66974],[66974,66935],[66936,66975],[66975,66936],[66937,66976],[66976,66937],[66938,66977],[66977,66938],[66940,66979],[66979,66940],[66941,66980],[66980,66941],[66942,66981],[66981,66942],[66943,66982],[66982,66943],[66944,66983],[66983,66944],[66945,66984],[66984,66945],[66946,66985],[66985,66946],[66947,66986],[66986,66947],[66948,66987],[66987,66948],[66949,66988],[66988,66949],[66950,66989],[66989,66950],[66951,66990],[66990,66951],[66952,66991],[66991,66952],[66953,66992],[66992,66953],[66954,66993],[66993,66954],[66956,66995],[66995,66956],[66957,66996],[66996,66957],[66958,66997],[66997,66958],[66959,66998],[66998,66959],[66960,66999],[66999,66960],[66961,67e3],[67e3,66961],[66962,67001],[67001,66962],[66964,67003],[67003,66964],[66965,67004],[67004,66965],[68736,68800],[68800,68736],[68737,68801],[68801,68737],[68738,68802],[68802,68738],[68739,68803],[68803,68739],[68740,68804],[68804,68740],[68741,68805],[68805,68741],[68742,68806],[68806,68742],[68743,68807],[68807,68743],[68744,68808],[68808,68744],[68745,68809],[68809,68745],[68746,68810],[68810,68746],[68747,68811],[68811,68747],[68748,68812],[68812,68748],[68749,68813],[68813,68749],[68750,68814],[68814,68750],[68751,68815],[68815,68751],[68752,68816],[68816,68752],[68753,68817],[68817,68753],[68754,68818],[68818,68754],[68755,68819],[68819,68755],[68756,68820],[68820,68756],[68757,68821],[68821,68757],[68758,68822],[68822,68758],[68759,68823],[68823,68759],[68760,68824],[68824,68760],[68761,68825],[68825,68761],[68762,68826],[68826,68762],[68763,68827],[68827,68763],[68764,68828],[68828,68764],[68765,68829],[68829,68765],[68766,68830],[68830,68766],[68767,68831],[68831,68767],[68768,68832],[68832,68768],[68769,68833],[68833,68769],[68770,68834],[68834,68770],[68771,68835],[68835,68771],[68772,68836],[68836,68772],[68773,68837],[68837,68773],[68774,68838],[68838,68774],[68775,68839],[68839,68775],[68776,68840],[68840,68776],[68777,68841],[68841,68777],[68778,68842],[68842,68778],[68779,68843],[68843,68779],[68780,68844],[68844,68780],[68781,68845],[68845,68781],[68782,68846],[68846,68782],[68783,68847],[68847,68783],[68784,68848],[68848,68784],[68785,68849],[68849,68785],[68786,68850],[68850,68786],[68944,68976],[68976,68944],[68945,68977],[68977,68945],[68946,68978],[68978,68946],[68947,68979],[68979,68947],[68948,68980],[68980,68948],[68949,68981],[68981,68949],[68950,68982],[68982,68950],[68951,68983],[68983,68951],[68952,68984],[68984,68952],[68953,68985],[68985,68953],[68954,68986],[68986,68954],[68955,68987],[68987,68955],[68956,68988],[68988,68956],[68957,68989],[68989,68957],[68958,68990],[68990,68958],[68959,68991],[68991,68959],[68960,68992],[68992,68960],[68961,68993],[68993,68961],[68962,68994],[68994,68962],[68963,68995],[68995,68963],[68964,68996],[68996,68964],[68965,68997],[68997,68965],[71840,71872],[71872,71840],[71841,71873],[71873,71841],[71842,71874],[71874,71842],[71843,71875],[71875,71843],[71844,71876],[71876,71844],[71845,71877],[71877,71845],[71846,71878],[71878,71846],[71847,71879],[71879,71847],[71848,71880],[71880,71848],[71849,71881],[71881,71849],[71850,71882],[71882,71850],[71851,71883],[71883,71851],[71852,71884],[71884,71852],[71853,71885],[71885,71853],[71854,71886],[71886,71854],[71855,71887],[71887,71855],[71856,71888],[71888,71856],[71857,71889],[71889,71857],[71858,71890],[71890,71858],[71859,71891],[71891,71859],[71860,71892],[71892,71860],[71861,71893],[71893,71861],[71862,71894],[71894,71862],[71863,71895],[71895,71863],[71864,71896],[71896,71864],[71865,71897],[71897,71865],[71866,71898],[71898,71866],[71867,71899],[71899,71867],[71868,71900],[71900,71868],[71869,71901],[71901,71869],[71870,71902],[71902,71870],[71871,71903],[71903,71871],[93760,93792],[93792,93760],[93761,93793],[93793,93761],[93762,93794],[93794,93762],[93763,93795],[93795,93763],[93764,93796],[93796,93764],[93765,93797],[93797,93765],[93766,93798],[93798,93766],[93767,93799],[93799,93767],[93768,93800],[93800,93768],[93769,93801],[93801,93769],[93770,93802],[93802,93770],[93771,93803],[93803,93771],[93772,93804],[93804,93772],[93773,93805],[93805,93773],[93774,93806],[93806,93774],[93775,93807],[93807,93775],[93776,93808],[93808,93776],[93777,93809],[93809,93777],[93778,93810],[93810,93778],[93779,93811],[93811,93779],[93780,93812],[93812,93780],[93781,93813],[93813,93781],[93782,93814],[93814,93782],[93783,93815],[93815,93783],[93784,93816],[93816,93784],[93785,93817],[93817,93785],[93786,93818],[93818,93786],[93787,93819],[93819,93787],[93788,93820],[93820,93788],[93789,93821],[93821,93789],[93790,93822],[93822,93790],[93791,93823],[93823,93791],[125184,125218],[125218,125184],[125185,125219],[125219,125185],[125186,125220],[125220,125186],[125187,125221],[125221,125187],[125188,125222],[125222,125188],[125189,125223],[125223,125189],[125190,125224],[125224,125190],[125191,125225],[125225,125191],[125192,125226],[125226,125192],[125193,125227],[125227,125193],[125194,125228],[125228,125194],[125195,125229],[125229,125195],[125196,125230],[125230,125196],[125197,125231],[125231,125197],[125198,125232],[125232,125198],[125199,125233],[125233,125199],[125200,125234],[125234,125200],[125201,125235],[125235,125201],[125202,125236],[125236,125202],[125203,125237],[125237,125203],[125204,125238],[125238,125204],[125205,125239],[125239,125205],[125206,125240],[125240,125206],[125207,125241],[125241,125207],[125208,125242],[125242,125208],[125209,125243],[125243,125209],[125210,125244],[125244,125210],[125211,125245],[125245,125211],[125212,125246],[125246,125212],[125213,125247],[125247,125213],[125214,125248],[125248,125214],[125215,125249],[125249,125215],[125216,125250],[125250,125216],[125217,125251],[125251,125217]]);static C=new K(new Uint32Array([0,31,1,127,159,1,173,888,715,889,896,7,897,899,1,907,909,2,930,1328,398,1367,1368,1,1419,1420,1,1424,1480,56,1481,1487,1,1515,1518,1,1525,1541,1,1564,1757,193,1806,1807,1,1867,1868,1,1970,1983,1,2043,2044,1,2094,2095,1,2111,2140,29,2141,2143,2,2155,2159,1,2191,2198,1,2274,2436,162,2445,2446,1,2449,2450,1,2473,2481,8,2483,2485,1,2490,2491,1,2501,2502,1,2505,2506,1,2511,2518,1,2520,2523,1,2526,2532,6,2533,2559,26,2560,2564,4,2571,2574,1,2577,2578,1,2601,2609,8,2612,2618,3,2619,2621,2,2627,2630,1,2633,2634,1,2638,2640,1,2642,2648,1,2653,2655,2,2656,2661,1,2679,2688,1,2692,2702,10,2706,2729,23,2737,2740,3,2746,2747,1,2758,2766,4,2767,2769,2,2770,2783,1,2788,2789,1,2802,2808,1,2816,2820,4,2829,2830,1,2833,2834,1,2857,2865,8,2868,2874,6,2875,2885,10,2886,2889,3,2890,2894,4,2895,2900,1,2904,2907,1,2910,2916,6,2917,2936,19,2937,2945,1,2948,2955,7,2956,2957,1,2961,2966,5,2967,2968,1,2971,2973,2,2976,2978,1,2981,2983,1,2987,2989,1,3002,3005,1,3011,3013,1,3017,3022,5,3023,3025,2,3026,3030,1,3032,3045,1,3067,3071,1,3085,3089,4,3113,3130,17,3131,3141,10,3145,3150,5,3151,3156,1,3159,3163,4,3164,3166,2,3167,3172,5,3173,3184,11,3185,3190,1,3213,3217,4,3241,3252,11,3258,3259,1,3269,3273,4,3278,3284,1,3287,3292,1,3295,3300,5,3301,3312,11,3316,3327,1,3341,3345,4,3397,3401,4,3408,3411,1,3428,3429,1,3456,3460,4,3479,3481,1,3506,3516,10,3518,3519,1,3527,3529,1,3531,3534,1,3541,3543,2,3552,3557,1,3568,3569,1,3573,3584,1,3643,3646,1,3676,3712,1,3715,3717,2,3723,3748,25,3750,3774,24,3775,3781,6,3783,3791,8,3802,3803,1,3808,3839,1,3912,3949,37,3950,3952,1,3992,4029,37,4045,4059,14,4060,4095,1,4294,4296,2,4297,4300,1,4302,4303,1,4681,4686,5,4687,4695,8,4697,4702,5,4703,4745,42,4750,4751,1,4785,4790,5,4791,4799,8,4801,4806,5,4807,4823,16,4881,4886,5,4887,4955,68,4956,4989,33,4990,4991,1,5018,5023,1,5110,5111,1,5118,5119,1,5789,5791,1,5881,5887,1,5910,5918,1,5943,5951,1,5972,5983,1,5997,6001,4,6004,6015,1,6110,6111,1,6122,6127,1,6138,6143,1,6158,6170,12,6171,6175,1,6265,6271,1,6315,6319,1,6390,6399,1,6431,6444,13,6445,6447,1,6460,6463,1,6465,6467,1,6510,6511,1,6517,6527,1,6572,6575,1,6602,6607,1,6619,6621,1,6684,6685,1,6751,6781,30,6782,6794,12,6795,6799,1,6810,6815,1,6830,6831,1,6863,6911,1,6989,7156,167,7157,7163,1,7224,7226,1,7242,7244,1,7307,7311,1,7355,7356,1,7368,7375,1,7419,7423,1,7958,7959,1,7966,7967,1,8006,8007,1,8014,8015,1,8024,8030,2,8062,8063,1,8117,8133,16,8148,8149,1,8156,8176,20,8177,8181,4,8191,8203,12,8204,8207,1,8234,8238,1,8288,8303,1,8306,8307,1,8335,8349,14,8350,8351,1,8385,8399,1,8433,8447,1,8588,8591,1,9258,9279,1,9291,9311,1,11124,11125,1,11158,11508,350,11509,11512,1,11558,11560,2,11561,11564,1,11566,11567,1,11624,11630,1,11633,11646,1,11671,11679,1,11687,11743,8,11870,11903,1,11930,12020,90,12021,12031,1,12246,12271,1,12352,12439,87,12440,12544,104,12545,12548,1,12592,12687,95,12774,12782,1,12831,42125,29294,42126,42127,1,42183,42191,1,42540,42559,1,42744,42751,1,42958,42959,1,42962,42964,2,42973,42993,1,43053,43055,1,43066,43071,1,43128,43135,1,43206,43213,1,43226,43231,1,43348,43358,1,43389,43391,1,43470,43482,12,43483,43485,1,43519,43575,56,43576,43583,1,43598,43599,1,43610,43611,1,43715,43738,1,43767,43776,1,43783,43784,1,43791,43792,1,43799,43807,1,43815,43823,8,43884,43887,1,44014,44015,1,44026,44031,1,55204,55215,1,55239,55242,1,55292,63743,1,64110,64111,1,64218,64255,1,64263,64274,1,64280,64284,1,64311,64317,6,64319,64325,3,64451,64466,1,64912,64913,1,64968,64974,1,64976,65007,1,65050,65055,1,65107,65127,20,65132,65135,1,65141,65277,136,65278,65280,1,65471,65473,1,65480,65481,1,65488,65489,1,65496,65497,1,65501,65503,1,65511,65519,8,65520,65531,1,65534,65535,1,65548,65575,27,65595,65598,3,65614,65615,1,65630,65663,1,65787,65791,1,65795,65798,1,65844,65846,1,65935,65949,14,65950,65951,1,65953,65999,1,66046,66175,1,66205,66207,1,66257,66271,1,66300,66303,1,66340,66348,1,66379,66383,1,66427,66431,1,66462,66500,38,66501,66503,1,66518,66559,1,66718,66719,1,66730,66735,1,66772,66775,1,66812,66815,1,66856,66863,1,66916,66926,1,66939,66955,16,66963,66966,3,66978,66994,16,67002,67005,3,67006,67007,1,67060,67071,1,67383,67391,1,67414,67423,1,67432,67455,1,67462,67505,43,67515,67583,1,67590,67591,1,67593,67638,45,67641,67643,1,67645,67646,1,67670,67743,73,67744,67750,1,67760,67807,1,67827,67830,3,67831,67834,1,67868,67870,1,67898,67902,1,67904,67967,1,68024,68027,1,68048,68049,1,68100,68103,3,68104,68107,1,68116,68120,4,68150,68151,1,68155,68158,1,68169,68175,1,68185,68191,1,68256,68287,1,68327,68330,1,68343,68351,1,68406,68408,1,68438,68439,1,68467,68471,1,68498,68504,1,68509,68520,1,68528,68607,1,68681,68735,1,68787,68799,1,68851,68857,1,68904,68911,1,68922,68927,1,68966,68968,1,68998,69005,1,69008,69215,1,69247,69290,43,69294,69295,1,69298,69313,1,69317,69371,1,69416,69423,1,69466,69487,1,69514,69551,1,69580,69599,1,69623,69631,1,69710,69713,1,69750,69758,1,69821,69827,6,69828,69839,1,69865,69871,1,69882,69887,1,69941,69960,19,69961,69967,1,70007,70015,1,70112,70133,21,70134,70143,1,70162,70210,48,70211,70271,1,70279,70281,2,70286,70302,16,70314,70319,1,70379,70383,1,70394,70399,1,70404,70413,9,70414,70417,3,70418,70441,23,70449,70452,3,70458,70469,11,70470,70473,3,70474,70478,4,70479,70481,2,70482,70486,1,70488,70492,1,70500,70501,1,70509,70511,1,70517,70527,1,70538,70540,2,70541,70543,2,70582,70593,11,70595,70596,1,70598,70603,5,70614,70617,3,70618,70624,1,70627,70655,1,70748,70754,6,70755,70783,1,70856,70863,1,70874,71039,1,71094,71095,1,71134,71167,1,71237,71247,1,71258,71263,1,71277,71295,1,71354,71359,1,71370,71375,1,71396,71423,1,71451,71452,1,71468,71471,1,71495,71679,1,71740,71839,1,71923,71934,1,71943,71944,1,71946,71947,1,71956,71959,3,71990,71993,3,71994,72007,13,72008,72015,1,72026,72095,1,72104,72105,1,72152,72153,1,72165,72191,1,72264,72271,1,72355,72367,1,72441,72447,1,72458,72639,1,72674,72687,1,72698,72703,1,72713,72759,46,72774,72783,1,72813,72815,1,72848,72849,1,72872,72887,15,72888,72959,1,72967,72970,3,73015,73017,1,73019,73022,3,73032,73039,1,73050,73055,1,73062,73065,3,73103,73106,3,73113,73119,1,73130,73439,1,73465,73471,1,73489,73531,42,73532,73533,1,73563,73647,1,73649,73663,1,73714,73726,1,74650,74751,1,74863,74869,6,74870,74879,1,75076,77711,1,77811,77823,1,78896,78911,1,78934,78943,1,82939,82943,1,83527,90367,1,90426,92159,1,92729,92735,1,92767,92778,11,92779,92781,1,92863,92874,11,92875,92879,1,92910,92911,1,92918,92927,1,92998,93007,1,93018,93026,8,93048,93052,1,93072,93503,1,93562,93759,1,93851,93951,1,94027,94030,1,94088,94094,1,94112,94175,1,94181,94191,1,94194,94207,1,100344,100351,1,101590,101630,1,101641,110575,1,110580,110588,8,110591,110883,292,110884,110897,1,110899,110927,1,110931,110932,1,110934,110947,1,110952,110959,1,111356,113663,1,113771,113775,1,113789,113791,1,113801,113807,1,113818,113819,1,113824,117759,1,118010,118015,1,118452,118527,1,118574,118575,1,118599,118607,1,118724,118783,1,119030,119039,1,119079,119080,1,119155,119162,1,119275,119295,1,119366,119487,1,119508,119519,1,119540,119551,1,119639,119647,1,119673,119807,1,119893,119965,72,119968,119969,1,119971,119972,1,119975,119976,1,119981,119994,13,119996,120004,8,120070,120075,5,120076,120085,9,120093,120122,29,120127,120133,6,120135,120137,1,120145,120486,341,120487,120780,293,120781,121484,703,121485,121498,1,121504,121520,16,121521,122623,1,122655,122660,1,122667,122879,1,122887,122905,18,122906,122914,8,122917,122923,6,122924,122927,1,122990,123022,1,123024,123135,1,123181,123183,1,123198,123199,1,123210,123213,1,123216,123535,1,123567,123583,1,123642,123646,1,123648,124111,1,124154,124367,1,124411,124414,1,124416,124895,1,124903,124908,5,124911,124927,16,125125,125126,1,125143,125183,1,125260,125263,1,125274,125277,1,125280,126064,1,126133,126208,1,126270,126463,1,126468,126496,28,126499,126501,2,126502,126504,2,126515,126520,5,126522,126524,2,126525,126529,1,126531,126534,1,126536,126540,2,126544,126547,3,126549,126550,1,126552,126560,2,126563,126565,2,126566,126571,5,126579,126589,5,126591,126602,11,126620,126624,1,126628,126634,6,126652,126703,1,126706,126975,1,127020,127023,1,127124,127135,1,127151,127152,1,127168,127184,16,127222,127231,1,127406,127461,1,127491,127503,1,127548,127551,1,127561,127567,1,127570,127583,1,127590,127743,1,128728,128731,1,128749,128751,1,128765,128767,1,128887,128890,1,128986,128991,1,129004,129007,1,129009,129023,1,129036,129039,1,129096,129103,1,129114,129119,1,129160,129167,1,129198,129199,1,129212,129215,1,129218,129279,1,129620,129631,1,129646,129647,1,129661,129663,1,129674,129678,1,129735,129741,1,129757,129758,1,129770,129775,1,129785,129791,1,129939,130042,103,130043,131071,1,173792,173823,1,177978,177983,1,178206,178207,1,183970,183983,1,191457,191471,1,192094,194559,1,195102,196607,1,201547,201551,1,205744,917759,1,918e3,1114111,1]));static Cc=new K(new Uint32Array([0,31,1,127,159,1]));static Cf=new K(new Uint32Array([173,1536,1363,1537,1541,1,1564,1757,193,1807,2192,385,2193,2274,81,6158,8203,2045,8204,8207,1,8234,8238,1,8288,8292,1,8294,8303,1,65279,65529,250,65530,65531,1,69821,69837,16,78896,78911,1,113824,113827,1,119155,119162,1,917505,917536,31,917537,917631,1]));static Co=new K(new Uint32Array([57344,63743,1,983040,1048573,1,1048576,1114109,1]));static Cs=new K(new Uint32Array([55296,57343,1]));static L=new K(new Uint32Array([65,90,1,97,122,1,170,181,11,186,192,6,193,214,1,216,246,1,248,705,1,710,721,1,736,740,1,748,750,2,880,884,1,886,887,1,890,893,1,895,902,7,904,906,1,908,910,2,911,929,1,931,1013,1,1015,1153,1,1162,1327,1,1329,1366,1,1369,1376,7,1377,1416,1,1488,1514,1,1519,1522,1,1568,1610,1,1646,1647,1,1649,1747,1,1749,1765,16,1766,1774,8,1775,1786,11,1787,1788,1,1791,1808,17,1810,1839,1,1869,1957,1,1969,1994,25,1995,2026,1,2036,2037,1,2042,2048,6,2049,2069,1,2074,2084,10,2088,2112,24,2113,2136,1,2144,2154,1,2160,2183,1,2185,2190,1,2208,2249,1,2308,2361,1,2365,2384,19,2392,2401,1,2417,2432,1,2437,2444,1,2447,2448,1,2451,2472,1,2474,2480,1,2482,2486,4,2487,2489,1,2493,2510,17,2524,2525,1,2527,2529,1,2544,2545,1,2556,2565,9,2566,2570,1,2575,2576,1,2579,2600,1,2602,2608,1,2610,2611,1,2613,2614,1,2616,2617,1,2649,2652,1,2654,2674,20,2675,2676,1,2693,2701,1,2703,2705,1,2707,2728,1,2730,2736,1,2738,2739,1,2741,2745,1,2749,2768,19,2784,2785,1,2809,2821,12,2822,2828,1,2831,2832,1,2835,2856,1,2858,2864,1,2866,2867,1,2869,2873,1,2877,2908,31,2909,2911,2,2912,2913,1,2929,2947,18,2949,2954,1,2958,2960,1,2962,2965,1,2969,2970,1,2972,2974,2,2975,2979,4,2980,2984,4,2985,2986,1,2990,3001,1,3024,3077,53,3078,3084,1,3086,3088,1,3090,3112,1,3114,3129,1,3133,3160,27,3161,3162,1,3165,3168,3,3169,3200,31,3205,3212,1,3214,3216,1,3218,3240,1,3242,3251,1,3253,3257,1,3261,3293,32,3294,3296,2,3297,3313,16,3314,3332,18,3333,3340,1,3342,3344,1,3346,3386,1,3389,3406,17,3412,3414,1,3423,3425,1,3450,3455,1,3461,3478,1,3482,3505,1,3507,3515,1,3517,3520,3,3521,3526,1,3585,3632,1,3634,3635,1,3648,3654,1,3713,3714,1,3716,3718,2,3719,3722,1,3724,3747,1,3749,3751,2,3752,3760,1,3762,3763,1,3773,3776,3,3777,3780,1,3782,3804,22,3805,3807,1,3840,3904,64,3905,3911,1,3913,3948,1,3976,3980,1,4096,4138,1,4159,4176,17,4177,4181,1,4186,4189,1,4193,4197,4,4198,4206,8,4207,4208,1,4213,4225,1,4238,4256,18,4257,4293,1,4295,4301,6,4304,4346,1,4348,4680,1,4682,4685,1,4688,4694,1,4696,4698,2,4699,4701,1,4704,4744,1,4746,4749,1,4752,4784,1,4786,4789,1,4792,4798,1,4800,4802,2,4803,4805,1,4808,4822,1,4824,4880,1,4882,4885,1,4888,4954,1,4992,5007,1,5024,5109,1,5112,5117,1,5121,5740,1,5743,5759,1,5761,5786,1,5792,5866,1,5873,5880,1,5888,5905,1,5919,5937,1,5952,5969,1,5984,5996,1,5998,6e3,1,6016,6067,1,6103,6108,5,6176,6264,1,6272,6276,1,6279,6312,1,6314,6320,6,6321,6389,1,6400,6430,1,6480,6509,1,6512,6516,1,6528,6571,1,6576,6601,1,6656,6678,1,6688,6740,1,6823,6917,94,6918,6963,1,6981,6988,1,7043,7072,1,7086,7087,1,7098,7141,1,7168,7203,1,7245,7247,1,7258,7293,1,7296,7306,1,7312,7354,1,7357,7359,1,7401,7404,1,7406,7411,1,7413,7414,1,7418,7424,6,7425,7615,1,7680,7957,1,7960,7965,1,7968,8005,1,8008,8013,1,8016,8023,1,8025,8031,2,8032,8061,1,8064,8116,1,8118,8124,1,8126,8130,4,8131,8132,1,8134,8140,1,8144,8147,1,8150,8155,1,8160,8172,1,8178,8180,1,8182,8188,1,8305,8319,14,8336,8348,1,8450,8455,5,8458,8467,1,8469,8473,4,8474,8477,1,8484,8490,2,8491,8493,1,8495,8505,1,8508,8511,1,8517,8521,1,8526,8579,53,8580,11264,2684,11265,11492,1,11499,11502,1,11506,11507,1,11520,11557,1,11559,11565,6,11568,11623,1,11631,11648,17,11649,11670,1,11680,11686,1,11688,11694,1,11696,11702,1,11704,11710,1,11712,11718,1,11720,11726,1,11728,11734,1,11736,11742,1,11823,12293,470,12294,12337,43,12338,12341,1,12347,12348,1,12353,12438,1,12445,12447,1,12449,12538,1,12540,12543,1,12549,12591,1,12593,12686,1,12704,12735,1,12784,12799,1,13312,19903,1,19968,42124,1,42192,42237,1,42240,42508,1,42512,42527,1,42538,42539,1,42560,42606,1,42623,42653,1,42656,42725,1,42775,42783,1,42786,42888,1,42891,42957,1,42960,42961,1,42963,42965,2,42966,42972,1,42994,43009,1,43011,43013,1,43015,43018,1,43020,43042,1,43072,43123,1,43138,43187,1,43250,43255,1,43259,43261,2,43262,43274,12,43275,43301,1,43312,43334,1,43360,43388,1,43396,43442,1,43471,43488,17,43489,43492,1,43494,43503,1,43514,43518,1,43520,43560,1,43584,43586,1,43588,43595,1,43616,43638,1,43642,43646,4,43647,43695,1,43697,43701,4,43702,43705,3,43706,43709,1,43712,43714,2,43739,43741,1,43744,43754,1,43762,43764,1,43777,43782,1,43785,43790,1,43793,43798,1,43808,43814,1,43816,43822,1,43824,43866,1,43868,43881,1,43888,44002,1,44032,55203,1,55216,55238,1,55243,55291,1,63744,64109,1,64112,64217,1,64256,64262,1,64275,64279,1,64285,64287,2,64288,64296,1,64298,64310,1,64312,64316,1,64318,64320,2,64321,64323,2,64324,64326,2,64327,64433,1,64467,64829,1,64848,64911,1,64914,64967,1,65008,65019,1,65136,65140,1,65142,65276,1,65313,65338,1,65345,65370,1,65382,65470,1,65474,65479,1,65482,65487,1,65490,65495,1,65498,65500,1,65536,65547,1,65549,65574,1,65576,65594,1,65596,65597,1,65599,65613,1,65616,65629,1,65664,65786,1,66176,66204,1,66208,66256,1,66304,66335,1,66349,66368,1,66370,66377,1,66384,66421,1,66432,66461,1,66464,66499,1,66504,66511,1,66560,66717,1,66736,66771,1,66776,66811,1,66816,66855,1,66864,66915,1,66928,66938,1,66940,66954,1,66956,66962,1,66964,66965,1,66967,66977,1,66979,66993,1,66995,67001,1,67003,67004,1,67008,67059,1,67072,67382,1,67392,67413,1,67424,67431,1,67456,67461,1,67463,67504,1,67506,67514,1,67584,67589,1,67592,67594,2,67595,67637,1,67639,67640,1,67644,67647,3,67648,67669,1,67680,67702,1,67712,67742,1,67808,67826,1,67828,67829,1,67840,67861,1,67872,67897,1,67968,68023,1,68030,68031,1,68096,68112,16,68113,68115,1,68117,68119,1,68121,68149,1,68192,68220,1,68224,68252,1,68288,68295,1,68297,68324,1,68352,68405,1,68416,68437,1,68448,68466,1,68480,68497,1,68608,68680,1,68736,68786,1,68800,68850,1,68864,68899,1,68938,68965,1,68975,68997,1,69248,69289,1,69296,69297,1,69314,69316,1,69376,69404,1,69415,69424,9,69425,69445,1,69488,69505,1,69552,69572,1,69600,69622,1,69635,69687,1,69745,69746,1,69749,69763,14,69764,69807,1,69840,69864,1,69891,69926,1,69956,69959,3,69968,70002,1,70006,70019,13,70020,70066,1,70081,70084,1,70106,70108,2,70144,70161,1,70163,70187,1,70207,70208,1,70272,70278,1,70280,70282,2,70283,70285,1,70287,70301,1,70303,70312,1,70320,70366,1,70405,70412,1,70415,70416,1,70419,70440,1,70442,70448,1,70450,70451,1,70453,70457,1,70461,70480,19,70493,70497,1,70528,70537,1,70539,70542,3,70544,70581,1,70583,70609,26,70611,70656,45,70657,70708,1,70727,70730,1,70751,70753,1,70784,70831,1,70852,70853,1,70855,71040,185,71041,71086,1,71128,71131,1,71168,71215,1,71236,71296,60,71297,71338,1,71352,71424,72,71425,71450,1,71488,71494,1,71680,71723,1,71840,71903,1,71935,71942,1,71945,71948,3,71949,71955,1,71957,71958,1,71960,71983,1,71999,72001,2,72096,72103,1,72106,72144,1,72161,72163,2,72192,72203,11,72204,72242,1,72250,72272,22,72284,72329,1,72349,72368,19,72369,72440,1,72640,72672,1,72704,72712,1,72714,72750,1,72768,72818,50,72819,72847,1,72960,72966,1,72968,72969,1,72971,73008,1,73030,73056,26,73057,73061,1,73063,73064,1,73066,73097,1,73112,73440,328,73441,73458,1,73474,73476,2,73477,73488,1,73490,73523,1,73648,73728,80,73729,74649,1,74880,75075,1,77712,77808,1,77824,78895,1,78913,78918,1,78944,82938,1,82944,83526,1,90368,90397,1,92160,92728,1,92736,92766,1,92784,92862,1,92880,92909,1,92928,92975,1,92992,92995,1,93027,93047,1,93053,93071,1,93504,93548,1,93760,93823,1,93952,94026,1,94032,94099,67,94100,94111,1,94176,94177,1,94179,94208,29,94209,100343,1,100352,101589,1,101631,101640,1,110576,110579,1,110581,110587,1,110589,110590,1,110592,110882,1,110898,110928,30,110929,110930,1,110933,110948,15,110949,110951,1,110960,111355,1,113664,113770,1,113776,113788,1,113792,113800,1,113808,113817,1,119808,119892,1,119894,119964,1,119966,119967,1,119970,119973,3,119974,119977,3,119978,119980,1,119982,119993,1,119995,119997,2,119998,120003,1,120005,120069,1,120071,120074,1,120077,120084,1,120086,120092,1,120094,120121,1,120123,120126,1,120128,120132,1,120134,120138,4,120139,120144,1,120146,120485,1,120488,120512,1,120514,120538,1,120540,120570,1,120572,120596,1,120598,120628,1,120630,120654,1,120656,120686,1,120688,120712,1,120714,120744,1,120746,120770,1,120772,120779,1,122624,122654,1,122661,122666,1,122928,122989,1,123136,123180,1,123191,123197,1,123214,123536,322,123537,123565,1,123584,123627,1,124112,124139,1,124368,124397,1,124400,124896,496,124897,124902,1,124904,124907,1,124909,124910,1,124912,124926,1,124928,125124,1,125184,125251,1,125259,126464,1205,126465,126467,1,126469,126495,1,126497,126498,1,126500,126503,3,126505,126514,1,126516,126519,1,126521,126523,2,126530,126535,5,126537,126541,2,126542,126543,1,126545,126546,1,126548,126551,3,126553,126561,2,126562,126564,2,126567,126570,1,126572,126578,1,126580,126583,1,126585,126588,1,126590,126592,2,126593,126601,1,126603,126619,1,126625,126627,1,126629,126633,1,126635,126651,1,131072,173791,1,173824,177977,1,177984,178205,1,178208,183969,1,183984,191456,1,191472,192093,1,194560,195101,1,196608,201546,1,201552,205743,1]));static foldL=new K(new Uint32Array([837,837,1]));static Ll=new K(new Uint32Array([97,122,1,181,223,42,224,246,1,248,255,1,257,311,2,312,328,2,329,375,2,378,382,2,383,384,1,387,389,2,392,396,4,397,402,5,405,409,4,410,411,1,414,417,3,419,421,2,424,426,2,427,429,2,432,436,4,438,441,3,442,445,3,446,447,1,454,460,3,462,476,2,477,495,2,496,499,3,501,505,4,507,563,2,564,569,1,572,575,3,576,578,2,583,591,2,592,659,1,661,687,1,881,883,2,887,891,4,892,893,1,912,940,28,941,974,1,976,977,1,981,983,1,985,1007,2,1008,1011,1,1013,1019,3,1020,1072,52,1073,1119,1,1121,1153,2,1163,1215,2,1218,1230,2,1231,1327,2,1376,1416,1,4304,4346,1,4349,4351,1,5112,5117,1,7296,7304,1,7306,7424,118,7425,7467,1,7531,7543,1,7545,7578,1,7681,7829,2,7830,7837,1,7839,7935,2,7936,7943,1,7952,7957,1,7968,7975,1,7984,7991,1,8e3,8005,1,8016,8023,1,8032,8039,1,8048,8061,1,8064,8071,1,8080,8087,1,8096,8103,1,8112,8116,1,8118,8119,1,8126,8130,4,8131,8132,1,8134,8135,1,8144,8147,1,8150,8151,1,8160,8167,1,8178,8180,1,8182,8183,1,8458,8462,4,8463,8467,4,8495,8505,5,8508,8509,1,8518,8521,1,8526,8580,54,11312,11359,1,11361,11365,4,11366,11372,2,11377,11379,2,11380,11382,2,11383,11387,1,11393,11491,2,11492,11500,8,11502,11507,5,11520,11557,1,11559,11565,6,42561,42605,2,42625,42651,2,42787,42799,2,42800,42801,1,42803,42865,2,42866,42872,1,42874,42876,2,42879,42887,2,42892,42894,2,42897,42899,2,42900,42901,1,42903,42921,2,42927,42933,6,42935,42947,2,42952,42954,2,42957,42961,4,42963,42971,2,42998,43002,4,43824,43866,1,43872,43880,1,43888,43967,1,64256,64262,1,64275,64279,1,65345,65370,1,66600,66639,1,66776,66811,1,66967,66977,1,66979,66993,1,66995,67001,1,67003,67004,1,68800,68850,1,68976,68997,1,71872,71903,1,93792,93823,1,119834,119859,1,119886,119892,1,119894,119911,1,119938,119963,1,119990,119993,1,119995,119997,2,119998,120003,1,120005,120015,1,120042,120067,1,120094,120119,1,120146,120171,1,120198,120223,1,120250,120275,1,120302,120327,1,120354,120379,1,120406,120431,1,120458,120485,1,120514,120538,1,120540,120545,1,120572,120596,1,120598,120603,1,120630,120654,1,120656,120661,1,120688,120712,1,120714,120719,1,120746,120770,1,120772,120777,1,120779,122624,1845,122625,122633,1,122635,122654,1,122661,122666,1,125218,125251,1]));static foldLl=new K(new Uint32Array([65,90,1,192,214,1,216,222,1,256,302,2,306,310,2,313,327,2,330,376,2,377,381,2,385,386,1,388,390,2,391,393,2,394,395,1,398,401,1,403,404,1,406,408,1,412,413,1,415,416,1,418,422,2,423,425,2,428,430,2,431,433,2,434,435,1,437,439,2,440,444,4,452,453,1,455,456,1,458,459,1,461,475,2,478,494,2,497,498,1,500,502,2,503,504,1,506,562,2,570,571,1,573,574,1,577,579,2,580,582,1,584,590,2,837,880,43,882,886,4,895,902,7,904,906,1,908,910,2,911,913,2,914,929,1,931,939,1,975,984,9,986,1006,2,1012,1015,3,1017,1018,1,1021,1071,1,1120,1152,2,1162,1216,2,1217,1229,2,1232,1326,2,1329,1366,1,4256,4293,1,4295,4301,6,5024,5109,1,7305,7312,7,7313,7354,1,7357,7359,1,7680,7828,2,7838,7934,2,7944,7951,1,7960,7965,1,7976,7983,1,7992,7999,1,8008,8013,1,8025,8031,2,8040,8047,1,8072,8079,1,8088,8095,1,8104,8111,1,8120,8124,1,8136,8140,1,8152,8155,1,8168,8172,1,8184,8188,1,8486,8490,4,8491,8498,7,8579,11264,2685,11265,11311,1,11360,11362,2,11363,11364,1,11367,11373,2,11374,11376,1,11378,11381,3,11390,11392,1,11394,11490,2,11499,11501,2,11506,42560,31054,42562,42604,2,42624,42650,2,42786,42798,2,42802,42862,2,42873,42877,2,42878,42886,2,42891,42893,2,42896,42898,2,42902,42922,2,42923,42926,1,42928,42932,1,42934,42948,2,42949,42951,1,42953,42955,2,42956,42960,4,42966,42972,2,42997,65313,22316,65314,65338,1,66560,66599,1,66736,66771,1,66928,66938,1,66940,66954,1,66956,66962,1,66964,66965,1,68736,68786,1,68944,68965,1,71840,71871,1,93760,93791,1,125184,125217,1]));static Lm=new K(new Uint32Array([688,705,1,710,721,1,736,740,1,748,750,2,884,890,6,1369,1600,231,1765,1766,1,2036,2037,1,2042,2074,32,2084,2088,4,2249,2417,168,3654,3782,128,4348,6103,1755,6211,6823,612,7288,7293,1,7468,7530,1,7544,7579,35,7580,7615,1,8305,8319,14,8336,8348,1,11388,11389,1,11631,11823,192,12293,12337,44,12338,12341,1,12347,12445,98,12446,12540,94,12541,12542,1,40981,42232,1251,42233,42237,1,42508,42623,115,42652,42653,1,42775,42783,1,42864,42888,24,42994,42996,1,43e3,43001,1,43471,43494,23,43632,43741,109,43763,43764,1,43868,43871,1,43881,65392,21511,65438,65439,1,67456,67461,1,67463,67504,1,67506,67514,1,68942,68975,33,92992,92995,1,93504,93506,1,93547,93548,1,94099,94111,1,94176,94177,1,94179,110576,16397,110577,110579,1,110581,110587,1,110589,110590,1,122928,122989,1,123191,123197,1,124139,125259,1120]));static Lo=new K(new Uint32Array([170,186,16,443,448,5,449,451,1,660,1488,828,1489,1514,1,1519,1522,1,1568,1599,1,1601,1610,1,1646,1647,1,1649,1747,1,1749,1774,25,1775,1786,11,1787,1788,1,1791,1808,17,1810,1839,1,1869,1957,1,1969,1994,25,1995,2026,1,2048,2069,1,2112,2136,1,2144,2154,1,2160,2183,1,2185,2190,1,2208,2248,1,2308,2361,1,2365,2384,19,2392,2401,1,2418,2432,1,2437,2444,1,2447,2448,1,2451,2472,1,2474,2480,1,2482,2486,4,2487,2489,1,2493,2510,17,2524,2525,1,2527,2529,1,2544,2545,1,2556,2565,9,2566,2570,1,2575,2576,1,2579,2600,1,2602,2608,1,2610,2611,1,2613,2614,1,2616,2617,1,2649,2652,1,2654,2674,20,2675,2676,1,2693,2701,1,2703,2705,1,2707,2728,1,2730,2736,1,2738,2739,1,2741,2745,1,2749,2768,19,2784,2785,1,2809,2821,12,2822,2828,1,2831,2832,1,2835,2856,1,2858,2864,1,2866,2867,1,2869,2873,1,2877,2908,31,2909,2911,2,2912,2913,1,2929,2947,18,2949,2954,1,2958,2960,1,2962,2965,1,2969,2970,1,2972,2974,2,2975,2979,4,2980,2984,4,2985,2986,1,2990,3001,1,3024,3077,53,3078,3084,1,3086,3088,1,3090,3112,1,3114,3129,1,3133,3160,27,3161,3162,1,3165,3168,3,3169,3200,31,3205,3212,1,3214,3216,1,3218,3240,1,3242,3251,1,3253,3257,1,3261,3293,32,3294,3296,2,3297,3313,16,3314,3332,18,3333,3340,1,3342,3344,1,3346,3386,1,3389,3406,17,3412,3414,1,3423,3425,1,3450,3455,1,3461,3478,1,3482,3505,1,3507,3515,1,3517,3520,3,3521,3526,1,3585,3632,1,3634,3635,1,3648,3653,1,3713,3714,1,3716,3718,2,3719,3722,1,3724,3747,1,3749,3751,2,3752,3760,1,3762,3763,1,3773,3776,3,3777,3780,1,3804,3807,1,3840,3904,64,3905,3911,1,3913,3948,1,3976,3980,1,4096,4138,1,4159,4176,17,4177,4181,1,4186,4189,1,4193,4197,4,4198,4206,8,4207,4208,1,4213,4225,1,4238,4352,114,4353,4680,1,4682,4685,1,4688,4694,1,4696,4698,2,4699,4701,1,4704,4744,1,4746,4749,1,4752,4784,1,4786,4789,1,4792,4798,1,4800,4802,2,4803,4805,1,4808,4822,1,4824,4880,1,4882,4885,1,4888,4954,1,4992,5007,1,5121,5740,1,5743,5759,1,5761,5786,1,5792,5866,1,5873,5880,1,5888,5905,1,5919,5937,1,5952,5969,1,5984,5996,1,5998,6e3,1,6016,6067,1,6108,6176,68,6177,6210,1,6212,6264,1,6272,6276,1,6279,6312,1,6314,6320,6,6321,6389,1,6400,6430,1,6480,6509,1,6512,6516,1,6528,6571,1,6576,6601,1,6656,6678,1,6688,6740,1,6917,6963,1,6981,6988,1,7043,7072,1,7086,7087,1,7098,7141,1,7168,7203,1,7245,7247,1,7258,7287,1,7401,7404,1,7406,7411,1,7413,7414,1,7418,8501,1083,8502,8504,1,11568,11623,1,11648,11670,1,11680,11686,1,11688,11694,1,11696,11702,1,11704,11710,1,11712,11718,1,11720,11726,1,11728,11734,1,11736,11742,1,12294,12348,54,12353,12438,1,12447,12449,2,12450,12538,1,12543,12549,6,12550,12591,1,12593,12686,1,12704,12735,1,12784,12799,1,13312,19903,1,19968,40980,1,40982,42124,1,42192,42231,1,42240,42507,1,42512,42527,1,42538,42539,1,42606,42656,50,42657,42725,1,42895,42999,104,43003,43009,1,43011,43013,1,43015,43018,1,43020,43042,1,43072,43123,1,43138,43187,1,43250,43255,1,43259,43261,2,43262,43274,12,43275,43301,1,43312,43334,1,43360,43388,1,43396,43442,1,43488,43492,1,43495,43503,1,43514,43518,1,43520,43560,1,43584,43586,1,43588,43595,1,43616,43631,1,43633,43638,1,43642,43646,4,43647,43695,1,43697,43701,4,43702,43705,3,43706,43709,1,43712,43714,2,43739,43740,1,43744,43754,1,43762,43777,15,43778,43782,1,43785,43790,1,43793,43798,1,43808,43814,1,43816,43822,1,43968,44002,1,44032,55203,1,55216,55238,1,55243,55291,1,63744,64109,1,64112,64217,1,64285,64287,2,64288,64296,1,64298,64310,1,64312,64316,1,64318,64320,2,64321,64323,2,64324,64326,2,64327,64433,1,64467,64829,1,64848,64911,1,64914,64967,1,65008,65019,1,65136,65140,1,65142,65276,1,65382,65391,1,65393,65437,1,65440,65470,1,65474,65479,1,65482,65487,1,65490,65495,1,65498,65500,1,65536,65547,1,65549,65574,1,65576,65594,1,65596,65597,1,65599,65613,1,65616,65629,1,65664,65786,1,66176,66204,1,66208,66256,1,66304,66335,1,66349,66368,1,66370,66377,1,66384,66421,1,66432,66461,1,66464,66499,1,66504,66511,1,66640,66717,1,66816,66855,1,66864,66915,1,67008,67059,1,67072,67382,1,67392,67413,1,67424,67431,1,67584,67589,1,67592,67594,2,67595,67637,1,67639,67640,1,67644,67647,3,67648,67669,1,67680,67702,1,67712,67742,1,67808,67826,1,67828,67829,1,67840,67861,1,67872,67897,1,67968,68023,1,68030,68031,1,68096,68112,16,68113,68115,1,68117,68119,1,68121,68149,1,68192,68220,1,68224,68252,1,68288,68295,1,68297,68324,1,68352,68405,1,68416,68437,1,68448,68466,1,68480,68497,1,68608,68680,1,68864,68899,1,68938,68941,1,68943,69248,305,69249,69289,1,69296,69297,1,69314,69316,1,69376,69404,1,69415,69424,9,69425,69445,1,69488,69505,1,69552,69572,1,69600,69622,1,69635,69687,1,69745,69746,1,69749,69763,14,69764,69807,1,69840,69864,1,69891,69926,1,69956,69959,3,69968,70002,1,70006,70019,13,70020,70066,1,70081,70084,1,70106,70108,2,70144,70161,1,70163,70187,1,70207,70208,1,70272,70278,1,70280,70282,2,70283,70285,1,70287,70301,1,70303,70312,1,70320,70366,1,70405,70412,1,70415,70416,1,70419,70440,1,70442,70448,1,70450,70451,1,70453,70457,1,70461,70480,19,70493,70497,1,70528,70537,1,70539,70542,3,70544,70581,1,70583,70609,26,70611,70656,45,70657,70708,1,70727,70730,1,70751,70753,1,70784,70831,1,70852,70853,1,70855,71040,185,71041,71086,1,71128,71131,1,71168,71215,1,71236,71296,60,71297,71338,1,71352,71424,72,71425,71450,1,71488,71494,1,71680,71723,1,71935,71942,1,71945,71948,3,71949,71955,1,71957,71958,1,71960,71983,1,71999,72001,2,72096,72103,1,72106,72144,1,72161,72163,2,72192,72203,11,72204,72242,1,72250,72272,22,72284,72329,1,72349,72368,19,72369,72440,1,72640,72672,1,72704,72712,1,72714,72750,1,72768,72818,50,72819,72847,1,72960,72966,1,72968,72969,1,72971,73008,1,73030,73056,26,73057,73061,1,73063,73064,1,73066,73097,1,73112,73440,328,73441,73458,1,73474,73476,2,73477,73488,1,73490,73523,1,73648,73728,80,73729,74649,1,74880,75075,1,77712,77808,1,77824,78895,1,78913,78918,1,78944,82938,1,82944,83526,1,90368,90397,1,92160,92728,1,92736,92766,1,92784,92862,1,92880,92909,1,92928,92975,1,93027,93047,1,93053,93071,1,93507,93546,1,93952,94026,1,94032,94208,176,94209,100343,1,100352,101589,1,101631,101640,1,110592,110882,1,110898,110928,30,110929,110930,1,110933,110948,15,110949,110951,1,110960,111355,1,113664,113770,1,113776,113788,1,113792,113800,1,113808,113817,1,122634,123136,502,123137,123180,1,123214,123536,322,123537,123565,1,123584,123627,1,124112,124138,1,124368,124397,1,124400,124896,496,124897,124902,1,124904,124907,1,124909,124910,1,124912,124926,1,124928,125124,1,126464,126467,1,126469,126495,1,126497,126498,1,126500,126503,3,126505,126514,1,126516,126519,1,126521,126523,2,126530,126535,5,126537,126541,2,126542,126543,1,126545,126546,1,126548,126551,3,126553,126561,2,126562,126564,2,126567,126570,1,126572,126578,1,126580,126583,1,126585,126588,1,126590,126592,2,126593,126601,1,126603,126619,1,126625,126627,1,126629,126633,1,126635,126651,1,131072,173791,1,173824,177977,1,177984,178205,1,178208,183969,1,183984,191456,1,191472,192093,1,194560,195101,1,196608,201546,1,201552,205743,1]));static Lt=new K(new Uint32Array([453,459,3,498,8072,7574,8073,8079,1,8088,8095,1,8104,8111,1,8124,8140,16,8188,8188,1]));static foldLt=new K(new Uint32Array([452,454,2,455,457,2,458,460,2,497,499,2,8064,8071,1,8080,8087,1,8096,8103,1,8115,8131,16,8179,8179,1]));static Lu=new K(new Uint32Array([65,90,1,192,214,1,216,222,1,256,310,2,313,327,2,330,376,2,377,381,2,385,386,1,388,390,2,391,393,2,394,395,1,398,401,1,403,404,1,406,408,1,412,413,1,415,416,1,418,422,2,423,425,2,428,430,2,431,433,2,434,435,1,437,439,2,440,444,4,452,461,3,463,475,2,478,494,2,497,500,3,502,504,1,506,562,2,570,571,1,573,574,1,577,579,2,580,582,1,584,590,2,880,882,2,886,895,9,902,904,2,905,906,1,908,910,2,911,913,2,914,929,1,931,939,1,975,978,3,979,980,1,984,1006,2,1012,1015,3,1017,1018,1,1021,1071,1,1120,1152,2,1162,1216,2,1217,1229,2,1232,1326,2,1329,1366,1,4256,4293,1,4295,4301,6,5024,5109,1,7305,7312,7,7313,7354,1,7357,7359,1,7680,7828,2,7838,7934,2,7944,7951,1,7960,7965,1,7976,7983,1,7992,7999,1,8008,8013,1,8025,8031,2,8040,8047,1,8120,8123,1,8136,8139,1,8152,8155,1,8168,8172,1,8184,8187,1,8450,8455,5,8459,8461,1,8464,8466,1,8469,8473,4,8474,8477,1,8484,8490,2,8491,8493,1,8496,8499,1,8510,8511,1,8517,8579,62,11264,11311,1,11360,11362,2,11363,11364,1,11367,11373,2,11374,11376,1,11378,11381,3,11390,11392,1,11394,11490,2,11499,11501,2,11506,42560,31054,42562,42604,2,42624,42650,2,42786,42798,2,42802,42862,2,42873,42877,2,42878,42886,2,42891,42893,2,42896,42898,2,42902,42922,2,42923,42926,1,42928,42932,1,42934,42948,2,42949,42951,1,42953,42955,2,42956,42960,4,42966,42972,2,42997,65313,22316,65314,65338,1,66560,66599,1,66736,66771,1,66928,66938,1,66940,66954,1,66956,66962,1,66964,66965,1,68736,68786,1,68944,68965,1,71840,71871,1,93760,93791,1,119808,119833,1,119860,119885,1,119912,119937,1,119964,119966,2,119967,119973,3,119974,119977,3,119978,119980,1,119982,119989,1,120016,120041,1,120068,120069,1,120071,120074,1,120077,120084,1,120086,120092,1,120120,120121,1,120123,120126,1,120128,120132,1,120134,120138,4,120139,120144,1,120172,120197,1,120224,120249,1,120276,120301,1,120328,120353,1,120380,120405,1,120432,120457,1,120488,120512,1,120546,120570,1,120604,120628,1,120662,120686,1,120720,120744,1,120778,125184,4406,125185,125217,1]));static Upper=this.Lu;static foldLu=new K(new Uint32Array([97,122,1,181,223,42,224,246,1,248,255,1,257,303,2,307,311,2,314,328,2,331,375,2,378,382,2,383,384,1,387,389,2,392,396,4,402,405,3,409,411,1,414,417,3,419,421,2,424,429,5,432,436,4,438,441,3,445,447,2,453,454,1,456,457,1,459,460,1,462,476,2,477,495,2,498,499,1,501,505,4,507,543,2,547,563,2,572,575,3,576,578,2,583,591,2,592,596,1,598,599,1,601,603,2,604,608,4,609,611,2,612,614,1,616,620,1,623,625,2,626,629,3,637,640,3,642,643,1,647,652,1,658,669,11,670,837,167,881,883,2,887,891,4,892,893,1,940,943,1,945,974,1,976,977,1,981,983,1,985,1007,2,1008,1011,1,1013,1019,3,1072,1119,1,1121,1153,2,1163,1215,2,1218,1230,2,1231,1327,2,1377,1414,1,4304,4346,1,4349,4351,1,5112,5117,1,7296,7304,1,7306,7545,239,7549,7566,17,7681,7829,2,7835,7841,6,7843,7935,2,7936,7943,1,7952,7957,1,7968,7975,1,7984,7991,1,8e3,8005,1,8017,8023,2,8032,8039,1,8048,8061,1,8112,8113,1,8126,8144,18,8145,8160,15,8161,8165,4,8526,8580,54,11312,11359,1,11361,11365,4,11366,11372,2,11379,11382,3,11393,11491,2,11500,11502,2,11507,11520,13,11521,11557,1,11559,11565,6,42561,42605,2,42625,42651,2,42787,42799,2,42803,42863,2,42874,42876,2,42879,42887,2,42892,42897,5,42899,42900,1,42903,42921,2,42933,42947,2,42952,42954,2,42957,42961,4,42967,42971,2,42998,43859,861,43888,43967,1,65345,65370,1,66600,66639,1,66776,66811,1,66967,66977,1,66979,66993,1,66995,67001,1,67003,67004,1,68800,68850,1,68976,68997,1,71872,71903,1,93792,93823,1,125218,125251,1]));static M=new K(new Uint32Array([768,879,1,1155,1161,1,1425,1469,1,1471,1473,2,1474,1476,2,1477,1479,2,1552,1562,1,1611,1631,1,1648,1750,102,1751,1756,1,1759,1764,1,1767,1768,1,1770,1773,1,1809,1840,31,1841,1866,1,1958,1968,1,2027,2035,1,2045,2070,25,2071,2073,1,2075,2083,1,2085,2087,1,2089,2093,1,2137,2139,1,2199,2207,1,2250,2273,1,2275,2307,1,2362,2364,1,2366,2383,1,2385,2391,1,2402,2403,1,2433,2435,1,2492,2494,2,2495,2500,1,2503,2504,1,2507,2509,1,2519,2530,11,2531,2558,27,2561,2563,1,2620,2622,2,2623,2626,1,2631,2632,1,2635,2637,1,2641,2672,31,2673,2677,4,2689,2691,1,2748,2750,2,2751,2757,1,2759,2761,1,2763,2765,1,2786,2787,1,2810,2815,1,2817,2819,1,2876,2878,2,2879,2884,1,2887,2888,1,2891,2893,1,2901,2903,1,2914,2915,1,2946,3006,60,3007,3010,1,3014,3016,1,3018,3021,1,3031,3072,41,3073,3076,1,3132,3134,2,3135,3140,1,3142,3144,1,3146,3149,1,3157,3158,1,3170,3171,1,3201,3203,1,3260,3262,2,3263,3268,1,3270,3272,1,3274,3277,1,3285,3286,1,3298,3299,1,3315,3328,13,3329,3331,1,3387,3388,1,3390,3396,1,3398,3400,1,3402,3405,1,3415,3426,11,3427,3457,30,3458,3459,1,3530,3535,5,3536,3540,1,3542,3544,2,3545,3551,1,3570,3571,1,3633,3636,3,3637,3642,1,3655,3662,1,3761,3764,3,3765,3772,1,3784,3790,1,3864,3865,1,3893,3897,2,3902,3903,1,3953,3972,1,3974,3975,1,3981,3991,1,3993,4028,1,4038,4139,101,4140,4158,1,4182,4185,1,4190,4192,1,4194,4196,1,4199,4205,1,4209,4212,1,4226,4237,1,4239,4250,11,4251,4253,1,4957,4959,1,5906,5909,1,5938,5940,1,5970,5971,1,6002,6003,1,6068,6099,1,6109,6155,46,6156,6157,1,6159,6277,118,6278,6313,35,6432,6443,1,6448,6459,1,6679,6683,1,6741,6750,1,6752,6780,1,6783,6832,49,6833,6862,1,6912,6916,1,6964,6980,1,7019,7027,1,7040,7042,1,7073,7085,1,7142,7155,1,7204,7223,1,7376,7378,1,7380,7400,1,7405,7412,7,7415,7417,1,7616,7679,1,8400,8432,1,11503,11505,1,11647,11744,97,11745,11775,1,12330,12335,1,12441,12442,1,42607,42610,1,42612,42621,1,42654,42655,1,42736,42737,1,43010,43014,4,43019,43043,24,43044,43047,1,43052,43136,84,43137,43188,51,43189,43205,1,43232,43249,1,43263,43302,39,43303,43309,1,43335,43347,1,43392,43395,1,43443,43456,1,43493,43561,68,43562,43574,1,43587,43596,9,43597,43643,46,43644,43645,1,43696,43698,2,43699,43700,1,43703,43704,1,43710,43711,1,43713,43755,42,43756,43759,1,43765,43766,1,44003,44010,1,44012,44013,1,64286,65024,738,65025,65039,1,65056,65071,1,66045,66272,227,66422,66426,1,68097,68099,1,68101,68102,1,68108,68111,1,68152,68154,1,68159,68325,166,68326,68900,574,68901,68903,1,68969,68973,1,69291,69292,1,69372,69375,1,69446,69456,1,69506,69509,1,69632,69634,1,69688,69702,1,69744,69747,3,69748,69759,11,69760,69762,1,69808,69818,1,69826,69888,62,69889,69890,1,69927,69940,1,69957,69958,1,70003,70016,13,70017,70018,1,70067,70080,1,70089,70092,1,70094,70095,1,70188,70199,1,70206,70209,3,70367,70378,1,70400,70403,1,70459,70460,1,70462,70468,1,70471,70472,1,70475,70477,1,70487,70498,11,70499,70502,3,70503,70508,1,70512,70516,1,70584,70592,1,70594,70597,3,70599,70602,1,70604,70608,1,70610,70625,15,70626,70709,83,70710,70726,1,70750,70832,82,70833,70851,1,71087,71093,1,71096,71104,1,71132,71133,1,71216,71232,1,71339,71351,1,71453,71467,1,71724,71738,1,71984,71989,1,71991,71992,1,71995,71998,1,72e3,72002,2,72003,72145,142,72146,72151,1,72154,72160,1,72164,72193,29,72194,72202,1,72243,72249,1,72251,72254,1,72263,72273,10,72274,72283,1,72330,72345,1,72751,72758,1,72760,72767,1,72850,72871,1,72873,72886,1,73009,73014,1,73018,73020,2,73021,73023,2,73024,73029,1,73031,73098,67,73099,73102,1,73104,73105,1,73107,73111,1,73459,73462,1,73472,73473,1,73475,73524,49,73525,73530,1,73534,73538,1,73562,78912,5350,78919,78933,1,90398,90415,1,92912,92916,1,92976,92982,1,94031,94033,2,94034,94087,1,94095,94098,1,94180,94192,12,94193,113821,19628,113822,118528,4706,118529,118573,1,118576,118598,1,119141,119145,1,119149,119154,1,119163,119170,1,119173,119179,1,119210,119213,1,119362,119364,1,121344,121398,1,121403,121452,1,121461,121476,15,121499,121503,1,121505,121519,1,122880,122886,1,122888,122904,1,122907,122913,1,122915,122916,1,122918,122922,1,123023,123184,161,123185,123190,1,123566,123628,62,123629,123631,1,124140,124143,1,124398,124399,1,125136,125142,1,125252,125258,1,917760,917999,1]));static foldM=new K(new Uint32Array([921,953,32,8126,8126,1]));static Mc=new K(new Uint32Array([2307,2363,56,2366,2368,1,2377,2380,1,2382,2383,1,2434,2435,1,2494,2496,1,2503,2504,1,2507,2508,1,2519,2563,44,2622,2624,1,2691,2750,59,2751,2752,1,2761,2763,2,2764,2818,54,2819,2878,59,2880,2887,7,2888,2891,3,2892,2903,11,3006,3007,1,3009,3010,1,3014,3016,1,3018,3020,1,3031,3073,42,3074,3075,1,3137,3140,1,3202,3203,1,3262,3264,2,3265,3268,1,3271,3272,1,3274,3275,1,3285,3286,1,3315,3330,15,3331,3390,59,3391,3392,1,3398,3400,1,3402,3404,1,3415,3458,43,3459,3535,76,3536,3537,1,3544,3551,1,3570,3571,1,3902,3903,1,3967,4139,172,4140,4145,5,4152,4155,3,4156,4182,26,4183,4194,11,4195,4196,1,4199,4205,1,4227,4228,1,4231,4236,1,4239,4250,11,4251,4252,1,5909,5940,31,6070,6078,8,6079,6085,1,6087,6088,1,6435,6438,1,6441,6443,1,6448,6449,1,6451,6456,1,6681,6682,1,6741,6743,2,6753,6755,2,6756,6765,9,6766,6770,1,6916,6965,49,6971,6973,2,6974,6977,1,6979,6980,1,7042,7073,31,7078,7079,1,7082,7143,61,7146,7148,1,7150,7154,4,7155,7204,49,7205,7211,1,7220,7221,1,7393,7415,22,12334,12335,1,43043,43044,1,43047,43136,89,43137,43188,51,43189,43203,1,43346,43347,1,43395,43444,49,43445,43450,5,43451,43454,3,43455,43456,1,43567,43568,1,43571,43572,1,43597,43643,46,43645,43755,110,43758,43759,1,43765,44003,238,44004,44006,2,44007,44009,2,44010,44012,2,69632,69634,2,69762,69808,46,69809,69810,1,69815,69816,1,69932,69957,25,69958,70018,60,70067,70069,1,70079,70080,1,70094,70188,94,70189,70190,1,70194,70195,1,70197,70368,171,70369,70370,1,70402,70403,1,70462,70463,1,70465,70468,1,70471,70472,1,70475,70477,1,70487,70498,11,70499,70584,85,70585,70586,1,70594,70597,3,70599,70602,1,70604,70605,1,70607,70709,102,70710,70711,1,70720,70721,1,70725,70832,107,70833,70834,1,70841,70843,2,70844,70846,1,70849,71087,238,71088,71089,1,71096,71099,1,71102,71216,114,71217,71218,1,71227,71228,1,71230,71340,110,71342,71343,1,71350,71454,104,71456,71457,1,71462,71724,262,71725,71726,1,71736,71984,248,71985,71989,1,71991,71992,1,71997,72e3,3,72002,72145,143,72146,72147,1,72156,72159,1,72164,72249,85,72279,72280,1,72343,72751,408,72766,72873,107,72881,72884,3,73098,73102,1,73107,73108,1,73110,73461,351,73462,73475,13,73524,73525,1,73534,73535,1,73537,90410,16873,90411,90412,1,94033,94087,1,94192,94193,1,119141,119142,1,119149,119154,1]));static Me=new K(new Uint32Array([1160,1161,1,6846,8413,1567,8414,8416,1,8418,8420,1,42608,42610,1]));static Mn=new K(new Uint32Array([768,879,1,1155,1159,1,1425,1469,1,1471,1473,2,1474,1476,2,1477,1479,2,1552,1562,1,1611,1631,1,1648,1750,102,1751,1756,1,1759,1764,1,1767,1768,1,1770,1773,1,1809,1840,31,1841,1866,1,1958,1968,1,2027,2035,1,2045,2070,25,2071,2073,1,2075,2083,1,2085,2087,1,2089,2093,1,2137,2139,1,2199,2207,1,2250,2273,1,2275,2306,1,2362,2364,2,2369,2376,1,2381,2385,4,2386,2391,1,2402,2403,1,2433,2492,59,2497,2500,1,2509,2530,21,2531,2558,27,2561,2562,1,2620,2625,5,2626,2631,5,2632,2635,3,2636,2637,1,2641,2672,31,2673,2677,4,2689,2690,1,2748,2753,5,2754,2757,1,2759,2760,1,2765,2786,21,2787,2810,23,2811,2815,1,2817,2876,59,2879,2881,2,2882,2884,1,2893,2901,8,2902,2914,12,2915,2946,31,3008,3021,13,3072,3076,4,3132,3134,2,3135,3136,1,3142,3144,1,3146,3149,1,3157,3158,1,3170,3171,1,3201,3260,59,3263,3270,7,3276,3277,1,3298,3299,1,3328,3329,1,3387,3388,1,3393,3396,1,3405,3426,21,3427,3457,30,3530,3538,8,3539,3540,1,3542,3633,91,3636,3642,1,3655,3662,1,3761,3764,3,3765,3772,1,3784,3790,1,3864,3865,1,3893,3897,2,3953,3966,1,3968,3972,1,3974,3975,1,3981,3991,1,3993,4028,1,4038,4141,103,4142,4144,1,4146,4151,1,4153,4154,1,4157,4158,1,4184,4185,1,4190,4192,1,4209,4212,1,4226,4229,3,4230,4237,7,4253,4957,704,4958,4959,1,5906,5908,1,5938,5939,1,5970,5971,1,6002,6003,1,6068,6069,1,6071,6077,1,6086,6089,3,6090,6099,1,6109,6155,46,6156,6157,1,6159,6277,118,6278,6313,35,6432,6434,1,6439,6440,1,6450,6457,7,6458,6459,1,6679,6680,1,6683,6742,59,6744,6750,1,6752,6754,2,6757,6764,1,6771,6780,1,6783,6832,49,6833,6845,1,6847,6862,1,6912,6915,1,6964,6966,2,6967,6970,1,6972,6978,6,7019,7027,1,7040,7041,1,7074,7077,1,7080,7081,1,7083,7085,1,7142,7144,2,7145,7149,4,7151,7153,1,7212,7219,1,7222,7223,1,7376,7378,1,7380,7392,1,7394,7400,1,7405,7412,7,7416,7417,1,7616,7679,1,8400,8412,1,8417,8421,4,8422,8432,1,11503,11505,1,11647,11744,97,11745,11775,1,12330,12333,1,12441,12442,1,42607,42612,5,42613,42621,1,42654,42655,1,42736,42737,1,43010,43014,4,43019,43045,26,43046,43052,6,43204,43205,1,43232,43249,1,43263,43302,39,43303,43309,1,43335,43345,1,43392,43394,1,43443,43446,3,43447,43449,1,43452,43453,1,43493,43561,68,43562,43566,1,43569,43570,1,43573,43574,1,43587,43596,9,43644,43696,52,43698,43700,1,43703,43704,1,43710,43711,1,43713,43756,43,43757,43766,9,44005,44008,3,44013,64286,20273,65024,65039,1,65056,65071,1,66045,66272,227,66422,66426,1,68097,68099,1,68101,68102,1,68108,68111,1,68152,68154,1,68159,68325,166,68326,68900,574,68901,68903,1,68969,68973,1,69291,69292,1,69372,69375,1,69446,69456,1,69506,69509,1,69633,69688,55,69689,69702,1,69744,69747,3,69748,69759,11,69760,69761,1,69811,69814,1,69817,69818,1,69826,69888,62,69889,69890,1,69927,69931,1,69933,69940,1,70003,70016,13,70017,70070,53,70071,70078,1,70089,70092,1,70095,70191,96,70192,70193,1,70196,70198,2,70199,70206,7,70209,70367,158,70371,70378,1,70400,70401,1,70459,70460,1,70464,70502,38,70503,70508,1,70512,70516,1,70587,70592,1,70606,70610,2,70625,70626,1,70712,70719,1,70722,70724,1,70726,70750,24,70835,70840,1,70842,70847,5,70848,70850,2,70851,71090,239,71091,71093,1,71100,71101,1,71103,71104,1,71132,71133,1,71219,71226,1,71229,71231,2,71232,71339,107,71341,71344,3,71345,71349,1,71351,71453,102,71455,71458,3,71459,71461,1,71463,71467,1,71727,71735,1,71737,71738,1,71995,71996,1,71998,72003,5,72148,72151,1,72154,72155,1,72160,72193,33,72194,72202,1,72243,72248,1,72251,72254,1,72263,72273,10,72274,72278,1,72281,72283,1,72330,72342,1,72344,72345,1,72752,72758,1,72760,72765,1,72767,72850,83,72851,72871,1,72874,72880,1,72882,72883,1,72885,72886,1,73009,73014,1,73018,73020,2,73021,73023,2,73024,73029,1,73031,73104,73,73105,73109,4,73111,73459,348,73460,73472,12,73473,73526,53,73527,73530,1,73536,73538,2,73562,78912,5350,78919,78933,1,90398,90409,1,90413,90415,1,92912,92916,1,92976,92982,1,94031,94095,64,94096,94098,1,94180,113821,19641,113822,118528,4706,118529,118573,1,118576,118598,1,119143,119145,1,119163,119170,1,119173,119179,1,119210,119213,1,119362,119364,1,121344,121398,1,121403,121452,1,121461,121476,15,121499,121503,1,121505,121519,1,122880,122886,1,122888,122904,1,122907,122913,1,122915,122916,1,122918,122922,1,123023,123184,161,123185,123190,1,123566,123628,62,123629,123631,1,124140,124143,1,124398,124399,1,125136,125142,1,125252,125258,1,917760,917999,1]));static foldMn=new K(new Uint32Array([921,953,32,8126,8126,1]));static N=new K(new Uint32Array([48,57,1,178,179,1,185,188,3,189,190,1,1632,1641,1,1776,1785,1,1984,1993,1,2406,2415,1,2534,2543,1,2548,2553,1,2662,2671,1,2790,2799,1,2918,2927,1,2930,2935,1,3046,3058,1,3174,3183,1,3192,3198,1,3302,3311,1,3416,3422,1,3430,3448,1,3558,3567,1,3664,3673,1,3792,3801,1,3872,3891,1,4160,4169,1,4240,4249,1,4969,4988,1,5870,5872,1,6112,6121,1,6128,6137,1,6160,6169,1,6470,6479,1,6608,6618,1,6784,6793,1,6800,6809,1,6992,7001,1,7088,7097,1,7232,7241,1,7248,7257,1,8304,8308,4,8309,8313,1,8320,8329,1,8528,8578,1,8581,8585,1,9312,9371,1,9450,9471,1,10102,10131,1,11517,12295,778,12321,12329,1,12344,12346,1,12690,12693,1,12832,12841,1,12872,12879,1,12881,12895,1,12928,12937,1,12977,12991,1,42528,42537,1,42726,42735,1,43056,43061,1,43216,43225,1,43264,43273,1,43472,43481,1,43504,43513,1,43600,43609,1,44016,44025,1,65296,65305,1,65799,65843,1,65856,65912,1,65930,65931,1,66273,66299,1,66336,66339,1,66369,66378,9,66513,66517,1,66720,66729,1,67672,67679,1,67705,67711,1,67751,67759,1,67835,67839,1,67862,67867,1,68028,68029,1,68032,68047,1,68050,68095,1,68160,68168,1,68221,68222,1,68253,68255,1,68331,68335,1,68440,68447,1,68472,68479,1,68521,68527,1,68858,68863,1,68912,68921,1,68928,68937,1,69216,69246,1,69405,69414,1,69457,69460,1,69573,69579,1,69714,69743,1,69872,69881,1,69942,69951,1,70096,70105,1,70113,70132,1,70384,70393,1,70736,70745,1,70864,70873,1,71248,71257,1,71360,71369,1,71376,71395,1,71472,71483,1,71904,71922,1,72016,72025,1,72688,72697,1,72784,72812,1,73040,73049,1,73120,73129,1,73552,73561,1,73664,73684,1,74752,74862,1,90416,90425,1,92768,92777,1,92864,92873,1,93008,93017,1,93019,93025,1,93552,93561,1,93824,93846,1,118e3,118009,1,119488,119507,1,119520,119539,1,119648,119672,1,120782,120831,1,123200,123209,1,123632,123641,1,124144,124153,1,124401,124410,1,125127,125135,1,125264,125273,1,126065,126123,1,126125,126127,1,126129,126132,1,126209,126253,1,126255,126269,1,127232,127244,1,130032,130041,1]));static Nd=new K(new Uint32Array([48,57,1,1632,1641,1,1776,1785,1,1984,1993,1,2406,2415,1,2534,2543,1,2662,2671,1,2790,2799,1,2918,2927,1,3046,3055,1,3174,3183,1,3302,3311,1,3430,3439,1,3558,3567,1,3664,3673,1,3792,3801,1,3872,3881,1,4160,4169,1,4240,4249,1,6112,6121,1,6160,6169,1,6470,6479,1,6608,6617,1,6784,6793,1,6800,6809,1,6992,7001,1,7088,7097,1,7232,7241,1,7248,7257,1,42528,42537,1,43216,43225,1,43264,43273,1,43472,43481,1,43504,43513,1,43600,43609,1,44016,44025,1,65296,65305,1,66720,66729,1,68912,68921,1,68928,68937,1,69734,69743,1,69872,69881,1,69942,69951,1,70096,70105,1,70384,70393,1,70736,70745,1,70864,70873,1,71248,71257,1,71360,71369,1,71376,71395,1,71472,71481,1,71904,71913,1,72016,72025,1,72688,72697,1,72784,72793,1,73040,73049,1,73120,73129,1,73552,73561,1,90416,90425,1,92768,92777,1,92864,92873,1,93008,93017,1,93552,93561,1,118e3,118009,1,120782,120831,1,123200,123209,1,123632,123641,1,124144,124153,1,124401,124410,1,125264,125273,1,130032,130041,1]));static Nl=new K(new Uint32Array([5870,5872,1,8544,8578,1,8581,8584,1,12295,12321,26,12322,12329,1,12344,12346,1,42726,42735,1,65856,65908,1,66369,66378,9,66513,66517,1,74752,74862,1]));static No=new K(new Uint32Array([178,179,1,185,188,3,189,190,1,2548,2553,1,2930,2935,1,3056,3058,1,3192,3198,1,3416,3422,1,3440,3448,1,3882,3891,1,4969,4988,1,6128,6137,1,6618,8304,1686,8308,8313,1,8320,8329,1,8528,8543,1,8585,9312,727,9313,9371,1,9450,9471,1,10102,10131,1,11517,12690,1173,12691,12693,1,12832,12841,1,12872,12879,1,12881,12895,1,12928,12937,1,12977,12991,1,43056,43061,1,65799,65843,1,65909,65912,1,65930,65931,1,66273,66299,1,66336,66339,1,67672,67679,1,67705,67711,1,67751,67759,1,67835,67839,1,67862,67867,1,68028,68029,1,68032,68047,1,68050,68095,1,68160,68168,1,68221,68222,1,68253,68255,1,68331,68335,1,68440,68447,1,68472,68479,1,68521,68527,1,68858,68863,1,69216,69246,1,69405,69414,1,69457,69460,1,69573,69579,1,69714,69733,1,70113,70132,1,71482,71483,1,71914,71922,1,72794,72812,1,73664,73684,1,93019,93025,1,93824,93846,1,119488,119507,1,119520,119539,1,119648,119672,1,125127,125135,1,126065,126123,1,126125,126127,1,126129,126132,1,126209,126253,1,126255,126269,1,127232,127244,1]));static P=new K(new Uint32Array([33,35,1,37,42,1,44,47,1,58,59,1,63,64,1,91,93,1,95,123,28,125,161,36,167,171,4,182,183,1,187,191,4,894,903,9,1370,1375,1,1417,1418,1,1470,1472,2,1475,1478,3,1523,1524,1,1545,1546,1,1548,1549,1,1563,1565,2,1566,1567,1,1642,1645,1,1748,1792,44,1793,1805,1,2039,2041,1,2096,2110,1,2142,2404,262,2405,2416,11,2557,2678,121,2800,3191,391,3204,3572,368,3663,3674,11,3675,3844,169,3845,3858,1,3860,3898,38,3899,3901,1,3973,4048,75,4049,4052,1,4057,4058,1,4170,4175,1,4347,4960,613,4961,4968,1,5120,5742,622,5787,5788,1,5867,5869,1,5941,5942,1,6100,6102,1,6104,6106,1,6144,6154,1,6468,6469,1,6686,6687,1,6816,6822,1,6824,6829,1,6990,6991,1,7002,7008,1,7037,7039,1,7164,7167,1,7227,7231,1,7294,7295,1,7360,7367,1,7379,8208,829,8209,8231,1,8240,8259,1,8261,8273,1,8275,8286,1,8317,8318,1,8333,8334,1,8968,8971,1,9001,9002,1,10088,10101,1,10181,10182,1,10214,10223,1,10627,10648,1,10712,10715,1,10748,10749,1,11513,11516,1,11518,11519,1,11632,11776,144,11777,11822,1,11824,11855,1,11858,11869,1,12289,12291,1,12296,12305,1,12308,12319,1,12336,12349,13,12448,12539,91,42238,42239,1,42509,42511,1,42611,42622,11,42738,42743,1,43124,43127,1,43214,43215,1,43256,43258,1,43260,43310,50,43311,43359,48,43457,43469,1,43486,43487,1,43612,43615,1,43742,43743,1,43760,43761,1,44011,64830,20819,64831,65040,209,65041,65049,1,65072,65106,1,65108,65121,1,65123,65128,5,65130,65131,1,65281,65283,1,65285,65290,1,65292,65295,1,65306,65307,1,65311,65312,1,65339,65341,1,65343,65371,28,65373,65375,2,65376,65381,1,65792,65794,1,66463,66512,49,66927,67671,744,67871,67903,32,68176,68184,1,68223,68336,113,68337,68342,1,68409,68415,1,68505,68508,1,68974,69293,319,69461,69465,1,69510,69513,1,69703,69709,1,69819,69820,1,69822,69825,1,69952,69955,1,70004,70005,1,70085,70088,1,70093,70107,14,70109,70111,1,70200,70205,1,70313,70612,299,70613,70615,2,70616,70731,115,70732,70735,1,70746,70747,1,70749,70854,105,71105,71127,1,71233,71235,1,71264,71276,1,71353,71484,131,71485,71486,1,71739,72004,265,72005,72006,1,72162,72255,93,72256,72262,1,72346,72348,1,72350,72354,1,72448,72457,1,72673,72769,96,72770,72773,1,72816,72817,1,73463,73464,1,73539,73551,1,73727,74864,1137,74865,74868,1,77809,77810,1,92782,92783,1,92917,92983,66,92984,92987,1,92996,93549,553,93550,93551,1,93847,93850,1,94178,113823,19645,121479,121483,1,124415,125278,863,125279,125279,1]));static Pc=new K(new Uint32Array([95,8255,8160,8256,8276,20,65075,65076,1,65101,65103,1,65343,65343,1]));static Pd=new K(new Uint32Array([45,1418,1373,1470,5120,3650,6150,8208,2058,8209,8213,1,11799,11802,3,11834,11835,1,11840,11869,29,12316,12336,20,12448,65073,52625,65074,65112,38,65123,65293,170,68974,69293,319]));static Pe=new K(new Uint32Array([41,93,52,125,3899,3774,3901,5788,1887,8262,8318,56,8334,8969,635,8971,9002,31,10089,10101,2,10182,10215,33,10217,10223,2,10628,10648,2,10713,10715,2,10749,11811,1062,11813,11817,2,11862,11868,2,12297,12305,2,12309,12315,2,12318,12319,1,64830,65048,218,65078,65092,2,65096,65114,18,65116,65118,2,65289,65341,52,65373,65379,3]));static Pf=new K(new Uint32Array([187,8217,8030,8221,8250,29,11779,11781,2,11786,11789,3,11805,11809,4]));static Pi=new K(new Uint32Array([171,8216,8045,8219,8220,1,8223,8249,26,11778,11780,2,11785,11788,3,11804,11808,4]));static Po=new K(new Uint32Array([33,35,1,37,39,1,42,46,2,47,58,11,59,63,4,64,92,28,161,167,6,182,183,1,191,894,703,903,1370,467,1371,1375,1,1417,1472,55,1475,1478,3,1523,1524,1,1545,1546,1,1548,1549,1,1563,1565,2,1566,1567,1,1642,1645,1,1748,1792,44,1793,1805,1,2039,2041,1,2096,2110,1,2142,2404,262,2405,2416,11,2557,2678,121,2800,3191,391,3204,3572,368,3663,3674,11,3675,3844,169,3845,3858,1,3860,3973,113,4048,4052,1,4057,4058,1,4170,4175,1,4347,4960,613,4961,4968,1,5742,5867,125,5868,5869,1,5941,5942,1,6100,6102,1,6104,6106,1,6144,6149,1,6151,6154,1,6468,6469,1,6686,6687,1,6816,6822,1,6824,6829,1,6990,6991,1,7002,7008,1,7037,7039,1,7164,7167,1,7227,7231,1,7294,7295,1,7360,7367,1,7379,8214,835,8215,8224,9,8225,8231,1,8240,8248,1,8251,8254,1,8257,8259,1,8263,8273,1,8275,8277,2,8278,8286,1,11513,11516,1,11518,11519,1,11632,11776,144,11777,11782,5,11783,11784,1,11787,11790,3,11791,11798,1,11800,11801,1,11803,11806,3,11807,11818,11,11819,11822,1,11824,11833,1,11836,11839,1,11841,11843,2,11844,11855,1,11858,11860,1,12289,12291,1,12349,12539,190,42238,42239,1,42509,42511,1,42611,42622,11,42738,42743,1,43124,43127,1,43214,43215,1,43256,43258,1,43260,43310,50,43311,43359,48,43457,43469,1,43486,43487,1,43612,43615,1,43742,43743,1,43760,43761,1,44011,65040,21029,65041,65046,1,65049,65072,23,65093,65094,1,65097,65100,1,65104,65106,1,65108,65111,1,65119,65121,1,65128,65130,2,65131,65281,150,65282,65283,1,65285,65287,1,65290,65294,2,65295,65306,11,65307,65311,4,65312,65340,28,65377,65380,3,65381,65792,411,65793,65794,1,66463,66512,49,66927,67671,744,67871,67903,32,68176,68184,1,68223,68336,113,68337,68342,1,68409,68415,1,68505,68508,1,69461,69465,1,69510,69513,1,69703,69709,1,69819,69820,1,69822,69825,1,69952,69955,1,70004,70005,1,70085,70088,1,70093,70107,14,70109,70111,1,70200,70205,1,70313,70612,299,70613,70615,2,70616,70731,115,70732,70735,1,70746,70747,1,70749,70854,105,71105,71127,1,71233,71235,1,71264,71276,1,71353,71484,131,71485,71486,1,71739,72004,265,72005,72006,1,72162,72255,93,72256,72262,1,72346,72348,1,72350,72354,1,72448,72457,1,72673,72769,96,72770,72773,1,72816,72817,1,73463,73464,1,73539,73551,1,73727,74864,1137,74865,74868,1,77809,77810,1,92782,92783,1,92917,92983,66,92984,92987,1,92996,93549,553,93550,93551,1,93847,93850,1,94178,113823,19645,121479,121483,1,124415,125278,863,125279,125279,1]));static Ps=new K(new Uint32Array([40,91,51,123,3898,3775,3900,5787,1887,8218,8222,4,8261,8317,56,8333,8968,635,8970,9001,31,10088,10100,2,10181,10214,33,10216,10222,2,10627,10647,2,10712,10714,2,10748,11810,1062,11812,11816,2,11842,11861,19,11863,11867,2,12296,12304,2,12308,12314,2,12317,64831,52514,65047,65077,30,65079,65091,2,65095,65113,18,65115,65117,2,65288,65339,51,65371,65375,4,65378,65378,1]));static S=new K(new Uint32Array([36,43,7,60,62,1,94,96,2,124,126,2,162,166,1,168,169,1,172,174,2,175,177,1,180,184,4,215,247,32,706,709,1,722,735,1,741,747,1,749,751,2,752,767,1,885,900,15,901,1014,113,1154,1421,267,1422,1423,1,1542,1544,1,1547,1550,3,1551,1758,207,1769,1789,20,1790,2038,248,2046,2047,1,2184,2546,362,2547,2554,7,2555,2801,246,2928,3059,131,3060,3066,1,3199,3407,208,3449,3647,198,3841,3843,1,3859,3861,2,3862,3863,1,3866,3871,1,3892,3896,2,4030,4037,1,4039,4044,1,4046,4047,1,4053,4056,1,4254,4255,1,5008,5017,1,5741,6107,366,6464,6622,158,6623,6655,1,7009,7018,1,7028,7036,1,8125,8127,2,8128,8129,1,8141,8143,1,8157,8159,1,8173,8175,1,8189,8190,1,8260,8274,14,8314,8316,1,8330,8332,1,8352,8384,1,8448,8449,1,8451,8454,1,8456,8457,1,8468,8470,2,8471,8472,1,8478,8483,1,8485,8489,2,8494,8506,12,8507,8512,5,8513,8516,1,8522,8525,1,8527,8586,59,8587,8592,5,8593,8967,1,8972,9e3,1,9003,9257,1,9280,9290,1,9372,9449,1,9472,10087,1,10132,10180,1,10183,10213,1,10224,10626,1,10649,10711,1,10716,10747,1,10750,11123,1,11126,11157,1,11159,11263,1,11493,11498,1,11856,11857,1,11904,11929,1,11931,12019,1,12032,12245,1,12272,12287,1,12292,12306,14,12307,12320,13,12342,12343,1,12350,12351,1,12443,12444,1,12688,12689,1,12694,12703,1,12736,12773,1,12783,12800,17,12801,12830,1,12842,12871,1,12880,12896,16,12897,12927,1,12938,12976,1,12992,13311,1,19904,19967,1,42128,42182,1,42752,42774,1,42784,42785,1,42889,42890,1,43048,43051,1,43062,43065,1,43639,43641,1,43867,43882,15,43883,64297,20414,64434,64450,1,64832,64847,1,64975,65020,45,65021,65023,1,65122,65124,2,65125,65126,1,65129,65284,155,65291,65308,17,65309,65310,1,65342,65344,2,65372,65374,2,65504,65510,1,65512,65518,1,65532,65533,1,65847,65855,1,65913,65929,1,65932,65934,1,65936,65948,1,65952,66e3,48,66001,66044,1,67703,67704,1,68296,69006,710,69007,71487,2480,73685,73713,1,92988,92991,1,92997,113820,20823,117760,117999,1,118016,118451,1,118608,118723,1,118784,119029,1,119040,119078,1,119081,119140,1,119146,119148,1,119171,119172,1,119180,119209,1,119214,119274,1,119296,119361,1,119365,119552,187,119553,119638,1,120513,120539,26,120571,120597,26,120629,120655,26,120687,120713,26,120745,120771,26,120832,121343,1,121399,121402,1,121453,121460,1,121462,121475,1,121477,121478,1,123215,123647,432,126124,126128,4,126254,126704,450,126705,126976,271,126977,127019,1,127024,127123,1,127136,127150,1,127153,127167,1,127169,127183,1,127185,127221,1,127245,127405,1,127462,127490,1,127504,127547,1,127552,127560,1,127568,127569,1,127584,127589,1,127744,128727,1,128732,128748,1,128752,128764,1,128768,128886,1,128891,128985,1,128992,129003,1,129008,129024,16,129025,129035,1,129040,129095,1,129104,129113,1,129120,129159,1,129168,129197,1,129200,129211,1,129216,129217,1,129280,129619,1,129632,129645,1,129648,129660,1,129664,129673,1,129679,129734,1,129742,129756,1,129759,129769,1,129776,129784,1,129792,129938,1,129940,130031,1]));static Sc=new K(new Uint32Array([36,162,126,163,165,1,1423,1547,124,2046,2047,1,2546,2547,1,2555,2801,246,3065,3647,582,6107,8352,2245,8353,8384,1,43064,65020,21956,65129,65284,155,65504,65505,1,65509,65510,1,73693,73696,1,123647,126128,2481]));static Sk=new K(new Uint32Array([94,96,2,168,175,7,180,184,4,706,709,1,722,735,1,741,747,1,749,751,2,752,767,1,885,900,15,901,2184,1283,8125,8127,2,8128,8129,1,8141,8143,1,8157,8159,1,8173,8175,1,8189,8190,1,12443,12444,1,42752,42774,1,42784,42785,1,42889,42890,1,43867,43882,15,43883,64434,20551,64435,64450,1,65342,65344,2,65507,127995,62488,127996,127999,1]));static Sm=new K(new Uint32Array([43,60,17,61,62,1,124,126,2,172,177,5,215,247,32,1014,1542,528,1543,1544,1,8260,8274,14,8314,8316,1,8330,8332,1,8472,8512,40,8513,8516,1,8523,8592,69,8593,8596,1,8602,8603,1,8608,8614,3,8622,8654,32,8655,8658,3,8660,8692,32,8693,8959,1,8992,8993,1,9084,9115,31,9116,9139,1,9180,9185,1,9655,9665,10,9720,9727,1,9839,10176,337,10177,10180,1,10183,10213,1,10224,10239,1,10496,10626,1,10649,10711,1,10716,10747,1,10750,11007,1,11056,11076,1,11079,11084,1,64297,65122,825,65124,65126,1,65291,65308,17,65309,65310,1,65372,65374,2,65506,65513,7,65514,65516,1,69006,69007,1,120513,120539,26,120571,120597,26,120629,120655,26,120687,120713,26,120745,120771,26,126704,126705,1]));static So=new K(new Uint32Array([166,169,3,174,176,2,1154,1421,267,1422,1550,128,1551,1758,207,1769,1789,20,1790,2038,248,2554,2928,374,3059,3064,1,3066,3199,133,3407,3449,42,3841,3843,1,3859,3861,2,3862,3863,1,3866,3871,1,3892,3896,2,4030,4037,1,4039,4044,1,4046,4047,1,4053,4056,1,4254,4255,1,5008,5017,1,5741,6464,723,6622,6655,1,7009,7018,1,7028,7036,1,8448,8449,1,8451,8454,1,8456,8457,1,8468,8470,2,8471,8478,7,8479,8483,1,8485,8489,2,8494,8506,12,8507,8522,15,8524,8525,1,8527,8586,59,8587,8597,10,8598,8601,1,8604,8607,1,8609,8610,1,8612,8613,1,8615,8621,1,8623,8653,1,8656,8657,1,8659,8661,2,8662,8691,1,8960,8967,1,8972,8991,1,8994,9e3,1,9003,9083,1,9085,9114,1,9140,9179,1,9186,9257,1,9280,9290,1,9372,9449,1,9472,9654,1,9656,9664,1,9666,9719,1,9728,9838,1,9840,10087,1,10132,10175,1,10240,10495,1,11008,11055,1,11077,11078,1,11085,11123,1,11126,11157,1,11159,11263,1,11493,11498,1,11856,11857,1,11904,11929,1,11931,12019,1,12032,12245,1,12272,12287,1,12292,12306,14,12307,12320,13,12342,12343,1,12350,12351,1,12688,12689,1,12694,12703,1,12736,12773,1,12783,12800,17,12801,12830,1,12842,12871,1,12880,12896,16,12897,12927,1,12938,12976,1,12992,13311,1,19904,19967,1,42128,42182,1,43048,43051,1,43062,43063,1,43065,43639,574,43640,43641,1,64832,64847,1,64975,65021,46,65022,65023,1,65508,65512,4,65517,65518,1,65532,65533,1,65847,65855,1,65913,65929,1,65932,65934,1,65936,65948,1,65952,66e3,48,66001,66044,1,67703,67704,1,68296,71487,3191,73685,73692,1,73697,73713,1,92988,92991,1,92997,113820,20823,117760,117999,1,118016,118451,1,118608,118723,1,118784,119029,1,119040,119078,1,119081,119140,1,119146,119148,1,119171,119172,1,119180,119209,1,119214,119274,1,119296,119361,1,119365,119552,187,119553,119638,1,120832,121343,1,121399,121402,1,121453,121460,1,121462,121475,1,121477,121478,1,123215,126124,2909,126254,126976,722,126977,127019,1,127024,127123,1,127136,127150,1,127153,127167,1,127169,127183,1,127185,127221,1,127245,127405,1,127462,127490,1,127504,127547,1,127552,127560,1,127568,127569,1,127584,127589,1,127744,127994,1,128e3,128727,1,128732,128748,1,128752,128764,1,128768,128886,1,128891,128985,1,128992,129003,1,129008,129024,16,129025,129035,1,129040,129095,1,129104,129113,1,129120,129159,1,129168,129197,1,129200,129211,1,129216,129217,1,129280,129619,1,129632,129645,1,129648,129660,1,129664,129673,1,129679,129734,1,129742,129756,1,129759,129769,1,129776,129784,1,129792,129938,1,129940,130031,1]));static Z=new K(new Uint32Array([32,160,128,5760,8192,2432,8193,8202,1,8232,8233,1,8239,8287,48,12288,12288,1]));static Zl=new K(new Uint32Array([8232,8232,1]));static Zp=new K(new Uint32Array([8233,8233,1]));static Zs=new K(new Uint32Array([32,160,128,5760,8192,2432,8193,8202,1,8239,8287,48,12288,12288,1]));static Adlam=new K(new Uint32Array([125184,125259,1,125264,125273,1,125278,125279,1]));static Ahom=new K(new Uint32Array([71424,71450,1,71453,71467,1,71472,71494,1]));static Anatolian_Hieroglyphs=new K(new Uint32Array([82944,83526,1]));static Arabic=new K(new Uint32Array([1536,1540,1,1542,1547,1,1549,1562,1,1564,1566,1,1568,1599,1,1601,1610,1,1622,1647,1,1649,1756,1,1758,1791,1,1872,1919,1,2160,2190,1,2192,2193,1,2199,2273,1,2275,2303,1,64336,64450,1,64467,64829,1,64832,64911,1,64914,64967,1,64975,65008,33,65009,65023,1,65136,65140,1,65142,65276,1,69216,69246,1,69314,69316,1,69372,69375,1,126464,126467,1,126469,126495,1,126497,126498,1,126500,126503,3,126505,126514,1,126516,126519,1,126521,126523,2,126530,126535,5,126537,126541,2,126542,126543,1,126545,126546,1,126548,126551,3,126553,126561,2,126562,126564,2,126567,126570,1,126572,126578,1,126580,126583,1,126585,126588,1,126590,126592,2,126593,126601,1,126603,126619,1,126625,126627,1,126629,126633,1,126635,126651,1,126704,126705,1]));static Armenian=new K(new Uint32Array([1329,1366,1,1369,1418,1,1421,1423,1,64275,64279,1]));static Avestan=new K(new Uint32Array([68352,68405,1,68409,68415,1]));static Balinese=new K(new Uint32Array([6912,6988,1,6990,7039,1]));static Bamum=new K(new Uint32Array([42656,42743,1,92160,92728,1]));static Bassa_Vah=new K(new Uint32Array([92880,92909,1,92912,92917,1]));static Batak=new K(new Uint32Array([7104,7155,1,7164,7167,1]));static Bengali=new K(new Uint32Array([2432,2435,1,2437,2444,1,2447,2448,1,2451,2472,1,2474,2480,1,2482,2486,4,2487,2489,1,2492,2500,1,2503,2504,1,2507,2510,1,2519,2524,5,2525,2527,2,2528,2531,1,2534,2558,1]));static Bhaiksuki=new K(new Uint32Array([72704,72712,1,72714,72758,1,72760,72773,1,72784,72812,1]));static Bopomofo=new K(new Uint32Array([746,747,1,12549,12591,1,12704,12735,1]));static Brahmi=new K(new Uint32Array([69632,69709,1,69714,69749,1,69759,69759,1]));static Braille=new K(new Uint32Array([10240,10495,1]));static Buginese=new K(new Uint32Array([6656,6683,1,6686,6687,1]));static Buhid=new K(new Uint32Array([5952,5971,1]));static Canadian_Aboriginal=new K(new Uint32Array([5120,5759,1,6320,6389,1,72368,72383,1]));static Carian=new K(new Uint32Array([66208,66256,1]));static Caucasian_Albanian=new K(new Uint32Array([66864,66915,1,66927,66927,1]));static Chakma=new K(new Uint32Array([69888,69940,1,69942,69959,1]));static Cham=new K(new Uint32Array([43520,43574,1,43584,43597,1,43600,43609,1,43612,43615,1]));static Cherokee=new K(new Uint32Array([5024,5109,1,5112,5117,1,43888,43967,1]));static Chorasmian=new K(new Uint32Array([69552,69579,1]));static Common=new K(new Uint32Array([0,64,1,91,96,1,123,169,1,171,185,1,187,191,1,215,247,32,697,735,1,741,745,1,748,767,1,884,894,10,901,903,2,1541,1548,7,1563,1567,4,1600,1757,157,2274,2404,130,2405,3647,1242,4053,4056,1,4347,5867,1520,5868,5869,1,5941,5942,1,6146,6147,1,6149,7379,1230,7393,7401,8,7402,7404,1,7406,7411,1,7413,7415,1,7418,8192,774,8193,8203,1,8206,8292,1,8294,8304,1,8308,8318,1,8320,8334,1,8352,8384,1,8448,8485,1,8487,8489,1,8492,8497,1,8499,8525,1,8527,8543,1,8585,8587,1,8592,9257,1,9280,9290,1,9312,10239,1,10496,11123,1,11126,11157,1,11159,11263,1,11776,11869,1,12272,12292,1,12294,12296,2,12297,12320,1,12336,12343,1,12348,12351,1,12443,12444,1,12448,12539,91,12540,12688,148,12689,12703,1,12736,12773,1,12783,12832,49,12833,12895,1,12927,13007,1,13055,13144,89,13145,13311,1,19904,19967,1,42752,42785,1,42888,42890,1,43056,43065,1,43310,43471,161,43867,43882,15,43883,64830,20947,64831,65040,209,65041,65049,1,65072,65106,1,65108,65126,1,65128,65131,1,65279,65281,2,65282,65312,1,65339,65344,1,65371,65381,1,65392,65438,46,65439,65504,65,65505,65510,1,65512,65518,1,65529,65533,1,65792,65794,1,65799,65843,1,65847,65855,1,65936,65948,1,66e3,66044,1,66273,66299,1,113824,113827,1,117760,118009,1,118016,118451,1,118608,118723,1,118784,119029,1,119040,119078,1,119081,119142,1,119146,119162,1,119171,119172,1,119180,119209,1,119214,119274,1,119488,119507,1,119520,119539,1,119552,119638,1,119648,119672,1,119808,119892,1,119894,119964,1,119966,119967,1,119970,119973,3,119974,119977,3,119978,119980,1,119982,119993,1,119995,119997,2,119998,120003,1,120005,120069,1,120071,120074,1,120077,120084,1,120086,120092,1,120094,120121,1,120123,120126,1,120128,120132,1,120134,120138,4,120139,120144,1,120146,120485,1,120488,120779,1,120782,120831,1,126065,126132,1,126209,126269,1,126976,127019,1,127024,127123,1,127136,127150,1,127153,127167,1,127169,127183,1,127185,127221,1,127232,127405,1,127462,127487,1,127489,127490,1,127504,127547,1,127552,127560,1,127568,127569,1,127584,127589,1,127744,128727,1,128732,128748,1,128752,128764,1,128768,128886,1,128891,128985,1,128992,129003,1,129008,129024,16,129025,129035,1,129040,129095,1,129104,129113,1,129120,129159,1,129168,129197,1,129200,129211,1,129216,129217,1,129280,129619,1,129632,129645,1,129648,129660,1,129664,129673,1,129679,129734,1,129742,129756,1,129759,129769,1,129776,129784,1,129792,129938,1,129940,130041,1,917505,917536,31,917537,917631,1]));static foldCommon=new K(new Uint32Array([924,956,32]));static Coptic=new K(new Uint32Array([994,1007,1,11392,11507,1,11513,11519,1]));static Cuneiform=new K(new Uint32Array([73728,74649,1,74752,74862,1,74864,74868,1,74880,75075,1]));static Cypriot=new K(new Uint32Array([67584,67589,1,67592,67594,2,67595,67637,1,67639,67640,1,67644,67647,3]));static Cypro_Minoan=new K(new Uint32Array([77712,77810,1]));static Cyrillic=new K(new Uint32Array([1024,1156,1,1159,1327,1,7296,7306,1,7467,7544,77,11744,11775,1,42560,42655,1,65070,65071,1,122928,122989,1,123023,123023,1]));static Deseret=new K(new Uint32Array([66560,66639,1]));static Devanagari=new K(new Uint32Array([2304,2384,1,2389,2403,1,2406,2431,1,43232,43263,1,72448,72457,1]));static Dives_Akuru=new K(new Uint32Array([71936,71942,1,71945,71948,3,71949,71955,1,71957,71958,1,71960,71989,1,71991,71992,1,71995,72006,1,72016,72025,1]));static Dogra=new K(new Uint32Array([71680,71739,1]));static Duployan=new K(new Uint32Array([113664,113770,1,113776,113788,1,113792,113800,1,113808,113817,1,113820,113823,1]));static Egyptian_Hieroglyphs=new K(new Uint32Array([77824,78933,1,78944,82938,1]));static Elbasan=new K(new Uint32Array([66816,66855,1]));static Elymaic=new K(new Uint32Array([69600,69622,1]));static Ethiopic=new K(new Uint32Array([4608,4680,1,4682,4685,1,4688,4694,1,4696,4698,2,4699,4701,1,4704,4744,1,4746,4749,1,4752,4784,1,4786,4789,1,4792,4798,1,4800,4802,2,4803,4805,1,4808,4822,1,4824,4880,1,4882,4885,1,4888,4954,1,4957,4988,1,4992,5017,1,11648,11670,1,11680,11686,1,11688,11694,1,11696,11702,1,11704,11710,1,11712,11718,1,11720,11726,1,11728,11734,1,11736,11742,1,43777,43782,1,43785,43790,1,43793,43798,1,43808,43814,1,43816,43822,1,124896,124902,1,124904,124907,1,124909,124910,1,124912,124926,1]));static Garay=new K(new Uint32Array([68928,68965,1,68969,68997,1,69006,69007,1]));static Georgian=new K(new Uint32Array([4256,4293,1,4295,4301,6,4304,4346,1,4348,4351,1,7312,7354,1,7357,7359,1,11520,11557,1,11559,11565,6]));static Glagolitic=new K(new Uint32Array([11264,11359,1,122880,122886,1,122888,122904,1,122907,122913,1,122915,122916,1,122918,122922,1]));static Gothic=new K(new Uint32Array([66352,66378,1]));static Grantha=new K(new Uint32Array([70400,70403,1,70405,70412,1,70415,70416,1,70419,70440,1,70442,70448,1,70450,70451,1,70453,70457,1,70460,70468,1,70471,70472,1,70475,70477,1,70480,70487,7,70493,70499,1,70502,70508,1,70512,70516,1]));static Greek=new K(new Uint32Array([880,883,1,885,887,1,890,893,1,895,900,5,902,904,2,905,906,1,908,910,2,911,929,1,931,993,1,1008,1023,1,7462,7466,1,7517,7521,1,7526,7530,1,7615,7936,321,7937,7957,1,7960,7965,1,7968,8005,1,8008,8013,1,8016,8023,1,8025,8031,2,8032,8061,1,8064,8116,1,8118,8132,1,8134,8147,1,8150,8155,1,8157,8175,1,8178,8180,1,8182,8190,1,8486,43877,35391,65856,65934,1,65952,119296,53344,119297,119365,1]));static foldGreek=new K(new Uint32Array([181,837,656]));static Gujarati=new K(new Uint32Array([2689,2691,1,2693,2701,1,2703,2705,1,2707,2728,1,2730,2736,1,2738,2739,1,2741,2745,1,2748,2757,1,2759,2761,1,2763,2765,1,2768,2784,16,2785,2787,1,2790,2801,1,2809,2815,1]));static Gunjala_Gondi=new K(new Uint32Array([73056,73061,1,73063,73064,1,73066,73102,1,73104,73105,1,73107,73112,1,73120,73129,1]));static Gurmukhi=new K(new Uint32Array([2561,2563,1,2565,2570,1,2575,2576,1,2579,2600,1,2602,2608,1,2610,2611,1,2613,2614,1,2616,2617,1,2620,2622,2,2623,2626,1,2631,2632,1,2635,2637,1,2641,2649,8,2650,2652,1,2654,2662,8,2663,2678,1]));static Gurung_Khema=new K(new Uint32Array([90368,90425,1]));static Han=new K(new Uint32Array([11904,11929,1,11931,12019,1,12032,12245,1,12293,12295,2,12321,12329,1,12344,12347,1,13312,19903,1,19968,40959,1,63744,64109,1,64112,64217,1,94178,94179,1,94192,94193,1,131072,173791,1,173824,177977,1,177984,178205,1,178208,183969,1,183984,191456,1,191472,192093,1,194560,195101,1,196608,201546,1,201552,205743,1]));static Hangul=new K(new Uint32Array([4352,4607,1,12334,12335,1,12593,12686,1,12800,12830,1,12896,12926,1,43360,43388,1,44032,55203,1,55216,55238,1,55243,55291,1,65440,65470,1,65474,65479,1,65482,65487,1,65490,65495,1,65498,65500,1]));static Hanifi_Rohingya=new K(new Uint32Array([68864,68903,1,68912,68921,1]));static Hanunoo=new K(new Uint32Array([5920,5940,1]));static Hatran=new K(new Uint32Array([67808,67826,1,67828,67829,1,67835,67839,1]));static Hebrew=new K(new Uint32Array([1425,1479,1,1488,1514,1,1519,1524,1,64285,64310,1,64312,64316,1,64318,64320,2,64321,64323,2,64324,64326,2,64327,64335,1]));static Hiragana=new K(new Uint32Array([12353,12438,1,12445,12447,1,110593,110879,1,110898,110928,30,110929,110930,1,127488,127488,1]));static Imperial_Aramaic=new K(new Uint32Array([67648,67669,1,67671,67679,1]));static Inherited=new K(new Uint32Array([768,879,1,1157,1158,1,1611,1621,1,1648,2385,737,2386,2388,1,6832,6862,1,7376,7378,1,7380,7392,1,7394,7400,1,7405,7412,7,7416,7417,1,7616,7679,1,8204,8205,1,8400,8432,1,12330,12333,1,12441,12442,1,65024,65039,1,65056,65069,1,66045,66272,227,70459,118528,48069,118529,118573,1,118576,118598,1,119143,119145,1,119163,119170,1,119173,119179,1,119210,119213,1,917760,917999,1]));static foldInherited=new K(new Uint32Array([921,953,32,8126,8126,1]));static Inscriptional_Pahlavi=new K(new Uint32Array([68448,68466,1,68472,68479,1]));static Inscriptional_Parthian=new K(new Uint32Array([68416,68437,1,68440,68447,1]));static Javanese=new K(new Uint32Array([43392,43469,1,43472,43481,1,43486,43487,1]));static Kaithi=new K(new Uint32Array([69760,69826,1,69837,69837,1]));static Kannada=new K(new Uint32Array([3200,3212,1,3214,3216,1,3218,3240,1,3242,3251,1,3253,3257,1,3260,3268,1,3270,3272,1,3274,3277,1,3285,3286,1,3293,3294,1,3296,3299,1,3302,3311,1,3313,3315,1]));static Katakana=new K(new Uint32Array([12449,12538,1,12541,12543,1,12784,12799,1,13008,13054,1,13056,13143,1,65382,65391,1,65393,65437,1,110576,110579,1,110581,110587,1,110589,110590,1,110592,110880,288,110881,110882,1,110933,110948,15,110949,110951,1]));static Kawi=new K(new Uint32Array([73472,73488,1,73490,73530,1,73534,73562,1]));static Kayah_Li=new K(new Uint32Array([43264,43309,1,43311,43311,1]));static Kharoshthi=new K(new Uint32Array([68096,68099,1,68101,68102,1,68108,68115,1,68117,68119,1,68121,68149,1,68152,68154,1,68159,68168,1,68176,68184,1]));static Khitan_Small_Script=new K(new Uint32Array([94180,101120,6940,101121,101589,1,101631,101631,1]));static Khmer=new K(new Uint32Array([6016,6109,1,6112,6121,1,6128,6137,1,6624,6655,1]));static Khojki=new K(new Uint32Array([70144,70161,1,70163,70209,1]));static Khudawadi=new K(new Uint32Array([70320,70378,1,70384,70393,1]));static Kirat_Rai=new K(new Uint32Array([93504,93561,1]));static Lao=new K(new Uint32Array([3713,3714,1,3716,3718,2,3719,3722,1,3724,3747,1,3749,3751,2,3752,3773,1,3776,3780,1,3782,3784,2,3785,3790,1,3792,3801,1,3804,3807,1]));static Latin=new K(new Uint32Array([65,90,1,97,122,1,170,186,16,192,214,1,216,246,1,248,696,1,736,740,1,7424,7461,1,7468,7516,1,7522,7525,1,7531,7543,1,7545,7614,1,7680,7935,1,8305,8319,14,8336,8348,1,8490,8491,1,8498,8526,28,8544,8584,1,11360,11391,1,42786,42887,1,42891,42957,1,42960,42961,1,42963,42965,2,42966,42972,1,42994,43007,1,43824,43866,1,43868,43876,1,43878,43881,1,64256,64262,1,65313,65338,1,65345,65370,1,67456,67461,1,67463,67504,1,67506,67514,1,122624,122654,1,122661,122666,1]));static Lepcha=new K(new Uint32Array([7168,7223,1,7227,7241,1,7245,7247,1]));static Limbu=new K(new Uint32Array([6400,6430,1,6432,6443,1,6448,6459,1,6464,6468,4,6469,6479,1]));static Linear_A=new K(new Uint32Array([67072,67382,1,67392,67413,1,67424,67431,1]));static Linear_B=new K(new Uint32Array([65536,65547,1,65549,65574,1,65576,65594,1,65596,65597,1,65599,65613,1,65616,65629,1,65664,65786,1]));static Lisu=new K(new Uint32Array([42192,42239,1,73648,73648,1]));static Lycian=new K(new Uint32Array([66176,66204,1]));static Lydian=new K(new Uint32Array([67872,67897,1,67903,67903,1]));static Mahajani=new K(new Uint32Array([69968,70006,1]));static Makasar=new K(new Uint32Array([73440,73464,1]));static Malayalam=new K(new Uint32Array([3328,3340,1,3342,3344,1,3346,3396,1,3398,3400,1,3402,3407,1,3412,3427,1,3430,3455,1]));static Mandaic=new K(new Uint32Array([2112,2139,1,2142,2142,1]));static Manichaean=new K(new Uint32Array([68288,68326,1,68331,68342,1]));static Marchen=new K(new Uint32Array([72816,72847,1,72850,72871,1,72873,72886,1]));static Masaram_Gondi=new K(new Uint32Array([72960,72966,1,72968,72969,1,72971,73014,1,73018,73020,2,73021,73023,2,73024,73031,1,73040,73049,1]));static Medefaidrin=new K(new Uint32Array([93760,93850,1]));static Meetei_Mayek=new K(new Uint32Array([43744,43766,1,43968,44013,1,44016,44025,1]));static Mende_Kikakui=new K(new Uint32Array([124928,125124,1,125127,125142,1]));static Meroitic_Cursive=new K(new Uint32Array([68e3,68023,1,68028,68047,1,68050,68095,1]));static Meroitic_Hieroglyphs=new K(new Uint32Array([67968,67999,1]));static Miao=new K(new Uint32Array([93952,94026,1,94031,94087,1,94095,94111,1]));static Modi=new K(new Uint32Array([71168,71236,1,71248,71257,1]));static Mongolian=new K(new Uint32Array([6144,6145,1,6148,6150,2,6151,6169,1,6176,6264,1,6272,6314,1,71264,71276,1]));static Mro=new K(new Uint32Array([92736,92766,1,92768,92777,1,92782,92783,1]));static Multani=new K(new Uint32Array([70272,70278,1,70280,70282,2,70283,70285,1,70287,70301,1,70303,70313,1]));static Myanmar=new K(new Uint32Array([4096,4255,1,43488,43518,1,43616,43647,1,71376,71395,1]));static Nabataean=new K(new Uint32Array([67712,67742,1,67751,67759,1]));static Nag_Mundari=new K(new Uint32Array([124112,124153,1]));static Nandinagari=new K(new Uint32Array([72096,72103,1,72106,72151,1,72154,72164,1]));static New_Tai_Lue=new K(new Uint32Array([6528,6571,1,6576,6601,1,6608,6618,1,6622,6623,1]));static Newa=new K(new Uint32Array([70656,70747,1,70749,70753,1]));static Nko=new K(new Uint32Array([1984,2042,1,2045,2047,1]));static Nushu=new K(new Uint32Array([94177,110960,16783,110961,111355,1]));static Nyiakeng_Puachue_Hmong=new K(new Uint32Array([123136,123180,1,123184,123197,1,123200,123209,1,123214,123215,1]));static Ogham=new K(new Uint32Array([5760,5788,1]));static Ol_Chiki=new K(new Uint32Array([7248,7295,1]));static Ol_Onal=new K(new Uint32Array([124368,124410,1,124415,124415,1]));static Old_Hungarian=new K(new Uint32Array([68736,68786,1,68800,68850,1,68858,68863,1]));static Old_Italic=new K(new Uint32Array([66304,66339,1,66349,66351,1]));static Old_North_Arabian=new K(new Uint32Array([68224,68255,1]));static Old_Permic=new K(new Uint32Array([66384,66426,1]));static Old_Persian=new K(new Uint32Array([66464,66499,1,66504,66517,1]));static Old_Sogdian=new K(new Uint32Array([69376,69415,1]));static Old_South_Arabian=new K(new Uint32Array([68192,68223,1]));static Old_Turkic=new K(new Uint32Array([68608,68680,1]));static Old_Uyghur=new K(new Uint32Array([69488,69513,1]));static Oriya=new K(new Uint32Array([2817,2819,1,2821,2828,1,2831,2832,1,2835,2856,1,2858,2864,1,2866,2867,1,2869,2873,1,2876,2884,1,2887,2888,1,2891,2893,1,2901,2903,1,2908,2909,1,2911,2915,1,2918,2935,1]));static Osage=new K(new Uint32Array([66736,66771,1,66776,66811,1]));static Osmanya=new K(new Uint32Array([66688,66717,1,66720,66729,1]));static Pahawh_Hmong=new K(new Uint32Array([92928,92997,1,93008,93017,1,93019,93025,1,93027,93047,1,93053,93071,1]));static Palmyrene=new K(new Uint32Array([67680,67711,1]));static Pau_Cin_Hau=new K(new Uint32Array([72384,72440,1]));static Phags_Pa=new K(new Uint32Array([43072,43127,1]));static Phoenician=new K(new Uint32Array([67840,67867,1,67871,67871,1]));static Psalter_Pahlavi=new K(new Uint32Array([68480,68497,1,68505,68508,1,68521,68527,1]));static Rejang=new K(new Uint32Array([43312,43347,1,43359,43359,1]));static Runic=new K(new Uint32Array([5792,5866,1,5870,5880,1]));static Samaritan=new K(new Uint32Array([2048,2093,1,2096,2110,1]));static Saurashtra=new K(new Uint32Array([43136,43205,1,43214,43225,1]));static Sharada=new K(new Uint32Array([70016,70111,1]));static Shavian=new K(new Uint32Array([66640,66687,1]));static Siddham=new K(new Uint32Array([71040,71093,1,71096,71133,1]));static SignWriting=new K(new Uint32Array([120832,121483,1,121499,121503,1,121505,121519,1]));static Sinhala=new K(new Uint32Array([3457,3459,1,3461,3478,1,3482,3505,1,3507,3515,1,3517,3520,3,3521,3526,1,3530,3535,5,3536,3540,1,3542,3544,2,3545,3551,1,3558,3567,1,3570,3572,1,70113,70132,1]));static Sogdian=new K(new Uint32Array([69424,69465,1]));static Sora_Sompeng=new K(new Uint32Array([69840,69864,1,69872,69881,1]));static Soyombo=new K(new Uint32Array([72272,72354,1]));static Sundanese=new K(new Uint32Array([7040,7103,1,7360,7367,1]));static Sunuwar=new K(new Uint32Array([72640,72673,1,72688,72697,1]));static Syloti_Nagri=new K(new Uint32Array([43008,43052,1]));static Syriac=new K(new Uint32Array([1792,1805,1,1807,1866,1,1869,1871,1,2144,2154,1]));static Tagalog=new K(new Uint32Array([5888,5909,1,5919,5919,1]));static Tagbanwa=new K(new Uint32Array([5984,5996,1,5998,6e3,1,6002,6003,1]));static Tai_Le=new K(new Uint32Array([6480,6509,1,6512,6516,1]));static Tai_Tham=new K(new Uint32Array([6688,6750,1,6752,6780,1,6783,6793,1,6800,6809,1,6816,6829,1]));static Tai_Viet=new K(new Uint32Array([43648,43714,1,43739,43743,1]));static Takri=new K(new Uint32Array([71296,71353,1,71360,71369,1]));static Tamil=new K(new Uint32Array([2946,2947,1,2949,2954,1,2958,2960,1,2962,2965,1,2969,2970,1,2972,2974,2,2975,2979,4,2980,2984,4,2985,2986,1,2990,3001,1,3006,3010,1,3014,3016,1,3018,3021,1,3024,3031,7,3046,3066,1,73664,73713,1,73727,73727,1]));static Tangsa=new K(new Uint32Array([92784,92862,1,92864,92873,1]));static Tangut=new K(new Uint32Array([94176,94208,32,94209,100343,1,100352,101119,1,101632,101640,1]));static Telugu=new K(new Uint32Array([3072,3084,1,3086,3088,1,3090,3112,1,3114,3129,1,3132,3140,1,3142,3144,1,3146,3149,1,3157,3158,1,3160,3162,1,3165,3168,3,3169,3171,1,3174,3183,1,3191,3199,1]));static Thaana=new K(new Uint32Array([1920,1969,1]));static Thai=new K(new Uint32Array([3585,3642,1,3648,3675,1]));static Tibetan=new K(new Uint32Array([3840,3911,1,3913,3948,1,3953,3991,1,3993,4028,1,4030,4044,1,4046,4052,1,4057,4058,1]));static Tifinagh=new K(new Uint32Array([11568,11623,1,11631,11632,1,11647,11647,1]));static Tirhuta=new K(new Uint32Array([70784,70855,1,70864,70873,1]));static Todhri=new K(new Uint32Array([67008,67059,1]));static Toto=new K(new Uint32Array([123536,123566,1]));static Tulu_Tigalari=new K(new Uint32Array([70528,70537,1,70539,70542,3,70544,70581,1,70583,70592,1,70594,70597,3,70599,70602,1,70604,70613,1,70615,70616,1,70625,70626,1]));static Ugaritic=new K(new Uint32Array([66432,66461,1,66463,66463,1]));static Vai=new K(new Uint32Array([42240,42539,1]));static Vithkuqi=new K(new Uint32Array([66928,66938,1,66940,66954,1,66956,66962,1,66964,66965,1,66967,66977,1,66979,66993,1,66995,67001,1,67003,67004,1]));static Wancho=new K(new Uint32Array([123584,123641,1,123647,123647,1]));static Warang_Citi=new K(new Uint32Array([71840,71922,1,71935,71935,1]));static Yezidi=new K(new Uint32Array([69248,69289,1,69291,69293,1,69296,69297,1]));static Yi=new K(new Uint32Array([40960,42124,1,42128,42182,1]));static Zanabazar_Square=new K(new Uint32Array([72192,72263,1]));static CATEGORIES=new Map([[`C`,e.C],[`Cc`,e.Cc],[`Cf`,e.Cf],[`Co`,e.Co],[`Cs`,e.Cs],[`L`,e.L],[`Ll`,e.Ll],[`Lm`,e.Lm],[`Lo`,e.Lo],[`Lt`,e.Lt],[`Lu`,e.Lu],[`M`,e.M],[`Mc`,e.Mc],[`Me`,e.Me],[`Mn`,e.Mn],[`N`,e.N],[`Nd`,e.Nd],[`Nl`,e.Nl],[`No`,e.No],[`P`,e.P],[`Pc`,e.Pc],[`Pd`,e.Pd],[`Pe`,e.Pe],[`Pf`,e.Pf],[`Pi`,e.Pi],[`Po`,e.Po],[`Ps`,e.Ps],[`S`,e.S],[`Sc`,e.Sc],[`Sk`,e.Sk],[`Sm`,e.Sm],[`So`,e.So],[`Z`,e.Z],[`Zl`,e.Zl],[`Zp`,e.Zp],[`Zs`,e.Zs]]);static SCRIPTS=new Map([[`Adlam`,e.Adlam],[`Ahom`,e.Ahom],[`Anatolian_Hieroglyphs`,e.Anatolian_Hieroglyphs],[`Arabic`,e.Arabic],[`Armenian`,e.Armenian],[`Avestan`,e.Avestan],[`Balinese`,e.Balinese],[`Bamum`,e.Bamum],[`Bassa_Vah`,e.Bassa_Vah],[`Batak`,e.Batak],[`Bengali`,e.Bengali],[`Bhaiksuki`,e.Bhaiksuki],[`Bopomofo`,e.Bopomofo],[`Brahmi`,e.Brahmi],[`Braille`,e.Braille],[`Buginese`,e.Buginese],[`Buhid`,e.Buhid],[`Canadian_Aboriginal`,e.Canadian_Aboriginal],[`Carian`,e.Carian],[`Caucasian_Albanian`,e.Caucasian_Albanian],[`Chakma`,e.Chakma],[`Cham`,e.Cham],[`Cherokee`,e.Cherokee],[`Chorasmian`,e.Chorasmian],[`Common`,e.Common],[`Coptic`,e.Coptic],[`Cuneiform`,e.Cuneiform],[`Cypriot`,e.Cypriot],[`Cypro_Minoan`,e.Cypro_Minoan],[`Cyrillic`,e.Cyrillic],[`Deseret`,e.Deseret],[`Devanagari`,e.Devanagari],[`Dives_Akuru`,e.Dives_Akuru],[`Dogra`,e.Dogra],[`Duployan`,e.Duployan],[`Egyptian_Hieroglyphs`,e.Egyptian_Hieroglyphs],[`Elbasan`,e.Elbasan],[`Elymaic`,e.Elymaic],[`Ethiopic`,e.Ethiopic],[`Garay`,e.Garay],[`Georgian`,e.Georgian],[`Glagolitic`,e.Glagolitic],[`Gothic`,e.Gothic],[`Grantha`,e.Grantha],[`Greek`,e.Greek],[`Gujarati`,e.Gujarati],[`Gunjala_Gondi`,e.Gunjala_Gondi],[`Gurmukhi`,e.Gurmukhi],[`Gurung_Khema`,e.Gurung_Khema],[`Han`,e.Han],[`Hangul`,e.Hangul],[`Hanifi_Rohingya`,e.Hanifi_Rohingya],[`Hanunoo`,e.Hanunoo],[`Hatran`,e.Hatran],[`Hebrew`,e.Hebrew],[`Hiragana`,e.Hiragana],[`Imperial_Aramaic`,e.Imperial_Aramaic],[`Inherited`,e.Inherited],[`Inscriptional_Pahlavi`,e.Inscriptional_Pahlavi],[`Inscriptional_Parthian`,e.Inscriptional_Parthian],[`Javanese`,e.Javanese],[`Kaithi`,e.Kaithi],[`Kannada`,e.Kannada],[`Katakana`,e.Katakana],[`Kawi`,e.Kawi],[`Kayah_Li`,e.Kayah_Li],[`Kharoshthi`,e.Kharoshthi],[`Khitan_Small_Script`,e.Khitan_Small_Script],[`Khmer`,e.Khmer],[`Khojki`,e.Khojki],[`Khudawadi`,e.Khudawadi],[`Kirat_Rai`,e.Kirat_Rai],[`Lao`,e.Lao],[`Latin`,e.Latin],[`Lepcha`,e.Lepcha],[`Limbu`,e.Limbu],[`Linear_A`,e.Linear_A],[`Linear_B`,e.Linear_B],[`Lisu`,e.Lisu],[`Lycian`,e.Lycian],[`Lydian`,e.Lydian],[`Mahajani`,e.Mahajani],[`Makasar`,e.Makasar],[`Malayalam`,e.Malayalam],[`Mandaic`,e.Mandaic],[`Manichaean`,e.Manichaean],[`Marchen`,e.Marchen],[`Masaram_Gondi`,e.Masaram_Gondi],[`Medefaidrin`,e.Medefaidrin],[`Meetei_Mayek`,e.Meetei_Mayek],[`Mende_Kikakui`,e.Mende_Kikakui],[`Meroitic_Cursive`,e.Meroitic_Cursive],[`Meroitic_Hieroglyphs`,e.Meroitic_Hieroglyphs],[`Miao`,e.Miao],[`Modi`,e.Modi],[`Mongolian`,e.Mongolian],[`Mro`,e.Mro],[`Multani`,e.Multani],[`Myanmar`,e.Myanmar],[`Nabataean`,e.Nabataean],[`Nag_Mundari`,e.Nag_Mundari],[`Nandinagari`,e.Nandinagari],[`New_Tai_Lue`,e.New_Tai_Lue],[`Newa`,e.Newa],[`Nko`,e.Nko],[`Nushu`,e.Nushu],[`Nyiakeng_Puachue_Hmong`,e.Nyiakeng_Puachue_Hmong],[`Ogham`,e.Ogham],[`Ol_Chiki`,e.Ol_Chiki],[`Ol_Onal`,e.Ol_Onal],[`Old_Hungarian`,e.Old_Hungarian],[`Old_Italic`,e.Old_Italic],[`Old_North_Arabian`,e.Old_North_Arabian],[`Old_Permic`,e.Old_Permic],[`Old_Persian`,e.Old_Persian],[`Old_Sogdian`,e.Old_Sogdian],[`Old_South_Arabian`,e.Old_South_Arabian],[`Old_Turkic`,e.Old_Turkic],[`Old_Uyghur`,e.Old_Uyghur],[`Oriya`,e.Oriya],[`Osage`,e.Osage],[`Osmanya`,e.Osmanya],[`Pahawh_Hmong`,e.Pahawh_Hmong],[`Palmyrene`,e.Palmyrene],[`Pau_Cin_Hau`,e.Pau_Cin_Hau],[`Phags_Pa`,e.Phags_Pa],[`Phoenician`,e.Phoenician],[`Psalter_Pahlavi`,e.Psalter_Pahlavi],[`Rejang`,e.Rejang],[`Runic`,e.Runic],[`Samaritan`,e.Samaritan],[`Saurashtra`,e.Saurashtra],[`Sharada`,e.Sharada],[`Shavian`,e.Shavian],[`Siddham`,e.Siddham],[`SignWriting`,e.SignWriting],[`Sinhala`,e.Sinhala],[`Sogdian`,e.Sogdian],[`Sora_Sompeng`,e.Sora_Sompeng],[`Soyombo`,e.Soyombo],[`Sundanese`,e.Sundanese],[`Sunuwar`,e.Sunuwar],[`Syloti_Nagri`,e.Syloti_Nagri],[`Syriac`,e.Syriac],[`Tagalog`,e.Tagalog],[`Tagbanwa`,e.Tagbanwa],[`Tai_Le`,e.Tai_Le],[`Tai_Tham`,e.Tai_Tham],[`Tai_Viet`,e.Tai_Viet],[`Takri`,e.Takri],[`Tamil`,e.Tamil],[`Tangsa`,e.Tangsa],[`Tangut`,e.Tangut],[`Telugu`,e.Telugu],[`Thaana`,e.Thaana],[`Thai`,e.Thai],[`Tibetan`,e.Tibetan],[`Tifinagh`,e.Tifinagh],[`Tirhuta`,e.Tirhuta],[`Todhri`,e.Todhri],[`Toto`,e.Toto],[`Tulu_Tigalari`,e.Tulu_Tigalari],[`Ugaritic`,e.Ugaritic],[`Vai`,e.Vai],[`Vithkuqi`,e.Vithkuqi],[`Wancho`,e.Wancho],[`Warang_Citi`,e.Warang_Citi],[`Yezidi`,e.Yezidi],[`Yi`,e.Yi],[`Zanabazar_Square`,e.Zanabazar_Square]]);static FOLD_CATEGORIES=new Map([[`L`,e.foldL],[`Ll`,e.foldLl],[`Lt`,e.foldLt],[`Lu`,e.foldLu],[`M`,e.foldM],[`Mn`,e.foldMn]]);static FOLD_SCRIPT=new Map([[`Common`,e.foldCommon],[`Greek`,e.foldGreek],[`Inherited`,e.foldInherited]]);static Print=new K(new Uint32Array([33,126,1,161,172,1,174,887,1,890,895,1,900,906,1,908,910,2,911,929,1,931,1327,1,1329,1366,1,1369,1418,1,1421,1423,1,1425,1479,1,1488,1514,1,1519,1524,1,1542,1563,1,1565,1756,1,1758,1805,1,1808,1866,1,1869,1969,1,1984,2042,1,2045,2093,1,2096,2110,1,2112,2139,1,2142,2144,2,2145,2154,1,2160,2190,1,2199,2273,1,2275,2435,1,2437,2444,1,2447,2448,1,2451,2472,1,2474,2480,1,2482,2486,4,2487,2489,1,2492,2500,1,2503,2504,1,2507,2510,1,2519,2524,5,2525,2527,2,2528,2531,1,2534,2558,1,2561,2563,1,2565,2570,1,2575,2576,1,2579,2600,1,2602,2608,1,2610,2611,1,2613,2614,1,2616,2617,1,2620,2622,2,2623,2626,1,2631,2632,1,2635,2637,1,2641,2649,8,2650,2652,1,2654,2662,8,2663,2678,1,2689,2691,1,2693,2701,1,2703,2705,1,2707,2728,1,2730,2736,1,2738,2739,1,2741,2745,1,2748,2757,1,2759,2761,1,2763,2765,1,2768,2784,16,2785,2787,1,2790,2801,1,2809,2815,1,2817,2819,1,2821,2828,1,2831,2832,1,2835,2856,1,2858,2864,1,2866,2867,1,2869,2873,1,2876,2884,1,2887,2888,1,2891,2893,1,2901,2903,1,2908,2909,1,2911,2915,1,2918,2935,1,2946,2947,1,2949,2954,1,2958,2960,1,2962,2965,1,2969,2970,1,2972,2974,2,2975,2979,4,2980,2984,4,2985,2986,1,2990,3001,1,3006,3010,1,3014,3016,1,3018,3021,1,3024,3031,7,3046,3066,1,3072,3084,1,3086,3088,1,3090,3112,1,3114,3129,1,3132,3140,1,3142,3144,1,3146,3149,1,3157,3158,1,3160,3162,1,3165,3168,3,3169,3171,1,3174,3183,1,3191,3212,1,3214,3216,1,3218,3240,1,3242,3251,1,3253,3257,1,3260,3268,1,3270,3272,1,3274,3277,1,3285,3286,1,3293,3294,1,3296,3299,1,3302,3311,1,3313,3315,1,3328,3340,1,3342,3344,1,3346,3396,1,3398,3400,1,3402,3407,1,3412,3427,1,3430,3455,1,3457,3459,1,3461,3478,1,3482,3505,1,3507,3515,1,3517,3520,3,3521,3526,1,3530,3535,5,3536,3540,1,3542,3544,2,3545,3551,1,3558,3567,1,3570,3572,1,3585,3642,1,3647,3675,1,3713,3714,1,3716,3718,2,3719,3722,1,3724,3747,1,3749,3751,2,3752,3773,1,3776,3780,1,3782,3784,2,3785,3790,1,3792,3801,1,3804,3807,1,3840,3911,1,3913,3948,1,3953,3991,1,3993,4028,1,4030,4044,1,4046,4058,1,4096,4293,1,4295,4301,6,4304,4680,1,4682,4685,1,4688,4694,1,4696,4698,2,4699,4701,1,4704,4744,1,4746,4749,1,4752,4784,1,4786,4789,1,4792,4798,1,4800,4802,2,4803,4805,1,4808,4822,1,4824,4880,1,4882,4885,1,4888,4954,1,4957,4988,1,4992,5017,1,5024,5109,1,5112,5117,1,5120,5759,1,5761,5788,1,5792,5880,1,5888,5909,1,5919,5942,1,5952,5971,1,5984,5996,1,5998,6e3,1,6002,6003,1,6016,6109,1,6112,6121,1,6128,6137,1,6144,6157,1,6159,6169,1,6176,6264,1,6272,6314,1,6320,6389,1,6400,6430,1,6432,6443,1,6448,6459,1,6464,6468,4,6469,6509,1,6512,6516,1,6528,6571,1,6576,6601,1,6608,6618,1,6622,6683,1,6686,6750,1,6752,6780,1,6783,6793,1,6800,6809,1,6816,6829,1,6832,6862,1,6912,6988,1,6990,7155,1,7164,7223,1,7227,7241,1,7245,7306,1,7312,7354,1,7357,7367,1,7376,7418,1,7424,7957,1,7960,7965,1,7968,8005,1,8008,8013,1,8016,8023,1,8025,8031,2,8032,8061,1,8064,8116,1,8118,8132,1,8134,8147,1,8150,8155,1,8157,8175,1,8178,8180,1,8182,8190,1,8208,8231,1,8240,8286,1,8304,8305,1,8308,8334,1,8336,8348,1,8352,8384,1,8400,8432,1,8448,8587,1,8592,9257,1,9280,9290,1,9312,11123,1,11126,11157,1,11159,11507,1,11513,11557,1,11559,11565,6,11568,11623,1,11631,11632,1,11647,11670,1,11680,11686,1,11688,11694,1,11696,11702,1,11704,11710,1,11712,11718,1,11720,11726,1,11728,11734,1,11736,11742,1,11744,11869,1,11904,11929,1,11931,12019,1,12032,12245,1,12272,12287,1,12289,12351,1,12353,12438,1,12441,12543,1,12549,12591,1,12593,12686,1,12688,12773,1,12783,12830,1,12832,42124,1,42128,42182,1,42192,42539,1,42560,42743,1,42752,42957,1,42960,42961,1,42963,42965,2,42966,42972,1,42994,43052,1,43056,43065,1,43072,43127,1,43136,43205,1,43214,43225,1,43232,43347,1,43359,43388,1,43392,43469,1,43471,43481,1,43486,43518,1,43520,43574,1,43584,43597,1,43600,43609,1,43612,43714,1,43739,43766,1,43777,43782,1,43785,43790,1,43793,43798,1,43808,43814,1,43816,43822,1,43824,43883,1,43888,44013,1,44016,44025,1,44032,55203,1,55216,55238,1,55243,55291,1,63744,64109,1,64112,64217,1,64256,64262,1,64275,64279,1,64285,64310,1,64312,64316,1,64318,64320,2,64321,64323,2,64324,64326,2,64327,64450,1,64467,64911,1,64914,64967,1,64975,65008,33,65009,65049,1,65056,65106,1,65108,65126,1,65128,65131,1,65136,65140,1,65142,65276,1,65281,65470,1,65474,65479,1,65482,65487,1,65490,65495,1,65498,65500,1,65504,65510,1,65512,65518,1,65532,65533,1,65536,65547,1,65549,65574,1,65576,65594,1,65596,65597,1,65599,65613,1,65616,65629,1,65664,65786,1,65792,65794,1,65799,65843,1,65847,65934,1,65936,65948,1,65952,66e3,48,66001,66045,1,66176,66204,1,66208,66256,1,66272,66299,1,66304,66339,1,66349,66378,1,66384,66426,1,66432,66461,1,66463,66499,1,66504,66517,1,66560,66717,1,66720,66729,1,66736,66771,1,66776,66811,1,66816,66855,1,66864,66915,1,66927,66938,1,66940,66954,1,66956,66962,1,66964,66965,1,66967,66977,1,66979,66993,1,66995,67001,1,67003,67004,1,67008,67059,1,67072,67382,1,67392,67413,1,67424,67431,1,67456,67461,1,67463,67504,1,67506,67514,1,67584,67589,1,67592,67594,2,67595,67637,1,67639,67640,1,67644,67647,3,67648,67669,1,67671,67742,1,67751,67759,1,67808,67826,1,67828,67829,1,67835,67867,1,67871,67897,1,67903,67968,65,67969,68023,1,68028,68047,1,68050,68099,1,68101,68102,1,68108,68115,1,68117,68119,1,68121,68149,1,68152,68154,1,68159,68168,1,68176,68184,1,68192,68255,1,68288,68326,1,68331,68342,1,68352,68405,1,68409,68437,1,68440,68466,1,68472,68497,1,68505,68508,1,68521,68527,1,68608,68680,1,68736,68786,1,68800,68850,1,68858,68903,1,68912,68921,1,68928,68965,1,68969,68997,1,69006,69007,1,69216,69246,1,69248,69289,1,69291,69293,1,69296,69297,1,69314,69316,1,69372,69415,1,69424,69465,1,69488,69513,1,69552,69579,1,69600,69622,1,69632,69709,1,69714,69749,1,69759,69820,1,69822,69826,1,69840,69864,1,69872,69881,1,69888,69940,1,69942,69959,1,69968,70006,1,70016,70111,1,70113,70132,1,70144,70161,1,70163,70209,1,70272,70278,1,70280,70282,2,70283,70285,1,70287,70301,1,70303,70313,1,70320,70378,1,70384,70393,1,70400,70403,1,70405,70412,1,70415,70416,1,70419,70440,1,70442,70448,1,70450,70451,1,70453,70457,1,70459,70468,1,70471,70472,1,70475,70477,1,70480,70487,7,70493,70499,1,70502,70508,1,70512,70516,1,70528,70537,1,70539,70542,3,70544,70581,1,70583,70592,1,70594,70597,3,70599,70602,1,70604,70613,1,70615,70616,1,70625,70626,1,70656,70747,1,70749,70753,1,70784,70855,1,70864,70873,1,71040,71093,1,71096,71133,1,71168,71236,1,71248,71257,1,71264,71276,1,71296,71353,1,71360,71369,1,71376,71395,1,71424,71450,1,71453,71467,1,71472,71494,1,71680,71739,1,71840,71922,1,71935,71942,1,71945,71948,3,71949,71955,1,71957,71958,1,71960,71989,1,71991,71992,1,71995,72006,1,72016,72025,1,72096,72103,1,72106,72151,1,72154,72164,1,72192,72263,1,72272,72354,1,72368,72440,1,72448,72457,1,72640,72673,1,72688,72697,1,72704,72712,1,72714,72758,1,72760,72773,1,72784,72812,1,72816,72847,1,72850,72871,1,72873,72886,1,72960,72966,1,72968,72969,1,72971,73014,1,73018,73020,2,73021,73023,2,73024,73031,1,73040,73049,1,73056,73061,1,73063,73064,1,73066,73102,1,73104,73105,1,73107,73112,1,73120,73129,1,73440,73464,1,73472,73488,1,73490,73530,1,73534,73562,1,73648,73664,16,73665,73713,1,73727,74649,1,74752,74862,1,74864,74868,1,74880,75075,1,77712,77810,1,77824,78895,1,78912,78933,1,78944,82938,1,82944,83526,1,90368,90425,1,92160,92728,1,92736,92766,1,92768,92777,1,92782,92862,1,92864,92873,1,92880,92909,1,92912,92917,1,92928,92997,1,93008,93017,1,93019,93025,1,93027,93047,1,93053,93071,1,93504,93561,1,93760,93850,1,93952,94026,1,94031,94087,1,94095,94111,1,94176,94180,1,94192,94193,1,94208,100343,1,100352,101589,1,101631,101640,1,110576,110579,1,110581,110587,1,110589,110590,1,110592,110882,1,110898,110928,30,110929,110930,1,110933,110948,15,110949,110951,1,110960,111355,1,113664,113770,1,113776,113788,1,113792,113800,1,113808,113817,1,113820,113823,1,117760,118009,1,118016,118451,1,118528,118573,1,118576,118598,1,118608,118723,1,118784,119029,1,119040,119078,1,119081,119154,1,119163,119274,1,119296,119365,1,119488,119507,1,119520,119539,1,119552,119638,1,119648,119672,1,119808,119892,1,119894,119964,1,119966,119967,1,119970,119973,3,119974,119977,3,119978,119980,1,119982,119993,1,119995,119997,2,119998,120003,1,120005,120069,1,120071,120074,1,120077,120084,1,120086,120092,1,120094,120121,1,120123,120126,1,120128,120132,1,120134,120138,4,120139,120144,1,120146,120485,1,120488,120779,1,120782,121483,1,121499,121503,1,121505,121519,1,122624,122654,1,122661,122666,1,122880,122886,1,122888,122904,1,122907,122913,1,122915,122916,1,122918,122922,1,122928,122989,1,123023,123136,113,123137,123180,1,123184,123197,1,123200,123209,1,123214,123215,1,123536,123566,1,123584,123641,1,123647,124112,465,124113,124153,1,124368,124410,1,124415,124896,481,124897,124902,1,124904,124907,1,124909,124910,1,124912,124926,1,124928,125124,1,125127,125142,1,125184,125259,1,125264,125273,1,125278,125279,1,126065,126132,1,126209,126269,1,126464,126467,1,126469,126495,1,126497,126498,1,126500,126503,3,126505,126514,1,126516,126519,1,126521,126523,2,126530,126535,5,126537,126541,2,126542,126543,1,126545,126546,1,126548,126551,3,126553,126561,2,126562,126564,2,126567,126570,1,126572,126578,1,126580,126583,1,126585,126588,1,126590,126592,2,126593,126601,1,126603,126619,1,126625,126627,1,126629,126633,1,126635,126651,1,126704,126705,1,126976,127019,1,127024,127123,1,127136,127150,1,127153,127167,1,127169,127183,1,127185,127221,1,127232,127405,1,127462,127490,1,127504,127547,1,127552,127560,1,127568,127569,1,127584,127589,1,127744,128727,1,128732,128748,1,128752,128764,1,128768,128886,1,128891,128985,1,128992,129003,1,129008,129024,16,129025,129035,1,129040,129095,1,129104,129113,1,129120,129159,1,129168,129197,1,129200,129211,1,129216,129217,1,129280,129619,1,129632,129645,1,129648,129660,1,129664,129673,1,129679,129734,1,129742,129756,1,129759,129769,1,129776,129784,1,129792,129938,1,129940,130041,1,131072,173791,1,173824,177977,1,177984,178205,1,178208,183969,1,183984,191456,1,191472,192093,1,194560,195101,1,196608,201546,1,201552,205743,1,917760,917999,1]))},fW=class{static MAX_RUNE=1114111;static MAX_ASCII=127;static MAX_LATIN1=255;static MAX_BMP=65535;static MIN_FOLD=65;static MAX_FOLD=125251;static is32(e,t){let n=0,r=e.length;for(;ne.getHi(n))continue;let r=e.getLo(n);if(t0&&t>=e.getLo(0)&&this.is32(e,t)}static isUpper(e){if(e<=this.MAX_LATIN1){let t=String.fromCodePoint(e);return t.toUpperCase()===t&&t.toLowerCase()!==t}return this.is(dW.Upper,e)}static isPrint(e){return e<=this.MAX_LATIN1?e>=32&&e=161&&e!==173:this.is(dW.Print,e)}static simpleFold(e){if(dW.CASE_ORBIT.has(e))return dW.CASE_ORBIT.get(e);let t=G.toLowerCase(e);return t===e?G.toUpperCase(e):t}static equalsIgnoreCase(e,t){if(e<0||t<0||e===t)return!0;if(e<=this.MAX_ASCII&&t<=this.MAX_ASCII)return G.CODES.get(`A`)<=e&&e<=G.CODES.get(`Z`)&&(e|=32),G.CODES.get(`A`)<=t&&t<=G.CODES.get(`Z`)&&(t|=32),e===t;for(let n=this.simpleFold(e);n!==e;n=this.simpleFold(n))if(n===t)return!0;return!1}},pW=class{static METACHARACTERS=`\\.+*?()|[]{}^$`;static EMPTY_BEGIN_LINE=1;static EMPTY_END_LINE=2;static EMPTY_BEGIN_TEXT=4;static EMPTY_END_TEXT=8;static EMPTY_WORD_BOUNDARY=16;static EMPTY_NO_WORD_BOUNDARY=32;static EMPTY_ALL=-1;static emptyInts(){return[]}static isalnum(e){return G.CODES.get(`0`)<=e&&e<=G.CODES.get(`9`)||G.CODES.get(`a`)<=e&&e<=G.CODES.get(`z`)||G.CODES.get(`A`)<=e&&e<=G.CODES.get(`Z`)}static unhex(e){return G.CODES.get(`0`)<=e&&e<=G.CODES.get(`9`)?e-G.CODES.get(`0`):G.CODES.get(`a`)<=e&&e<=G.CODES.get(`f`)?e-G.CODES.get(`a`)+10:G.CODES.get(`A`)<=e&&e<=G.CODES.get(`F`)?e-G.CODES.get(`A`)+10:-1}static escapeRune(e){let t=``;if(fW.isPrint(e))this.METACHARACTERS.indexOf(String.fromCodePoint(e))>=0&&(t+=`\\`),t+=String.fromCodePoint(e);else switch(e){case G.CODES.get(`"`):t+=`\\"`;break;case G.CODES.get(`\\`):t+=`\\\\`;break;case G.CODES.get(` `):t+=`\\t`;break;case G.CODES.get(` `):t+=`\\n`;break;case G.CODES.get(`\r`):t+=`\\r`;break;case G.CODES.get(`\b`):t+=`\\b`;break;case G.CODES.get(`\f`):t+=`\\f`;break;default:{let n=e.toString(16);e<256?(t+=`\\x`,n.length===1&&(t+=`0`),t+=n):t+=`\\x{${n}}`;break}}return t}static stringToRunes(e){return String(e).split(``).map(e=>e.codePointAt(0))}static runeToString(e){return String.fromCodePoint(e)}static isWordRune(e){return G.CODES.get(`a`)<=e&&e<=G.CODES.get(`z`)||G.CODES.get(`A`)<=e&&e<=G.CODES.get(`Z`)||G.CODES.get(`0`)<=e&&e<=G.CODES.get(`9`)||e===G.CODES.get(`_`)}static emptyOpContext(e,t){let n=0;return e<0&&(n|=this.EMPTY_BEGIN_TEXT|this.EMPTY_BEGIN_LINE),e===G.CODES.get(` `)&&(n|=this.EMPTY_BEGIN_LINE),t<0&&(n|=this.EMPTY_END_TEXT|this.EMPTY_END_LINE),t===G.CODES.get(` `)&&(n|=this.EMPTY_END_LINE),this.isWordRune(e)===this.isWordRune(t)?n|=this.EMPTY_NO_WORD_BOUNDARY:n|=this.EMPTY_WORD_BOUNDARY,n}static quoteMeta(e){return e.split(``).map(e=>this.METACHARACTERS.indexOf(e)>=0?`\\${e}`:e).join(``)}static charCount(e){return e>fW.MAX_BMP?2:1}static stringToUtf8ByteArray(e){if(globalThis.TextEncoder)return Array.from(new TextEncoder().encode(e));{let t=[],n=0;for(let r=0;r>6|192,t[n++]=i&63|128):(i&64512)==55296&&r+1>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=i&63|128):(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=i&63|128)}return t}}static utf8ByteArrayToString(e){if(globalThis.TextDecoder)return new TextDecoder(`utf-8`).decode(new Uint8Array(e));{let t=[],n=0,r=0;for(;n191&&i<224){let a=e[n++];t[r++]=String.fromCharCode((i&31)<<6|a&63)}else if(i>239&&i<365){let a=e[n++],o=e[n++],s=e[n++],c=((i&7)<<18|(a&63)<<12|(o&63)<<6|s&63)-65536;t[r++]=String.fromCharCode(55296+(c>>10)),t[r++]=String.fromCharCode(56320+(c&1023))}else{let a=e[n++],o=e[n++];t[r++]=String.fromCharCode((i&15)<<12|(a&63)<<6|o&63)}}return t.join(``)}}},mW=(e=[],t=0)=>{let n={};for(let r=0;re.codePointAt(0))}length(){return this.charSequence.length}},vW=class{static utf16(e){return new _W(e)}static utf8(e){return Array.isArray(e)?new gW(e):new gW(pW.stringToUtf8ByteArray(e))}},yW=class{static EOF(){return-8}canCheckPrefix(){return!0}endPos(){return this.end}},bW=class extends yW{constructor(e,t=0,n=e.length){super(),this.bytes=e,this.start=t,this.end=n}step(e){if(e+=this.start,e>=this.end)return yW.EOF();let t=this.bytes[e++]&255;return t&128?(t&224)==192?(t&=31,e>=this.end?yW.EOF():(t=t<<6|this.bytes[e++]&63,t<<3|2)):(t&240)==224?(t&=15,e+1>=this.end?yW.EOF():(t=t<<6|this.bytes[e++]&63,t=t<<6|this.bytes[e++]&63,t<<3|3)):(t&=7,e+2>=this.end?yW.EOF():(t=t<<6|this.bytes[e++]&63,t=t<<6|this.bytes[e++]&63,t=t<<6|this.bytes[e++]&63,t<<3|4)):t<<3|1}index(e,t){t+=this.start;let n=this.indexOf(this.bytes,e.prefixUTF8,t);return n<0?n:n-t}context(e){e+=this.start;let t=-1;if(e>this.start&&e<=this.end){let n=e-1;if(t=this.bytes[n--],t>=128){let r=e-4;for(r=r&&(this.bytes[n]&192)==128;)n--;n>3}}let n=e>3:-1;return pW.emptyOpContext(t,n)}indexOf(e,t,n=0){let r=t.length;if(r===0)return-1;let i=e.length;for(let a=n;a<=i-r;a++)for(let n=0;n0&&e<=this.charSequence.length?this.charSequence.codePointAt(e-1):-1,n=e{let t=e.codePointAt(0);return t===G.CODES.get(`\\`)||t===G.CODES.get(`$`)?`\\${e}`:e}).join(``)}constructor(e,t){if(e===null)throw Error(`pattern is null`);this.patternInput=e;let n=this.patternInput.re2();this.patternGroupCount=n.numberOfCapturingGroups(),this.groups=[],this.namedGroups=n.namedGroups,this.numberOfInstructions=n.numberOfInstructions(),t instanceof hW?this.resetMatcherInput(t):Array.isArray(t)?this.resetMatcherInput(vW.utf8(t)):this.resetMatcherInput(vW.utf16(t))}pattern(){return this.patternInput}reset(){return this.matcherInputLength=this.matcherInput.length(),this.appendPos=0,this.hasMatch=!1,this.hasGroups=!1,this.anchorFlag=0,this}resetMatcherInput(e){if(e===null)throw Error(`input is null`);return this.matcherInput=e,this.reset(),this}start(e=0){if(typeof e==`string`){let t=this.namedGroups[e];if(!Number.isFinite(t))throw new EW(`group '${e}' not found`);e=t}return this.loadGroup(e),this.groups[2*e]}end(e=0){if(typeof e==`string`){let t=this.namedGroups[e];if(!Number.isFinite(t))throw new EW(`group '${e}' not found`);e=t}return this.loadGroup(e),this.groups[2*e+1]}programSize(){return this.numberOfInstructions}group(e=0){if(typeof e==`string`){let t=this.namedGroups[e];if(!Number.isFinite(t))throw new EW(`group '${e}' not found`);e=t}let t=this.start(e),n=this.end(e);return t<0&&n<0?null:this.substring(t,n)}groupCount(){return this.patternGroupCount}loadGroup(e){if(e<0||e>this.patternGroupCount)throw new EW(`Group index out of bounds: ${e}`);if(!this.hasMatch)throw new EW(`perhaps no match attempted`);if(e===0||this.hasGroups)return;let t=this.groups[1]+1;t>this.matcherInputLength&&(t=this.matcherInputLength);let n=this.patternInput.re2().matchMachineInput(this.matcherInput,this.groups[0],t,this.anchorFlag,1+this.patternGroupCount);if(!n[0])throw new EW(`inconsistency in matching group data`);this.groups=n[1],this.hasGroups=!0}matches(){return this.genMatch(0,W.ANCHOR_BOTH)}lookingAt(){return this.genMatch(0,W.ANCHOR_START)}find(e=null){if(e!==null){if(e<0||e>this.matcherInputLength)throw new EW(`start index out of bounds: ${e}`);return this.reset(),this.genMatch(e,0)}return e=0,this.hasMatch&&(e=this.groups[1],this.groups[0]===this.groups[1]&&e++),this.genMatch(e,W.UNANCHORED)}genMatch(e,t){let n=this.patternInput.re2().matchMachineInput(this.matcherInput,e,this.matcherInputLength,t,1);return n[0]?(this.groups=n[1],this.hasMatch=!0,this.hasGroups=!1,this.anchorFlag=t,!0):!1}substring(e,t){return this.matcherInput.isUTF8Encoding()?pW.utf8ByteArrayToString(this.matcherInput.asBytes().slice(e,t)):this.matcherInput.asCharSequence().substring(e,t).toString()}inputLength(){return this.matcherInputLength}appendReplacement(e,t=!1){let n=``,r=this.start(),i=this.end();return this.appendPosG.CODES.get(`9`)||o*10+a-G.CODES.get(`0`)>this.patternGroupCount));i++)o=o*10+a-G.CODES.get(`0`);if(o>this.patternGroupCount)throw new EW(`n > number of groups: ${o}`);let s=this.group(o);s!==null&&(t+=s),n=i,i--;continue}if(a===G.CODES.get(`{`)){nG.CODES.get(`9`)||o*10+a-G.CODES.get(`0`)>this.patternGroupCount));i++)o=o*10+a-G.CODES.get(`0`);if(o>this.patternGroupCount){t+=`$${o}`,n=i,i--;continue}let s=this.group(o);s!==null&&(t+=s),n=i,i--;continue}if(a===G.CODES.get(`<`)){n`)&&e.codePointAt(r)!==G.CODES.get(` `);)r++;if(r===e.length||e.codePointAt(r)!==G.CODES.get(`>`)){t+=e.substring(i-1,r+1),n=r+1;continue}let a=e.substring(i+1,r);Object.prototype.hasOwnProperty.call(this.namedGroups,a)?t+=this.group(a):t+=`$<${a}>`,n=r+1}}return n ${this.out}, ${this.arg}`;case e.ALT_MATCH:return`altmatch -> ${this.out}, ${this.arg}`;case e.CAPTURE:return`cap ${this.arg} -> ${this.out}`;case e.EMPTY_WIDTH:return`empty ${this.arg} -> ${this.out}`;case e.MATCH:return`match`;case e.FAIL:return`fail`;case e.NOP:return`nop -> ${this.out}`;case e.RUNE:return this.runes===null?`rune `:[`rune `,e.escapeRunes(this.runes),(this.arg&W.FOLD_CASE)===0?``:`/i`,` -> `,this.out].join(``);case e.RUNE1:return`rune1 ${e.escapeRunes(this.runes)} -> ${this.out}`;case e.RUNE_ANY:return`any -> ${this.out}`;case e.RUNE_ANY_NOT_NL:return`anynotnl -> ${this.out}`;default:throw Error(`unhandled case in Inst.toString`)}}},AW=class{constructor(){this.inst=null,this.cap=[]}},jW=class{constructor(){this.sparse=[],this.densePcs=[],this.denseThreads=[],this.size=0}contains(e){let t=this.sparse[e];return tthis.matchcap.length?this.initNewCap(e):this.resetCap(e)}resetCap(e){for(let t=0;t0?(this.poolSize--,t=this.pool[this.poolSize]):t=new AW,t.inst=e,t}freeQueue(e,t=0){let n=e.size-t,r=this.poolSize+n;this.pool.length>3,c=o&7,l=-1,u=0;o!==yW.EOF()&&(o=e.step(t+c),l=o>>3,u=o&7);let d;for(d=t===0?pW.emptyOpContext(-1,s):e.context(t);;){if(i.isEmpty()){if((r&pW.EMPTY_BEGIN_TEXT)!==0&&t!==0||this.matched)break;if(this.re2.prefix.length!==0&&l!==this.re2.prefixRune&&e.canCheckPrefix()){let n=e.index(this.re2,t);if(n<0)break;t+=n,o=e.step(t),s=o>>3,c=o&7,o=e.step(t+c),l=o>>3,u=o&7}}!this.matched&&(t===0||n===W.UNANCHORED)&&(this.ncap>0&&(this.matchcap[0]=t),this.add(i,this.prog.start,t,this.matchcap,d,null));let f=t+c;if(d=e.context(f),this.step(i,a,t,f,s,d,n,t===e.endPos()),c===0||this.ncap===0&&this.matched)break;t+=c,s=l,c=u,s!==-1&&(o=e.step(t+c),l=o>>3,u=o&7);let p=i;i=a,a=p}return this.freeQueue(a),this.matched}step(e,t,n,r,i,a,o,s){let c=this.re2.longest;for(let l=0;l0&&this.matchcap[0]0&&(!c||!this.matched||this.matchcap[1]0&&a.cap!==r&&(a.cap=r.slice(0,this.ncap)),e.denseThreads[o]=a,a=null;break;default:throw Error(`unhandled`)}return a}},NW=e=>{let t=-2128831035;for(let n=0;n{if(e.length!==t.length)return!1;for(let n=0;n0;){let e=n.pop();if(t.has(e))continue;t.add(e);let i=this.prog.getInst(e);switch(i.op){case kW.MATCH:r=!0;break;case kW.ALT:case kW.ALT_MATCH:n.push(i.out),n.push(i.arg);break;case kW.NOP:case kW.CAPTURE:n.push(i.out);break;case kW.EMPTY_WIDTH:return null}}return{pcs:Int32Array.from(t).sort(),isMatch:r}}getState(e){let t=this.computeClosure(e);if(!t)return null;let n=t.pcs,r=NW(n),i=this.stateCache.get(r);if(i)for(let e=0;e=this.stateLimit)return this.stateCache.clear(),this.stateCount=0,this.startState=null,null;let a=new FW(n,t.isMatch);return i.push(a),this.stateCount++,a}step(e,t,n){if(n===W.UNANCHORED&&t<=fW.MAX_ASCII){let n=e.nextAscii[t];if(n!==null)return n}else{let r=t+(n===W.UNANCHORED?0:fW.MAX_RUNE+1);if(e.nextMap.has(r))return e.nextMap.get(r)}let r=[];for(let n=0;n>3,s=t&7;if(s===0)break;if(i=this.step(i,o,n),i===null)return null;if(i.isMatch){if(n===W.ANCHOR_BOTH){if(a+s===r)return!0}else return!0}if(i.nfaStates.length===0&&n!==W.UNANCHORED)return!1;a+=s}return!1}},q=class e{static Op=mW([`NO_MATCH`,`EMPTY_MATCH`,`LITERAL`,`CHAR_CLASS`,`ANY_CHAR_NOT_NL`,`ANY_CHAR`,`BEGIN_LINE`,`END_LINE`,`BEGIN_TEXT`,`END_TEXT`,`WORD_BOUNDARY`,`NO_WORD_BOUNDARY`,`CAPTURE`,`STAR`,`PLUS`,`QUEST`,`REPEAT`,`CONCAT`,`ALTERNATE`,`LEFT_PAREN`,`VERTICAL_BAR`]);static isPseudoOp(t){return t>=e.Op.LEFT_PAREN}static emptySubs(){return[]}static quoteIfHyphen(e){return e===G.CODES.get(`-`)?`\\`:``}static fromRegexp(t){let n=new e(t.op);return n.flags=t.flags,n.subs=t.subs,n.runes=t.runes,n.cap=t.cap,n.min=t.min,n.max=t.max,n.name=t.name,n.namedGroups=t.namedGroups,n}constructor(t){this.op=t,this.flags=0,this.subs=e.emptySubs(),this.runes=[],this.min=0,this.max=0,this.cap=0,this.name=null,this.namedGroups={}}reinit(){this.flags=0,this.subs=e.emptySubs(),this.runes=[],this.cap=0,this.min=0,this.max=0,this.name=null,this.namedGroups={}}toString(){return this.appendTo()}appendTo(){let t=``;switch(this.op){case e.Op.NO_MATCH:t+=`[^\\x00-\\x{10FFFF}]`;break;case e.Op.EMPTY_MATCH:t+=`(?:)`;break;case e.Op.STAR:case e.Op.PLUS:case e.Op.QUEST:case e.Op.REPEAT:{let n=this.subs[0];switch(n.op>e.Op.CAPTURE||n.op===e.Op.LITERAL&&n.runes.length>1?t+=`(?:${n.appendTo()})`:t+=n.appendTo(),this.op){case e.Op.STAR:t+=`*`;break;case e.Op.PLUS:t+=`+`;break;case e.Op.QUEST:t+=`?`;break;case e.Op.REPEAT:t+=`{${this.min}`,this.min!==this.max&&(t+=`,`,this.max>=0&&(t+=this.max)),t+=`}`}(this.flags&W.NON_GREEDY)!==0&&(t+=`?`);break}case e.Op.CONCAT:for(let n of this.subs)n.op===e.Op.ALTERNATE?t+=`(?:${n.appendTo()})`:t+=n.appendTo();break;case e.Op.ALTERNATE:{let e=``;for(let n of this.subs)t+=e,e=`|`,t+=n.appendTo();break}case e.Op.LITERAL:(this.flags&W.FOLD_CASE)!==0&&(t+=`(?i:`);for(let e of this.runes)t+=pW.escapeRune(e);(this.flags&W.FOLD_CASE)!==0&&(t+=`)`);break;case e.Op.ANY_CHAR_NOT_NL:t+=`(?-s:.)`;break;case e.Op.ANY_CHAR:t+=`(?s:.)`;break;case e.Op.CAPTURE:this.name===null||this.name.length===0?t+=`(`:t+=`(?P<${this.name}>`,this.subs[0].op!==e.Op.EMPTY_MATCH&&(t+=this.subs[0].appendTo()),t+=`)`;break;case e.Op.BEGIN_TEXT:t+=`\\A`;break;case e.Op.END_TEXT:(this.flags&W.WAS_DOLLAR)===0?t+=`\\z`:t+=`(?-m:$)`;break;case e.Op.BEGIN_LINE:t+=`^`;break;case e.Op.END_LINE:t+=`$`;break;case e.Op.WORD_BOUNDARY:t+=`\\b`;break;case e.Op.NO_WORD_BOUNDARY:t+=`\\B`;break;case e.Op.CHAR_CLASS:if(this.runes.length%2!=0){t+=`[invalid char class]`;break}if(t+=`[`,this.runes.length===0)t+=`^\\x00-\\x{10FFFF}`;else if(this.runes[0]===0&&this.runes[this.runes.length-1]===fW.MAX_RUNE){t+=`^`;for(let n=1;n>1];return e&1?t.arg:t.out}patch(e,t){for(;e!==0;){let n=this.inst[e>>1];e&1?(e=n.arg,n.arg=t):(e=n.out,n.out=t)}}append(e,t){if(e===0)return t;if(t===0)return e;let n=e;for(;;){let e=this.next(n);if(e===0)break;n=e}let r=this.inst[n>>1];return n&1?r.arg=t:r.out=t,e}toString(){let e=``;for(let t=0;t0){r=[];for(let e=0;et.min){let i=e.simplify1(q.Op.QUEST,t.flags,n,null);for(let r=t.min+1;r0&&(n+=` `);let t=e[r],i=e[r+1];n+=t===i?`0x${t.toString(16)}`:`0x${t.toString(16)}-0x${i.toString(16)}`}return n+=`]`,n}static cmp(e,t,n,r){let i=e[t]-n;return i===0?r-e[t+1]:i}static qsortIntPair(t,n,r){let i=((n+r)/2|0)&-2,a=t[i],o=t[i+1],s=n,c=r;for(;s<=c;){for(;sn&&e.cmp(t,c,a,o)>0;)c-=2;if(s<=c){if(s!==c){let e=t[s];t[s]=t[c],t[c]=e,e=t[s+1],t[s+1]=t[c+1],t[c+1]=e}s+=2,c-=2}}nthis.r[t-1]&&(this.r[t-1]=r);continue}this.r[t]=n,this.r[t+1]=r,t+=2}return this.len=t,this}appendLiteral(e,t){return(t&W.FOLD_CASE)===0?this.appendRange(e,e):this.appendFoldedRange(e,e)}appendRange(e,t){if(this.len>0){for(let n=2;n<=4;n+=2)if(this.len>=n){let r=this.r[this.len-n],i=this.r[this.len-n+1];if(e<=i+1&&r<=t+1)return ei&&(this.r[this.len-n+1]=t),this}}return this.r[this.len++]=e,this.r[this.len++]=t,this}appendFoldedRange(e,t){if(e<=fW.MIN_FOLD&&t>=fW.MAX_FOLD||tfW.MAX_FOLD)return this.appendRange(e,t);efW.MAX_FOLD&&(this.appendRange(fW.MAX_FOLD+1,t),t=fW.MAX_FOLD);for(let n=e;n<=t;n++){this.appendRange(n,n);for(let e=fW.simpleFold(n);e!==n;e=fW.simpleFold(e))this.appendRange(e,e)}return this}appendClass(e){for(let t=0;tfW.MAX_FOLD)return e;let t=e,n=e;for(e=fW.simpleFold(e);e!==n;e=fW.simpleFold(e))t>e&&(t=e);return t}static leadingRegexp(e){if(e.op===q.Op.EMPTY_MATCH)return null;if(e.op===q.Op.CONCAT&&e.subs.length>0){let t=e.subs[0];return t.op===q.Op.EMPTY_MATCH?null:t}return e}static literalRegexp(e,t){let n=new q(q.Op.LITERAL);return n.flags=t,n.runes=pW.stringToRunes(e),n}static parse(t,n){return new e(t,n).parseInternal()}static parseRepeat(t){let n=t.pos();if(!t.more()||!t.lookingAt(`{`))return-1;t.skip(1);let r=e.parseInt(t);if(r===-1||!t.more())return-1;let i;if(!t.lookingAt(`,`))i=r;else{if(t.skip(1),!t.more())return-1;if(t.lookingAt(`}`))i=-1;else if((i=e.parseInt(t))===-1)return-1}if(!t.more()||!t.lookingAt(`}`))return-1;if(t.skip(1),r<0||r>1e3||i===-2||i>1e3||i>=0&&r>i)throw new wW(e.ERR_INVALID_REPEAT_SIZE,t.from(n));return r<<16|i&fW.MAX_BMP}static isValidCaptureName(e){if(e.length===0)return!1;for(let t=0;t=G.CODES.get(`0`)&&e.peek()<=G.CODES.get(`9`);)e.skip(1);let n=e.from(t);return n.length===0||n.length>1&&n.codePointAt(0)===G.CODES.get(`0`)?-1:n.length>8?-2:parseFloat(n,10)}static isCharClass(e){return e.op===q.Op.LITERAL&&e.runes.length===1||e.op===q.Op.CHAR_CLASS||e.op===q.Op.ANY_CHAR_NOT_NL||e.op===q.Op.ANY_CHAR}static matchRune(e,t){switch(e.op){case q.Op.LITERAL:return e.runes.length===1&&e.runes[0]===t;case q.Op.CHAR_CLASS:for(let n=0;nG.CODES.get(`7`))break;case G.CODES.get(`0`):{let e=r-G.CODES.get(`0`);for(let n=1;n<3&&!(!t.more()||t.peek()G.CODES.get(`7`));n++)e=e*8+t.peek()-G.CODES.get(`0`),t.skip(1);return e}case G.CODES.get(`x`):{if(!t.more())break;if(r=t.pop(),r===G.CODES.get(`{`)){let e=0,n=0;for(;;){if(!t.more())break e;if(r=t.pop(),r===G.CODES.get(`}`))break;let i=pW.unhex(r);if(i<0||(n=n*16+i,n>fW.MAX_RUNE))break e;e++}if(e===0)break e;return n}let e=pW.unhex(r);if(!t.more())break;r=t.pop();let n=pW.unhex(r);if(e<0||n<0)break;return e*16+n}case G.CODES.get(`a`):return G.CODES.get(`\x07`);case G.CODES.get(`f`):return G.CODES.get(`\f`);case G.CODES.get(`n`):return G.CODES.get(` `);case G.CODES.get(`r`):return G.CODES.get(`\r`);case G.CODES.get(`t`):return G.CODES.get(` `);case G.CODES.get(`v`):return G.CODES.get(`\v`);default:if(r<=fW.MAX_ASCII&&!pW.isalnum(r))return r}throw new wW(e.ERR_INVALID_ESCAPE,t.from(n))}static parseClassChar(t,n){if(!t.more())throw new wW(e.ERR_MISSING_BRACKET,t.from(n));return t.lookingAt(`\\`)?e.parseEscape(t):t.pop()}static concatRunes(e,t){return[...e,...t]}constructor(e,t=0){this.wholeRegexp=e,this.flags=t,this.numCap=0,this.namedGroups={},this.stack=[],this.free=null,this.numRegexp=0,this.numRunes=0,this.repeats=0,this.height=null,this.size=null}newRegexp(e){let t=this.free;return t!==null&&t.subs!==null&&t.subs.length>0?(this.free=t.subs[0],t.reinit(),t.op=e):(t=new q(e),this.numRegexp+=1),t}reuse(e){this.height!==null&&Object.prototype.hasOwnProperty.call(this.height,e)&&delete this.height[e],e.subs!==null&&e.subs.length>0&&(e.subs[0]=this.free),this.free=e}checkLimits(t){if(this.numRunes>e.MAX_RUNES)throw new wW(e.ERR_LARGE);this.checkSize(t),this.checkHeight(t)}checkSize(t){if(this.size===null){if(this.repeats===0&&(this.repeats=1),t.op===q.Op.REPEAT){let n=t.max;n===-1&&(n=t.min),n<=0&&(n=1),n>e.MAX_SIZE/this.repeats?this.repeats=e.MAX_SIZE:this.repeats*=n}if(this.numRegexpe.MAX_SIZE)throw new wW(e.ERR_LARGE)}calcSize(e,t=!1){if(!t&&Object.prototype.hasOwnProperty.call(this.size,e))return this.size[e];let n=0;switch(e.op){case q.Op.LITERAL:n=e.runes.length;break;case q.Op.CAPTURE:case q.Op.STAR:n=2+this.calcSize(e.subs[0]);break;case q.Op.PLUS:case q.Op.QUEST:n=1+this.calcSize(e.subs[0]);break;case q.Op.CONCAT:for(let t of e.subs)n+=this.calcSize(t);break;case q.Op.ALTERNATE:for(let t of e.subs)n+=this.calcSize(t);e.subs.length>1&&(n=n+e.subs.length-1);break;case q.Op.REPEAT:{let t=this.calcSize(e.subs[0]);if(e.max===-1){n=e.min===0?2+t:1+e.min*t;break}n=e.max*t+(e.max-e.min);break}}return n=Math.max(1,n),this.size[e]=n,n}checkHeight(t){if(!(this.numRegexpe.MAX_HEIGHT)throw new wW(e.ERR_NESTING_DEPTH)}}calcHeight(e,t=!1){if(!t&&Object.prototype.hasOwnProperty.call(this.height,e))return this.height[e];let n=1;for(let t of e.subs){let e=this.calcHeight(t);n<1+e&&(n=1+e)}return this.height[e]=n,n}pop(){return this.stack.pop()}popToPseudo(){let e=this.stack.length,t=e;for(;t>0&&!q.isPseudoOp(this.stack[t-1].op);)t--;let n=this.stack.slice(t,e);return this.stack=this.stack.slice(0,t),n}push(e){if(this.numRunes+=e.runes.length,e.op===q.Op.CHAR_CLASS&&e.runes.length===2&&e.runes[0]===e.runes[1]){if(this.maybeConcat(e.runes[0],this.flags&-2))return null;e.op=q.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags&-2}else if(e.op===q.Op.CHAR_CLASS&&e.runes.length===4&&e.runes[0]===e.runes[1]&&e.runes[2]===e.runes[3]&&fW.simpleFold(e.runes[0])===e.runes[2]&&fW.simpleFold(e.runes[2])===e.runes[0]||e.op===q.Op.CHAR_CLASS&&e.runes.length===2&&e.runes[0]+1===e.runes[1]&&fW.simpleFold(e.runes[0])===e.runes[1]&&fW.simpleFold(e.runes[1])===e.runes[0]){if(this.maybeConcat(e.runes[0],this.flags|W.FOLD_CASE))return null;e.op=q.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags|W.FOLD_CASE}else this.maybeConcat(-1,0);return this.stack.push(e),this.checkLimits(e),e}maybeConcat(t,n){let r=this.stack.length;if(r<2)return!1;let i=this.stack[r-1],a=this.stack[r-2];return i.op!==q.Op.LITERAL||a.op!==q.Op.LITERAL||(i.flags&W.FOLD_CASE)!==(a.flags&W.FOLD_CASE)?!1:(a.runes=e.concatRunes(a.runes,i.runes),t>=0?(i.runes=[t],i.flags=n,!0):(this.pop(),this.reuse(i),!1))}newLiteral(t,n){let r=this.newRegexp(q.Op.LITERAL);return r.flags=n,(n&W.FOLD_CASE)!==0&&(t=e.minFoldRune(t)),r.runes=[t],r}literal(e){this.push(this.newLiteral(e,this.flags))}op(e){let t=this.newRegexp(e);return t.flags=this.flags,this.push(t)}repeat(t,n,r,i,a,o){let s=this.flags;if((s&W.PERL_X)!==0&&(a.more()&&a.lookingAt(`?`)&&(a.skip(1),s^=W.NON_GREEDY),o!==-1))throw new wW(e.ERR_INVALID_REPEAT_OP,a.from(o));let c=this.stack.length;if(c===0)throw new wW(e.ERR_MISSING_REPEAT_ARGUMENT,a.from(i));let l=this.stack[c-1];if(q.isPseudoOp(l.op))throw new wW(e.ERR_MISSING_REPEAT_ARGUMENT,a.from(i));let u=this.newRegexp(t);if(u.min=n,u.max=r,u.flags=s,u.subs=[l],this.stack[c-1]=u,this.checkLimits(u),t===q.Op.REPEAT&&(n>=2||r>=2)&&!this.repeatIsValid(u,1e3))throw new wW(e.ERR_INVALID_REPEAT_SIZE,a.from(i))}repeatIsValid(e,t){if(e.op===q.Op.REPEAT){let n=e.max;if(n===0)return!0;if(n<0&&(n=e.min),n>t)return!1;n>0&&(t=Math.trunc(t/n))}for(let n of e.subs)if(!this.repeatIsValid(n,t))return!1;return!0}concat(){this.maybeConcat(-1,0);let e=this.popToPseudo();return e.length===0?this.push(this.newRegexp(q.Op.EMPTY_MATCH)):this.push(this.collapse(e,q.Op.CONCAT))}alternate(){let e=this.popToPseudo();return e.length>0&&this.cleanAlt(e[e.length-1]),e.length===0?this.push(this.newRegexp(q.Op.NO_MATCH)):this.push(this.collapse(e,q.Op.ALTERNATE))}cleanAlt(e){e.op===q.Op.CHAR_CLASS&&(e.runes=new sG(e.runes).cleanClass().toArray(),e.runes.length===2&&e.runes[0]===0&&e.runes[1]===fW.MAX_RUNE?(e.runes=[],e.op=q.Op.ANY_CHAR):e.runes.length===4&&e.runes[0]===0&&e.runes[1]===G.CODES.get(` `)-1&&e.runes[2]===G.CODES.get(` `)+1&&e.runes[3]===fW.MAX_RUNE&&(e.runes=[],e.op=q.Op.ANY_CHAR_NOT_NL))}collapse(e,t){if(e.length===1)return e[0];let n=0;for(let r of e)n+=r.op===t?r.subs.length:1;let r=Array(n).fill(null),i=0;for(let n of e)n.op===t?(r.splice(i,n.subs.length,...n.subs),i+=n.subs.length,this.reuse(n)):r[i++]=n;let a=this.newRegexp(t);if(a.subs=r,t===q.Op.ALTERNATE&&(a.subs=this.factor(a.subs),a.subs.length===1)){let e=a;a=a.subs[0],this.reuse(e)}return a}factor(t){if(t.length<2)return t;let n=0,r=t.length,i=0,a=null,o=0,s=0,c=0;for(let e=0;e<=r;e++){let l=null,u=0,d=0;if(e0&&(r=r.subs[0]),r.op===q.Op.LITERAL&&(l=r.runes,u=r.runes.length,d=r.flags&W.FOLD_CASE),d===s){let e=0;for(;e0){o=e;continue}}}if(e!==c){if(e===c+1)t[i++]=t[n+c];else{let r=this.newRegexp(q.Op.LITERAL);r.flags=s,r.runes=a.slice(0,o);for(let r=c;r0){let n=this.removeLeadingString(e.subs[0],t);if(e.subs[0]=n,n.op===q.Op.EMPTY_MATCH)switch(this.reuse(n),e.subs.length){case 0:case 1:e.op=q.Op.EMPTY_MATCH,e.subs=null;break;case 2:{let t=e;e=e.subs[1],this.reuse(t);break}default:e.subs=e.subs.slice(1,e.subs.length)}return e}return e.op===q.Op.LITERAL&&(e.runes=e.runes.slice(t,e.runes.length),e.runes.length===0&&(e.op=q.Op.EMPTY_MATCH)),e}removeLeadingRegexp(e,t){if(e.op===q.Op.CONCAT&&e.subs.length>0){switch(t&&this.reuse(e.subs[0]),e.subs=e.subs.slice(1,e.subs.length),e.subs.length){case 0:e.op=q.Op.EMPTY_MATCH,e.subs=q.emptySubs();break;case 1:{let t=e;e=e.subs[0],this.reuse(t);break}}return e}return t&&this.reuse(e),this.newRegexp(q.Op.EMPTY_MATCH)}parseInternal(){if((this.flags&W.LITERAL)!==0)return e.literalRegexp(this.wholeRegexp,this.flags);let t=-1,n=-1,r=-1,i=new lG(this.wholeRegexp);for(;i.more();){let a=-1;e:switch(i.peek()){case G.CODES.get(`(`):if((this.flags&W.PERL_X)!==0&&i.lookingAt(`(?`)){this.parsePerlFlags(i);break}this.op(q.Op.LEFT_PAREN).cap=++this.numCap,i.skip(1);break;case G.CODES.get(`|`):this.parseVerticalBar(),i.skip(1);break;case G.CODES.get(`)`):this.parseRightParen(),i.skip(1);break;case G.CODES.get(`^`):(this.flags&W.ONE_LINE)===0?this.op(q.Op.BEGIN_LINE):this.op(q.Op.BEGIN_TEXT),i.skip(1);break;case G.CODES.get(`$`):(this.flags&W.ONE_LINE)===0?this.op(q.Op.END_LINE):this.op(q.Op.END_TEXT).flags|=W.WAS_DOLLAR,i.skip(1);break;case G.CODES.get(`.`):(this.flags&W.DOT_NL)===0?this.op(q.Op.ANY_CHAR_NOT_NL):this.op(q.Op.ANY_CHAR),i.skip(1);break;case G.CODES.get(`[`):this.parseClass(i);break;case G.CODES.get(`*`):case G.CODES.get(`+`):case G.CODES.get(`?`):{a=i.pos();let e=null;switch(i.pop()){case G.CODES.get(`*`):e=q.Op.STAR;break;case G.CODES.get(`+`):e=q.Op.PLUS;break;case G.CODES.get(`?`):e=q.Op.QUEST}this.repeat(e,n,r,a,i,t);break}case G.CODES.get(`{`):{a=i.pos();let o=e.parseRepeat(i);if(o<0){i.rewindTo(a),this.literal(i.pop());break}n=o>>16,r=(o&fW.MAX_BMP)<<16>>16,this.repeat(q.Op.REPEAT,n,r,a,i,t);break}case G.CODES.get(`\\`):{let t=i.pos();if(i.skip(1),(this.flags&W.PERL_X)!==0&&i.more())switch(i.pop()){case G.CODES.get(`A`):this.op(q.Op.BEGIN_TEXT);break e;case G.CODES.get(`b`):this.op(q.Op.WORD_BOUNDARY);break e;case G.CODES.get(`B`):this.op(q.Op.NO_WORD_BOUNDARY);break e;case G.CODES.get(`C`):throw new wW(e.ERR_INVALID_ESCAPE,`\\C`);case G.CODES.get(`Q`):{let e=i.rest(),t=e.indexOf(`\\E`);t>=0&&(e=e.substring(0,t)),i.skipString(e),i.skipString(`\\E`);let n=0;for(;n`);if(i<0)throw new wW(e.ERR_INVALID_NAMED_CAPTURE,r);let a=r.substring(n,i);if(t.skipString(a),t.skip(n+1),!e.isValidCaptureName(a))throw new wW(e.ERR_INVALID_NAMED_CAPTURE,r.substring(0,i+1));let o=this.op(q.Op.LEFT_PAREN);if(o.cap=++this.numCap,this.namedGroups[a])throw new wW(e.ERR_DUPLICATE_NAMED_CAPTURE,a);this.namedGroups[a]=this.numCap,o.name=a;return}t.skip(2);let i=this.flags,a=1,o=!1;e:for(;t.more();){let e=t.pop();switch(e){case G.CODES.get(`i`):i|=W.FOLD_CASE,o=!0;break;case G.CODES.get(`m`):i&=-17,o=!0;break;case G.CODES.get(`s`):i|=W.DOT_NL,o=!0;break;case G.CODES.get(`U`):i|=W.NON_GREEDY,o=!0;break;case G.CODES.get(`-`):if(a<0)break e;a=-1,i=~i,o=!1;break;case G.CODES.get(`:`):case G.CODES.get(`)`):if(a<0){if(!o)break e;i=~i}e===G.CODES.get(`:`)&&this.op(q.Op.LEFT_PAREN),this.flags=i;return;default:break e}}throw new wW(e.ERR_INVALID_PERL_OP,t.from(n))}parseVerticalBar(){this.concat(),this.swapVerticalBar()||this.op(q.Op.VERTICAL_BAR)}swapVerticalBar(){let t=this.stack.length;if(t>=3&&this.stack[t-2].op===q.Op.VERTICAL_BAR&&e.isCharClass(this.stack[t-1])&&e.isCharClass(this.stack[t-3])){let n=this.stack[t-1],r=this.stack[t-3];if(n.op>r.op){let e=r;r=n,n=e,this.stack[t-3]=r}return e.mergeCharClass(r,n),this.reuse(n),this.pop(),!0}if(t>=2){let e=this.stack[t-1],n=this.stack[t-2];if(n.op===q.Op.VERTICAL_BAR)return t>=3&&this.cleanAlt(this.stack[t-3]),this.stack[t-2]=e,this.stack[t-1]=n,!0}return!1}parseRightParen(){if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length<2)throw new wW(e.ERR_UNEXPECTED_PAREN,this.wholeRegexp);let t=this.pop(),n=this.pop();if(n.op!==q.Op.LEFT_PAREN)throw new wW(e.ERR_UNEXPECTED_PAREN,this.wholeRegexp);this.flags=n.flags,n.cap===0?this.push(t):(n.op=q.Op.CAPTURE,n.subs=[t],this.push(n))}parsePerlClassEscape(e,t){let n=e.pos();if((this.flags&W.PERL_X)===0||!e.more()||e.pop()!==G.CODES.get(`\\`)||!e.more())return!1;e.pop();let r=e.from(n),i=GW.has(r)?GW.get(r):null;return i!==null&&(t.appendGroup(i,(this.flags&W.FOLD_CASE)!==0),!0)}parseNamedClass(t,n){let r=t.rest(),i=r.indexOf(`:]`);if(i<0)return!1;let a=r.substring(0,i+2);t.skipString(a);let o=oG.has(a)?oG.get(a):null;if(o===null)throw new wW(e.ERR_INVALID_CHAR_RANGE,a);return n.appendGroup(o,(this.flags&W.FOLD_CASE)!==0),!0}parseUnicodeClass(t,n){let r=t.pos();if((this.flags&W.UNICODE_GROUPS)===0||!t.lookingAt(`\\p`)&&!t.lookingAt(`\\P`))return!1;t.skip(1);let i=1,a=t.pop();if(a===G.CODES.get(`P`)&&(i=-1),!t.more())throw t.rewindTo(r),new wW(e.ERR_INVALID_CHAR_RANGE,t.rest());a=t.pop();let o;if(a!==G.CODES.get(`{`))o=pW.runeToString(a);else{let n=t.rest(),i=n.indexOf(`}`);if(i<0)throw t.rewindTo(r),new wW(e.ERR_INVALID_CHAR_RANGE,t.rest());o=n.substring(0,i),t.skipString(o),t.skip(1)}o.length!==0&&o.codePointAt(0)===G.CODES.get(`^`)&&(i=0-i,o=o.substring(1));let s=e.unicodeTable(o);if(s===null)throw new wW(e.ERR_INVALID_CHAR_RANGE,t.from(r));let c=s.first,l=s.second;if((this.flags&W.FOLD_CASE)===0||l===null)n.appendTableWithSign(c,i);else{let e=new sG().appendTable(c).appendTable(l).cleanClass().toArray();n.appendClassWithSign(e,i)}return!0}parseClass(t){let n=t.pos();t.skip(1);let r=this.newRegexp(q.Op.CHAR_CLASS);r.flags=this.flags;let i=new sG,a=1;t.more()&&t.lookingAt(`^`)&&(a=-1,t.skip(1),(this.flags&W.CLASS_NL)===0&&i.appendRange(G.CODES.get(` `),G.CODES.get(` `)));let o=!0;for(;!t.more()||t.peek()!==G.CODES.get(`]`)||o;){if(t.more()&&t.lookingAt(`-`)&&(this.flags&W.PERL_X)===0&&!o){let r=t.rest();if(r===`-`||!r.startsWith(`-]`))throw t.rewindTo(n),new wW(e.ERR_INVALID_CHAR_RANGE,t.rest())}o=!1;let r=t.pos();if(t.lookingAt(`[:`)){if(this.parseNamedClass(t,i))continue;t.rewindTo(r)}if(this.parseUnicodeClass(t,i)||this.parsePerlClassEscape(t,i))continue;t.rewindTo(r);let a=e.parseClassChar(t,n),s=a;if(t.more()&&t.lookingAt(`-`)){if(t.skip(1),t.more()&&t.lookingAt(`]`))t.skip(-1);else if(s=e.parseClassChar(t,n),s0&&(s.prefixRune=s.prefix.codePointAt(0)),s.namedGroups=i.namedGroups,s}static match(t,n){return e.compile(t).match(n)}constructor(e,t,n=0,r=0){this.expr=e,this.prog=t,this.numSubexp=n,this.longest=r,this.cond=t.startCond(),this.prefix=null,this.prefixUTF8=null,this.prefixComplete=!1,this.prefixRune=0,this.pooled=new dG,this.dfa=new IW(t)}executeEngine(e,t,n,r){if(r>0)return this.doExecuteNFA(e,t,n,r);let i=this.dfa.match(e,t,n);return i===null?this.doExecuteNFA(e,t,n,r):i?[]:null}numberOfCapturingGroups(){return this.numSubexp}numberOfInstructions(){return this.prog.numInst()}get(){let e;do e=this.pooled.get();while(e&&!this.pooled.compareAndSet(e,e.next));return e}reset(){this.pooled.set(null)}put(e,t){let n=this.pooled.get();do n=this.pooled.get(),!t&&n&&(e=MW.fromMachine(e),t=!0),e.next!==n&&(e.next=n);while(!this.pooled.compareAndSet(n,e))}toString(){return this.expr}doExecuteNFA(e,t,n,r){let i=this.get(),a=!1;i?i.next!==null&&(i=MW.fromMachine(i),a=!0):(i=MW.fromRE2(this),a=!0),i.init(r);let o=i.match(e,t,n)?i.submatches():null;return this.put(i,a),o}match(e){return this.executeEngine(SW.fromUTF16(e),0,W.UNANCHORED,0)!==null}matchWithGroup(e,t,n,r,i){return e instanceof hW||(e=vW.utf16(e)),this.matchMachineInput(e,t,n,r,i)}matchMachineInput(e,t,n,r,i){if(t>n)return[!1,null];let a=e.isUTF16Encoding()?SW.fromUTF16(e.asCharSequence(),0,n):SW.fromUTF8(e.asBytes(),0,n),o=this.executeEngine(a,t,r,2*i);return o===null?[!1,null]:[!0,o]}matchUTF8(e){return this.executeEngine(SW.fromUTF8(e),0,W.UNANCHORED,0)!==null}replaceAll(e,t){return this.replaceAllFunc(e,()=>t,2*e.length+1)}replaceFirst(e,t){return this.replaceAllFunc(e,()=>t,1)}replaceAllFunc(e,t,n){let r=0,i=0,a=``,o=SW.fromUTF16(e),s=0;for(;i<=e.length;){let c=this.executeEngine(o,i,W.UNANCHORED,2);if(c===null||c.length===0)break;a+=e.substring(r,c[0]),(c[1]>r||c[0]===0)&&(a+=t(e.substring(c[0],c[1])),s++),r=c[1];let l=o.step(i)&7;if(i+l>c[1]?i+=l:i+1>c[1]?i++:i=c[1],s>=n)break}return a+=e.substring(r),a}pad(e){if(e===null)return null;let t=(1+this.numSubexp)*2;if(e.lengthe){let r=[],i=e.endPos();t<0&&(t=i+1);let a=0,o=0,s=-1;for(;o=0&&(n[r]=e.slice(t[2*r],t[2*r+1]));return n}findUTF8SubmatchIndex(e){return this.pad(this.executeEngine(SW.fromUTF8(e),0,W.UNANCHORED,this.prog.numCap))}findSubmatch(e){let t=this.executeEngine(SW.fromUTF16(e),0,W.UNANCHORED,this.prog.numCap);if(t===null)return null;let n=Array(1+this.numSubexp).fill(null);for(let r=0;r=0&&(n[r]=e.substring(t[2*r],t[2*r+1]));return n}findSubmatchIndex(e){return this.pad(this.executeEngine(SW.fromUTF16(e),0,W.UNANCHORED,this.prog.numCap))}findAllUTF8(e,t){let n=this.allMatches(SW.fromUTF8(e),t,t=>e.slice(t[0],t[1]));return n.length===0?null:n}findAllUTF8Index(e,t){let n=this.allMatches(SW.fromUTF8(e),t,e=>e.slice(0,2));return n.length===0?null:n}findAll(e,t){let n=this.allMatches(SW.fromUTF16(e),t,t=>e.substring(t[0],t[1]));return n.length===0?null:n}findAllIndex(e,t){let n=this.allMatches(SW.fromUTF16(e),t,e=>e.slice(0,2));return n.length===0?null:n}findAllUTF8Submatch(e,t){let n=this.allMatches(SW.fromUTF8(e),t,t=>{let n=Array(t.length/2|0).fill(null);for(let r=0;r=0&&(n[r]=e.slice(t[2*r],t[2*r+1]));return n});return n.length===0?null:n}findAllUTF8SubmatchIndex(e,t){let n=this.allMatches(SW.fromUTF8(e),t);return n.length===0?null:n}findAllSubmatch(e,t){let n=this.allMatches(SW.fromUTF16(e),t,t=>{let n=Array(t.length/2|0).fill(null);for(let r=0;r=0&&(n[r]=e.substring(t[2*r],t[2*r+1]));return n});return n.length===0?null:n}findAllSubmatchIndex(e,t){let n=this.allMatches(SW.fromUTF16(e),t);return n.length===0?null:n}},pG=class e{static isUpperCaseAlpha(e){return`A`<=e&&e<=`Z`}static isHexadecimal(e){return`0`<=e&&e<=`9`||`A`<=e&&e<=`F`||`a`<=e&&e<=`f`}static getUtf8CharSize(e){let t=e.charCodeAt(0);return t<128?1:t<2048?2:t<65536?3:4}static translate(t){if(typeof t!=`string`)return t;let n=``,r=!1,i=t.length;i===0&&(n=`(?:)`,r=!0);let a=0;for(;a>4).toString(16).toUpperCase(),n+=(i.charCodeAt(0)-64&15).toString(16).toUpperCase(),a+=3,r=!0;continue}}n+=`\\c`,a+=2;continue;case`u`:if(a+2=i||t[a+3]!==`=`&&t[a+3]!==`!`)){n+=`(?P<`,a+=3,r=!0;continue}let s=e.getUtf8CharSize(o);n+=t.substring(a,a+s),a+=s}return r?n:t}},mG=class e{static CASE_INSENSITIVE=1;static DOTALL=2;static MULTILINE=4;static DISABLE_UNICODE_GROUPS=8;static LONGEST_MATCH=16;static quote(e){return pW.quoteMeta(e)}static translateRegExp(e){return pG.translate(e)}static compile(t,n=0){let r=t;if((n&e.CASE_INSENSITIVE)!==0&&(r=`(?i)${r}`),(n&e.DOTALL)!==0&&(r=`(?s)${r}`),(n&e.MULTILINE)!==0&&(r=`(?m)${r}`),(n&~(e.MULTILINE|e.DOTALL|e.CASE_INSENSITIVE|e.DISABLE_UNICODE_GROUPS|e.LONGEST_MATCH))!==0)throw new DW(`Flags should only be a combination of MULTILINE, DOTALL, CASE_INSENSITIVE, DISABLE_UNICODE_GROUPS, LONGEST_MATCH`);let i=W.PERL;(n&e.DISABLE_UNICODE_GROUPS)!==0&&(i&=-129);let a=new e(t,n);return a.re2Input=fG.compileImpl(r,i,(n&e.LONGEST_MATCH)!==0),a}static matches(t,n){return e.compile(t).testExact(n)}static initTest(t,n,r){if(t==null)throw Error(`pattern is null`);if(r==null)throw Error(`re2 is null`);let i=new e(t,n);return i.re2Input=r,i}constructor(e,t){this.patternInput=e,this.flagsInput=t}reset(){this.re2Input.reset()}flags(){return this.flagsInput}pattern(){return this.patternInput}re2(){return this.re2Input}matches(e){return this.testExact(e)}matcher(e){return Array.isArray(e)&&(e=vW.utf8(e)),new OW(this,e)}test(e){return Array.isArray(e)?this.re2Input.matchUTF8(e):this.re2Input.match(e)}testExact(e){let t=Array.isArray(e)?SW.fromUTF8(e):SW.fromUTF16(e);return this.re2Input.executeEngine(t,0,W.ANCHOR_BOTH,0)!==null}split(e,t=0){let n=this.matcher(e),r=[],i=0,a=0;for(;n.find();){if(a===0&&n.end()===0){a=n.end();continue}if(t>0&&r.length===t-1)break;if(a===n.start()){if(t===0){i+=1,a=n.end();continue}}else for(;i>0;)r.push(``),--i;r.push(n.substring(a,n.start())),a=n.end()}if(t===0&&a!==n.inputLength()){for(;i>0;)r.push(``),--i;r.push(n.substring(a,n.inputLength()))}return(t!==0||r.length===0)&&r.push(n.substring(a,n.inputLength())),r}toString(){return this.patternInput}programSize(){return this.re2Input.numberOfInstructions()}groupCount(){return this.re2Input.numberOfCapturingGroups()}namedGroups(){return this.re2Input.namedGroups}equals(e){return this===e?!0:e===null||this.constructor!==e.constructor?!1:this.flagsInput===e.flagsInput&&this.patternInput===e.patternInput}}});function Zbe(e){let t=0;return e.includes(`i`)&&(t|=mG.CASE_INSENSITIVE),e.includes(`m`)&&(t|=mG.MULTILINE),e.includes(`s`)&&(t|=mG.DOTALL),t}function Qbe(e){return mG.translateRegExp(e)}function hG(e,t=``,n={}){return new vG(e,t,n)}var gG,_G,vG,yG,$be=B(()=>{Xbe(),cH(),U(),gG=1e6,_G=67108864,vG=class{_re2;_pattern;_flags;_global;_ignoreCase;_multiline;_lastIndex=0;_nativeRegex=null;_matcher=null;_matcherInput=null;maxResults;maxOutputBytes;signal;assertResultCount(e){if(this.signal?.aborted)throw Error(`regular expression aborted`);if(e>this.maxResults)throw new H(`regular expression result limit exceeded (${this.maxResults})`,`array_elements`)}expandReplacement(e,t){let n=new sH(this.maxOutputBytes,`regular expression replacement`),r=this._re2.groupCount(),i=this._re2.namedGroups();for(let a=0;a=t.length){n.append(o);continue}if(t[a+1]===`{`){let r=t.indexOf(`}`,a+2);if(r!==-1){let o=t.slice(a+2,r),s=i?.[o];if(s!==void 0){n.append(e.group(s)??``),a=r;continue}}}if(/\d/.test(t[a+1])){let i=a+1,o=0;for(;ir)break;o=e,i++}n.append(e.group(o)??``),a=i-1;continue}n.append(o)}return n.build()}acquireMatcher(e){return this._matcher===null?(this._matcher=this._re2.matcher(e),this._matcherInput=e,this._matcher):(this._matcherInput!==e&&(this._matcher.matcherInput.charSequence=e,this._matcherInput=e),this._matcher.reset(),this._matcher)}constructor(e,t=``,n={}){if(this._pattern=e,this._flags=t,this._global=t.includes(`g`),this._ignoreCase=t.includes(`i`),this._multiline=t.includes(`m`),this.maxResults=n.maxResults??gG,this.maxOutputBytes=n.maxOutputBytes??_G,this.signal=n.signal,!Number.isSafeInteger(this.maxResults)||this.maxResults<0||!Number.isSafeInteger(this.maxOutputBytes)||this.maxOutputBytes<0)throw Error(`invalid regular expression limits`);try{let n=Qbe(e),r=Zbe(t);this._re2=mG.compile(n,r)}catch(t){if(t instanceof wW){let n=t.message||``,r=``;throw n.includes(`(?=`)||n.includes(`(?!`)||n.includes(`(?<`)||n.includes(`(?0){let e=Object.create(null);for(let[n,r]of Object.entries(o)){let i=t.group(r);i!==null&&(e[n]=i)}a.groups=e}return this._global&&(this._lastIndex=t.end(0),t.start(0)===t.end(0)&&this._lastIndex++),a}match(e){if(this._global&&(this._lastIndex=0),!this._global)return this.exec(e);let t=[],n=this.acquireMatcher(e),r=0;for(;n.find(r);){let i=n.group(0)??``;if(this.assertResultCount(t.length+1),t.push(i),r=n.end(0),n.start(0)===n.end(0)&&r++,r>e.length)break}return t.length>0?t:null}replace(e,t){if(this._global&&(this._lastIndex=0),typeof t==`string`){let n=this._re2.matcher(e),r=new sH(this.maxOutputBytes,`regular expression replacement`),i=0,a=0,o=0;for(;n.find(a);){this.assertResultCount(++o);let s=n.start(0),c=n.end(0);if(r.append(e.slice(i,s)),r.append(this.expandReplacement(n,t)),i=c,a=c>s?c:c+1,!this._global||a>e.length)break}return r.append(e.slice(i)),r.build()}let n=new sH(this.maxOutputBytes,`regular expression replacement`),r=this._re2.matcher(e),i=0,a=0,o=0,s=this._re2.groupCount(),c=this._re2.namedGroups();for(;r.find(a);){this.assertResultCount(++o),n.append(e.slice(i,r.start(0)));let l=[],u=r.group(0)??``;for(let e=1;e<=s;e++)l.push(r.group(e));if(l.push(r.start(0)),l.push(e),c&&Object.keys(c).length>0){let e=Object.create(null);for(let[t,n]of Object.entries(c))e[t]=r.group(n)??``;l.push(e)}let d=r.start(0),f=r.end(0);if(n.append(t(u,...l)),i=f,a=i,d===f&&a++,!this._global||a>e.length)break}return n.append(e.slice(i)),n.build()}split(e,t){if(t===0)return[];let n=t===void 0||t<0?this.maxResults:Math.min(t,this.maxResults),r=[],i=this._re2.matcher(e),a=0,o=0;for(;r.lengthi.start(0)?i.end(0):i.end(0)+1;return r.length0){let e=Object.create(null);for(let[n,i]of Object.entries(r)){let r=t.group(i);r!==null&&(e[n]=r)}s.groups=e}if(yield s,i=t.end(0),t.start(0)===t.end(0)&&i++,i>e.length)break}}get native(){if(!this._nativeRegex)try{this._nativeRegex=new RegExp(this._pattern,this._flags)}catch{this._nativeRegex=RegExp(``,this._flags),Object.defineProperty(this._nativeRegex,"source",{value:this._pattern,writable:!1})}return this._nativeRegex}get source(){return this._pattern}get flags(){return this._flags}get global(){return this._global}get ignoreCase(){return this._ignoreCase}get multiline(){return this._multiline}get lastIndex(){return this._lastIndex}set lastIndex(e){this._lastIndex=e}},yG=class{_regex;constructor(e){this._regex=e}test(e){return this._regex.global&&(this._regex.lastIndex=0),this._regex.test(e)}exec(e){return this._regex.exec(e)}match(e){return this._regex.global&&(this._regex.lastIndex=0),e.match(this._regex)}replace(e,t){return this._regex.global&&(this._regex.lastIndex=0),e.replace(this._regex,t)}split(e,t){return e.split(this._regex,t)}search(e){return e.search(this._regex)}*matchAll(e){if(!this._regex.global)throw Error(`matchAll requires global flag`);this._regex.lastIndex=0;let t=this._regex.exec(e);for(;t!==null;)yield t,t[0].length===0&&this._regex.lastIndex++,t=this._regex.exec(e)}get native(){return this._regex}get source(){return this._regex.source}get flags(){return this._regex.flags}get global(){return this._regex.global}get ignoreCase(){return this._regex.ignoreCase}get multiline(){return this._regex.multiline}get lastIndex(){return this._regex.lastIndex}set lastIndex(e){this._regex.lastIndex=e}}}),bG=B(()=>{$be()});function xG(e,t,n){let r=typeof n==`boolean`?{ignoreCase:n}:n??{},i=t;r.stripQuotes&&(i.startsWith(`"`)&&i.endsWith(`"`)||i.startsWith(`'`)&&i.endsWith(`'`))&&(i=i.slice(1,-1));let a=r.ignoreCase?`i:${i}`:i,o=CG.get(a);if(!o){if(o=exe(i,r.ignoreCase),CG.size>=SG){let e=CG.keys().next().value;e!==void 0&&CG.delete(e)}CG.set(a,o)}return o.test(e)}function exe(e,t){let n=`^`;for(let t=0;t{bG(),SG=2048,CG=new Map});function TG(e,t){let n=e.ignoreCase?t.toLowerCase():t,r=e.needles;for(let e=0;e]+)>)/g,(e,n,r)=>n===`&`?t[0]:r===void 0?t[parseInt(n,10)]??``:t.groups?.[r]??``)}function DG(e,t,n={}){let{invertMatch:r=!1,showLineNumbers:i=!1,countOnly:a=!1,countMatches:o=!1,filename:s=``,onlyMatching:c=!1,beforeContext:l=0,afterContext:u=0,maxCount:d=0,contextSeparator:f=`--`,showColumn:p=!1,vimgrep:m=!1,showByteOffset:h=!1,replace:g=null,passthru:_=!1,multiline:v=!1,kResetGroup:y,preFilter:b,maxWork:x,maxMatches:S,signal:C}=n;if(v)return txe(e,t,{invertMatch:r,showLineNumbers:i,countOnly:a,countMatches:o,filename:s,onlyMatching:c,beforeContext:l,afterContext:u,maxCount:d,contextSeparator:f,showColumn:p,showByteOffset:h,replace:g,kResetGroup:y,preFilter:b,maxWork:x,maxMatches:S,signal:C});let w=0,T=(e=1)=>{if(C?.aborted)throw new UB;if(w+=e,x!==void 0&&w>x)throw new H(`search: matching work limit exceeded (${x})`,`iterations`)},E=(e,t)=>{if(S!==void 0&&e.length>=S)throw new H(`search: result limit exceeded (${S})`,`array_elements`);e.push(t)},D=1;for(let t=0;tS))throw new H(`search: line limit exceeded (${S})`,`array_elements`);let O=e.split(` `),k=O.length,A=k>0&&O[k-1]===``?k-1:k;if(a||o){let e=0,n=(o||c)&&!r;for(let i=0;i0,matchCount:e}}if(l===0&&u===0&&!_){let e=[],n=!1,a=0,o=0;for(let l=0;l0&&a>=d));l++){let u=O[l],d=null;if(b&&!TG(b,u)||(t.lastIndex=0,d=t.exec(u)),d!==null!==r){if(n=!0,a++,c)for(let n=d;n!==null;n=t.exec(u)){T();let r=y===void 0?n[0]:n[y]??``,a=g===null?r:EG(g,n),c=s?`${s}:`:``;h&&(c+=`${o+n.index}:`),i&&(c+=`${l+1}:`),p&&(c+=`${n.index+1}:`),E(e,c+a),n[0].length===0&&t.lastIndex++}else if(m)for(let n=d;n!==null;n=t.exec(u)){T();let r=s?`${s}:`:``;h&&(r+=`${o+n.index}:`),i&&(r+=`${l+1}:`),p&&(r+=`${n.index+1}:`),E(e,r+u),n[0].length===0&&t.lastIndex++}else{let n=d?d.index+1:1,r=u;g!==null&&(t.lastIndex=0,r=t.replace(u,(...e)=>{if(e[0].length===0)return``;let t=e,n=e[e.length-1];return typeof n==`object`&&n?(t.groups=n,t.input=e[e.length-2],t.index=e[e.length-3]):(t.input=e[e.length-1],t.index=e[e.length-2]),EG(g,t)}));let a=s?`${s}:`:``;h&&(a+=`${o+(d?d.index:0)}:`),i&&(a+=`${l+1}:`),p&&(a+=`${n}:`),E(e,a+r)}}o+=u.length+1}return{output:e.length>0?`${e.join(` `)} `:``,matched:n,matchCount:a}}if(_){let e=[],n=!1,a=0;for(let o=0;o0?`${e.join(` `)} `:``,matched:n,matchCount:a}}let j=[],M=0,ee=new Set,te=-1,N=[];for(let e=0;e0&&M>=d));e++){let n=O[e],i;if(b&&!TG(b,n)?i=!1:(t.lastIndex=0,i=t.test(n)),i!==r){if(S!==void 0&&N.length>=S)throw new H(`search: match limit exceeded (${S})`,`array_elements`);N.push(e),M++}}for(let e of N){T();let n=Math.max(0,e-l);te>=0&&n>te+1&&E(j,f);for(let t=n;t0?`${j.join(` `)} `:``,matched:M>0,matchCount:M}}function txe(e,t,n){let{invertMatch:r,showLineNumbers:i,countOnly:a,countMatches:o,filename:s,onlyMatching:c,beforeContext:l,afterContext:u,maxCount:d,contextSeparator:f,showColumn:p,showByteOffset:m,replace:h,kResetGroup:g,preFilter:_,maxWork:v,maxMatches:y,signal:b}=n,x=0,S=(e=1)=>{if(b?.aborted)throw new UB;if(x+=e,v!==void 0&&x>v)throw new H(`search: matching work limit exceeded (${v})`,`iterations`)};if(_&&!r&&!TG(_,e))return a||o?{output:`${s?`${s}:0`:`0`} `,matched:!1,matchCount:0}:{output:``,matched:!1,matchCount:0};let C=[0];for(let t=0;t=y)throw new H(`search: line index limit exceeded (${y})`,`array_elements`);C.push(t+1)}let w=e.split(` `),T=w.length,E=T>0&&w[T-1]===``?T-1:T,D=e=>{let t=0,n=C.length;for(;t{let t=D(e);return e-C[t]+1};if(a||o){let n=0,i=0,a=-1;t.lastIndex=0;for(let r=t.exec(e);r!==null&&(S(),!(d>0&&n>=d));r=t.exec(e)){if(n++,!o){let e=D(r.index),t=D(r.index+Math.max(0,r[0].length-1)),n=Math.max(e,a+1);n<=t&&(i+=t-n+1,a=t)}r[0].length===0&&t.lastIndex++}let c=o?r?0:n:r?E-i:i;return{output:`${s?`${s}:${c}`:String(c)} `,matched:c>0,matchCount:c}}let k=[];t.lastIndex=0;for(let n=t.exec(e);n!==null&&(S(),!(d>0&&k.length>=d));n=t.exec(e)){if(y!==void 0&&k.length>=y)throw new H(`search: match limit exceeded (${y})`,`array_elements`);let e=D(n.index),r=D(n.index+Math.max(0,n[0].length-1)),i=g===void 0?n[0]:n[g]??``;k.push({startLine:e,endLine:r,byteOffset:n.index,column:O(n.index),matchText:i}),n[0].length===0&&t.lastIndex++}if(r){let e=new Set;for(let t of k)for(let n=t.startLine;n<=t.endLine;n++)S(),e.add(n);let t=[];for(let n=0;n0?`${t.join(` `)} `:``,matched:t.length>0,matchCount:t.length}}if(k.length===0)return{output:``,matched:!1,matchCount:0};let A=new Set,j=-1,M=[];for(let e of k){S();let n=Math.max(0,e.startLine-l),r=Math.min(E-1,e.endLine+u);j>=0&&n>j+1&&M.push(f);for(let t=n;t0?`${M.join(` `)} `:``,matched:!0,matchCount:k.length}}var nxe=B(()=>{U()});function OG(e){let t=``,n=0;for(;n:]]`){t+=`\\b`,n+=7;continue}if(e[n]===`[`){let r=`[`;for(n++,n]+)>/g,`(?<$1>`),t.mode===`perl`){n=oxe(n),n=sxe(n),n=cxe(n);let e=fxe(n);n=e.pattern,r=e.kResetGroup}break;default:n=OG(e),n=hxe(n)}t.wholeWord&&(n=`\\b(?:${n})\\b`),t.lineRegexp&&(n=`^(?:${n})$`);let i=/\\u\{[0-9A-Fa-f]+\}/.test(n),a=`g`+(t.ignoreCase?`i`:``)+(t.multiline?`m`:``)+(t.multilineDotall?`s`:``)+(i?`u`:``),o=rxe(n,t.ignoreCase??!1);return{regex:hG(n,a),kResetGroup:r,preFilter:o??void 0}}function rxe(e,t){let n=e;if(n.startsWith(`\\b(?:`)&&n.endsWith(`)\\b`)?n=n.slice(5,n.length-3):n.startsWith(`\\b`)&&n.endsWith(`\\b`)&&n.length>=4&&(n=n.slice(2,n.length-2)),n.length===0)return null;let r=ixe(n);if(r===null)return null;let i=[];for(let e of r){let t=axe(e);if(t===null||t.length===0)return null;i.push(t)}return i.length===0?null:{needles:t?i.map(e=>e.toLowerCase()):i,ignoreCase:t}}function ixe(e){let t=[],n=0,r=!1,i=0;for(let a=0;a=0&&t[n]===`\\`;n--)e++;e%2==0&&(t=t.slice(0,-1))}if(t.length===0)return null;let n=``;for(let e=0;e0&&n+1=0&&e[r]===`\\`;)n++,r--;if(n%2==0)return t}t+=2}else t++;return-1}function mxe(e){let t=0,n=0;for(;n`),t=t.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)(?![>0-9])/g,`$$<$1>`),t}function hxe(e){let t=``,n=0,r=!0,i=0;for(;n{bG(),jG=new Map([[`alpha`,`a-zA-Z`],[`digit`,`0-9`],[`alnum`,`a-zA-Z0-9`],[`lower`,`a-z`],[`upper`,`A-Z`],[`xdigit`,`0-9A-Fa-f`],[`space`,` \\t\\n\\r\\f\\v`],[`blank`,` \\t`],[`punct`,"!-/:-@\\[-`{-~"],[`graph`,`!-~`],[`print`,` -~`],[`cntrl`,`\\x00-\\x1F\\x7F`],[`ascii`,`\\x00-\\x7F`],[`word`,`a-zA-Z0-9_`]])}),MG=B(()=>{nxe(),gxe()}),NG={};Tz(NG,{egrepCommand:()=>GG,egrepFlagsForFuzzing:()=>JG,fgrepCommand:()=>WG,fgrepFlagsForFuzzing:()=>qG,flagsForFuzzing:()=>KG,grepCommand:()=>HG});function PG(e){let t=e.limits.maxLoopIterations,n=e.limits.maxArrayElements;return Math.max(t,Math.min(n,t*10))}function FG(e){if(++e.operations>e.maxOperations)throw new H(`grep: glob operation limit exceeded (${e.maxOperations})`,`glob_operations`)}function IG(e){if(e.results>=e.maxResults)throw new H(`grep: array element limit exceeded (${e.maxResults})`,`array_elements`);e.results++}function _xe(e){return e.split(` `)}function vxe(e){if(e===``)return[];let t=e.split(` `);return t[t.length-1]===``&&t.pop(),t}function yxe(e,t){return e.length===1?{pattern:e[0],mode:t}:t===`fixed`?{pattern:e.map(e=>`(?:${e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)})`).join(`|`),mode:`extended`}:t===`basic`?{pattern:e.join(`\\|`),mode:t}:{pattern:e.map(e=>`(?:${e})`).join(`|`),mode:t}}async function LG(e,t,n,r,i,a=0){if(a>=UG)return;let o=n.fs.resolvePath(n.cwd,e);try{if(FG(i),!(await n.fs.stat(o)).isDirectory){let n=e.split(`/`).pop()||``;t&&xG(n,t.replace(/^\//,``),{stripQuotes:!0})&&(IG(i),r.push(e));return}FG(i);let s=await n.fs.readdir(o);for(let o of s){let s=e===`.`?o:`${e}/${o}`,c=n.fs.resolvePath(n.cwd,s);FG(i),(await n.fs.stat(c)).isDirectory?await LG(s,t,n,r,i,a+1):t&&xG(o,t.replace(/^\//,``),{stripQuotes:!0})&&(IG(i),r.push(s))}}catch(e){rV(e)}}async function bxe(e,t,n){let r=[],i=e.lastIndexOf(`/`),a,o;if(i===-1?(a=t.cwd,o=e):(a=e.slice(0,i)||`/`,o=e.slice(i+1)),e.includes(`**`)){let r=[],i=e.split(`**`);return await LG(i[0].replace(/\/$/,``)||`.`,i[1]||``,t,r,n),r.map(e=>({path:e}))}let s=t.fs.resolvePath(t.cwd,a);try{if(t.fs.readdirWithFileTypes){FG(n);let e=await t.fs.readdirWithFileTypes(s);for(let t of e)if(FG(n),xG(t.name,o,{stripQuotes:!0})){let e=i===-1?t.name:`${a}/${t.name}`;IG(n),r.push({path:e,isFile:t.isFile})}}else{FG(n);let e=await t.fs.readdir(s);for(let t of e)if(FG(n),xG(t,o,{stripQuotes:!0})){let e=i===-1?t:`${a}/${t}`;IG(n),r.push({path:e})}}}catch(e){rV(e)}return r.sort((e,t)=>e.path.localeCompare(t.path))}async function RG(e,t,n=[],r=[],i=[],a,o={operations:0,results:0,maxOperations:t.limits.maxGlobOperations,maxResults:t.limits.maxArrayElements},s=[],c=0){if(c>=UG)return s;let l=t.fs.resolvePath(t.cwd,e);try{let u,d;if(a!==void 0)u=a,d=!a;else{FG(o);let e=await t.fs.stat(l);u=e.isFile,d=e.isDirectory}if(u){let t=e.split(`/`).pop()||e;return r.length>0&&r.some(e=>xG(t,e,{stripQuotes:!0}))||n.length>0&&!n.some(e=>xG(t,e,{stripQuotes:!0}))||(IG(o),s.push({path:e,isFile:!0})),s}if(!d)return s;let f=e.split(`/`).pop()||e;if(i.length>0&&i.some(e=>xG(f,e,{stripQuotes:!0})))return s;if(t.fs.readdirWithFileTypes){FG(o);let a=await t.fs.readdirWithFileTypes(l);for(let l of a)FG(o),!l.name.startsWith(`.`)&&await RG(e===`.`?l.name:`${e}/${l.name}`,t,n,r,i,l.isFile,o,s,c+1)}else{FG(o);let a=await t.fs.readdir(l);for(let l of a)FG(o),!l.startsWith(`.`)&&await RG(e===`.`?l:`${e}/${l}`,t,n,r,i,void 0,o,s,c+1)}}catch(e){rV(e)}return s}var zG,BG,VG,HG,UG,WG,GG,KG,qG,JG,YG=B(()=>{AB(),iV(),U(),wG(),cV(),MG(),zG=`(standard input)`,BG=`[^\\s\\S]`,VG={name:`grep`,summary:`print lines that match patterns`,usage:`grep [OPTION]... PATTERN [FILE]...`,description:[`Search for PATTERN in each FILE.`,`With no FILE, or when FILE is -, read standard input.`],options:[`-E, --extended-regexp PATTERN is an extended regular expression`,`-P, --perl-regexp PATTERN is a Perl regular expression`,`-F, --fixed-strings PATTERN is a set of newline-separated strings`,`-i, --ignore-case ignore case distinctions`,`-v, --invert-match select non-matching lines`,`-w, --word-regexp match only whole words`,`-x, --line-regexp match only whole lines`,`-c, --count print only a count of matching lines`,`-l, --files-with-matches print only names of files with matches`,`-L, --files-without-match print names of files with no matches`,`-m NUM, --max-count=NUM stop after NUM matches`,`-n, --line-number print line number with output lines`,`-h, --no-filename suppress the file name prefix on output`,`-o, --only-matching show only nonempty parts of lines that match`,`-q, --quiet, --silent suppress all normal output`,`-r, -R, --recursive search directories recursively`,`-A NUM print NUM lines of trailing context`,`-B NUM print NUM lines of leading context`,`-C NUM print NUM lines of context`,`-e PATTERN use PATTERN for matching`,`-f FILE, --file=FILE obtain patterns from FILE, one per line`,` --include=GLOB search only files matching GLOB`,` --exclude=GLOB skip files matching GLOB`,` --exclude-dir=DIR skip directories matching DIR`,` --help display this help and exit`]},HG={name:`grep`,async execute(e,t){let n=!1,r=!1,i=!1,a=!1,o=!1,s=!1,c=!1,l=!1,u=!1,d=!1,f=!1,p=!1,m=!1,h=!1,g=!1,_=0,v=0,y=0,b=[],x=[],S=[],C=null,w=[],T=[],E=!0;for(let t=0;t0)w.push(n);else if(t+1t.limits.maxArrayElements)throw new H(`grep: array element limit exceeded (${t.limits.maxArrayElements})`,`array_elements`);O.push(...r)}if(O.length===0&&!i&&!s)return{stdout:``,stderr:``,exitCode:1};let A=p?`fixed`:d?`extended`:f?`perl`:`basic`;if(A===`perl`&&new Set(O).size>1)return{stdout:``,stderr:`grep: the -P option only supports a single pattern `,exitCode:2};if(O.length>1&&A!==`fixed`)for(let e of O)try{kG(e,{mode:A})}catch{return{stdout:``,stderr:`grep: invalid regular expression: ${e} `,exitCode:2}}let j=O.length===0?{pattern:BG,mode:`extended`}:yxe(O,A),M,ee,te;try{let e=kG(j.pattern,{mode:j.mode,ignoreCase:n,wholeWord:l,lineRegexp:u});M=e.regex,ee=e.kResetGroup,te=e.preFilter}catch{return{stdout:``,stderr:`grep: invalid regular expression: ${O.join(` `)} `,exitCode:2}}if(D.length===0&&t.stdin!==void 0){let e=DG(k?``:yB(t.stdin),M,{invertMatch:i,showLineNumbers:r,countOnly:a,filename:``,onlyMatching:m,beforeContext:v,afterContext:y,maxCount:_,kResetGroup:ee,preFilter:te,maxWork:PG(t),maxMatches:t.limits.maxArrayElements,signal:t.signal});return g?{stdout:``,stderr:``,exitCode:+!e.matched}:{stdout:e.output,stderr:``,exitCode:+!e.matched}}if(D.length===0)return{stdout:``,stderr:`grep: no input files `,exitCode:2};let N=``,ne=``,re=!1,ie=!1,ae=[],oe={operations:0,results:0,maxOperations:t.limits.maxGlobOperations,maxResults:t.limits.maxArrayElements},se=e=>{if(e.length>oe.maxResults-ae.length)throw new H(`grep: array element limit exceeded (${oe.maxResults})`,`array_elements`);ae.push(...e)},ce=!1,le=!1;for(let e of D){if(e===`-`){if(ae.length>=oe.maxResults)throw new H(`grep: array element limit exceeded (${oe.maxResults})`,`array_elements`);ae.push({path:zG,isFile:!0,isStdin:!0,stdinAtEof:ce}),ce=!0;continue}if(le=!0,e.includes(`*`)||e.includes(`?`)||e.includes(`[`)){let n=await bxe(e,t,oe);if(c)for(let e of n)se(await RG(e.path,t,b,x,S,e.isFile,oe));else se(n)}else if(c)se(await RG(e,t,b,x,S,void 0,oe));else{if(ae.length>=oe.maxResults)throw new H(`grep: array element limit exceeded (${oe.maxResults})`,`array_elements`);ae.push({path:e})}}let ue=(ae.length>1||c&&le)&&!h;for(let e=0;e{let n=e.path,o=n.split(`/`).pop()||n;if(x.length>0&&!c&&!e.isStdin&&x.some(e=>xG(o,e,{stripQuotes:!0}))||b.length>0&&!c&&!e.isStdin&&!b.some(e=>xG(o,e,{stripQuotes:!0})))return null;try{let o;if(e.isStdin)o=e.stdinAtEof||t.stdin===void 0?``:yB(t.stdin);else{let r=t.fs.resolvePath(t.cwd,n),i=!1;if(i=e.isFile===void 0?(await t.fs.stat(r)).isDirectory:!e.isFile,i)return c?null:{error:`grep: ${n}: Is a directory `};o=await t.fs.readFile(r)}if(te&&!i){let e=te.ignoreCase?o.toLowerCase():o;if(!te.needles.some(t=>e.includes(t)))return a?{file:n,result:{output:`${ue?`${n}:0`:`0`} `,matched:!1,matchCount:0}}:{file:n,result:{output:``,matched:!1,matchCount:0}}}return{file:n,result:DG(o,M,{invertMatch:i,showLineNumbers:r,countOnly:a,filename:ue?n:``,onlyMatching:m,beforeContext:v,afterContext:y,maxCount:_,kResetGroup:ee,preFilter:te,maxWork:PG(t),maxMatches:t.limits.maxArrayElements,signal:t.signal})}}catch(e){return rV(e),{error:`grep: ${n}: No such file or directory `}}}));for(let e of l){if(e===null)continue;if(`error`in e&&e.error){ne+=e.error,e.error.includes(`Is a directory`)||(ie=!0);continue}if(!(`file`in e)||!e.result)continue;let{file:t,result:n}=e;if(n.matched){if(re=!0,g)return{stdout:``,stderr:``,exitCode:0};o?N+=`${t} `:s||(N+=n.output)}else s?N+=`${t} `:a&&!o&&(N+=n.output)}}let de;return de=ie?2:+!re,g?{stdout:``,stderr:``,exitCode:de}:{stdout:N,stderr:ne,exitCode:de}}},UG=256,WG={name:`fgrep`,async execute(e,t){return HG.execute([`-F`,...e],t)}},GG={name:`egrep`,async execute(e,t){return HG.execute([`-E`,...e],t)}},KG={name:`grep`,flags:[{flag:`-E`,type:`boolean`},{flag:`-F`,type:`boolean`},{flag:`-P`,type:`boolean`},{flag:`-i`,type:`boolean`},{flag:`-v`,type:`boolean`},{flag:`-w`,type:`boolean`},{flag:`-x`,type:`boolean`},{flag:`-c`,type:`boolean`},{flag:`-l`,type:`boolean`},{flag:`-L`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-h`,type:`boolean`},{flag:`-o`,type:`boolean`},{flag:`-q`,type:`boolean`},{flag:`-r`,type:`boolean`},{flag:`-m`,type:`value`,valueHint:`number`},{flag:`-A`,type:`value`,valueHint:`number`},{flag:`-B`,type:`value`,valueHint:`number`},{flag:`-C`,type:`value`,valueHint:`number`},{flag:`-e`,type:`value`,valueHint:`pattern`},{flag:`-f`,type:`value`,valueHint:`path`}],stdinType:`text`,needsArgs:!0},qG={name:`fgrep`,flags:[],stdinType:`text`,needsArgs:!0},JG={name:`egrep`,flags:[],stdinType:`text`,needsArgs:!0}});function XG(e,t){if(Array.isArray(e))throw TypeError(`${t}: expected object, got array`);if(Object.getPrototypeOf(e)!==null)throw TypeError(`${t}: expected null-prototype object, got prototypal object`)}function ZG(e){return!iK.has(e)}function QG(e,t,n){XG(e,`safeSet`),ZG(t)&&(e[t]=n)}function $G(e,t){return XG(e,`safeHasOwn`),Object.hasOwn(e,t)}function eK(e,t={}){let n=t.maxDepth??2e3,r=t.maxElements??1e6,i=new WeakMap,a=t.elementBudget??{used:0};if(!Number.isSafeInteger(a.used)||a.used<0||a.used>r)throw new H(`query input element limit exceeded (${r})`,`array_elements`);let o=()=>{if(++a.used>r)throw new H(`query input element limit exceeded (${r})`,`array_elements`)},s=(e,t,r)=>{if(typeof e!=`object`||!e||e instanceof Date)return e;let a=i.get(e);if(a!==void 0)return a;if(t>n)throw new H(`query depth limit exceeded (${n})`,`recursion`);let o=Array.isArray(e)?[]:Object.create(null);return i.set(e,o),r.push({source:e,target:o,depth:t}),o},c=[],l=s(e,0,c);for(;c.length>0;){let e=c.pop();if(!e)break;let{source:t,target:n,depth:i}=e;if(Array.isArray(t)&&Array.isArray(n)){if(t.length>r-a.used)throw new H(`query input element limit exceeded (${r})`,`array_elements`);n.length=t.length;for(let e=t.length-1;e>=0;e--)o(),n[e]=s(t[e],i+1,c);continue}let l=t,u=n,d=Object.keys(l);if(d.length>r-a.used)throw new H(`query input element limit exceeded (${r})`,`array_elements`);for(let e=0;e{U(),iK=new Set([`__proto__`,`constructor`,`prototype`]),[...iK]});function Sxe(){let e=[];for(let[t,n]of Object.entries(oK).sort()){let r=[];for(let e of n.extensions)r.push(`*${e}`);for(let e of n.globs)r.push(e);e.push(`${t}: ${r.join(`, `)}`)}return`${e.join(` `)} `}var oK,sK,cK=B(()=>{bG(),aK(),oK=xxe({js:{extensions:[`.js`,`.mjs`,`.cjs`,`.jsx`],globs:[]},ts:{extensions:[`.ts`,`.tsx`,`.mts`,`.cts`],globs:[]},html:{extensions:[`.html`,`.htm`,`.xhtml`],globs:[]},css:{extensions:[`.css`,`.scss`,`.sass`,`.less`],globs:[]},json:{extensions:[`.json`,`.jsonc`,`.json5`],globs:[]},xml:{extensions:[`.xml`,`.xsl`,`.xslt`],globs:[]},c:{extensions:[`.c`,`.h`],globs:[]},cpp:{extensions:[`.cpp`,`.cc`,`.cxx`,`.hpp`,`.hh`,`.hxx`,`.h`],globs:[]},rust:{extensions:[`.rs`],globs:[]},go:{extensions:[`.go`],globs:[]},zig:{extensions:[`.zig`],globs:[]},java:{extensions:[`.java`],globs:[]},kotlin:{extensions:[`.kt`,`.kts`],globs:[]},scala:{extensions:[`.scala`,`.sc`],globs:[]},clojure:{extensions:[`.clj`,`.cljc`,`.cljs`,`.edn`],globs:[]},py:{extensions:[`.py`,`.pyi`,`.pyw`],globs:[]},rb:{extensions:[`.rb`,`.rake`,`.gemspec`],globs:[`Rakefile`,`Gemfile`]},php:{extensions:[`.php`,`.phtml`,`.php3`,`.php4`,`.php5`],globs:[]},perl:{extensions:[`.pl`,`.pm`,`.pod`,`.t`],globs:[]},lua:{extensions:[`.lua`],globs:[]},sh:{extensions:[`.sh`,`.bash`,`.zsh`,`.fish`],globs:[`.bashrc`,`.zshrc`,`.profile`]},bat:{extensions:[`.bat`,`.cmd`],globs:[]},ps:{extensions:[`.ps1`,`.psm1`,`.psd1`],globs:[]},yaml:{extensions:[`.yaml`,`.yml`],globs:[]},toml:{extensions:[`.toml`],globs:[`Cargo.toml`,`pyproject.toml`]},ini:{extensions:[`.ini`,`.cfg`,`.conf`],globs:[]},csv:{extensions:[`.csv`,`.tsv`],globs:[]},md:{extensions:[`.md`,`.mdx`,`.markdown`,`.mdown`,`.mkd`],globs:[]},markdown:{extensions:[`.md`,`.mdx`,`.markdown`,`.mdown`,`.mkd`],globs:[]},rst:{extensions:[`.rst`],globs:[]},txt:{extensions:[`.txt`,`.text`],globs:[]},tex:{extensions:[`.tex`,`.ltx`,`.sty`,`.cls`],globs:[]},sql:{extensions:[`.sql`],globs:[]},graphql:{extensions:[`.graphql`,`.gql`],globs:[]},proto:{extensions:[`.proto`],globs:[]},make:{extensions:[`.mk`,`.mak`],globs:[`Makefile`,`GNUmakefile`,`makefile`]},docker:{extensions:[],globs:[`Dockerfile`,`Dockerfile.*`,`*.dockerfile`]},tf:{extensions:[`.tf`,`.tfvars`],globs:[]}}),sK=class{types;constructor(){this.types=new Map(Object.entries(oK).map(([e,t])=>[e,{extensions:[...t.extensions],globs:[...t.globs]}]))}addType(e){let t=e.indexOf(`:`);if(t===-1)return;let n=e.slice(0,t),r=e.slice(t+1);if(r.startsWith(`include:`)){let e=r.slice(8),t=this.types.get(e);if(t){let e=this.types.get(n)||{extensions:[],globs:[]};e.extensions.push(...t.extensions),e.globs.push(...t.globs),this.types.set(n,e)}}else{let e=this.types.get(n)||{extensions:[],globs:[]};if(r.startsWith(`*.`)&&!r.slice(2).includes(`*`)){let t=r.slice(1);e.extensions.includes(t)||e.extensions.push(t)}else e.globs.includes(r)||e.globs.push(r);this.types.set(n,e)}}clearType(e){let t=this.types.get(e);t&&(t.extensions=[],t.globs=[])}getType(e){return this.types.get(e)}getAllTypes(){return this.types}matchesType(e,t){let n=e.toLowerCase();for(let r of t){if(r===`all`){if(this.matchesAnyType(e))return!0;continue}let t=this.types.get(r);if(t){for(let e of t.extensions)if(n.endsWith(e))return!0;for(let r of t.globs)if(r.includes(`*`)){if(hG(`^${r.replace(/\./g,`\\.`).replace(/\*/g,`.*`)}$`,`i`).test(e))return!0}else if(n===r.toLowerCase())return!0}}return!1}matchesAnyType(e){let t=e.toLowerCase();for(let n of this.types.values()){for(let e of n.extensions)if(t.endsWith(e))return!0;for(let r of n.globs)if(r.includes(`*`)){if(hG(`^${r.replace(/\./g,`\\.`).replace(/\*/g,`.*`)}$`,`i`).test(e))return!0}else if(t===r.toLowerCase())return!0}return!1}}});function Cxe(){return{ignoreCase:!1,caseSensitive:!1,smartCase:!0,fixedStrings:!1,wordRegexp:!1,lineRegexp:!1,invertMatch:!1,multiline:!1,multilineDotall:!1,patterns:[],patternFiles:[],count:!1,countMatches:!1,files:!1,filesWithMatches:!1,filesWithoutMatch:!1,stats:!1,onlyMatching:!1,maxCount:0,lineNumber:!0,noFilename:!1,withFilename:!1,nullSeparator:!1,byteOffset:!1,column:!1,vimgrep:!1,replace:null,afterContext:0,beforeContext:0,contextSeparator:`--`,quiet:!1,heading:!1,passthru:!1,includeZero:!1,sort:`path`,json:!1,globs:[],iglobs:[],globCaseInsensitive:!1,types:[],typesNot:[],typeAdd:[],typeClear:[],hidden:!1,noIgnore:!1,noIgnoreDot:!1,noIgnoreVcs:!1,ignoreFiles:[],maxDepth:256,maxFilesize:536870912,followSymlinks:!1,searchZip:!1,searchBinary:!1,preprocessor:null,preprocessorGlobs:[]}}var wxe=B(()=>{});function Txe(e){let t=e.match(/^(\d+)([KMG])?$/i);if(!t)return 0;let n=parseInt(t[1],10);switch((t[2]||``).toUpperCase()){case`K`:return n*1024;case`M`:return n*1024*1024;case`G`:return n*1024*1024*1024;default:return n}}function Exe(e){return/^\d+[KMG]?$/i.test(e)?null:{stdout:``,stderr:`rg: invalid --max-filesize value: ${e} `,exitCode:1}}function Dxe(e,t){return!/^\d+$/.test(t)||!Number.isSafeInteger(Number(t))?{stdout:``,stderr:`rg: invalid --${e} value: ${t} `,exitCode:1}:null}function lK(e){return null}function Oxe(e){e.hidden?e.searchBinary=!0:e.noIgnore?e.hidden=!0:e.noIgnore=!0}function kxe(e,t,n){let r=e[t];for(let i of dK){if(r.startsWith(`--${i.long}=`)){let e=uK(n,i,r.slice(`--${i.long}=`.length));return e?{newIndex:t,error:e}:{newIndex:t}}if(i.short&&r.startsWith(`-${i.short}`)&&r.length>2){let e=uK(n,i,r.slice(2));return e?{newIndex:t,error:e}:{newIndex:t}}if(i.short&&r===`-${i.short}`||r===`--${i.long}`){if(t+1>=e.length)return null;let r=e[t+1],a=uK(n,i,r);return a?{newIndex:t+1,error:a}:{newIndex:t+1}}}return null}function Axe(e){return dK.find(t=>t.short===e)}function uK(e,t,n){if(t.validate){let e=t.validate(n);if(e)return e}if(t.ignored||!t.target)return;let r=t.parse?t.parse(n):n;t.multi?e[t.target].push(r):e[t.target]=r}function jxe(e,t){let n=e[t];if(n===`--sort`&&t+1=e.length)return{success:!1,error:sV(`rg`,`-${n}`)};let i=uK(t,r,e[c+1]);if(i)return{success:!1,error:i};c++;continue}}let r=fK.get(n);if(r){r(t);continue}if(n.startsWith(`--`))return{success:!1,error:sV(`rg`,n)};if(n.length===1)return{success:!1,error:sV(`rg`,`-${n}`)}}}else n===null&&t.patterns.length===0&&t.patternFiles.length===0?n=l:r.push(l)}return(i>=0||o>=0)&&(t.afterContext=Math.max(i>=0?i:0,o>=0?o:0)),(a>=0||o>=0)&&(t.beforeContext=Math.max(a>=0?a:0,o>=0?o:0)),n!==null&&t.patterns.push(n),(t.column||t.vimgrep)&&(s=!0),{success:!0,options:t,paths:r,explicitLineNumbers:s}}var dK,fK,pK,Fxe=B(()=>{cV(),wxe(),dK=[{short:`g`,long:`glob`,target:`globs`,multi:!0},{long:`iglob`,target:`iglobs`,multi:!0},{short:`t`,long:`type`,target:`types`,multi:!0,validate:lK},{short:`T`,long:`type-not`,target:`typesNot`,multi:!0,validate:lK},{long:`type-add`,target:`typeAdd`,multi:!0},{long:`type-clear`,target:`typeClear`,multi:!0},{short:`m`,long:`max-count`,target:`maxCount`,parse:parseInt},{short:`e`,long:`regexp`,target:`patterns`,multi:!0},{short:`f`,long:`file`,target:`patternFiles`,multi:!0},{short:`r`,long:`replace`,target:`replace`},{short:`d`,long:`max-depth`,target:`maxDepth`,parse:e=>Number(e),validate:e=>Dxe(`max-depth`,e)},{long:`max-filesize`,target:`maxFilesize`,parse:Txe,validate:Exe},{long:`context-separator`,target:`contextSeparator`},{short:`j`,long:`threads`,ignored:!0},{long:`ignore-file`,target:`ignoreFiles`,multi:!0},{long:`pre`,target:`preprocessor`},{long:`pre-glob`,target:`preprocessorGlobs`,multi:!0}],fK=new Map([[`i`,e=>{e.ignoreCase=!0,e.caseSensitive=!1,e.smartCase=!1}],[`--ignore-case`,e=>{e.ignoreCase=!0,e.caseSensitive=!1,e.smartCase=!1}],[`s`,e=>{e.caseSensitive=!0,e.ignoreCase=!1,e.smartCase=!1}],[`--case-sensitive`,e=>{e.caseSensitive=!0,e.ignoreCase=!1,e.smartCase=!1}],[`S`,e=>{e.smartCase=!0,e.ignoreCase=!1,e.caseSensitive=!1}],[`--smart-case`,e=>{e.smartCase=!0,e.ignoreCase=!1,e.caseSensitive=!1}],[`F`,e=>{e.fixedStrings=!0}],[`--fixed-strings`,e=>{e.fixedStrings=!0}],[`w`,e=>{e.wordRegexp=!0}],[`--word-regexp`,e=>{e.wordRegexp=!0}],[`x`,e=>{e.lineRegexp=!0}],[`--line-regexp`,e=>{e.lineRegexp=!0}],[`v`,e=>{e.invertMatch=!0}],[`--invert-match`,e=>{e.invertMatch=!0}],[`U`,e=>{e.multiline=!0}],[`--multiline`,e=>{e.multiline=!0}],[`--multiline-dotall`,e=>{e.multilineDotall=!0,e.multiline=!0}],[`c`,e=>{e.count=!0}],[`--count`,e=>{e.count=!0}],[`--count-matches`,e=>{e.countMatches=!0}],[`l`,e=>{e.filesWithMatches=!0}],[`--files`,e=>{e.files=!0}],[`--files-with-matches`,e=>{e.filesWithMatches=!0}],[`--files-without-match`,e=>{e.filesWithoutMatch=!0}],[`--stats`,e=>{e.stats=!0}],[`o`,e=>{e.onlyMatching=!0}],[`--only-matching`,e=>{e.onlyMatching=!0}],[`q`,e=>{e.quiet=!0}],[`--quiet`,e=>{e.quiet=!0}],[`N`,e=>{e.lineNumber=!1}],[`--no-line-number`,e=>{e.lineNumber=!1}],[`H`,e=>{e.withFilename=!0}],[`--with-filename`,e=>{e.withFilename=!0}],[`I`,e=>{e.noFilename=!0}],[`--no-filename`,e=>{e.noFilename=!0}],[`0`,e=>{e.nullSeparator=!0}],[`--null`,e=>{e.nullSeparator=!0}],[`b`,e=>{e.byteOffset=!0}],[`--byte-offset`,e=>{e.byteOffset=!0}],[`--column`,e=>{e.column=!0,e.lineNumber=!0}],[`--no-column`,e=>{e.column=!1}],[`--vimgrep`,e=>{e.vimgrep=!0,e.column=!0,e.lineNumber=!0}],[`--json`,e=>{e.json=!0}],[`--hidden`,e=>{e.hidden=!0}],[`--no-ignore`,e=>{e.noIgnore=!0}],[`--no-ignore-dot`,e=>{e.noIgnoreDot=!0}],[`--no-ignore-vcs`,e=>{e.noIgnoreVcs=!0}],[`L`,e=>{e.followSymlinks=!0}],[`--follow`,e=>{e.followSymlinks=!0}],[`z`,e=>{e.searchZip=!0}],[`--search-zip`,e=>{e.searchZip=!0}],[`a`,e=>{e.searchBinary=!0}],[`--text`,e=>{e.searchBinary=!0}],[`--heading`,e=>{e.heading=!0}],[`--passthru`,e=>{e.passthru=!0}],[`--include-zero`,e=>{e.includeZero=!0}],[`--glob-case-insensitive`,e=>{e.globCaseInsensitive=!0}]]),pK=new Set([`n`,`--line-number`])});function Ixe(e){return`'${e.replace(/'/g,`'\\''`)}'`}function mK(e){return e.map(Ixe).join(` `)}var hK=B(()=>{});async function gK(e,t,n=!1,r=!1,i=[]){let a=new vK(e,t,n,r);await a.load(t);for(let n of i)try{let r=e.resolvePath(t,n),i=await e.readFile(r);a.addPatternsFromContent(i,t)}catch{}return a}var _K,vK,Lxe=B(()=>{bG(),_K=class{patterns=[];basePath;constructor(e=`/`){this.basePath=e}parse(e){let t=e.split(` `);for(let e of t){let t=e.replace(/\s+$/,``);if(!t||t.startsWith(`#`))continue;let n=!1;t.startsWith(`!`)&&(n=!0,t=t.slice(1));let r=!1;t.endsWith(`/`)&&(r=!0,t=t.slice(0,-1));let i=!1;t.startsWith(`/`)?(i=!0,t=t.slice(1)):t.includes(`/`)&&!t.startsWith(`**/`)&&(i=!0);let a=this.patternToRegex(t,i);this.patterns.push({pattern:e,regex:a,negated:n,directoryOnly:r,rooted:i})}}patternToRegex(e,t){let n=``;n=t?`^`:`(?:^|/)`;let r=0;for(;r=2&&e[0]===31&&e[1]===139}function zxe(e){let t=!1;for(let n=0;ne.limits.maxStringLength||t>Math.floor(e.limits.maxLiveBytes/3))throw new H(t>e.limits.maxStringLength?`rg: pattern file exceeds string limit (${e.limits.maxStringLength} bytes)`:`rg: live byte limit exceeded (${e.limits.maxLiveBytes} bytes)`,`string_length`);return e.executionScope?.reserveBytes(`rg pattern files`,t*3,`rg`)??{release:()=>{}}}function Bxe(e,t,n){let r=0;for(let i=0;i<=t.length;i++)if(!(ir){if(e.length>=n.limits.maxArrayElements)throw new H(`rg: pattern limit exceeded (${n.limits.maxArrayElements})`,`iterations`);n.executionScope?.consumeWork(1,`rg pattern insertion`),e.push(t.slice(r,i))}r=i+1}}function bK(e,t,n){if(t>e.limits.maxInputBytes-n)throw new H(`rg: aggregate input size limit exceeded (${e.limits.maxInputBytes} bytes)`,`string_length`);return e.executionScope?.consumeInput(t,`rg pattern files`),n+t}async function Vxe(e){let{ctx:t,options:n,paths:r,explicitLineNumbers:i}=e;for(let e of n.globs){let t=zxe(e.startsWith(`!`)?e.slice(1):e);if(t)return{stdout:``,stderr:`${t} `,exitCode:1}}if(n.files)return Wxe(t,[...n.patterns,...r],n);if(n.patterns.length>t.limits.maxArrayElements)throw new H(`rg: pattern limit exceeded (${t.limits.maxArrayElements})`,`iterations`);let a=n.patterns.slice(),o=[],s=0,c,l;try{for(let e of n.patternFiles)try{let n,r;if(e===`-`)n=t.stdin,r=t.stdin.length,s=bK(t,r,s);else{let i=t.fs.resolvePath(t.cwd,e);r=(await t.fs.stat(i)).size,s=bK(t,r,s);let a=yK(t,r);o.push(a),n=await SB(t.fs,i);let c=n.length;if(c>r)throw new H(`rg: pattern file grew while being read`,`string_length`);r=c}e===`-`&&o.push(yK(t,r));let i=yB(n,t.limits.maxStringLength);t.executionScope?.consumeWork(i.length,`rg pattern file parsing`),Bxe(a,i,t)}catch(t){return rV(t),{stdout:``,stderr:`rg: ${e}: No such file or directory `,exitCode:2}}if(a.length===0)return n.patternFiles.length>0?{stdout:``,stderr:``,exitCode:1}:{stdout:``,stderr:`rg: no pattern given `,exitCode:2};let e=Hxe(n,a);try{let t=Uxe(a,n,e);c=t.regex,l=t.kResetGroup}catch{return{stdout:``,stderr:`rg: invalid regex: ${a.join(`, `)} `,exitCode:2}}}finally{for(let e of o)e.release()}let u=n.patternFiles.includes(`-`),d=yB(t.stdin);if(r.length===0&&d.length>0&&!u){let e=DG(d,c,{invertMatch:n.invertMatch,showLineNumbers:n.lineNumber,countOnly:n.count,countMatches:n.countMatches,filename:``,onlyMatching:n.onlyMatching,beforeContext:n.beforeContext,afterContext:n.afterContext,maxCount:n.maxCount,contextSeparator:n.contextSeparator,showColumn:n.column,vimgrep:n.vimgrep,showByteOffset:n.byteOffset,replace:n.replace===null?null:AG(n.replace),passthru:n.passthru,multiline:n.multiline,kResetGroup:l,maxWork:t.limits.maxLoopIterations,maxMatches:t.limits.maxArrayElements,signal:t.signal});return n.quiet?{stdout:``,stderr:``,exitCode:+!e.matched}:n.filesWithMatches?{stdout:e.matched?`(standard input) `:``,stderr:``,exitCode:+!e.matched}:n.filesWithoutMatch?{stdout:e.matched?``:`(standard input) `,stderr:``,exitCode:+!!e.matched}:{stdout:e.output,stderr:``,exitCode:+!e.matched}}let f=r.length===0?[`.`]:r,p=null;n.noIgnore||(p=await gK(t.fs,t.cwd,n.noIgnoreDot,n.noIgnoreVcs,n.ignoreFiles));let m=new sK;for(let e of n.typeClear)m.clearType(e);for(let e of n.typeAdd)m.addType(e);let{files:h,singleExplicitFile:g}=await xK(t,f,n,p,m);if(h.length===0)return{stdout:``,stderr:``,exitCode:1};let _=!n.noFilename&&(n.withFilename||!g||h.length>1),v=n.lineNumber;return i||(g&&h.length===1&&(v=!1),n.onlyMatching&&(v=!1)),Jxe(t,h,c,n,_,v,l)}function Hxe(e,t){return e.caseSensitive?!1:e.ignoreCase?!0:e.smartCase?!t.some(e=>/[A-Z]/.test(e)):!1}function Uxe(e,t,n){let r;return r=e.length===1?e[0]:e.map(e=>t.fixedStrings?e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`):`(?:${e})`).join(`|`),kG(r,{mode:t.fixedStrings&&e.length===1?`fixed`:`perl`,ignoreCase:n,wholeWord:t.wordRegexp,lineRegexp:t.lineRegexp,multiline:t.multiline,multilineDotall:t.multilineDotall})}async function xK(e,t,n,r,i){let a=[],o=new DH({limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:`rg`}),s=0,c=0;for(let l of t){o.checkpoint();let t=e.fs.resolvePath(e.cwd,l);try{let u=await e.fs.stat(t);if(u.isFile){if(s++,n.maxFilesize>0&&u.size>n.maxFilesize)continue;if(CK(l,n,r,t,i)){if(a.length>=e.limits.maxArrayElements)throw new H(`rg: file collection limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);a.push(l)}}else u.isDirectory&&(c++,await SK(e,l,t,0,n,r,i,a,o,new Set))}catch(e){rV(e)}}return{files:n.sort===`path`?a.sort():a,singleExplicitFile:s===1&&c===0}}async function SK(e,t,n,r,i,a,o,s,c,l){if(r>=i.maxDepth)return;c.visit(r);let u;if(i.followSymlinks)try{let t=await e.fs.stat(n);if(u=t.identity===void 0?t.dev!==void 0&&t.ino!==void 0?`inode:${String(t.dev)}:${String(t.ino)}`:`path:${await e.fs.realpath(n)}`:`identity:${t.identity}`,l.has(u))return;l.add(u)}catch(e){rV(e);return}a&&await a.loadForDirectory(n);try{let u=e.fs.readdirWithFileTypes?await e.fs.readdirWithFileTypes(n):(await e.fs.readdir(n)).map(e=>({name:e,isFile:void 0}));for(let d of u){c.checkpoint();let u=d.name;if(!i.noIgnore&&vK.isCommonIgnored(u))continue;let f=u.startsWith(`.`),p=t===`.`?u:t===`./`?`./${u}`:t.endsWith(`/`)?`${t}${u}`:`${t}/${u}`,m=e.fs.resolvePath(n,u),h,g,_=!1;if(d.isFile!==void 0&&`isDirectory`in d){let t=d;if(_=t.isSymbolicLink===!0,_&&!i.followSymlinks)continue;if(_&&i.followSymlinks)try{let t=await e.fs.stat(m);h=t.isFile,g=t.isDirectory}catch{continue}else h=t.isFile,g=t.isDirectory}else try{let t=e.fs.lstat?await e.fs.lstat(m):await e.fs.stat(m);if(_=t.isSymbolicLink===!0,_&&!i.followSymlinks)continue;let n=_&&i.followSymlinks?await e.fs.stat(m):t;h=n.isFile,g=n.isDirectory}catch{continue}if(!a?.matches(m,g)&&(!f||i.hidden||a?.isWhitelisted(m,g))){if(g)await SK(e,p,m,r+1,i,a,o,s,c,l);else if(h){if(c.visit(r+1),i.maxFilesize>0)try{if((await e.fs.stat(m)).size>i.maxFilesize)continue}catch{continue}if(CK(p,i,a,m,o)){if(s.length>=e.limits.maxArrayElements)throw new H(`rg: file collection limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);s.push(p)}}}}}catch(e){rV(e)}finally{u!==void 0&&l.delete(u)}}function CK(e,t,n,r,i){let a=e.split(`/`).pop()||e;if(n?.matches(r,!1)||t.types.length>0&&!i.matchesType(a,t.types)||t.typesNot.length>0&&i.matchesType(a,t.typesNot))return!1;if(t.globs.length>0){let n=t.globCaseInsensitive,r=t.globs.filter(e=>!e.startsWith(`!`)),i=t.globs.filter(e=>e.startsWith(`!`)).map(e=>e.slice(1));if(r.length>0){let t=!1;for(let i of r)if(wK(a,i,n)||wK(e,i,n)){t=!0;break}if(!t)return!1}for(let t of i)if(t.startsWith(`/`)){if(wK(e,t.slice(1),n))return!1}else if(wK(a,t,n)||wK(e,t,n))return!1}if(t.iglobs.length>0){let n=t.iglobs.filter(e=>!e.startsWith(`!`)),r=t.iglobs.filter(e=>e.startsWith(`!`)).map(e=>e.slice(1));if(n.length>0){let t=!1;for(let r of n)if(wK(a,r,!0)||wK(e,r,!0)){t=!0;break}if(!t)return!1}for(let t of r)if(t.startsWith(`/`)){if(wK(e,t.slice(1),!0))return!1}else if(wK(a,t,!0)||wK(e,t,!0))return!1}return!0}function wK(e,t,n=!1){let r=`^`;for(let e=0;en.size)throw r?.release(),new H(`rg: file grew while being read`,`string_length`);if(e.executionScope?.consumeInput(i.byteLength,`rg`),Rxe(i)){let t;try{let n=Math.min(e.limits.maxStringLength,e.limits.maxOutputSize,Math.floor((e.executionScope?.remainingLiveBytes??e.limits.maxLiveBytes)/2));t=e.executionScope?.reserveBytes(`rg decompressed text`,n*2,`rg`);let a=(0,CR.gunzipSync)(i,{maxOutputLength:n}),o=new TextDecoder().decode(a);return{content:o,isBinary:o.slice(0,8192).includes(`\0`),lease:qxe(r,t)}}catch(e){return t?.release(),r?.release(),rV(e),null}}r?.release()}let a=await e.fs.stat(t);i=e.executionScope?.reserveBytes(`rg file text`,a.size*2,`rg`);let o=await SB(e.fs,t),s=o.length;if(s>a.size)throw new H(`rg: file grew while being read`,`string_length`);e.executionScope?.consumeInput(s,`rg`);let c=yB(o,e.limits.maxStringLength);return{content:c,isBinary:c.slice(0,8192).includes(`\0`),lease:i}}catch(e){return i?.release(),rV(e),null}}function qxe(...e){let t=e.filter(e=>e!==void 0);if(t.length!==0)return{release:()=>{for(let e of t)e.release()}}}async function Jxe(e,t,n,r,i,a,o){let s=``,c=!1,l=[],u=0,d=0,f=0,p=r.searchZip?2:50;e:for(let m=0;m{let s=await Kxe(e,e.fs.resolvePath(e.cwd,t),t,r);if(!s)return null;let{content:c,isBinary:l,lease:u}=s;if(f+=c.length,l&&!r.searchBinary)return u?.release(),null;let d=i&&!r.heading?t:``;try{let i=DG(c,n,{invertMatch:r.invertMatch,showLineNumbers:a,countOnly:r.count,countMatches:r.countMatches,filename:d,onlyMatching:r.onlyMatching,beforeContext:r.beforeContext,afterContext:r.afterContext,maxCount:r.maxCount,contextSeparator:r.contextSeparator,showColumn:r.column,vimgrep:r.vimgrep,showByteOffset:r.byteOffset,replace:r.replace===null?null:AG(r.replace),passthru:r.passthru,multiline:r.multiline,kResetGroup:o,maxWork:e.limits.maxLoopIterations,maxMatches:e.limits.maxArrayElements,signal:e.signal});return r.json&&i.matched?{file:t,result:i,content:c,isBinary:!1,lease:u}:(u?.release(),{file:t,result:i})}catch(e){throw u?.release(),e}}));for(let e of g){if(!e)continue;let{file:t,result:i}=e;if(i.matched){if(c=!0,d++,u+=i.matchCount,r.quiet&&!r.json)break e;if(r.json&&!r.quiet){let a=e.content||``;l.push(JSON.stringify({type:`begin`,data:{path:{text:t}}}));let o=a.split(` `);n.lastIndex=0;let s=0;for(let e=0;e0){let n={type:`match`,data:{path:{text:t},lines:{text:`${i} `},line_number:e+1,absolute_offset:s,submatches:a}};l.push(JSON.stringify(n))}s+=i.length+1}l.push(JSON.stringify({type:`end`,data:{path:{text:t},binary_offset:null,stats:{elapsed:{secs:0,nanos:0,human:`0s`},searches:1,searches_with_match:1,bytes_searched:a.length,bytes_printed:0,matched_lines:i.matchCount,matches:i.matchCount}}}))}else if(r.filesWithMatches){let e=r.nullSeparator?`\0`:` `;s+=`${t}${e}`}else r.filesWithoutMatch||(r.heading&&!r.noFilename&&(s+=`${t} `),s+=i.output)}else if(r.filesWithoutMatch){let e=r.nullSeparator?`\0`:` `;s+=`${t}${e}`}else r.includeZero&&(r.count||r.countMatches)&&(s+=i.output);e.lease?.release()}}r.json&&(l.push(JSON.stringify({type:`summary`,data:{elapsed_total:{secs:0,nanos:0,human:`0s`},stats:{elapsed:{secs:0,nanos:0,human:`0s`},searches:t.length,searches_with_match:d,bytes_searched:f,bytes_printed:0,matched_lines:u,matches:u}}})),s=`${l.join(` `)} `);let m=r.quiet&&!r.json?``:s;if(r.stats&&!r.json){let e=[``,`${u} matches`,`${u} matched lines`,`${d} files contained matches`,`${t.length} files searched`,`${f} bytes searched`].join(` `);m+=`${e} `}let h;return h=r.filesWithoutMatch?s.length>0?0:1:+!c,{stdout:m,stderr:``,exitCode:h}}var Yxe=B(()=>{cH(),AB(),iV(),OH(),hK(),U(),bG(),MG(),cK(),Lxe()}),TK={};Tz(TK,{flagsForFuzzing:()=>OK,rgCommand:()=>DK});var EK,DK,OK,Xxe=B(()=>{cV(),cK(),Fxe(),Yxe(),EK={name:`rg`,summary:`recursively search for a pattern`,usage:`rg [OPTIONS] PATTERN [PATH ...]`,description:`rg (ripgrep) recursively searches directories for a regex pattern. Unlike grep, rg is recursive by default and respects .gitignore files. EXAMPLES: rg foo Search for 'foo' in current directory rg foo src/ Search in src/ directory rg -i foo Case-insensitive search rg -w foo Match whole words only rg -t js foo Search only JavaScript files rg -g '*.ts' foo Search files matching glob rg --hidden foo Include hidden files rg -l foo List files with matches only`,options:[`-e, --regexp PATTERN search for PATTERN (can be used multiple times)`,`-f, --file FILE read patterns from FILE, one per line`,`-i, --ignore-case case-insensitive search`,`-s, --case-sensitive case-sensitive search (overrides smart-case)`,`-S, --smart-case smart case (default: case-insensitive unless pattern has uppercase)`,`-F, --fixed-strings treat pattern as literal string`,`-w, --word-regexp match whole words only`,`-x, --line-regexp match whole lines only`,`-v, --invert-match select non-matching lines`,`-r, --replace TEXT replace matches with TEXT`,`-c, --count print count of matching lines per file`,` --count-matches print count of individual matches per file`,`-l, --files-with-matches print only file names with matches`,` --files-without-match print file names without matches`,` --files list files that would be searched`,`-o, --only-matching print only matching parts`,`-m, --max-count NUM stop after NUM matches per file`,`-q, --quiet suppress output, exit 0 on match`,` --stats print search statistics`,`-n, --line-number print line numbers (default: on)`,`-N, --no-line-number do not print line numbers`,`-I, --no-filename suppress the prefixing of file names`,`-0, --null use NUL as filename separator`,`-b, --byte-offset show byte offset of each match`,` --column show column number of first match`,` --vimgrep show results in vimgrep format`,` --json show results in JSON Lines format`,`-A NUM print NUM lines after each match`,`-B NUM print NUM lines before each match`,`-C NUM print NUM lines before and after each match`,` --context-separator SEP separator for context groups (default: --)`,`-U, --multiline match patterns across lines`,`-z, --search-zip search in compressed files (gzip only)`,`-g, --glob GLOB include files matching GLOB`,`-t, --type TYPE only search files of TYPE (e.g., js, py, ts)`,`-T, --type-not TYPE exclude files of TYPE`,`-L, --follow follow symbolic links`,`-u, --unrestricted reduce filtering (-u: no ignore, -uu: +hidden, -uuu: +binary)`,`-a, --text search binary files as text`,` --hidden search hidden files and directories`,` --no-ignore don't respect .gitignore/.ignore files`,`-d, --max-depth NUM maximum search depth`,` --sort TYPE sort files (path, none)`,` --heading show file path above matches`,` --passthru print all lines (non-matches use - separator)`,` --include-zero include files with 0 matches in count output`,` --type-list list all available file types`,` --help display this help and exit`]},DK={name:`rg`,async execute(e,t){if(oV(e))return aV(EK);if(e.includes(`--type-list`))return{stdout:Sxe(),stderr:``,exitCode:0};let n=Pxe(e);return n.success?Vxe({ctx:t,options:n.options,paths:n.paths,explicitLineNumbers:n.explicitLineNumbers}):n.error}},OK={name:`rg`,flags:[{flag:`-i`,type:`boolean`},{flag:`-s`,type:`boolean`},{flag:`-S`,type:`boolean`},{flag:`-F`,type:`boolean`},{flag:`-w`,type:`boolean`},{flag:`-x`,type:`boolean`},{flag:`-v`,type:`boolean`},{flag:`-c`,type:`boolean`},{flag:`-l`,type:`boolean`},{flag:`-o`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-N`,type:`boolean`},{flag:`--hidden`,type:`boolean`},{flag:`--no-ignore`,type:`boolean`},{flag:`-m`,type:`value`,valueHint:`number`},{flag:`-A`,type:`value`,valueHint:`number`},{flag:`-B`,type:`value`,valueHint:`number`},{flag:`-C`,type:`value`,valueHint:`number`},{flag:`-g`,type:`value`,valueHint:`pattern`},{flag:`-t`,type:`value`,valueHint:`string`},{flag:`-T`,type:`value`,valueHint:`string`}],needsArgs:!0}});function kK(e,t,n){if(!e||aB.isInSandboxedContext())return;let r=`${t} ${n} attempted outside defense context`;throw new tB(r,{timestamp:Date.now(),type:`missing_defense_context`,message:r,path:`DefenseInDepthBox.context`,stack:Error().stack,executionId:aB.getCurrentExecutionId()})}async function AK(e,t,n,r){kK(e,t,`${n} (pre-await)`);let i=await r();return kK(e,t,`${n} (post-await)`),i}var jK=B(()=>{oB()});function MK(e){let t=``,n=0,r=!1;for(;n=127?`\\${i.toString(8).padStart(3,`0`)}`:r}return`${t}$`}var PK,Qxe=B(()=>{PK=new Map([[`alnum`,`a-zA-Z0-9`],[`alpha`,`a-zA-Z`],[`ascii`,`\\x00-\\x7F`],[`blank`,` \\t`],[`cntrl`,`\\x00-\\x1F\\x7F`],[`digit`,`0-9`],[`graph`,`!-~`],[`lower`,`a-z`],[`print`,` -~`],[`punct`,"!-/:-@\\[-`{-~"],[`space`,` \\t\\n\\r\\f\\v`],[`upper`,`A-Z`],[`word`,`a-zA-Z0-9_`],[`xdigit`,`0-9A-Fa-f`]])});function $xe(e,t,n){return{patternSpace:``,holdSpace:``,lineNumber:0,totalLines:e,deleted:!1,printed:!1,quit:!1,quitSilent:!1,exitCode:void 0,errorMessage:void 0,appendBuffer:[],substitutionMade:!1,lineNumberOutput:[],nCommandOutput:[],restartCycle:!1,inDRestartedCycle:!1,currentFilename:t,pendingFileReads:[],pendingFileWrites:[],rangeStates:n||new Map,linesConsumedInCycle:0}}function eSe(e){return typeof e==`object`&&`first`in e&&`step`in e}function tSe(e){return typeof e==`object`&&`offset`in e}function FK(e,t,n,r,i){if(e===`$`)return t===n;if(typeof e==`number`)return t===e;if(eSe(e)){let{first:n,step:r}=e;return r===0?t===n:(t-n)%r===0&&t>=n}if(typeof e==`object`&&`pattern`in e)try{let t=e.pattern;return t===``&&i?.lastPattern?t=i.lastPattern:t!==``&&i&&(i.lastPattern=t),hG(NK(MK(t))).test(r)}catch{return!1}return!1}function IK(e){let t=e=>e===void 0?`undefined`:e===`$`?`$`:typeof e==`number`?String(e):`pattern`in e?`/${e.pattern}/`:`first`in e?`${e.first}~${e.step}`:`unknown`;return`${t(e.start)},${t(e.end)}`}function nSe(e,t,n,r,i,a){if(!e||!e.start&&!e.end)return!0;let o=e.start,s=e.end;if(o!==void 0&&s===void 0)return FK(o,t,n,r,a);if(o!==void 0&&s!==void 0){let c=typeof o==`object`&&`pattern`in o,l=typeof s==`object`&&`pattern`in s,u=tSe(s);if(u&&i){let c=IK(e),l=i.get(c);return l||(l={active:!1},i.set(c,l)),l.active?(t>=(l.startLine||t)+s.offset&&(l.active=!1,i.set(c,l)),!0):FK(o,t,n,r,a)?(l.active=!0,l.startLine=t,i.set(c,l),s.offset===0&&(l.active=!1,i.set(c,l)),!0):!1}if(!c&&!l&&!u){let r=typeof o==`number`?o:o===`$`?n:1,a=typeof s==`number`?s:n;if(r<=a)return t>=r&&t<=a;if(i){let n=IK(e),a=i.get(n);return a||(a={active:!1},i.set(n,a)),!a.completed&&t>=r&&(a.completed=!0,i.set(n,a),!0)}return!1}if(i){let c=IK(e),l=i.get(c);if(l||(l={active:!1},i.set(c,l)),l.active)return FK(s,t,n,r,a)&&(l.active=!1,typeof o==`number`&&(l.completed=!0),i.set(c,l)),!0;{if(l.completed)return!1;let e=!1;return e=typeof o==`number`?t>=o:FK(o,t,n,r,a),e?(l.active=!0,l.startLine=t,i.set(c,l),FK(s,t,n,r,a)&&(l.active=!1,typeof o==`number`&&(l.completed=!0),i.set(c,l)),!0):!1}}return FK(o,t,n,r,a)}return!0}function LK(e,t,n,r,i,a){let o=nSe(e,t,n,r,i,a);return e?.negated?!o:o}function rSe(e,t,n,r){let i=``,a=0,o=!1;for(;a<=e.length;){t.lastIndex=a;let n=t.exec(e);if(!n){i+=e.slice(a);break}if(n.index!==a){i+=e.slice(a,n.index),a=n.index,o=!1;continue}let s=n[0],c=n.slice(1);if(o&&s.length===0){if(a=1&&o<=9){r+=n[o-1]||``,i+=2;continue}r+=a,i+=2;continue}if(e[i]===`&`){r+=t,i++;continue}r+=e[i],i++}return r}function zK(e,t,n){if(t>0&&e.length>t)throw new H(`sed: ${n} size limit exceeded (${t} bytes)`,`string_length`)}function iSe(e,t,n){let{lineNumber:r,totalLines:i,patternSpace:a}=t;if(e.type===`label`){t.coverage?.hit(`sed:cmd:${e.type}`);return}if(LK(e.address,r,i,a,t.rangeStates,t))switch(t.coverage?.hit(`sed:cmd:${e.type}`),e.type){case`substitute`:{let n=e,r=``;n.global&&(r+=`g`),n.ignoreCase&&(r+=`i`);let i=n.pattern;i===``&&t.lastPattern?i=t.lastPattern:i!==``&&(t.lastPattern=i);let a=NK(n.extendedRegex?i:MK(i));try{let e=hG(a,r),i=e.test(t.patternSpace);if(e.lastIndex=0,i){if(t.substitutionMade=!0,n.nthOccurrence&&n.nthOccurrence>0&&!n.global){let e=0,r=n.nthOccurrence;t.patternSpace=hG(a,`g${n.ignoreCase?`i`:``}`).replace(t.patternSpace,(t,...i)=>{if(e++,e===r){let e=i.slice(0,-2);return RK(n.replacement,t,e)}return t})}else if(n.global){let e=hG(a,`g${n.ignoreCase?`i`:``}`);t.patternSpace=rSe(t.patternSpace,e,n.replacement,(e,t)=>RK(n.replacement,e,t))}else t.patternSpace=e.replace(t.patternSpace,(e,...t)=>{let r=t.slice(0,-2);return RK(n.replacement,e,r)});n.printOnMatch&&t.lineNumberOutput.push(t.patternSpace)}}catch{}break}case`print`:t.lineNumberOutput.push(t.patternSpace);break;case`printFirstLine`:{let e=t.patternSpace.indexOf(` `);e===-1?t.lineNumberOutput.push(t.patternSpace):t.lineNumberOutput.push(t.patternSpace.slice(0,e));break}case`delete`:t.deleted=!0;break;case`deleteFirstLine`:{let e=t.patternSpace.indexOf(` `);e===-1?t.deleted=!0:(t.patternSpace=t.patternSpace.slice(e+1),t.restartCycle=!0,t.inDRestartedCycle=!0);break}case`zap`:t.patternSpace=``;break;case`append`:t.appendBuffer.push(e.text);break;case`insert`:t.appendBuffer.unshift(`__INSERT__${e.text}`);break;case`change`:t.deleted=!0,t.changedText=e.text;break;case`hold`:t.holdSpace=t.patternSpace;break;case`holdAppend`:t.holdSpace?t.holdSpace+=` ${t.patternSpace}`:t.holdSpace=t.patternSpace,zK(t.holdSpace,n?.maxStringLength??0,`hold space`);break;case`get`:t.patternSpace=t.holdSpace;break;case`getAppend`:t.patternSpace+=` ${t.holdSpace}`,zK(t.patternSpace,n?.maxStringLength??0,`pattern space`);break;case`exchange`:{let e=t.patternSpace;t.patternSpace=t.holdSpace,t.holdSpace=e;break}case`next`:t.printed=!0;break;case`quit`:t.quit=!0,e.exitCode!==void 0&&(t.exitCode=e.exitCode);break;case`quitSilent`:t.quit=!0,t.quitSilent=!0,e.exitCode!==void 0&&(t.exitCode=e.exitCode);break;case`list`:{let e=Zxe(t.patternSpace);t.lineNumberOutput.push(e);break}case`printFilename`:t.currentFilename&&t.lineNumberOutput.push(t.currentFilename);break;case`version`:{let n=[4,8,0];if(e.minVersion){let r=e.minVersion.split(`.`),i=[],a=!1;for(let n of r){let r=parseInt(n,10);if(Number.isNaN(r)||r<0){t.quit=!0,t.exitCode=1,t.errorMessage=`sed: invalid version string: ${e.minVersion}`,a=!0;break}i.push(r)}if(!a){for(;i.length<3;)i.push(0);for(let r=0;r<3;r++){if(i[r]>n[r]){t.quit=!0,t.exitCode=1,t.errorMessage=`sed: this is not GNU sed version ${e.minVersion}`;break}if(i[r]a)throw new H(`sed: command execution exceeded maximum iterations (${a})`,`iterations`);if(t.deleted||t.quit||t.quitSilent||t.restartCycle)break;let c=e[s];if(c.type===`next`){if(LK(c.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t)){if(t.coverage?.hit(`sed:cmd:next`),t.nCommandOutput.push(t.patternSpace),n&&n.currentLineIndex+t.linesConsumedInCycle+1{U(),bG(),Qxe(),VK=1e4}),HK,UK,sSe=B(()=>{U(),(function(e){e.NUMBER=`NUMBER`,e.DOLLAR=`DOLLAR`,e.PATTERN=`PATTERN`,e.STEP=`STEP`,e.RELATIVE_OFFSET=`RELATIVE_OFFSET`,e.LBRACE=`LBRACE`,e.RBRACE=`RBRACE`,e.SEMICOLON=`SEMICOLON`,e.NEWLINE=`NEWLINE`,e.COMMA=`COMMA`,e.NEGATION=`NEGATION`,e.COMMAND=`COMMAND`,e.SUBSTITUTE=`SUBSTITUTE`,e.TRANSLITERATE=`TRANSLITERATE`,e.LABEL_DEF=`LABEL_DEF`,e.BRANCH=`BRANCH`,e.BRANCH_ON_SUBST=`BRANCH_ON_SUBST`,e.BRANCH_ON_NO_SUBST=`BRANCH_ON_NO_SUBST`,e.TEXT_CMD=`TEXT_CMD`,e.FILE_READ=`FILE_READ`,e.FILE_READ_LINE=`FILE_READ_LINE`,e.FILE_WRITE=`FILE_WRITE`,e.FILE_WRITE_LINE=`FILE_WRITE_LINE`,e.EXECUTE=`EXECUTE`,e.VERSION=`VERSION`,e.EOF=`EOF`,e.ERROR=`ERROR`})(HK||={}),UK=class{maxInputLength;maxTokens;input;pos=0;line=1;column=1;constructor(e,t=1048576,n=1e5){this.maxInputLength=t,this.maxTokens=n,this.input=e}tokenize(){if(this.input.length>this.maxInputLength)throw new H(`sed: script size limit exceeded (${this.maxInputLength} bytes)`,`string_length`);let e=[];for(;this.pos=this.maxTokens-1)throw new H(`sed: token limit exceeded (${this.maxTokens})`,`array_elements`);e.push(t)}}return e.push(this.makeToken(HK.EOF,``)),e}makeToken(e,t,n){return{type:e,value:t,line:this.line,column:this.column,...n}}peek(e=0){return this.input[this.pos+e]||``}advance(){let e=this.input[this.pos++]||``;return e===` `?(this.line++,this.column=1):this.column++,e}readEscapedString(e){let t=``;for(;this.pos=this.input.length)return null;let e=this.line,t=this.column,n=this.peek();return n===` `?(this.advance(),{type:HK.NEWLINE,value:` `,line:e,column:t}):n===`;`?(this.advance(),{type:HK.SEMICOLON,value:`;`,line:e,column:t}):n===`{`?(this.advance(),{type:HK.LBRACE,value:`{`,line:e,column:t}):n===`}`?(this.advance(),{type:HK.RBRACE,value:`}`,line:e,column:t}):n===`,`?(this.advance(),{type:HK.COMMA,value:`,`,line:e,column:t}):n===`!`?(this.advance(),{type:HK.NEGATION,value:`!`,line:e,column:t}):n===`$`?(this.advance(),{type:HK.DOLLAR,value:`$`,line:e,column:t}):this.isDigit(n)?this.readNumber():n===`+`&&this.isDigit(this.input[this.pos+1]||``)?this.readRelativeOffset():n===`/`?this.readPattern():n===`:`?this.readLabelDef():this.readCommand()}readNumber(){let e=this.line,t=this.column,n=``;for(;this.isDigit(this.peek());)n+=this.advance();if(this.peek()===`~`){this.advance();let r=``;for(;this.isDigit(this.peek());)r+=this.advance();let i=parseInt(n,10),a=parseInt(r,10)||0;return{type:HK.STEP,value:`${i}~${a}`,first:i,step:a,line:e,column:t}}return{type:HK.NUMBER,value:parseInt(n,10),line:e,column:t}}readRelativeOffset(){let e=this.line,t=this.column;this.advance();let n=``;for(;this.isDigit(this.peek());)n+=this.advance();let r=parseInt(n,10)||0;return{type:HK.RELATIVE_OFFSET,value:`+${r}`,offset:r,line:e,column:t}}readPattern(){let e=this.line,t=this.column;this.advance();let n=``,r=!1;for(;this.pos=`0`&&e<=`9`}}});function cSe(e,t=!1,n){if(n){if(e.length>n.maxArrayElements)throw new H(`sed: script count limit exceeded (${n.maxArrayElements})`,`array_elements`);let t=Math.max(0,e.length-1);for(let r of e)if(t+=V(r),t>n.maxStringLength)throw new H(`sed: script size limit exceeded (${n.maxStringLength} bytes)`,`string_length`)}let r=!1,i=!1,a=[];for(let t=0;t0&&a[a.length-1].endsWith(`\\`)){let e=a[a.length-1];a[a.length-1]=`${e} ${n}`}else a.push(n)}let o=a.join(` `),s=new KK([o],t||i,n).parse();if(!s.error&&s.commands.length>0){let e=lSe(s.commands);if(e)return{commands:[],error:e,silentMode:r,extendedRegexMode:i}}return{...s,silentMode:r,extendedRegexMode:i}}function lSe(e){let t=new Set;WK(e,t);let n=GK(e,t);if(n)return`undefined label '${n}'`}function WK(e,t){for(let n of e)n.type===`label`?t.add(n.name):n.type===`group`&&WK(n.commands,t)}function GK(e,t){for(let n of e){if((n.type===`branch`||n.type===`branchOnSubst`||n.type===`branchOnNoSubst`)&&n.label&&!t.has(n.label))return n.label;if(n.type===`group`){let e=GK(n.commands,t);if(e)return e}}}var KK,uSe=B(()=>{U(),ZB(),sSe(),KK=class{scripts;limits;tokens=[];pos=0;extendedRegex=!1;constructor(e,t=!1,n){this.scripts=e,this.limits=n,this.extendedRegex=t}parse(){let e=[];for(let t of this.scripts){let n=new UK(t,this.limits?.maxStringLength,this.limits?.maxArrayElements);for(this.tokens=n.tokenize(),this.pos=0;!this.isAtEnd();){if(this.check(HK.NEWLINE)||this.check(HK.SEMICOLON)){this.advance();continue}let t=this.pos,n=this.parseCommand();if(n.error)return{commands:[],error:n.error};if(n.command&&e.push(n.command),this.pos===t&&!this.isAtEnd())return{commands:[],error:`unknown command: '${this.peek()?.value??this.peek()?.type}'`}}}return{commands:e}}parseCommand(){let e=this.parseAddressRange();if(e?.error)return{command:null,error:e.error};let t=e?.address;for(this.check(HK.NEGATION)&&(this.advance(),t&&(t.negated=!0));this.check(HK.NEWLINE)||this.check(HK.SEMICOLON);)this.advance();if(this.isAtEnd())return t&&(t.start!==void 0||t.end!==void 0)?{command:null,error:`command expected`}:{command:null};let n=this.peek();switch(n.type){case HK.COMMAND:return this.parseSimpleCommand(n,t);case HK.SUBSTITUTE:return this.parseSubstituteFromToken(n,t);case HK.TRANSLITERATE:return this.parseTransliterateFromToken(n,t);case HK.LABEL_DEF:return this.advance(),{command:{type:`label`,name:n.label||``}};case HK.BRANCH:return this.advance(),{command:{type:`branch`,address:t,label:n.label}};case HK.BRANCH_ON_SUBST:return this.advance(),{command:{type:`branchOnSubst`,address:t,label:n.label}};case HK.BRANCH_ON_NO_SUBST:return this.advance(),{command:{type:`branchOnNoSubst`,address:t,label:n.label}};case HK.TEXT_CMD:return this.advance(),this.parseTextCommand(n,t);case HK.FILE_READ:return this.advance(),{command:{type:`readFile`,address:t,filename:n.filename||``}};case HK.FILE_READ_LINE:return this.advance(),{command:{type:`readFileLine`,address:t,filename:n.filename||``}};case HK.FILE_WRITE:return this.advance(),{command:{type:`writeFile`,address:t,filename:n.filename||``}};case HK.FILE_WRITE_LINE:return this.advance(),{command:{type:`writeFirstLine`,address:t,filename:n.filename||``}};case HK.EXECUTE:return this.advance(),{command:{type:`execute`,address:t,command:n.command}};case HK.VERSION:return this.advance(),{command:{type:`version`,address:t,minVersion:n.label}};case HK.LBRACE:return this.parseGroup(t);case HK.RBRACE:return{command:null};case HK.ERROR:return{command:null,error:`invalid command: ${n.value}`};default:return t&&(t.start!==void 0||t.end!==void 0)?{command:null,error:`command expected`}:{command:null}}}parseSimpleCommand(e,t){this.advance();let n=e.value;switch(n){case`p`:return{command:{type:`print`,address:t}};case`P`:return{command:{type:`printFirstLine`,address:t}};case`d`:return{command:{type:`delete`,address:t}};case`D`:return{command:{type:`deleteFirstLine`,address:t}};case`h`:return{command:{type:`hold`,address:t}};case`H`:return{command:{type:`holdAppend`,address:t}};case`g`:return{command:{type:`get`,address:t}};case`G`:return{command:{type:`getAppend`,address:t}};case`x`:return{command:{type:`exchange`,address:t}};case`n`:return{command:{type:`next`,address:t}};case`N`:return{command:{type:`nextAppend`,address:t}};case`q`:return{command:{type:`quit`,address:t}};case`Q`:return{command:{type:`quitSilent`,address:t}};case`z`:return{command:{type:`zap`,address:t}};case`=`:return{command:{type:`lineNumber`,address:t}};case`l`:return{command:{type:`list`,address:t}};case`F`:return{command:{type:`printFilename`,address:t}};default:return{command:null,error:`unknown command: ${n}`}}}parseSubstituteFromToken(e,t){this.advance();let n=e.flags||``,r,i=n.match(/(\d+)/);return i&&(r=parseInt(i[1],10)),{command:{type:`substitute`,address:t,pattern:e.pattern||``,replacement:e.replacement||``,global:n.includes(`g`),ignoreCase:n.includes(`i`)||n.includes(`I`),printOnMatch:n.includes(`p`),nthOccurrence:r,extendedRegex:this.extendedRegex}}}parseTransliterateFromToken(e,t){this.advance();let n=e.source||``,r=e.dest||``;return n.length===r.length?{command:{type:`transliterate`,address:t,source:n,dest:r}}:{command:null,error:`transliteration sets must have same length`}}parseTextCommand(e,t){let n=e.value,r=e.text||``;switch(n){case`a`:return{command:{type:`append`,address:t,text:r}};case`i`:return{command:{type:`insert`,address:t,text:r}};case`c`:return{command:{type:`change`,address:t,text:r}};default:return{command:null,error:`unknown text command: ${n}`}}}parseGroup(e){this.advance();let t=[];for(;!this.isAtEnd()&&!this.check(HK.RBRACE);){if(this.check(HK.NEWLINE)||this.check(HK.SEMICOLON)){this.advance();continue}let e=this.pos,n=this.parseCommand();if(n.error)return{command:null,error:n.error};if(n.command&&t.push(n.command),this.pos===e&&!this.isAtEnd())return{command:null,error:`unknown command: '${this.peek()?.value??this.peek()?.type}'`}}return this.check(HK.RBRACE)?(this.advance(),{command:{type:`group`,address:e,commands:t}}):{command:null,error:`unmatched brace in grouped commands`}}parseAddressRange(){if(this.check(HK.COMMA))return{error:`expected context address`};let e=this.parseAddress();if(e===void 0)return;let t;if(this.check(HK.RELATIVE_OFFSET))t={offset:this.advance().offset||0};else if(this.check(HK.COMMA)&&(this.advance(),t=this.parseAddress(),t===void 0))return{error:`expected context address`};return{address:{start:e,end:t}}}parseAddress(){let e=this.peek();switch(e.type){case HK.NUMBER:return this.advance(),e.value;case HK.DOLLAR:return this.advance(),`$`;case HK.PATTERN:return this.advance(),{pattern:e.pattern||e.value};case HK.STEP:return this.advance(),{first:e.first||0,step:e.step||0};case HK.RELATIVE_OFFSET:return this.advance(),{offset:e.offset||0};default:return}}peek(){return this.tokens[this.pos]||{type:HK.EOF,value:``,line:0,column:0}}advance(){return this.isAtEnd()||this.pos++,this.tokens[this.pos-1]}check(e){return this.peek().type===e}isAtEnd(){return this.peek().type===HK.EOF}}}),qK={};Tz(qK,{flagsForFuzzing:()=>ZK,sedCommand:()=>XK});async function JK(e,t,n,r={}){let{limits:i,filename:a,fs:o,cwd:s,coverage:c,requireDefenseContext:l}=r;kK(l,`sed`,`processing entry`);let u=(e,t)=>AK(l,`sed`,e,t),d=e.endsWith(` `),f=e.split(` `);f.length>0&&f[f.length-1]===``&&f.pop();let p=f.length,m=``,h,g=!1,_=i?.maxStringLength??0,v=e=>{if(m+=e,_>0&&m.length>_)throw new H(`sed: output size limit exceeded (${_} bytes)`,`string_length`)},y=``,b,x=new Map,S=new Map,C=new Map,w=new Map,T=i?{maxIterations:i.maxSedIterations,maxStringLength:_}:void 0;for(let e=0;e1e4)break;if(r.restartCycle=!1,r.pendingFileReads=[],r.pendingFileWrites=[],BK(t,r,i,T),o&&s){for(let e of r.pendingFileReads){let t=o.resolvePath(s,e.filename);try{if(e.wholeFile){let e=await u(`read command file`,()=>o.readFile(t));r.appendBuffer.push(e.replace(/\n$/,``))}else{if(!S.has(t)){let e=await u(`read command file line cache`,()=>o.readFile(t));S.set(t,e.split(` `)),C.set(t,0)}let e=S.get(t),n=C.get(t);e&&n!==void 0&&n0;for(let e of r.lineNumberOutput)v(`${e} `);let m=[],_=[];for(let e of r.appendBuffer)e.startsWith(`__INSERT__`)?m.push(e.slice(10)):_.push(e);for(let e of m)v(`${e} `);let E=!1;!r.deleted&&!r.quitSilent?n?r.printed&&(v(`${r.patternSpace} `),E=!0):(v(`${r.patternSpace} `),E=!0):r.changedText!==void 0&&(v(`${r.changedText} `),E=!0);for(let e of _)v(`${e} `);if(g=(d||E)&&_.length===0,r.quit||r.quitSilent){if(r.exitCode!==void 0&&(h=r.exitCode),r.errorMessage)return{output:``,exitCode:h||1,errorMessage:r.errorMessage};break}}if(o&&s)for(let[e,t]of w)try{await u(`flush pending file writes`,()=>o.writeFile(e,t))}catch(e){if(e instanceof tB)throw e}return!d&&g&&m.endsWith(` `)&&(m=m.slice(0,-1)),{output:m,exitCode:h}}var YK,XK,ZK,dSe=B(()=>{AB(),yH(),U(),jK(),oB(),cV(),oSe(),uSe(),YK={name:`sed`,summary:`stream editor for filtering and transforming text`,usage:`sed [OPTION]... {script} [input-file]...`,options:[`-n, --quiet, --silent suppress automatic printing of pattern space`,`-e script add the script to commands to be executed`,`-f script-file read script from file`,`-i, --in-place edit files in place`,`-E, -r, --regexp-extended use extended regular expressions`,` --help display this help and exit`],description:`Commands: s/regexp/replacement/[flags] substitute d delete pattern space p print pattern space a\\ text append text after line i\\ text insert text before line c\\ text change (replace) line with text h copy pattern space to hold space H append pattern space to hold space g copy hold space to pattern space G append hold space to pattern space x exchange pattern and hold spaces n read next line into pattern space N append next line to pattern space y/source/dest/ transliterate characters = print line number l list pattern space (escape special chars) b [label] branch to label t [label] branch on substitution T [label] branch if no substitution :label define label q quit Q quit without printing Addresses: N line number $ last line /regexp/ lines matching regexp N,M range from line N to M first~step every step-th line starting at first`},XK={name:`sed`,async execute(e,t){kK(t.requireDefenseContext,`sed`,`execution entry`);let n=(e,n)=>AK(t.requireDefenseContext,`sed`,e,n);if(oV(e))return aV(YK);let r=[],i=[],a=!1,o=!1,s=!1,c=[];for(let t=0;t1){for(let e of n.slice(1))if(e!==`n`&&e!==`e`&&e!==`f`&&e!==`i`&&e!==`E`&&e!==`r`)return sV(`sed`,`-${e}`);n.includes(`n`)&&(a=!0),n.includes(`i`)&&(o=!0),(n.includes(`E`)||n.includes(`r`))&&(s=!0),n.includes(`e`)&&!n.includes(`n`)&&!n.includes(`i`)&&t+1t.fs.readFile(i));for(let t of e.split(` `)){let e=t.trim();e&&!e.startsWith(`#`)&&r.push(e)}}catch(t){if(t instanceof tB)throw t;return{stdout:``,stderr:`sed: couldn't open file ${e}: No such file or directory `,exitCode:1}}}if(r.length===0)return{stdout:``,stderr:`sed: no script specified `,exitCode:1};let{commands:l,error:u,silentMode:d}=cSe(r,s,t.limits);if(u)return{stdout:``,stderr:`sed: ${u} `,exitCode:1};let f=!!(a||d);if(o){if(c.length===0)return{stdout:``,stderr:`sed: -i requires at least one file argument `,exitCode:1};for(let e of c){if(e===`-`)continue;let r=t.fs.resolvePath(t.cwd,e);try{let i=await n(`in-place input read`,()=>t.fs.readFile(r)),a=await n(`in-place processing`,()=>JK(i,l,f,{limits:t.limits,filename:e,fs:t.fs,cwd:t.cwd,coverage:t.coverage,requireDefenseContext:t.requireDefenseContext}));if(a.errorMessage)return{stdout:``,stderr:`${a.errorMessage} `,exitCode:a.exitCode??1};await n(`in-place output write`,()=>t.fs.writeFile(r,a.output))}catch(t){if(t instanceof tB)throw t;return t instanceof H?{stdout:``,stderr:`sed: ${vH(t.message)} `,exitCode:H.EXIT_CODE}:{stdout:``,stderr:`sed: ${e}: No such file or directory `,exitCode:1}}}return{stdout:``,stderr:``,exitCode:0}}let p=``;if(c.length===0){p=yB(t.stdin);try{let e=await n(`stdin processing`,()=>JK(p,l,f,{limits:t.limits,fs:t.fs,cwd:t.cwd,coverage:t.coverage,requireDefenseContext:t.requireDefenseContext}));return{stdout:e.output,stderr:e.errorMessage?`${e.errorMessage} `:``,exitCode:e.exitCode??0}}catch(e){if(e instanceof tB)throw e;if(e instanceof H)return{stdout:``,stderr:`sed: ${vH(e.message)} `,exitCode:H.EXIT_CODE};throw e}}let m=!1;for(let e of c){let r;if(e===`-`)m?r=``:(r=yB(t.stdin),m=!0);else{let i=t.fs.resolvePath(t.cwd,e);try{r=await n(`input file read`,()=>t.fs.readFile(i))}catch(t){if(t instanceof tB)throw t;return t instanceof H?{stdout:``,stderr:`sed: ${vH(t.message)} `,exitCode:H.EXIT_CODE}:{stdout:``,stderr:`sed: ${e}: No such file or directory `,exitCode:1}}}p.length>0&&r.length>0&&!p.endsWith(` `)&&(p+=` `),p+=r}try{let e=await n(`final processing`,()=>JK(p,l,f,{limits:t.limits,filename:c.length===1?c[0]:void 0,fs:t.fs,cwd:t.cwd,coverage:t.coverage,requireDefenseContext:t.requireDefenseContext}));return{stdout:e.output,stderr:e.errorMessage?`${e.errorMessage} `:``,exitCode:e.exitCode??0}}catch(e){if(e instanceof tB)throw e;if(e instanceof H)return{stdout:``,stderr:`sed: ${vH(e.message)} `,exitCode:H.EXIT_CODE};throw e}}},ZK={name:`sed`,flags:[{flag:`-n`,type:`boolean`},{flag:`-i`,type:`boolean`},{flag:`-E`,type:`boolean`},{flag:`-r`,type:`boolean`},{flag:`-e`,type:`value`,valueHint:`string`}],stdinType:`text`,needsArgs:!0}});function QK(e){return Object.assign(Object.create(null),Object.fromEntries(e))}function $K(e,t){return Object.assign(Object.create(null),Object.fromEntries(e),t)}function eq(...e){return Object.assign(Object.create(null),...e)}var tq=B(()=>{});function fSe(e={}){let{fieldSep:t=iq,maxIterations:n=nq,maxRecursionDepth:r=rq,maxOutputSize:i=0,maxArrayElements:a=1e5,fs:o,cwd:s,exec:c,coverage:l,requireDefenseContext:u}=e;return{FS:` `,OFS:` `,ORS:` `,OFMT:`%.6g`,NR:0,NF:0,FNR:0,FILENAME:``,RSTART:0,RLENGTH:-1,SUBSEP:``,fields:[],line:``,vars:Object.create(null),arrays:Object.create(null),arrayAliases:new Map,ARGC:0,ARGV:Object.create(null),ENVIRON:Object.create(null),functions:new Map,getlineCommandStreams:new Map,getlineFileStreams:new Map,fieldSep:t,maxIterations:n,maxRecursionDepth:r,maxOutputSize:i,maxArrayElements:a,arrayElementCount:0,recordsProcessed:0,currentRecursionDepth:0,exitCode:0,shouldExit:!1,shouldNext:!1,shouldNextFile:!1,loopBreak:!1,loopContinue:!1,hasReturn:!1,inEndBlock:!1,output:``,openedFiles:new Set,fs:o,cwd:s,exec:c,coverage:l,requireDefenseContext:u}}var nq,rq,iq,pSe=B(()=>{bG(),nq=1e4,rq=100,iq=new yG(/\s+/)});function mSe(e,t,n){switch(n){case`+`:return e+t;case`-`:return e-t;case`*`:return e*t;case`/`:return t===0?0:e/t;case`%`:return t===0?0:e%t;case`^`:case`**`:return e**t;default:return 0}}var hSe=B(()=>{});function aq(e){if(typeof e==`number`)return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function oq(e){return typeof e==`string`?e:String(e)}function sq(e){return new sH(e,`awk string`,()=>new H(`string size limit exceeded (${e} bytes)`,`string_length`))}function cq(e){return e.maxOutputSize>0?e.maxOutputSize:vq}function lq(e,t,n,r,i){let a=sq(i),o=0,s=0,c=0;for(let i of t.matchAll(e)){let t=i.index??0;s++,a.append(e.slice(o,t)),n(s)?(a.append(r(i)),c++):a.append(i[0]),o=t+i[0].length}return a.append(e.slice(o)),{value:a.build(),replacements:c}}async function uq(e,t){if(e.type===`regex`)return e.pattern;let n=oq(await t.evalExpr(e));return n.startsWith(`/`)&&n.endsWith(`/`)&&(n=n.slice(1,-1)),n}async function dq(e,t){return e?e.type===`variable`?e.name:e.type===`field`?`$${Math.floor(aq(await t.evalExpr(e.index)))}`:`$0`:`$0`}function fq(e,t){if(e===`$0`)return t.line;if(e.startsWith(`$`)){let n=parseInt(e.slice(1),10)-1;return t.fields[n]||``}return oq(t.vars[e]??``)}function pq(e,t,n){if(e===`$0`)n.line=t,n.fields=n.FS===` `?t.trim().split(/\s+/).filter(Boolean):n.fieldSep.split(t),n.NF=n.fields.length;else if(e.startsWith(`$`)){let r=parseInt(e.slice(1),10)-1;for(;n.fields.length<=r;)n.fields.push(``);n.fields[r]=t,n.NF=n.fields.length,n.line=n.fields.join(n.OFS)}else n.vars[e]=t}async function gSe(e,t,n){return e.length===0?t.line.length:oq(await n.evalExpr(e[0])).length}async function _Se(e,t,n){if(e.length<2)return``;let r=oq(await n.evalExpr(e[0])),i=Math.floor(aq(await n.evalExpr(e[1])))-1;if(e.length>=3){let t=Math.floor(aq(await n.evalExpr(e[2])));return r.substr(Math.max(0,i),t)}return r.substr(Math.max(0,i))}async function vSe(e,t,n){if(e.length<2)return 0;let r=oq(await n.evalExpr(e[0])),i=oq(await n.evalExpr(e[1])),a=r.indexOf(i);return a===-1?0:a+1}async function ySe(e,t,n){if(e.length<2)return 0;let r=oq(await n.evalExpr(e[0])),i=e[1];if(i.type!==`variable`)return 0;let a=i.name,o=t.FS;if(e.length>=3){let t=e[2];if(t.type===`regex`)o=hG(t.pattern);else{let e=oq(await n.evalExpr(t));o=e===` `?hG(`\\s+`):e}}else t.FS===` `&&(o=hG(`\\s+`));let s=Object.keys(t.arrays[a]??{}).length,c=t.maxArrayElements-t.arrayElementCount+s,l=typeof o==`string`?r.split(o,c+1):o.split(r,c+1);if(l.length>c)throw new H(`array element limit exceeded (${t.maxArrayElements})`,`array_elements`);t.arrays[a]=Object.create(null);for(let e=0;ee===1,e=>mq(i,e[0],cq(t)),cq(t));return pq(a,e.value,t),e.replacements}catch(e){return rV(e),0}}async function xSe(e,t,n){if(e.length<2)return 0;let r=await uq(e[0],n),i=oq(await n.evalExpr(e[1])),a=await dq(e[2],n),o=fq(a,t);try{let e=lq(o,hG(r,`g`),()=>!0,e=>mq(i,e[0],cq(t)),cq(t));return pq(a,e.value,t),e.replacements}catch(e){return rV(e),0}}function mq(e,t,n){let r=sq(n),i=0;for(;i=4?oq(await n.evalExpr(e[3])):t.line;try{let e=a.toLowerCase()===`g`,n=e?0:parseInt(a,10)||1;return e?lq(o,hG(r,`g`),()=>!0,e=>hq(i,e[0],e.slice(1),cq(t)),cq(t)).value:lq(o,hG(r,`g`),e=>e===n,e=>hq(i,e[0],e.slice(1),cq(t)),cq(t)).value}catch(e){return rV(e),o}}function hq(e,t,n,r){let i=sq(r),a=0;for(;a=`1`&&r<=`9`){let e=parseInt(r,10)-1;i.append(n[e]||``),a+=2}else r===`n`?(i.append(` `),a+=2):r===`t`?(i.append(` `),a+=2):(i.append(r),a+=2)}else e[a]===`&`?(i.append(t),a++):(i.append(e[a]),a++);return i.build()}async function wSe(e,t,n){return e.length===0?``:oq(await n.evalExpr(e[0])).toLowerCase()}async function TSe(e,t,n){return e.length===0?``:oq(await n.evalExpr(e[0])).toUpperCase()}async function ESe(e,t,n){if(e.length===0)return``;let r=oq(await n.evalExpr(e[0])),i=[];for(let t=1;t0?aq(await n.evalExpr(e[0])):0,i=e.length>1?aq(await n.evalExpr(e[1])):0;return Math.atan2(r,i)}async function MSe(e,t,n){return e.length===0?0:Math.log(aq(await n.evalExpr(e[0])))}async function NSe(e,t,n){return e.length===0?1:Math.exp(aq(await n.evalExpr(e[0])))}function PSe(e,t,n){return t.random?t.random():Math.random()}async function FSe(e,t,n){let r=e.length>0?aq(await n.evalExpr(e[0])):Date.now();return t.vars._srand_seed=r,r}function ISe(e,t){return()=>{throw Error(`${e}() is not supported - ${t}`)}}function gq(e){return()=>{throw Error(`function '${e}()' is not implemented`)}}function _q(e,t,n=vq){let r=0,i=``,a=0,o=0,s=Math.min(yq,n),c=e=>{let t=V(e);if(t>n-a)throw new H(`formatted string size limit exceeded (${n} bytes)`,`string_length`);i+=e,a+=t};for(;od&&e[n]===`$`?(u=parseInt(e.substring(d,n),10)-1,n++):n=d;let f=()=>{if(ns)throw new H(`printf width limit exceeded (${s} bytes)`,`string_length`);if(e[n]===`.`){if(n++,e[n]===`*`){let e=t[r++],i=e===void 0?0:Math.floor(Number(e));if(!Number.isFinite(i)||!Number.isSafeInteger(i))throw new H(`printf precision limit exceeded (${s} bytes)`,`string_length`);l=i<0?``:String(i),n++}else for(;ns)throw new H(`printf precision limit exceeded (${s} bytes)`,`string_length`)}f();let p=e[n],m=t[u===void 0?r:u];switch(p){case`s`:{let e=m===void 0?``:String(m);if(l&&(e=e.substring(0,parseInt(l,10))),a){let t=parseInt(a,10);e=i.includes(`-`)?e.padEnd(t):e.padStart(t)}c(e),u===void 0&&r++;break}case`d`:case`i`:{let e=m===void 0?0:Math.floor(Number(m));Number.isNaN(e)&&(e=0);let t=e<0,n=Math.abs(e).toString();if(l){let e=parseInt(l,10);n=n.padStart(e,`0`)}let o=``;t?o=`-`:i.includes(`+`)?o=`+`:i.includes(` `)&&(o=` `);let s=o+n;if(a){let e=parseInt(a,10);s=i.includes(`-`)?s.padEnd(e):i.includes(`0`)&&!l?o+n.padStart(e-o.length,`0`):s.padStart(e)}c(s),u===void 0&&r++;break}case`f`:{let e=m===void 0?0:Number(m);Number.isNaN(e)&&(e=0);let t=l?parseInt(l,10):6;if(t>100)throw new H(`printf floating-point precision limit exceeded (100 digits)`,`string_length`);let n=e.toFixed(t);if(a){let e=parseInt(a,10);n=i.includes(`-`)?n.padEnd(e):n.padStart(e)}c(n),u===void 0&&r++;break}case`e`:case`E`:{let e=m===void 0?0:Number(m);Number.isNaN(e)&&(e=0);let t=l?parseInt(l,10):6;if(t>100)throw new H(`printf floating-point precision limit exceeded (100 digits)`,`string_length`);let n=e.toExponential(t);if(p===`E`&&(n=n.toUpperCase()),a){let e=parseInt(a,10);n=i.includes(`-`)?n.padEnd(e):n.padStart(e)}c(n),u===void 0&&r++;break}case`g`:case`G`:{let e=m===void 0?0:Number(m);Number.isNaN(e)&&(e=0);let t=l?parseInt(l,10):6;if(t>100)throw new H(`printf floating-point precision limit exceeded (100 digits)`,`string_length`);let n=e===0?0:Math.floor(Math.log10(Math.abs(e))),o;if(e===0?o=`0`:n<-4||n>=t?(o=e.toExponential(t-1),p===`G`&&(o=o.toUpperCase())):o=e.toPrecision(t),o.includes(`.`)&&(o=o.replace(/\.?0+$/,``).replace(/\.?0+e/,`e`)),o.includes(`e`)&&(o=o.replace(/\.?0+e/,`e`)),a){let e=parseInt(a,10);o=i.includes(`-`)?o.padEnd(e):o.padStart(e)}c(o),u===void 0&&r++;break}case`x`:case`X`:{let e=m===void 0?0:Math.floor(Number(m));Number.isNaN(e)&&(e=0);let t=Math.abs(e).toString(16);if(p===`X`&&(t=t.toUpperCase()),l){let e=parseInt(l,10);t=t.padStart(e,`0`)}let n=e<0?`-`:``,o=n+t;if(a){let e=parseInt(a,10);o=i.includes(`-`)?o.padEnd(e):i.includes(`0`)&&!l?n+t.padStart(e-n.length,`0`):o.padStart(e)}c(o),u===void 0&&r++;break}case`o`:{let e=m===void 0?0:Math.floor(Number(m));Number.isNaN(e)&&(e=0);let t=Math.abs(e).toString(8);if(l){let e=parseInt(l,10);t=t.padStart(e,`0`)}let n=e<0?`-`:``,o=n+t;if(a){let e=parseInt(a,10);o=i.includes(`-`)?o.padEnd(e):i.includes(`0`)&&!l?n+t.padStart(e-n.length,`0`):o.padStart(e)}c(o),u===void 0&&r++;break}case`c`:c(typeof m==`number`?String.fromCharCode(m):String(m??``).charAt(0)||``),u===void 0&&r++;break;case`%`:c(`%`);break;default:c(e.substring(o,n+1))}o=n+1}else if(e[o]===`\\`&&o+1{cH(),AB(),iV(),U(),bG(),vq=10485760,yq=1e4,bq=new Map([[`length`,gSe],[`substr`,_Se],[`index`,vSe],[`split`,ySe],[`sub`,bSe],[`gsub`,xSe],[`match`,SSe],[`gensub`,CSe],[`tolower`,wSe],[`toupper`,TSe],[`sprintf`,ESe],[`int`,DSe],[`sqrt`,OSe],[`sin`,kSe],[`cos`,ASe],[`atan2`,jSe],[`log`,MSe],[`exp`,NSe],[`rand`,PSe],[`srand`,FSe],[`system`,ISe(`system`,`shell execution not allowed in sandboxed environment`)],[`close`,()=>0],[`fflush`,()=>0],[`systime`,gq(`systime`)],[`mktime`,gq(`mktime`)],[`strftime`,gq(`strftime`)]])});function Sq(e){return typeof e==`number`?e!==0:e!==``&&e!==`0`}function Cq(e){if(typeof e==`number`)return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function wq(e){return typeof e==`string`?e:String(e)}function Tq(e){if(typeof e==`number`)return!0;let t=String(e).trim();return t!==``&&!Number.isNaN(Number(t))}function Eq(e,t){try{return hG(e).test(t)}catch{return!1}}var Dq=B(()=>{bG()});function Oq(e,t){return t===``?[]:e.FS===` `?t.trim().split(/\s+/).filter(Boolean):e.fieldSep.split(t)}function kq(e,t){return t===0?e.line:t<0||t>e.fields.length?``:e.fields[t-1]??``}function Aq(e,t,n){if(t===0)e.line=wq(n),e.fields=Oq(e,e.line),e.NF=e.fields.length;else if(t>0){for(;e.fields.length{bG(),Dq()});function Nq(e,t){switch(t){case`FS`:return e.FS;case`OFS`:return e.OFS;case`ORS`:return e.ORS;case`OFMT`:return e.OFMT;case`NR`:return e.NR;case`NF`:return e.NF;case`FNR`:return e.FNR;case`FILENAME`:return e.FILENAME;case`RSTART`:return e.RSTART;case`RLENGTH`:return e.RLENGTH;case`SUBSEP`:return e.SUBSEP;case`ARGC`:return e.ARGC}return e.vars[t]??``}function Pq(e,t,n){switch(t){case`FS`:LSe(e,wq(n));return;case`OFS`:e.OFS=wq(n);return;case`ORS`:e.ORS=wq(n);return;case`OFMT`:e.OFMT=wq(n);return;case`NR`:e.NR=Math.floor(Cq(n));return;case`NF`:{let t=Math.floor(Cq(n));if(te.NF){for(;e.fields.length=e.maxArrayElements)throw new H(`array element limit exceeded (${e.maxArrayElements})`,`array_elements`);e.arrayElementCount++}e.arrays[i][n]=r}function RSe(e,t,n){if(t===`ARGV`)return e.ARGV[n]!==void 0;if(t===`ENVIRON`)return e.ENVIRON[n]!==void 0;let r=Fq(e,t);return e.arrays[r]?.[n]!==void 0}function zSe(e,t,n){let r=Fq(e,t);e.arrays[r]&&(n in e.arrays[r]&&e.arrayElementCount--,delete e.arrays[r][n])}function BSe(e,t){let n=Fq(e,t);e.arrayElementCount-=Object.keys(e.arrays[n]??{}).length,delete e.arrays[n]}var Rq=B(()=>{U(),Mq(),Dq()});function VSe(e){Uq=e}function zq(e,t){kK(e.requireDefenseContext,`awk`,t)}function Bq(e,t,n){return AK(e.requireDefenseContext,`awk`,t,n)}async function Vq(e,t){switch(zq(e,`expression evaluation`),e.coverage?.hit(`awk:expr:${t.type}`),t.type){case`number`:return t.value;case`string`:return t.value;case`regex`:return+!!Eq(t.pattern,e.line);case`field`:return HSe(e,t);case`variable`:return Nq(e,t.name);case`array_access`:return USe(e,t);case`binary`:return WSe(e,t);case`unary`:return qSe(e,t);case`ternary`:return Sq(await Bq(e,`ternary condition evaluation`,()=>Vq(e,t.condition)))?await Bq(e,`ternary consequent evaluation`,()=>Vq(e,t.consequent)):await Bq(e,`ternary alternate evaluation`,()=>Vq(e,t.alternate));case`call`:return JSe(e,t.name,t.args);case`assignment`:return XSe(e,t);case`pre_increment`:return ZSe(e,t.operand);case`pre_decrement`:return QSe(e,t.operand);case`post_increment`:return $Se(e,t.operand);case`post_decrement`:return eCe(e,t.operand);case`in`:return tCe(e,t.key,t.array);case`getline`:return nCe(e,t.variable,t.file,t.command);case`tuple`:return aCe(e,t.elements);default:return``}}async function HSe(e,t){return zq(e,`field reference evaluation`),kq(e,Math.floor(Cq(await Bq(e,`field index evaluation`,()=>Vq(e,t.index)))))}async function USe(e,t){zq(e,`array access evaluation`);let n=wq(await Bq(e,`array key evaluation`,()=>Vq(e,t.key)));return Iq(e,t.array,n)}async function WSe(e,t){zq(e,`binary expression evaluation`);let n=t.operator;if(n===`||`)return Sq(await Bq(e,`logical-or left evaluation`,()=>Vq(e,t.left)))||Sq(await Bq(e,`logical-or right evaluation`,()=>Vq(e,t.right)))?1:0;if(n===`&&`)return Sq(await Bq(e,`logical-and left evaluation`,()=>Vq(e,t.left)))&&Sq(await Bq(e,`logical-and right evaluation`,()=>Vq(e,t.right)))?1:0;if(n===`~`){let n=await Bq(e,`regex left evaluation`,()=>Vq(e,t.left));t.right.type===`regex`&&e.coverage?.hit(`awk:expr:regex`);let r=t.right.type===`regex`?t.right.pattern:wq(await Bq(e,`regex right evaluation`,()=>Vq(e,t.right)));try{return+!!hG(r).test(wq(n))}catch{return 0}}if(n===`!~`){let n=await Bq(e,`negated-regex left evaluation`,()=>Vq(e,t.left));t.right.type===`regex`&&e.coverage?.hit(`awk:expr:regex`);let r=t.right.type===`regex`?t.right.pattern:wq(await Bq(e,`negated-regex right evaluation`,()=>Vq(e,t.right)));try{return+!hG(r).test(wq(n))}catch{return 1}}let r=await Bq(e,`binary left evaluation`,()=>Vq(e,t.left)),i=await Bq(e,`binary right evaluation`,()=>Vq(e,t.right));if(n===` `){let t=wq(r)+wq(i);if(e.maxOutputSize>0&&t.length>e.maxOutputSize)throw new H(`awk: string concatenation size limit exceeded (${e.maxOutputSize} bytes)`,`string_length`,e.output);return t}return GSe(n)?KSe(r,i,n):mSe(Cq(r),Cq(i),n)}function GSe(e){return[`<`,`<=`,`>`,`>=`,`==`,`!=`].includes(e)}function KSe(e,t,n){let r=Tq(e),i=Tq(t);if(r&&i){let r=Cq(e),i=Cq(t);switch(n){case`<`:return+(r`:return+(r>i);case`>=`:return+(r>=i);case`==`:return+(r===i);case`!=`:return r===i?0:1}}let a=wq(e),o=wq(t);switch(n){case`<`:return+(a`:return+(a>o);case`>=`:return+(a>=o);case`==`:return+(a===o);case`!=`:return a===o?0:1}return 0}async function qSe(e,t){zq(e,`unary expression evaluation`);let n=await Bq(e,`unary operand evaluation`,()=>Vq(e,t.operand));switch(t.operator){case`!`:return+!Sq(n);case`-`:return-Cq(n);case`+`:return+Cq(n);default:return n}}async function JSe(e,t,n){zq(e,`function call evaluation`);let r=bq.get(t);if(r)return r(n,e,{evalExpr:t=>Vq(e,t)});let i=e.functions.get(t);return i?YSe(e,i,n):``}async function YSe(e,t,n){if(zq(e,`user function call`),e.currentRecursionDepth++,e.currentRecursionDepth>e.maxRecursionDepth)throw e.currentRecursionDepth--,new H(`awk: recursion depth exceeded maximum (${e.maxRecursionDepth})`,`recursion`,e.output);let r=Object.create(null);for(let n of t.params)r[n]=e.vars[n];let i=[];for(let r=0;rVq(e,t));e.vars[a]=o}else e.vars[a]=``}e.hasReturn=!1,e.returnValue=void 0;let a=Uq;a&&await Bq(e,`user function body execution`,()=>a(e,t.body.statements));let o=e.returnValue??``;for(let n of t.params)r[n]===void 0?delete e.vars[n]:e.vars[n]=r[n];for(let t of i)e.arrayAliases.delete(t);return e.hasReturn=!1,e.returnValue=void 0,e.currentRecursionDepth--,o}async function XSe(e,t){zq(e,`assignment evaluation`);let n=await Bq(e,`assignment value evaluation`,()=>Vq(e,t.value)),r=t.target,i=t.operator,a;if(i===`=`)a=n;else{let t;if(r.type===`field`)t=kq(e,Math.floor(Cq(await Bq(e,`assignment field index`,()=>Vq(e,r.index)))));else if(r.type===`variable`)t=Nq(e,r.name);else{let n=wq(await Bq(e,`assignment array key`,()=>Vq(e,r.key)));t=Iq(e,r.array,n)}let o=Cq(t),s=Cq(n);switch(i){case`+=`:a=o+s;break;case`-=`:a=o-s;break;case`*=`:a=o*s;break;case`/=`:a=s===0?0:o/s;break;case`%=`:a=s===0?0:o%s;break;case`^=`:a=o**s;break;default:a=n}}if(r.type===`field`)Aq(e,Math.floor(Cq(await Bq(e,`assignment target field index`,()=>Vq(e,r.index)))),a);else if(r.type===`variable`)Pq(e,r.name,a);else{let t=wq(await Bq(e,`assignment target array key`,()=>Vq(e,r.key)));Lq(e,r.array,t,a)}return a}async function Hq(e,t,n,r){zq(e,`inc/dec evaluation`);let i;if(t.type===`field`){let r=Math.floor(Cq(await Bq(e,`inc/dec field index`,()=>Vq(e,t.index))));i=Cq(kq(e,r)),Aq(e,r,i+n)}else if(t.type===`variable`)i=Cq(Nq(e,t.name)),Pq(e,t.name,i+n);else{let r=wq(await Bq(e,`inc/dec array key`,()=>Vq(e,t.key)));i=Cq(Iq(e,t.array,r)),Lq(e,t.array,r,i+n)}return r?i+n:i}async function ZSe(e,t){return Hq(e,t,1,!0)}async function QSe(e,t){return Hq(e,t,-1,!0)}async function $Se(e,t){return Hq(e,t,1,!1)}async function eCe(e,t){return Hq(e,t,-1,!1)}async function tCe(e,t,n){zq(e,`in-expression evaluation`);let r;if(t.type===`tuple`){e.coverage?.hit(`awk:expr:tuple`);let n=[];for(let r of t.elements)n.push(wq(await Bq(e,`tuple key element evaluation`,()=>Vq(e,r))));r=n.join(e.SUBSEP)}else r=wq(await Bq(e,`in-expression key evaluation`,()=>Vq(e,t)));return+!!RSe(e,n,r)}async function nCe(e,t,n,r){if(zq(e,`getline evaluation`),r)return rCe(e,t,r);if(n)return iCe(e,t,n);if(!e.lines||e.lineIndex===void 0)return-1;let i=e.lineIndex+1;if(i>=e.lines.length)return 0;let a=e.lines[i];return t?Pq(e,t,a):jq(e,a),e.NR++,e.lineIndex=i,1}async function rCe(e,t,n){let r=e.exec;if(!r)return-1;zq(e,`getline command source`);let i=wq(await Bq(e,`getline command expression`,()=>Vq(e,n))),a=e.getlineCommandStreams.get(i);if(!a)try{let t=yB((await Bq(e,`getline command exec`,()=>r(i))).stdout).split(` `);t.length>0&&t[t.length-1]===``&&t.pop(),a={lines:t,index:-1},e.getlineCommandStreams.set(i,a)}catch(e){if(e instanceof tB)throw e;return-1}let o=a.index+1;if(o>=a.lines.length)return 0;let s=a.lines[o];return a.index=o,t?Pq(e,t,s):jq(e,s),1}async function iCe(e,t,n){let r=e.fs;if(!r||!e.cwd)return-1;zq(e,`getline file source`);let i=wq(await Bq(e,`getline filename evaluation`,()=>Vq(e,n)));if(i===`/dev/null`)return 0;let a=r.resolvePath(e.cwd,i),o=e.getlineFileStreams.get(a);if(!o)try{let t=(await Bq(e,`getline file read`,()=>r.readFile(a))).split(` `);t.length>0&&t[t.length-1]===``&&t.pop(),o={lines:t,index:-1},e.getlineFileStreams.set(a,o)}catch(e){if(e instanceof tB)throw e;return-1}let s=o.index+1;if(s>=o.lines.length)return 0;let c=o.lines[s];return o.index=s,t?Pq(e,t,c):jq(e,c),1}async function aCe(e,t){if(zq(e,`tuple evaluation`),t.length===0)return``;for(let n=0;nVq(e,t[n]));return Bq(e,`tuple final element`,()=>Vq(e,t[t.length-1]))}var Uq,Wq=B(()=>{AB(),U(),bG(),jK(),oB(),hSe(),xq(),Mq(),Dq(),Rq(),Uq=null});function Gq(e){if(e.maxOutputSize>0&&e.output.length>e.maxOutputSize)throw new H(`awk: output size limit exceeded (${e.maxOutputSize} bytes)`,`string_length`,e.output)}function Kq(e,t){kK(e.requireDefenseContext,`awk`,t)}function qq(e,t,n){return AK(e.requireDefenseContext,`awk`,t,n)}async function Jq(e,t){Kq(e,`block execution`);for(let n of t)if(await qq(e,`statement execution`,()=>Yq(e,n)),oCe(e))break}function oCe(e){return e.shouldExit||e.shouldNext||e.shouldNextFile||e.loopBreak||e.loopContinue||e.hasReturn}async function Yq(e,t){switch(Kq(e,`single statement execution`),e.coverage?.hit(`awk:stmt:${t.type}`),t.type){case`block`:await qq(e,`nested block statement`,()=>Jq(e,t.statements));break;case`expr_stmt`:await qq(e,`expression statement`,()=>Vq(e,t.expression));break;case`print`:await qq(e,`print statement`,()=>sCe(e,t.args,t.output));break;case`printf`:await qq(e,`printf statement`,()=>cCe(e,t.format,t.args,t.output));break;case`if`:await qq(e,`if statement`,()=>lCe(e,t));break;case`while`:await qq(e,`while statement`,()=>uCe(e,t));break;case`do_while`:await qq(e,`do-while statement`,()=>dCe(e,t));break;case`for`:await qq(e,`for statement`,()=>fCe(e,t));break;case`for_in`:await qq(e,`for-in statement`,()=>pCe(e,t));break;case`break`:e.loopBreak=!0;break;case`continue`:e.loopContinue=!0;break;case`next`:e.shouldNext=!0;break;case`nextfile`:e.shouldNextFile=!0;break;case`exit`:e.shouldExit=!0;{let n=t.code;e.exitCode=n?Math.floor(Cq(await qq(e,`exit code expression`,()=>Vq(e,n)))):0}break;case`return`:e.hasReturn=!0;{let n=t.value;e.returnValue=n?await qq(e,`return expression`,()=>Vq(e,n)):``}break;case`delete`:await qq(e,`delete statement`,()=>mCe(e,t.target))}}async function sCe(e,t,n){Kq(e,`print execution`);let r=[];for(let n of t){let t=await qq(e,`print argument evaluation`,()=>Vq(e,n));typeof t==`number`?Number.isInteger(t)&&Math.abs(t)<2**53-1?r.push(String(t)):r.push(_q(e.OFMT,[t],e.maxOutputSize||void 0)):r.push(wq(t))}let i=r.join(e.OFS)+e.ORS;n?await qq(e,`print redirection write`,()=>Xq(e,n.redirect,n.file,i)):(e.output+=i,Gq(e))}async function cCe(e,t,n,r){Kq(e,`printf execution`);let i=wq(await qq(e,`printf format evaluation`,()=>Vq(e,t))),a=[];for(let t of n)a.push(await qq(e,`printf argument evaluation`,()=>Vq(e,t)));let o=_q(i,a,e.maxOutputSize>0?Math.max(0,e.maxOutputSize-V(e.output)):void 0);r?await qq(e,`printf redirection write`,()=>Xq(e,r.redirect,r.file,o)):(e.output+=o,Gq(e))}async function Xq(e,t,n,r){Kq(e,`file write execution`);let i=e.fs;if(!i||!e.cwd){e.output+=r,Gq(e);return}let a=wq(await qq(e,`redirection filename evaluation`,()=>Vq(e,n))),o=i.resolvePath(e.cwd,a);t===`>`?e.openedFiles.has(o)?await qq(e,`redirection append write`,()=>i.appendFile(o,r)):(await qq(e,`redirection overwrite write`,()=>i.writeFile(o,r)),e.openedFiles.add(o)):(e.openedFiles.has(o)||e.openedFiles.add(o),await qq(e,`redirection append mode write`,()=>i.appendFile(o,r)))}async function lCe(e,t){if(Kq(e,`if execution`),Sq(await qq(e,`if condition evaluation`,()=>Vq(e,t.condition))))await qq(e,`if consequent execution`,()=>Yq(e,t.consequent));else if(t.alternate){let n=t.alternate;await qq(e,`if alternate execution`,()=>Yq(e,n))}}async function uCe(e,t){Kq(e,`while execution`);let n=0;for(;Sq(await qq(e,`while condition evaluation`,()=>Vq(e,t.condition)));){if(n++,n>e.maxIterations)throw new H(`awk: while loop exceeded maximum iterations (${e.maxIterations})`,`iterations`,e.output);if(e.loopContinue=!1,await qq(e,`while body execution`,()=>Yq(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function dCe(e,t){Kq(e,`do-while execution`);let n=0;do{if(n++,n>e.maxIterations)throw new H(`awk: do-while loop exceeded maximum iterations (${e.maxIterations})`,`iterations`,e.output);if(e.loopContinue=!1,await qq(e,`do-while body execution`,()=>Yq(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}while(Sq(await qq(e,`do-while condition evaluation`,()=>Vq(e,t.condition))))}async function fCe(e,t){Kq(e,`for execution`);let n=t.init,r=t.condition,i=t.update;n&&await qq(e,`for init evaluation`,()=>Vq(e,n));let a=0;for(;!r||Sq(await qq(e,`for condition evaluation`,()=>Vq(e,r)));){if(a++,a>e.maxIterations)throw new H(`awk: for loop exceeded maximum iterations (${e.maxIterations})`,`iterations`,e.output);if(e.loopContinue=!1,await qq(e,`for body execution`,()=>Yq(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break;i&&await qq(e,`for update evaluation`,()=>Vq(e,i))}}async function pCe(e,t){Kq(e,`for-in execution`);let n=e.arrays[t.array];if(n)for(let r of Object.keys(n)){if(e.vars[t.variable]=r,e.loopContinue=!1,await qq(e,`for-in body execution`,()=>Yq(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function mCe(e,t){if(Kq(e,`delete execution`),t.type===`array_access`){let n=wq(await qq(e,`delete key evaluation`,()=>Vq(e,t.key)));zSe(e,t.array,n)}else t.type===`variable`&&BSe(e,t.name)}var hCe=B(()=>{U(),jK(),ZB(),xq(),Wq(),Dq(),Rq(),VSe(Jq)}),Zq,gCe=B(()=>{U(),jK(),Wq(),Mq(),hCe(),Dq(),Zq=class{ctx;program=null;rangeStates=[];constructor(e){this.ctx=e}assertDefenseContext(e){kK(this.ctx.requireDefenseContext,`awk`,e)}withDefenseContext(e,t){return AK(this.ctx.requireDefenseContext,`awk`,e,t)}execute(e){this.assertDefenseContext(`program initialization`),this.program=e,this.ctx.output=``;for(let t of e.functions)this.ctx.functions.set(t.name,t);this.rangeStates=e.rules.map(()=>!1)}async executeBegin(){if(this.assertDefenseContext(`BEGIN execution entry`),this.program){for(let e of this.program.rules)if(e.pattern?.type===`begin`&&(await this.withDefenseContext(`BEGIN block execution`,()=>Jq(this.ctx,e.action.statements)),this.ctx.shouldExit))break}}async executeLine(e){if(this.assertDefenseContext(`line execution entry`),this.program&&!this.ctx.shouldExit){if(this.ctx.recordsProcessed++,this.ctx.recordsProcessed>this.ctx.maxIterations)throw new H(`record limit exceeded (${this.ctx.maxIterations})`,`iterations`);jq(this.ctx,e),this.ctx.NR++,this.ctx.FNR++,this.ctx.shouldNext=!1;for(let e=0;ethis.matchesRule(t,e))&&await this.withDefenseContext(`rule block execution`,()=>Jq(this.ctx,t.action.statements))}}}async executeEnd(){if(this.assertDefenseContext(`END execution entry`),this.program&&!this.ctx.inEndBlock){this.ctx.inEndBlock=!0,this.ctx.shouldExit=!1;for(let e of this.program.rules)if(e.pattern?.type===`end`&&(await this.withDefenseContext(`END block execution`,()=>Jq(this.ctx,e.action.statements)),this.ctx.shouldExit))break;this.ctx.inEndBlock=!1}}getOutput(){return this.ctx.output}getExitCode(){return this.ctx.exitCode}getContext(){return this.ctx}async matchesRule(e,t){this.assertDefenseContext(`rule matching`);let n=e.pattern;if(!n)return!0;switch(n.type){case`begin`:case`end`:return!1;case`regex_pattern`:return Eq(n.pattern,this.ctx.line);case`expr_pattern`:return Sq(await this.withDefenseContext(`expression pattern evaluation`,()=>Vq(this.ctx,n.expression)));case`range`:{let e=await this.withDefenseContext(`range start pattern`,()=>this.matchPattern(n.start)),r=await this.withDefenseContext(`range end pattern`,()=>this.matchPattern(n.end));return this.rangeStates[t]?(r&&(this.rangeStates[t]=!1),!0):e?(this.rangeStates[t]=!0,r&&(this.rangeStates[t]=!1),!0):!1}default:return!1}}async matchPattern(e){switch(this.assertDefenseContext(`pattern matching`),e.type){case`regex_pattern`:return Eq(e.pattern,this.ctx.line);case`expr_pattern`:return Sq(await this.withDefenseContext(`nested expression pattern`,()=>Vq(this.ctx,e.expression)));default:return!1}}}}),_Ce=B(()=>{pSe(),gCe()});function vCe(e){return e.replace(/\[\[:space:\]\]/g,`[ \\t\\n\\r\\f\\v]`).replace(/\[\[:blank:\]\]/g,`[ \\t]`).replace(/\[\[:alpha:\]\]/g,`[a-zA-Z]`).replace(/\[\[:digit:\]\]/g,`[0-9]`).replace(/\[\[:alnum:\]\]/g,`[a-zA-Z0-9]`).replace(/\[\[:upper:\]\]/g,`[A-Z]`).replace(/\[\[:lower:\]\]/g,`[a-z]`).replace(/\[\[:punct:\]\]/g,`[!"#$%&'()*+,\\-./:;<=>?@\\[\\]\\\\^_\`{|}~]`).replace(/\[\[:xdigit:\]\]/g,`[0-9A-Fa-f]`).replace(/\[\[:graph:\]\]/g,`[!-~]`).replace(/\[\[:print:\]\]/g,`[ -~]`).replace(/\[\[:cntrl:\]\]/g,`[\\x00-\\x1f\\x7f]`)}var J,Qq,$q,eJ,yCe=B(()=>{U(),(function(e){e.NUMBER=`NUMBER`,e.STRING=`STRING`,e.REGEX=`REGEX`,e.IDENT=`IDENT`,e.BEGIN=`BEGIN`,e.END=`END`,e.IF=`IF`,e.ELSE=`ELSE`,e.WHILE=`WHILE`,e.DO=`DO`,e.FOR=`FOR`,e.IN=`IN`,e.BREAK=`BREAK`,e.CONTINUE=`CONTINUE`,e.NEXT=`NEXT`,e.NEXTFILE=`NEXTFILE`,e.EXIT=`EXIT`,e.RETURN=`RETURN`,e.DELETE=`DELETE`,e.FUNCTION=`FUNCTION`,e.PRINT=`PRINT`,e.PRINTF=`PRINTF`,e.GETLINE=`GETLINE`,e.PLUS=`PLUS`,e.MINUS=`MINUS`,e.STAR=`STAR`,e.SLASH=`SLASH`,e.PERCENT=`PERCENT`,e.CARET=`CARET`,e.EQ=`EQ`,e.NE=`NE`,e.LT=`LT`,e.GT=`GT`,e.LE=`LE`,e.GE=`GE`,e.MATCH=`MATCH`,e.NOT_MATCH=`NOT_MATCH`,e.AND=`AND`,e.OR=`OR`,e.NOT=`NOT`,e.ASSIGN=`ASSIGN`,e.PLUS_ASSIGN=`PLUS_ASSIGN`,e.MINUS_ASSIGN=`MINUS_ASSIGN`,e.STAR_ASSIGN=`STAR_ASSIGN`,e.SLASH_ASSIGN=`SLASH_ASSIGN`,e.PERCENT_ASSIGN=`PERCENT_ASSIGN`,e.CARET_ASSIGN=`CARET_ASSIGN`,e.INCREMENT=`INCREMENT`,e.DECREMENT=`DECREMENT`,e.QUESTION=`QUESTION`,e.COLON=`COLON`,e.COMMA=`COMMA`,e.SEMICOLON=`SEMICOLON`,e.NEWLINE=`NEWLINE`,e.LPAREN=`LPAREN`,e.RPAREN=`RPAREN`,e.LBRACE=`LBRACE`,e.RBRACE=`RBRACE`,e.LBRACKET=`LBRACKET`,e.RBRACKET=`RBRACKET`,e.DOLLAR=`DOLLAR`,e.APPEND=`APPEND`,e.PIPE=`PIPE`,e.EOF=`EOF`})(J||={}),Qq=new Map([[`BEGIN`,J.BEGIN],[`END`,J.END],[`if`,J.IF],[`else`,J.ELSE],[`while`,J.WHILE],[`do`,J.DO],[`for`,J.FOR],[`in`,J.IN],[`break`,J.BREAK],[`continue`,J.CONTINUE],[`next`,J.NEXT],[`nextfile`,J.NEXTFILE],[`exit`,J.EXIT],[`return`,J.RETURN],[`delete`,J.DELETE],[`function`,J.FUNCTION],[`print`,J.PRINT],[`printf`,J.PRINTF],[`getline`,J.GETLINE]]),$q=new Set([J.COMMA,J.LBRACE,J.AND,J.OR,J.QUESTION,J.COLON,J.DO,J.ELSE,J.IF,J.WHILE]),eJ=class{maxTokens;input;pos=0;line=1;column=1;lastTokenType=null;constructor(e,t=1e5){this.maxTokens=t,this.input=e}tokenize(){let e=[];for(;this.pos=this.maxTokens)throw new H(`awk: token limit exceeded (${this.maxTokens})`,`array_elements`);e.push(t),this.lastTokenType=t.type}}if(e.length>=this.maxTokens)throw new H(`awk: token limit exceeded (${this.maxTokens})`,`array_elements`);return e.push(this.makeToken(J.EOF,``)),e}makeToken(e,t){return{type:e,value:t,line:this.line,column:this.column}}peek(e=0){return this.input[this.pos+e]||``}advance(){let e=this.input[this.pos++]||``;return e===` `?(this.line++,this.column=1):this.column++,e}skipWhitespace(){for(;this.pos=this.input.length)return null;let e=this.line,t=this.column,n=this.peek();return n===` `?(this.advance(),{type:J.NEWLINE,value:` `,line:e,column:t}):n===`"`?this.readString():n===`/`&&this.canBeRegex()?this.readRegex():this.isDigit(n)||n===`.`&&this.isDigit(this.peek(1))?this.readNumber():this.isAlpha(n)||n===`_`?this.readIdentifier():this.readOperator()}canBeRegex(){return new Set([null,J.NEWLINE,J.SEMICOLON,J.LBRACE,J.RBRACE,J.LPAREN,J.LBRACKET,J.COMMA,J.ASSIGN,J.PLUS_ASSIGN,J.MINUS_ASSIGN,J.STAR_ASSIGN,J.SLASH_ASSIGN,J.PERCENT_ASSIGN,J.CARET_ASSIGN,J.AND,J.OR,J.NOT,J.MATCH,J.NOT_MATCH,J.QUESTION,J.COLON,J.LT,J.GT,J.LE,J.GE,J.EQ,J.NE,J.PLUS,J.MINUS,J.STAR,J.PERCENT,J.CARET,J.PRINT,J.PRINTF,J.IF,J.WHILE,J.DO,J.FOR,J.RETURN]).has(this.lastTokenType)}readString(){let e=this.line,t=this.column;this.advance();let n=``;for(;this.pos0?n+=String.fromCharCode(parseInt(e,16)):n+=`x`;break}default:if(/[0-7]/.test(e)){let t=e;for(;t.length<3&&/[0-7]/.test(this.peek());)t+=this.advance();n+=String.fromCharCode(parseInt(t,8))}else n+=e}}else n+=this.advance();return this.peek()===`"`&&this.advance(),{type:J.STRING,value:n,line:e,column:t}}readRegex(){let e=this.line,t=this.column;this.advance();let n=``;for(;this.pos`:return r===`=`?(this.advance(),{type:J.GE,value:`>=`,line:e,column:t}):r===`>`?(this.advance(),{type:J.APPEND,value:`>>`,line:e,column:t}):{type:J.GT,value:`>`,line:e,column:t};case`&`:return r===`&`?(this.advance(),{type:J.AND,value:`&&`,line:e,column:t}):{type:J.IDENT,value:`&`,line:e,column:t};case`|`:return r===`|`?(this.advance(),{type:J.OR,value:`||`,line:e,column:t}):{type:J.PIPE,value:`|`,line:e,column:t};case`~`:return{type:J.MATCH,value:`~`,line:e,column:t};case`?`:return{type:J.QUESTION,value:`?`,line:e,column:t};case`:`:return{type:J.COLON,value:`:`,line:e,column:t};case`,`:return{type:J.COMMA,value:`,`,line:e,column:t};case`;`:return{type:J.SEMICOLON,value:`;`,line:e,column:t};case`(`:return{type:J.LPAREN,value:`(`,line:e,column:t};case`)`:return{type:J.RPAREN,value:`)`,line:e,column:t};case`{`:return{type:J.LBRACE,value:`{`,line:e,column:t};case`}`:return{type:J.RBRACE,value:`}`,line:e,column:t};case`[`:return{type:J.LBRACKET,value:`[`,line:e,column:t};case`]`:return{type:J.RBRACKET,value:`]`,line:e,column:t};case`$`:return{type:J.DOLLAR,value:`$`,line:e,column:t};default:return{type:J.IDENT,value:n,line:e,column:t}}}isDigit(e){return e>=`0`&&e<=`9`}isAlpha(e){return e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`}isAlphaNumeric(e){return this.isDigit(e)||this.isAlpha(e)}}});function bCe(e){e.expect(sJ.PRINT);let t=[];if(e.check(sJ.NEWLINE)||e.check(sJ.SEMICOLON)||e.check(sJ.RBRACE)||e.check(sJ.PIPE)||e.check(sJ.GT)||e.check(sJ.APPEND))t.push({type:`field`,index:{type:`number`,value:0}});else for(e.assertArrayLength(t.length),t.push(tJ(e));e.check(sJ.COMMA);)e.advance(),e.assertArrayLength(t.length),t.push(tJ(e));let n;return e.check(sJ.GT)?(e.advance(),n={redirect:`>`,file:e.parsePrimary()}):e.check(sJ.APPEND)&&(e.advance(),n={redirect:`>>`,file:e.parsePrimary()}),{type:`print`,args:t,output:n}}function tJ(e){return xCe(e)?nJ(e,!0):nJ(e,!1)}function nJ(e,t){let n=t?e.parseTernary():SCe(e);if(e.match(sJ.ASSIGN,sJ.PLUS_ASSIGN,sJ.MINUS_ASSIGN,sJ.STAR_ASSIGN,sJ.SLASH_ASSIGN,sJ.PERCENT_ASSIGN,sJ.CARET_ASSIGN)){let r=e.advance(),i=e.withDepth(()=>nJ(e,t));if(n.type!==`variable`&&n.type!==`field`&&n.type!==`array_access`)throw Error(`Invalid assignment target`);return{type:`assignment`,operator:new Map([[`=`,`=`],[`+=`,`+=`],[`-=`,`-=`],[`*=`,`*=`],[`/=`,`/=`],[`%=`,`%=`],[`^=`,`^=`]]).get(r.value)??`=`,target:n,value:i}}return n}function xCe(e){let t=0,n=e.pos;for(;n=`,`>=`],[`==`,`==`],[`!=`,`!=`]]).get(n.value)??`==`,left:t,right:r}}return t}function wCe(e){return e.match(sJ.NUMBER,sJ.STRING,sJ.IDENT,sJ.DOLLAR,sJ.LPAREN,sJ.NOT,sJ.MINUS,sJ.PLUS,sJ.INCREMENT,sJ.DECREMENT)}function TCe(e){return e.match(sJ.AND,sJ.OR,sJ.QUESTION,sJ.ASSIGN,sJ.PLUS_ASSIGN,sJ.MINUS_ASSIGN,sJ.STAR_ASSIGN,sJ.SLASH_ASSIGN,sJ.PERCENT_ASSIGN,sJ.CARET_ASSIGN,sJ.COMMA,sJ.SEMICOLON,sJ.NEWLINE,sJ.RBRACE,sJ.RPAREN,sJ.RBRACKET,sJ.COLON,sJ.PIPE,sJ.APPEND,sJ.GT,sJ.IN)}function ECe(e){e.expect(sJ.PRINTF);let t=e.check(sJ.LPAREN);t&&(e.advance(),e.skipNewlines());let n=t?e.parseExpression():tJ(e),r=[];for(;e.check(sJ.COMMA);)e.advance(),t&&e.skipNewlines(),e.assertArrayLength(r.length),r.push(t?e.parseExpression():tJ(e));t&&(e.skipNewlines(),e.expect(sJ.RPAREN));let i;return e.check(sJ.GT)?(e.advance(),i={redirect:`>`,file:e.parsePrimary()}):e.check(sJ.APPEND)&&(e.advance(),i={redirect:`>>`,file:e.parsePrimary()}),{type:`printf`,format:n,args:r,output:i}}var sJ,DCe=B(()=>{sJ={LPAREN:`LPAREN`,RPAREN:`RPAREN`,QUESTION:`QUESTION`,NEWLINE:`NEWLINE`,SEMICOLON:`SEMICOLON`,RBRACE:`RBRACE`,COMMA:`COMMA`,PIPE:`PIPE`,GT:`GT`,APPEND:`APPEND`,AND:`AND`,OR:`OR`,ASSIGN:`ASSIGN`,PLUS_ASSIGN:`PLUS_ASSIGN`,MINUS_ASSIGN:`MINUS_ASSIGN`,STAR_ASSIGN:`STAR_ASSIGN`,SLASH_ASSIGN:`SLASH_ASSIGN`,PERCENT_ASSIGN:`PERCENT_ASSIGN`,CARET_ASSIGN:`CARET_ASSIGN`,RBRACKET:`RBRACKET`,COLON:`COLON`,IN:`IN`,PRINT:`PRINT`,PRINTF:`PRINTF`,IDENT:`IDENT`,LT:`LT`,LE:`LE`,GE:`GE`,EQ:`EQ`,NE:`NE`,MATCH:`MATCH`,NOT_MATCH:`NOT_MATCH`,NUMBER:`NUMBER`,STRING:`STRING`,DOLLAR:`DOLLAR`,NOT:`NOT`,MINUS:`MINUS`,PLUS:`PLUS`,INCREMENT:`INCREMENT`,DECREMENT:`DECREMENT`}}),cJ,OCe=B(()=>{U(),yCe(),DCe(),cJ=class{tokens=[];pos=0;depth=0;operations=0;limits;constructor(e={}){this.limits={maxSourceLength:e.maxSourceLength??10485760,maxTokens:e.maxTokens??1e5,maxDepth:e.maxDepth??100,maxOperations:e.maxOperations??1e5}}parse(e){if(e.length>this.limits.maxSourceLength)throw new H(`awk: source length limit exceeded (${this.limits.maxSourceLength})`,`string_length`);let t=new eJ(e,this.limits.maxTokens);this.tokens=t.tokenize(),this.pos=0,this.depth=0,this.operations=0;let n=0;for(let e of this.tokens)if(this.useOperation(),e.type===J.LPAREN||e.type===J.LBRACKET||e.type===J.LBRACE){if(n++,n>this.limits.maxDepth)throw new H(`awk: parser depth limit exceeded (${this.limits.maxDepth})`,`recursion`)}else(e.type===J.RPAREN||e.type===J.RBRACKET||e.type===J.RBRACE)&&(n=Math.max(0,n-1));return this.parseProgram()}setPos(e){this.pos=e}current(){return this.tokens[this.pos]||{type:J.EOF,value:``,line:0,column:0}}advance(){this.useOperation();let e=this.current();return this.posthis.limits.maxOperations-this.operations)throw new H(`awk: parser operation limit exceeded (${this.limits.maxOperations})`,`iterations`);this.operations+=e}withDepth(e){if(this.depth>=this.limits.maxDepth)throw new H(`awk: parser depth limit exceeded (${this.limits.maxDepth})`,`recursion`);this.depth++;try{return e()}finally{this.depth--}}assertArrayLength(e){if(e>=this.limits.maxTokens)throw new H(`awk: AST array limit exceeded (${this.limits.maxTokens})`,`array_elements`)}match(...e){return e.includes(this.current().type)}check(e){return this.current().type===e}expect(e,t){if(!this.check(e)){let n=this.current();throw Error(t||`Expected ${e}, got ${n.type} at line ${n.line}:${n.column}`)}return this.advance()}skipNewlines(){for(;this.check(J.NEWLINE);)this.advance()}skipTerminators(){for(;this.check(J.NEWLINE)||this.check(J.SEMICOLON);)this.advance()}parseProgram(){let e=[],t=[];for(this.skipNewlines();!this.check(J.EOF)&&(this.skipNewlines(),!this.check(J.EOF));)this.check(J.FUNCTION)?e.push(this.parseFunction()):t.push(this.parseRule()),this.skipTerminators();return{functions:e,rules:t}}parseFunction(){this.expect(J.FUNCTION);let e=this.expect(J.IDENT).value;this.expect(J.LPAREN);let t=[];if(!this.check(J.RPAREN))for(t.push(this.expect(J.IDENT).value);this.check(J.COMMA);)this.advance(),t.push(this.expect(J.IDENT).value);return this.expect(J.RPAREN),this.skipNewlines(),{name:e,params:t,body:this.parseBlock()}}parseRule(){let e;if(this.check(J.BEGIN))this.advance(),e={type:`begin`};else if(this.check(J.END))this.advance(),e={type:`end`};else if(this.check(J.LBRACE))e=void 0;else if(this.check(J.REGEX)){let t=this.advance();if(this.check(J.AND)||this.check(J.OR)){let n={type:`binary`,operator:`~`,left:{type:`field`,index:{type:`number`,value:0}},right:{type:`regex`,pattern:t.value}};e={type:`expr_pattern`,expression:this.parseLogicalOrRest(n)}}else{let n={type:`regex_pattern`,pattern:t.value};if(this.check(J.COMMA)){this.advance();let t;t=this.check(J.REGEX)?{type:`regex_pattern`,pattern:this.advance().value}:{type:`expr_pattern`,expression:this.parseExpression()},e={type:`range`,start:n,end:t}}else e=n}}else{let t={type:`expr_pattern`,expression:this.parseExpression()};if(this.check(J.COMMA)){this.advance();let n;n=this.check(J.REGEX)?{type:`regex_pattern`,pattern:this.advance().value}:{type:`expr_pattern`,expression:this.parseExpression()},e={type:`range`,start:t,end:n}}else e=t}this.skipNewlines();let t;return t=this.check(J.LBRACE)?this.parseBlock():{type:`block`,statements:[{type:`print`,args:[{type:`field`,index:{type:`number`,value:0}}]}]},{pattern:e,action:t}}parseBlock(){this.expect(J.LBRACE),this.skipNewlines();let e=[];for(;!this.check(J.RBRACE)&&!this.check(J.EOF);)e.push(this.parseStatement()),this.skipTerminators();return this.expect(J.RBRACE),{type:`block`,statements:e}}parseStatement(){return this.withDepth(()=>this.parseStatementAtDepth())}parseStatementAtDepth(){if(this.check(J.SEMICOLON)||this.check(J.NEWLINE))return this.advance(),{type:`block`,statements:[]};if(this.check(J.LBRACE))return this.parseBlock();if(this.check(J.IF))return this.parseIf();if(this.check(J.WHILE))return this.parseWhile();if(this.check(J.DO))return this.parseDoWhile();if(this.check(J.FOR))return this.parseFor();if(this.check(J.BREAK))return this.advance(),{type:`break`};if(this.check(J.CONTINUE))return this.advance(),{type:`continue`};if(this.check(J.NEXT))return this.advance(),{type:`next`};if(this.check(J.NEXTFILE))return this.advance(),{type:`nextfile`};if(this.check(J.EXIT)){this.advance();let e;return!this.check(J.NEWLINE)&&!this.check(J.SEMICOLON)&&!this.check(J.RBRACE)&&!this.check(J.EOF)&&(e=this.parseExpression()),{type:`exit`,code:e}}if(this.check(J.RETURN)){this.advance();let e;return!this.check(J.NEWLINE)&&!this.check(J.SEMICOLON)&&!this.check(J.RBRACE)&&!this.check(J.EOF)&&(e=this.parseExpression()),{type:`return`,value:e}}if(this.check(J.DELETE)){this.advance();let e=this.parsePrimary();if(e.type!==`array_access`&&e.type!==`variable`)throw Error(`delete requires array element or array`);return{type:`delete`,target:e}}return this.check(J.PRINT)?bCe(this):this.check(J.PRINTF)?ECe(this):{type:`expr_stmt`,expression:this.parseExpression()}}parseIf(){this.expect(J.IF),this.expect(J.LPAREN);let e=this.parseExpression();this.expect(J.RPAREN),this.skipNewlines();let t=this.parseStatement();this.skipTerminators();let n;return this.check(J.ELSE)&&(this.advance(),this.skipNewlines(),n=this.parseStatement()),{type:`if`,condition:e,consequent:t,alternate:n}}parseWhile(){this.expect(J.WHILE),this.expect(J.LPAREN);let e=this.parseExpression();return this.expect(J.RPAREN),this.skipNewlines(),{type:`while`,condition:e,body:this.parseStatement()}}parseDoWhile(){this.expect(J.DO),this.skipNewlines();let e=this.parseStatement();this.skipNewlines(),this.expect(J.WHILE),this.expect(J.LPAREN);let t=this.parseExpression();return this.expect(J.RPAREN),{type:`do_while`,body:e,condition:t}}parseFor(){if(this.expect(J.FOR),this.expect(J.LPAREN),this.check(J.IDENT)){let e=this.advance();if(this.check(J.IN)){this.advance();let t=this.expect(J.IDENT).value;this.expect(J.RPAREN),this.skipNewlines();let n=this.parseStatement();return{type:`for_in`,variable:e.value,array:t,body:n}}this.pos--}let e;this.check(J.SEMICOLON)||(e=this.parseExpression()),this.expect(J.SEMICOLON);let t;this.check(J.SEMICOLON)||(t=this.parseExpression()),this.expect(J.SEMICOLON);let n;this.check(J.RPAREN)||(n=this.parseExpression()),this.expect(J.RPAREN),this.skipNewlines();let r=this.parseStatement();return{type:`for`,init:e,condition:t,update:n,body:r}}parseExpression(){return this.withDepth(()=>this.parseAssignment())}parseAssignment(){let e=this.parseTernary();if(this.match(J.ASSIGN,J.PLUS_ASSIGN,J.MINUS_ASSIGN,J.STAR_ASSIGN,J.SLASH_ASSIGN,J.PERCENT_ASSIGN,J.CARET_ASSIGN)){let t=this.advance(),n=this.parseExpression();if(e.type!==`variable`&&e.type!==`field`&&e.type!==`array_access`)throw Error(`Invalid assignment target`);let r=new Set([`=`,`+=`,`-=`,`*=`,`/=`,`%=`,`^=`]),i=t.value;if(!r.has(i))throw Error(`Unknown assignment operator: ${i}`);return{type:`assignment`,operator:i,target:e,value:n}}return e}parseTernary(){let e=this.parsePipeGetline();if(this.check(J.QUESTION)){this.advance();let t=this.parseExpression();this.expect(J.COLON);let n=this.parseExpression();e={type:`ternary`,condition:e,consequent:t,alternate:n}}return e}parsePipeGetline(){let e=this.parseOr();if(this.check(J.PIPE)){if(this.advance(),!this.check(J.GETLINE))throw Error(`Expected 'getline' after '|' in expression context`);this.advance();let t;return this.check(J.IDENT)&&(t=this.advance().value),{type:`getline`,command:e,variable:t}}return e}parseOr(){let e=this.parseAnd();for(;this.check(J.OR);){this.advance();let t=this.parseAnd();e={type:`binary`,operator:`||`,left:e,right:t}}return e}parseLogicalOrRest(e){for(e=this.parseLogicalAndRest(e);this.check(J.OR);){this.advance();let t=this.parseAnd();e={type:`binary`,operator:`||`,left:e,right:t}}return e}parseLogicalAndRest(e){for(;this.check(J.AND);){this.advance();let t=this.parseIn();e={type:`binary`,operator:`&&`,left:e,right:t}}return e}parseAnd(){let e=this.parseIn();for(;this.check(J.AND);){this.advance();let t=this.parseIn();e={type:`binary`,operator:`&&`,left:e,right:t}}return e}parseIn(){let e=this.parseConcatenation();return this.check(J.IN)?(this.advance(),{type:`in`,key:e,array:this.expect(J.IDENT).value}):e}parseConcatenation(){let e=this.parseMatch();for(;this.canStartExpression()&&!this.isConcatTerminator();){let t=this.parseMatch();e={type:`binary`,operator:` `,left:e,right:t}}return e}parseMatch(){let e=this.parseComparison();for(;this.match(J.MATCH,J.NOT_MATCH);){let t=this.advance().type===J.MATCH?`~`:`!~`,n=this.parseComparison();e={type:`binary`,operator:t,left:e,right:n}}return e}parseComparison(){let e=this.parseAddSub();for(;this.match(J.LT,J.LE,J.GT,J.GE,J.EQ,J.NE);){let t=this.advance(),n=this.parseAddSub();e={type:`binary`,operator:new Map([[`<`,`<`],[`<=`,`<=`],[`>`,`>`],[`>=`,`>=`],[`==`,`==`],[`!=`,`!=`]]).get(t.value)??`==`,left:e,right:n}}return e}canStartExpression(){return this.match(J.NUMBER,J.STRING,J.IDENT,J.DOLLAR,J.LPAREN,J.NOT,J.MINUS,J.PLUS,J.INCREMENT,J.DECREMENT)}isConcatTerminator(){return this.match(J.AND,J.OR,J.QUESTION,J.ASSIGN,J.PLUS_ASSIGN,J.MINUS_ASSIGN,J.STAR_ASSIGN,J.SLASH_ASSIGN,J.PERCENT_ASSIGN,J.CARET_ASSIGN,J.COMMA,J.SEMICOLON,J.NEWLINE,J.RBRACE,J.RPAREN,J.RBRACKET,J.COLON,J.PIPE,J.APPEND,J.IN)}parseAddSub(){let e=this.parseMulDiv();for(;this.match(J.PLUS,J.MINUS);){let t=this.advance().value,n=this.parseMulDiv();e={type:`binary`,operator:t,left:e,right:n}}return e}parseMulDiv(){let e=this.parseUnary();for(;this.match(J.STAR,J.SLASH,J.PERCENT);){let t=this.advance(),n=this.parseUnary();e={type:`binary`,operator:new Map([[`*`,`*`],[`/`,`/`],[`%`,`%`]]).get(t.value)??`*`,left:e,right:n}}return e}parseUnary(){if(this.check(J.INCREMENT)){this.advance();let e=this.withDepth(()=>this.parseUnary());return e.type!==`variable`&&e.type!==`field`&&e.type!==`array_access`?{type:`unary`,operator:`+`,operand:{type:`unary`,operator:`+`,operand:e}}:{type:`pre_increment`,operand:e}}if(this.check(J.DECREMENT)){this.advance();let e=this.withDepth(()=>this.parseUnary());return e.type!==`variable`&&e.type!==`field`&&e.type!==`array_access`?{type:`unary`,operator:`-`,operand:{type:`unary`,operator:`-`,operand:e}}:{type:`pre_decrement`,operand:e}}return this.match(J.NOT,J.MINUS,J.PLUS)?{type:`unary`,operator:this.advance().value,operand:this.withDepth(()=>this.parseUnary())}:this.parsePower()}parsePower(){let e=this.parsePostfix();if(this.check(J.CARET)){this.advance();let t=this.withDepth(()=>this.parsePower());e={type:`binary`,operator:`^`,left:e,right:t}}return e}parsePostfix(){let e=this.parsePrimary();if(this.check(J.INCREMENT)){if(this.advance(),e.type!==`variable`&&e.type!==`field`&&e.type!==`array_access`)throw Error(`Invalid increment operand`);return{type:`post_increment`,operand:e}}if(this.check(J.DECREMENT)){if(this.advance(),e.type!==`variable`&&e.type!==`field`&&e.type!==`array_access`)throw Error(`Invalid decrement operand`);return{type:`post_decrement`,operand:e}}return e}parseFieldIndex(){if(this.check(J.INCREMENT)){this.advance();let e=this.withDepth(()=>this.parseFieldIndex());return e.type!==`variable`&&e.type!==`field`&&e.type!==`array_access`?{type:`unary`,operator:`+`,operand:{type:`unary`,operator:`+`,operand:e}}:{type:`pre_increment`,operand:e}}if(this.check(J.DECREMENT)){this.advance();let e=this.withDepth(()=>this.parseFieldIndex());return e.type!==`variable`&&e.type!==`field`&&e.type!==`array_access`?{type:`unary`,operator:`-`,operand:{type:`unary`,operator:`-`,operand:e}}:{type:`pre_decrement`,operand:e}}return this.match(J.NOT,J.MINUS,J.PLUS)?{type:`unary`,operator:this.advance().value,operand:this.withDepth(()=>this.parseFieldIndex())}:this.parseFieldIndexPower()}parseFieldIndexPower(){let e=this.parseFieldIndexPrimary();if(this.check(J.CARET)){this.advance();let t=this.withDepth(()=>this.parseFieldIndexPower());e={type:`binary`,operator:`^`,left:e,right:t}}return e}parseFieldIndexPrimary(){if(this.check(J.NUMBER))return{type:`number`,value:this.advance().value};if(this.check(J.STRING))return{type:`string`,value:this.advance().value};if(this.check(J.DOLLAR))return this.advance(),{type:`field`,index:this.parseFieldIndex()};if(this.check(J.LPAREN)){this.advance();let e=this.parseExpression();return this.expect(J.RPAREN),e}if(this.check(J.IDENT)){let e=this.advance().value;if(this.check(J.LPAREN)){this.advance();let t=[];if(!this.check(J.RPAREN))for(t.push(this.parseExpression());this.check(J.COMMA);)this.advance(),t.push(this.parseExpression());return this.expect(J.RPAREN),{type:`call`,name:e,args:t}}if(this.check(J.LBRACKET)){this.advance();let t=this.parseExpression();if(this.check(J.COMMA)){let n=[t];for(;this.check(J.COMMA);)this.advance(),n.push(this.parseExpression());return this.expect(J.RBRACKET),{type:`array_access`,array:e,key:n.reduce((e,t)=>({type:`binary`,operator:` `,left:{type:`binary`,operator:` `,left:e,right:{type:`variable`,name:`SUBSEP`}},right:t}))}}return this.expect(J.RBRACKET),{type:`array_access`,array:e,key:t}}return{type:`variable`,name:e}}throw Error(`Unexpected token in field index: ${this.current().type} at line ${this.current().line}:${this.current().column}`)}parsePrimary(){if(this.check(J.NUMBER))return{type:`number`,value:this.advance().value};if(this.check(J.STRING))return{type:`string`,value:this.advance().value};if(this.check(J.REGEX))return{type:`regex`,pattern:this.advance().value};if(this.check(J.DOLLAR))return this.advance(),{type:`field`,index:this.parseFieldIndex()};if(this.check(J.LPAREN)){this.advance();let e=this.parseExpression();if(this.check(J.COMMA)){let t=[e];for(;this.check(J.COMMA);)this.advance(),t.push(this.parseExpression());return this.expect(J.RPAREN),{type:`tuple`,elements:t}}return this.expect(J.RPAREN),e}if(this.check(J.GETLINE)){this.advance();let e,t;return this.check(J.IDENT)&&(e=this.advance().value),this.check(J.LT)&&(this.advance(),t=this.parsePrimary()),{type:`getline`,variable:e,file:t}}if(this.check(J.IDENT)){let e=this.advance().value;if(this.check(J.LPAREN)){this.advance();let t=[];if(this.skipNewlines(),!this.check(J.RPAREN))for(t.push(this.parseExpression());this.check(J.COMMA);)this.advance(),this.skipNewlines(),t.push(this.parseExpression());return this.skipNewlines(),this.expect(J.RPAREN),{type:`call`,name:e,args:t}}if(this.check(J.LBRACKET)){this.advance();let t=[this.parseExpression()];for(;this.check(J.COMMA);)this.advance(),t.push(this.parseExpression());this.expect(J.RBRACKET);let n;if(t.length===1)n=t[0];else{n=t[0];for(let e=1;emJ,flagsForFuzzing:()=>hJ});function uJ(e){return e.replace(/\\t/g,` `).replace(/\\n/g,` `).replace(/\\r/g,`\r`).replace(/\\b/g,`\b`).replace(/\\f/g,`\f`).replace(/\\a/g,`\x07`).replace(/\\v/g,`\v`).replace(/\\\\/g,`\\`)}function dJ(e){if(e===` `)return hG(`\\s+`);if(/[[\](){}.*+?^$|\\]/.test(e))try{return hG(e)}catch{return hG(fJ(e))}return hG(fJ(e))}function fJ(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var pJ,mJ,hJ,kCe=B(()=>{AB(),iV(),tq(),U(),bG(),jK(),oB(),cV(),ZB(),_Ce(),OCe(),pJ={name:`awk`,summary:`pattern scanning and text processing language`,usage:`awk [OPTIONS] 'PROGRAM' [FILE...]`,options:[`-F FS use FS as field separator`,`-v VAR=VAL assign VAL to variable VAR`,` --help display this help and exit`]},mJ={name:`awk`,async execute(e,t){kK(t.requireDefenseContext,`awk`,`execution entry`);let n=(e,n)=>AK(t.requireDefenseContext,`awk`,e,n);if(oV(e))return aV(pJ);let r=new yG(/\s+/),i=` `,a=Object.create(null),o=0;for(let t=0;t0){let e=n.slice(0,r);a[e]=uJ(n.slice(r+1))}o=t+1}else{if(n.startsWith(`--`))return sV(`awk`,n);if(n.startsWith(`-`)&&n.length>1){let e=n[1];if(e!==`F`&&e!==`v`)return sV(`awk`,`-${e}`);o=t+1}else if(!n.startsWith(`-`)){o=t;break}}}if(o>=e.length)return{stdout:``,stderr:`awk: missing program `,exitCode:1};let s=e[o],c=e.slice(o+1),l=new cJ({maxSourceLength:t.limits.maxStringLength,maxTokens:t.limits.maxAwkParserTokens,maxDepth:t.limits.maxAwkParserDepth,maxOperations:t.limits.maxAwkParserOperations}),u;try{u=l.parse(s)}catch(e){return rV(e),{stdout:``,stderr:`awk: ${e instanceof Error?e.message:String(e)} `,exitCode:1}}let d={readFile:t.fs.readFile.bind(t.fs),writeFile:t.fs.writeFile.bind(t.fs),appendFile:async(e,r)=>{try{let i=await n(`appendFile read`,()=>t.fs.readFile(e));await n(`appendFile write`,()=>t.fs.writeFile(e,i+r))}catch(i){if(i instanceof tB)throw i;await n(`appendFile create`,()=>t.fs.writeFile(e,r))}},resolvePath:t.fs.resolvePath.bind(t.fs)},f=t.exec,p=fSe({fieldSep:r,maxIterations:t.limits.maxAwkIterations,maxOutputSize:Math.min(t.limits.maxStringLength,t.limits.maxOutputSize),maxArrayElements:t.limits.maxArrayElements,fs:d,cwd:t.cwd,exec:f?e=>n(`command pipe exec`,()=>f(e,{cwd:t.cwd,signal:t.signal})):void 0,coverage:t.coverage,requireDefenseContext:t.requireDefenseContext});p.FS=i,p.vars=Object.assign(Object.create(null),a),p.ARGC=c.length+1,p.ARGV=Object.create(null),p.ARGV[0]=`awk`;for(let e=0;ee.pattern?.type!==`begin`&&e.pattern?.type!==`end`),g=u.rules.some(e=>e.pattern?.type===`end`);try{if(await n(`BEGIN execution`,()=>m.executeBegin()),p.shouldExit)return await n(`END execution after BEGIN exit`,()=>m.executeEnd()),{stdout:m.getOutput(),stderr:``,exitCode:m.getExitCode()};if(!h&&!g)return{stdout:m.getOutput(),stderr:``,exitCode:m.getExitCode()};let e=Math.min(t.limits.maxInputBytes,t.limits.maxStringLength),r=t.limits.maxArrayElements,i=0,a=async(t,a)=>{let o=V(a);if(o>e-i)throw new H(`aggregate input size limit exceeded (${e} bytes)`,`string_length`);i+=o;let s=+(a.length>0);for(let e=0;er+1)throw new H(`record array limit exceeded (${r})`,`array_elements`);let c=a.split(` `);if(c.length>0&&c[c.length-1]===``&&c.pop(),c.length>r)throw new H(`record array limit exceeded (${r})`,`array_elements`);for(p.FILENAME=t,p.FNR=0,p.lines=c,p.lineIndex=-1,p.shouldNextFile=!1;p.lineIndexm.executeLine(c[e])),p.shouldExit||p.shouldNextFile)break}};if(c.length>0)for(let r of c){let o;try{let a=t.fs.resolvePath(t.cwd,r);if((await n(`input file stat`,()=>t.fs.stat(a))).size>e-i)throw new H(`aggregate input size limit exceeded (${e} bytes)`,`string_length`);o=await n(`input file read`,()=>t.fs.readFile(a))}catch(e){if(e instanceof tB||e instanceof H)throw e;return{stdout:``,stderr:`awk: ${r}: No such file or directory `,exitCode:1}}if(await n(`input processing`,()=>a(r,o)),p.shouldExit)break}else await n(`stdin processing`,()=>a(``,yB(t.stdin)));return await n(`END execution`,()=>m.executeEnd()),{stdout:m.getOutput(),stderr:``,exitCode:m.getExitCode()}}catch(e){if(e instanceof tB)throw e;let t=e instanceof Error?e.message:String(e),n=e instanceof H?H.EXIT_CODE:2;return{stdout:m.getOutput(),stderr:`awk: ${t} `,exitCode:n}}}},hJ={name:`awk`,flags:[{flag:`-F`,type:`value`,valueHint:`delimiter`},{flag:`-v`,type:`value`,valueHint:`string`}],stdinType:`text`,needsArgs:!0}});function gJ(e){let t=e.trim(),n=t.match(/^([+-]?\d*\.?\d+)\s*([kmgtpeKMGTPE])?[iI]?[bB]?$/);if(!n){let e=parseFloat(t);return Number.isNaN(e)?0:e}let r=parseFloat(n[1]),i=(n[2]||``).toLowerCase();return r*(xJ.get(i)??1)}function _J(e){let t=e.trim().toLowerCase().slice(0,3);return SJ.get(t)??0}function ACe(e,t){let n=e.split(/(\d+)/),r=t.split(/(\d+)/),i=Math.max(n.length,r.length);for(let e=0;e=i.length)return``;if(t.endField===void 0){let e=i[a]||``;return t.startChar!==void 0&&(e=e.slice(t.startChar-1)),t.ignoreLeading&&(e=e.trimStart()),e}let o=Math.min(t.endField-1,i.length-1),s=``;for(let e=a;e<=o&&ea&&(s+=n||` `),s+=r}return t.ignoreLeading&&(s=s.trimStart()),s}function bJ(e,t,n){let r=e,i=t;return n.dictionaryOrder&&(r=vJ(r),i=vJ(i)),n.ignoreCase&&(r=r.toLowerCase(),i=i.toLowerCase()),n.monthSort?_J(r)-_J(i):n.humanNumeric?gJ(r)-gJ(i):n.versionSort?ACe(r,i):n.numeric?(parseFloat(r)||0)-(parseFloat(i)||0):r.localeCompare(i)}function jCe(e){let{keys:t,fieldDelimiter:n,numeric:r,ignoreCase:i,reverse:a,humanNumeric:o,versionSort:s,dictionaryOrder:c,monthSort:l,ignoreLeadingBlanks:u,stable:d}=e;return(e,f)=>{let p=e,m=f;if(u&&(p=p.trimStart(),m=m.trimStart()),t.length===0){let t=bJ(p,m,{numeric:r,ignoreCase:i,humanNumeric:o,versionSort:s,dictionaryOrder:c,monthSort:l});if(t!==0)return a?-t:t;if(!d){let t=e.localeCompare(f);return a?-t:t}return 0}for(let e of t){let t=yJ(p,e,n),u=yJ(m,e,n);e.ignoreLeading&&(t=t.trimStart(),u=u.trimStart());let d={numeric:e.numeric??r,ignoreCase:e.ignoreCase??i,humanNumeric:e.humanNumeric??o,versionSort:e.versionSort??s,dictionaryOrder:e.dictionaryOrder??c,monthSort:e.monthSort??l},f=e.reverse??a,h=bJ(t,u,d);if(h!==0)return f?-h:h}if(!d){let t=e.localeCompare(f);return a?-t:t}return 0}}function MCe(e,t){if(t.keys.length===0){if(t.ignoreCase){let t=new Set;return e.filter(e=>{let n=e.toLowerCase();return!t.has(n)&&(t.add(n),!0)})}return[...new Set(e)]}let n=t.keys[0],r=new Set;return e.filter(e=>{let i=yJ(e,n,t.fieldDelimiter);return(n.ignoreCase??t.ignoreCase)&&(i=i.toLowerCase()),!r.has(i)&&(r.add(i),!0)})}var xJ,SJ,NCe=B(()=>{xJ=new Map([[``,1],[`k`,1024],[`m`,1048576],[`g`,1073741824],[`t`,1099511627776],[`p`,0x4000000000000],[`e`,0x1000000000000000]]),SJ=new Map([[`jan`,1],[`feb`,2],[`mar`,3],[`apr`,4],[`may`,5],[`jun`,6],[`jul`,7],[`aug`,8],[`sep`,9],[`oct`,10],[`nov`,11],[`dec`,12]])});function CJ(e){let t={startField:1},n=``,r=e,i=r.match(/([bdfhMnrV]+)$/);i&&(n=i[1],r=r.slice(0,-n.length)),n.includes(`n`)&&(t.numeric=!0),n.includes(`r`)&&(t.reverse=!0),n.includes(`f`)&&(t.ignoreCase=!0),n.includes(`b`)&&(t.ignoreLeading=!0),n.includes(`h`)&&(t.humanNumeric=!0),n.includes(`V`)&&(t.versionSort=!0),n.includes(`d`)&&(t.dictionaryOrder=!0),n.includes(`M`)&&(t.monthSort=!0);let a=r.split(`,`);if(a.length===0||a[0]===``)return null;let o=a[0].split(`.`),s=parseInt(o[0],10);if(Number.isNaN(s)||s<1)return null;if(t.startField=s,o.length>1&&o[1]){let e=parseInt(o[1],10);!Number.isNaN(e)&&e>=1&&(t.startChar=e)}if(a.length>1&&a[1]){let e=a[1],n=e.match(/([bdfhMnrV]+)$/);if(n){let r=n[1];r.includes(`n`)&&(t.numeric=!0),r.includes(`r`)&&(t.reverse=!0),r.includes(`f`)&&(t.ignoreCase=!0),r.includes(`b`)&&(t.ignoreLeading=!0),r.includes(`h`)&&(t.humanNumeric=!0),r.includes(`V`)&&(t.versionSort=!0),r.includes(`d`)&&(t.dictionaryOrder=!0),r.includes(`M`)&&(t.monthSort=!0),e=e.slice(0,-r.length)}let r=e.split(`.`);if(r[0]){let e=parseInt(r[0],10);if(!Number.isNaN(e)&&e>=1&&(t.endField=e),r.length>1&&r[1]){let e=parseInt(r[1],10);!Number.isNaN(e)&&e>=1&&(t.endChar=e)}}}return t}var PCe=B(()=>{}),wJ={};Tz(wJ,{flagsForFuzzing:()=>DJ,sortCommand:()=>EJ});var TJ,EJ,DJ,FCe=B(()=>{AB(),hV(),cV(),NCe(),PCe(),TJ={name:`sort`,summary:`sort lines of text files`,usage:`sort [OPTION]... [FILE]...`,options:[`-b, --ignore-leading-blanks ignore leading blanks`,`-d, --dictionary-order consider only blanks and alphanumeric characters`,`-f, --ignore-case fold lower case to upper case characters`,`-h, --human-numeric-sort compare human readable numbers (e.g., 2K 1G)`,`-M, --month-sort compare (unknown) < 'JAN' < ... < 'DEC'`,`-n, --numeric-sort compare according to string numerical value`,`-r, --reverse reverse the result of comparisons`,`-V, --version-sort natural sort of (version) numbers within text`,`-c, --check check for sorted input; do not sort`,`-o, --output=FILE write result to FILE instead of stdout`,`-s, --stable stabilize sort by disabling last-resort comparison`,`-u, --unique output only unique lines`,`-k, --key=KEYDEF sort via a key; KEYDEF gives location and type`,`-t, --field-separator=SEP use SEP as field separator`,` --help display this help and exit`],description:`KEYDEF is F[.C][OPTS][,F[.C][OPTS]] F is a field number (1-indexed) C is a character position within the field (1-indexed) OPTS can be: b d f h M n r V (per-key modifiers) Examples: -k1 sort by first field -k2,2 sort by second field only -k1.3 sort by first field starting at 3rd character -k1,2n sort by fields 1-2 numerically -k2 -k1 sort by field 2, then by field 1`},EJ={name:`sort`,async execute(e,t){if(oV(e))return aV(TJ);let n={reverse:!1,numeric:!1,unique:!1,ignoreCase:!1,humanNumeric:!1,versionSort:!1,dictionaryOrder:!1,monthSort:!1,ignoreLeadingBlanks:!1,stable:!1,checkOnly:!1,outputFile:null,keys:[],fieldDelimiter:null},r=[];for(let t=0;t0&&a[a.length-1]===``&&a.pop();let o=jCe(n);if(n.checkOnly){let e=r.length>0?r[0]:`-`;for(let t=1;t0)return{stdout:``,stderr:`sort: ${e}:${t+1}: disorder: ${a[t]} `,exitCode:1};return{stdout:``,stderr:``,exitCode:0}}a.sort(o),n.unique&&(a=MCe(a,n));let s=a.length>0?`${a.join(` `)} `:``;if(n.outputFile){let e=t.fs.resolvePath(t.cwd,n.outputFile);return await t.fs.writeFile(e,s),{stdout:``,stderr:``,exitCode:0}}return{stdout:s,stderr:``,exitCode:0}}},DJ={name:`sort`,flags:[{flag:`-r`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-u`,type:`boolean`},{flag:`-f`,type:`boolean`},{flag:`-h`,type:`boolean`},{flag:`-V`,type:`boolean`},{flag:`-d`,type:`boolean`},{flag:`-M`,type:`boolean`},{flag:`-b`,type:`boolean`},{flag:`-s`,type:`boolean`},{flag:`-c`,type:`boolean`},{flag:`-k`,type:`value`,valueHint:`string`},{flag:`-t`,type:`value`,valueHint:`delimiter`},{flag:`-o`,type:`value`,valueHint:`path`}],stdinType:`text`,needsFiles:!0}}),OJ={};Tz(OJ,{flagsForFuzzing:()=>MJ,uniqCommand:()=>jJ});var kJ,AJ,jJ,MJ,ICe=B(()=>{AB(),uV(),hV(),cV(),kJ={name:`uniq`,summary:`report or omit repeated lines`,usage:`uniq [OPTION]... [INPUT [OUTPUT]]`,options:[`-c, --count prefix lines by the number of occurrences`,`-d, --repeated only print duplicate lines`,`-i, --ignore-case ignore case when comparing`,`-u, --unique only print unique lines`,` --help display this help and exit`]},AJ={count:{short:`c`,long:`count`,type:`boolean`},duplicatesOnly:{short:`d`,long:`repeated`,type:`boolean`},uniqueOnly:{short:`u`,long:`unique`,type:`boolean`},ignoreCase:{short:`i`,long:`ignore-case`,type:`boolean`}},jJ={name:`uniq`,async execute(e,t){if(oV(e))return aV(kJ);let n=lV(`uniq`,e,AJ);if(!n.ok)return n.error;let{count:r,duplicatesOnly:i,uniqueOnly:a,ignoreCase:o}=n.result.flags,s=n.result.positional,c=await mV(t,s,{cmdName:`uniq`});if(!c.ok)return c.error;let l=(o?yB(c.content):c.content).split(` `);if(l.length>0&&l[l.length-1]===``&&l.pop(),l.length===0)return{stdout:``,stderr:``,exitCode:0};let u=[],d=l[0],f=1,p=(e,t)=>o?e.toLowerCase()===t.toLowerCase():e===t;for(let e=1;ee.count>1):a&&(m=u.filter(e=>e.count===1));let h=``;for(let{line:e,count:t}of m)h+=r?`${String(t).padStart(4)} ${e} `:`${e} `;return o?{stdout:h,stderr:``,exitCode:0}:{stdout:h,stderr:``,exitCode:0,stdoutKind:`bytes`,stdoutEncoding:`binary`}}},MJ={name:`uniq`,flags:[{flag:`-c`,type:`boolean`},{flag:`-d`,type:`boolean`},{flag:`-u`,type:`boolean`},{flag:`-i`,type:`boolean`}],stdinType:`text`,needsFiles:!0}}),NJ={};Tz(NJ,{commCommand:()=>FJ,flagsForFuzzing:()=>IJ});var PJ,FJ,IJ,LCe=B(()=>{AB(),cV(),PJ={name:`comm`,summary:`compare two sorted files line by line`,usage:`comm [OPTION]... FILE1 FILE2`,options:[`-1 suppress column 1 (lines unique to FILE1)`,`-2 suppress column 2 (lines unique to FILE2)`,`-3 suppress column 3 (lines that appear in both files)`,` --help display this help and exit`]},FJ={name:`comm`,async execute(e,t){if(oV(e))return aV(PJ);let n=!1,r=!1,i=!1,a=[];for(let t of e)if(t===`-1`)n=!0;else if(t===`-2`)r=!0;else if(t===`-3`)i=!0;else if(t===`-12`||t===`-21`)n=!0,r=!0;else if(t===`-13`||t===`-31`)n=!0,i=!0;else if(t===`-23`||t===`-32`)r=!0,i=!0;else if(t===`-123`||t===`-132`||t===`-213`||t===`-231`||t===`-312`||t===`-321`)n=!0,r=!0,i=!0;else{if(t.startsWith(`-`)&&t!==`-`)return sV(`comm`,t);a.push(t)}if(a.length!==2)return{stdout:``,stderr:`comm: missing operand Try 'comm --help' for more information. `,exitCode:1};let o=async e=>{if(e===`-`)return yB(t.stdin);try{let n=t.fs.resolvePath(t.cwd,e);return await t.fs.readFile(n)}catch{return null}},s=await o(a[0]);if(s===null)return{stdout:``,stderr:`comm: ${a[0]}: No such file or directory `,exitCode:1};let c=await o(a[1]);if(c===null)return{stdout:``,stderr:`comm: ${a[1]}: No such file or directory `,exitCode:1};let l=s.split(` `),u=c.split(` `);l.length>0&&l[l.length-1]===``&&l.pop(),u.length>0&&u[u.length-1]===``&&u.pop();let d=0,f=0,p=``,m=n?``:` `,h=(n?``:` `)+(r?``:` `);for(;d=l.length?(r||(p+=`${m}${u[f]} `),f++):f>=u.length||l[d]u[f]?(r||(p+=`${m}${u[f]} `),f++):(i||(p+=`${h}${l[d]} `),d++,f++);return{stdout:p,stderr:``,exitCode:0}}},IJ={name:`comm`,flags:[{flag:`-1`,type:`boolean`},{flag:`-2`,type:`boolean`},{flag:`-3`,type:`boolean`}],needsArgs:!0,minArgs:2}}),LJ={};Tz(LJ,{cutCommand:()=>zJ,flagsForFuzzing:()=>BJ});function RCe(e,t){let n=[],r=e.split(`,`);if(r.length>t)throw new H(`cut: range count limit exceeded (${t})`,`array_elements`);for(let e of r)if(e.includes(`-`)){let[t,r]=e.split(`-`),i=t?Number(t):1,a=r?Number(r):null;if(!Number.isSafeInteger(i)||i<1||a!==null&&(!Number.isSafeInteger(a)||a=0&&!r.has(i)&&(r.add(i),n.push(e[i]))}return n}var RJ,zJ,BJ,BCe=B(()=>{cH(),AB(),U(),hV(),cV(),RJ={name:`cut`,summary:`remove sections from each line of files`,usage:`cut [OPTION]... [FILE]...`,options:[`-c LIST select only these characters`,`-d DELIM use DELIM instead of TAB for field delimiter`,`-f LIST select only these fields`,`-s, --only-delimited do not print lines without delimiters`,` --help display this help and exit`]},zJ={name:`cut`,async execute(e,t){if(oV(e))return aV(RJ);let n=` `,r=null,i=null,a=!1,o=[];for(let t=0;t0&&c[c.length-1]===``&&c.pop();let l=RCe(r||i||`1`,t.limits.maxArrayElements),u=new sH(Math.min(t.limits.maxOutputSize,t.limits.maxStringLength),`cut`),d=0,f=e=>{if(!Number.isSafeInteger(e)||e<0||e>t.limits.maxLoopIterations-d)throw new H(`cut: range expansion limit exceeded (${t.limits.maxLoopIterations})`,`iterations`);d+=e,t.executionScope?.consumeWork(e,`cut range expansion`)};for(let e of c)if(i){let t=Array.from(e),n=[];for(let e of l){let r=e.start-1,i=e.end===null?t.length:e.end;f(Math.max(0,Math.min(i,t.length)-r));for(let e=r;e=0&&n.push(t[e])}u.append(`${n.join(``)} `)}else{if(a&&!e.includes(n))continue;let t=e.split(n);for(let e of l){let n=e.start-1,r=e.end===null?t.length:e.end;f(Math.max(0,Math.min(r,t.length)-n))}let r=zCe(t,l);u.append(`${r.join(n)} `)}return i?{stdout:u.build(),stderr:``,exitCode:0}:{stdout:u.build(),stderr:``,exitCode:0,stdoutKind:`bytes`,stdoutEncoding:`binary`}}},BJ={name:`cut`,flags:[{flag:`-d`,type:`value`,valueHint:`delimiter`},{flag:`-f`,type:`value`,valueHint:`string`},{flag:`-c`,type:`value`,valueHint:`string`},{flag:`-s`,type:`boolean`}],stdinType:`text`,needsFiles:!0}}),VJ={};Tz(VJ,{flagsForFuzzing:()=>KJ,pasteCommand:()=>GJ});function HJ(e,t){if(e.length===0)return``;if(e.length===1)return e[0];if(t.length===0)return e.join(``);let n=e[0];for(let r=1;r{cH(),AB(),iV(),U(),uV(),cV(),UJ={name:`paste`,summary:`merge lines of files`,usage:`paste [OPTION]... [FILE]...`,description:[`Write lines consisting of the sequentially corresponding lines from`,`each FILE, separated by TABs, to standard output.`,``,`With no FILE, or when FILE is -, read standard input.`],options:[`-d, --delimiters=LIST reuse characters from LIST instead of TABs`,`-s, --serial paste one file at a time instead of in parallel`,` --help display this help and exit`],examples:[`paste file1 file2 Merge file1 and file2 side by side`,`paste -d, file1 file2 Use comma as delimiter`,`paste -s file1 Paste all lines of file1 on one line`,`paste - - < file Paste pairs of lines from file`]},WJ={delimiter:{short:`d`,long:`delimiters`,type:`string`,default:` `},serial:{short:`s`,long:`serial`,type:`boolean`}},GJ={name:`paste`,async execute(e,t){if(oV(e))return aV(UJ);let n=lV(`paste`,e,WJ);if(!n.ok)return n.error;let r=n.result.flags.delimiter,i=n.result.flags.serial,a=n.result.positional;if(a.length>t.limits.maxArrayElements)throw new H(`paste: file operand limit exceeded (${t.limits.maxArrayElements})`,`array_elements`);if(V(r)>t.limits.maxStringLength)throw new H(`paste: delimiter size limit exceeded (${t.limits.maxStringLength} bytes)`,`string_length`);if(a.length===0)return{stdout:``,stderr:`usage: paste [-s] [-d delimiters] file ... `,exitCode:1};let o=yB(t.stdin),s=o?o.split(` `):[``];s.length>0&&s[s.length-1]===``&&s.pop();let c=a.filter(e=>e===`-`).length,l=[],u=0,d=V(o),f=e=>{if(e.length>t.limits.maxArrayElements-u)throw new H(`paste: line limit exceeded (${t.limits.maxArrayElements})`,`array_elements`);u+=e.length,t.executionScope?.consumeWork(e.length,`paste lines`)},p=0;for(let e of a)if(e===`-`){let e=[];for(let t=p;tt.limits.maxInputBytes-d)throw new H(`paste: aggregate input size limit exceeded (${t.limits.maxInputBytes} bytes)`,`string_length`);d+=r,t.executionScope?.consumeInput(r,`paste`);let i=e.split(` `);i.length>0&&i[i.length-1]===``&&i.pop(),f(i),l.push(i)}catch(t){return rV(t),{stdout:``,stderr:`paste: ${e}: No such file or directory `,exitCode:1}}}let m=new sH(Math.min(t.limits.maxOutputSize,t.limits.maxStringLength),`paste`);if(i)for(let e of l)e&&m.append(`${HJ(e,r)} `);else{let e=0;for(let t of l)e=Math.max(e,t?.length??0);for(let t=0;t$J,trCommand:()=>QJ});function JJ(e,t,n,r){let i=``,a=0,o=e=>{if(e.length>t-i.length)throw new H(`tr: expanded SET exceeds string length limit (${t})`,`string_length`);i+=e},s=(e=1)=>{if(e>n-r.iterations)throw new H(`tr: SET expansion iteration limit exceeded (${n})`,`iterations`);r.iterations+=e};for(;a=n?r-n+1:0;if(s(o),o>t-i.length)throw new H(`tr: expanded SET exceeds string length limit (${t})`,`string_length`);for(let e=n;e<=r;e++)i+=String.fromCharCode(e);a+=3;continue}o(e[a]),a++}return i}var YJ,XJ,ZJ,QJ,$J,HCe=B(()=>{AB(),iV(),yH(),U(),uV(),cV(),YJ={name:`tr`,summary:`translate or delete characters`,usage:`tr [OPTION]... SET1 [SET2]`,options:[`-c, -C, --complement use the complement of SET1`,`-d, --delete delete characters in SET1`,`-s, --squeeze-repeats squeeze repeated characters`,` --help display this help and exit`],description:`SET syntax: a-z character range [:alnum:] all letters and digits [:alpha:] all letters [:digit:] all digits [:lower:] all lowercase letters [:upper:] all uppercase letters [:space:] all whitespace [:blank:] horizontal whitespace [:punct:] all punctuation [:print:] all printable characters [:graph:] all printable characters except space [:cntrl:] all control characters [:xdigit:] all hexadecimal digits \\n, \\t, \\r escape sequences`},XJ=new Map([[`[:alnum:]`,`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`],[`[:alpha:]`,`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`],[`[:blank:]`,` `],[`[:cntrl:]`,Array.from({length:32},(e,t)=>String.fromCharCode(t)).join(``).concat(``)],[`[:digit:]`,`0123456789`],[`[:graph:]`,Array.from({length:94},(e,t)=>String.fromCharCode(33+t)).join(``)],[`[:lower:]`,`abcdefghijklmnopqrstuvwxyz`],[`[:print:]`,Array.from({length:95},(e,t)=>String.fromCharCode(32+t)).join(``)],[`[:punct:]`,`!"#$%&'()*+,-./:;<=>?@[\\]^_\`{|}~`],[`[:space:]`,` \r\f\v`],[`[:upper:]`,`ABCDEFGHIJKLMNOPQRSTUVWXYZ`],[`[:xdigit:]`,`0123456789ABCDEFabcdef`]]),ZJ={complement:{short:`c`,long:`complement`,type:`boolean`},complementUpper:{short:`C`,type:`boolean`},delete:{short:`d`,long:`delete`,type:`boolean`},squeeze:{short:`s`,long:`squeeze-repeats`,type:`boolean`}},QJ={name:`tr`,async execute(e,t){if(oV(e))return aV(YJ);let n=lV(`tr`,e,ZJ);if(!n.ok)return n.error;let r=n.result.flags.complement||n.result.flags.complementUpper,i=n.result.flags.delete,a=n.result.flags.squeeze,o=n.result.positional;if(o.length<1)return{stdout:``,stderr:`tr: missing operand `,exitCode:1};if(!i&&!a&&o.length<2)return{stdout:``,stderr:`tr: missing operand after SET1 `,exitCode:1};let s,c,l=Math.min(t.limits.maxInputBytes,t.limits.maxStringLength),u=t.limits.maxLoopIterations,d=t.limits.maxArrayElements,f=Math.min(t.limits.maxOutputSize,t.limits.maxStringLength);try{let e={iterations:0};s=JJ(o[0],l,u,e),c=o.length>1?JJ(o[1],l,u,e):``}catch(e){return rV(e),{stdout:``,stderr:`${vH(e.message)} `,exitCode:1}}if(t.stdin.length>l)throw new H(`tr: input size limit exceeded (${l} bytes)`,`string_length`);let p=yB(t.stdin);if(s.length>d||c.length>d)throw new H(`tr: array element limit exceeded (${d})`,`array_elements`);let m=new Set(s),h=new Set(c),g=e=>{let t=m.has(e);return r?!t:t},_=``,v=0,y=e=>{let t=V(e);if(t>f-v)throw new H(`tr: output size limit exceeded (${f} bytes)`,`output_size`);_+=e,v+=t};if(i)for(let e of p)g(e)||y(e);else if(a&&o.length===1){let e=``;for(let t of p)g(t)&&t===e||(y(t),e=t)}else{let e=``,t=t=>{a&&h.has(t)&&t===e||(y(t),e=t)};if(r){let e=c.length>0?c[c.length-1]:``;for(let n of p)m.has(n)?t(n):t(e)}else{let e=new Map;for(let t=0;trY,rev:()=>nY});function UCe(e){return Array.from(e).reverse().join(``)}var tY,nY,rY,WCe=B(()=>{AB(),cV(),tY={name:`rev`,summary:`reverse lines characterwise`,usage:`rev [file ...]`,description:`Copies the specified files to standard output, reversing the order of characters in every line. If no files are specified, standard input is read.`,examples:[`echo 'hello' | rev # Output: olleh`,`rev file.txt # Reverse each line in file`]},nY={name:`rev`,execute:async(e,t)=>{if(oV(e))return aV(tY);let n=[];for(let t of e)if(t===`--`){let r=e.indexOf(t);n.push(...e.slice(r+1));break}else{if(t.startsWith(`-`)&&t!==`-`)return sV(`rev`,t);n.push(t)}let r=``,i=e=>{let t=e.split(` `),n=e.endsWith(` `)&&t[t.length-1]===``;return n&&t.pop(),t.map(UCe).join(` `)+(n?` `:``)};if(n.length===0)r=i(yB(t.stdin)??``);else for(let e of n)if(e===`-`){let e=yB(t.stdin)??``;r+=i(e)}else{let n=t.fs.resolvePath(t.cwd,e),a=await t.fs.readFile(n);if(a===null)return{exitCode:1,stdout:r,stderr:`rev: ${e}: No such file or directory `};r+=i(a)}return{exitCode:0,stdout:r,stderr:``}}},rY={name:`rev`,flags:[],stdinType:`text`,needsFiles:!0}}),iY={};Tz(iY,{flagsForFuzzing:()=>cY,nl:()=>sY});function GCe(e,t,n){let r=String(e);switch(t){case`ln`:return r.padEnd(n);case`rn`:return r.padStart(n);case`rz`:return r.padStart(n,`0`);default:return t}}function KCe(e,t){switch(t){case`a`:return!0;case`t`:return e.trim().length>0;case`n`:return!1;default:return t}}function aY(e,t,n,r){if(e===``)return{output:``,nextNumber:n};let i=e.split(` `),a=[],o=0,s=n,c=e.endsWith(` `)&&i[i.length-1]===``;c&&i.pop();for(let e of i){let n=+(a.length>0),i=V(t.separator)+V(e);if(KCe(e,t.bodyStyle)){let c=Math.max(String(s).length,t.width)+i+n;if(c>r-o)throw new H(`nl: output size limit exceeded (${r} bytes)`,`output_size`);let l=`${GCe(s,t.numberFormat,t.width)}${t.separator}${e}`;a.push(l),o+=c,s+=t.increment}else{let s=t.width+i+n;if(s>r-o)throw new H(`nl: output size limit exceeded (${r} bytes)`,`output_size`);let c=`${` `.repeat(t.width)}${t.separator}${e}`;a.push(c),o+=s}}if(c&&o+1>r)throw new H(`nl: output size limit exceeded (${r} bytes)`,`output_size`);return{output:a.join(` `)+(c?` `:``),nextNumber:s}}var oY,sY,cY,qCe=B(()=>{AB(),U(),cV(),oY={name:`nl`,summary:`number lines of files`,usage:`nl [OPTION]... [FILE]...`,description:`Write each FILE to standard output, with line numbers added. If no FILE is specified, standard input is read.`,options:[`-b STYLE Body numbering style: a (all), t (non-empty), n (none)`,`-n FORMAT Number format: ln (left), rn (right), rz (right zeros)`,`-w WIDTH Number width (default: 6)`,`-s SEP Separator after number (default: TAB)`,`-v START Starting line number (default: 1)`,`-i INCR Line number increment (default: 1)`],examples:[`nl file.txt # Number non-empty lines`,`nl -ba file.txt # Number all lines`,`nl -n rz -w 3 file.txt # Right-justified with zeros`,`nl -s ': ' file.txt # Use ': ' as separator`]},sY={name:`nl`,execute:async(e,t)=>{if(oV(e))return aV(oY);let n={bodyStyle:`t`,numberFormat:`rn`,width:6,separator:` `,startNumber:1,increment:1},r=[],i=Math.min(t.limits.maxStringLength,t.limits.maxOutputSize),a=i,o=0;for(;oi)return{exitCode:1,stdout:``,stderr:`nl: invalid line number field width: '${e[o+1]}' `};n.width=t,o+=2}else if(t.startsWith(`-w`)){let e=/^\d+$/.test(t.slice(2))?Number(t.slice(2)):NaN;if(!Number.isSafeInteger(e)||e<1||e>i)return{exitCode:1,stdout:``,stderr:`nl: invalid line number field width: '${t.slice(2)}' `};n.width=e,o++}else if(t===`-s`&&o+1pY,fold:()=>fY});function JCe(e,t,n){return n?V(e):e===` `?8-t%8:e===`\b`?-1:1}function YCe(e,t){if(e.length===0)return e;let{width:n,breakAtSpaces:r,countBytes:i}=t,a=[],o=``,s=0,c=-1,l=0;for(let t of e){let e=JCe(t,s,i);s+e>n&&o.length>0?r&&c>=0?(a.push(o.slice(0,c+1)),o=o.slice(c+1)+t,s=s-l-1+e,c=-1,l=0):(a.push(o),o=t,s=e,c=-1,l=0):(o+=t,s+=e,(t===` `||t===` `)&&(c=o.length-1,l=s-e))}return o.length>0&&a.push(o),a.join(` `)}function uY(e,t){if(e===``)return``;let n=e.split(` `),r=e.endsWith(` `)&&n[n.length-1]===``;return r&&n.pop(),n.map(e=>YCe(e,t)).join(` `)+(r?` `:``)}var dY,fY,pY,XCe=B(()=>{AB(),cV(),dY={name:`fold`,summary:`wrap each input line to fit in specified width`,usage:`fold [OPTION]... [FILE]...`,description:`Wrap input lines in each FILE, writing to standard output. If no FILE is specified, standard input is read.`,options:[`-w WIDTH Use WIDTH columns instead of 80`,`-s Break at spaces`,`-b Count bytes rather than columns`],examples:[`fold -w 40 file.txt # Wrap at 40 columns`,`fold -sw 40 file.txt # Word wrap at 40 columns`,`echo 'long line' | fold -w 5 # Force wrap at 5`]},fY={name:`fold`,execute:async(e,t)=>{if(oV(e))return aV(dY);let n={width:80,breakAtSpaces:!1,countBytes:!1},r=[],i=0;for(;i2){let e=parseInt(t.slice(2),10);if(Number.isNaN(e)||e<1)return{exitCode:1,stdout:``,stderr:`fold: invalid number of columns: '${t.slice(2)}' `};n.width=e,i++}else if(t===`-s`)n.breakAtSpaces=!0,i++;else if(t===`-b`)n.countBytes=!0,i++;else if(t===`-bs`||t===`-sb`)n.breakAtSpaces=!0,n.countBytes=!0,i++;else if(t.match(/^-[sb]+w\d+$/)){t.includes(`s`)&&(n.breakAtSpaces=!0),t.includes(`b`)&&(n.countBytes=!0);let e=t.replace(/^-[sb]+w/,``),r=parseInt(e,10);if(Number.isNaN(r)||r<1)return{exitCode:1,stdout:``,stderr:`fold: invalid number of columns: '${e}' `};n.width=r,i++}else if(t.match(/^-[sb]+w$/)&&i+1vY,flagsForFuzzing:()=>yY});function hY(e,t,n){let r=e.split(`,`).map(e=>e.trim());if(r.length>n)return null;let i=[];for(let e of r){let n=/^\d+$/.test(e)?Number(e):NaN;if(!Number.isSafeInteger(n)||n<1||n>t)return null;i.push(n)}for(let e=1;ee)return n-e;if(t.length>=2){let n=t[t.length-1]-t[t.length-2],r=t[t.length-1];return r+(Math.floor((e-r)/n)+1)*n-e}return 1}function QCe(e,t,n){let{tabStops:r,leadingOnly:i}=t,a=``,o=0,s=!0,c=0;for(let t of e)if(t===` `){if(i&&!s){if(c+1>n)throw new H(`expand: output size limit exceeded (${n} bytes)`,`output_size`);a+=t,c++,o++}else{let e=ZCe(o,r);if(e>n-c)throw new H(`expand: output size limit exceeded (${n} bytes)`,`output_size`);a+=` `.repeat(e),c+=e,o+=e}}else{t!==` `&&t!==` `&&(s=!1);let e=V(t);if(e>n-c)throw new H(`expand: output size limit exceeded (${n} bytes)`,`output_size`);a+=t,c+=e,o++}return a}function gY(e,t,n){if(e===``)return``;let r=e.split(` `),i=e.endsWith(` `)&&r[r.length-1]===``;i&&r.pop();let a=[],o=0;for(let e of r){let r=+(a.length>0),i=QCe(e,t,n-o-r);o+=r+V(i),a.push(i)}if(i&&o+1>n)throw new H(`expand: output size limit exceeded (${n} bytes)`,`output_size`);return a.join(` `)+(i?` `:``)}var _Y,vY,yY,$Ce=B(()=>{AB(),U(),cV(),ZB(),_Y={name:`expand`,summary:`convert tabs to spaces`,usage:`expand [OPTION]... [FILE]...`,description:`Convert TABs in each FILE to spaces, writing to standard output. If no FILE is specified, standard input is read.`,options:[`-t N Use N spaces per tab (default: 8)`,`-t LIST Use comma-separated list of tab stops`,`-i Only convert leading tabs on each line`],examples:[`expand file.txt # Convert all tabs to 8 spaces`,`expand -t 4 file.txt # Use 4-space tabs`,`expand -t 4,8,12 file.txt # Custom tab stops`]},vY={name:`expand`,execute:async(e,t)=>{if(oV(e))return aV(_Y);let n={tabStops:[8],leadingOnly:!1},r=[],i=Math.min(t.limits.maxStringLength,t.limits.maxOutputSize),a=t.limits.maxArrayElements,o=0;for(;o2){let e=hY(t.slice(2),i,a);if(!e)return{exitCode:1,stdout:``,stderr:`expand: invalid tab size: '${t.slice(2)}' `};n.tabStops=e,o++}else if(t===`--tabs`&&o+1EY,unexpand:()=>TY});function xY(e){let t=e.split(`,`).map(e=>e.trim()),n=[];for(let e of t){let t=parseInt(e,10);if(Number.isNaN(t)||t<1)return null;n.push(t)}for(let e=1;ee)return n;if(t.length>=2){let n=t[t.length-1]-t[t.length-2],r=t[t.length-1];return r+(Math.floor((e-r)/n)+1)*n}return-1}function ewe(e,t){let{tabStops:n,allBlanks:r}=t,i=``,a=0,o=``,s=0,c=!0,l=()=>{if(o.length===0)return;let e=s+o.length;if(!r&&!c){i+=o,o=``;return}let t=s,a=``;for(;tt)a+=` `,t=r;else break}let l=e-t;l>0&&(a+=` `.repeat(l)),i+=a,o=``};for(let t of e)t===` `?(o.length===0&&(s=a),o+=t,a++):t===` `?(l(),i+=t,a=SY(a,n)):(l(),i+=t,a++,c=!1);return l(),i}function CY(e,t){if(e===``)return``;let n=e.split(` `),r=e.endsWith(` `)&&n[n.length-1]===``;return r&&n.pop(),n.map(e=>ewe(e,t)).join(` `)+(r?` `:``)}var wY,TY,EY,twe=B(()=>{AB(),cV(),wY={name:`unexpand`,summary:`convert spaces to tabs`,usage:`unexpand [OPTION]... [FILE]...`,description:`Convert blanks in each FILE to TABs, writing to standard output. If no FILE is specified, standard input is read.`,options:[`-t N Use N spaces per tab (default: 8)`,`-t LIST Use comma-separated list of tab stops`,`-a Convert all sequences of blanks (not just leading)`],examples:[`unexpand file.txt # Convert leading spaces to tabs`,`unexpand -a file.txt # Convert all space sequences`,`unexpand -t 4 file.txt # Use 4-space tabs`]},TY={name:`unexpand`,execute:async(e,t)=>{if(oV(e))return aV(wY);let n={tabStops:[8],allBlanks:!1},r=[],i=0;for(;i2){let e=xY(t.slice(2));if(!e)return{exitCode:1,stdout:``,stderr:`unexpand: invalid tab size: '${t.slice(2)}' `};n.tabStops=e,i++}else if(t===`--tabs`&&i+1MY,strings:()=>jY});function nwe(e){return e>=32&&e<=126||e===9}function OY(e,t){if(t===null)return``;switch(t){case`o`:return`${e.toString(8).padStart(7,` `)} `;case`x`:return`${e.toString(16).padStart(7,` `)} `;case`d`:return`${e.toString(10).padStart(7,` `)} `;default:return t}}function kY(e,t,n,r=!1,i){let a=[],o=0,s=0,c=typeof e==`string`&&!r?new TextEncoder().encode(e):e;if(c.length>n.maxStringLength-n.inputBytes)throw new H(`strings: aggregate input size limit exceeded (${n.maxStringLength} bytes)`,`string_length`);n.inputBytes+=c.length;let l=new TextDecoder,u=(e,t)=>typeof c==`string`?c.slice(e,t):l.decode(c.subarray(e,t)),d=e=>{if(++n.iterations>n.maxIterations)throw new H(`strings: iteration limit exceeded (${n.maxIterations})`,`iterations`);if(n.resultCount>=n.maxArrayElements)throw new H(`strings: array element limit exceeded (${n.maxArrayElements})`,`array_elements`);let t=e.length+1;if(t>n.maxOutputSize-n.outputBytes)throw new H(`strings: output size limit exceeded (${n.maxOutputSize} bytes)`,`output_size`);a.push(e),n.resultCount++,n.outputBytes+=t};for(let e=0;e=n.maxStringLength)throw new H(`strings: string length limit exceeded (${n.maxStringLength} bytes)`,`string_length`);o++}else o>=t.minLength&&d(`${OY(s,t.offsetFormat)}${u(s,e)}`),o=0}return o>=t.minLength&&d(`${OY(s,t.offsetFormat)}${u(s,c.length)}`),a}var AY,jY,MY,rwe=B(()=>{U(),cV(),AY={name:`strings`,summary:`print the sequences of printable characters in files`,usage:`strings [OPTION]... [FILE]...`,description:`For each FILE, print the printable character sequences that are at least MIN characters long. If no FILE is specified, standard input is read.`,options:[`-n MIN Print sequences of at least MIN characters (default: 4)`,`-t FORMAT Print offset before each string (o=octal, x=hex, d=decimal)`,`-a Scan the entire file (default behavior)`,`-e ENCODING Select character encoding (s=7-bit, S=8-bit)`],examples:[`strings file.bin # Extract strings (min 4 chars)`,`strings -n 8 file.bin # Extract strings (min 8 chars)`,`strings -t x file.bin # Show hex offset`,`echo 'hello' | strings # Read from stdin`]},jY={name:`strings`,execute:async(e,t)=>{if(oV(e))return aV(AY);let n={minLength:4,offsetFormat:null},r=[],i=0;for(;it.stdin;if(r.length===0){let e=kY(s(),n,o,!0,t.signal);a=e.length>0?`${e.join(` `)} `:``}else for(let e of r){let r;if(e===`-`)r=s();else{let n=t.fs.resolvePath(t.cwd,e);try{r=await t.fs.readFileBuffer(n)}catch{return{exitCode:1,stdout:a,stderr:`strings: ${e}: No such file or directory `}}}let i=kY(r,n,o,typeof r==`string`,t.signal);i.length>0&&(a+=`${i.join(` `)} `)}return{exitCode:0,stdout:a,stderr:``}}},MY={name:`strings`,flags:[{flag:`-n`,type:`value`,valueHint:`number`},{flag:`-t`,type:`value`,valueHint:`string`},{flag:`-a`,type:`boolean`},{flag:`-e`,type:`value`,valueHint:`string`}],stdinType:`text`,needsFiles:!0}}),NY={};Tz(NY,{flagsForFuzzing:()=>HY,split:()=>VY});function iwe(e){return Uint8Array.from(e,e=>e.charCodeAt(0))}function PY(e){let t=e.match(/^(\d+)([KMGTPEZY]?)([B]?)$/i);if(!t)return null;let n=Number(t[1]);if(!Number.isSafeInteger(n)||n<1)return null;let r=(t[2]||``).toUpperCase(),i=new Map([[``,1],[`K`,1024],[`M`,1048576],[`G`,1073741824],[`T`,1099511627776],[`P`,0x4000000000000]]).get(r);return i===void 0||n>Math.floor((2**53-1)/i)?null:n*i}function FY(e){if(!/^[0-9]+$/.test(e))return null;let t=Number(e);return Number.isSafeInteger(t)&&t>=1?t:null}function awe(e,t,n){if(t)return e.toString().padStart(n,`0`);let r=Array(n),i=e;for(let e=n-1;e>=0;e--)r[e]=`abcdefghijklmnopqrstuvwxyz`[i%26],i=Math.floor(i/26);return r.join(``)}function owe(e,t){let n=[],r=0,i=0;for(let a=0;a{AB(),iV(),OH(),U(),cV(),RY={name:`split`,summary:`split a file into pieces`,usage:`split [OPTION]... [FILE [PREFIX]]`,description:`Output pieces of FILE to PREFIXaa, PREFIXab, ...; default size is 1000 lines, and default PREFIX is 'x'.`,options:[`-l N Put N lines per output file`,`-b SIZE Put SIZE bytes per output file (K, M, G suffixes)`,`-n CHUNKS Split into CHUNKS equal-sized files`,`-d Use numeric suffixes (00, 01, ...) instead of alphabetic`,`-a LENGTH Use suffixes of length LENGTH (default: 2)`,`--additional-suffix=SUFFIX Append SUFFIX to file names`],examples:[`split -l 100 file.txt # Split into 100-line chunks`,`split -b 1M file.bin # Split into 1MB chunks`,`split -n 5 file.txt # Split into 5 equal parts`,`split -d file.txt part_ # part_00, part_01, ...`,`split -a 3 -d file.txt x # x000, x001, ...`]},zY=1e5,BY=0,VY={name:`split`,execute:async(e,t)=>{if(oV(e))return aV(RY);let n={mode:`lines`,lines:1e3,bytes:0,chunks:0,useNumericSuffix:!1,suffixLength:2,additionalSuffix:``},r=[],i=0;for(;iMath.min(t.limits.maxStringLength,t.limits.maxArrayElements))return{exitCode:1,stdout:``,stderr:`split: invalid suffix length: '${e[i+1]}' `};n.suffixLength=r,i+=2}else if(a.match(/^-a\d+$/)){let e=FY(a.slice(2));if(e===null||e>Math.min(t.limits.maxStringLength,t.limits.maxArrayElements))return{exitCode:1,stdout:``,stderr:`split: invalid suffix length: '${a.slice(2)}' `};n.suffixLength=e,i++}else if(a===`-d`||a===`--numeric-suffixes`)n.useNumericSuffix=!0,i++;else if(a.startsWith(`--additional-suffix=`))n.additionalSuffix=a.slice(20),i++;else if(a===`--additional-suffix`&&i+1=1&&(a=r[0]),r.length>=2&&(o=r[1]),r.length>2)return{exitCode:1,stdout:``,stderr:`split: extra operand '${r[2]}' `};if(V(o)>t.limits.maxStringLength||V(n.additionalSuffix)>t.limits.maxStringLength||n.suffixLength>t.limits.maxStringLength-Math.min(t.limits.maxStringLength,V(o))-Math.min(t.limits.maxStringLength,V(n.additionalSuffix)))return{exitCode:1,stdout:``,stderr:`split: output filename exceeds configured string limit `};let s,c=null,l;if(a===`-`){let e=t.stdin.length;l=t.executionScope?.reserveBytes(`split transaction`,e*2,`split`),s=iwe(t.stdin)}else{c=t.fs.resolvePath(t.cwd,a);try{let e=await t.fs.stat(c);if(l=t.executionScope?.reserveBytes(`split transaction`,e.size*2,`split`),s=await t.fs.readFileBuffer(c),s.byteLength>e.size)throw new H(`split: input grew while being read`,`string_length`);t.executionScope?.consumeInput(s.byteLength,`split`)}catch(e){return l?.release(),rV(e),{exitCode:1,stdout:``,stderr:`split: ${a}: No such file or directory `}}}try{if(s.length===0)return{exitCode:0,stdout:``,stderr:``};if(n.mode===`chunks`&&n.chunks>zY)return{exitCode:1,stdout:``,stderr:`split: too many output files (${n.chunks}), limit is ${zY} `};let e;switch(n.mode){case`lines`:e=owe(s,n.lines);break;case`bytes`:e=swe(s,n.bytes);break;case`chunks`:e=cwe(s,n.chunks);break;default:return n.mode}if(e.length>zY)return{exitCode:1,stdout:``,stderr:`split: too many output files (${e.length}), limit is ${zY} `};let r=lwe(n.useNumericSuffix,n.suffixLength);if(e.length>r)return{exitCode:1,stdout:``,stderr:`split: output file suffixes exhausted at ${r} files `};t.executionScope?.consumeWork(e.length*n.suffixLength,`split suffix generation`);let i=[],a=new Set,l=c?await SH(t.fs,c):null;if(l?.existence===`unknown`)return{exitCode:1,stdout:``,stderr:`split: cannot safely identify input file `};for(let r=0;r{}),void 0)}catch{for(let e of[...i].reverse())e.committed&&await t.fs.rm(e.path,{force:!0,recursive:!0}).catch(()=>{}),e.backupPath&&await t.fs.mv(e.backupPath,e.path).catch(()=>{}),e.stagePath&&await t.fs.rm(e.stagePath,{force:!0,recursive:!0}).catch(()=>{});return{exitCode:1,stdout:``,stderr:`split: failed to write output `}}return{exitCode:0,stdout:``,stderr:``}}finally{l?.release()}}},HY={name:`split`,flags:[{flag:`-l`,type:`value`,valueHint:`number`},{flag:`-b`,type:`value`,valueHint:`string`},{flag:`-n`,type:`value`,valueHint:`number`},{flag:`-d`,type:`boolean`},{flag:`-a`,type:`value`,valueHint:`number`}],needsFiles:!0}}),UY={};Tz(UY,{column:()=>qY,flagsForFuzzing:()=>JY});function WY(e,t,n,r){return t?n?e.split(t,r):e.split(t,r).filter(e=>e.length>0):n?e.split(/[ \t]/,r):e.split(/[ \t]+/,r).filter(e=>e.length>0)}function fwe(e){let t=[];for(let n of e)for(let e=0;et[e])&&(t[e]=r)}return t}function pwe(e,t,n){if(e.length===0)return``;let r=fwe(e),i=new sH(n,`column`,void 0,1);for(let n=0;n0&&i.append(` `);for(let e=0;e0&&i.append(t),i.append(a[e]),e0&&l.append(` `);let r=!1;for(let a=0;a=e.length?(r&&l.append(n),l.append(e[o])):(r&&l.append(n),l.append(e[o]),l.repeat(` `,i-e[o].length)),r=!0)}}return l.build()}var GY,KY,qY,JY,hwe=B(()=>{cH(),AB(),U(),uV(),cV(),GY={name:`column`,summary:`columnate lists`,usage:`column [OPTION]... [FILE]...`,description:`Format input into multiple columns. By default, fills rows first. Use -t to create a table based on whitespace-delimited input.`,options:[`-t Create a table (determine columns from input)`,`-s SEP Input field delimiter (default: whitespace)`,`-o SEP Output field delimiter (default: two spaces)`,`-c WIDTH Output width for fill mode (default: 80)`,`-n Don't merge multiple adjacent delimiters`],examples:[`ls | column # Fill columns with ls output`,`cat data | column -t # Format as table`,`column -t -s ',' file # Format CSV as table`,`column -c 40 file # Fill 40-char wide columns`]},KY={table:{short:`t`,long:`table`,type:`boolean`},separator:{short:`s`,type:`string`},outputSep:{short:`o`,type:`string`},width:{short:`c`,type:`number`,default:80},noMerge:{short:`n`,type:`boolean`}},qY={name:`column`,execute:async(e,t)=>{if(oV(e))return aV(GY);let n=lV(`column`,e,KY);if(!n.ok)return n.error;let{table:r,separator:i,outputSep:a,width:o,noMerge:s}=n.result.flags,c=n.result.positional,l=a??` `,u=Math.min(t.limits.maxInputBytes,t.limits.maxStringLength),d=t.limits.maxArrayElements,f=Math.min(t.limits.maxStringLength,t.limits.maxOutputSize);if(!Number.isFinite(o)||!Number.isSafeInteger(o)||o<=0||o>10485760)return{exitCode:1,stdout:``,stderr:`column: invalid width: ${o} `};let p;if(c.length===0)p=yB(t.stdin)??``;else{let e=[],n=0;for(let r of c)if(r===`-`){let r=yB(t.stdin)??``;if(n+=V(r),n>u)throw new H(`column: input size limit exceeded (${u} bytes)`,`string_length`);e.push(r)}else{let i=t.fs.resolvePath(t.cwd,r),a=await t.fs.readFile(i);if(a===null)return{exitCode:1,stdout:``,stderr:`column: ${r}: No such file or directory `};if(n+=V(a),n>u)throw new H(`column: input size limit exceeded (${u} bytes)`,`string_length`);e.push(a)}p=e.join(``)}if(V(p)>u)throw new H(`column: input size limit exceeded (${u} bytes)`,`string_length`);if(p===``||p.trim()===``)return{exitCode:0,stdout:``,stderr:``};let m=p.split(` `,d+1);if(m.length>d)throw new H(`column: field limit exceeded (${d})`,`array_elements`);p.endsWith(` `)&&m[m.length-1]===``&&m.pop();let h=m.filter(e=>e.trim().length>0),g;if(r){let e=[],t=0;for(let n of h){let r=WY(n,i,s,d-t+1);if(t+=r.length,t>d)throw new H(`column: field limit exceeded (${d})`,`array_elements`);e.push(r)}g=pwe(e,l,f)}else{let e=[];for(let t of h){let n=d-e.length,r=WY(t,i,s,n+1);if(r.length>n)throw new H(`column: field limit exceeded (${d})`,`array_elements`);for(let t of r)e.push(t)}g=mwe(e,o,l,f)}return g.length>0&&(g+=` `),{exitCode:0,stdout:g,stderr:``}}},JY={name:`column`,flags:[{flag:`-t`,type:`boolean`},{flag:`-s`,type:`value`,valueHint:`delimiter`},{flag:`-o`,type:`value`,valueHint:`string`},{flag:`-c`,type:`value`,valueHint:`number`},{flag:`-n`,type:`boolean`}],stdinType:`text`,needsFiles:!0}}),YY={};Tz(YY,{flagsForFuzzing:()=>$Y,join:()=>QY});function gwe(e,t){return t?e.split(t):e.split(/[ \t]+/).filter(e=>e.length>0)}function _we(e,t,n,r){let i=gwe(e,t),a=i[n-1]??``;return r&&(a=a.toLowerCase()),{fields:i,joinKey:a,original:e}}function XY(e,t,n){let r=n.separator??` `;if(n.outputFormat){let i=[];for(let{file:r,field:a}of n.outputFormat){let o=r===1?e:t;o&&a===0?i.push(o.joinKey):o&&o.fields[a-1]!==void 0?i.push(o.fields[a-1]):i.push(n.emptyString)}return i.join(r)}let i=[],a=e?.joinKey??t?.joinKey??``;if(i.push(a),e)for(let t=0;t{AB(),U(),cV(),ZB(),ZY={name:`join`,summary:`join lines of two files on a common field`,usage:`join [OPTION]... FILE1 FILE2`,description:`For each pair of input lines with identical join fields, write a line to standard output. The default join field is the first, delimited by blanks.`,options:[`-1 FIELD Join on this FIELD of file 1 (default: 1)`,`-2 FIELD Join on this FIELD of file 2 (default: 1)`,`-t CHAR Use CHAR as input and output field separator`,`-a FILENUM Also print unpairable lines from file FILENUM (1 or 2)`,`-v FILENUM Like -a but only output unpairable lines`,`-e STRING Replace missing fields with STRING`,`-o FORMAT Output format (comma-separated list of FILENUM.FIELD)`,`-i Ignore case when comparing fields`],examples:[`join file1 file2 # Join on first field`,`join -1 2 -2 1 file1 file2 # Join file1 col 2 with file2 col 1`,`join -t ',' file1.csv file2.csv # Join CSV files`,`join -a 1 file1 file2 # Left outer join`]},QY={name:`join`,execute:async(e,t)=>{if(oV(e))return aV(ZY);let n={field1:1,field2:1,separator:null,printUnpairable:new Set,onlyUnpairable:new Set,emptyString:``,outputFormat:null,ignoreCase:!1},r=[],i=0;for(;i2)n.separator=t.slice(2),i++;else if(t===`-a`&&i+1e+V(t),0)>c)throw new H(`join: aggregate input size limit exceeded (${c} bytes)`,`string_length`);let u=0,d=0,f=()=>{if(++d>s)throw new H(`join: iteration limit exceeded (${s})`,`iterations`)},p=(e,t)=>{let r=+(e.length>0);for(let t=0;to-u)throw new H(`join: array element limit exceeded (${o})`,`array_elements`);u+=r;let i=e.split(` `);return e.endsWith(` `)&&i[i.length-1]===``&&i.pop(),i.filter(e=>e.length>0).map(e=>_we(e,n.separator,t,n.ignoreCase))},m=p(a[0],n.field1),h=p(a[1],n.field2),g=new Map;for(let e of h){let t=g.get(e.joinKey);t?t.push(e):g.set(e.joinKey,[e])}let _=[],v=0,y=e=>{if(f(),_.length>=o)throw new H(`join: array element limit exceeded (${o})`,`array_elements`);let t=V(e)+1;if(t>l-v)throw new H(`join: output size limit exceeded (${l} bytes)`,`output_size`);_.push(e),v+=t},b=new Set;for(let e of m){let t=g.get(e.joinKey);if(t&&t.length>0){if(b.add(e.joinKey),n.onlyUnpairable.size===0)for(let r of t)y(XY(e,r,n))}else(n.printUnpairable.has(1)||n.onlyUnpairable.has(1))&&y(XY(e,null,n))}if(n.printUnpairable.has(2)||n.onlyUnpairable.has(2))for(let e of h)b.has(e.joinKey)||y(XY(null,e,n));return{exitCode:0,stdout:bB(_.length>0?`${_.join(` `)} `:``),stderr:``,stdoutEncoding:`binary`}}},$Y={name:`join`,flags:[{flag:`-1`,type:`value`,valueHint:`number`},{flag:`-2`,type:`value`,valueHint:`number`},{flag:`-t`,type:`value`,valueHint:`delimiter`},{flag:`-a`,type:`value`,valueHint:`number`},{flag:`-v`,type:`value`,valueHint:`number`},{flag:`-e`,type:`value`,valueHint:`string`},{flag:`-o`,type:`value`,valueHint:`format`},{flag:`-i`,type:`boolean`}],needsArgs:!0,minArgs:2}}),eX={};Tz(eX,{flagsForFuzzing:()=>iX,teeCommand:()=>rX});var tX,nX,rX,iX,bwe=B(()=>{AB(),uV(),cV(),tX={name:`tee`,summary:`read from stdin and write to stdout and files`,usage:`tee [OPTION]... [FILE]...`,options:[`-a, --append append to the given FILEs, do not overwrite`,` --help display this help and exit`]},nX={append:{short:`a`,long:`append`,type:`boolean`}},rX={name:`tee`,async execute(e,t){if(oV(e))return aV(tX);let n=lV(`tee`,e,nX);if(!n.ok)return n.error;let{append:r}=n.result.flags,i=n.result.positional,a=t.stdin,o=``,s=0;for(let e of i)try{let n=t.fs.resolvePath(t.cwd,e);r?await t.fs.appendFile(n,a,`binary`):await t.fs.writeFile(n,a,`binary`)}catch{o+=`tee: ${e}: No such file or directory `,s=1}return{stdout:a,stderr:o,exitCode:s,stdoutEncoding:`binary`}}},iX={name:`tee`,flags:[{flag:`-a`,type:`boolean`}],stdinType:`text`,needsArgs:!0}}),aX,oX=B(()=>{AB(),U(),aX=class{scope;site;stdoutChunks=[];stderrChunks=[];stdoutBytes=0;stderrBytes=0;attachedErrors=new WeakSet;constructor(e,t){this.scope=e,this.site=t}append(e,t,n=0,r=`text`){let i;try{i=this.scope.appendOutput(e,t,this.site,n,r)}catch(e){throw this.prependTo(e),e}t&&(e===`stdout`?this.stdoutChunks:this.stderrChunks).push(t),e===`stdout`?this.stdoutBytes+=i:this.stderrBytes+=i}prependTo(e){e instanceof MB&&(this.attachedErrors.has(e)||(this.attachedErrors.add(e),e.prependOutput(this.stdout,this.stderr)))}appendResult(e,t=e.stdout){let n=e.stdoutKind===`bytes`||e.stdoutEncoding===`binary`?`bytes`:`text`,r=n===`bytes`?t.length:V(t);this.append(`stdout`,t,Math.min(e.internalOutputAccounting?.stdout??0,r),n),this.append(`stderr`,e.stderr,e.internalOutputAccounting?.stderr??0)}build(e,t){return{stdout:this.stdoutChunks.join(``),stderr:this.stderrChunks.join(``),exitCode:e,...t,internalOutputAccounting:{stdout:this.stdoutBytes,stderr:this.stderrBytes}}}get stdout(){return this.stdoutChunks.join(``)}get stderr(){return this.stderrChunks.join(``)}}});function sX(e,t){switch(e.type){case`name`:{let n=e.pattern,r=n.match(/^\*(\.[a-zA-Z0-9]+)$/);if(r){let n=r[1],i=t.name;if(e.ignoreCase){if(!i.toLowerCase().endsWith(n.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!i.endsWith(n))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:xG(t.name,n,e.ignoreCase),pruned:!1,printed:!1}}case`path`:{let n=e.pattern,r=t.relativePath,i=n.split(`/`);for(let t=0;te.days:e.comparison===`less`?nn,pruned:!1,printed:!1}}case`size`:{let n=e.value;switch(e.unit){case`c`:n=e.value;break;case`k`:n=e.value*1024;break;case`M`:n=e.value*1024*1024;break;case`G`:n=e.value*1024*1024*1024;break;case`b`:n=e.value*512}let r;return r=e.comparison===`more`?t.size>n:e.comparison===`less`?t.size{e&&(e.type===`newer`?t.push(e.refPath):e.type===`not`?n(e.expr):(e.type===`and`||e.type===`or`)&&(n(e.left),n(e.right)))};return n(e),t}function uX(e){if(!e)return!0;switch(e.type){case`name`:case`path`:case`regex`:case`type`:case`prune`:return!0;case`action`:return!1;case`empty`:case`mtime`:case`newer`:case`size`:case`perm`:return!1;case`not`:return uX(e.expr);case`and`:case`or`:return uX(e.left)&&uX(e.right)}}function dX(e,t,n,r,i){switch(e.type){case`name`:{let n=e.pattern,r=n.match(/^\*(\.[a-zA-Z0-9]+)$/);if(r){let n=r[1];if(e.ignoreCase){if(!t.toLowerCase().endsWith(n.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!t.endsWith(n))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:xG(t,n,e.ignoreCase),pruned:!1,printed:!1}}case`path`:{let t=e.pattern,r=t.split(`/`);for(let t=0;t{bG(),wG()});function wwe(e,t){let n=[],r=t,i=e=>({expr:null,pathIndex:r,error:`find: missing argument to \`${e}' `}),a=(e,t)=>({expr:null,pathIndex:r,error:`find: invalid argument \`${t}' to \`${e}' `});for(;r=e.length)return i(t);n.push({type:`expr`,expr:{type:`name`,pattern:e[++r]}})}else if(t===`-iname`){if(r+1>=e.length)return i(t);n.push({type:`expr`,expr:{type:`name`,pattern:e[++r],ignoreCase:!0}})}else if(t===`-path`){if(r+1>=e.length)return i(t);n.push({type:`expr`,expr:{type:`path`,pattern:e[++r]}})}else if(t===`-ipath`){if(r+1>=e.length)return i(t);n.push({type:`expr`,expr:{type:`path`,pattern:e[++r],ignoreCase:!0}})}else if(t===`-regex`){if(r+1>=e.length)return i(t);n.push({type:`expr`,expr:{type:`regex`,pattern:e[++r]}})}else if(t===`-iregex`){if(r+1>=e.length)return i(t);n.push({type:`expr`,expr:{type:`regex`,pattern:e[++r],ignoreCase:!0}})}else if(t===`-type`){if(r+1>=e.length)return i(t);let a=e[++r];if(a===`f`||a===`d`)n.push({type:`expr`,expr:{type:`type`,fileType:a}});else return{expr:null,pathIndex:r,error:`find: Unknown argument to -type: ${a} `}}else if(t===`-empty`)n.push({type:`expr`,expr:{type:`empty`}});else if(t===`-mtime`){if(r+1>=e.length)return i(t);let o=e[++r],s=`exact`,c=o;if(o.startsWith(`+`)?(s=`more`,c=o.slice(1)):o.startsWith(`-`)&&(s=`less`,c=o.slice(1)),!/^\d+$/.test(c))return a(t,o);let l=Number(c);if(!Number.isSafeInteger(l))return a(t,o);n.push({type:`expr`,expr:{type:`mtime`,days:l,comparison:s}})}else if(t===`-newer`){if(r+1>=e.length)return i(t);let a=e[++r];n.push({type:`expr`,expr:{type:`newer`,refPath:a}})}else if(t===`-size`){if(r+1>=e.length)return i(t);let o=e[++r],s=`exact`,c=o;o.startsWith(`+`)?(s=`more`,c=o.slice(1)):o.startsWith(`-`)&&(s=`less`,c=o.slice(1));let l=c.match(/^(\d+)([ckMGb])?$/);if(!l)return a(t,o);let u=Number(l[1]);if(!Number.isSafeInteger(u))return a(t,o);let d=l[2]||`b`,f=d===`G`?1024**3:d===`M`?1024**2:d===`k`?1024:d===`b`?512:1;if(!Number.isSafeInteger(u*f))return a(t,o);n.push({type:`expr`,expr:{type:`size`,value:u,unit:d,comparison:s}})}else if(t===`-perm`){if(r+1>=e.length)return i(t);let o=e[++r],s=`exact`,c=o;if(o.startsWith(`-`)?(s=`all`,c=o.slice(1)):o.startsWith(`/`)&&(s=`any`,c=o.slice(1)),!/^[0-7]{1,4}$/.test(c))return a(t,o);let l=Number.parseInt(c,8);n.push({type:`expr`,expr:{type:`perm`,mode:l,matchType:s}})}else if(t===`-prune`)n.push({type:`expr`,expr:{type:`prune`}});else if(t===`-not`||t===`!`)n.push({type:`not`});else if(t===`-o`||t===`-or`)n.push({type:`op`,op:`or`});else if(t===`-a`||t===`-and`)n.push({type:`op`,op:`and`});else if(t===`-maxdepth`||t===`-mindepth`){if(r+1>=e.length)return i(t);r++}else if(t!==`-depth`){if(t===`-exec`){let t=[];for(r++;r=e.length)return{expr:null,pathIndex:r,error:`find: missing argument to \`-exec' `};if(t.length===0)return i(`-exec`);let o=e[r]===`+`;if(o&&(t.at(-1)!==`{}`||t.filter(e=>e===`{}`).length!==1))return a(`-exec`,`+`);n.push({type:`expr`,expr:{type:`action`,action:{type:`exec`,command:t,batchMode:o}}})}else if(t===`-print`)n.push({type:`expr`,expr:{type:`action`,action:{type:`print`}}});else if(t===`-print0`)n.push({type:`expr`,expr:{type:`action`,action:{type:`print0`}}});else if(t===`-printf`){if(r+1>=e.length)return i(t);let a=e[++r];n.push({type:`expr`,expr:{type:`action`,action:{type:`printf`,format:a}}})}else if(t===`-delete`)n.push({type:`expr`,expr:{type:`action`,action:{type:`delete`}}});else return t.startsWith(`-`)?{expr:null,pathIndex:r,error:`find: unknown predicate '${t}' `}:{expr:null,pathIndex:r,error:`find: paths must precede expression: \`${t}' `}}r++}if(n.length===0)return{expr:null,pathIndex:r};let o=Twe(n);return o.error?{expr:null,pathIndex:r,error:o.error}:{expr:o.expr,pathIndex:r}}function Twe(e){let t=0,n;function r(){let r=i();if(!r)return null;for(;t=e.length)return null;let i=e[t];if(i.type===`lparen`){t++;let i=r();return!i||t>=e.length||e[t].type!==`rparen`?(n=`find: missing closing \`)' `,null):(t++,i)}return i.type===`expr`?(t++,i.expr):(i.type,null)}let s=r();return!n&&t{}),gX={};Tz(gX,{findCommand:()=>bX,flagsForFuzzing:()=>xX});function Dwe(){return{readdirCalls:0,readdirTime:0,statCalls:0,statTime:0,evalCalls:0,evalTime:0,nodeCount:0,batchCount:0,batchTime:0,earlyPrunes:0}}function Owe(e,t,n){e({category:`find`,name:`summary`,durationMs:n,details:{readdirCalls:t.readdirCalls,readdirTimeMs:t.readdirTime,statCalls:t.statCalls,statTimeMs:t.statTime,evalCalls:t.evalCalls,evalTimeMs:t.evalTime,nodeCount:t.nodeCount,batchCount:t.batchCount,batchTimeMs:t.batchTime,earlyPrunes:t.earlyPrunes,otherTimeMs:n-t.readdirTime-t.statTime-t.evalTime-t.batchTime}})}function _X(e){return e?e.type===`action`?[e.action]:e.type===`not`?_X(e.expr):e.type===`and`||e.type===`or`?[..._X(e.left),..._X(e.right)]:[]:[]}function kwe(e,t){let n=YB(e),r=``,i=0;for(;i=n.length){r+=`%`;break}let s=n[i],c;switch(s){case`f`:c=t.name,i++;break;case`h`:{let e=t.path.lastIndexOf(`/`);c=e>0?t.path.slice(0,e):`.`,i++;break}case`p`:c=t.path,i++;break;case`P`:{let e=t.startingPoint;c=t.path===e?``:t.path.startsWith(`${e}/`)?t.path.slice(e.length+1):e===`.`&&t.path.startsWith(`./`)?t.path.slice(2):t.path,i++;break}case`s`:c=String(t.size),i++;break;case`d`:c=String(t.depth),i++;break;case`m`:c=(t.mode&511).toString(8),i++;break;case`M`:c=iW(t.mode,t.isDirectory),i++;break;case`t`:c=Awe(new Date(t.mtime)),i++;break;case`T`:if(i+1{AB(),oX(),OH(),hK(),U(),aW(),cV(),ZB(),Cwe(),Ewe(),vX=500,yX={name:`find`,summary:`search for files in a directory hierarchy`,usage:`find [path...] [expression]`,options:`-name PATTERN file name matches shell pattern PATTERN.-iname PATTERN like -name but case insensitive.-path PATTERN file path matches shell pattern PATTERN.-ipath PATTERN like -path but case insensitive.-regex PATTERN file path matches regular expression PATTERN.-iregex PATTERN like -regex but case insensitive.-type TYPE file is of type: f (regular file), d (directory).-empty file is empty or directory is empty.-mtime N file's data was modified N*24 hours ago.-newer FILE file was modified more recently than FILE.-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks).-perm MODE file's permission bits are exactly MODE (octal).-perm -MODE all permission bits MODE are set.-perm /MODE any permission bits MODE are set.-maxdepth LEVELS descend at most LEVELS directories.-mindepth LEVELS do not apply tests at levels less than LEVELS.-depth process directory contents before directory itself.-prune do not descend into this directory.-not, ! negate the following expression.-a, -and logical AND (default).-o, -or logical OR.-exec CMD {} ; execute CMD on each file ({} is replaced by filename).-exec CMD {} + execute CMD with multiple files at once.-print print the full file name (default action).-print0 print the full file name followed by a null character.-printf FORMAT print FORMAT with directives: %f %h %p %P %s %d %m %M %t.-delete delete found files/directories. --help display this help and exit`.split(`.`)},bX={name:`find`,async execute(e,t){if(oV(e))return aV(yX);let n=[],r=null,i=null,a=!1,o=e.length;for(let t=0;t0;l.some(e=>e.type===`delete`)&&(a=!0);let d=[],f=0,p=t.executionScope?new aX(t.executionScope,`find`):void 0,m=[],h=[],g=0,_=new DH({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:`find`}),v=e=>{if(p)p.append(`stdout`,e);else{let n=V(e);if(n>t.limits.maxOutputSize-g)throw new H(`find: output size limit exceeded (${t.limits.maxOutputSize} bytes)`,`output_size`);e&&m.push(e),g+=n}},y=e=>{if(p)p.append(`stderr`,e);else{let n=V(e);if(n>t.limits.maxOutputSize-g)throw new H(`find: output size limit exceeded (${t.limits.maxOutputSize} bytes)`,`output_size`);e&&h.push(e),g+=n}},b=xwe(s),x=new Map;for(let e of b){let n=t.fs.resolvePath(t.cwd,e);try{let r=await t.fs.stat(n);x.set(e,r.mtime?.getTime()??Date.now())}catch{}}let S=l.some(e=>{if(e.type!==`printf`)return!1;let t=e.format.replace(/%%/g,``);return/%[-+]?[0-9]*\.?[0-9]*(s|m|M|t|T)/.test(t)}),C=cX(s)||S,w=lX(s),T=fX(s),E=uX(s),D=typeof t.fs.readdirWithFileTypes==`function`;for(let e of n){let n=function(t){if(!(i===null||t.depth>=i))return[];let n=!0,r=[];if(s!==null){let e=Date.now(),i;if(E)i=dX(s,t.name,t.relativePath,t.isFile,t.isDirectory);else{let e={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:t.isEmpty,mtime:t.stat?.mtime?.getTime()??Date.now(),size:t.stat?.size??0,mode:t.stat?.mode??420,newerRefTimes:x};i=sX(s,e)}n=i.matches,r=i.actions??[],c.evalCalls++,c.evalTime+=Date.now()-e}if(!u&&n&&(r=[{type:`print`}]),r.length===0)return[];let a={path:t.relativePath,name:t.name,size:t.stat?.size??0,mtime:t.stat?.mtime?.getTime()??Date.now(),mode:t.stat?.mode??420,isDirectory:t.isDirectory,depth:t.depth,startingPoint:e};_.checkpoint(r.length);let o=[];for(let e of r)o.push({action:e,path:t.relativePath,printfData:a});return o};e.length>1&&e.endsWith(`/`)&&(e=e.slice(0,-1));let o=t.fs.resolvePath(t.cwd,e);try{await t.fs.stat(o)}catch{y(`find: ${e}: No such file or directory `),f=1;continue}let c=Dwe(),l=Date.now();async function p(n){let{path:i,depth:l,typeInfo:u}=n;if(_.visit(l),c.nodeCount++,l>(r??t.limits.maxTraversalDepth))return null;let d,f,p;if(u&&!C)d=u.isFile,f=u.isDirectory;else{try{let e=Date.now();p=await t.fs.lstat(i),c.statCalls++,c.statTime+=Date.now()-e}catch{return null}if(!p)return null;d=p.isFile,f=p.isDirectory}let m;m=i===o?e.split(`/`).pop()||e:i.split(`/`).pop()||``;let h=i===o?e:e===`.`?`./${i.slice(o===`/`?o.length:o.length+1)}`:e+i.slice(o.length),g=[],v=null,y=null,b=!1;f&&T&&!a&&(b=Swe(s,{name:m,relativePath:h,isFile:d,isDirectory:f}).shouldPrune,b&&c.earlyPrunes++);let S=!(l>=(r??t.limits.maxTraversalDepth))&&!b;if(f&&(S||w)&&!b){let e=Date.now();if(D&&t.fs.readdirWithFileTypes){v=await t.fs.readdirWithFileTypes(i),_.checkpoint(),_.discover(v.length),y=[];for(let e of v)y.push(e.name);if(c.readdirCalls++,c.readdirTime+=Date.now()-e,S)for(let e=0;ep(e.item)));c.batchCount++,c.batchTime+=Date.now()-e;for(let e=0;e=0){let e=i.get(a.parentIndex)||[];e.push(c),i.set(a.parentIndex,e)}t.push({node:n,parentIndex:a.parentIndex,childIndices:[]});for(let e=0;e=0&&e0){let r=[{index:0,visited:!1}];for(;r.length>0;){_.checkpoint();let i=r.pop();if(!i)break;let a=t[i.index];if(a){if(i.visited){for(let t of n(a.node))e.effects.push(t);continue}r.push({index:i.index,visited:!0});for(let e=a.childIndices.length-1;e>=0;e--)r.push({index:a.childIndices[e],visited:!1})}}}}else{let t=new Map,r=0,i=[{item:{path:o,depth:0,resultIndex:0},orderIndex:r++}],a=new Map,s=0;for(;s{let n=await p(e);return n?{node:n,orderIndex:t}:null}));c.batchCount++,c.batchTime+=Date.now()-e;for(let e of u){if(!e)continue;let{node:o,orderIndex:s}=e,c=n(o);if(c.length>0&&t.set(s,c),o.children.length>0){let e=[];for(let t of o.children){let n=r++;e.push(n),i.push({item:t,orderIndex:n})}a.set(s,e)}}}let l=[0];for(;l.length>0;){_.checkpoint();let n=l.pop();if(n===void 0)break;let r=t.get(n);if(r)for(let t of r)e.effects.push(t);let i=a.get(n);if(i)for(let e=i.length-1;e>=0;e--)l.push(i[e])}}return e}let h=await m();for(let e of h.effects)d.push(e);if(t.trace){let n=Date.now()-l;Owe(t.trace,c,n),t.trace({category:`find`,name:`searchPath`,durationMs:n,details:{path:e,resultsFound:h.effects.length}})}}let O=new Map;for(let e of d){let{action:n,path:r}=e;switch(n.type){case`print`:v(`${r} `);break;case`print0`:v(`${r}\0`);break;case`printf`:v(kwe(n.format,e.printfData));break;case`delete`:{let e=t.fs.resolvePath(t.cwd,r);try{await t.fs.rm(e,{recursive:!1})}catch(e){y(`find: cannot delete '${r}': ${e instanceof Error?e.message:String(e)} `),f=1}break}case`exec`:{if(!t.exec)return{stdout:``,stderr:`find: -exec not supported in this context `,exitCode:1};if(n.batchMode){let e=O.get(n)??[];e.push(r),O.set(n,e);break}let e=n.command.map(e=>e===`{}`?r:e),i=await t.exec(mK([e[0]]),{cwd:t.cwd,signal:t.signal,args:e.slice(1)});p?p.appendResult(i):(v(i.stdout),y(i.stderr)),i.exitCode!==0&&(f=i.exitCode);break}}}for(let[e,n]of O){if(e.type!==`exec`||!t.exec||n.length===0)continue;let r=[];for(let t of e.command)t===`{}`?r.push(...n):r.push(t);let i=await t.exec(mK([r[0]]),{cwd:t.cwd,signal:t.signal,args:r.slice(1)});p?p.appendResult(i):(v(i.stdout),y(i.stderr)),i.exitCode!==0&&(f=i.exitCode)}return p?.build(f)??{stdout:m.join(``),stderr:h.join(``),exitCode:f}}},xX={name:`find`,flags:[{flag:`-name`,type:`value`,valueHint:`pattern`},{flag:`-iname`,type:`value`,valueHint:`pattern`},{flag:`-type`,type:`value`,valueHint:`string`},{flag:`-maxdepth`,type:`value`,valueHint:`number`},{flag:`-mindepth`,type:`value`,valueHint:`number`},{flag:`-empty`,type:`boolean`},{flag:`-print`,type:`boolean`},{flag:`-print0`,type:`boolean`}],needsFiles:!0}}),SX={};Tz(SX,{basenameCommand:()=>wX,flagsForFuzzing:()=>TX});var CX,wX,TX,Nwe=B(()=>{cV(),CX={name:`basename`,summary:`strip directory and suffix from filenames`,usage:`basename NAME [SUFFIX] basename OPTION... NAME...`,options:[`-a, --multiple support multiple arguments`,`-s, --suffix=SUFFIX remove a trailing SUFFIX`,` --help display this help and exit`]},wX={name:`basename`,async execute(e,t){if(oV(e))return aV(CX);let n=!1,r=``,i=[];for(let t=0;t=2&&(r=i.pop()??``);let a=[];for(let e of i){let t=e.replace(/\/+$/,``),n=t.split(`/`).pop()||t;r&&n.endsWith(r)&&(n=n.slice(0,-r.length)),a.push(n)}return{stdout:`${a.join(` `)} `,stderr:``,exitCode:0}}},TX={name:`basename`,flags:[{flag:`-a`,type:`boolean`},{flag:`-s`,type:`value`,valueHint:`string`}],needsArgs:!0}}),EX={};Tz(EX,{dirnameCommand:()=>OX,flagsForFuzzing:()=>kX});var DX,OX,kX,Pwe=B(()=>{cV(),DX={name:`dirname`,summary:`strip last component from file name`,usage:`dirname [OPTION] NAME...`,options:[` --help display this help and exit`]},OX={name:`dirname`,async execute(e,t){if(oV(e))return aV(DX);let n=e.filter(e=>!e.startsWith(`-`));if(n.length===0)return{stdout:``,stderr:`dirname: missing operand `,exitCode:1};let r=[];for(let e of n){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);n===-1?r.push(`.`):n===0?r.push(`/`):r.push(t.slice(0,n))}return{stdout:`${r.join(` `)} `,stderr:``,exitCode:0}}},kX={name:`dirname`,flags:[],needsArgs:!0}}),AX={};Tz(AX,{flagsForFuzzing:()=>FX,treeCommand:()=>PX});async function Fwe(e,t,n,r,i){let a={output:``,stderr:``,dirCount:0,fileCount:0},o=e.fs.resolvePath(e.cwd,t);try{if(!(await e.fs.stat(o)).isDirectory)return a.output=`${t} `,a.fileCount=1,a}catch{return a.stderr=`tree: ${t}: No such file or directory `,a}if(a.output=`${t} `,n.maxDepth!==null&&i>=n.maxDepth)return a;try{let t=[];if(e.fs.readdirWithFileTypes)t=(await e.fs.readdirWithFileTypes(o)).map(e=>({name:e.name,isDirectory:e.isDirectory}));else{let n=await e.fs.readdir(o);for(let r=0;r{let n=o===`/`?`/${t}`:`${o}/${t}`;try{return{name:t,isDirectory:(await e.fs.stat(n)).isDirectory}}catch{return null}}));t.push(...a.filter(e=>e!==null))}}let s=t.filter(e=>!(!n.showHidden&&e.name.startsWith(`.`)||n.directoriesOnly&&!e.isDirectory));s.sort((e,t)=>e.name.localeCompare(t.name));for(let t=0;t=n.maxDepth)return a;try{let o=[];if(e.fs.readdirWithFileTypes)o=(await e.fs.readdirWithFileTypes(t)).map(e=>({name:e.name,isDirectory:e.isDirectory}));else{let n=await e.fs.readdir(t);for(let r=0;r{let r=t===`/`?`/${n}`:`${t}/${n}`;try{return{name:n,isDirectory:(await e.fs.stat(r)).isDirectory}}catch{return null}}));o.push(...a.filter(e=>e!==null))}}let s=o.filter(e=>!(!n.showHidden&&e.name.startsWith(`.`)||n.directoriesOnly&&!e.isDirectory));s.sort((e,t)=>e.name.localeCompare(t.name));for(let o=0;o{uV(),dV(),cV(),MX={name:`tree`,summary:`list contents of directories in a tree-like format`,usage:`tree [OPTION]... [DIRECTORY]...`,options:[`-a include hidden files`,`-d list directories only`,`-L LEVEL limit depth of directory tree`,`-f print full path prefix for each file`,` --help display this help and exit`]},NX={showHidden:{short:`a`,type:`boolean`},directoriesOnly:{short:`d`,type:`boolean`},fullPath:{short:`f`,type:`boolean`},maxDepth:{short:`L`,type:`number`}},PX={name:`tree`,async execute(e,t){if(oV(e))return aV(MX);let n=lV(`tree`,e,NX);if(!n.ok)return n.error;let r={showHidden:n.result.flags.showHidden,directoriesOnly:n.result.flags.directoriesOnly,maxDepth:n.result.flags.maxDepth??null,fullPath:n.result.flags.fullPath},i=n.result.positional;i.length===0&&i.push(`.`);let a=``,o=``,s=0,c=0;for(let e of i){let n=await Fwe(t,e,r,``,0);a+=n.output,o+=n.stderr,s+=n.dirCount,c+=n.fileCount}return a+=` ${s} director${s===1?`y`:`ies`}`,r.directoriesOnly||(a+=`, ${c} file${c===1?``:`s`}`),a+=` `,{stdout:a,stderr:o,exitCode:+!!o}}},FX={name:`tree`,flags:[{flag:`-a`,type:`boolean`},{flag:`-d`,type:`boolean`},{flag:`-f`,type:`boolean`},{flag:`-L`,type:`value`,valueHint:`number`}],needsFiles:!0}}),IX={};Tz(IX,{duCommand:()=>BX,flagsForFuzzing:()=>VX});async function Lwe(e,t,n,r,i){let a={output:``,totalSize:0,stderr:``},o=new Map;return await TH({fs:e.fs,root:t,limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:`du`,symlinks:`never`,includeLeave:!0},e=>{let s=e.path.slice(t.length).replace(/^\//,``),c=s?n===`.`?s:`${n}/${s}`:n,l=e.path===`/`?`/`:e.path.slice(0,e.path.lastIndexOf(`/`))||`/`;if(e.phase===`enter`){if(e.stat.isDirectory){o.set(e.path,0);return}o.set(l,(o.get(l)??0)+e.stat.size),(r.allFiles||e.depth===i)&&!r.summarize&&(a.output+=`${LX(e.stat.size,r.humanReadable)} ${c} `),e.depth===i&&(a.totalSize=e.stat.size);return}let u=o.get(e.path)??0;e.depth>i?o.set(l,(o.get(l)??0)+u):a.totalSize=u;let d=e.depth-i;(r.summarize&&d===0||!r.summarize&&(r.maxDepth===null||d<=r.maxDepth))&&(a.output+=`${LX(u,r.humanReadable)} ${c} `)}),a}function LX(e,t){return t?e<1024?`${e}`:e<1048576?`${(e/1024).toFixed(1)}K`:e<1073741824?`${(e/1048576).toFixed(1)}M`:`${(e/1073741824).toFixed(1)}G`:String(Math.ceil(e/1024)||1)}var RX,zX,BX,VX,Rwe=B(()=>{OH(),U(),uV(),cV(),RX={name:`du`,summary:`estimate file space usage`,usage:`du [OPTION]... [FILE]...`,options:[`-a write counts for all files, not just directories`,`-h print sizes in human readable format`,`-s display only a total for each argument`,`-c produce a grand total`,`--max-depth=N print total for directory only if N or fewer levels deep`,` --help display this help and exit`]},zX={allFiles:{short:`a`,type:`boolean`},humanReadable:{short:`h`,type:`boolean`},summarize:{short:`s`,type:`boolean`},grandTotal:{short:`c`,type:`boolean`},maxDepth:{long:`max-depth`,type:`number`}},BX={name:`du`,async execute(e,t){if(oV(e))return aV(RX);let n=lV(`du`,e,zX);if(!n.ok)return n.error;let r={allFiles:n.result.flags.allFiles,humanReadable:n.result.flags.humanReadable,summarize:n.result.flags.summarize,grandTotal:n.result.flags.grandTotal,maxDepth:n.result.flags.maxDepth??null},i=n.result.positional;i.length===0&&i.push(`.`);let a=``,o=``,s=0;for(let e of i){let n=t.fs.resolvePath(t.cwd,e);try{await t.fs.stat(n);let i=await Lwe(t,n,e,r,0);a+=i.output,s+=i.totalSize,o+=i.stderr}catch(t){if(t instanceof H||t instanceof UB)throw t;o+=`du: cannot access '${e}': No such file or directory `}}return r.grandTotal&&i.length>0&&(a+=`${LX(s,r.humanReadable)} total `),{stdout:a,stderr:o,exitCode:+!!o}}},VX={name:`du`,flags:[{flag:`-a`,type:`boolean`},{flag:`-h`,type:`boolean`},{flag:`-s`,type:`boolean`},{flag:`-c`,type:`boolean`},{flag:`--max-depth`,type:`value`,valueHint:`number`}],needsFiles:!0}}),HX={};Tz(HX,{envCommand:()=>WX,flagsForFuzzing:()=>qX,printenvCommand:()=>KX,printenvFlagsForFuzzing:()=>JX});var UX,WX,GX,KX,qX,JX,YX=B(()=>{AB(),tq(),cV(),UX={name:`env`,summary:`run a program in a modified environment`,usage:`env [OPTION]... [NAME=VALUE]... [COMMAND [ARG]...]`,options:[`-i, --ignore-environment start with an empty environment`,`-u NAME, --unset=NAME remove NAME from the environment`,` --help display this help and exit`]},WX={name:`env`,async execute(e,t){if(oV(e))return aV(UX);let n=!1,r=[],i=new Map,a=-1;for(let t=0;t0?` `:``),stderr:``,exitCode:0}}if(!t.exec)return{stdout:``,stderr:`env: command execution not supported in this context `,exitCode:1};let s=e.slice(a);return t.exec(`command`,{cwd:t.cwd,env:QK(o),replaceEnv:!0,stdin:t.stdin,stdinKind:`bytes`,signal:t.signal,args:s})}},GX={name:`printenv`,summary:`print all or part of environment`,usage:`printenv [OPTION]... [VARIABLE]...`,options:[` --help display this help and exit`]},KX={name:`printenv`,async execute(e,t){if(oV(e))return aV(GX);let n=e.filter(e=>!e.startsWith(`-`));if(n.length===0){let e=[];for(let[n,r]of t.env)e.push(`${n}=${r}`);return{stdout:e.join(` `)+(e.length>0?` `:``),stderr:``,exitCode:0}}let r=[],i=0;for(let e of n){let n=t.env.get(e);n===void 0?i=1:r.push(n)}return{stdout:r.join(` `)+(r.length>0?` `:``),stderr:``,exitCode:i}}},qX={name:`env`,flags:[{flag:`-i`,type:`boolean`},{flag:`-u`,type:`value`,valueHint:`string`}]},JX={name:`printenv`,flags:[]}}),XX={};Tz(XX,{aliasCommand:()=>$X,flagsForFuzzing:()=>tZ,unaliasCommand:()=>eZ,unaliasFlagsForFuzzing:()=>nZ});var ZX,QX,$X,eZ,tZ,nZ,rZ=B(()=>{cV(),ZX={name:`alias`,summary:`define or display aliases`,usage:`alias [name[=value] ...]`,options:[` --help display this help and exit`]},QX=`BASH_ALIAS_`,$X={name:`alias`,async execute(e,t){if(oV(e))return aV(ZX);if(e.length===0){let e=``;for(let[n,r]of t.env)if(n.startsWith(QX)){let t=n.slice(QX.length);e+=`alias ${t}='${r}' `}return{stdout:e,stderr:``,exitCode:0}}let n=e[0]===`--`?e.slice(1):e;for(let e of n){let n=e.indexOf(`=`);if(n===-1){let n=QX+e;return t.env.get(n)?{stdout:`alias ${e}='${t.env.get(n)}' `,stderr:``,exitCode:0}:{stdout:``,stderr:`alias: ${e}: not found `,exitCode:1}}{let r=e.slice(0,n),i=e.slice(n+1);(i.startsWith(`'`)&&i.endsWith(`'`)||i.startsWith(`"`)&&i.endsWith(`"`))&&(i=i.slice(1,-1)),t.env.set(QX+r,i)}}return{stdout:``,stderr:``,exitCode:0}}},eZ={name:`unalias`,async execute(e,t){if(oV(e))return aV({name:`unalias`,summary:`remove alias definitions`,usage:`unalias name [name ...]`,options:[`-a remove all aliases`,` --help display this help and exit`]});if(e.length===0)return{stdout:``,stderr:`unalias: usage: unalias [-a] name [name ...] `,exitCode:1};if(e[0]===`-a`){for(let e of t.env.keys())e.startsWith(QX)&&t.env.delete(e);return{stdout:``,stderr:``,exitCode:0}}let n=e[0]===`--`?e.slice(1):e,r=!1,i=``;for(let e of n){let n=QX+e;t.env.get(n)?t.env.delete(n):(i+=`unalias: ${e}: not found `,r=!0)}return{stdout:``,stderr:i,exitCode:+!!r}}},tZ={name:`alias`,flags:[]},nZ={name:`unalias`,flags:[{flag:`-a`,type:`boolean`}]}}),iZ={};Tz(iZ,{flagsForFuzzing:()=>cZ,historyCommand:()=>sZ});var aZ,oZ,sZ,cZ,zwe=B(()=>{cV(),aZ={name:`history`,summary:`display command history`,usage:`history [n]`,options:[`-c clear the history list`,` --help display this help and exit`]},oZ=`BASH_HISTORY`,sZ={name:`history`,async execute(e,t){if(oV(e))return aV(aZ);let n=t.env.get(oZ)||`[]`,r;try{r=JSON.parse(n)}catch{r=[]}if(e[0]===`-c`)return t.env.set(oZ,`[]`),{stdout:``,stderr:``,exitCode:0};let i=r.length;e[0]&&/^\d+$/.test(e[0])&&(i=Math.min(parseInt(e[0],10),r.length));let a=r.length-i,o=``;for(let e=a;epZ,xargsCommand:()=>fZ});function uZ(e,t,n){if(t.length===0)throw Error(`xargs: delimiter must not be empty`);let r=[],i=0;for(;i<=e.length;){let a=e.indexOf(t,i),o=e.slice(i,a===-1?e.length:a);if(o.length>0){if(r.length>=n)throw new H(`xargs: array element limit exceeded (${n})`,`array_elements`);r.push(o)}if(a===-1)break;i=a+t.length}return r}function Bwe(e,t){let n=[],r=-1;for(let i=0;i<=e.length;i++){let a=i===e.length||/\s/.test(e[i]);if(!a&&r===-1&&(r=i),a&&r!==-1){if(n.length>=t)throw new H(`xargs: array element limit exceeded (${t})`,`array_elements`);n.push(e.slice(r,i)),r=-1}}return n}var dZ,fZ,pZ,Vwe=B(()=>{AB(),oX(),hK(),U(),cV(),ZB(),dZ={name:`xargs`,summary:`build and execute command lines from standard input`,usage:`xargs [OPTION]... [COMMAND [INITIAL-ARGS]]`,options:[`-I REPLACE replace occurrences of REPLACE with input`,`-d DELIM use DELIM as input delimiter (e.g., -d '\\n' for newline)`,`-n NUM use at most NUM arguments per command line`,`-P NUM run at most NUM processes at a time`,`-0, --null items are separated by null, not whitespace`,`-t, --verbose print commands before executing`,`-r, --no-run-if-empty do not run command if input is empty`,` --help display this help and exit`]},fZ={name:`xargs`,async execute(e,t){if(oV(e))return aV(dZ);let n=null,r=null,i=null,a=null,o=!1,s=!1,c=0;for(let t=0;t1){for(let e of l.slice(1))if(!`0tr`.includes(e))return sV(`xargs`,`-${e}`);l.includes(`0`)&&(o=!0),l.includes(`t`)&&(s=!0),l.includes(`r`),c=t+1}else if(!l.startsWith(`-`)){c=t;break}}}let l=e.slice(c);l.length===0&&l.push(`echo`);let u=yB(t.stdin),d=Math.min(t.limits.maxInputBytes,t.limits.maxStringLength),f=t.limits.maxArrayElements,p=t.limits.maxLoopIterations,m=t.limits.maxOutputSize;if(V(u)>d)throw new H(`xargs: input size limit exceeded (${d} bytes)`,`string_length`);if(a!==null&&a>f)throw new H(`xargs: array element limit exceeded (${f})`,`array_elements`);let h;if(o)h=uZ(u,`\0`,f);else if(r!==null){let e=u.replace(/\n$/,``);try{h=uZ(e,r,f)}catch(e){if(e instanceof H)throw e;return{stdout:``,stderr:`xargs: delimiter must not be empty `,exitCode:1}}}else h=Bwe(u,f);if(h.length===0)return{stdout:``,stderr:``,exitCode:0};let g=[],_=[],v=0,y=0,b=0,x=t.executionScope?new aX(t.executionScope,`xargs`):void 0,S=e=>{if(x){x.appendResult(e);return}let t=V(e.stdout)+V(e.stderr);if(t>m-y)throw new H(`xargs: output size limit exceeded (${m} bytes)`,`output_size`);e.stdout&&g.push(e.stdout),e.stderr&&_.push(e.stderr),y+=t},C=e=>{if(x){x.append(`stderr`,e);return}let t=V(e);if(t>m-y)throw new H(`xargs: output size limit exceeded (${m} bytes)`,`output_size`);e&&_.push(e),y+=t},w=e=>/[\s"'\\$`!*?[\]{}();&|<>#]/.test(e)?`"${e.replace(/([\\"`$])/g,`\\$1`)}"`:e,T=async e=>{if(++b>p)throw new H(`xargs: iteration limit exceeded (${p})`,`iterations`);if(e.length>f)throw new H(`xargs: array element limit exceeded (${f})`,`array_elements`);for(let t of e)if(V(t)>d)throw new H(`xargs: string length limit exceeded (${d} bytes)`,`string_length`);if(s){let t=e.map(w).join(` `);C(`${t} `)}return t.exec?t.exec(mK([e[0]]),{cwd:t.cwd,signal:t.signal,args:e.slice(1)}):{stdout:`${e.map(w).join(` `)} `,stderr:``,exitCode:0}},E=async e=>{if(a!==null&&a>1)for(let t=0;tp)throw new H(`xargs: iteration limit exceeded (${p})`,`iterations`);if(n.length===0)return{stdout:``,stderr:`xargs: replacement string must not be empty `,exitCode:1};if(l.length>0&&h.length>Math.floor(f/l.length))throw new H(`xargs: array element limit exceeded (${f})`,`array_elements`);let e=(e,t)=>{let r=0,i=0;for(;i=e.indexOf(n,i),i!==-1;)r++,i+=n.length;if(V(e)+r*(V(t)-V(n))>d)throw new H(`xargs: string length limit exceeded (${d} bytes)`,`string_length`);return e.replaceAll(n,t)};await E(h.map(t=>l.map(n=>e(n,t))))}else if(i!==null){let e=[],t=Math.ceil(h.length/i);if(t>Math.min(f,p))throw new H(`xargs: iteration limit exceeded (${p})`,`iterations`);if(h.length+t*l.length>f)throw new H(`xargs: array element limit exceeded (${f})`,`array_elements`);for(let t=0;tgZ,falseFlagsForFuzzing:()=>vZ,flagsForFuzzing:()=>_Z,trueCommand:()=>hZ});var hZ,gZ,_Z,vZ,yZ=B(()=>{hZ={name:`true`,async execute(){return{stdout:``,stderr:``,exitCode:0}}},gZ={name:`false`,async execute(){return{stdout:``,stderr:``,exitCode:1}}},_Z={name:`true`,flags:[]},vZ={name:`false`,flags:[]}}),bZ={};Tz(bZ,{clearCommand:()=>SZ,flagsForFuzzing:()=>CZ});var xZ,SZ,CZ,Hwe=B(()=>{cV(),xZ={name:`clear`,summary:`clear the terminal screen`,usage:`clear [OPTIONS]`,options:[` --help display this help and exit`]},SZ={name:`clear`,async execute(e,t){return oV(e)?aV(xZ):{stdout:`\x1B[2J\x1B[H`,stderr:``,exitCode:0}}},CZ={name:`clear`,flags:[]}}),wZ={};Tz(wZ,{bashCommand:()=>DZ,flagsForFuzzing:()=>kZ,shCommand:()=>OZ,shFlagsForFuzzing:()=>AZ});async function TZ(e,t,n,r){if(!r.exec)return{stdout:``,stderr:`bash: internal error: exec function not available `,exitCode:1};let i=eq(r.exportedEnv||{},{0:t,"#":String(n.length),"@":n.join(` `),"*":n.join(` `)});n.forEach((e,t)=>{i[String(t+1)]=e});let a=e;if(a.startsWith(`#!`)){let e=a.indexOf(` `);e!==-1&&(a=a.slice(e+1))}let o=r.execWithInheritedStdin;return o?await o(a,{env:i,cwd:r.cwd,signal:r.signal}):await r.exec(a,{env:i,cwd:r.cwd,stdin:r.stdin,stdinKind:`bytes`,signal:r.signal})}var EZ,DZ,OZ,kZ,AZ,jZ=B(()=>{AB(),tq(),cV(),EZ={name:`bash`,summary:`execute shell commands or scripts`,usage:`bash [OPTIONS] [SCRIPT_FILE] [ARGUMENTS...]`,options:[`-c COMMAND execute COMMAND string`,` --help display this help and exit`],notes:[`Without -c, reads and executes commands from SCRIPT_FILE.`,`Arguments are passed as $1, $2, etc. to the script.`,`$0 is set to the script name (or "bash" with -c).`]},DZ={name:`bash`,async execute(e,t){if(oV(e))return aV(EZ);if(e[0]===`-c`&&e.length>=2){let n=e[1];return TZ(n,e[2]||`bash`,e.slice(3),t)}if(e.length===0){let e=yB(t.stdin);return e.trim()?TZ(e,`bash`,[],t):{stdout:``,stderr:``,exitCode:0}}let n=e[0],r=e.slice(1);try{let e=t.fs.resolvePath(t.cwd,n);return TZ(await t.fs.readFile(e),n,r,t)}catch{return{stdout:``,stderr:`bash: ${n}: No such file or directory `,exitCode:127}}}},OZ={name:`sh`,async execute(e,t){if(oV(e))return aV({...EZ,name:`sh`,summary:`execute shell commands or scripts (POSIX shell)`});if(e[0]===`-c`&&e.length>=2){let n=e[1];return TZ(n,e[2]||`sh`,e.slice(3),t)}if(e.length===0){let e=yB(t.stdin);return e.trim()?TZ(e,`sh`,[],t):{stdout:``,stderr:``,exitCode:0}}let n=e[0],r=e.slice(1);try{let e=t.fs.resolvePath(t.cwd,n);return TZ(await t.fs.readFile(e),n,r,t)}catch{return{stdout:``,stderr:`sh: ${n}: No such file or directory `,exitCode:127}}}},kZ={name:`bash`,flags:[{flag:`-c`,type:`value`,valueHint:`string`}],stdinType:`text`},AZ={name:`sh`,flags:[{flag:`-c`,type:`value`,valueHint:`string`}],stdinType:`text`}});function MZ(e,t,n=1){let r=e.limits.maxArrayElements;if(n<0||t>r-n)throw new H(`query result element limit exceeded (${r})`,`array_elements`)}function Uwe(e,t,n,r,i,a,o,s,c,l){switch(t){case`sort`:return Array.isArray(e)?[[...e].sort(o)]:[null];case`sort_by`:return!Array.isArray(e)||n.length===0?[null]:[[...e].sort((e,t)=>{let a=i(e,n[0],r)[0],s=i(t,n[0],r)[0];return o(a,s)})];case`bsearch`:if(!Array.isArray(e))throw Error(`${e===null?`null`:typeof e==`object`?`object`:typeof e} (${JSON.stringify(e)}) cannot be searched from`);return n.length===0?[null]:i(e,n[0],r).map(t=>{let n=0,r=e.length;for(;n>>1;o(e[i],t)<0?n=i+1:r=i}return no(e.key,t.key)),[a.map(e=>e.item)]}case`group_by`:{if(!Array.isArray(e)||n.length===0)return[null];let t=new Map;for(let a of e){let e=JSON.stringify(i(a,n[0],r)[0]);t.has(e)||t.set(e,[]),t.get(e)?.push(a)}return[[...t.values()]]}case`max`:return Array.isArray(e)&&e.length>0?[e.reduce((e,t)=>o(e,t)>0?e:t)]:[null];case`max_by`:return!Array.isArray(e)||e.length===0||n.length===0?[null]:[e.reduce((e,t)=>{let a=i(e,n[0],r)[0],s=i(t,n[0],r)[0];return o(a,s)>0?e:t})];case`min`:return Array.isArray(e)&&e.length>0?[e.reduce((e,t)=>o(e,t)<0?e:t)]:[null];case`min_by`:return!Array.isArray(e)||e.length===0||n.length===0?[null]:[e.reduce((e,t)=>{let a=i(e,n[0],r)[0],s=i(t,n[0],r)[0];return o(a,s)<0?e:t})];case`add`:{let t=e=>{let t=e.filter(e=>e!==null);return t.length===0?null:t.every(e=>typeof e==`number`)?t.reduce((e,t)=>e+t,0):t.every(e=>typeof e==`string`)?t.join(``):t.every(e=>Array.isArray(e))?t.flat():t.every(e=>e&&typeof e==`object`&&!Array.isArray(e))?eq(...t):null};return n.length>=1?[t(i(e,n[0],r))]:Array.isArray(e)?[t(e)]:[null]}case`any`:if(n.length>=2){try{let t=a(e,n[0],r);for(let e of t)if(i(e,n[1],r).some(s))return[!0]}catch(e){if(e instanceof l)throw e}return[!1]}return n.length===1?Array.isArray(e)?[e.some(e=>s(i(e,n[0],r)[0]))]:[!1]:Array.isArray(e)?[e.some(s)]:[!1];case`all`:if(n.length>=2){try{let t=a(e,n[0],r);for(let e of t)if(!i(e,n[1],r).some(s))return[!1]}catch(e){if(e instanceof l)throw e}return[!0]}return n.length===1?Array.isArray(e)?[e.every(e=>s(i(e,n[0],r)[0]))]:[!0]:Array.isArray(e)?[e.every(s)]:[!0];case`select`:return n.length===0||i(e,n[0],r).some(s)?[e]:[];case`map`:{if(n.length===0||!Array.isArray(e))return[null];MZ(r,0,e.length);let t=[];for(let a of e){let e=i(a,n[0],r);MZ(r,t.length,e.length);for(let n of e)t.push(n)}return[t]}case`map_values`:if(n.length===0)return[null];if(Array.isArray(e)){MZ(r,0,e.length);let t=[];for(let a of e){let e=i(a,n[0],r);MZ(r,t.length,e.length);for(let n of e)t.push(n)}return[t]}if(e&&typeof e==`object`){let t=Object.create(null),a=Object.keys(e);MZ(r,0,a.length);for(let o of a){if(!ZG(o))continue;let a=e[o],s=i(a,n[0],r);s.length>0&&QG(t,o,s[0])}return[t]}return[null];case`has`:{if(n.length===0)return[!1];let t=i(e,n[0],r)[0];return Array.isArray(e)&&typeof t==`number`?[t>=0&&t=0&&e{tq(),U(),aK()});function Gwe(e,t,n,r,i,a,o,s){switch(t){case`first`:if(n.length>0)try{let t=a(e,n[0],r);return t.length>0?[t[0]]:[]}catch(e){if(e instanceof s)throw e;return[]}return Array.isArray(e)&&e.length>0?[e[0]]:[null];case`last`:if(n.length>0){let t=i(e,n[0],r);return t.length>0?[t[t.length-1]]:[]}return Array.isArray(e)&&e.length>0?[e[e.length-1]]:[null];case`nth`:{if(n.length<1)return[null];let t=i(e,n[0],r);if(n.length>1){for(let e of t)if(e<0)throw Error(`nth doesn't support negative indices`);let i;try{i=a(e,n[1],r)}catch(e){if(e instanceof s)throw e;i=[]}return t.flatMap(e=>{let t=e;return t{let n=t;if(n<0)throw Error(`nth doesn't support negative indices`);return n{if(e.length>=t)throw new s(`query result element limit exceeded (${t})`,`array_elements`);e.push(n)},o=i(e,n[0],r);if(n.length===1){let e=[];for(let t of o){let n=t;for(let t=0;t0)for(let e=r;ei;e+=o)a(u,e)}}return u}case`limit`:return n.length<2?[]:i(e,n[0],r).flatMap(t=>{let i=t;if(i<0)throw Error(`limit doesn't support negative count`);if(i===0)return[];let o;try{o=a(e,n[1],r)}catch(e){if(e instanceof s)throw e;o=[]}return o.slice(0,i)});case`isempty`:if(n.length<1)return[!0];try{return[a(e,n[0],r).length===0]}catch(e){if(e instanceof s)throw e;return[!0]}case`isvalid`:if(n.length<1)return[!0];try{return[i(e,n[0],r).length>0]}catch(e){if(e instanceof s)throw e;return[!1]}case`skip`:return n.length<2?[]:i(e,n[0],r).flatMap(t=>{let a=t;if(a<0)throw Error(`skip doesn't support negative count`);return i(e,n[1],r).slice(a)});case`until`:{if(n.length<2)return[e];let t=e,a=r.limits.maxIterations;for(let e=0;e=c)throw new s(`jq while: too many iterations (${c}), increase executionLimits.maxJqIterations`,`iterations`);return t}case`repeat`:{if(n.length===0)return[e];let t=[],a=e,o=r.limits.maxIterations;for(let e=0;e=o)throw new s(`jq repeat: too many iterations (${o}), increase executionLimits.maxJqIterations`,`iterations`);return t}default:return null}}var Kwe=B(()=>{});function NZ(e,t){if(!Number.isFinite(e)||Math.abs(e)>864e10)throw Error(`${t} timestamp is outside the supported range`);return new Date(e*1e3)}function PZ(e){let t=e.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);if(!t)return null;let[,n,r,i,a,o,s]=t.map(Number),c=Date.UTC(n,r-1,i,a,o,s);if(!Number.isFinite(c))return null;let l=new Date(c);return l.getUTCFullYear()!==n||l.getUTCMonth()!==r-1||l.getUTCDate()!==i||l.getUTCHours()!==a||l.getUTCMinutes()!==o||l.getUTCSeconds()!==s?null:l}function qwe(e,t,n,r,i){switch(t){case`now`:return[Date.now()/1e3];case`gmtime`:{if(typeof e!=`number`)return[null];let t=NZ(e,`gmtime`),n=t.getUTCFullYear(),r=t.getUTCMonth(),i=t.getUTCDate(),a=t.getUTCHours(),o=t.getUTCMinutes(),s=t.getUTCSeconds(),c=t.getUTCDay(),l=Date.UTC(n,0,1);return[[n,r,i,a,o,s,c,Math.floor((t.getTime()-l)/864e5)]]}case`mktime`:{if(!Array.isArray(e))throw Error(`mktime requires parsed datetime inputs`);let[t,n,r,i=0,a=0,o=0]=e;if(typeof t!=`number`||typeof n!=`number`)throw Error(`mktime requires parsed datetime inputs`);return[Math.floor(Date.UTC(t,n,r??1,i??0,a??0,o??0)/1e3)]}case`strftime`:{if(n.length===0)return[null];let t=i(e,n[0],r)[0];if(typeof t!=`string`)throw Error(`strftime/1 requires a string format`);let a;if(typeof e==`number`)a=NZ(e,`strftime`);else if(Array.isArray(e)){let[t,n,r,i=0,o=0,s=0]=e;if(typeof t!=`number`||typeof n!=`number`)throw Error(`strftime/1 requires parsed datetime inputs`);a=new Date(Date.UTC(t,n,r??1,i??0,o??0,s??0))}else throw Error(`strftime/1 requires parsed datetime inputs`);let o=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],s=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],c=(e,t=2)=>String(e).padStart(t,`0`);return[t.replace(/%Y/g,String(a.getUTCFullYear())).replace(/%m/g,c(a.getUTCMonth()+1)).replace(/%d/g,c(a.getUTCDate())).replace(/%H/g,c(a.getUTCHours())).replace(/%M/g,c(a.getUTCMinutes())).replace(/%S/g,c(a.getUTCSeconds())).replace(/%A/g,o[a.getUTCDay()]).replace(/%B/g,s[a.getUTCMonth()]).replace(/%Z/g,`UTC`).replace(/%%/g,`%`)]}case`strptime`:{if(n.length===0)return[null];if(typeof e!=`string`)throw Error(`strptime/1 requires a string input`);let t=i(e,n[0],r)[0];if(typeof t!=`string`)throw Error(`strptime/1 requires a string format`);if(t!==FZ)throw Error(`strptime format is not supported: ${t}`);let a=PZ(e);if(a){let e=a.getUTCFullYear(),t=a.getUTCMonth(),n=a.getUTCDate(),r=a.getUTCHours(),i=a.getUTCMinutes(),o=a.getUTCSeconds(),s=a.getUTCDay(),c=Date.UTC(e,0,1);return[[e,t,n,r,i,o,s,Math.floor((a.getTime()-c)/864e5)]]}throw Error(`Cannot parse date: ${e}`)}case`fromdate`:{if(typeof e!=`string`)throw Error(`fromdate requires a string input`);let t=PZ(e);if(!t)throw Error(`date "${e}" does not match format "${FZ}"`);return[Math.floor(t.getTime()/1e3)]}case`todate`:if(typeof e!=`number`)throw Error(`todate requires a number input`);return[NZ(e,`todate`).toISOString().replace(/\.\d{3}Z$/,`Z`)];default:return null}}var FZ,Jwe=B(()=>{FZ=`%Y-%m-%dT%H:%M:%SZ`});function IZ(e){return e!==!1&&e!==null}function LZ(e,t){return JSON.stringify(e)===JSON.stringify(t)}function RZ(e,t){return typeof e==`number`&&typeof t==`number`?e-t:typeof e==`string`&&typeof t==`string`?e.localeCompare(t):0}function Ywe(e,t,n={}){let r=n.maxDepth??2e3,i=nK(e),a=[{target:i,source:t,depth:0}];for(;a.length>0;){let e=a.pop();if(!e)break;if(e.depth>r)throw new H(`query depth limit exceeded (${r})`,`recursion`);for(let t of Object.keys(e.source)){if(n.visit?.(),!ZG(t))continue;let r=$G(e.target,t)?tK(e.target[t]):null,i=tK(e.source[t]);if(r&&i){let n=nK(r);QG(e.target,t,n),a.push({target:n,source:i,depth:e.depth+1})}else QG(e.target,t,e.source[t])}}return i}function zZ(e,t=3e3){if(typeof e!=`object`||!e)return 0;if(t<=1)return t;let n=(e,t)=>({value:e,keys:Array.isArray(e)?void 0:Object.keys(e),nextChild:0,pathDepth:t,maxChildDepth:0}),r=e=>e.keys===void 0?e.value.length:e.keys.length,i=e=>{if(e.keys){let t=e.keys[e.nextChild++];return e.value[t]}return e.value[e.nextChild++]},a=new WeakMap,o=new WeakMap,s=e,c=[n(s,1)];for(a.set(s,`visiting`);c.length>0;){let e=c[c.length-1];if(e.nextChild=t)return t;e.maxChildDepth=Math.max(e.maxChildDepth,n);continue}let l=e.pathDepth+1;if(l>=t)return t;let u=r;a.set(r,`visiting`),c.push(n(u,l));continue}let s=e.maxChildDepth+1;o.set(e.value,s),a.set(e.value,`done`),c.pop();let l=c.at(-1);if(l)l.maxChildDepth=Math.max(l.maxChildDepth,s);else return s}return 0}function BZ(e,t){let n=e=>e===null?0:typeof e==`boolean`?1:typeof e==`number`?2:typeof e==`string`?3:Array.isArray(e)?4:typeof e==`object`?5:6,r=n(e),i=n(t);if(r!==i)return r-i;if(typeof e==`number`&&typeof t==`number`)return e-t;if(typeof e==`string`&&typeof t==`string`)return e.localeCompare(t);if(typeof e==`boolean`&&typeof t==`boolean`)return!!e-+!!t;if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;ne.some(e=>VZ(e,t)));let n=tK(e),r=tK(t);return n&&r?Object.keys(r).every(e=>$G(n,e)&&VZ(n[e],r[e])):!1}var HZ=B(()=>{U(),aK()});function Xwe(e){let t=[];for(let n=0;n{if(e===null)return``;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return String(e);let t=String(e);return t.includes(`,`)||t.includes(`"`)||t.includes(` `)||t.includes(`\r`)?`"${t.replace(/"/g,`""`)}"`:t}).join(`,`)]:[null];case`@tsv`:return Array.isArray(e)?[e.map(e=>String(e??``).replace(/\t/g,`\\t`).replace(/\n/g,`\\n`)).join(` `)]:[null];case`@json`:{let t=n??UZ;return zZ(e,t+1)>t?[null]:[JSON.stringify(e)]}case`@html`:return typeof e==`string`?[e.replace(/&/g,`&`).replace(//g,`>`).replace(/'/g,`'`).replace(/"/g,`"`)]:[null];case`@sh`:return typeof e==`string`?[`'${e.replace(/'/g,`'\\''`)}'`]:[null];case`@text`:return typeof e==`string`?[e]:e==null?[``]:[String(e)];default:return null}}var UZ,$we=B(()=>{HZ(),UZ=2e3});function eTe(e,t,n,r,i,a){switch(t){case`index`:return n.length===0?[null]:i(e,n[0],r).map(t=>{if(typeof e==`string`&&typeof t==`string`){if(t===``&&e===``)return null;let n=e.indexOf(t);return n>=0?n:null}if(Array.isArray(e)){if(Array.isArray(t)){for(let n=0;n<=e.length-t.length;n++){let r=!0;for(let i=0;ia(e,t));return n>=0?n:null}return null});case`rindex`:return n.length===0?[null]:i(e,n[0],r).map(t=>{if(typeof e==`string`&&typeof t==`string`){let n=e.lastIndexOf(t);return n>=0?n:null}if(Array.isArray(e)){if(Array.isArray(t)){for(let n=e.length-t.length;n>=0;n--){let r=!0;for(let i=0;i=0;n--)if(a(e[n],t))return n;return null}return null});case`indices`:return n.length===0?[[]]:i(e,n[0],r).map(t=>{let n=[];if(typeof e==`string`&&typeof t==`string`){let r=e.indexOf(t);for(;r!==-1;)n.push(r),r=e.indexOf(t,r+1)}else if(Array.isArray(e)){if(Array.isArray(t)){let r=t.length;if(r===0)for(let t=0;t<=e.length;t++)n.push(t);else for(let i=0;i<=e.length-r;i++){let o=!0;for(let n=0;n{});function nTe(e,t,n,r,i){switch(t){case`fabs`:case`abs`:return typeof e==`number`?[Math.abs(e)]:typeof e==`string`?[e]:[null];case`exp10`:return typeof e==`number`?[10**e]:[null];case`exp2`:return typeof e==`number`?[2**e]:[null];case`pow`:{if(n.length<2)return[null];let t=i(e,n[0],r),a=i(e,n[1],r),o=t[0],s=a[0];return typeof o!=`number`||typeof s!=`number`?[null]:[o**s]}case`atan2`:{if(n.length<2)return[null];let t=i(e,n[0],r),a=i(e,n[1],r),o=t[0],s=a[0];return typeof o!=`number`||typeof s!=`number`?[null]:[Math.atan2(o,s)]}case`hypot`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[Math.hypot(e,t)]}case`fma`:{if(typeof e!=`number`||n.length<2)return[null];let t=i(e,n[0],r)[0],a=i(e,n[1],r)[0];return[e*t+a]}case`copysign`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[Math.sign(t)*Math.abs(e)]}case`drem`:case`remainder`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[e-Math.round(e/t)*t]}case`fdim`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[Math.max(0,e-t)]}case`fmax`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[Math.max(e,t)]}case`fmin`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[Math.min(e,t)]}case`ldexp`:return typeof e!=`number`||n.length===0?[null]:[e*2**i(e,n[0],r)[0]];case`scalbn`:case`scalbln`:return typeof e!=`number`||n.length===0?[null]:[e*2**i(e,n[0],r)[0]];case`nearbyint`:return typeof e==`number`?[Math.round(e)]:[null];case`logb`:return typeof e==`number`?[Math.floor(Math.log2(Math.abs(e)))]:[null];case`significand`:return typeof e==`number`?[e/2**Math.floor(Math.log2(Math.abs(e)))]:[null];case`frexp`:if(typeof e==`number`){if(e===0)return[[0,0]];let t=Math.floor(Math.log2(Math.abs(e)))+1;return[[e/2**t,t]]}return[null];case`modf`:if(typeof e==`number`){let t=Math.trunc(e);return[[e-t,t]]}return[null];default:return null}}var rTe=B(()=>{});function WZ(e){let t=e.limits.maxIterations;return{maxDepth:e.limits.maxDepth,maxResults:e.limits.maxArrayElements,maxIterations:t}}function GZ(e){throw new H(e,`array_elements`)}function KZ(e,t){let n=1;for(let r of e){if(!Number.isSafeInteger(r)||r<0)throw Error(`combinations requires finite array lengths`);r!==0&&n>Math.floor(t/r)&&GZ(`query combination limit exceeded (${t})`),n*=r}return n}function iTe(e,t,n,r,i,a,o,s){switch(t){case`recurse`:{let t=[],o=WZ(r),s=n.length>=2?n[1]:null,c=[{value:e,depth:0}],l=0;for(;c.length>0;){let e=c.pop();if(!e)break;if(++l>o.maxIterations)throw new H(`query iteration limit exceeded (${o.maxIterations})`,`iterations`);if(e.depth>o.maxDepth)throw new H(`query depth limit exceeded (${o.maxDepth})`,`recursion`);if(s&&!i(e.value,s,r).some(a))continue;t.length>=o.maxResults&&GZ(`query result element limit exceeded (${o.maxResults})`),t.push(e.value);let u=[];n.length===0?Array.isArray(e.value)?u=e.value:e.value&&typeof e.value==`object`&&(u=Object.keys(e.value).map(t=>e.value[t])):u=i(e.value,n[0],r).filter(e=>e!=null),c.length>o.maxResults-u.length&&GZ(`query traversal queue limit exceeded (${o.maxResults})`);for(let t=u.length-1;t>=0;t--)c.push({value:u[t],depth:e.depth+1})}return t}case`recurse_down`:return s(e,`recurse`,n,r);case`walk`:{if(n.length===0)return[e];let t=WZ(r),a=new WeakSet,o=new WeakMap,s=[{value:e,depth:0,expanded:!1}],c=e,l=0;for(;s.length>0;){let e=s.pop();if(!e)break;if(++l>t.maxIterations)throw new H(`query iteration limit exceeded (${t.maxIterations})`,`iterations`);if(e.depth>t.maxDepth)throw new H(`query depth limit exceeded (${t.maxDepth})`,`recursion`);let u=e.value!==null&&typeof e.value==`object`?e.value:null;if(!e.expanded&&u){if(a.has(u))continue;a.add(u),s.push({...e,expanded:!0});let n=tK(e.value),r=Array.isArray(e.value)?e.value:Object.keys(n??{}).map(e=>n?.[e]);s.length>t.maxResults-r.length&&GZ(`query traversal queue limit exceeded (${t.maxResults})`);for(let t=r.length-1;t>=0;t--)s.push({value:r[t],depth:e.depth+1,expanded:!1});continue}let d=e.value;if(Array.isArray(e.value))d=e.value.map(e=>typeof e==`object`&&e?o.get(e)??e:e);else if(u){let t=Object.create(null),n=tK(e.value);for(let e of Object.keys(n??{})){if(!ZG(e))continue;let r=n?.[e];QG(t,e,typeof r==`object`&&r?o.get(r)??r:r)}d=t}let f=i(d,n[0],r)[0];u&&o.set(u,f),e.depth===0&&(c=f)}return[c]}case`transpose`:{if(!Array.isArray(e))return[null];if(e.length===0)return[[]];let t=WZ(r),n=0;for(let t of e)Array.isArray(t)&&(n=Math.max(n,t.length));KZ([e.length,n],t.maxResults);let i=[];for(let t=0;tArray.isArray(e)?e[t]:null));return[i]}case`combinations`:{if(n.length>0){let t=i(e,n[0],r)[0];if(!Array.isArray(e))return[];if(!Number.isFinite(t)||!Number.isSafeInteger(t)||t<0)throw Error(`combinations length must be a finite non-negative integer`);let a=WZ(r);if(t>a.maxDepth||t>a.maxResults)throw new H(`query depth limit exceeded (${a.maxDepth})`,`recursion`);if(t===0)return a.maxResults<1&&GZ(`query combination limit exceeded (0)`),[[]];let o=KZ(Array.from({length:t},()=>e.length),a.maxResults);if(o===0)return[];let s=[],c=Array(t).fill(0);for(let n=0;ne[t]));for(let n=t-1;n>=0&&(c[n]++,!(c[n]t.maxDepth)throw new H(`query depth limit exceeded (${t.maxDepth})`,`recursion`);let o=KZ(a.map(e=>e.length),t.maxResults);if(o===0)return[];let s=[],c=Array(a.length).fill(0);for(let e=0;ea[t][e]));for(let e=a.length-1;e>=0&&(c[e]++,!(c[e]0?i(e,n[0],r)[0]:1;if(a>=0){if(a>t.length)return[];let e=t.slice(0,t.length-a);return[o(r.root,e)]}{let n=-a-1;if(n>=t.length)return[e];let i=t.slice(0,n);return[o(r.root,i)]}}case`parents`:{if(r.root===void 0||r.currentPath===void 0)return[[]];let e=r.currentPath,t=[];for(let n=e.length-1;n>=0;n--)t.push(o(r.root,e.slice(0,n)));return[t]}case`root`:return r.root===void 0?[]:[r.root];default:return null}}var aTe=B(()=>{U(),aK()});function qZ(e){return e.limits.maxArrayElements}function JZ(e,t){let n=qZ(e);if(t>=n)throw new H(`query result element limit exceeded (${n})`,`array_elements`)}function oTe(e,t){let n=t.limits.maxDepth??YZ;if(e.length>n)throw new H(`query depth limit exceeded (${n})`,`recursion`);let r=t.limits.maxArrayElements;for(let t of e)if(typeof t==`number`){if(!Number.isSafeInteger(t)||t<0||t>=r)throw new H(`query array index limit exceeded (${r})`,`array_elements`)}else if(typeof t!=`string`)throw Error(`stream path components must be strings or integers`)}function sTe(e,t,n,r,i){switch(t){case`keys`:return Array.isArray(e)?[e.map((e,t)=>t)]:e&&typeof e==`object`?[Object.keys(e).sort()]:[null];case`keys_unsorted`:return Array.isArray(e)?[e.map((e,t)=>t)]:e&&typeof e==`object`?[Object.keys(e)]:[null];case`length`:return typeof e==`string`||Array.isArray(e)?[e.length]:e&&typeof e==`object`?[Object.keys(e).length]:e===null?[0]:typeof e==`number`?[Math.abs(e)]:[null];case`utf8bytelength`:{if(typeof e==`string`)return[V(e)];let t=e===null?`null`:Array.isArray(e)?`array`:typeof e,n=t===`array`||t===`object`?JSON.stringify(e):String(e);throw Error(`${t} (${n}) only strings have UTF-8 byte length`)}case`to_entries`:{let t=tK(e);if(t){let e=Object.keys(t);if(e.length>qZ(r))throw new H(`query result element limit exceeded (${qZ(r)})`,`array_elements`);return[e.map(e=>{let n=Object.create(null);return QG(n,`key`,e),QG(n,`value`,t[e]),n})]}return[null]}case`from_entries`:if(Array.isArray(e)){let t=Object.create(null);for(let n of e){let e=tK(n);if(e){let n=e.key??e.Key??e.name??e.Name??e.k,r=e.value??e.Value??e.v;if(n!==void 0){let e=String(n);ZG(e)&&QG(t,e,r)}}}return[t]}return[null];case`with_entries`:{if(n.length===0)return[e];let t=tK(e);if(t){let e=Object.keys(t);if(e.length>qZ(r))throw new H(`query result element limit exceeded (${qZ(r)})`,`array_elements`);let a=[];for(let o of e){let e=Object.create(null);QG(e,`key`,o),QG(e,`value`,t[o]);let s=i(e,n[0],r);if(a.length>qZ(r)-s.length)throw new H(`query result element limit exceeded (${qZ(r)})`,`array_elements`);for(let e of s)a.push(e)}let o=Object.create(null);for(let e of a){let t=tK(e);if(t){let e=t.key??t.name??t.k,n=t.value??t.v;if(e!==void 0){let t=String(e);ZG(t)&&QG(o,t,n)}}}return[o]}return[null]}case`reverse`:return Array.isArray(e)?[[...e].reverse()]:typeof e==`string`?[e.split(``).reverse().join(``)]:[null];case`flatten`:return Array.isArray(e)?(n.length>0?i(e,n[0],r):[1/0]).map(t=>{let n=t;if(n<0)throw Error(`flatten depth must not be negative`);return e.flat(n)}):[null];case`unique`:if(Array.isArray(e)){let t=new Set,n=[];for(let r of e){let e=JSON.stringify(r);t.has(e)||(t.add(e),n.push(r))}return[n]}return[null];case`tojson`:case`tojsonstream`:{let t=r.limits.maxDepth??YZ;return zZ(e,t+1)>t?[null]:[JSON.stringify(e)]}case`fromjson`:if(typeof e==`string`){let t=e.trim().toLowerCase();if(t===`nan`)return[NaN];if(t===`inf`||t===`infinity`)return[1/0];if(t===`-inf`||t===`-infinity`)return[-1/0];try{return[eK(JSON.parse(e),{maxDepth:r.limits.maxDepth,maxElements:r.limits.maxArrayElements})]}catch(t){throw t instanceof H?t:Error(`Invalid JSON: ${e}`)}}return[e];case`tostring`:return typeof e==`string`?[e]:[JSON.stringify(e)];case`tonumber`:if(typeof e==`number`)return[e];if(typeof e==`string`){let t=Number(e);if(Number.isNaN(t))throw Error(`${JSON.stringify(e)} cannot be parsed as a number`);return[t]}throw Error(`${typeof e} cannot be parsed as a number`);case`toboolean`:{if(typeof e==`boolean`)return[e];if(typeof e==`string`){if(e===`true`)return[!0];if(e===`false`)return[!1];throw Error(`string (${JSON.stringify(e)}) cannot be parsed as a boolean`)}let t=e===null?`null`:Array.isArray(e)?`array`:typeof e,n=t===`array`||t===`object`?JSON.stringify(e):String(e);throw Error(`${t} (${n}) cannot be parsed as a boolean`)}case`tostream`:{let t=[],n=r.limits.maxDepth??YZ,i=[{value:e,path:[]}],a=new WeakSet,o=0;for(;i.length>0;){let e=i.pop();if(!e)break;if(++o>r.limits.maxIterations)throw new H(`query iteration limit exceeded (${r.limits.maxIterations})`,`iterations`);if(e.path.length>n)throw new H(`query depth limit exceeded (${n})`,`recursion`);let s=e.value;if(typeof s!=`object`||!s)JZ(r,t.length),t.push([e.path,s]);else if(Array.isArray(s)){if(a.has(s))throw new H(`cyclic value cannot be converted to a stream`,`recursion`);if(a.add(s),s.length===0)JZ(r,t.length),t.push([e.path,[]]);else{if(i.length>qZ(r)-s.length)throw new H(`query traversal queue limit exceeded (${qZ(r)})`,`array_elements`);for(let t=s.length-1;t>=0;t--)i.push({value:s[t],path:[...e.path,t]})}}else{if(a.has(s))throw new H(`cyclic value cannot be converted to a stream`,`recursion`);a.add(s);let n=Object.keys(s);if(n.length===0)JZ(r,t.length),t.push([e.path,Object.create(null)]);else{if(i.length>qZ(r)-n.length)throw new H(`query traversal queue limit exceeded (${qZ(r)})`,`array_elements`);for(let t=n.length-1;t>=0;t--){let r=n[t];i.push({value:s[r],path:[...e.path,r]})}}}}return JZ(r,t.length),t.push([[]]),t}case`fromstream`:{if(n.length===0)return[e];let t=i(e,n[0],r);if(t.length>qZ(r))throw new H(`query stream item limit exceeded (${qZ(r)})`,`array_elements`);let a=null,o=0;for(let e of t){if(!Array.isArray(e)||e.length===1&&Array.isArray(e[0])&&e[0].length===0||e.length!==2)continue;let[t,n]=e;if(!Array.isArray(t))continue;if(oTe(t,r),t.length===0){a=n;continue}a===null&&(a=typeof t[0]==`number`?[]:Object.create(null));let i=a;for(let e=0;er.limits.maxIterations-o)throw new H(`query iteration limit exceeded (${r.limits.maxIterations})`,`iterations`);for(o+=Math.max(0,e);i.length<=n;)i.push(null);i[n]===null&&(i[n]=typeof a==`number`?[]:Object.create(null)),i=i[n]}else{let e=tK(i);if(e){let t=String(n);if(!ZG(t))continue;(e[t]===null||e[t]===void 0)&&QG(e,t,typeof a==`number`?[]:Object.create(null)),i=e[t]}}}let s=t[t.length-1];if(Array.isArray(i)&&typeof s==`number`){let e=s+1-i.length;if(e>r.limits.maxIterations-o)throw new H(`query iteration limit exceeded (${r.limits.maxIterations})`,`iterations`);for(o+=Math.max(0,e);i.length<=s;)i.push(null);i[s]=n}else{let e=tK(i);if(e){let t=String(s);ZG(t)&&QG(e,t,n)}}}return[a]}case`truncate_stream`:{let t=typeof e==`number`?Math.floor(e):0;if(n.length===0)return[];let a=[],o=i(e,n[0],r);for(let e of o)if(Array.isArray(e)){if(e.length===1&&Array.isArray(e[0])){let n=e[0];n.length>t&&a.push([n.slice(t)]);continue}if(e.length===2&&Array.isArray(e[0])){let n=e[0],r=e[1];n.length>t&&a.push([n.slice(t),r])}}return a}default:return null}}var YZ,cTe=B(()=>{AB(),U(),aK(),HZ(),YZ=2e3});function XZ(e,t){if(!Array.isArray(e))throw Error(`path must be an array`);let n=t.limits.maxDepth;if(e.length>n)throw new H(`query depth limit exceeded (${n})`,`recursion`);let r=t.limits.maxArrayElements,i=0;for(let t of e)if(typeof t==`number`){if(!Number.isSafeInteger(t)||t<0||t>=r)throw new H(`query array index limit exceeded (${r})`,`array_elements`);let e=t+1;if(i>r-e)throw new H(`query cumulative array allocation limit exceeded (${r})`,`array_elements`);i+=e}else if(typeof t!=`string`)throw Error(`path components must be strings or integers`);return iQ(t,i+e.length),e}function ZZ(e,t,n){let r=[],i=[{value:e,path:[],isRoot:!0}];for(;i.length>0;){let e=i.pop();if(!e)break;if(iQ(t),e.path.length>t.limits.maxDepth)throw new H(`query depth limit exceeded (${t.limits.maxDepth})`,`recursion`);if(e.value===null||typeof e.value!=`object`){(n||!e.isRoot)&&(aQ(t,r.length),r.push(e.path));continue}!n&&!e.isRoot&&(aQ(t,r.length),r.push(e.path));let a=Array.isArray(e.value)?e.value.map((e,t)=>[t,e]):Object.keys(e.value).map(t=>[t,e.value[t]]);aQ(t,r.length,i.length+a.length);for(let t=a.length-1;t>=0;t--){let[n,r]=a[t],o=[...e.path,n];i.push({value:r,path:o,isRoot:!1})}}return r}function lTe(e,t,n,r,i,a,o,s,c,l){switch(t){case`getpath`:{if(n.length===0)return[null];let t=i(e,n[0],r),a=[];for(let n of t){let t=n,r=e;for(let e of t){if(r==null){r=null;break}if(Array.isArray(r)&&typeof e==`number`)r=r[e];else if(typeof e==`string`){let t=tK(r);if(!t||!Object.hasOwn(t,e)){r=null;break}r=t[e]}else{r=null;break}}a.push(r)}return a}case`setpath`:{if(n.length<2)return[null];let t=XZ(i(e,n[0],r)[0],r),a=i(e,n[1],r)[0];return[o(e,t,a)]}case`delpaths`:{if(n.length===0)return[e];let t=i(e,n[0],r)[0],a=e;for(let e of t.sort((e,t)=>t.length-e.length))a=s(a,e);return[a]}case`path`:{if(n.length===0)return[[]];let t=[];return l(e,n[0],r,[],t),t}case`del`:return n.length===0?[e]:[c(e,n[0],r)];case`pick`:{if(n.length===0)return[null];let t=[];for(let i of n)l(e,i,r,[],t);let i=null;for(let n of t){for(let e of n)if(typeof e==`number`&&e<0)throw Error(`Out of bounds negative array index`);XZ(n,r);let t=e;for(let e of n){if(t==null)break;if(Array.isArray(t)&&typeof e==`number`)t=t[e];else if(typeof e==`string`){let n=tK(t);if(!n||!Object.hasOwn(n,e)){t=null;break}t=n[e]}else{t=null;break}}i=o(i,n,t)}return[i]}case`paths`:{let t=ZZ(e,r,!1);return n.length>0?t.filter(t=>{let o=e;for(let e of t)if(Array.isArray(o)&&typeof e==`number`)o=o[e];else if(typeof e==`string`){let t=tK(o);if(!t||!Object.hasOwn(t,e))return!1;o=t[e]}else return!1;return i(o,n[0],r).some(a)}):t}case`leaf_paths`:return ZZ(e,r,!0);default:return null}}var uTe=B(()=>{U(),SQ(),aK()});function dTe(e,t,n,r,i,a){switch(t){case`IN`:{if(n.length===0)return[!1];if(n.length===1){let t=i(e,n[0],r);for(let n of t)if(a(e,n))return[!0];return[!1]}let t=i(e,n[0],r),o=i(e,n[1],r),s=new Set(o.map(e=>JSON.stringify(e)));for(let e of t)if(s.has(JSON.stringify(e)))return[!0];return[!1]}case`INDEX`:{if(n.length===0)return[Object.create(null)];if(n.length===1){let t=i(e,n[0],r),a=Object.create(null);for(let e of t){let t=String(e);ZG(t)&&QG(a,t,e)}return[a]}if(n.length===2){let t=i(e,n[0],r),a=Object.create(null);for(let e of t){let t=i(e,n[1],r);if(t.length>0){let n=String(t[0]);ZG(n)&&QG(a,n,e)}}return[a]}let t=i(e,n[0],r),a=Object.create(null);for(let e of t){let t=i(e,n[1],r),o=i(e,n[2],r);if(t.length>0&&o.length>0){let e=String(t[0]);ZG(e)&&QG(a,e,o[0])}}return[a]}case`JOIN`:{if(n.length<2)return[null];let t=tK(i(e,n[0],r)[0]);if(!t||!Array.isArray(e))return[null];let a=[];for(let o of e){let e=i(o,n[1],r),s=e.length>0?String(e[0]):``,c=$G(t,s)?t[s]:null;a.push([o,c])}return[a]}default:return null}}var fTe=B(()=>{aK()});function QZ(e){return e.limits.maxArrayElements}function $Z(e){return Math.min(e.limits.maxStringLength,e.limits.maxOutputSize)}function eQ(e,t){let n=QZ(e);if(!Number.isSafeInteger(t)||t<0||t>n)throw new H(`query result element limit exceeded (${n})`,`array_elements`)}function pTe(e,t,n){if(e===``)return t===``?0:1;if(t===``)return e.length;let r=1,i=0;for(;;){let a=e.indexOf(t,i);if(a<0||(r++,r>n))return r;i=a+t.length}}function mTe(e,t,n,r,i){switch(t){case`join`:{if(!Array.isArray(e))return[null];let t=n.length>0?i(e,n[0],r):[``];for(let t of e)if(Array.isArray(t)||typeof t==`object`&&t)throw Error(`cannot join: contains arrays or objects`);return eQ(r,t.length),t.map(t=>{let n=String(t),i=0;for(let t=0;t0&&(i+=V(n)),i>$Z(r))throw new H(`query string size limit exceeded (${$Z(r)} bytes)`,`string_length`)}return e.map(e=>e===null?``:typeof e==`string`?e:String(e)).join(n)})}case`split`:{if(typeof e!=`string`||n.length===0)return[null];let t=i(e,n[0],r),a=String(t[0]);return eQ(r,pTe(e,a,QZ(r))),[e.split(a)]}case`splits`:{if(typeof e!=`string`||n.length===0)return[];let t=i(e,n[0],r),a=String(t[0]);try{let t=n.length>1?String(i(e,n[1],r)[0]):`g`,o=hG(a,t.includes(`g`)?t:`${t}g`),s=1;for(let t of o.matchAll(e))s+=Math.max(1,t.length),eQ(r,s);let c=o.split(e);return eQ(r,c.length),c}catch(e){if(e instanceof H)throw e;return[]}}case`scan`:{if(typeof e!=`string`||n.length===0)return[];let t=i(e,n[0],r),a=String(t[0]);try{let t=n.length>1?String(i(e,n[1],r)[0]):``,o=hG(a,t.includes(`g`)?t:`${t}g`),s=[];for(let t of o.matchAll(e))eQ(r,s.length+1),t.length>1?(eQ(r,t.length-1),s.push(t.slice(1))):s.push(t[0]);return s}catch(e){if(e instanceof H)throw e;return[]}}case`test`:{if(typeof e!=`string`||n.length===0)return[!1];let t=i(e,n[0],r),a=String(t[0]);try{return[hG(a,n.length>1?String(i(e,n[1],r)[0]):``).test(e)]}catch{return[!1]}}case`match`:{if(typeof e!=`string`||n.length===0)return[null];let t=i(e,n[0],r),a=String(t[0]);try{let t=hG(a,`${n.length>1?String(i(e,n[1],r)[0]):``}d`).exec(e);if(!t)return[];let o=t.indices;return[{offset:t.index,length:t[0].length,string:t[0],captures:t.slice(1).map((e,t)=>({offset:o?.[t+1]?.[0]??null,length:e?.length??0,string:e??``,name:null}))}]}catch{return[null]}}case`capture`:{if(typeof e!=`string`||n.length===0)return[null];let t=i(e,n[0],r),a=String(t[0]);try{let t=hG(a,n.length>1?String(i(e,n[1],r)[0]):``).match(e);return!t||!t.groups?[Object.create(null)]:[t.groups]}catch{return[null]}}case`sub`:{if(typeof e!=`string`||n.length<2)return[null];let t=i(e,n[0],r),a=i(e,n[1],r),o=String(t[0]),s=String(a[0]);try{return[hG(o,n.length>2?String(i(e,n[2],r)[0]):``).replace(e,s)]}catch{return[e]}}case`gsub`:{if(typeof e!=`string`||n.length<2)return[null];let t=i(e,n[0],r),a=i(e,n[1],r),o=String(t[0]),s=String(a[0]);try{let t=n.length>2?String(i(e,n[2],r)[0]):`g`;return[hG(o,t.includes(`g`)?t:`${t}g`).replace(e,s)]}catch{return[e]}}case`ascii_downcase`:return typeof e==`string`?[e.replace(/[A-Z]/g,e=>String.fromCharCode(e.charCodeAt(0)+32))]:[null];case`ascii_upcase`:return typeof e==`string`?[e.replace(/[a-z]/g,e=>String.fromCharCode(e.charCodeAt(0)-32))]:[null];case`ltrimstr`:{if(typeof e!=`string`||n.length===0)return[e];let t=i(e,n[0],r),a=String(t[0]);return[e.startsWith(a)?e.slice(a.length):e]}case`rtrimstr`:{if(typeof e!=`string`||n.length===0)return[e];let t=i(e,n[0],r),a=String(t[0]);return a===``?[e]:[e.endsWith(a)?e.slice(0,-a.length):e]}case`trimstr`:{if(typeof e!=`string`||n.length===0)return[e];let t=i(e,n[0],r),a=String(t[0]);if(a===``)return[e];let o=e;return o.startsWith(a)&&(o=o.slice(a.length)),o.endsWith(a)&&(o=o.slice(0,-a.length)),[o]}case`trim`:if(typeof e==`string`)return[e.trim()];throw Error(`trim input must be a string`);case`ltrim`:if(typeof e==`string`)return[e.trimStart()];throw Error(`trim input must be a string`);case`rtrim`:if(typeof e==`string`)return[e.trimEnd()];throw Error(`trim input must be a string`);case`startswith`:{if(typeof e!=`string`||n.length===0)return[!1];let t=i(e,n[0],r);return[e.startsWith(String(t[0]))]}case`endswith`:{if(typeof e!=`string`||n.length===0)return[!1];let t=i(e,n[0],r);return[e.endsWith(String(t[0]))]}case`ascii`:return typeof e==`string`&&e.length>0?[e.charCodeAt(0)]:[null];case`explode`:if(typeof e==`string`){let t=0;for(let n of e)t++,eQ(r,t);return[Array.from(e).map(e=>e.codePointAt(0))]}return[null];case`implode`:if(!Array.isArray(e))throw Error(`implode input must be an array`);return[e.map(e=>{if(typeof e==`string`)throw Error(`string (${JSON.stringify(e)}) can't be imploded, unicode codepoint needs to be numeric`);if(typeof e!=`number`||Number.isNaN(e))throw Error(`number (null) can't be imploded, unicode codepoint needs to be numeric`);let t=Math.trunc(e);return t<0||t>1114111||t>=55296&&t<=57343?String.fromCodePoint(65533):String.fromCodePoint(t)}).join(``)];default:return null}}var hTe=B(()=>{U(),bG(),ZB()});function gTe(e,t){switch(t){case`type`:return e===null?[`null`]:Array.isArray(e)?[`array`]:typeof e==`boolean`?[`boolean`]:typeof e==`number`?[`number`]:typeof e==`string`?[`string`]:typeof e==`object`?[`object`]:[`null`];case`infinite`:return[1/0];case`nan`:return[NaN];case`isinfinite`:return[typeof e==`number`&&!Number.isFinite(e)];case`isnan`:return[typeof e==`number`&&Number.isNaN(e)];case`isnormal`:return[typeof e==`number`&&Number.isFinite(e)&&e!==0];case`isfinite`:return[typeof e==`number`&&Number.isFinite(e)];case`numbers`:return typeof e==`number`?[e]:[];case`strings`:return typeof e==`string`?[e]:[];case`booleans`:return typeof e==`boolean`?[e]:[];case`nulls`:return e===null?[e]:[];case`arrays`:return Array.isArray(e)?[e]:[];case`objects`:return e&&typeof e==`object`&&!Array.isArray(e)?[e]:[];case`iterables`:return Array.isArray(e)||e&&typeof e==`object`&&!Array.isArray(e)?[e]:[];case`scalars`:return!Array.isArray(e)&&!(e&&typeof e==`object`)?[e]:[];case`values`:return e===null?[]:[e];case`not`:return e===!1||e===null?[!0]:[!1];case`null`:return[null];case`true`:return[!0];case`false`:return[!1];case`empty`:return[];default:return null}}var _Te=B(()=>{}),vTe=B(()=>{Wwe(),Kwe(),Jwe(),$we(),tTe(),rTe(),aTe(),cTe(),uTe(),fTe(),hTe(),_Te()});function tQ(e,t,n){if(t.length===0)return n;let[r,...i]=t;if(typeof r==`number`){if(e&&typeof e==`object`&&!Array.isArray(e))throw Error(`Cannot index object with number`);if(r>536870911)throw Error(`Array index too large`);if(r<0)throw Error(`Out of bounds negative array index`);let t=Array.isArray(e)?[...e]:[];for(;t.length<=r;)t.push(null);return t[r]=tQ(t[r],i,n),t}if(Array.isArray(e))throw Error(`Cannot index array with string`);if(!ZG(r))return e??Object.create(null);let a=tK(e),o=a?nK(a):Object.create(null);return QG(o,r,tQ(Object.hasOwn(o,r)?o[r]:void 0,i,n)),o}function nQ(e,t){if(t.length===0)return null;if(t.length===1){let n=t[0];if(Array.isArray(e)&&typeof n==`number`){let t=[...e];return t.splice(n,1),t}if(e&&typeof e==`object`&&!Array.isArray(e)){let t=String(n);if(!ZG(t))return e;let r=nK(e);return delete r[t],r}return e}let[n,...r]=t;if(Array.isArray(e)&&typeof n==`number`){let t=[...e];return t[n]=nQ(t[n],r),t}if(e&&typeof e==`object`&&!Array.isArray(e)){let t=String(n);if(!ZG(t))return e;let i=nK(e);return Object.hasOwn(i,t)&&QG(i,t,nQ(i[t],r)),i}return e}var yTe=B(()=>{aK()});function rQ(e,t){return new H(e,t)}function iQ(e,t=1){if(!Number.isSafeInteger(t)||t<0||e.budget.operations>e.limits.maxIterations-t)throw rQ(`query evaluation: too many iterations (${e.limits.maxIterations})`,`iterations`);e.budget.operations+=t}function aQ(e,t,n=1){let r=e.limits.maxArrayElements;if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||t<0||n<0||t>r-n)throw rQ(`query result element limit exceeded (${r})`,`array_elements`)}function oQ(e,t,n){aQ(e,t.length,n.length);for(let e of n)t.push(e)}function sQ(e,t,n){let r=[];for(let i of t)iQ(e),oQ(e,r,n(i));return r}function bTe(e){let t=new Map;if(e?.namedArgs)for(let[n,r]of e.namedArgs)t.set(`$${n}`,r);return{vars:t,limits:{maxIterations:e?.limits?.maxIterations??vQ,maxDepth:e?.limits?.maxDepth??bQ,maxStringLength:e?.limits?.maxStringLength??yQ,maxOutputSize:e?.limits?.maxOutputSize??yQ,maxArrayElements:e?.limits?.maxArrayElements??1e5},env:e?.env,namedArgs:e?.namedArgs,positionalArgs:e?.positionalArgs,coverage:e?.coverage,requireDefenseContext:e?.requireDefenseContext,defenseContextChecked:!1,budget:e?.budget??{operations:0,callDepth:0}}}function cQ(e,t,n){let r=new Map(e.vars);return r.set(t,n),{vars:r,limits:e.limits,env:e.env,namedArgs:e.namedArgs,positionalArgs:e.positionalArgs,requireDefenseContext:e.requireDefenseContext,defenseContextChecked:e.defenseContextChecked,root:e.root,currentPath:e.currentPath,funcs:e.funcs,labels:e.labels,coverage:e.coverage,budget:e.budget}}function lQ(e,t,n){switch(t.type){case`var`:return cQ(e,t.name,n);case`array`:{if(!Array.isArray(n))return null;let r=e;for(let e=0;e0&&t.args[0].type===`Literal`){let e=t.args[0].value;typeof e==`number`&&(n=e)}if(n>=0)return e.slice(0,Math.max(0,e.length-n));{let t=-n-1;return e.slice(0,Math.min(t,e.length))}}if(t.name===`root`)return[]}if(t.type===`Field`){let n=uQ(t);if(n!==null)return[...e,...n]}if(t.type===`Index`&&t.index.type===`Literal`){let n=uQ(t);if(n!==null)return[...e,...n]}if(t.type===`Pipe`){let n=dQ(e,t.left);return n===null?null:dQ(n,t.right)}return t.type===`Identity`?e:null}function fQ(e,t,n){if(t.type===`Comma`){let r=[];try{oQ(n,r,Y(e,t.left,n))}catch(e){if(e instanceof H)throw e;if(r.length>0)return r;throw Error(`evaluation failed`)}try{oQ(n,r,Y(e,t.right,n))}catch(e){if(e instanceof H)throw e;return r}return r}return Y(e,t,n)}function Y(e,t,n){let r=n&&`vars`in n?n:bTe(n);if(r.defenseContextChecked||(kK(r.requireDefenseContext,`query-engine`,`evaluation`),r={...r,defenseContextChecked:!0}),r.root===void 0&&(r={...r,root:e,currentPath:[]}),iQ(r),r.budget.callDepth++,r.budget.callDepth>r.limits.maxDepth)throw r.budget.callDepth--,rQ(`query depth limit exceeded (${r.limits.maxDepth})`,`recursion`);try{let n=STe(e,t,r);return aQ(r,0,n.length),n}finally{r.budget.callDepth--}}function STe(e,t,n){switch(n.coverage?.hit(`jq:node:${t.type}`),t.type){case`Identity`:return[e];case`Field`:return sQ(n,t.base?Y(e,t.base,n):[e],e=>{let n=tK(e);if(n){if(!Object.hasOwn(n,t.name))return[null];let e=n[t.name];return[e===void 0?null:e]}if(e===null)return[null];throw Error(`Cannot index ${Array.isArray(e)?`array`:typeof e} with string "${t.name}"`)});case`Index`:return sQ(n,t.base?Y(e,t.base,n):[e],e=>sQ(n,Y(e,t.index,n),t=>{if(typeof t==`number`&&Array.isArray(e)){if(Number.isNaN(t))return[null];let n=Math.trunc(t),r=n<0?e.length+n:n;return r>=0&&r{if(r===null)return[null];if(!Array.isArray(r)&&typeof r!=`string`)throw Error(`Cannot slice ${typeof r} (${JSON.stringify(r)})`);let i=r.length,a=t.start?Y(e,t.start,n):[0],o=t.end?Y(e,t.end,n):[i];return aQ(n,0,a.length*o.length),sQ(n,a,e=>o.map(t=>{let n=e,a=t,o=Number.isNaN(n)?0:Number.isInteger(n)?n:Math.floor(n),s=Number.isNaN(a)?i:Number.isInteger(a)?a:Math.ceil(a),c=pQ(o,i),l=pQ(s,i);return r.slice(c,l)}))});case`Iterate`:return sQ(n,t.base?Y(e,t.base,n):[e],e=>Array.isArray(e)?e:e&&typeof e==`object`?Object.values(e):[]);case`Pipe`:{let r=Y(e,t.left,n),i=uQ(t.left),a=[];for(let e of r)try{if(i!==null){let r={...n,currentPath:[...n.currentPath??[],...i]};oQ(n,a,Y(e,t.right,r))}else oQ(n,a,Y(e,t.right,n))}catch(e){throw e instanceof gQ?e.withPrependedResults(a):e}return a}case`Comma`:{let r=Y(e,t.left,n),i=Y(e,t.right,n);return aQ(n,r.length,i.length),[...r,...i]}case`Literal`:return[t.value];case`Array`:return t.elements?[Y(e,t.elements,n)]:[[]];case`Object`:{let r=[Object.create(null)];for(let i of t.entries){let t=typeof i.key==`string`?[i.key]:Y(e,i.key,n),a=Y(e,i.value,n),o=[],s=t.filter(e=>typeof e==`string`&&ZG(e)).length,c=s+(t.length-s);aQ(n,0,r.length*c*a.length);for(let e of r)for(let n of t){if(typeof n!=`string`)throw Error(`Cannot use ${n===null?`null`:Array.isArray(n)?`array`:typeof n} (${JSON.stringify(n)}) as object key`);if(!ZG(n)){for(let t of a)o.push(nK(e));continue}for(let t of a){let r=nK(e);QG(r,n,t),o.push(r)}}r.length=0,oQ(n,r,o)}return r}case`Paren`:return Y(e,t.expr,n);case`BinaryOp`:return TTe(e,t.op,t.left,t.right,n);case`UnaryOp`:return Y(e,t.operand,n).map(e=>{if(t.op===`-`){if(typeof e==`number`)return-e;if(typeof e==`string`)throw Error(`string (${(e=>e.length>5?`"${e.slice(0,3)}...`:JSON.stringify(e))(e)}) cannot be negated`);return null}return t.op===`not`?!IZ(e):null});case`Cond`:return sQ(n,Y(e,t.cond,n),r=>{if(IZ(r))return Y(e,t.then,n);for(let r of t.elifs)if(Y(e,r.cond,n).some(IZ))return Y(e,r.then,n);return t.else?Y(e,t.else,n):[e]});case`Try`:try{return Y(e,t.body,n)}catch(e){if(e instanceof H)throw e;return t.catch?Y(e instanceof _Q?e.value:e instanceof Error?e.message:String(e),t.catch,n):[]}case`Call`:return mQ(e,t.name,t.args,n);case`VarBind`:return sQ(n,Y(e,t.value,n),r=>{let i=null,a=[];if(t.pattern?a.push(t.pattern):t.name&&a.push({type:`var`,name:t.name}),t.alternatives)for(let e of t.alternatives)a.push(e);for(let e of a)if(i=lQ(n,e,r),i!==null)break;return i===null?[]:Y(e,t.body,i)});case`VarRef`:{if(t.name===`$ENV`)return[n.env?QK(n.env):Object.create(null)];if(t.name===`$ARGS`){let e=Object.create(null);if(n.namedArgs)for(let[t,r]of n.namedArgs)Object.defineProperty(e,t,{value:r,enumerable:!0,writable:!0,configurable:!0});let t=Object.create(null);return t.positional=n.positionalArgs?[...n.positionalArgs]:[],t.named=e,[t]}let e=n.vars.get(t.name);return e===void 0?[null]:[e]}case`Recurse`:{let t=[],r=new WeakSet,i=[{val:e,depth:0}];for(;i.length>0;){let e=i.pop();if(!e)break;let{val:a,depth:o}=e;if(iQ(n),o>n.limits.maxDepth)throw rQ(`query depth limit exceeded (${n.limits.maxDepth})`,`recursion`);if(a&&typeof a==`object`){if(r.has(a))continue;r.add(a)}if(aQ(n,t.length),t.push(a),Array.isArray(a))for(let e=a.length-1;e>=0;e--)i.push({val:a[e],depth:o+1});else if(a&&typeof a==`object`){let e=Object.keys(a);for(let t=e.length-1;t>=0;t--)i.push({val:a[e[t]],depth:o+1})}}return t}case`Optional`:try{return Y(e,t.expr,n)}catch(e){if(e instanceof H)throw e;return[]}case`StringInterp`:{let r=new sH(n.limits.maxStringLength,`query string interpolation`,()=>new H(`string size limit exceeded (${n.limits.maxStringLength} bytes)`,`string_length`));for(let i of t.parts){if(typeof i==`string`){r.append(i);continue}let t=Y(e,i,n);for(let e of t){if(iQ(n),zZ(e,n.limits.maxDepth+1)>n.limits.maxDepth)throw rQ(`query depth limit exceeded (${n.limits.maxDepth})`,`recursion`);r.append(typeof e==`string`?e:JSON.stringify(e))}}return[r.build()]}case`UpdateOp`:return[CTe(e,t.path,t.op,t.value,n)];case`Reduce`:{let r=Y(e,t.expr,n),i=Y(e,t.init,n)[0],a=n.limits.maxDepth??bQ;for(let e of r){let r;if(t.pattern){if(r=lQ(n,t.pattern,e),r===null)continue}else r=cQ(n,t.varName,e);if(i=Y(i,t.update,r)[0],zZ(i,a+1)>a)return[null]}return[i]}case`Foreach`:{let r=Y(e,t.expr,n),i=Y(e,t.init,n)[0],a=[];for(let e of r)try{let r;if(t.pattern){if(r=lQ(n,t.pattern,e),r===null)continue}else r=cQ(n,t.varName,e);i=Y(i,t.update,r)[0],t.extract?oQ(n,a,Y(i,t.extract,r)):(aQ(n,a.length),a.push(i))}catch(e){throw e instanceof gQ?e.withPrependedResults(a):e}return a}case`Label`:try{return Y(e,t.body,{...n,labels:new Set([...n.labels??[],t.name])})}catch(e){if(e instanceof gQ&&e.label===t.name)return e.partialResults;throw e}case`Break`:throw new gQ(t.name);case`Def`:{let r=new Map(n.funcs??[]),i=`${t.name}/${t.params.length}`;r.set(i,{params:t.params,body:t.funcBody,closure:new Map(n.funcs??[])});let a={...n,funcs:r};return Y(e,t.body,a)}default:throw Error(`Unknown AST node type: ${t.type}`)}}function pQ(e,t){return e<0?Math.max(0,t+e):Math.min(e,t)}function CTe(e,t,n,r,i){function a(e,t){switch(n){case`=`:return t;case`|=`:return Y(e,r,i)[0]??null;case`+=`:return typeof e==`number`&&typeof t==`number`||typeof e==`string`&&typeof t==`string`?e+t:Array.isArray(e)&&Array.isArray(t)?(aQ(i,e.length,t.length),[...e,...t]):e&&t&&typeof e==`object`&&typeof t==`object`?rK(e,t):t;case`-=`:return typeof e==`number`&&typeof t==`number`?e-t:e;case`*=`:return typeof e==`number`&&typeof t==`number`?e*t:e;case`/=`:return typeof e==`number`&&typeof t==`number`?e/t:e;case`%=`:return typeof e==`number`&&typeof t==`number`?e%t:e;case`//=`:return e===null||e===!1?t:e;default:return t}}function o(t,n,r){switch(n.type){case`Identity`:return r(t);case`Field`:if(!ZG(n.name))return t;if(n.base)return o(t,n.base,e=>{if(e&&typeof e==`object`&&!Array.isArray(e)){let t=nK(e),i=Object.hasOwn(t,n.name)?t[n.name]:void 0;return QG(t,n.name,r(i)),t}return e});if(t&&typeof t==`object`&&!Array.isArray(t)){let e=nK(t),i=Object.hasOwn(e,n.name)?e[n.name]:void 0;return QG(e,n.name,r(i)),e}return t;case`Index`:{let a=Y(e,n.index,i)[0];if(typeof a==`number`&&Number.isNaN(a))throw Error(`Cannot set array element at NaN index`);if(typeof a==`number`&&!Number.isFinite(a))throw Error(`array index must be finite`);if(typeof a==`number`&&!Number.isInteger(a)&&(a=Math.trunc(a)),n.base)return o(t,n.base,e=>{if(typeof a==`number`&&Array.isArray(e)){let t=[...e],n=a<0?t.length+a:a;if(n>=0){aQ(i,0,n+1),t.length<=n&&(t.length=n+1);for(let r=e.length;r536870911)throw Error(`Array index too large`);if(a<0&&(!t||!Array.isArray(t)))throw Error(`Out of bounds negative array index`);if(Array.isArray(t)){let e=[...t],n=a<0?e.length+a:a;if(n>=0){aQ(i,0,n+1),e.length<=n&&(e.length=n+1);for(let r=t.length;r{if(Array.isArray(e)){aQ(i,0,e.length);let t=[];for(let n of e)iQ(i),t.push(r(n));return t}if(e&&typeof e==`object`){let t=Object.create(null);for(let[n,i]of Object.entries(e))ZG(n)&&QG(t,n,r(i));return t}return e};return n.base?o(t,n.base,e):e(t)}case`Pipe`:return o(o(t,n.left,e=>e),n.right,r);default:return r(t)}}return o(e,t,t=>n===`|=`?a(t,t):a(t,Y(e,r,i)[0]??null))}function wTe(e,t,n){function r(t,i,a){switch(i.type){case`Identity`:return a;case`Field`:if(!ZG(i.name))return t;if(i.base){let e=Y(t,i.base,n)[0],o=r(e,{type:`Field`,name:i.name},a);return r(t,i.base,o)}if(t&&typeof t==`object`&&!Array.isArray(t)){let e=nK(t);return QG(e,i.name,a),e}return t;case`Index`:{if(i.base){let e=Y(t,i.base,n)[0],o=r(e,{type:`Index`,index:i.index},a);return r(t,i.base,o)}let o=Y(e,i.index,n)[0];if(typeof o==`number`&&Array.isArray(t)){let e=[...t],n=o<0?e.length+o:o;return n>=0&&n=0&&n=0&&nIZ(t)?sQ(i,Y(e,r,i),e=>[IZ(e)]):[!1]);if(t===`or`)return sQ(i,Y(e,n,i),t=>IZ(t)?[!0]:sQ(i,Y(e,r,i),e=>[IZ(e)]));if(t===`//`){let t=Y(e,n,i).filter(e=>e!=null&&e!==!1);return t.length>0?t:Y(e,r,i)}let a=Y(e,n,i),o=Y(e,r,i),s=a.length*o.length;return aQ(i,0,s),iQ(i,s),a.flatMap(e=>o.map(n=>{switch(t){case`+`:if(e===null)return n;if(n===null)return e;if(typeof e==`number`&&typeof n==`number`)return e+n;if(typeof e==`string`&&typeof n==`string`){let t=i.limits.maxStringLength;if(V(e)+V(n)>t)throw new H(`string size limit exceeded (${t} bytes)`,`string_length`);return e+n}return Array.isArray(e)&&Array.isArray(n)?(aQ(i,e.length,n.length),[...e,...n]):e&&n&&typeof e==`object`&&typeof n==`object`&&!Array.isArray(e)&&!Array.isArray(n)?rK(e,n):null;case`-`:if(typeof e==`number`&&typeof n==`number`)return e-n;if(Array.isArray(e)&&Array.isArray(n)){let t=new Set(n.map(e=>JSON.stringify(e)));return e.filter(e=>!t.has(JSON.stringify(e)))}if(typeof e==`string`&&typeof n==`string`){let t=e=>e.length>10?`"${e.slice(0,10)}...`:JSON.stringify(e);throw Error(`string (${t(e)}) and string (${t(n)}) cannot be subtracted`)}return null;case`*`:if(typeof e==`number`&&typeof n==`number`)return e*n;if(typeof e==`string`&&typeof n==`number`){if(!Number.isFinite(n))throw Error(`invalid string repetition count: ${n}`);let t=Math.trunc(n);if(t<0)return null;let r=V(e),a=i.limits.maxStringLength;if(r>0&&t>Math.floor(a/r))throw new H(`string size limit exceeded (${a} bytes)`,`string_length`);return e.repeat(t)}{let t=tK(e),r=tK(n);if(t&&r)return Ywe(t,r,{maxDepth:i.limits.maxDepth,visit:()=>iQ(i)})}return null;case`/`:if(typeof e==`number`&&typeof n==`number`){if(n===0)throw Error(`number (${e}) and number (${n}) cannot be divided because the divisor is zero`);return e/n}return typeof e==`string`&&typeof n==`string`?e.split(n):null;case`%`:if(typeof e==`number`&&typeof n==`number`){if(n===0)throw Error(`number (${e}) and number (${n}) cannot be divided (remainder) because the divisor is zero`);return!Number.isFinite(e)&&!Number.isNaN(e)?!Number.isFinite(n)&&!Number.isNaN(n)&&e<0&&n>0?-1:0:e%n}return null;case`==`:return LZ(e,n);case`!=`:return!LZ(e,n);case`<`:return RZ(e,n)<0;case`<=`:return RZ(e,n)<=0;case`>`:return RZ(e,n)>0;case`>=`:return RZ(e,n)>=0;default:return null}}))}function mQ(e,t,n,r){let i=xQ.get(t);if(i)return typeof e==`number`?[i(e)]:[null];let a=nTe(e,t,n,r,Y);if(a!==null)return a;let o=mTe(e,t,n,r,Y);if(o!==null)return o;let s=qwe(e,t,n,r,Y);if(s!==null)return s;let c=Qwe(e,t,r.limits.maxDepth);if(c!==null)return c;let l=gTe(e,t);if(l!==null)return l;let u=sTe(e,t,n,r,Y);if(u!==null)return u;let d=Uwe(e,t,n,r,Y,fQ,BZ,IZ,VZ,H);if(d!==null)return d;let f=lTe(e,t,n,r,Y,IZ,tQ,nQ,wTe,hQ);if(f!==null)return f;let p=eTe(e,t,n,r,Y,LZ);if(p!==null)return p;let m=Gwe(e,t,n,r,Y,fQ,IZ,H);if(m!==null)return m;let h=iTe(e,t,n,r,Y,IZ,xTe,mQ);if(h!==null)return h;let g=dTe(e,t,n,r,Y,LZ);if(g!==null)return g;switch(t){case`builtins`:return[`add/0.all/0.all/1.all/2.any/0.any/1.any/2.arrays/0.ascii/0.ascii_downcase/0.ascii_upcase/0.booleans/0.bsearch/1.builtins/0.combinations/0.combinations/1.contains/1.debug/0.del/1.delpaths/1.empty/0.env/0.error/0.error/1.explode/0.first/0.first/1.flatten/0.flatten/1.floor/0.from_entries/0.fromdate/0.fromjson/0.getpath/1.gmtime/0.group_by/1.gsub/2.gsub/3.has/1.implode/0.IN/1.IN/2.INDEX/1.INDEX/2.index/1.indices/1.infinite/0.inside/1.isempty/1.isnan/0.isnormal/0.isvalid/1.iterables/0.join/1.keys/0.keys_unsorted/0.last/0.last/1.length/0.limit/2.ltrimstr/1.map/1.map_values/1.match/1.match/2.max/0.max_by/1.min/0.min_by/1.mktime/0.modulemeta/1.nan/0.not/0.nth/1.nth/2.null/0.nulls/0.numbers/0.objects/0.path/1.paths/0.paths/1.pick/1.range/1.range/2.range/3.recurse/0.recurse/1.recurse_down/0.repeat/1.reverse/0.rindex/1.rtrimstr/1.scalars/0.scan/1.scan/2.select/1.setpath/2.skip/2.sort/0.sort_by/1.split/1.splits/1.splits/2.sqrt/0.startswith/1.strftime/1.strings/0.strptime/1.sub/2.sub/3.test/1.test/2.to_entries/0.toboolean/0.todate/0.tojson/0.tostream/0.fromstream/1.truncate_stream/1.tonumber/0.tostring/0.transpose/0.trim/0.ltrim/0.rtrim/0.type/0.unique/0.unique_by/1.until/2.utf8bytelength/0.values/0.walk/1.while/2.with_entries/1`.split(`.`)];case`error`:{let t=n.length>0?Y(e,n[0],r)[0]:e;throw new _Q(t)}case`env`:return[r.env?QK(r.env):Object.create(null)];case`debug`:return[e];case`input_line_number`:return[1];default:{let i=`${t}/${n.length}`,a=r.funcs?.get(i);if(a){let t=a.closure??r.funcs??new Map,o=new Map(t);o.set(i,a);for(let t=0;t=0;e--)n={type:`Comma`,left:{type:`Literal`,value:t[e]},right:n}}o.set(`${i}/0`,{params:[],body:n})}}let s={...r,funcs:o};return Y(e,a.body,s)}throw Error(`Unknown function: ${t}`)}}}function hQ(e,t,n,r,i){if(iQ(n),r.length>n.limits.maxDepth)throw rQ(`query depth limit exceeded (${n.limits.maxDepth})`,`recursion`);let a=e=>{if(e.length>n.limits.maxDepth)throw rQ(`query depth limit exceeded (${n.limits.maxDepth})`,`recursion`);aQ(n,i.length),i.push(e)};if(t.type===`Comma`){let a=t;hQ(e,a.left,n,r,i),hQ(e,a.right,n,r,i);return}let o=uQ(t);if(o!==null){a([...r,...o]);return}if(t.type===`Iterate`){if(Array.isArray(e))for(let t=0;t0;){let e=t.pop();if(!e)break;if(iQ(n),a([...r,...e.path]),e.value&&typeof e.value==`object`){let r=Array.isArray(e.value)?e.value.map((e,t)=>[t,e]):Object.keys(e.value).map(t=>[t,e.value[t]]);aQ(n,0,t.length+r.length);for(let n=r.length-1;n>=0;n--){let[i,a]=r[n];t.push({value:a,path:[...e.path,i]})}}}return}if(t.type===`Pipe`){let a=uQ(t.left);if(a!==null){let o=Y(e,t.left,n);for(let e of o)hQ(e,t.right,n,[...r,...a],i);return}}Y(e,t,n).length>0&&a(r)}var gQ,_Q,vQ,yQ,bQ,xQ,SQ=B(()=>{cH(),tq(),U(),jK(),ZB(),vTe(),yTe(),aK(),HZ(),gQ=class e extends Error{label;partialResults;constructor(e,t=[]){super(`break ${e}`),this.label=e,this.partialResults=t,this.name=`BreakError`}withPrependedResults(t){return new e(this.label,[...t,...this.partialResults])}},_Q=class extends Error{value;constructor(e){super(typeof e==`string`?e:JSON.stringify(e)),this.value=e,this.name=`JqError`}},vQ=1e4,yQ=10485760,bQ=2e3,xQ=new Map([[`floor`,Math.floor],[`ceil`,Math.ceil],[`round`,Math.round],[`sqrt`,Math.sqrt],[`log`,Math.log],[`log10`,Math.log10],[`log2`,Math.log2],[`exp`,Math.exp],[`sin`,Math.sin],[`cos`,Math.cos],[`tan`,Math.tan],[`asin`,Math.asin],[`acos`,Math.acos],[`atan`,Math.atan],[`sinh`,Math.sinh],[`cosh`,Math.cosh],[`tanh`,Math.tanh],[`asinh`,Math.asinh],[`acosh`,Math.acosh],[`atanh`,Math.atanh],[`cbrt`,Math.cbrt],[`expm1`,Math.expm1],[`log1p`,Math.log1p],[`trunc`,Math.trunc]])});function CQ(e){let t=[],n=0,r=(t=0)=>e[n+t],i=()=>e[n++],a=()=>n>=e.length,o=e=>e>=`0`&&e<=`9`,s=e=>e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e===`_`,c=e=>s(e)||o(e);for(;!a();){let l=n,u=i();if(u!==` `&&u!==` `&&u!==` `&&u!==`\r`){if(u===`#`){for(;!a()&&r()!==` `;)i();continue}if(u===`.`&&r()===`.`){i(),t.push({type:`DOTDOT`,pos:l});continue}if(u===`=`&&r()===`=`){i(),t.push({type:`EQ`,pos:l});continue}if(u===`!`&&r()===`=`){i(),t.push({type:`NE`,pos:l});continue}if(u===`<`&&r()===`=`){i(),t.push({type:`LE`,pos:l});continue}if(u===`>`&&r()===`=`){i(),t.push({type:`GE`,pos:l});continue}if(u===`/`&&r()===`/`){i(),r()===`=`?(i(),t.push({type:`UPDATE_ALT`,pos:l})):t.push({type:`ALT`,pos:l});continue}if(u===`+`&&r()===`=`){i(),t.push({type:`UPDATE_ADD`,pos:l});continue}if(u===`-`&&r()===`=`){i(),t.push({type:`UPDATE_SUB`,pos:l});continue}if(u===`*`&&r()===`=`){i(),t.push({type:`UPDATE_MUL`,pos:l});continue}if(u===`/`&&r()===`=`){i(),t.push({type:`UPDATE_DIV`,pos:l});continue}if(u===`%`&&r()===`=`){i(),t.push({type:`UPDATE_MOD`,pos:l});continue}if(u===`=`&&r()!==`=`){t.push({type:`ASSIGN`,pos:l});continue}if(u===`.`){t.push({type:`DOT`,pos:l});continue}if(u===`|`){r()===`=`?(i(),t.push({type:`UPDATE_PIPE`,pos:l})):t.push({type:`PIPE`,pos:l});continue}if(u===`,`){t.push({type:`COMMA`,pos:l});continue}if(u===`:`){t.push({type:`COLON`,pos:l});continue}if(u===`;`){t.push({type:`SEMICOLON`,pos:l});continue}if(u===`(`){t.push({type:`LPAREN`,pos:l});continue}if(u===`)`){t.push({type:`RPAREN`,pos:l});continue}if(u===`[`){t.push({type:`LBRACKET`,pos:l});continue}if(u===`]`){t.push({type:`RBRACKET`,pos:l});continue}if(u===`{`){t.push({type:`LBRACE`,pos:l});continue}if(u===`}`){t.push({type:`RBRACE`,pos:l});continue}if(u===`?`){t.push({type:`QUESTION`,pos:l});continue}if(u===`+`){t.push({type:`PLUS`,pos:l});continue}if(u===`-`){t.push({type:`MINUS`,pos:l});continue}if(u===`*`){t.push({type:`STAR`,pos:l});continue}if(u===`/`){t.push({type:`SLASH`,pos:l});continue}if(u===`%`){t.push({type:`PERCENT`,pos:l});continue}if(u===`<`){t.push({type:`LT`,pos:l});continue}if(u===`>`){t.push({type:`GT`,pos:l});continue}if(o(u)){let s=u;for(;!a()&&(o(r())||r()===`.`||r()===`e`||r()===`E`);)(r()===`e`||r()===`E`)&&(e[n+1]===`+`||e[n+1]===`-`)&&(s+=i()),s+=i();t.push({type:`NUMBER`,value:Number(s),pos:l});continue}if(u===`"`){let e=``,n=0;for(;!a();){let t=r();if(n===0&&t===`"`)break;if(n===0&&t===`\\`){if(i(),a())break;let t=i();switch(t){case`n`:e+=` `;break;case`r`:e+=`\r`;break;case`t`:e+=` `;break;case`\\`:e+=`\\`;break;case`"`:e+=`"`;break;case`(`:e+=`\\(`,n=1;break;default:e+=t}continue}if(n>0){if(t===`"`){for(e+=i();!a();){let t=r();if(t===`\\`){e+=i(),a()||(e+=i());continue}if(e+=i(),t===`"`)break}continue}t===`(`?n++:t===`)`&&n--,e+=i();continue}e+=i()}a()||i(),t.push({type:`STRING`,value:e,pos:l});continue}if(s(u)||u===`$`||u===`@`){let e=u;for(;!a()&&c(r());)e+=i();let n=wQ.get(e);n?t.push({type:n,value:e,pos:l}):t.push({type:`IDENT`,value:e,pos:l});continue}throw Error(`Unexpected character '${u}' at position ${l}`)}}return t.push({type:`EOF`,pos:n}),t}function ETe(e,t={}){let n=t.maxDepth??256,r=t.maxTokens??1e5,i=t.maxSourceLength??1048576;if(e.length>i)throw Error(`query source length limit exceeded (${i} characters)`);if(e.length+1>r)throw Error(`query token limit exceeded (${r})`);let a=CQ(e);return new EQ(a,n).parse()}var wQ,TQ,EQ,DTe=B(()=>{wQ=new Map([[`and`,`AND`],[`or`,`OR`],[`not`,`NOT`],[`if`,`IF`],[`then`,`THEN`],[`elif`,`ELIF`],[`else`,`ELSE`],[`end`,`END`],[`as`,`AS`],[`try`,`TRY`],[`catch`,`CATCH`],[`true`,`TRUE`],[`false`,`FALSE`],[`null`,`NULL`],[`reduce`,`REDUCE`],[`foreach`,`FOREACH`],[`label`,`LABEL`],[`break`,`BREAK`],[`def`,`DEF`]]),TQ=new Set(wQ.values()),EQ=class e{maxDepth;tokens;pos=0;depth;constructor(e,t,n=0){this.maxDepth=t,this.tokens=e,this.depth=n}peek(e=0){return this.tokens[this.pos+e]??{type:`EOF`,pos:-1}}advance(){return this.tokens[this.pos++]}check(e){return this.peek().type===e}match(...e){for(let t of e)if(this.check(t))return this.advance();return null}expect(e,t){if(!this.check(e))throw Error(`${t} at position ${this.peek().pos}, got ${this.peek().type}`);return this.advance()}withDepth(e){if(this.depth++,this.depth>this.maxDepth)throw this.depth--,Error(`query parse depth limit exceeded (${this.maxDepth})`);try{return e()}finally{this.depth--}}isFieldNameAfterDot(e=0){let t=this.peek(e),n=this.peek(e+1);return n.type===`STRING`?!0:n.type===`IDENT`||TQ.has(n.type)?n.pos===t.pos+1:!1}isIdentLike(){let e=this.peek().type;return e===`IDENT`||TQ.has(e)}consumeFieldNameAfterDot(e){let t=this.peek();return t.type===`STRING`||(t.type===`IDENT`||TQ.has(t.type))&&t.pos===e.pos+1?this.advance().value:null}parse(){let e=this.parseExpr();if(!this.check(`EOF`))throw Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`);return e}parseExpr(){if(this.depth++,this.depth>this.maxDepth)throw this.depth--,Error(`query parse depth limit exceeded (${this.maxDepth})`);try{return this.parsePipe()}finally{this.depth--}}parsePattern(){if(this.depth++,this.depth>this.maxDepth)throw this.depth--,Error(`query parse depth limit exceeded (${this.maxDepth})`);try{return this.parsePatternInner()}finally{this.depth--}}parsePatternInner(){if(this.match(`LBRACKET`)){let e=[];if(!this.check(`RBRACKET`))for(e.push(this.parsePattern());this.match(`COMMA`)&&!this.check(`RBRACKET`);)e.push(this.parsePattern());return this.expect(`RBRACKET`,`Expected ']' after array pattern`),{type:`array`,elements:e}}if(this.match(`LBRACE`)){let e=[];if(!this.check(`RBRACE`))for(e.push(this.parsePatternField());this.match(`COMMA`)&&!this.check(`RBRACE`);)e.push(this.parsePatternField());return this.expect(`RBRACE`,`Expected '}' after object pattern`),{type:`object`,fields:e}}let e=this.expect(`IDENT`,`Expected variable name in pattern`),t=e.value;if(!t.startsWith(`$`))throw Error(`Variable name must start with $ at position ${e.pos}`);return{type:`var`,name:t}}parsePatternField(){if(this.match(`LPAREN`)){let e=this.parseExpr();return this.expect(`RPAREN`,`Expected ')' after computed key`),this.expect(`COLON`,`Expected ':' after computed key`),{key:e,pattern:this.parsePattern()}}let e=this.peek();if(e.type===`IDENT`||TQ.has(e.type)){let t=e.value;if(t.startsWith(`$`)){if(this.advance(),this.match(`COLON`)){let e=this.parsePattern();return{key:t.slice(1),pattern:e,keyVar:t}}return{key:t.slice(1),pattern:{type:`var`,name:t}}}return this.advance(),this.match(`COLON`)?{key:t,pattern:this.parsePattern()}:{key:t,pattern:{type:`var`,name:`$${t}`}}}throw Error(`Expected field name in object pattern at position ${e.pos}`)}parsePipe(){let e=this.parseComma();for(;this.match(`PIPE`);){let t=this.parseComma();e={type:`Pipe`,left:e,right:t}}return e}parseComma(){let e=this.parseVarBind();for(;this.match(`COMMA`);){let t=this.parseVarBind();e={type:`Comma`,left:e,right:t}}return e}parseVarBind(){let e=this.parseUpdate();if(this.match(`AS`)){let t=this.parsePattern(),n=[];for(;this.check(`QUESTION`)&&this.peekAhead(1)?.type===`ALT`;)this.advance(),this.advance(),n.push(this.parsePattern());this.expect(`PIPE`,`Expected '|' after variable binding`);let r=this.parseExpr();return t.type===`var`&&n.length===0?{type:`VarBind`,name:t.name,value:e,body:r}:{type:`VarBind`,name:t.type===`var`?t.name:``,value:e,body:r,pattern:t.type===`var`?void 0:t,alternatives:n.length>0?n:void 0}}return e}peekAhead(e){let t=this.pos+e;return tthis.parseVarBind()),i=t.get(n.type);if(i)return{type:`UpdateOp`,op:i,path:e,value:r}}return e}parseAlt(){let e=this.parseOr();for(;this.match(`ALT`);){let t=this.parseOr();e={type:`BinaryOp`,op:`//`,left:e,right:t}}return e}parseOr(){let e=this.parseAnd();for(;this.match(`OR`);){let t=this.parseAnd();e={type:`BinaryOp`,op:`or`,left:e,right:t}}return e}parseAnd(){let e=this.parseNot();for(;this.match(`AND`);){let t=this.parseNot();e={type:`BinaryOp`,op:`and`,left:e,right:t}}return e}parseNot(){return this.parseComparison()}parseComparison(){let e=this.parseAddSub(),t=new Map([[`EQ`,`==`],[`NE`,`!=`],[`LT`,`<`],[`LE`,`<=`],[`GT`,`>`],[`GE`,`>=`]]),n=this.match(`EQ`,`NE`,`LT`,`LE`,`GT`,`GE`);if(n){let r=t.get(n.type);if(r){let t=this.parseAddSub();e={type:`BinaryOp`,op:r,left:e,right:t}}}return e}parseAddSub(){let e=this.parseMulDiv();for(;;)if(this.match(`PLUS`)){let t=this.parseMulDiv();e={type:`BinaryOp`,op:`+`,left:e,right:t}}else if(this.match(`MINUS`)){let t=this.parseMulDiv();e={type:`BinaryOp`,op:`-`,left:e,right:t}}else break;return e}parseMulDiv(){let e=this.parseUnary();for(;;)if(this.match(`STAR`)){let t=this.parseUnary();e={type:`BinaryOp`,op:`*`,left:e,right:t}}else if(this.match(`SLASH`)){let t=this.parseUnary();e={type:`BinaryOp`,op:`/`,left:e,right:t}}else if(this.match(`PERCENT`)){let t=this.parseUnary();e={type:`BinaryOp`,op:`%`,left:e,right:t}}else break;return e}parseUnary(){let e=0;for(;this.match(`MINUS`);)if(e++,this.depth+e>this.maxDepth)throw Error(`query parse depth limit exceeded (${this.maxDepth})`);let t=this.parsePostfix();for(;e-->0;)t={type:`UnaryOp`,op:`-`,operand:t};return t}parsePostfix(){let e=this.parsePrimary();for(;;)if(this.match(`QUESTION`))e={type:`Optional`,expr:e};else if(this.check(`DOT`)&&this.isFieldNameAfterDot())this.advance(),e={type:`Field`,name:this.advance().value,base:e};else if(this.check(`LBRACKET`)){if(this.advance(),this.match(`RBRACKET`))e={type:`Iterate`,base:e};else if(this.check(`COLON`)){this.advance();let t=this.check(`RBRACKET`)?void 0:this.parseExpr();this.expect(`RBRACKET`,`Expected ']'`),e={type:`Slice`,end:t,base:e}}else{let t=this.parseExpr();if(this.match(`COLON`)){let n=this.check(`RBRACKET`)?void 0:this.parseExpr();this.expect(`RBRACKET`,`Expected ']'`),e={type:`Slice`,start:t,end:n,base:e}}else this.expect(`RBRACKET`,`Expected ']'`),e={type:`Index`,index:t,base:e}}}else break;return e}parsePrimary(){if(this.match(`DOTDOT`))return{type:`Recurse`};if(this.check(`DOT`)){let e=this.advance();if(this.check(`LBRACKET`)){if(this.advance(),this.match(`RBRACKET`))return{type:`Iterate`};if(this.check(`COLON`)){this.advance();let e=this.check(`RBRACKET`)?void 0:this.parseExpr();return this.expect(`RBRACKET`,`Expected ']'`),{type:`Slice`,end:e}}let e=this.parseExpr();if(this.match(`COLON`)){let t=this.check(`RBRACKET`)?void 0:this.parseExpr();return this.expect(`RBRACKET`,`Expected ']'`),{type:`Slice`,start:e,end:t}}return this.expect(`RBRACKET`,`Expected ']'`),{type:`Index`,index:e}}let t=this.consumeFieldNameAfterDot(e);return t===null?{type:`Identity`}:{type:`Field`,name:t}}if(this.match(`TRUE`))return{type:`Literal`,value:!0};if(this.match(`FALSE`))return{type:`Literal`,value:!1};if(this.match(`NULL`))return{type:`Literal`,value:null};if(this.check(`NUMBER`))return{type:`Literal`,value:this.advance().value};if(this.check(`STRING`)){let e=this.advance().value;return e.includes(`\\(`)?this.parseStringInterpolation(e):{type:`Literal`,value:e}}if(this.match(`LBRACKET`)){if(this.match(`RBRACKET`))return{type:`Array`};let e=this.parseExpr();return this.expect(`RBRACKET`,`Expected ']'`),{type:`Array`,elements:e}}if(this.match(`LBRACE`))return this.parseObjectConstruction();if(this.match(`LPAREN`)){let e=this.parseExpr();return this.expect(`RPAREN`,`Expected ')'`),{type:`Paren`,expr:e}}if(this.match(`IF`))return this.parseIf();if(this.match(`TRY`)){let e=this.withDepth(()=>this.parsePostfix()),t;return this.match(`CATCH`)&&(t=this.withDepth(()=>this.parsePostfix())),{type:`Try`,body:e,catch:t}}if(this.match(`REDUCE`)){let e=this.parseAddSub();this.expect(`AS`,`Expected 'as' after reduce expression`);let t=this.parsePattern();this.expect(`LPAREN`,`Expected '(' after variable`);let n=this.parseExpr();this.expect(`SEMICOLON`,`Expected ';' after init expression`);let r=this.parseExpr();return this.expect(`RPAREN`,`Expected ')' after update expression`),{type:`Reduce`,expr:e,varName:t.type===`var`?t.name:``,init:n,update:r,pattern:t.type===`var`?void 0:t}}if(this.match(`FOREACH`)){let e=this.parseAddSub();this.expect(`AS`,`Expected 'as' after foreach expression`);let t=this.parsePattern();this.expect(`LPAREN`,`Expected '(' after variable`);let n=this.parseExpr();this.expect(`SEMICOLON`,`Expected ';' after init expression`);let r=this.parseExpr(),i;return this.match(`SEMICOLON`)&&(i=this.parseExpr()),this.expect(`RPAREN`,`Expected ')' after expressions`),{type:`Foreach`,expr:e,varName:t.type===`var`?t.name:``,init:n,update:r,extract:i,pattern:t.type===`var`?void 0:t}}if(this.match(`LABEL`)){let e=this.expect(`IDENT`,`Expected label name (e.g., $out)`),t=e.value;if(!t.startsWith(`$`))throw Error(`Label name must start with $ at position ${e.pos}`);return this.expect(`PIPE`,`Expected '|' after label name`),{type:`Label`,name:t,body:this.parseExpr()}}if(this.match(`BREAK`)){let e=this.expect(`IDENT`,`Expected label name to break to`),t=e.value;if(!t.startsWith(`$`))throw Error(`Break label must start with $ at position ${e.pos}`);return{type:`Break`,name:t}}if(this.match(`DEF`)){let e=this.expect(`IDENT`,`Expected function name after def`).value,t=[];if(this.match(`LPAREN`)){if(!this.check(`RPAREN`)){let e=this.expect(`IDENT`,`Expected parameter name`);for(t.push(e.value);this.match(`SEMICOLON`);){let e=this.expect(`IDENT`,`Expected parameter name`);t.push(e.value)}}this.expect(`RPAREN`,`Expected ')' after parameters`)}this.expect(`COLON`,`Expected ':' after function name`);let n=this.parseExpr();return this.expect(`SEMICOLON`,`Expected ';' after function body`),{type:`Def`,name:e,params:t,funcBody:n,body:this.parseExpr()}}if(this.match(`NOT`))return{type:`Call`,name:`not`,args:[]};if(this.check(`IDENT`)){let e=this.advance().value;if(e.startsWith(`$`))return{type:`VarRef`,name:e};if(this.match(`LPAREN`)){let t=[];if(!this.check(`RPAREN`))for(t.push(this.parseExpr());this.match(`SEMICOLON`);)t.push(this.parseExpr());return this.expect(`RPAREN`,`Expected ')'`),{type:`Call`,name:e,args:t}}return{type:`Call`,name:e,args:[]}}throw Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`)}parseObjectConstruction(){if(this.depth++,this.depth>this.maxDepth)throw this.depth--,Error(`query parse depth limit exceeded (${this.maxDepth})`);try{return this.parseObjectConstructionInner()}finally{this.depth--}}parseObjectConstructionInner(){let e=[];if(!this.check(`RBRACE`))do{let t,n;if(this.match(`LPAREN`))t=this.parseExpr(),this.expect(`RPAREN`,`Expected ')'`),this.expect(`COLON`,`Expected ':'`),n=this.parseObjectValue();else if(this.isIdentLike()){let e=this.advance().value;this.match(`COLON`)?(t=e,n=this.parseObjectValue()):(t=e,n={type:`Field`,name:e})}else if(this.check(`STRING`))t=this.advance().value,this.expect(`COLON`,`Expected ':'`),n=this.parseObjectValue();else throw Error(`Expected object key at position ${this.peek().pos}`);e.push({key:t,value:n})}while(this.match(`COMMA`));return this.expect(`RBRACE`,`Expected '}'`),{type:`Object`,entries:e}}parseObjectValue(){let e=this.parseVarBind();for(;this.match(`PIPE`);){let t=this.parseVarBind();e={type:`Pipe`,left:e,right:t}}return e}parseIf(){let e=this.parseExpr();this.expect(`THEN`,`Expected 'then'`);let t=this.parseExpr(),n=[];for(;this.match(`ELIF`);){let e=this.parseExpr();this.expect(`THEN`,`Expected 'then' after elif`);let t=this.parseExpr();n.push({cond:e,then:t})}let r;return this.match(`ELSE`)&&(r=this.parseExpr()),this.expect(`END`,`Expected 'end'`),{type:`Cond`,cond:e,then:t,elifs:n,else:r}}parseStringInterpolation(t){let n=[],r=``,i=0;for(;i0;){let e=t[i];if(e===`"`){for(o+=e,i++;i0&&(o+=e),i++}let s=CQ(o),c=new e(s,this.maxDepth,this.depth);n.push(c.parse())}else r+=t[i],i++;return r&&n.push(r),{type:`StringInterp`,parts:n}}}}),OTe=B(()=>{SQ(),DTe()});function kTe(e,t,n={}){let r=new sH(t,`query JSON output`,()=>new H(`output size limit exceeded (${t} bytes)`,n.limitKind??`output_size`));return DQ(r,e,n,0),r.build()}function DQ(e,t,n,r){if(t==null){e.append(`null`);return}if(typeof t==`boolean`){e.append(String(t));return}if(typeof t==`number`){e.append(Number.isFinite(t)?String(t):`null`);return}if(typeof t==`string`){n.raw&&r===0?e.append(t):OQ(e,t);return}let i=n.compact??!1,a=n.indent??2,o=n.useTab?` `:` `.repeat(a);if(Array.isArray(t)){e.append(`[`);for(let a=0;a0&&e.append(` `).repeat(o,r),e.append(`]`);return}let s=Object.keys(t);n.sortKeys&&(s=s.sort()),e.append(`{`);for(let a=0;a0&&e.append(` `).repeat(o,r),e.append(`}`)}function OQ(e,t){e.append(`"`);let n=0;for(let r=0;r{cH(),U()}),kQ={};Tz(kQ,{flagsForFuzzing:()=>FQ,jqCommand:()=>PQ});function jTe(e){switch(e){case`\b`:return`\\b`;case`\f`:return`\\f`;case` `:return`\\n`;case`\r`:return`\\r`;case` `:return`\\t`;default:return`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`}}function MTe(e){let t=``,n=!1,r=!1;for(let i=0;i{if(n.length>=t.maxElements)throw new H(`query result element limit exceeded (${t.maxElements})`,`array_elements`);n.push(e)},i=0,a=e.length;for(;i=a)break;let n=i,o=e[i];if(o===`{`||o===`[`){let s=[o===`{`?`}`:`]`],c=!1,l=!1;for(i++;i0;){let n=e[i];if(l)l=!1;else if(n===`\\`)l=!0;else if(n===`"`)c=!c;else if(!c){if(n===`{`||n===`[`){if(s.push(n===`{`?`}`:`]`),s.length>t.maxDepth)throw new H(`query depth limit exceeded (${t.maxDepth})`,`recursion`)}else if((n===`}`||n===`]`)&&s.pop()!==n)throw Error(`Mismatched JSON delimiter at position ${i}`)}i++}if(s.length!==0)throw Error(`Unexpected end of JSON input at position ${i} (unclosed ${o})`);r(eK(AQ(e,n,i),{maxDepth:t.maxDepth,maxElements:t.maxElements}))}else if(o===`"`){let o=!1;for(i++;i=`0`&&o<=`9`){for(;i{AB(),yH(),U(),jK(),oB(),hV(),cV(),ZB(),OTe(),ATe(),aK(),HZ(),NQ={name:`jq`,summary:`command-line JSON processor`,usage:`jq [OPTIONS] FILTER [FILE...]`,options:[`-R, --raw-input read each line as string instead of JSON`,`-r, --raw-output output strings without quotes`,`-c, --compact-output compact instead of pretty-printed output`,`-e, --exit-status set exit status based on output`,`-s, --slurp read entire input into array`,`-n, --null-input don't read any input`,`-j, --join-output don't print newlines after each output`,`-a, --ascii force ASCII output`,`-S, --sort-keys sort object keys`,`-C, --color colorize output (ignored)`,`-M, --monochrome monochrome output (ignored)`,` --tab use tabs for indentation`,` --arg NAME VALUE bind $NAME to the string VALUE`,` --argjson NAME JSON bind $NAME to the JSON-decoded value JSON`,` --rawfile NAME FILE bind $NAME to the raw contents of FILE`,` --slurpfile NAME FILE bind $NAME to the array of JSON values in FILE`,` --args remaining arguments are string positional args ($ARGS.positional)`,` --jsonargs remaining arguments are JSON positional args ($ARGS.positional)`,` --help display this help and exit`]},PQ={name:`jq`,async execute(e,t){kK(t.requireDefenseContext,`jq`,`execution entry`);let n=(e,n)=>AK(t.requireDefenseContext,`jq`,e,n);if(oV(e))return aV(NQ);let r=!1,i=!1,a=!1,o=!1,s=!1,c=!1,l=!1,u=!1,d=!1,f=`.`,p=!1,m=`none`,h=[],g=new Map,_=[],v=[],y={maxDepth:t.limits.maxQueryDepth,maxElements:t.limits.maxQueryElements};for(let t=0;t0){let e=await n(`arg file read`,()=>pV(t,v.map(e=>e.file),{cmdName:`jq`,stopOnError:!0}));if(e.exitCode!==0)return{stdout:``,stderr:e.stderr,exitCode:2};for(let t=0;tpV(t,h,{cmdName:`jq`,stopOnError:!0}));if(e.exitCode!==0)return{stdout:``,stderr:e.stderr,exitCode:2};b=e.files.map(e=>({source:e.filename||`stdin`,content:yB(e.content)}))}}try{let e=ETe(f,{maxDepth:t.limits.maxQueryDepth,maxTokens:t.limits.maxQueryTokens,maxSourceLength:t.limits.maxStringLength}),n=[],p={limits:t.limits?{maxIterations:t.limits.maxJqIterations,maxStringLength:t.limits.maxStringLength,maxOutputSize:t.limits.maxOutputSize,maxArrayElements:t.limits.maxQueryElements,maxDepth:t.limits.maxQueryDepth}:void 0,env:t.env,namedArgs:g,positionalArgs:_,coverage:t.coverage,requireDefenseContext:t.requireDefenseContext,budget:{operations:0,callDepth:0}},m=(e,n)=>{if(n.length>t.limits.maxQueryElements-e.length)throw new H(`query result element limit exceeded (${t.limits.maxQueryElements})`,`array_elements`);for(let t of n)e.push(t)};if(c)n=Y(null,e,p);else if(i&&s)n=Y(b.map(({content:e})=>e).join(``),e,p);else if(i){let t=``;for(let{content:r}of b){let i=t+r,a=0,o=i.indexOf(` `,a);for(;o!==-1;)m(n,Y(i.slice(a,o),e,p)),a=o+1,o=i.indexOf(` `,a);t=i.slice(a)}t!==``&&m(n,Y(t,e,p))}else if(s){let t=[];for(let{content:e}of b){let n=e.trim();n&&m(t,jQ(n,y))}n=Y(t,e,p)}else for(let{content:t}of b){let r=t.trim();if(!r)continue;let i=jQ(r,y);for(let t of i)m(n,Y(t,e,p))}let h=l?``:` `,v=Math.min(t.limits.maxStringLength,t.limits.maxOutputSize),x=[],S=0;for(let e of n){let n=x.length>0?h.length:0,i=+!l,o=v-S-n-i;if(o<0)throw new H(`output size limit exceeded (${v} bytes)`,`string_length`);if(zZ(e,t.limits.maxQueryDepth+1)>t.limits.maxQueryDepth)throw new H(`query depth limit exceeded (${t.limits.maxQueryDepth})`,`recursion`);let s=kTe(e,o,{compact:a,raw:r,sortKeys:u,useTab:d,limitKind:`string_length`}),c=V(s);if(S+n+c+i>v)throw new H(`output size limit exceeded (${v} bytes)`,`string_length`);S+=n+c,x.push(s)}let C=x.join(h),w=o&&(n.length===0||n.every(e=>e==null||e===!1))?1:0;return{stdout:C?l?C:`${C} `:``,stderr:``,exitCode:w}}catch(e){if(e instanceof tB)throw e;if(e instanceof H)return{stdout:``,stderr:`jq: ${vH(e.message)} `,exitCode:H.EXIT_CODE};let t=vH(e.message);return t.includes(`Unknown function`)?{stdout:``,stderr:`jq: error: ${t} `,exitCode:3}:{stdout:``,stderr:`jq: parse error: ${t} `,exitCode:5}}}},FQ={name:`jq`,flags:[{flag:`-R`,type:`boolean`},{flag:`-r`,type:`boolean`},{flag:`-c`,type:`boolean`},{flag:`-e`,type:`boolean`},{flag:`-s`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-j`,type:`boolean`},{flag:`-S`,type:`boolean`},{flag:`--tab`,type:`boolean`}],stdinType:`json`,needsArgs:!0}}),IQ={};Tz(IQ,{base64Command:()=>UQ,flagsForFuzzing:()=>WQ});function LQ(e,t,n,r){if(e>t)throw new H(`base64: ${n} limit exceeded (${t} bytes)`,r)}function RQ(e){let t=[];for(let n=0;ne.charCodeAt(0))};let a=[],o=0;for(let s of t){if(s===`-`){LQ(o+i.length,r,`input size`,`string_length`),a.push(Uint8Array.from(i,e=>e.charCodeAt(0))),o+=i.length;continue}try{let t=e.fs.resolvePath(e.cwd,s),i=await e.fs.stat(t);LQ(o+i.size,r,`input size`,`string_length`);let c=await e.fs.readFileBuffer(t);LQ(o+c.length,r,`input size`,`string_length`),fV(e,c.length,n),a.push(c),o+=c.length}catch(e){return rV(e),{ok:!1,error:{stdout:``,stderr:`${n}: ${s}: No such file or directory `,exitCode:1}}}}let s=new Uint8Array(o),c=0;for(let e of a)s.set(e,c),c+=e.length;return{ok:!0,data:s}}var VQ,HQ,UQ,WQ,PTe=B(()=>{AB(),iV(),U(),uV(),hV(),cV(),VQ={name:`base64`,summary:`base64 encode/decode data and print to standard output`,usage:`base64 [OPTION]... [FILE]`,options:[`-d, --decode decode data`,`-w, --wrap=COLS wrap encoded lines after COLS character (default 76, 0 to disable)`,` --help display this help and exit`]},HQ={decode:{short:`d`,long:`decode`,type:`boolean`},wrap:{short:`w`,long:`wrap`,type:`number`,default:76}},UQ={name:`base64`,async execute(e,t){if(oV(e))return aV(VQ);let n=lV(`base64`,e,HQ);if(!n.ok)return n.error;let r=n.result.flags.decode,i=n.result.flags.wrap,a=n.result.positional;if(!Number.isSafeInteger(i)||i<0)return{stdout:``,stderr:`base64: invalid wrap size `,exitCode:1};try{if(r){let e=await BQ(t,a,`base64`);if(!e.ok)return e.error;if(typeof Buffer<`u`){let n=Buffer.from(e.data).toString(`utf8`).replace(/\s/g,``),r=zQ(n);LQ(r,t.limits.maxStringLength,`decoded size`,`string_length`),LQ(r,t.limits.maxOutputSize,`output size`,`output_size`);let i=Buffer.from(n,`base64`);return LQ(i.length,t.limits.maxOutputSize,`output size`,`output_size`),{stdout:i.toString(`latin1`),stderr:``,exitCode:0,stdoutEncoding:`binary`}}let n=RQ(e.data).replace(/\s/g,``),r=zQ(n);LQ(r,t.limits.maxStringLength,`decoded size`,`string_length`),LQ(r,t.limits.maxOutputSize,`output size`,`output_size`);let i=atob(n);return LQ(i.length,t.limits.maxOutputSize,`output size`,`output_size`),{stdout:i,stderr:``,exitCode:0,stdoutEncoding:`binary`}}let e=await BQ(t,a,`base64`);if(!e.ok)return e.error;let n=Math.ceil(e.data.length/3)*4,o=i>0&&n>0?Math.ceil(n/i):0;if(o>t.limits.maxArrayElements)throw new H(`base64: wrapped line limit exceeded (${t.limits.maxArrayElements})`,`array_elements`);LQ(n,t.limits.maxStringLength,`encoded size`,`string_length`),LQ(n+o,t.limits.maxOutputSize,`output size`,`output_size`);let s;if(s=typeof Buffer<`u`?Buffer.from(e.data).toString(`base64`):btoa(RQ(e.data)),i>0){let e=[];for(let t=0;t0?` `:``)}return{stdout:s,stderr:``,exitCode:0}}catch(e){return rV(e),{stdout:``,stderr:`base64: invalid input `,exitCode:1}}}},WQ={name:`base64`,flags:[{flag:`-d`,type:`boolean`},{flag:`-w`,type:`value`,valueHint:`number`}],stdinType:`text`,needsFiles:!0}}),GQ={};Tz(GQ,{diffCommand:()=>JQ,flagsForFuzzing:()=>YQ});var KQ,qQ,JQ,YQ,FTe=B(()=>{AB(),uV(),cV(),KQ={name:`diff`,summary:`compare files line by line`,usage:`diff [OPTION]... FILE1 FILE2`,options:[`-u, --unified output unified diff format (default)`,`-q, --brief report only whether files differ`,`-s, --report-identical-files report when files are the same`,`-i, --ignore-case ignore case differences`,` --help display this help and exit`]},qQ={unified:{short:`u`,long:`unified`,type:`boolean`},brief:{short:`q`,long:`brief`,type:`boolean`},reportSame:{short:`s`,long:`report-identical-files`,type:`boolean`},ignoreCase:{short:`i`,long:`ignore-case`,type:`boolean`}},JQ={name:`diff`,async execute(e,t){if(oV(e))return aV(KQ);let n=lV(`diff`,e,qQ);if(!n.ok)return n.error;let r=n.result.flags.brief,i=n.result.flags.reportSame,a=n.result.flags.ignoreCase,o=n.result.positional;if(n.result.flags.unified,o.length<2)return{stdout:``,stderr:`diff: missing operand `,exitCode:2};let s,c,[l,u]=o;try{s=l===`-`?yB(t.stdin):await t.fs.readFile(t.fs.resolvePath(t.cwd,l))}catch{return{stdout:``,stderr:`diff: ${l}: No such file or directory `,exitCode:2}}try{c=u===`-`?yB(t.stdin):await t.fs.readFile(t.fs.resolvePath(t.cwd,u))}catch{return{stdout:``,stderr:`diff: ${u}: No such file or directory `,exitCode:2}}let d=s,f=c;return a&&(d=d.toLowerCase(),f=f.toLowerCase()),d===f?i?{stdout:`Files ${l} and ${u} are identical `,stderr:``,exitCode:0}:{stdout:``,stderr:``,exitCode:0}:r?{stdout:`Files ${l} and ${u} differ `,stderr:``,exitCode:1}:{stdout:wle(l,u,s,c,``,``,{context:3}),stderr:``,exitCode:1}}},YQ={name:`diff`,flags:[{flag:`-u`,type:`boolean`},{flag:`-q`,type:`boolean`},{flag:`-s`,type:`boolean`},{flag:`-i`,type:`boolean`}],needsArgs:!0,minArgs:2}}),XQ={};Tz(XQ,{dateCommand:()=>QQ,flagsForFuzzing:()=>$Q});function ITe(e){try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),!0}catch{return!1}}function LTe(e,t){let n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}).formatToParts(e),r=e=>n.find(t=>t.type===e)?.value??`00`,i=Number.parseInt(r(`hour`),10)%24,a=new Date(`${r(`year`)}-${r(`month`)}-${r(`day`)}T${String(i).padStart(2,`0`)}:${r(`minute`)}:${r(`second`)}Z`);return Number.isNaN(a.getTime())?null:a}function RTe(e,t){let n=e.match(/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?$/);if(!n)return null;let[,r,i,a,o=`00`,s=`00`,c=`00`]=n,l=new Date(`${r}-${i}-${a}T${o}:${s}:${c}Z`);if(Number.isNaN(l.getTime()))return null;try{let e=l;for(let n=0;n<3;n++){let n=LTe(e,t);if(n===null)return null;let r=n.getTime()-l.getTime();if(r===0)return e;e=new Date(e.getTime()-r)}return e}catch{return null}}function zTe(e,t){if(e.startsWith(`@`)){let t=e.slice(1);if(!/^-?\d+$/.test(t))return null;let n=Number(t);if(!Number.isSafeInteger(n))return null;let r=new Date(n*1e3);return Number.isNaN(r.getTime())?null:r}let n=e.toLowerCase().trim();if(n===`now`||n===`today`)return new Date;if(n===`yesterday`)return new Date(Date.now()-864e5);if(n===`tomorrow`)return new Date(Date.now()+864e5);if(t&&!/Z$/i.test(e)&&!/[+-]\d{2}:?\d{2}$/.test(e)){let n=RTe(e,t);if(n)return n}let r=new Date(e);return Number.isNaN(r.getTime())?null:r}var ZQ,QQ,$Q,BTe=B(()=>{cV(),IV(),ZQ={name:`date`,summary:`display the current time in the given FORMAT`,usage:`date [OPTION]... [+FORMAT]`,options:[`-d, --date=STRING display time described by STRING, not 'now'`,`-u, --utc print Coordinated Universal Time (UTC)`,`-I, --iso-8601 output date/time in ISO 8601 format`,`-R, --rfc-email output RFC 5322 date format`,` --help display this help and exit`]},QQ={name:`date`,async execute(e,t){if(oV(e))return aV(ZQ);let n=!1,r=null,i=null,a=!1,o=!1;for(let t=0;t{}),n$={};Tz(n$,{flagsForFuzzing:()=>o$,sleepCommand:()=>a$});var r$,i$,a$,o$,VTe=B(()=>{hB(),t$(),cV(),r$={name:`sleep`,summary:`delay for a specified amount of time`,usage:`sleep NUMBER[SUFFIX]`,description:`Pause for NUMBER seconds. SUFFIX may be: s - seconds (default) m - minutes h - hours d - days NUMBER may be a decimal number.`,options:[` --help display this help and exit`]},i$=36e5,a$={name:`sleep`,async execute(e,t){if(oV(e))return aV(r$);if(e.length===0)return{stdout:``,stderr:`sleep: missing operand `,exitCode:1};let n=0;for(let t of e){let e=e$(t);if(e===null)return{stdout:``,stderr:`sleep: invalid time interval '${t}' `,exitCode:1};n+=e}if(n>i$&&(n=i$),t.signal?.aborted)return{stdout:``,stderr:``,exitCode:0};if(t.sleep){let e=Promise.resolve(t.sleep(n));if(t.signal){let n,r=new Promise(e=>{n=e,t.signal?.addEventListener(`abort`,n,{once:!0}),t.signal?.aborted&&e()});try{await Promise.race([e,r])}finally{n&&t.signal.removeEventListener(`abort`,n)}}else await e}else t.signal?await new Promise(e=>{let r=()=>{pB(i),e()},i=fB(()=>{t.signal?.removeEventListener(`abort`,r),e()},n);t.signal?.addEventListener(`abort`,r,{once:!0})}):await new Promise(e=>fB(e,n));return{stdout:``,stderr:``,exitCode:0}}},o$={name:`sleep`,flags:[],needsArgs:!0}}),s$={};Tz(s$,{flagsForFuzzing:()=>u$,timeoutCommand:()=>l$});var c$,l$,u$,HTe=B(()=>{_B(),AB(),hK(),hB(),t$(),cV(),c$={name:`timeout`,summary:`run a command with a time limit`,usage:`timeout [OPTION] DURATION COMMAND [ARG]...`,description:`Start COMMAND, and kill it if still running after DURATION. DURATION is a number with optional suffix: s - seconds (default) m - minutes h - hours d - days`,options:[`-k, --kill-after=DURATION send KILL signal after DURATION if still running`,`-s, --signal=SIGNAL specify signal to send (default: TERM)`,` --preserve-status exit with same status as COMMAND, even on timeout`,` --foreground run command in foreground`,` --help display this help and exit`]},l$={name:`timeout`,async execute(e,t){if(oV(e))return aV(c$);let n=0;for(let t=0;t1&&r!==`--`){if(r.startsWith(`-k`))n=t+1;else if(r.startsWith(`-s`))n=t+1;else return sV(`timeout`,r)}else{n=t;break}}}let r=e.slice(n);if(r.length===0)return{stdout:``,stderr:`timeout: missing operand `,exitCode:1};let i=r[0],a=e$(i);if(a===null)return{stdout:``,stderr:`timeout: invalid time interval '${i}' `,exitCode:1};let o=r.slice(1);if(o.length===0)return{stdout:``,stderr:`timeout: missing operand `,exitCode:1};if(!t.exec)return{stdout:``,stderr:`timeout: exec not available `,exitCode:1};let s=new AbortController,c=gB(t.signal,s.signal),l,u;try{let e=new Promise(e=>{u=()=>e({timedOut:!0}),c.signal?.addEventListener(`abort`,u,{once:!0}),l=fB(()=>{s.abort()},a)}),n=t.exec(mK([o[0]]),{cwd:t.cwd,signal:c.signal,stdin:t.stdin,stdinKind:`bytes`,args:o.slice(1)}).then(e=>({timedOut:!1,result:e})),r=await Promise.race([e,n]);return r.timedOut?(await n.catch(()=>{}),{stdout:``,stderr:``,exitCode:124}):r.result}finally{l!==void 0&&pB(l),u&&c.signal?.removeEventListener(`abort`,u),c.cleanup()}}},u$={name:`timeout`,flags:[{flag:`-k`,type:`value`,valueHint:`string`},{flag:`-s`,type:`value`,valueHint:`string`},{flag:`--preserve-status`,type:`boolean`},{flag:`--foreground`,type:`boolean`}],needsArgs:!0,minArgs:2}}),d$,f$,p$,m$=B(()=>{globalThis.SharedArrayBuffer,globalThis.Atomics,d$=performance.now.bind(performance),f$=globalThis.Headers,p$=globalThis.Proxy}),h$={};Tz(h$,{flagsForFuzzing:()=>v$,timeCommand:()=>_$});function g$(e){let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}:${n.toString().padStart(2,`0`)}:${r.toFixed(2).padStart(5,`0`)}`:`${n}:${r.toFixed(2).padStart(5,`0`)}`}var _$,v$,UTe=B(()=>{AB(),yH(),tq(),hK(),m$(),_$={name:`time`,async execute(e,t){let n=`%e %M`,r=null,i=!1,a=!1,o=0;for(;o=e.length)return{stdout:``,stderr:`time: missing argument to '-f' `,exitCode:1};n=e[o],o++}else if(t===`-o`||t===`--output`){if(o++,o>=e.length)return{stdout:``,stderr:`time: missing argument to '-o' `,exitCode:1};r=e[o],o++}else if(t===`-a`||t===`--append`)i=!0,o++;else if(t===`-v`||t===`--verbose`)n=`Command being timed: %C Elapsed (wall clock) time: %e seconds Maximum resident set size (kbytes): %M`,o++;else if(t===`-p`||t===`--portability`)a=!0,o++;else if(t===`--`){o++;break}else if(t.startsWith(`-`))o++;else break}let s=e.slice(o);if(s.length===0)return{stdout:``,stderr:``,exitCode:0};let c=d$(),l=s.join(` `),u;try{if(!t.exec)return{stdout:``,stderr:`time: exec not available `,exitCode:1};u=await t.exec(mK([s[0]]),{env:QK(t.env),cwd:t.cwd,stdin:t.stdin,stdinKind:`bytes`,signal:t.signal,args:s.slice(1)})}catch(e){u={stdout:``,stderr:`time: ${vH(e.message)} `,exitCode:127}}let d=(d$()-c)/1e3,f;if(a?f=`real ${d.toFixed(2)} user 0.00 sys 0.00 `:(f=n.replace(/%e/g,d.toFixed(2)).replace(/%E/g,g$(d)).replace(/%M/g,`0`).replace(/%S/g,`0.00`).replace(/%U/g,`0.00`).replace(/%P/g,`0%`).replace(/%C/g,l),f.endsWith(` `)||(f+=` `)),r)try{let e=t.fs.resolvePath(t.cwd,r);if(i&&await t.fs.exists(e)){let n=await t.fs.readFile(e);await t.fs.writeFile(e,n+f)}else await t.fs.writeFile(e,f)}catch(e){let t=vH(e.message);return{stdout:u.stdout,stderr:u.stderr+`time: cannot write to '${r}': ${t} `,exitCode:u.exitCode}}else u={...u,stderr:u.stderr+f};return u}},v$={name:`time`,flags:[{flag:`-p`,type:`boolean`}],needsArgs:!0}}),y$={};Tz(y$,{flagsForFuzzing:()=>x$,seqCommand:()=>b$});var b$,x$,WTe=B(()=>{cH(),AB(),U(),b$={name:`seq`,async execute(e,t){let n=` `,r=!1,i=[],a=0;for(;a2){n=t.slice(2),a++;continue}if((t===`-ws`||t===`-sw`)&&(r=!0,a+1!Number.isFinite(parseFloat(e)))}' `,exitCode:1};if(s===0)return{stdout:``,stderr:`seq: invalid Zero increment value: '0' `,exitCode:1};let l=[],u=e=>{let t=String(e),n=t.indexOf(`.`);return n===-1?0:t.length-n-1},d=Math.max(u(o),u(s),u(c)),f=Math.min(t.limits.maxLoopIterations,t.limits.maxArrayElements),p=Math.min(t.limits.maxOutputSize,t.limits.maxStringLength),m=V(n),h=0,g=0,_=e=>{if(g>=f)throw new H(`seq: iteration limit exceeded (${f})`,`iterations`);let t=iH(iH(h,l.length>0?m:0,`seq`),iH(V(e),1,`seq`),`seq`);if(t>p)throw new H(`seq: output size limit exceeded (${p} bytes)`,`output_size`);h=t-1,l.push(e),g++};if(s>0)for(let e=o;e<=c+1e-10;e+=s)_(d>0?e.toFixed(d):String(Math.round(e)));else for(let e=o;e>=c-1e-10;e+=s)_(d>0?e.toFixed(d):String(Math.round(e)));if(r&&l.length>0){let e=0;for(let t of l)e=Math.max(e,t.startsWith(`-`)?t.length-1:t.length);if(iH(iH(l.reduce((t,n)=>iH(t,e+ +!!n.startsWith(`-`),`seq`),0),aH(m,Math.max(0,l.length-1),`seq`),`seq`),1,`seq`)>p)throw new H(`seq: output size limit exceeded (${p} bytes)`,`output_size`);for(let t=0;tC$,flagsForFuzzing:()=>w$});function GTe(e,t){if(e.length===1)return e[0];let n=0;function r(){let t=i();for(;n`,`<=`,`>=`].includes(r)){n++;let e=o(),i=parseInt(t,10),a=parseInt(e,10),s=!Number.isNaN(i)&&!Number.isNaN(a),c;c=r===`=`?s?i===a:t===e:r===`!=`?s?i!==a:t!==e:r===`<`?s?i`?s?i>a:t>e:r===`<=`?s?i<=a:t<=e:s?i>=a:t>=e,t=c?`1`:`0`}else break}return t}function o(){let t=s();for(;n=e.length)throw Error(`syntax error`);let i=e[n];if(i===`match`){n++;let e=l(),t=hG(l()).match(e);return t?t[1]===void 0?String(t[0].length):t[1]:`0`}if(i===`substr`){n++;let e=l(),t=parseInt(l(),10),r=parseInt(l(),10);if(Number.isNaN(t)||Number.isNaN(r))throw Error(`non-integer argument`);return e.substring(t-1,t-1+r)}if(i===`index`){n++;let e=l(),r=l();t(r.length+e.length);let i=new Set;for(let e=0;e=e.length||e[n]!==`)`)throw Error(`syntax error`);return n++,t}return n++,i}let u=r();if(n!==e.length)throw Error(`syntax error`);return u}var C$,w$,KTe=B(()=>{iV(),yH(),bG(),C$={name:`expr`,async execute(e,t){if(e.length===0)return{stdout:``,stderr:`expr: missing operand `,exitCode:2};try{let n=GTe(e,e=>t.executionScope?.consumeWork(e,`expr index`)),r=+(n===`0`||n===``);return{stdout:`${n} `,stderr:``,exitCode:r}}catch(e){return rV(e),{stdout:``,stderr:`expr: ${vH(e.message)} `,exitCode:2}}}},w$={name:`expr`,flags:[],needsArgs:!0}});function qTe(e){function t(e,t){return e<>>32-t}let n=new Uint32Array([3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745]),r=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],i=e.length*8,a=(e.length%64<56?56:120)-e.length%64,o=new Uint8Array(e.length+a+8);o.set(e),o[e.length]=128;let s=new DataView(o.buffer);s.setUint32(o.length-8,i>>>0,!0),s.setUint32(o.length-4,Math.floor(i/4294967296),!0);let c=1732584193,l=4023233417,u=2562383102,d=271733878;for(let e=0;e>>0,a=p,p=f,f=o,o=o+t(s,r[e])>>>0}c=c+a>>>0,l=l+o>>>0,u=u+f>>>0,d=d+p>>>0}let f=new Uint8Array(16);return new DataView(f.buffer).setUint32(0,c,!0),new DataView(f.buffer).setUint32(4,l,!0),new DataView(f.buffer).setUint32(8,u,!0),new DataView(f.buffer).setUint32(12,d,!0),Array.from(f).map(e=>e.toString(16).padStart(2,`0`)).join(``)}async function T$(e,t){if(e===`md5`)return qTe(t);let n=D$.get(e);if(!n)throw Error(`Unknown algorithm: ${e}`);let r=await globalThis.crypto.subtle.digest(n,new Uint8Array(t).buffer);return Array.from(new Uint8Array(r)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}function E$(e,t,n){let r={name:e,summary:n,usage:`${e} [OPTION]... [FILE]...`,options:[`-c, --check read checksums from FILEs and check them`,` --help display this help and exit`]};return{name:e,async execute(n,i){if(oV(n))return aV(r);let a=!1,o=[];for(let t of n)if(t===`-c`||t===`--check`)a=!0;else if(t!==`-b`&&t!==`-t`&&t!==`--binary`&&t!==`--text`){if(t.startsWith(`-`)&&t!==`-`)return sV(e,t);o.push(t)}o.length===0&&o.push(`-`);let s=async e=>{if(e===`-`)return Uint8Array.from(i.stdin,e=>e.charCodeAt(0));try{return await i.fs.readFileBuffer(i.fs.resolvePath(i.cwd,e))}catch{return null}};if(a){let n=0,r=``;for(let a of o){let o=a===`-`?yB(i.stdin):await i.fs.readFile(i.fs.resolvePath(i.cwd,a)).catch(()=>null);if(o===null)return{stdout:``,stderr:`${e}: ${a}: No such file or directory `,exitCode:1};for(let e of o.split(` `)){let i=e.match(/^([a-fA-F0-9]+)\s+[* ]?(.+)$/);if(!i)continue;let[,a,o]=i,c=await s(o);if(c===null){r+=`${o}: FAILED open or read `,n++;continue}let l=await T$(t,c)===a.toLowerCase();r+=`${o}: ${l?`OK`:`FAILED`} `,l||n++}}return n>0&&(r+=`${e}: WARNING: ${n} computed checksum${n>1?`s`:``} did NOT match `),{stdout:r,stderr:``,exitCode:+(n>0)}}let c=``,l=0;for(let n of o){let r=await s(n);if(r===null){c+=`${e}: ${n}: No such file or directory `,l=1;continue}c+=`${await T$(t,r)} ${n} `}return{stdout:c,stderr:``,exitCode:l}}}}var D$,O$=B(()=>{AB(),cV(),D$=new Map([[`sha1`,`SHA-1`],[`sha256`,`SHA-256`]])}),k$={};Tz(k$,{flagsForFuzzing:()=>j$,md5sumCommand:()=>A$});var A$,j$,JTe=B(()=>{O$(),A$=E$(`md5sum`,`md5`,`compute MD5 message digest`),j$={name:`md5sum`,flags:[{flag:`-c`,type:`boolean`}],needsFiles:!0}}),M$={};Tz(M$,{flagsForFuzzing:()=>P$,sha1sumCommand:()=>N$});var N$,P$,YTe=B(()=>{O$(),N$=E$(`sha1sum`,`sha1`,`compute SHA1 message digest`),P$={name:`sha1sum`,flags:[{flag:`-c`,type:`boolean`}],needsFiles:!0}}),F$={};Tz(F$,{flagsForFuzzing:()=>L$,sha256sumCommand:()=>I$});var I$,L$,XTe=B(()=>{O$(),I$=E$(`sha256sum`,`sha256`,`compute SHA256 message digest`),L$={name:`sha256sum`,flags:[{flag:`-c`,type:`boolean`}],needsFiles:!0}}),ZTe=wz(e=>{e.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else{if(a===c)return o?NaN:1/0*(p?-1:1);o+=2**r,a-=l}return(p?-1:1)*o*2**(a-r)},e.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=+(t<0||t===0&&1/t<0);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128}});function QTe(){if(!(typeof globalThis.TextDecoder>`u`))return oEe??=new globalThis.TextDecoder(`utf-8`)}function $Te(e,t=`utf-8`){switch(t.toLowerCase()){case`utf-8`:case`utf8`:{let t=QTe();return t?t.decode(e):tEe(e)}case`utf-16le`:return nEe(e);case`us-ascii`:case`ascii`:return rEe(e);case`latin1`:case`iso-8859-1`:return iEe(e);case`windows-1252`:return aEe(e);default:throw RangeError(`Encoding '${t}' not supported`)}}function R$(e,t){t.length!==0&&(e.push(String.fromCharCode.apply(null,t)),t.length=0)}function z$(e,t,n){t.push(n),t.length>=H$&&R$(e,t)}function eEe(e,t,n){if(n<=65535){z$(e,t,n);return}n-=65536,z$(e,t,55296+(n>>10)),z$(e,t,56320+(n&1023))}function tEe(e){let t=[],n=[],r=0;for(e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191&&(r=3);r244){z$(t,n,U$),r++;continue}if(i<=223){if(r+1>=e.length){z$(t,n,U$),r++;continue}let a=e[r+1];if((a&192)!=128){z$(t,n,U$),r++;continue}z$(t,n,(i&31)<<6|a&63),r+=2;continue}if(i<=239){if(r+2>=e.length){z$(t,n,U$),r++;continue}let a=e[r+1],o=e[r+2];if((a&192)!=128||(o&192)!=128||i===224&&a<160||i===237&&a>=160){z$(t,n,U$),r++;continue}z$(t,n,(i&15)<<12|(a&63)<<6|o&63),r+=3;continue}if(r+3>=e.length){z$(t,n,U$),r++;continue}let a=e[r+1],o=e[r+2],s=e[r+3];if((a&192)!=128||(o&192)!=128||(s&192)!=128||i===240&&a<144||i===244&&a>143){z$(t,n,U$),r++;continue}eEe(t,n,(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63),r+=4}return R$(t,n),t.join(``)}function nEe(e){let t=[],n=[],r=e.length,i=0;for(;i+1=55296&&a<=56319){if(i+1=56320&&r<=57343?(z$(t,n,a),z$(t,n,r),i+=2):z$(t,n,U$)}else z$(t,n,U$);continue}if(a>=56320&&a<=57343){z$(t,n,U$);continue}z$(t,n,a)}return i=128&&i<=159?B$[i]:void 0;n+=a??String.fromCharCode(i),n.length>=H$&&(t.push(n),n=``)}return n&&t.push(n),t.join(``)}var B$,V$,oEe,H$,U$,sEe=B(()=>{B$={128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`},V$={};for(let[e,t]of Object.entries(B$))V$[t]=Number.parseInt(e,10);H$=32768,U$=65533});function W$(e){return new DataView(e.buffer,e.byteOffset)}var G$,K$,q$,J$,Y$,X$,Z$,Q$,$$=B(()=>{Dz(ZTe(),1),sEe(),G$={len:1,get(e,t){return W$(e).getUint8(t)},put(e,t,n){return W$(e).setUint8(t,n),t+1}},K$={len:2,get(e,t){return W$(e).getUint16(t,!0)},put(e,t,n){return W$(e).setUint16(t,n,!0),t+2}},q$={len:2,get(e,t){return W$(e).getUint16(t)},put(e,t,n){return W$(e).setUint16(t,n),t+2}},J$={len:4,get(e,t){return W$(e).getUint32(t,!0)},put(e,t,n){return W$(e).setUint32(t,n,!0),t+4}},Y$={len:4,get(e,t){return W$(e).getUint32(t)},put(e,t,n){return W$(e).setUint32(t,n),t+4}},X$={len:4,get(e,t){return W$(e).getInt32(t)},put(e,t,n){return W$(e).setInt32(t,n),t+4}},Z$={len:8,get(e,t){return W$(e).getBigUint64(t,!0)},put(e,t,n){return W$(e).setBigUint64(t,n,!0),t+8}},Q$=class{constructor(e,t){this.len=e,this.encoding=t}get(e,t=0){return $Te(e.subarray(t,t+this.len),this.encoding)}}}),e1,t1,n1,r1=B(()=>{e1=`End-Of-Stream`,t1=class extends Error{constructor(){super(e1),this.name=`EndOfStreamError`}},n1=class extends Error{constructor(e=`The operation was aborted`){super(e),this.name=`AbortError`}}}),cEe=B(()=>{}),i1,a1=B(()=>{r1(),i1=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,t=!1){let n=await this.read(e,t);return this.peekQueue.push(e.subarray(0,n)),n}async read(e,t=!1){if(e.length===0)return 0;let n=this.readFromPeekBuffer(e);if(this.endOfStream||(n+=await this.readRemainderFromStream(e.subarray(n),t)),n===0&&!t)throw new t1;return n}readFromPeekBuffer(e){let t=e.length,n=0;for(;this.peekQueue.length>0&&t>0;){let r=this.peekQueue.pop();if(!r)throw Error(`peekData should be defined`);let i=Math.min(r.length,t);e.set(r.subarray(0,i),n),n+=i,t-=i,i{r1(),cEe(),a1()}),o1,uEe=B(()=>{a1(),o1=class extends i1{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}}}),s1,c1=B(()=>{uEe(),s1=class extends o1{async readFromStream(e,t){if(e.length===0)return 0;let n=await this.reader.read(new Uint8Array(e.length),{min:t?void 0:e.length});return n.done&&(this.endOfStream=n.done),n.value?(e.set(n.value),n.value.length):0}}}),l1,u1=B(()=>{r1(),a1(),l1=class extends i1{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,t){let n=Math.min(t.length,e.length);return e.set(t.subarray(0,n)),this.buffer=n{c1(),u1()}),d1=B(()=>{r1(),lEe(),c1(),u1(),fEe()}),f1,p1=B(()=>{d1(),f1=class{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e?.onClose,e?.abortSignal&&e.abortSignal.addEventListener(`abort`,()=>{this.abort()})}async readToken(e,t=this.position){let n=new Uint8Array(e.len);if(await this.readBuffer(n,{position:t})t)return this.position+=t,t}return this.position+=e,e}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(e,t){if(!this.supportsRandomAccess()&&t&&t.position!==void 0&&t.position{p1(),d1(),m1=256e3,h1=class extends f1{constructor(e,t){super(t),this.streamReader=e,this.fileInfo=t?.fileInfo??{}}async readBuffer(e,t){let n=this.normalizeOptions(e,t),r=n.position-this.position;if(r>0)return await this.ignore(r),this.readBuffer(e,t);if(r<0)throw Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;let i=await this.streamReader.read(e.subarray(0,n.length),n.mayBeLess);if(this.position+=i,(!t||!t.mayBeLess)&&i0){let i=new Uint8Array(n.length+t);return r=await this.peekBuffer(i,{mayBeLess:n.mayBeLess}),e.set(i.subarray(t)),r-t}if(t<0)throw Error(`Cannot peek from a negative offset in a stream`)}if(n.length>0){try{r=await this.streamReader.peek(e.subarray(0,n.length),n.mayBeLess)}catch(e){if(t?.mayBeLess&&e instanceof t1)return 0;throw e}if(!n.mayBeLess&&r{d1(),p1(),g1=class extends f1{constructor(e,t){super(t),this.uint8Array=e,this.fileInfo={...t?.fileInfo??{},size:e.length}}async readBuffer(e,t){t?.position&&(this.position=t.position);let n=await this.peekBuffer(e,t);return this.position+=n,n}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),r=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&r{d1(),p1(),_1=class extends f1{constructor(e,t){super(t),this.blob=e,this.fileInfo={...t?.fileInfo??{},size:e.size,mimeType:e.type}}async readBuffer(e,t){t?.position&&(this.position=t.position);let n=await this.peekBuffer(e,t);return this.position+=n,n}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),r=Math.min(this.blob.size-n.position,n.length);if(!n.mayBeLess&&r{if(await n.close(),i)return i()},new h1(n,r)}function _Ee(e,t){return new g1(e,t)}function vEe(e,t){return new _1(e,t)}var yEe=B(()=>{d1(),pEe(),mEe(),hEe(),d1(),p1()}),bEe=wz((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t||={};var n=typeof e;if(n===`string`&&e.length>0)return c(e);if(n===`number`&&isFinite(e))return t.long?u(e):l(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function c(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function l(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function u(e){var t=Math.abs(e);return t>=a?d(e,t,a,`day`):t>=i?d(e,t,i,`hour`):t>=r?d(e,t,r,`minute`):t>=n?d(e,t,n,`second`):e+` ms`}function d(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}}),xEe=wz((e,t)=>{function n(e){n.debug=n,n.default=n,n.coerce=c,n.disable=o,n.enable=i,n.enabled=s,n.humanize=bEe(),n.destroy=l,Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={};function t(e){let t=0;for(let n=0;n{if(t===`%%`)return`%`;a++;let o=n.formatters[i];if(typeof o==`function`){let n=e[a];t=o.call(r,n),e.splice(a,1),a--}return t}),n.formatArgs.call(r,e),(r.log||n.log).apply(r,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=r,s.destroy=n.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>i===null?(a!==n.namespaces&&(a=n.namespaces,o=n.enabled(e)),o):i,set:e=>{i=e}}),typeof n.init==`function`&&n.init(s),s}function r(e,t){let r=n(this.namespace+(typeof t>`u`?`:`:t)+e);return r.log=this.log,r}function i(e){n.save(e),n.namespaces=e,n.names=[],n.skips=[];let t=(typeof e==`string`?e:``).trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?n.skips.push(e.slice(1)):n.names.push(e)}function a(e,t){let n=0,r=0,i=-1,a=0;for(;n`-`+e)].join(`,`);return n.enable(``),e}function s(e){for(let t of n.skips)if(a(e,t))return!1;for(let t of n.names)if(a(e,t))return!0;return!1}function c(e){return e instanceof Error?e.stack||e.message:e}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}t.exports=n}),SEe=wz((e,t)=>{e.formatArgs=r,e.save=i,e.load=a,e.useColors=n,e.storage=o(),e.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=`#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33`.split(`.`);function n(){if(typeof window<`u`&&window.process&&(window.process.type===`renderer`||window.process.__nwjs))return!0;if(typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<`u`&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<`u`&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<`u`&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(e){if(e[0]=(this.useColors?`%c`:``)+this.namespace+(this.useColors?` %c`:` `)+e[0]+(this.useColors?`%c `:` `)+`+`+t.exports.humanize(this.diff),!this.useColors)return;let n=`color: `+this.color;e.splice(1,0,n,`color: inherit`);let r=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{e!==`%%`&&(r++,e===`%c`&&(i=r))}),e.splice(i,0,n)}e.log=console.debug||console.log||(()=>{});function i(t){try{t?e.storage.setItem(`debug`,t):e.storage.removeItem(`debug`)}catch{}}function a(){let t;try{t=e.storage.getItem(`debug`)||e.storage.getItem(`DEBUG`)}catch{}return!t&&typeof process<`u`&&`env`in process&&(t={}.DEBUG),t}function o(){try{return localStorage}catch{}}t.exports=xEe()(e);var{formatters:s}=t.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: `+e.message}}}),v1,y1,b1,x1,S1,CEe=B(()=>{$$(),v1={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},y1={get(e){return{signature:J$.get(e,0),compressedSize:J$.get(e,8),uncompressedSize:J$.get(e,12)}},len:16},b1={get(e){let t=K$.get(e,6);return{signature:J$.get(e,0),minVersion:K$.get(e,4),dataDescriptor:!!(t&8),compressedMethod:K$.get(e,8),compressedSize:J$.get(e,18),uncompressedSize:J$.get(e,22),filenameLength:K$.get(e,26),extraFieldLength:K$.get(e,28),filename:null}},len:30},x1={get(e){return{signature:J$.get(e,0),nrOfThisDisk:K$.get(e,4),nrOfThisDiskWithTheStart:K$.get(e,6),nrOfEntriesOnThisDisk:K$.get(e,8),nrOfEntriesOfSize:K$.get(e,10),sizeOfCd:J$.get(e,12),offsetOfStartOfCd:J$.get(e,16),zipFileCommentLength:K$.get(e,20)}},len:22},S1={get(e){let t=K$.get(e,8);return{signature:J$.get(e,0),minVersion:K$.get(e,6),dataDescriptor:!!(t&8),compressedMethod:K$.get(e,10),compressedSize:J$.get(e,20),uncompressedSize:J$.get(e,24),filenameLength:K$.get(e,28),extraFieldLength:K$.get(e,30),fileCommentLength:K$.get(e,32),relativeOffsetOfLocalHeader:J$.get(e,42),filename:null}},len:46}});function C1(e){let t=new Uint8Array(J$.len);return J$.put(t,0,e),t}function wEe(e,t){let n=e.length,r=t.length;if(r>n)return-1;for(let i=0;i<=n-r;i++){let n=!0;for(let a=0;ae+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var w1,T1,E1,D1,O1,k1,EEe=B(()=>{$$(),w1=Dz(SEe(),1),CEe(),T1=(0,w1.default)(`tokenizer:inflate`),E1=262144,D1=C1(v1.DataDescriptor),O1=C1(v1.EndOfCentralDirectory),k1=class e{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(E1)}async isZip(){return await this.peekSignature()===v1.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(J$)}async findEndOfCentralDirectoryLocator(){let e=this.tokenizer,t=Math.min(16384,e.fileInfo.size),n=this.syncBuffer.subarray(0,t);await this.tokenizer.readBuffer(n,{position:e.fileInfo.size-t});for(let r=n.length-4;r>=0;r--)if(n[r]===O1[0]&&n[r+1]===O1[1]&&n[r+2]===O1[2]&&n[r+3]===O1[3])return e.fileInfo.size-t+r;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){T1(`Cannot reading central-directory without random-read support`);return}T1(`Reading central-directory...`);let e=this.tokenizer.position,t=await this.findEndOfCentralDirectoryLocator();if(t>0){T1(`Central-directory 32-bit signature found`);let n=await this.tokenizer.readToken(x1,t),r=[];this.tokenizer.setPosition(n.offsetOfStartOfCd);for(let e=0;e=0?i:n;if(r.handler){let n=new Uint8Array(t);await this.tokenizer.readBuffer(n),e.push(n)}else await this.tokenizer.ignore(t)}T1(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),r.handler&&await this.inflate(t,TEe(e),r.handler)}else r.handler?(T1(`Reading compressed-file-data: ${t.compressedSize} bytes`),i=new Uint8Array(t.compressedSize),await this.tokenizer.readBuffer(i),await this.inflate(t,i,r.handler)):(T1(`Ignoring compressed-file-data: ${t.compressedSize} bytes`),await this.tokenizer.ignore(t.compressedSize));if(T1(`Reading data-descriptor at pos=${this.tokenizer.position}`),t.dataDescriptor&&(await this.tokenizer.readToken(y1)).signature!==134695760)throw Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-y1.len}`)}while(!n)}async iterateOverCentralDirectory(e,t){for(let n of e){let e=t(n);if(e.handler){this.tokenizer.setPosition(n.relativeOffsetOfLocalHeader);let t=await this.readLocalFileHeader();if(t){await this.tokenizer.ignore(t.extraFieldLength);let r=new Uint8Array(n.compressedSize);await this.tokenizer.readBuffer(r),await this.inflate(t,r,e.handler)}}if(e.stop)break}}async inflate(t,n,r){if(t.compressedMethod===0)return r(n);if(t.compressedMethod!==8)throw Error(`Unsupported ZIP compression method: ${t.compressedMethod}`);return T1(`Decompress filename=${t.filename}, compressed-size=${n.length}`),r(await e.decompressDeflateRaw(n))}static async decompressDeflateRaw(e){let t=new ReadableStream({start(t){t.enqueue(e),t.close()}}),n=new DecompressionStream(`deflate-raw`),r=t.pipeThrough(n);try{let e=await new Response(r).arrayBuffer();return new Uint8Array(e)}catch(e){let t=e instanceof Error?`Failed to deflate ZIP entry: ${e.message}`:`Unknown decompression error in ZIP entry`;throw TypeError(t)}}async readLocalFileHeader(){let e=await this.tokenizer.peekToken(J$);if(e===v1.LocalFileHeader){let e=await this.tokenizer.readToken(b1);return e.filename=await this.tokenizer.readToken(new Q$(e.filenameLength,`utf-8`)),e}if(e===v1.CentralFileHeader)return!1;throw Error(e===3759263696?`Encrypted ZIP`:`Unexpected signature`)}}}),A1,DEe=B(()=>{A1=class{constructor(e){this.tokenizer=e}inflate(){let e=this.tokenizer;return new ReadableStream({async pull(t){let n=new Uint8Array(1024),r=await e.readBuffer(n,{mayBeLess:!0});if(r===0){t.close();return}t.enqueue(n.subarray(0,r))}}).pipeThrough(new DecompressionStream(`gzip`))}}}),OEe=B(()=>{EEe(),DEe()});function j1(e){let{byteLength:t}=e;if(t===6)return e.getUint16(0)*2**32+e.getUint32(2);if(t===5)return e.getUint8(0)*2**32+e.getUint32(1);if(t===4)return e.getUint32(0);if(t===3)return e.getUint8(0)*2**16+e.getUint16(1);if(t===2)return e.getUint16(0);if(t===1)return e.getUint8(0)}var kEe=B(()=>{new globalThis.TextDecoder(`utf8`),new globalThis.TextEncoder,Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`))});function AEe(e,t){if(t===`utf-16le`){let t=[];for(let n=0;n>8&255)}return t}if(t===`utf-16be`){let t=[];for(let n=0;n>8&255,r&255)}return t}return[...e].map(e=>e.charCodeAt(0))}function jEe(e,t=0){let n=Number.parseInt(new Q$(6).get(e,148).replace(/\0.*$/,``).trim(),8);if(Number.isNaN(n))return!1;let r=256;for(let n=t;n{$$(),M1={get:(e,t)=>e[t+3]&127|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4}}),N1,P1,NEe=B(()=>{N1=`jpg,png,apng,gif,webp,flif,xcf,cr2,cr3,orf,arw,dng,nef,rw2,raf,tif,bmp,icns,jxr,psd,indd,zip,tar,rar,gz,bz2,7z,dmg,mp4,mid,mkv,webm,mov,avi,mpg,mp2,mp3,m4a,oga,ogg,ogv,opus,flac,wav,spx,amr,pdf,epub,elf,macho,exe,swf,rtf,wasm,woff,woff2,eot,ttf,otf,ttc,ico,flv,ps,xz,sqlite,nes,crx,xpi,cab,deb,ar,rpm,Z,lz,cfb,mxf,mts,blend,bpg,docx,pptx,xlsx,3gp,3g2,j2c,jp2,jpm,jpx,mj2,aif,qcp,odt,ods,odp,xml,mobi,heic,cur,ktx,ape,wv,dcm,ics,glb,pcap,dsf,lnk,alias,voc,ac3,m4v,m4p,m4b,f4v,f4p,f4b,f4a,mie,asf,ogm,ogx,mpc,arrow,shp,aac,mp1,it,s3m,xm,skp,avif,eps,lzh,pgp,asar,stl,chm,3mf,zst,jxl,vcf,jls,pst,dwg,parquet,class,arj,cpio,ace,avro,icc,fbx,vsdx,vtt,apk,drc,lz4,potx,xltx,dotx,xltm,ott,ots,otp,odg,otg,xlsm,docm,dotm,potm,pptm,jar,jmp,rm,sav,ppsm,ppsx,tar.gz,reg,dat`.split(`,`),P1=`image/jpeg,image/png,image/gif,image/webp,image/flif,image/x-xcf,image/x-canon-cr2,image/x-canon-cr3,image/tiff,image/bmp,image/vnd.ms-photo,image/vnd.adobe.photoshop,application/x-indesign,application/epub+zip,application/x-xpinstall,application/vnd.ms-powerpoint.slideshow.macroenabled.12,application/vnd.oasis.opendocument.text,application/vnd.oasis.opendocument.spreadsheet,application/vnd.oasis.opendocument.presentation,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.openxmlformats-officedocument.presentationml.slideshow,application/zip,application/x-tar,application/x-rar-compressed,application/gzip,application/x-bzip2,application/x-7z-compressed,application/x-apple-diskimage,application/vnd.apache.arrow.file,video/mp4,audio/midi,video/matroska,video/webm,video/quicktime,video/vnd.avi,audio/wav,audio/qcelp,audio/x-ms-asf,video/x-ms-asf,application/vnd.ms-asf,video/mpeg,video/3gpp,audio/mpeg,audio/mp4,video/ogg,audio/ogg,audio/ogg; codecs=opus,application/ogg,audio/flac,audio/ape,audio/wavpack,audio/amr,application/pdf,application/x-elf,application/x-mach-binary,application/x-msdownload,application/x-shockwave-flash,application/rtf,application/wasm,font/woff,font/woff2,application/vnd.ms-fontobject,font/ttf,font/otf,font/collection,image/x-icon,video/x-flv,application/postscript,application/eps,application/x-xz,application/x-sqlite3,application/x-nintendo-nes-rom,application/x-google-chrome-extension,application/vnd.ms-cab-compressed,application/x-deb,application/x-unix-archive,application/x-rpm,application/x-compress,application/x-lzip,application/x-cfb,application/x-mie,application/mxf,video/mp2t,application/x-blender,image/bpg,image/j2c,image/jp2,image/jpx,image/jpm,image/mj2,audio/aiff,application/xml,application/x-mobipocket-ebook,image/heif,image/heif-sequence,image/heic,image/heic-sequence,image/icns,image/ktx,application/dicom,audio/x-musepack,text/calendar,text/vcard,text/vtt,model/gltf-binary,application/vnd.tcpdump.pcap,audio/x-dsf,application/x.ms.shortcut,application/x.apple.alias,audio/x-voc,audio/vnd.dolby.dd-raw,audio/x-m4a,image/apng,image/x-olympus-orf,image/x-sony-arw,image/x-adobe-dng,image/x-nikon-nef,image/x-panasonic-rw2,image/x-fujifilm-raf,video/x-m4v,video/3gpp2,application/x-esri-shape,audio/aac,audio/x-it,audio/x-s3m,audio/x-xm,video/MP1S,video/MP2P,application/vnd.sketchup.skp,image/avif,application/x-lzh-compressed,application/pgp-encrypted,application/x-asar,model/stl,application/vnd.ms-htmlhelp,model/3mf,image/jxl,application/zstd,image/jls,application/vnd.ms-outlook,image/vnd.dwg,application/vnd.apache.parquet,application/java-vm,application/x-arj,application/x-cpio,application/x-ace-compressed,application/avro,application/vnd.iccprofile,application/x.autodesk.fbx,application/vnd.visio,application/vnd.android.package-archive,application/vnd.google.draco,application/x-lz4,application/vnd.openxmlformats-officedocument.presentationml.template,application/vnd.openxmlformats-officedocument.spreadsheetml.template,application/vnd.openxmlformats-officedocument.wordprocessingml.template,application/vnd.ms-excel.template.macroenabled.12,application/vnd.oasis.opendocument.text-template,application/vnd.oasis.opendocument.spreadsheet-template,application/vnd.oasis.opendocument.presentation-template,application/vnd.oasis.opendocument.graphics,application/vnd.oasis.opendocument.graphics-template,application/vnd.ms-excel.sheet.macroenabled.12,application/vnd.ms-word.document.macroenabled.12,application/vnd.ms-word.template.macroenabled.12,application/vnd.ms-powerpoint.template.macroenabled.12,application/vnd.ms-powerpoint.presentation.macroenabled.12,application/java-archive,application/vnd.rn-realmedia,application/x-spss-sav,application/x-ms-regedit,application/x-ft-windows-registry-hive,application/x-jmp-data`.split(`,`)});function PEe(e){let t=e?.streamReader;if(t?.constructor?.name!==`WebStreamByobReader`)return e;let{reader:n}=t,r=async()=>{await n.cancel(),n.releaseLock()};return t.close=r,t.abort=async()=>{t.interrupted=!0,await r()},e}function F1(e,t,n){if(!Number.isFinite(e)||e<0||e>t)throw new _0(`${n} has invalid size ${e} (maximum ${t} bytes)`);return e}async function I1(e,t,{maximumLength:n=Y1,reason:r=`skip`}={}){let i=F1(t,n,r);await e.ignore(i)}async function L1(e,t,n,{maximumLength:r=t.length,reason:i=`read`}={}){let a=F1(n?.length??t.length,r,i);return e.readBuffer(t,{...n,length:a})}async function FEe(e,{maximumLength:t=K1}={}){let n=new ReadableStream({start(t){t.enqueue(e),t.close()}}).pipeThrough(new DecompressionStream(`deflate-raw`)).getReader(),r=[],i=0;try{for(;;){let{done:e,value:a}=await n.read();if(e)break;if(i+=a.length,i>t)throw await n.cancel(),Error(`ZIP entry decompressed data exceeds ${t} bytes`);r.push(a)}}finally{n.releaseLock()}let a=new Uint8Array(i),o=0;for(let e of r)a.set(e,o),o+=e.length;return a}function IEe(e,t){if(e.length=0?0:s===i?Math.min(b0,s-1):0,u=c>=0?c:s-l;if(u===0)break;if(o+=u,o>n)throw Error(`ZIP entry compressed data exceeds ${n} bytes`);if(t){let t=new Uint8Array(u);await e.tokenizer.readBuffer(t),a.push(t)}else await e.tokenizer.ignore(u);if(c>=0)break}if(B1(e.tokenizer)||(e.knownSizeDescriptorScannedBytes+=o),t)return REe(a,o)}function BEe(e,t){return B1(e.tokenizer)?Math.max(0,Y1-(e.tokenizer.position-t)):Math.max(0,K1-e.knownSizeDescriptorScannedBytes)}async function VEe(e,t,{shouldBuffer:n,maximumDescriptorLength:r=K1}={}){if(t.dataDescriptor&&t.compressedSize===0)return zEe(e,{shouldBuffer:n,maximumLength:r});if(!n){await I1(e.tokenizer,t.compressedSize,{maximumLength:B1(e.tokenizer)?K1:e.tokenizer.fileInfo.size,reason:`ZIP entry compressed data`});return}let i=JEe(e.tokenizer);if(!Number.isFinite(t.compressedSize)||t.compressedSize<0||t.compressedSize>i)throw Error(`ZIP entry compressed data exceeds ${i} bytes`);let a=new Uint8Array(t.compressedSize);return await e.tokenizer.readBuffer(a),a}function HEe(e,t){let n=e.getReader(),r=0,i=!1,a=!1,o=async e=>{i||a||(a=!0,await n.cancel(e))};return new ReadableStream({async pull(e){if(r>=t){e.close(),await o();return}let{done:a,value:s}=await n.read();if(a||!s){i=!0,e.close();return}let c=t-r;if(s.length>c){e.enqueue(s.subarray(0,c)),r+=c,e.close(),await o();return}e.enqueue(s),r+=s.length},async cancel(e){await o(e)}})}async function UEe(e,t){return new x0(t).fromBuffer(e)}function R1(e){switch(e=e.toLowerCase(),e){case`application/epub+zip`:return{ext:`epub`,mime:e};case`application/vnd.oasis.opendocument.text`:return{ext:`odt`,mime:e};case`application/vnd.oasis.opendocument.text-template`:return{ext:`ott`,mime:e};case`application/vnd.oasis.opendocument.spreadsheet`:return{ext:`ods`,mime:e};case`application/vnd.oasis.opendocument.spreadsheet-template`:return{ext:`ots`,mime:e};case`application/vnd.oasis.opendocument.presentation`:return{ext:`odp`,mime:e};case`application/vnd.oasis.opendocument.presentation-template`:return{ext:`otp`,mime:e};case`application/vnd.oasis.opendocument.graphics`:return{ext:`odg`,mime:e};case`application/vnd.oasis.opendocument.graphics-template`:return{ext:`otg`,mime:e};case`application/vnd.openxmlformats-officedocument.presentationml.slideshow`:return{ext:`ppsx`,mime:e};case`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`:return{ext:`xlsx`,mime:e};case`application/vnd.ms-excel.sheet.macroenabled`:return{ext:`xlsm`,mime:`application/vnd.ms-excel.sheet.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.spreadsheetml.template`:return{ext:`xltx`,mime:e};case`application/vnd.ms-excel.template.macroenabled`:return{ext:`xltm`,mime:`application/vnd.ms-excel.template.macroenabled.12`};case`application/vnd.ms-powerpoint.slideshow.macroenabled`:return{ext:`ppsm`,mime:`application/vnd.ms-powerpoint.slideshow.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.wordprocessingml.document`:return{ext:`docx`,mime:e};case`application/vnd.ms-word.document.macroenabled`:return{ext:`docm`,mime:`application/vnd.ms-word.document.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.wordprocessingml.template`:return{ext:`dotx`,mime:e};case`application/vnd.ms-word.template.macroenabledtemplate`:return{ext:`dotm`,mime:`application/vnd.ms-word.template.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.presentationml.template`:return{ext:`potx`,mime:e};case`application/vnd.ms-powerpoint.template.macroenabled`:return{ext:`potm`,mime:`application/vnd.ms-powerpoint.template.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.presentationml.presentation`:return{ext:`pptx`,mime:e};case`application/vnd.ms-powerpoint.presentation.macroenabled`:return{ext:`pptm`,mime:`application/vnd.ms-powerpoint.presentation.macroenabled.12`};case`application/vnd.ms-visio.drawing`:return{ext:`vsdx`,mime:`application/vnd.visio`};case`application/vnd.ms-package.3dmanufacturing-3dmodel+xml`:return{ext:`3mf`,mime:`model/3mf`}}}function z1(e,t,n){n={offset:0,...n};for(let[r,i]of t.entries())if(n.mask){if(i!==(n.mask[r]&e[r+n.offset]))return!1}else if(i!==e[r+n.offset])return!1;return!0}function WEe(e){return Number.isFinite(e)?Math.max(1,Math.trunc(e)):W1}function GEe(e,t,n){return n===void 0?e.read(t):(n.throwIfAborted(),new Promise((r,i)=>{let a=()=>{n.removeEventListener(`abort`,o)},o=()=>{let t=n.reason;a(),(async()=>{try{await e.cancel(t)}catch{}})(),i(t)};n.addEventListener(`abort`,o,{once:!0}),(async()=>{try{let n=await e.read(t);a(),r(n)}catch(e){a(),i(e)}})()}))}function KEe(e){return Number.isFinite(e)?Math.max(0,Math.min(G1,Math.trunc(e))):0}function qEe(e){return Number.isFinite(e)?Math.max(0,e):2**53-1}function B1(e){let t=e.fileInfo.size;return!Number.isFinite(t)||t===2**53-1}function V1(e,t,n){return B1(e)&&e.position-t>n}function JEe(e){let t=e.fileInfo.size,n=Number.isFinite(t)?Math.max(0,t-e.position):2**53-1;return Math.min(n,J1)}function YEe(e){if(e instanceof t1||e instanceof _0)return!0;if(!(e instanceof Error))return!1;if(m0.has(e.message)||g0.has(e.code))return!0;for(let t of h0)if(e.message.startsWith(t))return!0;return!1}function H1(e,t=K1){let n=[e.compressedSize,e.uncompressedSize];for(let e of n)if(!Number.isFinite(e)||e<0||e>t)return!1;return!0}function XEe(){return{hasContentTypesEntry:!1,hasParsedContentTypesEntry:!1,isParsingContentTypes:!1,hasUnparseableContentTypes:!1,hasWordDirectory:!1,hasPresentationDirectory:!1,hasSpreadsheetDirectory:!1,hasThreeDimensionalModelEntry:!1}}function ZEe(e,t){t.startsWith(`word/`)&&(e.hasWordDirectory=!0),t.startsWith(`ppt/`)&&(e.hasPresentationDirectory=!0),t.startsWith(`xl/`)&&(e.hasSpreadsheetDirectory=!0),t.startsWith(`3D/`)&&t.endsWith(`.model`)&&(e.hasThreeDimensionalModelEntry=!0)}function U1(e){if(!(!e.hasContentTypesEntry||e.hasUnparseableContentTypes||e.isParsingContentTypes||e.hasParsedContentTypesEntry)){if(e.hasWordDirectory)return{ext:`docx`,mime:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`};if(e.hasPresentationDirectory)return{ext:`pptx`,mime:`application/vnd.openxmlformats-officedocument.presentationml.presentation`};if(e.hasSpreadsheetDirectory)return{ext:`xlsx`,mime:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`};if(e.hasThreeDimensionalModelEntry)return{ext:`3mf`,mime:`model/3mf`}}}function QEe(e){let t=e.indexOf(`.main+xml"`);if(t===-1){let t=`application/vnd.ms-package.3dmanufacturing-3dmodel+xml`;return e.includes(`ContentType="${t}"`)?t:void 0}let n=e.slice(0,t),r=n.lastIndexOf(`"`);return n.slice(r+1)}var W1,G1,K1,q1,J1,Y1,X1,Z1,Q1,$1,e0,t0,n0,r0,i0,a0,o0,s0,c0,l0,u0,d0,f0,p0,m0,h0,g0,_0,v0,y0,b0,x0,$Ee=B(()=>{$$(),yEe(),OEe(),kEe(),MEe(),NEe(),W1=4100,G1=W1-2,K1=1048576,q1=1024,J1=2**31-1,Y1=16777216,X1=K1,Z1=K1,Q1=Y1,$1=1,e0=100,t0=Y1,n0=64,r0=X1,i0=256,a0=512,o0=Y1,s0=512,c0=512,l0=256,u0=X1,d0=X1,f0=X1,p0=Y1,m0=new Set([`Unexpected signature`,`Encrypted ZIP`,`Expected Central-File-Header signature`]),h0=[`ZIP entry count exceeds `,`Unsupported ZIP compression method:`,`ZIP entry compressed data exceeds `,`ZIP entry decompressed data exceeds `,`Expected data-descriptor-signature at position `],g0=new Set([`Z_BUF_ERROR`,`Z_DATA_ERROR`,`ERR_INVALID_STATE`]),_0=class extends Error{},v0=134695760,y0=16,b0=y0-1,k1.prototype.inflate=async function(e,t,n){if(e.compressedMethod===0)return n(t);if(e.compressedMethod!==8)throw Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);return n(await FEe(t,{maximumLength:K1}))},k1.prototype.unzip=async function(e){let t=!1,n=0,r=this.tokenizer.position;this.knownSizeDescriptorScannedBytes=0;do{if(V1(this.tokenizer,r,Y1))throw new _0(`ZIP stream probing exceeds ${Y1} bytes`);let i=await this.readLocalFileHeader();if(!i)break;if(n++,n>q1)throw Error(`ZIP entry count exceeds ${q1}`);let a=e(i);t=!!a.stop,await this.tokenizer.ignore(i.extraFieldLength);let o=await VEe(this,i,{shouldBuffer:!!a.handler,maximumDescriptorLength:Math.min(K1,BEe(this,r))});if(a.handler&&await this.inflate(i,o,a.handler),i.dataDescriptor){let e=new Uint8Array(y0);if(await this.tokenizer.readBuffer(e),J$.get(e,0)!==v0)throw Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-e.length}`)}if(V1(this.tokenizer,r,Y1))throw new _0(`ZIP stream probing exceeds ${Y1} bytes`)}while(!t)},x0=class e{constructor(e){let t=KEe(e?.mpegOffsetTolerance);this.options={...e,mpegOffsetTolerance:t},this.detectors=[...this.options.customDetectors??[],{id:`core`,detect:this.detectConfident},{id:`core.imprecise`,detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:this.options.signal},this.gzipProbeDepth=0}getTokenizerOptions(){return{...this.tokenizerOptions}}createTokenizerFromWebStream(e){return PEe(gEe(e,this.getTokenizerOptions()))}async parseTokenizer(e,t=0){this.detectionReentryCount=t;let n=e.position;for(let t of this.detectors){let r;try{r=await t.detect(e)}catch(e){if(e instanceof t1||e instanceof _0)return;throw e}if(r)return r;if(n!==e.position)return}}async fromTokenizer(e){try{return await this.parseTokenizer(e)}finally{await e.close()}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);let t=e instanceof Uint8Array?e:new Uint8Array(e);if(t?.length>1)return this.fromTokenizer(_Ee(t,this.getTokenizerOptions()))}async fromBlob(e){this.options.signal?.throwIfAborted();let t=vEe(e,this.getTokenizerOptions());return this.fromTokenizer(t)}async fromStream(e){this.options.signal?.throwIfAborted();let t=this.createTokenizerFromWebStream(e);return this.fromTokenizer(t)}async toDetectionStream(e,t){let n=WEe(t?.sampleSize??W1),r,i,a=e.getReader({mode:`byob`});try{let{value:e,done:t}=await GEe(a,new Uint8Array(n),this.options.signal);if(i=e,!t&&e)try{r=await this.fromBuffer(e.subarray(0,n))}catch(e){if(!(e instanceof t1))throw e;r=void 0}i=e}finally{a.releaseLock()}let o=new TransformStream({async start(e){e.enqueue(i)},transform(e,t){t.enqueue(e)}}),s=e.pipeThrough(o);return s.fileType=r,s}async detectGzip(t){if(this.gzipProbeDepth>=$1)return{ext:`gz`,mime:`application/gzip`};let n=HEe(new A1(t).inflate(),Q1),r=B1(t),i,a,o,s;if(r){let t=new AbortController;i=setTimeout(()=>{t.abort(new DOMException(`Operation timed out after ${e0} ms`,`TimeoutError`))},e0),a=this.options.signal===void 0?t.signal:AbortSignal.any([this.options.signal,t.signal]),o=new e({...this.options,signal:a}),o.gzipProbeDepth=this.gzipProbeDepth+1}else this.gzipProbeDepth++;try{s=await(o??this).fromStream(n)}catch(e){if(e?.name===`AbortError`&&a?.reason?.name!==`TimeoutError`)throw e}finally{clearTimeout(i),r||this.gzipProbeDepth--}return s?.ext===`tar`?{ext:`tar.gz`,mime:`application/gzip`}:{ext:`gz`,mime:`application/gzip`}}check(e,t){return z1(this.buffer,e,t)}checkString(e,t){return this.check(AEe(e,t?.encoding),t)}detectConfident=async e=>{if(this.buffer=new Uint8Array(W1),e.fileInfo.size===void 0&&(e.fileInfo.size=2**53-1),this.tokenizer=e,B1(e)&&(await e.peekBuffer(this.buffer,{length:3,mayBeLess:!0}),this.check([31,139,8])))return this.detectGzip(e);if(await e.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:`bmp`,mime:`image/bmp`};if(this.check([11,119]))return{ext:`ac3`,mime:`audio/vnd.dolby.dd-raw`};if(this.check([120,1]))return{ext:`dmg`,mime:`application/x-apple-diskimage`};if(this.check([77,90]))return{ext:`exe`,mime:`application/x-msdownload`};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString(`PS-Adobe-`,{offset:2})&&this.checkString(` EPSF-`,{offset:14})?{ext:`eps`,mime:`application/eps`}:{ext:`ps`,mime:`application/postscript`};if(this.check([31,160])||this.check([31,157]))return{ext:`Z`,mime:`application/x-compress`};if(this.check([199,113]))return{ext:`cpio`,mime:`application/x-cpio`};if(this.check([96,234]))return{ext:`arj`,mime:`application/x-arj`};if(this.check([239,187,191]))return this.detectionReentryCount>=l0?void 0:(this.detectionReentryCount++,await this.tokenizer.ignore(3),this.detectConfident(e));if(this.check([71,73,70]))return{ext:`gif`,mime:`image/gif`};if(this.check([73,73,188]))return{ext:`jxr`,mime:`image/vnd.ms-photo`};if(this.check([31,139,8]))return this.detectGzip(e);if(this.check([66,90,104]))return{ext:`bz2`,mime:`application/x-bzip2`};if(this.checkString(`ID3`)){await I1(e,6,{maximumLength:6,reason:`ID3 header prefix`});let t=await e.readToken(M1),n=B1(e);if(!Number.isFinite(t)||t<0||n&&(t>t0||e.position+t>t0))return;if(e.position+t>e.fileInfo.size)return n?void 0:{ext:`mp3`,mime:`audio/mpeg`};try{await I1(e,t,{maximumLength:n?t0:e.fileInfo.size,reason:`ID3 payload`})}catch(e){if(e instanceof t1)return;throw e}return this.detectionReentryCount>=l0?void 0:(this.detectionReentryCount++,this.parseTokenizer(e,this.detectionReentryCount))}if(this.checkString(`MP+`))return{ext:`mpc`,mime:`audio/x-musepack`};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:`swf`,mime:`application/x-shockwave-flash`};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:`jls`,mime:`image/jls`}:{ext:`jpg`,mime:`image/jpeg`};if(this.check([79,98,106,1]))return{ext:`avro`,mime:`application/avro`};if(this.checkString(`FLIF`))return{ext:`flif`,mime:`image/flif`};if(this.checkString(`8BPS`))return{ext:`psd`,mime:`image/vnd.adobe.photoshop`};if(this.checkString(`MPCK`))return{ext:`mpc`,mime:`audio/x-musepack`};if(this.checkString(`FORM`))return{ext:`aif`,mime:`audio/aiff`};if(this.checkString(`icns`,{offset:0}))return{ext:`icns`,mime:`image/icns`};if(this.check([80,75,3,4])){let t,n=XEe();try{await new k1(e).unzip(e=>{ZEe(n,e.filename);let r=e.filename===`[Content_Types].xml`,i=U1(n);if(!r&&i)return t=i,{stop:!0};switch(e.filename){case`META-INF/mozilla.rsa`:return t={ext:`xpi`,mime:`application/x-xpinstall`},{stop:!0};case`META-INF/MANIFEST.MF`:return t={ext:`jar`,mime:`application/java-archive`},{stop:!0};case`mimetype`:return H1(e,Z1)?{async handler(e){t=R1(new TextDecoder(`utf-8`).decode(e).trim())},stop:!0}:{};case`[Content_Types].xml`:return n.hasContentTypesEntry=!0,H1(e,Z1)?(n.isParsingContentTypes=!0,{async handler(e){let r=QEe(new TextDecoder(`utf-8`).decode(e));r&&(t=R1(r)),n.hasParsedContentTypesEntry=!0,n.isParsingContentTypes=!1},stop:!0}):(n.hasUnparseableContentTypes=!0,{});default:return/classes\d*\.dex/.test(e.filename)?(t={ext:`apk`,mime:`application/vnd.android.package-archive`},{stop:!0}):{}}})}catch(e){if(!YEe(e))throw e;n.isParsingContentTypes&&(n.isParsingContentTypes=!1,n.hasUnparseableContentTypes=!0)}return t??U1(n)??{ext:`zip`,mime:`application/zip`}}if(this.checkString(`OggS`)){await e.ignore(28);let t=new Uint8Array(8);return await e.readBuffer(t),z1(t,[79,112,117,115,72,101,97,100])?{ext:`opus`,mime:`audio/ogg; codecs=opus`}:z1(t,[128,116,104,101,111,114,97])?{ext:`ogv`,mime:`video/ogg`}:z1(t,[1,118,105,100,101,111,0])?{ext:`ogm`,mime:`video/ogg`}:z1(t,[127,70,76,65,67])?{ext:`oga`,mime:`audio/ogg`}:z1(t,[83,112,101,101,120,32,32])?{ext:`spx`,mime:`audio/ogg`}:z1(t,[1,118,111,114,98,105,115])?{ext:`ogg`,mime:`audio/ogg`}:{ext:`ogx`,mime:`application/ogg`}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:`zip`,mime:`application/zip`};if(this.checkString(`MThd`))return{ext:`mid`,mime:`audio/midi`};if(this.checkString(`wOFF`)&&(this.check([0,1,0,0],{offset:4})||this.checkString(`OTTO`,{offset:4})))return{ext:`woff`,mime:`font/woff`};if(this.checkString(`wOF2`)&&(this.check([0,1,0,0],{offset:4})||this.checkString(`OTTO`,{offset:4})))return{ext:`woff2`,mime:`font/woff2`};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:`pcap`,mime:`application/vnd.tcpdump.pcap`};if(this.checkString(`DSD `))return{ext:`dsf`,mime:`audio/x-dsf`};if(this.checkString(`LZIP`))return{ext:`lz`,mime:`application/x-lzip`};if(this.checkString(`fLaC`))return{ext:`flac`,mime:`audio/flac`};if(this.check([66,80,71,251]))return{ext:`bpg`,mime:`image/bpg`};if(this.checkString(`wvpk`))return{ext:`wv`,mime:`audio/wavpack`};if(this.checkString(`%PDF`))return{ext:`pdf`,mime:`application/pdf`};if(this.check([0,97,115,109]))return{ext:`wasm`,mime:`application/wasm`};if(this.check([73,73])){let e=await this.readTiffHeader(!1);if(e)return e}if(this.check([77,77])){let e=await this.readTiffHeader(!0);if(e)return e}if(this.checkString(`MAC `))return{ext:`ape`,mime:`audio/ape`};if(this.check([26,69,223,163])){async function t(){let t=await e.peekNumber(G$),n=128,r=0;for(;(t&n)===0&&n!==0;)++r,n>>=1;let i=new Uint8Array(r+1);return await L1(e,i,void 0,{maximumLength:i.length,reason:`EBML field`}),i}async function n(){let e=await t(),n=await t();n[0]^=128>>n.length-1;let r=Math.min(6,n.length),i=new DataView(e.buffer),a=new DataView(n.buffer,n.length-r,r);return{id:j1(i),len:j1(a)}}async function r(t){let r=0;for(;t>0;){if(r++,r>i0||V1(e,a,Y1))return;let i=e.position,o=await n();if(o.id===17026){if(o.len>n0)return;let t=F1(o.len,n0,`EBML DocType`);return(await e.readToken(new Q$(t))).replaceAll(/\00.*$/g,``)}if(B1(e)&&(!Number.isFinite(o.len)||o.len<0||o.len>r0)||(await I1(e,o.len,{maximumLength:B1(e)?r0:e.fileInfo.size,reason:`EBML payload`}),--t,e.position<=i))return}}let i=await n(),a=e.position;switch(await r(i.len)){case`webm`:return{ext:`webm`,mime:`video/webm`};case`matroska`:return{ext:`mkv`,mime:`video/matroska`};default:return}}if(this.checkString(`SQLi`))return{ext:`sqlite`,mime:`application/x-sqlite3`};if(this.check([78,69,83,26]))return{ext:`nes`,mime:`application/x-nintendo-nes-rom`};if(this.checkString(`Cr24`))return{ext:`crx`,mime:`application/x-google-chrome-extension`};if(this.checkString(`MSCF`)||this.checkString(`ISc(`))return{ext:`cab`,mime:`application/vnd.ms-cab-compressed`};if(this.check([237,171,238,219]))return{ext:`rpm`,mime:`application/x-rpm`};if(this.check([197,208,211,198]))return{ext:`eps`,mime:`application/eps`};if(this.check([40,181,47,253]))return{ext:`zst`,mime:`application/zstd`};if(this.check([127,69,76,70]))return{ext:`elf`,mime:`application/x-elf`};if(this.check([33,66,68,78]))return{ext:`pst`,mime:`application/vnd.ms-outlook`};if(this.checkString(`PAR1`)||this.checkString(`PARE`))return{ext:`parquet`,mime:`application/vnd.apache.parquet`};if(this.checkString(`ttcf`))return{ext:`ttc`,mime:`font/collection`};if(this.check([254,237,250,206])||this.check([254,237,250,207])||this.check([206,250,237,254])||this.check([207,250,237,254]))return{ext:`macho`,mime:`application/x-mach-binary`};if(this.check([4,34,77,24]))return{ext:`lz4`,mime:`application/x-lz4`};if(this.checkString(`regf`))return{ext:`dat`,mime:`application/x-ft-windows-registry-hive`};if(this.checkString(`$FL2`)||this.checkString(`$FL3`))return{ext:`sav`,mime:`application/x-spss-sav`};if(this.check([79,84,84,79,0]))return{ext:`otf`,mime:`font/otf`};if(this.checkString(`#!AMR`))return{ext:`amr`,mime:`audio/amr`};if(this.checkString(`{\\rtf`))return{ext:`rtf`,mime:`application/rtf`};if(this.check([70,76,86,1]))return{ext:`flv`,mime:`video/x-flv`};if(this.checkString(`IMPM`))return{ext:`it`,mime:`audio/x-it`};if(this.checkString(`-lh0-`,{offset:2})||this.checkString(`-lh1-`,{offset:2})||this.checkString(`-lh2-`,{offset:2})||this.checkString(`-lh3-`,{offset:2})||this.checkString(`-lh4-`,{offset:2})||this.checkString(`-lh5-`,{offset:2})||this.checkString(`-lh6-`,{offset:2})||this.checkString(`-lh7-`,{offset:2})||this.checkString(`-lzs-`,{offset:2})||this.checkString(`-lz4-`,{offset:2})||this.checkString(`-lz5-`,{offset:2})||this.checkString(`-lhd-`,{offset:2}))return{ext:`lzh`,mime:`application/x-lzh-compressed`};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:`mpg`,mime:`video/MP1S`};if(this.check([68],{offset:4,mask:[196]}))return{ext:`mpg`,mime:`video/MP2P`}}if(this.checkString(`ITSF`))return{ext:`chm`,mime:`application/vnd.ms-htmlhelp`};if(this.check([202,254,186,190])){let e=Y$.get(this.buffer,4),t=q$.get(this.buffer,6);if(e>0&&e<=30)return{ext:`macho`,mime:`application/x-mach-binary`};if(t>30)return{ext:`class`,mime:`application/java-vm`}}if(this.checkString(`.RMF`))return{ext:`rm`,mime:`application/vnd.rn-realmedia`};if(this.checkString(`DRACO`))return{ext:`drc`,mime:`application/vnd.google.draco`};if(this.check([253,55,122,88,90,0]))return{ext:`xz`,mime:`application/x-xz`};if(this.checkString(`=1e3&&e<=1050)return{ext:`dwg`,mime:`image/vnd.dwg`}}if(this.checkString(`070707`))return{ext:`cpio`,mime:`application/x-cpio`};if(this.checkString(`BLENDER`))return{ext:`blend`,mime:`application/x-blender`};if(this.checkString(`!`))return await e.ignore(8),await e.readToken(new Q$(13,`ascii`))===`debian-binary`?{ext:`deb`,mime:`application/x-deb`}:{ext:`ar`,mime:`application/x-unix-archive`};if(this.checkString(`WEBVTT`)&&[` `,`\r`,` `,` `,`\0`].some(e=>this.checkString(e,{offset:6})))return{ext:`vtt`,mime:`text/vtt`};if(this.check([137,80,78,71,13,10,26,10])){let t={ext:`png`,mime:`image/png`},n={ext:`apng`,mime:`image/apng`};await e.ignore(8);async function r(){return{length:await e.readToken(X$),type:await e.readToken(new Q$(4,`latin1`))}}let i=B1(e),a=e.position,o=0,s=!1;do{if(o++,o>a0||V1(e,a,o0))break;let c=e.position,l=await r();if(l.length<0)return;if(l.type===`IHDR`){if(l.length!==13)return;s=!0}switch(l.type){case`IDAT`:return t;case`acTL`:return n;default:if(!s&&l.type!==`CgBI`)return;if(i&&l.length>u0)return s&&LEe(l.type)?t:void 0;try{await I1(e,l.length+4,{maximumLength:i?u0+4:e.fileInfo.size,reason:`PNG chunk payload`})}catch(e){if(!i&&(e instanceof _0||e instanceof t1))return t;throw e}}if(e.position<=c)break}while(e.position+8s0||V1(e,i,Y1)));){let i=e.position,a=await n(),o=a.size-24;if(!Number.isFinite(o)||o<0){t=!0;break}if(z1(a.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let t=new Uint8Array(16);if(o-=await L1(e,t,void 0,{maximumLength:t.length,reason:`ASF stream type GUID`}),z1(t,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:`asf`,mime:`audio/x-ms-asf`};if(z1(t,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:`asf`,mime:`video/x-ms-asf`};break}if(r&&o>d0){t=!0;break}if(await I1(e,o,{maximumLength:r?d0:e.fileInfo.size,reason:`ASF header payload`}),e.position<=i){t=!0;break}}}catch(n){if(n instanceof t1||n instanceof _0)B1(e)&&(t=!0);else throw n}return t?void 0:{ext:`asf`,mime:`application/vnd.ms-asf`}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:`ktx`,mime:`image/ktx`};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:`mie`,mime:`application/x-mie`};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:`shp`,mime:`application/x-esri-shape`};if(this.check([255,79,255,81]))return{ext:`j2c`,mime:`image/j2c`};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await e.ignore(20),await e.readToken(new Q$(4,`ascii`))){case`jp2 `:return{ext:`jp2`,mime:`image/jp2`};case`jpx `:return{ext:`jpx`,mime:`image/jpx`};case`jpm `:return{ext:`jpm`,mime:`image/jpm`};case`mjp2`:return{ext:`mj2`,mime:`image/mj2`};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:`jxl`,mime:`image/jxl`};if(this.check([254,255]))return this.checkString(`=16){let e=new DataView(this.buffer.buffer).getUint32(12,!0);if(e>12&&this.buffer.length>=e+16)try{let t=new TextDecoder().decode(this.buffer.subarray(16,e+16));if(JSON.parse(t).files)return{ext:`asar`,mime:`application/x-asar`}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:`mxf`,mime:`application/mxf`};if(this.checkString(`SCRM`,{offset:44}))return{ext:`s3m`,mime:`audio/x-s3m`};if(this.check([71])&&this.check([71],{offset:188})||this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:`mts`,mime:`video/mp2t`};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:`mobi`,mime:`application/x-mobipocket-ebook`};if(this.check([68,73,67,77],{offset:128}))return{ext:`dcm`,mime:`application/dicom`};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:`lnk`,mime:`application/x.ms.shortcut`};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:`alias`,mime:`application/x.apple.alias`};if(this.checkString(`Kaydara FBX Binary \0`))return{ext:`fbx`,mime:`application/x.autodesk.fbx`};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:`eot`,mime:`application/vnd.ms-fontobject`};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:`indd`,mime:`application/x-indesign`};if(this.check([255,255,0,0,7,0,0,0,4,0,0,0,1,0,1,0])||this.check([0,0,255,255,0,0,0,7,0,0,0,4,0,1,0,1]))return{ext:`jmp`,mime:`application/x-jmp-data`};if(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString(`ustar`,{offset:257})&&(this.checkString(`\0`,{offset:262})||this.checkString(` `,{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&jEe(this.buffer))return{ext:`tar`,mime:`application/x-tar`};if(this.check([255,254])){let e=`utf-16le`;return this.checkString(`{this.buffer=new Uint8Array(W1);let t=qEe(e.fileInfo.size);if(await e.peekBuffer(this.buffer,{length:Math.min(8,t),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:`mpg`,mime:`video/mpeg`};if(this.check([0,1,0,0,0]))return{ext:`ttf`,mime:`font/ttf`};if(this.check([0,0,1,0]))return{ext:`ico`,mime:`image/x-icon`};if(this.check([0,0,2,0]))return{ext:`cur`,mime:`image/x-icon`};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,t),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let e=0;e<=this.options.mpegOffsetTolerance;++e){let t=this.scanMpeg(e);if(t)return t}};async readTiffTag(e){let t=await this.tokenizer.readToken(e?q$:K$);switch(await this.tokenizer.ignore(10),t){case 50341:return{ext:`arw`,mime:`image/x-sony-arw`};case 50706:return{ext:`dng`,mime:`image/x-adobe-dng`}}}async readTiffIFD(e){let t=await this.tokenizer.readToken(e?q$:K$);if(!(t>c0)&&!(B1(this.tokenizer)&&2+t*12>p0))for(let n=0;n=6){if(this.checkString(`CR`,{offset:8}))return{ext:`cr2`,mime:`image/x-canon-cr2`};if(r>=8){let t=(e?q$:K$).get(this.buffer,8),n=(e?q$:K$).get(this.buffer,10);if(t===28&&n===254||t===31&&n===11)return{ext:`nef`,mime:`image/x-nikon-nef`}}}if(B1(this.tokenizer)&&r>f0)return t;let n=B1(this.tokenizer)?p0:this.tokenizer.fileInfo.size;try{await I1(this.tokenizer,r,{maximumLength:n,reason:`TIFF IFD offset`})}catch(e){if(e instanceof t1)return;throw e}let i;try{i=await this.readTiffIFD(e)}catch(e){if(e instanceof t1)return;throw e}return i??t}if(n===43)return t}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]}),{ext:`aac`,mime:`audio/aac`};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:`mp3`,mime:`audio/mpeg`};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:`mp2`,mime:`audio/mpeg`};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:`mp1`,mime:`audio/mpeg`}}}},new Set(N1),new Set(P1)}),S0={};Tz(S0,{fileCommand:()=>E0,flagsForFuzzing:()=>D0});function eDe(e,t){let n=T0.get(e);if(n)return n;let[r,i]=t.split(`/`),a=i?.split(`+`)[0]?.replace(/-/g,` `)||e;switch(r){case`image`:return`${a.toUpperCase()} image data`;case`audio`:return`${a.toUpperCase()} audio`;case`video`:return`${a.toUpperCase()} video`;case`font`:return`${a} font`;case`model`:return`${a} 3D model`;case`application`:return i?.includes(`zip`)||i?.includes(`compressed`)?`${a} archive data`:i?.includes(`executable`)?`${a} executable`:`${e.toUpperCase()} data`;default:return`${e.toUpperCase()} data`}}function tDe(e){let t=e.split(`/`).pop()||e;if(t.startsWith(`.`)&&!t.includes(`.`,1))return t;let n=t.lastIndexOf(`.`);return n===-1||n===0?``:t.slice(n).toLowerCase()}function nDe(e,t){if(e.startsWith(`#!`)){let t=e.split(` `)[0];return t.includes(`python`)?{description:`Python script, ASCII text executable`,mime:`text/x-python`}:t.includes(`node`)||t.includes(`bun`)||t.includes(`deno`)?{description:`JavaScript script, ASCII text executable`,mime:`text/javascript`}:t.includes(`bash`)?{description:`Bourne-Again shell script, ASCII text executable`,mime:`text/x-shellscript`}:t.includes(`sh`)?{description:`POSIX shell script, ASCII text executable`,mime:`text/x-shellscript`}:t.includes(`ruby`)?{description:`Ruby script, ASCII text executable`,mime:`text/x-ruby`}:t.includes(`perl`)?{description:`Perl script, ASCII text executable`,mime:`text/x-perl`}:{description:`script, ASCII text executable`,mime:`text/plain`}}let n=e.trimStart();if(n.startsWith(`127){c=!0;break}return c?{description:`UTF-8 Unicode text${a}`,mime:`text/plain; charset=utf-8`}:{description:`ASCII text${a}`,mime:`text/plain`}}async function rDe(e,t){if(t.length===0)return{description:`empty`,mime:`inode/x-empty`};let n=await UEe(t);return n?{description:eDe(n.ext,n.mime),mime:n.mime}:nDe(new TextDecoder(`utf-8`,{fatal:!1}).decode(t),e)}var C0,w0,T0,E0,D0,iDe=B(()=>{$Ee(),cH(),iV(),cV(),C0={name:`file`,summary:`determine file type`,usage:`file [OPTION]... FILE...`,options:[`-b, --brief do not prepend filenames to output`,`-i, --mime output MIME type strings`,`-L, --dereference follow symlinks`,` --help display this help and exit`]},w0=new Map([[`.js`,{description:`JavaScript source`,mime:`text/javascript`}],[`.mjs`,{description:`JavaScript module`,mime:`text/javascript`}],[`.cjs`,{description:`CommonJS module`,mime:`text/javascript`}],[`.ts`,{description:`TypeScript source`,mime:`text/typescript`}],[`.tsx`,{description:`TypeScript JSX source`,mime:`text/typescript`}],[`.jsx`,{description:`JavaScript JSX source`,mime:`text/javascript`}],[`.py`,{description:`Python script`,mime:`text/x-python`}],[`.rb`,{description:`Ruby script`,mime:`text/x-ruby`}],[`.go`,{description:`Go source`,mime:`text/x-go`}],[`.rs`,{description:`Rust source`,mime:`text/x-rust`}],[`.c`,{description:`C source`,mime:`text/x-c`}],[`.h`,{description:`C header`,mime:`text/x-c`}],[`.cpp`,{description:`C++ source`,mime:`text/x-c++`}],[`.hpp`,{description:`C++ header`,mime:`text/x-c++`}],[`.java`,{description:`Java source`,mime:`text/x-java`}],[`.sh`,{description:`Bourne-Again shell script`,mime:`text/x-shellscript`}],[`.bash`,{description:`Bourne-Again shell script`,mime:`text/x-shellscript`}],[`.zsh`,{description:`Zsh shell script`,mime:`text/x-shellscript`}],[`.json`,{description:`JSON data`,mime:`application/json`}],[`.yaml`,{description:`YAML data`,mime:`text/yaml`}],[`.yml`,{description:`YAML data`,mime:`text/yaml`}],[`.xml`,{description:`XML document`,mime:`application/xml`}],[`.csv`,{description:`CSV text`,mime:`text/csv`}],[`.toml`,{description:`TOML data`,mime:`text/toml`}],[`.html`,{description:`HTML document`,mime:`text/html`}],[`.htm`,{description:`HTML document`,mime:`text/html`}],[`.css`,{description:`CSS stylesheet`,mime:`text/css`}],[`.svg`,{description:`SVG image`,mime:`image/svg+xml`}],[`.md`,{description:`Markdown document`,mime:`text/markdown`}],[`.markdown`,{description:`Markdown document`,mime:`text/markdown`}],[`.txt`,{description:`ASCII text`,mime:`text/plain`}],[`.rst`,{description:`reStructuredText`,mime:`text/x-rst`}],[`.env`,{description:`ASCII text`,mime:`text/plain`}],[`.gitignore`,{description:`ASCII text`,mime:`text/plain`}],[`.dockerignore`,{description:`ASCII text`,mime:`text/plain`}]]),T0=new Map([[`jpg`,`JPEG image data`],[`jpeg`,`JPEG image data`],[`png`,`PNG image data`],[`gif`,`GIF image data`],[`webp`,`WebP image data`],[`bmp`,`PC bitmap`],[`ico`,`MS Windows icon resource`],[`tif`,`TIFF image data`],[`tiff`,`TIFF image data`],[`psd`,`Adobe Photoshop Document`],[`avif`,`AVIF image`],[`heic`,`HEIC image`],[`heif`,`HEIF image`],[`jxl`,`JPEG XL image`],[`icns`,`Mac OS X icon`],[`svg`,`SVG Scalable Vector Graphics image`],[`pdf`,`PDF document`],[`epub`,`EPUB document`],[`mobi`,`Mobipocket E-book`],[`djvu`,`DjVu document`],[`zip`,`Zip archive data`],[`gz`,`gzip compressed data`],[`gzip`,`gzip compressed data`],[`bz2`,`bzip2 compressed data`],[`xz`,`XZ compressed data`],[`tar`,`POSIX tar archive`],[`rar`,`RAR archive data`],[`7z`,`7-zip archive data`],[`lz`,`lzip compressed data`],[`lzma`,`LZMA compressed data`],[`zst`,`Zstandard compressed data`],[`cab`,`Microsoft Cabinet archive`],[`ar`,`Unix ar archive`],[`rpm`,`RPM package`],[`deb`,`Debian binary package`],[`apk`,`Android Package`],[`dmg`,`Apple disk image`],[`iso`,`ISO 9660 CD-ROM filesystem data`],[`vhd`,`Microsoft Virtual Hard Disk`],[`vhdx`,`Microsoft Virtual Hard Disk (new format)`],[`qcow2`,`QEMU QCOW Image`],[`mp3`,`Audio file with ID3`],[`m4a`,`MPEG-4 audio`],[`aac`,`AAC audio`],[`wav`,`RIFF (little-endian) data, WAVE audio`],[`flac`,`FLAC audio bitstream data`],[`ogg`,`Ogg data`],[`oga`,`Ogg audio`],[`opus`,`Ogg Opus audio`],[`aiff`,`AIFF audio`],[`wma`,`Windows Media Audio`],[`amr`,`AMR audio`],[`mid`,`MIDI audio`],[`midi`,`MIDI audio`],[`ape`,`Monkey's Audio`],[`mp4`,`ISO Media, MPEG-4`],[`m4v`,`MPEG-4 video`],[`webm`,`WebM`],[`avi`,`RIFF (little-endian) data, AVI`],[`mov`,`ISO Media, Apple QuickTime movie`],[`mkv`,`Matroska data`],[`wmv`,`Windows Media Video`],[`flv`,`Flash Video`],[`3gp`,`3GPP multimedia`],[`3g2`,`3GPP2 multimedia`],[`ogv`,`Ogg video`],[`mts`,`MPEG transport stream`],[`m2ts`,`MPEG transport stream`],[`ts`,`MPEG transport stream`],[`mpg`,`MPEG video`],[`mpeg`,`MPEG video`],[`exe`,`PE32 executable`],[`dll`,`PE32 DLL`],[`elf`,`ELF executable`],[`mach`,`Mach-O executable`],[`wasm`,`WebAssembly (wasm) binary module`],[`dex`,`Android Dalvik executable`],[`class`,`Java class file`],[`swf`,`Adobe Flash`],[`doc`,`Microsoft Word Document`],[`docx`,`Microsoft Word 2007+ Document`],[`xls`,`Microsoft Excel Spreadsheet`],[`xlsx`,`Microsoft Excel 2007+ Spreadsheet`],[`ppt`,`Microsoft PowerPoint Presentation`],[`pptx`,`Microsoft PowerPoint 2007+ Presentation`],[`odt`,`OpenDocument Text`],[`ods`,`OpenDocument Spreadsheet`],[`odp`,`OpenDocument Presentation`],[`ttf`,`TrueType Font`],[`otf`,`OpenType Font`],[`woff`,`Web Open Font Format`],[`woff2`,`Web Open Font Format 2`],[`eot`,`Embedded OpenType font`],[`stl`,`Stereolithography CAD`],[`obj`,`Wavefront 3D Object`],[`gltf`,`GL Transmission Format`],[`glb`,`GL Transmission Format (binary)`],[`sqlite`,`SQLite 3.x database`],[`mdb`,`Microsoft Access Database`],[`xml`,`XML document`],[`json`,`JSON data`],[`macho`,`Mach-O binary`],[`ics`,`iCalendar data`],[`vcf`,`vCard data`],[`msi`,`Microsoft Installer`],[`ps`,`PostScript`],[`ai`,`Adobe Illustrator`],[`indd`,`Adobe InDesign`],[`sketch`,`Sketch design file`],[`fig`,`Figma design file`],[`xd`,`Adobe XD`],[`blend`,`Blender`],[`fbx`,`Autodesk FBX`],[`lnk`,`MS Windows shortcut`],[`alias`,`Mac OS alias`],[`torrent`,`BitTorrent file`],[`pcap`,`pcap capture file`],[`arrow`,`Apache Arrow`],[`parquet`,`Apache Parquet`]]),E0={name:`file`,async execute(e,t){if(oV(e))return aV(C0);let n=!1,r=!1,i=!1,a=[];for(let t of e)if(t.startsWith(`--`)){if(t===`--brief`)n=!0;else if(t===`--mime`||t===`--mime-type`)r=!0;else if(t===`--dereference`)i=!0;else return sV(`file`,t)}else if(t.startsWith(`-`)&&t!==`-`)for(let e of t.slice(1))if(e===`b`)n=!0;else if(e===`i`)r=!0;else if(e===`L`)i=!0;else return sV(`file`,`-${e}`);else a.push(t);if(a.length===0)return{stdout:``,stderr:`Usage: file [-bLi] FILE... `,exitCode:1};let o=new sH(Math.min(t.limits.maxOutputSize,t.limits.maxStringLength),`file`),s=0;for(let e of a){t.executionScope?.consumeLimited(`file-operands`,1,t.limits.maxArrayElements,`file`);try{let a=t.fs.resolvePath(t.cwd,e),s=i?await t.fs.stat(a):await t.fs.lstat(a);if(s.isSymbolicLink){let i=await t.fs.readlink(a),s=r?`inode/symlink`:`symbolic link to ${i}`;o.append(n?`${s} `:`${e}: ${s} `);continue}if(s.isDirectory){let t=r?`inode/directory`:`directory`;o.append(n?`${t} `:`${e}: ${t} `);continue}let c=await t.fs.readFileBuffer(a);t.executionScope?.consumeInput(c.byteLength,`file`);let l=await rDe(e,c),u=r?l.mime:l.description;o.append(n?`${u} `:`${e}: ${u} `)}catch(t){rV(t),o.append(n?`cannot open `:`${e}: cannot open (No such file or directory) `),s=1}}return{stdout:o.build(),stderr:``,exitCode:s}}},D0={name:`file`,flags:[{flag:`-b`,type:`boolean`},{flag:`-i`,type:`boolean`},{flag:`-L`,type:`boolean`}],needsArgs:!0}}),O0={};Tz(O0,{flagsForFuzzing:()=>j0,htmlToMarkdownCommand:()=>A0});var k0,A0,j0,aDe=B(()=>{AB(),iV(),U(),cV(),k0={name:`html-to-markdown`,summary:`convert HTML to Markdown (BashEnv extension)`,usage:`html-to-markdown [OPTION]... [FILE]`,description:[`Convert HTML content to Markdown format using the turndown library.`,`This is a non-standard BashEnv extension command, not available in regular bash.`,``,`Read HTML from FILE or standard input and output Markdown to standard output.`,`Commonly used with curl to convert web pages:`,` curl -s https://example.com | html-to-markdown`,``,`Supported HTML elements:`,` - Headings (h1-h6) → # Markdown headings`,` - Paragraphs (p) → Plain text with blank lines`,` - Links (a) → [text](url)`,` - Images (img) → ![alt](src)`,` - Bold/Strong → **text**`,` - Italic/Em → _text_`," - Code (code, pre) → `inline` or fenced blocks",` - Lists (ul, ol, li) → - or 1. items`,` - Blockquotes → > quoted text`,` - Horizontal rules (hr) → ---`],options:[`-b, --bullet=CHAR bullet character for unordered lists (-, +, or *)`,"-c, --code=FENCE fence style for code blocks (``` or ~~~)",`-r, --hr=STRING string for horizontal rules (default: ---)`,` --heading-style=STYLE`,` heading style: 'atx' for # headings (default),`,` 'setext' for underlined headings (h1/h2 only)`,` --help display this help and exit`],examples:[`echo '

Hello

World

' | html-to-markdown`,`html-to-markdown page.html`,`curl -s https://example.com | html-to-markdown > page.md`]},A0={name:`html-to-markdown`,async execute(e,t){if(oV(e))return aV(k0);let n=`-`,r="```",i=`---`,a=`atx`,o=[];for(let t=0;tc)throw new H(`html-to-markdown: input size limit exceeded (${c} bytes)`,`string_length`);s=yB(t.stdin)}else try{let e=t.fs.resolvePath(t.cwd,o[0]);if((await t.fs.stat(e)).size>c||(s=await t.fs.readFile(e),V(s)>c))throw new H(`html-to-markdown: input size limit exceeded (${c} bytes)`,`string_length`)}catch(e){return rV(e),{stdout:``,stderr:`html-to-markdown: ${o[0]}: No such file or directory `,exitCode:1}}if(!s.trim())return{stdout:``,stderr:``,exitCode:0};if(![`-`,`+`,`*`].includes(n))return{stdout:``,stderr:`html-to-markdown: invalid bullet marker `,exitCode:1};if(r!=="```"&&r!==`~~~`)return{stdout:``,stderr:`html-to-markdown: invalid code fence `,exitCode:1};let l=0,u=t.limits.maxLoopIterations;for(let e=0;eu)throw new H(`html-to-markdown: complexity limit exceeded (${u} tags)`,`iterations`);t.executionScope?.consumeWork(l,`html-to-markdown tags`);let d=V(s),f=Math.min(t.limits.maxStringLength,t.limits.maxOutputSize);if(d>Math.floor((f-1)/4))throw new H(`html-to-markdown: prospective output size limit exceeded (${f} bytes)`,`output_size`);let p=d*4+1,m=t.executionScope?.reserveBytes(`html input`,d,`html-to-markdown`),h=t.executionScope?.reserveBytes(`html prospective output`,p,`html-to-markdown`);try{let e=new fz({bulletListMarker:n,codeBlockStyle:`fenced`,fence:r,hr:i,headingStyle:a});e.remove([`script`,`style`,`footer`]);let t=e.turndown(s).trim();if(V(t)+1>f)throw new H(`html-to-markdown: output size limit exceeded (${f} bytes)`,`output_size`);return{stdout:`${t} `,stderr:``,exitCode:0}}catch(e){return rV(e),{stdout:``,stderr:`html-to-markdown: conversion error: ${e.message} `,exitCode:1}}finally{h?.release(),m?.release()}}},j0={name:`html-to-markdown`,flags:[],stdinType:`text`}}),M0={};Tz(M0,{flagsForFuzzing:()=>F0,helpCommand:()=>P0});function oDe(e){let t=[],n=new Set(e);t.push(`Available commands: `);let r=[];for(let[e,r]of N0){let i=r.filter(e=>n.has(e));if(i.length>0){t.push(` ${e}:`),t.push(` ${i.join(`, `)} `);for(let e of i)n.delete(e)}}for(let e of n)r.push(e);return r.length>0&&(t.push(` Other:`),t.push(` ${r.sort().join(`, `)} `)),t.push(`Use ' --help' for details on a specific command.`),`${t.join(` `)} `}var N0,P0,F0,sDe=B(()=>{hK(),N0=new Map([[`File operations`,[`ls`,`cat`,`head`,`tail`,`wc`,`touch`,`mkdir`,`rm`,`cp`,`mv`,`ln`,`chmod`,`stat`,`readlink`]],[`Text processing`,[`grep`,`sed`,`awk`,`sort`,`uniq`,`cut`,`tr`,`tee`,`diff`]],[`Search`,[`find`]],[`Navigation & paths`,[`pwd`,`basename`,`dirname`,`tree`,`du`]],[`Environment & shell`,[`echo`,`printf`,`env`,`printenv`,`export`,`alias`,`unalias`,`history`,`clear`,`true`,`false`,`bash`,`sh`]],[`Data processing`,[`xargs`,`jq`,`base64`,`date`]],[`Network`,[`curl`,`html-to-markdown`]]]),P0={name:`help`,async execute(e,t){if(e.includes(`--help`)||e.includes(`-h`))return{stdout:`help - display available commands Usage: help [command] Options: -h, --help Show this help message If a command name is provided, shows help for that command. Otherwise, lists all available commands. `,stderr:``,exitCode:0};if(e.length>0&&t.exec){let n=e[0];return t.exec(mK([n]),{cwd:t.cwd,signal:t.signal,args:[`--help`]})}return{stdout:oDe(t.getRegisteredCommands?.()??[]),stderr:``,exitCode:0}}},F0={name:`help`,flags:[]}}),I0={};Tz(I0,{flagsForFuzzing:()=>B0,whichCommand:()=>z0});var L0,R0,z0,B0,cDe=B(()=>{uV(),cV(),L0={name:`which`,summary:`locate a command`,usage:`which [-as] program ...`,options:[`-a List all instances of executables found`,`-s No output, just return 0 if found, 1 if not`,`--help display this help and exit`]},R0={showAll:{short:`a`,type:`boolean`},silent:{short:`s`,type:`boolean`}},z0={name:`which`,async execute(e,t){if(oV(e))return aV(L0);let n=lV(`which`,e,R0);if(!n.ok)return n.error;let r=n.result.flags.showAll,i=n.result.flags.silent,a=n.result.positional;if(a.length===0)return{stdout:``,stderr:``,exitCode:1};let o=(t.env.get(`PATH`)||`/usr/bin:/bin`).split(`:`),s=``,c=!0;for(let e of a){let n=!1;for(let a of o){if(!a)continue;let o=t.fs.resolvePath(a,e);if(await t.fs.exists(o)&&(n=!0,i||(s+=`${o} `),!r))break}n||(c=!1)}return{stdout:s,stderr:``,exitCode:+!c}}},B0={name:`which`,flags:[{flag:`-a`,type:`boolean`},{flag:`-s`,type:`boolean`}],needsArgs:!0}}),V0={};Tz(V0,{flagsForFuzzing:()=>U0,tac:()=>H0});async function lDe(e,t){if(e.length>0&&e[0]!==`-`){let n=t.fs.resolvePath(t.cwd,e[0]);try{let e=(await t.fs.readFile(n)).split(` `);e[e.length-1]===``&&e.pop();let r=e.reverse();return{stdout:r.length>0?`${r.join(` `)} `:``,stderr:``,exitCode:0}}catch{return{stdout:``,stderr:`tac: ${e[0]}: No such file or directory `,exitCode:1}}}let n=t.stdin.split(` `);n[n.length-1]===``&&n.pop();let r=n.reverse();return{stdout:r.length>0?`${r.join(` `)} `:``,stderr:``,exitCode:0,stdoutKind:`bytes`}}var H0,U0,uDe=B(()=>{AB(),H0={name:`tac`,execute:lDe},U0={name:`tac`,flags:[],stdinType:`text`,needsFiles:!0}}),W0={};Tz(W0,{flagsForFuzzing:()=>K0,hostname:()=>G0});async function dDe(e,t){return{stdout:`localhost `,stderr:``,exitCode:0}}var G0,K0,fDe=B(()=>{G0={name:`hostname`,execute:dDe},K0={name:`hostname`,flags:[]}}),q0={};Tz(q0,{flagsForFuzzing:()=>Y0,whoami:()=>J0});async function pDe(e,t){return{stdout:`user `,stderr:``,exitCode:0}}var J0,Y0,mDe=B(()=>{J0={name:`whoami`,execute:pDe},Y0={name:`whoami`,flags:[]}}),X0={};Tz(X0,{flagsForFuzzing:()=>Q0,od:()=>Z0});async function hDe(e,t){let n=`octal`,r=[],i=[];for(let t=0;t=32&&e<127?` ${String.fromCharCode(e)}`:` ${e.toString(8).padStart(3,`0`)}`}function l(e){return s?` ${e.toString(16).padStart(2,`0`)}`:` ${e.toString(16).padStart(2,`0`)}`}function u(e){return` ${e.toString(8).padStart(3,`0`)}`}let d=a.build(),f=new sH(Math.min(t.limits.maxOutputSize,t.limits.maxStringLength),`od`),p=r.length;if(p>0&&d.length>Math.floor(t.limits.maxLoopIterations/p))throw new H(`od: format work limit exceeded (${t.limits.maxLoopIterations})`,`iterations`);t.executionScope?.consumeWork(d.length*p,`od formatting`);for(let e=0;ec(e.charCodeAt(0))):i===`hex`?Array.from(d.slice(e,e+16),e=>l(e.charCodeAt(0))):Array.from(d.slice(e,e+16),e=>u(e.charCodeAt(0)));let o=``;t===0&&n!==`none`?o=`${e.toString(8).padStart(7,`0`)} `:(t>0||n===`none`)&&(o=n===`none`?``:` `),f.append(o+a.join(``)).append(` `)}return n!==`none`&&d.length>0&&f.append(d.length.toString(8).padStart(7,`0`)).append(` `),{stdout:f.build(),stderr:``,exitCode:0}}var Z0,Q0,gDe=B(()=>{cH(),AB(),iV(),U(),Z0={name:`od`,execute:hDe},Q0={name:`od`,flags:[{flag:`-c`,type:`boolean`},{flag:`-A`,type:`value`,valueHint:`string`},{flag:`-t`,type:`value`,valueHint:`string`},{flag:`-N`,type:`value`,valueHint:`number`}],stdinType:`text`,needsFiles:!0}}),$0,_De=B(()=>{$0=class{options;inputBytes=0;outputBytes=0;workBytes=0;label;constructor(e){this.options=e,this.label=e.label??`codec`;for(let[t,n]of[[`maxInputBytes`,e.maxInputBytes],[`maxOutputBytes`,e.maxOutputBytes],[`maxExpansionRatio`,e.maxExpansionRatio],[`ratioGraceBytes`,e.ratioGraceBytes],[`maxWorkBytes`,e.maxWorkBytes]])if(n!==void 0&&(!Number.isSafeInteger(n)||n<0))throw Error(`${this.label}: invalid ${t}`)}checkpoint(){if(this.options.signal?.aborted)throw Error(`${this.label}: operation aborted`)}acceptInput(e){this.checkpoint(),this.inputBytes=this.addWithinLimit(this.inputBytes,e,this.options.maxInputBytes,`input`),this.chargeWork(e)}acceptOutput(e){this.checkpoint();let t=this.addWithinLimit(this.outputBytes,e,this.options.maxOutputBytes,`output`),n=this.options.ratioGraceBytes??1048576,r=this.options.maxExpansionRatio;if(r!==void 0&&t>n&&(this.inputBytes===0||t>this.inputBytes*r))throw Error(`${this.label}: expansion ratio exceeds limit (${r}:1)`);this.outputBytes=t,this.chargeWork(e)}get inputLength(){return this.inputBytes}get outputLength(){return this.outputBytes}chargeWork(e){let t=this.options.maxWorkBytes??this.options.maxInputBytes+this.options.maxOutputBytes;this.workBytes=this.addWithinLimit(this.workBytes,e,t,`work`)}addWithinLimit(e,t,n,r){if(!Number.isSafeInteger(t)||t<0||t>n-e)throw Error(`${this.label}: ${r} exceeds limit (${n} bytes)`);return e+t}}}),e2={};Tz(e2,{flagsForFuzzing:()=>b2,gunzipCommand:()=>v2,gunzipFlagsForFuzzing:()=>x2,gzipCommand:()=>_2,zcatCommand:()=>y2,zcatFlagsForFuzzing:()=>S2});function t2(e){return e.best?CR.constants.Z_BEST_COMPRESSION:e.level8?8:e.level7?7:e.level6?6:e.level5?5:e.level4?4:e.level3?3:e.level2?2:e.fast?CR.constants.Z_BEST_SPEED:CR.constants.Z_DEFAULT_COMPRESSION}function n2(e){if(e.length<10||e[0]!==31||e[1]!==139)return{originalName:null,mtime:null,headerSize:0};let t=e[3],n=e[4]|e[5]<<8|e[6]<<16|e[7]<<24,r=10;if(t&4){if(r+2>e.length)return{originalName:null,mtime:null,headerSize:0};let t=e[r]|e[r+1]<<8;r+=2+t}let i=null;if(t&8){let t=r;for(;r0?new Date(n*1e3):null,headerSize:r}}function vDe(e){return e.length===0||e===`.`||e===`..`||e.includes(`/`)||e.includes(`\\`)||/[\0-\x1f\x7f]/.test(e)?null:e}function r2(e){if(e.length<4)return 0;let t=e.length;return e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24}function i2(e){return e.length>=2&&e[0]===31&&e[1]===139}function a2(e){return Buffer.from(e).toString(`latin1`)}function o2(e){return e.limits.maxOutputSize}function s2(e,t,n,r,i){if(t<=0)throw Error(`decompressed data exceeds limit (0 bytes)`);let a=new $0({maxInputBytes:n,maxOutputBytes:t,maxExpansionRatio:1e4,signal:r,label:`gzip`});if(a.acceptInput(e.length),r2(e)>t)throw Error(`decompressed data exceeds limit (${t} bytes)`);let o;try{let n=Math.min(t,Math.floor((i?.executionScope?.remainingLiveBytes??t*2)/2));if(n<=0)throw Error(`gzip: live byte limit exceeded`);o=i?.executionScope?.reserveBytes(`gzip output`,n*2,`gzip`);let r=(0,CR.gunzipSync)(e,{maxOutputLength:n});return a.acceptOutput(r.length),{data:r,lease:o}}catch(e){throw o?.release(),e}}function c2(e,t,n){let r=new $0({maxInputBytes:n.limits.maxInputBytes,maxOutputBytes:n.limits.maxOutputSize,signal:n.signal,label:`gzip`});r.acceptInput(e.length);let i;try{let a=Math.min(n.limits.maxOutputSize,Math.floor((n.executionScope?.remainingLiveBytes??n.limits.maxOutputSize*2)/2));if(a<=0)throw Error(`gzip: live byte limit exceeded`);i=n.executionScope?.reserveBytes(`gzip output`,a*2,`gzip`);let o=(0,CR.gzipSync)(e,{level:t,maxOutputLength:a});return r.acceptOutput(o.length),{data:o,lease:i}}catch(e){throw i?.release(),e}}async function l2(e,t,n){let r=await e.fs.stat(t);if(r.size>e.limits.maxInputBytes)throw new H(`input size limit exceeded (${e.limits.maxInputBytes} bytes)`,`string_length`);let i=e.executionScope?.reserveBytes(`gzip input`,r.size,n);try{let a=await e.fs.readFileBuffer(t);if(a.byteLength>r.size)throw new H(`gzip: input grew while being read`,`string_length`);return e.executionScope?.consumeInput(a.byteLength,n),{data:a,lease:i}}catch(e){throw i?.release(),e}}async function u2(e,t,n){if(t!==`-`&&t!==``)return l2(e,e.fs.resolvePath(e.cwd,t),n);let r=e.stdin,i=e.executionScope?.reserveBytes(`gzip input`,r.length,n);try{return{data:Uint8Array.from(r,e=>e.charCodeAt(0)),lease:i}}catch(e){throw i?.release(),e}}async function d2(e,t,n,r,i,a){let o=n.suffix,s,c,l,u=o2(e);if(t===`-`||t===``){let t=e.stdin,a=e.executionScope?.reserveBytes(`gzip input`,t.length,r),o;try{if(l=Uint8Array.from(t,e=>e.charCodeAt(0)),i){if(!i2(l))return n.quiet?{stdout:``,stderr:``,exitCode:1}:{stdout:``,stderr:`${r}: stdin: not in gzip format `,exitCode:1};try{let t=s2(l,u,e.limits.maxInputBytes,e.signal,e);return o=t.lease,{stdout:a2(t.data),stderr:``,exitCode:0}}catch(e){return rV(e),{stdout:``,stderr:`${r}: stdin: ${e instanceof Error?e.message:`unknown error`} `,exitCode:1}}}{let t=c2(l,t2(n),e);return o=t.lease,{stdout:a2(t.data),stderr:``,exitCode:0}}}finally{o?.release(),a?.release()}}s=e.fs.resolvePath(e.cwd,t);try{let o=await e.fs.stat(s);if(o.size>e.limits.maxInputBytes)return{stdout:``,stderr:`${r}: ${t}: input size limit exceeded (${e.limits.maxInputBytes} bytes) `,exitCode:1};if(o.isDirectory)return n.recursive?await yDe(e,s,n,r,i,a):n.quiet?{stdout:``,stderr:``,exitCode:1}:{stdout:``,stderr:`${r}: ${t}: is a directory -- ignored `,exitCode:1}}catch{return{stdout:``,stderr:`${r}: ${t}: No such file or directory `,exitCode:1}}let d,f;try{let t=await l2(e,s,r);l=t.data,d=t.lease}catch(e){return rV(e),{stdout:``,stderr:`${r}: ${t}: No such file or directory `,exitCode:1}}try{if(i){if(!t.endsWith(o))return n.quiet?{stdout:``,stderr:``,exitCode:1}:{stdout:``,stderr:`${r}: ${t}: unknown suffix -- ignored `,exitCode:1};if(!i2(l))return n.quiet?{stdout:``,stderr:``,exitCode:1}:{stdout:``,stderr:`${r}: ${t}: not in gzip format `,exitCode:1};let i;try{let t=s2(l,u,e.limits.maxInputBytes,e.signal,e);i=t.data,f=t.lease}catch(e){return rV(e),{stdout:``,stderr:`${r}: ${t}: ${e instanceof Error?e.message:`unknown error`} `,exitCode:1}}if(a)return{stdout:a2(i),stderr:``,exitCode:0};if(n.name){let t=n2(l),n=t.originalName?vDe(t.originalName):null;c=n?e.fs.resolvePath(e.cwd,n):s.slice(0,-o.length)}else c=s.slice(0,-o.length);if(!n.force)try{return await e.fs.stat(c),{stdout:``,stderr:`${r}: ${c} already exists; not overwritten `,exitCode:1}}catch{}return await e.fs.writeFile(c,i),!n.keep&&!a&&await e.fs.rm(s),n.verbose?{stdout:``,stderr:`${t}: ${l.length>0?((1-l.length/i.length)*100).toFixed(1):`0.0`}% -- replaced with ${c.split(`/`).pop()} `,exitCode:0}:{stdout:``,stderr:``,exitCode:0}}{if(t.endsWith(o))return n.quiet?{stdout:``,stderr:``,exitCode:1}:{stdout:``,stderr:`${r}: ${t} already has ${o} suffix -- unchanged `,exitCode:1};let i=t2(n),u;try{let t=c2(l,i,e);u=t.data,f=t.lease}catch(e){return rV(e),{stdout:``,stderr:`${r}: ${t}: ${e instanceof Error?e.message:`unknown error`} `,exitCode:1}}if(a)return{stdout:a2(u),stderr:``,exitCode:0};if(c=s+o,!n.force)try{return await e.fs.stat(c),{stdout:``,stderr:`${r}: ${c} already exists; not overwritten `,exitCode:1}}catch{}return await e.fs.writeFile(c,u),!n.keep&&!a&&await e.fs.rm(s),n.verbose?{stdout:``,stderr:`${t}: ${l.length>0?((1-u.length/l.length)*100).toFixed(1):`0.0`}% -- replaced with ${c.split(`/`).pop()} `,exitCode:0}:{stdout:``,stderr:``,exitCode:0}}}finally{f?.release(),d?.release()}}async function yDe(e,t,n,r,i,a){let o=Math.min(e.limits.maxOutputSize,e.limits.maxStringLength),s=new sH(o,r),c=new sH(o,r),l=0;return await TH({fs:e.fs,root:t,symlinks:`never`,limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:r},async t=>{if(t.depth===0||t.phase!==`enter`||!t.stat.isFile)return;let o=n.suffix;if(i&&!t.path.endsWith(o)||!i&&t.path.endsWith(o))return;let u=await d2(e,t.path.startsWith(`${e.cwd}/`)?t.path.slice(e.cwd.length+1):t.path,n,r,i,a);s.append(u.stdout),c.append(u.stderr),u.exitCode!==0&&(l=u.exitCode)}),{stdout:s.build(),stderr:c.build(),exitCode:l}}async function bDe(e,t,n,r){let i,a;try{let n=await u2(e,t,r);i=n.data,a=n.lease}catch(e){return rV(e),{stdout:``,stderr:`${r}: ${t}: No such file or directory `,exitCode:1}}try{if(!i2(i))return n.quiet?{stdout:``,stderr:``,exitCode:1}:{stdout:``,stderr:`${r}: ${t}: not in gzip format `,exitCode:1};let e=i.length,a=r2(i),o=a>0?((1-e/a)*100).toFixed(1):`0.0`,s=n2(i).originalName||(t===`-`?``:t.replace(/\.gz$/,``));return{stdout:`${e.toString().padStart(10)} ${a.toString().padStart(10)} ${o.padStart(5)}% ${s} `,stderr:``,exitCode:0}}finally{a?.release()}}async function xDe(e,t,n,r){let i,a;try{let n=await u2(e,t,r);i=n.data,a=n.lease}catch(e){return rV(e),{stdout:``,stderr:`${r}: ${t}: No such file or directory `,exitCode:1}}try{if(!i2(i))return n.quiet?{stdout:``,stderr:``,exitCode:1}:{stdout:``,stderr:`${r}: ${t}: not in gzip format `,exitCode:1};try{return s2(i,o2(e),e.limits.maxInputBytes,e.signal,e).lease?.release(),n.verbose?{stdout:``,stderr:`${t}: OK `,exitCode:0}:{stdout:``,stderr:``,exitCode:0}}catch(e){return rV(e),{stdout:``,stderr:`${r}: ${t}: ${e instanceof Error?e.message:`invalid`} `,exitCode:1}}}finally{a?.release()}}async function f2(e,t,n){let r=n===`zcat`?h2:n===`gunzip`?m2:p2;if(oV(e))return aV(r);let i=lV(n,e,g2);if(!i.ok)return i.error.stderr.includes(`unrecognized option`),i.error;let a=i.result.flags,o=i.result.positional,s=n===`gunzip`||n===`zcat`||a.decompress||a.uncompress,c=n===`zcat`||a.stdout||a.toStdout;if(a.list){o.length===0&&(o=[`-`]);let e=` compressed uncompressed ratio uncompressed_name `,r=``,i=0;for(let s of o){let o=await bDe(t,s,a,n);e+=o.stdout,r+=o.stderr,o.exitCode!==0&&(i=o.exitCode)}return{stdout:e,stderr:r,exitCode:i}}if(a.test){o.length===0&&(o=[`-`]);let e=``,r=``,i=0;for(let s of o){let o=await xDe(t,s,a,n);e+=o.stdout,r+=o.stderr,o.exitCode!==0&&(i=o.exitCode)}return{stdout:e,stderr:r,exitCode:i}}o.length===0&&(o=[`-`]);let l=``,u=``,d=0;for(let e of o){let r=await d2(t,e,a,n,s,c);l+=r.stdout,u+=r.stderr,r.exitCode!==0&&(d=r.exitCode)}return{stdout:l,stderr:u,exitCode:d}}var p2,m2,h2,g2,_2,v2,y2,b2,x2,S2,C2=B(()=>{cH(),AB(),iV(),OH(),U(),uV(),_De(),cV(),p2={name:`gzip`,summary:`compress or expand files`,usage:`gzip [OPTION]... [FILE]...`,description:`Compress FILEs (by default, in-place). When no FILE is given, or when FILE is -, read from standard input. With -d, decompress instead.`,options:[`-c, --stdout write to standard output, keep original files`,`-d, --decompress decompress`,`-f, --force force overwrite of output file`,`-k, --keep keep (don't delete) input files`,`-l, --list list compressed file contents`,`-n, --no-name do not save or restore the original name and timestamp`,`-N, --name save or restore the original file name and timestamp`,`-q, --quiet suppress all warnings`,`-r, --recursive operate recursively on directories`,`-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)`,`-t, --test test compressed file integrity`,`-v, --verbose verbose mode`,`-1, --fast compress faster`,`-9, --best compress better`,` --help display this help and exit`]},m2={name:`gunzip`,summary:`decompress files`,usage:`gunzip [OPTION]... [FILE]...`,description:`Decompress FILEs (by default, in-place). When no FILE is given, or when FILE is -, read from standard input.`,options:[`-c, --stdout write to standard output, keep original files`,`-f, --force force overwrite of output file`,`-k, --keep keep (don't delete) input files`,`-l, --list list compressed file contents`,`-n, --no-name do not restore the original name and timestamp`,`-N, --name restore the original file name and timestamp`,`-q, --quiet suppress all warnings`,`-r, --recursive operate recursively on directories`,`-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)`,`-t, --test test compressed file integrity`,`-v, --verbose verbose mode`,` --help display this help and exit`]},h2={name:`zcat`,summary:`decompress files to stdout`,usage:`zcat [OPTION]... [FILE]...`,description:`Decompress FILEs to standard output. When no FILE is given, or when FILE is -, read from standard input.`,options:[`-f, --force force; read compressed data even from a terminal`,`-l, --list list compressed file contents`,`-q, --quiet suppress all warnings`,`-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)`,`-t, --test test compressed file integrity`,`-v, --verbose verbose mode`,` --help display this help and exit`]},g2={stdout:{short:`c`,long:`stdout`,type:`boolean`},toStdout:{long:`to-stdout`,type:`boolean`},decompress:{short:`d`,long:`decompress`,type:`boolean`},uncompress:{long:`uncompress`,type:`boolean`},force:{short:`f`,long:`force`,type:`boolean`},keep:{short:`k`,long:`keep`,type:`boolean`},list:{short:`l`,long:`list`,type:`boolean`},noName:{short:`n`,long:`no-name`,type:`boolean`},name:{short:`N`,long:`name`,type:`boolean`},quiet:{short:`q`,long:`quiet`,type:`boolean`},recursive:{short:`r`,long:`recursive`,type:`boolean`},suffix:{short:`S`,long:`suffix`,type:`string`,default:`.gz`},test:{short:`t`,long:`test`,type:`boolean`},verbose:{short:`v`,long:`verbose`,type:`boolean`},fast:{short:`1`,long:`fast`,type:`boolean`},level2:{short:`2`,type:`boolean`},level3:{short:`3`,type:`boolean`},level4:{short:`4`,type:`boolean`},level5:{short:`5`,type:`boolean`},level6:{short:`6`,type:`boolean`},level7:{short:`7`,type:`boolean`},level8:{short:`8`,type:`boolean`},best:{short:`9`,long:`best`,type:`boolean`}},_2={name:`gzip`,async execute(e,t){return{...await f2(e,t,`gzip`),stdoutEncoding:`binary`}}},v2={name:`gunzip`,async execute(e,t){return{...await f2(e,t,`gunzip`),stdoutEncoding:`binary`}}},y2={name:`zcat`,async execute(e,t){return{...await f2(e,t,`zcat`),stdoutEncoding:`binary`}}},b2={name:`gzip`,flags:[{flag:`-c`,type:`boolean`},{flag:`-d`,type:`boolean`},{flag:`-f`,type:`boolean`},{flag:`-k`,type:`boolean`},{flag:`-l`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-q`,type:`boolean`},{flag:`-r`,type:`boolean`},{flag:`-t`,type:`boolean`},{flag:`-v`,type:`boolean`},{flag:`-1`,type:`boolean`},{flag:`-9`,type:`boolean`}],stdinType:`binary`,needsFiles:!0},x2={name:`gunzip`,flags:[{flag:`-c`,type:`boolean`},{flag:`-f`,type:`boolean`},{flag:`-k`,type:`boolean`},{flag:`-q`,type:`boolean`},{flag:`-v`,type:`boolean`}],stdinType:`binary`,needsFiles:!0},S2={name:`zcat`,flags:[{flag:`-f`,type:`boolean`},{flag:`-q`,type:`boolean`},{flag:`-v`,type:`boolean`}],stdinType:`binary`,needsFiles:!0}});function w2(e,t){if(e instanceof Uint8Array)return e;if(t===`base64`)return Uint8Array.from(atob(e),e=>e.charCodeAt(0));if(t===`hex`){let t=new Uint8Array(e.length/2);for(let n=0;ne.charCodeAt(0));let t=new Uint8Array(e.length);for(let n=0;ne.toString(16).padStart(2,`0`)).join(``);if(t===`binary`||t===`latin1`){if(typeof Buffer<`u`)return Buffer.from(e).toString(t);let n=65536;if(e.length<=n)return String.fromCharCode(...e);let r=``;for(let t=0;t{D2=new TextEncoder,O2=new TextDecoder});function A2(e){return encodeURIComponent(e).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16)}`).replace(/%20/g,`+`).replace(/%[0-9A-F]{2}/g,e=>e.toLowerCase())}function SDe(e){let t=e.indexOf(`=`);if(t>=0){let n=e.slice(0,t),r=A2(e.slice(t+1));return n?`${n}=${r}`:r}return A2(e)}function j2(e){let t=e.indexOf(`=`);if(t<0)return null;let n=e.slice(0,t),r=e.slice(t+1),i,a,o=r.match(/;type=([^;]+)$/);o&&(a=o[1],r=r.slice(0,-o[0].length));let s=r.match(/;filename=([^;]+)/);return s&&(i=s[1],r=r.replace(s[0],``)),(r.startsWith(`@`)||r.startsWith(`<`))&&(i??=r.slice(1).split(`/`).pop()),{name:n,value:r,filename:i,contentType:a}}function CDe(e,t){let n=`----CurlFormBoundary${Date.now().toString(36)}`,r=[];for(let i of e){let e=i.value;if(e.startsWith(`@`)||e.startsWith(`<`)){let n=e.slice(1);e=t.get(n)??``}let a=`--${n}\r `;i.filename?(a+=`Content-Disposition: form-data; name="${i.name}"; filename="${i.filename}"\r `,i.contentType&&(a+=`Content-Type: ${i.contentType}\r `)):a+=`Content-Disposition: form-data; name="${i.name}"\r `,a+=`\r ${e}\r `,r.push(a)}return r.push(`--${n}--\r `),{body:r.join(``),boundary:n}}var M2=B(()=>{}),N2,wDe=B(()=>{N2={name:`curl`,summary:`transfer a URL`,usage:`curl [OPTIONS] URL`,options:[`-X, --request METHOD HTTP method (GET, POST, PUT, DELETE, etc.)`,`-H, --header HEADER Add header (can be used multiple times)`,`-d, --data DATA HTTP POST data (DATA=@file reads from file, strips newlines)`,`-G, --get Append data payloads to URL query string`,` --data-raw DATA HTTP POST data (no @ interpretation)`,` --data-binary DATA HTTP POST binary data (DATA=@file reads file verbatim)`,` --data-urlencode DATA URL-encode and POST data (supports @file and name@file)`,`-F, --form NAME=VALUE Multipart form data`,`-u, --user USER:PASS HTTP authentication`,`-A, --user-agent STR Set User-Agent header`,`-e, --referer URL Set Referer header`,`-b, --cookie DATA Send cookies (name=value or @file)`,`-c, --cookie-jar FILE Save cookies to file`,`-T, --upload-file FILE Upload file (PUT)`,`-o, --output FILE Write output to file`,`-O, --remote-name Write to file named from URL`,`-I, --head Show headers only (HEAD request)`,`-i, --include Include response headers in output`,`-s, --silent Silent mode (no progress)`,`-S, --show-error Show errors even when silent`,`-f, --fail Fail silently on HTTP errors (no output)`,`-L, --location Follow redirects (default)`,` --max-redirs NUM Maximum redirects (default: 20)`,`-m, --max-time SECS Maximum time for request`,` --connect-timeout SECS Connection timeout`,`-w, --write-out FMT Output format after completion`,`-v, --verbose Verbose output`,` --help Display this help and exit`,``,`Note: Network access must be configured via BashEnv network option.`,` curl is not available by default for security reasons.`]}});function P2(e,t,n){n.allowFile&&t.startsWith(`@`)?e.dataParts.push({file:{path:t.slice(1),mode:n.binary?`binary`:`ascii`}}):e.dataParts.push({value:t}),n.binary&&(e.dataBinary=!0)}function F2(e,t){if(t.startsWith(`@`)){e.dataParts.push({file:{path:t.slice(1),mode:`urlencode`}});return}let n=t.indexOf(`@`),r=t.indexOf(`=`);if(n>0&&(r<0||n0){let r=n.slice(0,e).trim(),i=n.slice(e+1).trim();t.headers.append(r,i)}}}else if(a.startsWith(`--header=`)){let e=a.slice(9),n=e.indexOf(`:`);if(n>0){let r=e.slice(0,n).trim(),i=e.slice(n+1).trim();t.headers.append(r,i)}}else if(a===`-G`||a===`--get`)t.getMode=!0,r||(t.method=`GET`);else if(a===`-d`||a===`--data`)P2(t,e[++i]??``,{binary:!1,allowFile:!0}),n=!0;else if(a===`--data-raw`)P2(t,e[++i]??``,{binary:!1,allowFile:!1}),n=!0;else if(a.startsWith(`-d`))P2(t,a.slice(2),{binary:!1,allowFile:!0}),n=!0;else if(a.startsWith(`--data=`))P2(t,a.slice(7),{binary:!1,allowFile:!0}),n=!0;else if(a.startsWith(`--data-raw=`))P2(t,a.slice(11),{binary:!1,allowFile:!1}),n=!0;else if(a===`--data-binary`)P2(t,e[++i]??``,{binary:!0,allowFile:!0}),n=!0;else if(a.startsWith(`--data-binary=`))P2(t,a.slice(14),{binary:!0,allowFile:!0}),n=!0;else if(a===`--data-urlencode`)F2(t,e[++i]??``),n=!0;else if(a.startsWith(`--data-urlencode=`))F2(t,a.slice(17)),n=!0;else if(a===`-F`||a===`--form`){let r=j2(e[++i]??``);r&&t.formFields.push(r),n=!0}else if(a.startsWith(`--form=`)){let e=j2(a.slice(7));e&&t.formFields.push(e),n=!0}else if(a===`-u`||a===`--user`)t.user=e[++i];else if(a.startsWith(`-u`))t.user=a.slice(2);else if(a.startsWith(`--user=`))t.user=a.slice(7);else if(a===`-A`||a===`--user-agent`)t.headers.set(`User-Agent`,e[++i]??``);else if(a.startsWith(`-A`))t.headers.set(`User-Agent`,a.slice(2));else if(a.startsWith(`--user-agent=`))t.headers.set(`User-Agent`,a.slice(13));else if(a===`-e`||a===`--referer`)t.headers.set(`Referer`,e[++i]??``);else if(a.startsWith(`-e`))t.headers.set(`Referer`,a.slice(2));else if(a.startsWith(`--referer=`))t.headers.set(`Referer`,a.slice(10));else if(a===`-b`||a===`--cookie`)t.headers.set(`Cookie`,e[++i]??``);else if(a.startsWith(`-b`))t.headers.set(`Cookie`,a.slice(2));else if(a.startsWith(`--cookie=`))t.headers.set(`Cookie`,a.slice(9));else if(a===`-c`||a===`--cookie-jar`)t.cookieJar=e[++i];else if(a.startsWith(`--cookie-jar=`))t.cookieJar=a.slice(13);else if(a===`-T`||a===`--upload-file`)t.uploadFile=e[++i],t.method===`GET`&&(t.method=`PUT`);else if(a.startsWith(`--upload-file=`))t.uploadFile=a.slice(14),t.method===`GET`&&(t.method=`PUT`);else if(a===`-m`||a===`--max-time`){let n=parseFloat(e[++i]??`0`);!Number.isNaN(n)&&n>0&&(t.timeoutMs=n*1e3)}else if(a.startsWith(`--max-time=`)){let e=parseFloat(a.slice(11));!Number.isNaN(e)&&e>0&&(t.timeoutMs=e*1e3)}else if(a===`--connect-timeout`){let n=parseFloat(e[++i]??`0`);!Number.isNaN(n)&&n>0&&t.timeoutMs===void 0&&(t.timeoutMs=n*1e3)}else if(a.startsWith(`--connect-timeout=`)){let e=parseFloat(a.slice(18));!Number.isNaN(e)&&e>0&&t.timeoutMs===void 0&&(t.timeoutMs=e*1e3)}else if(a===`-o`||a===`--output`)t.outputFile=e[++i];else if(a.startsWith(`--output=`))t.outputFile=a.slice(9);else if(a===`-O`||a===`--remote-name`)t.useRemoteName=!0;else if(a===`-I`||a===`--head`)t.headOnly=!0,t.method=`HEAD`,r=!0;else if(a===`-i`||a===`--include`)t.includeHeaders=!0;else if(a===`-s`||a===`--silent`)t.silent=!0;else if(a===`-S`||a===`--show-error`)t.showError=!0;else if(a===`-f`||a===`--fail`)t.failSilently=!0;else if(a===`-L`||a===`--location`)t.followRedirects=!0;else if(a===`--max-redirs`){let n=e[++i];if(n===void 0||!/^\d+$/.test(n))return{stdout:``,stderr:`curl: option --max-redirs: expected a non-negative integer `,exitCode:2};let r=Number(n);if(!Number.isSafeInteger(r))return{stdout:``,stderr:`curl: option --max-redirs: value is out of range `,exitCode:2};t.maxRedirects=r}else if(a.startsWith(`--max-redirs=`)){let e=a.slice(13);if(!/^\d+$/.test(e)||!Number.isSafeInteger(Number(e)))return{stdout:``,stderr:`curl: option --max-redirs: expected a non-negative integer `,exitCode:2};t.maxRedirects=Number(e)}else if(a===`-w`||a===`--write-out`)t.writeOut=e[++i];else if(a.startsWith(`--write-out=`))t.writeOut=a.slice(12);else if(a===`-v`||a===`--verbose`)t.verbose=!0;else{if(a.startsWith(`--`)&&a!==`--`)return sV(`curl`,a);if(a.startsWith(`-`)&&a!==`-`)for(let e of a.slice(1))switch(e){case`s`:t.silent=!0;break;case`S`:t.showError=!0;break;case`f`:t.failSilently=!0;break;case`L`:t.followRedirects=!0;break;case`I`:t.headOnly=!0,t.method=`HEAD`,r=!0;break;case`i`:t.includeHeaders=!0;break;case`O`:t.useRemoteName=!0;break;case`v`:t.verbose=!0;break;case`G`:t.getMode=!0,r||(t.method=`GET`);break;default:return sV(`curl`,`-${e}`)}else a.startsWith(`-`)||(t.url=a)}}return n&&!r&&!t.getMode&&(t.method=`POST`),t}var EDe=B(()=>{m$(),cV(),M2()});function I2(e){return Object.entries(e).map(([e,t])=>`${e}: ${t}`).join(`\r `)}function DDe(e){try{return new URL(e).pathname.split(`/`).pop()||`index.html`}catch{return`index.html`}}function L2(e,t){let n=e;return n=n.replace(/%\{http_code\}/g,String(t.status)),n=n.replace(/%\{content_type\}/g,t.headers[`content-type`]||``),n=n.replace(/%\{url_effective\}/g,t.url),n=n.replace(/%\{size_download\}/g,String(t.bodyLength)),n=n.replace(/\\n/g,` `),n}var ODe=B(()=>{}),R2={};Tz(R2,{curlCommand:()=>z2});async function kDe(e,t){if(e.dataParts.length===0)return;let n=[];for(let r of e.dataParts)if(r.file){let e=t.fs.resolvePath(t.cwd,r.file.path),i=await t.fs.readFile(e);if(r.file.mode===`ascii`)n.push(i.replace(/[\r\n]/g,``));else if(r.file.mode===`binary`)n.push(i);else{let e=A2(i);n.push(r.file.name?`${r.file.name}=${e}`:e)}}else n.push(r.value??``);return n.join(`&`)}async function ADe(e,t,n){if(e.uploadFile){let n=t.fs.resolvePath(t.cwd,e.uploadFile);return{body:await t.fs.readFile(n)}}if(e.formFields.length>0){let n=new Map;for(let r of e.formFields)if(r.value.startsWith(`@`)||r.value.startsWith(`<`)){let e=t.fs.resolvePath(t.cwd,r.value.slice(1));try{let i=await t.fs.readFile(e);n.set(r.value.slice(1),i)}catch{n.set(r.value.slice(1),``)}}let{body:r,boundary:i}=CDe(e.formFields,n);return{body:r,contentType:`multipart/form-data; boundary=${i}`}}return n!==void 0&&!e.getMode?{body:n,contentType:`application/x-www-form-urlencoded`}:{}}function jDe(e,t){if(!t)return e;let n=e.indexOf(`#`),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n);return`${r}${r.endsWith(`?`)||r.endsWith(`&`)?``:r.includes(`?`)?`&`:`?`}${t}${i}`}function MDe(e,t){let n=new f$(e.headers);if(e.user){let t=Buffer.from(e.user).toString(`base64`);n.set(`Authorization`,`Basic ${t}`)}return t&&!n.has(`Content-Type`)&&n.set(`Content-Type`,t),n}async function NDe(e,t,n){if(!e.cookieJar)return;let r=t[`set-cookie`];if(!r)return;let i=n.fs.resolvePath(n.cwd,e.cookieJar);await n.fs.writeFile(i,r)}function PDe(e){return T2(e,`binary`)}function FDe(e,t,n){let r=``;if(e.verbose){r+=`> ${e.method} ${n} `;for(let[t,n]of e.headers)r+=`> ${t}: ${n} `;r+=`> `,r+=`< HTTP/1.1 ${t.status} ${t.statusText} `;for(let[e,n]of Object.entries(t.headers))r+=`< ${e}: ${n} `;r+=`< `}return e.includeHeaders&&!e.verbose&&(r+=`HTTP/1.1 ${t.status} ${t.statusText}\r `,r+=I2(t.headers),r+=`\r \r `),e.headOnly?e.includeHeaders||e.verbose||(r+=`HTTP/1.1 ${t.status} ${t.statusText}\r `,r+=I2(t.headers),r+=`\r `):r+=PDe(t.body),e.writeOut&&(r+=L2(e.writeOut,{status:t.status,headers:t.headers,url:t.url,bodyLength:t.body.byteLength})),r}var z2,IDe=B(()=>{k2(),EV(),m$(),cV(),M2(),wDe(),EDe(),ODe(),z2={name:`curl`,async execute(e,t){if(oV(e))return aV(N2);let n=TDe(e);if(`exitCode`in n)return n;let r=n;if(!r.url)return{stdout:``,stderr:`curl: no URL specified `,exitCode:2};if(!t.fetch)return{stdout:``,stderr:`curl: internal error: fetch not available `,exitCode:1};let i=r.url;i.match(/^https?:\/\//)||(i=`https://${i}`);try{let e=await kDe(r,t);r.getMode&&(i=jDe(i,e));let{body:n,contentType:a}=await ADe(r,t,e),o=MDe(r,a),s=await t.fetch(i,{method:r.method,headers:o,body:n,followRedirects:r.followRedirects,timeoutMs:r.timeoutMs,maxRedirects:r.maxRedirects,signal:t.signal});if(await NDe(r,s.headers,t),r.failSilently&&s.status>=400)return{stdout:``,stderr:r.showError||!r.silent?`curl: (22) The requested URL returned error: ${s.status} `:``,exitCode:22};let c=FDe(r,s,i);if(r.outputFile||r.useRemoteName){let e=r.outputFile||DDe(i),n=t.fs.resolvePath(t.cwd,e);await t.fs.writeFile(n,r.headOnly?``:s.body),r.verbose||(c=``),r.writeOut&&(c=L2(r.writeOut,{status:s.status,headers:s.headers,url:s.url,bodyLength:s.body.byteLength}))}return{stdout:c,stderr:``,exitCode:0,stdoutKind:`bytes`}}catch(e){let t=TV(e),n=1;return t.includes(`Network access denied`)?n=7:t.includes(`HTTP method`)&&t.includes(`not allowed`)?n=3:t.includes(`Redirect target not in allow-list`)||t.includes(`Too many redirects`)?n=47:t.includes(`aborted`)&&(n=28),{stdout:``,stderr:!r.silent||r.showError?`curl: (${n}) ${t} `:``,exitCode:n}}}}});hB(),_B(),ZB(),oB();var B2=[{name:`echo`,load:async()=>(await Promise.resolve().then(()=>(nV(),QB))).echoCommand},{name:`cat`,load:async()=>(await Promise.resolve().then(()=>(wV(),gV))).catCommand},{name:`printf`,load:async()=>(await Promise.resolve().then(()=>(tH(),LV))).printfCommand},{name:`ls`,load:async()=>(await Promise.resolve().then(()=>(VH(),kH))).lsCommand},{name:`mkdir`,load:async()=>(await Promise.resolve().then(()=>(KH(),HH))).mkdirCommand},{name:`rmdir`,load:async()=>(await Promise.resolve().then(()=>(tU(),qH))).rmdirCommand},{name:`touch`,load:async()=>(await Promise.resolve().then(()=>(oU(),nU))).touchCommand},{name:`rm`,load:async()=>(await Promise.resolve().then(()=>(dU(),sU))).rmCommand},{name:`cp`,load:async()=>(await Promise.resolve().then(()=>(_U(),fU))).cpCommand},{name:`mv`,load:async()=>(await Promise.resolve().then(()=>(CU(),vU))).mvCommand},{name:`ln`,load:async()=>(await Promise.resolve().then(()=>(zbe(),wU))).lnCommand},{name:`chmod`,load:async()=>(await Promise.resolve().then(()=>(Vbe(),OU))).chmodCommand},{name:`pwd`,load:async()=>(await Promise.resolve().then(()=>(Hbe(),NU))).pwdCommand},{name:`readlink`,load:async()=>(await Promise.resolve().then(()=>(Ube(),IU))).readlinkCommand},{name:`head`,load:async()=>(await Promise.resolve().then(()=>(Kbe(),UU))).headCommand},{name:`tail`,load:async()=>(await Promise.resolve().then(()=>(qbe(),qU))).tailCommand},{name:`wc`,load:async()=>(await Promise.resolve().then(()=>(Jbe(),ZU))).wcCommand},{name:`stat`,load:async()=>(await Promise.resolve().then(()=>(Ybe(),oW))).statCommand},{name:`grep`,load:async()=>(await Promise.resolve().then(()=>(YG(),NG))).grepCommand},{name:`fgrep`,load:async()=>(await Promise.resolve().then(()=>(YG(),NG))).fgrepCommand},{name:`egrep`,load:async()=>(await Promise.resolve().then(()=>(YG(),NG))).egrepCommand},{name:`rg`,load:async()=>(await Promise.resolve().then(()=>(Xxe(),TK))).rgCommand},{name:`sed`,load:async()=>(await Promise.resolve().then(()=>(dSe(),qK))).sedCommand},{name:`awk`,load:async()=>(await Promise.resolve().then(()=>(kCe(),lJ))).awkCommand2},{name:`sort`,load:async()=>(await Promise.resolve().then(()=>(FCe(),wJ))).sortCommand},{name:`uniq`,load:async()=>(await Promise.resolve().then(()=>(ICe(),OJ))).uniqCommand},{name:`comm`,load:async()=>(await Promise.resolve().then(()=>(LCe(),NJ))).commCommand},{name:`cut`,load:async()=>(await Promise.resolve().then(()=>(BCe(),LJ))).cutCommand},{name:`paste`,load:async()=>(await Promise.resolve().then(()=>(VCe(),VJ))).pasteCommand},{name:`tr`,load:async()=>(await Promise.resolve().then(()=>(HCe(),qJ))).trCommand},{name:`rev`,load:async()=>(await Promise.resolve().then(()=>(WCe(),eY))).rev},{name:`nl`,load:async()=>(await Promise.resolve().then(()=>(qCe(),iY))).nl},{name:`fold`,load:async()=>(await Promise.resolve().then(()=>(XCe(),lY))).fold},{name:`expand`,load:async()=>(await Promise.resolve().then(()=>($Ce(),mY))).expand},{name:`unexpand`,load:async()=>(await Promise.resolve().then(()=>(twe(),bY))).unexpand},{name:`strings`,load:async()=>(await Promise.resolve().then(()=>(rwe(),DY))).strings},{name:`split`,load:async()=>(await Promise.resolve().then(()=>(dwe(),NY))).split},{name:`column`,load:async()=>(await Promise.resolve().then(()=>(hwe(),UY))).column},{name:`join`,load:async()=>(await Promise.resolve().then(()=>(ywe(),YY))).join},{name:`tee`,load:async()=>(await Promise.resolve().then(()=>(bwe(),eX))).teeCommand},{name:`find`,load:async()=>(await Promise.resolve().then(()=>(Mwe(),gX))).findCommand},{name:`basename`,load:async()=>(await Promise.resolve().then(()=>(Nwe(),SX))).basenameCommand},{name:`dirname`,load:async()=>(await Promise.resolve().then(()=>(Pwe(),EX))).dirnameCommand},{name:`tree`,load:async()=>(await Promise.resolve().then(()=>(Iwe(),AX))).treeCommand},{name:`du`,load:async()=>(await Promise.resolve().then(()=>(Rwe(),IX))).duCommand},{name:`env`,load:async()=>(await Promise.resolve().then(()=>(YX(),HX))).envCommand},{name:`printenv`,load:async()=>(await Promise.resolve().then(()=>(YX(),HX))).printenvCommand},{name:`alias`,load:async()=>(await Promise.resolve().then(()=>(rZ(),XX))).aliasCommand},{name:`unalias`,load:async()=>(await Promise.resolve().then(()=>(rZ(),XX))).unaliasCommand},{name:`history`,load:async()=>(await Promise.resolve().then(()=>(zwe(),iZ))).historyCommand},{name:`xargs`,load:async()=>(await Promise.resolve().then(()=>(Vwe(),lZ))).xargsCommand},{name:`true`,load:async()=>(await Promise.resolve().then(()=>(yZ(),mZ))).trueCommand},{name:`false`,load:async()=>(await Promise.resolve().then(()=>(yZ(),mZ))).falseCommand},{name:`clear`,load:async()=>(await Promise.resolve().then(()=>(Hwe(),bZ))).clearCommand},{name:`bash`,load:async()=>(await Promise.resolve().then(()=>(jZ(),wZ))).bashCommand},{name:`sh`,load:async()=>(await Promise.resolve().then(()=>(jZ(),wZ))).shCommand},{name:`jq`,load:async()=>(await Promise.resolve().then(()=>(NTe(),kQ))).jqCommand},{name:`base64`,load:async()=>(await Promise.resolve().then(()=>(PTe(),IQ))).base64Command},{name:`diff`,load:async()=>(await Promise.resolve().then(()=>(FTe(),GQ))).diffCommand},{name:`date`,load:async()=>(await Promise.resolve().then(()=>(BTe(),XQ))).dateCommand},{name:`sleep`,load:async()=>(await Promise.resolve().then(()=>(VTe(),n$))).sleepCommand},{name:`timeout`,load:async()=>(await Promise.resolve().then(()=>(HTe(),s$))).timeoutCommand},{name:`time`,load:async()=>(await Promise.resolve().then(()=>(UTe(),h$))).timeCommand},{name:`seq`,load:async()=>(await Promise.resolve().then(()=>(WTe(),y$))).seqCommand},{name:`expr`,load:async()=>(await Promise.resolve().then(()=>(KTe(),S$))).exprCommand},{name:`md5sum`,load:async()=>(await Promise.resolve().then(()=>(JTe(),k$))).md5sumCommand},{name:`sha1sum`,load:async()=>(await Promise.resolve().then(()=>(YTe(),M$))).sha1sumCommand},{name:`sha256sum`,load:async()=>(await Promise.resolve().then(()=>(XTe(),F$))).sha256sumCommand},{name:`file`,load:async()=>(await Promise.resolve().then(()=>(iDe(),S0))).fileCommand},{name:`html-to-markdown`,load:async()=>(await Promise.resolve().then(()=>(aDe(),O0))).htmlToMarkdownCommand},{name:`help`,load:async()=>(await Promise.resolve().then(()=>(sDe(),M0))).helpCommand},{name:`which`,load:async()=>(await Promise.resolve().then(()=>(cDe(),I0))).whichCommand},{name:`tac`,load:async()=>(await Promise.resolve().then(()=>(uDe(),V0))).tac},{name:`hostname`,load:async()=>(await Promise.resolve().then(()=>(fDe(),W0))).hostname},{name:`whoami`,load:async()=>(await Promise.resolve().then(()=>(mDe(),q0))).whoami},{name:`od`,load:async()=>(await Promise.resolve().then(()=>(gDe(),X0))).od},{name:`gzip`,load:async()=>(await Promise.resolve().then(()=>(C2(),e2))).gzipCommand},{name:`gunzip`,load:async()=>(await Promise.resolve().then(()=>(C2(),e2))).gunzipCommand},{name:`zcat`,load:async()=>(await Promise.resolve().then(()=>(C2(),e2))).zcatCommand}],LDe=[],RDe=[],zDe=[{name:`curl`,load:async()=>(await Promise.resolve().then(()=>(IDe(),R2))).curlCommand}],V2=new Map;function H2(e){return{name:e.name,async execute(t,n){let r=V2.get(e.name);return r||(r=await aB.runTrustedAsync(()=>e.load()),V2.set(e.name,r)),n.coverage,r.execute(t,n)}}}function BDe(e){return(e?B2.filter(t=>e.includes(t.name)):B2).map(H2)}function VDe(){return zDe.map(H2)}function HDe(){return LDe.map(H2)}function UDe(){return RDe.map(H2)}AB();var U2=new WeakMap,W2=new WeakSet;function WDe(e){let t=U2.get(e);return t===void 0&&(t=Object.freeze(Object.create(null)),U2.set(e,t),W2.add(t)),t}function GDe(e){return W2.has(e)}var G2={maxSourceBytes:67108864,maxExecDepth:64,maxCallDepth:100,maxCommandCount:1e5,maxLoopIterations:1e5,maxAwkIterations:1e5,maxSedIterations:1e5,maxJqIterations:1e7,maxQueryTokens:1e5,maxQueryDepth:1e3,maxQueryElements:1e6,maxAwkParserTokens:1e5,maxAwkParserDepth:256,maxAwkParserOperations:1e6,maxCsvRows:1e6,maxCsvCells:1e7,maxWorkUnits:1e8,maxTraversalEntries:1e6,maxTraversalDepth:1e3,maxTraversalWork:1e6,maxLiveBytes:536870912,maxInputBytes:536870912,maxFileSystemBytes:1073741824,maxDatabaseBytes:1073741824,maxDatabaseResultBytes:268435456,maxArchiveBytes:1073741824,maxArchiveCompressedBytes:536870912,maxArchiveEntryBytes:536870912,maxArchiveEntries:1e6,maxWorkerMessageBytes:67108864,maxExecutionTimeMs:36e5,maxExtensionCleanupTimeMs:100,maxSqliteTimeoutMs:3e4,maxPythonTimeoutMs:3e4,maxJsTimeoutMs:3e4,maxGlobOperations:1e6,maxStringLength:67108864,maxArrayElements:1e6,maxHeredocSize:67108864,maxSubstitutionDepth:50,maxBraceExpansionResults:1e5,maxOutputSize:268435456,maxFileDescriptors:4096,maxSourceDepth:100},KDe={...G2,maxSourceBytes:8388608,maxCommandCount:1e4,maxLoopIterations:1e4,maxAwkIterations:1e4,maxSedIterations:1e4,maxJqIterations:1e4,maxSqliteTimeoutMs:5e3,maxPythonTimeoutMs:1e4,maxJsTimeoutMs:1e4,maxExtensionCleanupTimeMs:25,maxGlobOperations:1e5,maxStringLength:10485760,maxArrayElements:1e5,maxHeredocSize:10485760,maxBraceExpansionResults:1e4,maxOutputSize:10485760,maxFileDescriptors:1024,maxQueryTokens:25e3,maxQueryDepth:256,maxQueryElements:1e5,maxAwkParserTokens:25e3,maxAwkParserDepth:128,maxAwkParserOperations:1e5,maxCsvRows:1e5,maxCsvCells:1e6,maxWorkUnits:1e5,maxTraversalEntries:1e5,maxTraversalDepth:256,maxTraversalWork:1e5,maxLiveBytes:67108864,maxInputBytes:33554432,maxFileSystemBytes:134217728,maxDatabaseBytes:67108864,maxDatabaseResultBytes:16777216,maxArchiveBytes:134217728,maxArchiveCompressedBytes:67108864,maxArchiveEntryBytes:67108864,maxArchiveEntries:1e5,maxWorkerMessageBytes:16777216,maxExecutionTimeMs:3e4};function qDe(e,t=`normal`){if(t!==`normal`&&t!==`hardened`)throw RangeError(`executionLimitProfile must be "normal" or "hardened"`);let n=t===`hardened`?KDe:G2;if(!e)return{...n};let r={maxSourceBytes:e.maxSourceBytes??n.maxSourceBytes,maxExecDepth:e.maxExecDepth??n.maxExecDepth,maxCallDepth:e.maxCallDepth??n.maxCallDepth,maxCommandCount:e.maxCommandCount??n.maxCommandCount,maxLoopIterations:e.maxLoopIterations??n.maxLoopIterations,maxAwkIterations:e.maxAwkIterations??n.maxAwkIterations,maxSedIterations:e.maxSedIterations??n.maxSedIterations,maxJqIterations:e.maxJqIterations??n.maxJqIterations,maxQueryTokens:e.maxQueryTokens??n.maxQueryTokens,maxQueryDepth:e.maxQueryDepth??n.maxQueryDepth,maxQueryElements:e.maxQueryElements??n.maxQueryElements,maxAwkParserTokens:e.maxAwkParserTokens??n.maxAwkParserTokens,maxAwkParserDepth:e.maxAwkParserDepth??n.maxAwkParserDepth,maxAwkParserOperations:e.maxAwkParserOperations??n.maxAwkParserOperations,maxCsvRows:e.maxCsvRows??n.maxCsvRows,maxCsvCells:e.maxCsvCells??n.maxCsvCells,maxWorkUnits:e.maxWorkUnits??n.maxWorkUnits,maxTraversalEntries:e.maxTraversalEntries??n.maxTraversalEntries,maxTraversalDepth:e.maxTraversalDepth??n.maxTraversalDepth,maxTraversalWork:e.maxTraversalWork??n.maxTraversalWork,maxLiveBytes:e.maxLiveBytes??n.maxLiveBytes,maxInputBytes:e.maxInputBytes??n.maxInputBytes,maxFileSystemBytes:e.maxFileSystemBytes??n.maxFileSystemBytes,maxDatabaseBytes:e.maxDatabaseBytes??n.maxDatabaseBytes,maxDatabaseResultBytes:e.maxDatabaseResultBytes??n.maxDatabaseResultBytes,maxArchiveBytes:e.maxArchiveBytes??n.maxArchiveBytes,maxArchiveCompressedBytes:e.maxArchiveCompressedBytes??n.maxArchiveCompressedBytes,maxArchiveEntryBytes:e.maxArchiveEntryBytes??n.maxArchiveEntryBytes,maxArchiveEntries:e.maxArchiveEntries??n.maxArchiveEntries,maxWorkerMessageBytes:e.maxWorkerMessageBytes??n.maxWorkerMessageBytes,maxExecutionTimeMs:e.maxExecutionTimeMs??n.maxExecutionTimeMs,maxExtensionCleanupTimeMs:e.maxExtensionCleanupTimeMs??n.maxExtensionCleanupTimeMs,maxSqliteTimeoutMs:e.maxSqliteTimeoutMs??n.maxSqliteTimeoutMs,maxPythonTimeoutMs:e.maxPythonTimeoutMs??n.maxPythonTimeoutMs,maxJsTimeoutMs:e.maxJsTimeoutMs??n.maxJsTimeoutMs,maxGlobOperations:e.maxGlobOperations??n.maxGlobOperations,maxStringLength:e.maxStringLength??n.maxStringLength,maxArrayElements:e.maxArrayElements??n.maxArrayElements,maxHeredocSize:e.maxHeredocSize??n.maxHeredocSize,maxSubstitutionDepth:e.maxSubstitutionDepth??n.maxSubstitutionDepth,maxBraceExpansionResults:e.maxBraceExpansionResults??n.maxBraceExpansionResults,maxOutputSize:e.maxOutputSize??n.maxOutputSize,maxFileDescriptors:e.maxFileDescriptors??n.maxFileDescriptors,maxSourceDepth:e.maxSourceDepth??n.maxSourceDepth};for(let e of Object.keys(r)){let t=r[e];if(t!==1/0&&(!Number.isSafeInteger(t)||t<0))throw RangeError(`${e} must be a non-negative safe integer or positive Infinity`)}return r}function JDe(e){return`load`in e&&typeof e.load==`function`}function YDe(e){let t=null,n=null;return{name:e.name,trusted:e.trusted!==!1,async execute(r,i){if(!t){let r=n;r||(r=e.load().then(e=>(t=e,e)),n=r);try{t=await r}catch(e){throw n===r&&(n=null),e}}let a=t;if(!a)throw Error(`Failed to load command: ${e.name}`);return a.execute(r,i)}}}AB(),AB(),U(),hB();var K2=Object.freeze(Object.create(null)),XDe=class{limits;signal;commandCount=0;workUnits=0;liveBytes=0;inputBytes=0;outputBytes=0;countersByKind=new Map;bytesByKind=new Map;depthByKind=new Map;cleanupCallbacks=[];poisoned;closed=!1;startedAt=Date.now();get remainingLiveBytes(){return Math.max(0,this.limits.maxLiveBytes-this.liveBytes)}get outputBytesUsed(){return this.outputBytes}constructor(e,t=void 0){this.limits=e,this.signal=t}fail(e){throw this.poisoned??=e,this.poisoned}poisonAfterAbort(e){this.poisoned??=e}assertUsable(){if(this.poisoned)throw this.poisoned;if(this.closed)throw Error(`execution budget is already closed`);this.throwIfAborted()}chargeCommand(){return this.consume(`commands`,1,`execution`)}consumeWork(e=1,t=`execution`){return this.consume(`work`,e,t)}consumeLimited(e,t,n,r=e){this.assertUsable();let i=this.countersByKind.get(e)??0;return(!Number.isSafeInteger(t)||t<0||!Number.isSafeInteger(n)||n<0||t>n-i)&&this.fail(new H(`${r}: ${e} work limit exceeded (${n})`,`iterations`)),t>this.limits.maxWorkUnits-this.workUnits&&this.fail(new H(`${r}: aggregate work limit exceeded (${this.limits.maxWorkUnits})`,`iterations`)),this.countersByKind.set(e,i+t),this.workUnits+=t,i+t}consumeInput(e,t=`execution`){return this.assertUsable(),(!Number.isSafeInteger(e)||e<0||e>this.limits.maxInputBytes-this.inputBytes)&&this.fail(new H(`${t}: aggregate input size limit exceeded (${this.limits.maxInputBytes} bytes)`,`string_length`)),this.inputBytes+=e,this.inputBytes}consume(e,t=1,n=e){this.assertUsable();let r=this.countersByKind.get(e)??0,i=e===`commands`?this.commandCount:this.workUnits,a=e===`commands`?this.limits.maxCommandCount:this.limits.maxWorkUnits;(!Number.isSafeInteger(t)||t<0||t>a-i)&&this.fail(new H(e===`commands`?`too many commands executed (>${a}), increase executionLimits.maxCommandCount`:`${n}: ${e} work limit exceeded (${a})`,e===`commands`?`commands`:`iterations`));let o=i+t;return e===`commands`?this.commandCount=o:this.workUnits=o,this.countersByKind.set(e,r+t),o}reserveBytes(e,t,n){this.assertUsable();let r=typeof e==`string`?e:`live`,i=typeof e==`string`?t:e,a=typeof e==`string`?n??r:t??`execution`;(!Number.isSafeInteger(i)||i<0||i>this.limits.maxLiveBytes-this.liveBytes)&&this.fail(new H(`${a}: live byte limit exceeded (${this.limits.maxLiveBytes} bytes)`,`string_length`)),this.liveBytes+=i,this.bytesByKind.set(r,(this.bytesByKind.get(r)??0)+i);let o=!1;return{release:()=>{if(o)return;o=!0,this.liveBytes-=i;let e=(this.bytesByKind.get(r)??i)-i;e<=0?this.bytesByKind.delete(r):this.bytesByKind.set(r,e)}}}appendOutput(e,t,n=`execution`,r=0,i=`text`){this.assertUsable();let a=i===`bytes`?t.length:V(t);(!Number.isSafeInteger(r)||r<0||r>a)&&this.fail(new H(`${n}: invalid ${e} accounting`,`output_size`));let o=a-r;return o>this.limits.maxOutputSize-this.outputBytes&&this.fail(new H(`${n}: total output size exceeded (>${this.limits.maxOutputSize} bytes), increase executionLimits.maxOutputSize`,`output_size`)),this.outputBytes+=o,a}accountResult(e,t=`execution`,n=1/0){let r=e.internalOutputAccounting,i=Math.min(r?.stdout??0,n),a=Math.min(r?.stderr??0,Math.max(0,n-i)),o=this.appendOutput(`stdout`,e.stdout,t,i,e.stdoutKind===`bytes`||e.stdoutEncoding===`binary`?`bytes`:`text`),s=this.appendOutput(`stderr`,e.stderr,t,a);return Object.isExtensible(e)?(e.internalOutputAccounting={stdout:o,stderr:s},e):o===0&&s===0?e:{...e,internalOutputAccounting:{stdout:o,stderr:s}}}relinquishOutput(e,t,n){this.assertUsable(),n!==K2&&this.fail(new H(`${t}: unauthorized output accounting release`,`output_size`)),(!Number.isSafeInteger(e)||e<0||e>this.outputBytes)&&this.fail(new H(`${t}: invalid output accounting release`,`output_size`)),this.outputBytes-=e}enterDepth(e,t=this.limits.maxCallDepth,n){this.assertUsable();let r=typeof t==`number`?t:this.limits.maxCallDepth,i=typeof t==`string`?t:n??e,a=this.depthByKind.get(e)??0;a>=r&&this.fail(new H(`${i}: maximum depth (${r}) exceeded`,`recursion`)),this.depthByKind.set(e,a+1);let o=!1;return{release:()=>{if(o)return;o=!0;let t=(this.depthByKind.get(e)??1)-1;t<=0?this.depthByKind.delete(e):this.depthByKind.set(e,t)}}}throwIfAborted(e=`execution`){this.signal?.aborted&&this.fail(new UB(``,`bash: ${e} aborted `)),Date.now()-this.startedAt>this.limits.maxExecutionTimeMs&&this.fail(new UB(``,`bash: ${e} exceeded execution deadline (${this.limits.maxExecutionTimeMs}ms) `))}remainingTimeMs(){return Math.max(0,this.limits.maxExecutionTimeMs-(Date.now()-this.startedAt))}registerCleanup(e){this.assertUsable(),this.cleanupCallbacks.push(e);let t=!0;return()=>{if(!t)return;t=!1;let n=this.cleanupCallbacks.indexOf(e);n>=0&&this.cleanupCallbacks.splice(n,1)}}async close(){if(this.closed)return;this.closed=!0;let e=[],t=Date.now()+this.limits.maxExtensionCleanupTimeMs;for(let n=this.cleanupCallbacks.length-1;n>=0;n--)try{let r=t-Date.now();if(r<=0){e.push(Error(`execution cleanup grace period exceeded`));break}let i,a=await Promise.race([Promise.resolve().then(this.cleanupCallbacks[n]).then(()=>({ok:!0}),e=>({ok:!1,error:e})),new Promise(e=>{i=cB(()=>e({ok:!1,error:Error(`execution cleanup grace period exceeded`)}),r)})]);if(lB(i),!a.ok&&(e.push(a.error),Date.now()>=t))break}catch(t){e.push(t)}if(this.cleanupCallbacks.length=0,this.depthByKind.clear(),this.bytesByKind.clear(),this.liveBytes=0,e.length>0)throw AggregateError(e,`execution cleanup failed`)}assertExecDepth(e){this.assertUsable(),e>this.limits.maxExecDepth&&this.fail(new H(`maximum nested execution depth (${this.limits.maxExecDepth}) exceeded`,`recursion`))}};function ZDe(e){let t=Object.create(null);return Object.defineProperties(t,{remainingLiveBytes:{enumerable:!0,get:()=>e.remainingLiveBytes},consumeWork:{enumerable:!0,value:e.consumeWork.bind(e)},consumeLimited:{enumerable:!0,value:e.consumeLimited.bind(e)},consumeInput:{enumerable:!0,value:e.consumeInput.bind(e)},reserveBytes:{enumerable:!0,value:e.reserveBytes.bind(e)},enterDepth:{enumerable:!0,value:e.enterDepth.bind(e)},throwIfAborted:{enumerable:!0,value:e.throwIfAborted.bind(e)},remainingTimeMs:{enumerable:!0,value:e.remainingTimeMs.bind(e)},registerCleanup:{enumerable:!0,value:e.registerCleanup.bind(e)}}),Object.freeze(t)}function QDe(e,t,n=`pipeline`){e.relinquishOutput(t,n,K2)}AB(),k2(),gH();var q2=new TextEncoder;function $De(e){return typeof e==`object`&&!!e&&!(e instanceof Uint8Array)&&`content`in e}var J2=class{data=new Map;entryIdentities=new WeakMap;nextEntryIdentity=1;maxTotalBytes;retainedBytes=0;contentReferences=new WeakMap;materializedContent(e){return e?.type===`file`&&`content`in e?e.content:null}storedByteLength(e){return e===null?0:e instanceof Uint8Array?e.byteLength:V(e)}wouldReleaseBytes(e){let t=this.materializedContent(e);return t===null?0:t instanceof Uint8Array?this.contentReferences.get(t)===1?t.byteLength:0:this.storedByteLength(t)}assertCanAllocate(e,t){let n=this.wouldReleaseBytes(this.data.get(e));if(!Number.isSafeInteger(t)||t<0||t>this.maxTotalBytes-this.retainedBytes+n)throw Error(`ENOSPC: in-memory filesystem byte limit exceeded (${this.maxTotalBytes} bytes)`)}setEntry(e,t){let n=this.data.get(e),r=this.materializedContent(n),i=this.materializedContent(t);if(r===i){this.data.set(e,t);return}let a=this.wouldReleaseBytes(n),o=i instanceof Uint8Array?this.contentReferences.has(i)?0:i.byteLength:this.storedByteLength(i);if(o>this.maxTotalBytes-this.retainedBytes+a)throw Error(`ENOSPC: in-memory filesystem byte limit exceeded (${this.maxTotalBytes} bytes)`);if(r instanceof Uint8Array){let e=this.contentReferences.get(r)??0;e<=1?this.contentReferences.delete(r):this.contentReferences.set(r,e-1)}i instanceof Uint8Array&&this.contentReferences.set(i,(this.contentReferences.get(i)??0)+1),this.retainedBytes+=o-a,this.data.set(e,t)}deleteEntry(e){let t=this.data.get(e);if(!t)return!1;let n=this.materializedContent(t),r=this.wouldReleaseBytes(t);if(n instanceof Uint8Array){let e=this.contentReferences.get(n)??0;e<=1?this.contentReferences.delete(n):this.contentReferences.set(n,e-1)}return this.retainedBytes-=r,this.data.delete(e)}contentByteLength(e,t){if(e instanceof Uint8Array)return e.byteLength;if(t===`hex`)return Math.floor(e.length/2);if(t===`base64`){let t=e.endsWith(`==`)?2:+!!e.endsWith(`=`);return Math.max(0,Math.floor(e.length*3/4)-t)}return t===`binary`||t===`latin1`?e.length:V(e)}identityFor(e){let t=this.entryIdentities.get(e);return t||(t=`memfs:${this.nextEntryIdentity++}`,this.entryIdentities.set(e,t)),t}constructor(e,t={}){if(this.maxTotalBytes=t.maxTotalBytes??1073741824,!Number.isSafeInteger(this.maxTotalBytes)||this.maxTotalBytes<0)throw Error(`InMemoryFs: invalid maxTotalBytes`);if(this.data.set(`/`,{type:`directory`,mode:493,mtime:new Date}),e)for(let[t,n]of Object.entries(e))typeof n==`function`?this.writeFileLazy(t,n):$De(n)?this.writeFileSync(t,n.content,void 0,{mode:n.mode,mtime:n.mtime}):this.writeFileSync(t,n)}ensureParentDirs(e){let t=fH(e);t!==`/`&&(this.data.has(t)||(this.ensureParentDirs(t),this.data.set(t,{type:`directory`,mode:493,mtime:new Date})))}writeFileSync(e,t,n,r){dH(e,`write`);let i=lH(e);this.ensureParentDirs(i);let a=E2(n);this.assertCanAllocate(i,this.contentByteLength(t,a));let o=w2(t,a);this.setEntry(i,{type:`file`,content:o,mode:r?.mode??420,mtime:r?.mtime??new Date})}writeFileLazy(e,t,n){dH(e,`write`);let r=lH(e);this.ensureParentDirs(r),this.setEntry(r,{type:`file`,lazy:t,mode:n?.mode??420,mtime:n?.mtime??new Date})}async materializeLazy(e,t){let n=await t.lazy(),r=typeof n==`string`?q2.encode(n):n,i={type:`file`,content:r,mode:t.mode,mtime:t.mtime};return this.assertCanAllocate(e,r.byteLength),this.setEntry(e,i),i}async readFile(e,t){return T2(await this.readFileBuffer(e),E2(t))}async readFileBytes(e){return T2(await this.readFileBuffer(e),`binary`)}async readFileBuffer(e){dH(e,`open`);let t=this.resolvePathWithSymlinks(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, open '${e}'`);if(n.type!==`file`)throw Error(`EISDIR: illegal operation on a directory, read '${e}'`);if(`lazy`in n){let e=await this.materializeLazy(t,n);return e.content instanceof Uint8Array?e.content:q2.encode(e.content)}return n.content instanceof Uint8Array?n.content:q2.encode(n.content)}async writeFile(e,t,n){this.writeFileSync(e,t,n)}async appendFile(e,t,n){dH(e,`append`);let r=lH(e),i=this.data.get(r);if(i&&i.type===`directory`)throw Error(`EISDIR: illegal operation on a directory, write '${e}'`);let a=E2(n),o=this.contentByteLength(t,a);if(i?.type===`file`){let e=i;`lazy`in e&&(e=await this.materializeLazy(r,e));let n=`content`in e&&e.content instanceof Uint8Array?e.content:q2.encode(`content`in e?e.content:``);this.assertCanAllocate(r,n.byteLength+o);let s=w2(t,a),c=new Uint8Array(n.length+s.length);c.set(n),c.set(s,n.length),this.setEntry(r,{type:`file`,content:c,mode:e.mode,mtime:new Date})}else this.writeFileSync(e,t,n)}async exists(e){if(e.includes(`\0`))return!1;try{let t=this.resolvePathWithSymlinks(e);return this.data.has(t)}catch{return!1}}async stat(e){dH(e,`stat`);let t=this.resolvePathWithSymlinks(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, stat '${e}'`);n.type===`file`&&`lazy`in n&&(n=await this.materializeLazy(t,n));let r=0;return n.type===`file`&&`content`in n&&n.content&&(r=n.content instanceof Uint8Array?n.content.length:q2.encode(n.content).length),{isFile:n.type===`file`,isDirectory:n.type===`directory`,isSymbolicLink:!1,mode:n.mode,size:r,mtime:n.mtime||new Date,identity:this.identityFor(n)}}async lstat(e){dH(e,`lstat`);let t=this.resolveIntermediateSymlinks(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, lstat '${e}'`);if(n.type===`symlink`)return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:n.mode,size:n.target.length,mtime:n.mtime||new Date};n.type===`file`&&`lazy`in n&&(n=await this.materializeLazy(t,n));let r=0;return n.type===`file`&&`content`in n&&n.content&&(r=n.content instanceof Uint8Array?n.content.length:q2.encode(n.content).length),{isFile:n.type===`file`,isDirectory:n.type===`directory`,isSymbolicLink:!1,mode:n.mode,size:r,mtime:n.mtime||new Date,identity:this.identityFor(n)}}resolveIntermediateSymlinks(e){let t=lH(e);if(t===`/`)return`/`;let n=t.slice(1).split(`/`);if(n.length<=1)return t;let r=``,i=new Set;for(let t=0;t=40)throw Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`)}return`${r}/${n[n.length-1]}`}resolvePathWithSymlinks(e){let t=lH(e);if(t===`/`)return`/`;let n=t.slice(1).split(`/`),r=``,i=new Set;for(let t of n){r=`${r}/${t}`;let n=this.data.get(r),a=0;for(;n&&n.type===`symlink`&&a<40;){if(i.has(r))throw Error(`ELOOP: too many levels of symbolic links, open '${e}'`);i.add(r),r=hH(r,n.target),n=this.data.get(r),a++}if(a>=40)throw Error(`ELOOP: too many levels of symbolic links, open '${e}'`)}return r}async mkdir(e,t){this.mkdirSync(e,t)}mkdirSync(e,t){dH(e,`mkdir`);let n=lH(e);if(this.data.has(n)){if(this.data.get(n)?.type===`file`)throw Error(`EEXIST: file already exists, mkdir '${e}'`);if(!t?.recursive)throw Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let r=fH(n);if(r!==`/`&&!this.data.has(r)){if(t?.recursive)this.mkdirSync(r,{recursive:!0});else throw Error(`ENOENT: no such file or directory, mkdir '${e}'`)}this.data.set(n,{type:`directory`,mode:493,mtime:new Date})}async readdir(e){return(await this.readdirWithFileTypes(e)).map(e=>e.name)}async readdirWithFileTypes(e){dH(e,`scandir`);let t=lH(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, scandir '${e}'`);let r=new Set;for(;n&&n.type===`symlink`;){if(r.has(t))throw Error(`ELOOP: too many levels of symbolic links, scandir '${e}'`);r.add(t),t=hH(t,n.target),n=this.data.get(t)}if(!n)throw Error(`ENOENT: no such file or directory, scandir '${e}'`);if(n.type!==`directory`)throw Error(`ENOTDIR: not a directory, scandir '${e}'`);let i=t===`/`?`/`:`${t}/`,a=new Map;for(let[e,n]of this.data.entries())if(e!==t&&e.startsWith(i)){let t=e.slice(i.length),r=t.split(`/`)[0];r&&!t.includes(`/`,r.length)&&!a.has(r)&&a.set(r,{name:r,isFile:n.type===`file`,isDirectory:n.type===`directory`,isSymbolicLink:n.type===`symlink`})}return Array.from(a.values()).sort((e,t)=>e.namet.name))}async rm(e,t){dH(e,`rm`);let n=lH(e),r=this.data.get(n);if(!r){if(t?.force)return;throw Error(`ENOENT: no such file or directory, rm '${e}'`)}if(r.type===`directory`){let r=await this.readdir(n);if(r.length>0){if(!t?.recursive)throw Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let e of r){let r=mH(n,e);await this.rm(r,t)}}}this.deleteEntry(n)}async cp(e,t,n){dH(e,`cp`),dH(t,`cp`);let r=lH(e),i=lH(t),a=this.data.get(r);if(!a)throw Error(`ENOENT: no such file or directory, cp '${e}'`);if(a.type===`file`){if(this.ensureParentDirs(i),`content`in a){let e=a.content instanceof Uint8Array?a.content.byteLength:q2.encode(a.content).byteLength;this.assertCanAllocate(i,e);let t=a.content instanceof Uint8Array?new Uint8Array(a.content):a.content;this.setEntry(i,{...a,content:t})}else this.setEntry(i,{...a})}else if(a.type===`symlink`)this.ensureParentDirs(i),this.data.set(i,{...a});else if(a.type===`directory`){if(!n?.recursive)throw Error(`EISDIR: is a directory, cp '${e}'`);if(uH(r,i))throw Error(`EINVAL: cannot copy '${e}' into itself, '${t}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(r);for(let e of a){let t=mH(r,e),a=mH(i,e);await this.cp(t,a,n)}}}async mv(e,t){dH(e,`mv`),dH(t,`mv`);let n=lH(e),r=lH(t);if(n===r)return;let i=this.data.get(n);if(!i)throw Error(`ENOENT: no such file or directory, mv '${e}'`);if(i.type===`directory`&&uH(n,r))throw Error(`EINVAL: cannot move '${e}' into itself, '${t}'`);if(i.type===`directory`){await this.mkdir(r,{recursive:!0});let e=await this.readdir(n);for(let t of e)await this.mv(mH(n,t),mH(r,t));this.deleteEntry(n);return}this.ensureParentDirs(r),this.setEntry(r,i),this.deleteEntry(n)}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,t){return pH(e,t)}async chmod(e,t){dH(e,`chmod`);let n=lH(e),r=this.data.get(n);if(!r)throw Error(`ENOENT: no such file or directory, chmod '${e}'`);r.mode=t}async symlink(e,t){dH(t,`symlink`);let n=lH(t);if(this.data.has(n))throw Error(`EEXIST: file already exists, symlink '${t}'`);this.ensureParentDirs(n),this.data.set(n,{type:`symlink`,target:e,mode:511,mtime:new Date})}async link(e,t){dH(e,`link`),dH(t,`link`);let n=lH(e),r=lH(t),i=this.data.get(n);if(!i)throw Error(`ENOENT: no such file or directory, link '${e}'`);if(i.type!==`file`)throw Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(r))throw Error(`EEXIST: file already exists, link '${t}'`);let a=i;`lazy`in a&&(a=await this.materializeLazy(n,a)),this.ensureParentDirs(r);let o={type:`file`,content:a.content,mode:a.mode,mtime:a.mtime};this.entryIdentities.set(o,this.identityFor(a)),this.setEntry(r,o)}async readlink(e){dH(e,`readlink`);let t=lH(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, readlink '${e}'`);if(n.type!==`symlink`)throw Error(`EINVAL: invalid argument, readlink '${e}'`);return n.target}async realpath(e){dH(e,`realpath`);let t=this.resolvePathWithSymlinks(e);if(!this.data.has(t))throw Error(`ENOENT: no such file or directory, realpath '${e}'`);return t}async utimes(e,t,n){dH(e,`utimes`);let r=lH(e),i=this.resolvePathWithSymlinks(r),a=this.data.get(i);if(!a)throw Error(`ENOENT: no such file or directory, utimes '${e}'`);a.mtime=n}},eOe=`5.1.0(1)-release`,tOe=`Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT`;function Y2(e){let{pid:t,ppid:n,uid:r,gid:i}=e;return`Name: bash State: R (running) Pid: ${t} PPid: ${n} Uid: ${r} ${r} ${r} ${r} Gid: ${i} ${i} ${i} ${i} `}function nOe(e){let t=e;return typeof t.mkdirSync==`function`&&typeof t.writeFileSync==`function`}function rOe(e,t){e.mkdirSync(`/bin`,{recursive:!0}),e.mkdirSync(`/usr/bin`,{recursive:!0}),t&&(e.mkdirSync(`/home/user`,{recursive:!0}),e.mkdirSync(`/tmp`,{recursive:!0}))}function iOe(e){e.mkdirSync(`/dev`,{recursive:!0}),e.mkdirSync(`/dev/fd`,{recursive:!0}),e.writeFileSync(`/dev/null`,``),e.writeFileSync(`/dev/zero`,new Uint8Array),e.writeFileSync(`/dev/stdin`,``),e.writeFileSync(`/dev/stdout`,``),e.writeFileSync(`/dev/stderr`,``)}function aOe(e,t){e.mkdirSync(`/proc/self/fd`,{recursive:!0}),e.writeFileSync(`/proc/version`,`${tOe} `),e.writeFileSync(`/proc/self/exe`,`/bin/bash`),e.writeFileSync(`/proc/self/cmdline`,`bash\0`),e.writeFileSync(`/proc/self/comm`,`bash `),e.writeFileLazy?e.writeFileLazy(`/proc/self/status`,()=>Y2(t)):e.writeFileSync(`/proc/self/status`,Y2(t)),e.writeFileSync(`/proc/self/fd/0`,`/dev/stdin`),e.writeFileSync(`/proc/self/fd/1`,`/dev/stdout`),e.writeFileSync(`/proc/self/fd/2`,`/dev/stderr`)}function oOe(e,t,n={pid:1,ppid:0,uid:1e3,gid:1e3}){nOe(e)&&(rOe(e,t),iOe(e),aOe(e,n))}yH(),tq(),U(),AB(),U();function X2(e){return{kind:e.kind,elements:new Map(e.elements)}}function Z2(e){return new Map(Array.from(e??[],([e,t])=>[e,X2(t)]))}function Q2(e,t){return e.state.arrays?.get(t)}function $2(e,t,n=`indexed`){e.state.arrays??=new Map;let r=e.state.arrays.get(t);return r||(r={kind:n,elements:new Map},e.state.arrays.set(t,r)),r}function e4(e,t,n){let r=$2(e,t,n);return r.kind=n,r}function t4(e,t){return e.state.arrays?.has(t)??!1}function n4(e,t,n){return Q2(e,t)?.elements.get(String(n))}function r4(e,t,n){return Q2(e,t)?.elements.has(String(n))??!1}function i4(e,t,n,r,i){let a=$2(e,t,i),o=String(n);if(!a.elements.has(o)&&a.elements.size>=e.limits.maxArrayElements)throw new H(`array element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);if(V(r)>e.limits.maxStringLength)throw new H(`array value string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);a.elements.set(o,r)}function a4(e,t,n,r=!1){let i=new Set(r?[]:Q2(e,t)?.elements.keys()??[]);for(let t of n)if(i.add(String(t)),i.size>e.limits.maxArrayElements)throw new H(`array element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`)}function o4(e,t,n){return Q2(e,t)?.elements.delete(String(n))??!1}function s4(e,t){e.state.arrays?.delete(t),e.state.associativeArrays?.delete(t)}function c4(e,t){return Array.from(Q2(e,t)?.elements.keys()??[]).filter(e=>/^(0|[1-9]\d*)$/.test(e)).map(Number).sort((e,t)=>e-t)}function l4(e,t){$2(e,t,e.state.associativeArrays?.has(t)?`associative`:`indexed`).elements.clear()}function u4(e,t){return Array.from(Q2(e,t)?.elements.keys()??[]).sort()}function d4(e){return e.startsWith(`'`)&&e.endsWith(`'`)||e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e}function f4(e){if(e.parts.length<2)return null;let t=e.parts[0],n=e.parts[1];if(t.type!==`Glob`||!t.pattern.startsWith(`[`))return null;let r,i=n,a=1;if(n.type===`Literal`&&n.value.startsWith(`]`)){let o=n.value.slice(1);if(o.startsWith(`+=`)||o.startsWith(`=`))r=t.pattern.slice(1);else if(o===``){if(e.parts.length<3)return null;let n=e.parts[2];if(n.type!==`Literal`||!n.value.startsWith(`=`)&&!n.value.startsWith(`+=`))return null;r=t.pattern.slice(1),i=n,a=2}else return null}else if(t.pattern===`[`&&(n.type===`DoubleQuoted`||n.type===`SingleQuoted`)){if(e.parts.length<3)return null;let t=e.parts[2];if(t.type!==`Literal`||!t.value.startsWith(`]=`)&&!t.value.startsWith(`]+=`))return null;if(n.type===`SingleQuoted`)r=n.value;else{r=``;for(let e of n.parts)(e.type===`Literal`||e.type===`Escaped`)&&(r+=e.value)}i=t,a=2}else if(t.pattern.endsWith(`]`)){if(n.type!==`Literal`||!n.value.startsWith(`=`)&&!n.value.startsWith(`+=`))return null;r=t.pattern.slice(1,-1)}else return null;r=d4(r);let o;if(i.type!==`Literal`)return null;o=i.value.startsWith(`]=`)||i.value.startsWith(`]+=`)?i.value.slice(1):i.value;let s=o.startsWith(`+=`);if(!s&&!o.startsWith(`=`))return null;let c=[],l=s?2:1,u=o.slice(l);u&&c.push({type:`Literal`,value:u});for(let t=a+1;t{if(e.type===`Range`){let t=`${e.startStr??String(e.start)}..${e.endStr??String(e.end)}`;return e.step&&(t+=`..${e.step}`),t}return p4(e.word)}).join(`,`)}}`}function p4(e){let t=``;for(let n of e.parts)switch(n.type){case`Literal`:t+=n.value;break;case`Glob`:t+=n.pattern;break;case`SingleQuoted`:t+=n.value;break;case`DoubleQuoted`:for(let e of n.parts)(e.type===`Literal`||e.type===`Escaped`)&&(t+=e.value);break;case`Escaped`:t+=n.value;break;case`BraceExpansion`:t+=`{`,t+=n.items.map(e=>e.type===`Range`?`${e.startStr}..${e.endStr}${e.step?`..${e.step}`:``}`:p4(e.word)).join(`,`),t+=`}`;break;case`TildeExpansion`:t+=`~`,n.user&&(t+=n.user)}return t}var cOe=[`allexport`,`errexit`,`noglob`,`noclobber`,`noexec`,`nounset`,`pipefail`,`posix`,`verbose`,`xtrace`],lOe=[`braceexpand`,`hashall`,`interactive-comments`];function m4(e){let t=[],n=[...lOe.map(e=>({name:e,enabled:!0})),...cOe.map(t=>({name:t,enabled:e[t]}))].sort((e,t)=>e.name.localeCompare(t.name));for(let e of n)e.enabled&&t.push(e.name);return t.join(`:`)}function h4(e){e.state.env.set(`SHELLOPTS`,m4(e.state.options))}var uOe=[`dotglob`,`expand_aliases`,`extglob`,`failglob`,`globskipdots`,`globstar`,`lastpipe`,`nocaseglob`,`nocasematch`,`nullglob`,`xpg_echo`];function g4(e){let t=[];for(let n of uOe)e[n]&&t.push(n);return t.join(`:`)}function _4(e){e.state.env.set(`BASHOPTS`,g4(e.state.shoptOptions))}AB(),oX(),tq();var X={script(e){return{type:`Script`,statements:e}},statement(e,t=[],n=!1,r,i){let a={type:`Statement`,pipelines:e,operators:t,background:n};return r&&(a.deferredError=r),i!==void 0&&(a.sourceText=i),a},pipeline(e,t=!1,n=!1,r=!1,i){return{type:`Pipeline`,commands:e,negated:t,timed:n,timePosix:r,pipeStderr:i}},simpleCommand(e,t=[],n=[],r=[]){return{type:`SimpleCommand`,name:e,args:t,assignments:n,redirections:r}},word(e){return{type:`Word`,parts:e}},literal(e){return{type:`Literal`,value:e}},singleQuoted(e){return{type:`SingleQuoted`,value:e}},doubleQuoted(e){return{type:`DoubleQuoted`,parts:e}},escaped(e){return{type:`Escaped`,value:e}},parameterExpansion(e,t=null){return{type:`ParameterExpansion`,parameter:e,operation:t}},commandSubstitution(e,t=!1){return{type:`CommandSubstitution`,body:e,legacy:t}},arithmeticExpansion(e){return{type:`ArithmeticExpansion`,expression:e}},processSubstitution(e,t){return{type:`ProcessSubstitution`,body:e,direction:t}},assignment(e,t,n=!1,r=null){return{type:`Assignment`,name:e,value:t,append:n,array:r}},redirection(e,t,n=null,r){let i={type:`Redirection`,fd:n,operator:e,target:t};return r&&(i.fdVariable=r),i},hereDoc(e,t,n=!1,r=!1,i){let a={type:`HereDoc`,delimiter:e,content:t,stripTabs:n,quoted:r};return i!==void 0&&(a.terminated=i),a},ifNode(e,t=null,n=[]){return{type:`If`,clauses:e,elseBody:t,redirections:n}},forNode(e,t,n,r=[]){return{type:`For`,variable:e,words:t,body:n,redirections:r}},whileNode(e,t,n=[]){return{type:`While`,condition:e,body:t,redirections:n}},untilNode(e,t,n=[]){return{type:`Until`,condition:e,body:t,redirections:n}},caseNode(e,t,n=[]){return{type:`Case`,word:e,items:t,redirections:n}},caseItem(e,t,n=`;;`){return{type:`CaseItem`,patterns:e,body:t,terminator:n}},subshell(e,t=[]){return{type:`Subshell`,body:e,redirections:t}},group(e,t=[]){return{type:`Group`,body:e,redirections:t}},functionDef(e,t,n=[],r){return{type:`FunctionDef`,name:e,body:t,redirections:n,sourceFile:r}},conditionalCommand(e,t=[],n){return{type:`ConditionalCommand`,expression:e,redirections:t,line:n}},arithmeticCommand(e,t=[],n){return{type:`ArithmeticCommand`,expression:e,redirections:t,line:n}}};function dOe(e,t){let n=e.length,r=t+3,i=2,a=!1,o=!1;for(;r0;){let t=e[r];if(a){t===`'`&&(a=!1),r++;continue}if(o){if(t===`\\`){r+=2;continue}t===`"`&&(o=!1),r++;continue}if(t===`'`){a=!0,r++;continue}if(t===`"`){o=!0,r++;continue}if(t===`\\`){r+=2;continue}if(t===`(`){i++,r++;continue}if(t===`)`){if(i--,i===1){let t=r+1;return!(te===` `||e===` `||e===` `||e===`;`||e===`&`||e===`|`||e===`<`||e===`>`||e===`(`||e===`)`;for(;r0;for(s||(a=!0),s&&(n+=t),r++;r0;for(s||(a=!0),s&&(n+=t),r++;r0){n+=e.slice(r,r+2),r+=2;continue}a=!0;let t=e[r+1];t!==` `&&(n+=t),r+=2;continue}if(i===0&&(t===`$`||t===`<`||t===`>`)&&e[r+1]===`(`){n+=`${t}(`,i=1,r+=2;continue}if(i===0&&s(t))break;i>0&&(t===`(`?i++:t===`)`&&i--),n+=t,r++}return{delim:n,endPos:r,quoted:a,unclosedQuote:o,unclosedSubstitution:i>0}}function fOe(e,t,n){let r=t+1;for(let{delim:t,stripTabs:i}of n)for(;;){if(r>=e.length)return e.length;let n=e.indexOf(` `,r);n===-1&&(n=e.length);let a=e.slice(r,n);if(i&&(a=a.replace(/^\t+/,``)),a===t){r=n+1;break}if(n>=e.length)return e.length;r=n+1}return Math.min(r,e.length)}function y4(e,t,n){let r=1,i=t,a=!1,o=!1,s=0,c=!1,l=``,u=[],d=0;for(;i0;){let t=e[i];if(a)t===`'`&&(a=!1);else if(o)t===`\\`&&i+10&&d--,d===0&&t===`<`&&e[i+1]===`<`&&e[i+2]!==`<`){let t=i+2,r=!1;for(e[t]===`-`&&(r=!0,t++);e[t]===` `||e[t]===` `;)t++;let{delim:a,endPos:o,unclosedQuote:s,unclosedSubstitution:c}=v4(e,t);if(s&&n(`unexpected EOF while looking for matching \`${s}'`),c&&n("unexpected EOF while looking for matching `)'"),a.length>0){u.push({delim:a,stripTabs:r}),l=``,i=o;continue}}if(t===` `&&u.length>0){let t=fOe(e,i,u);u.length=0,l=``,i=t;continue}t===`'`?(a=!0,l=``):t===`"`?(o=!0,l=``):t===`\\`&&i+10?c=!0:l===`esac`&&s>0&&(s--,c=!1),l=``,t===`(`?i>0&&e[i-1]===`$`?r++:c||r++:t===`)`?c?c=!1:r--:t===`;`&&s>0&&i+10&&i++}return r>0&&n("unexpected EOF while looking for matching `)'"),i}function pOe(e,t,n,r){let i=t+2,a=y4(e,i,r),o=e.slice(i,a),s=n().parse(o);return{part:X.commandSubstitution(s,!1),endIndex:a+1}}function mOe(e,t,n,r){let i=e[t]===`<`?`input`:`output`,a=t+2,o=y4(e,a,r),s=n().parse(e.slice(a,o));return{part:X.processSubstitution(s,i),endIndex:o+1}}function hOe(e,t,n,r,i){let a=t+1,o=``;for(;a=e.length&&i("unexpected EOF while looking for matching ``'");let s=r().parse(o);return{part:X.commandSubstitution(s,!0),endIndex:a+1}}var gOe=10485760,Z;(function(e){e.EOF=`EOF`,e.NEWLINE=`NEWLINE`,e.SEMICOLON=`SEMICOLON`,e.AMP=`AMP`,e.PIPE=`PIPE`,e.PIPE_AMP=`PIPE_AMP`,e.AND_AND=`AND_AND`,e.OR_OR=`OR_OR`,e.BANG=`BANG`,e.LESS=`LESS`,e.GREAT=`GREAT`,e.DLESS=`DLESS`,e.DGREAT=`DGREAT`,e.LESSAND=`LESSAND`,e.GREATAND=`GREATAND`,e.LESSGREAT=`LESSGREAT`,e.DLESSDASH=`DLESSDASH`,e.CLOBBER=`CLOBBER`,e.TLESS=`TLESS`,e.AND_GREAT=`AND_GREAT`,e.AND_DGREAT=`AND_DGREAT`,e.LPAREN=`LPAREN`,e.RPAREN=`RPAREN`,e.LBRACE=`LBRACE`,e.RBRACE=`RBRACE`,e.DSEMI=`DSEMI`,e.SEMI_AND=`SEMI_AND`,e.SEMI_SEMI_AND=`SEMI_SEMI_AND`,e.DBRACK_START=`DBRACK_START`,e.DBRACK_END=`DBRACK_END`,e.DPAREN_START=`DPAREN_START`,e.DPAREN_END=`DPAREN_END`,e.IF=`IF`,e.THEN=`THEN`,e.ELSE=`ELSE`,e.ELIF=`ELIF`,e.FI=`FI`,e.FOR=`FOR`,e.WHILE=`WHILE`,e.UNTIL=`UNTIL`,e.DO=`DO`,e.DONE=`DONE`,e.CASE=`CASE`,e.ESAC=`ESAC`,e.IN=`IN`,e.FUNCTION=`FUNCTION`,e.SELECT=`SELECT`,e.TIME=`TIME`,e.COPROC=`COPROC`,e.WORD=`WORD`,e.NAME=`NAME`,e.NUMBER=`NUMBER`,e.ASSIGNMENT_WORD=`ASSIGNMENT_WORD`,e.FD_VARIABLE=`FD_VARIABLE`,e.COMMENT=`COMMENT`,e.HEREDOC_CONTENT=`HEREDOC_CONTENT`})(Z||={});var b4=class extends Error{line;column;constructor(e,t,n){super(`line ${t}: ${e}`),this.line=t,this.column=n,this.name=`LexerError`}},x4=new Map([[`if`,Z.IF],[`then`,Z.THEN],[`else`,Z.ELSE],[`elif`,Z.ELIF],[`fi`,Z.FI],[`for`,Z.FOR],[`while`,Z.WHILE],[`until`,Z.UNTIL],[`do`,Z.DO],[`done`,Z.DONE],[`case`,Z.CASE],[`esac`,Z.ESAC],[`in`,Z.IN],[`function`,Z.FUNCTION],[`select`,Z.SELECT],[`time`,Z.TIME],[`coproc`,Z.COPROC]]),_Oe=new Set(x4.values());function S4(e){return _Oe.has(e)}function C4(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return!1;let n=e.slice(t[0].length);if(n===``||n===`+`)return!0;if(n[0]===`[`){let e=0,t=0;for(;t=n.length)return!1;let r=n.slice(t+1);return r===``||r===`+`}return!1}function w4(e){let t=0;for(let n=0;n`,`>`,Z.AND_DGREAT]],yOe=[[`[`,`[`,Z.DBRACK_START],[`]`,`]`,Z.DBRACK_END],[`(`,`(`,Z.DPAREN_START],[`)`,`)`,Z.DPAREN_END],[`&`,`&`,Z.AND_AND],[`|`,`|`,Z.OR_OR],[`;`,`;`,Z.DSEMI],[`;`,`&`,Z.SEMI_AND],[`|`,`&`,Z.PIPE_AMP],[`>`,`>`,Z.DGREAT],[`<`,`&`,Z.LESSAND],[`>`,`&`,Z.GREATAND],[`<`,`>`,Z.LESSGREAT],[`>`,`|`,Z.CLOBBER],[`&`,`>`,Z.AND_GREAT]],bOe=new Map([[`|`,Z.PIPE],[`&`,Z.AMP],[`;`,Z.SEMICOLON],[`(`,Z.LPAREN],[`)`,Z.RPAREN],[`<`,Z.LESS],[`>`,Z.GREAT]]);function xOe(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function T4(e){return e===` `||e===` `||e===` `||e===`;`||e===`&`||e===`|`||e===`(`||e===`)`||e===`<`||e===`>`}var SOe=class{input;pos=0;line=1;column=1;tokens=[];pendingHeredocs=[];pendingHeredocDelimiterMode;dparenDepth=0;maxHeredocSize;constructor(e,t){this.input=e,this.maxHeredocSize=t?.maxHeredocSize??gOe}tokenize(){let e=this.input.length,t=this.tokens,n=this.pendingHeredocs;for(;this.pos0&&t.length>0&&t[t.length-1].type===Z.NEWLINE){this.readHeredocContent();continue}if(this.skipWhitespace(),this.pos>=e)break;let r=this.nextToken();r&&t.push(r)}return n.length>0&&this.readHeredocContent(),t.push({type:Z.EOF,value:``,start:this.pos,end:this.pos,line:this.line,column:this.column}),t}skipWhitespace(){let e=this.input,t=e.length,n=this.pos,r=this.column,i=this.line;for(;n0?(this.pos=t+1,this.column=r+1,this.dparenDepth++,this.makeToken(Z.LPAREN,`(`,t,n,r)):this.looksLikeNestedSubshells(t+2)||this.dparenClosesWithSpacedParens(t+2)?(this.pos=t+1,this.column=r+1,this.makeToken(Z.LPAREN,`(`,t,n,r)):(this.pos=t+2,this.column=r+2,this.dparenDepth=1,this.makeToken(Z.DPAREN_START,`((`,t,n,r))}if(i===`)`&&a===`)`)return this.dparenDepth===1?(this.pos=t+2,this.column=r+2,this.dparenDepth=0,this.makeToken(Z.DPAREN_END,`))`,t,n,r)):this.dparenDepth>1?(this.pos=t+1,this.column=r+1,this.dparenDepth--,this.makeToken(Z.RPAREN,`)`,t,n,r)):(this.pos=t+1,this.column=r+1,this.makeToken(Z.RPAREN,`)`,t,n,r));for(let[o,s,c]of yOe)if(!(o===`(`&&s===`(`||o===`)`&&s===`)`)&&!(this.dparenDepth>0&&o===`;`&&(c===Z.DSEMI||c===Z.SEMI_AND||c===Z.SEMI_SEMI_AND))&&i===o&&a===s){if(c===Z.DBRACK_START||c===Z.DBRACK_END){let n=e[t+2];if(n!==void 0&&n!==` `&&n!==` `&&n!==` `&&n!==`;`&&n!==`&`&&n!==`|`&&n!==`(`&&n!==`)`&&n!==`<`&&n!==`>`)break}return this.pos=t+2,this.column=r+2,this.makeToken(c,o+s,t,n,r)}if(i===`(`&&this.dparenDepth>0)return this.pos=t+1,this.column=r+1,this.dparenDepth++,this.makeToken(Z.LPAREN,`(`,t,n,r);if(i===`)`&&this.dparenDepth>1)return this.pos=t+1,this.column=r+1,this.dparenDepth--,this.makeToken(Z.RPAREN,`)`,t,n,r);let c=bOe.get(i);if(c!==void 0)return this.pos=t+1,this.column=r+1,this.makeToken(c,i,t,n,r);if(i===`{`){let e=this.scanFdVariable(t);return e===null?a===`}`?(this.pos=t+2,this.column=r+2,{type:Z.WORD,value:`{}`,start:t,end:t+2,line:n,column:r,quoted:!1,singleQuoted:!1}):this.scanBraceExpansion(t)===null&&this.scanLiteralBraceWord(t)===null?a!==void 0&&a!==` `&&a!==` `&&a!==` `?this.readWord(t,n,r):(this.pos=t+1,this.column=r+1,this.makeToken(Z.LBRACE,`{`,t,n,r)):this.readWordWithBraceExpansion(t,n,r):(this.pos=e.end,this.column=r+(e.end-t),{type:Z.FD_VARIABLE,value:e.varname,start:t,end:e.end,line:n,column:r})}return i===`}`?this.isWordCharFollowing(t+1)?this.readWord(t,n,r):(this.pos=t+1,this.column=r+1,this.makeToken(Z.RBRACE,`}`,t,n,r)):i===`!`?a===`=`?(this.pos=t+2,this.column=r+2,this.makeToken(Z.WORD,`!=`,t,n,r)):(this.pos=t+1,this.column=r+1,this.makeToken(Z.BANG,`!`,t,n,r)):this.readWord(t,n,r)}looksLikeNestedSubshells(e){let t=this.input,n=t.length,r=e;for(;r=n)return!1;let i=t[r];if(i===`(`)return this.looksLikeNestedSubshells(r+1);let a=/[a-zA-Z_]/.test(i),o=i===`!`||i===`[`;if(!a&&!o)return!1;let s=r;for(;s=n)return!1;let l=t[c];if(l===`=`&&t[c+1]!==`=`||l===` `||s===c&&/[+\-*/%<>&|^!~?:]/.test(l)&&l!==`-`||l===`)`&&t[c+1]===`)`)return!1;if(c>s&&(l===`-`||l===`"`||l===`'`||l===`$`||/[a-zA-Z_/.]/.test(l))){let e=c;for(;e`||e===`'`||e===`"`||e===`\\`||e===`$`||e==="`"||e===`{`||e===`}`||e===`~`||e===`*`||e===`?`||e===`[`)break;a++}if(a>o){let s=r[a];if(!(s===`(`&&a>o&&`@*+?!`.includes(r[a-1]))&&(a>=i||s===` `||s===` `||s===` `||s===`;`||s===`&`||s===`|`||s===`(`||s===`)`||s===`<`||s===`>`)){let i=r.slice(o,a);this.pos=a,this.column=n+(a-o);let s=x4.get(i);if(s!==void 0)return{type:s,value:i,start:e,end:a,line:t,column:n};let c=w4(i);return c>0&&C4(i.slice(0,c))?{type:Z.ASSIGNMENT_WORD,value:i,start:e,end:a,line:t,column:n}:/^[0-9]+$/.test(i)?{type:Z.NUMBER,value:i,start:e,end:a,line:t,column:n}:/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)?{type:Z.NAME,value:i,start:e,end:a,line:t,column:n,quoted:!1,singleQuoted:!1}:{type:Z.WORD,value:i,start:e,end:a,line:t,column:n,quoted:!1,singleQuoted:!1}}}a=this.pos;let s=this.column,c=this.line,l=``,u=!1,d=!1,f=!1,p=!1,m=r[a]===`"`||r[a]===`'`,h=!1,g=0;for(;a0&&`@*+?!`.includes(l[l.length-1])){let e=this.scanExtglobPattern(a);if(e!==null){l+=e.content,a=e.end,s+=e.content.length;continue}}if(e===`[`&&g===0){if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(l)){let t=a+10){l.length>0&&l[l.length-1]!==`\\`&&g++,l+=e,a++,s++;continue}else if(e===`]`&&g>0){l.length>0&&l[l.length-1]!==`\\`&&g--,l+=e,a++,s++;continue}if(g>0){if(e===` `)break;l+=e,a++,s++;continue}if(e===` `||e===` `||e===` `||e===`;`||e===`&`||e===`|`||e===`(`||e===`)`||e===`<`||e===`>`)break}if(e===`$`&&a+10&&a0&&h--,h===0&&e===`<`&&r[a+1]===`<`&&r[a+2]!==`<`){let e=a+2,t=!1;for(r[e]===`-`&&(t=!0,e++);r[e]===` `||r[e]===` `;)e++;let{delim:n,endPos:i,unclosedQuote:o,unclosedSubstitution:u}=v4(r,e);if(o)throw new b4(`unexpected EOF while looking for matching \`${o}'`,c,s);if(u)throw new b4("unexpected EOF while looking for matching `)'",c,s);if(n.length>0){l+=r.slice(a+1,i),s+=i-a,p.push({delim:n,stripTabs:t}),a=i;continue}}if(e===` `&&p.length>0){c++,s=0;let e=a+1;for(let{delim:t,stripTabs:n}of p)for(;!(e>=i);){let a=r.indexOf(` `,e);a===-1&&(a=i);let o=r.slice(e,a),s=n?o.replace(/^\t+/,``):o;l+=r.slice(e,Math.min(a+1,i)),a=i;if(e=a+1,s===t||u)break}p.length=0,s=0,a=Math.min(e,i);continue}if(e===`'`)n=!0,f=``;else if(e===`"`)o=!0,f=``;else if(e===`\\`&&a+10&&a0?d=!0:f===`esac`&&u>0&&(u--,d=!1),f=``,e===`(`?a>0&&r[a-1]===`$`?t++:d||t++:e===`)`?d?d=!1:t--:e===`;`&&u>0&&(a+10&&a0&&a=`0`&&t<=`9`){l+=e+t,a+=2,s+=2;continue}}if(e==="`"&&!f){for(l+=e,a++,s++;a=2){if(l[0]===`'`&&l[l.length-1]===`'`){let e=l.slice(1,-1);!e.includes(`'`)&&!e.includes(`"`)&&(l=e,u=!0,d=!0)}else if(l[0]===`"`&&l[l.length-1]===`"`){let e=l.slice(1,-1),t=!1;for(let n=0;n0&&C4(l.slice(0,r)))return{type:Z.ASSIGNMENT_WORD,value:l,start:e,end:a,line:t,column:n,quoted:u,singleQuoted:d}}return/^[0-9]+$/.test(l)?{type:Z.NUMBER,value:l,start:e,end:a,line:t,column:n}:xOe(l)?{type:Z.NAME,value:l,start:e,end:a,line:t,column:n,quoted:u,singleQuoted:d}:{type:Z.WORD,value:l,start:e,end:a,line:t,column:n,quoted:u,singleQuoted:d}}readHeredocContent(){for(;this.pendingHeredocs.length>0;){let e=this.pendingHeredocs.shift();if(!e)break;let t=this.pos,n=this.line,r=this.column,i=``,a=!1;for(;this.pos=this.input.length)break;s=s.slice(0,-1),o+=`${t} `,this.pos++,this.line++,this.column=1}if((e.stripTabs?s.replace(/^\t+/,``):s)===e.delimiter){a=!0,this.pos0&&(i+=` `),i.length>this.maxHeredocSize)throw new b4(`Heredoc size limit exceeded (${this.maxHeredocSize} bytes)`,n,r)}this.tokens.push({type:Z.HEREDOC_CONTENT,value:i,start:t,end:this.pos,line:n,column:r,heredocTerminated:a})}}readHeredocDelimiterToken(e,t,n,r){let i=this.input,{delim:a,endPos:o,quoted:s,unclosedQuote:c,unclosedSubstitution:l}=v4(i,e);if(c)throw new b4(`unexpected EOF while looking for matching \`${c}'`,t,n);if(l)throw new b4("unexpected EOF while looking for matching `)'",t,n);if(o===e)throw new b4(`Expected here-document delimiter`,t,n);let u=t,d=n;for(let t=e;t=this.input.length)return!1;let t=this.input[e];return t!==` `&&t!==` `&&t!==` `&&t!==`;`&&t!==`&`&&t!==`|`&&t!==`(`&&t!==`)`&&t!==`<`&&t!==`>`}readWordWithBraceExpansion(e,t,n){let r=this.input,i=r.length,a=e,o=n;for(;a`)break;if(e===`{`){if(this.scanBraceExpansion(a)!==null){let e=1;for(a++,o++;a0;)r[a]===`{`?e++:r[a]===`}`&&e--,a++,o++;continue}a++,o++;continue}if(e===`}`){a++,o++;continue}if(e===`$`&&a+10&&a0&&a0;){let e=t[r];if(e===`{`)i++,r++;else if(e===`}`)i--,r++;else if(e===`,`&&i===1)a=!0,r++;else if(e===`.`&&r+10;){let n=t[r];if(n===`{`)i++,r++;else if(n===`}`){if(i--,i===0)return t.slice(e,r+1);r++}else{if(n===` `||n===` `||n===` `||n===`;`||n===`&`||n===`|`)return null;r++}}return null}scanExtglobPattern(e){let t=this.input,n=t.length,r=e+1,i=1;for(;r0;){let e=t[r];if(e===`\\`&&r+1=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e===`_`))return null}else if(!(e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e>=`0`&&e<=`9`||e===`_`))break;r++}if(r===i)return null;let a=t.slice(i,r);if(r>=n||t[r]!==`}`||(r++,r>=n))return null;let o=t[r],s=r+1`||o===`<`||o===`&`&&(s===`>`||s===`<`)?{varname:a,end:r}:null}dollarDparenIsSubshell(e){let t=this.input,n=t.length,r=e+1,i=2,a=!1,o=!1,s=!1;for(;r0;){let e=t[r];if(a){e===`'`&&(a=!1),e===` `&&(s=!0),r++;continue}if(o){if(e===`\\`){r+=2;continue}e===`"`&&(o=!1),e===` `&&(s=!0),r++;continue}if(e===`'`){a=!0,r++;continue}if(e===`"`){o=!0,r++;continue}if(e===`\\`){r+=2;continue}if(e===` `&&(s=!0),e===`(`){i++,r++;continue}if(e===`)`){if(i--,i===1){let e=r+1;if(e0;){let e=t[r];if(a){e===`'`&&(a=!1),r++;continue}if(o){if(e===`\\`){r+=2;continue}e===`"`&&(o=!1),r++;continue}if(e===`'`){a=!0,r++;continue}if(e===`"`){o=!0,r++;continue}if(e===`\\`){r+=2;continue}if(e===`(`){i++,r++;continue}if(e===`)`){if(i--,i===1){let e=r+1;if(eCOe)throw new A4(`Maximum parse iterations exceeded (possible infinite loop)`,e,t)}chargeTokens(e,t=1,n=1){if(this.tokens+=e,this.tokens>D4)throw new A4(`Too many tokens: cumulative count exceeds limit of ${D4}`,t,n)}enter(e,t){if(this.depth++,this.depth>O4)throw this.depth--,new A4(`Maximum parser nesting depth exceeded (${O4})`,e,t);let n=!0;return()=>{n&&(n=!1,this.depth--)}}};oB(),ZB(),U();function j4(e,t){for(;t>=`,`&=`,`|=`,`^=`];function N4(e){if(e.includes(`#`)){let t=e.split(`#`);if(t.length!==2)return NaN;let[n,r]=t;if(!/^\d+$/.test(n)||r.length===0)return NaN;let i=Number.parseInt(n,10);if(i<2||i>64)return NaN;let a=0;for(let e of r){let t;if(/[0-9]/.test(e))t=e.charCodeAt(0)-48;else if(/[a-z]/.test(e))t=e.charCodeAt(0)-97+10;else if(/[A-Z]/.test(e))t=e.charCodeAt(0)-65+(i<=36?10:36);else if(e===`@`)t=62;else if(e===`_`)t=63;else return NaN;if(t>=i)return NaN;if(a=a*i+t,a>2**53-1)return 2**53-1}return a}if(e.startsWith(`0x`)||e.startsWith(`0X`)){let t=Number.parseInt(e.slice(2),16);return t>2**53-1?2**53-1:t}if(e.startsWith(`0`)&&e.length>1&&/^[0-9]+$/.test(e)){if(/[89]/.test(e))return NaN;let t=Number.parseInt(e,8);return t>2**53-1?2**53-1:t}let t=Number.parseInt(e,10);return t>2**53-1?2**53-1:t}function OOe(e,t,n,r){if(n.slice(r,r+3)!==`$((`)return null;let i=r+3,a=1,o=i;for(;i0;)n[i]===`(`&&n[i+1]===`(`?(a++,i+=2):n[i]===`)`&&n[i+1]===`)`?(a--,a>0&&(i+=2)):i++;let{expr:s}=e(t,n.slice(o,i),0);return i+=2,{expr:{type:`ArithNested`,expression:s},pos:i}}function kOe(e,t){if(e.slice(t,t+2)!==`$'`)return null;let n=t+2,r=``;for(;n=e.length}function L4(e,t,n){return MOe(e,t,n)}function R4(e,t,n){return e.withDepth(()=>L4(e,t,n))}function MOe(e,t,n){let{expr:r,pos:i}=z4(e,t,n);for(i=j4(t,i);t[i]===`,`;){if(i++,I4(t,i))return F4(`,`,i);let{expr:n,pos:a}=z4(e,t,i);r={type:`ArithBinary`,operator:`,`,left:r,right:n},i=j4(t,a)}return{expr:r,pos:i}}function z4(e,t,n){let{expr:r,pos:i}=NOe(e,t,n);if(i=j4(t,i),t[i]===`?`){i++;let{expr:n,pos:a}=R4(e,t,i);if(i=j4(t,a),t[i]===`:`){i++;let{expr:a,pos:o}=R4(e,t,i);return{expr:{type:`ArithTernary`,condition:r,consequent:n,alternate:a},pos:o}}}return{expr:r,pos:i}}function NOe(e,t,n){let{expr:r,pos:i}=B4(e,t,n);for(;i=j4(t,i),t.slice(i,i+2)===`||`;){if(i+=2,I4(t,i))return F4(`||`,i);let{expr:n,pos:a}=B4(e,t,i);r={type:`ArithBinary`,operator:`||`,left:r,right:n},i=a}return{expr:r,pos:i}}function B4(e,t,n){let{expr:r,pos:i}=V4(e,t,n);for(;i=j4(t,i),t.slice(i,i+2)===`&&`;){if(i+=2,I4(t,i))return F4(`&&`,i);let{expr:n,pos:a}=V4(e,t,i);r={type:`ArithBinary`,operator:`&&`,left:r,right:n},i=a}return{expr:r,pos:i}}function V4(e,t,n){let{expr:r,pos:i}=H4(e,t,n);for(;i=j4(t,i),t[i]===`|`&&t[i+1]!==`|`;){if(i++,I4(t,i))return F4(`|`,i);let{expr:n,pos:a}=H4(e,t,i);r={type:`ArithBinary`,operator:`|`,left:r,right:n},i=a}return{expr:r,pos:i}}function H4(e,t,n){let{expr:r,pos:i}=U4(e,t,n);for(;i=j4(t,i),t[i]===`^`;){if(i++,I4(t,i))return F4(`^`,i);let{expr:n,pos:a}=U4(e,t,i);r={type:`ArithBinary`,operator:`^`,left:r,right:n},i=a}return{expr:r,pos:i}}function U4(e,t,n){let{expr:r,pos:i}=W4(e,t,n);for(;i=j4(t,i),t[i]===`&`&&t[i+1]!==`&`;){if(i++,I4(t,i))return F4(`&`,i);let{expr:n,pos:a}=W4(e,t,i);r={type:`ArithBinary`,operator:`&`,left:r,right:n},i=a}return{expr:r,pos:i}}function W4(e,t,n){let{expr:r,pos:i}=G4(e,t,n);for(;i=j4(t,i),t.slice(i,i+2)===`==`||t.slice(i,i+2)===`!=`;){let n=t.slice(i,i+2);if(i+=2,I4(t,i))return F4(n,i);let{expr:a,pos:o}=G4(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}return{expr:r,pos:i}}function G4(e,t,n){let{expr:r,pos:i}=K4(e,t,n);for(;;)if(i=j4(t,i),t.slice(i,i+2)===`<=`||t.slice(i,i+2)===`>=`){let n=t.slice(i,i+2);if(i+=2,I4(t,i))return F4(n,i);let{expr:a,pos:o}=K4(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}else if(t[i]===`<`||t[i]===`>`){let n=t[i];if(i++,I4(t,i))return F4(n,i);let{expr:a,pos:o}=K4(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}else break;return{expr:r,pos:i}}function K4(e,t,n){let{expr:r,pos:i}=q4(e,t,n);for(;i=j4(t,i),t.slice(i,i+2)===`<<`||t.slice(i,i+2)===`>>`;){let n=t.slice(i,i+2);if(i+=2,I4(t,i))return F4(n,i);let{expr:a,pos:o}=q4(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}return{expr:r,pos:i}}function q4(e,t,n){let{expr:r,pos:i}=J4(e,t,n);for(;i=j4(t,i),(t[i]===`+`||t[i]===`-`)&&t[i+1]!==t[i];){let n=t[i];if(i++,I4(t,i))return F4(n,i);let{expr:a,pos:o}=J4(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}return{expr:r,pos:i}}function J4(e,t,n){let{expr:r,pos:i}=Y4(e,t,n);for(;;)if(i=j4(t,i),t[i]===`*`&&t[i+1]!==`*`){if(i++,I4(t,i))return F4(`*`,i);let{expr:n,pos:a}=Y4(e,t,i);r={type:`ArithBinary`,operator:`*`,left:r,right:n},i=a}else if(t[i]===`/`||t[i]===`%`){let n=t[i];if(i++,I4(t,i))return F4(n,i);let{expr:a,pos:o}=Y4(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}else break;return{expr:r,pos:i}}function Y4(e,t,n){let{expr:r,pos:i}=X4(e,t,n),a=j4(t,i);if(t.slice(a,a+2)===`**`){if(a+=2,I4(t,a))return F4(`**`,a);let{expr:n,pos:i}=e.withDepth(()=>Y4(e,t,a));return{expr:{type:`ArithBinary`,operator:`**`,left:r,right:n},pos:i}}return{expr:r,pos:i}}function X4(e,t,n){let r=j4(t,n);if(t.slice(r,r+2)===`++`||t.slice(r,r+2)===`--`){let n=t.slice(r,r+2);r+=2;let{expr:i,pos:a}=e.withDepth(()=>X4(e,t,r));return{expr:{type:`ArithUnary`,operator:n,operand:i,prefix:!0},pos:a}}if(t[r]===`+`||t[r]===`-`||t[r]===`!`||t[r]===`~`){let n=t[r];r++;let{expr:i,pos:a}=e.withDepth(()=>X4(e,t,r));return{expr:{type:`ArithUnary`,operator:n,operand:i,prefix:!0},pos:a}}return FOe(e,t,r)}function POe(e,t){let n=e[t];return n===`$`||n==="`"}function FOe(e,t,n){let{expr:r,pos:i}=Z4(e,t,n,!1),a=[r];for(;POe(t,i);){let{expr:n,pos:r}=Z4(e,t,i,!0);a.push(n),i=r}a.length>1&&(r={type:`ArithConcat`,parts:a});let o;if(t[i]===`[`&&r.type===`ArithConcat`){i++;let{expr:n,pos:r}=R4(e,t,i);o=n,i=r,t[i]===`]`&&i++}if(o&&r.type===`ArithConcat`&&(r={type:`ArithDynamicElement`,nameExpr:r,subscript:o},o=void 0),i=j4(t,i),r.type===`ArithConcat`||r.type===`ArithVariable`||r.type===`ArithDynamicElement`){for(let n of M4)if(t.slice(i,i+n.length)===n&&t.slice(i,i+n.length+1)!==`==`){i+=n.length;let{expr:a,pos:o}=e.withDepth(()=>z4(e,t,i));return r.type===`ArithDynamicElement`?{expr:{type:`ArithDynamicAssignment`,operator:n,target:r.nameExpr,subscript:r.subscript,value:a},pos:o}:r.type===`ArithConcat`?{expr:{type:`ArithDynamicAssignment`,operator:n,target:r,value:a},pos:o}:{expr:{type:`ArithAssignment`,operator:n,variable:r.name,value:a},pos:o}}}if(t.slice(i,i+2)===`++`||t.slice(i,i+2)===`--`){let e=t.slice(i,i+2);return i+=2,{expr:{type:`ArithUnary`,operator:e,operand:r,prefix:!1},pos:i}}return{expr:r,pos:i}}function Z4(e,t,n,r=!1){let i=j4(t,n),a=OOe(R4,e,t,i);if(a)return a;let o=kOe(t,i);if(o)return o;let s=AOe(t,i);if(s)return s;if(t.slice(i,i+2)===`$(`&&t[i+2]!==`(`){i+=2;let e=1,n=i;for(;i0;)t[i]===`(`?e++:t[i]===`)`&&e--,e>0&&i++;let r=t.slice(n,i);return i++,{expr:{type:`ArithCommandSubst`,command:r},pos:i}}if(t[i]==="`"){i++;let e=i;for(;i0;)t[r]===`{`?n++:t[r]===`}`&&n--,n>0&&r++;let a=t.slice(e,r),o=r+1;if(t[o]===`#`){let e=o+1;for(;ez4(e,t,i));return{expr:{type:`ArithAssignment`,operator:r,variable:n,subscript:o,stringKey:a,value:s},pos:c}}}return{expr:{type:`ArithArrayElement`,array:n,index:o,stringKey:a},pos:i}}if(i=j4(t,i),!r){for(let r of M4)if(t.slice(i,i+r.length)===r&&t.slice(i,i+r.length+1)!==`==`){i+=r.length;let{expr:a,pos:o}=e.withDepth(()=>z4(e,t,i));return{expr:{type:`ArithAssignment`,operator:r,variable:n,value:a},pos:o}}}return{expr:{type:`ArithVariable`,name:n,hasDollarPrefix:c},pos:i}}if(t[i]===`#`){let e=i+1;for(;e{let t,n=``;for(let r=0;r=194){let i=(r&31)<<6|e[n+1]&63;t+=String.fromCharCode(i),n+=2;continue}t+=String.fromCharCode(r),n++;continue}if((r&240)==224){if(n+2=55296&&i<=57343){t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(i),n+=3;continue}t+=String.fromCharCode(r),n++;continue}if((r&248)==240&&r<=244){if(n+31114111){t+=String.fromCharCode(r),n++;continue}t+=String.fromCodePoint(i),n+=4;continue}t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(r),n++}return t}function LOe(e,t,n){let r=n+1;for(;r0;)t[o]===r?a++:t[o]===i&&a--,a>0&&o++;return a===0?o:-1}function e3(e,t,n){let r=n,i=1;for(;r0;){let e=t[r];if(e===`\\`&&r+10&&r++}return r}function ROe(e,t,n){let r=n,i=!1;for(;r0)e.push(i),n+=2+r.length;else break}e.length>0?(r+=IOe(e),i=n):(r+=`\\x`,i+=2);break}case`u`:{let e=t.slice(i+2,i+6),n=parseInt(e,16);Number.isNaN(n)?(r+=`\\u`,i+=2):(r+=String.fromCharCode(n),i+=6);break}case`c`:if(i+2e.withDepth(()=>({type:`Word`,word:X.word(r(e,t,!1,!1,!1))})))},endIndex:i+1}:a.includes(`,`)?{part:{type:`BraceExpansion`,items:n3(a).map(e=>({type:`Word`,word:X.word([X.literal(e)])}))},endIndex:i+1}:null}function r3(e,t){let n=``;for(let r of t.parts)switch(r.type){case`Literal`:n+=r.value;break;case`SingleQuoted`:n+=`'${r.value}'`;break;case`Escaped`:n+=r.value;break;case`DoubleQuoted`:n+=`"`;for(let e of r.parts)e.type===`Literal`||e.type===`Escaped`?n+=e.value:e.type===`ParameterExpansion`&&(n+=`\${${e.parameter}}`);n+=`"`;break;case`ParameterExpansion`:n+=`\${${r.parameter}}`;break;case`Glob`:n+=r.pattern;break;case`TildeExpansion`:n+=`~`,r.user&&(n+=r.user);break;case`BraceExpansion`:{n+=`{`;let t=[];for(let n of r.items)if(n.type===`Range`){let e=n.startStr??String(n.start),r=n.endStr??String(n.end);n.step===void 0?t.push(`${e}..${r}`):t.push(`${e}..${r}..${n.step}`)}else t.push(r3(e,n.word));t.length===1&&r.items[0].type===`Range`?n+=t[0]:n+=t.join(`,`),n+=`}`;break}default:n+=r.type}return n}function UOe(e,t){return{[Z.LESS]:`<`,[Z.GREAT]:`>`,[Z.DGREAT]:`>>`,[Z.LESSAND]:`<&`,[Z.GREATAND]:`>&`,[Z.LESSGREAT]:`<>`,[Z.CLOBBER]:`>|`,[Z.TLESS]:`<<<`,[Z.AND_GREAT]:`&>`,[Z.AND_DGREAT]:`&>>`,[Z.DLESS]:`<`,[Z.DLESSDASH]:`<`}[t]||`>`}function i3(e){let t=e.current(),n=t.type;if(n===Z.NUMBER){let n=e.peek(1);return t.end!==n.start||e.isProcessSubstitutionStart(1)?!1:TOe.has(n.type)}if(n===Z.FD_VARIABLE){let n=e.peek(1);return t.end!==n.start||e.isProcessSubstitutionStart(1)?!1:EOe.has(n.type)}return!e.isProcessSubstitutionStart()&&wOe.has(n)}function a3(e){let t=null,n;e.check(Z.NUMBER)?t=Number.parseInt(e.advance().value,10):e.check(Z.FD_VARIABLE)&&(n=e.advance().value);let r=e.advance(),i=UOe(e,r.type);if(r.type===Z.DLESS||r.type===Z.DLESSDASH)return WOe(e,t,n,r.type===Z.DLESSDASH);e.isWord()||e.error(`Expected redirection target`);let a=e.parseWord();return X.redirection(i,a,t,n)}function WOe(e,t,n,r){e.isWord()||e.error(`Expected here-document delimiter`);let i=e.advance(),a=i.heredocDelimiter??i.value,o=i.quoted||!1,s=X.redirection(r?`<<-`:`<<`,X.hereDoc(a,X.word([]),r,o),t,n);return e.addPendingHeredoc(s,a,r,o),s}function o3(e){let t=e.getSourceLine(),n=[],r=null,i=[],a=[];for(;e.check(Z.ASSIGNMENT_WORD)||i3(e);)e.checkIterationLimit(),e.check(Z.ASSIGNMENT_WORD)?n.push(GOe(e)):a.push(a3(e));if(e.isWord())r=e.parseWord();else if(n.length>0&&(e.check(Z.DBRACK_START)||e.check(Z.DPAREN_START))){let t=e.advance();r=X.word([X.literal(t.value)])}for(;(!e.isStatementEnd()||e.check(Z.RBRACE))&&!e.check(Z.PIPE,Z.PIPE_AMP);)if(e.checkIterationLimit(),i3(e))a.push(a3(e));else if(e.check(Z.ASSIGNMENT_WORD)){let t=e.advance(),n=t.value,r=n.endsWith(`=`),a=n.endsWith(`=(`);if((r||a)&&(a||e.check(Z.LPAREN))){let t=a?n.slice(0,-2):n.slice(0,-1);a||e.expect(Z.LPAREN);let r=s3(e);e.expect(Z.RPAREN);let o=`${t}=(${r.map(t=>r3(e,t)).join(` `)})`;i.push(e.parseWordFromString(o,!1,!1,!0))}else{let r=e.parseWordFromString(n,t.quoted,t.singleQuoted,!0);i.push(e.parseAdjacentWordParts(r.parts,t.end,k4.Assignment))}}else if(e.isWord())i.push(e.parseWord());else if(e.check(Z.RBRACE)){let t=e.advance();i.push(e.parseWordFromString(t.value,!1,!1))}else if(e.check(Z.LBRACE)){let t=e.advance();i.push(e.parseWordFromString(t.value,!1,!1))}else if(e.check(Z.DBRACK_END)){let t=e.advance();i.push(e.parseWordFromString(t.value,!1,!1))}else if(e.check(Z.LPAREN))e.error("syntax error near unexpected token `('");else break;let o=X.simpleCommand(r,i,n,a);return o.line=t,o}function GOe(e){let t=e.expect(Z.ASSIGNMENT_WORD),n=t.value,r=n.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);r||e.error(`Invalid assignment: ${n}`);let i=r[0],a,o=i.length;if(n[o]===`[`){let t=0,r=o+1;for(;o2)break}else t.value===`(`&&c++,t.value===`)`&&c--,o[s]+=t.value}e.expect(Z.DPAREN_END),o[0].trim()&&(r=P4(e,o[0].trim())),o[1].trim()&&(i=P4(e,o[1].trim())),o[2].trim()&&(a=P4(e,o[2].trim())),e.skipNewlines(),e.check(Z.SEMICOLON)&&e.advance(),e.skipNewlines();let l;e.check(Z.LBRACE)?(e.advance(),l=e.parseCompoundList(),e.expect(Z.RBRACE)):(e.expect(Z.DO),l=e.parseCompoundList(),e.expect(Z.DONE));let u=t?.skipRedirections?[]:e.parseOptionalRedirections();return{type:`CStyleFor`,init:r,condition:i,update:a,body:l,redirections:u,line:n}}function u3(e,t){e.expect(Z.WHILE);let n=e.parseCompoundList();e.expect(Z.DO);let r=e.parseCompoundList();r.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(Z.DONE);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.whileNode(n,r,i)}function d3(e,t){e.expect(Z.UNTIL);let n=e.parseCompoundList();e.expect(Z.DO);let r=e.parseCompoundList();r.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(Z.DONE);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.untilNode(n,r,i)}function f3(e,t){e.expect(Z.CASE),e.isWord()||e.error(`Expected word after 'case'`);let n=e.parseWord();e.skipNewlines(),e.expect(Z.IN),e.skipNewlines();let r=[];for(;!e.check(Z.ESAC,Z.EOF);){e.checkIterationLimit();let t=e.getPos(),n=JOe(e);if(n&&r.push(n),e.skipNewlines(),e.getPos()===t&&!n)break}e.expect(Z.ESAC);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.caseNode(n,r,i)}function JOe(e){e.check(Z.LPAREN)&&e.advance();let t=[];for(;e.isWord()&&(t.push(e.parseWord()),e.check(Z.PIPE));)e.advance();if(t.length===0)return null;e.expect(Z.RPAREN),e.skipNewlines();let n=[];for(;!e.check(Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND,Z.ESAC,Z.EOF);){e.checkIterationLimit(),e.isWord()&&e.peek(1).type===Z.RPAREN&&e.error("syntax error near unexpected token `)'"),e.check(Z.LPAREN)&&e.peek(1).type===Z.WORD&&e.error(`syntax error near unexpected token \`${e.peek(1).value}'`);let t=e.getPos(),r=e.parseStatement();if(r&&n.push(r),e.skipSeparators(!1),e.getPos()===t&&!r)break}let r=`;;`;return e.check(Z.DSEMI)?(e.advance(),r=`;;`):e.check(Z.SEMI_AND)?(e.advance(),r=`;&`):e.check(Z.SEMI_SEMI_AND)&&(e.advance(),r=`;;&`),X.caseItem(t,n,r)}function p3(e,t){e.expect(Z.LPAREN);let n=e.parseCompoundList();e.expect(Z.RPAREN);let r=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.subshell(n,r)}function m3(e,t){e.expect(Z.LBRACE);let n=e.parseCompoundList();e.expect(Z.RBRACE);let r=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.group(n,r)}var YOe=`-a.-b.-c.-d.-e.-f.-g.-h.-k.-p.-r.-s.-t.-u.-w.-x.-G.-L.-N.-O.-S.-z.-n.-o.-v.-R`.split(`.`),XOe=[`==`,`!=`,`=~`,`<`,`>`,`-eq`,`-ne`,`-lt`,`-le`,`-gt`,`-ge`,`-nt`,`-ot`,`-ef`];function h3(e){return e.isWord()||e.check(Z.LBRACE)||e.check(Z.RBRACE)||e.check(Z.ASSIGNMENT_WORD)}function g3(e){if(e.check(Z.BANG)&&e.peek(1).type===Z.LPAREN){e.advance(),e.advance();let t=1,n=`!(`;for(;t>0&&!e.check(Z.EOF);)if(e.check(Z.LPAREN))t++,n+=`(`,e.advance();else if(e.check(Z.RPAREN))t--,t>0&&(n+=`)`),e.advance();else if(e.isWord())n+=e.advance().value;else if(e.check(Z.PIPE))n+=`|`,e.advance();else break;return n+=`)`,e.parseWordFromString(n,!1,!1,!1,!1,!0)}return e.parseWordNoBraceExpansion()}function _3(e){return e.skipNewlines(),ZOe(e)}function ZOe(e){let t=v3(e);for(e.skipNewlines();e.check(Z.OR_OR);){e.advance(),e.skipNewlines();let n=v3(e);t={type:`CondOr`,left:t,right:n},e.skipNewlines()}return t}function v3(e){let t=y3(e);for(e.skipNewlines();e.check(Z.AND_AND);){e.advance(),e.skipNewlines();let n=y3(e);t={type:`CondAnd`,left:t,right:n},e.skipNewlines()}return t}function y3(e){return e.skipNewlines(),e.check(Z.BANG)?(e.advance(),e.skipNewlines(),{type:`CondNot`,operand:e.withDepth(()=>y3(e))}):QOe(e)}function QOe(e){if(e.check(Z.LPAREN)){e.advance();let t=e.withDepth(()=>_3(e));return e.expect(Z.RPAREN),{type:`CondGroup`,expression:t}}if(h3(e)){let t=e.current(),n=t.value;if(YOe.includes(n)&&!t.quoted){if(e.advance(),e.check(Z.DBRACK_END)&&e.error(`Expected operand after ${n}`),h3(e))return{type:`CondUnary`,operator:n,operand:e.parseWordNoBraceExpansion()};let t=e.current();e.error(`unexpected argument \`${t.value}' to conditional unary operator`)}let r=e.parseWordNoBraceExpansion();if(e.isWord()&&XOe.includes(e.current().value)){let t=e.advance().value,n;return n=t===`=~`?$Oe(e):t===`==`||t===`!=`?g3(e):e.parseWordNoBraceExpansion(),{type:`CondBinary`,operator:t,left:r,right:n}}return e.check(Z.LESS)?(e.advance(),{type:`CondBinary`,operator:`<`,left:r,right:e.parseWordNoBraceExpansion()}):e.check(Z.GREAT)?(e.advance(),{type:`CondBinary`,operator:`>`,left:r,right:e.parseWordNoBraceExpansion()}):e.isWord()&&e.current().value===`=`?(e.advance(),{type:`CondBinary`,operator:`==`,left:r,right:g3(e)}):{type:`CondWord`,word:r}}e.error(`Expected conditional expression`)}function $Oe(e){let t=[],n=0,r=-1,i=e.getInput(),a=()=>e.check(Z.DBRACK_END)||e.check(Z.AND_AND)||e.check(Z.OR_OR)||e.check(Z.NEWLINE)||e.check(Z.EOF);for(;!a();){let a=e.current(),o=r>=0&&a.start>r;if(n===0&&o)break;if(n>0&&o){let e=i.slice(r,a.start);t.push({type:`Literal`,value:e})}if(e.isWord()||e.check(Z.ASSIGNMENT_WORD)){let n=e.parseWordForRegex();t.push(...n.parts),r=e.peek(-1).end}else if(e.check(Z.LPAREN)){let i=e.advance();t.push({type:`Literal`,value:`(`}),n++,r=i.end}else if(e.check(Z.DPAREN_START)){let i=e.advance();t.push({type:`Literal`,value:`((`}),n+=2,r=i.end}else if(e.check(Z.DPAREN_END)){if(n>=2){let i=e.advance();t.push({type:`Literal`,value:`))`}),n-=2,r=i.end}else{if(n===1)break;break}}else if(e.check(Z.RPAREN)){if(n>0){let i=e.advance();t.push({type:`Literal`,value:`)`}),n--,r=i.end}else break}else if(e.check(Z.PIPE)){let n=e.advance();t.push({type:`Literal`,value:`|`}),r=n.end}else if(e.check(Z.SEMICOLON)){if(n>0){let n=e.advance();t.push({type:`Literal`,value:`;`}),r=n.end}else break}else if(n>0&&e.check(Z.LESS)){let n=e.advance();t.push({type:`Literal`,value:`<`}),r=n.end}else if(n>0&&e.check(Z.GREAT)){let n=e.advance();t.push({type:`Literal`,value:`>`}),r=n.end}else if(n>0&&e.check(Z.DGREAT)){let n=e.advance();t.push({type:`Literal`,value:`>>`}),r=n.end}else if(n>0&&e.check(Z.DLESS)){let n=e.advance();t.push({type:`Literal`,value:`<<`}),r=n.end}else if(n>0&&e.check(Z.LESSAND)){let n=e.advance();t.push({type:`Literal`,value:`<&`}),r=n.end}else if(n>0&&e.check(Z.GREATAND)){let n=e.advance();t.push({type:`Literal`,value:`>&`}),r=n.end}else if(n>0&&e.check(Z.LESSGREAT)){let n=e.advance();t.push({type:`Literal`,value:`<>`}),r=n.end}else if(n>0&&e.check(Z.CLOBBER)){let n=e.advance();t.push({type:`Literal`,value:`>|`}),r=n.end}else if(n>0&&e.check(Z.TLESS)){let n=e.advance();t.push({type:`Literal`,value:`<<<`}),r=n.end}else if(n>0&&e.check(Z.AMP)){let n=e.advance();t.push({type:`Literal`,value:`&`}),r=n.end}else if(n>0&&e.check(Z.LBRACE)){let n=e.advance();t.push({type:`Literal`,value:`{`}),r=n.end}else if(n>0&&e.check(Z.RBRACE)){let n=e.advance();t.push({type:`Literal`,value:`}`}),r=n.end}else break}return t.length===0&&e.error(`Expected regex pattern after =~`),{type:`Word`,parts:t}}function eke(e){let t=``;for(let n=0;n0?e:[X.literal(``)]}function tke(e,t){let n=1,r=t+1;for(;r0;){let t=e[r];if(t===`\\`){r+=2;continue}if(`@*+?!`.includes(t)&&r+10;)t[r]===`{`?e++:t[r]===`}`&&e--,e>0&&r++;let a=t.slice(n+2,r);return{part:X.parameterExpansion(``,{type:`BadSubstitution`,text:a}),endIndex:r+1}}}if(s===``&&!a&&!o&&t[i]!==`}`){let e=1,r=i;for(;r0;)t[r]===`{`?e++:t[r]===`}`&&e--,e>0&&r++;if(e>0)throw new A4(`unexpected EOF while looking for matching '}'`,0,0);let a=t.slice(n+2,r);return{part:X.parameterExpansion(``,{type:`BadSubstitution`,text:a}),endIndex:r+1}}let l=null;if(a){let n=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(n){if(i=t.length)throw new A4(`unexpected EOF while looking for matching '}'`,0,0);return{part:X.parameterExpansion(s,l),endIndex:i+1}}function x3(e,t,n,r,i=!1){let a=n,o=t[a],s=t[a+1]||``;if(o===`:`){let n=s;if(`-=?+`.includes(n)){a+=2;let r=e3(e,t,a),o=t.slice(a,r),s=e.withDepth(()=>w3(e,o,!1,!1,!0,!1,i,!1,!1,!0)),c=X.word(b3(s));if(n===`-`)return{operation:{type:`DefaultValue`,word:c,checkEmpty:!0},endIndex:r};if(n===`=`)return{operation:{type:`AssignDefault`,word:c,checkEmpty:!0},endIndex:r};if(n===`?`)return{operation:{type:`ErrorIfUnset`,word:c,checkEmpty:!0},endIndex:r};if(n===`+`)return{operation:{type:`UseAlternative`,word:c,checkEmpty:!0},endIndex:r}}a++;let r=e3(e,t,a),o=t.slice(a,r),c=-1,l=0,u=0;for(let e=0;e0)u--;else{c=e;break}}}let d=c>=0?o.slice(0,c):o,f=c>=0?o.slice(c+1):null;return{operation:{type:`Substring`,offset:t3(e,d),length:f===null?null:t3(e,f)},endIndex:r}}if(`-=?+`.includes(o)){a++;let n=e3(e,t,a),r=t.slice(a,n),s=e.withDepth(()=>w3(e,r,!1,!1,!0,!1,i,!1,!1,!0)),c=X.word(b3(s));if(o===`-`)return{operation:{type:`DefaultValue`,word:c,checkEmpty:!1},endIndex:n};if(o===`=`)return{operation:{type:`AssignDefault`,word:c,checkEmpty:!1},endIndex:n};if(o===`?`)return{operation:{type:`ErrorIfUnset`,word:r?c:null,checkEmpty:!1},endIndex:n};if(o===`+`)return{operation:{type:`UseAlternative`,word:c,checkEmpty:!1},endIndex:n}}if(o===`#`||o===`%`){let n=s===o,r=o===`#`?`prefix`:`suffix`;a+=n?2:1;let i=e3(e,t,a),c=t.slice(a,i),l=e.withDepth(()=>w3(e,c,!1,!1,!1));return{operation:{type:`PatternRemoval`,pattern:X.word(b3(l)),side:r,greedy:n},endIndex:i}}if(o===`/`){let n=s===`/`;a+=n?2:1;let r=null;t[a]===`#`?(r=`start`,a++):t[a]===`%`&&(r=`end`,a++);let i;i=r!==null&&(t[a]===`/`||t[a]===`}`)?a:ROe(e,t,a);let o=t.slice(a,i),c=e.withDepth(()=>w3(e,o,!1,!1,!1)),l=X.word(b3(c)),u=null,d=i;if(t[i]===`/`){let n=i+1,r=e3(e,t,n),a=t.slice(n,r),o=e.withDepth(()=>w3(e,a,!1,!1,!1));u=X.word(b3(o)),d=r}return{operation:{type:`PatternReplacement`,pattern:l,replacement:u,all:n,anchor:r},endIndex:d}}if(o===`^`||o===`,`){let n=s===o,r=o===`^`?`upper`:`lower`;a+=n?2:1;let i=e3(e,t,a),c=t.slice(a,i);return{operation:{type:`CaseModification`,direction:r,all:n,pattern:c?X.word([X.literal(c)]):null},endIndex:i}}return o===`@`&&/[QPaAEKkuUL]/.test(s)?{operation:{type:`Transform`,operator:s},endIndex:a+2}:{operation:null,endIndex:a}}function S3(e,t,n,r=!1){let i=n+1;if(i>=t.length)return{part:X.literal(`$`),endIndex:i};let a=t[i];if(a===`(`&&t[i+1]===`(`)return e.isDollarDparenSubshell(t,n)?e.parseCommandSubstitution(t,n):e.parseArithmeticExpansion(t,n);if(a===`[`){let n=1,r=i+1;for(;r0;)t[r]===`[`?n++:t[r]===`]`&&n--,n>0&&r++;if(n===0){let n=P4(e,t.slice(i+1,r));return{part:X.arithmeticExpansion(n),endIndex:r+1}}}return a===`(`?e.parseCommandSubstitution(t,n):a===`{`?rke(e,t,n,r):/[a-zA-Z_0-9@*#?$!-]/.test(a)?nke(e,t,n):{part:X.literal(`$`),endIndex:i}}function C3(e,t){let n=[],r=0,i=``,a=()=>{i&&=(n.push(X.literal(i)),``)};for(;r{a&&=(r.push(X.literal(a)),``)};for(;i=2&&t[0]===`"`&&t[t.length-1]===`"`){let n=t.slice(1,-1),r=!1;for(let e=0;e{p&&=(d.push(X.literal(p)),``)};for(;f`)&&t[f+1]===`(`&&!a&&!o){m();let{part:n,endIndex:r}=e.parseProcessSubstitutionFromString(t,f);d.push(n),f=r;continue}if(n===`~`){let n=f>0?t[f-1]:``;if(f===0&&u||n===`=`||i&&n===`:`){let n=LOe(e,t,f),r=t[n];if(r===void 0||r===`/`||r===`:`){m();let e=t.slice(f+1,n)||null;d.push({type:`TildeExpansion`,user:e}),f=n;continue}}}if(`@*+?!`.includes(n)&&f+1E4)throw new A4(`Input too large: ${e.length} bytes exceeds limit of ${E4}`,1,1);this._input=e,this.processLineState=void 0;let n=new SOe(e,t);if(this.tokens=n.tokenize(),this.tokens.length>D4)throw new A4(`Too many tokens: ${this.tokens.length} exceeds limit of ${D4}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseBudget.chargeTokens(this.tokens.length),this.parseScript()}finally{n?.()}}parseTokens(e){this.ownsParseBudget&&this.parseBudget.reset();let t=this.ownsParseBudget?void 0:this.enterDepth();try{return this.tokens=e,this.pos=0,this.pendingHeredocs=[],this.processLineState=void 0,this.parseBudget.chargeTokens(e.length),this.parseScript()}finally{t?.()}}current(){return this.tokens[this.pos]||this.tokens[this.tokens.length-1]}peek(e=0){return this.tokens[this.pos+e]||this.tokens[this.tokens.length-1]}advance(){let e=this.current();return this.post.currentPhysicalLine&&(t.currentPhysicalLine=e.line,t.currentLogicalLine+=1),t.currentLogicalLine):e.line}check(e,t,n,r,...i){let a=this.tokens[this.pos]?.type;return a===e||t!==void 0&&a===t||n!==void 0&&a===n||r!==void 0&&a===r||i.length>0&&i.includes(a)}expect(e,t){if(this.check(e))return this.advance();let n=this.current();throw new A4(t||`Expected ${e}, got ${n.type}`,n.line,n.column,n)}error(e){let t=this.current();throw new A4(e,t.line,t.column,t)}skipNewlines(){for(;this.check(Z.NEWLINE,Z.COMMENT);)this.check(Z.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(e=!0){for(;;){if(this.check(Z.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(Z.SEMICOLON,Z.COMMENT)){this.advance();continue}if(e&&this.check(Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(e,t,n,r){this.pendingHeredocs.push({redirect:e,delimiter:t,stripTabs:n,quoted:r})}processHeredocs(){for(let e of this.pendingHeredocs)if(this.check(Z.HEREDOC_CONTENT)){let t=this.advance(),n;n=e.quoted?X.word([X.literal(t.value)]):this.parseWordFromString(t.value,!1,!1,!1,!0),e.redirect.target=X.hereDoc(e.delimiter,n,e.stripTabs,e.quoted,t.heredocTerminated??!1)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(Z.EOF,Z.NEWLINE,Z.SEMICOLON,Z.AMP,Z.AND_AND,Z.OR_OR,Z.RPAREN,Z.RBRACE,Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND)}isCommandStart(){let e=this.current().type;return this.isWord()||e===Z.ASSIGNMENT_WORD||e===Z.FD_VARIABLE||e===Z.LPAREN||e===Z.LBRACE||e===Z.DPAREN_START||e===Z.DBRACK_START||i3(this)}parseScript(){let e=[],t=0;for(this.skipNewlines();!this.check(Z.EOF);){t++,t>1e4&&this.error(`Parser stuck: too many iterations (>10000)`);let n=this.checkUnexpectedToken();if(n){e.push(n),this.skipSeparators(!1);continue}let r=this.pos,i=this.parseStatement();i&&e.push(i),this.check(Z.HEREDOC_CONTENT)&&this.processHeredocs(),this.skipSeparators(!1),this.check(Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${this.current().value}'`),this.pos===r&&!this.check(Z.EOF)&&this.error(`syntax error near unexpected token \`${this.current().value}'`)}return X.script(e)}checkUnexpectedToken(){let e=this.current().type,t=this.current().value;if(this.currentTokenJoinsProcessSubstitution())return null;if((e===Z.DO||e===Z.DONE||e===Z.THEN||e===Z.ELSE||e===Z.ELIF||e===Z.FI||e===Z.ESAC)&&this.error(`syntax error near unexpected token \`${t}'`),e===Z.RBRACE||e===Z.RPAREN){let e=`syntax error near unexpected token \`${t}'`;return this.advance(),X.statement([X.pipeline([X.simpleCommand(null,[],[],[])])],[],!1,{message:e,token:t})}return(e===Z.DSEMI||e===Z.SEMI_AND||e===Z.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${t}'`),e===Z.SEMICOLON&&this.error(`syntax error near unexpected token \`${t}'`),(e===Z.AMP||e===Z.AND_AND||e===Z.OR_OR||e===Z.PIPE||e===Z.PIPE_AMP)&&this.error(`syntax error near unexpected token \`${t}'`),null}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let e=this.current().start,t=[],n=[],r=!1,i=this.parsePipeline();for(t.push(i);this.check(Z.AND_AND,Z.OR_OR);){let e=this.advance();n.push(e.type===Z.AND_AND?`&&`:`||`),this.skipNewlines();let r=this.parsePipeline();t.push(r)}this.check(Z.AMP)&&(this.advance(),r=!0);let a=this.pos>0?this.tokens[this.pos-1].end:e,o=this._input.slice(e,a);return X.statement(t,n,r,void 0,o)}parseTimePrefix(){if(!this.check(Z.TIME)||this.currentTokenJoinsProcessSubstitution())return;this.advance();let e=!1;return this.check(Z.WORD,Z.NAME)&&this.current().value===`-p`&&(this.advance(),e=!0),e}parsePipeline(){let e=!1,t=!1,n=0;for(;this.check(Z.BANG)&&!this.currentTokenJoinsProcessSubstitution();)this.advance(),n++;if(n===0){let r=this.parseTimePrefix();if(r!==void 0)for(e=!0,t=r;this.check(Z.BANG)&&!this.currentTokenJoinsProcessSubstitution();)this.advance(),n++}let r=n%2==1,i=[],a=[],o=this.parseCommand();for(i.push(o);this.check(Z.PIPE,Z.PIPE_AMP);){let e=this.advance();this.skipNewlines(),a.push(e.type===Z.PIPE_AMP);let t=this.parseCommand();i.push(t)}return X.pipeline(i,r,e,t,a.length>0?a:void 0)}parseCommand(){if(this.currentTokenJoinsProcessSubstitution())return o3(this);let e=this.current();switch(e.type){case Z.IF:return c3(this);case Z.FOR:return l3(this);case Z.WHILE:return u3(this);case Z.UNTIL:return d3(this);case Z.CASE:return f3(this);case Z.LPAREN:return p3(this);case Z.LBRACE:return m3(this);case Z.DPAREN_START:return this.dparenClosesWithSpacedParens()?this.parseNestedSubshellsFromDparen():this.parseArithmeticCommand();case Z.DBRACK_START:return this.parseConditionalCommand();case Z.FUNCTION:return this.parseFunctionDef();case Z.TIME:break;case Z.BANG:this.error(`syntax error near unexpected token \`${e.value}'`);break;default:S4(e.type)&&this.error(`syntax error near unexpected token \`${e.value}'`)}return this.check(Z.NAME,Z.WORD)&&this.peek(1).type===Z.LPAREN&&this.peek(2).type===Z.RPAREN?this.parseFunctionDef():o3(this)}dparenClosesWithSpacedParens(){let e=1,t=1;for(;tnew e(this.parseBudget),e=>this.error(e))}parseProcessSubstitutionFromString(t,n){return mOe(t,n,()=>new e(this.parseBudget),e=>this.error(e))}parseProcessSubstitution(){let e=this.advance();this.expect(Z.LPAREN);let t=this.processLineState,n=this.getSourceLine(e);this.processLineState={currentLogicalLine:n};let r;try{r=X.script(this.parseCompoundList())}finally{this.processLineState=t}return this.check(Z.EOF)&&this.error("unexpected EOF while looking for matching `)'"),this.expect(Z.RPAREN),X.processSubstitution(r,e.type===Z.LESS?`input`:`output`)}parseBacktickSubstitution(t,n,r=!1){return hOe(t,n,r,()=>new e(this.parseBudget),e=>this.error(e))}isDollarDparenSubshell(e,t){return dOe(e,t)}parseArithmeticExpansion(e,t){let n=t+3,r=1,i=0,a=n;for(;a0;)e[a]===`$`&&e[a+1]===`(`?e[a+2]===`(`?(r++,a+=3):(i++,a+=2):e[a]===`(`&&e[a+1]===`(`?(r++,a+=2):e[a]===`)`&&e[a+1]===`)`?i>0?(i--,a++):(r--,r>0&&(a+=2)):e[a]===`(`?(i++,a++):(e[a]===`)`&&i>0&&i--,a++);let o=e.slice(n,a),s=this.parseArithmeticExpression(o);return{part:X.arithmeticExpansion(s),endIndex:a+2}}parseArithmeticCommand(){let e=this.expect(Z.DPAREN_START),t=``,n=1,r=0,i=!1,a=!1;for(;n>0&&!this.check(Z.EOF);){if(i){if(i=!1,r>0){r--,t+=`)`;continue}if(this.check(Z.RPAREN)){n--,a=!0,this.advance();continue}if(this.check(Z.DPAREN_END)){n--,a=!0;continue}t+=`)`;continue}if(this.check(Z.DPAREN_START))n++,t+=`((`,this.advance();else if(this.check(Z.DPAREN_END))r>=2?(r-=2,t+=`))`,this.advance()):r===1?(r--,t+=`)`,i=!0,this.advance()):(n--,a=!0,n>0&&(t+=`))`),this.advance());else if(this.check(Z.LPAREN))r++,t+=`(`,this.advance();else if(this.check(Z.RPAREN))r>0&&r--,t+=`)`,this.advance();else{let e=this.current().value,n=t.length>0?t[t.length-1]:``;t.length>0&&!t.endsWith(` `)&&!(e===`=`&&/[|&^+\-*/%<>]$/.test(t))&&(e!==`<`||n!==`<`)&&(e!==`>`||n!==`>`)&&(t+=` `),t+=e,this.advance()}}a||this.expect(Z.DPAREN_END);let o=this.parseArithmeticExpression(t.trim()),s=this.parseOptionalRedirections();return X.arithmeticCommand(o,s,this.getSourceLine(e))}parseConditionalCommand(){let e=this.expect(Z.DBRACK_START),t=_3(this);this.expect(Z.DBRACK_END);let n=this.parseOptionalRedirections();return X.conditionalCommand(t,n,this.getSourceLine(e))}parseFunctionDef(){let e;if(this.check(Z.FUNCTION)){if(this.advance(),this.check(Z.NAME)||this.check(Z.WORD))e=this.advance().value;else{let e=this.current();throw new A4(`Expected function name`,e.line,e.column,e)}this.check(Z.LPAREN)&&(this.advance(),this.expect(Z.RPAREN))}else e=this.advance().value,e.includes(`$`)&&this.error(`\`${e}': not a valid identifier`),this.expect(Z.LPAREN),this.expect(Z.RPAREN);this.skipNewlines();let t=this.parseCompoundCommandBody({forFunctionBody:!0}),n=this.parseOptionalRedirections();return X.functionDef(e,t,n)}parseCompoundCommandBody(e){let t=e?.forFunctionBody;if(this.check(Z.LBRACE))return m3(this,{skipRedirections:t});if(this.check(Z.LPAREN))return p3(this,{skipRedirections:t});if(this.check(Z.IF))return c3(this,{skipRedirections:t});if(this.check(Z.FOR))return l3(this,{skipRedirections:t});if(this.check(Z.WHILE))return u3(this,{skipRedirections:t});if(this.check(Z.UNTIL))return d3(this,{skipRedirections:t});if(this.check(Z.CASE))return f3(this,{skipRedirections:t});this.error(`Expected compound command for function body`)}parseCompoundList(){let e=this.enterDepth();try{let e=[];for(this.skipNewlines();(this.currentTokenJoinsProcessSubstitution()||!this.check(Z.EOF,Z.FI,Z.ELSE,Z.ELIF,Z.THEN,Z.DO,Z.DONE,Z.ESAC,Z.RPAREN,Z.RBRACE,Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND))&&this.isCommandStart();){this.checkIterationLimit();let t=this.pos,n=this.parseStatement();if(n&&e.push(n),this.skipSeparators(),this.pos===t&&!n)break}return e}finally{e()}}parseOptionalRedirections(){let e=[];for(;i3(this);){this.checkIterationLimit();let t=this.pos;if(e.push(a3(this)),this.pos===t)break}return e}parseArithmeticExpression(e){return P4(this,e)}};function E3(e,t){return new T3().parse(e,t)}function ake(e){return D3(e)}function D3(e){return e.statements.map(O3).join(` `)}function O3(e){let t=[];for(let n=0;n0?`${t.join(` `)} `:``)+n.join(` `)}function k3(e){switch(e.type){case`SimpleCommand`:return ske(e);case`If`:return gke(e);case`For`:return _ke(e);case`CStyleFor`:return vke(e);case`While`:return yke(e);case`Until`:return bke(e);case`Case`:return xke(e);case`Subshell`:return Cke(e);case`Group`:return wke(e);case`ArithmeticCommand`:return Tke(e);case`ConditionalCommand`:return Eke(e);case`FunctionDef`:return Dke(e);default:throw Error(`Unsupported command type: ${e.type}`)}}function ske(e){let t=[];for(let n of e.assignments)t.push(cke(n));e.name&&t.push(A3(e.name));for(let n of e.args)t.push(A3(n));for(let n of e.redirections)t.push(F3(n));return t.join(` `)}function cke(e){let t=e.append?`+=`:`=`;if(e.array){let n=e.array.map(A3).join(` `);return`${e.name}${t}(${n})`}return e.value?`${e.name}${t}${A3(e.value)}`:`${e.name}${t}`}function A3(e){return e.parts.map(e=>M3(e,!1)).join(``)}function j3(e){return e.parts.map(e=>M3(e,!0)).join(``)}function M3(e,t){switch(e.type){case`Literal`:return t?uke(e.value):lke(e.value);case`SingleQuoted`:return`'${e.value}'`;case`DoubleQuoted`:return`"${e.parts.map(e=>M3(e,!0)).join(``)}"`;case`Escaped`:return`\\${e.value}`;case`ParameterExpansion`:return N3(e);case`CommandSubstitution`:return e.legacy?`\`${D3(e.body)}\``:`$(${D3(e.body)})`;case`ArithmeticExpansion`:return`$((${R3(e.expression.expression)}))`;case`ProcessSubstitution`:return e.direction===`input`?`<(${D3(e.body)})`:`>(${D3(e.body)})`;case`BraceExpansion`:return mke(e);case`TildeExpansion`:return e.user===null?`~`:`~${e.user}`;case`Glob`:return e.pattern;default:throw Error(`Unsupported word part type: ${e.type}`)}}function lke(e){return e.replace(/[\s\\'"`!|&;()<>{}[\]*?~#]/g,`\\$&`)}function uke(e){return e.replace(/[$`"\\]/g,`\\$&`)}function dke(e,t){return e.parts.map(e=>fke(e,t)).join(``)}function fke(e,t){switch(e.type){case`Literal`:return t?e.value:e.value.replace(/[$`]/g,`\\$&`);case`Escaped`:return`\\${e.value}`;case`ParameterExpansion`:return N3(e);case`CommandSubstitution`:return e.legacy?`\`${D3(e.body)}\``:`$(${D3(e.body)})`;case`ArithmeticExpansion`:return`$((${R3(e.expression.expression)}))`;default:return M3(e,!1)}}function N3(e){return e.operation?`\${${P3(e.parameter,e.operation)}}`:pke(e.parameter)?`\${${e.parameter}}`:`$${e.parameter}`}function pke(e){return!(/^[?#@*$!\-0-9]$/.test(e)||/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e))}function P3(e,t){switch(t.type){case`Length`:return`#${e}`;case`LengthSliceError`:return`#${e}:`;case`BadSubstitution`:return t.text;case`DefaultValue`:return`${e}${t.checkEmpty?`:`:``}-${j3(t.word)}`;case`AssignDefault`:return`${e}${t.checkEmpty?`:`:``}=${j3(t.word)}`;case`ErrorIfUnset`:return`${e}${t.checkEmpty?`:`:``}?${t.word?j3(t.word):``}`;case`UseAlternative`:return`${e}${t.checkEmpty?`:`:``}+${j3(t.word)}`;case`Substring`:{let n=R3(t.offset.expression);return t.length?`${e}:${n}:${R3(t.length.expression)}`:`${e}:${n}`}case`PatternRemoval`:{let n=t.side===`prefix`?`#`:`%`;return`${e}${t.greedy?`${n}${n}`:n}${j3(t.pattern)}`}case`PatternReplacement`:{let n=`/`;t.all?n=`//`:t.anchor===`start`?n=`/#`:t.anchor===`end`&&(n=`/%`);let r=t.replacement?`/${j3(t.replacement)}`:``;return`${e}${n}${j3(t.pattern)}${r}`}case`CaseModification`:{let n=t.direction===`upper`?`^`:`,`;return`${e}${t.all?`${n}${n}`:n}${t.pattern?j3(t.pattern):``}`}case`Transform`:return`${e}@${t.operator}`;case`Indirection`:return t.innerOp?`!${P3(e,t.innerOp)}`:`!${e}`;case`ArrayKeys`:return`!${t.array}[${t.star?`*`:`@`}]`;case`VarNamePrefix`:return`!${t.prefix}${t.star?`*`:`@`}`;default:throw Error(`Unsupported parameter operation type: ${t.type}`)}}function mke(e){return`{${e.items.map(hke).join(`,`)}}`}function hke(e){if(e.type===`Word`)return A3(e.word);let t=e.startStr??String(e.start),n=e.endStr??String(e.end);return e.step===void 0?`${t}..${n}`:`${t}..${n}..${e.step}`}function F3(e){let t=e.fdVariable?`{${e.fdVariable}}`:e.fd===null?``:String(e.fd);if(e.operator===`<<`||e.operator===`<<-`){let n=e.target;if(n.terminated===!1)throw Error(`Cannot serialize an unterminated here-document`);let r=n.quoted?`'${n.delimiter}'`:n.delimiter,i=dke(n.content,n.quoted);return`${t}${e.operator}${r} ${i}${n.delimiter}`}return e.operator===`<<<`?`${t}<<< ${A3(e.target)}`:e.operator===`&>`||e.operator===`&>>`?`${e.operator} ${A3(e.target)}`:`${t}${e.operator} ${A3(e.target)}`}function I3(e){return e.length===0?``:` ${e.map(F3).join(` `)}`}function L3(e){return e.map(O3).join(` `)}function gke(e){let t=[];for(let n=0;nn-r.value)throw new H(`alias expansion exceeds string length limit (${n} bytes)`,`string_length`);return r.value+=i,e+t}function V3(e){return e.parts.length===1&&e.parts[0].type===`Literal`}function H3(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type===`Literal`?t.value:null}function U3(e,t){return e.env.get(`${Oke}${t}`)}function kke(e,t,n){return W3(e,t,n)}function W3(e,t,n,r=!0){if(!t.name||!V3(t.name))return t;let i=H3(t.name);if(!i)return t;let a=U3(e,i);if(!a||n.has(i))return t;try{n.add(i);let o=new T3,s={value:0},c=B3(``,a,e.limits.maxStringLength,s),l=a.endsWith(` `);if(!l)for(let n of t.args){let t=A3(n);c=B3(c,` ${t}`,e.limits.maxStringLength,s)}let u;try{u=o.parse(c)}catch(e){if(e instanceof A4)throw e;return t}if(u.statements.length!==1||u.statements[0].pipelines.length!==1||u.statements[0].pipelines[0].commands.length!==1)return G3(e,t,a);let d=u.statements[0].pipelines[0].commands[0];if(d.type!==`SimpleCommand`)return G3(e,t,a);let f={...d,assignments:[...t.assignments,...d.assignments],redirections:[...d.redirections,...t.redirections],line:t.line};if(l&&t.args.length>0){f={...f,args:[...f.args,...t.args]};let i=1;for(;r&&f.args.length>0;){let t=f.args[0];if(!V3(t))break;let r=H3(t),a=r?U3(e,r):null;if(!a)break;if(i>=e.limits.maxCallDepth)throw new H(`alias expansion depth limit exceeded (${e.limits.maxCallDepth})`,`recursion`);i++;let o={type:`SimpleCommand`,name:t,args:f.args.slice(1),assignments:[],redirections:[]},s=W3(e,o,n,!1);if(s===o||(f={...f,name:s.name,args:[...s.args]},!a.endsWith(` `)))break}}return f}catch(e){throw n.delete(i),e}}function G3(e,t,n){let r={value:0},i=B3(``,n,e.limits.maxStringLength,r);for(let n of t.args){let t=A3(n);i=B3(i,` ${t}`,e.limits.maxStringLength,r)}let a=new T3,o=a.parseWordFromString(`eval`,!1,!1),s=0;for(let e of i)e===`'`&&s++;if(r.value+2+s*3>e.limits.maxStringLength)throw new H(`alias expansion exceeds string length limit (${e.limits.maxStringLength} bytes)`,`string_length`);return{type:`SimpleCommand`,name:o,args:[a.parseWordFromString(`'${i.replace(/'/g,`'\\''`)}'`,!1,!1)],assignments:t.assignments,redirections:t.redirections,line:t.line}}U(),U(),bG(),dV(),bG();var Ake=new Map([[`alnum`,`a-zA-Z0-9`],[`alpha`,`a-zA-Z`],[`ascii`,`\\x00-\\x7F`],[`blank`,` \\t`],[`cntrl`,`\\x00-\\x1F\\x7F`],[`digit`,`0-9`],[`graph`,`!-~`],[`lower`,`a-z`],[`print`,` -~`],[`punct`,"!-/:-@\\[-`{-~"],[`space`,` \\t\\n\\r\\f\\v`],[`upper`,`A-Z`],[`word`,`a-zA-Z0-9_`],[`xdigit`,`0-9a-fA-F`]]);function K3(e){return Ake.get(e)??``}function jke(e){let t=[],n=``,r=0;for(;r0;){let t=e[r];if(t===`\\`){r+=2;continue}if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r;r++}return-1}function J3(e){let t=[],n=``,r=0,i=!1,a=0;for(;athis.maxOps)throw new H(`Glob operation limit exceeded (${this.maxOps})`,`glob_operations`);this.consumeOperation?.()}hasNullglob(){return this.nullglob}hasFailglob(){return this.failglob}filterGlobignore(e){return!this.hasGlobignore&&!this.globskipdots?e:e.filter(e=>{let t=e.split(`/`).pop()||e;if((this.hasGlobignore||this.globskipdots)&&(t===`.`||t===`..`))return!1;if(this.hasGlobignore){for(let t of this.globignorePatterns)if(this.matchGlobignorePattern(e,t))return!1}return!0})}matchGlobignorePattern(e,t){return Mke(t).test(e)}isGlobPattern(e){return!!(e.includes(`*`)||e.includes(`?`)||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandArgs(e,t){let n=e.map((e,n)=>(t?.[n]??!1)||!this.isGlobPattern(e)?null:this.expand(e)),r=await Promise.all(n.map(e=>e||Promise.resolve(null))),i=[];for(let t=0;t0?i.push(...n):i.push(e[t])}return i}async expand(e){if(this.globstar){let t=e.split(`/`),n=0;for(let e of t)if(e===`**`&&(n++,n>Y3))throw new H(`Glob pattern has too many ** segments (max ${Y3})`,`glob_operations`)}let t;if(e.includes(`**`)&&this.globstar&&this.isGlobstarValid(e))t=await this.expandRecursive(e);else{let n=e.replace(/\*\*+/g,`*`);t=await this.expandSimple(n)}return this.filterGlobignore(t)}isGlobstarValid(e){let t=e.split(`/`);for(let e of t)if(e.includes(`**`)&&e!==`**`)return!1;return!0}hasGlobChars(e){return!!(e.includes(`*`)||e.includes(`?`)||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandSimple(e){let t=e.startsWith(`/`),n=e.split(`/`).filter(e=>e!==``),r=-1;for(let e=0;ee.name===`.`),t=n.some(e=>e.name===`..`);e||s.push({name:`.`,isFile:!1,isDirectory:!0,isSymbolicLink:!1}),t||s.push({name:`..`,isFile:!1,isDirectory:!0,isSymbolicLink:!1})}for(let n of s)if((!n.name.startsWith(`.`)||r.startsWith(`.`)||c)&&this.matchPattern(n.name,r)){let r=e===`/`?`/${n.name}`:`${e}/${n.name}`,a;a=t===``?n.name:t===`/`?`/${n.name}`:`${t}/${n.name}`,i.length===0?o.push(Promise.resolve([a])):n.isDirectory&&o.push(this.expandSegments(r,a,i))}let l=await Promise.all(o);for(let e of l)a.push(...e)}else{this.checkOpsLimit();let n=await this.fs.readdir(e),o=[],s=[...n],c=this.dotglob||this.hasGlobignore;(r.startsWith(`.`)||this.dotglob)&&(n.includes(`.`)||s.push(`.`),n.includes(`..`)||s.push(`..`));for(let n of s)if((!n.startsWith(`.`)||r.startsWith(`.`)||c)&&this.matchPattern(n,r)){let r=e===`/`?`/${n}`:`${e}/${n}`,a;a=t===``?n:t===`/`?`/${n}`:`${t}/${n}`,i.length===0?o.push(Promise.resolve([a])):o.push((async()=>{try{if(this.checkOpsLimit(),(await this.fs.stat(r)).isDirectory)return this.expandSegments(r,a,i)}catch(e){if(e instanceof H)throw e}return[]})())}let l=await Promise.all(o);for(let e of l)a.push(...e)}}catch(e){if(e instanceof H)throw e}return a}async expandRecursive(e){let t=[],n=e.indexOf(`**`),r=e.slice(0,n).replace(/\/$/,``)||`.`,i=e.slice(n+2).replace(/^\//,``);return i.includes(`**`)&&this.isGlobstarValid(i)?(await this.walkDirectoryMultiGlobstar(r,i,t),[...new Set(t)].sort()):(await this.walkDirectory(r,i,t),t.sort())}async walkDirectoryMultiGlobstar(e,t,n){this.checkOpsLimit();let r=this.fs.resolvePath(this.cwd,e);try{this.checkOpsLimit();let i=this.fs.readdirWithFileTypes?await this.fs.readdirWithFileTypes(r):null;if(i){let r=[];for(let t of i){let n=e===`.`?t.name:`${e}/${t.name}`;t.isDirectory&&r.push(n)}let a=e===`.`?t:`${e}/${t}`,o=await this.expandRecursive(a);n.push(...o);for(let e=0;ethis.walkDirectoryMultiGlobstar(e,t,n)))}}else{this.checkOpsLimit();let i=await this.fs.readdir(r),a=[];for(let t of i){let n=e===`.`?t:`${e}/${t}`,r=this.fs.resolvePath(this.cwd,n);try{this.checkOpsLimit(),(await this.fs.stat(r)).isDirectory&&a.push(n)}catch(e){if(e instanceof H)throw e}}let o=e===`.`?t:`${e}/${t}`,s=await this.expandRecursive(o);n.push(...s);for(let e=0;ethis.walkDirectoryMultiGlobstar(e,t,n)))}}}catch(e){if(e instanceof H)throw e}}async walkDirectory(e,t,n){this.checkOpsLimit();let r=this.fs.resolvePath(this.cwd,e);try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let i=await this.fs.readdirWithFileTypes(r),a=[],o=[];for(let n of i){let r=e===`.`?n.name:`${e}/${n.name}`;n.isDirectory?o.push(r):t&&this.matchPattern(n.name,t)&&a.push(r)}n.push(...a);for(let e=0;ethis.walkDirectory(e,t,n)))}}else{this.checkOpsLimit();let i=await this.fs.readdir(r),a=[];for(let t=0;t{let n=e===`.`?t:`${e}/${t}`,r=this.fs.resolvePath(this.cwd,n);try{return this.checkOpsLimit(),{name:t,path:n,isDirectory:(await this.fs.stat(r)).isDirectory}}catch(e){if(e instanceof H)throw e;return null}}));a.push(...r.filter(e=>e!==null))}for(let e of a)!e.isDirectory&&t&&this.matchPattern(e.name,t)&&n.push(e.path);let o=a.filter(e=>e.isDirectory);for(let e=0;ethis.walkDirectory(e.path,t,n)))}}}catch(e){if(e instanceof H)throw e}}matchPattern(e,t){return this.patternToRegex(t).test(e)}patternToRegex(e){return hG(`^${this.patternToRegexStr(e)}$`)}patternToRegexStr(e){let t=``,n=!1;for(let r=0;rthis.patternToRegexStr(e)),s=o.length>0?o.join(`|`):`(?:)`;if(i===`@`)t+=`(?:${s})`;else if(i===`*`)t+=`(?:${s})*`;else if(i===`+`)t+=`(?:${s})+`;else if(i===`?`)t+=`(?:${s})?`;else if(i===`!`){if(nthis.computePatternLength(e));if(e.every(e=>e!==null)&&e.every(t=>t===e[0])&&e[0]!==null){let n=e[0];if(n===0)t+=`(?:.+)`;else{let e=[];n>0&&e.push(`.{0,${n-1}}`),e.push(`.{${n+1},}`),e.push(`(?!(?:${s})).{${n}}`),t+=`(?:${e.join(`|`)})`}}else t+=`(?:(?!(?:${s})).)*?`}else t+=`(?!(?:${s})$).*`}r=n;continue}}if(i===`*`)t+=`.*`;else if(i===`?`)t+=`.`;else if(i===`[`){let n=r+1,i=`[`;nthis.computePatternLength(e));if(i.every(e=>e!==null)&&i.every(e=>e===i[0])){t+=i[0],n=r+1;continue}return null}return null}}if(i===`*`)return null;if(i===`?`){t+=1,n++;continue}if(i===`[`){let r=e.indexOf(`]`,n+1);if(r!==-1){t+=1,n=r+1;continue}t+=1,n++;continue}if(i===`\\`){t+=1,n+=2;continue}t+=1,n++}return t}};U();function Z3(e){for(let t=0;t=t)throw new H(`array element limit exceeded (${t})`,`array_elements`)}function e6(e,t,n,r,i){$3(e.length,i),$3(t.length,i),e.push(n),t.push(r)}function t6(e){return e.get(`IFS`)??Fke}function n6(e){return e.get(`IFS`)===``}function r6(e){let t=t6(e);if(t===``)return!0;for(let e of t)if(e!==` `&&e!==` `&&e!==` `)return!1;return!0}function Ike(e){let t=!1,n=[];for(let r of e.split(``))r===`-`?t=!0:/[\\^$.*+?()[\]{}|]/.test(r)?n.push(`\\${r}`):r===` `?n.push(`\\t`):r===` `?n.push(`\\n`):n.push(r);return t&&n.push(`\\-`),n.join(``)}function i6(e){let t=e.get(`IFS`);return t===void 0?` `:t[0]||``}var Lke=` `;function Rke(e){return Lke.includes(e)}function a6(e){let t=new Set,n=new Set;for(let r of e)Rke(r)?t.add(r):n.add(r);return{whitespace:t,nonWhitespace:n}}function o6(e,t,n,r,i){if(t===``)return e===``?{words:[],wordStarts:[]}:($3(0,n),{words:[e],wordStarts:[0]});let{whitespace:a,nonWhitespace:o}=a6(t),s=[],c=[],l=0;for(;l=e.length)return{words:[],wordStarts:[]};if(o.has(e[l]))for(e6(s,c,``,l,n),l++;l=r);){let t=l;for(;l=e.length)break;for(;l=r);)for(e6(s,c,``,l,n),l++;ll&&(s=!0),o>=e.length)return{words:[],hadLeadingDelimiter:!0,hadTrailingDelimiter:!0};if(i.has(e[o]))for($3(a.length,n),a.push(``),o++;o=e.length){c=!1;break}let s=o;for(;o=e.length&&o>s&&(c=!0)}return{words:a,hadLeadingDelimiter:s,hadTrailingDelimiter:c}}function c6(e,t,n){return s6(e,t,n).words}function zke(e,t){for(let n of e)if(t.has(n))return!0;return!1}function Bke(e,t,n){if(t===``)return e;let{whitespace:r,nonWhitespace:i}=a6(t),a=e.length;for(;a>0&&r.has(e[a-1]);){if(!n&&a>=2){let t=0,n=a-2;for(;n>=0&&e[n]===`\\`;)t++,n--;if(t%2==1)break}a--}let o=e.substring(0,a);if(o.length>=1&&i.has(o[o.length-1])){if(!n&&o.length>=2){let e=0,t=o.length-2;for(;t>=0&&o[t]===`\\`;)e++,t--;if(e%2==1)return o}let e=o.substring(0,o.length-1);if(!zke(e,i))return e}return o}function l6(e,t){return e.state.namerefs?.has(t)??!1}function u6(e,t){e.state.namerefs??=new Set,e.state.namerefs.add(t)}function Vke(e,t){e.state.namerefs?.delete(t),e.state.boundNamerefs?.delete(t),e.state.invalidNamerefs?.delete(t)}function Hke(e,t){e.state.invalidNamerefs??=new Set,e.state.invalidNamerefs.add(t)}function d6(e,t){return e.state.invalidNamerefs?.has(t)??!1}function f6(e,t){e.state.boundNamerefs??=new Set,e.state.boundNamerefs.add(t)}function p6(e,t){let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let t=n[1],r=t4(e,t),i=e.state.associativeArrays?.has(t)??!1;return r||i}return t4(e,t)?!0:e.state.env.has(t)}function m6(e,t,n=100){if(!l6(e,t)||d6(e,t))return t;let r=new Set,i=t;for(;n-->0;){if(r.has(i))return;if(r.add(i),!l6(e,i))return i;let t=e.state.env.get(i);if(t===void 0||t===``||!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(t))return i;i=t}}function h6(e,t){if(l6(e,t))return e.state.env.get(t)}function g6(e,t,n,r=100){if(!l6(e,t)||d6(e,t))return t;let i=new Set,a=t;for(;r-->0;){if(i.has(a))return;if(i.add(a),!l6(e,a))return a;let t=e.state.env.get(a);if(t===void 0||t===``)return n===void 0||/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)&&p6(e,n)?a:null;if(!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(t))return a;a=t}}function _6(e,t){let n=t.replace(/\$\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g,(t,n)=>e.state.env.get(n)??``);return n=n.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(t,n)=>e.state.env.get(n)??``),n}function v6(e,t){return t===`FUNCNAME`?(e.state.funcNameStack??[]).map((e,t)=>[t,e]):t===`BASH_LINENO`?(e.state.callLineStack??[]).map((e,t)=>[t,String(e)]):t===`BASH_SOURCE`?(e.state.sourceStack??[]).map((e,t)=>[t,e]):e.state.associativeArrays?.has(t)?u4(e,t).map(n=>[n,n4(e,t,n)??``]):c4(e,t).map(n=>[n,n4(e,t,n)??``])}function y6(e,t){return t===`FUNCNAME`?(e.state.funcNameStack?.length??0)>0:t===`BASH_LINENO`?(e.state.callLineStack?.length??0)>0:t===`BASH_SOURCE`?(e.state.sourceStack?.length??0)>0:(e.state.associativeArrays?.has(t),t4(e,t))}async function b6(e,t,n=!0,r=!1){switch(t){case`?`:return String(e.state.lastExitCode);case`$`:return String(e.state.virtualPid);case`#`:return e.state.env.get(`#`)||`0`;case`@`:return e.state.env.get(`@`)||``;case`_`:return e.state.lastArg;case`-`:{let t=``;return t+=`h`,e.state.options.errexit&&(t+=`e`),e.state.options.noglob&&(t+=`f`),e.state.options.nounset&&(t+=`u`),e.state.options.verbose&&(t+=`v`),e.state.options.xtrace&&(t+=`x`),t+=`B`,e.state.options.noclobber&&(t+=`C`),t+=`s`,t}case`*`:{let t=Number.parseInt(e.state.env.get(`#`)||`0`,10);if(t===0)return``;let n=[];for(let r=1;r<=t;r++)n.push(e.state.env.get(String(r))||``);return n.join(i6(e.state.env))}case`0`:return e.state.env.get(`0`)||`bash`;case`PWD`:return e.state.env.get(`PWD`)??``;case`OLDPWD`:return e.state.env.get(`OLDPWD`)??``;case`PPID`:return String(e.state.virtualPpid);case`UID`:return String(e.state.virtualUid);case`EUID`:return String(e.state.virtualUid);case`RANDOM`:return String(Math.floor(Math.random()*32768));case`SECONDS`:return String(Math.floor((Date.now()-e.state.startTime)/1e3));case`BASH_VERSION`:return eOe;case`!`:return String(e.state.lastBackgroundPid);case`BASHPID`:return String(e.state.bashPid);case`LINENO`:return String(e.state.currentLine);case`FUNCNAME`:{let t=e.state.funcNameStack?.[0];if(t!==void 0)return t;if(n&&e.state.options.nounset)throw new LB(`FUNCNAME`);return``}case`BASH_LINENO`:{let t=e.state.callLineStack?.[0];if(t!==void 0)return String(t);if(n&&e.state.options.nounset)throw new LB(`BASH_LINENO`);return``}case`BASH_SOURCE`:{let t=e.state.sourceStack?.[0];if(t!==void 0)return t;if(n&&e.state.options.nounset)throw new LB(`BASH_SOURCE`);return``}}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[\]$/.test(t))throw new BB(`\${${t}}`);let i=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(i){let t=i[1],r=i[2];if(l6(e,t)){let n=m6(e,t);if(n&&n!==t){if(n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return``;t=n}}if(r===`@`||r===`*`){let n=v6(e,t);if(n.length>0)return n.map(([,e])=>e).join(` `);let r=e.state.env.get(t);return r===void 0?``:r}if(t===`FUNCNAME`){let t=Number.parseInt(r,10);return!Number.isNaN(t)&&t>=0?e.state.funcNameStack?.[t]??``:``}if(t===`BASH_LINENO`){let t=Number.parseInt(r,10);if(!Number.isNaN(t)&&t>=0){let n=e.state.callLineStack?.[t];return n===void 0?``:String(n)}return``}if(t===`BASH_SOURCE`){let t=Number.parseInt(r,10);return!Number.isNaN(t)&&t>=0?e.state.sourceStack?.[t]??``:``}if(e.state.associativeArrays?.has(t)){let i=d4(r);i=_6(e,i);let a=n4(e,t,i);if(a===void 0&&n&&e.state.options.nounset)throw new LB(`${t}[${r}]`);return a||``}let a;if(/^-?\d+$/.test(r))a=Number.parseInt(r,10);else try{a=await N8(e,P4(new T3,r).expression)}catch{let t=e.state.env.get(r);a=t?Number.parseInt(t,10):0,Number.isNaN(a)&&(a=0)}if(a<0){let n=v6(e,t),r=e.state.currentLine;if(n.length===0)return e.state.expansionStderr=(e.state.expansionStderr||``)+`bash: line ${r}: ${t}: bad array subscript `,``;let i=Math.max(...n.map(([e])=>typeof e==`number`?e:0))+1+a;return i<0?(e.state.expansionStderr=(e.state.expansionStderr||``)+`bash: line ${r}: ${t}: bad array subscript `,``):n4(e,t,i)||``}let o=n4(e,t,a);if(o!==void 0)return o;if(a===0){let n=e.state.env.get(t);if(n!==void 0)return n}if(n&&e.state.options.nounset)throw new LB(`${t}[${a}]`);return``}if(/^[1-9][0-9]*$/.test(t)){let r=e.state.env.get(t);if(r===void 0&&n&&e.state.options.nounset)throw new LB(t);return r||``}if(l6(e,t)){let i=m6(e,t);if(i===void 0)return``;if(i!==t)return await b6(e,i,n,r);let a=e.state.env.get(t);if((a===void 0||a===``)&&n&&e.state.options.nounset)throw new LB(t);return a||``}let a=e.state.env.get(t);if(a!==void 0)return e.state.tempEnvBindings?.some(e=>e.has(t))&&(e.state.accessedTempEnvVars=e.state.accessedTempEnvVars||new Set,e.state.accessedTempEnvVars.add(t)),a;if(y6(e,t)){let r=n4(e,t,0);if(r!==void 0)return r;if(n&&e.state.options.nounset)throw new LB(t);return``}if(n&&e.state.options.nounset)throw new LB(t);return``}async function x6(e,t){if(new Set([`?`,`$`,`#`,`_`,`-`,`0`,`PPID`,`UID`,`EUID`,`RANDOM`,`SECONDS`,`BASH_VERSION`,`!`,`BASHPID`,`LINENO`]).has(t))return!0;if(t===`@`||t===`*`)return Number.parseInt(e.state.env.get(`#`)||`0`,10)>0;if(t===`PWD`||t===`OLDPWD`)return e.state.env.has(t);let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let t=n[1],r=n[2];if(l6(e,t)){let n=m6(e,t);if(n&&n!==t){if(n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return!1;t=n}}if(r===`@`||r===`*`)return v6(e,t).length>0||e.state.env.has(t);if(e.state.associativeArrays?.has(t)){let n=_6(e,d4(r));return r4(e,t,n)}let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else try{i=await N8(e,P4(new T3,r).expression)}catch{let t=e.state.env.get(r);i=t?Number.parseInt(t,10):0,Number.isNaN(i)&&(i=0)}if(i<0){let n=v6(e,t);if(n.length===0)return!1;let r=Math.max(...n.map(([e])=>typeof e==`number`?e:0))+1+i;return r<0?!1:r4(e,t,r)}return r4(e,t,i)}if(l6(e,t)){let n=m6(e,t);return n===void 0||n===t?e.state.env.has(t):x6(e,n)}return e.state.env.has(t)?!0:y6(e,t)?r4(e,t,0):!1}async function Uke(e,t){let n=``,r=0;for(;r0;)t[i]===`{`?e++:t[i]===`}`&&e--,i++;n+=t.slice(r,i),r=i;continue}if(t[r+1]===`(`){let e=1,i=r+2;for(;i0;)t[i]===`(`?e++:t[i]===`)`&&e--,i++;n+=t.slice(r,i),r=i;continue}if(/[a-zA-Z_]/.test(t[r+1]||``)){let i=r+1;for(;i0;)n[r]===`(`&&n[r-1]===`$`||n[r]===`(`?t++:n[r]===`)`&&t--,r++;let i=n.slice(o+2,r-1);if(e.execFn){let t=await e.execFn(i,{signal:e.state.signal});a+=t.stdout.replace(/\n+$/,``),t.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+t.stderr)}o=r}else if(n[o+1]===`{`){let t=1,r=o+2;for(;r0;)n[r]===`{`?t++:n[r]===`}`&&t--,r++;let i=await b6(e,n.slice(o+2,r-1));a+=i,o=r}else if(/[a-zA-Z_]/.test(n[o+1]||``)){let t=o+1;for(;t=n.maxResults)return!1;let i=V(t);if(i>n.maxStringBytes-r.value)throw new H(`brace expansion string limit exceeded (${n.maxStringBytes} bytes)`,`string_length`);return e.push(t),r.value+=i,!0}function Wke(e,t,n,r,i,a=w6){let o=n??1;o===0&&(o=1);let s=Math.abs(o),c=[],l=0;if(r?.match(/^-?0\d/)&&(l=Math.max(l,r.replace(/^-/,``).length)),i?.match(/^-?0\d/)&&(l=Math.max(l,i.replace(/^-/,``).length)),l>a.maxStringBytes)throw new H(`brace expansion padding limit exceeded (${a.maxStringBytes} bytes)`,`string_length`);let u={value:0},d=e=>{if(l>0){let t=e<0,n=String(Math.abs(e)).padStart(l,`0`);return t?`-${n}`:n}return String(e)};if(e<=t)for(let n=e,r=0;n<=t&&r=t&&r=`A`&&e<=`Z`&&t>=`a`&&t<=`z`||e>=`a`&&e<=`z`&&t>=`A`&&t<=`Z`){let r=n===void 0?``:`..${n}`;throw new HB(`{${e}..${t}${r}}: invalid sequence`)}let c=[],l={value:0};if(a<=o)for(let e=a,t=0;e<=o&&t=o&&tM6(e,t,n)),c=s.length>0?s.join(`|`):`(?:)`;a===`@`?r+=`(?:${c})`:a===`*`?r+=`(?:${c})*`:a===`+`?r+=`(?:${c})+`:a===`?`?r+=`(?:${c})?`:a===`!`&&(r+=`(?!(?:${c})$).*`),i=o+1;continue}}if(a===`\\`){if(i+10;){let t=e[r];if(t===`\\`){r+=2;continue}if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r;r++}return-1}function Jke(e){let t=[],n=``,r=0,i=0;for(;i0&&nnew H(`pattern replacement: string length limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`));n.lastIndex=0;let o=0,s=n.exec(t);for(;s!==null&&(e.executionScope.consumeLimited(`pattern_operations`,1,e.limits.maxGlobOperations,`pattern replacement`),!(i&&s[0].length===0&&s.index===t.length||(a.append(t.slice(o,s.index)),a.append(r),o=s.index+s[0].length,!i)));)s[0].length===0&&(o++,n.lastIndex<=s.index&&(n.lastIndex=s.index+1)),s=n.exec(t);return a.append(t.slice(o)),n.lastIndex=0,a.build()}ZB(),U();function I6(e){let t=[],n=0;return{append(r){let i=V(r);if(i>e-n)throw new H(`prompt expansion exceeds string length limit (${e} bytes)`,`string_length`);r&&t.push(r),n+=i},build:()=>t.join(``)}}function $ke(e,t,n){let r=(e,t=2)=>String(e).padStart(t,`0`);if(e===``)return`${r(t.getHours())}:${r(t.getMinutes())}:${r(t.getSeconds())}`;let i=I6(n),a=0;for(;a=e.length){i.append(`%`),a++;continue}let n=e[a+1];switch(n){case`H`:i.append(r(t.getHours()));break;case`M`:i.append(r(t.getMinutes()));break;case`S`:i.append(r(t.getSeconds()));break;case`d`:i.append(r(t.getDate()));break;case`m`:i.append(r(t.getMonth()+1));break;case`Y`:i.append(String(t.getFullYear()));break;case`y`:i.append(r(t.getFullYear()%100));break;case`I`:{let e=t.getHours()%12;e===0&&(e=12),i.append(r(e));break}case`p`:i.append(t.getHours()<12?`AM`:`PM`);break;case`P`:i.append(t.getHours()<12?`am`:`pm`);break;case`%`:i.append(`%`);break;case`a`:i.append([`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`][t.getDay()]);break;case`b`:i.append([`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][t.getMonth()]);break;default:i.append(`%${n}`)}a+=2}else i.append(e[a]),a++;return i.build()}function L6(e,t){let n=I6(e.limits.maxStringLength),r=0,i=e.state.env.get(`USER`)||e.state.env.get(`LOGNAME`)||`user`,a=e.state.env.get(`HOSTNAME`)||`localhost`,o=a.split(`.`)[0],s=e.state.env.get(`PWD`)||`/`,c=e.state.env.get(`HOME`)||`/`,l=s.startsWith(c)?`~${s.slice(c.length)}`:s,u=s.split(`/`).pop()||s,d=new Date,f=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],p=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],m=e.state.env.get(`__COMMAND_NUMBER`)||`1`;for(;r=t.length){n.append(`\\`),r++;continue}let s=t[r+1];if(s>=`0`&&s<=`7`){let e=``,i=r+1;for(;i=`0`&&t[i]<=`7`;)e+=t[i],i++;let a=Number.parseInt(e,8)%256;n.append(String.fromCharCode(a)),r=i;continue}switch(s){case`\\`:n.append(`\\`),r+=2;break;case`a`:n.append(`\x07`),r+=2;break;case`e`:n.append(`\x1B`),r+=2;break;case`n`:n.append(` `),r+=2;break;case`r`:n.append(`\r`),r+=2;break;case`$`:n.append(`$`),r+=2;break;case`[`:case`]`:r+=2;break;case`u`:n.append(i),r+=2;break;case`h`:n.append(o),r+=2;break;case`H`:n.append(a),r+=2;break;case`w`:n.append(l),r+=2;break;case`W`:n.append(u),r+=2;break;case`d`:{let e=String(d.getDate()).padStart(2,` `);n.append(`${f[d.getDay()]} ${p[d.getMonth()]} ${e}`),r+=2;break}case`t`:{let e=String(d.getHours()).padStart(2,`0`),t=String(d.getMinutes()).padStart(2,`0`),i=String(d.getSeconds()).padStart(2,`0`);n.append(`${e}:${t}:${i}`),r+=2;break}case`T`:{let e=d.getHours()%12;e===0&&(e=12);let t=String(e).padStart(2,`0`),i=String(d.getMinutes()).padStart(2,`0`),a=String(d.getSeconds()).padStart(2,`0`);n.append(`${t}:${i}:${a}`),r+=2;break}case`@`:{let e=d.getHours()%12;e===0&&(e=12);let t=String(e).padStart(2,`0`),i=String(d.getMinutes()).padStart(2,`0`),a=d.getHours()<12?`AM`:`PM`;n.append(`${t}:${i} ${a}`),r+=2;break}case`A`:{let e=String(d.getHours()).padStart(2,`0`),t=String(d.getMinutes()).padStart(2,`0`);n.append(`${e}:${t}`),r+=2;break}case`D`:if(r+20&&e.state.localScopes[e.state.localScopes.length-1].has(t)&&!n){for(e.state.localExportedVars||(e.state.localExportedVars=[]);e.state.localExportedVars.length0?String(n.length):e.state.env.get(t)===void 0?`0`:`1`}if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)&&y6(e,t)){if(t===`FUNCNAME`){let t=e.state.funcNameStack?.[0]||``;return String([...t].length)}if(t===`BASH_LINENO`){let t=e.state.callLineStack?.[0];return String(t===void 0?0:[...String(t)].length)}let n=n4(e,t,0)||``;return String([...n].length)}return String([...n].length)}async function sAe(e,t,n,r){e.coverage?.hit(`bash:expansion:substring`);let i=await N8(e,r.offset.expression),a=r.length?await N8(e,r.length.expression):void 0;if(t===`@`||t===`*`){let t=Number.parseInt(e.state.env.get(`#`)||`0`,10),n=[];for(let r=1;r<=t;r++)n.push(e.state.env.get(String(r))||``);let r=e.state.env.get(`0`)||`bash`,o,s;if(i<=0){if(o=[r,...n],i<0){if(s=o.length+i,s<0)return``}else s=0}else o=n,s=i-1;if(s<0||s>=o.length)return``;if(a!==void 0){let e=a<0?o.length+a:s+a;return o.slice(s,Math.max(s,e)).join(` `)}return o.slice(s).join(` `)}let o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(o){let t=o[1];if(e.state.associativeArrays?.has(t))throw new RB(1,``,`bash: \${${t}[@]: 0: 3}: bad substitution `);let n=v6(e,t),r=0;if(i<0){if(n.length>0){let e=n[n.length-1][0],t=(typeof e==`number`?e:0)+1+i;if(t<0||(r=n.findIndex(([e])=>typeof e==`number`&&e>=t),r<0))return``}}else if(r=n.findIndex(([e])=>typeof e==`number`&&e>=i),r<0)return``;if(a!==void 0){if(a<0)throw new zB(`${o[1]}[@]: substring expression < 0`);return n.slice(r,r+a).map(([,e])=>e).join(` `)}return n.slice(r).map(([,e])=>e).join(` `)}let s=[...n],c=i;if(c<0&&(c=Math.max(0,s.length+c)),a!==void 0){if(a<0){let e=s.length+a;return s.slice(c,Math.max(c,e)).join(``)}return s.slice(c,c+a).join(``)}return s.slice(c).join(``)}async function cAe(e,t,n,r,i){if(e.coverage?.hit(`bash:expansion:case_modification`),n.pattern){let a=e.state.shoptOptions.extglob,o=``;for(let t of n.pattern.parts)if(t.type===`Glob`)o+=M6(t.pattern,!0,a);else if(t.type===`Literal`)o+=M6(t.value,!0,a);else if(t.type===`SingleQuoted`||t.type===`Escaped`)o+=j6(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);o+=j6(n)}else if(t.type===`ParameterExpansion`){let n=await i(e,t);o+=M6(n,!0,a)}let s=hG(`^(?:${o})$`),c=n.direction===`upper`?e=>e.toUpperCase():e=>e.toLowerCase(),l=``,u=!1;for(let e of t)!n.all&&u?l+=e:s.test(e)?(l+=c(e),u=!0):l+=e;return l}return n.direction===`upper`?n.all?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1):n.all?t.toLowerCase():t.charAt(0).toLowerCase()+t.slice(1)}function lAe(e,t,n,r,i){e.coverage?.hit(`bash:expansion:transform`);let a=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(a&&i.operator===`Q`)return v6(e,a[1]).map(([,e])=>R6(e)).join(` `);if(a&&i.operator===`a`)return W6(e,a[1]);let o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[.+\]$/);if(o&&i.operator===`a`)return W6(e,o[1]);switch(i.operator){case`Q`:return r?``:R6(n);case`P`:return L6(e,n);case`a`:return W6(e,t);case`A`:return r?``:`${t}=${R6(n)}`;case`E`:return n.replace(/\\([\\abefnrtv'"?])/g,(e,t)=>{switch(t){case`\\`:return`\\`;case`a`:return`\x07`;case`b`:return`\b`;case`e`:return`\x1B`;case`f`:return`\f`;case`n`:return` `;case`r`:return`\r`;case`t`:return` `;case`v`:return`\v`;case`'`:return`'`;case`"`:return`"`;case`?`:return`?`;default:return t}});case`K`:case`k`:return r?``:R6(n);case`u`:return n.charAt(0).toUpperCase()+n.slice(1);case`U`:return n.toUpperCase();case`L`:return n.toLowerCase();default:return n}}async function uAe(e,t,n,r,i,a,o=!1){if(e.coverage?.hit(`bash:expansion:indirection`),l6(e,t))return h6(e,t)||``;let s=/^[a-zA-Z_][a-zA-Z0-9_]*\[([@*])\]$/.test(t);if(r){if(i.innerOp?.type===`UseAlternative`)return``;throw new BB(`\${!${t}}`)}let c=n;if(s&&(c===``||c.includes(` `)))throw new BB(`\${!${t}}`);let l=c.match(/^[a-zA-Z_][a-zA-Z0-9_]*\[(.+)\]$/);if(l&&l[1].includes(`~`))throw new BB(`\${!${t}}`);return i.innerOp?a(e,{type:`ParameterExpansion`,parameter:c,operation:i.innerOp},o):await b6(e,c)}function dAe(e,t){e.coverage?.hit(`bash:expansion:array_keys`);let n=v6(e,t.array).map(([e])=>String(e));return t.star?n.join(i6(e.state.env)):n.join(` `)}function fAe(e,t){e.coverage?.hit(`bash:expansion:var_name_prefix`);let n=P6(e,t.prefix);return t.star?n.join(i6(e.state.env)):n.join(` `)}function pAe(e,t,n,r){let i=Number.parseInt(e.state.env.get(`#`)||`0`,10),a=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t===`*`)return{isEmpty:i===0,effectiveValue:n};if(t===`@`)return{isEmpty:i===0||i===1&&e.state.env.get(`1`)===``,effectiveValue:n};if(a){let[,t,n]=a,i=v6(e,t);if(i.length===0)return{isEmpty:!0,effectiveValue:``};if(n===`*`){let t=i6(e.state.env),n=i.map(([,e])=>e).join(t);return{isEmpty:r?n===``:!1,effectiveValue:n}}return{isEmpty:i.length===1&&i.every(([,e])=>e===``),effectiveValue:i.map(([,e])=>e).join(` `)}}return{isEmpty:n===``,effectiveValue:n}}U();function mAe(e){let t=0;for(;t0;){let t=e[r];if(t===`\\`&&!i&&r+1J6(e,t)).join(`:`)}U(),U();function X6(e,t,n,r){if(e.length>n-t.length)throw new H(`${r} element limit exceeded (${n})`,`array_elements`);for(let n of t)e.push(n)}bG();async function vAe(e,t,n,r){let i=``;for(let a of t.parts)if(a.type===`Glob`)i+=M6(a.pattern,!0,e.state.shoptOptions.extglob);else if(a.type===`Literal`)i+=M6(a.value,!0,e.state.shoptOptions.extglob);else if(a.type===`SingleQuoted`||a.type===`Escaped`)i+=j6(a.value);else if(a.type===`DoubleQuoted`){let t=await n(e,a.parts);i+=j6(t)}else if(a.type===`ParameterExpansion`){let t=await r(e,a);i+=M6(t,!0,e.state.shoptOptions.extglob)}else{let t=await r(e,a);i+=j6(t)}return i}async function yAe(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0];if(i.parts.length!==1||i.parts[0].type!==`ParameterExpansion`||i.parts[0].operation?.type!==`PatternReplacement`)return null;let a=i.parts[0],o=a.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let s=o[1],c=o[2]===`*`,l=a.operation,u=v6(e,s),d=u.map(([,e])=>e);if(u.length===0){let t=e.state.env.get(s);t!==void 0&&d.push(t)}if(d.length===0)return{values:[],quoted:!0};let f=``;l.pattern&&(f=await vAe(e,l.pattern,n,r));let p=l.replacement?await n(e,l.replacement.parts):``,m=f;l.anchor===`start`?m=`^${f}`:l.anchor===`end`&&(m=`${f}$`);let h=[];try{let e=hG(m,l.all?`g`:``);for(let t of d)h.push(e.replace(t,p))}catch{h.push(...d)}if(c){let t=i6(e.state.env);return{values:[h.join(t)],quoted:!0}}return{values:h,quoted:!0}}async function bAe(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0];if(i.parts.length!==1||i.parts[0].type!==`ParameterExpansion`||i.parts[0].operation?.type!==`PatternRemoval`)return null;let a=i.parts[0],o=a.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let s=o[1],c=o[2]===`*`,l=a.operation,u=v6(e,s),d=u.map(([,e])=>e);if(u.length===0){let t=e.state.env.get(s);t!==void 0&&d.push(t)}if(d.length===0)return{values:[],quoted:!0};let f=``,p=e.state.shoptOptions.extglob;if(l.pattern)for(let t of l.pattern.parts)if(t.type===`Glob`)f+=M6(t.pattern,l.greedy,p);else if(t.type===`Literal`)f+=M6(t.value,l.greedy,p);else if(t.type===`SingleQuoted`||t.type===`Escaped`)f+=j6(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);f+=j6(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);f+=M6(n,l.greedy,p)}else{let n=await r(e,t);f+=j6(n)}let m=[];for(let t of d)m.push(N6(e,t,f,l.side,l.greedy));if(c){let t=i6(e.state.env);return{values:[m.join(t)],quoted:!0}}return{values:m,quoted:!0}}bG();async function xAe(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`||n.parts[0].operation?.type!==`DefaultValue`&&n.parts[0].operation?.type!==`UseAlternative`&&n.parts[0].operation?.type!==`AssignDefault`)return null;let r=n.parts[0],i=r.operation,a=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/),o,s=!1;if(a){let t=a[1];s=a[2]===`*`;let n=v6(e,t),r=n.length>0||e.state.env.has(t),c=n.length===0||n.length===1&&n.every(([,e])=>e===``),l=i.checkEmpty??!1;if(o=i.type===`UseAlternative`?r&&!(l&&c):!r||l&&c,!o){if(n.length>0){let t=n.map(([,e])=>e);if(s){let n=i6(e.state.env);return{values:[t.join(n)],quoted:!0}}return{values:t,quoted:!0}}let r=e.state.env.get(t);return r===void 0?{values:[],quoted:!0}:{values:[r],quoted:!0}}}else{let t=r.parameter,n=await x6(e,t),a=await b6(e,t),s=a===``,c=i.checkEmpty??!1;if(o=i.type===`UseAlternative`?n&&!(c&&s):!n||c&&s,!o)return{values:[a],quoted:!0}}if(o&&i.word){let t=i.word.parts,n=null,r=!1;for(let e of t)if(e.type===`ParameterExpansion`&&!e.operation){let t=e.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t){n=t[1],r=t[2]===`*`;break}}if(n){let t=v6(e,n);if(t.length>0){let n=t.map(([,e])=>e);if(r||s){let t=i6(e.state.env);return{values:[n.join(t)],quoted:!0}}return{values:n,quoted:!0}}let i=e.state.env.get(n);return i===void 0?{values:[],quoted:!0}:{values:[i],quoted:!0}}}return null}async function SAe(e,t,n,r,i){if(!n||t.length!==1||t[0].type!==`DoubleQuoted`)return null;let a=t[0],o=-1,s=``,c=!1,l=null;for(let e=0;ee);if(f.length===0){let t=e.state.env.get(s);if(t!==void 0)p=[t];else{if(c)return{values:[u+d],quoted:!0};let e=u+d;return{values:e?[e]:[],quoted:!0}}}if(l?.type===`PatternRemoval`){let t=l,n=``,a=e.state.shoptOptions.extglob;if(t.pattern)for(let o of t.pattern.parts)if(o.type===`Glob`)n+=M6(o.pattern,t.greedy,a);else if(o.type===`Literal`)n+=M6(o.value,t.greedy,a);else if(o.type===`SingleQuoted`||o.type===`Escaped`)n+=j6(o.value);else if(o.type===`DoubleQuoted`){let t=await i(e,o.parts);n+=j6(t)}else if(o.type===`ParameterExpansion`){let i=await r(e,o);n+=M6(i,t.greedy,a)}else{let t=await r(e,o);n+=j6(t)}p=p.map(r=>N6(e,r,n,t.side,t.greedy))}else if(l?.type===`PatternReplacement`){let t=l,n=``;if(t.pattern)for(let a of t.pattern.parts)if(a.type===`Glob`)n+=M6(a.pattern,!0,e.state.shoptOptions.extglob);else if(a.type===`Literal`)n+=M6(a.value,!0,e.state.shoptOptions.extglob);else if(a.type===`SingleQuoted`||a.type===`Escaped`)n+=j6(a.value);else if(a.type===`DoubleQuoted`){let t=await i(e,a.parts);n+=j6(t)}else if(a.type===`ParameterExpansion`){let t=await r(e,a);n+=M6(t,!0,e.state.shoptOptions.extglob)}else{let t=await r(e,a);n+=j6(t)}let a=t.replacement?await i(e,t.replacement.parts):``,o=n;t.anchor===`start`?o=`^${n}`:t.anchor===`end`&&(o=`${n}$`);try{let e=hG(o,t.all?`g`:``);p=p.map(t=>e.replace(t,a))}catch{}}if(c){let t=i6(e.state.env);return{values:[u+p.join(t)+d],quoted:!0}}return p.length===1?{values:[u+p[0]+d],quoted:!0}:{values:[u+p[0],...p.slice(1,-1),p[p.length-1]+d],quoted:!0}}async function CAe(e,t,n,r){if(!n||t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=``,s=!1;for(let e=0;ee);if(u.length===0){let t=e.state.env.get(o);if(t!==void 0)return{values:[c+t+l],quoted:!0};if(s)return{values:[c+l],quoted:!0};let n=c+l;return{values:n?[n]:[],quoted:!0}}if(s){let t=i6(e.state.env);return{values:[c+d.join(t)+l],quoted:!0}}return d.length===1?{values:[c+d[0]+l],quoted:!0}:{values:[c+d[0],...d.slice(1,-1),d[d.length-1]+l],quoted:!0}}ZB(),U();async function wAe(e,t,n){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let r=t[0];if(r.parts.length!==1||r.parts[0].type!==`ParameterExpansion`||r.parts[0].operation?.type!==`Substring`)return null;let i=r.parts[0],a=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!a)return null;let o=a[1],s=a[2]===`*`,c=i.operation;if(e.state.associativeArrays?.has(o))throw new RB(1,``,`bash: \${${o}[@]: 0: 3}: bad substitution `);let l=c.offset?await n(e,c.offset.expression):0,u=c.length?await n(e,c.length.expression):void 0,d=v6(e,o);if(d.length>e.limits.maxArrayElements)throw new H(`array transform element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let f=0;if(l<0){if(d.length>0){let e=d[d.length-1][0],t=(typeof e==`number`?e:0)+1+l;if(t<0)return{values:[],quoted:!0};f=d.findIndex(([e])=>typeof e==`number`&&e>=t),f<0&&(f=d.length)}}else f=d.findIndex(([e])=>typeof e==`number`&&e>=l),f<0&&(f=d.length);let p;if(u!==void 0){if(u<0)throw new zB(`${o}[@]: substring expression < 0`);p=d.slice(f,f+u).map(([,e])=>e)}else p=d.slice(f).map(([,e])=>e);if(p.length===0)return{values:[],quoted:!0};if(s){let t=i6(e.state.env);return{values:[p.join(t)],quoted:!0}}return{values:p,quoted:!0}}function TAe(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`||n.parts[0].operation?.type!==`Transform`)return null;let r=n.parts[0],i=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!i)return null;let a=i[1],o=i[2]===`*`,s=r.operation,c=v6(e,a);if(c.length===0){let t=e.state.env.get(a);if(t!==void 0){let n;switch(s.operator){case`a`:n=``;break;case`P`:n=L6(e,t);break;case`Q`:n=R6(t);break;default:n=t}if(V(n)>e.limits.maxStringLength)throw new H(`array transform string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return{values:[n],quoted:!0}}return o?{values:[``],quoted:!0}:{values:[],quoted:!0}}let l=W6(e,a),u=[],d=0;for(let[,t]of c){let n;switch(s.operator){case`a`:n=l;break;case`P`:n=L6(e,t);break;case`Q`:n=R6(t);break;case`u`:n=t.charAt(0).toUpperCase()+t.slice(1);break;case`U`:n=t.toUpperCase();break;case`L`:n=t.toLowerCase();break;default:n=t}let r=V(n);if(r>e.limits.maxStringLength-d)throw new H(`array transform string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);u.push(n),d+=r}if(o){let t=i6(e.state.env);if(Math.max(0,u.length-1)*V(t)>e.limits.maxStringLength-d)throw new H(`array transform string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return{values:[u.join(t)],quoted:!0}}return{values:u,quoted:!0}}function EAe(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`)return null;let r=n.parts[0];if(r.operation)return null;let i=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!i)return null;let a=i[1];if(l6(e,a)){let t=h6(e,a);if(t?.endsWith(`[@]`)||t?.endsWith(`[*]`))return{values:[],quoted:!0}}let o=v6(e,a);if(o.length>0)return{values:o.map(([,e])=>e),quoted:!0};let s=e.state.env.get(a);return s===void 0?{values:[],quoted:!0}:{values:[s],quoted:!0}}function DAe(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`||n.parts[0].operation)return null;let r=n.parts[0].parameter;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)||!l6(e,r))return null;let i=h6(e,r);if(!i)return null;let a=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!a)return null;let o=a[1],s=v6(e,o);if(s.length>0)return{values:s.map(([,e])=>e),quoted:!0};let c=e.state.env.get(o);return c===void 0?{values:[],quoted:!0}:{values:[c],quoted:!0}}U();async function OAe(e,t,n,r,i){if(!n||t.length!==1||t[0].type!==`DoubleQuoted`)return null;let a=t[0];if(a.parts.length!==1||a.parts[0].type!==`ParameterExpansion`||a.parts[0].operation?.type!==`Indirection`)return null;let o=a.parts[0],s=o.operation,c=await b6(e,o.parameter),l=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!l){if(!s.innerOp&&(c===`@`||c===`*`)){let t=Number.parseInt(e.state.env.get(`#`)||`0`,10),n=[];for(let r=1;r<=t;r++)n.push(e.state.env.get(String(r))||``);return c===`*`?{values:[n.join(i6(e.state.env))],quoted:!0}:{values:n,quoted:!0}}return null}let u=l[1],d=l[2]===`*`,f=v6(e,u);if(s.innerOp){if(s.innerOp.type===`Substring`)return kAe(e,f,u,d,s.innerOp);if(s.innerOp.type===`DefaultValue`||s.innerOp.type===`UseAlternative`||s.innerOp.type===`AssignDefault`||s.innerOp.type===`ErrorIfUnset`)return AAe(e,f,u,d,s.innerOp,i);if(s.innerOp.type===`Transform`&&s.innerOp.operator===`a`){let t=W6(e,u),n=f.map(()=>t);return d?{values:[n.join(i6(e.state.env))],quoted:!0}:{values:n,quoted:!0}}let t=[];for(let[,n]of f){let i={type:`ParameterExpansion`,parameter:`_indirect_elem_`,operation:s.innerOp},a=e.state.env.get(`_indirect_elem_`);e.state.env.set(`_indirect_elem_`,n);try{let n=await r(e,i,!0);t.push(n)}finally{a===void 0?e.state.env.delete(`_indirect_elem_`):e.state.env.set(`_indirect_elem_`,a)}}return d?{values:[t.join(i6(e.state.env))],quoted:!0}:{values:t,quoted:!0}}if(f.length>0){let t=f.map(([,e])=>e);return d?{values:[t.join(i6(e.state.env))],quoted:!0}:{values:t,quoted:!0}}let p=e.state.env.get(u);return p===void 0?{values:[],quoted:!0}:{values:[p],quoted:!0}}async function kAe(e,t,n,r,i){let a=i.offset?await N8(e,i.offset.expression):0,o=i.length?await N8(e,i.length.expression):void 0,s=0;if(a<0){if(t.length>0){let e=t[t.length-1][0],n=(typeof e==`number`?e:0)+1+a;if(n<0||(s=t.findIndex(([e])=>typeof e==`number`&&e>=n),s<0))return{values:[],quoted:!0}}}else if(s=t.findIndex(([e])=>typeof e==`number`&&e>=a),s<0)return{values:[],quoted:!0};let c;if(o!==void 0){if(o<0)throw new zB(`${n}[@]: substring expression < 0`);c=t.slice(s,s+o)}else c=t.slice(s);let l=c.map(([,e])=>e);return r?{values:[l.join(i6(e.state.env))],quoted:!0}:{values:l,quoted:!0}}async function AAe(e,t,n,r,i,a){let o=i.checkEmpty??!1,s=t.map(([,e])=>e),c=t.length===0,l=t.length===0;if(i.type===`UseAlternative`)return!l&&!(o&&c)&&i.word?{values:[await a(e,i.word.parts,!0)],quoted:!0}:{values:[],quoted:!0};if(i.type===`DefaultValue`)return(l||o&&c)&&i.word?{values:[await a(e,i.word.parts,!0)],quoted:!0}:r?{values:[s.join(i6(e.state.env))],quoted:!0}:{values:s,quoted:!0};if(i.type===`AssignDefault`){if((l||o&&c)&&i.word){let t=await a(e,i.word.parts,!0);return i4(e,n,0,t),{values:[t],quoted:!0}}return r?{values:[s.join(i6(e.state.env))],quoted:!0}:{values:s,quoted:!0}}return r?{values:[s.join(i6(e.state.env))],quoted:!0}:{values:s,quoted:!0}}async function jAe(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`UseAlternative`&&t[0].operation?.type!==`DefaultValue`)return null;let n=t[0],r=n.operation,i=r?.word;if(!i||i.parts.length!==1||i.parts[0].type!==`DoubleQuoted`)return null;let a=i.parts[0];if(a.parts.length!==1||a.parts[0].type!==`ParameterExpansion`||a.parts[0].operation?.type!==`Indirection`)return null;let o=a.parts[0],s=(await b6(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let c=await x6(e,n.parameter),l=await b6(e,n.parameter)===``,u=r.checkEmpty??!1,d;if(d=r.type===`UseAlternative`?c&&!(u&&l):!c||u&&l,d){let t=s[1],n=s[2]===`*`,r=v6(e,t);if(r.length>0){let t=r.map(([,e])=>e);return n?{values:[t.join(i6(e.state.env))],quoted:!0}:{values:t,quoted:!0}}let i=e.state.env.get(t);return i===void 0?{values:[],quoted:!0}:{values:[i],quoted:!0}}return{values:[],quoted:!1}}async function MAe(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`Indirection`)return null;let n=t[0],r=n.operation.innerOp;if(!r||r.type!==`UseAlternative`&&r.type!==`DefaultValue`)return null;let i=r.word;if(!i||i.parts.length!==1||i.parts[0].type!==`DoubleQuoted`)return null;let a=i.parts[0];if(a.parts.length!==1||a.parts[0].type!==`ParameterExpansion`||a.parts[0].operation?.type!==`Indirection`)return null;let o=a.parts[0],s=(await b6(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let c=await b6(e,n.parameter),l=await x6(e,n.parameter),u=c===``,d=r.checkEmpty??!1,f;if(f=r.type===`UseAlternative`?l&&!(d&&u):!l||d&&u,f){let t=s[1],n=s[2]===`*`,r=v6(e,t);if(r.length>0){let t=r.map(([,e])=>e);return n?{values:[t.join(i6(e.state.env))],quoted:!0}:{values:t,quoted:!0}}let i=e.state.env.get(t);return i===void 0?{values:[],quoted:!0}:{values:[i],quoted:!0}}return{values:[],quoted:!1}}ZB(),bG(),U();function Z6(e){let t=Number.parseInt(e.state.env.get(`#`)||`0`,10);if(t>e.limits.maxArrayElements)throw new H(`positional parameter element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let n=[],r=0;for(let i=1;i<=t;i++){let t=e.state.env.get(String(i))||``,a=V(t);if(a>e.limits.maxStringLength-r)throw new H(`positional parameter string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);n.push(t),r+=a}return n}function Q6(e,t,n){if(V(t)>n-V(e))throw new H(`positional expansion string limit exceeded (${n} bytes)`,`string_length`);return e+t}function $6(e,t,n,r){if(e.length>=r.limits.maxArrayElements)throw new H(`positional expansion element limit exceeded (${r.limits.maxArrayElements})`,`array_elements`);let i=V(t);if(i>r.limits.maxStringLength-n.value)throw new H(`positional expansion string limit exceeded (${r.limits.maxStringLength} bytes)`,`string_length`);e.push(t),n.value+=i}async function NAe(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=!1;for(let e=0;e=d.length)p=[];else if(l!==void 0){let t=l<0?d.length+l:e+l;p=d.slice(e,Math.max(e,t))}else p=d.slice(e)}let m=``;for(let t=0;t]+>|`|')/g;for(;c.exec(f)!==null;)o++;if(i+r*a+r*o*i>e.limits.maxStringLength-h.value)throw new H(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);$6(m,t.replace(n,f),h,e)}}catch(t){if(t instanceof H)throw t;for(let t of c)$6(m,t,h,e)}if(o){let t=i6(e.state.env);if(h.value+Math.max(0,m.length-1)*V(t)+V(l)+V(u)>e.limits.maxStringLength)throw new H(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return{values:[l+m.join(t)+u],quoted:!0}}if(V(l)+h.value+V(u)>e.limits.maxStringLength)throw new H(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return m.length===1?{values:[l+m[0]+u],quoted:!0}:{values:[l+m[0],...m.slice(1,-1),m[m.length-1]+u],quoted:!0}}async function FAe(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=!1;for(let e=0;ee.limits.maxStringLength)throw new H(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return{values:[l+p.join(t)+u],quoted:!0}}if(V(l)+m.value+V(u)>e.limits.maxStringLength)throw new H(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return p.length===1?{values:[l+p[0]+u],quoted:!0}:{values:[l+p[0],...p.slice(1,-1),p[p.length-1]+u],quoted:!0}}async function IAe(e,t,n){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let r=t[0],i=-1,a=!1;for(let e=0;e=e.limits.maxArrayElements)throw new H(`unquoted expansion element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let i=V(n);if(i>e.limits.maxStringLength-r.value)throw new H(`unquoted expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);t.push(n),r.value+=i}function t8(e,t,n,r){let i=V(n),a=Math.max(0,t.length-1);if(i>0&&a>Math.floor((e.limits.maxStringLength-r)/i))throw new H(`unquoted expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return t.join(n)}function LAe(e){return new X3(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations,consumeOperation:()=>e.executionScope.consumeLimited(`glob_operations`,1,e.limits.maxGlobOperations,`glob expansion`)})}async function n8(e,t){if(e.state.options.noglob)return t;let n=LAe(e),r=[];for(let i of t)if(D6(i,e.state.shoptOptions.extglob)){let t=await n.expand(i);if(t.length>0)X6(r,t,e.limits.maxArrayElements,`unquoted glob expansion`);else{if(n.hasFailglob())throw new VB(i);n.hasNullglob()||r.push(i)}}else r.push(i);return r}async function RAe(e,t,n,r){let i=-1,a=``,o=!1;for(let e=0;ee);if(c.length===0){let t=e.state.env.get(a);t!==void 0&&(l=[t])}if(l.length===0)return{values:[],quoted:!1};let u=``;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)u+=M6(t.pattern,!0,e.state.shoptOptions.extglob);else if(t.type===`Literal`)u+=M6(t.value,!0,e.state.shoptOptions.extglob);else if(t.type===`SingleQuoted`||t.type===`Escaped`)u+=j6(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);u+=j6(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);u+=M6(n,!0,e.state.shoptOptions.extglob)}else{let n=await r(e,t);u+=j6(n)}let d=s.replacement?await n(e,s.replacement.parts):``,f=u;s.anchor===`start`?f=`^${u}`:s.anchor===`end`&&(f=`${u}$`);let p=[],m={value:0};try{let t=hG(f,s.all?`g`:``);for(let n of l)e8(e,p,F6(e,n,t,d,s.all),m)}catch(t){if(t instanceof H)throw t;for(let t of l)e8(e,p,t,m)}let h=t6(e.state.env),g=n6(e.state.env);if(o){let t=t8(e,p,i6(e.state.env),m.value);return g?{values:t?[t]:[],quoted:!1}:{values:c6(t,h,e.limits.maxArrayElements),quoted:!1}}if(g)return{values:p,quoted:!1};let _=[],v={value:0};for(let t of p)if(t===``)e8(e,_,``,v);else for(let n of c6(t,h,e.limits.maxArrayElements))e8(e,_,n,v);return{values:_,quoted:!1}}async function zAe(e,t,n,r){let i=-1,a=``,o=!1;for(let e=0;ee);if(c.length===0){let t=e.state.env.get(a);t!==void 0&&(l=[t])}if(l.length===0)return{values:[],quoted:!1};let u=``,d=e.state.shoptOptions.extglob;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)u+=M6(t.pattern,s.greedy,d);else if(t.type===`Literal`)u+=M6(t.value,s.greedy,d);else if(t.type===`SingleQuoted`||t.type===`Escaped`)u+=j6(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);u+=j6(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);u+=M6(n,s.greedy,d)}else{let n=await r(e,t);u+=j6(n)}let f=[],p={value:0};for(let t of l)e8(e,f,N6(e,t,u,s.side,s.greedy),p);let m=t6(e.state.env),h=n6(e.state.env);if(o){let t=t8(e,f,i6(e.state.env),p.value);return h?{values:t?[t]:[],quoted:!1}:{values:c6(t,m,e.limits.maxArrayElements),quoted:!1}}if(h)return{values:f,quoted:!1};let g=[],_={value:0};for(let t of f)if(t===``)e8(e,g,``,_);else for(let n of c6(t,m,e.limits.maxArrayElements))e8(e,g,n,_);return{values:g,quoted:!1}}async function BAe(e,t,n,r){let i=-1,a=!1;for(let e=0;e=u.length)f=[];else if(c!==void 0){let t=c<0?u.length+c:e+c;f=u.slice(e,Math.max(e,t))}else f=u.slice(e)}let p=``;for(let n=0;ne!==``);else{let t=i6(e.state.env);c=c6(i.join(t),a,e.limits.maxArrayElements)}}else if(o)c=i.filter(e=>e!==``);else if(s){c=[];for(let t of i){if(t===``)continue;let n=c6(t,a,e.limits.maxArrayElements);X6(c,n,e.limits.maxArrayElements,`unquoted expansion`)}}else{c=[];for(let t of i)if(t===``)c.push(``);else{let n=c6(t,a,e.limits.maxArrayElements);X6(c,n,e.limits.maxArrayElements,`unquoted expansion`)}for(;c.length>0&&c[c.length-1]===``;)c.pop()}return{values:await n8(e,c),quoted:!1}}async function UAe(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation)return null;let n=t[0].parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!n)return null;let r=n[1],i=n[2]===`*`,a=v6(e,r),o;if(a.length===0){let t=e.state.env.get(r);if(t!==void 0)o=[t];else return{values:[],quoted:!1}}else o=a.map(([,e])=>e);let s=t6(e.state.env),c=n6(e.state.env),l=r6(e.state.env),u;if(i){if(c)u=o.filter(e=>e!==``);else{let t=i6(e.state.env);u=c6(o.join(t),s,e.limits.maxArrayElements)}}else if(c)u=o.filter(e=>e!==``);else if(l){u=[];for(let t of o){if(t===``)continue;let n=c6(t,s,e.limits.maxArrayElements);X6(u,n,e.limits.maxArrayElements,`unquoted expansion`)}}else{u=[];for(let t of o)if(t===``)u.push(``);else{let n=c6(t,s,e.limits.maxArrayElements);X6(u,n,e.limits.maxArrayElements,`unquoted expansion`)}for(;u.length>0&&u[u.length-1]===``;)u.pop()}return{values:await n8(e,u),quoted:!1}}function WAe(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`VarNamePrefix`)return null;let n=t[0].operation,r=P6(e,n.prefix);if(r.length===0)return{values:[],quoted:!1};let i=t6(e.state.env),a=n6(e.state.env),o;if(n.star){if(a)o=r;else{let t=i6(e.state.env);o=c6(r.join(t),i,e.limits.maxArrayElements)}}else if(a)o=r;else{o=[];for(let t of r){let n=c6(t,i,e.limits.maxArrayElements);X6(o,n,e.limits.maxArrayElements,`unquoted expansion`)}}return{values:o,quoted:!1}}function GAe(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`ArrayKeys`)return null;let n=t[0].operation,r=v6(e,n.array).map(([e])=>String(e));if(r.length===0)return{values:[],quoted:!1};let i=t6(e.state.env),a=n6(e.state.env),o;if(n.star){if(a)o=r;else{let t=i6(e.state.env);o=c6(r.join(t),i,e.limits.maxArrayElements)}}else if(a)o=r;else{o=[];for(let t of r){let n=c6(t,i,e.limits.maxArrayElements);X6(o,n,e.limits.maxArrayElements,`unquoted expansion`)}}return{values:o,quoted:!1}}async function KAe(e,t,n){let r=-1;for(let e=0;ee!==``);else if(u){d=[];for(let n of t){if(n===``)continue;let t=c6(n,c,e.limits.maxArrayElements);X6(d,t,e.limits.maxArrayElements,`unquoted expansion`)}}else{d=[];for(let n of t)if(n===``)d.push(``);else{let t=c6(n,c,e.limits.maxArrayElements);X6(d,t,e.limits.maxArrayElements,`unquoted expansion`)}for(;d.length>0&&d[d.length-1]===``;)d.pop()}}return d.length===0?{values:[],quoted:!1}:{values:await n8(e,d),quoted:!1}}async function qAe(e,t,n){e.coverage?.hit(`bash:expansion:word_glob`);let r=t.parts,{hasQuoted:i,hasCommandSub:a,hasArrayVar:o,hasArrayAtExpansion:s,hasParamExpansion:c,hasVarNamePrefixExpansion:l,hasIndirection:u}=Q3(r),d=n.hasBraceExpansion(r)?await n.expandWordWithBracesAsync(e,t):null;if(d&&d.length>1)return JAe(e,d,i);let f=await YAe(e,r,s,l,u,n);if(f!==null)return f;let p=await ZAe(e,r,n);if(p!==null)return p;let m=await QAe(e,r,n);if(m!==null)return m;let h=await eje(e,r,n.expandPart);if(h!==null)return i8(e,h);if((a||o||c)&&!n6(e.state.env)){let t=t6(e.state.env),i=n.buildIfsCharClassPattern(t);return i8(e,await n.smartWordSplit(e,r,t,i,n.expandPart))}return tje(e,t,r,await n.expandWordAsync(e,t),i,n.expandWordForGlobbing)}async function JAe(e,t,n){let r=[];for(let i of t)(n||i!==``)&&(!n&&!e.state.options.noglob&&D6(i,e.state.shoptOptions.extglob)?X6(r,await a8(e,i),e.limits.maxArrayElements,`brace/glob expansion`):r.push(i));return{values:r,quoted:!1}}async function YAe(e,t,n,r,i,a){if(n){let n=EAe(e,t);if(n!==null)return n}{let n=DAe(e,t);if(n!==null)return n}{let n=await xAe(e,t);if(n!==null)return n}{let r=await SAe(e,t,n,a.expandPart,a.expandWordPartsAsync);if(r!==null)return r}{let r=await CAe(e,t,n,a.expandPart);if(r!==null)return r}{let n=await wAe(e,t,a.evaluateArithmetic);if(n!==null)return n}{let n=TAe(e,t);if(n!==null)return n}{let n=await yAe(e,t,a.expandWordPartsAsync,a.expandPart);if(n!==null)return n}{let n=await bAe(e,t,a.expandWordPartsAsync,a.expandPart);if(n!==null)return n}if(r&&t.length===1&&t[0].type===`DoubleQuoted`){let n=XAe(e,t);if(n!==null)return n}{let n=await OAe(e,t,i,a.expandParameterAsync,a.expandWordPartsAsync);if(n!==null)return n}{let n=await jAe(e,t);if(n!==null)return n}{let n=await MAe(e,t);if(n!==null)return n}return null}function XAe(e,t){let n=t[0];if(n.type!==`DoubleQuoted`)return null;if(n.parts.length===1&&n.parts[0].type===`ParameterExpansion`&&n.parts[0].operation?.type===`VarNamePrefix`){let t=n.parts[0].operation,r=P6(e,t.prefix);return t.star?{values:[r.join(i6(e.state.env))],quoted:!0}:{values:r,quoted:!0}}if(n.parts.length===1&&n.parts[0].type===`ParameterExpansion`&&n.parts[0].operation?.type===`ArrayKeys`){let t=n.parts[0].operation,r=v6(e,t.array).map(([e])=>String(e));return t.star?{values:[r.join(i6(e.state.env))],quoted:!0}:{values:r,quoted:!0}}return null}async function ZAe(e,t,n){{let r=await NAe(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await PAe(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await FAe(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await IAe(e,t,n.expandPart);if(r!==null)return r}return null}async function QAe(e,t,n){{let r=await RAe(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await zAe(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await BAe(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await VAe(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let n=await HAe(e,t);if(n!==null)return n}{let n=await UAe(e,t);if(n!==null)return n}{let n=WAe(e,t);if(n!==null)return n}{let n=GAe(e,t);if(n!==null)return n}{let r=await KAe(e,t,n.expandPart);if(r!==null)return r}return null}function r8(e){if(e.type!==`DoubleQuoted`)return null;for(let t=0;te),o.length===0){let t=e.state.env.get(n.name);t!==void 0&&(o=[t])}}else{let t=Number.parseInt(e.state.env.get(`#`)||`0`,10);o=[];for(let n=1;n<=t;n++)o.push(e.state.env.get(String(n))||``)}if(n.isStar){let t=i6(e.state.env),n=o.join(t);return[i+n+a]}if(o.length===0){let e=i+a;return e?[e]:[]}return o.length===1?[i+o[0]+a]:[i+o[0],...o.slice(1,-1),o[o.length-1]+a]}async function eje(e,t,n){if(t.length<2)return null;let r=!1;for(let e of t)if(r8(e)){r=!0;break}if(!r)return null;let i=t6(e.state.env),a=n6(e.state.env),o=[];for(let r of t){let t=r8(r);if(t&&r.type===`DoubleQuoted`){let i=await $Ae(e,r,t,n);o.push(i)}else if(r.type===`DoubleQuoted`||r.type===`SingleQuoted`){let t=await n(e,r);o.push([t])}else if(r.type===`Literal`)o.push([r.value]);else if(r.type===`ParameterExpansion`){let t=await n(e,r);if(a)o.push(t?[t]:[]);else{let n=c6(t,i,e.limits.maxArrayElements);o.push(n)}}else{let t=await n(e,r);if(a)o.push(t?[t]:[]);else{let n=c6(t,i,e.limits.maxArrayElements);o.push(n)}}}let s=[];for(let t of o)if(t.length!==0){if(s.length===0)X6(s,t,e.limits.maxArrayElements,`word expansion`);else{let e=s.length-1;s[e]=s[e]+t[0];for(let e=1;ee.executionScope.consumeLimited(`glob_operations`,1,e.limits.maxGlobOperations,`glob expansion`)}),r=await n.expand(t);if(r.length>0)return r;if(n.hasFailglob())throw new VB(t);return n.hasNullglob()?[]:[t]}async function tje(e,t,n,r,i,a){let o=n.some(e=>e.type===`Glob`);if(!e.state.options.noglob&&o){let n=await a(e,t);if(D6(n,e.state.shoptOptions.extglob)){let t=await a8(e,n);if(t.length>0&&t[0]!==n)return{values:t,quoted:!1};if(t.length===0)return{values:[],quoted:!1}}let i=O6(r);return n6(e.state.env)?{values:[i],quoted:!1}:{values:c6(i,t6(e.state.env),e.limits.maxArrayElements),quoted:!1}}if(!i&&!e.state.options.noglob&&D6(r,e.state.shoptOptions.extglob)){let n=await a(e,t);if(D6(n,e.state.shoptOptions.extglob)){let t=await a8(e,n);if(t.length>0&&t[0]!==n)return{values:t,quoted:!1}}}if(r===``&&!i)return{values:[],quoted:!1};if(o&&!i){let t=O6(r);return n6(e.state.env)?{values:[t],quoted:!1}:{values:c6(t,t6(e.state.env),e.limits.maxArrayElements),quoted:!1}}return{values:[r],quoted:i}}U();function o8(e,t,n){if(t.length>=e.limits.maxArrayElements)throw new H(`word splitting element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);t.push(n)}async function s8(e,t){let n=t.operation;if(!n||n.type!==`DefaultValue`&&n.type!==`AssignDefault`&&n.type!==`UseAlternative`)return null;let r=n.word;if(!r||r.parts.length===0)return null;let i=await x6(e,t.parameter),a=await b6(e,t.parameter,!1)===``,o=n.checkEmpty??!1,s;return s=n.type===`UseAlternative`?i&&!(o&&a):!i||o&&a,s?r.parts:null}function nje(e){return e.type===`SingleQuoted`||e.type===`DoubleQuoted`&&e.parts.every(e=>e.type===`Literal`)}async function rje(e,t){if(t.type!==`ParameterExpansion`)return null;let n=await s8(e,t);if(!n||n.length<=1)return null;let r=n.some(e=>nje(e)),i=n.some(e=>e.type===`Literal`||e.type===`ParameterExpansion`||e.type===`CommandSubstitution`||e.type===`ArithmeticExpansion`);return r&&i?n:null}function ije(e){return e.type===`DoubleQuoted`||e.type===`SingleQuoted`||e.type===`Literal`?!1:e.type===`Glob`?Z3(e.pattern):!(e.type!==`ParameterExpansion`&&e.type!==`CommandSubstitution`&&e.type!==`ArithmeticExpansion`||e.type===`ParameterExpansion`&&Pke(e))}async function aje(e,t,n,r,i){if(e.coverage?.hit(`bash:expansion:word_split`),t.length===1&&t[0].type===`ParameterExpansion`){let a=t[0],o=await s8(e,a);if(o&&o.length>0&&o.length>1&&o.some(e=>e.type===`DoubleQuoted`||e.type===`SingleQuoted`)&&o.some(e=>e.type===`Literal`||e.type===`ParameterExpansion`||e.type===`CommandSubstitution`||e.type===`ArithmeticExpansion`))return c8(e,o,n,r,i)}let a=[],o=!1;for(let n of t){let t=ije(n),r=n.type===`DoubleQuoted`||n.type===`SingleQuoted`,s=t?await rje(e,n):null,c=await i(e,n);a.push({value:c,isSplittable:t,isQuoted:r,mixedDefaultParts:s??void 0}),t&&(o=!0)}if(!o){let e=a.map(e=>e.value).join(``);return e?[e]:[]}let s=[],c=``,l=!1,u=!1,d=!1;for(let t of a)if(!t.isSplittable)u?t.isQuoted&&t.value===``?(c!==``&&o8(e,s,c),o8(e,s,``),l=!0,c=``,u=!1,d=!0):t.value===``?(c+=t.value,d=!1):(c!==``&&o8(e,s,c),c=t.value,u=!1,d=!1):(c+=t.value,d=t.isQuoted&&t.value===``);else if(t.mixedDefaultParts){let a=await c8(e,t.mixedDefaultParts,n,r,i);if(a.length!==0){if(a.length===1)c+=a[0],l=!0;else{c+=a[0],o8(e,s,c),l=!0;for(let t=1;t0&&t.includes(e[0])}async function c8(e,t,n,r,i){let a=[];for(let n of t){let t=n.type!==`DoubleQuoted`&&n.type!==`SingleQuoted`,r=await i(e,n);a.push({value:r,isSplittable:t})}let o=[],s=``,c=!1,l=!1;for(let t of a)if(!t.isSplittable)l&&t.value!==``?(s!==``&&o8(e,o,s),s=t.value,l=!1):s+=t.value;else{oje(t.value,n)&&s!==``&&(o8(e,o,s),s=``,c=!0);let{words:r,hadTrailingDelimiter:i}=s6(t.value,n,e.limits.maxArrayElements);if(r.length===0)i&&(l=!0);else if(r.length===1)s+=r[0],c=!0,l=i;else{s+=r[0],o8(e,o,s),c=!0;for(let t=1;t({mountPoint:e.mountPoint,filesystem:e.filesystem}))}isMountPoint(e){let t=lH(e);return this.mounts.has(t)}validateMountPath(e){let t=e.split(`/`);for(let n of t)if(n===`.`||n===`..`)throw Error(`Invalid mount point '${e}': contains '.' or '..' segments`)}validateMount(e){if(e===`/`)throw Error(`Cannot mount at root '/'`);for(let t of this.mounts.keys())if(t!==e){if(e.startsWith(`${t}/`))throw Error(`Cannot mount at '${e}': inside existing mount '${t}'`);if(t.startsWith(`${e}/`))throw Error(`Cannot mount at '${e}': would contain existing mount '${t}'`)}}routePath(e){dH(e,`access`);let t=lH(e),n=null,r=0;for(let e of this.mounts.values()){let i=e.mountPoint;if(t===i)return{fs:e.filesystem,relativePath:`/`};t.startsWith(`${i}/`)&&i.length>r&&(n=e,r=i.length)}if(n){let e=t.slice(r);return{fs:n.filesystem,relativePath:e||`/`}}return{fs:this.baseFs,relativePath:t}}getChildMountPoints(e){let t=lH(e),n=t===`/`?`/`:`${t}/`,r=[];for(let e of this.mounts.keys())if(e.startsWith(n)){let t=e.slice(n.length).split(`/`)[0];t&&!r.includes(t)&&r.push(t)}return r}async readFile(e,t){let{fs:n,relativePath:r}=this.routePath(e);return n.readFile(r,t)}async readFileBytes(e){let{fs:t,relativePath:n}=this.routePath(e);return SB(t,n)}async readFileBuffer(e){let{fs:t,relativePath:n}=this.routePath(e);return t.readFileBuffer(n)}async writeFile(e,t,n){let{fs:r,relativePath:i}=this.routePath(e);return r.writeFile(i,t,n)}async appendFile(e,t,n){let{fs:r,relativePath:i}=this.routePath(e);return r.appendFile(i,t,n)}async exists(e){let t=lH(e);if(this.mounts.has(t)||this.getChildMountPoints(t).length>0)return!0;let{fs:n,relativePath:r}=this.routePath(e);return n.exists(r)}async stat(e){let t=lH(e),n=this.mounts.get(t);if(n)try{return await n.filesystem.stat(`/`)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}if(this.getChildMountPoints(t).length>0)try{return await this.baseFs.stat(t)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:r,relativePath:i}=this.routePath(e);return r.stat(i)}async lstat(e){let t=lH(e),n=this.mounts.get(t);if(n)try{return await n.filesystem.lstat(`/`)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}if(this.getChildMountPoints(t).length>0)try{return await this.baseFs.lstat(t)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:r,relativePath:i}=this.routePath(e);return r.lstat(i)}async mkdir(e,t){let n=lH(e);if(this.mounts.has(n)){if(t?.recursive)return;throw Error(`EEXIST: directory already exists, mkdir '${e}'`)}if(this.getChildMountPoints(n).length>0&&t?.recursive)return;let{fs:r,relativePath:i}=this.routePath(e);return r.mkdir(i,t)}async readdir(e){let t=lH(e),n=new Set,r=null,{fs:i,relativePath:a}=this.routePath(e);try{let e=await i.readdir(a);for(let t of e)n.add(t)}catch(e){let t=e.code,n=e.message||``;if(t!==`ENOENT`&&!n.includes(`ENOENT`))throw e;r=e}let o=this.getChildMountPoints(t);for(let e of o)n.add(e);if(n.size===0&&r&&!this.mounts.has(t))throw r;return Array.from(n).sort()}async rm(e,t){let n=lH(e);if(this.mounts.has(n))throw Error(`EBUSY: mount point, cannot remove '${e}'`);if(this.getChildMountPoints(n).length>0)throw Error(`EBUSY: contains mount points, cannot remove '${e}'`);let{fs:r,relativePath:i}=this.routePath(e);return r.rm(i,t)}async cp(e,t,n){if((await this.stat(e)).isDirectory&&uH(e,t))throw Error(`EINVAL: cannot copy '${e}' into itself, '${t}'`);let r=this.routePath(e),i=this.routePath(t);return r.fs===i.fs?r.fs.cp(r.relativePath,i.relativePath,n):this.crossMountCopy(e,t,n)}async mv(e,t){let n=lH(e);if((await this.stat(e)).isDirectory&&uH(e,t))throw Error(`EINVAL: cannot move '${e}' into itself, '${t}'`);if(this.mounts.has(n))throw Error(`EBUSY: mount point, cannot move '${e}'`);let r=this.routePath(e),i=this.routePath(t);if(r.fs===i.fs)return r.fs.mv(r.relativePath,i.relativePath);await this.cp(e,t,{recursive:!0}),await this.rm(e,{recursive:!0})}resolvePath(e,t){return pH(e,t)}getAllPaths(){let e=new Set;for(let t of this.baseFs.getAllPaths())e.add(t);for(let t of this.mounts.keys()){let n=t.split(`/`).filter(Boolean),r=``;for(let t of n)r=`${r}/${t}`,e.add(r);let i=this.mounts.get(t);if(i)for(let n of i.filesystem.getAllPaths())n===`/`?e.add(t):e.add(`${t}${n}`)}return Array.from(e).sort()}async chmod(e,t){let n=lH(e),r=this.mounts.get(n);if(r)return r.filesystem.chmod(`/`,t);let{fs:i,relativePath:a}=this.routePath(e);return i.chmod(a,t)}async symlink(e,t){let{fs:n,relativePath:r}=this.routePath(t);return n.symlink(e,r)}async link(e,t){let n=this.routePath(e),r=this.routePath(t);if(n.fs!==r.fs)throw Error(`EXDEV: cross-device link not permitted, link '${e}' -> '${t}'`);return n.fs.link(n.relativePath,r.relativePath)}async readlink(e){let{fs:t,relativePath:n}=this.routePath(e);return t.readlink(n)}async realpath(e){let t=lH(e);if(this.mounts.get(t))return t;let{fs:n,relativePath:r}=this.routePath(e),i=await n.realpath(r);for(let[e,n]of this.mounts)if(t===e||t.startsWith(`${e}/`))return i===`/`?e:`${e}${i}`;return i}async crossMountCopy(e,t,n){let r=await this.lstat(e);if(r.isFile){let n=await this.readFileBuffer(e);await this.writeFile(t,n),await this.chmod(t,r.mode)}else if(r.isDirectory){if(!n?.recursive)throw Error(`cp: ${e} is a directory (not copied)`);await this.mkdir(t,{recursive:!0});let r=await this.readdir(e);for(let i of r){let r=mH(e,i),a=mH(t,i);await this.crossMountCopy(r,a,n)}}else if(r.isSymbolicLink){let n=await this.readlink(e);await this.symlink(n,t)}}async utimes(e,t,n){let{fs:r,relativePath:i}=this.routePath(e);return r.utimes(i,t,n)}};U();var l8=`/dev/fd`,u8=63,d8=u8-10+1,uje=class extends J2{isLiveDescriptor;constructor(e){super(),this.isLiveDescriptor=e}assertLiveDescriptor(e,t){this.isLiveDescriptor(e)||this.refuse(e,t)}refuse(e,t){throw Error(`EROFS: read-only file system, ${t} '${l8}${e}'`)}async writeFile(e,t,n){return this.assertLiveDescriptor(e,`write`),super.writeFile(e,t,n)}async appendFile(e,t,n){return this.assertLiveDescriptor(e,`append`),super.appendFile(e,t,n)}async rm(e,t){return this.assertLiveDescriptor(e,`rm`),super.rm(e,t)}async mkdir(e,t){this.refuse(e,`mkdir`)}async cp(e,t){this.refuse(t,`cp`)}async mv(e,t){this.refuse(t,`mv`)}async symlink(e,t){this.refuse(t,`symlink`)}async link(e,t){this.refuse(t,`link`)}async chmod(e,t){this.refuse(e,`chmod`)}async utimes(e,t,n){this.refuse(e,`utimes`)}};function dje(e){let t=new uje(t=>f8(e).some(e=>e.path===`${l8}${t}`));e.fs=new lje({base:e.fs,mounts:[{mountPoint:l8,filesystem:t}]}),e.state.processSubstitutionFsMounted=!0}async function fje(e,t,n){try{await e.fs.writeFile(t,n,`binary`);return}catch(t){if(e.state.processSubstitutionFsMounted)throw t;dje(e)}await e.fs.writeFile(t,n,`binary`)}async function pje(e,t){try{await e.fs.rm(t,{force:!0})}catch{}}function f8(e){let t=e.state.processSubstitutions;if(t)return t;let n=[];return e.state.processSubstitutions=n,n}async function p8(e,t,n){let r=e.substitutionDepth??0,i=e.limits.maxSubstitutionDepth;if(r>=i)throw new H(`Process substitution nesting limit exceeded (${i})`,`substitution_depth`);let a=e.substitutionDepth,o=new Map(e.state.env),s=Z2(e.state.arrays),c=e.state.cwd,l=e.state.bashPid,u=e.state.suppressVerbose,d=e.state.groupStdin,f=e.state.lastExitCode,p=e.state.env.get(`?`);e.substitutionDepth=r+1,e.state.bashPid=e.state.nextVirtualPid++,e.state.suppressVerbose=!0,n!==void 0&&(e.state.groupStdin=n);let m;try{m=await e.executeScript(t)}catch(e){if(e instanceof H)throw e;if(e instanceof RB)return{stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode};throw e}finally{e.substitutionDepth=a,e.state.env=o,e.state.arrays=s,e.state.cwd=c,e.state.bashPid=l,e.state.suppressVerbose=u,e.state.groupStdin=d,e.state.lastExitCode=f,p===void 0?e.state.env.delete(`?`):e.state.env.set(`?`,p)}return m}async function mje(e,t){let n=f8(e);if(n.length>=d8)throw new H(`Process substitution limit exceeded (${d8} concurrent)`,`file_descriptors`);let r=``;if(t.direction===`input`){let n=await p8(e,t.body,void 0);if(n.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+n.stderr),r=wB(n),r.length>e.limits.maxStringLength)throw new H(`process substitution: string length limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`)}let i=u8-n.length,a=`${l8}/${i}`;n.push({fd:i,path:a,direction:t.direction,body:t.body});try{await fje(e,a,r)}catch(e){throw n.pop(),e}return a}function hje(e){return e.state.processSubstitutions?.length??0}var gje={stdout:``,stderr:``};async function m8(e,t){let n=e.state.processSubstitutions;if(!n||n.length<=t)return gje;let r=``,i=``;for(;n.length>t;){let t=n[n.length-1],a=``;if(t.direction===`output`)try{a=await SB(e.fs,t.path)}catch{}if(await pje(e,t.path),n.pop(),t.direction===`output`){let n=await p8(e,t.body,a);r+=wB(n),i+=n.stderr}}return{stdout:r,stderr:i}}function h8(e,t,n){if(e.length>t)throw new H(`${n}: string length limit exceeded (${t} bytes)`,`string_length`)}async function g8(e,t,n=!1){let r=[];for(let i of t)r.push(await E8(e,i,n));return r.join(``)}function _je(e){return cje(e)}function vje(e){if(e.parts.length===0)return!0;for(let t of e.parts)if(!_je(t))return!1;return!0}function yje(e,t,n=!1){let r=sje(t);if(r!==null)return r;switch(t.type){case`TildeExpansion`:return n?t.user===null?`~`:`~${t.user}`:(e.coverage?.hit(`bash:expansion:tilde`),t.user===null?e.state.env.get(`HOME`)??`/home/user`:t.user===`root`?`/root`:`~${t.user}`);case`Glob`:return q6(e,t.pattern);default:return null}}async function _8(e,t){return T8(e,t)}async function bje(e,t){let n=[];for(let r of t.parts)if(r.type===`Escaped`)n.push(A6(r.value));else if(r.type===`SingleQuoted`)n.push(r.value);else if(r.type===`DoubleQuoted`){let t=await g8(e,r.parts);n.push(t)}else if(r.type===`TildeExpansion`){let t=await E8(e,r);n.push(A6(t))}else n.push(await E8(e,r));return n.join(``)}async function xje(e,t){let n=[];for(let r of t.parts)if(r.type===`Escaped`){let e=r.value;`()|*?[]`.includes(e)?n.push(`\\${e}`):n.push(e)}else if(r.type===`SingleQuoted`)n.push(k6(r.value));else if(r.type===`DoubleQuoted`){let t=await g8(e,r.parts);n.push(k6(t))}else n.push(await E8(e,r));return n.join(``)}async function v8(e,t){let n=[];for(let r of t.parts)if(r.type===`SingleQuoted`)n.push(k6(r.value));else if(r.type===`Escaped`){let e=r.value;`*?[]\\()|`.includes(e)?n.push(`\\${e}`):n.push(e)}else if(r.type===`DoubleQuoted`){let t=await g8(e,r.parts);n.push(k6(t))}else r.type===`Glob`?mAe(r.pattern)?n.push(await gAe(e,r.pattern)):n.push(q6(e,r.pattern)):r.type===`Literal`?n.push(r.value):n.push(await E8(e,r));return n.join(``)}function y8(e){for(let t of e)if(t.type===`BraceExpansion`||t.type===`DoubleQuoted`&&y8(t.parts))return!0;return!1}var b8=1e5;async function x8(e,t,n={count:0}){let r=()=>{n.count++,e.executionScope.consumeLimited(`brace_operations`,1,Math.min(b8,e.limits.maxBraceExpansionResults),`brace expansion`)},i=(t,n)=>{if(t.length>=e.limits.maxBraceExpansionResults)throw new H(`brace expansion result limit exceeded (${e.limits.maxBraceExpansionResults})`,`array_elements`);r(),t.push(n)},a=[[]];for(let o of t)if(o.type===`BraceExpansion`){let t=[],s=!1,c=``;for(let r of o.items)if(r.type===`Range`){let n=E6(r.start,r.end,r.step,r.startStr,r.endStr,{maxResults:e.limits.maxBraceExpansionResults,maxStringBytes:e.limits.maxStringLength});if(n.expanded)for(let e of n.expanded)i(t,e);else{s=!0,c=n.literal;break}}else{let a=await x8(e,r.word.parts,n);for(let n of a){let r=[];for(let t of n)typeof t==`string`?r.push(t):r.push(await E8(e,t));i(t,r.join(``))}}if(s){for(let e of a)r(),e.push(c);continue}if(a.length*t.length>e.limits.maxBraceExpansionResults||n.count>b8)throw new H(`brace expansion result limit exceeded (${e.limits.maxBraceExpansionResults})`,`array_elements`);let l=[];for(let n of a)for(let i of t){if(l.length>=e.limits.maxBraceExpansionResults)throw new H(`brace expansion result limit exceeded (${e.limits.maxBraceExpansionResults})`,`array_elements`);r(),l.push([...n,i])}a=l}else for(let e of a)r(),e.push(o);return a}async function S8(e,t){let n=t.parts;if(!y8(n))return[await _8(e,t)];let r=await x8(e,n),i=[];for(let t of r){let n=[];for(let r of t)typeof r==`string`?n.push(r):n.push(await E8(e,r));i.push(J6(e,n.join(``)))}return i}function Sje(){return{expandWordAsync:T8,expandWordForGlobbing:v8,expandWordWithBracesAsync:S8,expandWordPartsAsync:g8,expandPart:E8,expandParameterAsync:D8,hasBraceExpansion:y8,evaluateArithmetic:N8,buildIfsCharClassPattern:Ike,smartWordSplit:aje}}async function C8(e,t){return qAe(e,t,Sje())}function Cje(e){for(let t of e){if(t.type===`ParameterExpansion`)return t.parameter;if(t.type===`Literal`)return t.value}return``}function w8(e,t){if(Number.parseInt(e.state.env.get(`#`)||`0`,10)<2)return!1;function n(e){for(let t of e)if(t.type===`DoubleQuoted`){for(let e of t.parts)if(e.type===`ParameterExpansion`&&e.parameter===`@`&&!e.operation)return!0}return!1}return n(t.parts)}async function wje(e,t){if(w8(e,t))return{error:`bash: $@: ambiguous redirect `};let n=t.parts,{hasQuoted:r}=Q3(n);if(y8(n)&&(await S8(e,t)).length>1)return{error:`bash: ${n.map(e=>e.type===`Literal`?e.value:e.type===`BraceExpansion`?`{${e.items.map(e=>{if(e.type===`Range`){let t=e.step?`..${e.step}`:``;return`${e.startStr??e.start}..${e.endStr??e.end}${t}`}return e.word.parts.map(e=>e.type===`Literal`?e.value:``).join(``)}).join(`,`)}}`:``).join(``)}: ambiguous redirect `};let i=await T8(e,t),{hasParamExpansion:a,hasCommandSub:o}=Q3(n);if((a||o)&&!r&&!n6(e.state.env)&&c6(i,t6(e.state.env),e.limits.maxArrayElements).length>1)return{error:`bash: $${Cje(n)}: ambiguous redirect `};if(r||e.state.options.noglob||n.some(e=>e.type===`ProcessSubstitution`))return{target:i};let s=await v8(e,t);if(!D6(s,e.state.shoptOptions.extglob))return{target:i};let c=new X3(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations,consumeOperation:()=>e.executionScope.consumeLimited(`glob_operations`,1,e.limits.maxGlobOperations,`glob expansion`)}),l=await c.expand(s);return l.length===0?c.hasFailglob()?{error:`bash: no match: ${i} `}:{target:i}:l.length===1?{target:l[0]}:{error:`bash: ${i}: ambiguous redirect `}}async function T8(e,t){let n=t.parts,r=n.length;if(r===1){let t=await E8(e,n[0]);return h8(t,e.limits.maxStringLength,`word expansion`),t}let i=[];for(let t=0;t=i)throw new H(`Command substitution nesting limit exceeded (${i})`,`substitution_depth`);let a=e.substitutionDepth;e.substitutionDepth=r+1;let o=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let s=new Map(e.state.env),c=Z2(e.state.arrays),l=e.state.cwd,u=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let n=await e.executeScript(t.body),r=n.exitCode;e.state.env=s,e.state.arrays=c,e.state.cwd=l,e.state.suppressVerbose=u,e.state.lastExitCode=r,e.state.env.set(`?`,String(r)),n.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+n.stderr),e.state.bashPid=o,e.substitutionDepth=a;let i=n.stdout.replace(/\n+$/,``);return h8(i,e.limits.maxStringLength,`command substitution`),i}catch(t){if(e.state.env=s,e.state.arrays=c,e.state.cwd=l,e.state.bashPid=o,e.substitutionDepth=a,e.state.suppressVerbose=u,t instanceof H)throw t;if(t instanceof RB){e.state.lastExitCode=t.exitCode,e.state.env.set(`?`,String(t.exitCode)),t.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+t.stderr);let n=t.stdout.replace(/\n+$/,``);return h8(n,e.limits.maxStringLength,`command substitution`),n}throw t}}case`ProcessSubstitution`:return mje(e,t);case`ArithmeticExpansion`:{let n=t.expression.originalText;if(n&&/\$[a-zA-Z_][a-zA-Z0-9_]*(?![{[(])/.test(n)){let t=await Uke(e,n),r=P4(new T3,t);return String(await N8(e,r.expression,!0))}return String(await N8(e,t.expression.expression,!0))}case`BraceExpansion`:{let n=[];for(let r of t.items)if(r.type===`Range`){let t=E6(r.start,r.end,r.step,r.startStr,r.endStr,{maxResults:e.limits.maxBraceExpansionResults,maxStringBytes:e.limits.maxStringLength});if(t.expanded)n.push(...t.expanded);else return t.literal}else n.push(await _8(e,r.word));return n.join(` `)}default:return``}}async function D8(e,t,n=!1){let{parameter:r}=t,{operation:i}=t,a=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(a){let[,t,n]=a;(e.state.associativeArrays?.has(t)||n.includes(`$(`)||n.includes("`")||n.includes("${"))&&(r=`${t}[${await S6(e,n)}]`)}else if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)&&l6(e,r)){let t=m6(e,r);if(t&&t!==r){let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let[,t,i]=n;(e.state.associativeArrays?.has(t)||i.includes(`$(`)||i.includes("`")||i.includes("${"))&&(r=`${t}[${await S6(e,i)}]`)}}}let o=i&&(i.type===`DefaultValue`||i.type===`AssignDefault`||i.type===`UseAlternative`||i.type===`ErrorIfUnset`),s=await b6(e,r,!o);if(!i)return s;let c=!await x6(e,r),{isEmpty:l,effectiveValue:u}=pAe(e,r,s,n),d={value:s,isUnset:c,isEmpty:l,effectiveValue:u,inDoubleQuotes:n};switch(i.type){case`DefaultValue`:return eAe(e,i,d,g8);case`AssignDefault`:return tAe(e,r,i,d,g8);case`ErrorIfUnset`:return nAe(e,r,i,d,g8);case`UseAlternative`:return rAe(e,i,d,g8);case`PatternRemoval`:{let t=await iAe(e,s,i,g8,E8);return h8(t,e.limits.maxStringLength,`pattern removal`),t}case`PatternReplacement`:{let t=await aAe(e,s,i,g8,E8);return h8(t,e.limits.maxStringLength,`pattern replacement`),t}case`Length`:return oAe(e,r,s);case`LengthSliceError`:throw new BB(r);case`BadSubstitution`:throw new BB(i.text);case`Substring`:return sAe(e,r,s,i);case`CaseModification`:{let t=await cAe(e,s,i,g8,D8);return h8(t,e.limits.maxStringLength,`case modification`),t}case`Transform`:return lAe(e,r,s,c,i);case`Indirection`:return uAe(e,r,s,c,i,D8,n);case`ArrayKeys`:return dAe(e,i);case`VarNamePrefix`:return fAe(e,i);default:return s}}function O8(){return{visited:new Set,depth:0}}function Tje(e,t,n){switch(n){case`+`:return e+t;case`-`:return e-t;case`*`:return e*t;case`/`:if(t===0)throw new zB(`division by 0`);return Math.trunc(e/t);case`%`:if(t===0)throw new zB(`division by 0`);return e%t;case`**`:if(t<0)throw new zB(`exponent less than 0`);return e**t;case`<<`:return e<>`:return e>>t;case`<`:return+(e`:return+(e>t);case`>=`:return+(e>=t);case`==`:return+(e===t);case`!=`:return e===t?0:1;case`&`:return e&t;case`|`:return e|t;case`^`:return e^t;case`,`:return t;default:return 0}}function k8(e,t,n){switch(n){case`=`:return t;case`+=`:return e+t;case`-=`:return e-t;case`*=`:return e*t;case`/=`:return t===0?0:Math.trunc(e/t);case`%=`:return t===0?0:e%t;case`<<=`:return e<>=`:return e>>t;case`&=`:return e&t;case`|=`:return e|t;case`^=`:return e^t;default:return t}}function Eje(e,t){switch(t){case`-`:return-e;case`+`:return+e;case`!`:return+(e===0);case`~`:return~e;default:return e}}async function Dje(e,t){let n=e.state.env.get(t);if(n!==void 0)return n;let r=n4(e,t,0);return r===void 0?await b6(e,t):r}async function Oje(e,t,n){if(!t)return 0;let r=Number.parseInt(t,10);if(!Number.isNaN(r)&&/^-?\d+$/.test(t.trim()))return r;let i=t.trim();if(!i)return 0;let{expr:a,pos:o}=L4(new T3,i,0);if(o100)throw new zB(`maximum variable indirection depth exceeded`);if(r.visited.has(t))throw new zB(`arithmetic variable cycle detected at ${t}`);r.visited.add(t),r.depth++;try{return await Oje(e,n,r)}finally{r.depth--,r.visited.delete(t)}}async function j8(e,t,n){if(n.depth>100)throw new zB(`maximum variable indirection depth exceeded`);if(n.visited.has(t))throw new zB(`arithmetic variable cycle detected at ${t}`);n.visited.add(t),n.depth++;try{let r=await Dje(e,t);if(!r)return 0;let i=Number.parseInt(r,10);if(!Number.isNaN(i)&&/^-?\d+$/.test(r.trim()))return i;let a=r.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a))return await j8(e,a,n);let{expr:o,pos:s}=L4(new T3,a,0);if(s0&&(r===-1||nP8(e,t,i,r);switch(t.type){case`ArithNumber`:if(Number.isNaN(t.value))throw new zB(`value too great for base`);return t.value;case`ArithVariable`:return await j8(e,t.name,r);case`ArithSpecialVar`:{let n=(await b6(e,t.name)).trim();if(!n)return 0;let r=Number.parseInt(n,10);if(!Number.isNaN(r)&&/^-?\d+$/.test(n))return r;let{expr:a}=L4(new T3,n,0);return await i(a)}case`ArithNested`:return await i(t.expression);case`ArithCommandSubst`:if(e.execFn){let n=await e.execFn(t.command,{signal:e.state.signal});n.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+n.stderr);let r=n.stdout.trim();return Number.parseInt(r,10)||0}return 0;case`ArithBracedExpansion`:{let n=await M8(e,t.content);return Number.parseInt(n,10)||0}case`ArithDynamicBase`:{let n=await M8(e,t.baseExpr),r=Number.parseInt(n,10);return r<2||r>64?0:N4(`${r}#${t.value}`)}case`ArithDynamicNumber`:return N4(await M8(e,t.prefix)+t.suffix);case`ArithArrayElement`:{let n=e.state.associativeArrays?.has(t.array),a=async n=>{let i=n4(e,t.array,n);return i===void 0?0:await A8(e,`${t.array}[${n}]`,i,r)};if(t.stringKey!==void 0)return await a(t.stringKey);if(n&&t.index?.type===`ArithVariable`&&!t.index.hasDollarPrefix)return await a(t.index.name);if(n&&t.index?.type===`ArithVariable`&&t.index.hasDollarPrefix)return await a(await b6(e,t.index.name));if(t.index){let n=await i(t.index);if(n<0){let r=v6(e,t.array),i=e.state.currentLine;if(r.length===0)return e.state.expansionStderr=(e.state.expansionStderr||``)+`bash: line ${i}: ${t.array}: bad array subscript `,0;let a=Math.max(...r.map(([e])=>typeof e==`number`?e:0))+1+n;if(a<0)return e.state.expansionStderr=(e.state.expansionStderr||``)+`bash: line ${i}: ${t.array}: bad array subscript `,0;n=a}let a=`${t.array}[${n}]`,o=n4(e,t.array,n);if(o!==void 0)return A8(e,a,o,r);if(n===0){let n=e.state.env.get(t.array);if(n!==void 0)return A8(e,t.array,n,r)}if(e.state.options.nounset&&!(e.state.env.has(t.array)||t4(e,t.array)))throw new LB(`${t.array}[${n}]`);return 0}return 0}case`ArithDoubleSubscript`:throw new zB(`double subscript`,``,``);case`ArithNumberSubscript`:throw new zB(`${t.number}${t.errorToken}: syntax error: invalid arithmetic operator (error token is "${t.errorToken}")`);case`ArithSyntaxError`:throw new zB(t.message,``,``,!0);case`ArithSingleQuote`:if(n)throw new zB(`syntax error: operand expected (error token is "'${t.content}'")`);return t.value;case`ArithBinary`:return t.operator===`||`?await i(t.left)||await i(t.right)?1:0:t.operator===`&&`?await i(t.left)&&await i(t.right)?1:0:Tje(await i(t.left),await i(t.right),t.operator);case`ArithUnary`:{let a=await i(t.operand);if(t.operator===`++`||t.operator===`--`){if(t.operand.type===`ArithVariable`){let n=t.operand.name,r=Number.parseInt(await b6(e,n),10)||0,i=t.operator===`++`?r+1:r-1;return e.state.env.set(n,String(i)),t.prefix?i:r}if(t.operand.type===`ArithArrayElement`){let n=t.operand.array,r=e.state.associativeArrays?.has(n),o;if(t.operand.stringKey!==void 0)o=t.operand.stringKey;else if(r&&t.operand.index?.type===`ArithVariable`&&!t.operand.index.hasDollarPrefix)o=t.operand.index.name;else if(r&&t.operand.index?.type===`ArithVariable`&&t.operand.index.hasDollarPrefix)o=await b6(e,t.operand.index.name);else if(t.operand.index){let e=await i(t.operand.index);o=String(e)}else return a;let s=Number.parseInt(n4(e,n,o)||`0`,10)||0,c=t.operator===`++`?s+1:s-1;return i4(e,n,o,String(c),r?`associative`:`indexed`),t.prefix?c:s}if(t.operand.type===`ArithConcat`){let i=``;for(let a of t.operand.parts)i+=await F8(e,a,n,r);if(i&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)){let n=Number.parseInt(e.state.env.get(i)||`0`,10)||0,r=t.operator===`++`?n+1:n-1;return e.state.env.set(i,String(r)),t.prefix?r:n}}if(t.operand.type===`ArithDynamicElement`){let a=``;if(t.operand.nameExpr.type===`ArithConcat`)for(let i of t.operand.nameExpr.parts)a+=await F8(e,i,n,r);else t.operand.nameExpr.type===`ArithVariable`&&(a=t.operand.nameExpr.hasDollarPrefix?await b6(e,t.operand.nameExpr.name):t.operand.nameExpr.name);if(a&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a)){let n=await i(t.operand.subscript),r=Number.parseInt(n4(e,a,n)||`0`,10)||0,o=t.operator===`++`?r+1:r-1;return i4(e,a,n,String(o)),t.prefix?o:r}}return a}return Eje(a,t.operator)}case`ArithTernary`:return await i(t.condition)?await i(t.consequent):await i(t.alternate);case`ArithAssignment`:{let n=t.variable,r=n,a;if(t.stringKey!==void 0)a=t.stringKey;else if(t.subscript){let r=e.state.associativeArrays?.has(n);if(r&&t.subscript.type===`ArithVariable`&&!t.subscript.hasDollarPrefix)a=t.subscript.name;else if(r&&t.subscript.type===`ArithVariable`&&t.subscript.hasDollarPrefix)a=await b6(e,t.subscript.name)||`\\`;else if(r){let e=await i(t.subscript);a=String(e)}else{let r=await i(t.subscript);if(r<0){let t=v6(e,n);t.length>0&&(r=Math.max(...t.map(([e])=>typeof e==`number`?e:0))+1+r)}a=String(r)}}let o=a===void 0?e.state.env.get(r):n4(e,n,a),s=k8(Number.parseInt(o||`0`,10)||0,await i(t.value),t.operator);return a===void 0?e.state.env.set(r,String(s)):i4(e,n,a,String(s),e.state.associativeArrays?.has(n)?`associative`:`indexed`),s}case`ArithGroup`:return await i(t.expression);case`ArithConcat`:{let i=``;for(let a of t.parts)i+=await F8(e,a,n,r);return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)?await j8(e,i,r):Number.parseInt(i,10)||0}case`ArithDynamicAssignment`:{let a=``;if(t.target.type===`ArithConcat`)for(let i of t.target.parts)a+=await F8(e,i,n,r);else t.target.type===`ArithVariable`&&(a=t.target.hasDollarPrefix?await b6(e,t.target.name):t.target.name);if(!a||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a))return 0;let o=a;if(t.subscript){let e=await i(t.subscript);o=`${a}_${e}`}let s=k8(Number.parseInt(e.state.env.get(o)||`0`,10)||0,await i(t.value),t.operator);return e.state.env.set(o,String(s)),s}case`ArithDynamicElement`:{let a=``;if(t.nameExpr.type===`ArithConcat`)for(let i of t.nameExpr.parts)a+=await F8(e,i,n,r);else t.nameExpr.type===`ArithVariable`&&(a=t.nameExpr.hasDollarPrefix?await b6(e,t.nameExpr.name):t.nameExpr.name);if(!a||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a))return 0;let o=await i(t.subscript),s=`${a}_${o}`,c=e.state.env.get(s);return c===void 0?0:A8(e,s,c,r)}default:return 0}}async function F8(e,t,n=!1,r=O8()){switch(t.type){case`ArithNumber`:return String(t.value);case`ArithSingleQuote`:return String(await P8(e,t,n,r));case`ArithVariable`:return t.hasDollarPrefix?await b6(e,t.name):t.name;case`ArithSpecialVar`:return await b6(e,t.name);case`ArithBracedExpansion`:return await M8(e,t.content);case`ArithCommandSubst`:return e.execFn?(await e.execFn(t.command,{signal:e.state.signal})).stdout.trim():`0`;case`ArithConcat`:{let i=``;for(let a of t.parts)i+=await F8(e,a,n,r);return i}default:return String(await P8(e,t,n,r))}}ZB(),U();async function kje(e,t){let n=``,r=0;for(let i of t.parts){let t=i.type===`Literal`?i.value:`\0`,a=V(t);if(a>e.limits.maxStringLength-r)throw new H(`array assignment string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);n+=t,r+=a}let i=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!i||!n.endsWith(`)`))return null;let a=i[1],o=[],s=[],c=!1,l=``,u=0,d=0,f=!1,p=!0,m=t=>{let n=V(t);if(n>e.limits.maxStringLength-d-u)throw new H(`array assignment string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);l+=t,u+=n},h=(t,n=!1)=>{if(o.length>=e.limits.maxArrayElements)throw new H(`array assignment element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let r=V(t);if(r>e.limits.maxStringLength-d)throw new H(`array assignment string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);o.push(t),s.push(n),d+=r},g=()=>{h(l,p),l=``,u=0,f=!1,p=!0};for(let n of t.parts)if(n.type===`Literal`){let e=n.value;if(!c){let t=e.indexOf(`=(`);t!==-1&&(c=!0,e=e.slice(t+2))}if(c){e.endsWith(`)`)&&(e=e.slice(0,-1));for(let t of e)/\s/.test(t)?(l||f)&&g():m(t)}}else if(c){if(n.type===`BraceExpansion`){if(/^\[.+\]=/.test(l))m(p4({type:`Word`,parts:[n]}));else{(l||f)&&g();let t=await C8(e,{type:`Word`,parts:[n]});for(let e of t.values)h(e)}}else(n.type===`SingleQuoted`||n.type===`DoubleQuoted`||n.type===`Escaped`)&&(f=!0),p=!1,m(await _8(e,{type:`Word`,parts:[n]}))}(l||f)&&g();let _=o.splice(0),v=s.splice(0);d=0;for(let t=0;t<_.length;t++){let n=_[t];if(!v[t]){h(n);continue}let r=n.match(/^(\[[^\]]+\]=)(.*)$/s);if(r){let t=Y6(e,r[2]);n=r[1]+t}if(n.includes(`{`)&&n.includes(`}`)){let t=new T3().parseWordFromString(n,!1,!1);if(t.parts.some(e=>e.type===`BraceExpansion`)){let n=await C8(e,t);for(let e of n.values)h(e);continue}}h(n)}let y=[`${a}=(`],b=V(y[0]);for(let t=0;t()]/.test(n)&&!n.startsWith(`'`)&&!n.startsWith(`"`)?`'${n.replace(/'/g,`'\\''`)}'`:n;let i=`${t>0?` `:``}${r}`,a=V(i);if(a+1>e.limits.maxStringLength-b)throw new H(`array assignment string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);y.push(i),b+=a}return y.push(`)`),y.join(``)}async function Aje(e,t){let n=-1,r=-1,i=!1;for(let e=0;e0?await _8(e,f):``;return`${d}${i?`+=`:`=`}${p}`}var jje=[`tar`,`yq`,`xan`,`sqlite3`,`python3`,`python`];function Mje(e){return jje.includes(e)}AB(),yH(),jK(),oB(),m$(),hB(),U(),U();var I8=Object.freeze({stdout:``,stderr:``,exitCode:0,internalStdinConsumed:0});function L8(e=``){return{stdout:e,stderr:``,exitCode:0}}function Q(e,t=1){return{stdout:``,stderr:e,exitCode:t}}function $(e,t,n){return{stdout:e,stderr:t,exitCode:n}}function R8(e){return{stdout:``,stderr:``,exitCode:+!e,internalStdinConsumed:0}}function z8(e,t,n=``,r=``){throw new H(e,t,n,r)}function Nje(e){let t=e.state.fileDescriptors;if(t&&t.size>=e.limits.maxFileDescriptors)throw new H(`too many open file descriptors (max ${e.limits.maxFileDescriptors})`,`file_descriptors`)}function Pje(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new WB;return I8}if(t.length>1)throw new RB(1,``,`bash: break: too many arguments `);let n=1;if(t.length>0){let e=Number.parseInt(t[0],10);if(Number.isNaN(e)||e<1)throw new RB(128,``,`bash: break: ${t[0]}: numeric argument required `);n=e}throw new NB(n)}async function Fje(e,t){let n,r=!1,i=!1,a=0;for(;ae);for(let t of i){let i=t.startsWith(`/`)?`${t}/${n}`:`${e.state.cwd}/${t}/${n}`;try{if((await e.fs.stat(i)).isDirectory){n=i,r=!0;break}}catch{}}}}let s=(n.startsWith(`/`)?n:`${e.state.cwd}/${n}`).split(`/`).filter(e=>e&&e!==`.`),c=``;for(let t of s)if(t===`..`)c=c.split(`/`).slice(0,-1).join(`/`)||`/`;else{c=c?`${c}/${t}`:`/${t}`;try{if(!(await e.fs.stat(c)).isDirectory)return Q(`bash: cd: ${n}: Not a directory `)}catch{return Q(`bash: cd: ${n}: No such file or directory `)}}let l=c||`/`;if(i)try{l=await e.fs.realpath(l)}catch{}return e.state.previousDir=e.state.cwd,e.state.cwd=l,e.state.env.set(`PWD`,e.state.cwd),e.state.env.set(`OLDPWD`,e.state.previousDir),L8(r?`${l} `:``)}cH(),AB(),bG(),U();function B8(e,t){return e.fs.resolvePath(e.state.cwd,t)}var Ije=[`-e`,`-a`,`-f`,`-d`,`-r`,`-w`,`-x`,`-s`,`-L`,`-h`,`-k`,`-g`,`-u`,`-G`,`-O`,`-b`,`-c`,`-p`,`-S`,`-t`,`-N`];function V8(e){return Ije.includes(e)}async function H8(e,t,n){let r=B8(e,n);switch(t){case`-e`:case`-a`:return e.fs.exists(r);case`-f`:return await e.fs.exists(r)?(await e.fs.stat(r)).isFile:!1;case`-d`:return await e.fs.exists(r)?(await e.fs.stat(r)).isDirectory:!1;case`-r`:return await e.fs.exists(r)?!!((await e.fs.stat(r)).mode&256):!1;case`-w`:return await e.fs.exists(r)?!!((await e.fs.stat(r)).mode&128):!1;case`-x`:return await e.fs.exists(r)?!!((await e.fs.stat(r)).mode&64):!1;case`-s`:return await e.fs.exists(r)?(await e.fs.stat(r)).size>0:!1;case`-L`:case`-h`:try{return(await e.fs.lstat(r)).isSymbolicLink}catch{return!1}case`-k`:return await e.fs.exists(r)?!!((await e.fs.stat(r)).mode&512):!1;case`-g`:return await e.fs.exists(r)?!!((await e.fs.stat(r)).mode&1024):!1;case`-u`:return await e.fs.exists(r)?!!((await e.fs.stat(r)).mode&2048):!1;case`-G`:case`-O`:return e.fs.exists(r);case`-b`:return!1;case`-c`:return[`/dev/null`,`/dev/zero`,`/dev/random`,`/dev/urandom`,`/dev/tty`,`/dev/stdin`,`/dev/stdout`,`/dev/stderr`].includes(r);case`-p`:return!1;case`-S`:return!1;case`-t`:return!1;case`-N`:return e.fs.exists(r);default:return!1}}var Lje=[`-nt`,`-ot`,`-ef`];function U8(e){return Lje.includes(e)}async function W8(e,t,n,r){let i=B8(e,n),a=B8(e,r);switch(t){case`-nt`:{let[t,n]=await Promise.all([e.fs.stat(i).catch(()=>null),e.fs.stat(a).catch(()=>null)]);return t!==null&&(n===null||t.mtime>n.mtime)}case`-ot`:{let[t,n]=await Promise.all([e.fs.stat(i).catch(()=>null),e.fs.stat(a).catch(()=>null)]);return n!==null&&(t===null||t.mtimen;case`-ge`:return t>=n}}function q8(e){return e===`=`||e===`==`||e===`!=`}function J8(e,t,n,r=!1,i=!1,a=!1,o=256){if(r){let r=r5(t,n,i,a,o);return e===`!=`?!r:r}if(i){let r=t.toLowerCase()===n.toLowerCase();return e===`!=`?!r:r}let s=t===n;return e===`!=`?!s:s}var zje=new Set([`-z`,`-n`]);function Y8(e){return zje.has(e)}function X8(e,t){switch(e){case`-z`:return t===``;case`-n`:return t!==``}}async function Z8(e,t){let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let t=n[1],r=n[2];if(e.state.associativeArrays?.has(t)){let n=r;return(n.startsWith(`'`)&&n.endsWith(`'`)||n.startsWith(`"`)&&n.endsWith(`"`))&&(n=n.slice(1,-1)),n=n.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(t,n)=>e.state.env.get(n)||``),r4(e,t,n)}let i;try{i=await N8(e,P4(new T3,r).expression)}catch{if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else{let t=e.state.env.get(r);i=t?Number.parseInt(t,10):0}}if(i<0){let n=c4(e,t),r=e.state.currentLine;if(n.length===0||(i=Math.max(...n)+1+i,i<0))return e.state.expansionStderr=(e.state.expansionStderr||``)+`bash: line ${r}: ${t}: bad array subscript `,!1}return r4(e,t,i)}return e.state.env.has(t)?!0:e.state.associativeArrays?.has(t)?u4(e,t).length>0:c4(e,t).length>0}async function Q8(e,t){switch(t.type){case`CondBinary`:{let n=await _8(e,t.left),r=t.right.parts.length>0&&t.right.parts.every(e=>e.type===`SingleQuoted`||e.type===`DoubleQuoted`||e.type===`Escaped`&&t.operator!==`=~`),i;if(i=t.operator===`=~`?r?A6(await _8(e,t.right)):await bje(e,t.right):q8(t.operator)&&!r?await xje(e,t.right):await _8(e,t.right),q8(t.operator)){let a=e.state.shoptOptions.nocasematch;return J8(t.operator,n,i,!r,a,!0,e.limits.maxCallDepth)}if(G8(t.operator))return K8(t.operator,await l5(e,n),await l5(e,i));if(U8(t.operator))return W8(e,t.operator,n,i);switch(t.operator){case`=~`:try{let t=e.state.shoptOptions.nocasematch,r=hG(Wje(i),t?`i`:``).match(n);if(l4(e,`BASH_REMATCH`),r)for(let t=0;t`:return n>i;default:return!1}}case`CondUnary`:{let n=await _8(e,t.operand);return V8(t.operator)?H8(e,t.operator,n):Y8(t.operator)?X8(t.operator,n):t.operator===`-v`?await Z8(e,n):t.operator===`-o`&&c5(e,n)}case`CondNot`:return e.state.shoptOptions.extglob&&t.operand.type===`CondGroup`&&t.operand.expression.type===`CondWord`?`!(${await _8(e,t.operand.expression.word)})`!=``:!await Q8(e,t.operand);case`CondAnd`:return await Q8(e,t.left)?await Q8(e,t.right):!1;case`CondOr`:return await Q8(e,t.left)?!0:await Q8(e,t.right);case`CondGroup`:return await Q8(e,t.expression);case`CondWord`:return await _8(e,t.word)!==``;default:return!1}}async function $8(e,t){if(t.length===0)return $(``,``,1);if(t.length===1)return R8(!!t[0]);if(t.length===2){let n=t[0],r=t[1];return n===`(`?Q(`test: '(' without matching ')' `,2):V8(n)?R8(await H8(e,n,r)):Y8(n)?R8(X8(n,r)):n===`!`?R8(!r):n===`-v`?R8(await Z8(e,r)):n===`-o`?R8(c5(e,r)):n===`=`||n===`==`||n===`!=`||n===`<`||n===`>`||n===`-eq`||n===`-ne`||n===`-lt`||n===`-le`||n===`-gt`||n===`-ge`||n===`-nt`||n===`-ot`||n===`-ef`?Q(`test: ${n}: unary operator expected `,2):$(``,``,1)}if(t.length===3){let n=t[0],r=t[1],i=t[2];if(q8(r))return R8(J8(r,n,i));if(G8(r)){let e=d5(n),t=d5(i);return!e.valid||!t.valid?$(``,``,2):R8(K8(r,e.value,t.value))}if(U8(r))return R8(await W8(e,r,n,i));switch(r){case`-a`:return R8(n!==``&&i!==``);case`-o`:return R8(n!==``||i!==``);case`>`:return R8(n>i);case`<`:return R8(n0&&`@*+?!`.includes(e[i-1]);if(r.push(a),a&&n++,n>t)throw new H(`extglob maximum depth (${t}) exceeded`,`recursion`)}else e[i]===`)`&&r.length>0&&r.pop()&&n--}}function i5(e,t){let n=``;for(let r=0;ri5(e,t)),c=s.length>0?s.join(`|`):`(?:)`;if(i===`@`)n+=`(?:${c})`;else if(i===`*`)n+=`(?:${c})*`;else if(i===`+`)n+=`(?:${c})+`;else if(i===`?`)n+=`(?:${c})?`;else if(i===`!`){if(as5(e,t));if(e.every(e=>e!==null)&&e.every(t=>t===e[0])&&e[0]!==null){let t=e[0];if(t===0)n+=`(?:.+)`;else{let e=[];t>0&&e.push(`.{0,${t-1}}`),e.push(`.{${t+1},}`),e.push(`(?!(?:${c})).{${t}}`),n+=`(?:${e.join(`|`)})`}}else n+=`(?:(?!(?:${c})).)*?`}else n+=`(?!(?:${c})$).*`}r=a;continue}}if(i===`\\`){if(r+10;){let t=e[r];if(t===`\\`){r+=2;continue}if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r;r++}return-1}function o5(e){let t=[],n=``,r=0,i=0;for(;is5(e,t));if(i.every(e=>e!==null)&&i.every(e=>e===i[0])){n+=i[0],r=a+1;continue}return null}return null}}if(i===`*`)return null;if(i===`?`){n+=1,r++;continue}if(i===`[`){let t=e.indexOf(`]`,r+1);if(t!==-1){n+=1,r=t+1;continue}n+=1,r++;continue}if(i===`\\`){n+=1,r+=2;continue}n+=1,r++}return n}function c5(e,t){let n=new Map([[`errexit`,()=>e.state.options.errexit===!0],[`nounset`,()=>e.state.options.nounset===!0],[`pipefail`,()=>e.state.options.pipefail===!0],[`xtrace`,()=>e.state.options.xtrace===!0],[`e`,()=>e.state.options.errexit===!0],[`u`,()=>e.state.options.nounset===!0],[`x`,()=>e.state.options.xtrace===!0]]).get(t);return n?n():!1}async function l5(e,t){if(t=t.trim(),t===``)return 0;if(/^[+-]?(\d+#[a-zA-Z0-9@_]+|0[xX][0-9a-fA-F]+|0[0-7]+|\d+)$/.test(t))return u5(t);try{return await N8(e,P4(new T3,t).expression)}catch{return u5(t)}}function Uje(e,t){let n=0;for(let r of e){let e;if(r>=`0`&&r<=`9`)e=r.charCodeAt(0)-48;else if(r>=`a`&&r<=`z`)e=r.charCodeAt(0)-97+10;else if(r>=`A`&&r<=`Z`)e=r.charCodeAt(0)-65+36;else if(r===`@`)e=62;else if(r===`_`)e=63;else return NaN;if(e>=t)return NaN;n=n*t+e}return n}function u5(e){if(e=e.trim(),e===``)return 0;let t=!1;e.startsWith(`-`)?(t=!0,e=e.slice(1)):e.startsWith(`+`)&&(e=e.slice(1));let n,r=e.match(/^(\d+)#([a-zA-Z0-9@_]+)$/);if(r){let e=Number.parseInt(r[1],10);n=e>=2&&e<=64?Uje(r[2],e):0}else n=/^0[xX][0-9a-fA-F]+$/.test(e)?Number.parseInt(e,16):/^0[0-7]+$/.test(e)?Number.parseInt(e,8):Number.parseInt(e,10);return Number.isNaN(n)&&(n=0),t?-n:n}function d5(e){if(e=e.trim(),e===``)return{value:0,valid:!0};let t=!1;if(e.startsWith(`-`)?(t=!0,e=e.slice(1)):e.startsWith(`+`)&&(e=e.slice(1)),!/^\d+$/.test(e))return{value:0,valid:!1};let n=Number.parseInt(e,10);return Number.isNaN(n)?{value:0,valid:!1}:{value:t?-n:n,valid:!0}}function Wje(e){let t=``,n=0;for(;n=n.maxElements)throw new H(`array element limit exceeded (${n.maxElements})`,`array_elements`);e.push(t)}function p5(e,t){if(t&&V(e)>t.maxStringBytes)throw new H(`array assignment string limit exceeded (${t.maxStringBytes} bytes)`,`string_length`);let n=[],r=``,i=!1,a=!1,o=!1,s=!1;for(let c of e){if(o){r+=c,o=!1,s=!0;continue}if(c===`\\`){o=!0;continue}if(c===`'`&&!a){i||(s=!0),i=!i;continue}if(c===`"`&&!i){a||(s=!0),a=!a;continue}if((c===` `||c===` `||c===` `)&&!i&&!a){s&&=(f5(n,r,t),r=``,!1);continue}r+=c,s=!0}return s&&f5(n,r,t),n}function m5(e,t){if(t&&V(e)>t.maxStringBytes)throw new H(`array assignment string limit exceeded (${t.maxStringBytes} bytes)`,`string_length`);let n=[],r=0;for(;r=e.length)break;if(e[r]!==`[`){r++;continue}r++;let i=``;if(e[r]===`'`||e[r]===`"`){let t=e[r];for(r++;r0&&r[r.length-1].scopeIndex===t;)r.pop();r.length===0&&e.state.localVarStack.delete(n)}}U();var y5=new Set([`:`,`.`,`break`,`continue`,`eval`,`exec`,`exit`,`export`,`readonly`,`return`,`set`,`shift`,`trap`,`unset`]);function Qje(e){return y5.has(e)}var b5=new Set([`if`,`then`,`else`,`elif`,`fi`,`case`,`esac`,`for`,`select`,`while`,`until`,`do`,`done`,`in`,`function`,`{`,`}`,`time`,`[[`,`]]`,`!`]),x5=new Set(`:,true,false,cd,export,unset,exit,local,set,break,continue,return,eval,shift,getopts,compgen,complete,compopt,pushd,popd,dirs,source,.,read,mapfile,readarray,declare,typeset,readonly,let,command,shopt,exec,test,[,echo,printf,pwd,alias,unalias,type,hash,ulimit,umask,trap,times,wait,kill,jobs,fg,bg,disown,suspend,fc,history,help,enable,builtin,caller`.split(`,`));AB(),U();var S5=`__file__:`,C5=`__file_append__:`,w5=`__rw__:`,T5=`__dupout__:`,E5=`__dupin__:`,D5=3;function $je(e){let t=e.slice(w5.length),n=t.indexOf(`:`);if(n===-1)return null;let r=Number.parseInt(t.slice(0,n),10);if(Number.isNaN(r)||r<0)return null;let i=n+1,a=t.slice(i,i+r),o=t.slice(i+r+1),s=o.indexOf(`:`);if(s===-1)return null;let c=Number.parseInt(o.slice(0,s),10);return Number.isNaN(c)||c<0?null:{path:a,position:c,content:o.slice(s+1)}}function O5(e,t){let n=Number.parseInt(e.slice(t.length),10);return Number.isNaN(n)?null:n}function eMe(e){if(e.startsWith(S5))return{kind:`output`,path:e.slice(S5.length),append:!1};if(e.startsWith(C5))return{kind:`output`,path:e.slice(C5.length),append:!0};if(e.startsWith(w5)){let t=$je(e);if(t)return{kind:`readwrite`,...t}}if(e.startsWith(T5)){let t=O5(e,T5);if(t!==null)return{kind:`dup-out`,sourceFd:t}}if(e.startsWith(E5)){let t=O5(e,E5);if(t!==null)return{kind:`dup-in`,sourceFd:t}}return{kind:`input`,content:e}}function k5(e){switch(e.kind){case`input`:return e.content;case`output`:return`${e.append?C5:S5}${e.path}`;case`readwrite`:return`${w5}${e.path.length}:${e.path}:${e.position}:${e.content}`;case`dup-out`:return`${T5}${e.sourceFd}`;case`dup-in`:return`${E5}${e.sourceFd}`;case`closed`:throw Error(`Closed descriptors have no table encoding`)}}function tMe(e){return e.state.fileDescriptors??=new Map,e.state.fileDescriptors}function nMe(e,t,n){n?(e.state.inputFds??=new Set,e.state.inputFds.add(t)):e.state.inputFds?.delete(t)}function A5(e,t){return e.state.fdAliases?.get(t)}function j5(e,t){return[...A5(e,t)??[t]]}function M5(e,t){let n=A5(e,t);if(n&&(n.delete(t),e.state.fdAliases?.delete(t),n.size<2))for(let t of n)e.state.fdAliases?.delete(t)}function N5(e,t,n){if(t===n)return;e.state.fdAliases??=new Map;let r=A5(e,n)??new Set([n]);r.add(t);for(let t of r)e.state.fdAliases.set(t,r)}function P5(e,t){return e.state.fileDescriptors?.get(t)}function F5(e,t){let n=P5(e,t);if(n!==void 0)return e.state.inputFds?.has(t)?{kind:`input`,content:n}:eMe(n)}function I5(e,t){return e.state.fileDescriptors?.has(t)===!0}function L5(e,t,n,r){let i=tMe(e);i.has(t)||Nje(e),i.set(t,n),nMe(e,t,r)}function R5(e,t,n,r=!1){M5(e,t),L5(e,t,n,r)}function z5(e,t,n){R5(e,t,k5(n),n.kind===`input`)}function B5(e,t){e.state.fileDescriptors?.delete(t),e.state.inputFds?.delete(t),M5(e,t)}function V5(e,t,n){let r=P5(e,n);return r!==void 0&&(R5(e,t,r,e.state.inputFds?.has(n)===!0),N5(e,t,n),!0)}function H5(e,t,n){let r=P5(e,n);if(r===void 0)return!1;if(t===n)return!0;let i=e.state.inputFds?.has(n)===!0,a=[...A5(e,n)??[]].filter(e=>e!==n);B5(e,n),R5(e,t,r,i);let o=a.find(t=>I5(e,t));return o!==void 0&&N5(e,t,o),!0}function U5(e,t){let n=F5(e,t);if(n===void 0)return{error:`not-open`};switch(n.kind){case`input`:return{content:n.content};case`readwrite`:return{content:n.content.slice(n.position)};case`output`:case`dup-out`:return{error:`write-only`};case`dup-in`:return{error:`not-open`};case`closed`:return{error:`not-open`}}}function W5(e,t,n){let r=F5(e,t);if(r===void 0)return;let i;if(r.kind===`input`)i={kind:`input`,content:r.content.slice(n)};else if(r.kind===`readwrite`)i={...r,position:r.position+n};else return;let a=k5(i),o=i.kind===`input`;for(let n of A5(e,t)??[t])L5(e,n,a,o)}async function G5(e,t,n,r,i){if(t.kind===`output`)return await e.fs.appendFile(t.path,r,i),!0;let a=n.map(t=>F5(e,t)).find(e=>e?.kind===`readwrite`)??t;if(a.kind!==`readwrite`)return!1;let o=a.content.slice(0,a.position)+r+a.content.slice(a.position+r.length),s={...a,position:a.position+r.length,content:o};await e.fs.writeFile(a.path,o,i);let c=k5(s);for(let t of n)I5(e,t)&&L5(e,t,c,!1);return!0}function K5(e,t,n){if(t.has(n))return;let r=A5(e,n);t.set(n,{raw:P5(e,n),isInput:e.state.inputFds?.has(n)===!0,aliases:r?[...r].filter(e=>e!==n):[]})}function q5(e,t){let n=e.state.fileDescriptors;if(n)for(let[r,{raw:i,isInput:a,aliases:o}]of t){if(i===void 0){B5(e,r);continue}R5(e,r,i,a);let t=o.find(e=>n.has(e));t!==void 0&&N5(e,r,t)}}function J5(e){switch(e.operator){case`<`:case`<>`:case`<<`:case`<<-`:case`<<<`:case`<&`:return e.fd??0;case`>`:case`>>`:case`>|`:case`>&`:return e.fd??1;default:return null}}function rMe(e){if(e.fdVariable)return!1;let t=J5(e);return t!==null&&t>=D5}async function iMe(e,t,n,r){try{if(!await e.fs.exists(t))return null;if((await e.fs.stat(t)).isDirectory)return`bash: ${n}: Is a directory `;if(r.checkNoclobber&&e.state.options.noclobber&&!r.isClobber&&n!==`/dev/null`)return`bash: ${n}: cannot overwrite existing file `}catch{return`bash: ${n}: cannot open redirect target `}return null}function Y5(e){let t=Math.min(e.length,8192);for(let n=0;n127)return`utf8`;return`binary`}var X5=`scoped`,aMe=`bare`,oMe=`persistent`,sMe=e=>new H(`too many open file descriptors (max ${e.limits.maxFileDescriptors})`,`file_descriptors`),cMe=(e,t)=>I5(e,t)||(e.state.fileDescriptors?.size??0){let t=Math.max(e.state.nextFd??10,10);for(;I5(e,t);)t+=1;return t},Q5=e=>{let t=e.endsWith(`-`),n=t?e.slice(0,-1):e;return/^\d+$/.test(n)?{sourceFd:Number.parseInt(n,10),move:t}:null},lMe=(e,t,n)=>{let r=F5(e,t);return t{let n=await _8(e,t.content);return t.stripTabs?n.split(` `).map(e=>e.replace(/^\t+/,``)).join(` `):n};async function dMe(e,t,n,r){let i=new Map,a=new Map,o=(t,n)=>e.state.closedStandardFds?.has(t)?{kind:`closed`}:F5(e,t)??n,s=new Map([[0,o(0,{kind:`dup-in`,sourceFd:0})],[1,o(1,{kind:`dup-out`,sourceFd:1})],[2,o(2,{kind:`dup-out`,sourceFd:2})]]),c=r.numericSnapshot,l,u=-1,d=s.get(0);d?.kind===`input`?(l=d.content,u=0):d?.kind===`readwrite`&&(l=d.content.slice(d.position),u=0);let f=()=>({targets:i,dupSources:a,standardRoutes:s,stdin:l,stdinSourceFd:u,error:null}),p=async(n,r,o)=>{let c={...f(),error:await a7(e,n,t.slice(0,r),i,a,s)};return o?{...c,errorCause:o}:c},m=async(t,n)=>{if(cMe(e,t))return null;let r=sMe(e);return p($(``,r.stderr,H.EXIT_CODE),n,r)},h=(t,n)=>{t!==null&&t{s.set(t,n),K5(e,r.standardSnapshot,t),r.standardClosedSnapshot.has(t)||r.standardClosedSnapshot.set(t,e.state.closedStandardFds?.has(t)===!0),e.state.closedStandardFds?.delete(t),z5(e,t,n)},_=(t,n)=>{if(t=D5){let n=await m(f,o);if(n)return n;K5(e,c,f),z5(e,f,{kind:`input`,content:t})}else if(f===0||f===null)l=bB(t),u=-1,h(f,{kind:`input`,content:l});else{let e={kind:`input`,content:t};r.policy===`persistent`?h(f,e):g(f,e)}continue}let v,y=d.operator===`>&`||d.operator===`<&`;if(y){if(w8(e,d.target))return p($(``,`bash: $@: ambiguous redirect `,1),o);v=await _8(e,d.target)}else if(d.operator===`<<<`)v=await _8(e,d.target);else{let t=await wje(e,d.target);if(`error`in t)return p($(``,t.error,1),o);v=t.target}if(i.set(o,v),v.includes(`\0`))return p($(``,`bash: ${v.replace(/\0/g,``)}: No such file or directory `,1),o);if(d.fdVariable){try{V6(e,d.fdVariable)}catch(e){if(!(e instanceof RB))throw e;return p($(e.stdout,e.stderr,e.exitCode),o,e)}if(y&&v===`-`){let t=Number.parseInt(e.state.env.get(d.fdVariable)??``,10);Number.isNaN(t)||(K5(e,r.fdVariableSnapshot,t),B5(e,t));continue}let t=Z5(e),n=y?Q5(v):null;if(n&&!_(n.sourceFd,d.operator===`<&`))return p($(``,`bash: ${n.sourceFd}: Bad file descriptor `,1),o);if(!(n?.move===!0&&n.sourceFd>=D5)){let e=await m(t,o);if(e)return e}K5(e,r.fdVariableSnapshot,t),r.fdVariableEnv.has(d.fdVariable)||r.fdVariableEnv.set(d.fdVariable,e.state.env.get(d.fdVariable));let i,a;if(y){let t=n;if(t){let e=_(t.sourceFd,d.operator===`<&`);if(!e)return p($(``,`bash: ${t.sourceFd}: Bad file descriptor `,1),o);a=t,e.kind===`standard`?i={kind:d.operator===`<&`?`dup-in`:`dup-out`,sourceFd:e.fd}:t.sourceFd`||d.operator===`>|`||d.operator===`>>`||d.operator===`&>`||d.operator===`&>>`){let t=d.operator===`>>`||d.operator===`&>>`,n=await $5(e,v,t,d.operator===`>|`);if(n.error)return p(n.error,o);i=n.entry}else if(d.operator===`<<<`)i={kind:`input`,content:`${v} `};else if(d.operator===`<`||d.operator===`<>`){let t=await e7(e,v,d.operator===`<>`);if(t.error)return p(t.error,o);i=t.entry}if(a&&a.sourceFd>=D5){if(!(a.move?H5(e,t,a.sourceFd):V5(e,t,a.sourceFd)))return p($(``,`bash: ${a.sourceFd}: Bad file descriptor `,1),o)}else i&&z5(e,t,i);a?.move&&a.sourceFd!==t&&a.sourceFd=D5)){let e=await m(t,o);if(e)return e}if(K5(e,c,t),y){let r=n;if(!r){if(d.operator===`<&`)return p($(``,`bash: ${v}: ambiguous redirect `,1),o);let n=await $5(e,v,!1,!1);if(n.error)return p(n.error,o);z5(e,t,n.entry);continue}let i=_(r.sourceFd,d.operator===`<&`);if(!i)return p($(``,`bash: ${r.sourceFd}: Bad file descriptor `,1),o);if(i.kind===`standard`)z5(e,t,{kind:d.operator===`<&`?`dup-in`:`dup-out`,sourceFd:i.fd});else if(r.sourceFd`||d.operator===`>|`||d.operator===`>>`){let n=await $5(e,v,d.operator===`>>`,d.operator===`>|`);if(n.error)return p(n.error,o);z5(e,t,n.entry)}else if(d.operator===`<<<`)z5(e,t,{kind:`input`,content:`${v} `});else if(d.operator===`<`||d.operator===`<>`){let n=await e7(e,v,d.operator===`<>`);if(n.error)return p(n.error,o);z5(e,t,n.entry)}continue}if(y){if(v===`-`){f===0&&(l=``,u=-1),f!==null&&f=D5){if(!V5(e,f,t.sourceFd))return p($(``,`bash: ${t.sourceFd}: Bad file descriptor `,1),o);s.set(f,F5(e,f)),e.state.closedStandardFds?.delete(f)}else i.kind===`standard`?h(f,{kind:d.operator===`<&`?`dup-in`:`dup-out`,sourceFd:i.fd}):h(f,i.entry);if(d.operator===`<&`&&f===0){if(i.kind===`standard`)l=i.fd===0?n:``,u=-1;else if(i.entry.kind===`input`||i.entry.kind===`readwrite`){let n=t.sourceFd=D5?B5(e,t.sourceFd):(s.set(t.sourceFd,{kind:`closed`}),r.policy===`persistent`&&(B5(e,t.sourceFd),e.state.closedStandardFds??=new Set,e.state.closedStandardFds.add(t.sourceFd))));continue}if(d.operator===`>`||d.operator===`>|`||d.operator===`>>`||d.operator===`&>`||d.operator===`&>>`){let t=await $5(e,v,d.operator===`>>`||d.operator===`&>>`,d.operator===`>|`,!1);if(t.error)return p(t.error,o);let n=t.entry;d.operator===`&>`||d.operator===`&>>`?(h(1,n),h(2,n)):h(f,n);continue}if(d.operator===`<<<`)l=bB(`${v} `),u=-1,h(f,{kind:`input`,content:l});else if(d.operator===`<`){let t=e.fs.resolvePath(e.state.cwd,v);try{l=await SB(e.fs,t),u=-1,h(f,{kind:`input`,content:l})}catch{return p($(``,`bash: ${v}: No such file or directory `,1),o)}}else if(d.operator===`<>`){let t=await e7(e,v,!0);if(t.error)return p(t.error,o);let n=t.entry;h(f,n),f===0&&n.kind===`readwrite`&&(l=n.content,u=-1)}}return f()}function t7(e,t,n){let r={numericSnapshot:new Map,fdVariableSnapshot:new Map,standardSnapshot:new Map,standardClosedSnapshot:new Map,fdVariableEnv:new Map,nextFd:e.state.nextFd,policy:n},i=!1;return{prepare:(n=``)=>dMe(e,t,n,r),finish:()=>{if(!i){if(i=!0,n!==`persistent`&&q5(e,r.numericSnapshot),n!==`persistent`){q5(e,r.standardSnapshot);for(let[t,n]of r.standardClosedSnapshot)n?(e.state.closedStandardFds??=new Set,e.state.closedStandardFds.add(t)):e.state.closedStandardFds?.delete(t)}if(n===`bare`){q5(e,r.fdVariableSnapshot);for(let[t,n]of r.fdVariableEnv)n===void 0?e.state.env.delete(t):e.state.env.set(t,n);e.state.nextFd=r.nextFd}}}}}function n7(e){if(!e.error)throw Error(`Expected a redirection error`);if(e.errorCause)throw e.errorCause.stdout=e.error.stdout,e.errorCause.stderr=e.error.stderr,e.errorCause;return e.error}async function r7(e,t,n,r){let i=t instanceof RB||t instanceof FB||t instanceof IB?t.exitCode:t instanceof H?H.EXIT_CODE:0,a=await a7(e,$(t.stdout,t.stderr,i),n,r.targets,r.dupSources,r.standardRoutes);t.stdout=a.stdout,t.stderr=a.stderr,t.internalOutputAccounting=a.internalOutputAccounting??{stdout:V(a.stdout),stderr:V(a.stderr)}}async function i7(e,t,n,r){let i=t7(e,t,X5),a;try{if(a=await i.prepare(n),a.error)return n7(a);let o=e.state.groupStdin,s=e.state.groupStdinSourceFd;a.stdin!==void 0&&(e.state.groupStdin=a.stdin,e.state.groupStdinSourceFd=a.stdinSourceFd);try{return await a7(e,await r(a),t,a.targets,a.dupSources,a.standardRoutes)}finally{a.stdin!==void 0&&(e.state.groupStdin=o,e.state.groupStdinSourceFd=s)}}catch(n){throw!(n instanceof MB)||!a||await r7(e,n,t,a),n}finally{i.finish()}}async function a7(e,t,n,r,i=new Map,a=new Map,o=`bash`,s=!1){n.length>0&&(t=e.executionScope.accountResult(t,`redirection`));let{stdout:c,stderr:l,exitCode:u}=t,d=t.stdoutKind===`bytes`||t.stdoutKind===void 0&&t.stdoutEncoding===`binary`?`binary`:`utf8`,f=e=>d,p={kind:`live-stdout`},m={kind:`live-stderr`},h=e=>{if(!e)return null;if(e.kind===`entry`){if(e.entry.kind===`dup-out`){if(e.entry.sourceFd===1)return{kind:`live-stdout`};if(e.entry.sourceFd===2)return{kind:`live-stderr`}}return e.entry.kind===`output`||e.entry.kind===`readwrite`?{kind:`descriptor`,source:e}:null}return e.fd===1?p:e.fd===2?m:null},g=t=>{let n=a.get(t)??F5(e,t);return n?n.kind===`closed`||n.kind===`input`||n.kind===`dup-in`?{kind:`invalid-output`,fd:t}:n.kind===`dup-out`?n.sourceFd===1?{kind:`live-stdout`}:n.sourceFd===2?{kind:`live-stderr`}:null:n.kind===`output`||n.kind===`readwrite`?{kind:`descriptor`,source:{kind:`entry`,entry:n,descriptors:j5(e,t)}}:null:null};p=g(1)??p,m=g(2)??m;for(let t=0;t`:case`>|`:case`>>`:{let t=a.fd??1;if(t!==1&&t!==2)break;let n=a.operator===`>>`;if(o===`/dev/stdout`){t===2&&(m=p);break}if(o===`/dev/stderr`){t===1&&(p=m);break}if(o===`/dev/full`){l+=`bash: echo: write error: No space left on device `,u=1,t===1&&(c=``);break}if(o===`/dev/null`&&t===2){m={kind:`discard`};break}let r=e.fs.resolvePath(e.state.cwd,o);t===1?p={kind:`file`,path:r,append:n}:m={kind:`file`,path:r,append:n};break}case`>&`:case`<&`:{let e=a.fd??(a.operator===`<&`?0:1);if(e>=D5||e===0)break;if(o===`-`){e===1?p={kind:`discard`}:m={kind:`discard`};break}let n=h(i.get(t));if(!n)break;a.fd==null&&Q5(o)===null?(p=n,m=n):e===1?p=n:e===2&&(m=n);break}case`&>`:p={kind:`file`,path:e.fs.resolvePath(e.state.cwd,o),append:!1},m=p;break;case`&>>`:p={kind:`file`,path:e.fs.resolvePath(e.state.cwd,o),append:!0},m=p}}if(c!==``||l!==``){let t=c,n=l;c=``,l=``,p.kind===`invalid-output`&&t!==``&&(t=``,n+=`${s?``:`bash: `}${o}: write error: Bad file descriptor `,u=1),m.kind===`invalid-output`&&(n=``);let r=async(t,n,r)=>{t.append?await e.fs.appendFile(t.path,n,r):await e.fs.writeFile(t.path,n,r)};if(p===m&&(p.kind===`file`||p.kind===`descriptor`)){let i=t+n;i!==``&&(p.kind===`file`?await r(p,i,f(i)):await G5(e,p.source.entry,p.source.descriptors,i,f(i)))}else for(let[i,a,o]of[[t,p,!0],[n,m,!1]])if(i!==``)switch(a.kind){case`live-stdout`:c+=i;break;case`live-stderr`:l+=i;break;case`file`:await r(a,i,o?f(i):Y5(i));break;case`descriptor`:await G5(e,a.source.entry,a.source.descriptors,i,o?f(i):Y5(i))}}let _=$(c,l,u);if(t.stdoutKind&&(_.stdoutKind=t.stdoutKind),t.stdoutEncoding===`binary`&&(_.stdoutEncoding=`binary`),t.internalPipeStatusOverride&&(_.internalPipeStatusOverride=t.internalPipeStatusOverride),n.length>0||e.state.fileDescriptors?.has(1)===!0||e.state.fileDescriptors?.has(2)===!0){let n=(t.internalOutputAccounting?.stdout??0)+(t.internalOutputAccounting?.stderr??0),r=V(_.stdout),i=V(_.stderr),a=Math.min(r,n);_.internalOutputAccounting={stdout:a,stderr:Math.min(i,n-a)},e.executionScope.accountResult(_,`redirection`)}else t.internalOutputAccounting&&(_.internalOutputAccounting=t.internalOutputAccounting);return _}function fMe(e,t){if(e.state.options.posix&&y5.has(t.name)){let n=`bash: line ${e.state.currentLine}: \`${t.name}': is a special builtin `;throw new RB(2,``,n)}let n={...t,sourceFile:t.sourceFile??e.state.currentSource??`main`};return e.state.functions.set(t.name,n),I8}async function o7(e,t,n,r=``,i,a=!1){e.state.callDepth++,e.state.callDepth>e.limits.maxCallDepth&&(e.state.callDepth--,z8(`${t.name}: maximum recursion depth (${e.limits.maxCallDepth}) exceeded, increase executionLimits.maxCallDepth`,`recursion`)),e.state.funcNameStack||(e.state.funcNameStack=[]),e.state.callLineStack||(e.state.callLineStack=[]),e.state.sourceStack||(e.state.sourceStack=[]),e.state.funcNameStack.unshift(t.name),e.state.callLineStack.unshift(i??e.state.currentLine),e.state.sourceStack.unshift(t.sourceFile??`main`),e.state.localScopes.push(new Map),e.state.localArrayScopes??=[],e.state.localArrayScopes.push(new Map),e.state.localExportedVars||(e.state.localExportedVars=[]),e.state.localExportedVars.push(new Set);let o=new Map,s=Number.parseInt(e.state.env.get(`#`)??`0`,10),c=Math.max(n.length,s);for(let t=0;t{if(l)return;l=!0;let t=e.state.localScopes.length-1,n=e.state.localScopes.pop(),r=e.state.localArrayScopes?.pop();if(n)for(let[t,r]of n)r===void 0?e.state.env.delete(t):e.state.env.set(t,r);if(r){e.state.arrays??=new Map;for(let[t,n]of r)n===void 0?(e.state.arrays.delete(t),e.state.associativeArrays?.delete(t)):(e.state.arrays.set(t,X2(n)),e.state.associativeArrays??=new Set,n.kind===`associative`?e.state.associativeArrays.add(t):e.state.associativeArrays.delete(t))}if(Zje(e,t),e.state.fullyUnsetLocals)for(let[n,r]of e.state.fullyUnsetLocals.entries())r===t&&e.state.fullyUnsetLocals.delete(n);if(e.state.localExportedVars&&e.state.localExportedVars.length>0){let t=e.state.localExportedVars.pop();if(t)for(let n of t)e.state.exportedVars?.delete(n)}for(let[t,n]of o)n===void 0?e.state.env.delete(t):e.state.env.set(t,n);e.state.funcNameStack?.shift(),e.state.callLineStack?.shift(),e.state.sourceStack?.shift(),e.state.callDepth--},d=null,f=t7(e,t.redirections,X5);try{if(d=await f.prepare(r),d.error)return n7(d);let n=d.stdin??r,i=a||d.stdin!==void 0||r!==``;return a7(e,await e.executeCommand(t.body,n,i),t.redirections,d.targets,d.dupSources,d.standardRoutes)}catch(n){if(n instanceof MB&&d&&(await r7(e,n,t.redirections,d),n instanceof FB))return $(n.stdout,n.stderr,n.exitCode);throw n}finally{f.finish(),u()}}var s7=e=>e.type===`Escaped`?X.literal(`\\${e.value}`):e.type===`DoubleQuoted`?{...e,parts:e.parts.map(s7)}:e,c7=[`!`,`[[`,`]]`,`case`,`do`,`done`,`elif`,`else`,`esac`,`fi`,`for`,`function`,`if`,`in`,`then`,`time`,`until`,`while`,`{`,`}`],l7=`.,:,[,alias,bg,bind,break,builtin,caller,cd,command,compgen,complete,compopt,continue,declare,dirs,disown,echo,enable,eval,exec,exit,export,false,fc,fg,getopts,hash,help,history,jobs,kill,let,local,logout,mapfile,popd,printf,pushd,pwd,read,readarray,readonly,return,set,shift,shopt,source,suspend,test,times,trap,true,type,typeset,ulimit,umask,unalias,unset,wait`.split(`,`),pMe=`autocd.assoc_expand_once.cdable_vars.cdspell.checkhash.checkjobs.checkwinsize.cmdhist.compat31.compat32.compat40.compat41.compat42.compat43.compat44.complete_fullquote.direxpand.dirspell.dotglob.execfail.expand_aliases.extdebug.extglob.extquote.failglob.force_fignore.globasciiranges.globstar.gnu_errfmt.histappend.histreedit.histverify.hostcomplete.huponexit.inherit_errexit.interactive_comments.lastpipe.lithist.localvar_inherit.localvar_unset.login_shell.mailwarn.no_empty_cmd_completion.nocaseglob.nocasematch.nullglob.progcomp.progcomp_alias.promptvars.restricted_shell.shift_verbose.sourcepath.xpg_echo`.split(`.`),mMe=l7;async function hMe(e,t){let n=[],r=null,i=``,a=``,o=null,s=!1,c=!1,l=!1,u=null,d=null,f=null,p=[],m=[`alias`,`arrayvar`,`binding`,`builtin`,`command`,`directory`,`disabled`,`enabled`,`export`,`file`,`function`,`group`,`helptopic`,`hostname`,`job`,`keyword`,`running`,`service`,`setopt`,`shopt`,`signal`,`stopped`,`user`,`variable`];for(let e=0;e=t.length)return Q(`compgen: -A: option requires an argument `,2);let r=t[e];if(!m.includes(r))return Q(`compgen: ${r}: invalid action name `,2);n.push(r)}else if(o===`-W`){if(e++,e>=t.length)return Q(`compgen: -W: option requires an argument `,2);r=t[e]}else if(o===`-P`){if(e++,e>=t.length)return Q(`compgen: -P: option requires an argument `,2);i=t[e]}else if(o===`-S`){if(e++,e>=t.length)return Q(`compgen: -S: option requires an argument `,2);a=t[e]}else if(o===`-o`){if(e++,e>=t.length)return Q(`compgen: -o: option requires an argument `,2);let n=t[e];if(n===`plusdirs`)s=!0;else if(n===`dirnames`)c=!0;else if(n==="default")l=!0;else if(n!==`filenames`&&n!==`nospace`&&n!==`bashdefault`&&n!==`noquote`)return Q(`compgen: ${n}: invalid option name `,2)}else if(o===`-F`){if(e++,e>=t.length)return Q(`compgen: -F: option requires an argument `,2);d=t[e]}else if(o===`-C`){if(e++,e>=t.length)return Q(`compgen: -C: option requires an argument `,2);f=t[e]}else if(o===`-X`){if(e++,e>=t.length)return Q(`compgen: -X: option requires an argument `,2);u=t[e]}else if(o===`-G`){if(e++,e>=t.length)return Q(`compgen: -G: option requires an argument `,2)}else if(o===`--`){p.push(...t.slice(e+1));break}else o.startsWith(`-`)||p.push(o)}o=p[0]??null;let h=[],g=new Set,_=()=>e.limits.maxArrayElements-h.length,v=t=>{for(let n of t){if(h.length>=e.limits.maxArrayElements)throw new H(`compgen: completion element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);if(V(n)>e.limits.maxStringLength)throw new H(`compgen: completion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);e.executionScope.consumeWork(1,`compgen completion`),h.push(n),g.add(n)}};c&&v(await u7(e,o,_())),l&&v(await d7(e,o,_()));for(let t of n)t===`variable`?v(gMe(e,o,_())):t===`export`?v(_Me(e,o,_())):t===`function`?v(vMe(e,o,_())):t===`builtin`?v(yMe(e,o,_())):t===`keyword`?v(bMe(e,o,_())):t===`alias`?v(xMe(e,o,_())):t===`shopt`?v(SMe(e,o,_())):t===`helptopic`?v(CMe(e,o,_())):t===`directory`?v(await u7(e,o,_())):t===`file`?v(await d7(e,o,_())):t===`user`?v(wMe(e,o,_())):t===`command`&&v(await TMe(e,o,_()));if(r!==null)try{let t=DMe(e,await EMe(e,r),_(),o);for(let e of t)v([e])}catch(e){if(e instanceof H)throw e;return $(``,``,1)}if(s){let t=await u7(e,o,_(),g);for(let e of t)g.has(e)||v([e])}let y=``;if(d!==null){let t=e.state.functions.get(d);if(t){let n=new Map,r=Q2(e,`COMP_WORDS`),i=r?X2(r):void 0;l4(e,`COMP_WORDS`),$2(e,`COMP_WORDS`),n.set(`COMP_CWORD`,e.state.env.get(`COMP_CWORD`)),e.state.env.set(`COMP_CWORD`,`-1`),n.set(`COMP_LINE`,e.state.env.get(`COMP_LINE`)),e.state.env.set(`COMP_LINE`,``),n.set(`COMP_POINT`,e.state.env.get(`COMP_POINT`)),e.state.env.set(`COMP_POINT`,`0`);let a=Q2(e,`COMPREPLY`),o=a?X2(a):void 0,s=e.state.env.get(`COMPREPLY`);l4(e,`COMPREPLY`),e.state.env.delete(`COMPREPLY`);let c=[`compgen`,p[0]??``,``];try{let r=await o7(e,t,c,``);if(r.exitCode!==0)return p7(e,n),m7(e,`COMP_WORDS`,i),m7(e,`COMPREPLY`,o),s!==void 0&&e.state.env.set(`COMPREPLY`,s),$(``,r.stderr,1);y=r.stdout,v(OMe(e,_()))}catch(t){if(t instanceof H)throw t;return p7(e,n),m7(e,`COMP_WORDS`,i),m7(e,`COMPREPLY`,o),s!==void 0&&e.state.env.set(`COMPREPLY`,s),$(``,``,1)}p7(e,n),m7(e,`COMP_WORDS`,i),m7(e,`COMPREPLY`,o),s!==void 0&&e.state.env.set(`COMPREPLY`,s)}}if(f!==null)try{let t=E3(f),n=await e.executeScript(t);if(n.exitCode!==0)return $(``,n.stderr,n.exitCode);if(n.stdout)for(let e of kMe(n.stdout))e.length>0&&v([e])}catch(e){if(e.name===`ParseException`)return Q(`compgen: -C: ${e.message} `,2);throw e}let b=h;if(u!==null){let t=u.startsWith(`!`),n=t?u.slice(1):u;b=h.filter(r=>{let i=r5(r,n,!1,!0,e.limits.maxCallDepth);return t?i:!i})}if(b.length===0&&o!==null)return $(y,``,1);let x=new sH(e.limits.maxOutputSize,`compgen`);x.append(y);for(let e of b)x.append(i).append(e).append(a).append(` `);return L8(x.build())}function gMe(e,t,n){let r=f7(e,t,n);for(let t of e.state.env.keys())/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)&&r.add(t);for(let t of e.state.arrays?.keys()??[])r.add(t);return r.build()}function _Me(e,t,n){let r=f7(e,t,n),i=e.state.exportedVars??new Set;for(let t of i)e.state.env.has(t)&&r.add(t);return r.build()}function vMe(e,t,n){let r=f7(e,t,n);for(let t of e.state.functions.keys())r.add(t);return r.build()}function yMe(e,t,n){let r=f7(e,t,n);for(let e of l7)r.add(e);return r.build()}function bMe(e,t,n){let r=f7(e,t,n);for(let e of c7)r.add(e);return r.build()}function xMe(e,t,n){let r=f7(e,t,n);for(let t of e.state.env.keys())if(t.startsWith(`BASH_ALIAS_`)){let e=t.slice(11);r.add(e)}return r.build()}function SMe(e,t,n){let r=f7(e,t,n);for(let e of pMe)r.add(e);return r.build()}function CMe(e,t,n){let r=f7(e,t,n);for(let e of mMe)r.add(e);return r.build()}async function u7(e,t,n=e.limits.maxArrayElements,r){let i=f7(e,null,n,r);try{let n=e.state.cwd,r=t??``;if(t){let i=t.lastIndexOf(`/`);if(i!==-1){let a=t.slice(0,i)||`/`;r=t.slice(i+1),n=a.startsWith(`/`)?a:`${e.state.cwd}/${a}`}}let a=await e.fs.readdir(n);for(let o of a){e.executionScope.consumeWork(1,`compgen directory scan`);let a=`${n}/${o}`;try{if((await e.fs.stat(a)).isDirectory&&(!r||o.startsWith(r))){if(t?.includes(`/`)){let e=t.lastIndexOf(`/`),n=t.slice(0,e+1);i.add(n+o)}else i.add(o)}}catch(e){if(e instanceof H)throw e}}}catch(e){if(e instanceof H)throw e}return i.build()}async function d7(e,t,n=e.limits.maxArrayElements){let r=f7(e,null,n);try{let n=e.state.cwd,i=t??``;if(t){let r=t.lastIndexOf(`/`);if(r!==-1){let a=t.slice(0,r)||`/`;i=t.slice(r+1),n=a.startsWith(`/`)?a:`${e.state.cwd}/${a}`}}let a=await e.fs.readdir(n);for(let n of a)if(e.executionScope.consumeWork(1,`compgen file scan`),!i||n.startsWith(i)){if(t?.includes(`/`)){let e=t.lastIndexOf(`/`),i=t.slice(0,e+1);r.add(i+n)}else r.add(n)}}catch(e){if(e instanceof H)throw e}return r.build()}function wMe(e,t,n){let r=f7(e,t,n);return r.add(`root`),r.add(`nobody`),r.build()}async function TMe(e,t,n){let r=f7(e,t,n);for(let e of l7)r.add(e);for(let t of e.state.functions.keys())r.add(t);for(let t of e.state.env.keys())t.startsWith(`BASH_ALIAS_`)&&r.add(t.slice(11));for(let e of c7)r.add(e);let i=e.state.env.get(`PATH`)??`/usr/bin:/bin`;for(let t of i.split(`:`))if(t)try{let n=await e.fs.readdir(t);for(let e of n)r.add(e)}catch(e){if(e instanceof H)throw e}return r.build()}function f7(e,t,n,r){let i=new Set;return{add(a){if(e.executionScope.consumeWork(1,`compgen candidate collection`),(t===null||a.startsWith(t))&&!r?.has(a)&&!i.has(a)){if(i.size>=n)throw new H(`compgen: completion element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);if(V(a)>e.limits.maxStringLength)throw new H(`compgen: completion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);i.add(a)}},build(){return Array.from(i).sort()}}}async function EMe(e,t){let n=new T3().parseWordFromString(t,!1,!1);return await _8(e,X.word(n.parts.map(s7)))}function DMe(e,t,n,r){let i=e.state.env.get(`IFS`)??` `;if(i.length===0){if(r!==null&&!t.startsWith(r))return[];if(n===0)throw new H(`compgen: completion element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);return[t]}let a=new Set(i.split(``)),o=[],s=t=>{if(r===null||t.startsWith(r)){if(o.length>=n)throw new H(`compgen: completion element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);o.push(t)}},c=``,l=0;for(;l0&&(s(c),c=``),l++):(c+=e,l++)}return c.length>0&&s(c),o}function p7(e,t){for(let[n,r]of t)r===void 0?e.state.env.delete(n):e.state.env.set(n,r)}function m7(e,t,n){e.state.arrays??=new Map,n?e.state.arrays.set(t,X2(n)):e.state.arrays.delete(t)}function OMe(e,t){let n=[],r=r=>{if(n.length>=t)throw new H(`compgen: completion element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);n.push(r)};if(t4(e,`COMPREPLY`)){let t=v6(e,`COMPREPLY`);for(let[,e]of t)r(e)}else{let t=e.state.env.get(`COMPREPLY`);t!==void 0&&r(t)}return n}function*kMe(e){let t=0;for(;t<=e.length;){let n=e.indexOf(` `,t),r=n===-1?e.length:n;if(r>t&&(yield e.slice(t,r)),n===-1)return;t=n+1}}AB();function h7(e){for(let t=0;t=t.length)return Q(`complete: -W: option requires an argument `,2);a=t[e]}else if(d===`-F`){if(e++,e>=t.length)return Q(`complete: -F: option requires an argument `,2);o=t[e]}else if(d===`-o`){if(e++,e>=t.length)return Q(`complete: -o: option requires an argument `,2);let n=t[e];if(!jMe.includes(n))return Q(`complete: ${n}: invalid option name `,2);c.push(n)}else if(d===`-A`){if(e++,e>=t.length)return Q(`complete: -A: option requires an argument `,2);l.push(t[e])}else if(d===`-C`){if(e++,e>=t.length)return Q(`complete: -C: option requires an argument `,2);s=t[e]}else if(d===`-G`){if(e++,e>=t.length)return Q(`complete: -G: option requires an argument `,2)}else if(d===`-P`){if(e++,e>=t.length)return Q(`complete: -P: option requires an argument `,2)}else if(d===`-S`){if(e++,e>=t.length)return Q(`complete: -S: option requires an argument `,2)}else if(d===`-X`){if(e++,e>=t.length)return Q(`complete: -X: option requires an argument `,2)}else if(d===`--`){u.push(...t.slice(e+1));break}else d.startsWith(`-`)||u.push(d)}if(r){if(u.length===0)return e.state.completionSpecs.clear(),e.state.defaultCompletionSpec=void 0,e.state.emptyCompletionSpec=void 0,L8(``);for(let t of u)e.state.completionSpecs.delete(t);return L8(``)}if(n)return u.length===0?S7(e):S7(e,u);if(t.length===0||u.length===0&&!a&&!o&&!s&&c.length===0&&l.length===0&&!i)return S7(e);if(o&&u.length===0&&!i)return Q(`complete: -F: option requires a command name `,2);if(i){let t={isDefault:!0};return a!==void 0&&(t.wordlist=a),o!==void 0&&(t.function=o),s!==void 0&&(t.command=s),c.length>0&&(t.options=c),l.length>0&&(t.actions=l),e.state.defaultCompletionSpec=t,L8(``)}for(let t of u){let n=Object.create(null);a!==void 0&&(n.wordlist=a),o!==void 0&&(n.function=o),s!==void 0&&(n.command=s),c.length>0&&(n.options=c),l.length>0&&(n.actions=l),e.state.completionSpecs.set(t,n)}return L8(``)}function S7(e,t){let n=e.state.completionSpecs??new Map;if(n.size===0&&!e.state.defaultCompletionSpec){if(t&&t.length>0){let e=``;for(let n of t)e+=`complete: ${n}: no completion specification `;return $(``,e,1)}return L8(``)}let r=[],i=t||Array.from(n.keys());for(let e of i){let i=n.get(e);if(!i){if(t)return $(r.join(` `)+(r.length>0?` `:``),`complete: ${e}: no completion specification `,1);continue}let a=`complete`;if(i.options)for(let e of i.options)a+=` -o ${_7(e)}`;if(i.actions)for(let e of i.actions)a+=` -A ${_7(e)}`;i.wordlist!==void 0&&(i.wordlist.includes(` `)||i.wordlist.includes(`'`),a+=` -W ${_7(i.wordlist)}`),i.function!==void 0&&(a+=` -F ${_7(i.function)}`),i.command!==void 0&&(a+=` -C ${_7(i.command)}`),i.isDefault&&(a+=` -D`),a+=`${e.startsWith(`-`)?` -- `:` `}${_7(e)}`,r.push(a)}if(!t&&e.state.defaultCompletionSpec){let t=e.state.defaultCompletionSpec,n=`complete`;for(let e of t.options??[])n+=` -o ${_7(e)}`;for(let e of t.actions??[])n+=` -A ${_7(e)}`;t.wordlist!==void 0&&(n+=` -W ${_7(t.wordlist)}`),t.function!==void 0&&(n+=` -F ${_7(t.function)}`),t.command!==void 0&&(n+=` -C ${_7(t.command)}`),n+=` -D`,r.push(n)}return r.length===0?L8(``):L8(`${r.join(` `)} `)}var C7=[`bashdefault`,`default`,`dirnames`,`filenames`,`noquote`,`nosort`,`nospace`,`plusdirs`];function NMe(e,t){e.state.completionSpecs||(e.state.completionSpecs=new Map);let n=!1,r=!1,i=[],a=[],o=[];for(let e=0;e=t.length)return Q(`compopt: -o: option requires an argument `,2);let n=t[e];if(!C7.includes(n))return Q(`compopt: ${n}: invalid option name `,2);i.push(n)}else if(s===`+o`){if(e++,e>=t.length)return Q(`compopt: +o: option requires an argument `,2);let n=t[e];if(!C7.includes(n))return Q(`compopt: ${n}: invalid option name `,2);a.push(n)}else if(s===`--`){o.push(...t.slice(e+1));break}else!s.startsWith(`-`)&&!s.startsWith(`+`)&&o.push(s)}if(n){let t=e.state.defaultCompletionSpec??{isDefault:!0},n=new Set(t.options??[]);for(let e of i)n.add(e);for(let e of a)n.delete(e);return t.options=n.size>0?Array.from(n):void 0,e.state.defaultCompletionSpec=t,L8(``)}if(r){let t=e.state.emptyCompletionSpec??Object.create(null),n=new Set(t.options??[]);for(let e of i)n.add(e);for(let e of a)n.delete(e);return t.options=n.size>0?Array.from(n):void 0,e.state.emptyCompletionSpec=t,L8(``)}if(o.length>0){for(let t of o){let n=e.state.completionSpecs.get(t)??{},r=new Set(n.options??[]);for(let e of i)r.add(e);for(let e of a)r.delete(e);n.options=r.size>0?Array.from(r):void 0,e.state.completionSpecs.set(t,n)}return L8(``)}return Q(`compopt: not currently executing completion function `,1)}U();function PMe(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new WB;return I8}if(t.length>1)throw new RB(1,``,`bash: continue: too many arguments `);let n=1;if(t.length>0){let e=Number.parseInt(t[0],10);if(Number.isNaN(e)||e<1)throw new RB(1,``,`bash: continue: ${t[0]}: numeric argument required `);n=e}throw new PB(n)}cH();function w7(e,t){let n=``;return e.state.integerVars?.has(t)&&(n+=`i`),e.state.lowercaseVars?.has(t)&&(n+=`l`),l6(e,t)&&(n+=`n`),e.state.readonlyVars?.has(t)&&(n+=`r`),e.state.uppercaseVars?.has(t)&&(n+=`u`),e.state.exportedVars?.has(t)&&(n+=`x`),n===``?`--`:`-${n}`}function T7(e){return _7(e)}function E7(e){return`'${e.replace(/'/g,`'\\''`)}'`}function FMe(e,t){let n=``,r=``,i=!1;for(let a of t){let t=w7(e,a);if(e.state.associativeArrays?.has(a)){let t=u4(e,a);if(t.length===0)n+=`declare -A ${a}=() `;else{let r=t.map(t=>{let n=T7(n4(e,a,t)??``);return`[${E7(t)}]=${n}`});n+=`declare -A ${a}=(${r.join(` `)}) `}continue}let o=c4(e,a);if(o.length>0){let t=o.map(t=>`[${t}]=${y7(n4(e,a,t)??``)}`);n+=`declare -a ${a}=(${t.join(` `)}) `;continue}if(t4(e,a)){n+=`declare -a ${a}=() `;continue}let s=e.state.env.get(a);if(s!==void 0)n+=`declare ${t} ${a}=${x7(s)} `;else{let o=e.state.declaredVars?.has(a),s=e.state.localVarDepth?.has(a);o||s?n+=`declare ${t} ${a} `:(r+=`bash: declare: ${a}: not found `,i=!0)}}return $(n,r,+!!i)}function IMe(e,t){let{filterExport:n,filterReadonly:r,filterNameref:i,filterIndexedArray:a,filterAssocArray:o}=t,s=n||r||i||a||o,c=``,l=new Set;for(let t of e.state.env.keys())t.startsWith(`BASH_`)||l.add(t);for(let t of e.state.arrays?.keys()??[])l.add(t);if(e.state.localVarDepth)for(let t of e.state.localVarDepth.keys())l.add(t);if(e.state.associativeArrays)for(let t of e.state.associativeArrays)l.add(t);let u=Array.from(l).sort();for(let t of u){let l=w7(e,t),u=e.state.associativeArrays?.has(t),d=c4(e,t),f=!u&&t4(e,t);if(s&&(o&&!u||a&&!f||n&&!e.state.exportedVars?.has(t)||r&&!e.state.readonlyVars?.has(t)||i&&!l6(e,t)))continue;if(u){let n=u4(e,t);if(n.length===0)c+=`declare -A ${t}=() `;else{let r=n.map(n=>{let r=T7(n4(e,t,n)??``);return`[${E7(n)}]=${r}`});c+=`declare -A ${t}=(${r.join(` `)}) `}continue}if(d.length>0){let n=d.map(n=>`[${n}]=${y7(n4(e,t,n)??``)}`);c+=`declare -a ${t}=(${n.join(` `)}) `;continue}if(t4(e,t)){c+=`declare -a ${t}=() `;continue}let p=e.state.env.get(t);p!==void 0&&(c+=`declare ${l} ${t}=${x7(p)} `)}return L8(c)}function LMe(e){let t=``,n=Array.from(e.state.associativeArrays??[]).sort();for(let r of n){let n=u4(e,r);if(n.length===0)t+=`declare -A ${r}=() `;else{let i=n.map(t=>{let n=T7(n4(e,r,t)??``);return`[${E7(t)}]=${n}`});t+=`declare -A ${r}=(${i.join(` `)}) `}}return L8(t)}function RMe(e){let t=``,n=new Set(Array.from(e.state.arrays??[]).filter(([,e])=>e.kind===`indexed`).map(([e])=>e)),r=Array.from(n).sort();for(let n of r){let r=c4(e,n);if(r.length===0)t+=`declare -a ${n}=() `;else{let i=r.map(t=>`[${t}]=${y7(n4(e,n,t)??``)}`);t+=`declare -a ${n}=(${i.join(` `)}) `}}return L8(t)}function zMe(e){let t=``,n=new Set;for(let t of e.state.env.keys())t.startsWith(`BASH_`)||n.add(t);let r=Array.from(n).sort();for(let n of r){if(e.state.associativeArrays?.has(n)||c4(e,n).length>0||t4(e,n))continue;let r=e.state.env.get(n);r!==void 0&&(t+=`${n}=${_7(r)} `)}return L8(t)}function D7(e,t){e.state.integerVars??=new Set,e.state.integerVars.add(t)}function O7(e,t){return e.state.integerVars?.has(t)??!1}function k7(e,t){e.state.lowercaseVars??=new Set,e.state.lowercaseVars.add(t),e.state.uppercaseVars?.delete(t)}function BMe(e,t){return e.state.lowercaseVars?.has(t)??!1}function A7(e,t){e.state.uppercaseVars??=new Set,e.state.uppercaseVars.add(t),e.state.lowercaseVars?.delete(t)}function VMe(e,t){return e.state.uppercaseVars?.has(t)??!1}function j7(e,t,n){return BMe(e,t)?n.toLowerCase():VMe(e,t)?n.toUpperCase():n}async function M7(e,t){try{let n=await N8(e,P4(new T3,t).expression);return String(n)}catch{return`0`}}function HMe(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return null;let n=t[0],r=n.length;if(e[r]!==`[`)return null;let i=0,a=r+1;for(;r0&&!_,b=t=>{if(!y)return;let n=e.state.localScopes[e.state.localScopes.length-1];n.has(t)||n.set(t,e.state.env.get(t))},x=t=>{if(!y)return;let n=e.state.localScopes[e.state.localScopes.length-1];for(n.has(t)||n.set(t,e.state.env.get(t)),e.state.localArrayScopes??=[];e.state.localArrayScopes.length{y&&h5(e,t)};if(g){if(v.length===0){let t=Array.from(e.state.functions.keys()).sort(),n=``;for(let e of t)n+=`declare -f ${e} `;return L8(n)}let t=!0,n=``;for(let r of v)e.state.functions.has(r)?n+=`${r} `:t=!1;return $(n,``,+!t)}if(h){if(v.length===0){let t=``,n=Array.from(e.state.functions.keys()).sort();for(let e of n)t+=`${e} () { # function body } `;return L8(t)}let t=!0;for(let n of v)e.state.functions.has(n)||(t=!1);return $(``,``,+!t)}if(s&&v.length>0)return FMe(e,v);if(s&&v.length===0)return IMe(e,{filterExport:o,filterReadonly:a,filterNameref:c,filterIndexedArray:r,filterAssocArray:i});if(v.length===0&&i&&!s)return LMe(e);if(v.length===0&&r&&!s)return RMe(e);if(v.length===0&&!s)return zMe(e);let C=``,w=0;for(let t of v){let s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(s&&!u){let t=s[1],c=s[2],l=V6(e,t);if(l)return l;if(i&&c4(e,t).length>0){C+=`bash: declare: ${t}: cannot convert indexed to associative array `,w=1;continue}if((r||!i&&!r)&&e.state.associativeArrays?.has(t)){C+=`bash: declare: ${t}: cannot convert associative to indexed array `,w=1;continue}let u=i&&c.includes(`[`)?m5(c,n):void 0,d=u===void 0?p5(c,{...n,maxElements:i?n.maxElements*2:n.maxElements}):void 0;if(e.executionScope.consumeWork(u?.length??d?.length??0,`declare array assignment`),x(t),i?(e.state.associativeArrays??=new Set,e.state.associativeArrays.add(t),e4(e,t,`associative`)):e4(e,t,`indexed`),l4(e,t),e.state.env.delete(t),i&&c.includes(`[`))for(let[n,r]of u??[])i4(e,t,n,Y6(e,r),`associative`);else if(i){let n=d??[];for(let r=0;r/^\[[^\]]+\]=/.test(e))){let r=0;for(let i of n){let n=i.match(/^\[([^\]]+)\]=(.*)$/);if(n){let i=n[1],a=n[2],o;if(/^-?\d+$/.test(i))o=Number.parseInt(i,10);else try{o=await N8(e,P4(new T3,i).expression)}catch{o=0}i4(e,t,o,Y6(e,a)),r=o+1}else i4(e,t,r,i),r++}}else for(let r=0;re));for(let[n,r]of i)i4(e,t,n,r,`associative`)}else{e.executionScope.consumeWork(s.length,`declare array append`);let n=c4(e,t),r=0,i=e.state.env.get(t);n.length===0&&i!==void 0?(i4(e,t,0,i),e.state.env.delete(t),r=1):n.length>0&&(r=Math.max(...n)+1),a4(e,t,Array.from({length:s.length},(e,t)=>r+t));for(let n=0;n0||e.state.associativeArrays?.has(t);if(O7(e,t)){let r=e.state.env.get(t)??`0`,i=parseInt(r,10)||0,a=parseInt(await M7(e,n),10)||0;n=String(i+a),e.state.env.set(t,n)}else if(i)n=j7(e,t,n),i4(e,t,0,oH([n4(e,t,0)??``,n],``,e.limits.maxStringLength,`declare append`));else{n=j7(e,t,n);let r=e.state.env.get(t)??``;e.state.env.set(t,oH([r,n],``,e.limits.maxStringLength,`declare append`))}S(t),a&&z6(e,t),o&&H6(e,t),e.state.options.allexport&&!d&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(t));continue}if(t.includes(`=`)){let n=t.indexOf(`=`),r=t.slice(0,n),i=t.slice(n+1);if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)){C+=`bash: typeset: \`${r}': not a valid identifier `,w=1;continue}let s=V6(e,r);if(s)return s;if(b(r),c){if(i!==``&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(i)){C+=`bash: declare: \`${i}': invalid variable name for name reference `,w=1;continue}e.state.env.set(r,i),u6(e,r),i!==``&&p6(e,i)&&f6(e,r),S(r),a&&z6(e,r),o&&H6(e,r);continue}if(f&&D7(e,r),p&&k7(e,r),m&&A7(e,r),O7(e,r)&&(i=await M7(e,i)),i=j7(e,r,i),l6(e,r)){let t=m6(e,r);t&&t!==r?e.state.env.set(t,i):e.state.env.set(r,i)}else e.state.env.set(r,i);S(r),a&&z6(e,r),o&&H6(e,r),e.state.options.allexport&&!d&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(r))}else{let n=t;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)){C+=`bash: typeset: \`${n}': not a valid identifier `,w=1;continue}if(r||i?x(n):b(n),c){u6(e,n);let t=e.state.env.get(n);t!==void 0&&t!==``&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(t)?Hke(e,n):t&&p6(e,t)&&f6(e,n),S(n),a&&z6(e,n),o&&H6(e,n);continue}if(f&&D7(e,n),p&&k7(e,n),m&&A7(e,n),i){if(c4(e,n).length>0){C+=`bash: declare: ${n}: cannot convert indexed to associative array `,w=1;continue}e.state.associativeArrays??=new Set,e.state.associativeArrays.add(n),e4(e,n,`associative`)}let s=t4(e,n);!e.state.env.has(n)&&!s&&(r||i?e4(e,n,i?`associative`:`indexed`):(e.state.declaredVars??=new Set,e.state.declaredVars.add(n))),S(n),a&&z6(e,n),o&&H6(e,n)}}return $(``,C,w)}async function WMe(e,t){let n={maxElements:e.limits.maxArrayElements,maxStringBytes:e.limits.maxStringLength},r=[];for(let e=0;ee));for(let[n,i]of r)i4(e,t,n,i,`associative`)}else{e.executionScope.consumeWork(o.length,`readonly array append`);let n=c4(e,t),r=0,i=e.state.env.get(t);n.length===0&&i!==void 0?(i4(e,t,0,i),e.state.env.delete(t),r=1):n.length>0&&(r=Math.max(...n)+1),a4(e,t,Array.from({length:o.length},(e,t)=>r+t));for(let n=0;ne&&e!==`.`),n=[];for(let e of t)e===`..`?n.pop():n.push(e);return`/${n.join(`/`)}`}async function KMe(e,t){let n=N7(e),r;for(let e=0;ee);t.pop(),i=`/${t.join(`/`)}`}else i=r===`.`?e.state.cwd:r.startsWith(`~`)?(e.state.env.get(`HOME`)||`/`)+r.slice(1):`${e.state.cwd}/${r}`;i=GMe(i);try{if(!(await e.fs.stat(i)).isDirectory)return Q(`bash: pushd: ${r}: Not a directory `,1)}catch{return Q(`bash: pushd: ${r}: No such file or directory `,1)}n.unshift(e.state.cwd),e.state.previousDir=e.state.cwd,e.state.cwd=i,e.state.env.set(`PWD`,i),e.state.env.set(`OLDPWD`,e.state.previousDir);let a=e.state.env.get(`HOME`)||``;return L8(`${[i,...n].map(e=>P7(e,a)).join(` `)} `)}function qMe(e,t){let n=N7(e);for(let e of t)if(e!==`--`)return e.startsWith(`-`)&&e!==`-`?Q(`bash: popd: ${e}: invalid option `,2):Q(`bash: popd: too many arguments `,2);if(n.length===0)return Q(`bash: popd: directory stack empty `,1);let r=n.shift();if(!r)return Q(`bash: popd: directory stack empty `,1);e.state.previousDir=e.state.cwd,e.state.cwd=r,e.state.env.set(`PWD`,r),e.state.env.set(`OLDPWD`,e.state.previousDir);let i=e.state.env.get(`HOME`)||``;return L8(`${[r,...n].map(e=>P7(e,i)).join(` `)} `)}function JMe(e,t){let n=N7(e),r=!1,i=!1,a=!1,o=!1;for(let e of t)if(e!==`--`){if(e.startsWith(`-`))for(let t of e.slice(1))if(t===`c`)r=!0;else if(t===`l`)i=!0;else if(t===`p`)a=!0;else if(t===`v`)a=!0,o=!0;else return Q(`bash: dirs: -${t}: invalid option `,2);else return Q(`bash: dirs: too many arguments `,1)}if(r)return e.state.directoryStack=[],I8;let s=[e.state.cwd,...n],c=e.state.env.get(`HOME`)||``,l;return o?(l=s.map((e,t)=>` ${t} ${i?e:P7(e,c)}`).join(` `),l+=` `):l=a?s.map(e=>i?e:P7(e,c)).join(` `)+` `:s.map(e=>i?e:P7(e,c)).join(` `)+` `,L8(l)}U();async function F7(e,t,n,r=!1){let i=t;if(i.length>0){let e=i[0];if(e===`--`)i=i.slice(1);else if(e.startsWith(`-`)&&e!==`-`&&e.length>1)return Q(`bash: eval: ${e}: invalid option eval: usage: eval [arg ...] `,2)}if(i.length===0)return I8;let a=i.join(` `);if(a.trim()===``)return I8;let o=e.state.groupStdin,s=r||n!==void 0&&n!==``;s&&(e.state.groupStdin=n??``);try{let t=E3(a);return await e.executeScript(t)}catch(e){if(e instanceof NB||e instanceof PB||e instanceof FB||e instanceof RB)throw e;if(e.name===`ParseException`)return Q(`bash: eval: ${e.message} `);throw e}finally{(s||o!==void 0&&e.state.groupStdin===void 0)&&(e.state.groupStdin=o)}}U();function YMe(e,t){let n,r=``;if(t.length===0)n=e.state.lastExitCode;else{let e=t[0];if(e===``||!/^-?\d+$/.test(e))r=`bash: exit: ${e}: numeric argument required `,n=2;else{let t=BigInt(e);n=Number((t%256n+256n)%256n)}}throw new RB(n,``,r)}function XMe(e,t){let n=!1,r=[];for(let e of t)e===`-n`?n=!0:e===`-p`||e===`--`||r.push(e);if(r.length===0&&!n){let t=``,n=e.state.exportedVars??new Set,r=Array.from(n).sort();for(let n of r){let r=e.state.env.get(n);r!==void 0&&(t+=`declare -x ${n}=${x7(r)} `)}return L8(t)}if(n){for(let t of r){let n,r;if(t.includes(`=`)){let e=t.indexOf(`=`);n=t.slice(0,e),r=t.slice(e+1)}else n=t;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n))return $(``,`bash: export: \`${t}': not a valid identifier `,1);r!==void 0&&(V6(e,n),e.state.env.set(n,r)),U6(e,n)}return I8}let i=``,a=0;for(let t of r){let n,r,o=!1,s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(s)n=s[1],r=s[2],o=!0;else if(t.includes(`=`)){let e=t.indexOf(`=`);n=t.slice(0,e),r=t.slice(e+1)}else n=t;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)){i+=`bash: export: \`${t}': not a valid identifier `,a=1;continue}if(r!==void 0){if(V6(e,n),o){let t=e.state.env.get(n)??``;e.state.env.set(n,t+r)}else e.state.env.set(n,r)}else e.state.env.has(n)||e.state.env.set(n,``);H6(e,n)}return $(``,i,a)}function I7(e,t){if(t.length<2)return Q(`bash: getopts: usage: getopts optstring name [arg ...] `);let n=t[0],r=t[1],i=!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r),a=n.startsWith(`:`),o=a?n.slice(1):n,s;if(t.length>2)s=t.slice(2);else{let t=Number.parseInt(e.state.env.get(`#`)||`0`,10);s=[];for(let n=1;n<=t;n++)s.push(e.state.env.get(String(n))||``)}let c=Number.parseInt(e.state.env.get(`OPTIND`)||`1`,10);c<1&&(c=1);let l=Number.parseInt(e.state.env.get(`__GETOPTS_CHARINDEX`)||`0`,10);if(e.state.env.set(`OPTARG`,``),c>s.length)return i||e.state.env.set(r,`?`),e.state.env.set(`OPTIND`,String(s.length+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`),{exitCode:i?2:1,stdout:``,stderr:``};let u=s[c-1];if(!u||u===`-`||!u.startsWith(`-`))return i||e.state.env.set(r,`?`),{exitCode:i?2:1,stdout:``,stderr:``};if(u===`--`)return e.state.env.set(`OPTIND`,String(c+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`),i||e.state.env.set(r,`?`),{exitCode:i?2:1,stdout:``,stderr:``};let d=l===0?1:l,f=u[d];if(!f)return e.state.env.set(`OPTIND`,String(c+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`),I7(e,t);let p=o.indexOf(f);if(p===-1){let t=``;return a?e.state.env.set(`OPTARG`,f):t=`bash: illegal option -- ${f} `,i||e.state.env.set(r,`?`),d+1=s.length){let t=``;return a?(e.state.env.set(`OPTARG`,f),i||e.state.env.set(r,`:`)):(t=`bash: option requires an argument -- ${f} `,i||e.state.env.set(r,`?`)),e.state.env.set(`OPTIND`,String(c+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`),{exitCode:i?2:0,stdout:``,stderr:t}}e.state.env.set(`OPTARG`,s[c]),e.state.env.set(`OPTIND`,String(c+2)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`)}}else d+1=t.length)return Q(`bash: hash: -p: option requires an argument `,1);s=t[l],l++}else if(e.startsWith(`-`)&&e.length>1){for(let t of e.slice(1))if(t===`r`)n=!0;else if(t===`d`)r=!0;else if(t===`l`)i=!0;else if(t===`t`)o=!0;else return Q(t===`p`?`bash: hash: -p: option requires an argument `:`bash: hash: -${t}: invalid option `,1);l++}else c.push(e),l++}if(n)return e.state.hashTable.clear(),I8;if(r){if(c.length===0)return Q(`bash: hash: -d: option requires an argument `,1);let t=!1,n=``;for(let r of c)e.state.hashTable.has(r)?e.state.hashTable.delete(r):(n+=`bash: hash: ${r}: not found `,t=!0);return t?Q(n,1):I8}if(o){if(c.length===0)return Q(`bash: hash: -t: option requires an argument `,1);let t=``,n=!1,r=``;for(let i of c){let a=e.state.hashTable.get(i);a?c.length>1?t+=`${i} ${a} `:t+=`${a} `:(r+=`bash: hash: ${i}: not found `,n=!0)}return n?{exitCode:1,stdout:t,stderr:r}:L8(t)}if(a){if(c.length===0)return Q(`bash: hash: usage: hash [-lr] [-p pathname] [-dt] [name ...] `,1);let t=c[0];return e.state.hashTable.set(t,s),I8}if(c.length===0){if(e.state.hashTable.size===0)return L8(`hash: hash table empty `);let t=``;if(i)for(let[n,r]of e.state.hashTable){let e=n.startsWith(`-`)?` --`:``;t+=`builtin hash -p ${_7(r)}${e} ${_7(n)} `}else{t=`hits command `;for(let[,n]of e.state.hashTable)t+=` 1 ${n} `}return L8(t)}let u=!1,d=``,f=(e.state.env.get(`PATH`)||`/usr/bin:/bin`).split(`:`);for(let t of c){if(t.includes(`/`)){d+=`bash: hash: ${t}: cannot use / in name `,u=!0;continue}let n=!1;for(let r of f){if(!r)continue;let i=`${r}/${t}`;if(await e.fs.exists(i)){e.state.hashTable.set(t,i),n=!0;break}}n||(d+=`bash: hash: ${t}: not found `,u=!0)}return u?Q(d,1):I8}bG();var L7=new Map([[`:`,[`: [arguments]`,`Null command. No effect; the command does nothing. Exit Status: Always succeeds.`]],[`.`,[`. filename [arguments]`,`Execute commands from a file in the current shell. Read and execute commands from FILENAME in the current shell. The entries in $PATH are used to find the directory containing FILENAME. Exit Status: Returns the status of the last command executed in FILENAME.`]],[`[`,[`[ arg... ]`,`Evaluate conditional expression. This is a synonym for the "test" builtin, but the last argument must be a literal \`]', to match the opening \`['.`]],[`alias`,[`alias [-p] [name[=value] ... ]`,`Define or display aliases. Without arguments, \`alias' prints the list of aliases in the reusable form \`alias NAME=VALUE' on standard output. Exit Status: alias returns true unless a NAME is supplied for which no alias has been defined.`]],[`bg`,[`bg [job_spec ...]`,`Move jobs to the background. Place the jobs identified by each JOB_SPEC in the background, as if they had been started with \`&'.`]],[`break`,[`break [n]`,`Exit for, while, or until loops. Exit a FOR, WHILE or UNTIL loop. If N is specified, break N enclosing loops. Exit Status: The exit status is 0 unless N is not greater than or equal to 1.`]],[`builtin`,[`builtin [shell-builtin [arg ...]]`,`Execute shell builtins. Execute SHELL-BUILTIN with arguments ARGs without performing command lookup. This is useful when you wish to reimplement a shell builtin as a shell function, but need to execute the builtin within the function. Exit Status: Returns the exit status of SHELL-BUILTIN, or false if SHELL-BUILTIN is not a shell builtin.`]],[`caller`,[`caller [expr]`,`Return the context of the current subroutine call. Without EXPR, returns "$line $filename". With EXPR, returns "$line $subroutine $filename"; this extra information can be used to provide a stack trace. Exit Status: Returns 0 unless the shell is not executing a subroutine call or EXPR is invalid.`]],[`cd`,[`cd [-L|-P] [dir]`,`Change the shell working directory. Change the current directory to DIR. The default DIR is the value of the HOME shell variable. The variable CDPATH defines the search path for the directory containing DIR. Alternative directory names in CDPATH are separated by a colon (:). A null directory name is the same as the current directory. If DIR begins with a slash (/), then CDPATH is not used. If the directory is not found, and the shell option \`cdable_vars' is set, the word is assumed to be a variable name. If that variable has a value, its value is used for DIR. Options: -L force symbolic links to be followed -P use the physical directory structure without following symbolic links The default is to follow symbolic links, as if \`-L' were specified. Exit Status: Returns 0 if the directory is changed; non-zero otherwise.`]],[`command`,[`command [-pVv] command [arg ...]`,`Execute a simple command or display information about commands. Runs COMMAND with ARGS suppressing shell function lookup, or display information about the specified COMMANDs. Options: -p use a default value for PATH that is guaranteed to find all of the standard utilities -v print a description of COMMAND similar to the \`type' builtin -V print a more verbose description of each COMMAND Exit Status: Returns exit status of COMMAND, or failure if COMMAND is not found.`]],[`compgen`,[`compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]`,`Display possible completions depending on the options. Intended to be used from within a shell function generating possible completions. If the optional WORD argument is supplied, matches against WORD are generated. Exit Status: Returns success unless an invalid option is supplied or an error occurs.`]],[`complete`,[`complete [-abcdefgjksuv] [-pr] [-DEI] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]`,`Specify how arguments are to be completed. For each NAME, specify how arguments are to be completed. Exit Status: Returns success unless an invalid option is supplied or an error occurs.`]],[`continue`,[`continue [n]`,`Resume for, while, or until loops. Resumes the next iteration of the enclosing FOR, WHILE or UNTIL loop. If N is specified, resumes the Nth enclosing loop. Exit Status: The exit status is 0 unless N is not greater than or equal to 1.`]],[`declare`,[`declare [-aAfFgilnrtux] [-p] [name[=value] ...]`,`Set variable values and attributes. Declare variables and give them attributes. If no NAMEs are given, display the attributes and values of all variables. Options: -a to make NAMEs indexed arrays (if supported) -A to make NAMEs associative arrays (if supported) -i to make NAMEs have the \`integer' attribute -l to convert the value of each NAME to lower case on assignment -n make NAME a reference to the variable named by its value -r to make NAMEs readonly -t to make NAMEs have the \`trace' attribute -u to convert the value of each NAME to upper case on assignment -x to make NAMEs export Exit Status: Returns success unless an invalid option is supplied or a variable assignment error occurs.`]],[`dirs`,[`dirs [-clpv] [+N] [-N]`,`Display directory stack. Display the list of currently remembered directories. Directories find their way onto the list with the \`pushd' command; you can get back up through the list with the \`popd' command. Exit Status: Returns success unless an invalid option is supplied or an error occurs.`]],[`disown`,[`disown [-h] [-ar] [jobspec ...]`,`Remove jobs from current shell. Without any JOBSPECs, remove the current job.`]],[`echo`,[`echo [-neE] [arg ...]`,`Write arguments to the standard output. Display the ARGs, separated by a single space character and followed by a newline, on the standard output. Options: -n do not append a newline -e enable interpretation of the following backslash escapes -E explicitly suppress interpretation of backslash escapes Exit Status: Returns success unless a write error occurs.`]],[`enable`,[`enable [-a] [-dnps] [-f filename] [name ...]`,`Enable and disable shell builtins. Enables and disables builtin shell commands. Exit Status: Returns success unless NAME is not a shell builtin or an error occurs.`]],[`eval`,[`eval [arg ...]`,`Execute arguments as a shell command. Combine ARGs into a single string, use the result as input to the shell, and execute the resulting commands. Exit Status: Returns exit status of command or success if command is null.`]],[`exec`,[`exec [-cl] [-a name] [command [arguments ...]] [redirection ...]`,`Replace the shell with the given command. Execute COMMAND, replacing this shell with the specified program. ARGUMENTS become the arguments to COMMAND. If COMMAND is not specified, any redirections take effect in the current shell. Exit Status: Returns success unless COMMAND is not found or a redirection error occurs.`]],[`exit`,[`exit [n]`,`Exit the shell. Exits the shell with a status of N. If N is omitted, the exit status is that of the last command executed.`]],[`export`,[`export [-fn] [name[=value] ...] or export -p`,`Set export attribute for shell variables. Marks each NAME for automatic export to the environment of subsequently executed commands. If VALUE is supplied, assign VALUE before exporting. Options: -f refer to shell functions -n remove the export property from each NAME -p display a list of all exported variables and functions Exit Status: Returns success unless an invalid option is given or NAME is invalid.`]],[`false`,[`false`,`Return an unsuccessful result. Exit Status: Always fails.`]],[`fc`,[`fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command]`,`Display or execute commands from the history list. Exit Status: Returns success or status of executed command.`]],[`fg`,[`fg [job_spec]`,`Move job to the foreground. Place the job identified by JOB_SPEC in the foreground, making it the current job.`]],[`getopts`,[`getopts optstring name [arg]`,`Parse option arguments. Getopts is used by shell procedures to parse positional parameters as options. OPTSTRING contains the option letters to be recognized; if a letter is followed by a colon, the option is expected to have an argument, which should be separated from it by white space. Exit Status: Returns success if an option is found; fails if the end of options is encountered or an error occurs.`]],[`hash`,[`hash [-lr] [-p pathname] [-dt] [name ...]`,`Remember or display program locations. Determine and remember the full pathname of each command NAME. Exit Status: Returns success unless NAME is not found or an invalid option is given.`]],[`help`,[`help [-s] [pattern ...]`,`Display information about builtin commands. Displays brief summaries of builtin commands. If PATTERN is specified, gives detailed help on all commands matching PATTERN, otherwise the list of help topics is printed. Options: -s output only a short usage synopsis for each topic matching PATTERN Exit Status: Returns success unless PATTERN is not found.`]],[`history`,[`history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]`,`Display or manipulate the history list. Display the history list with line numbers, prefixing each modified entry with a \`*'. Exit Status: Returns success unless an invalid option is given or an error occurs.`]],[`jobs`,[`jobs [-lnprs] [jobspec ...] or jobs -x command [args]`,`Display status of jobs. Lists the active jobs. Exit Status: Returns success unless an invalid option is given or an error occurs.`]],[`kill`,[`kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]`,`Send a signal to a job. Send the processes identified by PID or JOBSPEC the signal named by SIGSPEC or SIGNUM. Exit Status: Returns success unless an invalid option is given or an error occurs.`]],[`let`,[`let arg [arg ...]`,`Evaluate arithmetic expressions. Evaluate each ARG as an arithmetic expression. Evaluation is done in fixed-width integers with no check for overflow, though division by 0 is trapped and flagged as an error. Exit Status: If the last ARG evaluates to 0, let returns 1; 0 is returned otherwise.`]],[`local`,[`local [option] name[=value] ...`,`Define local variables. Create a local variable called NAME, and give it VALUE. OPTION can be any option accepted by \`declare'. Local can only be used within a function; it makes the variable NAME have a visible scope restricted to that function and its children. Exit Status: Returns success unless an invalid option is supplied, a variable assignment error occurs, or the shell is not executing a function.`]],[`logout`,[`logout [n]`,`Exit a login shell. Exits a login shell with exit status N. Returns an error if not executed in a login shell.`]],[`mapfile`,[`mapfile [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]`,`Read lines from the standard input into an indexed array variable. Read lines from the standard input into the indexed array variable ARRAY, or from file descriptor FD if the -u option is supplied. Options: -d delim Use DELIM to terminate lines, instead of newline -n count Copy at most COUNT lines -O origin Begin assigning to ARRAY at index ORIGIN -s count Discard the first COUNT lines read -t Remove a trailing DELIM from each line read (default newline) -u fd Read lines from file descriptor FD instead of standard input Exit Status: Returns success unless an invalid option is given or ARRAY is readonly.`]],[`popd`,[`popd [-n] [+N | -N]`,`Remove directories from stack. Removes entries from the directory stack. Exit Status: Returns success unless an invalid argument is supplied or the directory change fails.`]],[`printf`,[`printf [-v var] format [arguments]`,`Formats and prints ARGUMENTS under control of the FORMAT. Options: -v var assign the output to shell variable VAR rather than display it on the standard output FORMAT is a character string which contains three types of objects: plain characters, which are simply copied to standard output; character escape sequences, which are converted and copied to the standard output; and format specifications, each of which causes printing of the next successive argument. Exit Status: Returns success unless an invalid option is given or a write or assignment error occurs.`]],[`pushd`,[`pushd [-n] [+N | -N | dir]`,`Add directories to stack. Adds a directory to the top of the directory stack, or rotates the stack, making the new top of the stack the current working directory. Exit Status: Returns success unless an invalid argument is supplied or the directory change fails.`]],[`pwd`,[`pwd [-LP]`,`Print the name of the current working directory. Options: -L print the value of $PWD if it names the current working directory -P print the physical directory, without any symbolic links By default, \`pwd' behaves as if \`-L' were specified. Exit Status: Returns 0 unless an invalid option is given or the current directory cannot be read.`]],[`read`,[`read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]`,`Read a line from the standard input and split it into fields. Reads a single line from the standard input, or from file descriptor FD if the -u option is supplied. The line is split into fields as with word splitting, and the first word is assigned to the first NAME, the second word to the second NAME, and so on, with any leftover words assigned to the last NAME. Exit Status: The return code is zero, unless end-of-file is encountered, read times out, or an invalid file descriptor is supplied as the argument to -u.`]],[`readarray`,[`readarray [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]`,`Read lines from a file into an array variable. A synonym for \`mapfile'.`]],[`readonly`,[`readonly [-aAf] [name[=value] ...] or readonly -p`,`Mark shell variables as unchangeable. Mark each NAME as read-only; the values of these NAMEs may not be changed by subsequent assignment. Exit Status: Returns success unless an invalid option is given or NAME is invalid.`]],[`return`,[`return [n]`,`Return from a shell function. Causes a function or sourced script to exit with the return value specified by N. If N is omitted, the return status is that of the last command executed within the function or script. Exit Status: Returns N, or failure if the shell is not executing a function or script.`]],[`set`,[`set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]`,`Set or unset values of shell options and positional parameters. Change the value of shell attributes and positional parameters, or display the names and values of shell variables. Options: -e Exit immediately if a command exits with a non-zero status. -u Treat unset variables as an error when substituting. -x Print commands and their arguments as they are executed. -o option-name Set the variable corresponding to option-name Exit Status: Returns success unless an invalid option is given.`]],[`shift`,[`shift [n]`,`Shift positional parameters. Rename the positional parameters $N+1,$N+2 ... to $1,$2 ... If N is not given, it is assumed to be 1. Exit Status: Returns success unless N is negative or greater than $#.`]],[`shopt`,[`shopt [-pqsu] [-o] [optname ...]`,`Set and unset shell options. Change the setting of each shell option OPTNAME. Without any option arguments, list each supplied OPTNAME, or all shell options if no OPTNAMEs are given, with an indication of whether or not each is set. Options: -o restrict OPTNAMEs to those defined for use with \`set -o' -p print each shell option with an indication of its status -q suppress output -s enable (set) each OPTNAME -u disable (unset) each OPTNAME Exit Status: Returns success if OPTNAME is enabled; fails if an invalid option is given or OPTNAME is disabled.`]],[`source`,[`source filename [arguments]`,`Execute commands from a file in the current shell. Read and execute commands from FILENAME in the current shell. The entries in $PATH are used to find the directory containing FILENAME. Exit Status: Returns the status of the last command executed in FILENAME.`]],[`suspend`,[`suspend [-f]`,`Suspend shell execution. Suspend the execution of this shell until it receives a SIGCONT signal.`]],[`test`,[`test [expr]`,`Evaluate conditional expression. Exits with a status of 0 (true) or 1 (false) depending on the evaluation of EXPR. Expressions may be unary or binary. Exit Status: Returns success if EXPR evaluates to true; fails if EXPR evaluates to false or an invalid argument is given.`]],[`times`,[`times`,`Display process times. Prints the accumulated user and system times for the shell and all of its child processes. Exit Status: Always succeeds.`]],[`trap`,[`trap [-lp] [[arg] signal_spec ...]`,`Trap signals and other events. Defines and activates handlers to be run when the shell receives signals or other conditions. Exit Status: Returns success unless a SIGSPEC is invalid or an invalid option is given.`]],[`true`,[`true`,`Return a successful result. Exit Status: Always succeeds.`]],[`type`,[`type [-afptP] name [name ...]`,`Display information about command type. For each NAME, indicate how it would be interpreted if used as a command name. Options: -a display all locations containing an executable named NAME -f suppress shell function lookup -P force a PATH search for each NAME, even if it is an alias, builtin, or function, and returns the name of the disk file that would be executed -p returns either the name of the disk file that would be executed, or nothing if \`type -t NAME' would not return \`file' -t output a single word which is one of \`alias', \`keyword', \`function', \`builtin', \`file' or \`', if NAME is an alias, shell reserved word, shell function, shell builtin, disk file, or not found, respectively Exit Status: Returns success if all of the NAMEs are found; fails if any are not found.`]],[`typeset`,[`typeset [-aAfFgilnrtux] [-p] name[=value] ...`,`Set variable values and attributes. A synonym for \`declare'.`]],[`ulimit`,[`ulimit [-SHabcdefiklmnpqrstuvxPT] [limit]`,`Modify shell resource limits. Provides control over the resources available to the shell and processes it creates, on systems that allow such control. Exit Status: Returns success unless an invalid option is supplied or an error occurs.`]],[`umask`,[`umask [-p] [-S] [mode]`,`Display or set file mode mask. Sets the user file-creation mask to MODE. If MODE is omitted, prints the current value of the mask. Exit Status: Returns success unless MODE is invalid or an invalid option is given.`]],[`unalias`,[`unalias [-a] name [name ...]`,`Remove each NAME from the list of defined aliases. Exit Status: Returns success unless a NAME is not an existing alias.`]],[`unset`,[`unset [-f] [-v] [-n] [name ...]`,`Unset values and attributes of shell variables and functions. For each NAME, remove the corresponding variable or function. Options: -f treat each NAME as a shell function -v treat each NAME as a shell variable -n treat each NAME as a name reference and unset the variable itself rather than the variable it references Without options, unset first tries to unset a variable, and if that fails, tries to unset a function. Exit Status: Returns success unless an invalid option is given or a NAME is read-only.`]],[`wait`,[`wait [-fn] [id ...]`,`Wait for job completion and return exit status. Waits for each process identified by an ID, which may be a process ID or a job specification, and reports its termination status. Exit Status: Returns the status of the last ID; fails if ID is invalid or an invalid option is given.`]]]),R7=[...L7.keys()].sort();function QMe(e,t){let n=!1,r=[],i=0;for(;i1){for(let t=1;tt.test(e))}function eNe(){let e=[];e.push(`just-bash shell builtins`),e.push("These shell commands are defined internally. Type `help' to see this list."),e.push("Type `help name' to find out more about the function `name'."),e.push(``);let t=R7.slice(),n=Math.ceil(t.length/2);for(let r=0;r0&&n.pipelines[0].commands.length>0){let t=n.pipelines[0].commands[0];t.type===`ArithmeticCommand`&&(r=await N8(e,t.expression.expression))}}catch(e){return Q(`bash: let: ${t}: ${e.message} `)}return $(``,``,+(r===0))}cH();async function rNe(e,t){let n={maxElements:e.limits.maxArrayElements,maxStringBytes:e.limits.maxStringLength};if(e.state.localScopes.length===0)return Q(`bash: local: can only be used in a function `);let r=e.state.localScopes[e.state.localScopes.length-1];for(e.state.localArrayScopes??=[];e.state.localArrayScopes.length{if(r.has(t)||r.set(t,e.state.env.get(t)),i&&!i.has(t)){let n=Q2(e,t);i.set(t,n?X2(n):void 0)}},o=``,s=0,c=!1,l=!1,u=[];for(let e of t)if(e===`-n`)c=!0;else if(e===`-a`)l=!0;else if(e!==`-p`){if(e.startsWith(`-`)&&!e.includes(`=`))for(let t of e.slice(1))t===`n`?c=!0:t===`a`&&(l=!0);else u.push(e)}if(u.length===0){let t=``,n=Array.from(r.keys()).sort();for(let r of n){let n=e.state.env.get(r);n!==void 0&&(t+=`${r}=${n} `)}return $(t,``,0)}for(let t of u){let i,u,d=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(d){i=d[1];let r=d[2];if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)){o+=`bash: local: \`${t}': not a valid identifier `,s=1;continue}V6(e,i,`bash`);let l=p5(r,n);e.executionScope.consumeWork(l.length,`local array assignment`),a(i),l4(e,i),e4(e,i,`indexed`);for(let t=0;t0&&(s=Math.max(...o)+1),a4(e,i,Array.from({length:r.length},(e,t)=>s+t));for(let t=0;t=0;n--){let r=e.state.tempEnvBindings[n];if(r.has(i)){t=r.get(i);break}}}Xje(e,i,t)}if(!h){let t=e.state.env.get(i);if(e.state.tempEnvBindings)for(let n=e.state.tempEnvBindings.length-1;n>=0;n--){let r=e.state.tempEnvBindings[n];if(r.has(i)){t=r.get(i);break}}r.set(i,t),l&&a(i)}if(l&&u===void 0)l4(e,i),e4(e,i,`indexed`);else if(u!==void 0){if(V6(e,i,`bash`),c&&u!==``&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(u)){o+=`bash: local: \`${u}': invalid variable name for name reference `,s=1;continue}e.state.env.set(i,u),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(i))}else{let t=e.state.tempEnvBindings?.some(e=>e.has(i));!h&&!t&&e.state.env.delete(i)}h5(e,i),c&&u6(e,i)}return $(``,o,s)}AB(),U();function iNe(e,t,n){let r=` `,i=0,a=0,o=0,s=!1,c=`MAPFILE`,l=0;for(;l{if(V(t)>e.limits.maxStringLength)throw new H(`mapfile: string length limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);d.push(t)};for(;f=h)return $(``,`mapfile: array element limit exceeded (${h}) `,1);g(e),p++}}break}let n=u.slice(f,t),a=n.indexOf(`\0`);if(a!==-1&&(n=n.substring(0,a)),!s&&r!==`\0`&&(n+=r),f=t+r.length,m0&&p>=i)break;if(d.length>=h)return $(``,`mapfile: array element limit exceeded (${h}) `,1);g(n),p++}let _=new Set(a===0?[]:e.state.arrays?.get(c)?.elements.keys()??[]);for(let e=0;eh)return $(``,`mapfile: array element limit exceeded (${h}) `,1);a===0&&l4(e,c);for(let t=0;t{let r=1;for(;r1&&e!==`--`){let t=m(e,f);if(t.nextArgIndex===-1)return{stdout:``,stderr:``,exitCode:2};if(t.nextArgIndex===-2)return{stdout:``,stderr:``,exitCode:1};f=t.nextArgIndex}else if(e===`--`)for(f++;f=0&&d.length===0&&h.add(`REPLY`);for(let t of h){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t))return $(``,`bash: read: \`${t}': not a valid identifier `,1);V6(e,t,`bash`)}if(u===0){if(c)l4(e,c);else{for(let t of d)e.state.env.set(t,``);d.length===0&&e.state.env.set(`REPLY`,``)}return $(``,``,0)}if(u<0&&u!==-1)return $(``,``,1);let g=n,_=F5(e,l),v=l>0&&(_?.kind!==`dup-in`||_.sourceFd!==0);if(v){let t=U5(e,l);if(`error`in t)return $(``,t.error===`write-only`||l===1||l===2?`bash: read: read error: ${l}: Bad file descriptor `:`bash: read: ${l}: invalid file descriptor: Bad file descriptor `,1);g=t.content}else!g&&e.state.groupStdin!==void 0&&(g=e.state.groupStdin);let y=a===``?`\0`:a,b=``,x=0,S=t=>{let n=V(t);if(n>e.limits.maxStringLength-x)throw new H(`read: string length limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);b+=t,x+=n},C=t=>{if(V(t)>e.limits.maxStringLength)throw new H(`read: string length limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`)},w=0,T=!0,E=t=>{v?W5(e,l,t):r>=0?W5(e,r,t):e.state.groupStdin!==void 0&&!n&&(e.state.groupStdin=g.substring(t),e.state.groupStdinSourceFd!==void 0&&W5(e,e.state.groupStdinSourceFd,t))};if(s>=0){let t=Math.min(s,g.length);b=g.substring(0,t),C(b),w=t,T=t>=s,E(w);let n=d[0]||`REPLY`;e.state.env.set(n,b);for(let t=1;t=0){let e=0,t=0,n=!1;for(;t=o||n,E(w)}else{w=0;let t=0;for(;t=g.length&&(T=!1,w=t,b.length===0&&g.length===0)){for(let t of d)e.state.env.set(t,``);return c&&l4(e,c),$(``,``,1)}E(w)}y===` `&&b.endsWith(` `)&&(b=b.slice(0,-1));let D=e=>i?e:e.replace(/\\(.)/g,`$1`);if(d.length===1&&d[0]===`REPLY`)return e.state.env.set(`REPLY`,D(b)),$(``,``,+!T);let O=t6(e.state.env),k=e.limits.maxArrayElements;if(c){let{words:t}=o6(b,O,k,void 0,i);l4(e,c);for(let n=0;n0){let e=t[0],r=Number.parseInt(e,10);if(e===``||Number.isNaN(r)||!/^-?\d+$/.test(e))return Q(`bash: return: ${e}: numeric argument required `,2);n=(r%256+256)%256}throw new FB(n)}cH(),U();var z7=`set: usage: set [-eux] [+eux] [-o option] [+o option] Options: -e Exit immediately if a command exits with non-zero status +e Disable -e -u Treat unset variables as an error when substituting +u Disable -u -x Print commands and their arguments as they are executed +x Disable -x -o errexit Same as -e +o errexit Disable errexit -o nounset Same as -u +o nounset Disable nounset -o pipefail Return status of last failing command in pipeline +o pipefail Disable pipefail -o xtrace Same as -x +o xtrace Disable xtrace `,B7=new Map([[`e`,`errexit`],[`u`,`nounset`],[`x`,`xtrace`],[`v`,`verbose`],[`f`,`noglob`],[`C`,`noclobber`],[`a`,`allexport`],[`n`,`noexec`],[`h`,null],[`b`,null],[`m`,null],[`B`,null],[`H`,null],[`P`,null],[`T`,null],[`E`,null],[`p`,null]]),V7=new Map([[`errexit`,`errexit`],[`pipefail`,`pipefail`],[`nounset`,`nounset`],[`xtrace`,`xtrace`],[`verbose`,`verbose`],[`noclobber`,`noclobber`],[`noglob`,`noglob`],[`allexport`,`allexport`],[`noexec`,`noexec`],[`posix`,`posix`],[`vi`,`vi`],[`emacs`,`emacs`],[`notify`,null],[`monitor`,null],[`braceexpand`,null],[`histexpand`,null],[`physical`,null],[`functrace`,null],[`errtrace`,null],[`privileged`,null],[`hashall`,null],[`ignoreeof`,null],[`interactive-comments`,null],[`keyword`,null],[`onecmd`,null]]),H7=[`errexit`,`nounset`,`pipefail`,`verbose`,`xtrace`,`posix`,`allexport`,`noclobber`,`noglob`,`noexec`,`vi`,`emacs`],U7=[`braceexpand`,`errtrace`,`functrace`,`hashall`,`histexpand`,`history`,`ignoreeof`,`interactive-comments`,`keyword`,`monitor`,`nolog`,`notify`,`onecmd`,`physical`,`privileged`];function W7(e,t,n){t!==null&&(n&&(t===`vi`?e.state.options.emacs=!1:t===`emacs`&&(e.state.options.vi=!1)),e.state.options[t]=n,h4(e))}function sNe(e,t){return t+10&&t.append(` `),t.append(`[${a}]=`),t.reserve(v7(o)),t.append(y7(o))}t.append(`)`)}function lNe(e,t){if(/^[a-zA-Z0-9_]+$/.test(t)){e.append(t);return}e.reserve(v7(t)),e.append(y7(t))}function uNe(e,t,n){let r=u4(e,n);if(r.length===0){t.append(n).append(`=()`);return}t.append(n).append(`=(`);for(let i=0;i0&&t.append(` `),t.append(`[`),lNe(t,a),t.append(`]=`),t.reserve(v7(o)),t.append(y7(o))}t.append(` )`)}function dNe(e){let t=new Set,n=e.state.associativeArrays??new Set;for(let[r,i]of e.state.arrays??[])i.kind===`indexed`&&!n.has(r)&&t.add(r);return t}function fNe(e){return e.state.associativeArrays??new Set}function G7(e){let t=H7.map(t=>`${t.padEnd(16)}${e.state.options[t]?`on`:`off`}`),n=U7.map(e=>`${e.padEnd(16)}off`);return`${[...t,...n].sort().join(` `)} `}function K7(e){let t=H7.map(t=>`set ${e.state.options[t]?`-o`:`+o`} ${t}`),n=U7.map(e=>`set +o ${e}`);return`${[...t,...n].sort().join(` `)} `}function pNe(e,t){if(t.includes(`--help`))return L8(z7);if(t.length===0){let t=dNe(e),n=fNe(e),r=[];for(let[i,a]of e.state.env)/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)&&(t.has(i)||n.has(i)||r.push([i,a]));let i=[...r.map(([e,t])=>({kind:`scalar`,name:e,value:t})),...Array.from(t,e=>({kind:`indexed`,name:e})),...Array.from(n,e=>({kind:`associative`,name:e}))];i.sort((e,t)=>e.namet.name));let a=new sH(e.limits.maxOutputSize,`set`);for(let t of i)e.executionScope.consumeWork(1,`set variable listing`),t.kind===`scalar`?(a.append(t.name).append(`=`),a.reserve(AMe(t.value)),a.append(_7(t.value))):t.kind===`indexed`?cNe(e,a,t.name):uNe(e,a,t.name),a.append(` `);return L8(a.build())}let n=[],r=()=>n.length>0?L8(n.join(``)):I8,i=0;for(;i1&&(a[0]===`-`||a[0]===`+`)&&a[1]!==`-`){let r=a[0]===`-`,o=0;for(let s=1;s0){let r=Number.parseInt(t[0],10);if(Number.isNaN(r)||r<0){let n=`bash: shift: ${t[0]}: numeric argument required `;if(e.state.options.posix)throw new GB(1,``,n);return Q(n)}n=r}let r=Number.parseInt(e.state.env.get(`#`)||`0`,10);if(n>r){let t=`bash: shift: shift count out of range `;if(e.state.options.posix)throw new GB(1,``,t);return Q(t)}if(n===0)return I8;let i=[];for(let t=1;t<=r;t++)i.push(e.state.env.get(String(t))||``);let a=i.slice(n);for(let t=1;t<=r;t++)e.state.env.delete(String(t));for(let t=0;t0&&n[0]===`--`&&(n=n.slice(1)),n.length===0)return $(``,`bash: source: filename argument required `,2);let r=n[0],i=null;if(r.includes(`/`)){let t=e.fs.resolvePath(e.state.cwd,r);try{i=await e.fs.readFile(t)}catch{}}else{let t=(e.state.env.get(`PATH`)||``).split(`:`).filter(e=>e);for(let n of t){let t=e.fs.resolvePath(e.state.cwd,`${n}/${r}`);try{if((await e.fs.stat(t)).isDirectory)continue;i=await e.fs.readFile(t);break}catch{}}if(i===null){let t=e.fs.resolvePath(e.state.cwd,r);try{i=await e.fs.readFile(t)}catch{}}}if(i===null)return Q(`bash: ${r}: No such file or directory `);let a=new Map;if(n.length>1){for(let t=1;t<=9;t++)a.set(String(t),e.state.env.get(String(t)));a.set(`#`,e.state.env.get(`#`)),a.set(`@`,e.state.env.get(`@`));let t=n.slice(1);e.state.env.set(`#`,String(t.length)),e.state.env.set(`@`,t.join(` `));for(let n=0;n{if(e.state.sourceDepth--,e.state.currentSource=o,n.length>1)for(let[t,n]of a)n===void 0?e.state.env.delete(t):e.state.env.set(t,n)};if(e.state.sourceDepth++,e.state.sourceDepth>e.limits.maxSourceDepth)throw e.state.sourceDepth--,new H(`source: maximum nesting depth (${e.limits.maxSourceDepth}) exceeded, increase executionLimits.maxSourceDepth`,`recursion`);e.state.currentSource=r;try{let t=E3(i),n=await e.executeScript(t);return s(),n}catch(e){if(s(),e instanceof RB)throw e;if(e instanceof FB)return $(e.stdout,e.stderr,e.exitCode);if(e.name===`ParseException`)return Q(`bash: ${r}: ${e.message} `);throw e}}function J7(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function gNe(e){return e.startsWith(`'`)&&e.endsWith(`'`)||e.startsWith(`"`)&&e.endsWith(`"`)}async function Y7(e,t){if(gNe(t))return null;try{return await N8(e,P4(new T3,t).expression)}catch{let e=parseInt(t,10);return Number.isNaN(e)?0:e}}function X7(e,t){if(e.state.localVarStack?.has(t)){let n=v5(e,t);if(n){n.value===void 0?e.state.env.delete(t):e.state.env.set(t,n.value);let r=e.state.localVarStack?.get(t);if(!r||r.length===0)_5(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,n.scopeIndex),Z7(e,t);else{let n=r[r.length-1];e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,n.scopeIndex+1)}return!0}return e.state.env.delete(t),_5(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,0),!0}for(let n=e.state.localScopes.length-1;n>=0;n--){let r=e.state.localScopes[n];if(r.has(t)){let i=r.get(t);i===void 0?e.state.env.delete(t):e.state.env.set(t,i),r.delete(t);let a=!1;for(let r=n-1;r>=0;r--)if(e.state.localScopes[r].has(t)){e.state.localVarDepth&&e.state.localVarDepth.set(t,r+1),a=!0;break}return a||_5(e,t),!0}}return!1}function Z7(e,t){if(!e.state.tempEnvBindings||e.state.tempEnvBindings.length===0)return!1;for(let n=e.state.tempEnvBindings.length-1;n>=0;n--){let r=e.state.tempEnvBindings[n];if(r.has(t)){let n=r.get(t);return n===void 0?e.state.env.delete(t):e.state.env.set(t,n),r.delete(t),!0}}return!1}async function Q7(e,t){if(t.startsWith(`'`)&&t.endsWith(`'`))return t.slice(1,-1);if(t.startsWith(`"`)&&t.endsWith(`"`)){let n=t.slice(1,-1);return _8(e,new T3().parseWordFromString(n,!0,!1))}return t.includes(`$`)?_8(e,new T3().parseWordFromString(t,!1,!1)):t}async function _Ne(e,t){let n=`both`,r=``,i=0;for(let a of t){if(a===`-v`){n=`variable`;continue}if(a===`-f`){n=`function`;continue}if(n===`function`){e.state.functions.delete(a);continue}if(n===`variable`){let t=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(t){let n=t[1],a=t[2];if(B6(e,n)){r+=`bash: unset: ${n}: cannot unset: readonly variable `,i=1;continue}if(a===`@`||a===`*`){s4(e,n),e.state.env.delete(n);continue}let o=e.state.associativeArrays?.has(n);if(o){o4(e,n,await Q7(e,a));continue}let s=y6(e,n),c=e.state.declaredVars?.has(n);if((e.state.env.has(n)||c)&&!s&&!o){r+=`bash: unset: ${n}: not an array variable `,i=1;continue}let l=await Y7(e,a);if(l===null&&s){r+=`bash: unset: ${a}: not a valid identifier `,i=1;continue}if(l===null)continue;if(l<0){let t=v6(e,n),a=t.length,o=e.state.currentLine;if(a===0){r+=`bash: line ${o}: unset: [${l}]: bad array subscript `,i=1;continue}let s=a+l;if(s<0){r+=`bash: line ${o}: unset: [${l}]: bad array subscript `,i=1;continue}let c=t[s][0];o4(e,n,c);continue}o4(e,n,l);continue}if(!J7(a)){r+=`bash: unset: \`${a}': not a valid identifier `,i=1;continue}let n=a;if(l6(e,a)){let t=m6(e,a);t&&t!==a&&(n=t)}if(B6(e,n)){r+=`bash: unset: ${n}: cannot unset: readonly variable `,i=1;continue}s4(e,n);let o=g5(e,n);if(o!==void 0&&o!==e.state.callDepth)X7(e,n);else if(e.state.fullyUnsetLocals?.has(n))e.state.env.delete(n);else if(o!==void 0){let t=e.state.accessedTempEnvVars?.has(n),r=e.state.mutatedTempEnvVars?.has(n);if((t||r)&&e.state.localVarStack?.has(n)){let t=v5(e,n);t?t.value===void 0?e.state.env.delete(n):e.state.env.set(n,t.value):e.state.env.delete(n)}else e.state.env.delete(n)}else Z7(e,n)||e.state.env.delete(n);e.state.exportedVars?.delete(n);continue}let t=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(t){let n=t[1],a=t[2];if(B6(e,n)){r+=`bash: unset: ${n}: cannot unset: readonly variable `,i=1;continue}if(a===`@`||a===`*`){s4(e,n),e.state.env.delete(n);continue}let o=e.state.associativeArrays?.has(n);if(o){o4(e,n,await Q7(e,a));continue}let s=y6(e,n);if(e.state.env.has(n)&&!s&&!o){r+=`bash: unset: ${n}: not an array variable `,i=1;continue}let c=await Y7(e,a);if(c===null&&s){r+=`bash: unset: ${a}: not a valid identifier `,i=1;continue}if(c===null)continue;if(c<0){let t=v6(e,n),a=t.length,o=e.state.currentLine;if(a===0){r+=`bash: line ${o}: unset: [${c}]: bad array subscript `,i=1;continue}let s=a+c;if(s<0){r+=`bash: line ${o}: unset: [${c}]: bad array subscript `,i=1;continue}let l=t[s][0];o4(e,n,l);continue}o4(e,n,c);continue}if(!J7(a)){r+=`bash: unset: \`${a}': not a valid identifier `,i=1;continue}let o=a;if(l6(e,a)){let t=m6(e,a);t&&t!==a&&(o=t)}if(B6(e,o)){r+=`bash: unset: ${o}: cannot unset: readonly variable `,i=1;continue}s4(e,o);let s=g5(e,o);if(s!==void 0&&s!==e.state.callDepth)X7(e,o);else if(e.state.fullyUnsetLocals?.has(o))e.state.env.delete(o);else if(s!==void 0){let t=e.state.accessedTempEnvVars?.has(o),n=e.state.mutatedTempEnvVars?.has(o);if((t||n)&&e.state.localVarStack?.has(o)){let t=v5(e,o);t?t.value===void 0?e.state.env.delete(o):e.state.env.set(o,t.value):e.state.env.delete(o)}else e.state.env.delete(o)}else Z7(e,o)||e.state.env.delete(o);e.state.exportedVars?.delete(o),e.state.functions.delete(a)}return $(``,r,i)}ZB(),U();function $7(e,t,n,r){let i=n+V(t)+1;if(i>r)throw new H(`shopt: output size limit exceeded (${r} bytes)`,`output_size`);return e.push(t),i}var e9=[`extglob`,`dotglob`,`nullglob`,`failglob`,`globstar`,`globskipdots`,`nocaseglob`,`nocasematch`,`expand_aliases`,`lastpipe`,`xpg_echo`],vNe=`autocd.cdable_vars.cdspell.checkhash.checkjobs.checkwinsize.cmdhist.compat31.compat32.compat40.compat41.compat42.compat43.compat44.complete_fullquote.direxpand.dirspell.execfail.extdebug.extquote.force_fignore.globasciiranges.gnu_errfmt.histappend.histreedit.histverify.hostcomplete.huponexit.inherit_errexit.interactive_comments.lithist.localvar_inherit.localvar_unset.login_shell.mailwarn.no_empty_cmd_completion.progcomp.progcomp_alias.promptvars.restricted_shell.shift_verbose.sourcepath`.split(`.`);function t9(e){return e9.includes(e)}function yNe(e){return vNe.includes(e)}function bNe(e,t){let n=e.limits.maxArrayElements;if(t.length>n)throw new H(`shopt: argument limit exceeded (${n})`,`array_elements`);let r=Math.min(e.limits.maxOutputSize,e.limits.maxStringLength),i=!1,a=!1,o=!1,s=!1,c=!1,l=[],u=0;for(;u1){for(let t=1;t0?`${t.join(` `)} `:``,stderr:``}}let t=[];for(let n of e9){let r=e.state.shoptOptions[n];t.push(o?`shopt ${r?`-s`:`-u`} ${n}`:`${n} ${r?`on`:`off`}`)}return{exitCode:0,stdout:`${t.join(` `)} `,stderr:``}}let d=!1,f=[],p=0,m=[],h=0;for(let t of l){if(!t9(t)&&!yNe(t)){p=$7(f,`shopt: ${t}: invalid shell option name`,p,r),d=!0;continue}if(i)t9(t)&&(e.state.shoptOptions[t]=!0,_4(e));else if(a)t9(t)&&(e.state.shoptOptions[t]=!1,_4(e));else if(t9(t)){let n=e.state.shoptOptions[t];s?n||(d=!0):o?(h=$7(m,`shopt ${n?`-s`:`-u`} ${t}`,h,r),n||(d=!0)):(h=$7(m,`${t} ${n?`on`:`off`}`,h,r),n||(d=!0))}else s?d=!0:o?(h=$7(m,`shopt -u ${t}`,h,r),d=!0):(h=$7(m,`${t} off`,h,r),d=!0)}return{exitCode:+!!d,stdout:m.length>0?`${m.join(` `)} `:``,stderr:f.length>0?`${f.join(` `)} `:``}}function xNe(e,t,n,r,i,a){let o=Math.min(e.limits.maxOutputSize,e.limits.maxStringLength),s=new Map([[`errexit`,`errexit`],[`pipefail`,`pipefail`],[`nounset`,`nounset`],[`xtrace`,`xtrace`],[`verbose`,`verbose`],[`posix`,`posix`],[`allexport`,`allexport`],[`noclobber`,`noclobber`],[`noglob`,`noglob`],[`noexec`,`noexec`],[`vi`,`vi`],[`emacs`,`emacs`]]),c=[`braceexpand`,`errtrace`,`functrace`,`hashall`,`histexpand`,`history`,`ignoreeof`,`interactive-comments`,`keyword`,`monitor`,`nolog`,`notify`,`onecmd`,`physical`,`privileged`],l=[...s.keys(),...c].sort();if(t.length===0){let t=[];for(let a of l){let o=c.includes(a),l=s.get(a),u=o||!l?!1:e.state.options[l];n&&!u||r&&u||t.push(i?`set ${u?`-o`:`+o`} ${a}`:`${a} ${u?`on`:`off`}`)}return{exitCode:0,stdout:t.length>0?`${t.join(` `)} `:``,stderr:``}}let u=!1,d=[],f=0,p=[],m=0;for(let l of t){let t=s.has(l),h=c.includes(l);if(!t&&!h){f=$7(d,`shopt: ${l}: invalid option name`,f,o),u=!0;continue}if(h){n||r||(a?u=!0:i?(m=$7(p,`set +o ${l}`,m,o),u=!0):(m=$7(p,`${l} off`,m,o),u=!0));continue}let g=s.get(l);if(g){if(n)g===`vi`?e.state.options.emacs=!1:g===`emacs`&&(e.state.options.vi=!1),e.state.options[g]=!0,h4(e);else if(r)e.state.options[g]=!1,h4(e);else{let t=e.state.options[g];a?t||(u=!0):i?(m=$7(p,`set ${t?`-o`:`+o`} ${l}`,m,o),t||(u=!0)):(m=$7(p,`${l} ${t?`on`:`off`}`,m,o),t||(u=!0))}}}return{exitCode:+!!u,stdout:p.length>0?`${p.join(` `)} `:``,stderr:d.length>0?`${d.join(` `)} `:``}}function n9(e,t){return e===`/bin/${t}`||e===`/usr/bin/${t}`}async function SNe(e,t,n){if(t.includes(`/`)){let n=e.fs.resolvePath(e.state.cwd,t);if(!await e.fs.exists(n))return{error:`not_found`,path:n};try{let r=await e.fs.stat(n);if(r.isDirectory)return{error:`permission_denied`,path:n};let i=n.split(`/`).pop()||t,a=e.commands.get(i);return a&&n9(n,i)?{cmd:a,path:n}:r.mode&73?{script:!0,path:n}:{error:`permission_denied`,path:n}}catch{return{error:`not_found`,path:n}}}if(!n&&e.state.hashTable){let n=e.state.hashTable.get(t);if(n){try{let r=await e.fs.stat(n);if(!r.isDirectory){let i=e.commands.get(t);if(i&&n9(n,t))return{cmd:i,path:n};if(r.mode&73)return{script:!0,path:n}}}catch{}e.state.hashTable.delete(t)}}let r=(n??e.state.env.get(`PATH`)??`/usr/bin:/bin`).split(`:`);for(let n of r){if(!n)continue;let r=`${n.startsWith(`/`)?n:e.fs.resolvePath(e.state.cwd,n)}/${t}`;if(await e.fs.exists(r))try{let n=await e.fs.stat(r);if(n.isDirectory)continue;let i=!!(n.mode&73),a=e.commands.get(t),o=n9(r,t);if(a&&o)return{cmd:a,path:r};if(i&&(a&&!o||!a))return{script:!0,path:r}}catch{}}if(!await e.fs.exists(`/usr/bin`)){let n=e.commands.get(t);if(n)return{cmd:n,path:`/usr/bin/${t}`}}return null}async function r9(e,t){let n=[];if(t.includes(`/`)){let r=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(r))try{let i=await e.fs.stat(r);i.isDirectory||i.mode&73&&n.push(t)}catch{}return n}let r=(e.state.env.get(`PATH`)||`/usr/bin:/bin`).split(`:`);for(let i of r){if(!i)continue;let r=`${i.startsWith(`/`)?i:e.fs.resolvePath(e.state.cwd,i)}/${t}`;if(n9(r,t)&&e.commands.has(t)){n.push(r);continue}if(await e.fs.exists(r)){try{let t=await e.fs.stat(r);if(t.isDirectory||!(t.mode&73))continue}catch{continue}n.push(i.startsWith(`/`)?r:`${i}/${t}`)}}return n}jK();function CNe(e){return typeof e==`object`&&!!e&&`then`in e&&typeof e.then==`function`}function i9(e,t,n,r){return((...i)=>{kK(t,n,`${r} call`);let a=e(...i);return CNe(a)?a.then(e=>(kK(t,n,`${r} post-await`),e),e=>{throw kK(t,n,`${r} post-await`),e}):(kK(t,n,`${r} return`),a)})}function wNe(e,t,n){let r={readFile:i9(e.readFile.bind(e),t,n,`fs.readFile`),...typeof e.readFileBytes==`function`?{readFileBytes:i9(e.readFileBytes.bind(e),t,n,`fs.readFileBytes`)}:Object.create(null),readFileBuffer:i9(e.readFileBuffer.bind(e),t,n,`fs.readFileBuffer`),writeFile:i9(e.writeFile.bind(e),t,n,`fs.writeFile`),appendFile:i9(e.appendFile.bind(e),t,n,`fs.appendFile`),exists:i9(e.exists.bind(e),t,n,`fs.exists`),stat:i9(e.stat.bind(e),t,n,`fs.stat`),mkdir:i9(e.mkdir.bind(e),t,n,`fs.mkdir`),readdir:i9(e.readdir.bind(e),t,n,`fs.readdir`),rm:i9(e.rm.bind(e),t,n,`fs.rm`),cp:i9(e.cp.bind(e),t,n,`fs.cp`),mv:i9(e.mv.bind(e),t,n,`fs.mv`),resolvePath:i9(e.resolvePath.bind(e),t,n,`fs.resolvePath`),getAllPaths:i9(e.getAllPaths.bind(e),t,n,`fs.getAllPaths`),chmod:i9(e.chmod.bind(e),t,n,`fs.chmod`),symlink:i9(e.symlink.bind(e),t,n,`fs.symlink`),link:i9(e.link.bind(e),t,n,`fs.link`),readlink:i9(e.readlink.bind(e),t,n,`fs.readlink`),lstat:i9(e.lstat.bind(e),t,n,`fs.lstat`),realpath:i9(e.realpath.bind(e),t,n,`fs.realpath`),utimes:i9(e.utimes.bind(e),t,n,`fs.utimes`)};return e.readdirWithFileTypes&&(r.readdirWithFileTypes=i9(e.readdirWithFileTypes.bind(e),t,n,`fs.readdirWithFileTypes`)),r}function a9(e,t){if(!e.requireDefenseContext)return e;let n=`command:${t}`,r=Object.getOwnPropertyDescriptors(e);r.fs={value:wNe(e.fs,e.requireDefenseContext,n),enumerable:!0,configurable:!0,writable:!0};let i=Object.defineProperties(Object.create(Object.getPrototypeOf(e)),r);return e.exec&&(i.exec=i9(e.exec,e.requireDefenseContext,n,`exec`)),e.origCommand&&(i.origCommand=i9(e.origCommand,e.requireDefenseContext,n,`origCommand`)),e.fetch&&(i.fetch=i9(e.fetch,e.requireDefenseContext,n,`fetch`)),e.sleep&&(i.sleep=i9(e.sleep,e.requireDefenseContext,n,`sleep`)),e.getRegisteredCommands&&(i.getRegisteredCommands=i9(e.getRegisteredCommands,e.requireDefenseContext,n,`getRegisteredCommands`)),i}U(),EV(),cH(),U(),U();var o9=`+ `;async function s9(e){let t=e.state.env.get(`PS4`);if(t===void 0)return o9;if(t===``)return``;let n=e.state.options.xtrace;e.state.options.xtrace=!1;try{return await _8(e,new T3().parseWordFromString(t,!1,!1))}catch(n){if(n instanceof zB&&!n.fatal)return t;if(n instanceof MB||n instanceof Error&&n.name===`AbortError`)throw n;return e.state.expansionStderr=`${e.state.expansionStderr||``}bash: ${t}: bad substitution `,t||o9}finally{e.state.options.xtrace=n}}function TNe(e){return e.map(e=>ENe(e)).join(` `)}function ENe(e){if(e===``)return`''`;if(!/[\s'"\\$`!*?[\]{}|&;<>()~#\n\t]/.test(e))return e;let t=/[\x00-\x1f\x7f]/.test(e),n=e.includes(` `),r=e.includes(` `),i=e.includes(`\\`),a=e.includes(`'`);if(t||n||r||i){let t=``;for(let n of e){let e=n.charCodeAt(0);t+=n===` `?`\\n`:n===` `?`\\t`:n===`\\`?`\\\\`:n===`'`?`'`:n===`"`?`"`:e<32||e===127?e<256?`\\x${e.toString(16).padStart(2,`0`)}`:`\\u${e.toString(16).padStart(4,`0`)}`:n}return`$'${t}'`}return a?`"${e.replace(/([\\$`"])/g,`\\$1`)}"`:`'${e}'`}async function DNe(e,t,n){return e.state.options.xtrace?`${await s9(e)}${TNe([t,...n])} `:``}async function ONe(e,t,n){return e.state.options.xtrace?`${await s9(e)}${t}=${n} `:``}function c9(e,t,n){return oH([t,n],``,e.limits.maxStringLength,`array assignment`)}async function kNe(e,t){let n=new Map,r=``;for(let i of t.assignments){let a=i.name;if(i.array){let o=await ANe(e,t,a,i.array,i.append,n);if(o.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:n,error:o.error};if(r+=o.xtraceOutput,o.continueToNext)continue}let o=i.value?await _8(e,i.value):``;if(a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[\]$/))return{continueToNext:!1,xtraceOutput:r,tempAssignments:n,error:$(``,`bash: ${a}: bad array subscript `,1)};let s=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(s){let a=await FNe(e,t,s[1],s[2],o,i.append,n);if(a.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:n,error:a.error};if(a.continueToNext)continue}let c=await INe(e,t,a,o,i.append,n);if(c.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:n,error:c.error};r+=c.xtraceOutput,c.continueToNext}return{continueToNext:!1,xtraceOutput:r,tempAssignments:n}}async function ANe(e,t,n,r,i,a){let o=``;if(/\[.+\]$/.test(n))return{continueToNext:!1,xtraceOutput:``,error:$(``,`bash: ${n}: cannot assign list to array member `,1)};if(l6(e,n)){let t=h6(e,n);if(t===void 0||t===``)throw new RB(1,``,``);let r=m6(e,n);if(r&&/^[a-zA-Z_][a-zA-Z0-9_]*\[@\]$/.test(r))return{continueToNext:!1,xtraceOutput:``,error:$(``,`bash: ${n}: cannot assign list to array member `,1)}}if(B6(e,n)){if(t.name)return o+=`bash: ${n}: readonly variable `,{continueToNext:!0,xtraceOutput:o};let r=V6(e,n);if(r)return{continueToNext:!1,xtraceOutput:``,error:r}}let s=e.state.associativeArrays?.has(n),c=Q2(e,n),l=c?X2(c):void 0,u=e.state.env.get(n),d=()=>{e.state.arrays??=new Map,l?e.state.arrays.set(n,l):e.state.arrays.delete(n),u===void 0?e.state.env.delete(n):e.state.env.set(n,u)},f=jNe(r),p=()=>{l4(e,n),e.state.env.delete(n)};try{s&&f?await MNe(e,t,n,r,i,p,e=>{o+=e}):f?await NNe(e,n,r,i,p):await PNe(e,n,r,i,p)}catch(e){throw d(),e}if(t.name){a.set(n,e.state.env.get(n));let t=`(${r.map(e=>p4(e)).join(` `)})`;e.state.env.set(n,t)}return{continueToNext:!0,xtraceOutput:o}}function jNe(e){return e.some(e=>{if(e.parts.length>=2){let t=e.parts[0],n=e.parts[1];if(t.type!==`Glob`||!t.pattern.startsWith(`[`))return!1;if(t.pattern===`[`&&(n.type===`DoubleQuoted`||n.type===`SingleQuoted`)){if(e.parts.length<3)return!1;let t=e.parts[2];return t.type===`Literal`?t.value.startsWith(`]=`)||t.value.startsWith(`]+=`):!1}return n.type===`Literal`?n.value.startsWith(`]`)?n.value.startsWith(`]=`)||n.value.startsWith(`]+=`):t.pattern.endsWith(`]`)?n.value.startsWith(`=`)||n.value.startsWith(`+=`):!1:!1}return!1})}async function MNe(e,t,n,r,i,a,o){let s=[];for(let t of r){if(s.length>=e.limits.maxArrayElements)throw new H(`array element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let n=f4(t);if(n){let{key:t,valueParts:r,append:i}=n,a;r.length>0?(a=await _8(e,{type:`Word`,parts:r}),r.every(e=>e.type===`Literal`||e.type===`TildeExpansion`)&&(a=Y6(e,a))):a=``,s.push({type:`keyed`,key:t,value:a,append:i})}else{let n=await _8(e,t);s.push({type:`invalid`,expandedValue:n})}}e.executionScope.consumeWork(s.length,`associative array assignment`),i||a();for(let r of s)if(r.type===`keyed`){if(r.append){let t=n4(e,n,r.key)??``;i4(e,n,r.key,c9(e,t,r.value),`associative`)}else i4(e,n,r.key,r.value,`associative`)}else o(`bash: line ${t.line??e.state.currentLine??1}: ${n}: ${r.expandedValue}: must use subscript when assigning associative array `)}async function NNe(e,t,n,r,i){let a=[],o=0;for(let t of n){let n=f4(t);if(n){if(o>=e.limits.maxArrayElements)throw new H(`array element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let{key:t,valueParts:r,append:i}=n,s;r.length>0?(s=await _8(e,{type:`Word`,parts:r}),r.every(e=>e.type===`Literal`||e.type===`TildeExpansion`)&&(s=Y6(e,s))):s=``,a.push({type:`keyed`,indexExpr:t,value:s,append:i}),o++}else{let n=await C8(e,t);if(n.values.length>e.limits.maxArrayElements-o)throw new H(`array element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);a.push({type:`non-keyed`,values:n.values}),o+=n.values.length}}e.executionScope.consumeWork(o,`indexed array assignment`),r||i();let s=0;for(let n of a)if(n.type===`keyed`){let r;try{r=await N8(e,P4(new T3,n.indexExpr).expression,!1)}catch{if(/^-?\d+$/.test(n.indexExpr))r=Number.parseInt(n.indexExpr,10);else{let t=e.state.env.get(n.indexExpr);r=t?Number.parseInt(t,10):0,Number.isNaN(r)&&(r=0)}}if(n.append){let i=n4(e,t,r)??``;i4(e,t,r,c9(e,i,n.value))}else i4(e,t,r,n.value);s=r+1}else for(let r of n.values)i4(e,t,s++,r)}async function PNe(e,t,n,r,i){let a=[];for(let t of n){let n=await C8(e,t);for(let t of n.values){if(a.length>=e.limits.maxArrayElements)throw new H(`array element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);a.push(t)}}let o=0;if(e.executionScope.consumeWork(a.length,`indexed array assignment`),r){let n=v6(e,t);if(n.length>0)o=Math.max(...n.map(([e])=>typeof e==`number`?e:0))+1;else{let n=e.state.env.get(t);n!==void 0&&(i4(e,t,0,n),e.state.env.delete(t),o=1)}}else i();for(let n=0;n=2&&(r=n.slice(1,-1));let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else{try{i=await N8(e,P4(new T3,r).expression,!1)}catch(r){if(r instanceof RB)throw r;if(r instanceof zB){let t=`bash: line ${e.state.currentLine}: ${n}: ${r.message} `;if(r.fatal)throw new RB(1,``,t);return{index:0,error:$(``,t,1)}}let i=e.state.currentLine;return{index:0,error:$(``,`bash: line ${i}: ${t}[${n}]: bad array subscript `,1)}}Number.isNaN(i)&&(i=0)}if(i<0){let r=v6(e,t);if(r.length===0){let r=e.state.currentLine;return{index:0,error:$(``,`bash: line ${r}: ${t}[${n}]: bad array subscript `,1)}}if(i=Math.max(...r.map(([e])=>typeof e==`number`?e:0))+1+i,i<0){let r=e.state.currentLine;return{index:0,error:$(``,`bash: line ${r}: ${t}[${n}]: bad array subscript `,1)}}}return{index:i}}async function INe(e,t,n,r,i,a){let o=``,s=n,c=null;if(l6(e,n)){let t=g6(e,n,r);if(t===void 0)return{continueToNext:!1,xtraceOutput:``,error:$(``,`bash: ${n}: circular name reference `,1)};if(t===null)return{continueToNext:!0,xtraceOutput:``};s=t;let i=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);i&&(c={arrayName:i[1],subscriptExpr:i[2]},s=i[1])}if(B6(e,s)){if(t.name)return o+=`bash: ${s}: readonly variable `,{continueToNext:!0,xtraceOutput:o};let n=V6(e,s);if(n)return{continueToNext:!1,xtraceOutput:``,error:n}}let l;if(O7(e,s))try{let t=new T3;if(i){let n=P4(t,`(${e.state.env.get(s)||`0`}) + (${r})`);l=String(await N8(e,n.expression))}else{let n=P4(t,r);l=String(await N8(e,n.expression))}}catch{l=`0`}else{let t=y6(e,s)?n4(e,s,0):e.state.env.get(s);l=i?c9(e,t||``,r):r}l=j7(e,s,l),o+=await ONe(e,s,l);let u;return c?u=await LNe(e,c):y6(e,s)&&(u=`0`),t.name?u===void 0&&(a.set(s,e.state.env.get(s)),e.state.env.set(s,l)):(u===void 0?e.state.env.set(s,l):i4(e,s,u,l),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(s)),e.state.tempEnvBindings?.some(e=>e.has(s))&&(e.state.mutatedTempEnvVars=e.state.mutatedTempEnvVars||new Set,e.state.mutatedTempEnvVars.add(s))),{continueToNext:!1,xtraceOutput:o}}async function LNe(e,t){let{arrayName:n,subscriptExpr:r}=t;if(e.state.associativeArrays?.has(n))return l9(e,r);let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else{try{i=await N8(e,P4(new T3,r).expression,!1)}catch{let t=e.state.env.get(r);i=t?Number.parseInt(t,10):0}Number.isNaN(i)&&(i=0)}if(i<0){let t=v6(e,n);t.length>0&&(i=Math.max(...t.map(e=>e[0]))+1+i)}return String(i)}async function RNe(e,t,n,r){let i=!1,a=!1,o=!1,s=!1,c=!1,l=[];for(let e of t)if(e.startsWith(`-`)&&e.length>1)for(let t of e.slice(1))t===`t`?i=!0:t===`p`?a=!0:t===`P`?o=!0:t===`a`?s=!0:t===`f`&&(c=!0);else l.push(e);let u=``,d=``,f=0,p=!1,m=!1;for(let t of l){let l=!1;if(o){if(s){let e=await r(t);if(e.length>0){for(let t of e)u+=`${t} `;p=!0,l=!0}}else{let e=await n(t);e&&(u+=`${e} `,p=!0,l=!0)}l||(m=!0);continue}let f=!c&&e.state.functions.has(t);if(s&&f){if(!a){if(i)u+=`function `;else{let n=e.state.functions.get(t),r=n?d9(t,n):`${t} is a function `;u+=r}}l=!0}let h=e.state.env.get(`BASH_ALIAS_${t}`);if(!(h!==void 0&&(s||!l)&&(a||(u+=i?`alias `:`${t} is aliased to \`${h}' `),l=!0,!s)||b5.has(t)&&(s||!l)&&(a||(u+=i?`keyword `:`${t} is a shell keyword `),l=!0,!s))){if(!s&&f&&!l){if(!a){if(i)u+=`function `;else{let n=e.state.functions.get(t),r=n?d9(t,n):`${t} is a function `;u+=r}}l=!0;continue}if(!(x5.has(t)&&(s||!l)&&(a||(u+=i?`builtin `:`${t} is a shell builtin `),l=!0,!s))){if(s){let e=await r(t);for(let n of e)u+=a?`${n} `:i?`file `:`${t} is ${n} `,p=!0,l=!0}else if(!l){let e=await n(t);e&&(u+=a?`${e} `:i?`file `:`${t} is ${e} `,p=!0,l=!0)}if(!l&&(m=!0,!i&&!a)){let n=!0;if(t.includes(`/`)){let r=e.fs.resolvePath(e.state.cwd,t);await e.fs.exists(r)&&(n=!1)}n&&(d+=`bash: type: ${t}: not found `)}}}}return f=a?m&&!p?1:0:+!!m,$(u,d,f)}function d9(e,t){let n;return n=t.body.type===`Group`?t.body.body.map(e=>f9(e)).join(`; `):f9(t.body),`${e} is a function ${e} () { ${n} } `}function f9(e){if(Array.isArray(e))return e.map(e=>f9(e)).join(`; `);if(e.type===`Statement`){let t=[];for(let n=0;nf9(e)).join(`; `)}; }`:`...`}function p9(e){return e.parts.map(m9).join(``)}function m9(e){switch(e.type){case`Literal`:return e.value;case`Escaped`:return`\\${e.value}`;case`SingleQuoted`:return`'${e.value}'`;case`DoubleQuoted`:return`"${e.parts.map(m9).join(``)}"`;default:return A3(X.word([e]))}}function zNe(e){let t=e.commands.map(e=>f9(e));return(e.negated?`! `:``)+t.join(` | `)}async function BNe(e,t,n,r){let i=``,a=``,o=0;for(let n of t){if(!n){o=1;continue}let t=e.state.env.get(`BASH_ALIAS_${n}`);if(t!==void 0)i+=r?`${n} is an alias for "${t}" `:`alias ${n}='${t}' `;else if(b5.has(n))i+=r?`${n} is a shell keyword `:`${n} `;else if(x5.has(n))i+=r?`${n} is a shell builtin `:`${n} `;else if(e.state.functions.has(n))i+=r?`${n} is a function `:`${n} `;else if(n.includes(`/`)){let t=e.fs.resolvePath(e.state.cwd,n),s=!1;if(await e.fs.exists(t))try{let a=await e.fs.stat(t);a.isDirectory||a.mode&73&&(i+=r?`${n} is ${n} `:`${n} `,s=!0)}catch{}s||(r&&(a+=`${n}: not found `),o=1)}else if(e.commands.has(n)){let t=(e.state.env.get(`PATH`)??`/usr/bin:/bin`).split(`:`),a=null;for(let r of t){if(!r)continue;let t=`${r}/${n}`;try{let n=await e.fs.stat(t);if(!n.isDirectory&&n.mode&73){a=t;break}}catch{}}a||=`/usr/bin/${n}`,i+=r?`${n} is ${a} `:`${a} `}else r&&(a+=`${n}: not found `),o=1}return $(i,a,o)}async function VNe(e,t){if(t.includes(`/`)){let n=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(n)){try{let t=await e.fs.stat(n);if(t.isDirectory||!(t.mode&73))return null}catch{return null}return t}return null}let n=(e.state.env.get(`PATH`)??`/usr/bin:/bin`).split(`:`);for(let r of n){if(!r)continue;let n=`${r.startsWith(`/`)?r:e.fs.resolvePath(e.state.cwd,r)}/${t}`;if(await e.fs.exists(n)){try{let t=await e.fs.stat(n);if(t.isDirectory||!(t.mode&73))continue}catch{continue}return`${r}/${t}`}}if(e.commands.has(t)){for(let e of n)if(e===`/usr/bin`||e===`/bin`)return`${e}/${t}`;return`/usr/bin/${t}`}return null}function h9(e,t){let n=!0,r=e.signal?new AbortController:void 0,i=new WeakMap,a=()=>{if(!n)throw new UB(``,`bash: ${t} used its context after cancellation `)},o=e=>{if(e===null||typeof e!=`object`&&typeof e!=`function`)return e;let n=i.get(e);if(n!==void 0)return n;if(typeof e==`object`&&GDe(e))return e;if(e instanceof Uint8Array){let t=new Uint8Array(e);return i.set(e,t),t}if(e instanceof ArrayBuffer){let t=e.slice(0);return i.set(e,t),t}if(e instanceof Promise){let t=e.then(e=>(a(),o(e)));return i.set(e,t),t}if(typeof e==`function`){let t=function(...t){return a(),o(Reflect.apply(e,this,t))};return i.set(e,t),t}let r=Object.getPrototypeOf(e);if(Array.isArray(e)||r===Object.prototype||r===null){let t=Array.isArray(e)?[]:Object.create(r);i.set(e,t);let n=Object.getOwnPropertyDescriptors(e);for(let t of Object.values(n)){if(`value`in t){let n=t.value;t.value=typeof n==`function`?(...t)=>(a(),o(Reflect.apply(n,e,t))):o(n)}if(t.get){let n=t.get;t.get=()=>(a(),o(Reflect.apply(n,e,[])))}if(t.set){let n=t.set;t.set=t=>{a(),Reflect.apply(n,e,[t])}}}return Object.defineProperties(t,n),t}let s=new Map,c=new p$(e,{get(e,n){if(a(),n===`constructor`||n===`prototype`||n===`__proto__`)throw Error(`${t}: unsafe context property access`);let r=Reflect.get(e,n,e);if(typeof r!=`function`)return o(r);if(s.has(n))return s.get(n);let i=(...t)=>(a(),o(Reflect.apply(r,e,t)));return s.set(n,i),i},set(e,n,r){if(a(),n===`constructor`||n===`prototype`||n===`__proto__`)throw Error(`${t}: unsafe context property access`);return Reflect.set(e,n,r,e)}});return i.set(e,c),c},s=e=>o(e),c=e=>e&&((...t)=>(a(),o(e(...t)))),l=e=>({value:e,enumerable:!0,configurable:!0,writable:!0}),u=Object.getOwnPropertyDescriptors(e);return Object.assign(u,{fs:l(s(e.fs)),env:l(s(e.env)),limits:l(Object.freeze({...e.limits})),exportedEnv:l(e.exportedEnv?Object.freeze({...e.exportedEnv}):void 0),executionScope:l(e.executionScope?s(e.executionScope):void 0),fileDescriptors:l(e.fileDescriptors?s(e.fileDescriptors):void 0),coverage:l(e.coverage?s(e.coverage):void 0),assignShellVariable:l(c(e.assignShellVariable)),exec:l(c(e.exec)),origCommand:l(c(e.origCommand)),execWithInheritedStdin:l(c(e.execWithInheritedStdin)),fetch:l(c(e.fetch)),getRegisteredCommands:l(c(e.getRegisteredCommands)),sleep:l(c(e.sleep)),trace:l(c(e.trace)),invokeTool:l(c(e.invokeTool)),signal:l(r?.signal)}),{context:Object.defineProperties(Object.create(Object.getPrototypeOf(e)),u),revoke(){n=!1,r?.signal.aborted||r?.abort(new UB(``,`bash: ${t} context revoked `))}}}async function HNe(e,t,n,r,i,a){let o=i.remainingTimeMs()??t.limits.maxExecutionTimeMs,s=t.limits.maxExtensionCleanupTimeMs,c,l,u,d=Promise.resolve().then(e).then(e=>({kind:`result`,result:e}),e=>({kind:`error`,error:e})),f=new Promise(e=>{let t=()=>{n(),e({kind:`abort`})};l=t,a?.addEventListener(`abort`,t,{once:!0}),a?.aborted&&t(),c=cB(()=>{n(),e({kind:`deadline`})},o)});try{let e=await Promise.race([d,f]);if(e.kind===`result`)return e.result;if(e.kind===`error`)throw e.error;n();let t=await Promise.race([d.then(()=>!0),new Promise(e=>{u=cB(()=>e(!1),s)})]),a=e.kind===`deadline`?new UB(``,`bash: ${r} exceeded its execution deadline `):new UB(``,`bash: execution aborted `);throw t||i.poisonAfterAbort(a),a}finally{n(),lB(c),lB(u),l&&a?.removeEventListener(`abort`,l)}}async function UNe(e,t,n,r,i,a,o,s,c=!1){let{ctx:l,runCommand:u}=e;if(l.coverage&&x5.has(t)&&l.coverage.hit(`bash:builtin:${t}`),t===`export`)return XMe(l,n);if(t===`unset`)return _Ne(l,n);if(t===`exit`)return YMe(l,n);if(t===`local`)return rNe(l,n);if(t===`set`)return pNe(l,n);if(t===`break`)return Pje(l,n);if(t===`continue`)return PMe(l,n);if(t===`return`)return oNe(l,n);if(t===`eval`&&l.state.options.posix)return F7(l,n,i,c);if(t===`shift`)return mNe(l,n);if(t===`getopts`)return I7(l,n);if(t===`compgen`)return hMe(l,n);if(t===`complete`)return MMe(l,n);if(t===`compopt`)return NMe(l,n);if(t===`pushd`)return await KMe(l,n);if(t===`popd`)return qMe(l,n);if(t===`dirs`)return JMe(l,n);if(t===`source`||t===`.`)return hNe(l,n);if(t===`read`)return aNe(l,n,i,s);if(t===`mapfile`||t===`readarray`)return iNe(l,n,i);if(t===`declare`||t===`typeset`)return UMe(l,n);if(t===`readonly`)return WMe(l,n);if(!a){let e=l.state.functions.get(t);if(e)return o7(l,e,n,i,void 0,c)}if(t===`__just_bash_tee_restore`){if(n.length===0||n.length>l.limits.maxArrayElements)return Q(`bash: invalid internal pipeline status restore `,2);let e=[];for(let t of n){if(!/^(?:0|[1-9][0-9]{0,2})$/.test(t))return Q(`bash: invalid internal pipeline status restore `,2);let n=Number(t);if(!Number.isSafeInteger(n)||n>255)return Q(`bash: invalid internal pipeline status restore `,2);e.push(n)}let t=e[e.length-1]??0,r=[...e].reverse().find(e=>e!==0);return{stdout:``,stderr:``,exitCode:l.state.options.pipefail&&r!==void 0?r:t,internalPipeStatusOverride:e}}if(t===`eval`)return F7(l,n,i,c);if(t===`cd`)return await Fje(l,n);if(t===`:`||t===`true`)return I8;if(t===`false`)return R8(!1);if(t===`let`)return nNe(l,n);if(t===`command`)return WNe(e,n,i,c);if(t===`builtin`)return GNe(e,n,i,c);if(t===`shopt`)return bNe(l,n);if(t===`exec`){if(n.length===0)return I8;let[e,...t]=n;return{...await u(e,t,[],i,!1,!1,-1,c),internalProducerOmitsShellPrefix:!0}}if(t===`wait`)return I8;if(t===`type`)return await RNe(l,n,e=>VNe(l,e),e=>r9(l,e));if(t===`hash`)return ZMe(l,n);if(t===`help`)return QMe(l,n);if(t===`[`||t===`test`){let e=n;if(t===`[`){if(n[n.length-1]!==`]`)return Q(`[: missing \`]' `,2);e=n.slice(0,-1)}return $8(l,e)}return null}async function WNe(e,t,n,r=!1){let{ctx:i,runCommand:a}=e;if(t.length===0)return I8;let o=!1,s=!1,c=!1,l=t;for(;l.length>0&&l[0].startsWith(`-`);){let e=l[0];if(e===`--`){l=l.slice(1);break}for(let t of e.slice(1))t===`p`?o=!0:t===`V`?s=!0:t===`v`&&(c=!0);l=l.slice(1)}if(l.length===0)return I8;if(c||s)return await BNe(i,l,c,s);let[u,...d]=l;return a(u,d,[],n,!0,o,-1,r)}async function GNe(e,t,n,r=!1){let{runCommand:i}=e;if(t.length===0)return I8;let a=t;if(a[0]===`--`&&(a=a.slice(1),a.length===0))return I8;let o=a[0];if(o!==`__just_bash_tee_restore`&&!x5.has(o))return Q(`bash: builtin: ${o}: not a shell builtin `);let[,...s]=a;return i(o,s,[],n,!0,!1,-1,r)}async function KNe(e,t,n,r,i){let{ctx:a,buildExportedEnv:o,executeUserScript:s}=e,c=await SNe(a,t,i?`/usr/bin:/bin`:void 0);if(!c)return Mje(t)?Q(`bash: ${t}: command not available in browser environments. Exclude '${t}' from your commands or use the Node.js bundle. `,127):Q(`bash: ${t}: command not found `,127);if(`error`in c)return c.error===`permission_denied`?Q(`bash: ${t}: Permission denied `,126):Q(`bash: ${t}: No such file or directory `,127);if(`script`in c)return t.includes(`/`)||(a.state.hashTable||(a.state.hashTable=new Map),a.state.hashTable.set(t,c.path)),await s(c.path,n,r);let{cmd:l,path:u}=c;t.includes(`/`)||(a.state.hashTable||(a.state.hashTable=new Map),a.state.hashTable.set(t,u));let d=r||a.state.groupStdin||``,f=!1,p=o();a.state.fileDescriptors??=new Map;let m={fs:a.fs,fsIdentity:WDe(a.fs),cwd:a.state.cwd,env:a.state.env,assignShellVariable:async(e,t,n)=>{if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e))throw Error(`${e}: not a valid identifier`);let r=n===void 0?e:`${e}[${n}]`,i=g6(a,e,t);if(i===void 0)throw Error(`${e}: circular name reference`);if(i===null)return;let o=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)(?:\[(.*)\])?$/);if(!o)throw Error(`${r}: not a valid identifier`);let s=o[1],c=o[2]??n;if(B6(a,e)||B6(a,s))throw Error(`${s}: readonly variable`);if(c===void 0)a.state.env.set(s,t);else{let e=a.state.associativeArrays?.has(s)?`associative`:`indexed`;if(e===`associative`){i4(a,s,c,t,e);return}let n=await u9(a,s,c);if(n.error)throw new RB(n.error.exitCode,n.error.stdout,n.error.stderr);i4(a,s,n.index,t,e)}},exportedEnv:p,get stdin(){return f=!0,d},limits:a.limits,executionScope:l.internalIsExtension?ZDe(a.executionScope):a.executionScope,exec:(e,t)=>a.execFn(e,t,!1),execWithInheritedStdin:(e,t)=>a.execFn(e,{...t,stdin:d,stdinKind:`bytes`},!0),fetch:a.fetch,getRegisteredCommands:()=>Array.from(a.commands.keys()),sleep:a.sleep,trace:a.trace,fileDescriptors:a.state.fileDescriptors,xpgEcho:a.state.shoptOptions.xpg_echo,coverage:a.coverage,signal:a.state.signal,requireDefenseContext:a.requireDefenseContext,jsBootstrapCode:a.jsBootstrapCode,invokeTool:a.invokeTool},h=l.internalOriginalCommand,g=()=>{};if(h){let e=Object.getOwnPropertyDescriptors(m);e.executionScope={value:a.executionScope,enumerable:!0,configurable:!0,writable:!0};let t=h9(Object.defineProperties(Object.create(Object.getPrototypeOf(m)),e),h.name),n=a9(t.context,h.name);g=t.revoke,m.origCommand=e=>{let t=()=>h.execute(e,n);return h.trusted?aB.runTrustedAsync(t):aB.runUntrustedAsync(t)}}let _=h9(m,t),v=a9(_.context,t),y=()=>{_.revoke(),g()};try{let e=()=>AK(a.requireDefenseContext,`command`,`${t} execution`,()=>l.execute(n,v)),i=()=>HNe(e,v,y,t,a.executionScope,a.state.signal),o=l.trusted?await aB.runTrustedAsync(i):await i();return{...o,internalStdinConsumed:o.internalStdinConsumed??(f?r.length:0)}}catch(e){if(e instanceof H||e instanceof UB||e instanceof tB)throw e;return Q(`${t}: ${vH(TV(e))} `)}}AB(),U(),oX();async function g9(e,t){let n=e.state.inCondition;e.state.inCondition=!0;let r=new aX(e.executionScope,`condition`),i=0;try{for(let n of t){let t=await e.executeStatement(n);r.appendResult(t),i=t.exitCode}}catch(e){throw r.prependTo(e),e}finally{e.state.inCondition=n}return r.build(i)}EV(),U(),EV();function _9(e,t,n,r){if(e instanceof NB)return t+=e.stdout,n+=e.stderr,e.levels>1&&r>1?(e.levels--,e.stdout=t,e.stderr=n,{action:`rethrow`,stdout:t,stderr:n,error:e}):{action:`break`,stdout:t,stderr:n};if(e instanceof PB)return t+=e.stdout,n+=e.stderr,e.levels>1&&r>1?(e.levels--,e.stdout=t,e.stderr=n,{action:`rethrow`,stdout:t,stderr:n,error:e}):{action:`continue`,stdout:t,stderr:n};if(e instanceof FB||e instanceof IB||e instanceof RB||e instanceof H)return e.prependOutput(t,n),{action:`rethrow`,stdout:t,stderr:n,error:e};let i=TV(e);return{action:`error`,stdout:t,stderr:`${n}${i} `,exitCode:1}}function v9(e,t){return e===void 0?t===``?{owns:!1}:{owns:!0,stdin:t}:{owns:!0,stdin:e}}var y9=class{ctx;stdoutChunks=[];stderrChunks=[];totalBytes=0;constructor(e){this.ctx=e}append(e,t){let n=V(e)+V(t);n>this.ctx.limits.maxOutputSize-this.totalBytes&&z8(`total output size exceeded (>${this.ctx.limits.maxOutputSize} bytes), increase executionLimits.maxOutputSize`,`output_size`),e&&this.stdoutChunks.push(e),t&&this.stderrChunks.push(t),this.totalBytes+=n}appendUnaccounted(e,t){this.ctx.executionScope.appendOutput(`stdout`,e,`control-flow`),this.ctx.executionScope.appendOutput(`stderr`,t,`control-flow`),this.append(e,t)}replace(e,t){this.stdoutChunks=[],this.stderrChunks=[],this.totalBytes=0,this.append(e,t)}get stdout(){return this.stdoutChunks.join(``)}get stderr(){return this.stderrChunks.join(``)}build(e){let t=this.stdout,n=this.stderr;return{stdout:t,stderr:n,exitCode:e,internalOutputAccounting:{stdout:V(t),stderr:V(n)}}}};async function b9(e,t,n){let r=0;try{for(let i of t){let t=await e.executeStatement(i);n.append(t.stdout,t.stderr),r=t.exitCode}}catch(e){if(jB(e)||e instanceof IB||e instanceof RB||e instanceof H||e instanceof WB)throw e.prependOutput(n.stdout,n.stderr),e;return n.appendUnaccounted(``,`${TV(e)} `),n.build(1)}return n.build(r)}async function qNe(e,t){return i7(e,t.redirections,``,()=>JNe(e,t))}async function JNe(e,t){let n=new y9(e);for(let r of t.clauses){let t=await g9(e,r.condition);if(n.append(t.stdout,t.stderr),t.exitCode===0)return b9(e,r.body,n)}return t.elseBody?b9(e,t.elseBody,n):n.build(0)}async function YNe(e,t){return i7(e,t.redirections,``,()=>XNe(e,t))}async function XNe(e,t){let n=new y9(e),r=0,i=0;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t.variable))return Q(`bash: \`${t.variable}': not a valid identifier `);let a=[];if(t.words===null)a=(e.state.env.get(`@`)||``).split(` `).filter(Boolean);else if(t.words.length===0)a=[];else try{for(let n of t.words){let t=await C8(e,n);X6(a,t.values,e.limits.maxArrayElements,`for-loop expansion`)}}catch(e){if(e instanceof VB)return{stdout:``,stderr:e.stderr,exitCode:1};throw e}e.state.loopDepth++;try{for(let o of a){i++,i>e.limits.maxLoopIterations&&z8(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,`iterations`,n.stdout,n.stderr),e.state.env.set(t.variable,o);try{for(let i of t.body){let t=await e.executeStatement(i);n.append(t.stdout,t.stderr),r=t.exitCode}}catch(t){let r=_9(t,n.stdout,n.stderr,e.state.loopDepth);if(n.replace(r.stdout,r.stderr),r.action===`break`)break;if(r.action===`continue`)continue;if(r.action===`error`)return n.build(r.exitCode??1);throw r.error}}}finally{e.state.loopDepth--}return n.build(r)}async function ZNe(e,t){return i7(e,t.redirections,``,()=>QNe(e,t))}async function QNe(e,t){let n=t.line;n!==void 0&&(e.state.currentLine=n);let r=new y9(e),i=0,a=0;t.init&&await N8(e,t.init.expression),e.state.loopDepth++;try{for(;a++,a>e.limits.maxLoopIterations&&z8(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,`iterations`,r.stdout,r.stderr),!(t.condition&&(n!==void 0&&(e.state.currentLine=n),await N8(e,t.condition.expression)===0));){try{for(let n of t.body){let t=await e.executeStatement(n);r.append(t.stdout,t.stderr),i=t.exitCode}}catch(n){let i=_9(n,r.stdout,r.stderr,e.state.loopDepth);if(r.replace(i.stdout,i.stderr),i.action===`break`)break;if(i.action===`continue`){t.update&&await N8(e,t.update.expression);continue}if(i.action===`error`)return r.build(i.exitCode??1);throw i.error}t.update&&await N8(e,t.update.expression)}}finally{e.state.loopDepth--}return r.build(i)}async function $Ne(e,t,n=``){return i7(e,t.redirections,n,r=>ePe(e,t,n,r))}async function ePe(e,t,n,r){let i=new y9(e),a=0,o=0,s=v9(r.stdin,n),c=e.state.groupStdin;s.owns&&(e.state.groupStdin=s.stdin),e.state.loopDepth++;try{for(;;){o++,o>e.limits.maxLoopIterations&&z8(`while loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,`iterations`,i.stdout,i.stderr);let n=0,r=!1,s=!1,c=e.state.inCondition;e.state.inCondition=!0;try{for(let r of t.condition){let t=await e.executeStatement(r);i.append(t.stdout,t.stderr),n=t.exitCode}}catch(t){if(t instanceof NB){if(i.append(t.stdout,t.stderr),t.levels>1&&e.state.loopDepth>1)throw t.levels--,t.stdout=i.stdout,t.stderr=i.stderr,e.state.inCondition=c,t;r=!0}else if(t instanceof PB){if(i.append(t.stdout,t.stderr),t.levels>1&&e.state.loopDepth>1)throw t.levels--,t.stdout=i.stdout,t.stderr=i.stderr,e.state.inCondition=c,t;s=!0}else throw e.state.inCondition=c,t}finally{e.state.inCondition=c}if(r)break;if(!s){if(n!==0)break;try{for(let n of t.body){let t=await e.executeStatement(n);i.append(t.stdout,t.stderr),a=t.exitCode}}catch(t){let n=_9(t,i.stdout,i.stderr,e.state.loopDepth);if(i.replace(n.stdout,n.stderr),n.action===`break`)break;if(n.action===`continue`)continue;if(n.action===`error`)return i.build(n.exitCode??1);throw n.error}}}}finally{e.state.loopDepth--,s.owns&&(e.state.groupStdin=c)}return i.build(a)}async function tPe(e,t,n=``){return i7(e,t.redirections,n,r=>nPe(e,t,n,r))}async function nPe(e,t,n,r){let i=new y9(e),a=0,o=0,s=v9(r.stdin,n),c=e.state.groupStdin;s.owns&&(e.state.groupStdin=s.stdin),e.state.loopDepth++;try{for(;;){o++,o>e.limits.maxLoopIterations&&z8(`until loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,`iterations`,i.stdout,i.stderr);let n=await g9(e,t.condition);if(i.append(n.stdout,n.stderr),n.exitCode===0)break;try{for(let n of t.body){let t=await e.executeStatement(n);i.append(t.stdout,t.stderr),a=t.exitCode}}catch(t){let n=_9(t,i.stdout,i.stderr,e.state.loopDepth);if(i.replace(n.stdout,n.stderr),n.action===`break`)break;if(n.action===`continue`)continue;if(n.action===`error`)return i.build(n.exitCode??1);throw n.error}}}finally{e.state.loopDepth--,s.owns&&(e.state.groupStdin=c)}return i.build(a)}async function rPe(e,t){return i7(e,t.redirections,``,()=>iPe(e,t))}async function iPe(e,t){let n=new y9(e),r=0,i=await _8(e,t.word),a=!1;for(let o=0;o1,d=e.state.lastArg,f=e.state.groupStdin,p=e.state.groupStdinSourceFd;for(let r=0;r1)y={stdout:n.stdout,stderr:n.stderr,exitCode:n.exitCode};else if(n instanceof IB&&t.commands.length>1)y={stdout:n.stdout,stderr:n.stderr,exitCode:n.exitCode};else throw _&&(e.state.env=_,e.state.arrays=v??new Map),n}finally{u&&(h&&(f=e.state.groupStdin,p=e.state.groupStdinSourceFd),e.state.groupStdin=f,e.state.groupStdinSourceFd=p)}if(_&&(e.state.env=_,e.state.arrays=v??new Map),y=e.executionScope.accountResult(y,`pipeline`,e.executionScope.outputBytesUsed-b),!m){let n=t.pipeStderr?.[r]??!1,i=y.internalOutputAccounting?.stdout??0,a=n?y.internalOutputAccounting?.stderr??0:0;QDe(e.executionScope,i+a,`pipeline`),y={...y,internalOutputAccounting:{stdout:0,stderr:n?0:y.internalOutputAccounting?.stderr??0}}}s.push(y.exitCode),y.exitCode!==0&&(o=y.exitCode),m?a=y:(t.pipeStderr?.[r]??!1?i=bB(y.stderr)+wB(y):(i=wB(y),c+=y.stderr,l+=y.internalOutputAccounting?.stderr??0),a={stdout:``,stderr:``,exitCode:y.exitCode})}c&&(a={...a,stderr:c+a.stderr,internalOutputAccounting:{stdout:a.internalOutputAccounting?.stdout??0,stderr:l+(a.internalOutputAccounting?.stderr??0)}});let m=t.commands.length>1||t.commands.length===1&&t.commands[0].type===`SimpleCommand`,h=a.internalPipeStatusOverride??s;if(m){l4(e,`PIPESTATUS`);for(let t=0;t[e,S9(t)])):void 0}function sPe(e){if(!e)return;let t=new Map,n=new Map;for(let[r,i]of e){let e=t.get(i);e||(e=new Set(i),t.set(i,e)),n.set(r,e)}return n}function cPe(e){return e?.map(e=>new Map(Array.from(e,([e,t])=>[e,t?{kind:t.kind,elements:new Map(t.elements)}:void 0])))}function lPe(e){return e?new Map(Array.from(e,([e,t])=>[e,t.map(e=>({...e}))])):void 0}function C9(e){let t={env:e.env,arrays:e.arrays,cwd:e.cwd,previousDir:e.previousDir,lastExitCode:e.lastExitCode,lastArg:e.lastArg,currentLine:e.currentLine,options:e.options,shoptOptions:e.shoptOptions,fileDescriptors:e.fileDescriptors,inputFds:e.inputFds,fdAliases:e.fdAliases,closedStandardFds:e.closedStandardFds,nextFd:e.nextFd,readonlyVars:e.readonlyVars,associativeArrays:e.associativeArrays,namerefs:e.namerefs,boundNamerefs:e.boundNamerefs,invalidNamerefs:e.invalidNamerefs,integerVars:e.integerVars,lowercaseVars:e.lowercaseVars,uppercaseVars:e.uppercaseVars,exportedVars:e.exportedVars,tempExportedVars:e.tempExportedVars,localExportedVars:e.localExportedVars,declaredVars:e.declaredVars,localScopes:e.localScopes,localArrayScopes:e.localArrayScopes,localVarDepth:e.localVarDepth,localVarStack:e.localVarStack,fullyUnsetLocals:e.fullyUnsetLocals,tempEnvBindings:e.tempEnvBindings,mutatedTempEnvVars:e.mutatedTempEnvVars,accessedTempEnvVars:e.accessedTempEnvVars,functions:e.functions,callDepth:e.callDepth,sourceDepth:e.sourceDepth,callLineStack:e.callLineStack,funcNameStack:e.funcNameStack,sourceStack:e.sourceStack,currentSource:e.currentSource,inCondition:e.inCondition,loopDepth:e.loopDepth,parentHasLoopContext:e.parentHasLoopContext,errexitSafe:e.errexitSafe,directoryStack:e.directoryStack,hashTable:e.hashTable,completionSpecs:e.completionSpecs,defaultCompletionSpec:e.defaultCompletionSpec,emptyCompletionSpec:e.emptyCompletionSpec,groupStdin:e.groupStdin,groupStdinSourceFd:e.groupStdinSourceFd,bashPid:e.bashPid,expansionExitCode:e.expansionExitCode,expansionStderr:e.expansionStderr};e.env=new Map(e.env),e.arrays=Z2(e.arrays),e.options={...e.options},e.shoptOptions={...e.shoptOptions},e.fileDescriptors=e.fileDescriptors?new Map(e.fileDescriptors):void 0,e.inputFds=e.inputFds?new Set(e.inputFds):void 0,e.fdAliases=sPe(e.fdAliases),e.closedStandardFds=e.closedStandardFds?new Set(e.closedStandardFds):void 0,e.readonlyVars=new Set(e.readonlyVars),e.associativeArrays=new Set(e.associativeArrays),e.namerefs=new Set(e.namerefs),e.boundNamerefs=new Set(e.boundNamerefs),e.invalidNamerefs=new Set(e.invalidNamerefs),e.integerVars=new Set(e.integerVars),e.lowercaseVars=new Set(e.lowercaseVars),e.uppercaseVars=new Set(e.uppercaseVars),e.exportedVars=new Set(e.exportedVars),e.tempExportedVars=new Set(e.tempExportedVars),e.localExportedVars=e.localExportedVars?.map(e=>new Set(e)),e.declaredVars=new Set(e.declaredVars),e.localScopes=e.localScopes.map(e=>new Map(e)),e.localArrayScopes=cPe(e.localArrayScopes),e.localVarDepth=e.localVarDepth?new Map(e.localVarDepth):void 0,e.localVarStack=lPe(e.localVarStack),e.fullyUnsetLocals=e.fullyUnsetLocals?new Map(e.fullyUnsetLocals):void 0,e.tempEnvBindings=e.tempEnvBindings?.map(e=>new Map(e)),e.mutatedTempEnvVars=e.mutatedTempEnvVars?new Set(e.mutatedTempEnvVars):void 0,e.accessedTempEnvVars=e.accessedTempEnvVars?new Set(e.accessedTempEnvVars):void 0,e.functions=new Map(e.functions),e.callLineStack=e.callLineStack?[...e.callLineStack]:void 0,e.funcNameStack=e.funcNameStack?[...e.funcNameStack]:void 0,e.sourceStack=e.sourceStack?[...e.sourceStack]:void 0,e.directoryStack=e.directoryStack?[...e.directoryStack]:void 0,e.hashTable=e.hashTable?new Map(e.hashTable):void 0,e.completionSpecs=oPe(e.completionSpecs),e.defaultCompletionSpec=S9(e.defaultCompletionSpec),e.emptyCompletionSpec=S9(e.emptyCompletionSpec);let n=!1;return()=>{n||(n=!0,Object.assign(e,t))}}async function uPe(e,t,n,r,i=!1){let a=e.state.loopDepth,o=new Map;for(let t of e.state.fileDescriptors?.keys()??[]){let n=F5(e,t);n&&o.set(t,n)}let s=C9(e.state);e.state.parentHasLoopContext=a>0,e.state.loopDepth=0,e.state.bashPid=e.state.nextVirtualPid++;try{return await i7(e,t.redirections,n,a=>dPe(e,t,a.stdin??n,r,i||a.stdin!==void 0))}finally{let t=new Map;for(let[n,r]of o){let i=F5(e,n),a=r.kind===`input`&&i?.kind===`input`?r.content.length-i.content.length:r.kind===`readwrite`&&i?.kind===`readwrite`&&r.path===i.path?i.position-r.position:0;if(a<=0)continue;let o=Math.min(...j5(e,n));t.set(o,Math.max(t.get(o)??0,a))}s();for(let[n,r]of t)W5(e,n,r)}}async function dPe(e,t,n,r,i){(i||n)&&(e.state.groupStdin=n);let a=new aX(e.executionScope,`subshell`),o=0;try{for(let e of t.body){let t=await r(e);a.appendResult(t),o=t.exitCode}}catch(e){if(e instanceof H)throw a.prependTo(e),e;return e instanceof WB||e instanceof NB||e instanceof PB?(a.append(`stdout`,e.stdout,e.internalOutputAccounting.stdout),a.append(`stderr`,e.stderr,e.internalOutputAccounting.stderr),a.build(0)):e instanceof RB||e instanceof FB||e instanceof IB?(a.append(`stdout`,e.stdout,e.internalOutputAccounting.stdout),a.append(`stderr`,e.stderr,e.internalOutputAccounting.stderr),a.build(e.exitCode)):(a.append(`stderr`,`${TV(e)} `),a.build(1))}return a.build(o)}async function fPe(e,t,n,r,i=!1){return i7(e,t.redirections,n,a=>pPe(e,t,n,r,i,a))}async function pPe(e,t,n,r,i,a){let o=new aX(e.executionScope,`group`),s=0,c=a.stdin??n,l=i||n!==``||a.stdin!==void 0,u=e.state.groupStdin;l&&(e.state.groupStdin=c);let d=()=>{(l||u!==void 0&&e.state.groupStdin===void 0)&&(e.state.groupStdin=u)};try{for(let e of t.body){let t=await r(e);o.appendResult(t),s=t.exitCode}}catch(e){if(d(),e instanceof H)throw o.prependTo(e),e;if(jB(e)||e instanceof IB||e instanceof RB)throw e.prependOutput(o.stdout,o.stderr),e;return o.append(`stderr`,`${TV(e)} `),o.build(1)}return d(),o.build(s)}async function mPe(e,t,n,r,i){let a;try{a=await e.fs.readFile(t)}catch{return Q(`bash: ${t}: No such file or directory `,127)}if(a.startsWith(`#!`)){let e=a.indexOf(` `);e!==-1&&(a=a.slice(e+1))}let o=e.state.loopDepth,s=C9(e.state);e.state.parentHasLoopContext=o>0,e.state.loopDepth=0,e.state.bashPid=e.state.nextVirtualPid++,r&&(e.state.groupStdin=r),e.state.currentSource=t,e.state.env.set(`0`,t),e.state.env.set(`#`,String(n.length)),e.state.env.set(`@`,n.join(` `)),e.state.env.set(`*`,n.join(` `));for(let t=0;t0)throw e.prependOutput(n.stdout,n.stderr),e;n.append(`stdout`,e.stdout),n.append(`stderr`,e.stderr);continue}throw e instanceof FB&&e.prependOutput(n.stdout,n.stderr),e}return{...n.build(t),env:QK(this.ctx.state.env)}}async executeUserScript(e,t,n=``){return mPe(this.ctx,e,t,n,e=>this.executeScript(e))}async executeStatement(e){if(this.assertDefenseContext(`statement`),this.ctx.state.signal?.aborted)throw new UB;if(e.deferredError)throw new A4(e.deferredError.message,e.line??1,1);if(this.ctx.state.options.noexec)return I8;this.ctx.state.errexitSafe=!1;let t=new aX(this.ctx.executionScope,`statement`);this.ctx.state.options.verbose&&!this.ctx.state.suppressVerbose&&e.sourceText&&t.append(`stderr`,`${e.sourceText} `);let n=0,r=-1,i=!1;try{for(let a=0;a0?e.operators[a-1]:null;if(s===`&&`&&n!==0||s===`||`&&n===0)continue;let c=await this.executePipeline(o);t.appendResult(c,TB(c)),n=c.exitCode,r=a,i=o.negated,this.ctx.state.lastExitCode=n,this.ctx.state.env.set(`?`,String(n))}}catch(e){throw t.prependTo(e),e}let a=rthis.executeCommand(e,t))}async executeCommand(e,t,n=!1){let r=hje(this.ctx),i;try{i=await this.executeCommandInner(e,t,n)}catch(e){throw await m8(this.ctx,r).catch(()=>{}),e}let a=await m8(this.ctx,r);return!a.stdout&&!a.stderr?i:{...i,stdout:a.stdout?wB(i)+a.stdout:i.stdout,stdoutKind:a.stdout?`bytes`:i.stdoutKind,stderr:i.stderr+a.stderr}}async executeCommandInner(e,t,n){switch(this.assertDefenseContext(`command`),this.ctx.coverage?.hit(`bash:cmd:${e.type}`),e.type){case`SimpleCommand`:return this.executeSimpleCommand(e,t);case`If`:return qNe(this.ctx,e);case`For`:return YNe(this.ctx,e);case`CStyleFor`:return ZNe(this.ctx,e);case`While`:return $Ne(this.ctx,e,t);case`Until`:return tPe(this.ctx,e,t);case`Case`:return rPe(this.ctx,e);case`Subshell`:return this.executeSubshell(e,t,n);case`Group`:return this.executeGroup(e,t,n);case`FunctionDef`:return fMe(this.ctx,e);case`ArithmeticCommand`:return this.executeArithmeticCommand(e);case`ConditionalCommand`:return this.executeConditionalCommand(e);default:return hPe(e)}}async executeSimpleCommand(e,t){let n;try{return await this.executeSimpleCommandInner(e,t,e=>{n=e})}catch(e){if(n?.finish(),e instanceof VB)return Q(e.stderr);throw e}}async executeSimpleCommandInner(e,t,n){if(e.line!==void 0&&(this.ctx.state.currentLine=e.line),this.ctx.state.shoptOptions.expand_aliases&&e.name){let t=e,n=0;for(;;){let e=this.expandAlias(t);if(e===t)break;if(n>=this.ctx.limits.maxCallDepth)throw new H(`alias expansion depth limit exceeded (${this.ctx.limits.maxCallDepth})`,`recursion`);n++,t=e}this.aliasExpansionStack.clear(),t!==e&&(e=t)}this.ctx.state.expansionStderr=``;let r=await kNe(this.ctx,e);if(r.error)return r.error;let i=r.tempAssignments,a=r.xtraceOutput,o=()=>{for(let[e,t]of i)t===void 0?this.ctx.state.env.delete(e):this.ctx.state.env.set(e,t)};if(!e.name){if(e.redirections.length>0){let r=t7(this.ctx,e.redirections,aMe);n(r);let i=await r.prepare(t);if(i.error){if(o(),!i.errorCause)return r.finish(),i.error;try{return n7(i)}finally{r.finish()}}let s=$(``,a,0),c=await a7(this.ctx,s,e.redirections,i.targets,i.dupSources,i.standardRoutes);return r.finish(),c}this.ctx.state.lastArg=``;let r=(this.ctx.state.expansionStderr||``)+a;return this.ctx.state.expansionStderr=``,$(``,r,this.ctx.state.lastExitCode)}let s=e.name&&x9(e.name,[`local`,`declare`,`typeset`,`export`,`readonly`]),c=Array.from(i.keys());if(c.length>0&&!s){this.ctx.state.tempExportedVars=this.ctx.state.tempExportedVars||new Set;for(let e of c)this.ctx.state.tempExportedVars.add(e)}let l=await _8(this.ctx,e.name),u=[],d=[],f=(e,t)=>{if(u.length>=this.ctx.limits.maxArrayElements)throw new H(`expanded argument element limit exceeded (${this.ctx.limits.maxArrayElements})`,`array_elements`);u.push(e),d.push(t)};if(x9(e.name,[`local`,`declare`,`typeset`,`export`,`readonly`])&&(l===`local`||l===`declare`||l===`typeset`||l===`export`||l===`readonly`))for(let t of e.args){let e=await kje(this.ctx,t);if(e)f(e,!0);else{let e=await Aje(this.ctx,t);if(e!==null)f(e,!0);else{let e=await C8(this.ctx,t);for(let t of e.values)f(t,e.quoted)}}}else for(let t of e.args){let e=await C8(this.ctx,t);for(let t of e.values)f(t,e.quoted)}let p=e.name.parts.every(e=>e.type===`CommandSubstitution`||e.type===`ParameterExpansion`||e.type===`ArithmeticExpansion`);!l&&p&&u.length>0&&(l=u.shift(),d.shift());let m=t7(this.ctx,e.redirections,l===`exec`?oMe:X5);n(m);let h=await m.prepare(t);if(h.error)return o(),h.errorCause?n7(h):(m.finish(),h.error);let g=h.stdinSourceFd,_=h.stdin!==void 0;if(h.stdin!==void 0&&(t=h.stdin),!l)return p?(m.finish(),$(``,``,this.ctx.state.lastExitCode)):(m.finish(),Q(`bash: : command not found `,127));if(l===`exec`&&(u.length===0||u[0]===`--`)){for(let[e,t]of i)t===void 0?this.ctx.state.env.delete(e):this.ctx.state.env.set(e,t);if(this.ctx.state.tempExportedVars)for(let e of i.keys())this.ctx.state.tempExportedVars.delete(e);return m.finish(),I8}if(this.ctx.state.extraArgs){let e=this.ctx.state.extraArgs;this.ctx.state.extraArgs=void 0;for(let t of e)f(t,!0)}let v=await DNe(this.ctx,l,u);i.size>0&&(this.ctx.state.tempEnvBindings=this.ctx.state.tempEnvBindings||[],this.ctx.state.tempEnvBindings.push(new Map(i)));let y,b=null;try{y=await this.runCommand(l,u,d,t,!1,!1,g,_)}catch(e){if(e instanceof NB||e instanceof PB)b=e,y=I8;else throw e}g>=0&&l!==`read`&&W5(this.ctx,g,y.internalStdinConsumed??0);let x=a+v;if(x&&(y={...y,stderr:x+y.stderr}),y=await a7(this.ctx,y,e.redirections,h.targets,h.dupSources,h.standardRoutes,y.internalProducerCommand??l,y.internalProducerOmitsShellPrefix),m.finish(),b)throw b;if(u.length>0){let e=u[u.length-1];if((l===`declare`||l===`local`||l===`typeset`)&&/^[a-zA-Z_][a-zA-Z0-9_]*=\(/.test(e)){let t=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);t&&(e=t[1])}this.ctx.state.lastArg=e}else this.ctx.state.lastArg=l;let S=Qje(l)&&l!==`unset`&&l!==`eval`;if(!this.ctx.state.options.posix||!S)for(let[e,t]of i)this.ctx.state.fullyUnsetLocals?.has(e)||(t===void 0?this.ctx.state.env.delete(e):this.ctx.state.env.set(e,t));if(this.ctx.state.tempExportedVars)for(let e of i.keys())this.ctx.state.tempExportedVars.delete(e);return i.size>0&&this.ctx.state.tempEnvBindings&&this.ctx.state.tempEnvBindings.pop(),this.ctx.state.expansionStderr&&(y={...y,stderr:this.ctx.state.expansionStderr+y.stderr},this.ctx.state.expansionStderr=``),y}async runCommand(e,t,n,r,i=!1,a=!1,o=-1,s=!1){let c={ctx:this.ctx,runCommand:(e,t,n,r,i,a,o,s)=>this.runCommand(e,t,n,r,i,a,o,s),buildExportedEnv:()=>this.buildExportedEnv(),executeUserScript:(e,t,n)=>this.executeUserScript(e,t,n)},l=await UNe(c,e,t,n,r,i,a,o,s);return l===null?{...await KNe(c,e,t,r,a),internalProducerCommand:e}:l.internalProducerCommand===void 0?{...l,internalProducerCommand:e}:l}aliasExpansionStack=new Set;expandAlias(e){return kke({env:this.ctx.state.env,limits:this.ctx.limits},e,this.aliasExpansionStack)}async findCommandInPath(e){return r9(this.ctx,e)}async executeSubshell(e,t=``,n=!1){return uPe(this.ctx,e,t,e=>this.executeStatement(e),n)}async executeGroup(e,t=``,n=!1){return fPe(this.ctx,e,t,e=>this.executeStatement(e),n)}async executeArithmeticCommand(e){return e.line!==void 0&&(this.ctx.state.currentLine=e.line),i7(this.ctx,e.redirections,``,async()=>{try{let t=R8(await N8(this.ctx,e.expression.expression)!==0);return this.ctx.state.expansionStderr&&(t={...t,stderr:this.ctx.state.expansionStderr+t.stderr},this.ctx.state.expansionStderr=``),t}catch(e){return Q(`bash: arithmetic expression: ${e.message} `)}})}async executeConditionalCommand(e){return e.line!==void 0&&(this.ctx.state.currentLine=e.line),i7(this.ctx,e.redirections,``,async()=>{try{let t=R8(await Q8(this.ctx,e.expression));return this.ctx.state.expansionStderr&&(t={...t,stderr:this.ctx.state.expansionStderr+t.stderr},this.ctx.state.expansionStderr=``),t}catch(e){let t=e instanceof zB?1:2;return Q(`bash: conditional expression: ${e.message} `,t)}})}};Mz(),_B(),oB(),hB();function w9(e){try{let t=new URL(e);return{origin:t.origin,pathname:t.pathname,href:t.href}}catch{return null}}function _Pe(e){let t=w9(e);return t?{origin:t.origin,pathPrefix:t.pathname}:null}var vPe=3;function T9(e){let t=e;for(let e=0;eE9(e,D9(t)))}function O9(e){let t=xPe(e);if(t===`localhost`||t.endsWith(`.localhost`))return!0;let n=k9(t);if(n)return A9(n);let r=CPe(t);return r?wPe(r):!1}function xPe(e){let t=e.trim().toLowerCase();return t.startsWith(`[`)&&t.endsWith(`]`)?t.slice(1,-1):t}function SPe(e){if(!e)return null;let t=10,n=e;if(n.startsWith(`0x`)||n.startsWith(`0X`)?(t=16,n=n.slice(2)):n.length>1&&n.startsWith(`0`)&&(t=8),!n||t===16&&!/^[0-9a-fA-F]+$/.test(n)||t===10&&!/^\d+$/.test(n)||t===8&&!/^[0-7]+$/.test(n))return null;let r=Number.parseInt(n,t);return!Number.isFinite(r)||r<0?null:r}function k9(e){let t=e.split(`.`);if(t.length===0||t.length>4)return null;let n=t.map(e=>SPe(e));if(n.some(e=>e===null))return null;let r=n;if(t.length===1){let e=r[0];return e>4294967295?null:[e>>>24&255,e>>>16&255,e>>>8&255,e&255]}if(t.length===2){let[e,t]=r;return e>255||t>16777215?null:[e,t>>>16&255,t>>>8&255,t&255]}if(t.length===3){let[e,t,n]=r;return e>255||t>255||n>65535?null:[e,t,n>>>8&255,n&255]}let[i,a,o,s]=r;return i>255||a>255||o>255||s>255?null:[i,a,o,s]}function CPe(e){let t=e,n=null;if(t.includes(`.`)){let e=t.lastIndexOf(`:`);if(e<0)return null;let r=k9(t.slice(e+1));if(!r)return null;n=r,t=t.slice(0,e)}let r=t.includes(`::`)?t.split(`::`).length-1:0;if(r>1)return null;let[i,a]=t.split(`::`),o=i?i.split(`:`).filter(Boolean):[],s=a?a.split(`:`).filter(Boolean):[],c=e=>/^[0-9a-f]{1,4}$/i.test(e)?Number.parseInt(e,16):null,l=o.map(c),u=s.map(c);if(l.some(e=>e===null)||u.some(e=>e===null))return null;let d=n?2:0,f=l.length+u.length+d,p=0;if(r===1){if(p=8-f,p<0)return null}else if(f!==8)return null;let m=[...l,...Array(p).fill(0),...u];return n&&(m.push(n[0]<<8|n[1]),m.push(n[2]<<8|n[3])),m.length===8?m:null}function A9(e){let[t,n]=e;return t===127||t===10||t===172&&n>=16&&n<=31||t===192&&n===168||t===169&&n===254||t===0||t===100&&n>=64&&n<=127||t===198&&(n===18||n===19)||t===192&&n===0&&e[2]===0||t===192&&n===0&&e[2]===2||t===198&&n===51&&e[2]===100||t===203&&n===0&&e[2]===113||t>=240}function wPe(e){return e.every(e=>e===0)||e.slice(0,7).every(e=>e===0)&&e[7]===1||(e[0]&65472)==65152||(e[0]&65024)==64512?!0:e[0]===0&&e[1]===0&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===65535?A9([e[6]>>>8&255,e[6]&255,e[7]>>>8&255,e[7]&255]):e[0]===8193&&e[1]===3512?!0:e[0]===100&&e[1]===65435&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===0?A9([e[6]>>>8&255,e[6]&255,e[7]>>>8&255,e[7]&255]):e[0]===100&&e[1]===65435&&e[2]===1||e[0]===8194&&A9([e[1]>>>8&255,e[1]&255,e[2]>>>8&255,e[2]&255])}function TPe(e){let t=[];for(let n of e){if(typeof n!=`string`&&(typeof n!=`object`||!n||!(`url`in n)||typeof n.url!=`string`)){t.push(`Invalid allow-list entry: must be a string URL or an object with a "url" string property`);continue}let e=D9(n);if(!w9(e)){t.push(`Invalid URL in allow-list: "${e}" - must be a valid URL with scheme and host (e.g., "https://example.com")`);continue}let r=new URL(e);if(r.protocol!==`http:`&&r.protocol!==`https:`){t.push(`Only http and https URLs are allowed in allow-list: "${e}"`);continue}if(!r.hostname){t.push(`Allow-list entry must include a hostname: "${e}"`);continue}if(r.pathname!==`/`&&r.pathname!==``&&T9(r.pathname)){t.push(`Allow-list entry contains ambiguous path separators: "${e}"`);continue}(r.search||r.hash)&&t.push(`Query strings and fragments are ignored in allow-list entries: "${e}"`)}return t}var j9=class extends Error{constructor(){super(`DNS pinning is unavailable in this runtime`),this.name=`DnsPinningUnavailableError`}},EPe=async e=>{throw new j9},M9=class extends Error{constructor(e,t){super(`Network access denied: ${t??`URL not in allow-list`}: ${e}`),this.name=`NetworkAccessDeniedError`}},DPe=class extends Error{constructor(e){super(`Too many redirects (max: ${e})`),this.name=`TooManyRedirectsError`}},OPe=class extends Error{constructor(e){super(`Redirect target not in allow-list: ${e}`),this.name=`RedirectNotAllowedError`}},kPe=class extends Error{constructor(e,t){super(`HTTP method '${e}' not allowed. Allowed methods: ${t.join(`, `)}`),this.name=`MethodNotAllowedError`}},N9=class extends Error{constructor(e){super(`Response body too large (max: ${e} bytes)`),this.name=`ResponseTooLargeError`}};function APe(e){return new Promise((t,n)=>{kz(e,{all:!0},(e,r)=>{e?n(e):t(r)})})}var jPe=20,MPe=3e4,NPe=10485760,PPe=[`GET`,`HEAD`],FPe=new Set([`GET`,`HEAD`,`OPTIONS`]),IPe=new Set([301,302,303,307,308]);function P9(e){return e.reason instanceof Error?e.reason:new DOMException(`The operation was aborted`,`AbortError`)}function F9(e){if(e?.aborted)throw P9(e)}async function I9(e,t){if(!t)return e;if(t.aborted)throw e.catch(()=>{}),P9(t);let n,r=new Promise((e,r)=>{n=()=>r(P9(t)),t.addEventListener(`abort`,n,{once:!0})});try{return await Promise.race([e,r])}finally{n&&t.removeEventListener(`abort`,n)}}async function LPe(e,t){try{return await I9(e,t)}catch(n){throw t?.aborted&&e.then(e=>aB.runTrustedAsync(()=>e.close())).catch(()=>{}),n}}async function RPe(e){e.body&&!e.body.locked&&await e.body.cancel()}function zPe(e){let t=e.allowedUrlPrefixes??[];if(!e.dangerouslyAllowFullInternetAccess){let e=TPe(t);if(e.length>0)throw Error(`Invalid network allow-list: ${e.join(` `)}`)}let n=[];for(let e of t)typeof e==`object`&&e.transform&&e.transform.length>0&&n.push(e);function r(e){if(n.length===0)return null;let t=null;for(let r of n)if(E9(e,r.url)&&r.transform){t||=new Headers;for(let e of r.transform)for(let[n,r]of Object.entries(e.headers))t.set(n,r)}return t}if(e.maxRedirects!==void 0&&(!Number.isSafeInteger(e.maxRedirects)||e.maxRedirects<0))throw RangeError(`maxRedirects must be a non-negative safe integer`);let i=e.maxRedirects??jPe,a=e.timeoutMs??MPe,o=e.maxResponseSize??NPe,s=e.dangerouslyAllowFullInternetAccess?[`GET`,`HEAD`,`POST`,`PUT`,`DELETE`,`PATCH`,`OPTIONS`]:e.allowedMethods??PPe,c=e.denyPrivateRanges??(typeof process<`u`&&!0),l=e._dnsResolve??APe,u=e._createConnectionOwner??EPe;function d(e){let t=e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,-1):e;if(/^(?:0|[1-9]\d{0,2})(?:\.(?:0|[1-9]\d{0,2})){3}$/.test(t)&&t.split(`.`).every(e=>Number(e)<=255))return 4;if(t.includes(`:`)&&!t.includes(`%`))try{if(new URL(`http://[${t}]/`).hostname.length>2)return 6}catch{}return null}function f(e,t,n){let{address:r,family:i}=n;if(d(r)!==i)throw new M9(e,`DNS returned an invalid address for private IP check`);return{hostname:t,address:r,family:i}}async function p(n,r){if(F9(r),!e.dangerouslyAllowFullInternetAccess&&!bPe(n,t))throw new M9(n);if(!c)return null;let i;try{i=new URL(n)}catch{throw new M9(n,`invalid URL`)}if(O9(i.hostname))throw new M9(n,`private/loopback IP address blocked`);let a=i.hostname;if(d(a)!==null)return null;let o;try{o=await I9(l(a),r)}catch{throw r?.aborted?P9(r):new M9(n,`DNS resolution failed for private IP check`)}if(!Array.isArray(o)||o.length===0)throw new M9(n,`DNS resolution returned no addresses for private IP check`);let s=o.map(e=>f(n,a,e));for(let{address:e}of s)if(O9(e))throw new M9(n,`hostname resolves to private/loopback IP address`);return s[0]}function m(t){if(e.dangerouslyAllowFullInternetAccess)return;let n=t.toUpperCase();if(!s.includes(n))throw new kPe(n,s)}async function h(e,t={}){let n=t.method?.toUpperCase()??`GET`,s=t.followRedirects??!0;if(t.maxRedirects!==void 0&&(!Number.isSafeInteger(t.maxRedirects)||t.maxRedirects<0))throw RangeError(`maxRedirects must be a non-negative safe integer`);let c=t.maxRedirects??i,l=Math.min(i,c),d=t.timeoutMs===void 0?a:Math.min(t.timeoutMs,a),f=new AbortController,h=fB(()=>f.abort(new DOMException(`The operation was aborted`,`AbortError`)),d),g=gB(t.signal,f.signal);try{let i=await p(e,g.signal);m(n);let a=e,c=0;for(;;){F9(g.signal);let e;try{let d=await aB.runTrustedAsync(async()=>{let o=r(a),s=BPe(t.headers,o),c={method:n,headers:s,signal:g.signal,redirect:`manual`};if(t.body&&!FPe.has(n)&&(c.body=t.body),!i)return await I9(fetch(a,c),g.signal);try{return e=await LPe(u(i),g.signal),await I9(e.fetch(a,c),g.signal)}catch(e){throw e instanceof j9?new M9(a,`DNS pinning unavailable for private IP enforcement`):e}});if(IPe.has(d.status)&&s){let e=d.headers.get(`location`);if(!e)return await L9(d,a,o,g.signal);let t=new URL(e,a).href;await I9(RPe(d),g.signal);try{i=await p(t,g.signal)}catch{throw g.signal?.aborted?P9(g.signal):new OPe(t)}if(c++,c>l)throw new DPe(l);a=t;continue}return await L9(d,a,o,g.signal)}finally{if(e){let t=e;await I9(aB.runTrustedAsync(()=>t.close()),g.signal)}}}}finally{pB(h),g.cleanup()}}return h}function BPe(e,t){if(!e&&!t)return;if(!t)return e;let n=(e instanceof Headers,new Headers(e));for(let[e,r]of t)n.set(e,r);return n}async function L9(e,t,n,r){let i=Object.create(null);if(e.headers.forEach((e,t)=>{i[t.toLowerCase()]=e}),n>0){let t=e.headers.get(`content-length`);if(t){let e=parseInt(t,10);if(!Number.isNaN(e)&&e>n)throw new N9(n)}}let a;if(n>0&&e.body){let t=e.body.getReader(),i=[],o=0;try{for(;;){let{done:e,value:a}=await I9(t.read(),r);if(e)break;if(a){if(o+=a.byteLength,o>n)throw await t.cancel(),new N9(n);i.push(a)}}}catch(e){throw r?.aborted&&await t.cancel(P9(r)).catch(()=>{}),e}a=new Uint8Array(o);let s=0;for(let e of i)a.set(e,s),s+=e.byteLength}else{let t=await I9(e.arrayBuffer(),r);if(n>0&&t.byteLength>n)throw new N9(n);a=new Uint8Array(t)}return{status:e.status,statusText:e.statusText,headers:i,body:a,url:t}}oB(),ZB(),U();function R9(e,t){if(e.length>t||V(e)>t)throw new H(`script input size limit exceeded (${t} bytes)`,`string_length`)}var VPe=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;jsBootstrapCode;invokeToolFn;transformPlugins=[];state;constructor(e={}){this.limits=qDe({...e.executionLimits,...e.maxCallDepth!==void 0&&{maxCallDepth:e.maxCallDepth},...e.maxCommandCount!==void 0&&{maxCommandCount:e.maxCommandCount},...e.maxLoopIterations!==void 0&&{maxLoopIterations:e.maxLoopIterations}},e.executionLimitProfile);let t=e.fs??new J2(e.files,{maxTotalBytes:this.limits.maxFileSystemBytes});this.fs=t,this.useDefaultLayout=!e.cwd&&!e.files;let n=e.cwd||(this.useDefaultLayout?`/home/user`:`/`),r=new Map([[`HOME`,this.useDefaultLayout?`/home/user`:`/`],[`PATH`,`/usr/bin:/bin`],[`IFS`,` `],[`OSTYPE`,`linux-gnu`],[`MACHTYPE`,`x86_64-pc-linux-gnu`],[`HOSTTYPE`,`x86_64`],[`HOSTNAME`,`localhost`],[`PWD`,n],[`OLDPWD`,n],[`OPTIND`,`1`],...Object.entries(e.env??{})]);if(e.fetch?this.secureFetch=e.fetch:e.network&&(this.secureFetch=zPe(e.network)),this.sleepFn=e.sleep,this.traceFn=e.trace,this.logger=e.logger,this.defenseInDepthConfig=e.defenseInDepth??!0,this.coverageWriter=e.coverage,this.state={env:r,arrays:new Map,cwd:n,previousDir:`/home/user`,functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:``,startTime:Date.now(),lastBackgroundPid:0,virtualPid:e.processInfo?.pid??1,virtualPpid:e.processInfo?.ppid??0,virtualUid:e.processInfo?.uid??1e3,virtualGid:e.processInfo?.gid??1e3,bashPid:e.processInfo?.pid??1,nextVirtualPid:(e.processInfo?.pid??1)+1,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1,posix:!1,allexport:!1,noclobber:!1,noglob:!1,noexec:!1,vi:!1,emacs:!1},shoptOptions:{extglob:!1,dotglob:!1,nullglob:!1,failglob:!1,globstar:!1,globskipdots:!0,nocaseglob:!1,nocasematch:!1,expand_aliases:!1,lastpipe:!1,xpg_echo:!1},inCondition:!1,loopDepth:0,exportedVars:new Set([`HOME`,`PATH`,`PWD`,`OLDPWD`,...Object.keys(e.env||{})]),readonlyVars:new Set([`SHELLOPTS`,`BASHOPTS`]),hashTable:new Map},this.state.env.set(`SHELLOPTS`,m4(this.state.options)),this.state.env.set(`BASHOPTS`,g4(this.state.shoptOptions)),oOe(t,this.useDefaultLayout,{pid:this.state.virtualPid,ppid:this.state.virtualPpid,uid:this.state.virtualUid,gid:this.state.virtualGid}),n!==`/`&&t instanceof J2)try{t.mkdirSync(n,{recursive:!0})}catch{}for(let t of BDe(e.commands))this.registerBundledCommand(t);if(e.fetch||e.network)for(let e of VDe())this.registerBundledCommand(e);if(e.python)for(let e of HDe())this.registerBundledCommand(e);let i=typeof e.javascript==`object`?e.javascript:Object.create(null);if(e.javascript||i.invokeTool){for(let e of UDe())this.registerBundledCommand(e);i.bootstrap&&(this.jsBootstrapCode=i.bootstrap),i.invokeTool&&(this.invokeToolFn=i.invokeTool)}if(e.customCommands)for(let t of e.customCommands)if(JDe(t)){let e=YDe(t);this.registerCommandInternal(e,!0)}else this.registerCommandInternal(t,!0)}registerCommand(e){this.registerCommandInternal(e,!0)}registerBundledCommand(e){this.registerCommandInternal(e,!1)}registerCommandInternal(e,t,n=t?e.trusted??!0:e.trusted){let r=this.commands.get(e.name),i=t?r?.internalOriginalCommand??(r&&!r.internalIsExtension?r:void 0):void 0,a={name:e.name,trusted:n,internalIsExtension:t,internalOriginalCommand:i,execute:(t,n)=>e.execute(t,n)};this.commands.set(e.name,a);let o=this.fs;if(typeof o.writeFileSync==`function`){let t=`#!/bin/bash # Built-in command: ${e.name} `;try{o.writeFileSync(`/bin/${e.name}`,t)}catch{}try{o.writeFileSync(`/usr/bin/${e.name}`,t)}catch{}}}logResult(e){return this.logger&&(e.stdout&&this.logger.debug(`stdout`,{output:e.stdout}),e.stderr&&this.logger.info(`stderr`,{output:e.stderr}),this.logger.info(`exit`,{exitCode:e.exitCode})),e.stdout=B9(e.stdout),e.stderr=B9(e.stderr),e}async exec(e,t){let n=new XDe(this.limits,t?.signal),r;try{r=await this.execInScope(e,t,n,0,t?.signal,!1,!1)}catch(e){try{await n.close()}catch{}throw e}let i=r;try{await n.close()}catch{i={...r,stderr:`${r.stderr}bash: execution cleanup failed `,exitCode:126}}return e.trim()?this.logResult(i):i}async execInScope(e,t,n,r,i,a=!1,o=!0){let s=e=>o?this.logResult(e):e,c=gB(i,t?.signal),l=t?{...t,signal:c.signal}:{signal:c.signal};try{if(n.assertExecDepth(r),R9(e,this.limits.maxSourceBytes),!e.trim())return{stdout:``,stderr:``,exitCode:0,env:$K(this.state.env,l.env)};this.logger?.info(`exec`,{command:e});let t=l.cwd??this.state.cwd,i,o=t;if(l.cwd){if(l.env&&`PWD`in l.env)i=l.env.PWD;else if(l.env&&!(`PWD`in l.env))try{i=await this.fs.realpath(t),o=i}catch{i=t}else i=t}let c=l.replaceEnv?new Map:new Map(this.state.env);if(l.env)for(let[e,t]of Object.entries(l.env))c.set(e,t);i!==void 0&&c.set(`PWD`,i);let u={...this.state,env:c,arrays:l.replaceEnv?new Map:Z2(this.state.arrays),cwd:o,previousDir:l.env?.OLDPWD??this.state.previousDir,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:WPe(l.stdin,l.stdinKind,this.limits.maxInputBytes,this.limits.maxStringLength,n,a),signal:l.signal,extraArgs:l.args},d=e;l.rawScript||(d=z9(e));let f=this.defenseInDepthConfig?aB.getInstance(this.defenseInDepthConfig):null,p=f?.activate();try{let e=async()=>{let e=E3(d,{maxHeredocSize:this.limits.maxHeredocSize}),t;if(this.transformPlugins.length>0){let n=Object.create(null);for(let t of this.transformPlugins){let r=t.transform({ast:e,metadata:n});e=r.ast,r.metadata&&(n=eq(n,r.metadata))}t=n}let i=await new gPe({fs:this.fs,commands:this.commands,limits:this.limits,executionScope:n,exec:(e,t,i=!1)=>this.execInScope(e,t,n,r+1,l.signal,i),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter,requireDefenseContext:f?.isEnabled()===!0,jsBootstrapCode:this.jsBootstrapCode,invokeTool:this.invokeToolFn},u).executeScript(e);return t&&(i.metadata=t),s(i)};return p?await p.run(e):await e()}catch(e){if(e instanceof RB)return s({stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode,internalOutputAccounting:e.internalOutputAccounting,env:$K(this.state.env,l.env)});if(e instanceof GB)return s({stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode,env:$K(this.state.env,l.env)});if(e instanceof zB)return s({stdout:e.stdout,stderr:e.stderr,exitCode:1,env:$K(this.state.env,l.env)});if(e instanceof UB)return s({stdout:e.stdout,stderr:e.stderr,exitCode:124,env:$K(this.state.env,l.env)});if(e instanceof H)return s({stdout:e.stdout,stderr:vH(e.stderr),exitCode:H.EXIT_CODE,internalOutputAccounting:e.internalOutputAccounting,env:$K(this.state.env,l.env)});if(e instanceof tB)return s({stdout:``,stderr:`bash: security violation: ${vH(e.message)} `,exitCode:1,env:$K(this.state.env,l.env)});if(e.name===`ParseException`)return s({stdout:``,stderr:`bash: syntax error: ${vH(e.message)} `,exitCode:2,env:$K(this.state.env,l.env)});if(e instanceof b4)return s({stdout:``,stderr:`bash: ${vH(e.message)} `,exitCode:2,env:$K(this.state.env,l.env)});if(e instanceof RangeError)return s({stdout:``,stderr:`bash: ${vH(e.message)} `,exitCode:1,env:$K(this.state.env,l.env)});throw e}finally{p?.deactivate()}}catch(e){if(e instanceof UB)return s({stdout:e.stdout,stderr:e.stderr,exitCode:124,env:$K(this.state.env,l.env)});if(e instanceof H)return s({stdout:e.stdout,stderr:vH(e.stderr),exitCode:H.EXIT_CODE,internalOutputAccounting:e.internalOutputAccounting,env:$K(this.state.env,l.env)});throw e}finally{c.cleanup()}}async readFile(e){return this.fs.readFile(this.fs.resolvePath(this.state.cwd,e))}async writeFile(e,t){return this.fs.writeFile(this.fs.resolvePath(this.state.cwd,e),t)}getCwd(){return this.state.cwd}getEnv(){return QK(this.state.env)}registerTransformPlugin(e){this.transformPlugins.push(e)}transform(e){R9(e,this.limits.maxSourceBytes);let t=E3(z9(e),{maxHeredocSize:this.limits.maxHeredocSize}),n=Object.create(null);for(let e of this.transformPlugins){let r=e.transform({ast:t,metadata:n});t=r.ast,r.metadata&&(n=eq(n,r.metadata))}return{script:ake(t),ast:t,metadata:n}}};function HPe(e,t){let n=t;for(let t=0;t0){let e=r[r.length-1];if((e.stripTabs?a.replace(/^\t+/,``):a)===e.delimiter){n.push(a.trimStart()),r.pop();continue}n.push(a);continue}let o=i,s=o===`none`?a.trimStart():a;if(n.push(s),i=HPe(a,o),o===`none`)for(let e of s.matchAll(/<<(-?)\s*(['"]?)([\w-]+)\2/g)){let t=e[1]===`-`,n=e[3];r.push({delimiter:n,stripTabs:t})}}return n.join(` `)}var UPe=new TextDecoder(`utf-8`,{fatal:!0});function B9(e){if(!e)return e;let t=!1;for(let n=0;n255)return e;r>127&&(t=!0)}if(!t)return e;let n=new Uint8Array(e.length);for(let t=0;tn||o>r)throw new H(`stdin size limit exceeded (${Math.min(n,r)} bytes)`,`string_length`);return a||i.consumeInput(o,`stdin`),t===`bytes`?e:bB(e)} /*! Bundled license information: re2js/build/index.esm.js: (*! * re2js * RE2JS is the JavaScript port of RE2, a regular expression engine that provides linear time matching * * @version v1.3.3 * @author Alexey Vasiliev * @homepage https://github.com/le0pard/re2js#readme * @repository github:le0pard/re2js * @license MIT *) ieee754/index.js: (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh *) */ const V9=JSON.stringify([{product:`Notebook`,unit_cost:2.5,stock:24},{product:`Pencil`,unit_cost:.5,stock:120},{product:`Folder`,unit_cost:1.2,stock:18},{product:`Eraser`,unit_cost:.35,stock:40},{product:`Stapler`,unit_cost:2.75,stock:9},{product:`Ruler`,unit_cost:.8,stock:30}],null,2)+` `,GPe=JSON.stringify(JSON.parse(V9).map(({product:e,unit_cost:t})=>({product:e,unit_cost:t})),null,2)+` `,H9={"/workspace/README.md":`# Browser workspace Your files are saved in this browser. `,"/workspace/sales.csv":`product,units Notebook,12 Pencil,30 Folder,8 `,"/workspace/products.json":JSON.stringify([{product:`Notebook`,price:5},{product:`Pencil`,price:2},{product:`Folder`,price:3},{product:`Eraser`,price:1.5},{product:`Stapler`,price:4.99},{product:`Ruler`,price:2.5}],null,2)+` `},KPe=e=>e.length>6e3?e.slice(0,6e3)+` [Output truncated at 6,000 characters; use head, grep, or a narrower query.]`:e,U9=(e,t={})=>({content:[{type:`text`,text:KPe(e)}],details:t});function qPe(e=H9,t){t&&(e=Object.fromEntries(t.filter(([,e])=>e.type===`file`).map(([e,t])=>[e,{mode:t.mode,content:Uint8Array.from(atob(t.base64),e=>e.charCodeAt(0))}])));let n=new VPe({files:e,cwd:`/workspace`,executionLimitProfile:`hardened`,executionLimits:{maxExecutionTimeMs:1e4,maxCommandCount:3e3,maxFileSystemBytes:16*1024**2,maxOutputSize:262144,maxSourceBytes:131072}}),r=e=>n.fs.resolvePath(`/workspace`,e),i=(async()=>{for(let[e,r]of t??[])r.type===`directory`?(await n.fs.mkdir(e,{recursive:!0}),await n.fs.chmod(e,r.mode)):r.type===`symlink`&&await n.fs.symlink(r.target,e)})();async function a(e,t){let i=r(e);if(new TextEncoder().encode(t).length>1024**2)throw Error(`The editor accepts files up to 1 MiB.`);await n.fs.mkdir(i.slice(0,i.lastIndexOf(`/`))||`/`,{recursive:!0}),await n.fs.writeFile(i,t)}let o=[{name:`bash`,label:`Bash`,description:`Run a bash command in /workspace. Supports cat, ls, grep, sed, awk, jq, sort, pipes, redirects, and shell scripts. No network, Node.js, Python, npm, or native binaries. Files persist across commands; cd and variables reset each call.`,parameters:Sn({command:Yr({description:`The shell command to execute.`})}),execute:async(e,{command:t},r)=>{let i=await n.exec(t,{signal:r});return U9(`${i.stdout}${i.stderr?` STDERR: `+i.stderr:``}\nExit code: ${i.exitCode}`,{exitCode:i.exitCode})}},{name:`read`,label:`Read file`,description:`Read a UTF-8 text file. Use bash head/grep for large files.`,parameters:Sn({path:Yr()}),execute:async(e,t)=>{let i=await n.fs.realpath(r(t.path));return U9(await n.fs.readFile(i),{path:i})}},{name:`write`,label:`Write file`,description:`Create or replace a UTF-8 text file. Parent directories are created.`,parameters:Sn({path:Yr(),content:Yr()}),execute:async(e,t)=>(await a(t.path,t.content),U9(`Wrote `+r(t.path)))},{name:`edit`,label:`Edit file`,description:`Replace one exact occurrence of oldText with newText in a UTF-8 file. oldText must match exactly once.`,parameters:Sn({path:Yr(),oldText:Yr(),newText:Yr()}),execute:async(e,t)=>{let i=await n.fs.readFile(r(t.path));if(!t.oldText||i.split(t.oldText).length!==2)throw Error(`oldText must match exactly once. Read the file first.`);return await a(t.path,i.replace(t.oldText,()=>t.newText)),U9(`Edited `+r(t.path))}}];async function s(){let e={};for(let t of n.fs.getAllPaths().sort())t.startsWith(`/bin/`)||t.startsWith(`/usr/bin/`)||t.startsWith(`/dev/`)||t.startsWith(`/proc/`)||(await n.fs.lstat(t)).isFile&&(e[t]=await n.fs.readFile(t));return e}async function c(){let e=[];for(let t of n.fs.getAllPaths().sort()){if([`/bin`,`/usr/bin`,`/dev`,`/proc`].some(e=>t===e||t.startsWith(e+`/`)))continue;let r=await n.fs.lstat(t);if(r.isSymbolicLink)e.push([t,{type:`symlink`,target:await n.fs.readlink(t)}]);else if(r.isDirectory)e.push([t,{type:`directory`,mode:r.mode}]);else if(r.isFile){let i=await n.fs.readFileBuffer(t),a=``;for(let e=0;en.fs.readFile(r(e))}}async function JPe(){let e=await new Promise((e,t)=>{let n=indexedDB.open(`minicpm5-pi-workspace`,1);n.onupgradeneeded=()=>n.result.createObjectStore(`state`),n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)});return{async load(){return new Promise((t,n)=>{let r=e.transaction(`state`).objectStore(`state`).get(`current`);r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error)})},async save(t){return new Promise((n,r)=>{let i=e.transaction(`state`,`readwrite`);i.objectStore(`state`).put(t,`current`),i.oncomplete=n,i.onerror=()=>r(i.error),i.onabort=()=>r(i.error)})}}}const W9=e=>postMessage(e),G9=KI(W9);let K9,q9,J9,Y9=!1,X9,Z9=0;async function Q9(){return{version:1,demoVersion:4,files:await K9.snapshot(),entries:await K9.serialize(),messages:q9.state.messages}}async function $9(){let e=await Q9();try{await J9?.save(e)}catch(e){W9({type:`persistence_error`,error:`Changes are in memory, but browser storage failed: `+e.message})}return W9({type:`workspace`,files:e.files}),e}const YPe=(async()=>{let e;try{J9=await JPe(),e=await J9.load()}catch(e){W9({type:`persistence_error`,error:`Workspace saving is unavailable: `+e.message})}K9=qPe(e?.files,e?.entries),await K9.ready;let t=e&&(e.demoVersion??0)<4;if(t){let t=K9.bash.fs.getAllPaths(),n=`/workspace/products.csv`,r=`/workspace/products.json`,i=`/workspace/sales.csv`,a=async(e,n)=>t.includes(e)&&(await K9.bash.fs.lstat(e)).isFile&&n.includes(await K9.read(e));if(await a(i,[`product,units,price Notebook,12,5 Pencil,30,2 Folder,8,3 `])){let o=await a(r,[V9,GPe]),s=!t.includes(r)&&await a(n,[`product,unit_cost,stock Notebook,2.50,24 Pencil,0.50,120 Folder,1.20,18 Eraser,0.35,40 Stapler,2.75,9 Ruler,0.80,30 `]),c=(e.demoVersion??0)<1&&!t.includes(r)&&!t.includes(n);(o||s||c)&&(await K9.write(i,H9[i]),await K9.write(r,H9[r]),s&&await K9.bash.fs.rm(n))}let o=`/workspace/README.md`;await a(o,[`# Browser workspace Pi can read, write, edit, and run shell commands here. Everything stays in this browser. Explore our sales, product costs, and stock levels. `,`# Browser workspace Sales and product costs for a small shop. Prices and unit costs are in USD. Profit means revenue minus the cost of units sold, before tax and other operating expenses. Pi can read, edit, and run shell commands here. Everything stays in this browser. `])&&await K9.write(o,H9[o])}q9=new zce({initialState:{model:GI,thinkingLevel:`medium`,systemPrompt:`You are Pi, a coding assistant powered by MiniCPM5-2B, a language model from OpenBMB. The model, inference, tools, and workspace run entirely in the user's browser. Workspace files are stored in this browser, not on the user's operating-system filesystem. Use your tools to inspect and change actual files. Never claim a command ran or a file changed without a successful tool result. When the user explicitly asks you to use a tool, call that tool even if you already know the answer. Working directory: /workspace. Use read, write, edit, and bash. Keep tool calls and answers concise. The bash tool supports cat, ls, find, grep, sed, awk, jq, sort, wc, printf, pipes, redirects, and shell scripts. Use jq for JSON and awk for CSV and calculations; python, python3, node, npm, native binaries, and network access are unavailable. You can create and edit text files, including HTML, CSS, JavaScript, and shell scripts. HTML may reference external assets by URL; writing such a reference does not require network access from the shell. Do not claim an external asset was fetched or tested. Interpret short follow-ups using the conversation and inspect the relevant files when needed. Inspect files before editing them. After changing files, verify the result with a tool. Finish with a short factual answer.`,tools:K9.tools,messages:e?.messages??[]},streamFn:G9.streamFn,toolExecution:`sequential`,afterToolCall:({result:e,isError:t})=>({isError:t||e.details?.exitCode!==void 0&&e.details.exitCode!==0}),shouldStopAfterTurn:({toolResults:e})=>{let t=++Z9>=12&&e.length>0;return t&&W9({type:`notice`,text:`Paused after 12 agent turns. Send a follow-up to continue.`}),t}}),q9.subscribe(async e=>{W9({type:`agent_event`,event:e}),(e.type===`tool_execution_end`||e.type===`agent_end`)&&await $9()});let n=await Q9();if(t)try{await J9?.save(n)}catch(e){W9({type:`persistence_error`,error:`Changes are in memory, but browser storage failed: `+e.message})}W9({type:`initialized`,...n})})();onmessage=async({data:e})=>{let{id:t,action:n,args:r={}}=e,i=e=>W9({type:`reply`,id:t,value:e});try{if(await YPe,n===`stop`)return X9?.abort(),q9.abort(),G9.stop(),i(!0);if(n===`snapshot`)return i(await Q9());if(n===`cache_status`)return i(await CI());if(Y9)throw Error(`Wait for the current operation or stop it first.`);Y9=!0,X9=new AbortController,W9({type:`busy`,action:n,cachedOnly:r.cachedOnly===!0});try{let e;if(n===`load`)await G9.load(r,X9.signal),e=G9.device;else if(n===`prompt`)Z9=0,await q9.prompt(r.text),e=await Q9();else if(n===`shell`)e=await K9.bash.exec(r.command,{signal:X9.signal}),await $9();else if(n===`write`)await K9.write(r.path,r.content),e=await $9();else if(n===`new_chat`)q9.reset(),e=await $9();else if(n===`read`)e=await K9.read(r.path);else throw Error(`Unknown action: `+n);i(e)}finally{Y9=!1,X9=void 0,W9({type:`idle`})}}catch(e){W9({type:`reply`,id:t,error:e?.name===`AbortError`?`Stopped.`:String(e?.message??e),errorName:e?.name,errorCode:e?.code})}};