howtocode 0.7.68 → 0.7.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/{chunk-NPD6557W.js → chunk-336TZTEK.js} +1 -1
- package/dist/{chunk-7LAMZWB5.js → chunk-4SK7TRJW.js} +1 -1
- package/dist/chunk-5FIFNXLT.js +10 -0
- package/dist/{chunk-EPNFKO5O.js → chunk-63TDK73J.js} +1 -1
- package/dist/{chunk-LUBZSBUH.js → chunk-CJLCMZKZ.js} +1 -1
- package/dist/{chunk-L4XKIPIG.js → chunk-E2UZLMQH.js} +1 -1
- package/dist/{chunk-XVHYS2UZ.js → chunk-EOZHQRU2.js} +1 -1
- package/dist/chunk-FABEBOGV.js +2 -0
- package/dist/{chunk-KS6FRAVP.js → chunk-GM6T357A.js} +1 -1
- package/dist/chunk-GNV6G3JW.js +201 -0
- package/dist/{chunk-YX2QDCVK.js → chunk-GQYIIDKK.js} +1 -1
- package/dist/{chunk-4KNWFMK6.js → chunk-HGINAX3Z.js} +1 -1
- package/dist/{chunk-O3XEEDMR.js → chunk-I555QJLZ.js} +1 -1
- package/dist/{chunk-6PZTZT6T.js → chunk-LAPEUVNT.js} +1 -1
- package/dist/{chunk-HKABQFBG.js → chunk-MXO4OS67.js} +1 -1
- package/dist/{chunk-W2U7D5UF.js → chunk-RJYOUCLJ.js} +1 -1
- package/dist/chunk-RKIOE6G6.js +141 -0
- package/dist/{chunk-YFJKKWIX.js → chunk-SDU65XW4.js} +1 -1
- package/dist/{chunk-NIDL55H4.js → chunk-SOWZZCT4.js} +1 -1
- package/dist/{chunk-AVNJV7SN.js → chunk-T3KNQOMX.js} +1 -1
- package/dist/{chunk-3H2ECHBB.js → chunk-ULXYWUXZ.js} +1 -1
- package/dist/{chunk-SVONBXW3.js → chunk-ZJL4OEXX.js} +3 -3
- package/dist/{chunk-2GVIOMRN.js → cli-auth.js} +1 -1
- package/dist/main-app.js +7 -7
- package/dist/main.js +10 -0
- package/package.json +2 -2
- package/dist/chunk-465RG5I6.js +0 -10
- package/dist/chunk-HDH5ER4H.js +0 -141
- package/dist/chunk-U3GZBLTM.js +0 -2
- package/dist/chunk-VDUY46W2.js +0 -198
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import{b as ff}from"./chunk-27TRKD65.js";import{t as pf}from"./chunk-ZJL4OEXX.js";import{H as Ye,K as cf,L as Dn,a as Hi}from"./chunk-5FIFNXLT.js";import{a as sr}from"./chunk-UTYFLLSM.js";import{a as qm,b as jn,c as Nn,d as _m,e as Um,f as Mo,g as Bm,h as Br,j as vo}from"./chunk-MVVEYKN6.js";import{a as Ot}from"./chunk-WOT6VMZA.js";import{spawn as w1}from"node:child_process";import{existsSync as C1,readFileSync as R1}from"node:fs";import{join as P1}from"node:path";var B={};Ot(B,{Match:()=>_w});function _w(e,t){return t[e.length]?.(...e)??(()=>{throw Error("Invalid Arguments")})()}var Me={};Ot(Me,{Get:()=>Zi,Reset:()=>DC,Set:()=>jC});var s={};Ot(s,{CodePointCount:()=>tC,Counted:()=>mC,Entries:()=>pC,EntriesRegExp:()=>cC,Every:()=>oC,EveryAll:()=>iC,GraphemeCount:()=>eC,HasPropertyKey:()=>uC,IsArray:()=>Lo,IsBigInt:()=>Fo,IsBoolean:()=>hf,IsClassInstance:()=>Zw,IsConstructor:()=>Ww,IsDeepEqual:()=>Hm,IsEqual:()=>Y,IsFunction:()=>If,IsGreaterEqualThan:()=>$f,IsGreaterThan:()=>Yw,IsInteger:()=>Gm,IsLessEqualThan:()=>bf,IsLessThan:()=>Qw,IsMaxLength:()=>rC,IsMinLength:()=>nC,IsMultipleOf:()=>Xw,IsNull:()=>Ji,IsNumber:()=>Yi,IsObject:()=>Do,IsObjectNotArray:()=>Vw,IsString:()=>Qi,IsSymbol:()=>Jw,IsUndefined:()=>Km,IsUnsafePropertyKey:()=>Sf,IsValueLike:()=>Ef,Keys:()=>Vi,ShiftLeft:()=>Xi,Some:()=>sC,SomeAll:()=>aC,Symbols:()=>fC,Values:()=>dC});function qn(e,t,r){return e>=t&&e<=r}function Uw(e){return e===8205}function df(e){return qn(e,127462,127487)}function Bw(e){return qn(e,65024,65039)}function Gw(e){return qn(e,768,879)||qn(e,6832,6911)||qn(e,7616,7679)||qn(e,65056,65071)}function zi(e){return e>65535?2:1}function lf(e,t){for(;t<e.length;){let r=e.codePointAt(t);if(Gw(r)||Bw(r))t+=zi(r);else break}return t}function Kw(e,t){let r=e.codePointAt(t),n=t+zi(r);for(n=lf(e,n);n<e.length-1&&Uw(e.codePointAt(n));){let o=e.codePointAt(n+1);n+=1+zi(o),n=lf(e,n)}return df(r)&&n<e.length&&df(e.codePointAt(n))&&(n+=zi(e.codePointAt(n))),n}function gf(e){let t=0,r=0;for(;r<e.length;)r=Kw(e,r),t++;return t}function Wi(e){let t=0,r=0,n=0;for(;r<e.length;){let o=e.charCodeAt(r++)>>10;t+=+((n<<8|o)!==13879),n=o}return t}function yf(e,t){return e.length<=t||e.length<=t<<1&&Wi(e)<=t}function xf(e,t){return e.length>=t<<1||e.length>=t&&Wi(e)>=t}function Lo(e){return Array.isArray(e)}function Fo(e){return Y(typeof e,"bigint")}function hf(e){return Y(typeof e,"boolean")}function Ww(e){if(Km(e)||!If(e))return!1;let t=Function.prototype.toString.call(e);return!!(/^class\s/.test(t)||/\[native code\]/.test(t))}function If(e){return Y(typeof e,"function")}function Gm(e){return Number.isInteger(e)}function Ji(e){return Y(e,null)}function Yi(e){return Number.isFinite(e)}function Vw(e){return Do(e)&&!Lo(e)}function Do(e){return Y(typeof e,"object")&&!Ji(e)}function Qi(e){return Y(typeof e,"string")}function Jw(e){return Y(typeof e,"symbol")}function Km(e){return Y(e,void 0)}function Y(e,t){return e===t}function Yw(e,t){return e>t}function Qw(e,t){return e<t}function bf(e,t){return e<=t}function $f(e,t){return e>=t}function Xw(e,t){if(Fo(e)||Fo(t))return BigInt(e)%BigInt(t)===0n;let r=1e-10;if(!Yi(e)||Gm(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))<r}function Zw(e){if(!Do(e))return!1;let t=globalThis.Object.getPrototypeOf(e);return Ji(t)?!1:Y(typeof t.constructor,"function")&&!(Y(t.constructor,globalThis.Object)||Y(t.constructor.name,"Object"))}function Ef(e){return Fo(e)||hf(e)||Ji(e)||Yi(e)||Qi(e)||Km(e)}function eC(e){return gf(e)}function tC(e){return Wi(e)}function rC(e,t){return yf(e,t)}function nC(e,t){return xf(e,t)}function oC(e,t,r){return e.every((n,o)=>o<t||r(n,o))}function iC(e,t,r){let n=!0;return e.forEach((o,i)=>{i>=t&&!r(o,i)&&(n=!1)}),n}function sC(e,t){return e.some((r,n)=>t(r,n))}function aC(e,t){let r=!1;return e.forEach((n,o)=>{t(n,o)&&(r=!0)}),r}function mC(e,t){return e.reduce((r,n,o)=>t(n,o)?++r:r,0)}function Xi(e,t,r){return Y(e.length,0)?r():t(e[0],e.slice(1))}function Sf(e){return Y(e,"__proto__")||Y(e,"constructor")||Y(e,"prototype")}function uC(e,t){return Sf(t)?Object.prototype.hasOwnProperty.call(e,t):t in e}function cC(e){return Vi(e).map(t=>[new RegExp(`^${t}$`),e[t]])}function pC(e){return Object.entries(e)}function Vi(e){return Object.getOwnPropertyNames(e)}function fC(e){return Object.getOwnPropertySymbols(e)}function dC(e){return Object.values(e)}function lC(e,t){if(!Do(t))return!1;let r=Vi(e);return Y(r.length,Vi(t).length)&&r.every(n=>Hm(e[n],t[n]))}function gC(e,t){return Lo(t)&&Y(e.length,t.length)&&e.every((r,n)=>Hm(e[n],t[n]))}function Hm(e,t){return Lo(e)?gC(e,t):Do(e)?lC(e,t):Y(e,t)}var je={};Ot(je,{IsBigInt64Array:()=>PC,IsBigUint64Array:()=>AC,IsBoolean:()=>yC,IsDate:()=>MC,IsFloat32Array:()=>CC,IsFloat64Array:()=>RC,IsInt16Array:()=>SC,IsInt32Array:()=>TC,IsInt8Array:()=>bC,IsMap:()=>FC,IsNumber:()=>xC,IsRegExp:()=>OC,IsSet:()=>vC,IsString:()=>hC,IsTypeArray:()=>IC,IsUint16Array:()=>kC,IsUint32Array:()=>wC,IsUint8Array:()=>$C,IsUint8ClampedArray:()=>EC});function yC(e){return e instanceof Boolean}function xC(e){return e instanceof Number}function hC(e){return e instanceof String}function IC(e){return globalThis.ArrayBuffer.isView(e)}function bC(e){return e instanceof globalThis.Int8Array}function $C(e){return e instanceof globalThis.Uint8Array}function EC(e){return e instanceof globalThis.Uint8ClampedArray}function SC(e){return e instanceof globalThis.Int16Array}function kC(e){return e instanceof globalThis.Uint16Array}function TC(e){return e instanceof globalThis.Int32Array}function wC(e){return e instanceof globalThis.Uint32Array}function CC(e){return e instanceof globalThis.Float32Array}function RC(e){return e instanceof globalThis.Float64Array}function PC(e){return e instanceof globalThis.BigInt64Array}function AC(e){return e instanceof globalThis.BigUint64Array}function OC(e){return e instanceof globalThis.RegExp}function MC(e){return e instanceof globalThis.Date}function vC(e){return e instanceof globalThis.Set}function FC(e){return e instanceof globalThis.Map}var kf=s;var Vt={immutableTypes:!1,maxErrors:8,maxParseErrors:1,maxInstantiationCount:128,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1,unionPrioritySort:!0};function DC(){Vt.immutableTypes=!1,Vt.maxErrors=8,Vt.maxParseErrors=1,Vt.maxInstantiationCount=128,Vt.useAcceleration=!0,Vt.exactOptionalPropertyTypes=!1,Vt.enumerableKind=!1,Vt.correctiveParse=!1,Vt.unionPrioritySort=!0}function jC(e){for(let t of s.Keys(e)){let r=e[t];r!==void 0&&Object.defineProperty(Vt,t,{value:r})}}function Zi(){return Vt}function es(e){return s.HasPropertyKey(e,"~refine")&&s.IsArray(e["~refine"])&&s.Every(e["~refine"],0,t=>s.IsObject(t)&&s.HasPropertyKey(t,"check")&&s.HasPropertyKey(t,"error")&&s.IsFunction(t.check)&&s.IsFunction(t.error))}function yt(e){return s.IsObject(e)&&!s.IsArray(e)}function ln(e){return s.IsBoolean(e)}function L(e){return yt(e)||ln(e)}function ts(e){return s.HasPropertyKey(e,"additionalItems")&&L(e.additionalItems)}function Ut(e){return s.HasPropertyKey(e,"additionalProperties")&&L(e.additionalProperties)}function rs(e){return s.HasPropertyKey(e,"allOf")&&s.IsArray(e.allOf)&&e.allOf.every(t=>L(t))}function Tf(e){return s.HasPropertyKey(e,"$anchor")&&s.IsString(e.$anchor)}function ns(e){return s.HasPropertyKey(e,"anyOf")&&s.IsArray(e.anyOf)&&e.anyOf.every(t=>L(t))}function zm(e){return s.HasPropertyKey(e,"const")}function Gr(e){return s.HasPropertyKey(e,"contains")&&L(e.contains)}function $t(e){return s.HasPropertyKey(e,"default")}function Wm(e){return s.HasPropertyKey(e,"dependencies")&&s.IsObject(e.dependencies)&&Object.values(e.dependencies).every(t=>L(t)||s.IsArray(t)&&t.every(r=>s.IsString(r)))}function Vm(e){return s.HasPropertyKey(e,"dependentRequired")&&s.IsObject(e.dependentRequired)&&Object.values(e.dependentRequired).every(t=>s.IsArray(t)&&t.every(r=>s.IsString(r)))}function os(e){return s.HasPropertyKey(e,"dependentSchemas")&&s.IsObject(e.dependentSchemas)&&Object.values(e.dependentSchemas).every(t=>L(t))}function Kr(e){return s.HasPropertyKey(e,"$dynamicAnchor")&&s.IsString(e.$dynamicAnchor)}function is(e){return s.HasPropertyKey(e,"$dynamicRef")&&s.IsString(e.$dynamicRef)}function ss(e){return s.HasPropertyKey(e,"else")&&L(e.else)}function Jm(e){return s.HasPropertyKey(e,"enum")&&s.IsArray(e.enum)}function Ym(e){return s.HasPropertyKey(e,"exclusiveMaximum")&&(s.IsNumber(e.exclusiveMaximum)||s.IsBigInt(e.exclusiveMaximum))}function wr(e){return s.HasPropertyKey(e,"exclusiveMinimum")&&(s.IsNumber(e.exclusiveMinimum)||s.IsBigInt(e.exclusiveMinimum))}function jo(e){return s.HasPropertyKey(e,"format")&&s.IsString(e.format)}function ut(e){return s.HasPropertyKey(e,"$id")&&s.IsString(e.$id)}function as(e){return s.HasPropertyKey(e,"if")&&L(e.if)}function gn(e){return s.HasPropertyKey(e,"items")&&(L(e.items)||s.IsArray(e.items)&&e.items.every(t=>L(t)))}function ms(e){return gn(e)&&s.IsArray(e.items)}function Qm(e){return s.HasPropertyKey(e,"maximum")&&(s.IsNumber(e.maximum)||s.IsBigInt(e.maximum))}function Xm(e){return s.HasPropertyKey(e,"maxContains")&&s.IsNumber(e.maxContains)}function No(e){return s.HasPropertyKey(e,"maxItems")&&s.IsNumber(e.maxItems)}function Zm(e){return s.HasPropertyKey(e,"maxLength")&&s.IsNumber(e.maxLength)}function eu(e){return s.HasPropertyKey(e,"maxProperties")&&s.IsNumber(e.maxProperties)}function Cr(e){return s.HasPropertyKey(e,"minimum")&&(s.IsNumber(e.minimum)||s.IsBigInt(e.minimum))}function yn(e){return s.HasPropertyKey(e,"minContains")&&s.IsNumber(e.minContains)}function xn(e){return s.HasPropertyKey(e,"minItems")&&s.IsNumber(e.minItems)}function qo(e){return s.HasPropertyKey(e,"minLength")&&s.IsNumber(e.minLength)}function _o(e){return s.HasPropertyKey(e,"minProperties")&&s.IsNumber(e.minProperties)}function tu(e){return s.HasPropertyKey(e,"multipleOf")&&(s.IsNumber(e.multipleOf)||s.IsBigInt(e.multipleOf))}function us(e){return s.HasPropertyKey(e,"not")&&L(e.not)}function cs(e){return s.HasPropertyKey(e,"oneOf")&&s.IsArray(e.oneOf)&&e.oneOf.every(t=>L(t))}function Uo(e){return s.HasPropertyKey(e,"pattern")&&(s.IsString(e.pattern)||e.pattern instanceof RegExp)}function _n(e){return s.HasPropertyKey(e,"patternProperties")&&s.IsObject(e.patternProperties)&&Object.values(e.patternProperties).every(t=>L(t))}function hn(e){return s.HasPropertyKey(e,"prefixItems")&&s.IsArray(e.prefixItems)&&e.prefixItems.every(t=>L(t))}function Un(e){return s.HasPropertyKey(e,"properties")&&s.IsObject(e.properties)&&Object.values(e.properties).every(t=>L(t))}function ps(e){return s.HasPropertyKey(e,"propertyNames")&&(s.IsObject(e.propertyNames)||L(e.propertyNames))}function NC(e){return s.HasPropertyKey(e,"$recursiveAnchor")&&s.IsBoolean(e.$recursiveAnchor)}function Bo(e){return NC(e)&&s.IsEqual(e.$recursiveAnchor,!0)}function fs(e){return s.HasPropertyKey(e,"$recursiveRef")&&s.IsString(e.$recursiveRef)}function ds(e){return s.HasPropertyKey(e,"$ref")&&s.IsString(e.$ref)}function In(e){return s.HasPropertyKey(e,"required")&&s.IsArray(e.required)&&e.required.every(t=>s.IsString(t))}function ls(e){return s.HasPropertyKey(e,"then")&&L(e.then)}function ru(e){return s.HasPropertyKey(e,"type")&&(s.IsString(e.type)||s.IsArray(e.type)&&e.type.every(t=>s.IsString(t)))}function Hr(e){return s.HasPropertyKey(e,"uniqueItems")&&s.IsBoolean(e.uniqueItems)}function Go(e){return s.HasPropertyKey(e,"unevaluatedItems")&&L(e.unevaluatedItems)}function Ko(e){return s.HasPropertyKey(e,"unevaluatedProperties")&&L(e.unevaluatedProperties)}var ct=class{constructor(){let t=new Set,r=new Set;this.stack=[{indices:t,keys:r}]}Push(){let t=new Set,r=new Set;return this.stack.push({indices:t,keys:r}),!0}Pop(){return this.stack.pop(),!0}AddIndex(t){return this.GetIndices().add(t),!0}AddKey(t){return this.GetKeys().add(t),!0}GetIndices(){return this.stack[this.stack.length-1].indices}GetKeys(){return this.stack[this.stack.length-1].keys}Merge(t){for(let r of t)r.GetIndices().forEach(n=>this.GetIndices().add(n)),r.GetKeys().forEach(n=>this.GetKeys().add(n));return!0}},et=class extends ct{constructor(){super(),this.errors=[]}AtCapacity(){return this.errors.length>=Me.Get().maxErrors}AddError(t,r,n,o){return this.AddErrorObject({keyword:t,schemaPath:r,instancePath:n,params:o})}AddErrors(t){return t.forEach(r=>this.AddErrorObject(r)),!1}GetErrors(){return this.errors}AddErrorObject(t){return this.AtCapacity()||this.errors.push(t),!1}};function wf(e,t,r,n){return s.Every(r["~refine"],0,(o,i)=>o.check(n))}function Cf(e,t,r,n,o,i){return s.EveryAll(o["~refine"],0,(a,m)=>a.check(i)||t.AddError("~refine",r,n,{index:m,message:a.error(i)}))}var Ho="urn:typebox:root";function Rr(e,t){return URL.canParse(e,t)?new URL(e,t):s.IsEqual(t,Ho)?new URL(`${t}:${e}`):new URL(`${t.slice(0,t.lastIndexOf(":"))}:${e}`)}function Gn(e,t){let r=yt(t)&&ut(t)?Rr(t.$id,Ho).href:Ho;return{context:e,schema:t,lexicalSchema:t,lexicalBase:r,resourceBase:r,referenceBase:r,ids:[],useResourceBaseForReference:!0,recursiveAnchor:void 0,dynamicAnchors:[],resourceEntries:new Map,pendingResource:!0,enteredResource:!1}}function nu(e,t,r=!0){if(ln(t))return e;if(Array.isArray(t))return t.reduce((o,i)=>nu(o,i,!1),e);if(!yt(t)||!r&&ut(t))return e;let n=!r&&Kr(t)?[...e,t]:e;return Object.keys(t).reduce((o,i)=>nu(o,t[i],!1),n)}function zo(e,t){return e.resourceEntries.get(t)}function Rf(e,t){return e.enteredResource||zo(e,t)!==void 0}function qC(e){return!/^[A-Za-z][A-Za-z0-9+.-]*:/.test(e.$id)}function _C(e,t){return ut(t)?[...e.ids,t]:e.ids}function UC(e,t){return e.recursiveAnchor??(Bo(t)?t:void 0)}function BC(e,t){let r=ut(t)?nu(e.dynamicAnchors,t):e.dynamicAnchors;return Kr(t)?[...r,t]:r}function GC(e,t){return ut(t)?!1:e.pendingResource}function Pf(e,t){let r=zo(e,t);return r?r.base:ut(t)?Rr(t.$id,e.lexicalBase).href:e.lexicalBase}function Af(e,t){let r=zo(e,t);return r?r.base:ut(t)&&e.pendingResource?Rr(t.$id,e.resourceBase).href:e.resourceBase}function Of(e,t){return ut(t)?!qC(t):e.useResourceBaseForReference}function KC(e,t){let r=Rf(e,t),n=Of(e,t);return r||n?Af(e,t):Pf(e,t)}function HC(e,t){let r=zo(e,t);return r?r.root:ut(t)?t:e.lexicalSchema}function zC(e,t){return yt(t)&&(ut(t)||Kr(t)||s.IsUndefined(e.recursiveAnchor)&&Bo(t)||!s.IsUndefined(zo(e,t)))}function Kn(e,t){return zC(e,t)?{...e,ids:_C(e,t),dynamicAnchors:BC(e,t),recursiveAnchor:UC(e,t),pendingResource:GC(e,t),lexicalBase:Pf(e,t),resourceBase:Af(e,t),useResourceBaseForReference:Of(e,t),referenceBase:KC(e,t),lexicalSchema:HC(e,t),enteredResource:Rf(e,t)}:e}function Mf(e){return gn(e)&&s.IsArray(e.items)}function vf(e,t,r,n){return Mf(r)?s.Every(n,0,(i,a)=>s.IsLessThan(a,r.items.length)||Mt(e,t,r.additionalItems,i)&&t.AddIndex(a)):!0}function Ff(e,t,r,n,o,i){return Mf(o)?s.Every(i,0,(m,c)=>{let p=`${r}/additionalItems`,f=`${n}/${c}`;return s.IsLessThan(c,o.items.length)||vt(e,t,p,f,o.additionalItems,m)&&t.AddIndex(c)}):!0}function Et(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function zr(e){return new RegExp(e,"u")}function WC(e){return`^${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}$`}function Lf(e){let t=[];return _n(e)&&t.push(...s.Keys(e.patternProperties)),Un(e)&&t.push(...s.Keys(e.properties).map(WC)),s.IsEqual(t.length,0)?"(?!)":`(${t.join("|")})`}function Df(e,t,r,n){let o=zr(Lf(r));return s.Every(s.Keys(n),0,(a,m)=>o.test(a)||Mt(e,t,r.additionalProperties,n[a])&&t.AddKey(a))}function jf(e,t,r,n,o,i){let a=zr(Lf(o)),m=[];return s.EveryAll(s.Keys(i),0,(p,f)=>{let d=`${r}/additionalProperties`,g=`${n}/${Et(p)}`,y=a.test(p)||vt(e,t,d,g,o.additionalProperties,i[p])&&t.AddKey(p);return y||m.push(p),y})||t.AddError("additionalProperties",r,n,{additionalProperties:m})}function Nf(e,t,r,n){let o=r.allOf.reduce((i,a)=>{let m=new ct;return Q(e,m,a,n)?[...i,m]:i},[]);return s.IsEqual(o.length,r.allOf.length)&&t.Merge(o)}function qf(e,t,r,n,o,i){let a=[],m=o.allOf.reduce((p,f,d)=>{let g=`${r}/allOf/${d}`,y=new et,I=ce(e,y,g,n,f,i);return I||a.push(y),I?[...p,y]:p},[]),c=s.IsEqual(m.length,o.allOf.length)&&t.Merge(m);return c||a.forEach(p=>t.AddErrors(p.GetErrors())),c}function _f(e,t,r,n){let o=r.anyOf.reduce((i,a)=>{let m=new ct;return Q(e,m,a,n)?[...i,m]:i},[]);return s.IsGreaterThan(o.length,0)&&t.Merge(o)}function Uf(e,t,r,n,o,i){let a=[],m=o.anyOf.reduce((p,f,d)=>{let g=new et,y=`${r}/anyOf/${d}`,I=ce(e,g,y,n,f,i);return I||a.push(g),I?[...p,g]:p},[]),c=s.IsGreaterThan(m.length,0)&&t.Merge(m);return c||a.forEach(p=>t.AddErrors(p.GetErrors())),c||t.AddError("anyOf",r,n,{})}function su(e,t,r,n){return r}function Bf(e,t,r,n,o,i){return su(e,t,o,i)||t.AddError("boolean",r,n,{})}function au(e,t,r,n){return s.IsValueLike(r.const)?s.IsEqual(n,r.const):s.IsDeepEqual(n,r.const)}function Gf(e,t,r,n,o,i){return au(e,t,o,i)||t.AddError("const",r,n,{allowedValue:o.const})}function VC(e){return!(yn(e)&&s.IsEqual(e.minContains,0))}function mu(e,t,r,n){return VC(r)?!s.IsEqual(n.length,0)&&s.SomeAll(n,(o,i)=>Q(e,t,r.contains,o)&&t.AddIndex(i)):!0}function Kf(e,t,r,n,o,i){return mu(e,t,o,i)||t.AddError("contains",r,n,{minContains:1})}function Hf(e,t,r,n){let o=s.IsEqual(s.Keys(n).length,0),i=s.Every(s.Entries(r.dependencies),0,([a,m])=>!s.HasPropertyKey(n,a)||(s.IsArray(m)?m.every(c=>s.HasPropertyKey(n,c)):Q(e,t,m,n)));return o||i}function zf(e,t,r,n,o,i){let a=s.IsEqual(s.Keys(i).length,0),m=s.EveryAll(s.Entries(o.dependencies),0,([c,p])=>{let f=`${r}/dependencies/${Et(c)}`;return!s.HasPropertyKey(i,c)||(s.IsArray(p)?p.every(d=>s.HasPropertyKey(i,d)||t.AddError("dependencies",r,n,{property:c,dependencies:p})):ce(e,t,f,n,p,i))});return a||m}function Wf(e,t,r,n){let o=s.IsEqual(s.Keys(n).length,0),i=s.Every(s.Entries(r.dependentRequired),0,([a,m])=>!s.HasPropertyKey(n,a)||m.every(c=>s.HasPropertyKey(n,c)));return o||i}function Vf(e,t,r,n,o,i){let a=s.IsEqual(s.Keys(i).length,0),m=s.EveryAll(s.Entries(o.dependentRequired),0,([c,p])=>!s.HasPropertyKey(i,c)||s.EveryAll(p,0,f=>s.HasPropertyKey(i,f)||t.AddError("dependentRequired",r,n,{property:c,dependencies:p})));return a||m}function Jf(e,t,r,n){let o=s.IsEqual(s.Keys(n).length,0),i=s.Every(s.Entries(r.dependentSchemas),0,([a,m])=>!s.HasPropertyKey(n,a)||Q(e,t,m,n));return o||i}function Yf(e,t,r,n,o,i){let a=s.IsEqual(s.Keys(i).length,0),m=s.EveryAll(s.Entries(o.dependentSchemas),0,([c,p])=>{let f=`${r}/dependentSchemas/${Et(c)}`;return!s.HasPropertyKey(i,c)||ce(e,t,f,n,p,i)});return a||m}var Bt={};Ot(Bt,{DynamicRef:()=>TR,RecursiveRef:()=>ER,Ref:()=>bR});var mr={};Ot(mr,{Delete:()=>XC,Get:()=>YC,Has:()=>JC,Indices:()=>Vo,Set:()=>QC});function Xf(e){throw Error(e)}function Qf(){Xf("Pointer contains unsafe property key")}function uu(){Xf("Cannot set value")}function Vo(e){let t=e.split("/").map(r=>r.replace(/~1/g,"/").replace(/~0/g,"~"));return t[0]===""?t.slice(1):t}function JC(e,t){let r=e;for(let n of Vo(t)){if(!s.IsObject(r)||!s.HasPropertyKey(r,n))return!1;r=r[n]}return!0}function YC(e,t){let r=e;for(let n of Vo(t)){if(!s.IsObject(r)||s.IsUnsafePropertyKey(n))return;r=r[n]}return r}function Zf(e,t,r){let n=e;for(let o of t)s.IsUnsafePropertyKey(o)&&Qf(),n=s.IsObject(n)?n[o]:void 0;return s.IsUnsafePropertyKey(r)&&Qf(),s.IsObject(n)||uu(),n}function QC(e,t,r){let n=Vo(t),o=n.pop();return s.IsUndefined(o)&&uu(),Zf(e,n,o)[o]=r,e}function XC(e,t){let r=Vo(t),n=r.pop();s.IsUndefined(n)&&uu();let o=Zf(e,r,n);return s.IsArray(o)&&/^(0|[1-9]\d*)$/.test(n)?o.splice(Number(n),1):delete o[n],e}function fu(e,t){return yt(e)&&ut(e)?Rr(e.$id,t.href):t}function du(e){return Rr(e,Ho)}function cu(e){return e.href.split("#")[0]}function ZC(e,t,r){return pu(e,du(t),r)}function eR(e,t){return t.$ref.startsWith("#")||e.enteredResource?e.lexicalSchema:e.schema}function tR(e){return e.startsWith("#/")}function ed(e,t){if(s.IsObject(e)&&Kr(e)&&s.IsEqual(e.$dynamicAnchor,t))return e;if(s.IsObject(e))for(let r of s.Keys(e)){let n=ed(e[r],t);if(n)return n}}function pu(e,t,r){if(s.IsEqual(e,r))return t.href;let n=fu(e,t);if(s.IsArray(e))for(let o of e){let i=pu(o,n,r);if(!s.IsUndefined(i))return i}else if(s.IsObject(e))for(let o of s.Keys(e)){let i=pu(e[o],n,r);if(!s.IsUndefined(i))return i}}function td(e,t){if(t.href.endsWith("#"))return e;if(!t.hash.startsWith("#"))return;let r=decodeURIComponent(t.hash.slice(1));if(r.startsWith("/"))return mr.Get(e,r)}function rR(e,t,r){if(!ut(e))return;if(s.IsEqual(e.$id,r.hash))return e;let n=new URL(r.href,t.href);if(s.IsEqual(t.pathname,n.pathname))return r.hash.startsWith("#")?td(e,r):e}function nR(e,t,r){if(!Tf(e))return;let n=new URL(`#${e.$anchor}`,t.href),o=new URL(r.href,t.href);return s.IsEqual(n.href,o.href)?e:void 0}function oR(e,t,r){if(!Kr(e))return;let n=new URL(`#${e.$dynamicAnchor}`,t.href),o=new URL(r.href,t.href);return s.IsEqual(n.href,o.href)?e:void 0}function iR(e,t,r){if(yt(e))return rR(e,t,r)??nR(e,t,r)??oR(e,t,r)??td(e,r)}function sR(e,t,r){if(s.IsArray(e))return e.reduce((n,o)=>{let i=gs(o,t,r);return s.IsUndefined(i)?n:i},void 0)}function aR(e,t,r){if(s.IsObject(e))return s.Keys(e).reduce((n,o)=>{if(s.IsEqual(o,"const")||s.IsEqual(o,"enum"))return n;let i=gs(e[o],t,r);return s.IsUndefined(i)?n:i},void 0)}function gs(e,t,r){let n=fu(e,t);return iR(e,n,r)??sR(e,n,r)??aR(e,n,r)}function mR(e,t,r,n){let o=ys(e,t,r,n);return yt(o)&&ut(o)?o:void 0}function uR(e,t,r){if(!t.$ref.startsWith("#")||!yt(e.schema)||s.HasPropertyKey(e.schema,"$schema"))return;let n=ZC(e.lexicalSchema,e.referenceBase,r);if(!(s.IsUndefined(n)||s.IsEqual(n,e.referenceBase)))return{target:r,base:n,root:e.lexicalSchema}}function cR(e,t,r){let n=e.context[t];if(yt(n))return{target:r,base:t,root:n}}function pR(e,t,r,n,o){let i=o?cR(e,n,r):void 0;return s.IsUndefined(i)?uR(e,t,r):i}function fR(e,t,r){if(ut(r))return;let n=mR(e.context,e.schema,e.referenceBase,t);if(!(!n||e.ids.includes(n)))return{resource:n}}function dR(e,t){return s.HasPropertyKey(e,t)?e[t]:void 0}function lR(e,t,r){return gs(e,t,r)}function gR(e,t,r){let n=cu(r);if(!s.HasPropertyKey(e,n)||s.IsEqual(n,cu(t)))return;let o=e[n],i=fu(o,new URL(n));return s.IsEqual(r.hash,"")?o:gs(o,i,r)}function ys(e,t,r,n){let o=du(r),i=Rr(n,o.href);return dR(e,n)??lR(t,o,i)??gR(e,o,i)}function yR(e,t){if(!t)return e;let r=new Map(e.resourceEntries);return r.set(t.target,{base:t.base,root:t.root}),{...e,resourceEntries:r}}function xR(e,t){return t?Kn(e,t.resource):e}function rd(e,t,r,n){let o=yR({...e,pendingResource:t},r);return xR(o,n)}function hR(e,t,r){let n=cu(Rr(t.$ref,e.referenceBase)),o=!s.IsEqual(n,e.resourceBase),i=pR(e,t,r,n,o),a=o?fR(e,n,r):void 0;return{schema:r,stack:rd(e,!0,i,a)}}function IR(e,t){return{schema:t,stack:rd(e,!s.IsUndefined(t))}}function bR(e,t){let r=ys(e.context,eR(e,t),e.referenceBase,t.$ref);return yt(r)?hR(e,t,r):IR(e,r)}function $R(e){return yt(e.lexicalSchema)&&Bo(e.lexicalSchema)}function ER(e,t){let r=$R(e)?e.recursiveAnchor:e.lexicalSchema;return ys(e.context,r,e.lexicalBase,t.$recursiveRef)}function nd(e,t){return Rr(t.$dynamicRef,du(e.lexicalBase).href).hash}function od(e,t){return e.dynamicAnchors.find(r=>s.IsEqual(r.$dynamicAnchor,t))??ed(e.schema,t)}function SR(e,t,r){if(!yt(r)||!Kr(r))return r;let n=nd(e,t);return tR(n)?r:od(e,r.$dynamicAnchor)}function kR(e,t){let r=nd(e,t);return od(e,decodeURIComponent(r.slice(1)))}function TR(e,t){let r=t.$dynamicRef.startsWith("#")?e.lexicalSchema:e.schema,n=ys(e.context,r,e.lexicalBase,t.$dynamicRef);return s.IsUndefined(n)?kR(e,t):SR(e,t,n)}function id(e,t,r,n){let o=Bt.DynamicRef(e,r)??!1,i=o?{...e,pendingResource:!0}:e;return L(o)&&Q(i,t,o,n)}function sd(e,t,r,n,o,i){let a=Bt.DynamicRef(e,o)??!1,m=a?{...e,pendingResource:!0}:e;return L(a)&&ce(m,t,r,n,a,i)}function yu(e,t,r,n){return s.Some(r.enum,o=>s.IsValueLike(o)?s.IsEqual(n,o):s.IsDeepEqual(n,o))}function ad(e,t,r,n,o,i){return yu(e,t,o,i)||t.AddError("enum",r,n,{allowedValues:o.enum})}function xu(e,t,r,n){return s.IsLessThan(n,r.exclusiveMaximum)}function md(e,t,r,n,o,i){return xu(e,t,o,i)||t.AddError("exclusiveMaximum",r,n,{comparison:"<",limit:o.exclusiveMaximum})}function hu(e,t,r,n){return s.IsGreaterThan(n,r.exclusiveMinimum)}function ud(e,t,r,n,o,i){return hu(e,t,o,i)||t.AddError("exclusiveMinimum",r,n,{comparison:">",limit:o.exclusiveMinimum})}var Xo={};Ot(Xo,{Clear:()=>Dd,Entries:()=>l0,Get:()=>x0,Has:()=>y0,IsDate:()=>zn,IsDateTime:()=>xs,IsDuration:()=>hs,IsEmail:()=>Is,IsHostname:()=>Cs,IsIPv4:()=>As,IsIPv6:()=>Os,IsIdnEmail:()=>Rs,IsIdnHostname:()=>Ps,IsIri:()=>vs,IsIriReference:()=>Ms,IsJsonPointer:()=>Ls,IsJsonPointerUriFragment:()=>Fs,IsRegex:()=>Ds,IsRelativeJsonPointer:()=>js,IsTime:()=>Wn,IsUri:()=>_s,IsUriReference:()=>Ns,IsUriTemplate:()=>qs,IsUrl:()=>Us,IsUuid:()=>Bs,Reset:()=>jd,Set:()=>g0,Test:()=>h0});var wR=[0,31,28,31,30,31,30,31,31,30,31,30,31],CR=/^(\d\d\d\d)-(\d\d)-(\d\d)$/;function RR(e){return e%4===0&&(e%100!==0||e%400===0)}function zn(e){let t=CR.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],o=+t[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&RR(r)?29:wR[n])}var PR=/^(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:([Zz])|([+-])(\d\d):(\d\d))?$/;function Wn(e,t=!0){let r=PR.exec(e);if(!r||t&&!r[4]&&!r[5])return!1;let n=+r[1],o=+r[2],i=+r[3];if(n>23||o>59||i>60)return!1;if(r[5]){let f=+r[6],d=+r[7];if(f>23||d>59)return!1}if(i<60)return!0;let a=r[5]==="-"?-1:1,m=+(r[6]||0),c=+(r[7]||0);return((n*60+o-a*(m*60+c))%1440+1440)%1440===1439}var AR=/^(?:\[!?(?:(?!\.{1,2}[/\]])[A-Za-z._][A-Za-z._0-9+-]{0,13}(?:\/(?!\.{1,2}[/\]])[A-Za-z._][A-Za-z._0-9+-]{0,13})*|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])\](?:\[!?[a-z_][a-z_0-9-]*=[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*\])*|(?:\[!?[a-z_][a-z_0-9-]*=[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*\])*)$/;function xs(e){let t=e.indexOf("["),r=t===-1?e:e.slice(0,t);if(t!==-1&&!AR.test(e.slice(t)))return!1;let n=r.split(/T/i);return n.length===2&&zn(n[0])&&Wn(n[1])}var OR=/^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 hs(e){return OR.test(e)}var MR=/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[^"\\]|\\[\x20-\x7e])*")@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*|\[(?:IPv6:[a-f0-9:]+|(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?:\.(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3})\])$/i;function Is(e){return MR.test(e)}var cd=/^(?!-).*(?<!-)$/,pd=/^(?!..--)/,fd=/^[a-zA-Z0-9-]*$/,pG=new RegExp("^\\p{ASCII}*$","u"),Vn=/[^\p{ASCII}]/u;var vR=/[0-9]/,dd=/[\u{0660}-\u{0669}]/u,FR=/[\u{06f0}-\u{06f9}]/u,LR=/[\u{002e}\u{002c}\u{003a}\u{002f}]/u,DR=/[\u{002d}\u{002b}]/u,Iu=new RegExp("\\p{Mn}","u"),jR=new RegExp("\\p{Mc}","u"),fG=new RegExp("\\p{Me}","u"),ld=/[\p{Mn}\p{Mc}\p{Me}]/u,bu=new RegExp("\\p{L}","u"),NR=new RegExp("\\p{Nd}","u"),gd=new RegExp("\\p{Script=Greek}","u"),bs=new RegExp("\\p{Script=Hebrew}","u"),yd=/[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u,xd=/[\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Mandaic}]/u,$u=/[\u{094d}\u{09cd}\u{0a4d}\u{0acd}\u{0b4d}\u{0bcd}\u{0c4d}\u{0ccd}\u{0d3b}\u{0d3c}\u{0d4d}\u{0dca}\u{1b44}\u{1baa}\u{1bab}\u{a9c0}\u{11046}\u{1107f}\u{110b9}\u{11133}\u{11134}\u{111c0}\u{11235}\u{1134d}\u{11442}\u{114c2}\u{115bf}\u{1163f}\u{116b6}\u{11c3f}\u{11d44}\u{11d45}]/u,hd=/[\u{0640}\u{07fa}\u{302e}\u{302f}\u{3031}\u{3032}\u{3033}\u{3034}\u{3035}\u{303b}]/u,qR=/[\u{00b7}\u{0375}\u{05f3}\u{05f4}\u{200c}\u{200d}\u{30fb}]/u,_R=/[\u{00df}\u{03c2}\u{06fd}\u{06fe}\u{0f0b}\u{3007}]/u,Id=new RegExp([vR,FR].map(e=>e.source).join("|"),"u"),bd=new RegExp([bu,DR,LR,NR,Iu,jR,qR,_R].map(e=>e.source).join("|"),"u");function $d(e){return cd.test(e)&&pd.test(e)&&fd.test(e)}var Yt=36,Yo=1,Qo=26,BR=38,GR=700,Sd=72,kd=128;function Eu(){throw null}function $s(e){return e.toLowerCase().startsWith("xn--")}function Td(e,t,r){e=r?Math.floor(e/GR):e>>1,e+=Math.floor(e/t);let n=0;for(;e>(Yt-Yo)*Qo>>1;)e=Math.floor(e/(Yt-Yo)),n+=Yt;return n+Math.floor((Yt-Yo+1)*e/(e+BR))}function Es(e){let t=[],r=kd,n=0,o=Sd,i=e.lastIndexOf("-");if(i>0)for(let m=0;m<i;m++){let c=e.charCodeAt(m);c>=128&&Eu(),t.push(c)}let a=i<0?0:i+1;for(;a<e.length;){let m=n,c=1,p=Yt;for(;;){a>=e.length&&Eu();let d=e.charCodeAt(a++),g;d>=97&&d<=122?g=d-97:d>=48&&d<=57?g=d-48+26:Eu(),n+=g*c;let y=p<=o?Yo:p>=o+Qo?Qo:p-o;if(g<y)break;c*=Yt-y,p+=Yt}let f=t.length+1;o=Td(n-m,f,m===0),r+=Math.floor(n/f),n%=f,t.splice(n,0,r),n++}return String.fromCodePoint(...t)}function Ed(e){return e<26?String.fromCharCode(e+97):String.fromCharCode(e-26+48)}var KR=new RegExp(Vn.source,"gu");function wd(e){let t=e.replace(KR,""),r=t.length,n=r>0?[t,"-"]:[],o=Array.from(e,p=>p.codePointAt(0)),i=kd,a=0,m=Sd,c=r;for(;c<o.length;){let p=1/0;for(let f of o)f>=i&&f<p&&(p=f);a+=(p-i)*(c+1),i=p;for(let f of o)if(f<i&&a++,f===i){let d=a;for(let g=Yt;;g+=Yt){let y=g<=m?Yo:g>=m+Qo?Qo:g-m;if(d<y)break;let I=y+(d-y)%(Yt-y);n.push(Ed(I)),d=Math.floor((d-y)/(Yt-y))}n.push(Ed(d)),m=Td(a,c+1,c===r),a=0,c++}a++,i++}return n.join("")}var HR=/^(?:R|AL|AN|EN|ES|CS|ET|ON|BN|NSM)$/,Cd=/^(?:L|EN|ES|CS|ET|ON|BN|NSM)$/,zR=/^(?:R|AL|AN)$/;function Rd(e){if($s(e))try{return Ss(Es(e.slice(4).toLowerCase()))}catch{return!1}return Ss(e)}function Pd(e){let t=String.fromCodePoint(e);return Id.test(t)?"EN":dd.test(t)?"AN":Iu.test(t)?"NSM":bs.test(t)?"R":xd.test(t)?"AL":bu.test(t)?"L":"ON"}function Ss(e){for(let t of e)if(zR.test(Pd(t.codePointAt(0))))return!0;return!1}function ks(e){let t=!1,r=Cd,n=!1,o=!1,i=!0;for(let a of e){let m=Pd(a.codePointAt(0));if(i){if(m!=="L"&&m!=="R"&&m!=="AL")return!1;t=m==="R"||m==="AL",r=t?HR:Cd,i=!1}if(!r.test(m))return!1;m==="EN"?n=!0:m==="AN"&&(o=!0)}return!(t&&n&&o)}function WR(e){return Vn.test(e)&&wd(e).length+4>63}function VR(e){return e[0]==="-"||e[e.length-1]==="-"?!0:e.slice(2).join("").startsWith("--")}function Ts(e){if(WR(e)||Ss(e)&&!ks(e))return!1;let t=[...e],r=t.map(i=>i.codePointAt(0)),n=r.length;if(VR(t)||ld.test(t[0]))return!1;let o=!1;for(let i=0;i<n;i++){let a=r[i],m=t[i];if(hd.test(m)||!bd.test(m))return!1;yd.test(m)&&(o=!0);let c=r[i-1],p=r[i+1];switch(a){case 183:if(c!==108||p!==108)return!1;break;case 885:if(!p||!gd.test(t[i+1]))return!1;break;case 1523:case 1524:if(!c||!bs.test(t[i-1]))return!1;break;case 8204:if(!c||c<128&&!$u.test(t[i-1]))return!1;break;case 8205:if(!c||!$u.test(t[i-1]))return!1;break;case 12539:break}}return!(e.includes("\u30FB")&&!o)}function ws(e){if(!$s(e))return!1;try{let t=e.slice(4).toLowerCase();if(t.lastIndexOf("-")===0)return!1;let r=Es(t);return Vn.test(r)?Ts(r):!1}catch{return!1}}function JR(e){return e.length>0&&e.length<=63}function YR(e){return JR(e)&&(ws(e)||$d(e))}function vd(e){return e.length===0||e.length>253||e.charCodeAt(e.length-1)===46?!1:e.split(".").every(t=>YR(t))}function QR(e){return e.length>0&&e.length<=63}function XR(e){return QR(e)&&(ws(e)||Ts(e))}function ZR(e){return e.replace(/[\uff01-\uff5e]/g,t=>String.fromCharCode(t.charCodeAt(0)-65248)).normalize("NFC").replace(/[\u00ad\u034f\u180b-\u180d\u200b\ufe00-\ufe0f\u{e0100}-\u{e01ef}]/gu,"").replace(/[\u002E\u3002\uFF0E\uFF61]/g,".")}function Fd(e){if(e.length===0||e.includes(" "))return!1;let t=ZR(e);if(t.length>253)return!1;let r=t.split("."),n=r.some(o=>Rd(o));return r.every(o=>XR(o)&&(!n||ks(o)))}function Cs(e){return vd(e)}var e0=/^(?:[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+(?:\.[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+)*|"(?:[^"\\]|\\.)*")@[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-)(?:\.[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-))*$/iu;function Rs(e){return e0.test(e.normalize("NFC"))}function Ps(e){return Fd(e)}var t0=/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;function As(e){return t0.test(e)}var r0=/^(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:)?[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)$/i;function Os(e){return r0.test(e)}var n0=/[\x00-\x20\x7F\\]|%(?![0-9a-fA-F]{2})/,o0=/^[a-zA-Z][a-zA-Z0-9+\-.]*\/\//;function Ms(e){return!n0.test(e)&&!o0.test(e)&&URL.canParse(e,"http://example.com")}var i0=/[\x00-\x20<>\^`{|}\\]/,s0=/%(?![0-9a-fA-F]{2})/;function vs(e){return i0.test(e)||s0.test(e)?!1:URL.canParse(e)}var a0=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;function Fs(e){return a0.test(e)}var m0=/^(?:\/(?:[^~/]|~0|~1)*)*$/;function Ls(e){return m0.test(e)}function Ds(e){try{return new RegExp(e,"u"),!0}catch{return!1}}var u0=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;function js(e){return u0.test(e)}var c0=/^(?:[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?)(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function Ns(e){return c0.test(e)}var p0=/^(?:(?:[^\x00-\x20"<>%\\^`{|}\x7f]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?)*\})*$/i;function qs(e){return p0.test(e)}var f0=/^[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function _s(e){return f0.test(e)}function Us(e){return URL.canParse(e)}var d0=/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;function Bs(e){return d0.test(e)}var le=new Map;function Dd(){le.clear()}function l0(){return[...le.entries()]}function g0(e,t){le.set(e,t)}function y0(e){return le.has(e)}function x0(e){return le.get(e)}function h0(e,t){return le.get(e)?.(t)??!0}function jd(){Dd(),le.set("date-time",xs),le.set("date",zn),le.set("duration",hs),le.set("email",Is),le.set("hostname",Cs),le.set("idn-email",Rs),le.set("idn-hostname",Ps),le.set("ipv4",As),le.set("ipv6",Os),le.set("iri-reference",Ms),le.set("iri",vs),le.set("json-pointer-uri-fragment",Fs),le.set("json-pointer",Ls),le.set("regex",Ds),le.set("relative-json-pointer",js),le.set("time",Wn),le.set("uri-reference",Ns),le.set("uri-template",qs),le.set("uri",_s),le.set("url",Us),le.set("uuid",Bs)}jd();function ku(e,t,r,n){return Xo.Test(r.format,n)}function Nd(e,t,r,n,o,i){return ku(e,t,o,i)||t.AddError("format",r,n,{format:o.format})}function qd(e,t,r,n){let o=ls(r)?r.then:!0,i=ss(r)?r.else:!0;return Q(e,t,r.if,n)?Q(e,t,o,n):Q(e,t,i,n)}function _d(e,t,r,n,o,i){let a=ls(o)?o.then:!0,m=ss(o)?o.else:!0,c=new et,p=ce(e,c,`${r}/if`,n,o.if,i)?ce(e,c,`${r}/then`,n,a,i)||t.AddError("if",r,n,{failingKeyword:"then"}):ce(e,t,`${r}/else`,n,m,i)||t.AddError("if",r,n,{failingKeyword:"else"});return p&&t.Merge([c]),p}function I0(e,t,r,n){return s.Every(r.items,0,(o,i)=>s.IsLessEqualThan(n.length,i)||Mt(e,t,o,n[i])&&t.AddIndex(i))}function b0(e,t,r,n,o,i){return s.EveryAll(o.items,0,(a,m)=>{let c=`${r}/items/${m}`,p=`${n}/${m}`;return s.IsLessEqualThan(i.length,m)||vt(e,t,c,p,a,i[m])&&t.AddIndex(m)})}function $0(e,t,r,n){let o=hn(r)?r.prefixItems.length:0;return s.Every(n,o,(i,a)=>Mt(e,t,r.items,i)&&t.AddIndex(a))}function E0(e,t,r,n,o,i){let a=hn(o)?o.prefixItems.length:0;return s.EveryAll(i,a,(m,c)=>{let p=`${r}/items`,f=`${n}/${c}`;return vt(e,t,p,f,o.items,m)&&t.AddIndex(c)})}function Ud(e,t,r,n){return ms(r)?I0(e,t,r,n):$0(e,t,r,n)}function Bd(e,t,r,n,o,i){return ms(o)?b0(e,t,r,n,o,i):E0(e,t,r,n,o,i)}function S0(e){return Gr(e)}function Tu(e,t,r,n){if(!S0(r))return!0;let o=s.Counted(n,i=>Q(e,t,r.contains,i));return s.IsLessEqualThan(o,r.maxContains)}function Gd(e,t,r,n,o,i){let a=yn(o)?o.minContains:1;return Tu(e,t,o,i)||t.AddError("contains",r,n,{minContains:a,maxContains:o.maxContains})}function wu(e,t,r,n){return s.IsLessEqualThan(n,r.maximum)}function Kd(e,t,r,n,o,i){return wu(e,t,o,i)||t.AddError("maximum",r,n,{comparison:"<=",limit:o.maximum})}function Cu(e,t,r,n){return s.IsLessEqualThan(n.length,r.maxItems)}function Hd(e,t,r,n,o,i){return Cu(e,t,o,i)||t.AddError("maxItems",r,n,{limit:o.maxItems})}function Ru(e,t,r,n){return s.IsMaxLength(n,r.maxLength)}function zd(e,t,r,n,o,i){return Ru(e,t,o,i)||t.AddError("maxLength",r,n,{limit:o.maxLength})}function Pu(e,t,r,n){return s.IsLessEqualThan(s.Keys(n).length,r.maxProperties)}function Wd(e,t,r,n,o,i){return Pu(e,t,o,i)||t.AddError("maxProperties",r,n,{limit:o.maxProperties})}function k0(e){return Gr(e)}function Au(e,t,r,n){if(!k0(r))return!0;let o=s.Counted(n,(i,a)=>Q(e,t,r.contains,i)&&t.AddIndex(a));return s.IsGreaterEqualThan(o,r.minContains)}function Vd(e,t,r,n,o,i){return Au(e,t,o,i)||t.AddError("contains",r,n,{minContains:o.minContains})}function Ou(e,t,r,n){return s.IsGreaterEqualThan(n,r.minimum)}function Jd(e,t,r,n,o,i){return Ou(e,t,o,i)||t.AddError("minimum",r,n,{comparison:">=",limit:o.minimum})}function Mu(e,t,r,n){return s.IsGreaterEqualThan(n.length,r.minItems)}function Yd(e,t,r,n,o,i){return Mu(e,t,o,i)||t.AddError("minItems",r,n,{limit:o.minItems})}function vu(e,t,r,n){return s.IsMinLength(n,r.minLength)}function Qd(e,t,r,n,o,i){return vu(e,t,o,i)||t.AddError("minLength",r,n,{limit:o.minLength})}function Fu(e,t,r,n){return s.IsGreaterEqualThan(s.Keys(n).length,r.minProperties)}function Xd(e,t,r,n,o,i){return Fu(e,t,o,i)||t.AddError("minProperties",r,n,{limit:o.minProperties})}function Lu(e,t,r,n){return s.IsMultipleOf(n,r.multipleOf)}function Zd(e,t,r,n,o,i){return Lu(e,t,o,i)||t.AddError("multipleOf",r,n,{multipleOf:o.multipleOf})}function Du(e,t,r,n){let o=new ct;return!Q(e,o,r.not,n)&&t.Merge([o])}function el(e,t,r,n,o,i){return Du(e,t,o,i)||t.AddError("not",r,n,{})}function tl(e,t,r,n){let o=r.oneOf.reduce((i,a)=>{let m=new ct;return Q(e,m,a,n)?[...i,m]:i},[]);return s.IsEqual(o.length,1)&&t.Merge(o)}function rl(e,t,r,n,o,i){let a=[],m=[],c=o.oneOf.reduce((f,d,g)=>{let y=new et,I=`${r}/oneOf/${g}`,h=ce(e,y,I,n,d,i);return h&&m.push(g),h||a.push(y),h?[...f,y]:f},[]),p=s.IsEqual(c.length,1)&&t.Merge(c);return!p&&s.IsEqual(m.length,0)&&a.forEach(f=>t.AddErrors(f.GetErrors())),p||t.AddError("oneOf",r,n,{passingSchemas:m})}function ju(e,t,r,n){return(s.IsString(r.pattern)?zr(r.pattern):r.pattern).test(n)}function nl(e,t,r,n,o,i){return ju(e,t,o,i)||t.AddError("pattern",r,n,{pattern:o.pattern})}function ol(e,t,r,n){return s.Every(s.Entries(r.patternProperties),0,([o,i])=>{let a=zr(o);return s.Every(s.Entries(n),0,([m,c])=>!a.test(m)||Mt(e,t,i,c)&&t.AddKey(m))})}function il(e,t,r,n,o,i){return s.EveryAll(s.Entries(o.patternProperties),0,([a,m])=>{let c=`${r}/patternProperties/${Et(a)}`,p=zr(a);return s.EveryAll(s.Entries(i),0,([f,d])=>{let g=`${n}/${Et(f)}`;return!p.test(f)||vt(e,t,c,g,m,d)&&t.AddKey(f)})})}function sl(e,t,r,n){return s.IsEqual(n.length,0)||s.Every(r.prefixItems,0,(o,i)=>s.IsLessEqualThan(n.length,i)||Mt(e,t,o,n[i])&&t.AddIndex(i))}function al(e,t,r,n,o,i){return s.IsEqual(i.length,0)||s.EveryAll(o.prefixItems,0,(a,m)=>{let c=`${r}/prefixItems/${m}`,p=`${n}/${m}`;return s.IsLessEqualThan(i.length,m)||vt(e,t,c,p,a,i[m])&&t.AddIndex(m)})}function Nu(e,t){return e.includes(t)||Me.Get().exactOptionalPropertyTypes}function qu(e,t){return s.IsUndefined(e[t])}function ml(e,t,r,n){let o=In(r)?r.required:[];return s.Every(s.Entries(r.properties),0,([a,m])=>{let c=!s.HasPropertyKey(n,a)||Mt(e,t,m,n[a])&&t.AddKey(a);return Nu(o,a)?c:qu(n,a)||c})}function ul(e,t,r,n,o,i){let a=In(o)?o.required:[];return s.EveryAll(s.Entries(o.properties),0,([c,p])=>{let f=`${r}/properties/${Et(c)}`,d=`${n}/${Et(c)}`,g=()=>!s.HasPropertyKey(i,c)||vt(e,t,f,d,p,i[c])&&t.AddKey(c);return Nu(a,c)?g():qu(i,c)||g()})}function cl(e,t,r,n){return s.Every(s.Keys(n),0,(o,i)=>Q(e,t,r.propertyNames,o))}function pl(e,t,r,n,o,i){let a=[];return s.EveryAll(s.Keys(i),0,(c,p)=>{let f=`${n}/${Et(c)}`,d=`${r}/propertyNames`,g=ce(e,t,d,f,o.propertyNames,c);return g||a.push(c),g})||t.AddError("propertyNames",r,n,{propertyNames:a})}function fl(e,t,r,n){let o=Bt.RecursiveRef(e,r)??!1,i=o?{...e,pendingResource:!0}:e;return L(o)&&Q(i,t,o,n)}function dl(e,t,r,n,o,i){let a=Bt.RecursiveRef(e,o)??!1,m=a?{...e,pendingResource:!0}:e;return L(a)&&ce(m,t,r,n,a,i)}function ll(e,t,r,n){let o=Bt.Ref(e,r),i=o.schema??!1,a=new ct,m=L(i)&&Q(o.stack,a,i,n);return m&&t.Merge([a]),m}function gl(e,t,r,n,o,i){let a=Bt.Ref(e,o),m=a.schema??!1,c=new et,p=L(m)&&ce(a.stack,c,r,n,m,i);return p&&t.Merge([c]),p||t.AddErrors(c.GetErrors()),p}function yl(e,t,r,n){return s.Every(r.required,0,o=>s.HasPropertyKey(n,o))}function xl(e,t,r,n,o,i){let a=[];return s.EveryAll(o.required,0,c=>{let p=s.HasPropertyKey(i,c);return p||a.push(c),p})||t.AddError("required",r,n,{requiredProperties:a})}function _u(e,t,r,n,o){return s.IsEqual(r,"object")?s.IsObjectNotArray(o):s.IsEqual(r,"array")?s.IsArray(o):s.IsEqual(r,"boolean")?s.IsBoolean(o):s.IsEqual(r,"integer")?s.IsInteger(o):s.IsEqual(r,"number")?s.IsNumber(o):s.IsEqual(r,"null")?s.IsNull(o):s.IsEqual(r,"string")?s.IsString(o):s.IsEqual(r,"bigint")?s.IsBigInt(o):s.IsEqual(r,"constructor")?s.IsConstructor(o):s.IsEqual(r,"function")?s.IsFunction(o):s.IsEqual(r,"symbol")?s.IsSymbol(o):s.IsEqual(r,"undefined")?s.IsUndefined(o):s.IsEqual(r,"void")?s.IsUndefined(o):!0}function hl(e,t,r,n,o){return s.Some(r,i=>_u(e,t,i,n,o))}function Il(e,t,r,n){return s.IsArray(r.type)?hl(e,t,r.type,r,n):_u(e,t,r.type,r,n)}function bl(e,t,r,n,o,i){return(s.IsArray(o.type)?hl(e,t,o.type,o,i):_u(e,t,o.type,o,i))||t.AddError("type",r,n,{type:o.type})}function $l(e,t,r,n){let o=t.GetIndices();return s.Every(n,0,(i,a)=>(o.has(a)||Q(e,t,r.unevaluatedItems,i))&&t.AddIndex(a))}function El(e,t,r,n,o,i){let a=t.GetIndices(),m=[];return s.EveryAll(i,0,(p,f)=>{let d=new et,g=(a.has(f)||ce(e,d,r,n,o.unevaluatedItems,p))&&t.AddIndex(f);return g||m.push(f),g})||t.AddError("unevaluatedItems",r,n,{unevaluatedItems:m})}function Sl(e,t,r,n){let o=t.GetKeys();return s.Every(s.Entries(n),0,([i,a])=>o.has(i)||Q(e,t,r.unevaluatedProperties,a)&&t.AddKey(i))}function kl(e,t,r,n,o,i){let a=t.GetKeys(),m=[];return s.EveryAll(s.Entries(i),0,([p,f])=>{let d=new et,g=a.has(p)||ce(e,d,r,n,o.unevaluatedProperties,f)&&t.AddKey(p);return g||m.push(p),g})||t.AddError("unevaluatedProperties",r,n,{unevaluatedProperties:m})}var Pr={};Ot(Pr,{Hash:()=>Al,HashCode:()=>q0});function $e(){throw new Error("Unreachable")}function T0(e){let t=new Set,r=e;for(;r&&r!==Object.prototype;){for(let n of Reflect.ownKeys(r))n!=="constructor"&&typeof n!="symbol"&&t.add(n);r=Object.getPrototypeOf(r)}return[...t]}function w0(e){return typeof e=="number"}var kt={Array:0,BigInt:1,Boolean:2,Date:3,Constructor:4,Function:5,Null:6,Number:7,Object:8,RegExp:9,String:10,Symbol:11,TypeArray:12,Undefined:13},Ks=8997,Zo=33826,Hs=40164,zs=52210,Cl=new Float64Array(1),Rl=new DataView(Cl.buffer),Pl=new Uint8Array(Cl.buffer);function Ge(e){let t=Ks^e,r=t*435,n=Zo*435+(r>>>16),o=Hs*435+(n>>>16)+(t<<8),i=zs*435+(o>>>16)+(Zo<<8);Ks=r&65535,Zo=n&65535,Hs=o&65535,zs=i&65535}function C0(e){Ge(kt.Array);for(let t of e)Wr(t)}function R0(e){Ge(kt.BigInt),Rl.setBigInt64(0,e);for(let t of Pl)Ge(t)}function Tl(e){Ge(kt.Boolean),Ge(e?1:0)}function P0(e){Ge(kt.Constructor),Wr(e.toString())}function A0(e){Ge(kt.Date),Wr(e.getTime())}function O0(e){Ge(kt.Function),Wr(e.toString())}function M0(e){Ge(kt.Null)}function wl(e){Ge(kt.Number),Rl.setFloat64(0,e,!0);for(let t of Pl)Ge(t)}function v0(e){Ge(kt.Object);for(let t of T0(e).sort())Wr(t),Wr(e[t])}function F0(e){Ge(kt.RegExp),Uu(e.toString())}var L0=new TextEncoder;function Uu(e){Ge(kt.String);for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r>127){for(let n of L0.encode(e.slice(t)))Ge(n);return}Ge(r)}}function D0(e){Ge(kt.Symbol),Wr(e.toString())}function j0(e){Ge(kt.TypeArray);let t=new Uint8Array(e.buffer);for(let r=0;r<t.length;r++)Ge(t[r])}function N0(e){return Ge(kt.Undefined)}function Wr(e){return je.IsTypeArray(e)?j0(e):je.IsDate(e)?A0(e):je.IsRegExp(e)?F0(e):je.IsBoolean(e)?Tl(e.valueOf()):je.IsString(e)?Uu(e.valueOf()):je.IsNumber(e)?wl(e.valueOf()):w0(e)?wl(e):s.IsArray(e)?C0(e):s.IsBoolean(e)?Tl(e):s.IsBigInt(e)?R0(e):s.IsConstructor(e)?P0(e):s.IsNull(e)?M0(e):s.IsObject(e)?v0(e):s.IsString(e)?Uu(e):s.IsSymbol(e)?D0(e):s.IsUndefined(e)?N0(e):s.IsFunction(e)?O0(e):$e()}function Gs(e){return e.toString(16).padStart(4,"0")}function q0(e){return BigInt(`0x${Al(e)}`)}function Al(e){return Ks=8997,Zo=33826,Hs=40164,zs=52210,Wr(e),`${Gs(zs)}${Gs(Hs)}${Gs(Zo)}${Gs(Ks)}`}function Ol(e){return!s.IsEqual(e.uniqueItems,!1)}function Ml(e,t,r,n){if(!Ol(r))return!0;let o=new Set(n.map(Pr.Hash)).size,i=n.length;return s.IsEqual(o,i)}function vl(e,t,r,n,o,i){if(!Ol(o))return!0;let a=new Set,m=i.reduce((p,f,d)=>{let g=Pr.Hash(f);return a.has(g)?[...p,d]:(a.add(g),p)},[]);return s.IsEqual(m.length,0)||t.AddError("uniqueItems",r,n,{duplicateItems:m})}function Mt(e,t,r,n){return t.Push()&&Q(e,t,r,n)&&t.Pop()}function Q(e,t,r,n){let o=Kn(e,r);return ln(r)?su(o,t,r,n):(!ru(r)||Il(o,t,r,n))&&(!(s.IsObject(n)&&!s.IsArray(n))||(!In(r)||yl(o,t,r,n))&&(!Ut(r)||Df(o,t,r,n))&&(!Wm(r)||Hf(o,t,r,n))&&(!Vm(r)||Wf(o,t,r,n))&&(!os(r)||Jf(o,t,r,n))&&(!_n(r)||ol(o,t,r,n))&&(!Un(r)||ml(o,t,r,n))&&(!ps(r)||cl(o,t,r,n))&&(!_o(r)||Fu(o,t,r,n))&&(!eu(r)||Pu(o,t,r,n)))&&(!s.IsArray(n)||(!ts(r)||vf(o,t,r,n))&&(!Gr(r)||mu(o,t,r,n))&&(!gn(r)||Ud(o,t,r,n))&&(!yn(r)||Au(o,t,r,n))&&(!Xm(r)||Tu(o,t,r,n))&&(!xn(r)||Mu(o,t,r,n))&&(!No(r)||Cu(o,t,r,n))&&(!hn(r)||sl(o,t,r,n))&&(!Hr(r)||Ml(o,t,r,n)))&&(!s.IsString(n)||(!qo(r)||vu(o,t,r,n))&&(!Zm(r)||Ru(o,t,r,n))&&(!jo(r)||ku(o,t,r,n))&&(!Uo(r)||ju(o,t,r,n)))&&(!(s.IsNumber(n)||s.IsBigInt(n))||(!wr(r)||hu(o,t,r,n))&&(!Ym(r)||xu(o,t,r,n))&&(!Cr(r)||Ou(o,t,r,n))&&(!Qm(r)||wu(o,t,r,n))&&(!tu(r)||Lu(o,t,r,n)))&&(!ds(r)||ll(o,t,r,n))&&(!fs(r)||fl(o,t,r,n))&&(!is(r)||id(o,t,r,n))&&(!zm(r)||au(o,t,r,n))&&(!Jm(r)||yu(o,t,r,n))&&(!as(r)||qd(o,t,r,n))&&(!us(r)||Du(o,t,r,n))&&(!rs(r)||Nf(o,t,r,n))&&(!ns(r)||_f(o,t,r,n))&&(!cs(r)||tl(o,t,r,n))&&(!Go(r)||!s.IsArray(n)||$l(o,t,r,n))&&(!Ko(r)||!s.IsObject(n)||Sl(o,t,r,n))&&(!es(r)||wf(o,t,r,n))}function vt(e,t,r,n,o,i){return t.Push()&&ce(e,t,r,n,o,i)&&t.Pop()}function ce(e,t,r,n,o,i){if(t.AtCapacity())return!1;let a=Kn(e,o);return ln(o)?Bf(a,t,r,n,o,i):!!(+(!ru(o)||bl(a,t,r,n,o,i))&+(!(s.IsObject(i)&&!s.IsArray(i))||!!(+(!In(o)||xl(a,t,r,n,o,i))&+(!Ut(o)||jf(a,t,r,n,o,i))&+(!Wm(o)||zf(a,t,r,n,o,i))&+(!Vm(o)||Vf(a,t,r,n,o,i))&+(!os(o)||Yf(a,t,r,n,o,i))&+(!_n(o)||il(a,t,r,n,o,i))&+(!Un(o)||ul(a,t,r,n,o,i))&+(!ps(o)||pl(a,t,r,n,o,i))&+(!_o(o)||Xd(a,t,r,n,o,i))&+(!eu(o)||Wd(a,t,r,n,o,i))))&+(!s.IsArray(i)||!!(+(!ts(o)||Ff(a,t,r,n,o,i))&+(!Gr(o)||Kf(a,t,r,n,o,i))&+(!gn(o)||Bd(a,t,r,n,o,i))&+(!yn(o)||Vd(a,t,r,n,o,i))&+(!Xm(o)||Gd(a,t,r,n,o,i))&+(!xn(o)||Yd(a,t,r,n,o,i))&+(!No(o)||Hd(a,t,r,n,o,i))&+(!hn(o)||al(a,t,r,n,o,i))&+(!Hr(o)||vl(a,t,r,n,o,i))))&+(!s.IsString(i)||!!(+(!qo(o)||Qd(a,t,r,n,o,i))&+(!Zm(o)||zd(a,t,r,n,o,i))&+(!jo(o)||Nd(a,t,r,n,o,i))&+(!Uo(o)||nl(a,t,r,n,o,i))))&+(!(s.IsNumber(i)||s.IsBigInt(i))||!!(+(!wr(o)||ud(a,t,r,n,o,i))&+(!Ym(o)||md(a,t,r,n,o,i))&+(!Cr(o)||Jd(a,t,r,n,o,i))&+(!Qm(o)||Kd(a,t,r,n,o,i))&+(!tu(o)||Zd(a,t,r,n,o,i))))&+(!ds(o)||gl(a,t,r,n,o,i))&+(!fs(o)||dl(a,t,r,n,o,i))&+(!is(o)||sd(a,t,r,n,o,i))&+(!zm(o)||Gf(a,t,r,n,o,i))&+(!Jm(o)||ad(a,t,r,n,o,i))&+(!as(o)||_d(a,t,r,n,o,i))&+(!us(o)||el(a,t,r,n,o,i))&+(!rs(o)||qf(a,t,r,n,o,i))&+(!ns(o)||Uf(a,t,r,n,o,i))&+(!cs(o)||rl(a,t,r,n,o,i))&+(!Go(o)||!s.IsArray(i)||El(a,t,r,n,o,i))&+(!Ko(o)||!s.IsObject(i)||kl(a,t,r,n,o,i)))&&(!es(o)||Cf(a,t,r,n,o,i))}function Ll(e){switch(e.keyword){case"additionalProperties":return"must not have additional properties";case"anyOf":return"must match a schema in anyOf";case"boolean":return"schema is false";case"const":return"must be equal to constant";case"contains":return"must contain at least 1 valid item";case"dependencies":return`must have properties ${e.params.dependencies.join(", ")} when property ${e.params.property} is present`;case"dependentRequired":return`must have properties ${e.params.dependencies.join(", ")} when property ${e.params.property} is present`;case"enum":return"must be equal to one of the allowed values";case"exclusiveMaximum":return`must be ${e.params.comparison} ${e.params.limit}`;case"exclusiveMinimum":return`must be ${e.params.comparison} ${e.params.limit}`;case"format":return`must match format "${e.params.format}"`;case"if":return`must match "${e.params.failingKeyword}" schema`;case"maxItems":return`must not have more than ${e.params.limit} items`;case"maxLength":return`must not have more than ${e.params.limit} characters`;case"maxProperties":return`must not have more than ${e.params.limit} properties`;case"maximum":return`must be ${e.params.comparison} ${e.params.limit}`;case"minItems":return`must not have fewer than ${e.params.limit} items`;case"minLength":return`must not have fewer than ${e.params.limit} characters`;case"minProperties":return`must not have fewer than ${e.params.limit} properties`;case"minimum":return`must be ${e.params.comparison} ${e.params.limit}`;case"multipleOf":return`must be multiple of ${e.params.multipleOf}`;case"not":return"must not be valid";case"oneOf":return"must match exactly one schema in oneOf";case"pattern":return`must match pattern "${e.params.pattern}"`;case"propertyNames":return`property names ${e.params.propertyNames.join(", ")} are invalid`;case"required":return`must have required properties ${e.params.requiredProperties.join(", ")}`;case"type":return typeof e.params.type=="string"?`must be ${e.params.type}`:`must be either ${e.params.type.join(" or ")}`;case"unevaluatedItems":return"must not have unevaluated items";case"unevaluatedProperties":return"must not have unevaluated properties";case"uniqueItems":return"must not have duplicate items";case"~refine":return e.params.message;default:return"an unknown validation error occurred"}}var _0=Ll;function Dl(){return _0}var l={};Ot(l,{Assign:()=>B0,Clone:()=>G0,Create:()=>H0,Discard:()=>z0,Metrics:()=>Qt,Update:()=>Y0});var Qt={assign:0,create:0,clone:0,discard:0,update:0};function Ft(e){return[...s.Keys(e),...s.Symbols(e)]}function jl(e,t){if(!t.has(e)){t.add(e);for(let r of Ft(e)){let n=Object.getOwnPropertyDescriptor(e,r);!n||!("value"in n)||s.IsObject(n.value)&&jl(n.value,t)}Object.freeze(e)}}function Vr(e){return Me.Get().immutableTypes&&jl(e,new WeakSet),e}function B0(e,t){Qt.assign+=1;let r={},n=Ft(t),o=Ft(e);for(let i of o)n.includes(i)||Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(e,i));for(let i of n)Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(t,i));return Vr(r)}function G0(e){Qt.clone+=1;let t={};for(let r of Ft(e)){if(s.IsUnsafePropertyKey(r))continue;let n=Object.getOwnPropertyDescriptor(e,r);s.IsEqual(n.enumerable,!0)?t[r]=n.value:Object.defineProperty(t,r,n)}return t}function Nl(e,t){return{...e,...t}}function K0(e,t){for(let r of Object.keys(t))Object.defineProperty(e,r,{configurable:!0,writable:!0,enumerable:!1,value:t[r]});return e}function H0(e,t,r={}){Qt.create+=1;let n=Nl(t,r),o=Me.Get().enumerableKind?Nl(n,e):K0(n,e);return Vr(o)}function z0(e,t){Qt.discard+=1;let r={};for(let n of Ft(e)){if(t.includes(n))continue;let o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,o)}return Vr(r)}function W0(e,t,r,n){for(let o of Ft(e)){if(s.IsUnsafePropertyKey(o)||t.includes(o)||r.includes(o))continue;let i=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(n,o,i)}}function V0(e,t,r){let n=Me.Get().enumerableKind;for(let o of t)s.IsUnsafePropertyKey(o)||Object.defineProperty(r,o,{configurable:!0,writable:!0,enumerable:n,value:e[o]})}function J0(e,t,r){for(let n of t)s.IsUnsafePropertyKey(n)||Object.defineProperty(r,n,{configurable:!0,enumerable:!0,writable:!0,value:e[n]})}function Y0(e,t,r){Qt.update+=1;let n={},o=Ft(t),i=Ft(r);return W0(e,o,i,n),V0(t,o,n),J0(r,i,n),Vr(n)}function Ws(...e){let[t,r,n]=B.Match(e,{3:(f,d,g)=>[f,d,g],2:(f,d)=>[{},f,d]}),o=Gn(t,r),i=new et,a=ce(o,i,"#","",r,n),m=i.GetErrors(),c=Dl(),p=m.map(f=>({...f,message:c(f)}));return[a,p]}var _l=0;function Vs(){let e=Zi();_l=e.maxErrors,e.maxErrors=e.maxParseErrors}function Js(){let e=Zi();e.maxErrors=_l}function Gu(...e){let[t,r,n]=B.Match(e,{3:(a,m,c)=>[a,m,c],2:(a,m)=>[{},a,m]}),o=Gn(t,r),i=new ct;return Q(o,i,r,n)}function K(...e){let[t,r,n]=B.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]});return Gu(t,r,n)}function Xt(...e){let[t,r,n]=B.Match(e,{3:(a,m,c)=>[a,m,c],2:(a,m)=>[{},a,m]}),[o,i]=Ws(t,r,n);return i}var Ar=class extends Error{constructor(t,r,n){super(t),Object.defineProperty(this,"cause",{value:{source:t,errors:n,value:r},writable:!1,configurable:!1,enumerable:!1})}};function Ys(...e){let[t,r,n]=B.Match(e,{3:(i,a,m)=>[i,a,m],2:(i,a)=>[{},i,a]});if(!K(t,r,n))throw new Ar("Assert",n,Xt(t,r,n))}function C(e,t){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.IsEqual(e["~kind"],t)}function ye(e){return s.IsObject(e)}function R(e,t,r){return l.Create({"~kind":"Deferred"},{type:"deferred",action:e,parameters:t,options:r},{})}function Jr(e){return C(e,"Deferred")}function ur(e,t){return l.Update(e,{"~readonly":!0},t)}function Ul(e,t,r,n){let o=E(e,t,r);return ur(o,n)}function cr(e,t){return l.Update(e,{"~optional":!0},t)}function Bl(e,t,r,n){let o=E(e,t,r);return cr(o,n)}function xt(e,t){return l.Create({"~kind":"Array"},{type:"array",items:e},t)}function W(e){return C(e,"Array")}function Jn(e){return l.Discard(e,["~kind","type","items"])}function pr(e,t,r={}){return l.Create({"~kind":"Constructor"},{type:"constructor",parameters:e,instanceType:t},r)}function Ee(e){return C(e,"Constructor")}function Gl(e){return l.Discard(e,["~kind","type","parameters","instanceType"])}function fr(e,t,r={}){return l.Create({"~kind":"Function"},{type:"function",parameters:e,returnType:t},r)}function Se(e){return C(e,"Function")}function Kl(e){return l.Discard(e,["~kind","type","parameters","returnType"])}function Be(e,t){return l.Create({"~kind":"Ref"},{$ref:e},t)}function te(e){return C(e,"Ref")}function Yr(e,t){return l.Create({"~kind":"Generic"},{type:"generic",parameters:e,expression:t})}function Yn(e){return C(e,"Generic")}function Qn(e){return l.Create({"~kind":"Any"},{},e)}function Ie(e){return C(e,"Any")}var Hl="(?!)";function ie(e){return l.Create({"~kind":"Never"},{not:{}},e)}function ht(e){return C(e,"Never")}function dr(e,t={}){return R("AddOptional",[e],t)}function Qs(e,t={}){return cr(e,t)}function zl(e){return Qs(e)}function ve(e){return ye(e)&&s.HasPropertyKey(e,"~optional")}function Wl(e){return s.Keys(e).filter(t=>!ve(e[t]))}function Xs(e){return s.Keys(e)}function Zs(e){return s.Values(e)}function M(e,t={}){let r=Wl(e),n=r.length>0?{required:r}:{};return l.Create({"~kind":"Object"},{type:"object",...n,properties:e},t)}function A(e){return C(e,"Object")}function Vl(e){return l.Discard(e,["~kind","type","properties","required"])}function Ne(e){return l.Create({"~kind":"Unknown"},{},e)}function Fe(e){return C(e,"Unknown")}function lr(e,t,r){let n=s.Keys(e).reduce((o,i)=>({...o,[i]:l.Update(e[i],{},{$id:i})}),{});return l.Create({"~kind":"Cyclic"},{$defs:n,$ref:t},r)}function me(e){return C(e,"Cyclic")}function Jl(e){return l.Update(e,{"~unsafe":null},{})}function ea(e){return s.IsObjectNotArray(e)&&s.HasPropertyKey(e,"~unsafe")&&s.IsNull(e["~unsafe"])}function ei(...e){let[t,r]=B.Match(e,{2:(n,o)=>[n,o,o],1:n=>[n,Ne(),Ne()]});return l.Create({"~kind":"Infer"},{type:"infer",name:t,extends:r},{})}function Le(e){return C(e,"Infer")}function $n(e,t,r,n={}){return l.Create({"~kind":"Dependent"},{if:e,then:t,else:r},n)}function ke(e){return C(e,"Dependent")}function Yl(e){return l.Discard(e,["~kind","if","then","else"])}function Ql(e){return s.IsObjectNotArray(e)}function Xl(e){return s.Keys(e).filter(r=>isNaN(r)).reduce((r,n)=>[...r,e[n]],[])}function Zl(e){return s.IsString(e)||s.IsNumber(e)}function eg(e,t){let r=Ql(e)?Xl(e):e;return l.Create({"~kind":"Enum"},{enum:r},t)}function Te(e){return C(e,"Enum")}function ot(e,t={}){return l.Create({"~kind":"Intersect"},{allOf:e},t)}function O(e){return C(e,"Intersect")}function tg(e){return l.Discard(e,["~kind","allOf"])}var ti=class{constructor(t,r){this.type=t,this.decode=r}Encode(t){let r=this.type,n=pt(r)?a=>this.decode(r["~codec"].decode(a)):this.decode,o=pt(r)?a=>r["~codec"].encode(t(a)):t,i={decode:n,encode:o};return l.Update(this.type,{"~codec":i},{})}},ri=class{constructor(t){this.type=t}Decode(t){return new ti(this.type,t)}};function ta(e){return new ri(e)}function rg(e,t){return ta(e).Decode(t).Encode(()=>{throw Error("Encode not implemented")})}function ng(e,t){return ta(e).Decode(()=>{throw Error("Decode not implemented")}).Encode(t)}function pt(e){return ye(e)&&s.HasPropertyKey(e,"~codec")&&s.IsObject(e["~codec"])&&s.HasPropertyKey(e["~codec"],"encode")&&s.HasPropertyKey(e["~codec"],"decode")}function og(e){return Xn(e)}function En(e){return ye(e)&&s.HasPropertyKey(e,"~immutable")}function gr(e,t={}){return R("AddReadonly",[e],t)}function ra(e,t={}){return ur(e,t)}function ig(e){return ra(e)}function Or(e){return ye(e)&&s.HasPropertyKey(e,"~readonly")}function Z0(e,t){let r=ni(e)?[...e["~refine"],t]:[t];return l.Update(e,{"~refine":r},{})}function sg(...e){let[t,r,n]=B.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[o,i,()=>"Refine Error"]});return Z0(t,{check:r,error:n})}function eP(e){return s.IsObjectNotArray(e)&&s.HasPropertyKey(e,"check")&&s.HasPropertyKey(e,"error")&&s.IsFunction(e.check)&&s.IsFunction(e.error)}function ni(e){return ye(e)&&s.HasPropertyKey(e,"~refine")&&s.IsArray(e["~refine"])&&s.Every(e["~refine"],0,t=>eP(t))}var ag="-?(?:0|[1-9][0-9]*)n";function oi(e){return l.Create({"~kind":"BigInt"},{type:"bigint"},e)}function Tt(e){return C(e,"BigInt")}function na(e){return l.Create({"~kind":"Boolean"},{type:"boolean"},e)}function ft(e){return C(e,"Boolean")}function ii(e){return l.Create({"~kind":"Identifier"},{name:e})}function mg(e){return C(e,"Identifier")}var oa="-?(?:0|[1-9][0-9]*)";function Sn(e){return l.Create({"~kind":"Integer"},{type:"integer"},e)}function Ke(e){return C(e,"Integer")}var Ku=class extends Error{constructor(t){super("Invalid Literal value"),Object.defineProperty(this,"cause",{value:{value:t},writable:!1,configurable:!1,enumerable:!1})}};function tP(e){return s.IsBigInt(e)?"bigint":s.IsBoolean(e)?"boolean":s.IsNumber(e)?"number":s.IsString(e)?"string":(()=>{throw new Ku(e)})()}function G(e,t){return l.Create({"~kind":"Literal"},{type:tP(e),const:e},t)}function ia(e){return s.IsBigInt(e)||s.IsBoolean(e)||s.IsNumber(e)||s.IsString(e)}function ug(e){return H(e)&&s.IsBigInt(e.const)}function cg(e){return H(e)&&s.IsBoolean(e.const)}function sa(e){return H(e)&&s.IsNumber(e.const)}function aa(e){return H(e)&&s.IsString(e.const)}function H(e){return C(e,"Literal")}function Zn(e){return l.Create({"~kind":"Null"},{type:"null"},e)}function yr(e){return C(e,"Null")}var ma="-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?";function wt(e){return l.Create({"~kind":"Number"},{type:"number"},e)}function xe(e){return C(e,"Number")}function eo(e){return l.Create({"~kind":"Symbol"},{type:"symbol"},e)}function xr(e){return C(e,"Symbol")}function kn(...e){let[t,r,n]=B.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[o,i,i],1:o=>[o,Ne(),Ne()]});return l.Create({"~kind":"Parameter"},{name:t,extends:r,equals:n},{})}function pg(e){return C(e,"Parameter")}var ua=".*";function tt(e){return l.Create({"~kind":"String"},{type:"string"},e)}function qe(e){return C(e,"String")}function D(e,t={}){return l.Create({"~kind":"Union"},{anyOf:e},t)}function k(e){return C(e,"Union")}function fg(e){return l.Discard(e,["~kind","anyOf"])}function si(e){let t=dg(e);return s.IsEqual(t.length,2)?t[0]:[]}function rP(e){return!0}function lg(e){return s.ShiftLeft(e,(t,r)=>nP(t)?lg(r):!1,()=>!0)}function gg(e){return s.IsEqual(e.length,0)?!1:lg(e)}function nP(e){return k(e)?gg(e.anyOf):H(e)?rP(e.const):!1}function ca(e){return gg(e)}function pa(e){return l.Create({"~kind":"TemplateLiteral"},{type:"string",pattern:e},{})}function yg(e,t,r=[]){return s.ShiftLeft(e,(n,o)=>yg(o,t,[...r,`${n}${t}`]),()=>r)}function oP(e,t){return s.IsEqual(e.length,0)?[`${t}`]:yg(e,t)}function xg(e,t,r=[]){return s.ShiftLeft(t,(n,o)=>xg(e,o,[...r,...hg(e,n)]),()=>r)}function hg(e,t){return k(t)?xg(e,t.anyOf):H(t)?oP(e,t.const):$e()}function Ig(e,t){return s.ShiftLeft(t,(r,n)=>Ig(hg(e,r),n),()=>e)}function iP(e){return e.map(t=>G(t))}function sP(e){let t=Ig([],e),r=iP(t);return D(r)}function aP(e){return s.IsEqual(e.length,0)?$e():s.IsEqual(e.length,1)&&H(e[0])?e[0]:sP(e)}function Hu(e){let t=si(e);return s.IsEqual(t.length,0)?tt():ca(t)?aP(t):pa(e)}function to(e){let t=Hu(e);return ue(t)?tt():t}function It(e,t){let r="object",n={[e]:t};return l.Create({"~kind":"Record"},{type:r,patternProperties:n})}function bg(e){return It(Zt,e)}function $g(e){return M({true:e,false:e})}function we(e,t={}){let[r,n,o]=[e,e.length,!1];return l.Create({"~kind":"Tuple"},{type:"array",additionalItems:o,items:r,minItems:n},t)}function _(e){return C(e,"Tuple")}function Eg(e){return l.Discard(e,["~kind","type","items","minItems","additionalItems"])}function zu(e){return e.reduceRight((r,n,o)=>({[o]:n,...r}),{})}function Sg(e){let t=zu(e.items);return M(t)}function mP(e){return l.Discard(e,["~optional"])}function Tn(e,t){return l.Update(mP(e),{},t)}function kg(e,t,r,n){let o=E(e,t,r);return Tn(o,n)}function uP(e){return l.Discard(e,["~readonly"])}function ro(e,t){return l.Update(uP(e),{},t)}function Tg(e,t,r,n){let o=E(e,t,r);return ro(o,n)}function fa(e,t){let r=Or(e)&&Or(t),n=ve(e)&&ve(t),o=Ce([e,t]),i=ro(Tn(o,{}),{});return r&&n?ur(cr(i,{}),{}):r?ur(i,{}):n?cr(i,{}):i}function wg(e,t){let r=Or(e)||Or(t),n=ve(e)||ve(t),o=ro(Tn(e,{}),{}),i=ro(Tn(t,{}),{}),a=bt([o,i]);return r&&n?ur(cr(a,{}),{}):r?ur(a,{}):n?cr(a,{}):a}function cP(e,t,r){return r in e?r in t?fa(e[r],t[r]):e[r]:r in t?t[r]:ie()}function pP(e,t){return[...new Set([...s.Keys(e),...s.Keys(t)])].reduce((o,i)=>({...o,[i]:cP(e,t,i)}),{})}function Cg(e){return A(e)?e.properties:_(e)?zu(e.items):{}}function Rg(e,t){let r=Cg(e),n=Cg(t),o=pP(r,n);return M(o)}function fP(e,t){let r=no(e,t);return s.IsEqual(r,mi)?e:s.IsEqual(r,ui)||s.IsEqual(r,ai)?t:ie()}function Pg(e){return A(e)||_(e)}function dP(e,t){let r=Pg(e),n=Pg(t);return r&&n?Rg(e,t):r&&!n?e:!r&&n?t:fP(e,t)}function Ag(e,t){return ht(e)||Ie(e)?e:Fe(e)||ht(t)||Ie(t)?t:Fe(t)?e:dP(e,t)}function lP(e,t){return k(e)||k(t)}function gP(e,t){let r=Gt(e),n=Gt(t);return lP(r,n)?Ce([r,n]):Ag(r,n)}function Og(e,t,r=[]){return s.ShiftLeft(t,(n,o)=>Og(e,o,[...r,gP(n,e)]),()=>s.IsEqual(r.length,0)?[e]:r)}function Mg(e,t,r=[]){return s.ShiftLeft(e,(n,o)=>Mg(o,t,[...r,...ci([n],t)]),()=>r)}function ci(e,t=[]){return s.ShiftLeft(e,(r,n)=>k(r)?ci(n,Mg(r.anyOf,t)):ci(n,Og(r,t)),()=>t)}function yP(e,t){let r=rt({},e,t);return F.IsExtendsTrueLike(r)?[]:[e]}function vg(e,t,r=[]){return s.ShiftLeft(e,(n,o)=>vg(o,t,[...r,...yP(n,t)]),()=>r)}function da(e,t){let r=Gt(e),n=k(r)?r.anyOf:[r],o=vg(n,t);return bt(o)}function er(e,t,r){let n=Ce([e,t]),o=da(r,e);return bt([n,o])}function dt(e,t=[]){return s.ShiftLeft(e,(r,n)=>dt(n,[...t,G(r)]),()=>bt(t))}function Ce(e){let t=ci(e),r=Wu(t);return bt(r)}function it(e){let t=to(e);return Gt(t)}function bt(e){let t=Wu(e);return Qr(t)}function Gt(e){return ke(e)?er(e.if,e.then,e.else):Te(e)?dt(e.enum):O(e)?Ce(e.allOf):ue(e)?it(e.pattern):k(e)?bt(e.anyOf):e}function Qr(e){return s.IsEqual(e.length,1)?e[0]:s.IsEqual(e.length,0)?ie():D(e)}function Fg(e,t){let r=dt(e);return Xr(r,t)}function Lg(e,t){return It(Zr,t)}function Dg(e,t){let r=Ce(e);return Xr(r,t)}function jg(e,t){return s.IsString(e)||s.IsNumber(e)?M({[e]:t}):s.IsEqual(e,!1)?M({false:t}):s.IsEqual(e,!0)?M({true:t}):M({})}function Ng(e,t){return It(oo,t)}function qg(e,t){return s.HasPropertyKey(e,"pattern")&&(s.IsString(e.pattern)||e.pattern instanceof RegExp)?It(e.pattern.toString(),t):It(Zt,t)}function _g(e,t){let r=si(e);return ca(r)?Xr(it(e),t):It(e,t)}function xP(e){return k(e)?en(e.anyOf):[e]}function en(e,t=[]){return s.ShiftLeft(e,(r,n)=>en(n,[...t,...xP(r)]),()=>t)}function hP(e){return e.some(t=>qe(t)||xe(t)||Ke(t))}function IP(e,t){return s.IsEqual(hP(e),!0)?It(Zt,t):void 0}function bP(e,t){return e.reduce((r,n)=>H(n)&&(s.IsString(n.const)||s.IsNumber(n.const))?{...r,[n.const]:t}:r,{})}function $P(e,t){let r=bP(e,t);return M(r)}function Ug(e,t){let r=en(e),n=IP(r,t);return ye(n)?n:$P(r,t)}function Xr(e,t){return Ie(e)?bg(t):ft(e)?$g(t):Te(e)?Fg(e.enum,t):Ke(e)?Lg(e,t):O(e)?Dg(e.allOf,t):H(e)?jg(e.const,t):xe(e)?Ng(e,t):k(e)?Ug(e.anyOf,t):qe(e)?qg(e,t):ue(e)?_g(e.pattern,t):M({})}function Vu(e,t,r){return U([e])?l.Update(Xr(e,t),{},r):la(e,t,r)}function Bg(e,t,r,n,o){let i=E(e,t,r),a=E(e,t,n);return Vu(i,a,o)}var Zr=`^${oa}$`,oo=`^${ma}$`,Zt=`^${ua}$`;function la(e,t,r={}){return R("Record",[e,t],r)}function io(e,t,r={}){return Vu(e,t,r)}function Gg(e,t){return It(e,t)}function ga(e){return s.IsEqual(e,Zt)?tt():s.IsEqual(e,Zr)?Sn():s.IsEqual(e,oo)?wt():Hu(e)}function De(e){return s.Keys(e.patternProperties)[0]}function so(e){let t=De(e);return ga(t)}function pe(e){return e.patternProperties[De(e)]}function ne(e){return C(e,"Record")}function wn(e){return l.Create({"~kind":"Rest"},{type:"rest",items:e},{})}function tn(e){return C(e,"Rest")}function ya(e){return l.Create({"~kind":"This"},{$ref:"#"},e)}function xa(e){return C(e,"This")}function ao(e){return l.Create({"~kind":"Undefined"},{type:"undefined"},e)}function Kt(e){return C(e,"Undefined")}function ha(e){return l.Create({"~kind":"Void"},{type:"void"},e)}function Ct(e){return C(e,"Void")}function SP(e,t){return s.IsEqual(e,"Array")?xt(t[0]):s.IsEqual(e,"Capitalize")?ba(t[0]):s.IsEqual(e,"ConstructorParameters")?Ta(t[0]):s.IsEqual(e,"Evaluate")?zx(t[0]):s.IsEqual(e,"Exclude")?wa(t[0],t[1]):s.IsEqual(e,"Extract")?Ca(t[0],t[1]):s.IsEqual(e,"Index")?li(t[0],t[1]):s.IsEqual(e,"InstanceType")?Ra(t[0]):s.IsEqual(e,"Lowercase")?$a(t[0]):s.IsEqual(e,"NonNullable")?Pa(t[0]):s.IsEqual(e,"Omit")?Aa(t[0],t[1]):s.IsEqual(e,"Parameters")?Oa(t[0]):s.IsEqual(e,"Partial")?Ma(t[0]):s.IsEqual(e,"Pick")?va(t[0],t[1]):s.IsEqual(e,"Readonly")?Fa(t[0]):s.IsEqual(e,"KeyOf")?gi(t[0]):s.IsEqual(e,"Record")?la(t[0],t[1]):s.IsEqual(e,"Required")?La(t[0]):s.IsEqual(e,"ReturnType")?Da(t[0]):s.IsEqual(e,"Uncapitalize")?Ea(t[0]):s.IsEqual(e,"Uppercase")?Sa(t[0]):di(Be(e),t)}function Cn(){throw Error("Unreachable")}function Vg(e,t=[]){return s.ShiftLeft(e,(r,n)=>Vg(n,[...t,r[1]]),()=>t)}function Mr(e){return s.IsEqual(e.length,3)?[e[0],...Vg(e[1])]:[]}function Jg(e){return kn(e[0],e[2],e[4])}function Yg(e){return kn(e[0],e[2],e[2])}function Qg(e){return kn(e[0],Ne(),e[2])}function Xg(e){return kn(e,Ne(),Ne())}function Zg(e){return Mr(e)}function ey(e){return e[1]}function ty(e){return Mr(e)}function ry(e){return e[1]}function ny(e){return SP(e[0],e[1])}function oy(e){return null}function iy(e){return tt()}function sy(e){return wt()}function ay(e){return na()}function my(e){return ao()}function uy(e){return Zn()}function cy(e){return Sn()}function py(e){return oi()}function fy(e){return Ne()}function dy(e){return Qn()}function ly(e){return M({})}function gy(e){return ie()}function yy(e){return eo()}function xy(e){return ha()}function hy(e){return ya()}function Iy(e){return G(BigInt(e))}function by(e){return G(s.IsEqual(e,"true"))}function $y(e){return G(parseFloat(e))}function Ey(e){return G(e)}function Sy(e){return e[1]}function ky(e){return G(e)}function Ty(e){return s.IsEqual(e.length,3)?[e[0],e[1],...e[2]]:[e[0]]}function wy(e){return e[1]}function Cy(e){return Ia(e)}function Ry(e){return s.IsEqual(e.length,6)?$n(e[1],e[3],e[5]):$n(e[1],e[3],Ne())}function Py(e){return e.length>0}function Ay(e){return e.reduce((t,r)=>s.IsEqual(r.length,3)?[...t,[r[1]]]:[...t,[]],[])}function Oy(e){return s.IsEqual(e.length,6)?[e[1],e[3],e[5]]:[]}function My(e){return s.IsArray(e)&&s.IsEqual(e.length,3)?e[1]:e}function vy(e){return s.IsEqual(e.length,2)?e[1]:[]}function Kg(e,t){return t.reduce((r,n)=>{let o=n;return s.IsEqual(o.length,1)?li(r,o[0]):s.IsEqual(o.length,0)?xt(r):Cn()},e)}function Hg(e,t){return s.IsEqual(t.length,3)?ka(e,t[0],t[1],t[2]):e}function kP(e,t){return s.IsArray(t)&&s.IsEqual(t.length,0)?e:ja(e,t)}function Fy(e){let[t,r,n,o,i]=e;return kP(Hg(t?gi(Kg(r,n)):Kg(r,n),o),i)}function Ju(e,t){return s.IsEqual(t.length,3)?(()=>{let[r,n,o]=t,i=Ju(n,o);if(s.IsEqual(r,"&"))return O(i)?ot([e,...i.allOf]):ot([e,i]);if(s.IsEqual(r,"|"))return k(i)?D([e,...i.anyOf]):D([e,i]);Cn()})():e}function Ly(e){let[t,r]=e;return Ju(t,r)}function Dy(e){let[t,r]=e;return Ju(t,r)}function jy(e){return Kx(e[1])}function Ny(e){return e[1]}function qy(e){return Yr(e[0],e[2])}function _y(e){return s.IsEqual(e.length,4)?ei(e[1],e[3]):s.IsEqual(e.length,2)?ei(e[1],Ne()):Cn()}function Uy(e){return`${e}`}function By(e){return Ke(e[3])?Zr:xe(e[3])?oo:xr(e[3])?Zt:qe(e[3])?Zt:Cn()}function Gy(e){return e.length>0}function Ky(e){return e.length>0}function Hy(e){let[t,r,n,o,i]=e;return{[r]:t&&n?gr(dr(i)):t&&!n?gr(i):!t&&n?dr(i):i}}function zy(e){return Mr(e)}function Wy(e){return e.reduce((t,r)=>s.HasPropertyKey(r,Zr)||s.HasPropertyKey(r,oo)||s.HasPropertyKey(r,Zt)?[t[0],l.Assign(t[1],r)]:[l.Assign(t[0],r),t[1]],[{},{}])}function Vy(e){return Wy(e[1])}function Jy(e){let[t,r]=e,n=s.IsEqual(s.Keys(r).length,0)?{}:{patternProperties:r};return M(t,n)}function Yy(e){return s.IsEqual(e.length,5)?gr(dr(e[4])):s.IsEqual(e.length,3)?e[2]:s.IsEqual(e.length,4)?s.IsEqual(e[2],"readonly")?gr(e[3]):dr(e[3]):Cn()}function Qy(e){if(!s.IsArray(e)||!s.IsEqual(e.length,3))return e;let[t,r,n]=e;return t&&n?gr(dr(r)):t&&!n?gr(r):!t&&n?dr(r):r}function Xy(e){return s.IsEqual(e.length,2)?wn(e[1]):s.IsEqual(e.length,1)?e[0]:Cn()}function Zy(e){return Mr(e)}function ex(e){return we(e[1])}function tx(e){return gr(dr(e[4]))}function rx(e){return gr(e[3])}function nx(e){return dr(e[3])}function ox(e){return e[2]}function ix(e){return s.IsEqual(e.length,2)?wn(e[1]):s.IsEqual(e.length,1)?e[0]:Cn()}function sx(e){return Mr(e)}function ax(e){return fr(e[1],e[4])}function mx(e){return pr(e[2],e[5])}function zg(e,t){return s.IsEqual(e,"remove")?Hx(t):s.IsEqual(e,"add")?gr(t):t}function ux(e){return s.IsEqual(e.length,2)&&s.IsEqual(e[0],"-")?"remove":s.IsEqual(e.length,2)&&s.IsEqual(e[0],"+")||s.IsEqual(e.length,1)?"add":"none"}function Wg(e,t){return s.IsEqual(e,"remove")?Gx(t):s.IsEqual(e,"add")?dr(t):t}function cx(e){return s.IsEqual(e.length,2)&&s.IsEqual(e[0],"-")?"remove":s.IsEqual(e.length,2)&&s.IsEqual(e[0],"+")||s.IsEqual(e.length,1)?"add":"none"}function px(e){return s.IsEqual(e.length,2)?[e[1]]:[]}function fx(e){return s.IsArray(e[6])&&s.IsEqual(e[6].length,1)?pi(ii(e[3]),e[5],e[6][0],zg(e[1],Wg(e[8],e[10]))):pi(ii(e[3]),e[5],Be(e[3]),zg(e[1],Wg(e[8],e[10])))}function dx(e){return Be(e)}function lx(e){return BigInt(e)}function gx(e){return parseFloat(e)}function yx(e){return s.IsEqual(e,"true")}function xx(e){return null}function hx(e){return{[e[0]]:e[2]}}function Ix(e){return Mr(e)}function TP(e){return e.reduce((t,r)=>l.Assign(t,r),{})}function bx(e){return TP(e[1])}function $x(e){return Mr(e)}function Ex(e){return e[1]}function Sx(e){return oi()}function kx(e){return tt()}function Tx(e){return wt()}function wx(e){return Sn()}function Cx(e){return ie()}function Rx(e){return G(e)}function Px(e){return D(e[1])}function Ax(e){return e.length===3?[...e[0],...e[2]]:e.length===1?[...e[0]]:[]}function Ox(e){return[e[0],...e[1]]}function Mx(e){return e[1]}function vx(e){return Mr(e)}function Fx(e){return s.IsEqual(e.length,2)?e[1]:[]}function Lx(e){let t=e[2],r=e[3],[n,o]=e[4],i=s.IsEqual(s.Keys(o).length,0)?{}:{patternProperties:o};return{[e[1]]:Yr(t,fi(r,n,i))}}function Dx(e){let t=e[2],[r,n]=e[3],o=s.IsEqual(s.Keys(n).length,0)?{}:{patternProperties:n};return{[e[1]]:fi(t,r,o)}}function jx(e){return{[e[1]]:Yr(e[2],e[4])}}function Nx(e){return{[e[1]]:e[3]}}function qx(e){return null}function _x(e){return Mr(e)}function Ux(e){return e[1]}function Bx(e){let[t,r]=[e[0],e[1]];return Wx(l.Assign(t,Wy(r)[0]))}function yi(e){return Y(e.length,2)}function V(e,t,r){return yi(e)?t(e[0],e[1]):r()}function RP(e,t){return Y(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function be(e,t){for(let r=0;r<e.length;r++){let n=RP(e[r],t);if(yi(n))return n}return[]}function Yu(e,t){return Array.from({length:t-e+1},(r,n)=>String.fromCharCode(e+n))}var Vx=[...Yu(97,122),...Yu(65,90)],Qu="0",Xu=Yu(49,57),mo=[Qu,...Xu],Jx=" ",uo=`
|
|
2
|
+
`;var rn="_",Na=".",Yx="$",qa="-";var Qx="//",Xx="/*",AP="*/";function Zx(e){let t=e.indexOf(AP);return Y(t,-1)?"":e.slice(t+2)}function eh(e){let t=e.indexOf(uo);return Y(t,-1)?"":e.slice(t)}function OP(e){return e.replace(/^[ \t\r\f\v]+/,"")}function _a(e){let t=OP(e);return t.startsWith(Xx)?_a(Zx(t.slice(2))):t.startsWith(Qx)?_a(eh(t.slice(2))):t}function Qe(e){let t=e.trimStart();return t.startsWith(Xx)?Qe(Zx(t.slice(2))):t.startsWith(Qx)?Qe(eh(t.slice(2))):t}function Ua(e,t){return V(be([e],t),(r,n)=>[r,n],()=>["",t])}function MP(e,t){return e.includes(t)}function co(e,t,r,n=""){return V(be(e,r),(o,i)=>MP(t,o)?co(e,t,i,n):co(e,t,i,`${n}${o}`),()=>[n,r])}function vP(e){return be(Xu,e)}var FP=[...mo,rn];function LP(e){return co(FP,[rn],e)}function DP(e){return V(be([Qu],e),(t,r)=>[t,r],()=>V(vP(e),(t,r)=>V(LP(r),(n,o)=>[`${t}${n}`,o],()=>[]),()=>[]))}function Ba(e){return DP(Qe(e))}function jP(e){return Ua(qa,e)}function NP(e){return V(jP(e),(t,r)=>V(Ba(r),(n,o)=>[`${t}${n}`,o],()=>[]),()=>[])}function th(e){return NP(Qe(e))}function qP(e){return V(th(e),(t,r)=>V(be(["n"],r),(n,o)=>[`${t}`,o],()=>[]),()=>[])}function Zu(e){return qP(e)}function ec(e,t){return be([e],t)}function x(e,t){return Y(e,"")?["",t]:e.startsWith(uo)?ec(e,_a(t)):e.startsWith(Jx)?ec(e,t):ec(e,Qe(t))}var rh=[...Vx,rn,Yx];function _P(e){return be(rh,e)}var UP=[...rh,...mo];function nh(e,t=""){return V(be(UP,e),(r,n)=>nh(n,`${t}${r}`),()=>[t,e])}function BP(e){return V(_P(e),(t,r)=>V(nh(r),(n,o)=>[`${t}${n}`,o],()=>[]),()=>[])}function Re(e){return BP(Qe(e))}var GP=[...mo,rn];function KP(e){return yi(be([Na],e))}function oh(e){return V(co(GP,[rn],e),(t,r)=>Y(t,"")?[]:[t,r],()=>[])}function HP(e){return V(be([Na],e),(t,r)=>V(oh(r),(n,o)=>[`0${t}${n}`,o],()=>[]),()=>[])}function zP(e){return V(Ba(e),(t,r)=>V(be([Na],r),(n,o)=>V(oh(o),(i,a)=>[`${t}${n}${i}`,a],()=>[`${t}`,o]),()=>[`${t}`,r]),()=>[])}function WP(e){return KP(e)?HP(e):zP(e)}function ih(e){return WP(Qe(e))}function VP(e){return Ua(qa,e)}function JP(e){return V(VP(e),(t,r)=>V(ih(r),(n,o)=>[`${t}${n}`,o],()=>[]),()=>[])}function Ga(e){return JP(Qe(e))}function YP(e){return Y(e,"")?[]:[e.slice(0,1),e.slice(1)]}function sh(e,t){return Xi(e,(r,n)=>t.startsWith(r)?!0:sh(n,t),()=>!1)}function nn(e,t,r=""){return V(YP(t),(n,o)=>sh(e,t)?[r,t]:nn(e,o,`${r}${n}`),()=>[])}function QP(e,t,r){return V(be([e],r),(n,o)=>V(nn([t],o),(i,a)=>V(be([t],a),(m,c)=>[`${i}`,c],()=>[]),()=>[]),()=>[])}function XP(e,t,r){return V(be([e],r),(n,o)=>V(nn([uo,t],o),(i,a)=>V(be([t],a),(m,c)=>[`${i}`,c],()=>[]),()=>[]),()=>[])}function ah(e,t,r,n){return r?QP(e,t,Qe(n)):XP(e,t,Qe(n))}function ZP(e,t){return be(e,t)}function eA(e,t){return ah(e,e,!1,t)}function tA(e,t){return V(ZP(e,t),(r,n)=>eA(r,`${r}${n}`),()=>[])}function Ka(e,t){return tA(e,Qe(t))}function mh(e,t){return V(nn(e,t),(r,n)=>Y(r,"")?[]:[r,n],()=>[])}var u=(e,t,r=()=>[])=>e.length===2?t(e):r(),nA=e=>u(u(Re(e),([t,r])=>u(x("extends",r),([n,o])=>u(X(o),([i,a])=>u(x("=",a),([m,c])=>u(X(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[Jg(t),r]),oA=e=>u(u(Re(e),([t,r])=>u(x("extends",r),([n,o])=>u(X(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Yg(t),r]),iA=e=>u(u(Re(e),([t,r])=>u(x("=",r),([n,o])=>u(X(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Qg(t),r]),sA=e=>u(Re(e),([t,r])=>[Xg(t),r]),ph=e=>u(u(nA(e),([t,r])=>[t,r],()=>u(oA(e),([t,r])=>[t,r],()=>u(iA(e),([t,r])=>[t,r],()=>u(sA(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),fh=(e,t=[])=>u(u(x(",",e),([r,n])=>u(ph(n),([o,i])=>[[r,o],i])),([r,n])=>fh(n,[...t,r]),()=>[t,e]),aA=e=>u(u(u(ph(e),([t,r])=>u(fh(r),([n,o])=>u(u(x(",",o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Zg(t),r]),nc=e=>u(u(x("<",e),([t,r])=>u(aA(r),([n,o])=>u(x(">",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[ey(t),r]),dh=(e,t=[])=>u(u(x(",",e),([r,n])=>u(X(n),([o,i])=>[[r,o],i])),([r,n])=>dh(n,[...t,r]),()=>[t,e]),mA=e=>u(u(u(X(e),([t,r])=>u(dh(r),([n,o])=>u(u(x(",",o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[ty(t),r]),uA=e=>u(u(x("<",e),([t,r])=>u(mA(r),([n,o])=>u(x(">",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[ry(t),r]),cA=e=>u(u(Re(e),([t,r])=>u(uA(r),([n,o])=>[[t,n],o])),([t,r])=>[ny(t),r]),lh=e=>u(u(u(x(";",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[oy(t),r]),gh=e=>u(x("string",e),([t,r])=>[iy(t),r]),yh=e=>u(x("number",e),([t,r])=>[sy(t),r]),pA=e=>u(x("boolean",e),([t,r])=>[ay(t),r]),fA=e=>u(x("undefined",e),([t,r])=>[my(t),r]),dA=e=>u(x("null",e),([t,r])=>[uy(t),r]),xh=e=>u(x("integer",e),([t,r])=>[cy(t),r]),lA=e=>u(x("bigint",e),([t,r])=>[py(t),r]),gA=e=>u(x("unknown",e),([t,r])=>[fy(t),r]),yA=e=>u(x("any",e),([t,r])=>[dy(t),r]),xA=e=>u(x("object",e),([t,r])=>[ly(t),r]),hA=e=>u(x("never",e),([t,r])=>[gy(t),r]),hh=e=>u(x("symbol",e),([t,r])=>[yy(t),r]),IA=e=>u(x("void",e),([t,r])=>[xy(t),r]),bA=e=>u(x("this",e),([t,r])=>[hy(t),r]),$A=e=>u(u(x("${",e),([t,r])=>u(X(r),([n,o])=>u(x("}",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Sy(t),r]),tc=e=>u(nn(["${","`"],e),([t,r])=>[ky(t),r]),Ih=e=>u(u(u(tc(e),([t,r])=>u($A(r),([n,o])=>u(Ih(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u(u(tc(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u(u(tc(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[]))),([t,r])=>[Ty(t),r]),oc=e=>u(u(x("`",e),([t,r])=>u(Ih(r),([n,o])=>u(x("`",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[wy(t),r]),EA=e=>u(oc(e),([t,r])=>[Cy(t),r]),SA=e=>u(u(u(x("if",e),([t,r])=>u(X(r),([n,o])=>u(x("then",o),([i,a])=>u(X(a),([m,c])=>u(x("else",c),([p,f])=>u(X(f),([d,g])=>[[t,n,i,m,p,d],g])))))),([t,r])=>[t,r],()=>u(u(x("if",e),([t,r])=>u(X(r),([n,o])=>u(x("then",o),([i,a])=>u(X(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[t,r],()=>[])),([t,r])=>[Ry(t),r]),kA=e=>u(Zu(e),([t,r])=>[Iy(t),r]),TA=e=>u(u(x("true",e),([t,r])=>[t,r],()=>u(x("false",e),([t,r])=>[t,r],()=>[])),([t,r])=>[by(t),r]),wA=e=>u(Ga(e),([t,r])=>[$y(t),r]),CA=e=>u(Ka(["'",'"'],e),([t,r])=>[Ey(t),r]),RA=e=>u(u(u(x("keyof",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Py(t),r]),bh=(e,t=[])=>u(u(u(x("[",e),([r,n])=>u(X(n),([o,i])=>u(x("]",i),([a,m])=>[[r,o,a],m]))),([r,n])=>[r,n],()=>u(u(x("[",e),([r,n])=>u(x("]",n),([o,i])=>[[r,o],i])),([r,n])=>[r,n],()=>[])),([r,n])=>bh(n,[...t,r]),()=>[t,e]),PA=e=>u(bh(e),([t,r])=>[Ay(t),r]),AA=e=>u(u(u(x("extends",e),([t,r])=>u(X(r),([n,o])=>u(x("?",o),([i,a])=>u(X(a),([m,c])=>u(x(":",c),([p,f])=>u(X(f),([d,g])=>[[t,n,i,m,p,d],g])))))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Oy(t),r]),OA=e=>u(u(u(x("(",e),([t,r])=>u(X(r),([n,o])=>u(x(")",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u(gh(e),([t,r])=>[t,r],()=>u(yh(e),([t,r])=>[t,r],()=>u(pA(e),([t,r])=>[t,r],()=>u(fA(e),([t,r])=>[t,r],()=>u(dA(e),([t,r])=>[t,r],()=>u(xh(e),([t,r])=>[t,r],()=>u(lA(e),([t,r])=>[t,r],()=>u(gA(e),([t,r])=>[t,r],()=>u(yA(e),([t,r])=>[t,r],()=>u(xA(e),([t,r])=>[t,r],()=>u(hA(e),([t,r])=>[t,r],()=>u(hh(e),([t,r])=>[t,r],()=>u(IA(e),([t,r])=>[t,r],()=>u(bA(e),([t,r])=>[t,r],()=>u(kA(e),([t,r])=>[t,r],()=>u(TA(e),([t,r])=>[t,r],()=>u(wA(e),([t,r])=>[t,r],()=>u(CA(e),([t,r])=>[t,r],()=>u(EA(e),([t,r])=>[t,r],()=>u(SA(e),([t,r])=>[t,r],()=>u(BA(e),([t,r])=>[t,r],()=>u(HA(e),([t,r])=>[t,r],()=>u(QA(e),([t,r])=>[t,r],()=>u(YA(e),([t,r])=>[t,r],()=>u(tO(e),([t,r])=>[t,r],()=>u(cA(e),([t,r])=>[t,r],()=>u(rO(e),([t,r])=>[t,r],()=>[])))))))))))))))))))))))))))),([t,r])=>[My(t),r]),MA=e=>u(u(u(x("with",e),([t,r])=>u(jh(r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[vy(t),r]),$h=e=>u(u(RA(e),([t,r])=>u(OA(r),([n,o])=>u(PA(o),([i,a])=>u(AA(a),([m,c])=>u(MA(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[Fy(t),r]),Eh=e=>u(u(u(x("&",e),([t,r])=>u($h(r),([n,o])=>u(Eh(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[t,r]),Sh=e=>u(u($h(e),([t,r])=>u(Eh(r),([n,o])=>[[t,n],o])),([t,r])=>[Ly(t),r]),kh=e=>u(u(u(x("|",e),([t,r])=>u(Sh(r),([n,o])=>u(kh(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[t,r]),Ha=e=>u(u(Sh(e),([t,r])=>u(kh(r),([n,o])=>[[t,n],o])),([t,r])=>[Dy(t),r]),vA=e=>u(u(x("readonly",e),([t,r])=>u(Ha(r),([n,o])=>[[t,n],o])),([t,r])=>[jy(t),r]),FA=e=>u(u(x("|",e),([t,r])=>u(Ha(r),([n,o])=>[[t,n],o])),([t,r])=>[Ny(t),r]),LA=e=>u(u(nc(e),([t,r])=>u(x("=",r),([n,o])=>u(X(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[qy(t),r]),DA=e=>u(u(u(x("infer",e),([t,r])=>u(Re(r),([n,o])=>u(x("extends",o),([i,a])=>u(Ha(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[t,r],()=>u(u(x("infer",e),([t,r])=>u(Re(r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>[])),([t,r])=>[_y(t),r]),X=e=>u(u(DA(e),([t,r])=>[t,r],()=>u(FA(e),([t,r])=>[t,r],()=>u(vA(e),([t,r])=>[t,r],()=>u(Ha(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),jA=e=>u(Ga(e),([t,r])=>[Uy(t),r]),NA=e=>u(Re(e),([t,r])=>[t,r]),qA=e=>u(Ka(["'",'"'],e),([t,r])=>[t,r]),_A=e=>u(u(x("[",e),([t,r])=>u(Re(r),([n,o])=>u(x(":",o),([i,a])=>u(u(xh(a),([m,c])=>[m,c],()=>u(yh(a),([m,c])=>[m,c],()=>u(gh(a),([m,c])=>[m,c],()=>u(hh(a),([m,c])=>[m,c],()=>[])))),([m,c])=>u(x("]",c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[By(t),r]),Th=e=>u(u(jA(e),([t,r])=>[t,r],()=>u(NA(e),([t,r])=>[t,r],()=>u(qA(e),([t,r])=>[t,r],()=>u(_A(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),wh=e=>u(u(u(x("readonly",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Gy(t),r]),Ch=e=>u(u(u(x("?",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Ky(t),r]),Rh=e=>u(u(wh(e),([t,r])=>u(Th(r),([n,o])=>u(Ch(o),([i,a])=>u(x(":",a),([m,c])=>u(X(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[Hy(t),r]),za=e=>u(u(u(x(",",e),([t,r])=>u(x(`
|
|
3
|
+
`,r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x(";",e),([t,r])=>u(x(`
|
|
4
|
+
`,r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x(",",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u(u(x(";",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u(u(x(`
|
|
5
|
+
`,e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[]))))),([t,r])=>[t,r]),Ph=(e,t=[])=>u(u(za(e),([r,n])=>u(Rh(n),([o,i])=>[[r,o],i])),([r,n])=>Ph(n,[...t,r]),()=>[t,e]),UA=e=>u(u(u(Rh(e),([t,r])=>u(Ph(r),([n,o])=>u(u(za(o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[zy(t),r]),ic=e=>u(u(x("{",e),([t,r])=>u(UA(r),([n,o])=>u(x("}",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Vy(t),r]),BA=e=>u(ic(e),([t,r])=>[Jy(t),r]),GA=e=>u(u(u(Re(e),([t,r])=>u(x("?",r),([n,o])=>u(x(":",o),([i,a])=>u(x("readonly",a),([m,c])=>u(X(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[t,r],()=>u(u(Re(e),([t,r])=>u(x(":",r),([n,o])=>u(x("readonly",o),([i,a])=>u(X(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[t,r],()=>u(u(Re(e),([t,r])=>u(x("?",r),([n,o])=>u(x(":",o),([i,a])=>u(X(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[t,r],()=>u(u(Re(e),([t,r])=>u(x(":",r),([n,o])=>u(X(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>[])))),([t,r])=>[Yy(t),r]),uh=e=>u(u(GA(e),([t,r])=>[t,r],()=>u(u(wh(e),([t,r])=>u(X(r),([n,o])=>u(Ch(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>[])),([t,r])=>[Qy(t),r]),Ah=e=>u(u(u(x("...",e),([t,r])=>u(uh(r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(uh(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[])),([t,r])=>[Xy(t),r]),Oh=(e,t=[])=>u(u(x(",",e),([r,n])=>u(Ah(n),([o,i])=>[[r,o],i])),([r,n])=>Oh(n,[...t,r]),()=>[t,e]),KA=e=>u(u(u(Ah(e),([t,r])=>u(Oh(r),([n,o])=>u(u(x(",",o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Zy(t),r]),HA=e=>u(u(x("[",e),([t,r])=>u(KA(r),([n,o])=>u(x("]",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[ex(t),r]),zA=e=>u(u(Re(e),([t,r])=>u(x("?",r),([n,o])=>u(x(":",o),([i,a])=>u(x("readonly",a),([m,c])=>u(X(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[tx(t),r]),WA=e=>u(u(Re(e),([t,r])=>u(x(":",r),([n,o])=>u(x("readonly",o),([i,a])=>u(X(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[rx(t),r]),VA=e=>u(u(Re(e),([t,r])=>u(x("?",r),([n,o])=>u(x(":",o),([i,a])=>u(X(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[nx(t),r]),JA=e=>u(u(Re(e),([t,r])=>u(x(":",r),([n,o])=>u(X(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[ox(t),r]),ch=e=>u(u(zA(e),([t,r])=>[t,r],()=>u(WA(e),([t,r])=>[t,r],()=>u(VA(e),([t,r])=>[t,r],()=>u(JA(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),Mh=e=>u(u(u(x("...",e),([t,r])=>u(ch(r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(ch(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[])),([t,r])=>[ix(t),r]),vh=(e,t=[])=>u(u(x(",",e),([r,n])=>u(Mh(n),([o,i])=>[[r,o],i])),([r,n])=>vh(n,[...t,r]),()=>[t,e]),Fh=e=>u(u(u(Mh(e),([t,r])=>u(vh(r),([n,o])=>u(u(x(",",o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[sx(t),r]),YA=e=>u(u(x("(",e),([t,r])=>u(Fh(r),([n,o])=>u(x(")",o),([i,a])=>u(x("=>",a),([m,c])=>u(X(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[ax(t),r]),QA=e=>u(u(x("new",e),([t,r])=>u(x("(",r),([n,o])=>u(Fh(o),([i,a])=>u(x(")",a),([m,c])=>u(x("=>",c),([p,f])=>u(X(f),([d,g])=>[[t,n,i,m,p,d],g])))))),([t,r])=>[mx(t),r]),XA=e=>u(u(u(x("+",e),([t,r])=>u(x("readonly",r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x("-",e),([t,r])=>u(x("readonly",r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x("readonly",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])))),([t,r])=>[ux(t),r]),ZA=e=>u(u(u(x("+",e),([t,r])=>u(x("?",r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x("-",e),([t,r])=>u(x("?",r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x("?",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])))),([t,r])=>[cx(t),r]),eO=e=>u(u(u(x("as",e),([t,r])=>u(X(r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[px(t),r]),tO=e=>u(u(x("{",e),([t,r])=>u(XA(r),([n,o])=>u(x("[",o),([i,a])=>u(Re(a),([m,c])=>u(x("in",c),([p,f])=>u(X(f),([d,g])=>u(eO(g),([y,I])=>u(x("]",I),([h,$])=>u(ZA($),([b,w])=>u(x(":",w),([S,z])=>u(X(z),([oe,ee])=>u(lh(ee),([j,lt])=>u(x("}",lt),([gt,ir])=>[[t,n,i,m,p,d,y,h,b,S,oe,j,gt],ir]))))))))))))),([t,r])=>[fx(t),r]),rO=e=>u(Re(e),([t,r])=>[dx(t),r]),nO=e=>u(Zu(e),([t,r])=>[lx(t),r]),oO=e=>u(Ga(e),([t,r])=>[gx(t),r]),iO=e=>u(u(x("true",e),([t,r])=>[t,r],()=>u(x("false",e),([t,r])=>[t,r],()=>[])),([t,r])=>[yx(t),r]),sO=e=>u(Ka(['"',"'"],e),([t,r])=>[t,r]),aO=e=>u(x("null",e),([t,r])=>[xx(t),r]),mO=e=>u(x("undefined",e),([t,r])=>[void 0,r]),Lh=e=>u(u(Th(e),([t,r])=>u(x(":",r),([n,o])=>u(sc(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[hx(t),r]),Dh=(e,t=[])=>u(u(za(e),([r,n])=>u(Lh(n),([o,i])=>[[r,o],i])),([r,n])=>Dh(n,[...t,r]),()=>[t,e]),uO=e=>u(u(u(Lh(e),([t,r])=>u(Dh(r),([n,o])=>u(u(za(o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Ix(t),r]),jh=e=>u(u(x("{",e),([t,r])=>u(uO(r),([n,o])=>u(x("}",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[bx(t),r]),Nh=(e,t=[])=>u(u(x(",",e),([r,n])=>u(sc(n),([o,i])=>[[r,o],i])),([r,n])=>Nh(n,[...t,r]),()=>[t,e]),cO=e=>u(u(u(sc(e),([t,r])=>u(Nh(r),([n,o])=>u(u(x(",",o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[$x(t),r]),pO=e=>u(u(x("[",e),([t,r])=>u(cO(r),([n,o])=>u(x("]",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Ex(t),r]),sc=e=>u(u(nO(e),([t,r])=>[t,r],()=>u(oO(e),([t,r])=>[t,r],()=>u(iO(e),([t,r])=>[t,r],()=>u(sO(e),([t,r])=>[t,r],()=>u(aO(e),([t,r])=>[t,r],()=>u(mO(e),([t,r])=>[t,r],()=>u(jh(e),([t,r])=>[t,r],()=>u(pO(e),([t,r])=>[t,r],()=>[])))))))),([t,r])=>[t,r]),fO=e=>u(x("-?(?:0|[1-9][0-9]*)n",e),([t,r])=>[Sx(t),r]),dO=e=>u(x(".*",e),([t,r])=>[kx(t),r]),lO=e=>u(x("-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?",e),([t,r])=>[Tx(t),r]),gO=e=>u(x("-?(?:0|[1-9][0-9]*)",e),([t,r])=>[wx(t),r]),yO=e=>u(x("(?!)",e),([t,r])=>[Cx(t),r]),xO=e=>u(mh(["-?(?:0|[1-9][0-9]*)n",".*","-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?","-?(?:0|[1-9][0-9]*)","(?!)","(",")","$","|"],e),([t,r])=>[Rx(t),r]),hO=e=>u(u(fO(e),([t,r])=>[t,r],()=>u(dO(e),([t,r])=>[t,r],()=>u(lO(e),([t,r])=>[t,r],()=>u(gO(e),([t,r])=>[t,r],()=>u(yO(e),([t,r])=>[t,r],()=>u(IO(e),([t,r])=>[t,r],()=>u(xO(e),([t,r])=>[t,r],()=>[]))))))),([t,r])=>[t,r]),IO=e=>u(u(x("(",e),([t,r])=>u(ac(r),([n,o])=>u(x(")",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Px(t),r]),qh=e=>u(u(u(rc(e),([t,r])=>u(x("|",r),([n,o])=>u(qh(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u(u(rc(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[]))),([t,r])=>[Ax(t),r]),rc=e=>u(u(hO(e),([t,r])=>u(ac(r),([n,o])=>[[t,n],o])),([t,r])=>[Ox(t),r]),ac=e=>u(u(qh(e),([t,r])=>[t,r],()=>u(rc(e),([t,r])=>[t,r],()=>[])),([t,r])=>[t,r]),dg=e=>u(u(x("^",e),([t,r])=>u(ac(r),([n,o])=>u(x("$",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Mx(t),r]),_h=(e,t=[])=>u(u(x(",",e),([r,n])=>u(X(n),([o,i])=>[[r,o],i])),([r,n])=>_h(n,[...t,r]),()=>[t,e]),bO=e=>u(u(u(X(e),([t,r])=>u(_h(r),([n,o])=>u(u(x(",",o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[vx(t),r]),Uh=e=>u(u(u(x("extends",e),([t,r])=>u(bO(r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Fx(t),r]),$O=e=>u(u(x("interface",e),([t,r])=>u(Re(r),([n,o])=>u(nc(o),([i,a])=>u(Uh(a),([m,c])=>u(ic(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[Lx(t),r]),EO=e=>u(u(x("interface",e),([t,r])=>u(Re(r),([n,o])=>u(Uh(o),([i,a])=>u(ic(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[Dx(t),r]),SO=e=>u(u(x("type",e),([t,r])=>u(Re(r),([n,o])=>u(nc(o),([i,a])=>u(x("=",a),([m,c])=>u(X(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[jx(t),r]),kO=e=>u(u(x("type",e),([t,r])=>u(Re(r),([n,o])=>u(x("=",o),([i,a])=>u(X(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[Nx(t),r]),TO=e=>u(u(u(x("export",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[qx(t),r]),Bh=e=>u(u(u(x(";",e),([t,r])=>u(x(`
|
|
6
|
+
`,r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x(";",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u(u(x(`
|
|
7
|
+
`,e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[]))),([t,r])=>[t,r]),Gh=(e,t=[])=>u(u(Bh(e),([r,n])=>u(mc(n),([o,i])=>[[r,o],i])),([r,n])=>Gh(n,[...t,r]),()=>[t,e]),wO=e=>u(u(u(mc(e),([t,r])=>u(Gh(r),([n,o])=>u(u(Bh(o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[_x(t),r]),mc=e=>u(u(TO(e),([t,r])=>u(u($O(r),([n,o])=>[n,o],()=>u(EO(r),([n,o])=>[n,o],()=>u(SO(r),([n,o])=>[n,o],()=>u(kO(r),([n,o])=>[n,o],()=>[])))),([n,o])=>u(lh(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Ux(t),r]),CO=e=>u(u(mc(e),([t,r])=>u(wO(r),([n,o])=>[[t,n],o])),([t,r])=>[Bx(t),r]),Kh=e=>u(u(CO(e),([t,r])=>[t,r],()=>u(LA(e),([t,r])=>[t,r],()=>u(X(e),([t,r])=>[t,r],()=>[]))),([t,r])=>[t,r]);function Hh(e){let t=oc(`\`${e}\``);return s.IsEqual(t.length,2)?t[0]:$e()}function PO(e){return e.join("|")}function AO(e){return e.slice(1,e.length-1)}function OO(e,t,r){return on(t,`${r}${e}`)}function MO(e,t){return on(e,`${t}${ag}`)}function vO(e,t){return on(e,`${t}${oa}`)}function FO(e,t){return on(e,`${t}${ma}`)}function LO(e,t){return xi(D([G("false"),G("true")]),e,t)}function DO(e,t){return on(e,`${t}${ua}`)}function jO(e,t,r){return on(t,`${r}${AO(e)}`)}function NO(e,t,r){let n=hi(e,{});return xi(n,t,r)}function qO(e,t,r){let n=dt(e);return xi(n,t,r)}function zh(e,t,r,n=[]){return s.ShiftLeft(e,(o,i)=>zh(i,t,r,[...n,xi(o,[],"")]),()=>on(t,`${r}(${PO(n)})`))}function xi(e,t,r){return Te(e)?qO(e.enum,t,r):Ke(e)?vO(t,r):H(e)?OO(e.const,t,r):Tt(e)?MO(t,r):ft(e)?LO(t,r):xe(e)?FO(t,r):qe(e)?DO(t,r):ue(e)?jO(e.pattern,t,r):Vh(e)?NO(e.parameters[0],t,r):k(e)?zh(e.anyOf,t,r):Hl}function on(e,t){return s.ShiftLeft(e,(r,n)=>xi(r,n,t),()=>t)}function _O(e){return`^${on(e,"")}$`}function Wh(e){let t=_O(e);return pa(t)}function hi(e,t){return U(e)?l.Update(Wh(e),{},t):Ia(e,t)}function Jh(e,t,r,n){let o=Lt(e,t,r);return hi(o,n)}function Ia(e,t={}){return R("TemplateLiteral",[e],t)}function Vh(e){return ye(e)&&s.HasPropertyKey(e,"action")&&s.IsEqual(e.action,"TemplateLiteral")}function Yh(e){return hi(e,{})}function UO(e){let t=Hh(e);return Yh(t)}function Qh(e,t={}){let r=s.IsString(e)?UO(e):Yh(e);return l.Update(r,{},t)}function ue(e){return C(e,"TemplateLiteral")}var F={};Ot(F,{ExtendsFalse:()=>q,ExtendsTrue:()=>T,ExtendsUnion:()=>uc,IsExtendsFalse:()=>BO,IsExtendsTrue:()=>Zh,IsExtendsTrueLike:()=>hr,IsExtendsUnion:()=>Xh,Match:()=>Pe});function uc(e){return l.Create({"~kind":"ExtendsUnion"},{inferred:e})}function Xh(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"inferred")&&s.IsEqual(e["~kind"],"ExtendsUnion")&&s.IsObject(e.inferred)}function T(e){return l.Create({"~kind":"ExtendsTrue"},{inferred:e})}function Zh(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"inferred")&&s.IsEqual(e["~kind"],"ExtendsTrue")&&s.IsObject(e.inferred)}function q(){return l.Create({"~kind":"ExtendsFalse"},{})}function BO(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.IsEqual(e["~kind"],"ExtendsFalse")}function hr(e){return Xh(e)||Zh(e)}function Pe(e,t,r){return hr(e)?t(e.inferred):r()}function GO(e,t,r,n){return Pe(J(e,r,n),o=>T(l.Assign(l.Assign(e,o),{[t]:r})),()=>q())}function KO(e,t){return T(e)}function HO(e,t,r,n,o){return Pe(J(e,t,r),i=>Pe(J(i,t,n),a=>T(a),()=>q()),()=>Pe(J(e,t,o),i=>T(i),()=>q()))}function zO(e,t,r){let n=dt(r);return J(e,t,n)}function eI(e,t,r){return s.ShiftLeft(r,(n,o)=>Pe(J(e,t,n),i=>eI(i,t,o),()=>q()),()=>T(e))}function WO(e,t,r){let n=it(r);return J(e,t,n)}function tI(e,t,r){return s.ShiftLeft(r,(n,o)=>Pe(J(e,t,n),i=>T(i),()=>tI(e,t,o)),()=>q())}function re(e,t,r){return Ie(r)?KO(e,t):ke(r)?HO(e,t,r.if,r.then,r.else):Te(r)?zO(e,t,r.enum):Le(r)?GO(e,r.name,t,r.extends):O(r)?eI(e,t,r.allOf):ue(r)?WO(e,t,r.pattern):k(r)?tI(e,t,r.anyOf):Fe(r)?T(e):q()}function rI(e,t,r){return Le(r)?re(e,t,r):Ie(r)?T(e):Fe(r)?T(e):uc(e)}function VO(e,t){let r=En(e),n=En(t);return r&&n||!r&&n?!0:!(r&&!n)}function nI(e,t,r,n){return W(n)?VO(t,n)?J(e,r,n.items):q():re(e,t,n)}function oI(e,t,r){return Tt(r)?T(e):re(e,t,r)}function iI(e,t,r){return ft(r)?T(e):re(e,t,r)}function JO(e,t,r,n,o){let i=Le(n)?t:n,a=Le(n)?n:t,m=ve(t),c=ve(n);return!m&&c?q():Pe(J(e,i,a),p=>Ii(p,r,o),()=>q())}function YO(e,t,r,n){return s.ShiftLeft(n,(o,i)=>JO(e,t,r,o,i),()=>ve(t)?T(e):q())}function QO(e,t,r){return s.ShiftLeft(t,(n,o)=>YO(e,n,o,r),()=>T(e))}function Ii(e,t,r){return QO(e,t,r)}function Wa(e,t,r){return Ct(r)?T(e):J(e,t,r)}function sI(e,t,r,n){return Ie(n)?T(e):Fe(n)?T(e):Ee(n)?Pe(Ii(e,t,n.parameters),o=>Wa(o,r,n.instanceType),()=>q()):q()}function aI(e,t,r,n,o){return Pe(J(e,t,o),()=>J(e,r,o),()=>J(e,n,o))}function mI(e,t,r){let n=dt(t);return J(e,n,r)}function uI(e,t,r,n){return Ie(n)?T(e):Fe(n)?T(e):Se(n)?Pe(Ii(e,t,n.parameters),o=>Wa(o,r,n.returnType),()=>q()):q()}function cI(e,t,r){return Ke(r)?T(e):xe(r)?T(e):re(e,t,r)}function pI(e,t,r){let n=Ce(t);return J(e,n,r)}function Va(e,t,r){return t===r?T(e):q()}function XO(e,t,r){return H(r)?Va(e,t,r.const):Tt(r)?T(e):re(e,G(t),r)}function ZO(e,t,r){return H(r)?Va(e,t,r.const):ft(r)?T(e):re(e,G(t),r)}function eM(e,t,r){return H(r)?Va(e,t,r.const):xe(r)?T(e):re(e,G(t),r)}function tM(e,t,r){return H(r)?Va(e,t,r.const):qe(r)?T(e):re(e,G(t),r)}function fI(e,t,r){return s.IsBigInt(t.const)?XO(e,t.const,r):s.IsBoolean(t.const)?ZO(e,t.const,r):s.IsNumber(t.const)?eM(e,t.const,r):s.IsString(t.const)?tM(e,t.const,r):$e()}function dI(e,t,r){return Le(r)?re(e,t,r):T(e)}function lI(e,t,r){return yr(r)?T(e):re(e,t,r)}function gI(e,t,r){return xe(r)?T(e):re(e,t,r)}function rM(e,t,r){return ve(t)?ve(r)?T(e):q():T(e)}function nM(e,t,r){return Le(r)&&ht(r.extends)?q():Pe(J(e,t,r),n=>rM(n,t,r),()=>q())}function oM(e,t){return e.reduce((r,n)=>n in t?hr(t[n])?{...r,...t[n].inferred}:$e():$e(),{})}function iM(e,t,r){let n={};for(let a of s.Keys(r))n[a]=a in t?nM({},t[a],r[a]):ve(r[a])?Le(r[a])?T(l.Assign(e,{[r[a].name]:r[a].extends})):T(e):q();let o=s.Values(n).every(a=>hr(a)),i=o?oM(s.Keys(n),n):{};return o?T(i):q()}function sM(e,t,r){let n=iM(e,t,r);return hr(n)?T(l.Assign(e,n.inferred)):q()}function aM(e,t,r){return sM(e,t,r)}function mM(e,t){return s.Keys(t).reduce((r,n)=>({...r,[n]:s.HasPropertyKey(e,n)?k(r[n])?D([...r[n].anyOf,t[n]]):D([e[n],t[n]]):t[n]}),e)}function yI(e,t,r,n){return s.ShiftLeft(t,(o,i)=>Pe(J({},e[o],r),a=>yI(e,i,r,mM(n,a)),()=>q()),()=>T(n))}function uM(e,t,r,n){let o=s.Keys(t);return yI(t,o,n,e)}function xI(e,t,r){return ne(r)?uM(e,t,De(r),pe(r)):A(r)?aM(e,t,r.properties):re(e,M(t),r)}function cM(e,t){return s.IsEqual(s.Keys(t).length,0)?T(e):q()}function pM(e,t,r,n,o){return J(e,r,o)}function hI(e,t,r,n){return ne(n)?pM(e,ga(t),r,ga(De(n)),pe(n)):A(n)?cM(e,n.properties):Ie(n)?T(e):Fe(n)?T(e):q()}function II(e,t,r){return qe(r)?T(e):re(e,t,r)}function bI(e,t,r){return xr(r)?T(e):re(e,t,r)}function $I(e,t,r){let n=it(t);return J(e,n,r)}function cc(e,t){return l.Create({"~kind":"Inferrable"},{name:e,type:t},{})}function bi(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"name")&&s.HasPropertyKey(e,"type")&&s.IsEqual(e["~kind"],"Inferrable")&&s.IsString(e.name)&&s.IsObject(e.type)}function pc(e){return tn(e)?Le(e.items)?W(e.items.extends)?cc(e.items.name,e.items.extends.items):Fe(e.items.extends)?cc(e.items.name,e.items.extends):void 0:$e():void 0}function Ja(e){return Le(e)?cc(e.name,e.extends):void 0}function EI(e,t){let r=[];for(let n of e){if(!hr(J({},n,t)))return;r.push(n)}return r}function SI(e,t,r,n){let o=EI(r,n);return s.IsArray(o)?T(l.Assign(e,{[t]:we(o)})):q()}function Ya(e,t,r,n){let o=EI(r,n);return s.IsArray(o)?T(l.Assign(e,{[t]:D(o)})):q()}function fM(e){return[...e].reverse()}function fc(e,t){return t?fM(e):e}function dM(e){let t=e.length>0?e[0]:void 0,r=ye(t)?pc(t):void 0;return ye(r)}function lM(e,t,r,n,o,i){return Pe(J(e,r,o),a=>kI(a,t,n,i),()=>q())}function gM(e,t,r,n,o){let i=pc(n);return bi(i)?SI(e,i.name,fc(r,t),i.type):s.ShiftLeft(r,(a,m)=>lM(e,t,a,m,n,o),()=>q())}function yM(e,t,r,n){return s.ShiftLeft(n,(o,i)=>gM(e,t,r,o,i),()=>s.IsEqual(r.length,0)?T(e):q())}function kI(e,t,r,n){return yM(e,t,r,n)}function xM(e,t,r){let n=sn(e,de([],[]),r),o=dM(n);return kI(e,o,fc(t,o),fc(n,o))}function hM(e,t,r){for(let n of t){let o=J(e,n,r);if(!hr(o))return o;e=o.inferred}return T(e)}function IM(e,t,r){let n=Ja(r);return bi(n)?Ya(e,n.name,t,n.type):hM(e,t,r)}function TI(e,t,r){let n=sn(e,de([],[]),t);return _(r)?xM(e,n,r.items):W(r)?IM(e,n,r.items):re(e,we(n),r)}function wI(e,t,r){return Ct(r)?T(e):Kt(r)?T(e):re(e,t,r)}function CI(e,t,r){return s.ShiftLeft(r,(n,o)=>Pe(J(e,t,n),i=>T(i),()=>CI(e,t,o)),()=>q())}function dc(e,t,r){return s.ShiftLeft(t,(n,o)=>Pe(CI(e,n,r),i=>dc(i,o,r),()=>q()),()=>T(e))}function RI(e,t,r){let n=Ja(r);return bi(n)?Ya(e,n.name,t,n.type):k(r)?dc(e,t,r.anyOf):dc(e,t,[r])}function PI(e,t,r){return Le(r)?re(e,t,r):Ie(r)?T(e):Fe(r)?T(e):q()}function AI(e,t,r){return Ct(r)?T(e):re(e,t,r)}function J(e,t,r){return Ie(t)?rI(e,t,r):W(t)?nI(e,t,t.items,r):Tt(t)?oI(e,t,r):ft(t)?iI(e,t,r):Ee(t)?sI(e,t.parameters,t.instanceType,r):ke(t)?aI(e,t.if,t.then,t.else,r):Te(t)?mI(e,t.enum,r):Se(t)?uI(e,t.parameters,t.returnType,r):Ke(t)?cI(e,t,r):O(t)?pI(e,t.allOf,r):H(t)?fI(e,t,r):ht(t)?dI(e,t,r):yr(t)?lI(e,t,r):xe(t)?gI(e,t,r):A(t)?xI(e,t.properties,r):ne(t)?hI(e,De(t),pe(t),r):qe(t)?II(e,t,r):xr(t)?bI(e,t,r):ue(t)?$I(e,t.pattern,r):_(t)?TI(e,t.items,r):Kt(t)?wI(e,t,r):k(t)?RI(e,t.anyOf,r):Fe(t)?PI(e,t,r):Ct(t)?AI(e,t,r):q()}function bM(e,t){return Ce([...e,M(t)])}function lc(e,t,r){return U(e)?l.Update(bM(e,t),{},r):fi(e,t,r)}function OI(e,t,r,n,o){let i=Lt(e,t,r),a=$i(e,t,n);return lc(i,a,o)}function fi(e,t,r={}){return R("Interface",[e,t],r)}function po(e){return ye(e)&&s.HasPropertyKey(e,"action")&&s.IsEqual(e.action,"Interface")}function MI(e,t,r={}){return lc(e,t,r)}function $M(e,t,r){return e.includes(r)?!0:Ei([...e,r],t,t[r])}function vI(e,t,r){let n=Zs(r);return Rn(e,t,n)}function Rn(e,t,r){return s.ShiftLeft(r,(n,o)=>Ei(e,t,n)?!0:Rn(e,t,o),()=>!1)}function Ei(e,t,r){return te(r)?$M(e,t,r.$ref):W(r)?Ei(e,t,r.items):Ee(r)?Rn(e,t,[...r.parameters,r.instanceType]):Se(r)?Rn(e,t,[...r.parameters,r.returnType]):po(r)?vI(e,t,r.parameters[1]):O(r)?Rn(e,t,r.allOf):A(r)?vI(e,t,r.properties):k(r)?Rn(e,t,r.anyOf):_(r)?Rn(e,t,r.items):ne(r)?Ei(e,t,pe(r)):!1}function FI(e,t,r){return Ei(e,t,r)}function EM(e,t){return t.reduce((r,n)=>FI([n],e,e[n])?[...r,n]:r,[])}function LI(e){let t=Xs(e);return EM(e,t)}function SM(e,t,r){return r.includes(t)?r:t in e?Si(e,e[t],[...r,t]):$e()}function DI(e,t,r){let n=Zs(t);return fo(e,n,r)}function fo(e,t,r){return t.reduce((n,o)=>Si(e,o,n),r)}function Si(e,t,r){return te(t)?SM(e,t.$ref,r):W(t)?Si(e,t.items,r):Ee(t)?fo(e,[...t.parameters,t.instanceType],r):Se(t)?fo(e,[...t.parameters,t.returnType],r):po(t)?DI(e,t.parameters[1],r):O(t)?fo(e,t.allOf,r):A(t)?DI(e,t.properties,r):k(t)?fo(e,t.anyOf,r):_(t)?fo(e,t.items,r):ne(t)?Si(e,pe(t),r):r}function jI(e,t,r){return Si(e,r,[t])}function kM(e){return Qn()}function TM(e){return s.Keys(e).reduce((t,r)=>({...t,[r]:Pn(e[r])}),{})}function ki(e){return e.reduce((t,r)=>[...t,Pn(r)],[])}function Pn(e){return te(e)?kM(e.$ref):W(e)?xt(Pn(e.items),Jn(e)):Ee(e)?pr(ki(e.parameters),Pn(e.instanceType)):Se(e)?fr(ki(e.parameters),Pn(e.returnType)):O(e)?ot(ki(e.allOf)):A(e)?M(TM(e.properties)):ne(e)?io(so(e),Pn(pe(e))):k(e)?D(ki(e.anyOf)):_(e)?we(ki(e.items)):e}function wM(e,t){return t in e?Pn(e[t]):Ne()}function NI(e){return wM(e.$defs,e.$ref)}function CM(e,t,r){let n=Lt(e,de([],[]),t),o=$i({},de([],[]),r);return Ce([...n,M(o)])}function RM(e,t){return s.Keys(e).filter(n=>t.includes(n)).reduce((n,o)=>{let i=e[o],a=po(i)?CM(e,i.parameters[0],i.parameters[1]):i;return{...n,[o]:a}},{})}function qI(e,t,r){let n=jI(e,t,r),o=RM(e,n);return lr(o,t)}function _I(e,t){return t in e?te(e[t])?_I(e,e[t].$ref):e[t]:ie()}function Ir(e,t){return _I(e,t)}function UI(e){return me(e)?NI(e):ea(e)?Ne():e}function rt(e,t,r){let n=UI(t),o=UI(r);return J(e,n,o)}var ai=0,Ti=1,mi=2,ui=3;function no(e,t){let r=[rt({},e,t),rt({},t,e)];return F.IsExtendsTrueLike(r[0])&&F.IsExtendsTrueLike(r[1])?ai:F.IsExtendsTrueLike(r[0])&&F.IsExtendsFalse(r[1])?mi:F.IsExtendsFalse(r[0])&&F.IsExtendsTrueLike(r[1])?ui:Ti}function gc(e,t,r=[],n=t){return s.ShiftLeft(t,(o,i)=>{let a=no(e,o);return s.IsEqual(a,mi)||s.IsEqual(a,ai)?n:s.IsEqual(a,Ti)?gc(e,i,[...r,o],n):gc(e,i,r,n)},()=>[...r,e])}function PM(e,t,r){let n=Gt(e);return Ie(n)?[n]:Fe(n)?[n]:ht(n)?Qa(t,r):A(n)?Qa(t,[...r,n]):Qa(t,gc(n,r))}function Qa(e,t=[]){return s.ShiftLeft(e,(r,n)=>PM(r,n,t),()=>t)}function Wu(e){let t=Qa(e);return en(t)}function yc(e,t){return l.Update(Gt(e),{},t)}function BI(e,t,r,n){let o=E(e,t,r);return yc(o,n)}function wi(e,t=[]){return Jr(e)&&s.IsEqual(e.action,"Conditional")?te(e.parameters[0])?wi(e.parameters[2],wi(e.parameters[3],[...t,e.parameters[0].$ref])):wi(e.parameters[2],wi(e.parameters[3],t)):Jr(e)&&s.IsEqual(e.action,"Mapped")&&Jr(e.parameters[1])&&s.IsEqual(e.parameters[1].action,"KeyOf")&&te(e.parameters[1].parameters[0])?[...t,e.parameters[1].parameters[0].$ref]:t}function AM(e,t){return e.reduce((r,n)=>[...r,t.includes(n.name)],[])}function HI(e,t,r=[]){return s.ShiftLeft(e,(n,o)=>s.ShiftLeft(t,(i,a)=>HI(o,a,[...r,[i,n]]),()=>r),()=>r)}function OM(e){return ue(e)?it(e.pattern):Te(e)?dt(e.enum):e}function MM(e){let t=OM(e);return k(t)?[...t.anyOf]:[t]}function vM(e,t){return e.reduce((r,n)=>[...r,[...n,t]],[])}function GI(e,t){return t.reduce((r,n)=>[...r,...vM(e,n)],[])}function KI(e){return e.reduce((t,r)=>s.IsEqual(r[0],!0)?GI(t,MM(r[1])):GI(t,[r[1]]),[[]])}function zI(e,t,r){let n=wi(r),o=AM(e,n),i=HI(t,o);return Jr(r)&&s.IsEqual(r.action,"Conditional")||Jr(r)&&s.IsEqual(r.action,"Mapped")?KI(i):[t]}function FM(){return["(not-resolvable)",ie()]}function LM(){return["(not-generic)",ie()]}function DM(e,t,r){return[e,Yr(t,r)]}function jM(e,t,r){return t in e?WI(e,t,e[t],r):FM()}function WI(e,t,r,n){return Yn(r)?DM(t,r.parameters,r.expression):te(r)?jM(e,r.$ref,n):LM()}function VI(e,t,r){return WI(e,"(anonymous)",t,r)}function NM(e,t,r){if(Le(t)||lo(t)||F.IsExtendsTrueLike(rt({},t,r)))return;let n={parameter:e,expect:r,actual:t};throw new Error(`Argument for parameter ${e} does not satisfy constraint`,{cause:n})}function JI(e,t,r,n,o){let i=E(e,t,o);return NM(r,i,n),l.Assign(e,{[r]:i})}function qM(e,t,r,n,o){let i=E(e,t,r.extends),a=E(e,t,r.equals);return s.ShiftLeft(o,(m,c)=>xc(JI(e,t,r.name,i,m),t,n,c),()=>xc(JI(e,t,r.name,i,a),t,n,[]))}function xc(e,t,r,n){return s.ShiftLeft(r,(o,i)=>qM(e,t,o,i,n),()=>e)}function YI(e,t,r,n){return xc(e,t,r,n)}var hc=0,Ic=0;function _M(){if(!s.IsLessThan(Ic,Me.Get().maxInstantiationCount))throw Error("Type instantiation is excessively deep and possibly infinite")}function UM(){_M(),Ic++,hc++}function BM(){hc--,s.IsEqual(hc,0)&&(Ic=0)}function GM(e){return s.IsGreaterThan(e.callstack.length,0)?e.callstack[e.callstack.length-1]:""}function KM(e,t){return s.IsEqual(GM(e),t)}function HM(e,t,r,n,o,i){UM();try{let a=YI(e,t,n,i),m=E(a,de([...t.callstack,r.$ref],t.visited),o);return E(a,de([],[]),m)}finally{BM()}}function zM(e,t,r,n,o,i){return i.reduce((a,m)=>{let c=HM(e,t,r,n,o,m);return[...a,c]},[])}function WM(e,t,r,n,o,i){let a=zI(n,i,o),m=zM(e,t,r,n,o,a);return s.IsEqual(m.length,1)?m[0]:bt(m)}function Xa(e,t,r,n){let o=Lt(e,t,n),i=VI(e,r,n),a=i[0],m=i[1];return Yn(m)?KM(t,a)?di(Be(a),o):WM(e,t,Be(a),m.parameters,m.expression,o):di(r,o)}function di(e,t){return l.Create({"~kind":"Call"},{type:"call",target:e,arguments:t},{})}function QI(e,t){return Xa({},de([],[]),e,t)}function lo(e){return C(e,"Call")}function VM(e){return l.Discard(e,["~immutable"])}function XI(e,t){return l.Update(VM(e),{},t)}function ZI(e,t,r,n){let o=E(e,t,r);return XI(o,n)}function eb(e,t){return e(t)}function tb(e,t){return s.IsString(t)?G(eb(e,t)):G(t)}function rb(e,t){let r=it(t);return vr(e,r)}function nb(e,t){let r=t.map(n=>vr(e,n));return D(r)}function vr(e,t){return H(t)?tb(e,t.const):ue(t)?rb(e,t.pattern):k(t)?nb(e,t.anyOf):t}function ba(e,t={}){return R("Capitalize",[e],t)}function ob(e,t={}){return bc(e,t)}function $a(e,t={}){return R("Lowercase",[e],t)}function ib(e,t={}){return $c(e,t)}function Ea(e,t={}){return R("Uncapitalize",[e],t)}function sb(e,t={}){return Ec(e,t)}function Sa(e,t={}){return R("Uppercase",[e],t)}function ab(e,t={}){return Sc(e,t)}var JM=e=>e[0].toUpperCase()+e.slice(1),YM=e=>e.toLowerCase(),QM=e=>e[0].toLowerCase()+e.slice(1),XM=e=>e.toUpperCase();function bc(e,t){return U([e])?l.Update(vr(JM,e),{},t):ba(e,t)}function $c(e,t){return U([e])?l.Update(vr(YM,e),{},t):$a(e,t)}function Ec(e,t){return U([e])?l.Update(vr(QM,e),{},t):Ea(e,t)}function Sc(e,t){return U([e])?l.Update(vr(XM,e),{},t):Sa(e,t)}function mb(e,t,r,n){let o=E(e,t,r);return bc(o,n)}function ub(e,t,r,n){let o=E(e,t,r);return $c(o,n)}function cb(e,t,r,n){let o=E(e,t,r);return Ec(o,n)}function pb(e,t,r,n){let o=E(e,t,r);return Sc(o,n)}function ka(e,t,r,n,o={}){return R("Conditional",[e,t,r,n],o)}function fb(e,t,r,n,o={}){return kc({},de([],[]),e,t,r,n,o)}function ZM(e,t,r,n,o,i){let a=rt(e,r,n);return F.IsExtendsUnion(a)?D([E(a.inferred,t,o),E(e,t,i)]):F.IsExtendsTrue(a)?E(a.inferred,t,o):E(e,t,i)}function kc(e,t,r,n,o,i,a){return U([r,n])?l.Update(ZM(e,t,r,n,o,i),{},a):ka(r,n,o,i,a)}function db(e,t,r,n,o,i,a){let m=E(e,t,r),c=E(e,t,n);return kc(e,t,m,c,o,i,a)}function Ta(e,t={}){return R("ConstructorParameters",[e],t)}function lb(e,t={}){return Tc(e,t)}function ev(e){let t=Ee(e)?e.parameters:[],r=sn({},de([],[]),t);return we(r)}function Tc(e,t){return U([e])?l.Update(ev(e),{},t):Ta(e,t)}function gb(e,t,r,n){let o=E(e,t,r);return Tc(o,n)}function wa(e,t,r={}){return R("Exclude",[e,t],r)}function yb(e,t,r={}){return Ci(e,t,r)}function Ci(e,t,r){return U([e,t])?l.Update(da(e,t),{},r):wa(e,t,r)}function xb(e,t,r,n,o){let i=E(e,t,r),a=E(e,t,n);return Ci(i,a,o)}function Ca(e,t,r={}){return R("Extract",[e,t],r)}function hb(e,t,r={}){return wc(e,t,r)}function tv(e,t){let r=rt({},e,t);return F.IsExtendsTrueLike(r)?[e]:[]}function Ib(e,t,r=[]){return s.ShiftLeft(e,(n,o)=>Ib(o,t,[...r,...tv(n,t)]),()=>r)}function bb(e,t){let r=Gt(e),n=k(r)?r.anyOf:[r],o=Ib(n,t);return bt(o)}function wc(e,t,r){return U([e,t])?l.Update(bb(e,t),{},r):Ca(e,t,r)}function $b(e,t,r,n,o){let i=E(e,t,r),a=E(e,t,n);return wc(i,a,o)}function rv(e){return e.reduce((t,r)=>ia(r)?[...t,G(r)]:t,[])}function go(e){let t=rv(e);return D(t)}function li(e,t,r={}){return R("Index",[e,t],r)}function Eb(e,t,r={}){let n=s.IsArray(t)?go(t):t;return Cc(e,n,r)}function Sb(e,t){let r=Ir(e,t);return Dt(r)}function kb(e,t,r){let n=er(e,t,r);return Dt(n)}function nv(e,t){let r=s.Keys(e).filter(f=>!s.HasPropertyKey(t,f)),n=s.Keys(t).filter(f=>!s.HasPropertyKey(e,f)),o=s.Keys(e).filter(f=>s.HasPropertyKey(t,f)),i=r.reduce((f,d)=>({...f,[d]:e[d]}),{}),a=n.reduce((f,d)=>({...f,[d]:t[d]}),{}),m=o.reduce((f,d)=>({...f,[d]:fa(e[d],t[d])}),{}),c=l.Assign(i,a);return l.Assign(c,m)}function Tb(e){return e.reduce((t,r)=>nv(t,Dt(r)),{})}function wb(e){let t=Sg(we(e));return Dt(t)}function ov(e,t){return s.Keys(e).filter(o=>o in t).reduce((o,i)=>({...o,[i]:wg(e[i],t[i])}),{})}function Cb(e,t){return s.ShiftLeft(e,(r,n)=>Cb(n,ov(t,Dt(r))),()=>t)}function Rb(e){return s.ShiftLeft(e,(t,r)=>Cb(r,Dt(t)),()=>$e())}function Dt(e){return me(e)?Sb(e.$defs,e.$ref):ke(e)?kb(e.if,e.then,e.else):O(e)?Tb(e.allOf):k(e)?Rb(e.anyOf):_(e)?wb(e.items):A(e)?e.properties:{}}function yo(e){let t=Dt(e);return M(t)}var iv=new RegExp("^(?:0|[1-9][0-9]*)$");function xo(e){let t=`${e}`;return iv.test(t)?parseInt(t):e}function sv(e){return G(xo(e))}function Pb(e){return e.map(t=>Ab(t))}function Ab(e){return O(e)?ot(Pb(e.allOf)):k(e)?D(Pb(e.anyOf)):H(e)?sv(e.const):e}function Ob(e,t){let r=Ab(t),n=rt({},r,wt());return F.IsExtendsTrueLike(n)?e:H(t)&&s.IsEqual(t.const,"length")?wt():ie()}function Mb(e,t){let r=Ir(e,t);return Rt(r)}function vb(e,t,r){let n=er(e,t,r);return Rt(n)}function Fb(e){let t=dt(e);return Rt(t)}function Lb(e){let t=Ce(e);return Rt(t)}function Db(e){return[`${e}`]}function jb(e){let t=it(e);return Rt(t)}function Nb(e){return e.reduce((t,r)=>[...t,...Rt(r)],[])}function Rt(e){return me(e)?Mb(e.$defs,e.$ref):ke(e)?vb(e.if,e.then,e.else):Te(e)?Fb(e.enum):O(e)?Lb(e.allOf):H(e)?Db(e.const):ue(e)?jb(e.pattern):k(e)?Nb(e.anyOf):[]}function ho(e){return Rt(e)}function Ri(e,t){return t.map(r=>Pi(e,r))}function Pi(e,t){return W(t)?xt(Pi(e,t.items)):Ee(t)?pr(Ri(e,t.parameters),Pi(e,t.instanceType)):Se(t)?fr(Ri(e,t.parameters),Pi(e,t.returnType)):_(t)?we(Ri(e,t.items)):k(t)?D(Ri(e,t.anyOf)):O(t)?ot(Ri(e,t.allOf)):xa(t)?M(e):t}function qb(e,t){return Pi(e,t)}function av(e,t){let r=t in e?e[t]:ie();return qb(e,r)}function _b(e,t){return t.reduce((r,n)=>[...r,av(e,n)],[])}function mv(e,t){let r=ho(t),n=_b(e,r);return bt(n)}var uv=new RegExp(Zr);function cv(e){return e.filter(r=>uv.test(r))}function pv(e){let t=Xs(e),r=cv(t),n=_b(e,r);return bt(n)}function Ub(e,t){return xe(t)?pv(e):mv(e,t)}function fv(e){return G(xo(e))}function Bb(e){return e.map(t=>Rc(t))}function Rc(e){return O(e)?ot(Bb(e.allOf)):k(e)?D(Bb(e.anyOf)):H(e)?fv(e.const):e}function dv(e,t){return e.reduceRight((r,n,o)=>{let i=rt({},G(o),t);return F.IsExtendsTrueLike(i)?[n,...r]:r},[])}function lv(e,t){let r=Rc(t),n=dv(e,r);return Qr(n)}function gv(e){return Qr(e)}function Gb(e,t){return H(t)&&s.IsEqual(t.const,"length")?G(e.length):xe(t)||Ke(t)?gv(e):lv(e,t)}function Kb(e,t){return W(e)?Ob(e.items,t):A(e)?Ub(e.properties,t):_(e)?Gb(e.items,t):ie()}function yv(e){return me(e)||ke(e)||O(e)||k(e)?yo(e):e}function Cc(e,t,r){return U([e,t])?l.Update(Kb(yv(e),t),{},r):li(e,t,r)}function Hb(e,t,r,n,o){let i=E(e,t,r),a=E(e,t,n);return Cc(i,a,o)}function Ra(e,t={}){return R("InstanceType",[e],t)}function zb(e,t={}){return Pc(e,t)}function xv(e){return Ee(e)?e.instanceType:ie()}function Pc(e,t){return U([e])?l.Update(xv(e),{},t):Ra(e,t)}function Wb(e,t,r,n={}){let o=E(e,t,r);return Pc(o,n)}function gi(e,t={}){return R("KeyOf",[e],t)}function Vb(e,t={}){return Ac(e,t)}function Jb(){return D([wt(),tt(),eo()])}function Yb(e){return wt()}function hv(e){return e.reduce((r,n)=>ia(n)?[...r,G(xo(n))]:$e(),[])}function Qb(e){let t=s.Keys(e),r=hv(t);return Qr(r)}function Xb(e){return so(e)}function Zb(e){let t=e.map((r,n)=>G(n));return Qr(t)}function e$(e){return Ie(e)?Jb():W(e)?Yb(e.items):A(e)?Qb(e.properties):ne(e)?Xb(e):_(e)?Zb(e.items):ie()}function Iv(e){return me(e)||ke(e)||O(e)||k(e)?yo(e):e}function Ac(e,t){return U([e])?l.Update(e$(Iv(e)),{},t):gi(e,t)}function t$(e,t,r,n){let o=E(e,t,r);return Ac(o,n)}function pi(e,t,r,n,o={}){return R("Mapped",[e,t,r,n],o)}function r$(e,t,r,n,o={}){return Oc({},de([],[]),e,t,r,n,o)}function bv(e){let t=it(e);return Za(t)}function $v(e){return e.reduce((t,r)=>[...t,...Za(r)],[])}function Ev(e){let t=dt(e);return Za(t)}function Sv(e){return s.IsNumber(e)?[G(`${e}`)]:[G(e)]}function Za(e){return Te(e)?Ev(e.enum):H(e)?Sv(e.const):ue(e)?bv(e.pattern):k(e)?$v(e.anyOf):[e]}function n$(e){return Za(e)}function kv(e){return ue(e)?it(e.pattern):e}function Tv(e,t,r,n,o,i){let a=l.Assign(e,{[r.name]:n}),m=E(a,t,o),c=kv(m),p=E(a,t,i);return sa(c)||aa(c)?{[c.const]:p}:{}}function wv(e,t,r,n,o,i){return n.reduce((a,m)=>[...a,Tv(e,t,r,m,o,i)],[])}function Cv(e){return e.reduce((t,r)=>[...t,M(r)],[])}function o$(e,t,r,n,o,i){let a=n$(n),m=wv(e,t,r,a,o,i),c=Cv(m);return Ce(c)}function Oc(e,t,r,n,o,i,a){return U([n])?l.Update(o$(e,t,r,n,o,i),{},a):pi(r,n,o,i,a)}function i$(e,t,r,n,o,i,a){let m=E(e,t,n);return Oc(e,t,r,m,o,i,a)}function Rv(e,t,r){let n=l.Assign(e,t);return s.Keys(t).filter(i=>r.includes(i)).reduce((i,a)=>({...i,[a]:qI(n,a,t[a])}),{})}function Pv(e,t,r){let n=l.Assign(e,t);return s.Keys(t).filter(i=>!r.includes(i)).reduce((i,a)=>({...i,[a]:E(n,de([],[]),t[a])}),{})}function Av(e,t,r){let n=LI(t),o=Rv(e,t,n),i=Pv(e,t,n),a={...o,...i};return l.Update(a,{},r)}function em(e,t,r,n){return Av(e,r,n)}function Pa(e,t={}){return R("NonNullable",[e],t)}function s$(e,t={}){return Mc(e,t)}function Ov(e){let t=D([Zn(),ao()]);return Ci(e,t,{})}function Mc(e,t){return U([e])?l.Update(Ov(e),{},t):Pa(e,t)}function a$(e,t,r,n){let o=E(e,t,r);return Mc(o,n)}function Aa(e,t,r={}){return R("Omit",[e,t],r)}function m$(e,t,r={}){let n=s.IsArray(t)?go(t):t;return vc(e,n,r)}function tm(e){let t=yo(e);return A(t)?t.properties:$e()}function Mv(e,t){return s.Keys(e).reduce((n,o)=>t.includes(o)?n:{...n,[o]:e[o]},{})}function u$(e,t){let r=tm(e),n=ho(t),o=Mv(r,n);return M(o)}function vc(e,t,r){return U([e,t])?l.Update(u$(e,t),{},r):Aa(e,t,r)}function c$(e,t,r,n,o){let i=E(e,t,r),a=E(e,t,n);return vc(i,a,o)}function Oa(e,t={}){return R("Parameters",[e],t)}function p$(e,t={}){return Fc(e,t)}function vv(e){let t=Se(e)?e.parameters:[],r=sn({},de([],[]),t);return we(r)}function Fc(e,t){return U([e])?l.Update(vv(e),{},t):Oa(e,t)}function f$(e,t,r,n){let o=E(e,t,r);return Fc(o,n)}function Ma(e,t={}){return R("Partial",[e],t)}function d$(e,t={}){return Lc(e,t)}function l$(e,t){let r=Ir(e,t),n=br(r);return lr(l.Assign(e,{[t]:n}),t)}function g$(e,t,r){let n=er(e,t,r);return br(n)}function y$(e){let t=Ce(e);return br(t)}function x$(e){let t=e.map(r=>br(r));return D(t)}function h$(e){let t=s.Keys(e).reduce((n,o)=>({...n,[o]:Qs(e[o])}),{});return M(t)}function br(e){return me(e)?l$(e.$defs,e.$ref):ke(e)?g$(e.if,e.then,e.else):O(e)?y$(e.allOf):k(e)?x$(e.anyOf):A(e)?h$(e.properties):M({})}function Lc(e,t){return U([e])?l.Update(br(e),{},t):Ma(e,t)}function I$(e,t,r,n){let o=E(e,t,r);return Lc(o,n)}function va(e,t,r={}){return R("Pick",[e,t],r)}function b$(e,t,r={}){let n=s.IsArray(t)?go(t):t;return Dc(e,n,r)}function Fv(e,t){return s.Keys(e).reduce((n,o)=>t.includes(o)?l.Assign(n,{[o]:e[o]}):n,{})}function $$(e,t){let r=tm(e),n=ho(t),o=Fv(r,n);return M(o)}function Dc(e,t,r){return U([e,t])?l.Update($$(e,t),{},r):va(e,t,r)}function E$(e,t,r,n,o){let i=E(e,t,r),a=E(e,t,n);return Dc(i,a,o)}function Fa(e,t={}){return R("ReadonlyObject",[e],t)}function jc(e,t={}){return Nc(e,t)}var S$=jc;function k$(e){return Xn(xt(e))}function T$(e,t){let r=Ir(e,t),n=$r(r);return lr(l.Assign(e,{[t]:n}),t)}function w$(e,t,r){let n=er(e,t,r);return $r(n)}function C$(e){let t=Ce(e);return $r(t)}function R$(e){let t=s.Keys(e).reduce((n,o)=>({...n,[o]:ra(e[o])}),{});return M(t)}function P$(e){return Xn(we(e))}function A$(e){let t=e.map(r=>$r(r));return D(t)}function $r(e){return W(e)?k$(e.items):me(e)?T$(e.$defs,e.$ref):ke(e)?w$(e.if,e.then,e.else):O(e)?C$(e.allOf):A(e)?R$(e.properties):_(e)?P$(e.items):k(e)?A$(e.anyOf):e}function Nc(e,t){return U([e])?l.Update($r(e),{},t):Fa(e)}function O$(e,t,r,n){let o=E(e,t,r);return Nc(o,n)}function M$(e,t,r,n){return t.visited.includes(n)?r:n in e?E(e,de(t.callstack,[...t.visited,n]),e[n]):r}function v$(e,t){let r=Ir(e,t),n=Er(r);return lr(l.Assign(e,{[t]:n}),t)}function F$(e,t,r){let n=er(e,t,r);return Er(n)}function L$(e){let t=Ce(e);return Er(t)}function D$(e){let t=e.map(r=>Er(r));return D(t)}function Gx(e,t={}){return R("RemoveOptional",[e],t)}function j$(e,t={}){return Tn(e,t)}function N$(e){let t=s.Keys(e).reduce((n,o)=>({...n,[o]:j$(e[o])}),{});return M(t)}function Er(e){return me(e)?v$(e.$defs,e.$ref):ke(e)?F$(e.if,e.then,e.else):O(e)?L$(e.allOf):k(e)?D$(e.anyOf):A(e)?N$(e.properties):M({})}function La(e,t={}){return R("Required",[e],t)}function q$(e,t={}){return qc(e,t)}function qc(e,t){return U([e])?l.Update(Er(e),{},t):La(e,t)}function _$(e,t,r,n){let o=E(e,t,r);return qc(o,n)}function Da(e,t={}){return R("ReturnType",[e],t)}function U$(e,t={}){return _c(e,t)}function Lv(e){return Se(e)?e.returnType:ie()}function _c(e,t){return U([e])?l.Update(Lv(e),{},t):Da(e,t)}function B$(e,t,r,n={}){let o=E(e,t,r);return _c(o,n)}function ja(e,t){return R("With",[e,t],{})}function rm(e,t){return Uc(e,t)}function Uc(e,t){return U([e])?l.Update(e,{},t):ja(e,t)}function G$(e,t,r,n){let o=E(e,t,r);return Uc(o,n)}function Dv(e){return tn(e)?_(e.items)?Bc(e.items.items):Le(e.items)?[e]:te(e.items)?[e]:[ie()]:[e]}function Bc(e){return e.reduce((r,n)=>[...r,...Dv(n)],[])}function de(e,t){return{callstack:e,visited:t}}function U(e){return s.ShiftLeft(e,(t,r)=>te(t)?!1:U(r),()=>!0)}function $i(e,t,r){return s.Keys(r).reduce((n,o)=>({...n,[o]:E(e,t,r[o])}),{})}function sn(e,t,r){let n=Lt(e,t,r);return Bc(n)}function Lt(e,t,r){return r.map(n=>E(e,t,n))}function jv(e,t){let r=ve(e)?cr(t,{}):t,n=Or(e)?ur(r,{}):r;return En(e)?Ai(n,{}):n}function Nv(e,t,r,n,o){return s.IsEqual(r,"AddImmutable")?K$(e,t,n[0],o):s.IsEqual(r,"RemoveImmutable")?ZI(e,t,n[0],o):s.IsEqual(r,"AddReadonly")?Ul(e,t,n[0],o):s.IsEqual(r,"RemoveReadonly")?Tg(e,t,n[0],o):s.IsEqual(r,"AddOptional")?Bl(e,t,n[0],o):s.IsEqual(r,"RemoveOptional")?kg(e,t,n[0],o):s.IsEqual(r,"Capitalize")?mb(e,t,n[0],o):s.IsEqual(r,"Conditional")?db(e,t,n[0],n[1],n[2],n[3],o):s.IsEqual(r,"ConstructorParameters")?gb(e,t,n[0],o):s.IsEqual(r,"Evaluate")?BI(e,t,n[0],o):s.IsEqual(r,"Exclude")?xb(e,t,n[0],n[1],o):s.IsEqual(r,"Extract")?$b(e,t,n[0],n[1],o):s.IsEqual(r,"Index")?Hb(e,t,n[0],n[1],o):s.IsEqual(r,"InstanceType")?Wb(e,t,n[0],o):s.IsEqual(r,"Interface")?OI(e,t,n[0],n[1],o):s.IsEqual(r,"KeyOf")?t$(e,t,n[0],o):s.IsEqual(r,"Lowercase")?ub(e,t,n[0],o):s.IsEqual(r,"Mapped")?i$(e,t,n[0],n[1],n[2],n[3],o):s.IsEqual(r,"Module")?em(e,t,n[0],o):s.IsEqual(r,"NonNullable")?a$(e,t,n[0],o):s.IsEqual(r,"Pick")?E$(e,t,n[0],n[1],o):s.IsEqual(r,"Parameters")?f$(e,t,n[0],o):s.IsEqual(r,"Partial")?I$(e,t,n[0],o):s.IsEqual(r,"Omit")?c$(e,t,n[0],n[1],o):s.IsEqual(r,"ReadonlyObject")?O$(e,t,n[0],o):s.IsEqual(r,"Record")?Bg(e,t,n[0],n[1],o):s.IsEqual(r,"Required")?_$(e,t,n[0],o):s.IsEqual(r,"ReturnType")?B$(e,t,n[0],o):s.IsEqual(r,"TemplateLiteral")?Jh(e,t,n[0],o):s.IsEqual(r,"Uncapitalize")?cb(e,t,n[0],o):s.IsEqual(r,"Uppercase")?pb(e,t,n[0],o):s.IsEqual(r,"With")?G$(e,t,n[0],n[1]):R(r,n,o)}function qv(e,t,r){let n=te(r)?M$(e,t,r,r.$ref):W(r)?xt(E(e,t,r.items),Jn(r)):lo(r)?Xa(e,t,r.target,r.arguments):Ee(r)?pr(Lt(e,t,r.parameters),E(e,t,r.instanceType),Gl(r)):Se(r)?fr(Lt(e,t,r.parameters),E(e,t,r.returnType),Kl(r)):ke(r)?$n(E(e,t,r.if),E(e,t,r.then),E(e,t,r.else),Yl(r)):O(r)?ot(Lt(e,t,r.allOf),tg(r)):A(r)?M($i(e,t,r.properties),Vl(r)):ne(r)?Gg(De(r),E(e,t,pe(r))):tn(r)?wn(E(e,t,r.items)):_(r)?we(sn(e,t,r.items),Eg(r)):k(r)?D(Lt(e,t,r.anyOf),fg(r)):r;return jv(r,n)}function E(e,t,r){return Jr(r)?Nv(e,t,r.action,r.parameters,r.options):qv(e,t,r)}function jt(e,t){return E(e,de([],[]),t)}function Ai(e,t){return l.Update(e,{"~immutable":!0},t)}function K$(e,t,r,n){let o=E(e,t,r);return Ai(o,n)}function Kx(e,t={}){return R("AddImmutable",[e],t)}function Xn(e,t={}){return Ai(e,t)}function Hx(e,t={}){return R("RemoveReadonly",[e],t)}function zx(e,t={}){return R("Evaluate",[e],t)}function He(e,t={}){return yc(e,t)}function Wx(e,t={}){return R("Module",[e],t)}function H$(e,t={}){return em({},de([],[]),e,t)}function _v(e,t){let r=no(e,t);return s.IsEqual(r,ui)||s.IsEqual(r,Ti)?1:0}function z$(e,t,r=[]){return s.ShiftLeft(t,(n,o)=>s.IsEqual(_v(e,n),1)?z$(e,o,[...r,n]):[...r,e,...t],()=>[...r,e])}function W$(e,t=[]){return s.ShiftLeft(e,(r,n)=>W$(n,z$(r,t)),()=>t)}function V$(e){return W$(e)}function J$(...e){let[t,r,n]=B.Match(e,{2:(a,m)=>s.IsString(a)?[{},a,m]:[a,m,{}],3:(a,m,c)=>[a,m,c],1:a=>[{},a,{}]}),o=Kh(r),i=s.IsArray(o)&&s.IsEqual(o.length,2)?E(t,de([],[]),o[0]):ie();return l.Update(i,{},n)}function Y$(e,t,r){return s.IsArray(r)?r.map(n=>ze(e,t.items,n)):r}function Q$(e,t,r){return ze({...e,...t.$defs},Be(t.$ref),r)}function Uv(e,t){let r=s.HasPropertyKey(t,"unevaluatedProperties")?{additionalProperties:t.unevaluatedProperties}:{},n=jt(e,t),o=He(n);return A(o)?rm(o,r):o}function X$(e,t,r){let n=Uv(e,t);return ze(e,n,r)}function nm(e){return s.HasPropertyKey(e,"additionalProperties")?e.additionalProperties:void 0}function Z$(e,t,r){if(!s.IsObject(r)||s.IsArray(r))return r;let n=nm(t);for(let o of s.Keys(r)){if(s.HasPropertyKey(t.properties,o)&&ye(t.properties[o])){r[o]=ze(e,t.properties[o],r[o]);continue}if(s.IsBoolean(n)&&s.IsEqual(n,!0)||ye(n)&&K(e,n,r[o])){r[o]=ze(e,n,r[o]);continue}delete r[o]}return r}function eE(e,t,r){if(!s.IsObject(r))return r;let n=nm(t),[o,i]=[new RegExp(De(t)),pe(t)];for(let a of s.Keys(r)){if(o.test(a)){r[a]=ze(e,i,r[a]);continue}if(s.IsBoolean(n)&&s.IsEqual(n,!0)||ye(n)&&K(e,n,r[a])){r[a]=ze(e,n,r[a]);continue}delete r[a]}return r}function tE(e,t,r){return s.HasPropertyKey(e,t.$ref)?ze(e,e[t.$ref],r):r}function rE(e,t,r){if(!s.IsArray(r))return r;let n=Math.min(r.length,t.items.length);for(let o=0;o<n;o++)r[o]=ze(e,t.items[o],r[o]);return s.IsGreaterThan(r.length,n)?r.slice(0,n):r}function Bv(e){return s.HasPropertyKey(e,"~kind")||s.HasPropertyKey(e,"~unsafe")}function Gv(e){let t={};for(let r of s.Keys(e)){if(s.IsUnsafePropertyKey(r))continue;let n=Object.getOwnPropertyDescriptor(e,r);n.value=On(n.value),s.IsEqual(n.enumerable,!0)?t[r]=n.value:Object.defineProperty(t,r,n)}return t}function Kv(e){let t={};for(let r of s.Keys(e))s.IsUnsafePropertyKey(r)||(t[r]=On(e[r]));for(let r of s.Symbols(e))t[r]=On(e[r]);return t}function Hv(e){return s.IsClassInstance(e)?e:Bv(e)?Gv(e):Kv(e)}function zv(e){return e.map(t=>On(t))}function Wv(e){return e.slice()}function Vv(e){return new RegExp(e.source,e.flags)}function Jv(e){return new Map(On([...e.entries()]))}function Yv(e){return new Set(On([...e.values()]))}function On(e){return je.IsTypeArray(e)?Wv(e):je.IsRegExp(e)?Vv(e):je.IsMap(e)?Jv(e):je.IsSet(e)?Yv(e):s.IsArray(e)?zv(e):s.IsObject(e)?Hv(e):e}function nE(e){return On(e)}function fe(e){return nE(e)}function oE(e,t,r){for(let n of t.anyOf){let o=ze(e,n,fe(r));if(K(e,n,o))return o}return r}function ze(e,t,r){return W(t)?Y$(e,t,r):me(t)?Q$(e,t,r):O(t)?X$(e,t,r):A(t)?Z$(e,t,r):ne(t)?eE(e,t,r):te(t)?tE(e,t,r):_(t)?rE(e,t,r):k(t)?oE(e,t,r):r}function Qv(e,t){return l.Assign(e,t)}function Xv(e){let t={};for(let r of kf.Keys(e))t[r]=Oi(e[r]);return t}function Zv(e){return tt({pattern:De(e)})}function eF(e){return Gc(V$(e))}function Gc(e){return e.map(t=>Oi(t))}function Oi(e){let t=W(e)?xt(Oi(e.items),Jn(e)):O(e)?ot(Gc(e.allOf)):k(e)?D(eF(e.anyOf)):A(e)?M(Xv(e.properties)):ne(e)?io(Zv(e),Oi(pe(e))):_(e)?we(Gc(e.items)):e;return Qv(e,t)}function Io(e){return Oi(e)}function tr(...e){let[t,r,n]=B.Match(e,{3:(i,a,m)=>[i,a,m],2:(i,a)=>[{},i,a]}),o=Me.Get().unionPrioritySort?Io(r):r;return ze(t,o,n)}var Z={};Ot(Z,{Fail:()=>Mn,IsOk:()=>Kc,Ok:()=>P,TryArray:()=>tF,TryBigInt:()=>Hc,TryBoolean:()=>dF,TryNull:()=>hF,TryNumber:()=>EF,TryString:()=>SF,TryUndefined:()=>RF});function Kc(e){return s.IsObject(e)&&s.HasPropertyKey(e,"value")}function P(e){return{value:e}}function Mn(){}function tF(e){return s.IsArray(e)?P(e):P([e])}function rF(e){return s.IsEqual(e,!0)?P(BigInt(1)):P(BigInt(0))}var nF=/^-?(0|[1-9]\d*)n$/,oF=/^-?(0|[1-9]\d*)\.\d+$/,iF=/^-?(0|[1-9]\d*)$/;function sF(e){return nF.test(e)}function aF(e){return oF.test(e)}function mF(e){return iF.test(e)}function uF(e){let t=e.toLowerCase();return sF(e)?P(BigInt(e.slice(0,e.length-1))):aF(e)?P(BigInt(e.split(".")[0])):mF(e)?P(BigInt(e)):s.IsEqual(t,"false")?P(BigInt(0)):s.IsEqual(t,"true")?P(BigInt(1)):void 0}function Hc(e){return s.IsBigInt(e)?P(e):s.IsBoolean(e)?rF(e):s.IsNumber(e)?P(BigInt(Math.trunc(e))):s.IsNull(e)?P(BigInt(0)):s.IsString(e)?uF(e):s.IsUndefined(e)?P(BigInt(0)):void 0}function cF(e){return s.IsEqual(e,BigInt(0))?P(!1):s.IsEqual(e,BigInt(1))?P(!0):void 0}function pF(e){return s.IsEqual(e,0)?P(!1):s.IsEqual(e,1)?P(!0):void 0}function fF(e){return s.IsEqual(e.toLowerCase(),"false")?P(!1):s.IsEqual(e.toLowerCase(),"true")?P(!0):s.IsEqual(e,"0")?P(!1):s.IsEqual(e,"1")?P(!0):void 0}function dF(e){return s.IsBigInt(e)?cF(e):s.IsBoolean(e)?P(e):s.IsNumber(e)?pF(e):s.IsNull(e)?P(!1):s.IsString(e)?fF(e):s.IsUndefined(e)?P(!1):void 0}function lF(e){return s.IsEqual(e,BigInt(0))?P(null):void 0}function gF(e){return s.IsEqual(e,!1)?P(null):void 0}function yF(e){return s.IsEqual(e,0)?P(null):void 0}function xF(e){let t=e.toLowerCase();return s.IsEqual(t,"undefined")||s.IsEqual(t,"null")||s.IsEqual(e,"")||s.IsEqual(e,"0")?P(null):void 0}function hF(e){return s.IsBigInt(e)?lF(e):s.IsBoolean(e)?gF(e):s.IsNumber(e)?yF(e):s.IsNull(e)?P(null):s.IsString(e)?xF(e):s.IsUndefined(e)?P(null):void 0}var iE=BigInt(Number.MAX_SAFE_INTEGER),sE=BigInt(Number.MIN_SAFE_INTEGER);function IF(e){return e<=iE&&e>=sE?P(Number(e)):void 0}function bF(e){return P(e?1:0)}function $F(e){let t=+e;if(s.IsNumber(t))return P(t);let r=e.toLowerCase();if(s.IsEqual(r,"false"))return P(0);if(s.IsEqual(r,"true"))return P(1);let n=Hc(e);return Kc(n)?n.value<=iE&&n.value>=sE?P(Number(n.value)):void 0:void 0}function EF(e){return s.IsBigInt(e)?IF(e):s.IsBoolean(e)?bF(e):s.IsNumber(e)?P(e):s.IsNull(e)?P(0):s.IsString(e)?$F(e):s.IsUndefined(e)?P(0):void 0}function SF(e){return s.IsBigInt(e)?P(e.toString()):s.IsBoolean(e)?P(e.toString()):s.IsNumber(e)?P(e.toString()):s.IsNull(e)?P("null"):s.IsString(e)?P(e):s.IsUndefined(e)?P(""):void 0}function kF(e){return s.IsEqual(e,BigInt(0))?P(void 0):void 0}function TF(e){return s.IsEqual(e,!1)?P(void 0):void 0}function wF(e){return s.IsEqual(e,0)?P(void 0):void 0}function CF(e){let t=e.toLowerCase();return s.IsEqual(t,"undefined")||s.IsEqual(t,"null")||s.IsEqual(e,"")||s.IsEqual(e,"0")?P(void 0):void 0}function RF(e){return s.IsBigInt(e)?kF(e):s.IsBoolean(e)?TF(e):s.IsNumber(e)?wF(e):s.IsNull(e)?P(void 0):s.IsString(e)?CF(e):s.IsUndefined(e)?P(e):void 0}function aE(e,t,r){return Z.TryArray(r).value.map(o=>Ae(e,t.items,o))}function mE(e,t,r){let n=Z.TryBigInt(r);return Z.IsOk(n)?n.value:r}function uE(e,t,r){let n=Z.TryBoolean(r);return Z.IsOk(n)?n.value:r}function cE(e,t,r){return Ae({...e,...t.$defs},Be(t.$ref),r)}function pE(e,t,r){return Ae(e,He(t),r)}function fE(e,t,r){let n=Z.TryNumber(r);return Z.IsOk(n)?Math.trunc(n.value):r}function dE(e,t,r){let n=jt(e,t),o=He(n);return Ae(e,o,r)}function PF(e,t,r){let n=Z.TryBigInt(r);return Z.IsOk(n)&&s.IsEqual(t.const,n.value)?n.value:r}function AF(e,t,r){let n=Z.TryBoolean(r);return Z.IsOk(n)&&s.IsEqual(t.const,n.value)?n.value:r}function OF(e,t,r){let n=Z.TryNumber(r);return Z.IsOk(n)&&s.IsEqual(t.const,n.value)?n.value:r}function MF(e,t,r){let n=Z.TryString(r);return Z.IsOk(n)&&s.IsEqual(t.const,n.value)?n.value:r}function lE(e,t,r){return s.IsEqual(t.const,r)?r:ug(t)?PF(e,t,r):cg(t)?AF(e,t,r):sa(t)?OF(e,t,r):aa(t)?MF(e,t,r):$e()}function gE(e,t,r){let n=Z.TryNull(r);return Z.IsOk(n)?n.value:r}function yE(e,t,r){let n=Z.TryNumber(r);return Z.IsOk(n)?n.value:r}function om(e,t,r,n){let o=s.Keys(n);for(let[i,a]of t)for(let m of o)i.test(m)||(n[m]=Ae(e,r,n[m]));return n}function Mi(e,t,r){return ve(e)&&s.IsUndefined(r[t])}function vF(e,t,r){let n=s.EntriesRegExp(t.properties),o=s.Keys(r);for(let[i,a]of n)for(let m of o)!i.test(m)||Mi(a,m,r)||(r[m]=Ae(e,a,r[m]));return s.HasPropertyKey(t,"additionalProperties")&&s.IsObject(t.additionalProperties)?om(e,n,t.additionalProperties,r):r}function xE(e,t,r){return s.IsObjectNotArray(r)?vF(e,t,r):r}function FF(e,t,r){let n=s.EntriesRegExp(t.patternProperties),o=s.Keys(r);for(let[i,a]of n)for(let m of o)i.test(m)&&(r[m]=Ae(e,a,r[m]));return s.HasPropertyKey(t,"additionalProperties")&&s.IsObject(t.additionalProperties)?om(e,n,t.additionalProperties,r):r}function hE(e,t,r){return s.IsObjectNotArray(r)?FF(e,t,r):r}function IE(e,t,r){return s.HasPropertyKey(e,t.$ref)?Ae(e,e[t.$ref],r):r}function bE(e,t,r){let n=Z.TryString(r);return Z.IsOk(n)?n.value:r}function $E(e,t,r){return Ae(e,He(t),r)}function EE(e,t,r){if(!s.IsArray(r))return r;for(let n=0;n<Math.min(t.items.length,r.length);n++)r[n]=Ae(e,t.items[n],r[n]);return r}function SE(e,t,r){let n=Z.TryUndefined(r);return Z.IsOk(n)?n.value:r}function kE(e,t,r){if(t.anyOf.some(a=>K(e,a,r)))return r;let i=t.anyOf.map(a=>Ae(e,a,fe(r))).find(a=>K(e,t,a));return s.IsUndefined(i)?r:i}function TE(e,t,r){let n=Z.TryUndefined(r);return Z.IsOk(n)?void 0:r}function Ae(e,t,r){return W(t)?aE(e,t,r):Tt(t)?mE(e,t,r):ft(t)?uE(e,t,r):me(t)?cE(e,t,r):Te(t)?pE(e,t,r):Ke(t)?fE(e,t,r):O(t)?dE(e,t,r):H(t)?lE(e,t,r):yr(t)?gE(e,t,r):xe(t)?yE(e,t,r):A(t)?xE(e,t,r):ne(t)?hE(e,t,r):te(t)?IE(e,t,r):qe(t)?bE(e,t,r):ue(t)?$E(e,t,r):_(t)?EE(e,t,r):Kt(t)?SE(e,t,r):k(t)?kE(e,t,r):Ct(t)?TE(e,t,r):r}function Sr(...e){let[t,r,n]=B.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]});return Ae(t,r,n)}function wE(e,t,r){if(!s.IsArray(r))return r;for(let n=0;n<r.length;n++)r[n]=We(e,t.items,r[n]);return r}function CE(e,t,r){return We({...e,...t.$defs},Be(t.$ref),r)}function RE(e,t){return s.IsUndefined(t)?s.IsFunction(e.default)?e.default():fe(e.default):t}function PE(e,t,r){let n=jt(e,t),o=He(n);return We(e,o,r)}function AE(e,t,r){if(!s.IsObject(r))return r;let n=s.Keys(t.properties);for(let o of n){let i=We(e,t.properties[o],r[o]);s.IsUndefined(i)&&(ve(t.properties[o])||!s.HasPropertyKey(t.properties[o],"default"))||(r[o]=i)}if(!Ut(t)||s.IsBoolean(t.additionalProperties))return r;for(let o of s.Keys(r))n.includes(o)||(r[o]=We(e,t.additionalProperties,r[o]));return r}function OE(e,t,r){if(!s.IsObject(r))return r;let[n,o]=[new RegExp(De(t)),pe(t)];for(let i of s.Keys(r))n.test(i)&&$t(o)&&(r[i]=We(e,o,r[i]));if(!Ut(t))return r;for(let i of s.Keys(r))n.test(i)||(r[i]=We(e,t.additionalProperties,r[i]));return r}function ME(e,t,r){return s.HasPropertyKey(e,t.$ref)?We(e,e[t.$ref],r):r}function vE(e,t,r){if(!s.IsArray(r))return r;let[n,o]=[t.items,Math.max(t.items.length,r.length)];for(let i=0;i<o;i++)i<n.length&&(r[i]=We(e,n[i],r[i]));return r}function FE(e,t,r){for(let n of t.anyOf){let o=We(e,n,fe(r));if(K(e,n,o))return o}return r}function We(e,t,r){let n=$t(t)?RE(t,r):r;return W(t)?wE(e,t,n):me(t)?CE(e,t,n):O(t)?PE(e,t,n):A(t)?AE(e,t,n):ne(t)?OE(e,t,n):te(t)?ME(e,t,n):_(t)?vE(e,t,n):k(t)?FE(e,t,n):n}function an(...e){let[t,r,n]=B.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]});return We(t,r,n)}function bo(e){return(...t)=>{let[r,n,o]=B.Match(t,{3:(i,a,m)=>[i,a,m],2:(i,a)=>[{},i,a]});return e.reduce((i,a)=>a(r,n,i),o)}}function LF(e,t,r){return t["~codec"].decode(r)}function DF(e,t,r){return t["~codec"].encode(r)}function ge(e,t,r,n){return pt(r)?s.IsEqual(e,"Decode")?LF(t,r,n):DF(t,r,n):n}function jF(e,t,r,n){if(!s.IsArray(n))return n;for(let o=0;o<n.length;o++)n[o]=he(e,t,r.items,n[o]);return ge(e,t,r,n)}function NF(e,t,r,n){let o=ge(e,t,r,n);if(!s.IsArray(o))return o;for(let i=0;i<o.length;i++)o[i]=he(e,t,r.items,o[i]);return o}function LE(e,t,r,n){return s.IsEqual(e,"Decode")?jF(e,t,r,n):NF(e,t,r,n)}function DE(e,t,r,n){return n=he(e,{...t,...r.$defs},Be(r.$ref),n),ge(e,t,r,n)}function jE(e){return e.reduce((t,r)=>({...t,...r}),{})}function NE(e,t){for(let r of t)if(!s.IsDeepEqual(e,r))return r;return e}function qF(e,t,r,n){if(s.IsEqual(r.allOf.length,0))return ge(e,t,r,n);let o=r.allOf.map(m=>he(e,t,m,tr(m,fe(n)))),a=o.every(m=>s.IsObject(m))?jE(o):NE(n,o);return ge(e,t,r,a)}function _F(e,t,r,n){if(s.IsEqual(r.allOf.length,0))return ge(e,t,r,n);let o=ge(e,t,r,n),i=r.allOf.map(m=>he(e,t,m,tr(m,fe(o))));return i.every(m=>s.IsObject(m))?jE(i):NE(o,i)}function qE(e,t,r,n){return s.IsEqual(e,"Decode")?qF(e,t,r,n):_F(e,t,r,n)}function UF(e,t,r,n){if(!s.IsObjectNotArray(n))return n;for(let o of s.Keys(r.properties))!s.HasPropertyKey(n,o)||Mi(r.properties[o],o,n)||(n[o]=he(e,t,r.properties[o],n[o]));return ge(e,t,r,n)}function BF(e,t,r,n){let o=ge(e,t,r,n);if(!s.IsObjectNotArray(o))return o;for(let i of s.Keys(r.properties))!s.HasPropertyKey(o,i)||Mi(r.properties[i],i,o)||(o[i]=he(e,t,r.properties[i],o[i]));return o}function _E(e,t,r,n){return s.IsEqual(e,"Decode")?UF(e,t,r,n):BF(e,t,r,n)}function GF(e,t,r,n){if(!s.IsObjectNotArray(n))return n;let o=new RegExp(De(r));for(let i of s.Keys(n))o.test(i)&&(n[i]=he(e,t,pe(r),n[i]));return ge(e,t,r,n)}function KF(e,t,r,n){let o=ge(e,t,r,n);if(!s.IsObjectNotArray(o))return o;let i=new RegExp(De(r));for(let a of s.Keys(o))i.test(a)&&(o[a]=he(e,t,pe(r),o[a]));return o}function UE(e,t,r,n){return s.IsEqual(e,"Decode")?GF(e,t,r,n):KF(e,t,r,n)}function BE(e,t,r,n){return s.HasPropertyKey(t,r.$ref)?he(e,t,t[r.$ref],n):n}function GE(e,t,r,n){return s.IsEqual(e,"Decode")?ge(e,t,r,BE(e,t,r,n)):BE(e,t,r,ge(e,t,r,n))}function HF(e,t,r,n){if(!s.IsArray(n))return n;for(let o=0;o<Math.min(r.items.length,n.length);o++)n[o]=he(e,t,r.items[o],n[o]);return ge(e,t,r,n)}function zF(e,t,r,n){let o=ge(e,t,r,n);if(!s.IsArray(o))return n;for(let i=0;i<Math.min(r.items.length,o.length);i++)o[i]=he(e,t,r.items[i],o[i]);return o}function KE(e,t,r,n){return s.IsEqual(e,"Decode")?HF(e,t,r,n):zF(e,t,r,n)}function WF(e,t,r,n){for(let o of r.anyOf){if(!K(t,o,n))continue;let i=he(e,t,o,n);return ge(e,t,r,i)}return n}function VF(e,t,r,n){let o=ge(e,t,r,n);for(let i of r.anyOf){let a=he(e,t,i,fe(o));if(K(t,i,a))return a}return o}function HE(e,t,r,n){return s.IsEqual(e,"Decode")?WF(e,t,r,n):VF(e,t,r,n)}function he(e,t,r,n){return W(r)?LE(e,t,r,n):me(r)?DE(e,t,r,n):O(r)?qE(e,t,r,n):A(r)?_E(e,t,r,n):ne(r)?UE(e,t,r,n):te(r)?GE(e,t,r,n):_(r)?KE(e,t,r,n):k(r)?HE(e,t,r,n):ge(e,t,r,n)}var zc=class extends Ar{constructor(t,r){super("Decode",t,r)}};function JF(e,t,r){if(!K(e,t,r))throw new zc(r,Xt(e,t,r));return r}function YF(e,t,r){let n=Me.Get().unionPrioritySort?Io(t):t;return he("Decode",e,n,r)}var QF=bo([(e,t,r)=>fe(r),(e,t,r)=>an(e,t,r),(e,t,r)=>Sr(e,t,r),(e,t,r)=>tr(e,t,r),(e,t,r)=>JF(e,t,r),(e,t,r)=>YF(e,t,r)]);function zE(...e){let[t,r,n]=B.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]});return QF(t,r,n)}var Wc=class extends Ar{constructor(t,r){super("Encode",t,r)}};function XF(e,t,r){if(!K(e,t,r))throw new Wc(r,Xt(e,t,r));return r}function ZF(e,t,r){let n=Me.Get().unionPrioritySort?Io(t):t;return he("Encode",e,n,r)}var e1=bo([(e,t,r)=>fe(r),(e,t,r)=>ZF(e,t,r),(e,t,r)=>an(e,t,r),(e,t,r)=>Sr(e,t,r),(e,t,r)=>tr(e,t,r),(e,t,r)=>XF(e,t,r)]);function WE(...e){let[t,r,n]=B.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]});return e1(t,r,n)}function t1(e,t){return pt(t)||mn(e,t.items)}function r1(e,t){return pt(t)||VE({...e,...t.$defs},Be(t.$ref))}function n1(e,t){return pt(t)||t.allOf.some(r=>mn(e,r))}function o1(e,t){return pt(t)||s.Keys(t.properties).some(r=>mn(e,t.properties[r]))}function i1(e,t){return pt(t)||mn(e,pe(t))}function VE(e,t){return Vc.has(t.$ref)?!1:(Vc.add(t.$ref),pt(t)||s.HasPropertyKey(e,t.$ref)&&mn(e,e[t.$ref]))}function s1(e,t){return pt(t)||t.items.some(r=>mn(e,r))}function a1(e,t){return pt(t)||t.anyOf.some(r=>mn(e,r))}function mn(e,t){return W(t)?t1(e,t):me(t)?r1(e,t):O(t)?n1(e,t):A(t)?o1(e,t):ne(t)?i1(e,t):te(t)?VE(e,t):_(t)?s1(e,t):k(t)?a1(e,t):pt(t)}var Vc=new Set;function JE(...e){let[t,r]=B.Match(e,{2:(n,o)=>[n,o],1:n=>[{},n]});return Vc.clear(),mn(t,r)}var Ht=class extends Error{constructor(t,r){super(r),this.type=t}};function YE(e,t){return s.IsFunction(t.default)?t.default(t):s.IsObject(t.default)?fe(t.default):t.default}function QE(e,t){if(Hr(t)&&!$t(t))throw new Ht(t,"Arrays with uniqueItems constraints must specify a default annotation");let r=xn(t)?t.minItems:0;return Array.from({length:r},()=>Oe(e,t.items))}function XE(e,t){return wr(t)?BigInt(t.exclusiveMinimum)+BigInt(1):Cr(t)?BigInt(t.minimum):BigInt(0)}function ZE(e,t){return!1}function eS(e,t){let r=Oe(e,t.instanceType);return class{constructor(){Object.assign(this,r)}}}function tS(e,t){return Oe({...e,...t.$defs},Be(t.$ref))}function rS(e,t){return Oe(e,He(t))}function nS(e,t){let r=Oe(e,t.returnType);return()=>r}function oS(e,t){return wr(t)&&s.IsNumber(t.exclusiveMinimum)?t.exclusiveMinimum+1:Cr(t)?t.minimum:0}function iS(e,t){let r=jt(e,t),n=He(r);return Oe(e,n)}function sS(e,t){return t.const}function aS(e,t){throw new Ht(t,"Cannot create TNever types")}function mS(e,t){return null}function uS(e,t){return wr(t)&&s.IsNumber(t.exclusiveMinimum)?t.exclusiveMinimum+1:Cr(t)?t.minimum:0}function cS(e,t){return(s.IsUndefined(t.required)?[]:t.required).reduce((n,o)=>({...n,[o]:Oe(e,t.properties[o])}),{})}function pS(e,t){if(_o(t)&&!$t(t))throw new Ht(t,"Record with the minProperties constraint must have a default annotation");return{}}function fS(e,t){return s.HasPropertyKey(e,t.$ref)?Oe(e,e[t.$ref]):(()=>{throw new Ht(t,"Unable to deref Ref")})()}function dS(e,t){if((Uo(t)||jo(t))&&!$t(t))throw Error("Strings with format or pattern constraints must specify default");let n=qo(t)?t.minLength:0;return"".padEnd(n)}function lS(e,t){return Symbol()}function gS(e,t){let r=to(t.pattern);if(qe(r))throw new Ht(t,"Unable to create TemplateLiteral due to infinite type expansion");return Oe(e,r)}function yS(e,t){return Array.from({length:t.minItems},(r,n)=>Oe(e,t.items[n]))}function xS(e,t){if(s.IsEqual(t.anyOf.length,0))throw Error("Unable to create Union with no variants");return Oe(e,t.anyOf[0])}function Oe(e,t){return $t(t)?YE(e,t):W(t)?QE(e,t):Tt(t)?XE(e,t):ft(t)?ZE(e,t):Ee(t)?eS(e,t):me(t)?tS(e,t):Te(t)?rS(e,t):Se(t)?nS(e,t):Ke(t)?oS(e,t):O(t)?iS(e,t):H(t)?sS(e,t):ht(t)?aS(e,t):yr(t)?mS(e,t):xe(t)?uS(e,t):A(t)?cS(e,t):ne(t)?pS(e,t):te(t)?fS(e,t):qe(t)?dS(e,t):xr(t)?lS(e,t):ue(t)?gS(e,t):_(t)?yS(e,t):Kt(t)?void 0:k(t)?xS(e,t):Ct(t)?void 0:void 0}function Xe(...e){let[t,r]=B.Match(e,{2:(n,o)=>[n,o],1:n=>[{},n]});return Oe(t,r)}function im(e,t){return s.IsDeepEqual(e,t)}function sm(e){return Pr.Hash(e)}var am=class extends Ar{constructor(t,r){super("Parse",t,r)}};function m1(e,t,r){Vs();let n=Xt(e,t,r);if(Js(),!K(e,t,r))throw new am(r,n);return r}var u1=bo([(e,t,r)=>fe(r),(e,t,r)=>an(e,t,r),(e,t,r)=>Sr(e,t,r),(e,t,r)=>tr(e,t,r),(e,t,r)=>m1(e,t,r)]);function hS(...e){let[t,r,n]=B.Match(e,{3:(a,m,c)=>[a,m,c],2:(a,m)=>[{},a,m]});if(K(t,r,n))return n;if(Me.Get().correctiveParse)return u1(t,r,n);Vs();let i=Xt(t,r,n);throw Js(),new am(n,i)}function mm(e,t){return{type:"update",path:e,value:t}}function bS(e,t){return{type:"insert",path:e,value:t}}function $S(e){return{type:"delete",path:e}}function IS(e){if(!(s.IsObject(e)&&s.IsEqual(s.Symbols(e).length,0)))throw new Error("Cannot create diffs for objects with symbols keys")}function*c1(e,t,r){if(!s.IsObject(r)||s.IsArray(r))return yield mm(e,r);IS(t),IS(r);let n=s.Keys(t),o=s.Keys(r);for(let i of o)s.HasPropertyKey(t,i)||s.IsUnsafePropertyKey(i)||(yield bS(`${e}/${i}`,r[i]));for(let i of n)s.HasPropertyKey(r,i)&&(s.IsUnsafePropertyKey(i)||im(t,r)||(yield*um(`${e}/${i}`,t[i],r[i])));for(let i of n)s.HasPropertyKey(r,i)||s.IsUnsafePropertyKey(i)||(yield $S(`${e}/${i}`))}function*p1(e,t,r){if(!s.IsArray(r))return yield mm(e,r);for(let n=0;n<Math.min(t.length,r.length);n++)yield*um(`${e}/${n}`,t[n],r[n]);for(let n=0;n<r.length;n++)n<t.length||(yield bS(`${e}/${n}`,r[n]));for(let n=t.length-1;n>=0;n--)n<r.length||(yield $S(`${e}/${n}`))}function*f1(e,t,r){let n=globalThis.Object.getPrototypeOf(t).constructor.name,o=globalThis.Object.getPrototypeOf(r).constructor.name;if(je.IsTypeArray(r)&&s.IsEqual(t.length,r.length)&&s.IsEqual(n,o))for(let a=0;a<Math.min(t.length,r.length);a++)yield*um(`${e}/${a}`,t[a],r[a]);else return yield mm(e,r)}function*d1(e,t,r){t!==r&&(yield mm(e,r))}function*um(e,t,r){return je.IsTypeArray(t)?yield*f1(e,t,r):s.IsArray(t)?yield*p1(e,t,r):s.IsObject(t)?yield*c1(e,t,r):yield*d1(e,t,r)}function ES(e,t){return[...um("",e,t)]}var l1=M({type:G("insert"),path:tt(),value:Ne()}),g1=Object({type:G("update"),path:tt(),value:Ne()}),y1=M({type:G("delete"),path:tt()}),gRe=D([l1,g1,y1]);function x1(e){return e.length>0&&e[0].path===""&&e[0].type==="update"}function h1(e){return e.length===0}function SS(e,t){if(x1(t))return fe(t[0].value);if(h1(t))return fe(e);let r=fe(e);for(let n of t)switch(n.type){case"insert":{mr.Set(r,n.path,n.value);break}case"update":{mr.Set(r,n.path,n.value);break}case"delete":{mr.Delete(r,n.path);break}}return r}var Fr=class extends Error{constructor(t,r,n,o){super(o),this.context=t,this.type=r,this.value=n}};function I1(e){let[t,r]=[new Set,[]];for(let n of e){let o=sm(n);t.has(o)||(t.add(o),r.push(n))}return r}function kS(e,t,r){if(K(e,t,r))return r;let n=s.IsArray(r)?r:Xe(e,t),o=xn(t)&&n.length<t.minItems?[...n,...Array.from({length:t.minItems-n.length},()=>Xe(e,t))]:n,a=(No(t)&&o.length>t.maxItems?o.slice(0,t.maxItems):o).map(c=>_e(e,t.items,c));if(!Hr(t)||Hr(t)&&!s.IsEqual(t.uniqueItems,!0))return a;let m=I1(a);if(!K(e,t,m))throw new Fr(e,t,r,"Failed to repair Array due to uniqueItems constraint");return m}function TS(e,t,r){return _e(e,He(t),r)}function wS(e,t,r){let n=jt(e,t),o=He(n);return _e(e,o,r)}function CS(e,t,r){if(K(e,t,r))return r;if(!s.IsObjectNotArray(r))return Xe(e,t);let n=new Set(s.IsUndefined(t.required)?[]:t.required),o={};for(let[a,m]of s.Entries(t.properties))!n.has(a)&&s.IsUndefined(r[a])||(o[a]=a in r?_e(e,m,r[a]):Xe(e,m));let i=s.Keys(t.properties);if(Ut(t)&&s.IsObject(t.additionalProperties))for(let a of s.Keys(r))i.includes(a)||(o[a]=_e(e,t.additionalProperties,r[a]));return o}function RS(e,t,r){if(K(e,t,r))return r;if(s.IsNull(r)||!s.IsObject(r)||s.IsArray(r))return Xe(e,t);let n=new RegExp(De(t)),o=pe(t),i=new Set,a={};for(let[m,c]of s.Entries(r))n.test(m)&&(a[m]=_e(e,o,c),i.add(m));if(Ut(t))for(let m of s.Keys(r))i.has(m)||(a[m]=_e(e,t.additionalProperties,r[m]));return a}function PS(e,t,r){return s.HasPropertyKey(e,t.$ref)?_e(e,e[t.$ref],r):(()=>{throw new Fr(e,t,r,"Unable to de-reference target type")})()}function AS(e,t,r){let n=to(t.pattern);return _e(e,n,r)}function OS(e,t,r){return K(e,t,r)?r:s.IsArray(r)?t.items.map((n,o)=>_e(e,n,r[o])):Xe(e,t)}function MS(e,t,r){return te(t)?s.HasPropertyKey(e,t.$ref)?MS(e,e[t.$ref],r):(()=>{throw new Error("Unable to Deref target")})():t}function b1(e,t,r){if(!(A(t)&&s.IsObject(r)))return 0;let n=s.Keys(r);return s.Entries(t.properties).reduce((i,[a,m])=>{let c=H(m)&&s.IsEqual(m.const,r[a])?100:0,p=K(e,m,r[a])?10:0,f=n.includes(a)?1:0;return i+(c+p+f)},0)}function vS(e,t,r){let n=t.anyOf.map(a=>MS(e,a,r)),[o,i]=[n[0],0];for(let a of n){let m=b1(e,a,r);m>i&&(o=a,i=m)}return o}function $1(e,t,r){let n=D(en(t.anyOf)),o=vS(e,n,r);return _e(e,o,r)}function FS(e,t,r){return K(e,t,r)?fe(r):$t(t)?Xe(e,t):$1(e,t,r)}function LS(e,t,r){if(K(e,t,r))return r;let n=Sr(e,t,r);return K(e,t,n)?n:Xe(e,t)}function E1(e,t,r){if(je.IsDate(r)||je.IsMap(r)||je.IsSet(r)||je.IsTypeArray(r)||s.IsConstructor(r)||s.IsFunction(r))throw new Fr(e,t,r,"Value is not repairable")}function S1(e,t,r){if(Ee(t)||Se(t)||ht(t))throw new Fr(e,t,r,"Type is not repairable")}function k1(e,t,r){return s.IsUndefined(r)&&!Kt(t)?Xe(e,t):r}function T1(e,t,r){return ni(t)?K(e,t,r)?r:Xe(e,t):r}function _e(e,t,r){E1(e,t,r),S1(e,t,r);let n=k1(e,t,r),o=W(t)?kS(e,t,n):Te(t)?TS(e,t,n):O(t)?wS(e,t,n):A(t)?CS(e,t,n):ne(t)?RS(e,t,n):te(t)?PS(e,t,n):ue(t)?AS(e,t,n):_(t)?OS(e,t,n):k(t)?FS(e,t,n):LS(e,t,n);return T1(e,t,o)}function DS(...e){let[t,r,n]=B.Match(e,{3:(i,a,m)=>[i,a,m],2:(i,a)=>[{},i,a]}),o=_e(t,r,n);return Ys(t,r,o),o}var $o={};Ot($o,{Assert:()=>Ys,Check:()=>K,Clean:()=>tr,Clone:()=>fe,Convert:()=>Sr,Create:()=>Xe,Decode:()=>zE,Default:()=>an,Diff:()=>ES,Encode:()=>WE,Equal:()=>im,Errors:()=>Xt,HasCodec:()=>JE,Hash:()=>sm,Parse:()=>hS,Patch:()=>SS,Pointer:()=>mr,Repair:()=>DS});var A1=P1(Ye,"hooks.json"),jS=64*1024,_S=30,NS=["PreToolUse","PostToolUse","UserPromptSubmit","SessionStart","Stop","PreCompact","SessionEnd"];function NPe(e,t){if(t===null||typeof t!="object"||Array.isArray(t))return"the rewrite is not a JSON object";if(!(e===null||typeof e!="object"))try{if($o.Check(e,t))return;let r=[...$o.Errors(e,t)][0];if(!r)return"the rewrite does not match the tool's schema";let n="instancePath"in r?String(r.instancePath):"";return`the rewrite does not match the tool's schema${n&&n!=="/"?` at \`${n}\``:""}: ${r.message}`}catch(r){return`the tool's schema could not be checked: ${r instanceof Error?r.message:String(r)}`}}function qPe(e=A1){let t=[],r={hooks:{}};try{if(!C1(e))return{config:r,diagnostics:t};let n=R1(e,"utf8");if(Buffer.byteLength(n,"utf8")>jS)return t.push({source:e,message:`skipped: larger than ${jS} bytes`}),{config:r,diagnostics:t};let o=JSON.parse(n),i=O1(o);for(let a of i.diagnostics)t.push({source:e,message:a});return{config:i.config,diagnostics:t}}catch(n){return t.push({source:e,message:`unreadable: ${n instanceof Error?n.message:String(n)}`}),{config:r,diagnostics:t}}}function O1(e){let t=[],r={hooks:{}};if(e===null||typeof e!="object"||Array.isArray(e))return{config:r,diagnostics:["expected a JSON object with a `hooks` key"]};let n=e.hooks;if(n===void 0)return{config:r,diagnostics:["no `hooks` key"]};if(n===null||typeof n!="object"||Array.isArray(n))return{config:r,diagnostics:["`hooks` must be an object keyed by event name"]};for(let[o,i]of Object.entries(n)){if(!NS.includes(o)){t.push(`unknown event \`${o}\` \u2014 supported: ${NS.join(", ")}`);continue}if(!Array.isArray(i)){t.push(`\`${o}\` must be an array of matchers`);continue}let a=[];for(let m of i){let c=M1(m,o,t);c&&a.push(c)}a.length&&(r.hooks[o]=a)}return{config:r,diagnostics:t}}function M1(e,t,r){if(e===null||typeof e!="object"||Array.isArray(e)){r.push(`\`${t}\`: a matcher must be an object`);return}let n=e,o=Array.isArray(n.hooks)?n.hooks:void 0;if(!o){r.push(`\`${t}\`: a matcher needs a \`hooks\` array`);return}let i=[];for(let m of o){if(m===null||typeof m!="object")continue;let c=m,p=typeof c.type=="string"?c.type:"command";if(p!=="command"){r.push(`\`${t}\`: only \`type: "command"\` is supported, got \`${p}\``);continue}if(typeof c.command!="string"||!c.command.trim()){r.push(`\`${t}\`: a hook needs a non-empty \`command\``);continue}let f=typeof c.timeout=="number"&&Number.isFinite(c.timeout)&&c.timeout>0?c.timeout:void 0;i.push({type:"command",command:c.command,timeout:f,...c.async===!0?{async:!0}:{},...c.once===!0?{once:!0}:{}})}return i.length?{matcher:typeof n.matcher=="string"?n.matcher:void 0,hooks:i}:void 0}function v1(e,t,r){let n=e.hooks[t];return n?n.filter(o=>{let i=o.matcher?.trim();if(!i||i==="*")return!0;if(r===void 0)return!1;let a=r.toLowerCase();return i.split("|").map(m=>m.trim().toLowerCase()).filter(Boolean).includes(a)}):[]}function qS(e,t,r={cwd:process.cwd()}){let n=r.timeoutS??_S;return new Promise(o=>{let i="",a="",m=!1,c=!1,p=w1(e,{cwd:r.cwd,shell:!0,stdio:["pipe","pipe","pipe"]});p.stdin?.on("error",()=>{}),p.stdout?.on("error",()=>{}),p.stderr?.on("error",()=>{});let f=setTimeout(()=>{m=!0,p.kill("SIGKILL")},n*1e3);p.stdout?.on("data",g=>{i+=g.toString("utf8")}),p.stderr?.on("data",g=>{a+=g.toString("utf8")});let d=g=>{c||(c=!0,clearTimeout(f),o({code:g,stdout:i,stderr:a,timedOut:m}))};p.on("error",g=>{a+=g.message,d(null)}),p.on("close",g=>d(g));try{p.stdin?.end(JSON.stringify(t))}catch{}})}function F1(e){let{code:t,stdout:r,stderr:n,timedOut:o}=e,i=n.trim();if(o)return{block:!1,error:`timed out after ${_S}s and was killed`};let a=L1(r),m=a?.hookSpecificOutput,c=typeof m?.additionalContext=="string"?m.additionalContext:typeof a?.additionalContext=="string"?a.additionalContext:void 0,p=typeof m?.permissionDecision=="string"?m.permissionDecision:void 0,f=typeof m?.permissionDecisionReason=="string"?m.permissionDecisionReason:void 0,d=m?.updatedInput,g=d!==null&&typeof d=="object"&&!Array.isArray(d)?d:void 0;return p==="deny"||p==="block"?{block:!0,reason:f||i||"denied by a hook",context:c}:p==="allow"?{block:!1,context:c,updatedInput:g}:t===2?{block:!0,reason:i||"blocked by a hook",context:c}:t!==0?{block:!1,context:c,updatedInput:g,error:`exited ${t===null?"without a status":t}${i?`: ${i}`:""}`}:!a&&r.trim()?{block:!1,context:r.trim()}:{block:!1,context:c,updatedInput:g}}function L1(e){let t=e.trim();if(t.startsWith("{"))try{let r=JSON.parse(t);return r&&typeof r=="object"&&!Array.isArray(r)?r:void 0}catch{return}}var Jc=new Set;function _Pe(){Jc.clear()}async function UPe(e,t,r,n){let o=v1(e,t,r.tool_name);if(!o.length)return{outcome:{block:!1},ran:0};let i=[],a=0,m,c,p;for(let f of o)for(let d of f.hooks){if(d.once){let I=`${t}\0${d.command}`;if(Jc.has(I))continue;Jc.add(I)}if(a+=1,d.async){qS(d.command,r,{cwd:n.cwd,timeoutS:d.timeout}).catch(()=>{});continue}let g=await qS(d.command,r,{cwd:n.cwd,timeoutS:d.timeout}),y=F1(g);y.context&&i.push(y.context),y.error&&(c=y.error),y.updatedInput&&(p=y.updatedInput),y.block&&!m&&(m=y)}return m?{outcome:{block:!0,reason:m.reason,context:i.join(`
|
|
8
|
+
|
|
9
|
+
`)||void 0},ran:a}:{outcome:{block:!1,context:i.join(`
|
|
10
|
+
|
|
11
|
+
`)||void 0,error:c,updatedInput:p},ran:a}}import{existsSync as US,readFileSync as D1}from"node:fs";function j1(e){return`${e}/.howtocode/mcp.json`}function Yc(e,t){if(!US(e))return{};try{let n=JSON.parse(D1(e,"utf8"))?.mcpServers;return!n||typeof n!="object"||Array.isArray(n)?{}:n}catch(r){return t.push(`${e}: ${r instanceof Error?r.message:String(r)}`),{}}}function zPe(e){let t=[];return Yc(Hi(e??Ye),t)}function WPe(e){let t=[],r=Yc(Hi(e.agentDir??Ye),t),n=j1(e.cwd),o=e.projectTrusted&&US(n)?n:void 0,i=o?Yc(o,t):{},a=Hi(e.agentDir??Ye),m=new Map;for(let[c,p]of Object.entries(r))m.set(c,{name:c,config:p,source:a,scope:"global"});for(let[c,p]of Object.entries(i))m.set(c,{name:c,config:p,source:o,scope:"project"});return{servers:[...m.values()],errors:t,projectConfig:o}}import{mkdirSync as N1,readdirSync as q1,readFileSync as _1,renameSync as U1,unlinkSync as BS,writeFileSync as B1}from"node:fs";import{join as GS}from"node:path";var G1=180*1e3,QPe="presence";function KS(e,t){return GS(e.dir,`${t.replace(/[^A-Za-z0-9._-]/g,"_")}.json`)}function K1(e,t=Date.now()){let r;try{r=q1(e.dir)}catch{return[]}let n=[];for(let o of r){if(!o.endsWith(".json"))continue;let i=GS(e.dir,o),a;try{a=_1(i,"utf8")}catch{continue}let m;try{m=JSON.parse(a)}catch{Qc(i);continue}if(typeof m?.id!="string"||typeof m?.cwd!="string"||typeof m?.at!="number"){Qc(i);continue}if(t-m.at>=G1){Qc(i);continue}n.push({id:m.id,cwd:m.cwd,host:typeof m.host=="string"?m.host:"",pid:typeof m.pid=="number"?m.pid:0,at:m.at,...typeof m.activity=="string"&&m.activity?{activity:m.activity}:{}})}return n.sort((o,i)=>i.at-o.at)}function XPe(e,t){N1(e.dir,{recursive:!0});let r=KS(e,t.id),n=`${r}.${process.pid}.tmp`;B1(n,JSON.stringify(t,null,2)),U1(n,r)}function ZPe(e,t){try{BS(KS(e,t))}catch{}}function HS(e,t,r,n=Date.now()){return K1(e,n).filter(o=>o.cwd===t&&o.id!==r)}function Qc(e){try{BS(e)}catch{}}import{Type as Ze}from"@netrodev/hxf-ai";import{defineTool as cm}from"@netrodev/hxf-coding-agent";import{relative as eL,join as tL}from"node:path";import{mkdirSync as rL,writeFileSync as nL}from"node:fs";import{existsSync as rAe,mkdirSync as H1,readFileSync as z1,renameSync as W1,writeFileSync as V1}from"node:fs";import{dirname as J1,isAbsolute as Y1,join as VS,relative as Q1,resolve as zS,sep as WS}from"node:path";var X1=1800*1e3,Z1=VS(".howtocode","claims.json");function JS(e){return VS(e,Z1)}function Zc(e,t){try{let r=z1(JS(e),"utf8"),n=JSON.parse(r);return(Array.isArray(n.claims)?[...n.claims]:[]).filter(i=>typeof i?.path=="string"&&typeof i?.holder=="string"&&typeof i?.at=="number"&&t-i.at<X1)}catch{return[]}}function YS(e,t){let r=JS(e);H1(J1(r),{recursive:!0});let n=`${r}.${process.pid}.tmp`;V1(n,JSON.stringify({version:1,claims:[...t]},null,2)),W1(n,r)}function QS(e,t){return Y1(t)?zS(t):zS(e,t)}function XS(e,t){if(e===t)return!0;let r=n=>n.endsWith(WS)?n:n+WS;return e.startsWith(r(t))||t.startsWith(r(e))}function ZS(e){let t=e.now??Date.now(),r=Zc(e.root,t),n=[],o=[],i=[];for(let a of e.paths){if(!a.trim())continue;let m=QS(e.root,a.trim()),c=r.find(p=>p.holder!==e.holder&&XS(p.path,m));if(c){o.push({path:Xc(e.root,m),by:c.holder,reason:c.reason||"no reason given"});continue}n.push(Xc(e.root,m)),i.push({path:m,holder:e.holder,reason:e.reason,at:t})}if(i.length>0){let a=r.filter(m=>m.holder!==e.holder||!i.some(c=>c.path===m.path));YS(e.root,[...a,...i])}return{granted:n,conflicts:o}}function ek(e,t,r){let n=Date.now(),o=Zc(e,n),i=r?.length?r.map(c=>QS(e,c.trim())).filter(Boolean):void 0,a=[],m=[];for(let c of o){let p=c.holder===t,f=i===void 0||i.some(d=>XS(c.path,d));p&&f?m.push(Xc(e,c.path)):a.push(c)}return YS(e,a),m}function ep(e,t=Date.now()){return Zc(e,t)}function Xc(e,t){let r=Q1(e,t);return r&&!r.startsWith("..")?r:t}var tp;function pAe(e){tp=e}var fAe=cm({name:"think",label:"think",description:"Private scratchpad. The text is not shown to the user. Use it before a non-obvious step.",promptSnippet:"think: private notes, not shown to the user",parameters:Ze.Object({thoughts:Ze.String({description:"Private notes"})}),async execute(){return{content:[{type:"text",text:"noted"}],details:{recorded:!0}}}}),dAe=cm({name:"ask",label:"ask",description:"Ask the user one question and wait for a selected answer. Use this instead of guessing when a choice blocks the task.",promptSnippet:"ask: ask the user to pick one option",parameters:Ze.Object({question:Ze.String(),options:Ze.Array(Ze.String(),{minItems:2})}),async execute(e,t){if(!tp)return{content:[{type:"text",text:"cancelled"}],details:{answer:"cancelled"}};let r=await tp(t.question,t.options);return{content:[{type:"text",text:r}],details:{answer:r}}}}),vi;function lAe(e){vi=e}var gAe=cm({name:"sessions",label:"sessions",description:"See the other HowToCode sessions working in this workspace, what they hold, and what they are doing. Use it to find who is blocking a claim, or to tell another session to release a file. Send a message with message + to.",promptSnippet:"sessions: other CLI sessions, and who holds what",parameters:Ze.Object({message:Ze.Optional(Ze.String({description:"Message text to leave for another session."})),to:Ze.Optional(Ze.String({description:"Session id to send the message to. Use `all` for every other session."}))}),async execute(e,t){let r=vi,n=r?.presenceDir?.();if(!r||!n)return{content:[{type:"text",text:"the session registry is unavailable here"}],details:{}};let o=r.selfId?.()??"",i=r.root(),a=HS({dir:n},i);if(t.message&&t.message.trim()){let c=t.to?.trim()||"all",p=a.filter(f=>f.id!==o&&(c==="all"||f.id===c));if(p.length===0)return{content:[{type:"text",text:"no other session in this workspace to message"}],details:{sent:0}};for(let f of p){let d=tL(n,`${f.id.replace(/[^A-Za-z0-9._-]/g,"_")}.inbox`);try{rL(n,{recursive:!0}),nL(d,`${JSON.stringify({from:o,at:Date.now(),text:t.message.trim()})}
|
|
12
|
+
`,{flag:"a"})}catch{}}return{content:[{type:"text",text:`left a message for ${p.map(f=>f.id).join(", ")}`}],details:{sent:p.length}}}if(a.length===0)return{content:[{type:"text",text:"no other session in this workspace"}],details:{sessions:[]}};let m=a.map(c=>{let p=c.id===o?"this session":c.id,f=ep(i).filter(y=>y.holder===`session:${c.id}`),d=c.activity?` \u2014 ${c.activity}`:"",g=f.length>0?`
|
|
13
|
+
holds:
|
|
14
|
+
${f.map(y=>` ${rk(i,y.path)} \u2014 ${y.reason}`).join(`
|
|
15
|
+
`)}`:"";return` ${p} (pid ${c.pid}${c.id===o?"":`, seen ${Math.round((Date.now()-c.at)/1e3)}s ago`})${d}${g}`});return{content:[{type:"text",text:`sessions in ${i}:
|
|
16
|
+
${m.join(`
|
|
17
|
+
`)}`}],details:{sessions:a}}}});function oL(e){let t=[];if(e.granted.length>0&&t.push(`claimed: ${e.granted.join(", ")}`),e.conflicts.length>0){t.push(""),t.push("refused \u2014 another agent is working on these:");for(let r of e.conflicts)t.push(` ${r.path} \u2014 held by ${r.by}: ${r.reason}`);t.push(""),t.push("Wait for the holder to release it, or work on something else. Do not edit a refused path.")}return t.length===0&&t.push("nothing to claim"),{text:t.join(`
|
|
18
|
+
`),isError:e.conflicts.length>0}}var tk=cm({name:"claim",label:"claim",description:"Claim files or directories before editing them, so a parallel agent cannot overwrite your work. Refused paths are held by someone else \u2014 do not edit them. Pass no paths to list every claim in this workspace.",promptSnippet:"claim: reserve files before editing",parameters:Ze.Object({paths:Ze.Optional(Ze.Array(Ze.String(),{description:"Files or directories to claim. Omit to list the current claims."})),reason:Ze.Optional(Ze.String({description:"Why you are taking them, shown to a refused agent."})),release:Ze.Optional(Ze.Boolean({description:"Release these paths instead of claiming them. Omit paths to release everything you hold."}))}),async execute(e,t){if(!vi)return{content:[{type:"text",text:"claims are unavailable in this session"}],details:{},isError:!0};let r=vi.root(),n=vi.holder();if(t.release){let m=ek(r,n,t.paths);return{content:[{type:"text",text:m.length>0?`released: ${m.join(", ")}`:"you held nothing matching that"}],details:{released:m}}}if(!t.paths||t.paths.length===0){let m=ep(r);return m.length===0?{content:[{type:"text",text:"no active claims in this workspace"}],details:{claims:[]}}:{content:[{type:"text",text:m.map(p=>`${p.holder===n?"(you) ":""}${rk(r,p.path)} \u2014 ${p.reason}`).join(`
|
|
19
|
+
`)}],details:{claims:m}}}let o=ZS({root:r,holder:n,reason:t.reason??"no reason given",paths:t.paths}),{text:i,isError:a}=oL(o);return{content:[{type:"text",text:i}],isError:a,details:o}}});function rk(e,t){let r=eL(e,t);return r&&!r.startsWith("..")?r:t}import{StringEnum as iL}from"@netrodev/hxf-ai";import{defineTool as sL}from"@netrodev/hxf-coding-agent";var v={};Ot(v,{Any:()=>Qn,Array:()=>xt,BigInt:()=>oi,Boolean:()=>na,Call:()=>QI,Capitalize:()=>ob,Codec:()=>ta,Conditional:()=>fb,Constructor:()=>pr,ConstructorParameters:()=>lb,Cyclic:()=>lr,Decode:()=>rg,DecodeBuilder:()=>ri,Dependent:()=>$n,Encode:()=>ng,EncodeBuilder:()=>ti,Enum:()=>eg,Evaluate:()=>He,Exclude:()=>yb,Extends:()=>rt,ExtendsResult:()=>F,Extract:()=>hb,Function:()=>fr,Generic:()=>Yr,Identifier:()=>ii,Immutable:()=>og,Index:()=>Eb,Infer:()=>ei,InstanceType:()=>zb,Instantiate:()=>jt,Integer:()=>Sn,Interface:()=>MI,Intersect:()=>ot,IsAny:()=>Ie,IsArray:()=>W,IsBigInt:()=>Tt,IsBoolean:()=>ft,IsCall:()=>lo,IsCodec:()=>pt,IsConstructor:()=>Ee,IsCyclic:()=>me,IsDependent:()=>ke,IsEnum:()=>Te,IsEnumValue:()=>Zl,IsFunction:()=>Se,IsGeneric:()=>Yn,IsIdentifier:()=>mg,IsImmutable:()=>En,IsInfer:()=>Le,IsInteger:()=>Ke,IsIntersect:()=>O,IsKind:()=>C,IsLiteral:()=>H,IsNever:()=>ht,IsNull:()=>yr,IsNumber:()=>xe,IsObject:()=>A,IsOptional:()=>ve,IsParameter:()=>pg,IsReadonly:()=>Or,IsRecord:()=>ne,IsRef:()=>te,IsRefine:()=>ni,IsRest:()=>tn,IsSchema:()=>ye,IsString:()=>qe,IsSymbol:()=>xr,IsTemplateLiteral:()=>ue,IsThis:()=>xa,IsTuple:()=>_,IsUndefined:()=>Kt,IsUnion:()=>k,IsUnknown:()=>Fe,IsUnsafe:()=>ea,IsVoid:()=>Ct,KeyOf:()=>Vb,Literal:()=>G,Lowercase:()=>ib,Mapped:()=>r$,Module:()=>H$,Never:()=>ie,NonNullable:()=>s$,Null:()=>Zn,Number:()=>wt,Object:()=>M,Omit:()=>m$,Optional:()=>zl,Parameter:()=>kn,Parameters:()=>p$,Partial:()=>d$,Pick:()=>b$,Readonly:()=>ig,ReadonlyObject:()=>jc,ReadonlyType:()=>S$,Record:()=>io,RecordKey:()=>so,RecordPattern:()=>De,RecordValue:()=>pe,Ref:()=>Be,Refine:()=>sg,Required:()=>q$,Rest:()=>wn,ReturnType:()=>U$,Script:()=>J$,String:()=>tt,Symbol:()=>eo,TemplateLiteral:()=>Qh,This:()=>ya,Tuple:()=>we,Uncapitalize:()=>sb,Undefined:()=>ao,Union:()=>D,Unknown:()=>Ne,Unsafe:()=>Jl,Uppercase:()=>ab,Void:()=>ha,With:()=>rm});var aL={pending:"[ ]",in_progress:"[>]",completed:"[x]",dropped:"[-]"},mL=v.Object({op:iL(["init","start","done","drop","view"],{description:"init replaces the list; start/done/drop move one task; view reads it"}),items:v.Optional(v.Array(v.String(),{description:"Task labels for init. 5-10 words each, specific enough to execute without re-planning"})),task:v.Optional(v.String({description:"Exact label of the task to start, complete or drop"}))});function nk(e){if(e.length===0)return"Todo list is empty.";let t=e.filter(o=>o.status==="completed").length,r=e.map(o=>`${aL[o.status]} ${o.content}`),n=e.filter(o=>o.status==="pending"||o.status==="in_progress").length;return[`${t}/${e.length} done, ${n} open`,...r].join(`
|
|
20
|
+
`)}function uL(e,t,r,n){let o=e.map(i=>({...i}));switch(t){case"init":return!r||r.length===0?{todos:o,error:"init needs a non-empty items array"}:{todos:r.map(i=>({content:i,status:"pending"}))};case"view":return{todos:o};case"start":case"done":case"drop":{if(!n)return{todos:o,error:`${t} needs task`};let i=o.find(a=>a.content===n);if(!i)return{todos:o,error:`no task matches ${JSON.stringify(n)}`};if(t==="start"){for(let a of o)a.status==="in_progress"&&(a.status="pending");i.status="in_progress"}else i.status=t==="done"?"completed":"dropped";return{todos:o}}default:return{todos:o,error:`unknown op ${JSON.stringify(t)}`}}}function cL(e){let t=[];for(let r of e.sessionManager.getBranch()){if(r.type!=="message")continue;let n=r.message;if(n.role!=="toolResult"||n.toolName!=="todo")continue;let o=n.details;o?.todos&&(t=o.todos)}return t}var ok=sL({name:"todo",label:"todo",description:"Track the plan for this task. Use `init` once with the whole plan (investigation through verification), then `start`/`done` as you go. Keep the list current so progress stays visible; do not re-init unless the plan materially changes.",promptSnippet:"todo: record and advance the plan for the current task",parameters:mL,async execute(e,t,r,n,o){let i=cL(o),{todos:a,error:m}=uL(i,t.op,t.items,t.task),c={op:t.op,todos:a,...m?{error:m}:{}};return{content:[{type:"text",text:m?`Error: ${m}
|
|
21
|
+
${nk(a)}`:nk(a)}],details:c,...m?{isError:!0}:{}}}});import{StringEnum as pL}from"@netrodev/hxf-ai";import{defineTool as fL}from"@netrodev/hxf-coding-agent";var kr=new Map,ik=2e3,sk=80;function GOe(){kr.clear()}function ak(){return kr.size===0?"":["<shared-notes>","Working notes recorded with the `context` tool. They survive compaction and are visible to every agent on this task.",...[...kr].map(([t,r])=>`- ${t}: ${r}`),"</shared-notes>"].join(`
|
|
22
|
+
`)}function dL(e,t,r){if(e==="list")return kr.size===0?{text:"No notes."}:{text:[...kr].map(([n,o])=>`${n} = ${o}`).join(`
|
|
23
|
+
`)};if(!t)return{text:"Error: key is required",error:"key required"};if(t.length>sk)return{text:`Error: key longer than ${sk} characters`,error:"key too long"};if(e==="forget")return{text:kr.delete(t)?`Removed ${t}`:`No note named ${t}`};if(e==="set"){if(!r)return{text:"Error: value is required for set",error:"value required"};let n=r.length>ik?`${r.slice(0,ik)}\u2026`:r;return kr.set(t,n),{text:`Recorded ${t} (${kr.size} note${kr.size===1?"":"s"} held)`}}return{text:`Error: unknown op ${JSON.stringify(e)}`,error:"unknown op"}}var mk=fL({name:"context",label:"context",description:"Record a durable working note (a decision, a file's role, a fact you would otherwise re-derive). Notes survive context compaction and are visible to every agent on this task, including subagents. Use `set` to write, `list` to read, `forget` to remove.",promptSnippet:"context: durable notes shared with every agent on this task",parameters:v.Object({op:pL(["set","list","forget"],{description:"set writes a note, list reads all, forget removes one"}),key:v.Optional(v.String({description:"Short lookup key, e.g. 'auth-entrypoint'"})),value:v.Optional(v.String({description:"The fact to keep (for set)"}))}),async execute(e,t){let{text:r,error:n}=dL(t.op,t.key,t.value);return{content:[{type:"text",text:r}],details:{op:t.op,notes:Object.fromEntries(kr)},...n?{isError:!0}:{}}}});import{StringEnum as lL}from"@netrodev/hxf-ai";import{defineTool as gL}from"@netrodev/hxf-coding-agent";var uk="howtocode.goal",VOe="howtocode.goal.continue",ck=400,pm=25,pk={active:"\u25CF",paused:"\u2016",done:"\u2713",cleared:"\u25CB"};function yL(e){if(!e||e.status==="cleared")return"No goal set.";let t=e.budget??pm,r=[`${pk[e.status]} ${e.status}`,`${e.used}/${t} continuations`];return e.note&&r.push(e.note),`${r.join(" \xB7 ")}
|
|
24
|
+
${e.text}`}function JOe(e){if(!e||e.status==="cleared"||e.status==="done")return"";let t=e.budget??pm,r=e.text.length>48?`${e.text.slice(0,47)}\u2026`:e.text;return`goal ${pk[e.status]} ${e.used}/${t} \xB7 ${r}`}function YOe(e){let t=["<goal>",e.text,`Status: ${e.status}.`];return e.status==="active"&&t.push("Work toward this goal until it is genuinely met. When it is, call the `goal` tool with",'op="complete" and a note naming the evidence; a command you ran or a file you checked.',"If you are blocked and cannot proceed, say so plainly instead of repeating an attempt."),t.push("</goal>"),t.join(`
|
|
25
|
+
`)}function QOe(e){return["[goal] The goal is still open and you stopped without closing it:",` ${e.text}`,"","Continue from where you left off. Do not repeat work you already did. If the goal is met,",'call the `goal` tool with op="complete" and a note naming the evidence. Do not call it',"complete to escape a hard problem: if you cannot make progress, state what is blocking you.",`Continuations used: ${e.used}/${e.budget??pm}.`].join(`
|
|
26
|
+
`)}var fk;function XOe(){return fk}function xL(e){fk=e}function ZOe(e){if(!e)return{action:"stop",reason:"no goal",close:!1};if(e.status==="done")return{action:"stop",reason:"goal complete",close:!1};if(e.status==="cleared")return{action:"stop",reason:"goal cleared",close:!1};if(e.status==="paused")return{action:"stop",reason:"goal paused",close:!1};let t=e.budget??pm;return e.used>=t?{action:"stop",reason:`budget exhausted (${t} continuations)`,close:!0}:{action:"continue"}}function hL(e,t,r,n,o){switch(t){case"view":return{goal:e};case"set":return r?.trim()?r.length>ck?{goal:e,error:`text longer than ${ck} characters`}:n!==void 0&&(!Number.isInteger(n)||n<1)?{goal:e,error:"budget must be a positive integer"}:{goal:{text:r.trim(),status:"active",used:0,...n===void 0?{}:{budget:n}}}:{goal:e,error:"set needs text"};case"pause":case"resume":case"complete":case"clear":return!e||e.status==="cleared"?{goal:e,error:"no goal to change"}:t==="resume"?e.status==="done"?{goal:e,error:"goal is complete; set a new one instead"}:{goal:{...e,status:"active",note:void 0}}:t==="pause"?{goal:{...e,status:"paused"}}:t==="clear"?{goal:{...e,status:"cleared"}}:o?.trim()?{goal:{...e,status:"done",note:o.trim()}}:{goal:e,error:"complete needs a note naming the evidence (a command you ran or a file you checked)"};default:return{goal:e,error:`unknown op ${JSON.stringify(t)}`}}}function IL(e){let t;for(let r of e.sessionManager.getBranch()){if(r.type==="custom"&&r.customType===uk){t=r.data;continue}if(r.type==="custom_message"&&r.customType===uk){t=r.details??t;continue}if(r.type!=="message")continue;let n=r.message;if(n.role!=="toolResult"||n.toolName!=="goal")continue;let o=n.details;o?.goal&&(t=o.goal)}return t}var bL=v.Object({op:lL(["set","view","pause","resume","complete","clear"],{description:"set starts a goal; complete closes it with evidence; pause/resume/clear manage it; view reads it"}),text:v.Optional(v.String({description:"The goal, in one sentence, as the user would state it (for set)"})),budget:v.Optional(v.Number({description:"Optional cap on automatic continuations before the run stops"})),note:v.Optional(v.String({description:"Evidence that the goal is met (required for complete)"}))}),eMe=gL({name:"goal",label:"goal",description:"Track the goal for this session. The goal is already shown in your context every request, so you rarely need `view`. Call `complete` only when the goal is genuinely met, and pass a note naming the evidence. When a goal is active the harness continues the run if you stop without closing it, so closing it is how you stop.",promptSnippet:"goal: the session's objective, and how to close it",parameters:bL,async execute(e,t,r,n,o){let i=IL(o),{goal:a,error:m}=hL(i,t.op,t.text,t.budget,t.note);xL(a);let c=yL(a);return{content:[{type:"text",text:m?`Error: ${m}
|
|
27
|
+
${c}`:c}],details:{op:t.op,goal:a},...m?{isError:!0}:{}}}});import{existsSync as op,mkdirSync as dk,readFileSync as lk}from"node:fs";import{dirname as gk,join as yk}from"node:path";import{defineTool as xk}from"@netrodev/hxf-coding-agent";function fm(){return{state:"inactive",wasActive:!1}}function $L(e){return e?e.state==="pending"?{...e,state:"inactive"}:{...e}:fm()}function aMe(e){return e.state!=="inactive"?e:{...e,state:"pending"}}function EL(e){return e.state!=="pending"?e:{state:"active",wasActive:!0}}function SL(e){return e.state!=="inactive"?e:{state:"active",wasActive:!0}}function kL(e){return e.state!=="active"?e:{...e,state:"inactive"}}function mMe(e){return e.state==="inactive"?e:{...e,state:"inactive"}}function dm(e){return e.state==="active"}function TL(e,t){return e===t}function wL(e,t){return["<plan-mode>","Plan mode is active. Do not make any edits or writes to the system.",t?`A plan file exists at ${e}. Read it and refine it with the \`edit\` tool.`:`No plan is written yet. Write yours to ${e} with the \`write\` tool.`,"That file is the only path you may edit.","Explore first: read, search, and run read-only commands until the approach is clear.","End your turn with either `ask` to clarify a requirement, or `exit_plan_mode` to present","the plan for approval. Do not start implementing before the plan is approved.","</plan-mode>"].join(`
|
|
28
|
+
`)}function CL(e){return`Rejected: file edits are not allowed in plan mode. The only editable file is the plan file (${e}). Present the plan with exit_plan_mode first.`}var st,at=fm(),np;function uMe(){return at}function cMe(){return st}function pMe(){return dm(at)}function hk(){if(!(!st||!op(st)))try{let e=lk(st,"utf8");return e.trim()?e:void 0}catch{return}}function Ik(){return hk()!==void 0}function fMe(){return at.state==="inactive"?"":at.state==="pending"?"plan pending":Ik()?"plan \u25CF ready":"plan \u25CF planning"}function bk(){return np?yk(np,"plan_mode.json"):void 0}function RL(){let e=bk();if(e)try{dk(gk(e),{recursive:!0}),sr(e,JSON.stringify(at))}catch{}}function PL(){let e=bk();if(!e||!op(e))return fm();try{return $L(JSON.parse(lk(e,"utf8")))}catch{return fm()}}function AL(e){np=e,st=yk(e,"plan.md"),at=PL()}function ip(e){return at=e,RL(),at}function dMe(){return e=>{e.on("tool_call",async t=>{if(!dm(at)||t.toolName!=="edit"&&t.toolName!=="write")return;let r=t.input?.path;if(typeof r=="string"&&!(!st||TL(r,st)))return{block:!0,reason:CL(st)}})}}function lMe(){return e=>{e.on("session_start",async(t,r)=>{AL(r.sessionManager.getSessionDir())}),e.on("before_agent_start",async()=>{at.state==="pending"&&ip(EL(at))}),e.on("context_with_system",async t=>{if(!dm(at)||!st)return;let r=t.messages[0];if(!r||r.role!=="system")return;let n=wL(st,Ik()),o=`${typeof r.content=="string"?r.content:""}
|
|
29
|
+
|
|
30
|
+
${n}`;return{messages:t.messages.map(a=>a===r?{...r,content:o}:a)}})}}var rp=2e4;function OL(){if(st){try{dk(gk(st),{recursive:!0}),op(st)||sr(st,"")}catch{return}return st}}var gMe=xk({name:"enter_plan_mode",label:"enter_plan_mode",description:"Enter plan mode to design an approach before writing code. Use it when a task has genuine ambiguity; several reasonable designs, or a restructuring where the wrong approach wastes significant effort. Do not use it for a clear fix, a rename, or a task that follows existing conventions. The user must approve entering.",promptSnippet:"enter_plan_mode: design first when the approach is genuinely ambiguous",parameters:v.Object({}),async execute(e,t,r,n,o){if(at.state!=="inactive")return{content:[{type:"text",text:`Plan mode is already ${at.state}.`}],details:{}};if(!o.hasUI)return{content:[{type:"text",text:"Plan mode needs an interactive session: there is no one to approve the plan. Proceed normally."}],details:{},isError:!0};if(!await o.ui.confirm("Enter plan mode?","The agent will explore and design an approach before editing anything."))return{content:[{type:"text",text:"The user declined plan mode. Proceed normally."}],details:{}};ip(SL(at));let a=OL();return{content:[{type:"text",text:["Plan mode is active. Edits are blocked except for the plan file.",a?`Write your plan to ${a}.`:"Write your plan to the session plan file."].join(`
|
|
31
|
+
`)}],details:{planFile:a}}}}),yMe=xk({name:"exit_plan_mode",label:"exit_plan_mode",description:"Present your plan for approval when you have finished planning. The plan is read from the plan file on disk, so write the file first. If the user asks for changes, stay in plan mode and revise it.",promptSnippet:"exit_plan_mode: present the written plan for approval",parameters:v.Object({}),executionMode:"sequential",async execute(e,t,r,n,o){if(!dm(at))return{content:[{type:"text",text:"Plan mode is not active."}],details:{},isError:!0};let i=hk();if(!i)return{content:[{type:"text",text:`No plan has been written yet. Write it to ${st??"the plan file"} before exiting plan mode.`}],details:{},isError:!0};if(!o.hasUI)return{content:[{type:"text",text:"Plan approval needs an interactive session."}],details:{},isError:!0};let a=i.length>rp?`${i.slice(0,rp)}
|
|
32
|
+
\u2026 (${i.length-rp} more characters)`:i;return await o.ui.confirm("Approve this plan?",a)?(ip(kL(at)),{content:[{type:"text",text:"Plan approved. You may now implement it."}],details:{approved:!0,planFile:st}}):{content:[{type:"text",text:"The user did not approve the plan. Stay in plan mode, revise the plan file with the feedback, and present it again."}],details:{approved:!1}}}});function Eo(e){return typeof e=="string"?e:Array.isArray(e)?e.map(t=>{let r=t;return r.type==="text"&&typeof r.text=="string"?r.text:""}).join(`
|
|
33
|
+
`):e==null?"":String(e)}function lm(e,t){if(Array.isArray(e)){let r=e.map(o=>({...o})),n=r.filter(o=>o.type==="text");if(n.length>0){n[0].text=t;for(let o of n.slice(1))o.text="";return r}return[...r,{type:"text",text:t}]}return t}function $k(){return e=>{e.on("context_with_system",async t=>{let r=ak();if(!r)return;let n=t.messages[0];if(!n||n.role!=="system")return;let o=`${Eo(n.content)}
|
|
34
|
+
|
|
35
|
+
${r}`;return{messages:t.messages.map(a=>a===n?{...n,content:lm(n.content,o)}:a)}})}}import{Type as vn}from"@netrodev/hxf-ai";import{defineTool as ML}from"@netrodev/hxf-coding-agent";var So="[Compressed conversation section]";function Fi(e){return Math.round(e.length/4)}function sp(e){let t=e.prune.messages.nextBlockId;return!Number.isInteger(t)||t<1?(e.prune.messages.nextBlockId=2,1):(e.prune.messages.nextBlockId=t+1,t)}function ap(e){let t=e.prune.messages.nextRunId;return!Number.isInteger(t)||t<1?(e.prune.messages.nextRunId=2,1):(e.prune.messages.nextRunId=t+1,t)}function mp(e,t,r="xml"){let n=Mo(Nn(e,r),void 0,r),o=t.trim();return o.length===0?`${So}
|
|
36
|
+
${n}`:`${So}
|
|
37
|
+
${o}
|
|
38
|
+
|
|
39
|
+
${n}`}function Lr(e){return e.prune.messages.blocks.filter(t=>t.active).map(t=>({blockId:t.blockId,anchorIndex:t.anchorIndex,coveredIndices:t.coveredIndices,summary:t.summary}))}function up(e,t,r,n,o,i,a){let m=e.prune.messages,c=[...new Set(a.filter($=>Number.isInteger($)&&$>0))],p=new Set;for(let $ of m.blocks)if($.active)for(let b of $.coveredIndices)p.add(b);let f=new Set(r.indices);for(let $ of c){let b=m.blocks.find(w=>w.blockId===$);if(b)for(let w of b.coveredIndices)f.add(w)}let d=[...f].sort(($,b)=>$-b),g=d.filter($=>!p.has($)),y=0;for(let $ of g)y+=r.tokenByIndex.get($)??0;let I={blockId:o,runId:t.runId,active:!0,deactivatedByUser:!1,mode:t.mode,topic:t.topic,startId:t.startId,endId:t.endId,anchorIndex:n,compressedTokens:y,summaryTokens:Fi(i),coveredIndices:d,consumedBlockIds:c,parentBlockIds:[],createdAt:Date.now(),summary:i};m.blocks.push(I);let h=Date.now();for(let $ of c){let b=m.blocks.find(w=>w.blockId===$);!b||!b.active||(b.active=!1,b.deactivatedAt=h,b.deactivatedByBlockId=o,b.parentBlockIds.includes(o)||b.parentBlockIds.push(o))}return e.stats.totalCompressTokens+=y,{compressedTokens:y,coveredIndices:d,newlyCoveredIndices:g}}function Sk(e,t="xml"){let r=[],n=t==="compact"?/@b([1-9]\d*)@/gi:/\(b(\d+)\)/gi,o;for(;(o=n.exec(e))!==null;){let i=Number.parseInt(o[1],10);Number.isInteger(i)&&r.push({raw:o[0],blockId:i,startIndex:o.index,endIndex:o.index+o[0].length})}return r}function kk(e){if(typeof e.topic!="string"||e.topic.trim().length===0)throw new Error("topic is required and must be a non-empty string");if(!Array.isArray(e.content)||e.content.length===0)throw new Error("content is required and must be a non-empty array");for(let t=0;t<e.content.length;t++){let r=e.content[t],n=`content[${t}]`;if(typeof r?.startId!="string"||r.startId.trim().length===0)throw new Error(`${n}.startId is required and must be a non-empty string`);if(typeof r?.endId!="string"||r.endId.trim().length===0)throw new Error(`${n}.endId is required and must be a non-empty string`);if(typeof r?.summary!="string"||r.summary.trim().length===0)throw new Error(`${n}.summary is required and must be a non-empty string`)}}function cp(e,t,r,n){let o=new Set,i=new Map;for(let d of r)o.add(d.index),i.set(d.index,d.tokenCount??0);let a=Ek(e,o,t.startId,"startId",n),m=Ek(e,o,t.endId,"endId",n);if(a.index>m.index)throw new Error(`startId ${a.ref} appears after endId ${m.ref} in the conversation. Start must come before end.`);let c=[];for(let d of r)d.index>=a.index&&d.index<=m.index&&c.push(d.index);let p=new Set(c),f=e.prune.messages.blocks.filter(d=>d.active&&p.has(d.anchorIndex)).map(d=>d.blockId);return{startIdx:a.index,endIdx:m.index,indices:c,requiredBlockIds:f,tokenByIndex:i}}function Ek(e,t,r,n,o){let i=_m(r,o);if(i===null){let m=o==="compact"?"@4@":"mNNNN",c=o==="compact"?"@b1@":"bN";throw new Error(`${n} is invalid. Use an injected message ID (${m}) or block ID (${c}).`)}let a;if(i.kind==="message")a=i.index;else{let m=e.prune.messages.blocks.find(c=>c.blockId===i.blockId&&c.active);a=m?m.anchorIndex:-1}if(a<0||!t.has(a))throw new Error(`${n} ${i.ref} is not available in the current conversation context. Choose an injected ID visible in context.`);return{ref:i.ref,index:a}}function Tk(e,t,r,n="xml"){let i=[...e.map((m,c)=>{let p={startId:m.startId.trim(),endId:m.endId.trim(),summary:m.summary};return{index:c,entry:p,selection:cp(t,p,r,n)}})].sort((m,c)=>m.selection.startIdx-c.selection.startIdx||m.selection.endIdx-c.selection.endIdx||m.index-c.index),a=[];for(let m=1;m<i.length;m++){let c=i[m-1],p=i[m];!c||!p||p.selection.startIdx>c.selection.endIdx||a.push(`content[${c.index}] (${c.entry.startId}..${c.entry.endId}) overlaps content[${p.index}] (${p.entry.startId}..${p.entry.endId}). Overlapping ranges cannot be compressed in the same batch.`)}if(a.length>0)throw new Error(a.length===1?a[0]:a.map(m=>`- ${m}`).join(`
|
|
40
|
+
`))}function wk(e,t,r,n="xml"){let o=new Set(t.prune.messages.blocks.filter(i=>i.active).map(i=>i.blockId));return e.map((i,a)=>{let m={startId:i.startId.trim(),endId:i.endId.trim(),summary:i.summary},c=cp(t,m,r,n),p=new Set(c.requiredBlockIds),f=Sk(m.summary,n),d=new Set,g=`content[${a}]`;for(let y of f){if(d.has(y.blockId))throw new Error(`${g}.summary duplicates placeholder ${y.raw}`);if(d.add(y.blockId),!p.has(y.blockId))throw new Error(o.has(y.blockId)?`${g}.summary references ${y.raw}, which is outside the selected range`:`${g}.summary references ${y.raw}, which is not an active compressed block`)}for(let y of c.requiredBlockIds)if(!d.has(y)){let I=n==="compact"?`@b${y}@`:`(b${y})`;throw new Error(`${g}.summary is missing the required placeholder ${I}`)}return f})}function Ck(e,t,r,n="xml"){return e.map((o,i)=>{let a={startId:o.startId.trim(),endId:o.endId.trim(),summary:o.summary},m=cp(t,a,r,n);return{index:i,entry:a,selection:m,anchorIndex:m.startIdx}})}function vL(e){let t=e.match(/^\s*\[Compressed conversation(?: section)?(?: b\d+)?\]/i);return t?e.slice(t[0].length).replace(/^(?:\r?\n)+/,"").replace(/(?:\r?\n)*<dcp-message-id>b\d+<\/dcp-message-id>\s*$/i,"").replace(/(?:\r?\n)*@b[1-9]\d*@\s*$/i,"").replace(/(?:\r?\n)+$/,""):e}function FL(e,t,r){if(t.length===0)return{expanded:e,consumedBlockIds:[]};let n="",o=0,i=[];for(let a of t){let m=r.prune.messages.blocks.find(c=>c.blockId===a.blockId&&c.active);if(!m)throw new Error(`Compressed block not found: ${a.raw}`);n+=e.slice(o,a.startIndex),n+=vL(m.summary),o=a.endIndex,i.push(a.blockId)}return n+=e.slice(o),{expanded:n,consumedBlockIds:i}}function Rk(e,t,r,n="xml"){kk(e),Tk(e.content,t,r,n);let o=wk(e.content,t,r,n),i=Ck(e.content,t,r,n),a=ap(t),m=[];for(let[c,p]of i.entries()){let f=o[c]??[],{expanded:d,consumedBlockIds:g}=FL(p.entry.summary,f,t),y=sp(t),I=mp(y,d,n),h=up(t,{topic:e.topic,startId:p.entry.startId,endId:p.entry.endId,mode:"range",runId:a},p.selection,p.anchorIndex,y,I,g);m.push({blockId:y,runId:a,coveredCount:h.coveredIndices.length,compressedTokens:h.compressedTokens,summaryTokens:Fi(I),expandedSummary:d})}return m}function LL(e){let t=e.format??"xml",r=jn(1,t),n=Nn(2,t);return ML({name:"compress",label:"compress",description:`Collapse conversation ranges into stored compressed summaries, each marked with "${So}". Copy startId and endId from the injected IDs in context (message IDs like ${r}, block IDs like ${n}); startId must come before endId. Ranges in one call must not overlap, and each summary must reference every required block placeholder exactly once.`,promptSnippet:"compress: replace a conversation range with a stored summary",parameters:vn.Object({topic:vn.String({description:"Short label (3-5 words) for display - e.g., 'Auth System Exploration'"}),content:vn.Array(vn.Object({startId:vn.String({description:`Message or block ID marking the beginning of range (e.g. ${r}, ${n})`}),endId:vn.String({description:`Message or block ID marking the end of range (e.g. ${jn(12,t)}, ${Nn(5,t)})`}),summary:vn.String({description:"Complete technical summary replacing all content in range"})}),{description:"One or more ranges to compress, each with start/end boundaries and a summary"})}),async execute(o,i){try{let a=Rk(i,e.state(),e.messages(),t),m=a.map(g=>g.blockId),c=a.reduce((g,y)=>g+y.coveredCount,0),p=a.reduce((g,y)=>g+y.compressedTokens,0),f=a.reduce((g,y)=>g+y.summaryTokens,0),d=Math.max(0,p-f);return{content:[{type:"text",text:`Compressed ${c} messages into ${So}`+(p>0?` - ${p} tokens replaced by ${f}, saving ${d}.`:".")}],details:{blockIds:m,runId:a[0]?.runId,messages:c,compressedTokens:p,summaryTokens:f}}}catch(a){let m=a instanceof Error?a.message:String(a);return{content:[{type:"text",text:m}],details:{error:m},isError:!0}}}})}import{existsSync as Pk,mkdirSync as DL,readFileSync as Ak,unlinkSync as jL}from"node:fs";import{dirname as NL,join as Ok}from"node:path";function pp(e){try{let t=Ok(e,".howtocode","dcp.json");if(!Pk(t))return;let r=JSON.parse(Ak(t,"utf8"));if(typeof r!="object"||r===null)return;let n=r.enabled;return typeof n=="boolean"?n:void 0}catch{return}}function fp(e){if(e.env!==void 0){let t=e.env.trim().toLowerCase();return{enabled:t!=="0"&&t!=="false",source:"env"}}return e.config!==void 0?{enabled:e.config,source:"config"}:e.runtime!==void 0?{enabled:e.runtime,source:"session"}:{enabled:!0,source:"default"}}function Mk(){return{messageIds:qm(),prune:{tools:{},messages:{blocks:[],nextBlockId:1,nextRunId:1}},stats:{totalPruneTokens:0,totalCompressTokens:0}}}function ym(e){let t=e.replace(/[^A-Za-z0-9._-]/g,"_")||"session";return Ok(Ye,"dcp",`${t}.json`)}function qL(e){if(typeof e!="object"||e===null)return!1;let t=e,r=t.prune?.messages,n=t.messageIds;return typeof t.prune=="object"&&t.prune!==null&&typeof t.prune.tools=="object"&&t.prune.tools!==null&&typeof r=="object"&&r!==null&&Array.isArray(r.blocks)&&Number.isInteger(r.nextBlockId)&&Number.isInteger(r.nextRunId)&&typeof n=="object"&&n!==null&&Number.isInteger(n.nextRef)&&typeof n.keyToRef=="object"&&n.keyToRef!==null&&typeof n.refToKey=="object"&&n.refToKey!==null&&typeof t.stats=="object"&&t.stats!==null&&Number.isFinite(t.stats.totalPruneTokens)&&Number.isFinite(t.stats.totalCompressTokens)}var gm=new Map;function Li(e){let t=gm.get(e);if(t)return t;let r;try{let o=ym(e);if(Pk(o)){let i=JSON.parse(Ak(o,"utf8"));qL(i)&&(r=i)}}catch{r=void 0}let n=r??Mk();return gm.set(e,n),n}function un(e){let t=gm.get(e);if(!t)return;let r=ym(e);DL(NL(r),{recursive:!0}),sr(r,JSON.stringify(t))}function _L(e){gm.delete(e);try{jL(ym(e))}catch{}}function rr(e){return e.replaceAll("\\","/")}function UL(e){return/[\\.^$+{}()|\[\]]/.test(e)?`\\${e}`:e}function dp(e,t){if(!t)return!1;let r=rr(e),n=rr(t),o="^";for(let i=0;i<n.length;i++){let a=n[i];if(a==="*"){if(n[i+1]==="*"){if(n[i+2]==="/"){o+="(?:.*/)?",i+=2;continue}o+=".*",i++;continue}o+="[^/]*";continue}if(a==="?"){o+="[^/]";continue}if(a==="/"){o+="/";continue}o+=UL(a)}return o+="$",new RegExp(o).test(r)}function xm(e,t){if(typeof t!="object"||t===null)return[];let r=[],n=t;if((e==="apply_patch"||e==="patch")&&typeof n.patchText=="string"){let o=/\*\*\* (?:Add|Delete|Update) File: ([^\n\r]+)/g,i;for(;(i=o.exec(n.patchText))!==null;)r.push(i[1].trim())}if(e==="multiedit"&&(typeof n.filePath=="string"&&r.push(n.filePath),Array.isArray(n.edits)))for(let o of n.edits)o&&typeof o=="object"&&typeof o.filePath=="string"&&r.push(o.filePath);return typeof n.filePath=="string"&&r.push(n.filePath),["read","write","edit"].includes(e)&&typeof n.path=="string"&&r.push(n.path),[...new Set(r)].filter(o=>o.length>0)}function vk(e,t){return e.length===0||t.length===0?!1:e.some(r=>t.some(n=>dp(r,n)))}var BL=/[*?]/,Fn=["todo","goal","context","task"];function Fk(e,t){if(!e||t.length===0)return!1;let r=new Set,n=[];for(let o of t)BL.test(o)?n.push(o):r.add(o);return r.has(e)?!0:n.some(o=>dp(e,o))}function hm(e,t,r,n,o){let i=[{tool:e,input:t}];if(e==="execute"&&Array.isArray(o?.toolCalls))for(let a of o.toolCalls)a&&typeof a=="object"&&typeof a.tool=="string"&&i.push({tool:a.tool,input:a.input});return i.some(a=>Fk(a.tool,r)||vk(xm(a.tool,a.input),n))}function gp(e,t){return t==null?e:`${e}::${JSON.stringify(lp(GL(t)))}`}function GL(e){if(typeof e!="object"||e===null||Array.isArray(e))return e;let t={};for(let[r,n]of Object.entries(e))n!=null&&(t[r]=n);return t}function lp(e){if(typeof e!="object"||e===null)return e;if(Array.isArray(e))return e.map(lp);let t={};for(let r of Object.keys(e).sort())t[r]=lp(e[r]);return t}var ko="[Output removed to save context - information superseded or no longer needed]",yp="[input removed due to failed tool call]",Dk="[questions removed - see output for user's answers]",jk=2e3,Im=["ask","question"],Lk=["read","grep","ls"],KL=["edit","write","multiedit","apply_patch","patch"];function HL(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function zL(e){if(!e)return{total:0,count:0};let t=0,r=0;for(let n of Object.values(e))typeof n=="string"&&(t+=n.length,r++);return{total:t,count:r}}function WL(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xp(e,t,r){let n=r?.bigOutputChars??jk,o=new Map,i=[];for(let h=0;h<e.length;h++){let $=e[h];if($.role==="assistant")for(let b of $.content)b.type==="toolCall"&&o.set(b.id,{name:b.name,args:b.arguments,callIndex:h});else if($.role==="toolResult"){let b=o.get($.toolCallId),w=$.toolName;i.push({index:h,callId:$.toolCallId,tool:w,isError:$.isError,text:HL($.content),paths:b?xm(w,b.args):[],signature:gp(w,b?.args),callIndex:b?.callIndex??-1})}}let a=t.planFile?rr(t.planFile):void 0,m=h=>h.index===0||Fn.includes(h.tool)||a!==void 0&&h.paths.some($=>rr($)===a),c=h=>h.callIndex<0||h.callIndex===0||Fn.includes(h.tool)||a!==void 0&&h.paths.some($=>rr($)===a),p=[],f=new Set,d=h=>{let $=`${h.kind}:${h.callId}`;f.has($)||(f.add($),p.push(h))},g=new Map;for(let h of i)if(!(h.isError||!Lk.includes(h.tool)&&!KL.includes(h.tool)))for(let $ of h.paths){let b=rr($),w=g.get(b);(w===void 0||h.index>w)&&g.set(b,h.index)}for(let h of i){if(h.isError||!Lk.includes(h.tool)||m(h)||h.text===ko)continue;h.paths.some(b=>(g.get(rr(b))??-1)>h.index)&&d({kind:"output",reason:"superseded-read",callId:h.callId,messageIndex:h.index,savedChars:Math.max(0,h.text.length-ko.length)})}let y=new Map;for(let h of i){if(h.isError)continue;let $=y.get(h.signature);($===void 0||h.index>$)&&y.set(h.signature,h.index)}for(let h of i){if(!h.isError||m(h))continue;let $=y.get(h.signature);if(!($===void 0||$<=h.index)&&(d({kind:"output",reason:"error-then-success",callId:h.callId,messageIndex:h.index,savedChars:Math.max(0,h.text.length-ko.length)}),!c(h))){let b=o.get(h.callId)?.args,{total:w,count:S}=zL(b);S>0&&d({kind:"failed-input",reason:"error-then-success",callId:h.callId,messageIndex:h.callIndex,savedChars:Math.max(0,w-S*yp.length)})}}if(t.files.length>0||t.identifiers.length>0){let h=[...t.files.map(rr),...a?[a]:[]],$=h.map(S=>S.split("/").pop()??"").filter(S=>S.length>0),b=t.identifiers.map(S=>new RegExp(`(?<![\\w.-])${WL(S)}(?![\\w.-])`)),w=S=>{let z=rr(S);return h.some(oe=>z.includes(oe))||$.some(oe=>S.includes(oe))?!0:b.some(oe=>oe.test(S))};for(let S of i)m(S)||Im.includes(S.tool)||S.text.length<=n||w(S.text)||d({kind:"output",reason:"unrelated-big-output",callId:S.callId,messageIndex:S.index,savedChars:Math.max(0,S.text.length-ko.length)})}let I=0;for(let h of p)I+=h.savedChars;return{ops:p,savedChars:I}}function hp(e,t){let r=new Set,n=new Set,o=new Set;for(let i of t)i.kind==="output"?r.add(i.callId):i.kind==="question-input"?n.add(i.callId):o.add(i.callId);return _k(qk(Nk(e,r),n),o)}function Nk(e,t){return t.size===0?[...e]:e.map((r,n)=>n===0||r.role!=="toolResult"||!t.has(r.toolCallId)||Im.includes(r.toolName)?r:{...r,content:[{type:"text",text:ko}]})}function qk(e,t){if(t.size===0)return[...e];let r=new Set;for(let n of e)n.role==="toolResult"&&!n.isError&&t.has(n.toolCallId)&&r.add(n.toolCallId);return r.size===0?[...e]:e.map((n,o)=>{if(o===0||n.role!=="assistant")return n;let i=!1,a=n.content.map(m=>{if(m.type!=="toolCall"||!r.has(m.id)||!Im.includes(m.name))return m;let c={...m.arguments},p=!1;for(let f of["question","questions","options"])f in c&&(c[f]=Dk,p=!0);return p?(i=!0,{...m,arguments:c}):m});return i?{...n,content:a}:n})}function _k(e,t){if(t.size===0)return[...e];let r=new Set;for(let n of e)n.role==="toolResult"&&n.isError&&t.has(n.toolCallId)&&r.add(n.toolCallId);return r.size===0?[...e]:e.map((n,o)=>{if(o===0||n.role!=="assistant")return n;let i=!1,a=n.content.map(m=>{if(m.type!=="toolCall"||!r.has(m.id))return m;let c={},p=!1;for(let[f,d]of Object.entries(m.arguments))typeof d=="string"?(c[f]=yp,p=!0):c[f]=d;return p?(i=!0,{...m,arguments:c}):m});return i?{...n,content:a}:n})}function Ip(e,t,r){if(t.length===0)return[...e];let n=Br(r,e),o=new Map;for(let d=0;d<n.length;d++){let g=n[d];g!==null&&o.set(g,d)}let i=new Set,a=new Map;for(let d of t){let g=[];for(let I of d.coveredIndices){let h=o.get(I);h!==void 0&&(i.add(h),g.push(h))}let y=o.get(d.anchorIndex)??(g.length>0?Math.min(...g):void 0);if(d.summary&&y!==void 0){let I=a.get(y);I?I.push(d.summary):a.set(y,[d.summary])}}let m=new Map,c=new Map;for(let d=0;d<e.length;d++){let g=e[d];if(g)if(g.role==="assistant"&&Array.isArray(g.content))for(let y of g.content)y.type==="toolCall"&&m.set(d,y.id);else g.role==="toolResult"&&c.set(g.toolCallId,d)}let p=[...i];for(;p.length>0;){let d=p.pop(),g=m.get(d);if(g!==void 0){let I=c.get(g);I!==void 0&&!i.has(I)&&(i.add(I),p.push(I))}let y=e[d];if(y?.role==="toolResult")for(let[I,h]of m)h===y.toolCallId&&!i.has(I)&&(i.add(I),p.push(I))}let f=[];for(let d=0;d<e.length;d++){let g=a.get(d);if(g){let y=e[d];for(let I of g){let h={role:"user",content:I,timestamp:y.timestamp};f.push(h)}}i.has(d)||f.push(e[d])}return f}var bp={thresholdChars:8192,headChars:4096,tailChars:1024};function VL(e,t={}){let r=t.thresholdChars??bp.thresholdChars,n=t.headChars??bp.headChars,o=t.tailChars??bp.tailChars;if(e.length<=r||n+o>=e.length)return{text:e,prunedChars:0};let i=n,a=e.charCodeAt(i-1);a>=55296&&a<=56319&&(i-=1);let m=e.length-o,c=e.charCodeAt(m);c>=56320&&c<=57343&&(m+=1);let p=e.slice(0,i),f=e.slice(m),d=m-i,g=`
|
|
41
|
+
|
|
42
|
+
[... ${d} characters pruned from the middle ...]
|
|
43
|
+
|
|
44
|
+
`;return{text:p+g+f,prunedChars:d-g.length}}function Uk(e,t={}){let r=0,n=0,o=!1,i=e.map(a=>{let m=a;if(m.role!=="toolResult"||!Array.isArray(m.content))return a;let c=m.content,p=!1,f=c.map(d=>{if(!d||typeof d!="object")return d;let g=d;if(g.type!=="text"||typeof g.text!="string")return d;let y=VL(g.text,t);return y.prunedChars<=0?d:(p=!0,r+=y.prunedChars,{...d,text:y.text})});return p?(o=!0,n+=1,{...a,content:f}):a});return{messages:o?i:e,savedChars:r,prunedResults:n}}function $p(e="xml"){let t=e==="compact",r=t?"@4@":"mNNNN",n=t?"@b1@":"bN",o=t?"@b1@":"(bN)";return`COMPRESSING A RANGE OF THIS CONVERSATION
|
|
45
|
+
|
|
46
|
+
This is what the \`compress\` tool is for, and how a range must be summarised when it is used. Reach for it when the conversation has grown long enough that its older turns cost more than they are worth - never as a way to answer the user, and never on a range they did not ask about. Nothing here is a standing instruction to summarise: it is the contract the tool's output is held to.
|
|
47
|
+
|
|
48
|
+
THE SUMMARY
|
|
49
|
+
Your summary must be EXHAUSTIVE. Capture file paths, function signatures, decisions made, constraints discovered, key findings... EVERYTHING that maintains context integrity. This is not a brief note - it is an authoritative record so faithful that the original conversation adds no value.
|
|
50
|
+
|
|
51
|
+
USER INTENT FIDELITY
|
|
52
|
+
When the compressed range includes user messages, preserve the user's intent with extra care. Do not change scope, constraints, priorities, acceptance criteria, or requested outcomes.
|
|
53
|
+
Directly quote user messages when they are short enough to include safely. Direct quotes are preferred when they best preserve exact meaning.
|
|
54
|
+
|
|
55
|
+
Yet be LEAN. Strip away the noise: failed attempts that led nowhere, verbose tool outputs, back-and-forth exploration. What remains should be pure signal - golden nuggets of detail that preserve full understanding with zero ambiguity.
|
|
56
|
+
|
|
57
|
+
COMPRESSED BLOCK PLACEHOLDERS
|
|
58
|
+
When the selected range includes previously compressed blocks, use this exact placeholder format when referencing one:
|
|
59
|
+
|
|
60
|
+
- \`${o}\`
|
|
61
|
+
|
|
62
|
+
Compressed block sections in context are clearly marked with a header:
|
|
63
|
+
|
|
64
|
+
- \`[Compressed conversation section]\`
|
|
65
|
+
|
|
66
|
+
${t?"Compressed block IDs look like `@b1@`, distinct from raw message IDs like `@4@`.":"Compressed block IDs always use the `bN` form (never `mNNNN`) and are represented in the same XML metadata tag format."}
|
|
67
|
+
|
|
68
|
+
Rules:
|
|
69
|
+
|
|
70
|
+
- Include every required block placeholder exactly once.
|
|
71
|
+
- Do not invent placeholders for blocks outside the selected range.
|
|
72
|
+
- Treat \`${o}\` placeholders as RESERVED TOKENS. Do not emit \`${o}\` text anywhere except intentional placeholders.
|
|
73
|
+
- If you need to mention a block in prose, use plain text like \`compressed ${t?"block 1":"bN"}\` (not as a placeholder).
|
|
74
|
+
- Preflight check before finalizing: the set of \`${o}\` placeholders in your summary must exactly match the required set, with no duplicates.
|
|
75
|
+
|
|
76
|
+
These placeholders are semantic references. They will be replaced with the full stored compressed block content when the tool processes your output.
|
|
77
|
+
|
|
78
|
+
FLOW PRESERVATION WITH PLACEHOLDERS
|
|
79
|
+
When you use compressed block placeholders, write the surrounding summary text so it still reads correctly AFTER placeholder expansion.
|
|
80
|
+
|
|
81
|
+
- Treat each placeholder as a stand-in for a full conversation segment, not a short label.
|
|
82
|
+
- Ensure transitions before and after each placeholder preserve chronology and causality.
|
|
83
|
+
- Do not write text that depends on the placeholder staying literal (for example, "as noted in \`${t?"@b2@":"(b2)"}\`").
|
|
84
|
+
- Your final meaning must be coherent once each placeholder is replaced with its full compressed block content.
|
|
85
|
+
|
|
86
|
+
BOUNDARY IDS
|
|
87
|
+
You specify boundaries by ID using the injected IDs visible in the conversation:
|
|
88
|
+
|
|
89
|
+
- \`${r}\` IDs identify raw messages
|
|
90
|
+
- \`${n}\` IDs identify previously compressed blocks
|
|
91
|
+
|
|
92
|
+
${t?"Each message has an ID like `@4@`. Copy the whole marker, including both `@` characters, into `startId` and `endId`.":"Each message has an ID inside XML metadata tags like `<dcp-message-id>...</dcp-message-id>`."}
|
|
93
|
+
The same ID tag appears in every tool output of the message it belongs to \u2014 each unique ID identifies one complete message.
|
|
94
|
+
Treat these tags as boundary metadata only, not as tool result content.
|
|
95
|
+
|
|
96
|
+
Rules:
|
|
97
|
+
|
|
98
|
+
- Pick \`startId\` and \`endId\` directly from injected IDs in context.
|
|
99
|
+
- IDs must exist in the current visible context.
|
|
100
|
+
- \`startId\` must appear before \`endId\`.
|
|
101
|
+
- Do not invent IDs. Use only IDs that are present in context.
|
|
102
|
+
|
|
103
|
+
BATCHING
|
|
104
|
+
When multiple independent ranges are ready and their boundaries do not overlap, include all of them as separate entries in the \`content\` array of a single tool call. Each entry should have its own \`startId\`, \`endId\`, and \`summary\`.
|
|
105
|
+
`}function Ep(e,t,r,n){let o=new Map;if(t.idState){let m=Br(t.idState,t.messages);for(let c=0;c<m.length;c++){let p=m[c];p!==null&&o.set(p,c)}}let i=new Set;for(let m of Lr(r))if(!(n!==void 0&&m.blockId===n))for(let c of m.coveredIndices)i.add(c);let a=[];if(t.idState)for(let m of e.indices){if(i.has(m))continue;let c=o.get(m);c!==void 0&&a.push(c)}return a}function Bk(e){if(typeof e.content=="string")return e.content.trim()?[e.content]:[];let t=[];for(let r of e.content)r.type==="text"&&r.text.trim()&&t.push(r.text);return t}function Gk(e,t,r,n,o,i){if(!o)return e;let a=[];for(let p of Ep(t,r,n,i)){let f=r.messages[p];if(!f||f.role!=="user")continue;let d=Bk(f)[0];d!==void 0&&a.push(d)}if(a.length===0)return e;let m=`
|
|
106
|
+
|
|
107
|
+
The following user messages were sent in this conversation verbatim:`,c=a.map(p=>`
|
|
108
|
+
${p}`).join("");return e+m+c}function Kk(e,t,r,n,o,i){if(!o)return e;let a=[];for(let p of Ep(t,r,n,i)){let f=r.messages[p];if(!(!f||f.role!=="user"))for(let d of Bk(f))a.push(...Hk(d))}if(a.length===0)return e;let m=`
|
|
109
|
+
|
|
110
|
+
The following protected prompt information was included in this conversation verbatim:`,c=a.map(p=>`
|
|
111
|
+
${p}`).join("");return e+m+c}function Hk(e){let t=[],r=/<protect>([\s\S]*?)<\/protect>/gi;for(let n of e.matchAll(r)){let o=n[1]?.trim();o&&t.push(o)}return t}function zk(e,t,r,n,o=[],i=[],a){let m=new Map,c=[];for(let y of Ep(t,r,n,a)){let I=r.messages[y];if(I){if(I.role==="assistant"){for(let h of I.content)h.type==="toolCall"&&m.set(h.id,h.arguments);continue}if(I.role==="toolResult"){if(I.isError)continue;let h=I.content.filter($=>$.type==="text").map($=>$.text).join("");h.trim()&&c.push({toolCallId:I.toolCallId,toolName:I.toolName,text:h})}}}if(c.length===0)return e;let p=[...new Set([...Fn,...o])],f=[...i],d=[];for(let y of c){let I=m.get(y.toolCallId);hm(y.toolName,I,p,f)&&d.push(`
|
|
112
|
+
### Tool: ${y.toolName}
|
|
113
|
+
${y.text}`)}return d.length===0?e:e+`
|
|
114
|
+
|
|
115
|
+
The following protected tools were used in this conversation as well:`+d.join("")}function Wk(e,t,r){if(t.protectedEnriched)return;let n=t.coveredIndices;if(n.length>0){let o={startIdx:Math.min(...n),endIdx:Math.max(...n),indices:[...n],requiredBlockIds:[],tokenByIndex:new Map},i={messages:r,idState:e.messageIds},a=zk(Kk(Gk(t.summary,o,i,e,!0,t.blockId),o,i,e,!0,t.blockId),o,i,e,[],[],t.blockId);t.summary=a,t.summaryTokens=Fi(a)}t.protectedEnriched=!0}function Vk(e,t){let r=[];for(let n=0;n<e.length;n+=1){let o=e[n];if(o===null)continue;let i=t[n],a=i&&"content"in i?Eo(i.content):"";r.push({index:o,tokenCount:Math.round(a.length/4)})}return r}var JL="COMPRESSED BLOCK PLACEHOLDERS",Sp=new Map;function YL(e){return Sp.get(e)??[]}function QL(e){Sp.delete(e)}var Jk;function XL(){return Jk}function ZL(e={}){return t=>{t.on("context_with_system",async(r,n)=>{let o=n?.sessionManager?.getSessionId()??"dcp-sessionless",i=Li(o);if(i.enabled===!1)return;let a=r.messages,m=a[0];if(!m||m.role!=="system")return;Bm(i.messageIds,a);let c=Br(i.messageIds,a);Sp.set(o,Vk(c,a)),Jk=o;let p=eD(a),f=Ip(p,Lr(i),i.messageIds),d=Uk(f);d.prunedResults>0&&(f=[...d.messages]);let g=e.keepSet?.()??{files:[],identifiers:[]},y=xp(f,g);if(y.ops.length>0){f=hp(f,y.ops);for(let h of y.ops)i.prune.tools[h.callId]=(i.prune.tools[h.callId]??0)+h.savedChars;i.stats.totalPruneTokens=Object.values(i.prune.tools).reduce((h,$)=>h+$,0)}for(let h of i.prune.messages.blocks)h.active&&!h.protectedEnriched&&Wk(i,h,a);un(o);let I=f.map((h,$)=>{if($!==0||!("content"in h))return h;let b=Eo(h.content);return b.includes(JL)?h:{...h,content:lm(h.content,`${b}
|
|
116
|
+
|
|
117
|
+
${$p()}`)}});return{messages:rD(I,i.messageIds)}})}}function eD(e){return e.map(t=>{if(t.role!=="assistant"||!("content"in t))return t;let r=tD(t.content);return r===t.content?t:{...t,content:r}})}function tD(e){if(typeof e=="string")return Um(e);if(!Array.isArray(e))return e;let t=!1,r=e.map(n=>{if(!n||typeof n!="object"||!("type"in n)||n.type!=="text")return n;let o="text"in n&&typeof n.text=="string"?n.text:"",i=Um(o);return i===o?n:(t=!0,{...n,text:i})});return t?r:e}function rD(e,t){let r=Br(t,e);return e.map((n,o)=>{let i=r[o];if(i==null||!("content"in n))return n;let a=Mo(jn(i));return Eo(n.content).includes(a)?n:{...n,content:nD(n.content,a)}})}function nD(e,t){if(typeof e=="string")return e+t;if(!Array.isArray(e))return e;let r=!1,n=e.map(o=>{if(!o||typeof o!="object"||!("type"in o)||o.type!=="text")return o;r=!0;let i="text"in o&&typeof o.text=="string"?o.text:"";return{...o,text:i+t}});return r?n:[...n,{type:"text",text:t.trimStart()}]}var Yk={on:"turn the transform on for this session",off:"turn it off; the full transcript is sent unchanged",status:"the switch, the block count, and the tokens saved",blocks:"list the active compressed blocks",stats:"prune and compress totals for this session",context:"what the next request will carry, and what was saved",decompress:"reopen one block by id, e.g. /dcp decompress b2",sweep:"drop blocks no longer referenced by the ref state"};function kp(e){return e<1e3?`${e}`:`${(e/1e3).toFixed(1)}k`}function oD(e,t,r){let[n]=e.trim().split(/\s+/),o=n===void 0||n===""?"status":n,i=Li(r);switch(o){case"on":return i.enabled=!0,un(r),"dcp: on";case"off":return i.enabled=!1,un(r),"dcp: off; the full transcript is sent unchanged";case"blocks":{let a=Lr(i);return a.length===0?"dcp: no active blocks":a.map(m=>{let c=String(m.anchorIndex).padStart(4,"0");return`b${m.blockId} covers ${m.coveredIndices.length} message(s), anchored at m${c}`}).join(`
|
|
118
|
+
`)}case"status":{let a=fp({runtime:i.enabled,config:pp(t)}),m=Lr(i),c=Object.values(i.prune.tools).reduce((p,f)=>p+f,0);return[`dcp: ${a.enabled?"on":"off"} (source: ${a.source})`,`messages tracked: ${Object.keys(i.messageIds.keyToRef).length}`,`active blocks: ${m.length}`,`pruned tool calls: ${Object.keys(i.prune.tools).length} (${kp(c)} chars)`,`compressed tokens total: ${i.stats.totalCompressTokens}`].join(`
|
|
119
|
+
`)}case"stats":{let a=i.prune.messages.blocks,m=a.filter(p=>p.active).length,c=Object.values(i.prune.tools).reduce((p,f)=>p+f,0);return[`blocks: ${m} active of ${a.length} total`,`compressed tokens: ${i.stats.totalCompressTokens}`,`pruned tool calls: ${Object.keys(i.prune.tools).length} (${kp(c)} chars)`,`messages tracked: ${Object.keys(i.messageIds.keyToRef).length}`,`refs allocated: ${i.messageIds.nextRef-1}`].join(`
|
|
120
|
+
`)}case"context":{let a=Lr(i),m=new Set;for(let f of a)for(let d of f.coveredIndices)m.add(d);let c=Object.keys(i.messageIds.keyToRef).length,p=Object.values(i.prune.tools).reduce((f,d)=>f+d,0);return[`messages tracked: ${c}`,`messages replaced by a block: ${m.size}`,`messages sent: ${Math.max(0,c-m.size)}`,`active blocks: ${a.length}`,`compressed tokens total: ${i.stats.totalCompressTokens}`,`pruned tool calls: ${Object.keys(i.prune.tools).length} (${kp(p)} chars)`].join(`
|
|
121
|
+
`)}case"decompress":{let a=e.trim().split(/\s+/)[1],m=a===void 0?null:/^b?(\d+)$/i.exec(a);if(!m)return"dcp: give a block id, e.g. /dcp decompress b2";let c=Number(m[1]),p=i.prune.messages.blocks,f=p.find(g=>g.blockId===c);if(!f)return`dcp: no block b${c}`;let d=p.filter(g=>g.active&&g.consumedBlockIds.includes(c));if(d.length>0){let g=d.map(y=>`b${y.blockId}`).join(", ");return`dcp: b${c} was consumed by ${g}; decompress that one first`}if(!f.active)return`dcp: b${c} is already open`;f.active=!1,f.deactivatedByUser=!0,f.deactivatedAt=Date.now();for(let g of f.parentBlockIds){let y=p.find(I=>I.blockId===g);y&&(y.consumedBlockIds=y.consumedBlockIds.filter(I=>I!==c))}return un(r),`dcp: b${c} reopened; ${f.coveredIndices.length} message(s) are back`}case"sweep":{let a=new Set(Object.keys(i.messageIds.refToKey).map(Number)),m=i.prune.messages.blocks,c=m.length,p=m.filter(d=>d.active&&!d.coveredIndices.some(g=>a.has(g)));for(let d of p)d.active=!1,d.deactivatedAt=Date.now();i.prune.messages.blocks=m.filter(d=>d.active||d.deactivatedByUser);let f=c-i.prune.messages.blocks.length;return un(r),p.length===0?"dcp: nothing to sweep":`dcp: ${p.length} orphaned block(s) closed, ${f} dropped from state`}default:return`dcp: unknown subcommand '${o}'. try: ${Object.keys(Yk).join(", ")}`}}import{Type as $m}from"@netrodev/hxf-ai";import{defineTool as nT}from"@netrodev/hxf-coding-agent";import{promises as iD}from"node:dns";var sD=/^(127\.|10\.|192\.168\.|169\.254\.|0\.)/;function Tp(e){if(sD.test(e))return!0;let t=/^172\.(\d+)\./.exec(e);if(!t)return!1;let r=Number(t[1]);return r>=16&&r<=31}function wp(e){let t=/^100\.(\d+)\.(\d+)\.(\d+)$/.exec(e);if(t){let n=Number(t[1]);return n>=64&&n<=127}let r=/^198\.(\d+)\./.exec(e);return r!==null&&(Number(r[1])===18||Number(r[1])===19)}function Xk(e){let t=e.toLowerCase().replace(/^\[|\]$/g,"").split("%")[0];if(t==="localhost"||t.endsWith(".localhost"))return!0;let r=/^::ffff:(\d+\.\d+\.\d+\.\d+)$/.exec(t);if(r){let o=r[1];return Tp(o)||wp(o)||o==="0.0.0.0"}let n=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/.exec(t);if(n){let o=Number.parseInt(n[1],16),i=Number.parseInt(n[2],16),a=`${o>>8&255}.${o&255}.${i>>8&255}.${i&255}`;return Tp(a)||wp(a)||a==="0.0.0.0"}return t.includes(":")?!!(t==="::1"||t==="::"||/^f[cd][0-9a-f]{2}:/.test(t)||/^fe[89ab][0-9a-f]:/.test(t)):t==="0.0.0.0"?!0:Tp(t)||wp(t)}var Cp=8e4,Rp=8;function bm(e){let t;try{t=new URL(e)}catch{return{ok:!1,reason:"not a URL"}}if(t.protocol!=="http:"&&t.protocol!=="https:")return{ok:!1,reason:`refused protocol ${t.protocol}`};let r=t.hostname.toLowerCase();return r==="localhost"||r.endsWith(".localhost")||r==="::1"||r==="[::1]"?{ok:!1,reason:"refused loopback host"}:Xk(r)?{ok:!1,reason:"refused private address"}:{ok:!0,url:t}}function Zk(e){let t=e.replace(/<script[\s\S]*?<\/script>/gi," ").replace(/<style[\s\S]*?<\/style>/gi," ").replace(/<noscript[\s\S]*?<\/noscript>/gi," ").replace(/<[^>]+>/g," ").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/\s+/g," ").trim();return t.length>Cp?t.slice(0,Cp):t}function aD(e){let t=[],r=/class="result__a"[^>]*href="([^"]+)"[^>]*>([\s\S]*?)<\/a>/gi,n;for(;(n=r.exec(e))&&t.length<Rp;){let o=n[1]??"",i=Zk(n[2]??""),a=o,m=/[?&]uddg=([^&]+)/.exec(o);if(m)try{a=decodeURIComponent(m[1])}catch{a=o}else o.startsWith("//")&&(a=`https:${o}`);let c=bm(a);!c.ok||!i||t.push({title:i,url:c.url.toString(),snippet:""})}return t}var eT="HowToCode (https://howtofix.id)";async function tT(e,t={}){let r=e.trim();if(!r)return{ok:!1,error:"empty query"};let n=t.fetchFn??fetch,o=t.timeoutMs??15e3,i={"user-agent":t.userAgent??eT,accept:"text/html, application/json"};try{if(t.braveKey){let p=`https://api.search.brave.com/res/v1/web/search?q=${encodeURIComponent(r)}&count=${Rp}`,f=await n(p,{headers:{...i,accept:"application/json","x-subscription-token":t.braveKey},signal:AbortSignal.timeout(o)});return f.ok?{ok:!0,hits:mD(await f.json()),provider:"brave"}:{ok:!1,error:`brave ${f.status}`}}let a=`https://html.duckduckgo.com/html/?q=${encodeURIComponent(r)}`,m=await n(a,{headers:i,signal:AbortSignal.timeout(o)});return m.ok?{ok:!0,hits:aD(await m.text()),provider:"ddg"}:{ok:!1,error:`search ${m.status}`}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}function mD(e){let t=[];if(e&&typeof e=="object"&&"web"in e){let n=e.web;n&&typeof n=="object"&&"results"in n&&Array.isArray(n.results)&&(t=n.results)}let r=[];for(let n of t){if(!n||typeof n!="object"||!("url"in n)||!("title"in n))continue;let o=n.url,i=n.title;if(typeof o!="string"||typeof i!="string")continue;let a=bm(o);if(!a.ok)continue;let m="description"in n?n.description:void 0;if(r.push({title:i,url:a.url.toString(),snippet:typeof m=="string"?m:""}),r.length>=Rp)break}return r}var Qk=5,uD=new Set([301,302,303,307,308]);async function cD(e,t){let r=e.toLowerCase().replace(/^\[|\]$/g,"");if(r.includes(":")||/^[\d.]+$/.test(r))return{ok:!0,addresses:[r]};let n;try{n=await t(r)}catch(i){return{ok:!1,error:`could not resolve ${e}: ${i instanceof Error?i.message:String(i)}`}}if(n.length===0)return{ok:!1,error:`could not resolve ${e}`};let o=n.find(i=>Xk(i));return o!==void 0?{ok:!1,error:`refused ${e}: resolves to private address ${o}`}:{ok:!0,addresses:n}}async function rT(e,t={}){let r=bm(e);if(!r.ok)return{ok:!1,error:r.reason};let n=t.fetchFn??fetch,o=t.lookup??(c=>iD.lookup(c,{all:!0}).then(p=>p.map(f=>f.address))),i=AbortSignal.timeout(t.timeoutMs??2e4),a={"user-agent":t.userAgent??eT,accept:"text/html, text/plain, application/json"},m;try{let{Agent:c}=await import("undici"),p=[],f=((g,y,I)=>{let h=p.map($=>({address:$,family:$.includes(":")?6:4}));y?.all?I(null,h):I(null,h[0].address,h[0].family)});m=new c({connect:{lookup:f}});let d=r.url;for(let g=0;g<=Qk;g++){let y=bm(d.toString());if(!y.ok)return{ok:!1,error:`redirect refused: ${y.reason}`};let I=await cD(y.url.hostname,o);if(!I.ok)return{ok:!1,error:I.error};p=I.addresses;let h=await n(y.url,{headers:a,signal:i,redirect:"manual",dispatcher:m});if(uD.has(h.status)){let S=h.headers.get("location");if(!S)return{ok:!1,error:`HTTP ${h.status} without a location`};try{d=new URL(S,y.url)}catch{return{ok:!1,error:"redirect location is not a URL"}}continue}if(!h.ok)return{ok:!1,error:`HTTP ${h.status}`};let $=h.headers.get("content-type")??"",b=await h.text(),w=/html/i.test($)?Zk(b):b.slice(0,Cp);return{ok:!0,url:d.toString(),contentType:$,text:w}}return{ok:!1,error:`too many redirects (max ${Qk})`}}catch(c){return{ok:!1,error:c instanceof Error?c.message:String(c)}}finally{await m?.close()}}function pD(e){return e.length===0?"no results":e.map((t,r)=>`${r+1}. ${t.title}
|
|
122
|
+
${t.url}${t.snippet?`
|
|
123
|
+
${t.snippet}`:""}`).join(`
|
|
124
|
+
`)}var oT=nT({name:"web_search",label:"web_search",description:"Search the public web. Use for current docs, changelogs, error messages, and anything not in this repo. Returns titles, URLs, and snippets. Follow a URL with web_fetch.",promptSnippet:"web_search: search the public web",parameters:$m.Object({query:$m.String({description:"Search query"})}),async execute(e,t){let r=await tT(t.query,{braveKey:process.env.BRAVE_API_KEY});return r.ok?{content:[{type:"text",text:pD(r.hits)}],details:{count:r.hits.length,provider:r.provider}}:{content:[{type:"text",text:r.error}],details:{error:r.error},isError:!0}}}),iT=nT({name:"web_fetch",label:"web_fetch",description:"Fetch a public http(s) URL and return its text. HTML is stripped to visible text. Local, loopback, and private addresses are refused.",promptSnippet:"web_fetch: read a public URL as text",parameters:$m.Object({url:$m.String({description:"http(s) URL"})}),async execute(e,t){let r=await rT(t.url);return r.ok?{content:[{type:"text",text:r.text}],details:{url:r.url,contentType:r.contentType,chars:r.text.length}}:{content:[{type:"text",text:r.error}],details:{error:r.error},isError:!0}}});import{spawn as fD}from"node:child_process";import{existsSync as Em,readFileSync as mT}from"node:fs";import{delimiter as uT,isAbsolute as cT,join as Sm}from"node:path";import{fileURLToPath as dD,pathToFileURL as Dr}from"node:url";function sT(e){let t=JSON.stringify(e);return`Content-Length: ${Buffer.byteLength(t,"utf8")}\r
|
|
125
|
+
\r
|
|
126
|
+
${t}`}var lD=32*1024*1024;function gD(e){let t=[],r=0;for(;r<e.length;){let n=e.indexOf(`\r
|
|
127
|
+
\r
|
|
128
|
+
`,r);if(n===-1)break;let o=e.subarray(r,n).toString("utf8"),i=/Content-Length:\s*(\d+)/i.exec(o);if(!i)break;let a=Number(i[1]);if(!Number.isSafeInteger(a)||a<0||a>lD)throw new Error(`lsp frame of ${i[1]} bytes refused`);let m=n+4,c=m+a;if(c>e.length)break;let p=e.subarray(m,c).toString("utf8");try{let f=JSON.parse(p);f&&typeof f=="object"&&t.push(f)}catch{}r=c}return{messages:t,rest:e.subarray(r)}}var Pp=class{constructor(t){this.io=t;t.stdout.on("data",r=>{if(this.broken)return;this.buffer=Buffer.concat([this.buffer,r]);let n;try{n=gD(this.buffer)}catch(o){this.buffer=Buffer.alloc(0),this.fail(o instanceof Error?o:new Error(String(o)));return}this.buffer=n.rest;for(let o of n.messages)this.dispatch(o)}),t.stdin.on("error",r=>{this.fail(r instanceof Error?r:new Error(String(r)))})}io;nextId=1;pending=new Map;buffer=Buffer.alloc(0);broken=null;opened=new Set;versions=new Map;diagnosticsByUri=new Map;diagnosticsWaiters=new Map;fail(t){if(!this.broken){this.broken=t;for(let[r,n]of this.pending)this.pending.delete(r),n.reject(t)}}dispatch(t){if(t.method==="textDocument/publishDiagnostics"){let n=t.params;if(n?.uri){let o=Array.isArray(n.diagnostics)?n.diagnostics:[];this.diagnosticsByUri.set(n.uri,o);let i=this.diagnosticsWaiters.get(n.uri);if(i){this.diagnosticsWaiters.delete(n.uri);for(let a of i)a(o)}}return}if(t.id===void 0)return;let r=this.pending.get(Number(t.id));r&&(this.pending.delete(Number(t.id)),t.error?r.reject(new Error(t.error.message)):r.resolve(t.result))}request(t,r,n=1e4){if(this.broken)return Promise.reject(this.broken);let o=this.nextId++,i=sT({jsonrpc:"2.0",id:o,method:t,params:r}),{promise:a,resolve:m,reject:c}=Promise.withResolvers(),p=setTimeout(()=>{this.pending.delete(o),c(new Error(`lsp ${t} timed out`))},n);this.pending.set(o,{resolve:f=>{clearTimeout(p),m(f)},reject:f=>{clearTimeout(p),c(f)}});try{this.io.stdin.write(i)}catch(f){let d=f instanceof Error?f:new Error(String(f));this.pending.delete(o),clearTimeout(p),c(d),this.fail(d)}return a}notify(t,r){if(!this.broken)try{this.io.stdin.write(sT({jsonrpc:"2.0",method:t,params:r}))}catch(n){this.fail(n instanceof Error?n:new Error(String(n)))}}async initialize(){await this.request("initialize",{processId:null,rootUri:Dr(this.io.root).toString(),capabilities:{textDocument:{hover:{},definition:{},references:{},documentSymbol:{},publishDiagnostics:{}}}}),this.notify("initialized",{})}async hover(t,r,n){return(await this.request("textDocument/hover",{textDocument:{uri:Dr(t).toString()},position:{line:r,character:n}}))?.contents?.value}async definition(t,r,n){let o=await this.request("textDocument/definition",{textDocument:{uri:Dr(t).toString()},position:{line:r,character:n}});return Array.isArray(o)?o[0]:o??void 0}async references(t,r,n){let o=await this.request("textDocument/references",{textDocument:{uri:Dr(t).toString()},position:{line:r,character:n},context:{includeDeclaration:!0}});return Array.isArray(o)?o:[]}async documentSymbols(t){let r=await this.request("textDocument/documentSymbol",{textDocument:{uri:Dr(t).toString()}});return Array.isArray(r)?r:[]}diagnostics(t,r=2e3){let n=Dr(t).toString(),o=this.diagnosticsByUri.get(n);if(o)return Promise.resolve(o);let{promise:i,resolve:a}=Promise.withResolvers(),m=setTimeout(()=>{let p=this.diagnosticsWaiters.get(n);if(p){this.diagnosticsWaiters.delete(n);for(let f of p)f(this.diagnosticsByUri.get(n)??[])}},r),c=this.diagnosticsWaiters.get(n)??[];return c.push(p=>{clearTimeout(m),a(p)}),this.diagnosticsWaiters.set(n,c),i}async ensureOpen(t,r,n){let o=Dr(t).toString();this.opened.has(o)||(this.versions.set(o,1),this.notify("textDocument/didOpen",{textDocument:{uri:o,languageId:n,version:1,text:r}}),this.opened.add(o))}isOpen(t){return this.opened.has(Dr(t).toString())}notifyChange(t,r,n){let o=Dr(t).toString();if(!this.opened.has(o)){this.versions.set(o,1),this.opened.add(o),this.notify("textDocument/didOpen",{textDocument:{uri:o,languageId:n,version:1,text:r}});return}let i=(this.versions.get(o)??1)+1;this.versions.set(o,i),this.diagnosticsByUri.delete(o),this.notify("textDocument/didChange",{textDocument:{uri:o,version:i},contentChanges:[{text:r}]})}dispose(){for(let[t,r]of this.pending)r.reject(new Error("lsp client disposed")),this.pending.delete(t);for(let[t,r]of this.diagnosticsWaiters){let n=this.diagnosticsByUri.get(t)??[];this.diagnosticsWaiters.delete(t);for(let o of r)o(n)}}},yD=[{command:"typescript-language-server",args:["--stdio"],languageId:"typescript",match:e=>/\.(ts|tsx|js|jsx|mts|cts)$/.test(e)},{command:"rust-analyzer",args:[],languageId:"rust",match:e=>e.endsWith(".rs")},{command:"gopls",args:[],languageId:"go",match:e=>e.endsWith(".go")},{command:"pylsp",args:[],languageId:"python",match:e=>e.endsWith(".py")}];function pT(e){return yD.find(t=>t.match(e))}var jr=new Map;async function fT(e,t){let r=jr.get(e.command);if(r)return await r.ready,r.client;let n=fD(e.command,e.args,{cwd:t,stdio:["pipe","pipe","ignore"]}),o=n.stdin,i=n.stdout;if(!o||!i)throw n.kill(),new Error(`${e.command}: stdio pipes unavailable`);let a=new Pp({stdin:o,stdout:i,root:t});n.on("error",()=>{let c=jr.get(e.command);c?.child===n&&jr.delete(e.command),c?.client.dispose()}),n.on("exit",()=>{jr.get(e.command)?.child===n&&jr.delete(e.command),a.dispose()});let m=a.initialize().catch(c=>{throw jr.delete(e.command),n.kill(),c});return jr.set(e.command,{client:a,child:n,ready:m}),await m,a}function xD(){for(let[e,t]of jr)jr.delete(e),t.client.dispose(),t.child.kill()}process.on("exit",xD);async function Fve(e,t,r={}){let n=pT(e);if(!n)return{diagnostics:[],unavailable:"no language server configured for this file type"};if(!(n.command.includes("/")?Em(n.command):(process.env.PATH??"").split(uT).some(i=>Em(Sm(i,n.command)))))return{diagnostics:[],unavailable:`${n.command} is not on PATH`};try{let i=cT(e)?e:Sm(t,e),a=await fT(n,t);return a.notifyChange(i,mT(i,"utf8"),n.languageId),{diagnostics:(await a.diagnostics(i,r.waitMs??1500)).map(c=>`${c.range.start.line+1}:${c.range.start.character+1} ${dT[c.severity??3]??"info"} ${c.message}`)}}catch(i){return{diagnostics:[],unavailable:i instanceof Error?i.message:String(i)}}}var dT={1:"error",2:"warning",3:"info",4:"hint"};function aT(e){let t=e.uri;try{t=dD(e.uri)}catch{}let r=e.range?.start;return r?`${t}:${r.line+1}:${r.character+1}`:t}function lT(e,t=0){let r=[];for(let n of e){let o=(n.selectionRange??n.range)?.start.line;r.push(`${" ".repeat(t)}${n.name}${o===void 0?"":` :${o+1}`}`),n.children&&r.push(...lT(n.children,t+1))}return r}async function gT(e){try{let t=pT(e.file);if(!t)return{ok:!1,error:`no language server configured for ${e.file}`};if((e.action==="definition"||e.action==="references"||e.action==="hover")&&(e.line===void 0||!Number.isInteger(e.line)||e.line<1))return{ok:!1,error:`line required (1-based) for ${e.action}`};if(!(t.command.includes("/")?Em(t.command):(process.env.PATH??"").split(uT).some(p=>Em(Sm(p,t.command)))))return{ok:!1,error:`${t.command} is not on PATH. Install it to use lsp on ${e.file}.`};let o=cT(e.file)?e.file:Sm(e.root,e.file),i=mT(o,"utf8"),a=await fT(t,e.root);await a.ensureOpen(o,i,t.languageId);let m=(e.line??1)-1,c=0;if(e.symbol){let p=(i.split(`
|
|
129
|
+
`)[m]??"").indexOf(e.symbol);p>=0&&(c=p)}switch(e.action){case"definition":{let p=await a.definition(o,m,c);return p?{ok:!0,text:aT(p),count:1}:{ok:!0,text:"no definition found",count:0}}case"references":{let f=(await a.references(o,m,c)).map(aT);return{ok:!0,text:f.length>0?f.join(`
|
|
130
|
+
`):"no references found",count:f.length}}case"hover":{let p=(await a.hover(o,m,c))?.trim();return{ok:!0,text:p||"no hover at that position"}}case"symbols":{let p=lT(await a.documentSymbols(o));return{ok:!0,text:p.length>0?p.join(`
|
|
131
|
+
`):"no symbols in this file",count:p.length}}case"diagnostics":{let f=(await a.diagnostics(o)).map(d=>`${d.range.start.line+1}:${d.range.start.character+1} ${dT[d.severity??3]??"info"} ${d.message}`);return{ok:!0,text:f.length>0?f.join(`
|
|
132
|
+
`):"no diagnostics",count:f.length}}}}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}}import{StringEnum as hD}from"@netrodev/hxf-ai";import{defineTool as ID}from"@netrodev/hxf-coding-agent";var yT=ID({name:"lsp",label:"lsp",description:"Language-server query: definition, references, hover, symbols, or diagnostics for a file. Line is 1-based. Does not edit. If the server binary is missing the result says so; do not pretend grep is a substitute without telling the user.",promptSnippet:"lsp: definition, references, hover, symbols, diagnostics",parameters:v.Object({action:hD(["diagnostics","definition","references","hover","symbols"],{description:"Which language-server query to run"}),file:v.String({description:"File to query, relative to the project root"}),line:v.Optional(v.Number({description:"1-based line (definition, references, hover)"})),symbol:v.Optional(v.String({description:"Substring to locate on that line when column is omitted"}))}),async execute(e,t,r,n,o){let i=await gT({action:t.action,file:t.file,line:t.line,symbol:t.symbol,root:o.cwd});return i.ok?{content:[{type:"text",text:i.text}],details:{action:t.action,count:i.count}}:{content:[{type:"text",text:i.error}],details:{error:i.error},isError:!0}}});import{defineTool as YD}from"@netrodev/hxf-coding-agent";import{API as bD}from"typescript/unstable/async";import{SyntaxKind as Nt,visitEachChild as xT}from"typescript/unstable/ast";var hT=new Set([Nt.FunctionDeclaration,Nt.FunctionExpression,Nt.ArrowFunction,Nt.MethodDeclaration,Nt.Constructor,Nt.GetAccessor,Nt.SetAccessor]);function wo(e){return hT.has(e)}var $D=new Set([Nt.AmpersandAmpersandToken,Nt.BarBarToken,Nt.QuestionQuestionToken]);function km(e){if(e.kind!==Nt.BinaryExpression)return!1;let t=Ve(e,"operatorToken");return t!==void 0&&$D.has(t.kind)}function Ve(e,t){let r=e[t];if(r&&typeof r=="object"&&typeof r.kind=="number")return r}function Di(e,t){let r=e[t];return Array.isArray(r)?r:[]}function IT(e,t){return Di(e,"modifiers").some(r=>r.kind===t)}function To(e){if(!e)return;let t=e.text;return typeof t=="string"?t:void 0}function ED(e,t){return e.getLineAndCharacterOfPosition(t).line+1}function Ap(e,t){let r=e.getLineAndCharacterOfPosition(t.getStart(e)),n=e.getLineAndCharacterOfPosition(t.end);return{startLine:r.line+1,startColumn:r.character+1,endLine:n.line+1,endColumn:n.character+1}}function Tm(e,t){t(e),xT(e,r=>(Tm(r,t),r))}function ji(e,t){t(e),xT(e,r=>(wo(r.kind)||ji(r,t),r))}var SD=hT;function kD(e){let t=To(Ve(e,"name"));if(t)return t;let r=Ve(e,"parent");for(;r&&!SD.has(r.kind);){if(r.kind===Nt.VariableDeclaration||r.kind===Nt.PropertyAssignment){let n=To(Ve(r,"name"));if(n)return n}r=Ve(r,"parent")}return"<anonymous>"}function TD(e){let t=[];return Tm(e,r=>{if(!wo(r.kind))return;let n=Ap(e,r);t.push({name:kD(r),node:r,startLine:n.startLine,endLine:n.endLine})}),t}async function bT(e){let t=new Map;if(e.length===0)return t;let r=new bD({cwd:process.cwd()});try{let n=await r.updateSnapshot({openFiles:[...e]});for(let o of e)try{let i=await n.getDefaultProjectForFile(o);if(!i){t.set(o,{ok:!1,error:"no TypeScript project contains this file"});continue}let a=await i.program.getSourceFile(o);if(!a){t.set(o,{ok:!1,error:"the compiler could not read this file"});continue}let m=await i.program.getSyntacticDiagnostics(o);if(m.length>0){let c=m[0],p=ED(a,c.pos);t.set(o,{ok:!1,error:`line ${p}: ${c.text} (TS${c.code})`});continue}t.set(o,{ok:!0,sourceFile:a,functions:TD(a)})}catch(i){t.set(o,{ok:!1,error:i instanceof Error?i.message:String(i)})}}finally{await r.close()}return t}import{SyntaxKind as Tr,visitEachChild as $T}from"typescript/unstable/ast";var wD=new Set([Tr.IfStatement,Tr.SwitchStatement,Tr.ForStatement,Tr.ForInStatement,Tr.ForOfStatement,Tr.WhileStatement,Tr.DoStatement,Tr.CatchClause]);function ET(e){let t=0,r=(o,i)=>{if(!wo(o.kind)){if(o.kind===Tr.IfStatement){n(o,i,!1);return}if(wD.has(o.kind)){t+=1+i,$T(o,a=>(r(a,i+1),a));return}km(o)&&(t+=1),$T(o,a=>(r(a,i),a))}},n=(o,i,a)=>{a||(t+=1+i);let m=Ve(o,"expression");m&&r(m,i);let c=Ve(o,"thenStatement");c&&r(c,i+1);let p=Ve(o,"alternate");p&&(t+=1,p.kind===Tr.IfStatement?n(p,i,!0):r(p,i+1))};return r(e,0),t}import{SyntaxKind as Nr}from"typescript/unstable/ast";var CD=new Set([Nr.IfStatement,Nr.ConditionalExpression,Nr.WhileStatement,Nr.DoStatement,Nr.ForStatement,Nr.ForInStatement,Nr.ForOfStatement,Nr.CatchClause,Nr.CaseClause]);function ST(e){let t=1;return ji(e,r=>{(CD.has(r.kind)||km(r))&&(t+=1)}),t}import{SyntaxKind as se}from"typescript/unstable/ast";var RD=new Set([se.BinaryExpression,se.PrefixUnaryExpression,se.PostfixUnaryExpression,se.ConditionalExpression,se.CallExpression,se.NewExpression,se.PropertyAccessExpression,se.ElementAccessExpression,se.AwaitExpression,se.YieldExpression,se.SpreadElement,se.IfStatement,se.WhileStatement,se.DoStatement,se.ForStatement,se.ForInStatement,se.ForOfStatement,se.SwitchStatement,se.ReturnStatement,se.ThrowStatement,se.TryStatement,se.BreakStatement,se.ContinueStatement]),PD=new Set([se.StringLiteral,se.NumericLiteral,se.BigIntLiteral,se.RegularExpressionLiteral,se.NoSubstitutionTemplateLiteral]);function Op(e,t){e.set(t,(e.get(t)??0)+1)}function kT(e){let t=new Map,r=new Map;ji(e,i=>{if(RD.has(i.kind)){let m=Ve(i,"operatorToken");Op(t,se[i.kind]+(m?`:${se[m.kind]}`:""));return}let a=To(i);a!==void 0&&(i.kind===se.Identifier||i.kind===se.PrivateIdentifier?Op(r,`id:${a}`):PD.has(i.kind)&&Op(r,`lit:${a}`))});let n=t.size+r.size;if(n===0)return 0;let o=0;for(let i of t.values())o+=i;for(let i of r.values())o+=i;return Math.round(o*Math.log2(n)*100)/100}function TT(e){return e.endLine-e.startLine+1}function wT(e,t,r){let n=171-5.2*Math.log(Math.max(e,1))-.23*t-16.2*Math.log(Math.max(r,1));return Math.round(Math.max(0,n*100/171)*10)/10}import{SyntaxKind as nr,visitEachChild as AD}from"typescript/unstable/ast";var OD=new Set([nr.IfStatement,nr.SwitchStatement,nr.WhileStatement,nr.DoStatement,nr.ForStatement,nr.ForInStatement,nr.ForOfStatement,nr.TryStatement,nr.CatchClause]);function CT(e){let t=0,r=(n,o)=>{if(wo(n.kind))return;let i=o;if(OD.has(n.kind)&&(i=o+1,i>t&&(t=i)),n.kind===nr.IfStatement){let a=Ve(n,"expression");a&&r(a,i);let m=Ve(n,"thenStatement");m&&r(m,i);let c=Ve(n,"alternate");c&&r(c,c.kind===nr.IfStatement?o:i);return}AD(n,a=>(r(a,i),a))};return r(e,0),t}import{spawnSync as MD}from"node:child_process";import{mkdirSync as aFe,readdirSync as vD,readFileSync as FD,statSync as LD,writeFileSync as mFe}from"node:fs";import{extname as Fp,join as FT,relative as LT,resolve as DD}from"node:path";import{SyntaxKind as wm}from"typescript/unstable/ast";var RT={"god-function":"split it into smaller functions, one job each",incomprehensible:"extract helpers and simplify the flow before touching it",bloated:"long but linear; extract helpers","deeply-tangled":"nesting, not branching; flatten with early returns",fragile:"many branches; add guard clauses and tests around it"};function PT(e,t){let r=[];return t.cyclomatic>=1&&t.length>=1&&t.nesting>=1&&r.push({id:"god-function",label:"God Function",reason:`high cyclomatic complexity (${e.cyclomatic}), long body (${e.length} lines), and deep nesting (${e.nesting}) \u2014 likely doing too many things`}),t.cognitive>=1&&t.halstead>=1&&t.mi>=1&&r.push({id:"incomprehensible",label:"Incomprehensible",reason:`high cognitive complexity (${e.cognitive}) and Halstead volume (${e.halstead}) with MI ${e.mi} \u2014 very hard to understand`}),t.length>=1&&t.halstead>=1&&t.cyclomatic===0&&r.push({id:"bloated",label:"Bloated",reason:`large function (${e.length} lines) with high vocabulary (Halstead ${e.halstead}) but low branching \u2014 consider extracting helpers`}),t.nesting>=1&&t.cognitive>=1&&t.cyclomatic===0&&r.push({id:"deeply-tangled",label:"Deeply Tangled",reason:`nesting depth ${e.nesting} drives cognitive complexity ${e.cognitive} \u2014 flatten with early returns or extracted helpers`}),t.cyclomatic>=1&&t.mi>=1&&t.length===0&&r.push({id:"fragile",label:"Fragile",reason:`high cyclomatic complexity (${e.cyclomatic}) with MI ${e.mi} \u2014 many branches, hard to change safely`}),r}var jD=["ok","warn","error"],Np=["cyclomatic","cognitive","nesting","length","halstead","mi","parameters","booleanParameters"];var qr={cyclomatic:{warn:15,error:25},cognitive:{warn:12,error:20},nesting:{warn:4,error:5},length:{warn:60,error:120},halstead:{warn:500,error:1e3},mi:{warn:65,error:20},fileLines:{warn:400,error:800},exports:{warn:20,error:30},parameters:{warn:5,error:8}};function DT(){let e={cyclomatic:{...qr.cyclomatic},cognitive:{...qr.cognitive},nesting:{...qr.nesting},length:{...qr.length},halstead:{...qr.halstead},mi:{...qr.mi},fileLines:{...qr.fileLines},exports:{...qr.exports},parameters:{...qr.parameters}};return{ignore:[],thresholds:e,ci:{failBelow:65,mode:"advisory"}}}var ND=["cyclomatic","cognitive","nesting","length","halstead","mi","fileLines","exports","parameters"];function Mp(e){return typeof e=="number"&&Number.isFinite(e)}function qp(e){let t=DT(),r;try{r=JSON.parse(FD(FT(e,".howtocode","quality.json"),"utf8"))}catch{return t}if(typeof r!="object"||r===null)return t;let n=r;if(typeof n.enabled=="boolean"&&(t.enabled=n.enabled),Array.isArray(n.ignore)&&(t.ignore=n.ignore.filter(o=>typeof o=="string")),typeof n.thresholds=="object"&&n.thresholds!==null){let o=n.thresholds;for(let i of ND){let a=o[i];if(typeof a!="object"||a===null)continue;let m=a;Mp(m.warn)&&(t.thresholds[i].warn=m.warn),Mp(m.error)&&(t.thresholds[i].error=m.error)}}if(typeof n.ci=="object"&&n.ci!==null){let o=n.ci;Mp(o.failBelow)&&(t.ci.failBelow=o.failBelow),(o.mode==="advisory"||o.mode==="blocking")&&(t.ci.mode=o.mode)}return t}function jT(e,t){let r=process.env.HOWTOCODE_QUALITY;if(r!==void 0){let o=r.trim().toLowerCase();return o==="0"||o==="false"?{enabled:!1,source:"env"}:{enabled:!0,source:"env"}}let n=qp(e).enabled;return n!==void 0?{enabled:n,source:"config"}:t!==void 0?{enabled:t,source:"runtime"}:{enabled:!0,source:"default"}}function cn(e,t){return e>t.error?2:e>t.warn?1:0}function NT(e,t){return e<t.error?2:e<t.warn?1:0}function qD(e){let t=[];for(let r of Di(e.node,"parameters"))Ve(r,"type")?.kind===wm.BooleanKeyword&&t.push(To(Ve(r,"name"))??"<pattern>");return t}function _D(e,t,r,n){let o=n.thresholds,i=Ve(e.node,"body")??e.node,a={cyclomatic:ST(i),cognitive:ET(i),nesting:CT(i),length:TT(e),halstead:kT(i),mi:0};a.mi=wT(a.halstead,a.cyclomatic,a.length);let m=qD(e),c=Di(e.node,"parameters").length,p={cyclomatic:{value:a.cyclomatic,rank:cn(a.cyclomatic,o.cyclomatic)},cognitive:{value:a.cognitive,rank:cn(a.cognitive,o.cognitive)},nesting:{value:a.nesting,rank:cn(a.nesting,o.nesting)},length:{value:a.length,rank:cn(a.length,o.length)},halstead:{value:a.halstead,rank:cn(a.halstead,o.halstead)},mi:{value:a.mi,rank:NT(a.mi,o.mi)},parameters:{value:c,rank:cn(c,o.parameters)},booleanParameters:{value:m.length,rank:m.length>0?1:0}},f={cyclomatic:p.cyclomatic.rank,cognitive:p.cognitive.rank,nesting:p.nesting.rank,length:p.length.rank,halstead:p.halstead.rank,mi:p.mi.rank},d=Ap(t,e.node),g=0;for(let y of Np)p[y].rank>g&&(g=p[y].rank);return{path:r,name:e.name,startLine:d.startLine,endLine:d.endLine,startColumn:d.startColumn,endColumn:d.endColumn,metrics:p,booleanParameterNames:m,smells:PT(a,f),worstRank:g}}function UD(e){let t=0;return Tm(e,r=>{if(r.kind===wm.ExportDeclaration){let n=Ve(r,"exportClause"),o=n?Di(n,"elements"):[];t+=o.length>0?o.length:1;return}if(r.kind===wm.ExportAssignment){t+=1;return}IT(r,wm.ExportKeyword)&&(t+=1)}),t}function BD(e){if(e.length===0)return 0;let t=1;for(let r=0;r<e.length;r+=1)e.charCodeAt(r)===10&&(t+=1);return e.charCodeAt(e.length-1)===10&&(t-=1),t}var AT={value:0,rank:0};function OT(e,t){return{path:e,ok:!1,error:t,lines:0,metrics:{lines:AT,exports:AT,mi:{value:100,rank:0}},functions:[]}}function vp(e,t,r,n,o,i,a){i.rank!==0&&e.push({path:t.path,metric:o,detail:o==="booleanParameters"?r?.booleanParameterNames.join(", ")??String(i.value):`${i.value} (limit ${a})`,rank:i.rank,line:n.line,endLine:n.endLine,startColumn:n.startColumn,endColumn:n.endColumn,...r?{function:r.name}:{}})}async function qT(e,t=DT()){let r=await bT(e),n=new Map,o=[],i=t.thresholds;for(let a of e){let m=r.get(a);if(!m){let $=OT(a,"internal: file missing from the parse result");n.set(a,$),o.push({path:a,metric:"parse error",detail:$.error??"",rank:2,line:1,endLine:1,startColumn:1,endColumn:1});continue}if(!m.ok){let $=OT(a,m.error);n.set(a,$),o.push({path:a,metric:"parse error",detail:m.error,rank:2,line:1,endLine:1,startColumn:1,endColumn:1});continue}let{sourceFile:c}=m,p=m.functions.map($=>_D($,c,a,t)),f=BD(c.text),d=UD(c),g=p.reduce(($,b)=>$+b.metrics.length.value,0),y=g===0?100:Math.round(p.reduce(($,b)=>$+b.metrics.mi.value*b.metrics.length.value,0)/g*10)/10,I={path:a,ok:!0,lines:f,metrics:{lines:{value:f,rank:cn(f,i.fileLines)},exports:{value:d,rank:cn(d,i.exports)},mi:{value:y,rank:NT(y,i.mi)}},functions:p};n.set(a,I);let h={line:1,endLine:Math.max(f,1),startColumn:1,endColumn:1};vp(o,I,void 0,h,"file lines",I.metrics.lines,i.fileLines.warn),vp(o,I,void 0,h,"exports",I.metrics.exports,i.exports.warn);for(let $ of p){let b={line:$.startLine,endLine:$.endLine,startColumn:$.startColumn,endColumn:$.endColumn};for(let w of Np)vp(o,I,$,b,w,$.metrics[w],_T(w,i));for(let w of $.smells)o.push({path:a,metric:"smell",detail:`${w.label}: ${w.reason}`,rank:1,line:$.startLine,endLine:$.endLine,startColumn:$.startColumn,endColumn:$.endColumn,function:$.name})}}return{files:n,findings:o}}function _p(e){let t=0,r=0;for(let n of e.files.values())if(n.ok)for(let o of n.functions)t+=o.metrics.length.value,r+=o.metrics.mi.value*o.metrics.length.value;return t===0?100:Math.round(r/t*10)/10}function Up(e){let t=0,r=0,n=0,o=0;for(let i of e.files.values())i.ok||(t+=1),r+=i.functions.length;for(let i of e.findings)i.rank>=2?o+=1:n+=1;return{files:e.files.size,errorFiles:t,functions:r,findings:e.findings.length,warn:n,error:o,score:_p(e)}}var GD=["ok","\u26A0","\u2717"],KD=[["cyclomatic","cyclomatic"],["cognitive","cognitive"],["nesting","nesting"],["length","length"],["halstead","halstead"],["mi","MI"],["parameters","parameters"],["booleanParameters","boolean params"]];function _T(e,t){return e==="mi"?t.mi.warn:e==="booleanParameters"?t.parameters.warn:t[e].warn}function Lp(e,t,r,n){return`${e}${t.padEnd(15)} ${r.value} (limit ${n}) ${jD[r.rank]}`}function HD(e,t){let r=[` ${e.name.padEnd(30)} L${e.startLine}-${e.endLine}`];for(let[n,o]of KD){let i=e.metrics[n];if(i.rank!==0){if(n==="booleanParameters"){r.push(` ${o.padEnd(15)} ${e.booleanParameterNames.join(", ")} warn`);continue}r.push(Lp(" ",o,i,_T(n,t.thresholds)))}}if(e.smells.length>0){r.push(` ${"smells".padEnd(15)} ${e.smells.map(n=>n.id).join(", ")}`);for(let n of e.smells)r.push(` \u2192 ${RT[n.id]??n.label}`)}return r}function MT(e){let t=e.smells.length;for(let r of Np)e.metrics[r].rank>0&&(t+=1);return t}function zD(e,t){let r=[];for(let o of e.files.values())for(let i of o.functions)i.worstRank>0&&r.push(i);r.sort((o,i)=>{if(o.worstRank!==i.worstRank)return i.worstRank-o.worstRank;let a=MT(i)-MT(o);if(a!==0)return a;let m=i.metrics.cyclomatic.value-o.metrics.cyclomatic.value;return m!==0?m:`${o.path}:${o.name}`.localeCompare(`${i.path}:${i.name}`)});let n=new Map;for(let o of r.slice(0,t)){let i=n.get(o.path)??new Set;i.add(`${o.name}@${o.startLine}`),n.set(o.path,i)}return n}function UT(e,t,r={}){let n=Up(e),o=r.top&&r.top>0?zD(e,r.top):void 0,i=[...e.files.values()].filter(p=>!o||(o.get(p.path)?.size??0)>0),a=Math.max(40,...i.map(p=>p.path.length)),m=[];for(let p of i){if(!p.ok){m.push(`${p.path.padEnd(a)} parse error`),m.push(` ${p.error}`);continue}m.push(`${p.path.padEnd(a)} MI ${p.metrics.mi.value} ${GD[p.metrics.mi.rank]}`),p.metrics.lines.rank>0&&m.push(Lp(" ","file lines",p.metrics.lines,t.thresholds.fileLines.warn)),p.metrics.exports.rank>0&&m.push(Lp(" ","exports",p.metrics.exports,t.thresholds.exports.warn));for(let f of p.functions)o&&!o.get(p.path)?.has(`${f.name}@${f.startLine}`)||f.worstRank===0&&f.smells.length===0||m.push(...HD(f,t))}m.length>0&&m.push("");let c=n.errorFiles>0?`, ${n.errorFiles} parse error(s)`:"";return m.push(`${n.findings} findings in ${n.files} files${c} \xB7 ${n.functions} functions \xB7 score ${n.score}`),m.join(`
|
|
133
|
+
`)}var Dp=new Set([".ts",".tsx",".mts",".cts"]),WD=new Set(["node_modules","dist","coverage"]);function jp(e,t,r){for(let n of vD(e,{withFileTypes:!0})){let o=FT(e,n.name);if(n.isDirectory()){if(n.name.startsWith(".")||WD.has(n.name))continue;jp(o,t,r);continue}n.isFile()&&Dp.has(Fp(n.name))&&r.push(LT(t,o))}}function vT(e,t){let r=MD("git",["-C",e,...t],{encoding:"utf8"});if(r.error||r.status!==0){let n=r.error?r.error.message:r.stderr.trim()||`exit ${r.status}`;throw new Error(`git ${t.join(" ")} failed: ${n}`)}return r.stdout.split(`
|
|
134
|
+
`).filter(n=>n.trim().length>0)}function VD(e,t){let r=vT(e,["diff","--name-only","--diff-filter=ACMR",t]),n=vT(e,["ls-files","--others","--exclude-standard"]);return[...r,...n]}function JD(e,t){if(!t.includes("*")){let n=t.endsWith("/")?t:`${t}/`;return e===t||e.startsWith(n)}let r=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"\0").replace(/\*/g,"[^/]*").replace(/\u0000/g,".*");return new RegExp(`^${r}$`).test(e)}function BT(e,t,r=[]){let n;if(t.changes)n=VD(e,t.base??"HEAD");else if(t.target){let i=DD(e,t.target),a=LD(i,{throwIfNoEntry:!1});if(!a)throw new Error(`no such path: ${t.target}`);if(a.isDirectory())n=[],jp(i,e,n);else{if(!Dp.has(Fp(i)))throw new Error(`not a TypeScript source file: ${t.target}`);n=[LT(e,i)]}}else n=[],jp(e,e,n);let o=new Set;for(let i of n)Dp.has(Fp(i))&&(r.some(a=>JD(i,a))||o.add(i));return[...o].sort()}var GT=6e3,KT=YD({name:"quality",label:"quality",description:"Measure code quality: cyclomatic and cognitive complexity, nesting depth, function length, Halstead volume, maintainability index, and compound smells like god-function and deeply-tangled. Read-only. Use it before reporting a task finished, especially on functions you just wrote or changed; it reports concrete numbers with line numbers and a suggested next step, so 'is this too complex' stops being a guess. Defaults to the changed files; pass a path to narrow it further.",promptSnippet:"quality: complexity and maintainability metrics for changed code",parameters:v.Object({path:v.Optional(v.String({description:"One file or directory, relative to the project root. Omit to scan the changed set."})),changes:v.Optional(v.Boolean({description:"Scan only files changed against the base ref. Default true when path is omitted."})),base:v.Optional(v.String({description:"Git ref for `changes`. Defaults to HEAD."})),top:v.Optional(v.Number({description:"Only report the N worst functions."}))}),async execute(e,t,r,n,o){let i=o.cwd??process.cwd(),a=jT(i);if(!a.enabled)return{content:[{type:"text",text:`quality metrics are off (source: ${a.source})`}],details:{off:!0}};let m=qp(i),c=t.changes??t.path===void 0,p=BT(i,{changes:c,base:t.base,target:t.path},m.ignore);if(p.length===0)return{content:[{type:"text",text:c?"no changed files to measure":"no source files found"}],details:{files:0}};let f=await qT(p,m),d=Up(f),g=UT(f,m,{top:t.top});return{content:[{type:"text",text:g.length>GT?`${g.slice(0,GT)}
|
|
135
|
+
\u2026 (truncated; run the quality script for the full report)`:g}],details:{files:d.files,functions:d.functions,findings:d.findings,score:_p(f)}}}});import{availableParallelism as QD}from"node:os";var XD=4;function ZD(){let e=ff(Ye).agents;return e!==void 0?e:Math.max(1,Math.min(XD,QD()-2))}var Bp=0,HT=[];async function Cm(){for(;Bp>=ZD();)await new Promise(t=>HT.push(t));Bp+=1;let e=!1;return()=>{e||(e=!0,Bp-=1,HT.shift()?.())}}function zT(e,t){let r=e.find(o=>`${o.provider}/${o.id}`===t||o.id===t);if(r)return r;let n=t.toLowerCase();return e.find(o=>o.id.toLowerCase().includes(n)||`${o.provider}/${o.id}`.toLowerCase().includes(n))}var ej=["deepseek","qwen","claude","gpt-5","gpt-4","gemini","glm","mimo","kimi","llama"],tj=/(image|embedding|embed|whisper|tts|audio|video|rerank|moderation|dall-e|stable-diffusion|sora)/i;function rj(e){let t=r=>{if(tj.test(r))return 100;let n=ej.findIndex(o=>r.toLowerCase().includes(o));return n===-1?50:n};return e.map((r,n)=>({id:r,index:n})).sort((r,n)=>t(r.id)-t(n.id)||r.index-n.index).map(r=>r.id)}function NFe(e,t=[]){if(e.length===0)return;let r=e.filter(i=>t.includes(i.provider)),n=r.length>0?r:e,o=rj(n.map(i=>i.id))[0];return n.find(i=>i.id===o)??n[0]}import{mkdirSync as nj,readdirSync as oj,readFileSync as ij,unlinkSync as sj}from"node:fs";import{join as Kp}from"node:path";import{createAgentSession as aj,DefaultResourceLoader as mj,SessionManager as uj}from"@netrodev/hxf-coding-agent";var Gp=["You are one agent on a shared task; siblings may be editing the same working tree right now.","Stay inside the files your assignment names. A file another agent owns is theirs to change: report what you need changed instead of changing it yourself, and never edit a file two agents were both given.","Never run project-wide validation (full builds, whole test suites, formatters, linters) unless your assignment explicitly tells you to.","Siblings' unfinished edits will make those runs fail for reasons that are not yours. Prove your own change with a scoped test, a targeted repro, or a smoke run instead."],cj=`You are a software architect planning an implementation. Your job is to explore the codebase and return a plan, not to write code.
|
|
136
|
+
|
|
137
|
+
## Read-only, by construction
|
|
138
|
+
You have no edit tool, no write tool, and no shell. Do not attempt to modify, create, move, or delete anything \u2014 the call would fail. Your output is text.
|
|
139
|
+
|
|
140
|
+
## Your process
|
|
141
|
+
1. Understand the requirement. If it is ambiguous in a way that changes the design, say so and name the options rather than silently picking one.
|
|
142
|
+
2. Explore: read the files involved, find the existing patterns and conventions with grep/find/ls, and trace the code paths the change touches. Follow the codebase's existing approach instead of inventing a new one.
|
|
143
|
+
3. Design: state the approach you recommend, not every alternative you considered. Note the trade-off that decided it.
|
|
144
|
+
4. Sequence: give the implementation as ordered steps, naming the files and functions to change at each one, and what to verify after each.
|
|
145
|
+
|
|
146
|
+
## Required output
|
|
147
|
+
End your reply with exactly this section, listing the 3-5 files most critical to the implementation, most important first:
|
|
148
|
+
|
|
149
|
+
### Critical Files for Implementation
|
|
150
|
+
- path/to/file.ts
|
|
151
|
+
- path/to/file.ts
|
|
152
|
+
|
|
153
|
+
Keep the plan concrete enough to execute without re-deriving it: name real paths and real function names you saw while exploring. If you could not confirm something, say which part you are unsure of instead of guessing.`,pn=new Map([["scout",{name:"scout",description:"read-only lookup",tools:["read","grep","find","ls","context","web_search","web_fetch","lsp"],prompt:["Inspect only what the task needs. Do not edit.",...Gp].join(`
|
|
154
|
+
`),effort:"low"}],["architect",{name:"architect",description:"designs an implementation plan",tools:["read","grep","find","ls","context","web_search","web_fetch","lsp"],prompt:cj,effort:"high"}],["task",{name:"task",description:"implements the assignment",tools:["read","bash","edit","write","grep","find","ls","context","todo","web_search","web_fetch","lsp"],prompt:["Do the assignment, then report files changed.",...Gp].join(`
|
|
155
|
+
`),effort:"medium"}],["reviewer",{name:"reviewer",description:"finds concrete issues",tools:["read","grep","find","ls","context","web_search","web_fetch","lsp"],prompt:["Return issues with file evidence. Do not edit.",...Gp].join(`
|
|
156
|
+
`),effort:"medium"}]]),r1e=new Set(pn.keys());function pj(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function fj(e){return e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${(e%6e4/1e3).toFixed(1)}s`}function n1e(e){let t=e.status==="parked"?"done":e.status==="error"?"failed":e.status,r=[];return e.model&&r.push(e.model),typeof e.toolUses=="number"&&r.push(`${e.toolUses} tool use${e.toolUses===1?"":"s"}`),typeof e.tokens=="number"&&e.tokens>0&&r.push(pj(e.tokens)),e.startedAt&&e.endedAt&&r.push(fj(e.endedAt-e.startedAt)),`## ${e.agent}#${e.id} ${t}${r.length>0?` (${r.join(" \xB7 ")})`:""}`}var Pt=[],dj=3,WT=8,o1e=6,Rm=12;function Pm(e){nj(Dn,{recursive:!0}),sr(Kp(Dn,`${e.id}.json`),JSON.stringify({...e,session:void 0},null,1))}function Hp(){let e;try{e=oj(Dn)}catch{return}for(let t of e)if(t.endsWith(".json"))try{let r=JSON.parse(ij(Kp(Dn,t),"utf8"));if(r.status!=="parked"||Pt.some(n=>n.id===r.id))continue;Pt.push({...r,mail:r.mail??[]})}catch{}if(Pt.length>Rm){let t=Pt.splice(0,Pt.length-Rm);for(let r of t){let n=r.session;r.session=void 0,n&&n.dispose();try{sj(Kp(Dn,`${r.id}.json`))}catch{}}}}function i1e(){if(Hp(),Pt.length===0)return"no agents";let e=Pt.map(t=>`${t.id} ${t.agent} ${t.status}${t.model?` model=${t.model}`:""}${t.background?" background":""} requests=${t.requests} ${t.task}`);return Co&&e.unshift("background work in flight"),e.join(`
|
|
157
|
+
`)}function s1e(e){Hp();let t=Pt.find(r=>r.id===e);return t?`${t.agent}#${t.id} ${t.status}
|
|
158
|
+
${t.result??t.task}`:`no agent ${e}`}async function Am(e){let t=pn.get(e.agent);if(!t)throw new Error(`unknown agent ${e.agent}`);let r=e.worktree||e.cwd||process.cwd(),n=new mj({cwd:r,agentDir:Ye,appendSystemPrompt:[t.prompt],additionalSkillPaths:cf(r),extensionFactories:[pf({interactive:!1}),$k()]});await n.reload();let{session:o}=await aj({cwd:r,agentDir:Ye,sessionManager:uj.inMemory(r),resourceLoader:n,tools:t.tools,customTools:[mk,ok,oT,iT,yT,KT,tk],thinkingLevel:e.effort}),i=lj(e,t);if(i){let a=await o.modelRuntime.getAvailable(),m=zT(a,i);if(!m){o.dispose();let c=e.model?"asked for by the task":t.model?`named by the ${e.agent} definition${t.source?` (${t.source})`:""}`:"inherited from the parent session";throw new Error(`unknown model '${i}' ${c}. /model lists what this account can reach.`)}await o.setModel(m)}return o}async function a1e(e,t){Hp();let r=Pt.find(o=>o.id===e);if(!r)return`no agent ${e}`;let n=r.session??await Am(r);if(r.session=n,r.status==="running"||n.isStreaming)return r.mail.push(t),Pm(r),`queued for ${e}`;if(r.requests>=WT)return`${e} is out of budget (${r.requests} requests)`;r.status="running";try{await n.prompt(t),r.requests+=1,r.result=vo(n.getLastAssistantText()??"")||r.result,r.status="parked"}catch(o){r.result=o instanceof Error?o.message:String(o),r.status="error"}return Pm(r),`${e} ${r.status}`}function lj(e,t){for(let r of[e.model,t.model,e.parentModel]){let n=r?.trim();if(n)return n}}function VT(e){if(!(!e?.provider||!e.id))return`${e.provider}/${e.id}`}async function m1e(e){let t=pn.get(e.agent);if(!t)throw new Error(`unknown agent ${e.agent}. known: ${[...pn.keys()].join(", ")}`);if(Pt.length>=Rm)throw new Error(`${Rm} agents is the limit (${Pt.length} live or parked). Finish with the existing ones, or clear them with /agents, before spawning more.`);let r={id:`${Date.now().toString(36)}-${Pt.length+1}`,cwd:e.cwd,agent:t.name,task:e.task.trim(),effort:e.effort||t.effort,model:(e.model||t.model)?.trim()||void 0,parentModel:e.parentModel?.trim()||void 0,background:e.background,status:"queued",requests:0,mail:[],worktree:e.worktree};return Pt.push(r),Pm(r),r}async function gj(e,t){if(!pn.get(e.agent))return;let n=e.session??await Am(e);e.session=n,e.startedAt=Date.now();try{let o=e.mail.splice(0).join(`
|
|
159
|
+
`);for(await n.prompt(`Task:
|
|
160
|
+
${e.task}${o?`
|
|
161
|
+
|
|
162
|
+
Messages:
|
|
163
|
+
${o}`:""}`),e.requests+=1;e.mail.length>0&&e.requests<WT;)await n.followUp(e.mail.splice(0).join(`
|
|
164
|
+
`)),e.requests+=1;if(t?.aborted)throw new Error("aborted");let i=vo(n.getLastAssistantText()??""),a=n.getSessionStats?.();if(!i&&(a?.toolCalls??0)===0)throw new Error(`agent produced no output (model ${n.model?.provider}/${n.model?.id} answered nothing; 0 tool calls). Check that the provider is reachable and the model is configured.`);e.result=i,e.status="parked"}catch(o){e.result=o instanceof Error?o.message:String(o),e.status="error"}finally{e.endedAt=Date.now();let o=n.getSessionStats?.();e.toolUses=o?.toolCalls,e.tokens=o?.tokens?.total,e.session=void 0,n.dispose(),Pm(e);try{JT?.(e)}catch{}}}var JT;function u1e(e){JT=e}var Co;function c1e(){Co||(Co=yj().catch(()=>{}).finally(()=>{Co=void 0}))}async function yj(e){Co&&await Co.catch(()=>{});let t=()=>Pt.find(n=>n.status==="queued"),r=async()=>{for(;;){if(e?.aborted)throw new Error("aborted");let n=t();if(!n)return;n.status="running";let o=await Cm();try{await gj(n,e)}finally{o()}}};if(await Promise.all(Array.from({length:dj},r)),e?.aborted)throw new Error("aborted")}import{execFile as xj}from"node:child_process";import{cp as hj,readdir as Ij,stat as YT}from"node:fs/promises";import{promisify as bj}from"node:util";import{tmpdir as $j}from"node:os";import{join as Om}from"node:path";var QT=bj(xj);async function zt(e,t){try{let{stdout:r}=await QT("git",t,{cwd:e,encoding:"utf8",maxBuffer:8388608});return{ok:!0,output:r.trim()}}catch(r){let n=r&&typeof r=="object"&&"stderr"in r&&typeof r.stderr=="string"?r.stderr.trim():"",o=r instanceof Error?r.message:String(r);return{ok:!1,output:n||o}}}async function Ej(e){return(await zt(e,["rev-parse","--is-inside-work-tree"])).output==="true"}async function x1e(e){return(await zt(e,["status","--porcelain"])).output.length>0}async function h1e(e,t){let r=await zt(e,["add","-A"]);if(!r.ok)return r;let n=await zt(e,["commit","-m",t]);return n.ok?{ok:!0,output:(await zt(e,["log","-1","--oneline"])).output||n.output}:n}async function I1e(e){let t=await zt(e,["reset","--soft","HEAD~1"]);return t.ok?{ok:!0,output:(await zt(e,["log","-1","--oneline"])).output||"reset to the previous commit"}:t}async function b1e(e){let t=(await zt(e,["diff"])).output,r=(await zt(e,["diff","--cached"])).output;return[t,r].filter(Boolean).join(`
|
|
165
|
+
`)}function $1e(e,t=60){let r=e.split(`
|
|
166
|
+
`);if(r.length<=t)return e;let n=r.slice(0,t),o=r.length-t;return[...n,`\u2026 ${o} more line${o===1?"":"s"} not shown \u2014 /copy puts the full diff on the clipboard`].join(`
|
|
167
|
+
`)}var Sj=["node_modules","vendor","target",".venv","venv","__pycache__",".pnpm-store","dist","build"],XT=1024*1024*1024;async function ZT(e){let t=0,r;try{r=await Ij(e,{withFileTypes:!0})}catch{return 0}for(let n of r){let o=Om(e,n.name);if(n.isDirectory())t+=await ZT(o);else if(n.isFile())try{t+=(await YT(o)).size}catch{}if(t>XT)return t}return t}async function kj(e,t){let r=[];for(let n of Sj){let o=Om(e,n),i=Om(t,n);try{if(!(await YT(o)).isDirectory())continue}catch{continue}if(await ZT(o)>XT){r.push(n);continue}await Tj(o,i)||r.push(n)}return r}async function Tj(e,t){if(process.platform!=="win32")try{return await QT("cp",["-a",e,t],{maxBuffer:8*1024*1024}),!0}catch{}try{return await hj(e,t,{recursive:!0,force:!0,errorOnExist:!1,dereference:!1}),!0}catch{return!1}}async function ew(e,t){if(!await Ej(e))return null;let r=t.replace(/[^A-Za-z0-9._-]/g,"-").slice(0,40)||"agent",n=Om($j(),`howtocode-wt-${process.pid}-${Date.now()}-${r}`);if(!(await zt(e,["worktree","add","--detach",n,"HEAD"])).ok)return null;let i=await kj(e,n);return{path:n,skipped:i,async remove(){await zt(e,["worktree","remove","--force",n]),await zt(e,["worktree","prune"])}}}import{detectCapabilities as wj,getTerminalColorMode as Cj,parseColor as _r,styleText as tw}from"@netrodev/hxf-tui";function Rj(){let e=process.env.NO_COLOR;if(e!==void 0&&e!=="")return"256color";try{return Cj(wj())}catch{return"256color"}}var rw=Rj();function Pj(){let e=process.env.NO_COLOR;return e!==void 0&&e!==""}var Ue={text:_r("#e6e6e6"),mute:_r("#8b8b8b"),dim:_r("#5c5c5c"),user:_r("#d0d0d0"),accent:_r("#c4b5fd"),tool:_r("#6ee7b7"),bad:_r("#f0a8a4"),warn:_r("#e6b15a"),line:_r("#3a3a3a")};function Aj(e,t){if(Pj()){let{bold:r,dim:n,italic:o,underline:i,strikethrough:a}=t;return!r&&!n&&!o&&!i&&!a?e:tw(e,{bold:r,dim:n,italic:o,underline:i,strikethrough:a},rw)}return tw(e,t,rw)}function mt(e,t,r){return Aj(e,{...r,fg:t})}var k1e={heading:e=>mt(e,Ue.text,{bold:!0}),link:e=>mt(e,Ue.accent,{underline:!0}),linkUrl:e=>mt(e,Ue.mute),code:e=>mt(e,Ue.text),codeBlock:e=>mt(e,Ue.text),codeBlockBorder:e=>mt(e,Ue.line),quote:e=>mt(e,Ue.mute,{italic:!0}),quoteBorder:e=>mt(e,Ue.line),hr:e=>mt(e,Ue.line),listBullet:e=>mt(e,Ue.mute),bold:e=>mt(e,Ue.text,{bold:!0}),italic:e=>mt(e,Ue.text,{italic:!0}),strikethrough:e=>mt(e,Ue.mute,{strikethrough:!0}),underline:e=>mt(e,Ue.text,{underline:!0})};import{truncateToWidth as qi,visibleWidth as or}from"@netrodev/hxf-tui";var nw={text:Ue.text,muted:Ue.mute,dim:Ue.dim,accent:Ue.accent,success:Ue.tool,error:Ue.bad,border:Ue.line},ae=(e,t,r=!1)=>r?mt(t,nw[e],{bold:!0}):mt(t,nw[e]),Oj=25,Mj=15e5,iw=420;function Po(e){let t=Math.max(0,Math.round(e/1e3)),r=Math.floor(t/3600),n=Math.floor(t%3600/60),o=t%60;return r>0?`${r}h${String(n).padStart(2,"0")}m`:n>0?`${n}m${String(o).padStart(2,"0")}s`:`${o}s`}function R1e(e){let t=Math.max(0,Math.floor(e/1e3));return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h`}function Vp(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}var Ni=(e,t,r)=>Math.max(t,Math.min(r,e)),Ro=(e,t)=>or(e)>t?qi(e,Math.max(0,t),"\u2026"):e;function Mm(e,t,r="left"){if(t<=0)return"";let n=or(e);if(n>t)return qi(e,t);let o=" ".repeat(t-n);return r==="right"?o+e:e+o}function Jp(e,t,r,n=1){if(r<=0)return"";let o=or(t);if(o>=r)return qi(t,r);let i=r-o-n;if(i<=0)return Mm(t,r,"right");let a=or(e)>i?qi(e,i):e,m=" ".repeat(r-or(a)-o);return a+m+t}function zp(e,t,r){let n=Ro(e,Math.max(0,r-2)),o=Math.max(1,r-1-or(n)),i=ae("border","\u250C\u2500 ")+ae("accent",n)+ae("border",` ${"\u2500".repeat(o)}\u2510`),a=ae("border",`\u2514${"\u2500".repeat(r+2)}\u2518`),m=ae("border","\u2502"),c=t.map(p=>`${m} ${Mm(p,r)} ${m}`);return[i,...c,a]}function vj(e,t,r,n){let o=n?.gap??1,i=n?.leftWidth??Ni(Math.round(r*.38),28,44),a=r-i-o,m=Math.max(e.rows.length,t.rows.length),c=g=>{let y=[...g];for(;y.length<m;)y.push("");return y},p=zp(e.title,c(e.rows),i-4),f=zp(t.title,c(t.rows),a-4),d=" ".repeat(o);return p.map((g,y)=>g+d+(f[y]??Mm("",a)))}function sw(e,t,r){switch(e){case"running":return ae(t||r?"accent":"muted","\u25CF");case"failed":return ae("error","\u2717");default:return ae("success","\u2713")}}function aw(e,t,r,n=Date.now(),o=0){return t?n-o<iw?ae("success","\u2713",!0):ae("success","\u2713"):ae(r?"accent":"dim",String(e))}var ow="Workflow";function Yp(e,t=Date.now()){let r=e.phases.map(o=>o.title),n=new Map(e.phases.map(o=>[o.title,o.detail]));for(let o of e.steps){let i=o.phase||ow;r.includes(i)||r.push(i)}return r.map((o,i)=>{let a=e.steps.filter(I=>(I.phase||ow)===o).map(I=>({...I,phaseIndex:i})),m=a.filter(I=>I.status!=="running").length,c=a.filter(I=>I.status==="failed").length,p=a.reduce((I,h)=>{let $=h.endedAt??t;return Math.max(I,$-h.startedAt)},0),f=-1;for(let I=0;I<a.length;I++){let h=a[I];h.status==="running"&&(f<0||h.startedAt>=a[f].startedAt)&&(f=I)}let d=n.get(o),g=a.length>0&&m===a.length&&c===0,y=g?a.reduce((I,h)=>Math.max(I,h.endedAt??0),0):0;return{title:o,...d?{detail:d}:{},agents:a,done:m,failed:c,outputTokens:a.reduce((I,h)=>I+h.outputTokens,0),elapsedMs:p,allDone:g,finishedAt:y,anchor:f}})}function Qp(e){return e.steps.reduce((t,r)=>t+r.outputTokens,0)}function Fj(e){return e.steps.reduce((t,r)=>t+(r.toolCalls??0),0)}function mw(e,t=Date.now()){return Math.max(0,(e.endedAt??t)-e.startedAt)}function Lj(e){return e.steps.length>Oj||Qp(e)>Mj}function Dj(e){if(e.length===0)return 0;let t=e.map((r,n)=>({group:r,index:n})).filter(r=>r.group.anchor>=0);if(t.length>0)return t.reduce((r,n)=>{let o=n.group.agents[n.group.anchor],i=r.group.agents[r.group.anchor];return o.startedAt>=i.startedAt?n:r}).index;for(let r=e.length-1;r>=0;r--)if(e[r].agents.length>0)return r;return e.length-1}function uw(e,t=Date.now()){let r=Yp(e,t),n=e.steps.length,o=e.steps.filter(p=>p.status!=="running").length,i=e.steps.filter(p=>p.status==="failed").length,a=[e.name],m=r.find(p=>p.anchor>=0);m?a.push(`${m.title} ${m.done}/${m.agents.length}`):r.length>0&&a.push(`${r[r.length-1].title} done`),a.push(`${o}/${n} agents`),a.push(`${Vp(Qp(e))} tok`),a.push(Po(mw(e,t))),i>0&&a.push(`${i} failed`);let c=a.join(" \xB7 ");return Lj(e)?`large workflow \xB7 ${c}`:c}var cw=16,jj=12,Nj=18,qj=72,_j=24;function pw(e,t){if(e.status==="running"&&e.outputTokens===0)return[`idle ${Po(t-e.startedAt)}`,"idle"];let r=Vp(e.outputTokens),n=e.toolCalls??0,o=Po((e.endedAt??t)-e.startedAt);return[`${r} tok \xB7 ${n} tools \xB7 ${o}`,`${r} tok \xB7 ${n} tools`,`${r} tok`]}var Uj=e=>e.status==="running"&&e.outputTokens===0;function Wp(e,t,r){if(e.length<=r)return{slice:e,start:0,more:0};let n=Math.max(1,r-1),o=Ni(t-Math.floor(n/2),0,e.length-n),i=e.slice(o,o+n);return{slice:i,start:o,more:e.length-i.length}}function Bj(e,t,r,n,o){let i=`${e.done}/${e.agents.length}`,a=r?ae("accent","\u276F"):" ",m=aw(t+1,e.allDone,r,o,e.finishedAt),c=Math.max(0,n-4-or(i)),p=or(e.title)>c?qi(e.title,c,"\u2026"):e.title,f=e.allDone&&o-e.finishedAt<iw,d=ae(f&&!r?"success":r?"accent":"text",p),g=`${a}${m} ${d}`,y=ae(r?"accent":"muted",i);return Jp(g,y,n,1)}function Gj(e,t,r,n,o,i){let a=t?ae("accent","\u276F"):" ",m=sw(e.status,t,r),c=ae(t?"accent":"text",Mm(e.label,n)),p=`${a}${m} ${c}`,f=Math.max(0,o-or(p)-1),d=pw(e,i).find(y=>or(y)<=f)??"",g=ae(t?"accent":Uj(e)?"dim":"muted",d);return Jp(p,g,o,1)}function Kj(e,t,r,n){let o=[];return e.forEach((i,a)=>{let c=`${aw(a+1,i.allDone,a===r,n,i.finishedAt)} ${ae(a===r?"accent":"text",i.title)} ${ae("muted",`${i.done}/${i.agents.length}`)}`;o.push(Ro(c,t));let{slice:p,more:f}=Wp(i.agents,0,cw);p.forEach((d,g)=>{let y=sw(d.status,!1,g===i.anchor),I=pw(d,n)[0]??"";o.push(Ro(` ${y} ${ae("text",d.label)} ${ae("muted",I)}`,t))}),f>0&&o.push(Ro(` ${ae("dim",`\u2026+${f} more`)}`,t))}),o}function Hj(e,t,r){let n=r?.now??Date.now(),o=Yp(e,n),i=e.steps,a=i.filter(gt=>gt.status!=="running").length,m=i.filter(gt=>gt.status==="failed").length,c=[`${a}/${i.length} agents`,`${Vp(Qp(e))} tok`,`${Fj(e)} tools`,Po(mw(e,n)),...m>0?[`${m} failed`]:[]].join(" \xB7 "),p=[Jp(ae("accent",e.name,!0),ae("muted",c),t,2),...e.description?[ae("muted",Ro(e.description,t))]:[]],f=r?.footer?[ae("muted",Ro(r.footerText??zj(),t))]:[];if(o.length===0)return[...p,...zp("Phases",["(no agents yet)"],Math.max(0,t-4)),...f];let d=Ni(r?.selectedPhase??Dj(o),0,Math.max(0,o.length-1)),g=Ni(Math.round(t*.38),28,44),y=t-g-1-4;if(t<qj||y<_j)return[...p,...Kj(o,t,d,n),...f];let I=o[d],{slice:h,start:$,more:b}=Wp(o,d,jj),w=h.map((gt,ir)=>Bj(gt,$+ir,$+ir===d,g-4,n));b>0&&w.push(ae("dim",`\u2026+${b} more`));let S=r?.filter?r.filter(I.agents):I.agents,z=S.length?Ni(Math.max(...S.map(gt=>or(gt.label))),6,Nj):6,{slice:oe,more:ee}=Wp(S,0,r?.agentWindow??cw),j=oe.map((gt,ir)=>Gj(gt,!1,ir===I.anchor,z,y,n));ee>0&&j.push(ae("dim",`\u2026+${ee} more`));let lt=vj({title:"Phases",rows:w},{title:`${I.title} \xB7 ${S.length} agents${r?.filterLabel??""}`,rows:j},t,{leftWidth:g,gap:1});return[...p,...lt,...f]}function P1e(e,t=[],r=96,n,o){let i=Hj(e,r,{now:e.endedAt??Date.now(),footer:!0,...n===void 0?{}:{selectedPhase:n},...o?.filter?{filter:o.filter}:{},...o?.footerText?{footerText:o.footerText}:{},...o?.filterLabel?{filterLabel:o.filterLabel}:{}}),a=new Set(t);if(o?.drill){let c=Yp(e,e.endedAt??Date.now()),p=c[Math.max(0,Math.min(c.length-1,n??0))];for(let f of p?.agents??[])a.add(f.label)}if(a.size===0)return i;let m=[];for(let c of e.steps)if(a.has(c.label)){for(let p of c.tasks??[]){let f=p.status==="completed"?"[x]":p.status==="in_progress"?"[>]":"[ ]";m.push(` ${ae("muted",f)} ${ae("text",p.content)}`)}c.detail&&m.push(` ${ae("dim",c.detail)}`)}return m.length===0?i:[...i.slice(0,-1),...m,i[i.length-1]]}function zj(){return"\u2191/\u2193 phase \xB7 Enter drill in \xB7 Esc back out \xB7 f filter by status \xB7 p pause \xB7 x stop \xB7 s save script"}import{readFileSync as eN}from"node:fs";import{basename as tN}from"node:path";import{StringEnum as rN}from"@netrodev/hxf-ai";import{defineTool as nN}from"@netrodev/hxf-coding-agent";var Ln=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function fw(e){return e===null?"null":Array.isArray(e)?"array":Number.isInteger(e)?"integer":typeof e}function Wj(e,t){let r=fw(e);return t==="number"?r==="number"||r==="integer":t==="integer"?r==="integer":r===t}function Vj(e,t){if(typeof t!="string"||!t.startsWith("#/"))return;let r=e;for(let n of t.slice(2).split("/")){let o=n.replace(/~1/g,"/").replace(/~0/g,"~");if(!Ln(r)&&!Array.isArray(r))return;r=r[o]}return Ln(r)?r:void 0}function fn(e,t,r,n,o){if(!Ln(t))return;if(t.$ref!==void 0){let a=Vj(r,t.$ref);a&&fn(e,a,r,n,o);return}if(Array.isArray(t.allOf))for(let a of t.allOf)fn(e,a,r,n,o);for(let a of["anyOf","oneOf"]){let m=t[a];if(!Array.isArray(m)||m.length===0)continue;let c=m.filter(p=>{let f=[];return fn(e,p,r,n,f),f.length===0}).length;a==="anyOf"&&c===0&&o.push({path:n,message:"does not match any allowed shape"}),a==="oneOf"&&c!==1&&o.push({path:n,message:`must match exactly one shape (matched ${c})`})}let i=t.type;if(i!==void 0){let a=Array.isArray(i)?i.map(String):[String(i)];if(!a.some(m=>Wj(e,m))){o.push({path:n,message:`expected ${a.join(" or ")}, got ${fw(e)}`});return}}if(Array.isArray(t.enum)&&!t.enum.some(a=>JSON.stringify(a)===JSON.stringify(e))&&o.push({path:n,message:`must be one of ${t.enum.map(a=>JSON.stringify(a)).join(", ")}`}),Ln(e)){let a=Ln(t.properties)?t.properties:{};if(Array.isArray(t.required))for(let m of t.required.map(String))m in e||o.push({path:n?`${n}.${m}`:m,message:"is required"});for(let[m,c]of Object.entries(a))m in e&&fn(e[m],c,r,n?`${n}.${m}`:m,o);if(t.additionalProperties===!1)for(let m of Object.keys(e))m in a||o.push({path:n?`${n}.${m}`:m,message:"is not an allowed property"});else if(Ln(t.additionalProperties))for(let[m,c]of Object.entries(e))m in a||fn(c,t.additionalProperties,r,n?`${n}.${m}`:m,o)}if(Array.isArray(e)&&t.items!==void 0){let a=t.items;Array.isArray(a)?e.forEach((m,c)=>{c<a.length&&fn(m,a[c],r,`${n}[${c}]`,o)}):e.forEach((m,c)=>fn(m,a,r,`${n}[${c}]`,o))}if(typeof e=="string"&&(typeof t.minLength=="number"&&e.length<t.minLength&&o.push({path:n,message:`is shorter than ${t.minLength} characters`}),typeof t.pattern=="string"))try{new RegExp(t.pattern).test(e)||o.push({path:n,message:`does not match ${t.pattern}`})}catch{}typeof e=="number"&&(typeof t.minimum=="number"&&e<t.minimum&&o.push({path:n,message:`is below ${t.minimum}`}),typeof t.maximum=="number"&&e>t.maximum&&o.push({path:n,message:`is above ${t.maximum}`}))}function dw(e,t){if(!Ln(t))return[];let r=[];return fn(e,t,t,"",r),r}function lw(e){return e.map(t=>`- ${t.path||"(root)"}: ${t.message}`).join(`
|
|
168
|
+
`)}function gw(e){let t=e.trim(),r=/```(?:json)?\s*([\s\S]*?)```/.exec(t),n=[t,r?.[1]?.trim()].filter(o=>!!o);for(let o of n){try{return JSON.parse(o)}catch{}for(let i=0;i<o.length;i++){let a=o[i];if(a!=="{"&&a!=="[")continue;let m=a==="{"?"}":"]",c=0,p=!1,f=!1;for(let d=i;d<o.length;d++){let g=o[d];if(p){f?f=!1:g==="\\"?f=!0:g==='"'&&(p=!1);continue}if(g==='"')p=!0;else if(g===a)c++;else if(g===m&&(c--,c===0))try{return JSON.parse(o.slice(i,d+1))}catch{break}}}}}var Jj=1e3,Yj=4096,yw=100,xw=300*1e3;async function Qj(e,t=yw,r=xw){let n=Date.now()+r;for(;e.isPaused?.();){if(e.signal?.aborted||Date.now()>=n)return!1;await new Promise(o=>setTimeout(o,t))}return!0}var Je=class extends Error{constructor(t){super(t),this.name="WorkflowError"}};function Xj(e){let t=0,r=[];return async function(){t>=e&&await new Promise(i=>r.push(i)),t++;let o=!1;return()=>{o||(o=!0,t--,r.shift()?.())}}}function hw(e){let t=e.lifetimeCap??Jj,r=e.fanoutCap??Yj,n=e.concurrency?Xj(e.concurrency):null,o=async()=>{let b=await Cm();if(!n)return b;let w=await n();return()=>{w(),b()}},i=0,a=0,m=0,c="",p=b=>e.onEvent?.(b),f=new Map,d=()=>e.onProgress?.([...f.values()]),g=async(b,w)=>{let S=w??{},z=typeof S.label=="string"?S.label:`agent-${i+1}`,oe=typeof S.phase=="string"?S.phase:c,ee=typeof S.agentType=="string"?S.agentType:"task",j=typeof S.effort=="string"?S.effort:void 0,lt=typeof S.model=="string"?S.model:void 0,gt=typeof S.isolation=="string"?S.isolation:void 0,ir=S.schema;if(e.budgetTotal!=null&&a+m>=e.budgetTotal)throw new Je(`budget exhausted: spent ${a+m} of ${e.budgetTotal} output tokens`);if(i>=t)throw new Je(`lifetime cap reached: ${t} agent calls in one run`);i++;let sf=i;if(e.isPaused?.()&&!await Qj(e,yw,xw))return null;let af=e.budgetTotal==null?0:Math.max(0,e.budgetTotal-a-m);m+=af;let qw=await o();try{if(e.signal?.aborted)return null;p({kind:"agent_start",label:z,phase:oe,ordinal:i}),f.set(sf,{label:z,phase:oe,agentType:ee,status:"running",outputTokens:0,...lt?{model:lt}:{},startedAt:Date.now()}),d();let Oo=(dn,Ur,_t)=>{let Wt=f.get(sf);Wt&&(Wt.status=dn,Wt.outputTokens=Ur.outputTokens,Wt.endedAt=Date.now(),Ur.toolCalls!==void 0&&(Wt.toolCalls=Ur.toolCalls),Ur.model!==void 0&&(Wt.model=Ur.model),_t&&(Wt.detail=_t)),p({kind:"agent_end",label:z,ok:dn==="ok",outputTokens:Ur.outputTokens}),d()},mf=ir===void 0?1:2;for(let dn=0;dn<mf;dn++){let Ur=dn===0?String(b):void 0,_t=await I(Ur??Zj(String(b),y),{label:z,phase:oe,agentType:ee,effort:j,model:lt,isolation:gt});if(_t===null)return Oo("failed",{text:"",outputTokens:0}),null;if(a+=_t.outputTokens,ir===void 0)return Oo("ok",_t,Xp(_t.text)),_t.text;let Wt=gw(_t.text),uf=Wt===void 0?[{path:"",message:"reply was not JSON"}]:dw(Wt,ir);if(uf.length===0)return Oo("ok",_t,Xp(_t.text)),Wt;if(y=lw(uf),dn===mf-1)return Oo("failed",_t,`schema: ${Xp(y)}`),null}return null}finally{m=Math.max(0,m-af),qw()}},y="",I=async(b,w)=>{try{return await e.invoke({prompt:b,...w})}catch{return null}};return{agent:(b,w)=>g(b,w),parallel:async b=>{if(b.length>r)throw new Je(`fan-out cap exceeded: ${b.length} items (max ${r})`);return await Promise.all(b.map(async S=>{try{return await S()}catch{return null}}))},pipeline:async(b,...w)=>{if(b.length>r)throw new Je(`fan-out cap exceeded: ${b.length} items (max ${r})`);return await Promise.all(b.map(async(z,oe)=>{let ee=z;for(let j of w)try{ee=await j(ee,z,oe)}catch{return null}return ee}))},phase:b=>{c=String(b),p({kind:"phase",title:c})},log:b=>p({kind:"log",message:String(b)}),args:e.args,budget:{total:e.budgetTotal??null,spent:()=>a+m,remaining:()=>e.budgetTotal==null?1/0:Math.max(0,e.budgetTotal-a-m)}}}function Zj(e,t){return`${e}
|
|
169
|
+
|
|
170
|
+
Your previous reply did not satisfy the required schema:
|
|
171
|
+
${t}
|
|
172
|
+
|
|
173
|
+
Reply with ONLY a corrected JSON value.`}function Xp(e,t=80){let r=e.split(`
|
|
174
|
+
`).map(n=>n.trim()).find(n=>n.length>0)??"";return r.length>t?`${r.slice(0,t)}\u2026`:r}var Zp="workflow",Iw=null;function H1e(e){Iw=e}var oN=600*1e3;function iN(e){let t=e.replace(/^(?:\s+|\/\/[^\n]*\n|\/\*[\s\S]*?\*\/)*/,""),r=/^export\s+const\s+meta\s*=\s*/.exec(t);if(!r)throw new Je("a workflow script must start with `export const meta = { name, description }`");let n=e.length-t.length,o=r[0].length,i=0,a=null,m=-1;for(let y=o;y<t.length;y++){let I=t[y];if(a){I==="\\"?y++:I===a&&(a=null);continue}if(I==='"'||I==="'"||I==="`")a=I;else if(I==="{"||I==="[")i++;else if((I==="}"||I==="]")&&(i--,i===0)){m=y+1;break}}if(m===-1)throw new Je("meta is not a closed literal object");let c=t.slice(o,m),p=e.slice(n+m).replace(/^\s*;/,"");if(/^\s*(import|export)\b/m.test(p))throw new Je("a workflow body must not contain import or export declarations");if(/\bimport\s*\(/.test(p))throw new Je("a workflow body must not use dynamic import()");let f;try{f=new Function(`"use strict"; return (${c});`)()}catch(y){throw new Je(`meta must be a literal object: ${y instanceof Error?y.message:String(y)}`)}if(typeof f!="object"||f===null)throw new Je("meta must be an object");let d=f;if(typeof d.name!="string"||!d.name.trim())throw new Je("meta.name is required");if(typeof d.description!="string"||!d.description.trim())throw new Je("meta.description is required");let g=Array.isArray(d.phases)?d.phases.filter(y=>typeof y=="object"&&y!==null).map(y=>({title:String(y.title??""),...typeof y.detail=="string"?{detail:y.detail}:{}})).filter(y=>y.title):void 0;return{meta:{name:d.name,description:d.description,...typeof d.whenToUse=="string"?{whenToUse:d.whenToUse}:{},...g?{phases:g}:{}},body:p}}function sN(e){let t=["agent","parallel","pipeline","phase","log","args","budget"],r=`"use strict"; return (async () => {
|
|
175
|
+
${e}
|
|
176
|
+
})();`,n;try{n=new Function(...t,r)}catch(o){throw new Je(`workflow did not compile: ${o instanceof Error?o.message:String(o)}`)}return n}function aN(e){return vo(e.getLastAssistantText()??"")}function mN(e){return async({prompt:t,agentType:r,effort:n,model:o,isolation:i})=>{let a=pn.get(r)??pn.get("task");if(!a)throw new Je(`no agent named ${r}`);let m=i==="worktree"?await ew(process.cwd(),r):null,c=await Am({agent:a.name,effort:n??a.effort,...o?{model:o}:{},...e?{parentModel:e}:{},...m?{worktree:m.path}:{}});try{await c.prompt(`${a.prompt}
|
|
177
|
+
|
|
178
|
+
Task:
|
|
179
|
+
${t}`);let p=c.getSessionStats(),f=uN(c)??o;return{text:aN(c),outputTokens:p.tokens.output,toolCalls:p.toolCalls,...f?{model:f}:{}}}finally{c.dispose(),await m?.remove()}}}function uN(e){return e.model?.id??e.model?.name}var cN=v.Object({code:v.Optional(v.String({description:"The workflow script source"})),path:v.Optional(v.String({description:"Path to a workflow script, instead of code"})),agent:v.Optional(rN(["scout","task","reviewer"],{description:"Default agent profile for calls"})),budget:v.Optional(v.Number({description:"Output-token ceiling for the whole run"}))});function z1e(e){let t=()=>e??Iw;return nN({name:"workflow",label:"workflow",description:"Run a JavaScript workflow that orchestrates many agents deterministically. Provide `code` (or `path`). The script starts with `export const meta = { name, description, phases }` and then uses the injected bindings: `agent(prompt, {label, phase, schema, effort, model, agentType, isolation})`, `parallel(thunks)`, `pipeline(items, ...stages)`, `phase(title)`, `log(msg)`, `args`, `budget`. `agent()` resolves null on failure and throws only when the budget or the call cap is exhausted, so null-check every result. `parallel()` takes thunks and never rejects; `pipeline()` has no barrier between items. Use it for fan-out, for builder-verifier loops that converge on a verdict, and for anything needing many agents whose order and count must be deterministic.",promptSnippet:"workflow: orchestrate many agents from one JavaScript script",parameters:cN,executionMode:"sequential",async execute(r,n,o,i,a){let m=n.path?eN(n.path,"utf8"):n.code??"";if(!m.trim())throw new Je("provide code or path");let{meta:c,body:p}=iN(m);if(n.path){let ee=tN(n.path).replace(/\.(js|mjs|cjs|ts)$/,"");if(ee!==c.name)throw new Je(`meta.name "${c.name}" must match the script filename "${ee}"`)}let f=sN(p),d=Date.now(),g=[],y=0,I=0,h=(ee,j)=>({name:c.name,...c.description?{description:c.description}:{},ok:ee,agents:I,outputTokens:y,startedAt:d,phases:c.phases??[],steps:g,...j?{error:j}:{}}),$=(ee,j)=>{a.ui.setStatus(Zp,j?void 0:uw(ee)),i?.({content:[],details:h(!1)})},b=ee=>{I=ee.length,y=ee.reduce((j,lt)=>j+lt.outputTokens,0),g.splice(0,g.length,...ee.map(j=>({label:j.label,phase:j.phase,agent:j.agentType,status:j.status,outputTokens:j.outputTokens,startedAt:j.startedAt,...j.toolCalls!==void 0?{toolCalls:j.toolCalls}:{},...j.model?{model:j.model}:{},...j.endedAt?{endedAt:j.endedAt}:{},...j.detail?{detail:j.detail}:{},...j.tasks?{tasks:j.tasks}:{}}))),$({name:c.name,...c.description?{description:c.description}:{},phases:c.phases??[],steps:g,startedAt:d},!1)},w=mN(VT(a?.model)),S=hw({invoke:n.agent?pN(w,n.agent):w,budgetTotal:n.budget??null,onProgress:b,...o?{signal:o}:{},...t()?.isPaused?{isPaused:t().isPaused}:{}}),z=new AbortController,oe=setTimeout(()=>z.abort(),oN);o&&o.addEventListener("abort",()=>z.abort(),{once:!0}),t()?.onStop?.(()=>z.abort());try{let ee=await Promise.race([f(S.agent,S.parallel,S.pipeline,S.phase,S.log,S.args,S.budget),new Promise((lt,gt)=>z.signal.addEventListener("abort",()=>gt(new Je("workflow timed out or was aborted"))))]),j=Date.now();return a.ui.setStatus(Zp,void 0),{content:[{type:"text",text:`${c.name}: ${I} agent call(s), ${y} output tokens in ${Po(j-d)}
|
|
180
|
+
|
|
181
|
+
${fN(ee)}`}],details:{...h(!0),endedAt:j}}}catch(ee){let j=ee instanceof Error?ee.message:String(ee);return a.ui.setStatus(Zp,void 0),{content:[{type:"text",text:`${c.name} failed after ${I} agent call(s): ${j}`}],details:{...h(!1,j),endedAt:Date.now()},isError:!0}}finally{clearTimeout(oe),t()?.onStop?.(null)}}})}function pN(e,t){return r=>e({...r,agentType:t})}function fN(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}import{createServer as dN}from"node:http";import{WebSocketServer as lN}from"ws";import{randomBytes as gN,timingSafeEqual as yN}from"node:crypto";var xN=9224,hN=3e4,IN=3e4;async function bw(e){let t=e.port??xN,r=e.token??gN(16).toString("hex"),n=e.log??(()=>{}),o=Date.now(),i=null,a=!1,m="",c="",p=[],f=1,d=new Map,g=b=>{let{promise:w,resolve:S,reject:z}=Promise.withResolvers();if(!i||i.readyState!==i.OPEN)return z(new Error("Browser relay extension is not connected. Run /browser-relay install and check the toolbar badge.")),w;let oe=f++,ee=setTimeout(()=>{d.delete(oe),z(new Error(`Browser relay RPC timed out: ${b.op}`))},hN);return d.set(oe,{resolve:S,reject:z,timer:ee}),i.send(JSON.stringify({t:"rpc",id:oe,...b})),w},y=(b,w)=>{let S;try{S=JSON.parse(w)}catch{return}switch(S.t){case"hello":a=!0,m=S.browserVersion,c=S.userAgent,p=S.tabs,n(`extension connected: ${S.tabs.length} tabs`);break;case"tabCreated":p=[...p.filter(z=>z.tabId!==S.tab.tabId),S.tab];break;case"tabUpdated":p=p.map(z=>z.tabId===S.tab.tabId?S.tab:z);break;case"tabRemoved":p=p.filter(z=>z.tabId!==S.tabId);break;case"rpcResult":{let z=d.get(S.id);if(!z)return;d.delete(S.id),clearTimeout(z.timer),S.ok?z.resolve(S.result):z.reject(new Error(S.error||`Browser relay RPC failed: ${S.id}`));break}case"ping":b.send(JSON.stringify({t:"pong"}));break;default:break}},I=dN((b,w)=>{let z=new URL(b.url??"/",`http://127.0.0.1:${t}`).pathname.replace(/\/+$/,"")||"/";if(b.headers.host!==`127.0.0.1:${t}`){w.writeHead(403).end("Forbidden");return}if(b.method!=="GET"){w.writeHead(405).end("Method not allowed");return}if(z==="/json/version"){let oe=i!==null&&i.readyState===i.OPEN,ee={Browser:m||"HowToCode Browser Relay","Protocol-Version":"1.3","User-Agent":c||"HowToCode",webSocketDebuggerUrl:`ws://127.0.0.1:${t}/cdp`,...oe?{}:{error:"relay extension is not connected",extensionSeen:a,uptimeMs:Date.now()-o}};w.writeHead(oe?200:503,{"content-type":"application/json"}).end(JSON.stringify(ee));return}if(z==="/json"||z==="/json/list"){w.writeHead(200,{"content-type":"application/json"}).end(JSON.stringify(p.map(oe=>({id:String(oe.tabId),type:"page",title:oe.title,url:oe.url,webSocketDebuggerUrl:`ws://127.0.0.1:${t}/cdp?tab=${oe.tabId}`}))));return}if(z==="/health"){w.writeHead(200,{"content-type":"application/json"}).end(JSON.stringify({ok:!0,ready:i!==null,tabs:p.length}));return}w.writeHead(404).end("Not found")}),h=new lN({noServer:!0});I.on("upgrade",(b,w,S)=>{let z=new URL(b.url??"/",`http://127.0.0.1:${t}`),oe=z.pathname.replace(/\/+$/,"")||"/";if(b.headers.host!==`127.0.0.1:${t}`){w.write(`HTTP/1.1 403 Forbidden\r
|
|
182
|
+
\r
|
|
183
|
+
`),w.destroy();return}let ee=b.headers.origin;if(oe==="/ext"){if(ee&&!ee.startsWith("chrome-extension://")){w.write(`HTTP/1.1 403 Forbidden\r
|
|
184
|
+
\r
|
|
185
|
+
`),w.destroy();return}let j=Buffer.from(z.searchParams.get("token")??""),lt=Buffer.from(r);if(j.length!==lt.length||!yN(j,lt)){w.write(`HTTP/1.1 401 Unauthorized\r
|
|
186
|
+
\r
|
|
187
|
+
`),w.destroy();return}}else if(oe==="/cdp"){if(ee){w.write(`HTTP/1.1 403 Forbidden\r
|
|
188
|
+
\r
|
|
189
|
+
`),w.destroy();return}}else{w.write(`HTTP/1.1 404 Not Found\r
|
|
190
|
+
\r
|
|
191
|
+
`),w.destroy();return}h.handleUpgrade(b,w,S,j=>{oe==="/ext"&&(i?.close(),i=j,j.on("message",lt=>y(j,lt.toString())),j.on("close",()=>{i===j&&(i=null)}))})}),await new Promise((b,w)=>{I.once("error",w),I.listen(t,"127.0.0.1",()=>{I.off("error",w);let S=I.address();S&&typeof S=="object"&&(t=S.port),b()})});let $=setInterval(()=>{for(let b of h.clients)b.readyState===b.OPEN&&b.ping()},IN);return $.unref?.(),n(`relay listening on 127.0.0.1:${t}`),{port:t,token:r,state:()=>({extensionConnected:i!==null&&i.readyState===i.OPEN,extensionSeen:a,browserVersion:m,userAgent:c,tabs:p,uptimeMs:Date.now()-o,port:t}),rpc:g,ready:()=>i!==null&&i.readyState===i.OPEN,stop:async()=>{clearInterval($);for(let b of d.values())clearTimeout(b.timer),b.reject(new Error("Browser relay stopped"));d.clear();for(let b of h.clients)b.terminate();await new Promise(b=>h.close(()=>b())),await new Promise(b=>I.close(()=>b()))}}}import{existsSync as Rw,readFileSync as Pw}from"node:fs";import{randomBytes as bN}from"node:crypto";import{existsSync as Sw,mkdirSync as kw,readFileSync as ef,renameSync as $N,writeFileSync as EN}from"node:fs";import{dirname as ww,join as Ao}from"node:path";import{fileURLToPath as SN}from"node:url";function $w(e,t,r){let n=r?`void chrome.storage.local.get({ token: "" }).then((stored) => { if (!stored.token) return chrome.storage.local.set({ token: ${JSON.stringify(r)} }); });
|
|
192
|
+
`:"";return`const OMP_INSTALL_VERSION = ${JSON.stringify(t)};
|
|
193
|
+
${n}${e}`}function Ew(e,t){let r=JSON.parse(e);return`${JSON.stringify({...r,name:"HowToCode Browser Relay",description:"Lets HowToCode CLI drive your existing tabs through a local CDP relay.",homepage_url:"https://howtofix.id",version_name:t,action:{default_title:"HowToCode Browser Relay (click for settings)"}},null," ")}
|
|
194
|
+
`}function vm(e){return e.replaceAll("OMP Browser Relay","HowToCode Browser Relay").replaceAll("omp-browser-relay","howtocode-browser-relay").replaceAll("omp-relay-keepalive","howtocode-relay-keepalive")}var kN=Ao(ww(SN(import.meta.url)),"assets");function Fm(e){let t=Ao(e,"browser-relay");return{extensionDir:Ao(t,"extension"),tokenPath:Ao(t,"token")}}function _i(e){return ef(Ao(kN,`${e}.txt`),"utf8")}function Tw(e,t,r){let n=`${e}.${process.pid}.tmp`;EN(n,t,r===void 0?void 0:{mode:r}),$N(n,e)}function Cw(e,t){let{extensionDir:r,tokenPath:n}=Fm(e);kw(r,{recursive:!0,mode:448});let o="";Sw(n)?o=ef(n,"utf8").trim():(o=bN(24).toString("hex"),kw(ww(n),{recursive:!0}),Tw(n,`${o}
|
|
195
|
+
`,384));let i={"manifest.json":Ew(_i("manifest.json"),t),"options.html":vm(_i("options.html")),"options.js":vm(_i("options.js")),LICENSE:_i("LICENSE"),"background.js":vm($w(_i("background.js"),t,o))},a=[];for(let[m,c]of Object.entries(i)){let p=Ao(r,m);(Sw(p)?ef(p,"utf8"):null)!==c&&(Tw(p,c,m==="background.js"?384:void 0),a.push(m))}return{extensionDir:r,tokenPath:n,token:o,wrote:a}}var Bi=null,Ui=null;function Aw(){try{return JSON.parse(Pw(new URL("../../package.json",import.meta.url),"utf8")).version??"0.0.0"}catch{return"0.0.0"}}function uLe(){let e=Cw(Ye,Aw());return{token:e.token,extensionDir:e.extensionDir,tokenPath:e.tokenPath,wrote:e.wrote}}async function cLe(){if(Bi)return Bi;if(Ui)return Ui;Ui=(async()=>{let{tokenPath:e}=Fm(Ye);if(!Rw(e))throw new Error("Browser relay is not installed. Run /browser-relay install and load the extension in Chrome first.");let t=Pw(e,"utf8").trim();if(!t)throw new Error("Browser relay token file is empty. Run /browser-relay install again.");let r=process.env.HOWTOCODE_BROWSER_RELAY_PORT?.trim(),n=r&&/^\d+$/.test(r)?Number(r):void 0,o=await bw({token:t,port:n,productVersion:Aw()});return Bi=o,o})();try{return await Ui}finally{Ui=null}}async function pLe(){let{extensionDir:e,tokenPath:t}=Fm(Ye);return{running:Bi!==null,state:Bi?.state()??null,tokenConfigured:Rw(t),extensionDir:e}}import{execFile as TN,execFileSync as Gi}from"node:child_process";import{promisify as wN}from"node:util";import{createHash as Fw}from"node:crypto";import{copyFileSync as CN,existsSync as Lm,mkdirSync as Dm,readFileSync as nf,readdirSync as RN,rmSync as PN,statSync as tf}from"node:fs";import{dirname as Lw,join as At,resolve as jm}from"node:path";var rf=At(Ye,"rewind"),Ki="refs/howtocode",Ow="refs/howtofix",Mw=100,Dw=30,jw="project.json",Nw="checkpoints.json",vw=!1;function AN(e){let t=jm(e);for(;;){if(Lm(At(t,".git")))return!0;let r=Lw(t);if(r===t)return!1;t=r}}var ON=wN(TN);async function qt(e,t){let r={...process.env};for(let o of["GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_NAMESPACE","GIT_COMMON_DIR"])delete r[o];r.GIT_DIR=e.gitDir,r.GIT_WORK_TREE=e.root,r.GIT_AUTHOR_NAME=r.GIT_COMMITTER_NAME="howtocode",r.GIT_AUTHOR_EMAIL=r.GIT_COMMITTER_EMAIL="howtocode@local";let{stdout:n}=await ON("git",t,{cwd:e.root,env:r,encoding:"utf8",maxBuffer:8*1024*1024});return n.trim()}function MN(e){return Fw("sha1").update(e).digest("hex").slice(0,16)}function vN(e){let t={...process.env,GIT_DIR:e.gitDir,GIT_WORK_TREE:e.root};try{let r=Gi("git",["for-each-ref","--format=%(refname)",`${Ow}/`],{env:t,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();for(let n of r.split(`
|
|
196
|
+
`).filter(Boolean)){let o=`${Ki}/${n.slice(Ow.length+1)}`;try{let i=Gi("git",["rev-parse",n],{env:t,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();Gi("git",["update-ref",o,i],{env:t,stdio:"ignore"}),Gi("git",["update-ref","-d",n],{env:t,stdio:"ignore"})}catch{}}}catch{}}function bLe(e){let t=jm(e).replace(/\/+$/,"")||"/",r=At(rf,MN(t)),n=At(r,"git"),o={root:t,gitDir:n,metaFile:At(r,Nw),disabled:!1};return!Lm(At(n,"HEAD"))&&!AN(t)?(o.disabled=!0,o):(Dm(r,{recursive:!0}),Lm(At(n,"HEAD"))||(Dm(n,{recursive:!0}),Gi("git",["init","--quiet","--initial-branch=howtocode"],{env:{...process.env,GIT_DIR:n},stdio:["ignore","ignore","pipe"]})),FN(t,n),vN(o),LN(r,t),vw||(vw=!0,jN({keep:r})),o)}function FN(e,t){let r=At(e,".git","info","exclude");try{if(!tf(r).isFile())return;Dm(At(t,"info"),{recursive:!0}),CN(r,At(t,"info","exclude"))}catch{}}function LN(e,t){let r=At(e,jw),n=`${JSON.stringify({version:1,root:t})}
|
|
197
|
+
`;try{if(nf(r,"utf8")===n)return}catch{}try{sr(r,n)}catch{}}function Nm(e){try{let t=JSON.parse(nf(e.metaFile,"utf8"));if(t?.version===1&&t.sessions)return t}catch{}return{version:1,sessions:{}}}function of(e,t){Dm(Lw(e.metaFile),{recursive:!0}),sr(e.metaFile,`${JSON.stringify(t,null,1)}
|
|
198
|
+
`)}function DN(e,t){return e.disabled?[]:[...Nm(e).sessions[t]??[]].sort((r,n)=>r.at-n.at)}async function $Le(e,t,r){if(e.disabled)return null;let n;try{await qt(e,["add","-A","--ignore-errors","--"]),n=await qt(e,["write-tree"])}catch{return null}let i=DN(e,t).find(g=>g.tree===n),a=Date.now(),m=`${a.toString(36)}-${Fw("sha1").update(`${n}:${a}`).digest("hex").slice(0,6)}`,c=i?.commit;if(!c){let g=["howtocode checkpoint",`session ${t}`,`created ${new Date(a).toISOString()}`,`prompt ${r.slice(0,200)}`].join(`
|
|
199
|
+
`);c=await qt(e,["commit-tree",n,"-m",g]),await qt(e,["update-ref",`${Ki}/${m}`,c])}let p={id:m,tree:n,commit:c,prompt:r,at:a},f=Nm(e),d=[...f.sessions[t]??[],p];for(let g of d.slice(0,Math.max(0,d.length-Mw)))try{await qt(e,["update-ref","-d",`${Ki}/${g.id}`])}catch{}return f.sessions[t]=d.slice(-Mw),of(e,f),p}async function ELe(e,t){let r=[];if(e.disabled)return{ok:!1,output:"checkpoints are off: this directory is not a git repository",removed:r};try{await qt(e,["read-tree","--reset","-u",t.tree])}catch(n){return{ok:!1,output:n instanceof Error?n.message:String(n),removed:r}}try{let n=await qt(e,["clean","-fd"]);for(let o of n.split(`
|
|
200
|
+
`)){let i=/^Removing\s+(.+)$/.exec(o.trim());i?.[1]&&r.push(i[1])}}catch{}return{ok:!0,output:`restored ${t.prompt||"the checkpoint"}`,removed:r}}async function SLe(e,t){if(e.disabled)return[];try{await qt(e,["add","-A","--ignore-errors","--"]);let r=await qt(e,["write-tree"]);return r===t.tree?[]:(await qt(e,["diff-tree","-r","--name-status","--no-commit-id",t.tree,r])).split(`
|
|
201
|
+
`).filter(Boolean).map(o=>{let[i,...a]=o.split(" ");return`${i?.[0]??"?"} ${a.at(-1)??""}`})}catch{return[]}}async function kLe(e,t={}){let r={droppedSessions:0,droppedRefs:0};if(e.disabled)return r;let n=(t.now??Date.now())-Dw*24*60*60*1e3,o=Nm(e),i=!1;for(let[a,m]of Object.entries(o.sessions))if(!(a===t.keep||m.reduce((p,f)=>Math.max(p,f.at),0)>=n)){delete o.sessions[a],i=!0,r.droppedSessions+=1;for(let p of m)try{await qt(e,["update-ref","-d",`${Ki}/${p.id}`]),r.droppedRefs+=1}catch{}}if(!i)return r;of(e,o);try{await qt(e,["gc","--quiet","--prune=now"])}catch{}return r}function jN(e={}){let t={removedDirs:0,failed:[]},r;try{r=RN(rf,{withFileTypes:!0})}catch{return t}let n=(e.now??Date.now())-Dw*24*60*60*1e3,o=e.keep?jm(e.keep):void 0;for(let i of r){if(!i.isDirectory())continue;let a=At(rf,i.name);if(jm(a)!==o)try{(NN(a)||qN(a)<n)&&(PN(a,{recursive:!0,force:!0}),t.removedDirs+=1)}catch{t.failed.push(i.name)}}return t}function NN(e){try{let t=JSON.parse(nf(At(e,jw),"utf8"));return typeof t?.root!="string"||t.root.length===0?!1:!Lm(t.root)}catch{return!1}}function qN(e){try{return tf(At(e,Nw)).mtimeMs}catch{return tf(e).mtimeMs}}async function TLe(e,t){if(e.disabled)return;let r=Nm(e);for(let n of r.sessions[t]??[])try{await qt(e,["update-ref","-d",`${Ki}/${n.id}`])}catch{}delete r.sessions[t],of(e,r)}export{Eo as a,lm as b,A1 as c,NPe as d,qPe as e,_Pe as f,UPe as g,zPe as h,WPe as i,G1 as j,QPe as k,XPe as l,ZPe as m,pAe as n,fAe as o,dAe as p,lAe as q,gAe as r,tk as s,v as t,ok as u,GOe as v,mk as w,uk as x,VOe as y,yL as z,JOe as A,YOe as B,QOe as C,XOe as D,xL as E,ZOe as F,hL as G,IL as H,eMe as I,aMe as J,mMe as K,uMe as L,cMe as M,pMe as N,fMe as O,ip as P,dMe as Q,lMe as R,gMe as S,yMe as T,$k as U,LL as V,Li as W,_L as X,YL as Y,QL as Z,XL as _,ZL as $,oD as aa,oT as ba,iT as ca,xD as da,Fve as ea,yT as fa,KT as ga,XD as ha,ZD as ia,zT as ja,rj as ka,NFe as la,pn as ma,r1e as na,n1e as oa,Pt as pa,o1e as qa,i1e as ra,s1e as sa,a1e as ta,VT as ua,m1e as va,u1e as wa,c1e as xa,yj as ya,Ej as za,x1e as Aa,h1e as Ba,I1e as Ca,b1e as Da,$1e as Ea,ew as Fa,rw as Ga,Ue as Ha,Aj as Ia,mt as Ja,k1e as Ka,iw as La,Po as Ma,R1e as Na,Yp as Oa,P1e as Pa,H1e as Qa,z1e as Ra,xN as Sa,uLe as Ta,cLe as Ua,pLe as Va,Dw as Wa,bLe as Xa,DN as Ya,$Le as Za,ELe as _a,SLe as $a,kLe as ab,TLe as bb};
|