howtocode 0.7.72 → 0.7.73

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 CHANGED
@@ -155,6 +155,7 @@ nothing to remember.
155
155
  - **Web search and fetch** — `web_search` and `web_fetch` read public http(s) URLs; local, loopback, and RFC1918 addresses are refused before any request is made. Search defaults to DuckDuckGo, with an optional `BRAVE_API_KEY` upgrade.
156
156
  - **Language server queries** — the read-only `lsp` tool asks a language server for definition, references, hover, symbols, or diagnostics. It needs the matching server on PATH (`typescript-language-server` for this repo); a missing binary comes back as a tool result that says so.
157
157
  - **Browser relay** — the `browser` tool drives the Chrome tabs you already have open, so signed-in sessions are reused instead of logging in again in a headless browser. Run `/browser-relay install` once, load the unpacked extension from `~/.howtocode/agent/browser-relay/extension` in `chrome://extensions`, set port `9224`, and paste the token from the file the command names into the extension options. The token is never printed. `/browser-relay status` reports the connection. The relay binds `127.0.0.1` only and requires that token; set `HOWTOCODE_BROWSER_RELAY_PORT` if the default port is taken. Actions: `status`, `tabs`, `open`, `activate`, `navigate`, `evaluate`, `screenshot`, `close`. The tier is `exec` — in `suggest` mode each call asks first. The extension ships under the MIT license; its license text is installed alongside the files.
158
+ - **Discord Rich Presence** — shows the running session on your Discord profile: `HowToCode`, the model, and the project folder. It works with the bundled HowToCode application id; set `HOWTOCODE_DISCORD_CLIENT_ID=<id>` or `"discordClientId": "<id>"` in `~/.howtocode/agent/settings.json` to use your own Discord app, and `HOWTOCODE_DISCORD_DISABLE=1` to turn it off. Discord already shows the application icon, so set that icon to the howtofix.id logo; for a dedicated Rich Presence image, upload an asset under Rich Presence → Art Assets and set `HOWTOCODE_DISCORD_LARGE_IMAGE=<asset-key>`. The IPC client is dependency-free and picks the right socket on Windows (`\\?\\pipe\\discord-ipc-N`), Linux and macOS (`$XDG_RUNTIME_DIR` or `/tmp`); a missing Discord client is a silent no-op.
158
159
  - **Hooks** — `hooks.json` in the config root attaches shell commands to seven lifecycle points (`PreToolUse`, `PostToolUse`, `UserPromptSubmit`, `SessionStart`, `Stop`, `PreCompact`, `SessionEnd`). A hook reads a JSON payload on stdin and decides with its exit code: `0` allows, `2` blocks with its stderr as the reason. A `PreToolUse` hook can also **rewrite** a call's arguments with `updatedInput` — validated against the tool's own schema, so a hook cannot make the agent run something it never asked for. A `PreToolUse` hook outranks the approval mode, so it holds under `full-auto` too. `async` and `once` are supported. See `docs/hooks.md`.
159
160
  - **Sessions** — stored as JSONL under `~/.howtocode/agent/sessions/<project>/`. `-c` continues the latest; `/resume` picks any of them. On startup, transcripts idle for more than 30 days are swept across every project — the session just opened is kept whatever its age — so the store does not grow for the life of the machine (the same window rewind's snapshots use).
160
161
  - **Project notes** — `/init` writes an `AGENTS.md` and asks the agent to fill it in; it is loaded into the system prompt on later runs.
@@ -1 +1 @@
1
- import{b as r}from"./chunk-2YWKLZB6.js";import{j as a}from"./chunk-MVVEYKN6.js";import"./chunk-WOT6VMZA.js";function c(e){return{prompt:s=>e.session.prompt(s),abort:()=>e.session.abort(),subscribe:s=>e.session.subscribe(n=>s(n)),getLastAssistantText:()=>a(e.session.getLastAssistantText()??""),lastStopReason:()=>{let s=e.session.state.messages.at(-1);return s?.role==="assistant"?s.stopReason:void 0},dispose:()=>e.dispose()}}async function g(e,s){let{openSession:n}=await import("./chunk-LVL53DBD.js"),i=t=>n({cwd:t,model:s.model,thinking:s.thinking,continueSession:!1,noSession:!1,sessionPath:void 0,interactive:!1});if(e==="acp"){let{runAcp:t}=await import("./chunk-TOV557ET.js");await t({input:process.stdin,output:process.stdout,version:r,createAgent:async u=>c(await i(u))});return}let{runRpc:p}=await import("./chunk-QOYTPACU.js"),{createJsonEventEncoder:d}=await import("./chunk-MCDEIIEN.js"),o=await i(s.cwd),m=d();await p({input:process.stdin,output:process.stdout,agent:c(o),encodeEvent:t=>m.line(t),state:()=>({sessionId:o.session.sessionId,model:o.modelLabel,cwd:s.cwd})})}export{c as agentFromSession,g as serveProtocol};
1
+ import{b as r}from"./chunk-WDMBTVK7.js";import{j as a}from"./chunk-MVVEYKN6.js";import"./chunk-WOT6VMZA.js";function c(e){return{prompt:s=>e.session.prompt(s),abort:()=>e.session.abort(),subscribe:s=>e.session.subscribe(n=>s(n)),getLastAssistantText:()=>a(e.session.getLastAssistantText()??""),lastStopReason:()=>{let s=e.session.state.messages.at(-1);return s?.role==="assistant"?s.stopReason:void 0},dispose:()=>e.dispose()}}async function g(e,s){let{openSession:n}=await import("./chunk-HMCCBHIZ.js"),i=t=>n({cwd:t,model:s.model,thinking:s.thinking,continueSession:!1,noSession:!1,sessionPath:void 0,interactive:!1});if(e==="acp"){let{runAcp:t}=await import("./chunk-TOV557ET.js");await t({input:process.stdin,output:process.stdout,version:r,createAgent:async u=>c(await i(u))});return}let{runRpc:p}=await import("./chunk-QOYTPACU.js"),{createJsonEventEncoder:d}=await import("./chunk-MCDEIIEN.js"),o=await i(s.cwd),m=d();await p({input:process.stdin,output:process.stdout,agent:c(o),encodeEvent:t=>m.line(t),state:()=>({sessionId:o.session.sessionId,model:o.modelLabel,cwd:s.cwd})})}export{c as agentFromSession,g as serveProtocol};
@@ -1,4 +1,4 @@
1
- import{b as df}from"./chunk-27TRKD65.js";import{t as ff}from"./chunk-ZJL4OEXX.js";import{H as it,K as pf,L as Un,a as Ji}from"./chunk-5FIFNXLT.js";import{a as dr}from"./chunk-UTYFLLSM.js";import{a as Gm,b as Bn,c as Gn,d as Km,e as Hm,f as Do,g as zm,h as Vr,j as jo}from"./chunk-MVVEYKN6.js";import{a as _t}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 z={};_t(z,{Match:()=>_w});function _w(e,t){return t[e.length]?.(...e)??(()=>{throw Error("Invalid Arguments")})()}var qe={};_t(qe,{Get:()=>ns,Reset:()=>DC,Set:()=>jC});var s={};_t(s,{CodePointCount:()=>tC,Counted:()=>mC,Entries:()=>pC,EntriesRegExp:()=>cC,Every:()=>oC,EveryAll:()=>iC,GraphemeCount:()=>eC,HasPropertyKey:()=>uC,IsArray:()=>qo,IsBigInt:()=>No,IsBoolean:()=>If,IsClassInstance:()=>Zw,IsConstructor:()=>Ww,IsDeepEqual:()=>Jm,IsEqual:()=>ee,IsFunction:()=>bf,IsGreaterEqualThan:()=>Ef,IsGreaterThan:()=>Yw,IsInteger:()=>Wm,IsLessEqualThan:()=>$f,IsLessThan:()=>Qw,IsMaxLength:()=>rC,IsMinLength:()=>nC,IsMultipleOf:()=>Xw,IsNull:()=>Zi,IsNumber:()=>es,IsObject:()=>_o,IsObjectNotArray:()=>Vw,IsString:()=>ts,IsSymbol:()=>Jw,IsUndefined:()=>Vm,IsUnsafePropertyKey:()=>kf,IsValueLike:()=>Sf,Keys:()=>Xi,ShiftLeft:()=>rs,Some:()=>sC,SomeAll:()=>aC,Symbols:()=>fC,Values:()=>dC});function Kn(e,t,r){return e>=t&&e<=r}function Uw(e){return e===8205}function lf(e){return Kn(e,127462,127487)}function Bw(e){return Kn(e,65024,65039)}function Gw(e){return Kn(e,768,879)||Kn(e,6832,6911)||Kn(e,7616,7679)||Kn(e,65056,65071)}function Yi(e){return e>65535?2:1}function gf(e,t){for(;t<e.length;){let r=e.codePointAt(t);if(Gw(r)||Bw(r))t+=Yi(r);else break}return t}function Kw(e,t){let r=e.codePointAt(t),n=t+Yi(r);for(n=gf(e,n);n<e.length-1&&Uw(e.codePointAt(n));){let o=e.codePointAt(n+1);n+=1+Yi(o),n=gf(e,n)}return lf(r)&&n<e.length&&lf(e.codePointAt(n))&&(n+=Yi(e.codePointAt(n))),n}function yf(e){let t=0,r=0;for(;r<e.length;)r=Kw(e,r),t++;return t}function Qi(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 xf(e,t){return e.length<=t||e.length<=t<<1&&Qi(e)<=t}function hf(e,t){return e.length>=t<<1||e.length>=t&&Qi(e)>=t}function qo(e){return Array.isArray(e)}function No(e){return ee(typeof e,"bigint")}function If(e){return ee(typeof e,"boolean")}function Ww(e){if(Vm(e)||!bf(e))return!1;let t=Function.prototype.toString.call(e);return!!(/^class\s/.test(t)||/\[native code\]/.test(t))}function bf(e){return ee(typeof e,"function")}function Wm(e){return Number.isInteger(e)}function Zi(e){return ee(e,null)}function es(e){return Number.isFinite(e)}function Vw(e){return _o(e)&&!qo(e)}function _o(e){return ee(typeof e,"object")&&!Zi(e)}function ts(e){return ee(typeof e,"string")}function Jw(e){return ee(typeof e,"symbol")}function Vm(e){return ee(e,void 0)}function ee(e,t){return e===t}function Yw(e,t){return e>t}function Qw(e,t){return e<t}function $f(e,t){return e<=t}function Ef(e,t){return e>=t}function Xw(e,t){if(No(e)||No(t))return BigInt(e)%BigInt(t)===0n;let r=1e-10;if(!es(e)||Wm(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(!_o(e))return!1;let t=globalThis.Object.getPrototypeOf(e);return Zi(t)?!1:ee(typeof t.constructor,"function")&&!(ee(t.constructor,globalThis.Object)||ee(t.constructor.name,"Object"))}function Sf(e){return No(e)||If(e)||Zi(e)||es(e)||ts(e)||Vm(e)}function eC(e){return yf(e)}function tC(e){return Qi(e)}function rC(e,t){return xf(e,t)}function nC(e,t){return hf(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 rs(e,t,r){return ee(e.length,0)?r():t(e[0],e.slice(1))}function kf(e){return ee(e,"__proto__")||ee(e,"constructor")||ee(e,"prototype")}function uC(e,t){return kf(t)?Object.prototype.hasOwnProperty.call(e,t):t in e}function cC(e){return Xi(e).map(t=>[new RegExp(`^${t}$`),e[t]])}function pC(e){return Object.entries(e)}function Xi(e){return Object.getOwnPropertyNames(e)}function fC(e){return Object.getOwnPropertySymbols(e)}function dC(e){return Object.values(e)}function lC(e,t){if(!_o(t))return!1;let r=Xi(e);return ee(r.length,Xi(t).length)&&r.every(n=>Jm(e[n],t[n]))}function gC(e,t){return qo(t)&&ee(e.length,t.length)&&e.every((r,n)=>Jm(e[n],t[n]))}function Jm(e,t){return qo(e)?gC(e,t):_o(e)?lC(e,t):ee(e,t)}var Ke={};_t(Ke,{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 Tf=s;var rr={immutableTypes:!1,maxErrors:8,maxParseErrors:1,maxInstantiationCount:128,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1,unionPrioritySort:!0};function DC(){rr.immutableTypes=!1,rr.maxErrors=8,rr.maxParseErrors=1,rr.maxInstantiationCount=128,rr.useAcceleration=!0,rr.exactOptionalPropertyTypes=!1,rr.enumerableKind=!1,rr.correctiveParse=!1,rr.unionPrioritySort=!0}function jC(e){for(let t of s.Keys(e)){let r=e[t];r!==void 0&&Object.defineProperty(rr,t,{value:r})}}function ns(){return rr}function os(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 kt(e){return s.IsObject(e)&&!s.IsArray(e)}function In(e){return s.IsBoolean(e)}function q(e){return kt(e)||In(e)}function is(e){return s.HasPropertyKey(e,"additionalItems")&&q(e.additionalItems)}function Yt(e){return s.HasPropertyKey(e,"additionalProperties")&&q(e.additionalProperties)}function ss(e){return s.HasPropertyKey(e,"allOf")&&s.IsArray(e.allOf)&&e.allOf.every(t=>q(t))}function wf(e){return s.HasPropertyKey(e,"$anchor")&&s.IsString(e.$anchor)}function as(e){return s.HasPropertyKey(e,"anyOf")&&s.IsArray(e.anyOf)&&e.anyOf.every(t=>q(t))}function Ym(e){return s.HasPropertyKey(e,"const")}function Jr(e){return s.HasPropertyKey(e,"contains")&&q(e.contains)}function Pt(e){return s.HasPropertyKey(e,"default")}function Qm(e){return s.HasPropertyKey(e,"dependencies")&&s.IsObject(e.dependencies)&&Object.values(e.dependencies).every(t=>q(t)||s.IsArray(t)&&t.every(r=>s.IsString(r)))}function Xm(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 ms(e){return s.HasPropertyKey(e,"dependentSchemas")&&s.IsObject(e.dependentSchemas)&&Object.values(e.dependentSchemas).every(t=>q(t))}function Yr(e){return s.HasPropertyKey(e,"$dynamicAnchor")&&s.IsString(e.$dynamicAnchor)}function us(e){return s.HasPropertyKey(e,"$dynamicRef")&&s.IsString(e.$dynamicRef)}function cs(e){return s.HasPropertyKey(e,"else")&&q(e.else)}function Zm(e){return s.HasPropertyKey(e,"enum")&&s.IsArray(e.enum)}function eu(e){return s.HasPropertyKey(e,"exclusiveMaximum")&&(s.IsNumber(e.exclusiveMaximum)||s.IsBigInt(e.exclusiveMaximum))}function vr(e){return s.HasPropertyKey(e,"exclusiveMinimum")&&(s.IsNumber(e.exclusiveMinimum)||s.IsBigInt(e.exclusiveMinimum))}function Uo(e){return s.HasPropertyKey(e,"format")&&s.IsString(e.format)}function It(e){return s.HasPropertyKey(e,"$id")&&s.IsString(e.$id)}function ps(e){return s.HasPropertyKey(e,"if")&&q(e.if)}function bn(e){return s.HasPropertyKey(e,"items")&&(q(e.items)||s.IsArray(e.items)&&e.items.every(t=>q(t)))}function fs(e){return bn(e)&&s.IsArray(e.items)}function tu(e){return s.HasPropertyKey(e,"maximum")&&(s.IsNumber(e.maximum)||s.IsBigInt(e.maximum))}function ru(e){return s.HasPropertyKey(e,"maxContains")&&s.IsNumber(e.maxContains)}function Bo(e){return s.HasPropertyKey(e,"maxItems")&&s.IsNumber(e.maxItems)}function nu(e){return s.HasPropertyKey(e,"maxLength")&&s.IsNumber(e.maxLength)}function ou(e){return s.HasPropertyKey(e,"maxProperties")&&s.IsNumber(e.maxProperties)}function Fr(e){return s.HasPropertyKey(e,"minimum")&&(s.IsNumber(e.minimum)||s.IsBigInt(e.minimum))}function $n(e){return s.HasPropertyKey(e,"minContains")&&s.IsNumber(e.minContains)}function En(e){return s.HasPropertyKey(e,"minItems")&&s.IsNumber(e.minItems)}function Go(e){return s.HasPropertyKey(e,"minLength")&&s.IsNumber(e.minLength)}function Ko(e){return s.HasPropertyKey(e,"minProperties")&&s.IsNumber(e.minProperties)}function iu(e){return s.HasPropertyKey(e,"multipleOf")&&(s.IsNumber(e.multipleOf)||s.IsBigInt(e.multipleOf))}function ds(e){return s.HasPropertyKey(e,"not")&&q(e.not)}function ls(e){return s.HasPropertyKey(e,"oneOf")&&s.IsArray(e.oneOf)&&e.oneOf.every(t=>q(t))}function Ho(e){return s.HasPropertyKey(e,"pattern")&&(s.IsString(e.pattern)||e.pattern instanceof RegExp)}function Hn(e){return s.HasPropertyKey(e,"patternProperties")&&s.IsObject(e.patternProperties)&&Object.values(e.patternProperties).every(t=>q(t))}function Sn(e){return s.HasPropertyKey(e,"prefixItems")&&s.IsArray(e.prefixItems)&&e.prefixItems.every(t=>q(t))}function zn(e){return s.HasPropertyKey(e,"properties")&&s.IsObject(e.properties)&&Object.values(e.properties).every(t=>q(t))}function gs(e){return s.HasPropertyKey(e,"propertyNames")&&(s.IsObject(e.propertyNames)||q(e.propertyNames))}function NC(e){return s.HasPropertyKey(e,"$recursiveAnchor")&&s.IsBoolean(e.$recursiveAnchor)}function zo(e){return NC(e)&&s.IsEqual(e.$recursiveAnchor,!0)}function ys(e){return s.HasPropertyKey(e,"$recursiveRef")&&s.IsString(e.$recursiveRef)}function xs(e){return s.HasPropertyKey(e,"$ref")&&s.IsString(e.$ref)}function kn(e){return s.HasPropertyKey(e,"required")&&s.IsArray(e.required)&&e.required.every(t=>s.IsString(t))}function hs(e){return s.HasPropertyKey(e,"then")&&q(e.then)}function su(e){return s.HasPropertyKey(e,"type")&&(s.IsString(e.type)||s.IsArray(e.type)&&e.type.every(t=>s.IsString(t)))}function Qr(e){return s.HasPropertyKey(e,"uniqueItems")&&s.IsBoolean(e.uniqueItems)}function Wo(e){return s.HasPropertyKey(e,"unevaluatedItems")&&q(e.unevaluatedItems)}function Vo(e){return s.HasPropertyKey(e,"unevaluatedProperties")&&q(e.unevaluatedProperties)}var bt=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}},ut=class extends bt{constructor(){super(),this.errors=[]}AtCapacity(){return this.errors.length>=qe.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 Cf(e,t,r,n){return s.Every(r["~refine"],0,(o,i)=>o.check(n))}function Rf(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 Jo="urn:typebox:root";function Lr(e,t){return URL.canParse(e,t)?new URL(e,t):s.IsEqual(t,Jo)?new URL(`${t}:${e}`):new URL(`${t.slice(0,t.lastIndexOf(":"))}:${e}`)}function Vn(e,t){let r=kt(t)&&It(t)?Lr(t.$id,Jo).href:Jo;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 au(e,t,r=!0){if(In(t))return e;if(Array.isArray(t))return t.reduce((o,i)=>au(o,i,!1),e);if(!kt(t)||!r&&It(t))return e;let n=!r&&Yr(t)?[...e,t]:e;return Object.keys(t).reduce((o,i)=>au(o,t[i],!1),n)}function Yo(e,t){return e.resourceEntries.get(t)}function Pf(e,t){return e.enteredResource||Yo(e,t)!==void 0}function qC(e){return!/^[A-Za-z][A-Za-z0-9+.-]*:/.test(e.$id)}function _C(e,t){return It(t)?[...e.ids,t]:e.ids}function UC(e,t){return e.recursiveAnchor??(zo(t)?t:void 0)}function BC(e,t){let r=It(t)?au(e.dynamicAnchors,t):e.dynamicAnchors;return Yr(t)?[...r,t]:r}function GC(e,t){return It(t)?!1:e.pendingResource}function Af(e,t){let r=Yo(e,t);return r?r.base:It(t)?Lr(t.$id,e.lexicalBase).href:e.lexicalBase}function Of(e,t){let r=Yo(e,t);return r?r.base:It(t)&&e.pendingResource?Lr(t.$id,e.resourceBase).href:e.resourceBase}function Mf(e,t){return It(t)?!qC(t):e.useResourceBaseForReference}function KC(e,t){let r=Pf(e,t),n=Mf(e,t);return r||n?Of(e,t):Af(e,t)}function HC(e,t){let r=Yo(e,t);return r?r.root:It(t)?t:e.lexicalSchema}function zC(e,t){return kt(t)&&(It(t)||Yr(t)||s.IsUndefined(e.recursiveAnchor)&&zo(t)||!s.IsUndefined(Yo(e,t)))}function Jn(e,t){return zC(e,t)?{...e,ids:_C(e,t),dynamicAnchors:BC(e,t),recursiveAnchor:UC(e,t),pendingResource:GC(e,t),lexicalBase:Af(e,t),resourceBase:Of(e,t),useResourceBaseForReference:Mf(e,t),referenceBase:KC(e,t),lexicalSchema:HC(e,t),enteredResource:Pf(e,t)}:e}function vf(e){return bn(e)&&s.IsArray(e.items)}function Ff(e,t,r,n){return vf(r)?s.Every(n,0,(i,a)=>s.IsLessThan(a,r.items.length)||Ut(e,t,r.additionalItems,i)&&t.AddIndex(a)):!0}function Lf(e,t,r,n,o,i){return vf(o)?s.Every(i,0,(m,c)=>{let p=`${r}/additionalItems`,f=`${n}/${c}`;return s.IsLessThan(c,o.items.length)||Bt(e,t,p,f,o.additionalItems,m)&&t.AddIndex(c)}):!0}function At(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Xr(e){return new RegExp(e,"u")}function WC(e){return`^${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}$`}function Df(e){let t=[];return Hn(e)&&t.push(...s.Keys(e.patternProperties)),zn(e)&&t.push(...s.Keys(e.properties).map(WC)),s.IsEqual(t.length,0)?"(?!)":`(${t.join("|")})`}function jf(e,t,r,n){let o=Xr(Df(r));return s.Every(s.Keys(n),0,(a,m)=>o.test(a)||Ut(e,t,r.additionalProperties,n[a])&&t.AddKey(a))}function Nf(e,t,r,n,o,i){let a=Xr(Df(o)),m=[];return s.EveryAll(s.Keys(i),0,(p,f)=>{let d=`${r}/additionalProperties`,g=`${n}/${At(p)}`,y=a.test(p)||Bt(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 qf(e,t,r,n){let o=r.allOf.reduce((i,a)=>{let m=new bt;return te(e,m,a,n)?[...i,m]:i},[]);return s.IsEqual(o.length,r.allOf.length)&&t.Merge(o)}function _f(e,t,r,n,o,i){let a=[],m=o.allOf.reduce((p,f,d)=>{let g=`${r}/allOf/${d}`,y=new ut,I=ge(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 Uf(e,t,r,n){let o=r.anyOf.reduce((i,a)=>{let m=new bt;return te(e,m,a,n)?[...i,m]:i},[]);return s.IsGreaterThan(o.length,0)&&t.Merge(o)}function Bf(e,t,r,n,o,i){let a=[],m=o.anyOf.reduce((p,f,d)=>{let g=new ut,y=`${r}/anyOf/${d}`,I=ge(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 cu(e,t,r,n){return r}function Gf(e,t,r,n,o,i){return cu(e,t,o,i)||t.AddError("boolean",r,n,{})}function pu(e,t,r,n){return s.IsValueLike(r.const)?s.IsEqual(n,r.const):s.IsDeepEqual(n,r.const)}function Kf(e,t,r,n,o,i){return pu(e,t,o,i)||t.AddError("const",r,n,{allowedValue:o.const})}function VC(e){return!($n(e)&&s.IsEqual(e.minContains,0))}function fu(e,t,r,n){return VC(r)?!s.IsEqual(n.length,0)&&s.SomeAll(n,(o,i)=>te(e,t,r.contains,o)&&t.AddIndex(i)):!0}function Hf(e,t,r,n,o,i){return fu(e,t,o,i)||t.AddError("contains",r,n,{minContains:1})}function zf(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)):te(e,t,m,n)));return o||i}function Wf(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/${At(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})):ge(e,t,f,n,p,i))});return a||m}function Vf(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 Jf(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 Yf(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)||te(e,t,m,n));return o||i}function Qf(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/${At(c)}`;return!s.HasPropertyKey(i,c)||ge(e,t,f,n,p,i)});return a||m}var Qt={};_t(Qt,{DynamicRef:()=>TR,RecursiveRef:()=>ER,Ref:()=>bR});var gr={};_t(gr,{Delete:()=>XC,Get:()=>YC,Has:()=>JC,Indices:()=>Xo,Set:()=>QC});function Zf(e){throw Error(e)}function Xf(){Zf("Pointer contains unsafe property key")}function du(){Zf("Cannot set value")}function Xo(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 Xo(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 Xo(t)){if(!s.IsObject(r)||s.IsUnsafePropertyKey(n))return;r=r[n]}return r}function ed(e,t,r){let n=e;for(let o of t)s.IsUnsafePropertyKey(o)&&Xf(),n=s.IsObject(n)?n[o]:void 0;return s.IsUnsafePropertyKey(r)&&Xf(),s.IsObject(n)||du(),n}function QC(e,t,r){let n=Xo(t),o=n.pop();return s.IsUndefined(o)&&du(),ed(e,n,o)[o]=r,e}function XC(e,t){let r=Xo(t),n=r.pop();s.IsUndefined(n)&&du();let o=ed(e,r,n);return s.IsArray(o)&&/^(0|[1-9]\d*)$/.test(n)?o.splice(Number(n),1):delete o[n],e}function yu(e,t){return kt(e)&&It(e)?Lr(e.$id,t.href):t}function xu(e){return Lr(e,Jo)}function lu(e){return e.href.split("#")[0]}function ZC(e,t,r){return gu(e,xu(t),r)}function eR(e,t){return t.$ref.startsWith("#")||e.enteredResource?e.lexicalSchema:e.schema}function tR(e){return e.startsWith("#/")}function td(e,t){if(s.IsObject(e)&&Yr(e)&&s.IsEqual(e.$dynamicAnchor,t))return e;if(s.IsObject(e))for(let r of s.Keys(e)){let n=td(e[r],t);if(n)return n}}function gu(e,t,r){if(s.IsEqual(e,r))return t.href;let n=yu(e,t);if(s.IsArray(e))for(let o of e){let i=gu(o,n,r);if(!s.IsUndefined(i))return i}else if(s.IsObject(e))for(let o of s.Keys(e)){let i=gu(e[o],n,r);if(!s.IsUndefined(i))return i}}function rd(e,t){if(t.href.endsWith("#"))return e;if(!t.hash.startsWith("#"))return;let r=decodeURIComponent(t.hash.slice(1));if(r.startsWith("/"))return gr.Get(e,r)}function rR(e,t,r){if(!It(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("#")?rd(e,r):e}function nR(e,t,r){if(!wf(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(!Yr(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(kt(e))return rR(e,t,r)??nR(e,t,r)??oR(e,t,r)??rd(e,r)}function sR(e,t,r){if(s.IsArray(e))return e.reduce((n,o)=>{let i=Is(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=Is(e[o],t,r);return s.IsUndefined(i)?n:i},void 0)}function Is(e,t,r){let n=yu(e,t);return iR(e,n,r)??sR(e,n,r)??aR(e,n,r)}function mR(e,t,r,n){let o=bs(e,t,r,n);return kt(o)&&It(o)?o:void 0}function uR(e,t,r){if(!t.$ref.startsWith("#")||!kt(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(kt(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(It(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 Is(e,t,r)}function gR(e,t,r){let n=lu(r);if(!s.HasPropertyKey(e,n)||s.IsEqual(n,lu(t)))return;let o=e[n],i=yu(o,new URL(n));return s.IsEqual(r.hash,"")?o:Is(o,i,r)}function bs(e,t,r,n){let o=xu(r),i=Lr(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?Jn(e,t.resource):e}function nd(e,t,r,n){let o=yR({...e,pendingResource:t},r);return xR(o,n)}function hR(e,t,r){let n=lu(Lr(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:nd(e,!0,i,a)}}function IR(e,t){return{schema:t,stack:nd(e,!s.IsUndefined(t))}}function bR(e,t){let r=bs(e.context,eR(e,t),e.referenceBase,t.$ref);return kt(r)?hR(e,t,r):IR(e,r)}function $R(e){return kt(e.lexicalSchema)&&zo(e.lexicalSchema)}function ER(e,t){let r=$R(e)?e.recursiveAnchor:e.lexicalSchema;return bs(e.context,r,e.lexicalBase,t.$recursiveRef)}function od(e,t){return Lr(t.$dynamicRef,xu(e.lexicalBase).href).hash}function id(e,t){return e.dynamicAnchors.find(r=>s.IsEqual(r.$dynamicAnchor,t))??td(e.schema,t)}function SR(e,t,r){if(!kt(r)||!Yr(r))return r;let n=od(e,t);return tR(n)?r:id(e,r.$dynamicAnchor)}function kR(e,t){let r=od(e,t);return id(e,decodeURIComponent(r.slice(1)))}function TR(e,t){let r=t.$dynamicRef.startsWith("#")?e.lexicalSchema:e.schema,n=bs(e.context,r,e.lexicalBase,t.$dynamicRef);return s.IsUndefined(n)?kR(e,t):SR(e,t,n)}function sd(e,t,r,n){let o=Qt.DynamicRef(e,r)??!1,i=o?{...e,pendingResource:!0}:e;return q(o)&&te(i,t,o,n)}function ad(e,t,r,n,o,i){let a=Qt.DynamicRef(e,o)??!1,m=a?{...e,pendingResource:!0}:e;return q(a)&&ge(m,t,r,n,a,i)}function bu(e,t,r,n){return s.Some(r.enum,o=>s.IsValueLike(o)?s.IsEqual(n,o):s.IsDeepEqual(n,o))}function md(e,t,r,n,o,i){return bu(e,t,o,i)||t.AddError("enum",r,n,{allowedValues:o.enum})}function $u(e,t,r,n){return s.IsLessThan(n,r.exclusiveMaximum)}function ud(e,t,r,n,o,i){return $u(e,t,o,i)||t.AddError("exclusiveMaximum",r,n,{comparison:"<",limit:o.exclusiveMaximum})}function Eu(e,t,r,n){return s.IsGreaterThan(n,r.exclusiveMinimum)}function cd(e,t,r,n,o,i){return Eu(e,t,o,i)||t.AddError("exclusiveMinimum",r,n,{comparison:">",limit:o.exclusiveMinimum})}var ri={};_t(ri,{Clear:()=>jd,Entries:()=>l0,Get:()=>x0,Has:()=>y0,IsDate:()=>Qn,IsDateTime:()=>$s,IsDuration:()=>Es,IsEmail:()=>Ss,IsHostname:()=>Os,IsIPv4:()=>Fs,IsIPv6:()=>Ls,IsIdnEmail:()=>Ms,IsIdnHostname:()=>vs,IsIri:()=>js,IsIriReference:()=>Ds,IsJsonPointer:()=>qs,IsJsonPointerUriFragment:()=>Ns,IsRegex:()=>_s,IsRelativeJsonPointer:()=>Us,IsTime:()=>Xn,IsUri:()=>Ks,IsUriReference:()=>Bs,IsUriTemplate:()=>Gs,IsUrl:()=>Hs,IsUuid:()=>zs,Reset:()=>Nd,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 Qn(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 Xn(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 $s(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&&Qn(n[0])&&Xn(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 Es(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 Ss(e){return MR.test(e)}var pd=/^(?!-).*(?<!-)$/,fd=/^(?!..--)/,dd=/^[a-zA-Z0-9-]*$/,pG=new RegExp("^\\p{ASCII}*$","u"),Zn=/[^\p{ASCII}]/u;var vR=/[0-9]/,ld=/[\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,Su=new RegExp("\\p{Mn}","u"),jR=new RegExp("\\p{Mc}","u"),fG=new RegExp("\\p{Me}","u"),gd=/[\p{Mn}\p{Mc}\p{Me}]/u,ku=new RegExp("\\p{L}","u"),NR=new RegExp("\\p{Nd}","u"),yd=new RegExp("\\p{Script=Greek}","u"),ks=new RegExp("\\p{Script=Hebrew}","u"),xd=/[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u,hd=/[\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Mandaic}]/u,Tu=/[\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,Id=/[\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,bd=new RegExp([vR,FR].map(e=>e.source).join("|"),"u"),$d=new RegExp([ku,DR,LR,NR,Su,jR,qR,_R].map(e=>e.source).join("|"),"u");function Ed(e){return pd.test(e)&&fd.test(e)&&dd.test(e)}var or=36,ei=1,ti=26,BR=38,GR=700,kd=72,Td=128;function wu(){throw null}function Ts(e){return e.toLowerCase().startsWith("xn--")}function wd(e,t,r){e=r?Math.floor(e/GR):e>>1,e+=Math.floor(e/t);let n=0;for(;e>(or-ei)*ti>>1;)e=Math.floor(e/(or-ei)),n+=or;return n+Math.floor((or-ei+1)*e/(e+BR))}function ws(e){let t=[],r=Td,n=0,o=kd,i=e.lastIndexOf("-");if(i>0)for(let m=0;m<i;m++){let c=e.charCodeAt(m);c>=128&&wu(),t.push(c)}let a=i<0?0:i+1;for(;a<e.length;){let m=n,c=1,p=or;for(;;){a>=e.length&&wu();let d=e.charCodeAt(a++),g;d>=97&&d<=122?g=d-97:d>=48&&d<=57?g=d-48+26:wu(),n+=g*c;let y=p<=o?ei:p>=o+ti?ti:p-o;if(g<y)break;c*=or-y,p+=or}let f=t.length+1;o=wd(n-m,f,m===0),r+=Math.floor(n/f),n%=f,t.splice(n,0,r),n++}return String.fromCodePoint(...t)}function Sd(e){return e<26?String.fromCharCode(e+97):String.fromCharCode(e-26+48)}var KR=new RegExp(Zn.source,"gu");function Cd(e){let t=e.replace(KR,""),r=t.length,n=r>0?[t,"-"]:[],o=Array.from(e,p=>p.codePointAt(0)),i=Td,a=0,m=kd,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=or;;g+=or){let y=g<=m?ei:g>=m+ti?ti:g-m;if(d<y)break;let I=y+(d-y)%(or-y);n.push(Sd(I)),d=Math.floor((d-y)/(or-y))}n.push(Sd(d)),m=wd(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)$/,Rd=/^(?:L|EN|ES|CS|ET|ON|BN|NSM)$/,zR=/^(?:R|AL|AN)$/;function Pd(e){if(Ts(e))try{return Cs(ws(e.slice(4).toLowerCase()))}catch{return!1}return Cs(e)}function Ad(e){let t=String.fromCodePoint(e);return bd.test(t)?"EN":ld.test(t)?"AN":Su.test(t)?"NSM":ks.test(t)?"R":hd.test(t)?"AL":ku.test(t)?"L":"ON"}function Cs(e){for(let t of e)if(zR.test(Ad(t.codePointAt(0))))return!0;return!1}function Rs(e){let t=!1,r=Rd,n=!1,o=!1,i=!0;for(let a of e){let m=Ad(a.codePointAt(0));if(i){if(m!=="L"&&m!=="R"&&m!=="AL")return!1;t=m==="R"||m==="AL",r=t?HR:Rd,i=!1}if(!r.test(m))return!1;m==="EN"?n=!0:m==="AN"&&(o=!0)}return!(t&&n&&o)}function WR(e){return Zn.test(e)&&Cd(e).length+4>63}function VR(e){return e[0]==="-"||e[e.length-1]==="-"?!0:e.slice(2).join("").startsWith("--")}function Ps(e){if(WR(e)||Cs(e)&&!Rs(e))return!1;let t=[...e],r=t.map(i=>i.codePointAt(0)),n=r.length;if(VR(t)||gd.test(t[0]))return!1;let o=!1;for(let i=0;i<n;i++){let a=r[i],m=t[i];if(Id.test(m)||!$d.test(m))return!1;xd.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||!yd.test(t[i+1]))return!1;break;case 1523:case 1524:if(!c||!ks.test(t[i-1]))return!1;break;case 8204:if(!c||c<128&&!Tu.test(t[i-1]))return!1;break;case 8205:if(!c||!Tu.test(t[i-1]))return!1;break;case 12539:break}}return!(e.includes("\u30FB")&&!o)}function As(e){if(!Ts(e))return!1;try{let t=e.slice(4).toLowerCase();if(t.lastIndexOf("-")===0)return!1;let r=ws(t);return Zn.test(r)?Ps(r):!1}catch{return!1}}function JR(e){return e.length>0&&e.length<=63}function YR(e){return JR(e)&&(As(e)||Ed(e))}function Fd(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)&&(As(e)||Ps(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 Ld(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=>Pd(o));return r.every(o=>XR(o)&&(!n||Rs(o)))}function Os(e){return Fd(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 Ms(e){return e0.test(e.normalize("NFC"))}function vs(e){return Ld(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 Fs(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 Ls(e){return r0.test(e)}var n0=/[\x00-\x20\x7F\\]|%(?![0-9a-fA-F]{2})/,o0=/^[a-zA-Z][a-zA-Z0-9+\-.]*\/\//;function Ds(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 js(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 Ns(e){return a0.test(e)}var m0=/^(?:\/(?:[^~/]|~0|~1)*)*$/;function qs(e){return m0.test(e)}function _s(e){try{return new RegExp(e,"u"),!0}catch{return!1}}var u0=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;function Us(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 Bs(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 Gs(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 Ks(e){return f0.test(e)}function Hs(e){return URL.canParse(e)}var d0=/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;function zs(e){return d0.test(e)}var be=new Map;function jd(){be.clear()}function l0(){return[...be.entries()]}function g0(e,t){be.set(e,t)}function y0(e){return be.has(e)}function x0(e){return be.get(e)}function h0(e,t){return be.get(e)?.(t)??!0}function Nd(){jd(),be.set("date-time",$s),be.set("date",Qn),be.set("duration",Es),be.set("email",Ss),be.set("hostname",Os),be.set("idn-email",Ms),be.set("idn-hostname",vs),be.set("ipv4",Fs),be.set("ipv6",Ls),be.set("iri-reference",Ds),be.set("iri",js),be.set("json-pointer-uri-fragment",Ns),be.set("json-pointer",qs),be.set("regex",_s),be.set("relative-json-pointer",Us),be.set("time",Xn),be.set("uri-reference",Bs),be.set("uri-template",Gs),be.set("uri",Ks),be.set("url",Hs),be.set("uuid",zs)}Nd();function Ru(e,t,r,n){return ri.Test(r.format,n)}function qd(e,t,r,n,o,i){return Ru(e,t,o,i)||t.AddError("format",r,n,{format:o.format})}function _d(e,t,r,n){let o=hs(r)?r.then:!0,i=cs(r)?r.else:!0;return te(e,t,r.if,n)?te(e,t,o,n):te(e,t,i,n)}function Ud(e,t,r,n,o,i){let a=hs(o)?o.then:!0,m=cs(o)?o.else:!0,c=new ut,p=ge(e,c,`${r}/if`,n,o.if,i)?ge(e,c,`${r}/then`,n,a,i)||t.AddError("if",r,n,{failingKeyword:"then"}):ge(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)||Ut(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)||Bt(e,t,c,p,a,i[m])&&t.AddIndex(m)})}function $0(e,t,r,n){let o=Sn(r)?r.prefixItems.length:0;return s.Every(n,o,(i,a)=>Ut(e,t,r.items,i)&&t.AddIndex(a))}function E0(e,t,r,n,o,i){let a=Sn(o)?o.prefixItems.length:0;return s.EveryAll(i,a,(m,c)=>{let p=`${r}/items`,f=`${n}/${c}`;return Bt(e,t,p,f,o.items,m)&&t.AddIndex(c)})}function Bd(e,t,r,n){return fs(r)?I0(e,t,r,n):$0(e,t,r,n)}function Gd(e,t,r,n,o,i){return fs(o)?b0(e,t,r,n,o,i):E0(e,t,r,n,o,i)}function S0(e){return Jr(e)}function Pu(e,t,r,n){if(!S0(r))return!0;let o=s.Counted(n,i=>te(e,t,r.contains,i));return s.IsLessEqualThan(o,r.maxContains)}function Kd(e,t,r,n,o,i){let a=$n(o)?o.minContains:1;return Pu(e,t,o,i)||t.AddError("contains",r,n,{minContains:a,maxContains:o.maxContains})}function Au(e,t,r,n){return s.IsLessEqualThan(n,r.maximum)}function Hd(e,t,r,n,o,i){return Au(e,t,o,i)||t.AddError("maximum",r,n,{comparison:"<=",limit:o.maximum})}function Ou(e,t,r,n){return s.IsLessEqualThan(n.length,r.maxItems)}function zd(e,t,r,n,o,i){return Ou(e,t,o,i)||t.AddError("maxItems",r,n,{limit:o.maxItems})}function Mu(e,t,r,n){return s.IsMaxLength(n,r.maxLength)}function Wd(e,t,r,n,o,i){return Mu(e,t,o,i)||t.AddError("maxLength",r,n,{limit:o.maxLength})}function vu(e,t,r,n){return s.IsLessEqualThan(s.Keys(n).length,r.maxProperties)}function Vd(e,t,r,n,o,i){return vu(e,t,o,i)||t.AddError("maxProperties",r,n,{limit:o.maxProperties})}function k0(e){return Jr(e)}function Fu(e,t,r,n){if(!k0(r))return!0;let o=s.Counted(n,(i,a)=>te(e,t,r.contains,i)&&t.AddIndex(a));return s.IsGreaterEqualThan(o,r.minContains)}function Jd(e,t,r,n,o,i){return Fu(e,t,o,i)||t.AddError("contains",r,n,{minContains:o.minContains})}function Lu(e,t,r,n){return s.IsGreaterEqualThan(n,r.minimum)}function Yd(e,t,r,n,o,i){return Lu(e,t,o,i)||t.AddError("minimum",r,n,{comparison:">=",limit:o.minimum})}function Du(e,t,r,n){return s.IsGreaterEqualThan(n.length,r.minItems)}function Qd(e,t,r,n,o,i){return Du(e,t,o,i)||t.AddError("minItems",r,n,{limit:o.minItems})}function ju(e,t,r,n){return s.IsMinLength(n,r.minLength)}function Xd(e,t,r,n,o,i){return ju(e,t,o,i)||t.AddError("minLength",r,n,{limit:o.minLength})}function Nu(e,t,r,n){return s.IsGreaterEqualThan(s.Keys(n).length,r.minProperties)}function Zd(e,t,r,n,o,i){return Nu(e,t,o,i)||t.AddError("minProperties",r,n,{limit:o.minProperties})}function qu(e,t,r,n){return s.IsMultipleOf(n,r.multipleOf)}function el(e,t,r,n,o,i){return qu(e,t,o,i)||t.AddError("multipleOf",r,n,{multipleOf:o.multipleOf})}function _u(e,t,r,n){let o=new bt;return!te(e,o,r.not,n)&&t.Merge([o])}function tl(e,t,r,n,o,i){return _u(e,t,o,i)||t.AddError("not",r,n,{})}function rl(e,t,r,n){let o=r.oneOf.reduce((i,a)=>{let m=new bt;return te(e,m,a,n)?[...i,m]:i},[]);return s.IsEqual(o.length,1)&&t.Merge(o)}function nl(e,t,r,n,o,i){let a=[],m=[],c=o.oneOf.reduce((f,d,g)=>{let y=new ut,I=`${r}/oneOf/${g}`,h=ge(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 Uu(e,t,r,n){return(s.IsString(r.pattern)?Xr(r.pattern):r.pattern).test(n)}function ol(e,t,r,n,o,i){return Uu(e,t,o,i)||t.AddError("pattern",r,n,{pattern:o.pattern})}function il(e,t,r,n){return s.Every(s.Entries(r.patternProperties),0,([o,i])=>{let a=Xr(o);return s.Every(s.Entries(n),0,([m,c])=>!a.test(m)||Ut(e,t,i,c)&&t.AddKey(m))})}function sl(e,t,r,n,o,i){return s.EveryAll(s.Entries(o.patternProperties),0,([a,m])=>{let c=`${r}/patternProperties/${At(a)}`,p=Xr(a);return s.EveryAll(s.Entries(i),0,([f,d])=>{let g=`${n}/${At(f)}`;return!p.test(f)||Bt(e,t,c,g,m,d)&&t.AddKey(f)})})}function al(e,t,r,n){return s.IsEqual(n.length,0)||s.Every(r.prefixItems,0,(o,i)=>s.IsLessEqualThan(n.length,i)||Ut(e,t,o,n[i])&&t.AddIndex(i))}function ml(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)||Bt(e,t,c,p,a,i[m])&&t.AddIndex(m)})}function Bu(e,t){return e.includes(t)||qe.Get().exactOptionalPropertyTypes}function Gu(e,t){return s.IsUndefined(e[t])}function ul(e,t,r,n){let o=kn(r)?r.required:[];return s.Every(s.Entries(r.properties),0,([a,m])=>{let c=!s.HasPropertyKey(n,a)||Ut(e,t,m,n[a])&&t.AddKey(a);return Bu(o,a)?c:Gu(n,a)||c})}function cl(e,t,r,n,o,i){let a=kn(o)?o.required:[];return s.EveryAll(s.Entries(o.properties),0,([c,p])=>{let f=`${r}/properties/${At(c)}`,d=`${n}/${At(c)}`,g=()=>!s.HasPropertyKey(i,c)||Bt(e,t,f,d,p,i[c])&&t.AddKey(c);return Bu(a,c)?g():Gu(i,c)||g()})}function pl(e,t,r,n){return s.Every(s.Keys(n),0,(o,i)=>te(e,t,r.propertyNames,o))}function fl(e,t,r,n,o,i){let a=[];return s.EveryAll(s.Keys(i),0,(c,p)=>{let f=`${n}/${At(c)}`,d=`${r}/propertyNames`,g=ge(e,t,d,f,o.propertyNames,c);return g||a.push(c),g})||t.AddError("propertyNames",r,n,{propertyNames:a})}function dl(e,t,r,n){let o=Qt.RecursiveRef(e,r)??!1,i=o?{...e,pendingResource:!0}:e;return q(o)&&te(i,t,o,n)}function ll(e,t,r,n,o,i){let a=Qt.RecursiveRef(e,o)??!1,m=a?{...e,pendingResource:!0}:e;return q(a)&&ge(m,t,r,n,a,i)}function gl(e,t,r,n){let o=Qt.Ref(e,r),i=o.schema??!1,a=new bt,m=q(i)&&te(o.stack,a,i,n);return m&&t.Merge([a]),m}function yl(e,t,r,n,o,i){let a=Qt.Ref(e,o),m=a.schema??!1,c=new ut,p=q(m)&&ge(a.stack,c,r,n,m,i);return p&&t.Merge([c]),p||t.AddErrors(c.GetErrors()),p}function xl(e,t,r,n){return s.Every(r.required,0,o=>s.HasPropertyKey(n,o))}function hl(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 Ku(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 Il(e,t,r,n,o){return s.Some(r,i=>Ku(e,t,i,n,o))}function bl(e,t,r,n){return s.IsArray(r.type)?Il(e,t,r.type,r,n):Ku(e,t,r.type,r,n)}function $l(e,t,r,n,o,i){return(s.IsArray(o.type)?Il(e,t,o.type,o,i):Ku(e,t,o.type,o,i))||t.AddError("type",r,n,{type:o.type})}function El(e,t,r,n){let o=t.GetIndices();return s.Every(n,0,(i,a)=>(o.has(a)||te(e,t,r.unevaluatedItems,i))&&t.AddIndex(a))}function Sl(e,t,r,n,o,i){let a=t.GetIndices(),m=[];return s.EveryAll(i,0,(p,f)=>{let d=new ut,g=(a.has(f)||ge(e,d,r,n,o.unevaluatedItems,p))&&t.AddIndex(f);return g||m.push(f),g})||t.AddError("unevaluatedItems",r,n,{unevaluatedItems:m})}function kl(e,t,r,n){let o=t.GetKeys();return s.Every(s.Entries(n),0,([i,a])=>o.has(i)||te(e,t,r.unevaluatedProperties,a)&&t.AddKey(i))}function Tl(e,t,r,n,o,i){let a=t.GetKeys(),m=[];return s.EveryAll(s.Entries(i),0,([p,f])=>{let d=new ut,g=a.has(p)||ge(e,d,r,n,o.unevaluatedProperties,f)&&t.AddKey(p);return g||m.push(p),g})||t.AddError("unevaluatedProperties",r,n,{unevaluatedProperties:m})}var Dr={};_t(Dr,{Hash:()=>Ol,HashCode:()=>q0});function Re(){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 Mt={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},Vs=8997,ni=33826,Js=40164,Ys=52210,Rl=new Float64Array(1),Pl=new DataView(Rl.buffer),Al=new Uint8Array(Rl.buffer);function Qe(e){let t=Vs^e,r=t*435,n=ni*435+(r>>>16),o=Js*435+(n>>>16)+(t<<8),i=Ys*435+(o>>>16)+(ni<<8);Vs=r&65535,ni=n&65535,Js=o&65535,Ys=i&65535}function C0(e){Qe(Mt.Array);for(let t of e)Zr(t)}function R0(e){Qe(Mt.BigInt),Pl.setBigInt64(0,e);for(let t of Al)Qe(t)}function wl(e){Qe(Mt.Boolean),Qe(e?1:0)}function P0(e){Qe(Mt.Constructor),Zr(e.toString())}function A0(e){Qe(Mt.Date),Zr(e.getTime())}function O0(e){Qe(Mt.Function),Zr(e.toString())}function M0(e){Qe(Mt.Null)}function Cl(e){Qe(Mt.Number),Pl.setFloat64(0,e,!0);for(let t of Al)Qe(t)}function v0(e){Qe(Mt.Object);for(let t of T0(e).sort())Zr(t),Zr(e[t])}function F0(e){Qe(Mt.RegExp),Hu(e.toString())}var L0=new TextEncoder;function Hu(e){Qe(Mt.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)))Qe(n);return}Qe(r)}}function D0(e){Qe(Mt.Symbol),Zr(e.toString())}function j0(e){Qe(Mt.TypeArray);let t=new Uint8Array(e.buffer);for(let r=0;r<t.length;r++)Qe(t[r])}function N0(e){return Qe(Mt.Undefined)}function Zr(e){return Ke.IsTypeArray(e)?j0(e):Ke.IsDate(e)?A0(e):Ke.IsRegExp(e)?F0(e):Ke.IsBoolean(e)?wl(e.valueOf()):Ke.IsString(e)?Hu(e.valueOf()):Ke.IsNumber(e)?Cl(e.valueOf()):w0(e)?Cl(e):s.IsArray(e)?C0(e):s.IsBoolean(e)?wl(e):s.IsBigInt(e)?R0(e):s.IsConstructor(e)?P0(e):s.IsNull(e)?M0(e):s.IsObject(e)?v0(e):s.IsString(e)?Hu(e):s.IsSymbol(e)?D0(e):s.IsUndefined(e)?N0(e):s.IsFunction(e)?O0(e):Re()}function Ws(e){return e.toString(16).padStart(4,"0")}function q0(e){return BigInt(`0x${Ol(e)}`)}function Ol(e){return Vs=8997,ni=33826,Js=40164,Ys=52210,Zr(e),`${Ws(Ys)}${Ws(Js)}${Ws(ni)}${Ws(Vs)}`}function Ml(e){return!s.IsEqual(e.uniqueItems,!1)}function vl(e,t,r,n){if(!Ml(r))return!0;let o=new Set(n.map(Dr.Hash)).size,i=n.length;return s.IsEqual(o,i)}function Fl(e,t,r,n,o,i){if(!Ml(o))return!0;let a=new Set,m=i.reduce((p,f,d)=>{let g=Dr.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 Ut(e,t,r,n){return t.Push()&&te(e,t,r,n)&&t.Pop()}function te(e,t,r,n){let o=Jn(e,r);return In(r)?cu(o,t,r,n):(!su(r)||bl(o,t,r,n))&&(!(s.IsObject(n)&&!s.IsArray(n))||(!kn(r)||xl(o,t,r,n))&&(!Yt(r)||jf(o,t,r,n))&&(!Qm(r)||zf(o,t,r,n))&&(!Xm(r)||Vf(o,t,r,n))&&(!ms(r)||Yf(o,t,r,n))&&(!Hn(r)||il(o,t,r,n))&&(!zn(r)||ul(o,t,r,n))&&(!gs(r)||pl(o,t,r,n))&&(!Ko(r)||Nu(o,t,r,n))&&(!ou(r)||vu(o,t,r,n)))&&(!s.IsArray(n)||(!is(r)||Ff(o,t,r,n))&&(!Jr(r)||fu(o,t,r,n))&&(!bn(r)||Bd(o,t,r,n))&&(!$n(r)||Fu(o,t,r,n))&&(!ru(r)||Pu(o,t,r,n))&&(!En(r)||Du(o,t,r,n))&&(!Bo(r)||Ou(o,t,r,n))&&(!Sn(r)||al(o,t,r,n))&&(!Qr(r)||vl(o,t,r,n)))&&(!s.IsString(n)||(!Go(r)||ju(o,t,r,n))&&(!nu(r)||Mu(o,t,r,n))&&(!Uo(r)||Ru(o,t,r,n))&&(!Ho(r)||Uu(o,t,r,n)))&&(!(s.IsNumber(n)||s.IsBigInt(n))||(!vr(r)||Eu(o,t,r,n))&&(!eu(r)||$u(o,t,r,n))&&(!Fr(r)||Lu(o,t,r,n))&&(!tu(r)||Au(o,t,r,n))&&(!iu(r)||qu(o,t,r,n)))&&(!xs(r)||gl(o,t,r,n))&&(!ys(r)||dl(o,t,r,n))&&(!us(r)||sd(o,t,r,n))&&(!Ym(r)||pu(o,t,r,n))&&(!Zm(r)||bu(o,t,r,n))&&(!ps(r)||_d(o,t,r,n))&&(!ds(r)||_u(o,t,r,n))&&(!ss(r)||qf(o,t,r,n))&&(!as(r)||Uf(o,t,r,n))&&(!ls(r)||rl(o,t,r,n))&&(!Wo(r)||!s.IsArray(n)||El(o,t,r,n))&&(!Vo(r)||!s.IsObject(n)||kl(o,t,r,n))&&(!os(r)||Cf(o,t,r,n))}function Bt(e,t,r,n,o,i){return t.Push()&&ge(e,t,r,n,o,i)&&t.Pop()}function ge(e,t,r,n,o,i){if(t.AtCapacity())return!1;let a=Jn(e,o);return In(o)?Gf(a,t,r,n,o,i):!!(+(!su(o)||$l(a,t,r,n,o,i))&+(!(s.IsObject(i)&&!s.IsArray(i))||!!(+(!kn(o)||hl(a,t,r,n,o,i))&+(!Yt(o)||Nf(a,t,r,n,o,i))&+(!Qm(o)||Wf(a,t,r,n,o,i))&+(!Xm(o)||Jf(a,t,r,n,o,i))&+(!ms(o)||Qf(a,t,r,n,o,i))&+(!Hn(o)||sl(a,t,r,n,o,i))&+(!zn(o)||cl(a,t,r,n,o,i))&+(!gs(o)||fl(a,t,r,n,o,i))&+(!Ko(o)||Zd(a,t,r,n,o,i))&+(!ou(o)||Vd(a,t,r,n,o,i))))&+(!s.IsArray(i)||!!(+(!is(o)||Lf(a,t,r,n,o,i))&+(!Jr(o)||Hf(a,t,r,n,o,i))&+(!bn(o)||Gd(a,t,r,n,o,i))&+(!$n(o)||Jd(a,t,r,n,o,i))&+(!ru(o)||Kd(a,t,r,n,o,i))&+(!En(o)||Qd(a,t,r,n,o,i))&+(!Bo(o)||zd(a,t,r,n,o,i))&+(!Sn(o)||ml(a,t,r,n,o,i))&+(!Qr(o)||Fl(a,t,r,n,o,i))))&+(!s.IsString(i)||!!(+(!Go(o)||Xd(a,t,r,n,o,i))&+(!nu(o)||Wd(a,t,r,n,o,i))&+(!Uo(o)||qd(a,t,r,n,o,i))&+(!Ho(o)||ol(a,t,r,n,o,i))))&+(!(s.IsNumber(i)||s.IsBigInt(i))||!!(+(!vr(o)||cd(a,t,r,n,o,i))&+(!eu(o)||ud(a,t,r,n,o,i))&+(!Fr(o)||Yd(a,t,r,n,o,i))&+(!tu(o)||Hd(a,t,r,n,o,i))&+(!iu(o)||el(a,t,r,n,o,i))))&+(!xs(o)||yl(a,t,r,n,o,i))&+(!ys(o)||ll(a,t,r,n,o,i))&+(!us(o)||ad(a,t,r,n,o,i))&+(!Ym(o)||Kf(a,t,r,n,o,i))&+(!Zm(o)||md(a,t,r,n,o,i))&+(!ps(o)||Ud(a,t,r,n,o,i))&+(!ds(o)||tl(a,t,r,n,o,i))&+(!ss(o)||_f(a,t,r,n,o,i))&+(!as(o)||Bf(a,t,r,n,o,i))&+(!ls(o)||nl(a,t,r,n,o,i))&+(!Wo(o)||!s.IsArray(i)||Sl(a,t,r,n,o,i))&+(!Vo(o)||!s.IsObject(i)||Tl(a,t,r,n,o,i)))&&(!os(o)||Rf(a,t,r,n,o,i))}function Dl(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=Dl;function jl(){return _0}var l={};_t(l,{Assign:()=>B0,Clone:()=>G0,Create:()=>H0,Discard:()=>z0,Metrics:()=>ir,Update:()=>Y0});var ir={assign:0,create:0,clone:0,discard:0,update:0};function Gt(e){return[...s.Keys(e),...s.Symbols(e)]}function Nl(e,t){if(!t.has(e)){t.add(e);for(let r of Gt(e)){let n=Object.getOwnPropertyDescriptor(e,r);!n||!("value"in n)||s.IsObject(n.value)&&Nl(n.value,t)}Object.freeze(e)}}function en(e){return qe.Get().immutableTypes&&Nl(e,new WeakSet),e}function B0(e,t){ir.assign+=1;let r={},n=Gt(t),o=Gt(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 en(r)}function G0(e){ir.clone+=1;let t={};for(let r of Gt(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 ql(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={}){ir.create+=1;let n=ql(t,r),o=qe.Get().enumerableKind?ql(n,e):K0(n,e);return en(o)}function z0(e,t){ir.discard+=1;let r={};for(let n of Gt(e)){if(t.includes(n))continue;let o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,o)}return en(r)}function W0(e,t,r,n){for(let o of Gt(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=qe.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){ir.update+=1;let n={},o=Gt(t),i=Gt(r);return W0(e,o,i,n),V0(t,o,n),J0(r,i,n),en(n)}function Qs(...e){let[t,r,n]=z.Match(e,{3:(f,d,g)=>[f,d,g],2:(f,d)=>[{},f,d]}),o=Vn(t,r),i=new ut,a=ge(o,i,"#","",r,n),m=i.GetErrors(),c=jl(),p=m.map(f=>({...f,message:c(f)}));return[a,p]}var Ul=0;function Xs(){let e=ns();Ul=e.maxErrors,e.maxErrors=e.maxParseErrors}function Zs(){let e=ns();e.maxErrors=Ul}function Wu(...e){let[t,r,n]=z.Match(e,{3:(a,m,c)=>[a,m,c],2:(a,m)=>[{},a,m]}),o=Vn(t,r),i=new bt;return te(o,i,r,n)}function V(...e){let[t,r,n]=z.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]});return Wu(t,r,n)}function sr(...e){let[t,r,n]=z.Match(e,{3:(a,m,c)=>[a,m,c],2:(a,m)=>[{},a,m]}),[o,i]=Qs(t,r,n);return i}var jr=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 ea(...e){let[t,r,n]=z.Match(e,{3:(i,a,m)=>[i,a,m],2:(i,a)=>[{},i,a]});if(!V(t,r,n))throw new jr("Assert",n,sr(t,r,n))}function w(e,t){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.IsEqual(e["~kind"],t)}function Ee(e){return s.IsObject(e)}function C(e,t,r){return l.Create({"~kind":"Deferred"},{type:"deferred",action:e,parameters:t,options:r},{})}function tn(e){return w(e,"Deferred")}function yr(e,t){return l.Update(e,{"~readonly":!0},t)}function Bl(e,t,r,n){let o=$(e,t,r);return yr(o,n)}function xr(e,t){return l.Update(e,{"~optional":!0},t)}function Gl(e,t,r,n){let o=$(e,t,r);return xr(o,n)}function Tt(e,t){return l.Create({"~kind":"Array"},{type:"array",items:e},t)}function Y(e){return w(e,"Array")}function eo(e){return l.Discard(e,["~kind","type","items"])}function hr(e,t,r={}){return l.Create({"~kind":"Constructor"},{type:"constructor",parameters:e,instanceType:t},r)}function Pe(e){return w(e,"Constructor")}function Kl(e){return l.Discard(e,["~kind","type","parameters","instanceType"])}function Ir(e,t,r={}){return l.Create({"~kind":"Function"},{type:"function",parameters:e,returnType:t},r)}function Ae(e){return w(e,"Function")}function Hl(e){return l.Discard(e,["~kind","type","parameters","returnType"])}function Ye(e,t){return l.Create({"~kind":"Ref"},{$ref:e},t)}function oe(e){return w(e,"Ref")}function rn(e,t){return l.Create({"~kind":"Generic"},{type:"generic",parameters:e,expression:t})}function to(e){return w(e,"Generic")}function ro(e){return l.Create({"~kind":"Any"},{},e)}function Te(e){return w(e,"Any")}var zl="(?!)";function me(e){return l.Create({"~kind":"Never"},{not:{}},e)}function wt(e){return w(e,"Never")}function br(e,t={}){return C("AddOptional",[e],t)}function ta(e,t={}){return xr(e,t)}function Wl(e){return ta(e)}function _e(e){return Ee(e)&&s.HasPropertyKey(e,"~optional")}function Vl(e){return s.Keys(e).filter(t=>!_e(e[t]))}function ra(e){return s.Keys(e)}function na(e){return s.Values(e)}function L(e,t={}){let r=Vl(e),n=r.length>0?{required:r}:{};return l.Create({"~kind":"Object"},{type:"object",...n,properties:e},t)}function M(e){return w(e,"Object")}function Jl(e){return l.Discard(e,["~kind","type","properties","required"])}function He(e){return l.Create({"~kind":"Unknown"},{},e)}function Ue(e){return w(e,"Unknown")}function $r(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 fe(e){return w(e,"Cyclic")}function Yl(e){return l.Update(e,{"~unsafe":null},{})}function oa(e){return s.IsObjectNotArray(e)&&s.HasPropertyKey(e,"~unsafe")&&s.IsNull(e["~unsafe"])}function oi(...e){let[t,r]=z.Match(e,{2:(n,o)=>[n,o,o],1:n=>[n,He(),He()]});return l.Create({"~kind":"Infer"},{type:"infer",name:t,extends:r},{})}function Be(e){return w(e,"Infer")}function wn(e,t,r,n={}){return l.Create({"~kind":"Dependent"},{if:e,then:t,else:r},n)}function Oe(e){return w(e,"Dependent")}function Ql(e){return l.Discard(e,["~kind","if","then","else"])}function Xl(e){return s.IsObjectNotArray(e)}function Zl(e){return s.Keys(e).filter(r=>isNaN(r)).reduce((r,n)=>[...r,e[n]],[])}function eg(e){return s.IsString(e)||s.IsNumber(e)}function tg(e,t){let r=Xl(e)?Zl(e):e;return l.Create({"~kind":"Enum"},{enum:r},t)}function Me(e){return w(e,"Enum")}function lt(e,t={}){return l.Create({"~kind":"Intersect"},{allOf:e},t)}function v(e){return w(e,"Intersect")}function rg(e){return l.Discard(e,["~kind","allOf"])}var ii=class{constructor(t,r){this.type=t,this.decode=r}Encode(t){let r=this.type,n=$t(r)?a=>this.decode(r["~codec"].decode(a)):this.decode,o=$t(r)?a=>r["~codec"].encode(t(a)):t,i={decode:n,encode:o};return l.Update(this.type,{"~codec":i},{})}},si=class{constructor(t){this.type=t}Decode(t){return new ii(this.type,t)}};function ia(e){return new si(e)}function ng(e,t){return ia(e).Decode(t).Encode(()=>{throw Error("Encode not implemented")})}function og(e,t){return ia(e).Decode(()=>{throw Error("Decode not implemented")}).Encode(t)}function $t(e){return Ee(e)&&s.HasPropertyKey(e,"~codec")&&s.IsObject(e["~codec"])&&s.HasPropertyKey(e["~codec"],"encode")&&s.HasPropertyKey(e["~codec"],"decode")}function ig(e){return no(e)}function Cn(e){return Ee(e)&&s.HasPropertyKey(e,"~immutable")}function Er(e,t={}){return C("AddReadonly",[e],t)}function sa(e,t={}){return yr(e,t)}function sg(e){return sa(e)}function Nr(e){return Ee(e)&&s.HasPropertyKey(e,"~readonly")}function Z0(e,t){let r=ai(e)?[...e["~refine"],t]:[t];return l.Update(e,{"~refine":r},{})}function ag(...e){let[t,r,n]=z.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 ai(e){return Ee(e)&&s.HasPropertyKey(e,"~refine")&&s.IsArray(e["~refine"])&&s.Every(e["~refine"],0,t=>eP(t))}var mg="-?(?:0|[1-9][0-9]*)n";function mi(e){return l.Create({"~kind":"BigInt"},{type:"bigint"},e)}function vt(e){return w(e,"BigInt")}function aa(e){return l.Create({"~kind":"Boolean"},{type:"boolean"},e)}function Et(e){return w(e,"Boolean")}function ui(e){return l.Create({"~kind":"Identifier"},{name:e})}function ug(e){return w(e,"Identifier")}var ma="-?(?:0|[1-9][0-9]*)";function Rn(e){return l.Create({"~kind":"Integer"},{type:"integer"},e)}function Xe(e){return w(e,"Integer")}var Vu=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 Vu(e)})()}function W(e,t){return l.Create({"~kind":"Literal"},{type:tP(e),const:e},t)}function ua(e){return s.IsBigInt(e)||s.IsBoolean(e)||s.IsNumber(e)||s.IsString(e)}function cg(e){return J(e)&&s.IsBigInt(e.const)}function pg(e){return J(e)&&s.IsBoolean(e.const)}function ca(e){return J(e)&&s.IsNumber(e.const)}function pa(e){return J(e)&&s.IsString(e.const)}function J(e){return w(e,"Literal")}function oo(e){return l.Create({"~kind":"Null"},{type:"null"},e)}function Sr(e){return w(e,"Null")}var fa="-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?";function Ft(e){return l.Create({"~kind":"Number"},{type:"number"},e)}function Se(e){return w(e,"Number")}function io(e){return l.Create({"~kind":"Symbol"},{type:"symbol"},e)}function kr(e){return w(e,"Symbol")}function Pn(...e){let[t,r,n]=z.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[o,i,i],1:o=>[o,He(),He()]});return l.Create({"~kind":"Parameter"},{name:t,extends:r,equals:n},{})}function fg(e){return w(e,"Parameter")}var da=".*";function ct(e){return l.Create({"~kind":"String"},{type:"string"},e)}function ze(e){return w(e,"String")}function _(e,t={}){return l.Create({"~kind":"Union"},{anyOf:e},t)}function S(e){return w(e,"Union")}function dg(e){return l.Discard(e,["~kind","anyOf"])}function ci(e){let t=lg(e);return s.IsEqual(t.length,2)?t[0]:[]}function rP(e){return!0}function gg(e){return s.ShiftLeft(e,(t,r)=>nP(t)?gg(r):!1,()=>!0)}function yg(e){return s.IsEqual(e.length,0)?!1:gg(e)}function nP(e){return S(e)?yg(e.anyOf):J(e)?rP(e.const):!1}function la(e){return yg(e)}function ga(e){return l.Create({"~kind":"TemplateLiteral"},{type:"string",pattern:e},{})}function xg(e,t,r=[]){return s.ShiftLeft(e,(n,o)=>xg(o,t,[...r,`${n}${t}`]),()=>r)}function oP(e,t){return s.IsEqual(e.length,0)?[`${t}`]:xg(e,t)}function hg(e,t,r=[]){return s.ShiftLeft(t,(n,o)=>hg(e,o,[...r,...Ig(e,n)]),()=>r)}function Ig(e,t){return S(t)?hg(e,t.anyOf):J(t)?oP(e,t.const):Re()}function bg(e,t){return s.ShiftLeft(t,(r,n)=>bg(Ig(e,r),n),()=>e)}function iP(e){return e.map(t=>W(t))}function sP(e){let t=bg([],e),r=iP(t);return _(r)}function aP(e){return s.IsEqual(e.length,0)?Re():s.IsEqual(e.length,1)&&J(e[0])?e[0]:sP(e)}function Ju(e){let t=ci(e);return s.IsEqual(t.length,0)?ct():la(t)?aP(t):ga(e)}function so(e){let t=Ju(e);return de(t)?ct():t}function Ct(e,t){let r="object",n={[e]:t};return l.Create({"~kind":"Record"},{type:r,patternProperties:n})}function $g(e){return Ct(ar,e)}function Eg(e){return L({true:e,false:e})}function ve(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 G(e){return w(e,"Tuple")}function Sg(e){return l.Discard(e,["~kind","type","items","minItems","additionalItems"])}function Yu(e){return e.reduceRight((r,n,o)=>({[o]:n,...r}),{})}function kg(e){let t=Yu(e.items);return L(t)}function mP(e){return l.Discard(e,["~optional"])}function An(e,t){return l.Update(mP(e),{},t)}function Tg(e,t,r,n){let o=$(e,t,r);return An(o,n)}function uP(e){return l.Discard(e,["~readonly"])}function ao(e,t){return l.Update(uP(e),{},t)}function wg(e,t,r,n){let o=$(e,t,r);return ao(o,n)}function ya(e,t){let r=Nr(e)&&Nr(t),n=_e(e)&&_e(t),o=Fe([e,t]),i=ao(An(o,{}),{});return r&&n?yr(xr(i,{}),{}):r?yr(i,{}):n?xr(i,{}):i}function Cg(e,t){let r=Nr(e)||Nr(t),n=_e(e)||_e(t),o=ao(An(e,{}),{}),i=ao(An(t,{}),{}),a=Rt([o,i]);return r&&n?yr(xr(a,{}),{}):r?yr(a,{}):n?xr(a,{}):a}function cP(e,t,r){return r in e?r in t?ya(e[r],t[r]):e[r]:r in t?t[r]:me()}function pP(e,t){return[...new Set([...s.Keys(e),...s.Keys(t)])].reduce((o,i)=>({...o,[i]:cP(e,t,i)}),{})}function Rg(e){return M(e)?e.properties:G(e)?Yu(e.items):{}}function Pg(e,t){let r=Rg(e),n=Rg(t),o=pP(r,n);return L(o)}function fP(e,t){let r=mo(e,t);return s.IsEqual(r,fi)?e:s.IsEqual(r,di)||s.IsEqual(r,pi)?t:me()}function Ag(e){return M(e)||G(e)}function dP(e,t){let r=Ag(e),n=Ag(t);return r&&n?Pg(e,t):r&&!n?e:!r&&n?t:fP(e,t)}function Og(e,t){return wt(e)||Te(e)?e:Ue(e)||wt(t)||Te(t)?t:Ue(t)?e:dP(e,t)}function lP(e,t){return S(e)||S(t)}function gP(e,t){let r=Xt(e),n=Xt(t);return lP(r,n)?Fe([r,n]):Og(r,n)}function Mg(e,t,r=[]){return s.ShiftLeft(t,(n,o)=>Mg(e,o,[...r,gP(n,e)]),()=>s.IsEqual(r.length,0)?[e]:r)}function vg(e,t,r=[]){return s.ShiftLeft(e,(n,o)=>vg(o,t,[...r,...li([n],t)]),()=>r)}function li(e,t=[]){return s.ShiftLeft(e,(r,n)=>S(r)?li(n,vg(r.anyOf,t)):li(n,Mg(r,t)),()=>t)}function yP(e,t){let r=pt({},e,t);return N.IsExtendsTrueLike(r)?[]:[e]}function Fg(e,t,r=[]){return s.ShiftLeft(e,(n,o)=>Fg(o,t,[...r,...yP(n,t)]),()=>r)}function xa(e,t){let r=Xt(e),n=S(r)?r.anyOf:[r],o=Fg(n,t);return Rt(o)}function mr(e,t,r){let n=Fe([e,t]),o=xa(r,e);return Rt([n,o])}function St(e,t=[]){return s.ShiftLeft(e,(r,n)=>St(n,[...t,W(r)]),()=>Rt(t))}function Fe(e){let t=li(e),r=Qu(t);return Rt(r)}function gt(e){let t=so(e);return Xt(t)}function Rt(e){let t=Qu(e);return nn(t)}function Xt(e){return Oe(e)?mr(e.if,e.then,e.else):Me(e)?St(e.enum):v(e)?Fe(e.allOf):de(e)?gt(e.pattern):S(e)?Rt(e.anyOf):e}function nn(e){return s.IsEqual(e.length,1)?e[0]:s.IsEqual(e.length,0)?me():_(e)}function Lg(e,t){let r=St(e);return on(r,t)}function Dg(e,t){return Ct(sn,t)}function jg(e,t){let r=Fe(e);return on(r,t)}function Ng(e,t){return s.IsString(e)||s.IsNumber(e)?L({[e]:t}):s.IsEqual(e,!1)?L({false:t}):s.IsEqual(e,!0)?L({true:t}):L({})}function qg(e,t){return Ct(uo,t)}function _g(e,t){return s.HasPropertyKey(e,"pattern")&&(s.IsString(e.pattern)||e.pattern instanceof RegExp)?Ct(e.pattern.toString(),t):Ct(ar,t)}function Ug(e,t){let r=ci(e);return la(r)?on(gt(e),t):Ct(e,t)}function xP(e){return S(e)?an(e.anyOf):[e]}function an(e,t=[]){return s.ShiftLeft(e,(r,n)=>an(n,[...t,...xP(r)]),()=>t)}function hP(e){return e.some(t=>ze(t)||Se(t)||Xe(t))}function IP(e,t){return s.IsEqual(hP(e),!0)?Ct(ar,t):void 0}function bP(e,t){return e.reduce((r,n)=>J(n)&&(s.IsString(n.const)||s.IsNumber(n.const))?{...r,[n.const]:t}:r,{})}function $P(e,t){let r=bP(e,t);return L(r)}function Bg(e,t){let r=an(e),n=IP(r,t);return Ee(n)?n:$P(r,t)}function on(e,t){return Te(e)?$g(t):Et(e)?Eg(t):Me(e)?Lg(e.enum,t):Xe(e)?Dg(e,t):v(e)?jg(e.allOf,t):J(e)?Ng(e.const,t):Se(e)?qg(e,t):S(e)?Bg(e.anyOf,t):ze(e)?_g(e,t):de(e)?Ug(e.pattern,t):L({})}function Xu(e,t,r){return K([e])?l.Update(on(e,t),{},r):ha(e,t,r)}function Gg(e,t,r,n,o){let i=$(e,t,r),a=$(e,t,n);return Xu(i,a,o)}var sn=`^${ma}$`,uo=`^${fa}$`,ar=`^${da}$`;function ha(e,t,r={}){return C("Record",[e,t],r)}function co(e,t,r={}){return Xu(e,t,r)}function Kg(e,t){return Ct(e,t)}function Ia(e){return s.IsEqual(e,ar)?ct():s.IsEqual(e,sn)?Rn():s.IsEqual(e,uo)?Ft():Ju(e)}function Ge(e){return s.Keys(e.patternProperties)[0]}function po(e){let t=Ge(e);return Ia(t)}function ye(e){return e.patternProperties[Ge(e)]}function se(e){return w(e,"Record")}function On(e){return l.Create({"~kind":"Rest"},{type:"rest",items:e},{})}function mn(e){return w(e,"Rest")}function ba(e){return l.Create({"~kind":"This"},{$ref:"#"},e)}function $a(e){return w(e,"This")}function fo(e){return l.Create({"~kind":"Undefined"},{type:"undefined"},e)}function Zt(e){return w(e,"Undefined")}function Ea(e){return l.Create({"~kind":"Void"},{type:"void"},e)}function Lt(e){return w(e,"Void")}function SP(e,t){return s.IsEqual(e,"Array")?Tt(t[0]):s.IsEqual(e,"Capitalize")?ka(t[0]):s.IsEqual(e,"ConstructorParameters")?Pa(t[0]):s.IsEqual(e,"Evaluate")?Wx(t[0]):s.IsEqual(e,"Exclude")?Aa(t[0],t[1]):s.IsEqual(e,"Extract")?Oa(t[0],t[1]):s.IsEqual(e,"Index")?hi(t[0],t[1]):s.IsEqual(e,"InstanceType")?Ma(t[0]):s.IsEqual(e,"Lowercase")?Ta(t[0]):s.IsEqual(e,"NonNullable")?va(t[0]):s.IsEqual(e,"Omit")?Fa(t[0],t[1]):s.IsEqual(e,"Parameters")?La(t[0]):s.IsEqual(e,"Partial")?Da(t[0]):s.IsEqual(e,"Pick")?ja(t[0],t[1]):s.IsEqual(e,"Readonly")?Na(t[0]):s.IsEqual(e,"KeyOf")?Ii(t[0]):s.IsEqual(e,"Record")?ha(t[0],t[1]):s.IsEqual(e,"Required")?qa(t[0]):s.IsEqual(e,"ReturnType")?_a(t[0]):s.IsEqual(e,"Uncapitalize")?wa(t[0]):s.IsEqual(e,"Uppercase")?Ca(t[0]):xi(Ye(e),t)}function Mn(){throw Error("Unreachable")}function Jg(e,t=[]){return s.ShiftLeft(e,(r,n)=>Jg(n,[...t,r[1]]),()=>t)}function qr(e){return s.IsEqual(e.length,3)?[e[0],...Jg(e[1])]:[]}function Yg(e){return Pn(e[0],e[2],e[4])}function Qg(e){return Pn(e[0],e[2],e[2])}function Xg(e){return Pn(e[0],He(),e[2])}function Zg(e){return Pn(e,He(),He())}function ey(e){return qr(e)}function ty(e){return e[1]}function ry(e){return qr(e)}function ny(e){return e[1]}function oy(e){return SP(e[0],e[1])}function iy(e){return null}function sy(e){return ct()}function ay(e){return Ft()}function my(e){return aa()}function uy(e){return fo()}function cy(e){return oo()}function py(e){return Rn()}function fy(e){return mi()}function dy(e){return He()}function ly(e){return ro()}function gy(e){return L({})}function yy(e){return me()}function xy(e){return io()}function hy(e){return Ea()}function Iy(e){return ba()}function by(e){return W(BigInt(e))}function $y(e){return W(s.IsEqual(e,"true"))}function Ey(e){return W(parseFloat(e))}function Sy(e){return W(e)}function ky(e){return e[1]}function Ty(e){return W(e)}function wy(e){return s.IsEqual(e.length,3)?[e[0],e[1],...e[2]]:[e[0]]}function Cy(e){return e[1]}function Ry(e){return Sa(e)}function Py(e){return s.IsEqual(e.length,6)?wn(e[1],e[3],e[5]):wn(e[1],e[3],He())}function Ay(e){return e.length>0}function Oy(e){return e.reduce((t,r)=>s.IsEqual(r.length,3)?[...t,[r[1]]]:[...t,[]],[])}function My(e){return s.IsEqual(e.length,6)?[e[1],e[3],e[5]]:[]}function vy(e){return s.IsArray(e)&&s.IsEqual(e.length,3)?e[1]:e}function Fy(e){return s.IsEqual(e.length,2)?e[1]:[]}function Hg(e,t){return t.reduce((r,n)=>{let o=n;return s.IsEqual(o.length,1)?hi(r,o[0]):s.IsEqual(o.length,0)?Tt(r):Mn()},e)}function zg(e,t){return s.IsEqual(t.length,3)?Ra(e,t[0],t[1],t[2]):e}function kP(e,t){return s.IsArray(t)&&s.IsEqual(t.length,0)?e:Ua(e,t)}function Ly(e){let[t,r,n,o,i]=e;return kP(zg(t?Ii(Hg(r,n)):Hg(r,n),o),i)}function Zu(e,t){return s.IsEqual(t.length,3)?(()=>{let[r,n,o]=t,i=Zu(n,o);if(s.IsEqual(r,"&"))return v(i)?lt([e,...i.allOf]):lt([e,i]);if(s.IsEqual(r,"|"))return S(i)?_([e,...i.anyOf]):_([e,i]);Mn()})():e}function Dy(e){let[t,r]=e;return Zu(t,r)}function jy(e){let[t,r]=e;return Zu(t,r)}function Ny(e){return Hx(e[1])}function qy(e){return e[1]}function _y(e){return rn(e[0],e[2])}function Uy(e){return s.IsEqual(e.length,4)?oi(e[1],e[3]):s.IsEqual(e.length,2)?oi(e[1],He()):Mn()}function By(e){return`${e}`}function Gy(e){return Xe(e[3])?sn:Se(e[3])?uo:kr(e[3])?ar:ze(e[3])?ar:Mn()}function Ky(e){return e.length>0}function Hy(e){return e.length>0}function zy(e){let[t,r,n,o,i]=e;return{[r]:t&&n?Er(br(i)):t&&!n?Er(i):!t&&n?br(i):i}}function Wy(e){return qr(e)}function Vy(e){return e.reduce((t,r)=>s.HasPropertyKey(r,sn)||s.HasPropertyKey(r,uo)||s.HasPropertyKey(r,ar)?[t[0],l.Assign(t[1],r)]:[l.Assign(t[0],r),t[1]],[{},{}])}function Jy(e){return Vy(e[1])}function Yy(e){let[t,r]=e,n=s.IsEqual(s.Keys(r).length,0)?{}:{patternProperties:r};return L(t,n)}function Qy(e){return s.IsEqual(e.length,5)?Er(br(e[4])):s.IsEqual(e.length,3)?e[2]:s.IsEqual(e.length,4)?s.IsEqual(e[2],"readonly")?Er(e[3]):br(e[3]):Mn()}function Xy(e){if(!s.IsArray(e)||!s.IsEqual(e.length,3))return e;let[t,r,n]=e;return t&&n?Er(br(r)):t&&!n?Er(r):!t&&n?br(r):r}function Zy(e){return s.IsEqual(e.length,2)?On(e[1]):s.IsEqual(e.length,1)?e[0]:Mn()}function ex(e){return qr(e)}function tx(e){return ve(e[1])}function rx(e){return Er(br(e[4]))}function nx(e){return Er(e[3])}function ox(e){return br(e[3])}function ix(e){return e[2]}function sx(e){return s.IsEqual(e.length,2)?On(e[1]):s.IsEqual(e.length,1)?e[0]:Mn()}function ax(e){return qr(e)}function mx(e){return Ir(e[1],e[4])}function ux(e){return hr(e[2],e[5])}function Wg(e,t){return s.IsEqual(e,"remove")?zx(t):s.IsEqual(e,"add")?Er(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 Vg(e,t){return s.IsEqual(e,"remove")?Kx(t):s.IsEqual(e,"add")?br(t):t}function px(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 fx(e){return s.IsEqual(e.length,2)?[e[1]]:[]}function dx(e){return s.IsArray(e[6])&&s.IsEqual(e[6].length,1)?gi(ui(e[3]),e[5],e[6][0],Wg(e[1],Vg(e[8],e[10]))):gi(ui(e[3]),e[5],Ye(e[3]),Wg(e[1],Vg(e[8],e[10])))}function lx(e){return Ye(e)}function gx(e){return BigInt(e)}function yx(e){return parseFloat(e)}function xx(e){return s.IsEqual(e,"true")}function hx(e){return null}function Ix(e){return{[e[0]]:e[2]}}function bx(e){return qr(e)}function TP(e){return e.reduce((t,r)=>l.Assign(t,r),{})}function $x(e){return TP(e[1])}function Ex(e){return qr(e)}function Sx(e){return e[1]}function kx(e){return mi()}function Tx(e){return ct()}function wx(e){return Ft()}function Cx(e){return Rn()}function Rx(e){return me()}function Px(e){return W(e)}function Ax(e){return _(e[1])}function Ox(e){return e.length===3?[...e[0],...e[2]]:e.length===1?[...e[0]]:[]}function Mx(e){return[e[0],...e[1]]}function vx(e){return e[1]}function Fx(e){return qr(e)}function Lx(e){return s.IsEqual(e.length,2)?e[1]:[]}function Dx(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]]:rn(t,yi(r,n,i))}}function jx(e){let t=e[2],[r,n]=e[3],o=s.IsEqual(s.Keys(n).length,0)?{}:{patternProperties:n};return{[e[1]]:yi(t,r,o)}}function Nx(e){return{[e[1]]:rn(e[2],e[4])}}function qx(e){return{[e[1]]:e[3]}}function _x(e){return null}function Ux(e){return qr(e)}function Bx(e){return e[1]}function Gx(e){let[t,r]=[e[0],e[1]];return Vx(l.Assign(t,Vy(r)[0]))}function bi(e){return ee(e.length,2)}function X(e,t,r){return bi(e)?t(e[0],e[1]):r()}function RP(e,t){return ee(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function we(e,t){for(let r=0;r<e.length;r++){let n=RP(e[r],t);if(bi(n))return n}return[]}function ec(e,t){return Array.from({length:t-e+1},(r,n)=>String.fromCharCode(e+n))}var Jx=[...ec(97,122),...ec(65,90)],tc="0",rc=ec(49,57),lo=[tc,...rc],Yx=" ",go=`
1
+ import{b as df}from"./chunk-XODGJSB3.js";import{t as ff}from"./chunk-ZJL4OEXX.js";import{H as it,K as pf,L as Un,a as Ji}from"./chunk-5FIFNXLT.js";import{a as dr}from"./chunk-UTYFLLSM.js";import{a as Gm,b as Bn,c as Gn,d as Km,e as Hm,f as Do,g as zm,h as Vr,j as jo}from"./chunk-MVVEYKN6.js";import{a as _t}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 z={};_t(z,{Match:()=>_w});function _w(e,t){return t[e.length]?.(...e)??(()=>{throw Error("Invalid Arguments")})()}var qe={};_t(qe,{Get:()=>ns,Reset:()=>DC,Set:()=>jC});var s={};_t(s,{CodePointCount:()=>tC,Counted:()=>mC,Entries:()=>pC,EntriesRegExp:()=>cC,Every:()=>oC,EveryAll:()=>iC,GraphemeCount:()=>eC,HasPropertyKey:()=>uC,IsArray:()=>qo,IsBigInt:()=>No,IsBoolean:()=>If,IsClassInstance:()=>Zw,IsConstructor:()=>Ww,IsDeepEqual:()=>Jm,IsEqual:()=>ee,IsFunction:()=>bf,IsGreaterEqualThan:()=>Ef,IsGreaterThan:()=>Yw,IsInteger:()=>Wm,IsLessEqualThan:()=>$f,IsLessThan:()=>Qw,IsMaxLength:()=>rC,IsMinLength:()=>nC,IsMultipleOf:()=>Xw,IsNull:()=>Zi,IsNumber:()=>es,IsObject:()=>_o,IsObjectNotArray:()=>Vw,IsString:()=>ts,IsSymbol:()=>Jw,IsUndefined:()=>Vm,IsUnsafePropertyKey:()=>kf,IsValueLike:()=>Sf,Keys:()=>Xi,ShiftLeft:()=>rs,Some:()=>sC,SomeAll:()=>aC,Symbols:()=>fC,Values:()=>dC});function Kn(e,t,r){return e>=t&&e<=r}function Uw(e){return e===8205}function lf(e){return Kn(e,127462,127487)}function Bw(e){return Kn(e,65024,65039)}function Gw(e){return Kn(e,768,879)||Kn(e,6832,6911)||Kn(e,7616,7679)||Kn(e,65056,65071)}function Yi(e){return e>65535?2:1}function gf(e,t){for(;t<e.length;){let r=e.codePointAt(t);if(Gw(r)||Bw(r))t+=Yi(r);else break}return t}function Kw(e,t){let r=e.codePointAt(t),n=t+Yi(r);for(n=gf(e,n);n<e.length-1&&Uw(e.codePointAt(n));){let o=e.codePointAt(n+1);n+=1+Yi(o),n=gf(e,n)}return lf(r)&&n<e.length&&lf(e.codePointAt(n))&&(n+=Yi(e.codePointAt(n))),n}function yf(e){let t=0,r=0;for(;r<e.length;)r=Kw(e,r),t++;return t}function Qi(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 xf(e,t){return e.length<=t||e.length<=t<<1&&Qi(e)<=t}function hf(e,t){return e.length>=t<<1||e.length>=t&&Qi(e)>=t}function qo(e){return Array.isArray(e)}function No(e){return ee(typeof e,"bigint")}function If(e){return ee(typeof e,"boolean")}function Ww(e){if(Vm(e)||!bf(e))return!1;let t=Function.prototype.toString.call(e);return!!(/^class\s/.test(t)||/\[native code\]/.test(t))}function bf(e){return ee(typeof e,"function")}function Wm(e){return Number.isInteger(e)}function Zi(e){return ee(e,null)}function es(e){return Number.isFinite(e)}function Vw(e){return _o(e)&&!qo(e)}function _o(e){return ee(typeof e,"object")&&!Zi(e)}function ts(e){return ee(typeof e,"string")}function Jw(e){return ee(typeof e,"symbol")}function Vm(e){return ee(e,void 0)}function ee(e,t){return e===t}function Yw(e,t){return e>t}function Qw(e,t){return e<t}function $f(e,t){return e<=t}function Ef(e,t){return e>=t}function Xw(e,t){if(No(e)||No(t))return BigInt(e)%BigInt(t)===0n;let r=1e-10;if(!es(e)||Wm(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(!_o(e))return!1;let t=globalThis.Object.getPrototypeOf(e);return Zi(t)?!1:ee(typeof t.constructor,"function")&&!(ee(t.constructor,globalThis.Object)||ee(t.constructor.name,"Object"))}function Sf(e){return No(e)||If(e)||Zi(e)||es(e)||ts(e)||Vm(e)}function eC(e){return yf(e)}function tC(e){return Qi(e)}function rC(e,t){return xf(e,t)}function nC(e,t){return hf(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 rs(e,t,r){return ee(e.length,0)?r():t(e[0],e.slice(1))}function kf(e){return ee(e,"__proto__")||ee(e,"constructor")||ee(e,"prototype")}function uC(e,t){return kf(t)?Object.prototype.hasOwnProperty.call(e,t):t in e}function cC(e){return Xi(e).map(t=>[new RegExp(`^${t}$`),e[t]])}function pC(e){return Object.entries(e)}function Xi(e){return Object.getOwnPropertyNames(e)}function fC(e){return Object.getOwnPropertySymbols(e)}function dC(e){return Object.values(e)}function lC(e,t){if(!_o(t))return!1;let r=Xi(e);return ee(r.length,Xi(t).length)&&r.every(n=>Jm(e[n],t[n]))}function gC(e,t){return qo(t)&&ee(e.length,t.length)&&e.every((r,n)=>Jm(e[n],t[n]))}function Jm(e,t){return qo(e)?gC(e,t):_o(e)?lC(e,t):ee(e,t)}var Ke={};_t(Ke,{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 Tf=s;var rr={immutableTypes:!1,maxErrors:8,maxParseErrors:1,maxInstantiationCount:128,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1,unionPrioritySort:!0};function DC(){rr.immutableTypes=!1,rr.maxErrors=8,rr.maxParseErrors=1,rr.maxInstantiationCount=128,rr.useAcceleration=!0,rr.exactOptionalPropertyTypes=!1,rr.enumerableKind=!1,rr.correctiveParse=!1,rr.unionPrioritySort=!0}function jC(e){for(let t of s.Keys(e)){let r=e[t];r!==void 0&&Object.defineProperty(rr,t,{value:r})}}function ns(){return rr}function os(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 kt(e){return s.IsObject(e)&&!s.IsArray(e)}function In(e){return s.IsBoolean(e)}function q(e){return kt(e)||In(e)}function is(e){return s.HasPropertyKey(e,"additionalItems")&&q(e.additionalItems)}function Yt(e){return s.HasPropertyKey(e,"additionalProperties")&&q(e.additionalProperties)}function ss(e){return s.HasPropertyKey(e,"allOf")&&s.IsArray(e.allOf)&&e.allOf.every(t=>q(t))}function wf(e){return s.HasPropertyKey(e,"$anchor")&&s.IsString(e.$anchor)}function as(e){return s.HasPropertyKey(e,"anyOf")&&s.IsArray(e.anyOf)&&e.anyOf.every(t=>q(t))}function Ym(e){return s.HasPropertyKey(e,"const")}function Jr(e){return s.HasPropertyKey(e,"contains")&&q(e.contains)}function Pt(e){return s.HasPropertyKey(e,"default")}function Qm(e){return s.HasPropertyKey(e,"dependencies")&&s.IsObject(e.dependencies)&&Object.values(e.dependencies).every(t=>q(t)||s.IsArray(t)&&t.every(r=>s.IsString(r)))}function Xm(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 ms(e){return s.HasPropertyKey(e,"dependentSchemas")&&s.IsObject(e.dependentSchemas)&&Object.values(e.dependentSchemas).every(t=>q(t))}function Yr(e){return s.HasPropertyKey(e,"$dynamicAnchor")&&s.IsString(e.$dynamicAnchor)}function us(e){return s.HasPropertyKey(e,"$dynamicRef")&&s.IsString(e.$dynamicRef)}function cs(e){return s.HasPropertyKey(e,"else")&&q(e.else)}function Zm(e){return s.HasPropertyKey(e,"enum")&&s.IsArray(e.enum)}function eu(e){return s.HasPropertyKey(e,"exclusiveMaximum")&&(s.IsNumber(e.exclusiveMaximum)||s.IsBigInt(e.exclusiveMaximum))}function vr(e){return s.HasPropertyKey(e,"exclusiveMinimum")&&(s.IsNumber(e.exclusiveMinimum)||s.IsBigInt(e.exclusiveMinimum))}function Uo(e){return s.HasPropertyKey(e,"format")&&s.IsString(e.format)}function It(e){return s.HasPropertyKey(e,"$id")&&s.IsString(e.$id)}function ps(e){return s.HasPropertyKey(e,"if")&&q(e.if)}function bn(e){return s.HasPropertyKey(e,"items")&&(q(e.items)||s.IsArray(e.items)&&e.items.every(t=>q(t)))}function fs(e){return bn(e)&&s.IsArray(e.items)}function tu(e){return s.HasPropertyKey(e,"maximum")&&(s.IsNumber(e.maximum)||s.IsBigInt(e.maximum))}function ru(e){return s.HasPropertyKey(e,"maxContains")&&s.IsNumber(e.maxContains)}function Bo(e){return s.HasPropertyKey(e,"maxItems")&&s.IsNumber(e.maxItems)}function nu(e){return s.HasPropertyKey(e,"maxLength")&&s.IsNumber(e.maxLength)}function ou(e){return s.HasPropertyKey(e,"maxProperties")&&s.IsNumber(e.maxProperties)}function Fr(e){return s.HasPropertyKey(e,"minimum")&&(s.IsNumber(e.minimum)||s.IsBigInt(e.minimum))}function $n(e){return s.HasPropertyKey(e,"minContains")&&s.IsNumber(e.minContains)}function En(e){return s.HasPropertyKey(e,"minItems")&&s.IsNumber(e.minItems)}function Go(e){return s.HasPropertyKey(e,"minLength")&&s.IsNumber(e.minLength)}function Ko(e){return s.HasPropertyKey(e,"minProperties")&&s.IsNumber(e.minProperties)}function iu(e){return s.HasPropertyKey(e,"multipleOf")&&(s.IsNumber(e.multipleOf)||s.IsBigInt(e.multipleOf))}function ds(e){return s.HasPropertyKey(e,"not")&&q(e.not)}function ls(e){return s.HasPropertyKey(e,"oneOf")&&s.IsArray(e.oneOf)&&e.oneOf.every(t=>q(t))}function Ho(e){return s.HasPropertyKey(e,"pattern")&&(s.IsString(e.pattern)||e.pattern instanceof RegExp)}function Hn(e){return s.HasPropertyKey(e,"patternProperties")&&s.IsObject(e.patternProperties)&&Object.values(e.patternProperties).every(t=>q(t))}function Sn(e){return s.HasPropertyKey(e,"prefixItems")&&s.IsArray(e.prefixItems)&&e.prefixItems.every(t=>q(t))}function zn(e){return s.HasPropertyKey(e,"properties")&&s.IsObject(e.properties)&&Object.values(e.properties).every(t=>q(t))}function gs(e){return s.HasPropertyKey(e,"propertyNames")&&(s.IsObject(e.propertyNames)||q(e.propertyNames))}function NC(e){return s.HasPropertyKey(e,"$recursiveAnchor")&&s.IsBoolean(e.$recursiveAnchor)}function zo(e){return NC(e)&&s.IsEqual(e.$recursiveAnchor,!0)}function ys(e){return s.HasPropertyKey(e,"$recursiveRef")&&s.IsString(e.$recursiveRef)}function xs(e){return s.HasPropertyKey(e,"$ref")&&s.IsString(e.$ref)}function kn(e){return s.HasPropertyKey(e,"required")&&s.IsArray(e.required)&&e.required.every(t=>s.IsString(t))}function hs(e){return s.HasPropertyKey(e,"then")&&q(e.then)}function su(e){return s.HasPropertyKey(e,"type")&&(s.IsString(e.type)||s.IsArray(e.type)&&e.type.every(t=>s.IsString(t)))}function Qr(e){return s.HasPropertyKey(e,"uniqueItems")&&s.IsBoolean(e.uniqueItems)}function Wo(e){return s.HasPropertyKey(e,"unevaluatedItems")&&q(e.unevaluatedItems)}function Vo(e){return s.HasPropertyKey(e,"unevaluatedProperties")&&q(e.unevaluatedProperties)}var bt=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}},ut=class extends bt{constructor(){super(),this.errors=[]}AtCapacity(){return this.errors.length>=qe.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 Cf(e,t,r,n){return s.Every(r["~refine"],0,(o,i)=>o.check(n))}function Rf(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 Jo="urn:typebox:root";function Lr(e,t){return URL.canParse(e,t)?new URL(e,t):s.IsEqual(t,Jo)?new URL(`${t}:${e}`):new URL(`${t.slice(0,t.lastIndexOf(":"))}:${e}`)}function Vn(e,t){let r=kt(t)&&It(t)?Lr(t.$id,Jo).href:Jo;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 au(e,t,r=!0){if(In(t))return e;if(Array.isArray(t))return t.reduce((o,i)=>au(o,i,!1),e);if(!kt(t)||!r&&It(t))return e;let n=!r&&Yr(t)?[...e,t]:e;return Object.keys(t).reduce((o,i)=>au(o,t[i],!1),n)}function Yo(e,t){return e.resourceEntries.get(t)}function Pf(e,t){return e.enteredResource||Yo(e,t)!==void 0}function qC(e){return!/^[A-Za-z][A-Za-z0-9+.-]*:/.test(e.$id)}function _C(e,t){return It(t)?[...e.ids,t]:e.ids}function UC(e,t){return e.recursiveAnchor??(zo(t)?t:void 0)}function BC(e,t){let r=It(t)?au(e.dynamicAnchors,t):e.dynamicAnchors;return Yr(t)?[...r,t]:r}function GC(e,t){return It(t)?!1:e.pendingResource}function Af(e,t){let r=Yo(e,t);return r?r.base:It(t)?Lr(t.$id,e.lexicalBase).href:e.lexicalBase}function Of(e,t){let r=Yo(e,t);return r?r.base:It(t)&&e.pendingResource?Lr(t.$id,e.resourceBase).href:e.resourceBase}function Mf(e,t){return It(t)?!qC(t):e.useResourceBaseForReference}function KC(e,t){let r=Pf(e,t),n=Mf(e,t);return r||n?Of(e,t):Af(e,t)}function HC(e,t){let r=Yo(e,t);return r?r.root:It(t)?t:e.lexicalSchema}function zC(e,t){return kt(t)&&(It(t)||Yr(t)||s.IsUndefined(e.recursiveAnchor)&&zo(t)||!s.IsUndefined(Yo(e,t)))}function Jn(e,t){return zC(e,t)?{...e,ids:_C(e,t),dynamicAnchors:BC(e,t),recursiveAnchor:UC(e,t),pendingResource:GC(e,t),lexicalBase:Af(e,t),resourceBase:Of(e,t),useResourceBaseForReference:Mf(e,t),referenceBase:KC(e,t),lexicalSchema:HC(e,t),enteredResource:Pf(e,t)}:e}function vf(e){return bn(e)&&s.IsArray(e.items)}function Ff(e,t,r,n){return vf(r)?s.Every(n,0,(i,a)=>s.IsLessThan(a,r.items.length)||Ut(e,t,r.additionalItems,i)&&t.AddIndex(a)):!0}function Lf(e,t,r,n,o,i){return vf(o)?s.Every(i,0,(m,c)=>{let p=`${r}/additionalItems`,f=`${n}/${c}`;return s.IsLessThan(c,o.items.length)||Bt(e,t,p,f,o.additionalItems,m)&&t.AddIndex(c)}):!0}function At(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Xr(e){return new RegExp(e,"u")}function WC(e){return`^${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}$`}function Df(e){let t=[];return Hn(e)&&t.push(...s.Keys(e.patternProperties)),zn(e)&&t.push(...s.Keys(e.properties).map(WC)),s.IsEqual(t.length,0)?"(?!)":`(${t.join("|")})`}function jf(e,t,r,n){let o=Xr(Df(r));return s.Every(s.Keys(n),0,(a,m)=>o.test(a)||Ut(e,t,r.additionalProperties,n[a])&&t.AddKey(a))}function Nf(e,t,r,n,o,i){let a=Xr(Df(o)),m=[];return s.EveryAll(s.Keys(i),0,(p,f)=>{let d=`${r}/additionalProperties`,g=`${n}/${At(p)}`,y=a.test(p)||Bt(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 qf(e,t,r,n){let o=r.allOf.reduce((i,a)=>{let m=new bt;return te(e,m,a,n)?[...i,m]:i},[]);return s.IsEqual(o.length,r.allOf.length)&&t.Merge(o)}function _f(e,t,r,n,o,i){let a=[],m=o.allOf.reduce((p,f,d)=>{let g=`${r}/allOf/${d}`,y=new ut,I=ge(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 Uf(e,t,r,n){let o=r.anyOf.reduce((i,a)=>{let m=new bt;return te(e,m,a,n)?[...i,m]:i},[]);return s.IsGreaterThan(o.length,0)&&t.Merge(o)}function Bf(e,t,r,n,o,i){let a=[],m=o.anyOf.reduce((p,f,d)=>{let g=new ut,y=`${r}/anyOf/${d}`,I=ge(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 cu(e,t,r,n){return r}function Gf(e,t,r,n,o,i){return cu(e,t,o,i)||t.AddError("boolean",r,n,{})}function pu(e,t,r,n){return s.IsValueLike(r.const)?s.IsEqual(n,r.const):s.IsDeepEqual(n,r.const)}function Kf(e,t,r,n,o,i){return pu(e,t,o,i)||t.AddError("const",r,n,{allowedValue:o.const})}function VC(e){return!($n(e)&&s.IsEqual(e.minContains,0))}function fu(e,t,r,n){return VC(r)?!s.IsEqual(n.length,0)&&s.SomeAll(n,(o,i)=>te(e,t,r.contains,o)&&t.AddIndex(i)):!0}function Hf(e,t,r,n,o,i){return fu(e,t,o,i)||t.AddError("contains",r,n,{minContains:1})}function zf(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)):te(e,t,m,n)));return o||i}function Wf(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/${At(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})):ge(e,t,f,n,p,i))});return a||m}function Vf(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 Jf(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 Yf(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)||te(e,t,m,n));return o||i}function Qf(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/${At(c)}`;return!s.HasPropertyKey(i,c)||ge(e,t,f,n,p,i)});return a||m}var Qt={};_t(Qt,{DynamicRef:()=>TR,RecursiveRef:()=>ER,Ref:()=>bR});var gr={};_t(gr,{Delete:()=>XC,Get:()=>YC,Has:()=>JC,Indices:()=>Xo,Set:()=>QC});function Zf(e){throw Error(e)}function Xf(){Zf("Pointer contains unsafe property key")}function du(){Zf("Cannot set value")}function Xo(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 Xo(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 Xo(t)){if(!s.IsObject(r)||s.IsUnsafePropertyKey(n))return;r=r[n]}return r}function ed(e,t,r){let n=e;for(let o of t)s.IsUnsafePropertyKey(o)&&Xf(),n=s.IsObject(n)?n[o]:void 0;return s.IsUnsafePropertyKey(r)&&Xf(),s.IsObject(n)||du(),n}function QC(e,t,r){let n=Xo(t),o=n.pop();return s.IsUndefined(o)&&du(),ed(e,n,o)[o]=r,e}function XC(e,t){let r=Xo(t),n=r.pop();s.IsUndefined(n)&&du();let o=ed(e,r,n);return s.IsArray(o)&&/^(0|[1-9]\d*)$/.test(n)?o.splice(Number(n),1):delete o[n],e}function yu(e,t){return kt(e)&&It(e)?Lr(e.$id,t.href):t}function xu(e){return Lr(e,Jo)}function lu(e){return e.href.split("#")[0]}function ZC(e,t,r){return gu(e,xu(t),r)}function eR(e,t){return t.$ref.startsWith("#")||e.enteredResource?e.lexicalSchema:e.schema}function tR(e){return e.startsWith("#/")}function td(e,t){if(s.IsObject(e)&&Yr(e)&&s.IsEqual(e.$dynamicAnchor,t))return e;if(s.IsObject(e))for(let r of s.Keys(e)){let n=td(e[r],t);if(n)return n}}function gu(e,t,r){if(s.IsEqual(e,r))return t.href;let n=yu(e,t);if(s.IsArray(e))for(let o of e){let i=gu(o,n,r);if(!s.IsUndefined(i))return i}else if(s.IsObject(e))for(let o of s.Keys(e)){let i=gu(e[o],n,r);if(!s.IsUndefined(i))return i}}function rd(e,t){if(t.href.endsWith("#"))return e;if(!t.hash.startsWith("#"))return;let r=decodeURIComponent(t.hash.slice(1));if(r.startsWith("/"))return gr.Get(e,r)}function rR(e,t,r){if(!It(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("#")?rd(e,r):e}function nR(e,t,r){if(!wf(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(!Yr(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(kt(e))return rR(e,t,r)??nR(e,t,r)??oR(e,t,r)??rd(e,r)}function sR(e,t,r){if(s.IsArray(e))return e.reduce((n,o)=>{let i=Is(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=Is(e[o],t,r);return s.IsUndefined(i)?n:i},void 0)}function Is(e,t,r){let n=yu(e,t);return iR(e,n,r)??sR(e,n,r)??aR(e,n,r)}function mR(e,t,r,n){let o=bs(e,t,r,n);return kt(o)&&It(o)?o:void 0}function uR(e,t,r){if(!t.$ref.startsWith("#")||!kt(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(kt(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(It(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 Is(e,t,r)}function gR(e,t,r){let n=lu(r);if(!s.HasPropertyKey(e,n)||s.IsEqual(n,lu(t)))return;let o=e[n],i=yu(o,new URL(n));return s.IsEqual(r.hash,"")?o:Is(o,i,r)}function bs(e,t,r,n){let o=xu(r),i=Lr(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?Jn(e,t.resource):e}function nd(e,t,r,n){let o=yR({...e,pendingResource:t},r);return xR(o,n)}function hR(e,t,r){let n=lu(Lr(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:nd(e,!0,i,a)}}function IR(e,t){return{schema:t,stack:nd(e,!s.IsUndefined(t))}}function bR(e,t){let r=bs(e.context,eR(e,t),e.referenceBase,t.$ref);return kt(r)?hR(e,t,r):IR(e,r)}function $R(e){return kt(e.lexicalSchema)&&zo(e.lexicalSchema)}function ER(e,t){let r=$R(e)?e.recursiveAnchor:e.lexicalSchema;return bs(e.context,r,e.lexicalBase,t.$recursiveRef)}function od(e,t){return Lr(t.$dynamicRef,xu(e.lexicalBase).href).hash}function id(e,t){return e.dynamicAnchors.find(r=>s.IsEqual(r.$dynamicAnchor,t))??td(e.schema,t)}function SR(e,t,r){if(!kt(r)||!Yr(r))return r;let n=od(e,t);return tR(n)?r:id(e,r.$dynamicAnchor)}function kR(e,t){let r=od(e,t);return id(e,decodeURIComponent(r.slice(1)))}function TR(e,t){let r=t.$dynamicRef.startsWith("#")?e.lexicalSchema:e.schema,n=bs(e.context,r,e.lexicalBase,t.$dynamicRef);return s.IsUndefined(n)?kR(e,t):SR(e,t,n)}function sd(e,t,r,n){let o=Qt.DynamicRef(e,r)??!1,i=o?{...e,pendingResource:!0}:e;return q(o)&&te(i,t,o,n)}function ad(e,t,r,n,o,i){let a=Qt.DynamicRef(e,o)??!1,m=a?{...e,pendingResource:!0}:e;return q(a)&&ge(m,t,r,n,a,i)}function bu(e,t,r,n){return s.Some(r.enum,o=>s.IsValueLike(o)?s.IsEqual(n,o):s.IsDeepEqual(n,o))}function md(e,t,r,n,o,i){return bu(e,t,o,i)||t.AddError("enum",r,n,{allowedValues:o.enum})}function $u(e,t,r,n){return s.IsLessThan(n,r.exclusiveMaximum)}function ud(e,t,r,n,o,i){return $u(e,t,o,i)||t.AddError("exclusiveMaximum",r,n,{comparison:"<",limit:o.exclusiveMaximum})}function Eu(e,t,r,n){return s.IsGreaterThan(n,r.exclusiveMinimum)}function cd(e,t,r,n,o,i){return Eu(e,t,o,i)||t.AddError("exclusiveMinimum",r,n,{comparison:">",limit:o.exclusiveMinimum})}var ri={};_t(ri,{Clear:()=>jd,Entries:()=>l0,Get:()=>x0,Has:()=>y0,IsDate:()=>Qn,IsDateTime:()=>$s,IsDuration:()=>Es,IsEmail:()=>Ss,IsHostname:()=>Os,IsIPv4:()=>Fs,IsIPv6:()=>Ls,IsIdnEmail:()=>Ms,IsIdnHostname:()=>vs,IsIri:()=>js,IsIriReference:()=>Ds,IsJsonPointer:()=>qs,IsJsonPointerUriFragment:()=>Ns,IsRegex:()=>_s,IsRelativeJsonPointer:()=>Us,IsTime:()=>Xn,IsUri:()=>Ks,IsUriReference:()=>Bs,IsUriTemplate:()=>Gs,IsUrl:()=>Hs,IsUuid:()=>zs,Reset:()=>Nd,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 Qn(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 Xn(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 $s(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&&Qn(n[0])&&Xn(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 Es(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 Ss(e){return MR.test(e)}var pd=/^(?!-).*(?<!-)$/,fd=/^(?!..--)/,dd=/^[a-zA-Z0-9-]*$/,pG=new RegExp("^\\p{ASCII}*$","u"),Zn=/[^\p{ASCII}]/u;var vR=/[0-9]/,ld=/[\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,Su=new RegExp("\\p{Mn}","u"),jR=new RegExp("\\p{Mc}","u"),fG=new RegExp("\\p{Me}","u"),gd=/[\p{Mn}\p{Mc}\p{Me}]/u,ku=new RegExp("\\p{L}","u"),NR=new RegExp("\\p{Nd}","u"),yd=new RegExp("\\p{Script=Greek}","u"),ks=new RegExp("\\p{Script=Hebrew}","u"),xd=/[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u,hd=/[\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Mandaic}]/u,Tu=/[\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,Id=/[\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,bd=new RegExp([vR,FR].map(e=>e.source).join("|"),"u"),$d=new RegExp([ku,DR,LR,NR,Su,jR,qR,_R].map(e=>e.source).join("|"),"u");function Ed(e){return pd.test(e)&&fd.test(e)&&dd.test(e)}var or=36,ei=1,ti=26,BR=38,GR=700,kd=72,Td=128;function wu(){throw null}function Ts(e){return e.toLowerCase().startsWith("xn--")}function wd(e,t,r){e=r?Math.floor(e/GR):e>>1,e+=Math.floor(e/t);let n=0;for(;e>(or-ei)*ti>>1;)e=Math.floor(e/(or-ei)),n+=or;return n+Math.floor((or-ei+1)*e/(e+BR))}function ws(e){let t=[],r=Td,n=0,o=kd,i=e.lastIndexOf("-");if(i>0)for(let m=0;m<i;m++){let c=e.charCodeAt(m);c>=128&&wu(),t.push(c)}let a=i<0?0:i+1;for(;a<e.length;){let m=n,c=1,p=or;for(;;){a>=e.length&&wu();let d=e.charCodeAt(a++),g;d>=97&&d<=122?g=d-97:d>=48&&d<=57?g=d-48+26:wu(),n+=g*c;let y=p<=o?ei:p>=o+ti?ti:p-o;if(g<y)break;c*=or-y,p+=or}let f=t.length+1;o=wd(n-m,f,m===0),r+=Math.floor(n/f),n%=f,t.splice(n,0,r),n++}return String.fromCodePoint(...t)}function Sd(e){return e<26?String.fromCharCode(e+97):String.fromCharCode(e-26+48)}var KR=new RegExp(Zn.source,"gu");function Cd(e){let t=e.replace(KR,""),r=t.length,n=r>0?[t,"-"]:[],o=Array.from(e,p=>p.codePointAt(0)),i=Td,a=0,m=kd,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=or;;g+=or){let y=g<=m?ei:g>=m+ti?ti:g-m;if(d<y)break;let I=y+(d-y)%(or-y);n.push(Sd(I)),d=Math.floor((d-y)/(or-y))}n.push(Sd(d)),m=wd(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)$/,Rd=/^(?:L|EN|ES|CS|ET|ON|BN|NSM)$/,zR=/^(?:R|AL|AN)$/;function Pd(e){if(Ts(e))try{return Cs(ws(e.slice(4).toLowerCase()))}catch{return!1}return Cs(e)}function Ad(e){let t=String.fromCodePoint(e);return bd.test(t)?"EN":ld.test(t)?"AN":Su.test(t)?"NSM":ks.test(t)?"R":hd.test(t)?"AL":ku.test(t)?"L":"ON"}function Cs(e){for(let t of e)if(zR.test(Ad(t.codePointAt(0))))return!0;return!1}function Rs(e){let t=!1,r=Rd,n=!1,o=!1,i=!0;for(let a of e){let m=Ad(a.codePointAt(0));if(i){if(m!=="L"&&m!=="R"&&m!=="AL")return!1;t=m==="R"||m==="AL",r=t?HR:Rd,i=!1}if(!r.test(m))return!1;m==="EN"?n=!0:m==="AN"&&(o=!0)}return!(t&&n&&o)}function WR(e){return Zn.test(e)&&Cd(e).length+4>63}function VR(e){return e[0]==="-"||e[e.length-1]==="-"?!0:e.slice(2).join("").startsWith("--")}function Ps(e){if(WR(e)||Cs(e)&&!Rs(e))return!1;let t=[...e],r=t.map(i=>i.codePointAt(0)),n=r.length;if(VR(t)||gd.test(t[0]))return!1;let o=!1;for(let i=0;i<n;i++){let a=r[i],m=t[i];if(Id.test(m)||!$d.test(m))return!1;xd.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||!yd.test(t[i+1]))return!1;break;case 1523:case 1524:if(!c||!ks.test(t[i-1]))return!1;break;case 8204:if(!c||c<128&&!Tu.test(t[i-1]))return!1;break;case 8205:if(!c||!Tu.test(t[i-1]))return!1;break;case 12539:break}}return!(e.includes("\u30FB")&&!o)}function As(e){if(!Ts(e))return!1;try{let t=e.slice(4).toLowerCase();if(t.lastIndexOf("-")===0)return!1;let r=ws(t);return Zn.test(r)?Ps(r):!1}catch{return!1}}function JR(e){return e.length>0&&e.length<=63}function YR(e){return JR(e)&&(As(e)||Ed(e))}function Fd(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)&&(As(e)||Ps(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 Ld(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=>Pd(o));return r.every(o=>XR(o)&&(!n||Rs(o)))}function Os(e){return Fd(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 Ms(e){return e0.test(e.normalize("NFC"))}function vs(e){return Ld(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 Fs(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 Ls(e){return r0.test(e)}var n0=/[\x00-\x20\x7F\\]|%(?![0-9a-fA-F]{2})/,o0=/^[a-zA-Z][a-zA-Z0-9+\-.]*\/\//;function Ds(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 js(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 Ns(e){return a0.test(e)}var m0=/^(?:\/(?:[^~/]|~0|~1)*)*$/;function qs(e){return m0.test(e)}function _s(e){try{return new RegExp(e,"u"),!0}catch{return!1}}var u0=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;function Us(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 Bs(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 Gs(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 Ks(e){return f0.test(e)}function Hs(e){return URL.canParse(e)}var d0=/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;function zs(e){return d0.test(e)}var be=new Map;function jd(){be.clear()}function l0(){return[...be.entries()]}function g0(e,t){be.set(e,t)}function y0(e){return be.has(e)}function x0(e){return be.get(e)}function h0(e,t){return be.get(e)?.(t)??!0}function Nd(){jd(),be.set("date-time",$s),be.set("date",Qn),be.set("duration",Es),be.set("email",Ss),be.set("hostname",Os),be.set("idn-email",Ms),be.set("idn-hostname",vs),be.set("ipv4",Fs),be.set("ipv6",Ls),be.set("iri-reference",Ds),be.set("iri",js),be.set("json-pointer-uri-fragment",Ns),be.set("json-pointer",qs),be.set("regex",_s),be.set("relative-json-pointer",Us),be.set("time",Xn),be.set("uri-reference",Bs),be.set("uri-template",Gs),be.set("uri",Ks),be.set("url",Hs),be.set("uuid",zs)}Nd();function Ru(e,t,r,n){return ri.Test(r.format,n)}function qd(e,t,r,n,o,i){return Ru(e,t,o,i)||t.AddError("format",r,n,{format:o.format})}function _d(e,t,r,n){let o=hs(r)?r.then:!0,i=cs(r)?r.else:!0;return te(e,t,r.if,n)?te(e,t,o,n):te(e,t,i,n)}function Ud(e,t,r,n,o,i){let a=hs(o)?o.then:!0,m=cs(o)?o.else:!0,c=new ut,p=ge(e,c,`${r}/if`,n,o.if,i)?ge(e,c,`${r}/then`,n,a,i)||t.AddError("if",r,n,{failingKeyword:"then"}):ge(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)||Ut(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)||Bt(e,t,c,p,a,i[m])&&t.AddIndex(m)})}function $0(e,t,r,n){let o=Sn(r)?r.prefixItems.length:0;return s.Every(n,o,(i,a)=>Ut(e,t,r.items,i)&&t.AddIndex(a))}function E0(e,t,r,n,o,i){let a=Sn(o)?o.prefixItems.length:0;return s.EveryAll(i,a,(m,c)=>{let p=`${r}/items`,f=`${n}/${c}`;return Bt(e,t,p,f,o.items,m)&&t.AddIndex(c)})}function Bd(e,t,r,n){return fs(r)?I0(e,t,r,n):$0(e,t,r,n)}function Gd(e,t,r,n,o,i){return fs(o)?b0(e,t,r,n,o,i):E0(e,t,r,n,o,i)}function S0(e){return Jr(e)}function Pu(e,t,r,n){if(!S0(r))return!0;let o=s.Counted(n,i=>te(e,t,r.contains,i));return s.IsLessEqualThan(o,r.maxContains)}function Kd(e,t,r,n,o,i){let a=$n(o)?o.minContains:1;return Pu(e,t,o,i)||t.AddError("contains",r,n,{minContains:a,maxContains:o.maxContains})}function Au(e,t,r,n){return s.IsLessEqualThan(n,r.maximum)}function Hd(e,t,r,n,o,i){return Au(e,t,o,i)||t.AddError("maximum",r,n,{comparison:"<=",limit:o.maximum})}function Ou(e,t,r,n){return s.IsLessEqualThan(n.length,r.maxItems)}function zd(e,t,r,n,o,i){return Ou(e,t,o,i)||t.AddError("maxItems",r,n,{limit:o.maxItems})}function Mu(e,t,r,n){return s.IsMaxLength(n,r.maxLength)}function Wd(e,t,r,n,o,i){return Mu(e,t,o,i)||t.AddError("maxLength",r,n,{limit:o.maxLength})}function vu(e,t,r,n){return s.IsLessEqualThan(s.Keys(n).length,r.maxProperties)}function Vd(e,t,r,n,o,i){return vu(e,t,o,i)||t.AddError("maxProperties",r,n,{limit:o.maxProperties})}function k0(e){return Jr(e)}function Fu(e,t,r,n){if(!k0(r))return!0;let o=s.Counted(n,(i,a)=>te(e,t,r.contains,i)&&t.AddIndex(a));return s.IsGreaterEqualThan(o,r.minContains)}function Jd(e,t,r,n,o,i){return Fu(e,t,o,i)||t.AddError("contains",r,n,{minContains:o.minContains})}function Lu(e,t,r,n){return s.IsGreaterEqualThan(n,r.minimum)}function Yd(e,t,r,n,o,i){return Lu(e,t,o,i)||t.AddError("minimum",r,n,{comparison:">=",limit:o.minimum})}function Du(e,t,r,n){return s.IsGreaterEqualThan(n.length,r.minItems)}function Qd(e,t,r,n,o,i){return Du(e,t,o,i)||t.AddError("minItems",r,n,{limit:o.minItems})}function ju(e,t,r,n){return s.IsMinLength(n,r.minLength)}function Xd(e,t,r,n,o,i){return ju(e,t,o,i)||t.AddError("minLength",r,n,{limit:o.minLength})}function Nu(e,t,r,n){return s.IsGreaterEqualThan(s.Keys(n).length,r.minProperties)}function Zd(e,t,r,n,o,i){return Nu(e,t,o,i)||t.AddError("minProperties",r,n,{limit:o.minProperties})}function qu(e,t,r,n){return s.IsMultipleOf(n,r.multipleOf)}function el(e,t,r,n,o,i){return qu(e,t,o,i)||t.AddError("multipleOf",r,n,{multipleOf:o.multipleOf})}function _u(e,t,r,n){let o=new bt;return!te(e,o,r.not,n)&&t.Merge([o])}function tl(e,t,r,n,o,i){return _u(e,t,o,i)||t.AddError("not",r,n,{})}function rl(e,t,r,n){let o=r.oneOf.reduce((i,a)=>{let m=new bt;return te(e,m,a,n)?[...i,m]:i},[]);return s.IsEqual(o.length,1)&&t.Merge(o)}function nl(e,t,r,n,o,i){let a=[],m=[],c=o.oneOf.reduce((f,d,g)=>{let y=new ut,I=`${r}/oneOf/${g}`,h=ge(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 Uu(e,t,r,n){return(s.IsString(r.pattern)?Xr(r.pattern):r.pattern).test(n)}function ol(e,t,r,n,o,i){return Uu(e,t,o,i)||t.AddError("pattern",r,n,{pattern:o.pattern})}function il(e,t,r,n){return s.Every(s.Entries(r.patternProperties),0,([o,i])=>{let a=Xr(o);return s.Every(s.Entries(n),0,([m,c])=>!a.test(m)||Ut(e,t,i,c)&&t.AddKey(m))})}function sl(e,t,r,n,o,i){return s.EveryAll(s.Entries(o.patternProperties),0,([a,m])=>{let c=`${r}/patternProperties/${At(a)}`,p=Xr(a);return s.EveryAll(s.Entries(i),0,([f,d])=>{let g=`${n}/${At(f)}`;return!p.test(f)||Bt(e,t,c,g,m,d)&&t.AddKey(f)})})}function al(e,t,r,n){return s.IsEqual(n.length,0)||s.Every(r.prefixItems,0,(o,i)=>s.IsLessEqualThan(n.length,i)||Ut(e,t,o,n[i])&&t.AddIndex(i))}function ml(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)||Bt(e,t,c,p,a,i[m])&&t.AddIndex(m)})}function Bu(e,t){return e.includes(t)||qe.Get().exactOptionalPropertyTypes}function Gu(e,t){return s.IsUndefined(e[t])}function ul(e,t,r,n){let o=kn(r)?r.required:[];return s.Every(s.Entries(r.properties),0,([a,m])=>{let c=!s.HasPropertyKey(n,a)||Ut(e,t,m,n[a])&&t.AddKey(a);return Bu(o,a)?c:Gu(n,a)||c})}function cl(e,t,r,n,o,i){let a=kn(o)?o.required:[];return s.EveryAll(s.Entries(o.properties),0,([c,p])=>{let f=`${r}/properties/${At(c)}`,d=`${n}/${At(c)}`,g=()=>!s.HasPropertyKey(i,c)||Bt(e,t,f,d,p,i[c])&&t.AddKey(c);return Bu(a,c)?g():Gu(i,c)||g()})}function pl(e,t,r,n){return s.Every(s.Keys(n),0,(o,i)=>te(e,t,r.propertyNames,o))}function fl(e,t,r,n,o,i){let a=[];return s.EveryAll(s.Keys(i),0,(c,p)=>{let f=`${n}/${At(c)}`,d=`${r}/propertyNames`,g=ge(e,t,d,f,o.propertyNames,c);return g||a.push(c),g})||t.AddError("propertyNames",r,n,{propertyNames:a})}function dl(e,t,r,n){let o=Qt.RecursiveRef(e,r)??!1,i=o?{...e,pendingResource:!0}:e;return q(o)&&te(i,t,o,n)}function ll(e,t,r,n,o,i){let a=Qt.RecursiveRef(e,o)??!1,m=a?{...e,pendingResource:!0}:e;return q(a)&&ge(m,t,r,n,a,i)}function gl(e,t,r,n){let o=Qt.Ref(e,r),i=o.schema??!1,a=new bt,m=q(i)&&te(o.stack,a,i,n);return m&&t.Merge([a]),m}function yl(e,t,r,n,o,i){let a=Qt.Ref(e,o),m=a.schema??!1,c=new ut,p=q(m)&&ge(a.stack,c,r,n,m,i);return p&&t.Merge([c]),p||t.AddErrors(c.GetErrors()),p}function xl(e,t,r,n){return s.Every(r.required,0,o=>s.HasPropertyKey(n,o))}function hl(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 Ku(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 Il(e,t,r,n,o){return s.Some(r,i=>Ku(e,t,i,n,o))}function bl(e,t,r,n){return s.IsArray(r.type)?Il(e,t,r.type,r,n):Ku(e,t,r.type,r,n)}function $l(e,t,r,n,o,i){return(s.IsArray(o.type)?Il(e,t,o.type,o,i):Ku(e,t,o.type,o,i))||t.AddError("type",r,n,{type:o.type})}function El(e,t,r,n){let o=t.GetIndices();return s.Every(n,0,(i,a)=>(o.has(a)||te(e,t,r.unevaluatedItems,i))&&t.AddIndex(a))}function Sl(e,t,r,n,o,i){let a=t.GetIndices(),m=[];return s.EveryAll(i,0,(p,f)=>{let d=new ut,g=(a.has(f)||ge(e,d,r,n,o.unevaluatedItems,p))&&t.AddIndex(f);return g||m.push(f),g})||t.AddError("unevaluatedItems",r,n,{unevaluatedItems:m})}function kl(e,t,r,n){let o=t.GetKeys();return s.Every(s.Entries(n),0,([i,a])=>o.has(i)||te(e,t,r.unevaluatedProperties,a)&&t.AddKey(i))}function Tl(e,t,r,n,o,i){let a=t.GetKeys(),m=[];return s.EveryAll(s.Entries(i),0,([p,f])=>{let d=new ut,g=a.has(p)||ge(e,d,r,n,o.unevaluatedProperties,f)&&t.AddKey(p);return g||m.push(p),g})||t.AddError("unevaluatedProperties",r,n,{unevaluatedProperties:m})}var Dr={};_t(Dr,{Hash:()=>Ol,HashCode:()=>q0});function Re(){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 Mt={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},Vs=8997,ni=33826,Js=40164,Ys=52210,Rl=new Float64Array(1),Pl=new DataView(Rl.buffer),Al=new Uint8Array(Rl.buffer);function Qe(e){let t=Vs^e,r=t*435,n=ni*435+(r>>>16),o=Js*435+(n>>>16)+(t<<8),i=Ys*435+(o>>>16)+(ni<<8);Vs=r&65535,ni=n&65535,Js=o&65535,Ys=i&65535}function C0(e){Qe(Mt.Array);for(let t of e)Zr(t)}function R0(e){Qe(Mt.BigInt),Pl.setBigInt64(0,e);for(let t of Al)Qe(t)}function wl(e){Qe(Mt.Boolean),Qe(e?1:0)}function P0(e){Qe(Mt.Constructor),Zr(e.toString())}function A0(e){Qe(Mt.Date),Zr(e.getTime())}function O0(e){Qe(Mt.Function),Zr(e.toString())}function M0(e){Qe(Mt.Null)}function Cl(e){Qe(Mt.Number),Pl.setFloat64(0,e,!0);for(let t of Al)Qe(t)}function v0(e){Qe(Mt.Object);for(let t of T0(e).sort())Zr(t),Zr(e[t])}function F0(e){Qe(Mt.RegExp),Hu(e.toString())}var L0=new TextEncoder;function Hu(e){Qe(Mt.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)))Qe(n);return}Qe(r)}}function D0(e){Qe(Mt.Symbol),Zr(e.toString())}function j0(e){Qe(Mt.TypeArray);let t=new Uint8Array(e.buffer);for(let r=0;r<t.length;r++)Qe(t[r])}function N0(e){return Qe(Mt.Undefined)}function Zr(e){return Ke.IsTypeArray(e)?j0(e):Ke.IsDate(e)?A0(e):Ke.IsRegExp(e)?F0(e):Ke.IsBoolean(e)?wl(e.valueOf()):Ke.IsString(e)?Hu(e.valueOf()):Ke.IsNumber(e)?Cl(e.valueOf()):w0(e)?Cl(e):s.IsArray(e)?C0(e):s.IsBoolean(e)?wl(e):s.IsBigInt(e)?R0(e):s.IsConstructor(e)?P0(e):s.IsNull(e)?M0(e):s.IsObject(e)?v0(e):s.IsString(e)?Hu(e):s.IsSymbol(e)?D0(e):s.IsUndefined(e)?N0(e):s.IsFunction(e)?O0(e):Re()}function Ws(e){return e.toString(16).padStart(4,"0")}function q0(e){return BigInt(`0x${Ol(e)}`)}function Ol(e){return Vs=8997,ni=33826,Js=40164,Ys=52210,Zr(e),`${Ws(Ys)}${Ws(Js)}${Ws(ni)}${Ws(Vs)}`}function Ml(e){return!s.IsEqual(e.uniqueItems,!1)}function vl(e,t,r,n){if(!Ml(r))return!0;let o=new Set(n.map(Dr.Hash)).size,i=n.length;return s.IsEqual(o,i)}function Fl(e,t,r,n,o,i){if(!Ml(o))return!0;let a=new Set,m=i.reduce((p,f,d)=>{let g=Dr.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 Ut(e,t,r,n){return t.Push()&&te(e,t,r,n)&&t.Pop()}function te(e,t,r,n){let o=Jn(e,r);return In(r)?cu(o,t,r,n):(!su(r)||bl(o,t,r,n))&&(!(s.IsObject(n)&&!s.IsArray(n))||(!kn(r)||xl(o,t,r,n))&&(!Yt(r)||jf(o,t,r,n))&&(!Qm(r)||zf(o,t,r,n))&&(!Xm(r)||Vf(o,t,r,n))&&(!ms(r)||Yf(o,t,r,n))&&(!Hn(r)||il(o,t,r,n))&&(!zn(r)||ul(o,t,r,n))&&(!gs(r)||pl(o,t,r,n))&&(!Ko(r)||Nu(o,t,r,n))&&(!ou(r)||vu(o,t,r,n)))&&(!s.IsArray(n)||(!is(r)||Ff(o,t,r,n))&&(!Jr(r)||fu(o,t,r,n))&&(!bn(r)||Bd(o,t,r,n))&&(!$n(r)||Fu(o,t,r,n))&&(!ru(r)||Pu(o,t,r,n))&&(!En(r)||Du(o,t,r,n))&&(!Bo(r)||Ou(o,t,r,n))&&(!Sn(r)||al(o,t,r,n))&&(!Qr(r)||vl(o,t,r,n)))&&(!s.IsString(n)||(!Go(r)||ju(o,t,r,n))&&(!nu(r)||Mu(o,t,r,n))&&(!Uo(r)||Ru(o,t,r,n))&&(!Ho(r)||Uu(o,t,r,n)))&&(!(s.IsNumber(n)||s.IsBigInt(n))||(!vr(r)||Eu(o,t,r,n))&&(!eu(r)||$u(o,t,r,n))&&(!Fr(r)||Lu(o,t,r,n))&&(!tu(r)||Au(o,t,r,n))&&(!iu(r)||qu(o,t,r,n)))&&(!xs(r)||gl(o,t,r,n))&&(!ys(r)||dl(o,t,r,n))&&(!us(r)||sd(o,t,r,n))&&(!Ym(r)||pu(o,t,r,n))&&(!Zm(r)||bu(o,t,r,n))&&(!ps(r)||_d(o,t,r,n))&&(!ds(r)||_u(o,t,r,n))&&(!ss(r)||qf(o,t,r,n))&&(!as(r)||Uf(o,t,r,n))&&(!ls(r)||rl(o,t,r,n))&&(!Wo(r)||!s.IsArray(n)||El(o,t,r,n))&&(!Vo(r)||!s.IsObject(n)||kl(o,t,r,n))&&(!os(r)||Cf(o,t,r,n))}function Bt(e,t,r,n,o,i){return t.Push()&&ge(e,t,r,n,o,i)&&t.Pop()}function ge(e,t,r,n,o,i){if(t.AtCapacity())return!1;let a=Jn(e,o);return In(o)?Gf(a,t,r,n,o,i):!!(+(!su(o)||$l(a,t,r,n,o,i))&+(!(s.IsObject(i)&&!s.IsArray(i))||!!(+(!kn(o)||hl(a,t,r,n,o,i))&+(!Yt(o)||Nf(a,t,r,n,o,i))&+(!Qm(o)||Wf(a,t,r,n,o,i))&+(!Xm(o)||Jf(a,t,r,n,o,i))&+(!ms(o)||Qf(a,t,r,n,o,i))&+(!Hn(o)||sl(a,t,r,n,o,i))&+(!zn(o)||cl(a,t,r,n,o,i))&+(!gs(o)||fl(a,t,r,n,o,i))&+(!Ko(o)||Zd(a,t,r,n,o,i))&+(!ou(o)||Vd(a,t,r,n,o,i))))&+(!s.IsArray(i)||!!(+(!is(o)||Lf(a,t,r,n,o,i))&+(!Jr(o)||Hf(a,t,r,n,o,i))&+(!bn(o)||Gd(a,t,r,n,o,i))&+(!$n(o)||Jd(a,t,r,n,o,i))&+(!ru(o)||Kd(a,t,r,n,o,i))&+(!En(o)||Qd(a,t,r,n,o,i))&+(!Bo(o)||zd(a,t,r,n,o,i))&+(!Sn(o)||ml(a,t,r,n,o,i))&+(!Qr(o)||Fl(a,t,r,n,o,i))))&+(!s.IsString(i)||!!(+(!Go(o)||Xd(a,t,r,n,o,i))&+(!nu(o)||Wd(a,t,r,n,o,i))&+(!Uo(o)||qd(a,t,r,n,o,i))&+(!Ho(o)||ol(a,t,r,n,o,i))))&+(!(s.IsNumber(i)||s.IsBigInt(i))||!!(+(!vr(o)||cd(a,t,r,n,o,i))&+(!eu(o)||ud(a,t,r,n,o,i))&+(!Fr(o)||Yd(a,t,r,n,o,i))&+(!tu(o)||Hd(a,t,r,n,o,i))&+(!iu(o)||el(a,t,r,n,o,i))))&+(!xs(o)||yl(a,t,r,n,o,i))&+(!ys(o)||ll(a,t,r,n,o,i))&+(!us(o)||ad(a,t,r,n,o,i))&+(!Ym(o)||Kf(a,t,r,n,o,i))&+(!Zm(o)||md(a,t,r,n,o,i))&+(!ps(o)||Ud(a,t,r,n,o,i))&+(!ds(o)||tl(a,t,r,n,o,i))&+(!ss(o)||_f(a,t,r,n,o,i))&+(!as(o)||Bf(a,t,r,n,o,i))&+(!ls(o)||nl(a,t,r,n,o,i))&+(!Wo(o)||!s.IsArray(i)||Sl(a,t,r,n,o,i))&+(!Vo(o)||!s.IsObject(i)||Tl(a,t,r,n,o,i)))&&(!os(o)||Rf(a,t,r,n,o,i))}function Dl(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=Dl;function jl(){return _0}var l={};_t(l,{Assign:()=>B0,Clone:()=>G0,Create:()=>H0,Discard:()=>z0,Metrics:()=>ir,Update:()=>Y0});var ir={assign:0,create:0,clone:0,discard:0,update:0};function Gt(e){return[...s.Keys(e),...s.Symbols(e)]}function Nl(e,t){if(!t.has(e)){t.add(e);for(let r of Gt(e)){let n=Object.getOwnPropertyDescriptor(e,r);!n||!("value"in n)||s.IsObject(n.value)&&Nl(n.value,t)}Object.freeze(e)}}function en(e){return qe.Get().immutableTypes&&Nl(e,new WeakSet),e}function B0(e,t){ir.assign+=1;let r={},n=Gt(t),o=Gt(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 en(r)}function G0(e){ir.clone+=1;let t={};for(let r of Gt(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 ql(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={}){ir.create+=1;let n=ql(t,r),o=qe.Get().enumerableKind?ql(n,e):K0(n,e);return en(o)}function z0(e,t){ir.discard+=1;let r={};for(let n of Gt(e)){if(t.includes(n))continue;let o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,o)}return en(r)}function W0(e,t,r,n){for(let o of Gt(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=qe.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){ir.update+=1;let n={},o=Gt(t),i=Gt(r);return W0(e,o,i,n),V0(t,o,n),J0(r,i,n),en(n)}function Qs(...e){let[t,r,n]=z.Match(e,{3:(f,d,g)=>[f,d,g],2:(f,d)=>[{},f,d]}),o=Vn(t,r),i=new ut,a=ge(o,i,"#","",r,n),m=i.GetErrors(),c=jl(),p=m.map(f=>({...f,message:c(f)}));return[a,p]}var Ul=0;function Xs(){let e=ns();Ul=e.maxErrors,e.maxErrors=e.maxParseErrors}function Zs(){let e=ns();e.maxErrors=Ul}function Wu(...e){let[t,r,n]=z.Match(e,{3:(a,m,c)=>[a,m,c],2:(a,m)=>[{},a,m]}),o=Vn(t,r),i=new bt;return te(o,i,r,n)}function V(...e){let[t,r,n]=z.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]});return Wu(t,r,n)}function sr(...e){let[t,r,n]=z.Match(e,{3:(a,m,c)=>[a,m,c],2:(a,m)=>[{},a,m]}),[o,i]=Qs(t,r,n);return i}var jr=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 ea(...e){let[t,r,n]=z.Match(e,{3:(i,a,m)=>[i,a,m],2:(i,a)=>[{},i,a]});if(!V(t,r,n))throw new jr("Assert",n,sr(t,r,n))}function w(e,t){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.IsEqual(e["~kind"],t)}function Ee(e){return s.IsObject(e)}function C(e,t,r){return l.Create({"~kind":"Deferred"},{type:"deferred",action:e,parameters:t,options:r},{})}function tn(e){return w(e,"Deferred")}function yr(e,t){return l.Update(e,{"~readonly":!0},t)}function Bl(e,t,r,n){let o=$(e,t,r);return yr(o,n)}function xr(e,t){return l.Update(e,{"~optional":!0},t)}function Gl(e,t,r,n){let o=$(e,t,r);return xr(o,n)}function Tt(e,t){return l.Create({"~kind":"Array"},{type:"array",items:e},t)}function Y(e){return w(e,"Array")}function eo(e){return l.Discard(e,["~kind","type","items"])}function hr(e,t,r={}){return l.Create({"~kind":"Constructor"},{type:"constructor",parameters:e,instanceType:t},r)}function Pe(e){return w(e,"Constructor")}function Kl(e){return l.Discard(e,["~kind","type","parameters","instanceType"])}function Ir(e,t,r={}){return l.Create({"~kind":"Function"},{type:"function",parameters:e,returnType:t},r)}function Ae(e){return w(e,"Function")}function Hl(e){return l.Discard(e,["~kind","type","parameters","returnType"])}function Ye(e,t){return l.Create({"~kind":"Ref"},{$ref:e},t)}function oe(e){return w(e,"Ref")}function rn(e,t){return l.Create({"~kind":"Generic"},{type:"generic",parameters:e,expression:t})}function to(e){return w(e,"Generic")}function ro(e){return l.Create({"~kind":"Any"},{},e)}function Te(e){return w(e,"Any")}var zl="(?!)";function me(e){return l.Create({"~kind":"Never"},{not:{}},e)}function wt(e){return w(e,"Never")}function br(e,t={}){return C("AddOptional",[e],t)}function ta(e,t={}){return xr(e,t)}function Wl(e){return ta(e)}function _e(e){return Ee(e)&&s.HasPropertyKey(e,"~optional")}function Vl(e){return s.Keys(e).filter(t=>!_e(e[t]))}function ra(e){return s.Keys(e)}function na(e){return s.Values(e)}function L(e,t={}){let r=Vl(e),n=r.length>0?{required:r}:{};return l.Create({"~kind":"Object"},{type:"object",...n,properties:e},t)}function M(e){return w(e,"Object")}function Jl(e){return l.Discard(e,["~kind","type","properties","required"])}function He(e){return l.Create({"~kind":"Unknown"},{},e)}function Ue(e){return w(e,"Unknown")}function $r(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 fe(e){return w(e,"Cyclic")}function Yl(e){return l.Update(e,{"~unsafe":null},{})}function oa(e){return s.IsObjectNotArray(e)&&s.HasPropertyKey(e,"~unsafe")&&s.IsNull(e["~unsafe"])}function oi(...e){let[t,r]=z.Match(e,{2:(n,o)=>[n,o,o],1:n=>[n,He(),He()]});return l.Create({"~kind":"Infer"},{type:"infer",name:t,extends:r},{})}function Be(e){return w(e,"Infer")}function wn(e,t,r,n={}){return l.Create({"~kind":"Dependent"},{if:e,then:t,else:r},n)}function Oe(e){return w(e,"Dependent")}function Ql(e){return l.Discard(e,["~kind","if","then","else"])}function Xl(e){return s.IsObjectNotArray(e)}function Zl(e){return s.Keys(e).filter(r=>isNaN(r)).reduce((r,n)=>[...r,e[n]],[])}function eg(e){return s.IsString(e)||s.IsNumber(e)}function tg(e,t){let r=Xl(e)?Zl(e):e;return l.Create({"~kind":"Enum"},{enum:r},t)}function Me(e){return w(e,"Enum")}function lt(e,t={}){return l.Create({"~kind":"Intersect"},{allOf:e},t)}function v(e){return w(e,"Intersect")}function rg(e){return l.Discard(e,["~kind","allOf"])}var ii=class{constructor(t,r){this.type=t,this.decode=r}Encode(t){let r=this.type,n=$t(r)?a=>this.decode(r["~codec"].decode(a)):this.decode,o=$t(r)?a=>r["~codec"].encode(t(a)):t,i={decode:n,encode:o};return l.Update(this.type,{"~codec":i},{})}},si=class{constructor(t){this.type=t}Decode(t){return new ii(this.type,t)}};function ia(e){return new si(e)}function ng(e,t){return ia(e).Decode(t).Encode(()=>{throw Error("Encode not implemented")})}function og(e,t){return ia(e).Decode(()=>{throw Error("Decode not implemented")}).Encode(t)}function $t(e){return Ee(e)&&s.HasPropertyKey(e,"~codec")&&s.IsObject(e["~codec"])&&s.HasPropertyKey(e["~codec"],"encode")&&s.HasPropertyKey(e["~codec"],"decode")}function ig(e){return no(e)}function Cn(e){return Ee(e)&&s.HasPropertyKey(e,"~immutable")}function Er(e,t={}){return C("AddReadonly",[e],t)}function sa(e,t={}){return yr(e,t)}function sg(e){return sa(e)}function Nr(e){return Ee(e)&&s.HasPropertyKey(e,"~readonly")}function Z0(e,t){let r=ai(e)?[...e["~refine"],t]:[t];return l.Update(e,{"~refine":r},{})}function ag(...e){let[t,r,n]=z.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 ai(e){return Ee(e)&&s.HasPropertyKey(e,"~refine")&&s.IsArray(e["~refine"])&&s.Every(e["~refine"],0,t=>eP(t))}var mg="-?(?:0|[1-9][0-9]*)n";function mi(e){return l.Create({"~kind":"BigInt"},{type:"bigint"},e)}function vt(e){return w(e,"BigInt")}function aa(e){return l.Create({"~kind":"Boolean"},{type:"boolean"},e)}function Et(e){return w(e,"Boolean")}function ui(e){return l.Create({"~kind":"Identifier"},{name:e})}function ug(e){return w(e,"Identifier")}var ma="-?(?:0|[1-9][0-9]*)";function Rn(e){return l.Create({"~kind":"Integer"},{type:"integer"},e)}function Xe(e){return w(e,"Integer")}var Vu=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 Vu(e)})()}function W(e,t){return l.Create({"~kind":"Literal"},{type:tP(e),const:e},t)}function ua(e){return s.IsBigInt(e)||s.IsBoolean(e)||s.IsNumber(e)||s.IsString(e)}function cg(e){return J(e)&&s.IsBigInt(e.const)}function pg(e){return J(e)&&s.IsBoolean(e.const)}function ca(e){return J(e)&&s.IsNumber(e.const)}function pa(e){return J(e)&&s.IsString(e.const)}function J(e){return w(e,"Literal")}function oo(e){return l.Create({"~kind":"Null"},{type:"null"},e)}function Sr(e){return w(e,"Null")}var fa="-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?";function Ft(e){return l.Create({"~kind":"Number"},{type:"number"},e)}function Se(e){return w(e,"Number")}function io(e){return l.Create({"~kind":"Symbol"},{type:"symbol"},e)}function kr(e){return w(e,"Symbol")}function Pn(...e){let[t,r,n]=z.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[o,i,i],1:o=>[o,He(),He()]});return l.Create({"~kind":"Parameter"},{name:t,extends:r,equals:n},{})}function fg(e){return w(e,"Parameter")}var da=".*";function ct(e){return l.Create({"~kind":"String"},{type:"string"},e)}function ze(e){return w(e,"String")}function _(e,t={}){return l.Create({"~kind":"Union"},{anyOf:e},t)}function S(e){return w(e,"Union")}function dg(e){return l.Discard(e,["~kind","anyOf"])}function ci(e){let t=lg(e);return s.IsEqual(t.length,2)?t[0]:[]}function rP(e){return!0}function gg(e){return s.ShiftLeft(e,(t,r)=>nP(t)?gg(r):!1,()=>!0)}function yg(e){return s.IsEqual(e.length,0)?!1:gg(e)}function nP(e){return S(e)?yg(e.anyOf):J(e)?rP(e.const):!1}function la(e){return yg(e)}function ga(e){return l.Create({"~kind":"TemplateLiteral"},{type:"string",pattern:e},{})}function xg(e,t,r=[]){return s.ShiftLeft(e,(n,o)=>xg(o,t,[...r,`${n}${t}`]),()=>r)}function oP(e,t){return s.IsEqual(e.length,0)?[`${t}`]:xg(e,t)}function hg(e,t,r=[]){return s.ShiftLeft(t,(n,o)=>hg(e,o,[...r,...Ig(e,n)]),()=>r)}function Ig(e,t){return S(t)?hg(e,t.anyOf):J(t)?oP(e,t.const):Re()}function bg(e,t){return s.ShiftLeft(t,(r,n)=>bg(Ig(e,r),n),()=>e)}function iP(e){return e.map(t=>W(t))}function sP(e){let t=bg([],e),r=iP(t);return _(r)}function aP(e){return s.IsEqual(e.length,0)?Re():s.IsEqual(e.length,1)&&J(e[0])?e[0]:sP(e)}function Ju(e){let t=ci(e);return s.IsEqual(t.length,0)?ct():la(t)?aP(t):ga(e)}function so(e){let t=Ju(e);return de(t)?ct():t}function Ct(e,t){let r="object",n={[e]:t};return l.Create({"~kind":"Record"},{type:r,patternProperties:n})}function $g(e){return Ct(ar,e)}function Eg(e){return L({true:e,false:e})}function ve(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 G(e){return w(e,"Tuple")}function Sg(e){return l.Discard(e,["~kind","type","items","minItems","additionalItems"])}function Yu(e){return e.reduceRight((r,n,o)=>({[o]:n,...r}),{})}function kg(e){let t=Yu(e.items);return L(t)}function mP(e){return l.Discard(e,["~optional"])}function An(e,t){return l.Update(mP(e),{},t)}function Tg(e,t,r,n){let o=$(e,t,r);return An(o,n)}function uP(e){return l.Discard(e,["~readonly"])}function ao(e,t){return l.Update(uP(e),{},t)}function wg(e,t,r,n){let o=$(e,t,r);return ao(o,n)}function ya(e,t){let r=Nr(e)&&Nr(t),n=_e(e)&&_e(t),o=Fe([e,t]),i=ao(An(o,{}),{});return r&&n?yr(xr(i,{}),{}):r?yr(i,{}):n?xr(i,{}):i}function Cg(e,t){let r=Nr(e)||Nr(t),n=_e(e)||_e(t),o=ao(An(e,{}),{}),i=ao(An(t,{}),{}),a=Rt([o,i]);return r&&n?yr(xr(a,{}),{}):r?yr(a,{}):n?xr(a,{}):a}function cP(e,t,r){return r in e?r in t?ya(e[r],t[r]):e[r]:r in t?t[r]:me()}function pP(e,t){return[...new Set([...s.Keys(e),...s.Keys(t)])].reduce((o,i)=>({...o,[i]:cP(e,t,i)}),{})}function Rg(e){return M(e)?e.properties:G(e)?Yu(e.items):{}}function Pg(e,t){let r=Rg(e),n=Rg(t),o=pP(r,n);return L(o)}function fP(e,t){let r=mo(e,t);return s.IsEqual(r,fi)?e:s.IsEqual(r,di)||s.IsEqual(r,pi)?t:me()}function Ag(e){return M(e)||G(e)}function dP(e,t){let r=Ag(e),n=Ag(t);return r&&n?Pg(e,t):r&&!n?e:!r&&n?t:fP(e,t)}function Og(e,t){return wt(e)||Te(e)?e:Ue(e)||wt(t)||Te(t)?t:Ue(t)?e:dP(e,t)}function lP(e,t){return S(e)||S(t)}function gP(e,t){let r=Xt(e),n=Xt(t);return lP(r,n)?Fe([r,n]):Og(r,n)}function Mg(e,t,r=[]){return s.ShiftLeft(t,(n,o)=>Mg(e,o,[...r,gP(n,e)]),()=>s.IsEqual(r.length,0)?[e]:r)}function vg(e,t,r=[]){return s.ShiftLeft(e,(n,o)=>vg(o,t,[...r,...li([n],t)]),()=>r)}function li(e,t=[]){return s.ShiftLeft(e,(r,n)=>S(r)?li(n,vg(r.anyOf,t)):li(n,Mg(r,t)),()=>t)}function yP(e,t){let r=pt({},e,t);return N.IsExtendsTrueLike(r)?[]:[e]}function Fg(e,t,r=[]){return s.ShiftLeft(e,(n,o)=>Fg(o,t,[...r,...yP(n,t)]),()=>r)}function xa(e,t){let r=Xt(e),n=S(r)?r.anyOf:[r],o=Fg(n,t);return Rt(o)}function mr(e,t,r){let n=Fe([e,t]),o=xa(r,e);return Rt([n,o])}function St(e,t=[]){return s.ShiftLeft(e,(r,n)=>St(n,[...t,W(r)]),()=>Rt(t))}function Fe(e){let t=li(e),r=Qu(t);return Rt(r)}function gt(e){let t=so(e);return Xt(t)}function Rt(e){let t=Qu(e);return nn(t)}function Xt(e){return Oe(e)?mr(e.if,e.then,e.else):Me(e)?St(e.enum):v(e)?Fe(e.allOf):de(e)?gt(e.pattern):S(e)?Rt(e.anyOf):e}function nn(e){return s.IsEqual(e.length,1)?e[0]:s.IsEqual(e.length,0)?me():_(e)}function Lg(e,t){let r=St(e);return on(r,t)}function Dg(e,t){return Ct(sn,t)}function jg(e,t){let r=Fe(e);return on(r,t)}function Ng(e,t){return s.IsString(e)||s.IsNumber(e)?L({[e]:t}):s.IsEqual(e,!1)?L({false:t}):s.IsEqual(e,!0)?L({true:t}):L({})}function qg(e,t){return Ct(uo,t)}function _g(e,t){return s.HasPropertyKey(e,"pattern")&&(s.IsString(e.pattern)||e.pattern instanceof RegExp)?Ct(e.pattern.toString(),t):Ct(ar,t)}function Ug(e,t){let r=ci(e);return la(r)?on(gt(e),t):Ct(e,t)}function xP(e){return S(e)?an(e.anyOf):[e]}function an(e,t=[]){return s.ShiftLeft(e,(r,n)=>an(n,[...t,...xP(r)]),()=>t)}function hP(e){return e.some(t=>ze(t)||Se(t)||Xe(t))}function IP(e,t){return s.IsEqual(hP(e),!0)?Ct(ar,t):void 0}function bP(e,t){return e.reduce((r,n)=>J(n)&&(s.IsString(n.const)||s.IsNumber(n.const))?{...r,[n.const]:t}:r,{})}function $P(e,t){let r=bP(e,t);return L(r)}function Bg(e,t){let r=an(e),n=IP(r,t);return Ee(n)?n:$P(r,t)}function on(e,t){return Te(e)?$g(t):Et(e)?Eg(t):Me(e)?Lg(e.enum,t):Xe(e)?Dg(e,t):v(e)?jg(e.allOf,t):J(e)?Ng(e.const,t):Se(e)?qg(e,t):S(e)?Bg(e.anyOf,t):ze(e)?_g(e,t):de(e)?Ug(e.pattern,t):L({})}function Xu(e,t,r){return K([e])?l.Update(on(e,t),{},r):ha(e,t,r)}function Gg(e,t,r,n,o){let i=$(e,t,r),a=$(e,t,n);return Xu(i,a,o)}var sn=`^${ma}$`,uo=`^${fa}$`,ar=`^${da}$`;function ha(e,t,r={}){return C("Record",[e,t],r)}function co(e,t,r={}){return Xu(e,t,r)}function Kg(e,t){return Ct(e,t)}function Ia(e){return s.IsEqual(e,ar)?ct():s.IsEqual(e,sn)?Rn():s.IsEqual(e,uo)?Ft():Ju(e)}function Ge(e){return s.Keys(e.patternProperties)[0]}function po(e){let t=Ge(e);return Ia(t)}function ye(e){return e.patternProperties[Ge(e)]}function se(e){return w(e,"Record")}function On(e){return l.Create({"~kind":"Rest"},{type:"rest",items:e},{})}function mn(e){return w(e,"Rest")}function ba(e){return l.Create({"~kind":"This"},{$ref:"#"},e)}function $a(e){return w(e,"This")}function fo(e){return l.Create({"~kind":"Undefined"},{type:"undefined"},e)}function Zt(e){return w(e,"Undefined")}function Ea(e){return l.Create({"~kind":"Void"},{type:"void"},e)}function Lt(e){return w(e,"Void")}function SP(e,t){return s.IsEqual(e,"Array")?Tt(t[0]):s.IsEqual(e,"Capitalize")?ka(t[0]):s.IsEqual(e,"ConstructorParameters")?Pa(t[0]):s.IsEqual(e,"Evaluate")?Wx(t[0]):s.IsEqual(e,"Exclude")?Aa(t[0],t[1]):s.IsEqual(e,"Extract")?Oa(t[0],t[1]):s.IsEqual(e,"Index")?hi(t[0],t[1]):s.IsEqual(e,"InstanceType")?Ma(t[0]):s.IsEqual(e,"Lowercase")?Ta(t[0]):s.IsEqual(e,"NonNullable")?va(t[0]):s.IsEqual(e,"Omit")?Fa(t[0],t[1]):s.IsEqual(e,"Parameters")?La(t[0]):s.IsEqual(e,"Partial")?Da(t[0]):s.IsEqual(e,"Pick")?ja(t[0],t[1]):s.IsEqual(e,"Readonly")?Na(t[0]):s.IsEqual(e,"KeyOf")?Ii(t[0]):s.IsEqual(e,"Record")?ha(t[0],t[1]):s.IsEqual(e,"Required")?qa(t[0]):s.IsEqual(e,"ReturnType")?_a(t[0]):s.IsEqual(e,"Uncapitalize")?wa(t[0]):s.IsEqual(e,"Uppercase")?Ca(t[0]):xi(Ye(e),t)}function Mn(){throw Error("Unreachable")}function Jg(e,t=[]){return s.ShiftLeft(e,(r,n)=>Jg(n,[...t,r[1]]),()=>t)}function qr(e){return s.IsEqual(e.length,3)?[e[0],...Jg(e[1])]:[]}function Yg(e){return Pn(e[0],e[2],e[4])}function Qg(e){return Pn(e[0],e[2],e[2])}function Xg(e){return Pn(e[0],He(),e[2])}function Zg(e){return Pn(e,He(),He())}function ey(e){return qr(e)}function ty(e){return e[1]}function ry(e){return qr(e)}function ny(e){return e[1]}function oy(e){return SP(e[0],e[1])}function iy(e){return null}function sy(e){return ct()}function ay(e){return Ft()}function my(e){return aa()}function uy(e){return fo()}function cy(e){return oo()}function py(e){return Rn()}function fy(e){return mi()}function dy(e){return He()}function ly(e){return ro()}function gy(e){return L({})}function yy(e){return me()}function xy(e){return io()}function hy(e){return Ea()}function Iy(e){return ba()}function by(e){return W(BigInt(e))}function $y(e){return W(s.IsEqual(e,"true"))}function Ey(e){return W(parseFloat(e))}function Sy(e){return W(e)}function ky(e){return e[1]}function Ty(e){return W(e)}function wy(e){return s.IsEqual(e.length,3)?[e[0],e[1],...e[2]]:[e[0]]}function Cy(e){return e[1]}function Ry(e){return Sa(e)}function Py(e){return s.IsEqual(e.length,6)?wn(e[1],e[3],e[5]):wn(e[1],e[3],He())}function Ay(e){return e.length>0}function Oy(e){return e.reduce((t,r)=>s.IsEqual(r.length,3)?[...t,[r[1]]]:[...t,[]],[])}function My(e){return s.IsEqual(e.length,6)?[e[1],e[3],e[5]]:[]}function vy(e){return s.IsArray(e)&&s.IsEqual(e.length,3)?e[1]:e}function Fy(e){return s.IsEqual(e.length,2)?e[1]:[]}function Hg(e,t){return t.reduce((r,n)=>{let o=n;return s.IsEqual(o.length,1)?hi(r,o[0]):s.IsEqual(o.length,0)?Tt(r):Mn()},e)}function zg(e,t){return s.IsEqual(t.length,3)?Ra(e,t[0],t[1],t[2]):e}function kP(e,t){return s.IsArray(t)&&s.IsEqual(t.length,0)?e:Ua(e,t)}function Ly(e){let[t,r,n,o,i]=e;return kP(zg(t?Ii(Hg(r,n)):Hg(r,n),o),i)}function Zu(e,t){return s.IsEqual(t.length,3)?(()=>{let[r,n,o]=t,i=Zu(n,o);if(s.IsEqual(r,"&"))return v(i)?lt([e,...i.allOf]):lt([e,i]);if(s.IsEqual(r,"|"))return S(i)?_([e,...i.anyOf]):_([e,i]);Mn()})():e}function Dy(e){let[t,r]=e;return Zu(t,r)}function jy(e){let[t,r]=e;return Zu(t,r)}function Ny(e){return Hx(e[1])}function qy(e){return e[1]}function _y(e){return rn(e[0],e[2])}function Uy(e){return s.IsEqual(e.length,4)?oi(e[1],e[3]):s.IsEqual(e.length,2)?oi(e[1],He()):Mn()}function By(e){return`${e}`}function Gy(e){return Xe(e[3])?sn:Se(e[3])?uo:kr(e[3])?ar:ze(e[3])?ar:Mn()}function Ky(e){return e.length>0}function Hy(e){return e.length>0}function zy(e){let[t,r,n,o,i]=e;return{[r]:t&&n?Er(br(i)):t&&!n?Er(i):!t&&n?br(i):i}}function Wy(e){return qr(e)}function Vy(e){return e.reduce((t,r)=>s.HasPropertyKey(r,sn)||s.HasPropertyKey(r,uo)||s.HasPropertyKey(r,ar)?[t[0],l.Assign(t[1],r)]:[l.Assign(t[0],r),t[1]],[{},{}])}function Jy(e){return Vy(e[1])}function Yy(e){let[t,r]=e,n=s.IsEqual(s.Keys(r).length,0)?{}:{patternProperties:r};return L(t,n)}function Qy(e){return s.IsEqual(e.length,5)?Er(br(e[4])):s.IsEqual(e.length,3)?e[2]:s.IsEqual(e.length,4)?s.IsEqual(e[2],"readonly")?Er(e[3]):br(e[3]):Mn()}function Xy(e){if(!s.IsArray(e)||!s.IsEqual(e.length,3))return e;let[t,r,n]=e;return t&&n?Er(br(r)):t&&!n?Er(r):!t&&n?br(r):r}function Zy(e){return s.IsEqual(e.length,2)?On(e[1]):s.IsEqual(e.length,1)?e[0]:Mn()}function ex(e){return qr(e)}function tx(e){return ve(e[1])}function rx(e){return Er(br(e[4]))}function nx(e){return Er(e[3])}function ox(e){return br(e[3])}function ix(e){return e[2]}function sx(e){return s.IsEqual(e.length,2)?On(e[1]):s.IsEqual(e.length,1)?e[0]:Mn()}function ax(e){return qr(e)}function mx(e){return Ir(e[1],e[4])}function ux(e){return hr(e[2],e[5])}function Wg(e,t){return s.IsEqual(e,"remove")?zx(t):s.IsEqual(e,"add")?Er(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 Vg(e,t){return s.IsEqual(e,"remove")?Kx(t):s.IsEqual(e,"add")?br(t):t}function px(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 fx(e){return s.IsEqual(e.length,2)?[e[1]]:[]}function dx(e){return s.IsArray(e[6])&&s.IsEqual(e[6].length,1)?gi(ui(e[3]),e[5],e[6][0],Wg(e[1],Vg(e[8],e[10]))):gi(ui(e[3]),e[5],Ye(e[3]),Wg(e[1],Vg(e[8],e[10])))}function lx(e){return Ye(e)}function gx(e){return BigInt(e)}function yx(e){return parseFloat(e)}function xx(e){return s.IsEqual(e,"true")}function hx(e){return null}function Ix(e){return{[e[0]]:e[2]}}function bx(e){return qr(e)}function TP(e){return e.reduce((t,r)=>l.Assign(t,r),{})}function $x(e){return TP(e[1])}function Ex(e){return qr(e)}function Sx(e){return e[1]}function kx(e){return mi()}function Tx(e){return ct()}function wx(e){return Ft()}function Cx(e){return Rn()}function Rx(e){return me()}function Px(e){return W(e)}function Ax(e){return _(e[1])}function Ox(e){return e.length===3?[...e[0],...e[2]]:e.length===1?[...e[0]]:[]}function Mx(e){return[e[0],...e[1]]}function vx(e){return e[1]}function Fx(e){return qr(e)}function Lx(e){return s.IsEqual(e.length,2)?e[1]:[]}function Dx(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]]:rn(t,yi(r,n,i))}}function jx(e){let t=e[2],[r,n]=e[3],o=s.IsEqual(s.Keys(n).length,0)?{}:{patternProperties:n};return{[e[1]]:yi(t,r,o)}}function Nx(e){return{[e[1]]:rn(e[2],e[4])}}function qx(e){return{[e[1]]:e[3]}}function _x(e){return null}function Ux(e){return qr(e)}function Bx(e){return e[1]}function Gx(e){let[t,r]=[e[0],e[1]];return Vx(l.Assign(t,Vy(r)[0]))}function bi(e){return ee(e.length,2)}function X(e,t,r){return bi(e)?t(e[0],e[1]):r()}function RP(e,t){return ee(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function we(e,t){for(let r=0;r<e.length;r++){let n=RP(e[r],t);if(bi(n))return n}return[]}function ec(e,t){return Array.from({length:t-e+1},(r,n)=>String.fromCharCode(e+n))}var Jx=[...ec(97,122),...ec(65,90)],tc="0",rc=ec(49,57),lo=[tc,...rc],Yx=" ",go=`
2
2
  `;var un="_",Ba=".",Qx="$",Ga="-";var Xx="//",Zx="/*",AP="*/";function eh(e){let t=e.indexOf(AP);return ee(t,-1)?"":e.slice(t+2)}function th(e){let t=e.indexOf(go);return ee(t,-1)?"":e.slice(t)}function OP(e){return e.replace(/^[ \t\r\f\v]+/,"")}function Ka(e){let t=OP(e);return t.startsWith(Zx)?Ka(eh(t.slice(2))):t.startsWith(Xx)?Ka(th(t.slice(2))):t}function st(e){let t=e.trimStart();return t.startsWith(Zx)?st(eh(t.slice(2))):t.startsWith(Xx)?st(th(t.slice(2))):t}function Ha(e,t){return X(we([e],t),(r,n)=>[r,n],()=>["",t])}function MP(e,t){return e.includes(t)}function yo(e,t,r,n=""){return X(we(e,r),(o,i)=>MP(t,o)?yo(e,t,i,n):yo(e,t,i,`${n}${o}`),()=>[n,r])}function vP(e){return we(rc,e)}var FP=[...lo,un];function LP(e){return yo(FP,[un],e)}function DP(e){return X(we([tc],e),(t,r)=>[t,r],()=>X(vP(e),(t,r)=>X(LP(r),(n,o)=>[`${t}${n}`,o],()=>[]),()=>[]))}function za(e){return DP(st(e))}function jP(e){return Ha(Ga,e)}function NP(e){return X(jP(e),(t,r)=>X(za(r),(n,o)=>[`${t}${n}`,o],()=>[]),()=>[])}function rh(e){return NP(st(e))}function qP(e){return X(rh(e),(t,r)=>X(we(["n"],r),(n,o)=>[`${t}`,o],()=>[]),()=>[])}function nc(e){return qP(e)}function oc(e,t){return we([e],t)}function x(e,t){return ee(e,"")?["",t]:e.startsWith(go)?oc(e,Ka(t)):e.startsWith(Yx)?oc(e,t):oc(e,st(t))}var nh=[...Jx,un,Qx];function _P(e){return we(nh,e)}var UP=[...nh,...lo];function oh(e,t=""){return X(we(UP,e),(r,n)=>oh(n,`${t}${r}`),()=>[t,e])}function BP(e){return X(_P(e),(t,r)=>X(oh(r),(n,o)=>[`${t}${n}`,o],()=>[]),()=>[])}function Le(e){return BP(st(e))}var GP=[...lo,un];function KP(e){return bi(we([Ba],e))}function ih(e){return X(yo(GP,[un],e),(t,r)=>ee(t,"")?[]:[t,r],()=>[])}function HP(e){return X(we([Ba],e),(t,r)=>X(ih(r),(n,o)=>[`0${t}${n}`,o],()=>[]),()=>[])}function zP(e){return X(za(e),(t,r)=>X(we([Ba],r),(n,o)=>X(ih(o),(i,a)=>[`${t}${n}${i}`,a],()=>[`${t}`,o]),()=>[`${t}`,r]),()=>[])}function WP(e){return KP(e)?HP(e):zP(e)}function sh(e){return WP(st(e))}function VP(e){return Ha(Ga,e)}function JP(e){return X(VP(e),(t,r)=>X(sh(r),(n,o)=>[`${t}${n}`,o],()=>[]),()=>[])}function Wa(e){return JP(st(e))}function YP(e){return ee(e,"")?[]:[e.slice(0,1),e.slice(1)]}function ah(e,t){return rs(e,(r,n)=>t.startsWith(r)?!0:ah(n,t),()=>!1)}function cn(e,t,r=""){return X(YP(t),(n,o)=>ah(e,t)?[r,t]:cn(e,o,`${r}${n}`),()=>[])}function QP(e,t,r){return X(we([e],r),(n,o)=>X(cn([t],o),(i,a)=>X(we([t],a),(m,c)=>[`${i}`,c],()=>[]),()=>[]),()=>[])}function XP(e,t,r){return X(we([e],r),(n,o)=>X(cn([go,t],o),(i,a)=>X(we([t],a),(m,c)=>[`${i}`,c],()=>[]),()=>[]),()=>[])}function mh(e,t,r,n){return r?QP(e,t,st(n)):XP(e,t,st(n))}function ZP(e,t){return we(e,t)}function eA(e,t){return mh(e,e,!1,t)}function tA(e,t){return X(ZP(e,t),(r,n)=>eA(r,`${r}${n}`),()=>[])}function Va(e,t){return tA(e,st(t))}function uh(e,t){return X(cn(e,t),(r,n)=>ee(r,"")?[]:[r,n],()=>[])}var u=(e,t,r=()=>[])=>e.length===2?t(e):r(),nA=e=>u(u(Le(e),([t,r])=>u(x("extends",r),([n,o])=>u(re(o),([i,a])=>u(x("=",a),([m,c])=>u(re(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[Yg(t),r]),oA=e=>u(u(Le(e),([t,r])=>u(x("extends",r),([n,o])=>u(re(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Qg(t),r]),iA=e=>u(u(Le(e),([t,r])=>u(x("=",r),([n,o])=>u(re(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Xg(t),r]),sA=e=>u(Le(e),([t,r])=>[Zg(t),r]),fh=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]),dh=(e,t=[])=>u(u(x(",",e),([r,n])=>u(fh(n),([o,i])=>[[r,o],i])),([r,n])=>dh(n,[...t,r]),()=>[t,e]),aA=e=>u(u(u(fh(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])=>[ey(t),r]),ac=e=>u(u(x("<",e),([t,r])=>u(aA(r),([n,o])=>u(x(">",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[ty(t),r]),lh=(e,t=[])=>u(u(x(",",e),([r,n])=>u(re(n),([o,i])=>[[r,o],i])),([r,n])=>lh(n,[...t,r]),()=>[t,e]),mA=e=>u(u(u(re(e),([t,r])=>u(lh(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])=>[ry(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])=>[ny(t),r]),cA=e=>u(u(Le(e),([t,r])=>u(uA(r),([n,o])=>[[t,n],o])),([t,r])=>[oy(t),r]),gh=e=>u(u(u(x(";",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[iy(t),r]),yh=e=>u(x("string",e),([t,r])=>[sy(t),r]),xh=e=>u(x("number",e),([t,r])=>[ay(t),r]),pA=e=>u(x("boolean",e),([t,r])=>[my(t),r]),fA=e=>u(x("undefined",e),([t,r])=>[uy(t),r]),dA=e=>u(x("null",e),([t,r])=>[cy(t),r]),hh=e=>u(x("integer",e),([t,r])=>[py(t),r]),lA=e=>u(x("bigint",e),([t,r])=>[fy(t),r]),gA=e=>u(x("unknown",e),([t,r])=>[dy(t),r]),yA=e=>u(x("any",e),([t,r])=>[ly(t),r]),xA=e=>u(x("object",e),([t,r])=>[gy(t),r]),hA=e=>u(x("never",e),([t,r])=>[yy(t),r]),Ih=e=>u(x("symbol",e),([t,r])=>[xy(t),r]),IA=e=>u(x("void",e),([t,r])=>[hy(t),r]),bA=e=>u(x("this",e),([t,r])=>[Iy(t),r]),$A=e=>u(u(x("${",e),([t,r])=>u(re(r),([n,o])=>u(x("}",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[ky(t),r]),ic=e=>u(cn(["${","`"],e),([t,r])=>[Ty(t),r]),bh=e=>u(u(u(ic(e),([t,r])=>u($A(r),([n,o])=>u(bh(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u(u(ic(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u(u(ic(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[]))),([t,r])=>[wy(t),r]),mc=e=>u(u(x("`",e),([t,r])=>u(bh(r),([n,o])=>u(x("`",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Cy(t),r]),EA=e=>u(mc(e),([t,r])=>[Ry(t),r]),SA=e=>u(u(u(x("if",e),([t,r])=>u(re(r),([n,o])=>u(x("then",o),([i,a])=>u(re(a),([m,c])=>u(x("else",c),([p,f])=>u(re(f),([d,g])=>[[t,n,i,m,p,d],g])))))),([t,r])=>[t,r],()=>u(u(x("if",e),([t,r])=>u(re(r),([n,o])=>u(x("then",o),([i,a])=>u(re(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[t,r],()=>[])),([t,r])=>[Py(t),r]),kA=e=>u(nc(e),([t,r])=>[by(t),r]),TA=e=>u(u(x("true",e),([t,r])=>[t,r],()=>u(x("false",e),([t,r])=>[t,r],()=>[])),([t,r])=>[$y(t),r]),wA=e=>u(Wa(e),([t,r])=>[Ey(t),r]),CA=e=>u(Va(["'",'"'],e),([t,r])=>[Sy(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])=>[Ay(t),r]),$h=(e,t=[])=>u(u(u(x("[",e),([r,n])=>u(re(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])=>$h(n,[...t,r]),()=>[t,e]),PA=e=>u($h(e),([t,r])=>[Oy(t),r]),AA=e=>u(u(u(x("extends",e),([t,r])=>u(re(r),([n,o])=>u(x("?",o),([i,a])=>u(re(a),([m,c])=>u(x(":",c),([p,f])=>u(re(f),([d,g])=>[[t,n,i,m,p,d],g])))))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[My(t),r]),OA=e=>u(u(u(x("(",e),([t,r])=>u(re(r),([n,o])=>u(x(")",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u(yh(e),([t,r])=>[t,r],()=>u(xh(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(hh(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(Ih(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])=>[vy(t),r]),MA=e=>u(u(u(x("with",e),([t,r])=>u(Nh(r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Fy(t),r]),Eh=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])=>[Ly(t),r]),Sh=e=>u(u(u(x("&",e),([t,r])=>u(Eh(r),([n,o])=>u(Sh(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[t,r]),kh=e=>u(u(Eh(e),([t,r])=>u(Sh(r),([n,o])=>[[t,n],o])),([t,r])=>[Dy(t),r]),Th=e=>u(u(u(x("|",e),([t,r])=>u(kh(r),([n,o])=>u(Th(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[t,r]),Ja=e=>u(u(kh(e),([t,r])=>u(Th(r),([n,o])=>[[t,n],o])),([t,r])=>[jy(t),r]),vA=e=>u(u(x("readonly",e),([t,r])=>u(Ja(r),([n,o])=>[[t,n],o])),([t,r])=>[Ny(t),r]),FA=e=>u(u(x("|",e),([t,r])=>u(Ja(r),([n,o])=>[[t,n],o])),([t,r])=>[qy(t),r]),LA=e=>u(u(ac(e),([t,r])=>u(x("=",r),([n,o])=>u(re(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[_y(t),r]),DA=e=>u(u(u(x("infer",e),([t,r])=>u(Le(r),([n,o])=>u(x("extends",o),([i,a])=>u(Ja(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[t,r],()=>u(u(x("infer",e),([t,r])=>u(Le(r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>[])),([t,r])=>[Uy(t),r]),re=e=>u(u(DA(e),([t,r])=>[t,r],()=>u(FA(e),([t,r])=>[t,r],()=>u(vA(e),([t,r])=>[t,r],()=>u(Ja(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),jA=e=>u(Wa(e),([t,r])=>[By(t),r]),NA=e=>u(Le(e),([t,r])=>[t,r]),qA=e=>u(Va(["'",'"'],e),([t,r])=>[t,r]),_A=e=>u(u(x("[",e),([t,r])=>u(Le(r),([n,o])=>u(x(":",o),([i,a])=>u(u(hh(a),([m,c])=>[m,c],()=>u(xh(a),([m,c])=>[m,c],()=>u(yh(a),([m,c])=>[m,c],()=>u(Ih(a),([m,c])=>[m,c],()=>[])))),([m,c])=>u(x("]",c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[Gy(t),r]),wh=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]),Ch=e=>u(u(u(x("readonly",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Ky(t),r]),Rh=e=>u(u(u(x("?",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Hy(t),r]),Ph=e=>u(u(Ch(e),([t,r])=>u(wh(r),([n,o])=>u(Rh(o),([i,a])=>u(x(":",a),([m,c])=>u(re(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[zy(t),r]),Ya=e=>u(u(u(x(",",e),([t,r])=>u(x(`
3
3
  `,r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x(";",e),([t,r])=>u(x(`
4
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(`
@@ -1,4 +1,4 @@
1
- import{b as j}from"./chunk-MCAAX33K.js";import{a as b}from"./chunk-2YWKLZB6.js";import{H as m,N as A}from"./chunk-5FIFNXLT.js";import"./chunk-UTYFLLSM.js";import{j as R}from"./chunk-MVVEYKN6.js";import{b as M,d as T,f as D}from"./chunk-TUXY64DT.js";import{a as I}from"./chunk-FABEBOGV.js";import"./chunk-WOT6VMZA.js";import{spawnSync as J}from"node:child_process";import{existsSync as S,readdirSync as E,readFileSync as x,realpathSync as B,statSync as C,writeFileSync as F,unlinkSync as z}from"node:fs";import{dirname as N,join as p}from"node:path";var k=[22,19];async function W(t="https://api.howtofix.id/api/status"){let n=[],[s,e]=process.versions.node.split(".").map(Number),r=s>k[0]||s===k[0]&&e>=k[1];n.push({name:"node",ok:r,detail:`${process.versions.node} (needs >= ${k[0]}.${k[1]})`});let i=J("git",["--version"],{encoding:"utf8"});n.push({name:"git",ok:i.status===0,detail:i.status===0?i.stdout.trim():"not found on PATH"});let o=I();n.push({name:"sandbox",ok:!!o,detail:o??"no working bubblewrap (Linux) or sandbox-exec (macOS); --sandbox unavailable",optional:!0});let l=!1,c=m;try{let d=p(m,`.doctor-${process.pid}`);F(d,"ok"),z(d),l=!0}catch(d){c=`${m} is not writable: ${d instanceof Error?d.message:String(d)}`}n.push({name:"state dir",ok:l,detail:c});let a=p(m,"auth.json"),u="no auth.json \u2014 run `howtocode` and sign in",h=!1;try{let d=JSON.parse(x(a,"utf8")),f=Object.keys(d).length;h=f>0,u=h?`${f} provider credential${f===1?"":"s"}`:u}catch{}n.push({name:"auth",ok:h,detail:u,optional:!0});try{let d=Date.now(),f=await fetch(t,{signal:AbortSignal.timeout(5e3)});n.push({name:"gateway",ok:f.ok,detail:`${t} \u2192 ${f.status} in ${Date.now()-d}ms`,optional:!0})}catch(d){n.push({name:"gateway",ok:!1,detail:`${t} unreachable: ${d instanceof Error?d.message:String(d)}`,optional:!0})}return n.push(G()),n}function G(t=q()){if(t===void 0)return{name:"install",ok:!0,detail:"not an npm install; skipped",optional:!0};if(!S(t))return{name:"install",ok:!0,detail:"no bundled dependencies to check",optional:!0};let n=[],s=0;for(let e of["@netrodev"]){let r=p(t,e);if(S(r))for(let i of E(r)){let o=p(r,i,"dist");if(S(o))for(let l of _(o)){s+=1;let c=x(l,"utf8");for(let a of c.matchAll(/import\("(\.[^"]+)"\)/g)){let u=p(N(l),a[1]);S(u)||n.push(`${e}/${i}: ${u.slice(o.length+1)}`)}}}}return n.length>0?{name:"install",ok:!1,detail:`${n.length} module${n.length===1?"":"s"} missing (${n[0]}); reinstall with \`npm install -g howtocode@latest\``}:{name:"install",ok:!0,detail:`${s} lazy module${s===1?"":"s"} present`}}function q(){try{return p(N(N(B(process.argv[1]??""))),"node_modules")}catch{return}}function _(t,n=[]){let s;try{s=E(t)}catch{return n}for(let e of s){let r=p(t,e);if(e.endsWith(".lazy.js"))n.push(r);else if(!e.includes("."))try{C(r).isDirectory()&&_(r,n)}catch{}}return n}async function ie(){let t=await W(),n=Math.max(...t.map(e=>e.name.length));for(let e of t){let r=e.ok?"ok ":e.optional?"warn":"FAIL";console.log(` ${r} ${e.name.padEnd(n)} ${e.detail}`)}let s=t.filter(e=>!e.ok&&!e.optional);return s.length>0?(console.log(`
1
+ import{b as j}from"./chunk-MCAAX33K.js";import{a as b}from"./chunk-WDMBTVK7.js";import{H as m,N as A}from"./chunk-5FIFNXLT.js";import"./chunk-UTYFLLSM.js";import{j as R}from"./chunk-MVVEYKN6.js";import{b as M,d as T,f as D}from"./chunk-TUXY64DT.js";import{a as I}from"./chunk-FABEBOGV.js";import"./chunk-WOT6VMZA.js";import{spawnSync as J}from"node:child_process";import{existsSync as S,readdirSync as E,readFileSync as x,realpathSync as B,statSync as C,writeFileSync as F,unlinkSync as z}from"node:fs";import{dirname as N,join as p}from"node:path";var k=[22,19];async function W(t="https://api.howtofix.id/api/status"){let n=[],[s,e]=process.versions.node.split(".").map(Number),r=s>k[0]||s===k[0]&&e>=k[1];n.push({name:"node",ok:r,detail:`${process.versions.node} (needs >= ${k[0]}.${k[1]})`});let i=J("git",["--version"],{encoding:"utf8"});n.push({name:"git",ok:i.status===0,detail:i.status===0?i.stdout.trim():"not found on PATH"});let o=I();n.push({name:"sandbox",ok:!!o,detail:o??"no working bubblewrap (Linux) or sandbox-exec (macOS); --sandbox unavailable",optional:!0});let l=!1,c=m;try{let d=p(m,`.doctor-${process.pid}`);F(d,"ok"),z(d),l=!0}catch(d){c=`${m} is not writable: ${d instanceof Error?d.message:String(d)}`}n.push({name:"state dir",ok:l,detail:c});let a=p(m,"auth.json"),u="no auth.json \u2014 run `howtocode` and sign in",h=!1;try{let d=JSON.parse(x(a,"utf8")),f=Object.keys(d).length;h=f>0,u=h?`${f} provider credential${f===1?"":"s"}`:u}catch{}n.push({name:"auth",ok:h,detail:u,optional:!0});try{let d=Date.now(),f=await fetch(t,{signal:AbortSignal.timeout(5e3)});n.push({name:"gateway",ok:f.ok,detail:`${t} \u2192 ${f.status} in ${Date.now()-d}ms`,optional:!0})}catch(d){n.push({name:"gateway",ok:!1,detail:`${t} unreachable: ${d instanceof Error?d.message:String(d)}`,optional:!0})}return n.push(G()),n}function G(t=q()){if(t===void 0)return{name:"install",ok:!0,detail:"not an npm install; skipped",optional:!0};if(!S(t))return{name:"install",ok:!0,detail:"no bundled dependencies to check",optional:!0};let n=[],s=0;for(let e of["@netrodev"]){let r=p(t,e);if(S(r))for(let i of E(r)){let o=p(r,i,"dist");if(S(o))for(let l of _(o)){s+=1;let c=x(l,"utf8");for(let a of c.matchAll(/import\("(\.[^"]+)"\)/g)){let u=p(N(l),a[1]);S(u)||n.push(`${e}/${i}: ${u.slice(o.length+1)}`)}}}}return n.length>0?{name:"install",ok:!1,detail:`${n.length} module${n.length===1?"":"s"} missing (${n[0]}); reinstall with \`npm install -g howtocode@latest\``}:{name:"install",ok:!0,detail:`${s} lazy module${s===1?"":"s"} present`}}function q(){try{return p(N(N(B(process.argv[1]??""))),"node_modules")}catch{return}}function _(t,n=[]){let s;try{s=E(t)}catch{return n}for(let e of s){let r=p(t,e);if(e.endsWith(".lazy.js"))n.push(r);else if(!e.includes("."))try{C(r).isDirectory()&&_(r,n)}catch{}}return n}async function ie(){let t=await W(),n=Math.max(...t.map(e=>e.name.length));for(let e of t){let r=e.ok?"ok ":e.optional?"warn":"FAIL";console.log(` ${r} ${e.name.padEnd(n)} ${e.detail}`)}let s=t.filter(e=>!e.ok&&!e.optional);return s.length>0?(console.log(`
2
2
  ${s.length} problem${s.length===1?"":"s"} must be fixed before a session will work.`),1):0}function ce(t=m){let n=p(t,"models.json"),s;try{s=x(n,"utf8")}catch(a){return a.code==="ENOENT"?console.log(` no models.json at ${n} \u2014 run \`howtocode /connect\` to pull the catalogue`):j(b,"models",a),1}let e;try{e=JSON.parse(s)}catch(a){return console.error(`${b}: models: ${n} is not valid JSON (${a instanceof Error?a.message:String(a)})`),console.error(" fix the file, or delete it and run `howtocode /connect` to write a new one"),1}let r=e.providers??{},i=D(A),o=i?new Set(i.ids):void 0,l=new Set,c=0;for(let[a,u]of Object.entries(r)){let h=u.models??[],d=h.map(f=>f.id).filter(Boolean);for(let f of d)l.add(f);c+=d.length,console.log(` ${a} (${d.length})`);for(let f of h){if(!f.id)continue;let O=T(m).get(f.id),$=M(O??[]),g=$?` ${$}`:"",w=o&&!o.has(f.id)?" \u2014 not on this account":"";console.log(` ${f.id}${g}${w}`)}}if(o){let a=[...l].filter(u=>!o.has(u)).length;console.log(`
3
3
  ${[...o].filter(u=>l.has(u)).length} of ${c} listed model(s) this account can call${a>0?`; ${a} cannot (kept for other plans)`:""}`)}else console.log("\n which of these this account can call is unknown: run `howtocode` once to record it");return c===0?(console.log(" no models configured"),1):0}function v(t=15,n=m){let s=p(n,"sessions"),e;try{e=E(s)}catch{return[]}let r=[];for(let i of e){let o=p(s,i),l;try{l=E(o)}catch{continue}for(let c of l){if(!c.endsWith(".jsonl"))continue;let a=p(o,c);try{let u=C(a);r.push({file:a,project:i,modified:u.mtimeMs,bytes:u.size})}catch{}}}return r.sort((i,o)=>o.modified-i.modified).slice(0,t)}function le(t){let n=t.indexOf("--search");if(n>=0){let o=t[n+1]?.trim();if(!o)return console.error(`${b}: sessions: --search needs a word or phrase`),2;let l=K(o);if(l.length===0)return console.log(` no session mentions "${o}"`),0;for(let c of l){let a=new Date(c.row.modified).toISOString().replace("T"," ").slice(0,16),u=`${c.matches} hit${c.matches===1?"":"s"}`;console.log(` ${a} ${c.row.project} (${u})`),console.log(` ${c.row.file}`),console.log(` ${c.snippet}`)}return 0}let s=t.indexOf("--limit"),e=s>=0&&Number(t[s+1])||15,r=v(e);if(r.length===0)return console.log(` no saved sessions under ${p(m,"sessions")}`),t.includes("--export")?1:0;let i=t.indexOf("--export");if(i>=0){let o=Number(t[i+1]);if(!Number.isInteger(o)||o<1||o>r.length)return console.error(`${b}: sessions: --export needs a number from the list (1-${r.length})`),2;let l=r[o-1];try{console.log(Q(l.file))}catch(c){return j(b,"sessions",c),1}return 0}return r.forEach((o,l)=>{let c=new Date(o.modified).toISOString().replace("T"," ").slice(0,16),a=Math.round(o.bytes/1024);console.log(` ${String(l+1).padStart(2)} ${c} ${String(a).padStart(6)}k ${o.project}`),console.log(` ${o.file}`)}),0}function H(t){let n=t;try{let s=JSON.parse(t),e=s.message?.content??s.content;if(typeof e=="string"&&e.trim())n=e;else if(Array.isArray(e)){let r=e.map(i=>i&&typeof i=="object"&&"text"in i?String(i.text):"").join(" ");r.trim()&&(n=r)}}catch{}return R(X(n).replace(/\s+/g," ").trim())}function X(t){return t.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007]*\u0007|\u001b[@-Z\\-_]/g,"")}function Z(t,n,s=80){let e=t.toLowerCase().indexOf(n);if(e<0)return t.slice(0,s*2).trim();let r=Math.max(0,e-s),i=Math.min(t.length,e+n.length+s);return`${r>0?"\u2026":""}${t.slice(r,i).trim()}${i<t.length?"\u2026":""}`}function K(t,n=10,s=m){let e=t.toLowerCase(),r=new RegExp(`\\b${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"i"),i=[];for(let o of v(Number.MAX_SAFE_INTEGER,s)){let l;try{l=x(o.file,"utf8")}catch{continue}let c=0,a=0,u=0,h=0,d=!1,f="";for(let $ of l.split(`
4
4
  `)){let g=$.toLowerCase(),w=g.indexOf(e);if(w<0)continue;let y=0;for(;w>=0;)y++,w=g.indexOf(e,w+e.length);c+=y;let L=g.includes('"role":"user"'),P=g.includes('"role":"toolresult"')||g.includes('"role":"tool"');L?a+=y:P?h+=y:u+=y,r.test($)&&(d=!0),f||(f=Z(H($),e))}if(c===0)continue;let O=(a>0?100:0)+(u>0?10:0)+Math.min(h,5)+(d?5:0)+Math.min(c,10)/100;i.push({row:o,matches:c,score:O,snippet:f})}return i.sort((o,l)=>l.score-o.score||l.row.modified-o.row.modified).slice(0,n)}function Q(t){let n=[`# Session ${t.split(/[\\/]/).pop()??t}`,""];for(let s of x(t,"utf8").split(`
@@ -1,4 +1,4 @@
1
- import{$ as We,B as De,C as Ce,E as R,F as H,Fa as ot,H as B,I as Pe,Q as je,R as Ne,Ra as st,S as Me,T as Fe,U as Le,Ua as Q,V as Be,W as Ue,Wa as rt,Y as Ge,_ as Y,a as N,b as M,ba as He,c as ge,ca as qe,d as he,da as ze,e as we,ea as V,f as be,fa as Ze,g as A,ga as Ke,i as ye,j as ke,ja as Xe,k as Se,l as _e,la as Ye,m as X,ma as q,na as Ve,o as Te,oa as Je,p as Ee,q as $e,qa as J,r as ve,s as Ae,t as x,u as Re,ua as Qe,va as et,w as Oe,x as W,xa as tt,y as Ie,ya as nt}from"./chunk-FBR7W7S2.js";import{b as xe}from"./chunk-27TRKD65.js";import{c as ue}from"./chunk-7BMVQMQW.js";import{h as pe,l as fe}from"./chunk-G5RR42BO.js";import{t as me}from"./chunk-ZJL4OEXX.js";import"./chunk-7LA2AMZB.js";import"./chunk-LQAHFJBU.js";import{b as G,c as ie,d as ae}from"./chunk-2YWKLZB6.js";import{H as S,K as de,v as ce,w as le}from"./chunk-5FIFNXLT.js";import"./chunk-UTYFLLSM.js";import"./chunk-MVVEYKN6.js";import"./chunk-WOT6VMZA.js";import{join as Nt}from"node:path";import{hostname as io}from"node:os";import{createAgentSession as ao,createCodemodeExtension as co,createMcpExtension as lo,createToolSearchExtension as uo,DefaultResourceLoader as po,ProjectTrustStore as fo,SessionManager as Z,SettingsManager as mo}from"@netrodev/hxf-coding-agent";import{existsSync as Ft,readFileSync as Lt}from"node:fs";import{join as Bt}from"node:path";var it=Bt(S,"APPEND_SYSTEM.md"),Ut=["<non-interactive>","This run has no user attached: it was started with --print, and there is nobody to answer a question. Anything that stops and waits for a reply \u2014 `ask`, a confirmation, a skill that resolves a mode by asking which mode to use \u2014 will simply end the run with the task unfinished.","So do not ask. Where an instruction tells you to ask the user and wait, take the default it describes and continue, and say which default you took and why in your final answer. The user reads that answer; they cannot answer mid-run.","Where a skill offers a choice of modes, prefer the one that applies the rules while you work over the one that audits afterwards: this is the mode for building something now, and the audit mode can still be run later by the same person who reads your answer.","</non-interactive>"].join(`
1
+ import{$ as We,B as De,C as Ce,E as R,F as H,Fa as ot,H as B,I as Pe,Q as je,R as Ne,Ra as st,S as Me,T as Fe,U as Le,Ua as Q,V as Be,W as Ue,Wa as rt,Y as Ge,_ as Y,a as N,b as M,ba as He,c as ge,ca as qe,d as he,da as ze,e as we,ea as V,f as be,fa as Ze,g as A,ga as Ke,i as ye,j as ke,ja as Xe,k as Se,l as _e,la as Ye,m as X,ma as q,na as Ve,o as Te,oa as Je,p as Ee,q as $e,qa as J,r as ve,s as Ae,t as x,u as Re,ua as Qe,va as et,w as Oe,x as W,xa as tt,y as Ie,ya as nt}from"./chunk-AMHJO4G3.js";import{b as xe}from"./chunk-XODGJSB3.js";import{c as ue}from"./chunk-RT3VOMO4.js";import{h as pe,l as fe}from"./chunk-WKR2L2CT.js";import{t as me}from"./chunk-ZJL4OEXX.js";import"./chunk-7LA2AMZB.js";import"./chunk-YUOYDO5O.js";import{b as G,c as ie,d as ae}from"./chunk-WDMBTVK7.js";import{H as S,K as de,v as ce,w as le}from"./chunk-5FIFNXLT.js";import"./chunk-UTYFLLSM.js";import"./chunk-MVVEYKN6.js";import"./chunk-WOT6VMZA.js";import{join as Nt}from"node:path";import{hostname as io}from"node:os";import{createAgentSession as ao,createCodemodeExtension as co,createMcpExtension as lo,createToolSearchExtension as uo,DefaultResourceLoader as po,ProjectTrustStore as fo,SessionManager as Z,SettingsManager as mo}from"@netrodev/hxf-coding-agent";import{existsSync as Ft,readFileSync as Lt}from"node:fs";import{join as Bt}from"node:path";var it=Bt(S,"APPEND_SYSTEM.md"),Ut=["<non-interactive>","This run has no user attached: it was started with --print, and there is nobody to answer a question. Anything that stops and waits for a reply \u2014 `ask`, a confirmation, a skill that resolves a mode by asking which mode to use \u2014 will simply end the run with the task unfinished.","So do not ask. Where an instruction tells you to ask the user and wait, take the default it describes and continue, and say which default you took and why in your final answer. The user reads that answer; they cannot answer mid-run.","Where a skill offers a choice of modes, prefer the one that applies the rules while you work over the one that audits afterwards: this is the mode for building something now, and the audit mode can still be run later by the same person who reads your answer.","</non-interactive>"].join(`
2
2
  `),Gt=16*1024;function Wt(e){try{if(!Ft(e))return;let t=Lt(e,"utf8").trim();return!t||Buffer.byteLength(t,"utf8")>Gt?void 0:t}catch{return}}function at(e,t){let s=[t?e:`${e}
3
3
 
4
4
  ${Ut}`],n=Wt(it);return n&&s.push(`# Standing instructions from ${it}
@@ -1,4 +1,4 @@
1
- import{$a as ps,A as Oo,Aa as Jo,Ba as Xo,Ca as Zo,D as Rt,Da as Qo,E as No,Ea as es,G as Fo,Ga as de,Ha as E,Ia as X,J as jo,Ja as A,K as Do,Ka as ts,L as It,La as ns,M as Wo,Ma as rs,N as Uo,Na as is,O as Bo,Oa as Kn,P as Wn,Pa as os,Qa as ss,Sa as as,Ta as ls,Va as cs,X as Un,Xa as ds,Ya as us,Z as Bn,Za as fs,_a as ms,aa as Qe,ab as gs,bb as hs,c as Ao,e as To,g as Eo,h as Mo,ha as Vo,ia as et,ka as _t,n as Io,oa as Ko,pa as Go,ra as Ho,sa as qo,ta as zo,v as _o,wa as Yo,x as Lo,z as Dn,za as Vn}from"./chunk-FBR7W7S2.js";import{b as bs,c as ws}from"./chunk-SDU65XW4.js";import{b as Ee,c as Ze,e as Po,f as Mt,g as Ro,h as Pt}from"./chunk-27TRKD65.js";import{A as so,B as Ct,C as ao,b as In,c as ye,d as Ji,e as Xi,h as Zi,n as _n,o as Qi,q as oe,s as eo,t as Ie,v as to,w as no,x as ro,y as io,z as oo}from"./chunk-7BMVQMQW.js";import{a as lo,b as co,c as uo,d as fo,f as mo,g as po,h as go,i as ho,l as bo}from"./chunk-G5RR42BO.js";import{a as At,b as Ln,c as On,d as wo,e as Tt}from"./chunk-3FYCFLNK.js";import{u as yo}from"./chunk-SDO33XPR.js";import{a as ko}from"./chunk-ORJ2QZBG.js";import{a as $o,c as Et,d as Nn,j as vo,k as xo,l as So,n as Fn,o as jn,p as Co}from"./chunk-ZJL4OEXX.js";import{a as Pn,b as Rn,c as Vi,d as Ki}from"./chunk-EZNNALD3.js";import{b as St}from"./chunk-7LA2AMZB.js";import{h as Ci,i as Ai}from"./chunk-LQAHFJBU.js";import{a as vn,b as wt,e as Si}from"./chunk-2YWKLZB6.js";import{A as ji,B as vt,C as xt,D as Di,E as Cn,F as An,G as Wi,H as P,M as Xe,N as Tn,O as Ui,Q as Bi,c as xn,d as yt,g as kt,i as Ti,j as Ei,k as Mi,l as Pi,m as $t,n as Ri,o as Sn,p as Ii,s as se,t as _i,u as Li,x as Oi,y as Ni,z as Fi}from"./chunk-5FIFNXLT.js";import{a as ie}from"./chunk-UTYFLLSM.js";import{j as En,k as Mn}from"./chunk-MVVEYKN6.js";import{b as Gi,c as Hi,d as qi,e as zi,f as Yi}from"./chunk-TUXY64DT.js";import"./chunk-WOT6VMZA.js";import{execFile as yd}from"node:child_process";import{promisify as kd}from"node:util";import{appendFileSync as $d,existsSync as qt,mkdirSync as $r,readFileSync as zt,rmSync as vd,statSync as tl,writeFileSync as vr}from"node:fs";import{basename as xd,dirname as Sd,join as me,resolve as Cd}from"node:path";function ys(e){if(e==="")return!0;let t=/^\x1b\[(\d+);(\d+)u$/.exec(e);if(t&&Number(t[1])===99&&(Number(t[2])&5)!==0)return!0;let n=/^\x1b\[27;(\d+);(\d+)~$/.exec(e);return!!(n&&Number(n[2])===99&&(Number(n[1])&5)!==0)}function ks(e){let t=!1;process.on("SIGINT",()=>{t||(t=!0,e())})}function Il(e){if(!e||typeof e!="object")return;let t=e;if(!(typeof t.input!="number"&&typeof t.cacheRead!="number"&&typeof t.cacheWrite!="number"))return t}function _l(e){let t=e?.input??0,n=e?.cacheRead??0,r=e?.cacheWrite??0;return{input:t,cacheRead:n,cacheWrite:r,prompt:t+n+r}}function Ll(e){if(typeof e!="string")return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function Ol(e){if(!e||typeof e!="object")return;let t=e,r=(t.message&&typeof t.message=="object"?t.message:void 0)??t,o=Il(r.usage);if(!o)return;let u=typeof r.provider=="string"?r.provider:"",a=typeof r.model=="string"?r.model:"";return{usage:o,model:[u,a].filter(Boolean).join("/")}}function $s(e){let t=0,n=0,r=[],o=0,u=null;for(let g of e){let b=Ol(g);if(!b)continue;let{input:k,cacheRead:C,cacheWrite:_,prompt:O}=_l(b.usage);if(O===0)continue;t+=C,n+=k+_;let F=Ll(g.timestamp),W=u,K=W?W.at:null;if(W!==null&&C===0&&k>=1e3){let ee=F!==null&&K!==null?Math.max(0,F-K):0;r.push({missedTokens:k,idleMs:ee,modelChanged:b.model!==""&&W.model!==""&&b.model!==W.model}),o+=k}u={prompt:O,at:F??K??null,model:b.model}}let a=t+n;return{cachedTokens:t,billedTokens:n,hitRate:a>0?t/a*100:null,misses:r,missedTokens:o}}function vs(e){return e.modelChanged?"model changed, so its cache had to be built":e.idleMs>=3e5?`cache expired after ${Math.round(e.idleMs/1e3)}s idle`:e.idleMs>0?"prompt changed too early in the prefix to hit":"reason not recorded"}import{copyToClipboard as Ad,ProjectTrustStore as Td,SessionManager as Ed}from"@netrodev/hxf-coding-agent";import{CombinedAutocompleteProvider as nl,Container as Md,Editor as Pd,matchesKey as q,ProcessTerminal as Rd,ScrollView as Id,KeybindingsManager as sl,setKeybindings as al,isKeyRelease as _d,parseColor as Jt,TUI_KEYBINDINGS as ll,SelectList as Ld,TuiAltScreen as Od,truncateToWidth as We,VStack as Nd,visibleWidth as Ar,wrapTextWithAnsi as cl}from"@netrodev/hxf-tui";import{spawn as Nl}from"node:child_process";function Fl(e,t,n=2e3){return new Promise(r=>{let o=!1,u,a=k=>{o||(o=!0,u!==void 0&&clearTimeout(u),r(k))},g;try{g=Nl(e,[...t],{stdio:["ignore","pipe","ignore"]})}catch{a({ok:!1,stdout:""});return}u=setTimeout(()=>{g.kill("SIGKILL"),a({ok:!1,stdout:""})},n);let b=[];g.stdout?.on("data",k=>b.push(k)),g.on("error",()=>a({ok:!1,stdout:""})),g.on("close",k=>{a({ok:k===0,stdout:Buffer.concat(b).toString("utf8")})})})}function Gn(){return process.env.XDG_SESSION_TYPE==="wayland"||(process.env.WAYLAND_DISPLAY?.length??0)>0}async function jl(){let e=[];process.platform==="darwin"?e.push({command:"pbpaste",args:[]}):process.platform==="win32"?e.push({command:"powershell.exe",args:["-NoProfile","-Command","Get-Clipboard -Raw"]}):(Gn()&&(e.push({command:"wl-paste",args:["--no-newline","--type","text/plain;charset=utf-8"]}),e.push({command:"wl-paste",args:["--no-newline","--type","text/plain"]}),e.push({command:"wl-paste",args:["--no-newline"]})),((process.env.DISPLAY?.length??0)>0||!Gn())&&(e.push({command:"xclip",args:["-selection","clipboard","-o"]}),e.push({command:"xsel",args:["--clipboard","--output"]})),e.push({command:"termux-clipboard-get",args:[]}));for(let t of e){let n=await Fl(t.command,t.args);if(n.ok&&n.stdout.length>0)return n.stdout}}async function xs(){let e;try{let{getNativeClipboard:r}=await import("@netrodev/hxf-tui");e=r()}catch{e=void 0}if(e)try{let r=await e.getText();if(typeof r=="string"&&r.length>0)return{ok:!0,text:r}}catch{}let t=await jl();return t!==void 0?{ok:!0,text:t}:{ok:!1,reason:`no clipboard tool could read it \u2014 ${Gn()?"install wl-clipboard (wl-paste)":process.platform==="darwin"?"pbpaste should be present on macOS":process.platform==="win32"?"Get-Clipboard should be present on Windows":"install xclip or xsel, or run under a display"}`}}import{spawn as Dl}from"node:child_process";import{mkdirSync as Wl,writeFileSync as Ul}from"node:fs";import{join as Bl}from"node:path";import{getNativeClipboard as Vl}from"@netrodev/hxf-tui";async function _e(e,t,n=4e3){let{promise:r,resolve:o}=Promise.withResolvers(),u=!1,a,g=C=>{u||(u=!0,clearTimeout(a),o(C))},b;try{b=Dl(e,[...t],{stdio:["ignore","pipe","ignore"]})}catch{return g(void 0),r}a=setTimeout(()=>{b.kill("SIGKILL"),g(void 0)},n);let k=[];return b.stdout?.on("data",C=>k.push(C)),b.on("error",()=>g(void 0)),b.on("close",C=>{let _=Buffer.concat(k);g(C===0&&_.length>0?_:void 0)}),r}function Ss(){return process.env.XDG_SESSION_TYPE==="wayland"||(process.env.WAYLAND_DISPLAY?.length??0)>0}function Kl(e){return e.length>8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71}function Gl(e){return e.length>3&&e[0]===255&&e[1]===216&&e[2]===255}async function Hl(){try{let e=await Vl()?.getImage();if(e&&e.length>0)return Buffer.from(e)}catch{}if(process.platform==="darwin"){let e=await _e("pngpaste",["-"]);return e||await _e("osascript",["-e",`set d to the clipboard as \xABclass PNGf\xBB
1
+ import{$a as ps,A as Oo,Aa as Jo,Ba as Xo,Ca as Zo,D as Rt,Da as Qo,E as No,Ea as es,G as Fo,Ga as de,Ha as E,Ia as X,J as jo,Ja as A,K as Do,Ka as ts,L as It,La as ns,M as Wo,Ma as rs,N as Uo,Na as is,O as Bo,Oa as Kn,P as Wn,Pa as os,Qa as ss,Sa as as,Ta as ls,Va as cs,X as Un,Xa as ds,Ya as us,Z as Bn,Za as fs,_a as ms,aa as Qe,ab as gs,bb as hs,c as Ao,e as To,g as Eo,h as Mo,ha as Vo,ia as et,ka as _t,n as Io,oa as Ko,pa as Go,ra as Ho,sa as qo,ta as zo,v as _o,wa as Yo,x as Lo,z as Dn,za as Vn}from"./chunk-AMHJO4G3.js";import{b as bs,c as ws}from"./chunk-SDU65XW4.js";import{b as Ee,c as Ze,e as Po,f as Mt,g as Ro,h as Pt}from"./chunk-XODGJSB3.js";import{A as so,B as Ct,C as ao,b as In,c as ye,d as Ji,e as Xi,h as Zi,n as _n,o as Qi,q as oe,s as eo,t as Ie,v as to,w as no,x as ro,y as io,z as oo}from"./chunk-RT3VOMO4.js";import{a as lo,b as co,c as uo,d as fo,f as mo,g as po,h as go,i as ho,l as bo}from"./chunk-WKR2L2CT.js";import{a as At,b as Ln,c as On,d as wo,e as Tt}from"./chunk-3FYCFLNK.js";import{u as yo}from"./chunk-SDO33XPR.js";import{a as ko}from"./chunk-ORJ2QZBG.js";import{a as $o,c as Et,d as Nn,j as vo,k as xo,l as So,n as Fn,o as jn,p as Co}from"./chunk-ZJL4OEXX.js";import{a as Pn,b as Rn,c as Vi,d as Ki}from"./chunk-EZNNALD3.js";import{b as St}from"./chunk-7LA2AMZB.js";import{h as Ci,i as Ai}from"./chunk-YUOYDO5O.js";import{a as vn,b as wt,e as Si}from"./chunk-WDMBTVK7.js";import{A as ji,B as vt,C as xt,D as Di,E as Cn,F as An,G as Wi,H as P,M as Xe,N as Tn,O as Ui,Q as Bi,c as xn,d as yt,g as kt,i as Ti,j as Ei,k as Mi,l as Pi,m as $t,n as Ri,o as Sn,p as Ii,s as se,t as _i,u as Li,x as Oi,y as Ni,z as Fi}from"./chunk-5FIFNXLT.js";import{a as ie}from"./chunk-UTYFLLSM.js";import{j as En,k as Mn}from"./chunk-MVVEYKN6.js";import{b as Gi,c as Hi,d as qi,e as zi,f as Yi}from"./chunk-TUXY64DT.js";import"./chunk-WOT6VMZA.js";import{execFile as yd}from"node:child_process";import{promisify as kd}from"node:util";import{appendFileSync as $d,existsSync as qt,mkdirSync as $r,readFileSync as zt,rmSync as vd,statSync as tl,writeFileSync as vr}from"node:fs";import{basename as xd,dirname as Sd,join as me,resolve as Cd}from"node:path";function ys(e){if(e==="")return!0;let t=/^\x1b\[(\d+);(\d+)u$/.exec(e);if(t&&Number(t[1])===99&&(Number(t[2])&5)!==0)return!0;let n=/^\x1b\[27;(\d+);(\d+)~$/.exec(e);return!!(n&&Number(n[2])===99&&(Number(n[1])&5)!==0)}function ks(e){let t=!1;process.on("SIGINT",()=>{t||(t=!0,e())})}function Il(e){if(!e||typeof e!="object")return;let t=e;if(!(typeof t.input!="number"&&typeof t.cacheRead!="number"&&typeof t.cacheWrite!="number"))return t}function _l(e){let t=e?.input??0,n=e?.cacheRead??0,r=e?.cacheWrite??0;return{input:t,cacheRead:n,cacheWrite:r,prompt:t+n+r}}function Ll(e){if(typeof e!="string")return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function Ol(e){if(!e||typeof e!="object")return;let t=e,r=(t.message&&typeof t.message=="object"?t.message:void 0)??t,o=Il(r.usage);if(!o)return;let u=typeof r.provider=="string"?r.provider:"",a=typeof r.model=="string"?r.model:"";return{usage:o,model:[u,a].filter(Boolean).join("/")}}function $s(e){let t=0,n=0,r=[],o=0,u=null;for(let g of e){let b=Ol(g);if(!b)continue;let{input:k,cacheRead:C,cacheWrite:_,prompt:O}=_l(b.usage);if(O===0)continue;t+=C,n+=k+_;let F=Ll(g.timestamp),W=u,K=W?W.at:null;if(W!==null&&C===0&&k>=1e3){let ee=F!==null&&K!==null?Math.max(0,F-K):0;r.push({missedTokens:k,idleMs:ee,modelChanged:b.model!==""&&W.model!==""&&b.model!==W.model}),o+=k}u={prompt:O,at:F??K??null,model:b.model}}let a=t+n;return{cachedTokens:t,billedTokens:n,hitRate:a>0?t/a*100:null,misses:r,missedTokens:o}}function vs(e){return e.modelChanged?"model changed, so its cache had to be built":e.idleMs>=3e5?`cache expired after ${Math.round(e.idleMs/1e3)}s idle`:e.idleMs>0?"prompt changed too early in the prefix to hit":"reason not recorded"}import{copyToClipboard as Ad,ProjectTrustStore as Td,SessionManager as Ed}from"@netrodev/hxf-coding-agent";import{CombinedAutocompleteProvider as nl,Container as Md,Editor as Pd,matchesKey as q,ProcessTerminal as Rd,ScrollView as Id,KeybindingsManager as sl,setKeybindings as al,isKeyRelease as _d,parseColor as Jt,TUI_KEYBINDINGS as ll,SelectList as Ld,TuiAltScreen as Od,truncateToWidth as We,VStack as Nd,visibleWidth as Ar,wrapTextWithAnsi as cl}from"@netrodev/hxf-tui";import{spawn as Nl}from"node:child_process";function Fl(e,t,n=2e3){return new Promise(r=>{let o=!1,u,a=k=>{o||(o=!0,u!==void 0&&clearTimeout(u),r(k))},g;try{g=Nl(e,[...t],{stdio:["ignore","pipe","ignore"]})}catch{a({ok:!1,stdout:""});return}u=setTimeout(()=>{g.kill("SIGKILL"),a({ok:!1,stdout:""})},n);let b=[];g.stdout?.on("data",k=>b.push(k)),g.on("error",()=>a({ok:!1,stdout:""})),g.on("close",k=>{a({ok:k===0,stdout:Buffer.concat(b).toString("utf8")})})})}function Gn(){return process.env.XDG_SESSION_TYPE==="wayland"||(process.env.WAYLAND_DISPLAY?.length??0)>0}async function jl(){let e=[];process.platform==="darwin"?e.push({command:"pbpaste",args:[]}):process.platform==="win32"?e.push({command:"powershell.exe",args:["-NoProfile","-Command","Get-Clipboard -Raw"]}):(Gn()&&(e.push({command:"wl-paste",args:["--no-newline","--type","text/plain;charset=utf-8"]}),e.push({command:"wl-paste",args:["--no-newline","--type","text/plain"]}),e.push({command:"wl-paste",args:["--no-newline"]})),((process.env.DISPLAY?.length??0)>0||!Gn())&&(e.push({command:"xclip",args:["-selection","clipboard","-o"]}),e.push({command:"xsel",args:["--clipboard","--output"]})),e.push({command:"termux-clipboard-get",args:[]}));for(let t of e){let n=await Fl(t.command,t.args);if(n.ok&&n.stdout.length>0)return n.stdout}}async function xs(){let e;try{let{getNativeClipboard:r}=await import("@netrodev/hxf-tui");e=r()}catch{e=void 0}if(e)try{let r=await e.getText();if(typeof r=="string"&&r.length>0)return{ok:!0,text:r}}catch{}let t=await jl();return t!==void 0?{ok:!0,text:t}:{ok:!1,reason:`no clipboard tool could read it \u2014 ${Gn()?"install wl-clipboard (wl-paste)":process.platform==="darwin"?"pbpaste should be present on macOS":process.platform==="win32"?"Get-Clipboard should be present on Windows":"install xclip or xsel, or run under a display"}`}}import{spawn as Dl}from"node:child_process";import{mkdirSync as Wl,writeFileSync as Ul}from"node:fs";import{join as Bl}from"node:path";import{getNativeClipboard as Vl}from"@netrodev/hxf-tui";async function _e(e,t,n=4e3){let{promise:r,resolve:o}=Promise.withResolvers(),u=!1,a,g=C=>{u||(u=!0,clearTimeout(a),o(C))},b;try{b=Dl(e,[...t],{stdio:["ignore","pipe","ignore"]})}catch{return g(void 0),r}a=setTimeout(()=>{b.kill("SIGKILL"),g(void 0)},n);let k=[];return b.stdout?.on("data",C=>k.push(C)),b.on("error",()=>g(void 0)),b.on("close",C=>{let _=Buffer.concat(k);g(C===0&&_.length>0?_:void 0)}),r}function Ss(){return process.env.XDG_SESSION_TYPE==="wayland"||(process.env.WAYLAND_DISPLAY?.length??0)>0}function Kl(e){return e.length>8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71}function Gl(e){return e.length>3&&e[0]===255&&e[1]===216&&e[2]===255}async function Hl(){try{let e=await Vl()?.getImage();if(e&&e.length>0)return Buffer.from(e)}catch{}if(process.platform==="darwin"){let e=await _e("pngpaste",["-"]);return e||await _e("osascript",["-e",`set d to the clipboard as \xABclass PNGf\xBB
2
2
  return d`])}if(process.platform==="win32"){let e=["Add-Type -AssemblyName System.Windows.Forms","$img = [System.Windows.Forms.Clipboard]::GetImage()","if ($img -ne $null) {"," $ms = New-Object System.IO.MemoryStream"," $img.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png)"," [Console]::OpenStandardOutput().Write($ms.ToArray(), 0, $ms.Length)","}"].join("; ");return _e("powershell.exe",["-NoProfile","-Command",e])}if(Ss()){let e=await _e("wl-paste",["--type","image/png"]);if(e)return e}if((process.env.DISPLAY?.length??0)>0||!Ss()){let e=await _e("xclip",["-selection","clipboard","-t","image/png","-o"]);if(e)return e;let t=await _e("xclip",["-selection","clipboard","-t","image/jpeg","-o"]);if(t)return t}}function ql(e,t){let n=t==="image/jpeg"?"jpg":"png";return`pasted-${new Date(e).toISOString().replace(/[:.]/g,"-")}.${n}`}async function Hn(e=Bi,t=Date.now()){let n=await Hl();if(!n)return{ok:!1,reason:"the clipboard holds no image"};let r=Kl(n)?"image/png":Gl(n)?"image/jpeg":void 0;if(!r)return{ok:!1,reason:"the clipboard image is not PNG or JPEG"};try{Wl(e,{recursive:!0});let o=Bl(e,ql(t,r));return Ul(o,n,{mode:384}),{ok:!0,image:{path:o,data:n.toString("base64"),mimeType:r}}}catch(o){return{ok:!1,reason:`could not store the image: ${o instanceof Error?o.message:String(o)}`}}}import{TreeSelectorComponent as Fd,initTheme as jd}from"@netrodev/hxf-coding-agent";import{getKeybindings as rl}from"@netrodev/hxf-tui";import{mixColors as zl,parseColor as Yl,styleText as he}from"@netrodev/hxf-tui";var ue=process.env.HOWTOCODE_NO_MOTION!=="1",Jl=45,Cs=5,As=8,qn=1e4,Ts=6e4,Es=3,Ms=4,zn=e=>e<0?0:e>1?1:e;function ke(e,t,n){let r=zn(n);return r>=1?t:r<=0?e:zl(e,t,r)}var Lt=class{value;velocity=0;last=Date.now();target;constructor(t,n=t){this.value=t,this.target=n}set(t){this.target=t}get moving(){return Math.abs(this.target-this.value)>.15}snap(t){this.value=t,this.target=t,this.velocity=0,this.last=Date.now()}step(t=Date.now()){let n=Math.max(0,t-this.last),r=Math.min(250,n)/1e3;if(this.last=t,!ue)return this.value=this.target,this.velocity=0,this.value;n>250&&(this.velocity=0);let o=150,u=2*Math.sqrt(o),a=Math.max(1,Math.ceil(r/.008)),g=r/a;for(let b=0;b<a;b+=1)this.velocity+=(this.target-this.value)*o*g-this.velocity*u*g,this.value+=this.velocity*g;return this.moving||(this.value=this.target,this.velocity=0),this.value}};function Yn(e,t,n,r){return!ue||e<=qn?t:e>=Ts?r:ke(n,r,(e-qn)/(Ts-qn))}function Ps(e,t){return!ue||t<=0||e<0?1:1-(1-zn(e/t))**3}var Rs=260,Xl=45;function Is(e,t,n=Xl,r=400){return!ue||n<=0||e<0||e>=r?t:Math.min(t,Math.floor(e/n)+1)}function _s(e,t,n=Date.now(),r=1400){if(!ue||r<=0)return e;let o=n%r/r;return ke(e,t,o<.5?o*2:(1-o)*2)}function Ot(e,t,n){let r=he(e,{fg:t.rest},de);if(!ue||e.length===0)return r;let o=zn(n);if(o>=1)return r;let u=t.band??1,a=e.length+Ms*2,b=Math.min(a-1,Math.floor(o*a))-Ms,k=K=>{let ee=Math.abs(K-b);return ee>u?0:1-ee/(u+1)},C="",_=0,O=null,F=0,W=0;for(let K of e){let ee=k(W);O===null?O=ee:ee!==O&&(C+=he(e.slice(_,F),{fg:ke(t.rest,t.lit,O)},de),_=F,O=ee),F+=K.length,W+=1}return C+he(e.slice(_),{fg:ke(t.rest,t.lit,O??0)},de)}function Jn(e,t,n=Date.now(),r=90){let o=t[0]??Yl("#e6e6e6");if(t.length===0||e.length===0)return he(e,{fg:o},de);if(!ue||r<=0)return he(e,{fg:t[t.length-1]??o},de);let u=t.length*r,a=(n%u+u)%u,g="",b=0,k=null,C=0,_=0,O=F=>{let W=(a+F*r)/u%1*t.length,K=Math.floor(W)%t.length,ee=(K+1)%t.length;return ke(t[K]??o,t[ee]??o,W-Math.floor(W))};for(let F of e){let W=O(_);k===null?k=W:W!==k&&(g+=he(e.slice(b,C),{fg:k},de),b=C,k=W),C+=F.length,_+=1}return g+he(e.slice(b),{fg:k??o},de)}function Zl(e,t){let n=Math.abs(e-t);return n>=Cs?0:Math.ceil((1-n/Cs)*Es)/Es}function Ls(e,t,n=Date.now()){let r=t.charMs??Jl;if(!ue||e.length===0||r<=0)return he(e,{fg:t.base},de);let o=e.length+As*2,u=n/r%o-As,a=(O,F)=>he(O,{fg:ke(t.base,t.bright,F)},de),g="",b=0,k=null,C=0,_=0;for(let O of e){let F=Zl(_,u);k===null?k=F:F!==k&&(g+=a(e.slice(b,C),k),b=C,k=F),C+=O.length,_+=1}return g+a(e.slice(b),k??0)}import{readFileSync as Ql,statSync as ec}from"node:fs";import{homedir as tc}from"node:os";import{extname as nc}from"node:path";var Xn="\x1B[200~",Zn="\x1B[201~",rc={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp"},Os=10*1024*1024,ic=256*1024,oc=20;function Ns(e){if(!e.startsWith(Xn)||!e.endsWith(Zn))return;let t=e.slice(Xn.length,e.length-Zn.length);if(!(t.includes(Xn)||t.includes(Zn)))return t}function Fs(e){return e.trim()===""}function sc(e){return/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\")||e.startsWith("/")||e==="~"||e.startsWith("~/")}function ac(e,t=tc()){let n=e.trim();return n.startsWith("file://")&&(n=decodeURIComponent(n.slice(7)),/^\/[a-zA-Z]:\//.test(n)&&(n=n.slice(1))),!/^[a-zA-Z]:[\\/]/.test(n)&&!n.startsWith("\\\\")&&(n=n.replace(/\\([ ()'&])/g,"$1")),n==="~"?t:n.startsWith("~/")?t+n.slice(1):n}function js(e,t){let n=e.trim();if(!n||n.length>8192)return;let r,o=[...n.matchAll(/"([^"]+)"|'([^']+)'/g)].map(a=>a[1]??a[2]??"");if(o.length>0&&n.replace(/"[^"]+"|'[^']+'/g,"").trim()===""?r=o:r=n.split(/\r?\n/).map(a=>a.trim()).filter(a=>a.length>0),r.length===0||r.length>oc||!r.every(a=>sc(a)||a.startsWith("file://")))return;let u=r.map(a=>ac(a));return u.every(t)?u:void 0}function Ds(e){return rc[nc(e).toLowerCase()]}function Ws(e){return`[file ${e}]`}function Qn(e){return`[image ${e}]`}function Us(e,t){return e.replace(/\[file ([^\]\n]+)\]/g,(n,r)=>{let o=t(r);return o===void 0?n:`<file name="${r}">
3
3
  ${o.trimEnd()}
4
4
  </file>`})}function Bs(e){try{let t=ec(e);if(!t.isFile()||t.size===0||t.size>ic)return;let n=Ql(e);return n.includes(0)?void 0:n.toString("utf8")}catch{return}}import{Markdown as Tc,wrapTextWithAnsi as Ec}from"@netrodev/hxf-tui";import{homedir as lc}from"node:os";import{isAbsolute as cc,relative as dc,resolve as uc,sep as Vs}from"node:path";import{getImageDimensions as fc,imageFallback as Ks,renderImage as mc}from"@netrodev/hxf-tui";var pc="\u25CF",nr="\u2514",Ft="\u22EF",er=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function rt(e=1e3/30){let t=Math.floor(Date.now()/e)%er.length;return er[t]??er[0]}var gc="\u25B2";var hc="\u25CB",bc=["create_object","set_properties","delete_object","clone_instance","reparent_instance","set_script_source","edit_script_lines","insert_script_lines","execute_luau","generate_mesh","generate_material","generate_procedural_model"];function rr(e){return e.includes("__")?e.slice(e.lastIndexOf("__")+2):e}function zs(e){return bc.includes(rr(e))}function tt(e,t=process.cwd()){if(!e||!cc(e))return e;let n=uc(e),r=dc(t,n);if(r==="")return".";if(r&&!r.startsWith(`..${Vs}`)&&r!=="..")return r;let o=lc();return o&&(n===o||n.startsWith(o+Vs))?`~${n.slice(o.length)}`:n}function ae(e,t){let n=e.replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,Math.max(1,t-1))}\u2026`:n}function U(e,t){if(e&&typeof e=="object"){let n=e[t];if(typeof n=="string"&&n.length>0)return n;if(typeof n=="number")return String(n)}}function wc(e,t=160){if(!e||typeof e!="object")return"";try{let n=JSON.stringify(e);return n&&n!=="{}"?ae(n,t):""}catch{return""}}function yc(e,t){switch(e){case"read":{let n=tt(U(t,"path")??""),r=[U(t,"offset"),U(t,"limit")].filter(Boolean);return r.length>0?`${n} ${r.length===1?`offset=${r[0]}`:`offset=${r[0]}, limit=${r[1]}`}`:n}case"edit":case"write":return tt(U(t,"path")??"");case"bash":case"powershell":{let n=U(t,"command")??"";return t?.run_in_background===!0?`${n} [background]`:n}case"bash_output":{let n=U(t,"task_id"),r=U(t,"filter");return n?r?`${n} filter=${r}`:n:"all tasks"}case"kill_shell":return U(t,"task_id")??"";case"compress":{let n=U(t,"topic")??"",r=Array.isArray(t.content)?t.content.length:0;return r>1?`${n} (${r} ranges)`:n}case"grep":{let n=U(t,"pattern")??"",r=U(t,"path");return r?`${n} in ${tt(r)}`:n}case"find":case"glob":{let n=U(t,"pattern")??U(t,"glob")??"",r=U(t,"path");return r?`${n} in ${tt(r)}`:n}case"ls":return tt(U(t,"path")??".");case"task":return U(t,"agent")??"task";case"ask":return U(t,"question")??"";case"web_search":return U(t,"query")??"";case"web_fetch":return U(t,"url")??"";case"lsp":{let n=U(t,"action")??"lsp",r=U(t,"file")??"",o=U(t,"line");return o?`${n} ${r}:${o}`:`${n} ${r}`}case"quality":return U(t,"path")??"changed files";case"think":return"private";case"todo":{let n=U(t,"op")??"view",r=U(t,"task"),o=t?.items;return n==="init"&&Array.isArray(o)?`init ${o.length} task${o.length===1?"":"s"}`:r?`${n} ${r}`:n}case"context":{let n=U(t,"op")??"list",r=U(t,"key");return r?`${n} ${r}`:n}case"workflow":{let n=U(t,"path");if(n)return n;let r=U(t,"code")??"",o=/export\s+const\s+meta\s*=\s*\{[\s\S]*?name\s*:\s*["'`]([^"'`]+)/.exec(r)?.[1];if(o)return o;let u=r.trim().split(`
@@ -138,4 +138,4 @@ plan file: ${Wo()??"(unknown)"}`);return}if(s==="goal"){let d=l.trim();if(!d){m(
138
138
  ${Dn(p)}`);return}if(s==="session"){let d=$.model;m("session",d?`${d.provider}/${d.id}`:"no model");return}if(s==="skills"){m("skills",ws($.resourceLoader.getSkills().skills));return}if(s==="preset"){xi(l);return}if(s==="roblox"){let d=se(e.cwd).entries.find(x=>x.manifest.name==="rotoolbox");if(!d||d.source!=="installed"){m("roblox","RoToolbox is not installed. Run /preset and install RoToolbox first.");return}let p=Sn(d.dir),w=$.getActiveToolNames().filter(x=>/roblox[-_]studio/i.test(x)),h=w.length>0;m("roblox",p?`RoToolbox: disabled
139
139
  Enable with /preset enable rotoolbox
140
140
  The MCP server and manager stay stopped while disabled.`:["RoToolbox: active",`MCP server: ${h?`connected \u2014 ${w.length} tool${w.length===1?"":"s"} registered`:"not connected yet"}`,"Open Roblox Studio with a place, then use a prompt to inspect it.","Disable with /preset disable rotoolbox"].join(`
141
- `));return}let f=bs(i,$.resourceLoader.getSkills().skills.map(d=>d.name));if(f){ai(f);return}let y=$.extensionRunner.getCommand(s??"");if(y){try{await y.handler(l,$.extensionRunner.createCommandContext())}catch(d){G(d instanceof Error?d.message:String(d))}return}m("command",`/${s??""} is not available in this screen yet`)};Io((i,s)=>{let{promise:c,resolve:l}=Promise.withResolvers();return j(i,s.map(f=>({value:f,label:f})),l,()=>l("cancelled")),c}),process.on("SIGTERM",Ge),ks(()=>{Ge()}),t.setTitle(`${vn} ${wt}`),Yd(),r.start(),r.requestRender(!0),gn(!0);{let{maybeShowWelcome:i}=await import("./chunk-NP2VDAEJ.js");await i({cwd:e.cwd,note:e.note,signedIn:be!==void 0,runSlash:s=>{Je(s)},openExternal:s=>{Fe(s)}},j,m)}e.initialPrompt&&hn(e.initialPrompt),await new Promise(()=>{})}var Z,Jd=1e3/30,Xd=45e3;export{Pr as Dock,Er as Hud,Mr as PinnedBlock,Hd as approvalDetail,Gd as infoPanel,_t as orderModelsForDefault,Kd as pickerPanel,Im as runWorkbench,Cr as slashCommands,qd as workflowPanel,Yt as workflowPanelFromRun,Rr as workflowRunOf};
141
+ `));return}let f=bs(i,$.resourceLoader.getSkills().skills.map(d=>d.name));if(f){ai(f);return}let y=$.extensionRunner.getCommand(s??"");if(y){try{await y.handler(l,$.extensionRunner.createCommandContext())}catch(d){G(d instanceof Error?d.message:String(d))}return}m("command",`/${s??""} is not available in this screen yet`)};Io((i,s)=>{let{promise:c,resolve:l}=Promise.withResolvers();return j(i,s.map(f=>({value:f,label:f})),l,()=>l("cancelled")),c}),process.on("SIGTERM",Ge),ks(()=>{Ge()}),t.setTitle(`${vn} ${wt}`),Yd(),r.start(),r.requestRender(!0),gn(!0);{let{maybeShowWelcome:i}=await import("./chunk-R7ANN5PP.js");await i({cwd:e.cwd,note:e.note,signedIn:be!==void 0,runSlash:s=>{Je(s)},openExternal:s=>{Fe(s)}},j,m)}e.initialPrompt&&hn(e.initialPrompt),await new Promise(()=>{})}var Z,Jd=1e3/30,Xd=45e3;export{Pr as Dock,Er as Hud,Mr as PinnedBlock,Hd as approvalDetail,Gd as infoPanel,_t as orderModelsForDefault,Kd as pickerPanel,Im as runWorkbench,Cr as slashCommands,qd as workflowPanel,Yt as workflowPanelFromRun,Rr as workflowRunOf};
@@ -1 +1 @@
1
- import{A,B,C,D,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-7BMVQMQW.js";import"./chunk-7LA2AMZB.js";import"./chunk-LQAHFJBU.js";import"./chunk-2YWKLZB6.js";import"./chunk-UTYFLLSM.js";import"./chunk-WOT6VMZA.js";export{g as CATALOG_CACHE_TTL_MS,m as DEFAULT_CONTEXT_WINDOW,a as HOWTOCODE_BASE_URL,b as HOWTOCODE_CONSOLE_URL,l as HOWTOCODE_MODEL_COMPAT,c as HOWTOCODE_PROVIDERS,j as HTTP_IDLE_TIMEOUT_MS,r as UNLIMITED_SENTINEL,w as applyCatalog,x as applyCompat,B as checkAccount,s as checkCreditPools,t as checkUsage,d as configuredProviderIds,y as countNewModels,k as ensureGatewaySettings,C as fetchGatewayPrices,A as findLiveModels,q as isHowtoCodeProvider,h as loadCatalog,o as looksLikeToken,n as maskToken,v as mergeModels,e as newProviderEntry,p as parseModelIds,z as probeModel,D as readProviderKey,f as repairGatewayModels,i as repairModelFacts,u as syncGatewayModelsOnStart};
1
+ import{A,B,C,D,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-RT3VOMO4.js";import"./chunk-7LA2AMZB.js";import"./chunk-YUOYDO5O.js";import"./chunk-WDMBTVK7.js";import"./chunk-UTYFLLSM.js";import"./chunk-WOT6VMZA.js";export{g as CATALOG_CACHE_TTL_MS,m as DEFAULT_CONTEXT_WINDOW,a as HOWTOCODE_BASE_URL,b as HOWTOCODE_CONSOLE_URL,l as HOWTOCODE_MODEL_COMPAT,c as HOWTOCODE_PROVIDERS,j as HTTP_IDLE_TIMEOUT_MS,r as UNLIMITED_SENTINEL,w as applyCatalog,x as applyCompat,B as checkAccount,s as checkCreditPools,t as checkUsage,d as configuredProviderIds,y as countNewModels,k as ensureGatewaySettings,C as fetchGatewayPrices,A as findLiveModels,q as isHowtoCodeProvider,h as loadCatalog,o as looksLikeToken,n as maskToken,v as mergeModels,e as newProviderEntry,p as parseModelIds,z as probeModel,D as readProviderKey,f as repairGatewayModels,i as repairModelFacts,u as syncGatewayModelsOnStart};
@@ -1,2 +1,2 @@
1
- import{b as c,d as l}from"./chunk-27TRKD65.js";import{a as i,b as r}from"./chunk-2YWKLZB6.js";import{H as s}from"./chunk-5FIFNXLT.js";import"./chunk-UTYFLLSM.js";import"./chunk-WOT6VMZA.js";var d=[["/connect","sign in to howtofix.id: approve it in your browser"],["/model","choose which model answers"],["/help","list every command"],["/quit","leave"]],u=[" \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557"," \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2554\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D"," \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2557 "," \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551 \u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2554\u2550\u2550\u255D "," \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u255D \u2588\u2588\u2557\u2588\u2588\u2551 "," \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D "],g=[" _ _ _____ ","| | | | __ __ | ___|","| |_| | \\ \\/ / | |_ ","| _ | > < | _| ","|_| |_| /_/\\_\\ |_| "];function m(){if(process.platform==="win32")return!1;let e=(process.env.LC_ALL||process.env.LC_CTYPE||process.env.LANG||"").toLowerCase();return e===""||e==="c"||e==="posix"||!e.includes("utf-8")&&!e.includes("utf8")?!1:!/ja|ko|zh|_kr|_jp|_cn|_tw|_hk/.test(e)}function h(){return m()?u:g}var _="https://howtofix.id/cli";function p(e){let n=process.env.HOME??"",t=n!==""&&e.startsWith(n)?`~${e.slice(n.length)}`:e,o=t.split("/").filter(Boolean);return o.length>3?`\u2026/${o.slice(-2).join("/")}`:t}function f(e){let n=e.signedIn?d.filter(([t])=>t!=="/connect"):d;return[...h(),"",`${i} ${r} \u2014 a terminal coding agent. Describe the change you want and it reads, edits and runs the code in front of you.`,"",` working in ${p(e.cwd)}`,...e.note?[` session ${e.note}`]:[],"",...e.signedIn?[" already signed in to howtofix.id",""]:[],...n.map(([t,o])=>` ${t.padEnd(11)}${o}`),"",' Or just start typing. Every message goes to the model; anything beginning with "/" stays local.'].join(`
1
+ import{b as c,d as l}from"./chunk-XODGJSB3.js";import{a as i,b as r}from"./chunk-WDMBTVK7.js";import{H as s}from"./chunk-5FIFNXLT.js";import"./chunk-UTYFLLSM.js";import"./chunk-WOT6VMZA.js";var d=[["/connect","sign in to howtofix.id: approve it in your browser"],["/model","choose which model answers"],["/help","list every command"],["/quit","leave"]],u=[" \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557"," \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2554\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D"," \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2557 "," \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551 \u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2554\u2550\u2550\u255D "," \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u255D \u2588\u2588\u2557\u2588\u2588\u2551 "," \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D "],g=[" _ _ _____ ","| | | | __ __ | ___|","| |_| | \\ \\/ / | |_ ","| _ | > < | _| ","|_| |_| /_/\\_\\ |_| "];function m(){if(process.platform==="win32")return!1;let e=(process.env.LC_ALL||process.env.LC_CTYPE||process.env.LANG||"").toLowerCase();return e===""||e==="c"||e==="posix"||!e.includes("utf-8")&&!e.includes("utf8")?!1:!/ja|ko|zh|_kr|_jp|_cn|_tw|_hk/.test(e)}function h(){return m()?u:g}var _="https://howtofix.id/cli";function p(e){let n=process.env.HOME??"",t=n!==""&&e.startsWith(n)?`~${e.slice(n.length)}`:e,o=t.split("/").filter(Boolean);return o.length>3?`\u2026/${o.slice(-2).join("/")}`:t}function f(e){let n=e.signedIn?d.filter(([t])=>t!=="/connect"):d;return[...h(),"",`${i} ${r} \u2014 a terminal coding agent. Describe the change you want and it reads, edits and runs the code in front of you.`,"",` working in ${p(e.cwd)}`,...e.note?[` session ${e.note}`]:[],"",...e.signedIn?[" already signed in to howtofix.id",""]:[],...n.map(([t,o])=>` ${t.padEnd(11)}${o}`),"",' Or just start typing. Every message goes to the model; anything beginning with "/" stays local.'].join(`
2
2
  `)}function v(){return[{value:"connect",label:"Sign in to howtofix.id",description:"approve the sign-in in your browser"},{value:"ready",label:"I have a key \u2014 just give me the prompt",description:"drops you at the prompt; run /connect whenever you like"},{value:"release",label:"What's in this release",description:`opens the ${r} notes in your browser`}]}async function E(e,n,t){c(s).welcomeSeen||(l(s),t(`welcome to ${i}`,f(e)),!e.signedIn&&await new Promise(o=>{n("First run \u2014 how do you want to begin?",v(),a=>{a==="connect"&&e.runSlash("/connect"),a==="release"&&e.openExternal(_),o()},()=>o())}))}export{E as maybeShowWelcome};
@@ -1,4 +1,4 @@
1
- import{a as v}from"./chunk-7LA2AMZB.js";import{h as M,i as T}from"./chunk-LQAHFJBU.js";import{a as w}from"./chunk-UTYFLLSM.js";import{existsSync as H,mkdirSync as I,readFileSync as b}from"node:fs";import{join as k}from"node:path";var J="https://models.dev/api.json";var N=["anthropic","openai","google","deepseek","zai","xai","moonshotai","minimax","alibaba","xiaomi","meta","tencent","nvidia","venice","openrouter"];function _(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"")}function S(n){let e=n.split("/");return _(e[e.length-1]??n)}function q(n){let e=new Map,s=new Map;if(!n||typeof n!="object")return e;let t=n,r=c=>{let o=N.indexOf(c);return o===-1?N.length:o};for(let c of Object.keys(t).sort()){let o=t[c]?.models;if(!(!o||typeof o!="object"))for(let a of Object.keys(o)){let i=o[a],u=Number(i?.limit?.context);if(!Number.isFinite(u)||u<=0)continue;let l=_(a),f=r(c),d=s.get(l);if(d!==void 0&&d<=f)continue;let m=Number(i?.limit?.output);e.set(l,{contextWindow:Math.floor(u),maxTokens:Number.isFinite(m)&&m>0?Math.floor(m):void 0,reasoning:i?.reasoning===!0,vision:Array.isArray(i?.modalities?.input)&&i.modalities.input.includes("image")}),s.set(l,f)}}return e}function A(n,e){let s=_(e);if(!s)return;let t=n.get(s);if(t)return t;let r=S(e);for(let[c,o]of n)if(S(c)===r)return o;for(let[c,o]of n)if(c.endsWith(s)||s.endsWith(c))return o}function R(n){return`${n}/models-dev-cache.json`}function $(n){let e={};for(let[s,t]of n)e[s]=[t.contextWindow,t.maxTokens??0,t.reasoning?1:0,t.vision?1:0];return JSON.stringify(e)}function P(n){let e=new Map,s;try{s=JSON.parse(n)}catch{return e}if(!s||typeof s!="object")return e;for(let[t,r]of Object.entries(s)){if(!Array.isArray(r)||r.length<3)continue;let c=Number(r[0]),o=Number(r[1]);!Number.isFinite(c)||c<=0||e.set(t,{contextWindow:Math.floor(c),maxTokens:Number.isFinite(o)&&o>0?Math.floor(o):void 0,reasoning:r[2]===1||r[2]===!0,vision:r[3]===1||r[3]===!0})}return e}async function U(n){let e=n?.url??J,s=n?.fetchImpl??fetch,t=n?.timeoutMs??2e4,r=new AbortController,c=setTimeout(()=>r.abort(),t);try{let o=await s(e,{signal:r.signal,headers:{Accept:"application/json"}});if(!o.ok)return{ok:!1,message:`the model catalogue answered ${o.status}`};let a=q(await o.json());return a.size===0?{ok:!1,message:"the model catalogue was empty or in an unexpected shape"}:{ok:!0,index:a}}catch(o){return{ok:!1,message:o instanceof Error&&o.name==="AbortError"?`the model catalogue did not answer within ${Math.round(t/1e3)}s`:"could not reach the model catalogue"}}finally{clearTimeout(c)}}var x="https://api.howtofix.id/v1",ce=v,C=["howtocode","howtocode-free"];function ue(n){try{let s=JSON.parse(b(k(n,"models.json"),"utf8")).providers;return!s||typeof s!="object"?new Set:new Set(Object.keys(s))}catch{return new Set}}function le(){return{baseUrl:x,api:"openai-completions",headers:{[M]:T()}}}function de(n){let e=k(n,"models.json"),s;try{s=JSON.parse(b(e,"utf8"))}catch{return 0}let t=s.providers;if(!t||typeof t!="object")return 0;let r=0;for(let c of C){let o=t[c];if(!o||!Array.isArray(o.models))continue;let a=Y(o.models),i={...o.headers??{},[M]:T()},u=o.headers?.[M]!==i[M];a.changed===0&&!u||(o.models=a.models,o.headers=i,r+=a.changed===0?1:a.changed)}if(r===0)return 0;try{w(e,`${JSON.stringify(s,null,2)}
1
+ import{a as v}from"./chunk-7LA2AMZB.js";import{h as M,i as T}from"./chunk-YUOYDO5O.js";import{a as w}from"./chunk-UTYFLLSM.js";import{existsSync as H,mkdirSync as I,readFileSync as b}from"node:fs";import{join as k}from"node:path";var J="https://models.dev/api.json";var N=["anthropic","openai","google","deepseek","zai","xai","moonshotai","minimax","alibaba","xiaomi","meta","tencent","nvidia","venice","openrouter"];function _(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"")}function S(n){let e=n.split("/");return _(e[e.length-1]??n)}function q(n){let e=new Map,s=new Map;if(!n||typeof n!="object")return e;let t=n,r=c=>{let o=N.indexOf(c);return o===-1?N.length:o};for(let c of Object.keys(t).sort()){let o=t[c]?.models;if(!(!o||typeof o!="object"))for(let a of Object.keys(o)){let i=o[a],u=Number(i?.limit?.context);if(!Number.isFinite(u)||u<=0)continue;let l=_(a),f=r(c),d=s.get(l);if(d!==void 0&&d<=f)continue;let m=Number(i?.limit?.output);e.set(l,{contextWindow:Math.floor(u),maxTokens:Number.isFinite(m)&&m>0?Math.floor(m):void 0,reasoning:i?.reasoning===!0,vision:Array.isArray(i?.modalities?.input)&&i.modalities.input.includes("image")}),s.set(l,f)}}return e}function A(n,e){let s=_(e);if(!s)return;let t=n.get(s);if(t)return t;let r=S(e);for(let[c,o]of n)if(S(c)===r)return o;for(let[c,o]of n)if(c.endsWith(s)||s.endsWith(c))return o}function R(n){return`${n}/models-dev-cache.json`}function $(n){let e={};for(let[s,t]of n)e[s]=[t.contextWindow,t.maxTokens??0,t.reasoning?1:0,t.vision?1:0];return JSON.stringify(e)}function P(n){let e=new Map,s;try{s=JSON.parse(n)}catch{return e}if(!s||typeof s!="object")return e;for(let[t,r]of Object.entries(s)){if(!Array.isArray(r)||r.length<3)continue;let c=Number(r[0]),o=Number(r[1]);!Number.isFinite(c)||c<=0||e.set(t,{contextWindow:Math.floor(c),maxTokens:Number.isFinite(o)&&o>0?Math.floor(o):void 0,reasoning:r[2]===1||r[2]===!0,vision:r[3]===1||r[3]===!0})}return e}async function U(n){let e=n?.url??J,s=n?.fetchImpl??fetch,t=n?.timeoutMs??2e4,r=new AbortController,c=setTimeout(()=>r.abort(),t);try{let o=await s(e,{signal:r.signal,headers:{Accept:"application/json"}});if(!o.ok)return{ok:!1,message:`the model catalogue answered ${o.status}`};let a=q(await o.json());return a.size===0?{ok:!1,message:"the model catalogue was empty or in an unexpected shape"}:{ok:!0,index:a}}catch(o){return{ok:!1,message:o instanceof Error&&o.name==="AbortError"?`the model catalogue did not answer within ${Math.round(t/1e3)}s`:"could not reach the model catalogue"}}finally{clearTimeout(c)}}var x="https://api.howtofix.id/v1",ce=v,C=["howtocode","howtocode-free"];function ue(n){try{let s=JSON.parse(b(k(n,"models.json"),"utf8")).providers;return!s||typeof s!="object"?new Set:new Set(Object.keys(s))}catch{return new Set}}function le(){return{baseUrl:x,api:"openai-completions",headers:{[M]:T()}}}function de(n){let e=k(n,"models.json"),s;try{s=JSON.parse(b(e,"utf8"))}catch{return 0}let t=s.providers;if(!t||typeof t!="object")return 0;let r=0;for(let c of C){let o=t[c];if(!o||!Array.isArray(o.models))continue;let a=Y(o.models),i={...o.headers??{},[M]:T()},u=o.headers?.[M]!==i[M];a.changed===0&&!u||(o.models=a.models,o.headers=i,r+=a.changed===0?1:a.changed)}if(r===0)return 0;try{w(e,`${JSON.stringify(s,null,2)}
2
2
  `)}catch{return 0}return r}var G=10080*60*1e3;async function F(n,e){let s=R(n),t=e?.now??Date.now(),r,c=0;try{let i=JSON.parse(b(s,"utf8"));typeof i?.entries=="string"&&(r=P(i.entries),c=Number(i.at)||0)}catch{r=void 0}if(r&&r.size>0&&t-c<G&&!e?.force)return{index:r};let a=await U({fetchImpl:e?.fetchImpl});if(!a.ok)return r&&r.size>0?{index:r,message:a.message}:{index:new Map,message:a.message};try{I(n,{recursive:!0}),w(s,`${JSON.stringify({at:t,entries:$(a.index)})}
3
3
  `)}catch{}return{index:a.index}}async function fe(n,e){let s=k(n,"models.json"),t;try{t=JSON.parse(b(s,"utf8"))}catch{return{changed:0}}let r=t.providers;if(!r||typeof r!="object")return{changed:0};let{index:c,message:o}=await F(n,e);if(c.size===0&&!e?.prices&&!e?.tiers)return{changed:0,message:o};let a=0;for(let i of C){let u=r[i];if(!u||!Array.isArray(u.models))continue;let l=Z(u.models,c,e?.prices,e?.tiers);l.changed!==0&&(u.models=l.models,a+=l.changed)}if(a>0)try{w(s,`${JSON.stringify(t,null,2)}
4
4
  `)}catch{return{changed:0,message:"the models file could not be written"}}return{changed:a,message:o}}var B=3e5;function me(n){let e=k(n,"settings.json"),s={};try{let t=b(e,"utf8"),r=JSON.parse(t);r&&typeof r=="object"&&!Array.isArray(r)&&(s=r)}catch{if(H(e))return!1}if("httpIdleTimeoutMs"in s)return!1;s.httpIdleTimeoutMs=B;try{I(n,{recursive:!0}),w(e,`${JSON.stringify(s,null,2)}
@@ -1 +1 @@
1
- import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i}from"./chunk-G5RR42BO.js";import"./chunk-LQAHFJBU.js";import"./chunk-2YWKLZB6.js";import"./chunk-UTYFLLSM.js";import"./chunk-WOT6VMZA.js";export{b as CLI_REFRESH_SKEW_MS,c as accessTokenIsFresh,g as clearCliCredential,a as cliCredentialsPath,e as readCliCredential,h as refreshCliCredential,d as refreshTokenIsUsable,i as renewCliCredentialIfNeeded,f as writeCliCredential};
1
+ import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i}from"./chunk-WKR2L2CT.js";import"./chunk-YUOYDO5O.js";import"./chunk-WDMBTVK7.js";import"./chunk-UTYFLLSM.js";import"./chunk-WOT6VMZA.js";export{b as CLI_REFRESH_SKEW_MS,c as accessTokenIsFresh,g as clearCliCredential,a as cliCredentialsPath,e as readCliCredential,h as refreshCliCredential,d as refreshTokenIsUsable,i as renewCliCredentialIfNeeded,f as writeCliCredential};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h}from"./chunk-27TRKD65.js";import"./chunk-UTYFLLSM.js";import"./chunk-WOT6VMZA.js";export{a as DEFAULT_WORKBENCH_SETTINGS,d as markWelcomeSeen,b as readWorkbenchSettings,f as rightClickPastesHere,g as writeAgentsSetting,e as writeRightClickPasteSetting,h as writeStringSetting,c as writeWorkbenchSetting};
1
+ import{a,b,c,d,e,f,g,h}from"./chunk-XODGJSB3.js";import"./chunk-UTYFLLSM.js";import"./chunk-WOT6VMZA.js";export{a as DEFAULT_WORKBENCH_SETTINGS,d as markWelcomeSeen,b as readWorkbenchSettings,f as rightClickPastesHere,g as writeAgentsSetting,e as writeRightClickPasteSetting,h as writeStringSetting,c as writeWorkbenchSetting};
@@ -1,4 +1,4 @@
1
- var a="HowToCode",o="0.7.72",n=["You are HowToCode, a coding agent. The user wants the fix, not a tour of the problem.",'NEVER report a check you did not run. NEVER state a version, path, result or capability you have not verified \u2014 if you did not check it, say you are unsure. "Not found" is not "impossible": a tool missing from PATH is often installed anyway, and one that is truly absent can usually be installed. Exhaust the real options before calling anything unavailable; when you do report a limit, say plainly what you tried and what you could not do. Unexercised behaviour is not evidence.',"NEVER mention the underlying harness, its vendor or its project name to the user.","Every tool is `read`, `write` or `exec`, and each approval mode auto-approves every tier up to its own: `suggest` runs `read` only, `auto-edit` adds `write`, `full-auto` adds `exec`. A read-only shell command runs in every mode, so inspecting the tree asks nothing.","NEVER aim a command at the filesystem root, a block device or a system account file, and NEVER shut down the host: those are refused in EVERY mode, `full-auto` included, so proposing one wastes the turn. This is not a list of things to avoid \u2014 it is a list of things that will not run.","Lead with the diagnosis in one or two sentences, then change the code. SHOULD prefer the smallest correct change over a rewrite. Name the file and the reason in a short line; do not narrate tool calls.","Fix the problem that was asked for. NEVER add features, refactors, validation, error handling or dependencies nobody requested.","Something reported broken: reproduce it first, confirm the fix after. Cannot reproduce it? Say so \u2014 NEVER edit code and call it fixed.","Tests describe intended behaviour. A failing test means fix the code, not the test: NEVER delete, skip or loosen an assertion to get green, and NEVER re-pin an expected value to whatever the code happens to print.","Anything you cannot settle by reading \u2014 a page, a layout, a screenshot, a CLI, a service, a failure \u2014 run it and look at the result. For a visual task, find a browser the way a real one does: `$PUPPETEER_EXECUTABLE_PATH`, `$CHROME_PATH`, then `which` for google-chrome, chromium and chromium-browser, then /usr/bin, /snap/bin and /var/lib/flatpak, then the puppeteer and playwright caches under the home directory. Still empty? `npx -y puppeteer browsers install chrome`, or `npm i puppeteer-core` against a chrome the image already ships outside PATH. Then drive the real artifact \u2014 open it, read the DOM, click the controls, measure at the widths that matter \u2014 instead of describing what you assume it does.","Done means the requested behaviour works end to end and every stated requirement is met \u2014 not a scaffold, a narrowed test or a plausible subset. Genuinely out of reach? Finish everything else, then say exactly what is missing and what you tried.","SHOULD plan multi-step work with `todo` before starting it, and mark each step done as you finish. A plan the user can see is worth more than a narration of what you are about to do.","Genuinely ambiguous design: enter plan mode, write the plan to the plan file, then present it with `exit_plan_mode`. Use it when several reasonable approaches exist or when a restructuring would be hard to undo. In plan mode `edit` and `write` are refused for every path except the plan file itself \u2014 that limit is enforced, not advisory, so plan the work rather than starting it. Plan mode needs an interactive session in which the user can approve it; when there is no UI it is unavailable, so design the approach yourself instead of calling it.","Work that is independent and would flood this conversation belongs in `task` subagents. Give each a self-contained assignment, then verify the file it wrote rather than trusting its summary. When that work has a shape you can script \u2014 many items through the same stages, or fan-out whose results must be combined \u2014 `workflow` states the orchestration in one place and runs it deterministically; `task` is for the one-off you cannot describe in advance.","MUST give each subagent a self-contained assignment: a child starts with none of this conversation, so a brief that says 'the file we discussed' reaches it as nothing. Choose the agent by what the work is \u2014 scout looks something up, architect returns a plan, reviewer reports issues with file evidence, task changes files \u2014 and NEVER send work that needs an edit to scout or reviewer, because neither can make one.","SHOULD delegate only work that is genuinely parallel: a subagent costs its own session and its own requests on the same quota as this conversation. A single lookup, a file you can read yourself, or a step whose result decides the next step stays here. MUST keep one call to at most six agents and the session to twelve live or parked ones \u2014 a larger fan-out is refused, and the refusal is a limit rather than a failure to work around.","Record a decision, a file's role, or a fact you would otherwise re-derive with `context`: notes survive compaction and are visible to the other agents on the task.","Look it up instead of recalling it: `web_search` and `web_fetch` for anything outside this repo, `lsp` for a definition, reference or diagnostic. Name the source you checked.","Before calling changed code done, run `quality` and `slop` over it and act on what they report. A metric you did not measure is a claim you cannot make.","A command runs under a two-minute default timeout. MUST pass a longer timeout for anything that legitimately takes more than that \u2014 a recursive directory walk, a package install, a build, a network fetch \u2014 and SHOULD prefer a bounded command to an unbounded one: 'du -sh' with an explicit path beats the whole profile, and on Windows/MSYS a recursive 'du' over a profile directory takes minutes rather than seconds.","When a choice blocks the task, use `ask` instead of guessing; when you need to work something out, use `think`, whose text stays out of the transcript.","Above all: NEVER claim a check you did not run, and NEVER call done on a subset."].join(`
1
+ var a="HowToCode",o="0.7.73",n=["You are HowToCode, a coding agent. The user wants the fix, not a tour of the problem.",'NEVER report a check you did not run. NEVER state a version, path, result or capability you have not verified \u2014 if you did not check it, say you are unsure. "Not found" is not "impossible": a tool missing from PATH is often installed anyway, and one that is truly absent can usually be installed. Exhaust the real options before calling anything unavailable; when you do report a limit, say plainly what you tried and what you could not do. Unexercised behaviour is not evidence.',"NEVER mention the underlying harness, its vendor or its project name to the user.","Every tool is `read`, `write` or `exec`, and each approval mode auto-approves every tier up to its own: `suggest` runs `read` only, `auto-edit` adds `write`, `full-auto` adds `exec`. A read-only shell command runs in every mode, so inspecting the tree asks nothing.","NEVER aim a command at the filesystem root, a block device or a system account file, and NEVER shut down the host: those are refused in EVERY mode, `full-auto` included, so proposing one wastes the turn. This is not a list of things to avoid \u2014 it is a list of things that will not run.","Lead with the diagnosis in one or two sentences, then change the code. SHOULD prefer the smallest correct change over a rewrite. Name the file and the reason in a short line; do not narrate tool calls.","Fix the problem that was asked for. NEVER add features, refactors, validation, error handling or dependencies nobody requested.","Something reported broken: reproduce it first, confirm the fix after. Cannot reproduce it? Say so \u2014 NEVER edit code and call it fixed.","Tests describe intended behaviour. A failing test means fix the code, not the test: NEVER delete, skip or loosen an assertion to get green, and NEVER re-pin an expected value to whatever the code happens to print.","Anything you cannot settle by reading \u2014 a page, a layout, a screenshot, a CLI, a service, a failure \u2014 run it and look at the result. For a visual task, find a browser the way a real one does: `$PUPPETEER_EXECUTABLE_PATH`, `$CHROME_PATH`, then `which` for google-chrome, chromium and chromium-browser, then /usr/bin, /snap/bin and /var/lib/flatpak, then the puppeteer and playwright caches under the home directory. Still empty? `npx -y puppeteer browsers install chrome`, or `npm i puppeteer-core` against a chrome the image already ships outside PATH. Then drive the real artifact \u2014 open it, read the DOM, click the controls, measure at the widths that matter \u2014 instead of describing what you assume it does.","Done means the requested behaviour works end to end and every stated requirement is met \u2014 not a scaffold, a narrowed test or a plausible subset. Genuinely out of reach? Finish everything else, then say exactly what is missing and what you tried.","SHOULD plan multi-step work with `todo` before starting it, and mark each step done as you finish. A plan the user can see is worth more than a narration of what you are about to do.","Genuinely ambiguous design: enter plan mode, write the plan to the plan file, then present it with `exit_plan_mode`. Use it when several reasonable approaches exist or when a restructuring would be hard to undo. In plan mode `edit` and `write` are refused for every path except the plan file itself \u2014 that limit is enforced, not advisory, so plan the work rather than starting it. Plan mode needs an interactive session in which the user can approve it; when there is no UI it is unavailable, so design the approach yourself instead of calling it.","Work that is independent and would flood this conversation belongs in `task` subagents. Give each a self-contained assignment, then verify the file it wrote rather than trusting its summary. When that work has a shape you can script \u2014 many items through the same stages, or fan-out whose results must be combined \u2014 `workflow` states the orchestration in one place and runs it deterministically; `task` is for the one-off you cannot describe in advance.","MUST give each subagent a self-contained assignment: a child starts with none of this conversation, so a brief that says 'the file we discussed' reaches it as nothing. Choose the agent by what the work is \u2014 scout looks something up, architect returns a plan, reviewer reports issues with file evidence, task changes files \u2014 and NEVER send work that needs an edit to scout or reviewer, because neither can make one.","SHOULD delegate only work that is genuinely parallel: a subagent costs its own session and its own requests on the same quota as this conversation. A single lookup, a file you can read yourself, or a step whose result decides the next step stays here. MUST keep one call to at most six agents and the session to twelve live or parked ones \u2014 a larger fan-out is refused, and the refusal is a limit rather than a failure to work around.","Record a decision, a file's role, or a fact you would otherwise re-derive with `context`: notes survive compaction and are visible to the other agents on the task.","Look it up instead of recalling it: `web_search` and `web_fetch` for anything outside this repo, `lsp` for a definition, reference or diagnostic. Name the source you checked.","Before calling changed code done, run `quality` and `slop` over it and act on what they report. A metric you did not measure is a claim you cannot make.","A command runs under a two-minute default timeout. MUST pass a longer timeout for anything that legitimately takes more than that \u2014 a recursive directory walk, a package install, a build, a network fetch \u2014 and SHOULD prefer a bounded command to an unbounded one: 'du -sh' with an explicit path beats the whole profile, and on Windows/MSYS a recursive 'du' over a profile directory takes minutes rather than seconds.","When a choice blocks the task, use `ask` instead of guessing; when you need to work something out, use `think`, whose text stays out of the transcript.","Above all: NEVER claim a check you did not run, and NEVER call done on a subset."].join(`
2
2
  `);function s(e){return e===void 0?void 0:e.replace(/Use \/login to log into a provider[^\n]*/gi,"Connect a provider with /connect or /login:").replace(/^[ \t]*\S*hxf-coding-agent[\\/]docs[\\/][^\n]*$/gim,"").replace(/\bhxf-coding-agent\b/gi,"the harness").replace(/\n{3,}/g,`
3
3
 
4
4
  `).trim()}var i=["# Project notes","","## What this is","","## Commands","- build:","- test:","","## Conventions","-",""].join(`
@@ -1,2 +1,2 @@
1
- import{g as T,j as R}from"./chunk-LQAHFJBU.js";import{a as P}from"./chunk-UTYFLLSM.js";import{existsSync as z,readFileSync as ye,rmSync as xe}from"node:fs";import{join as ve}from"node:path";import{createHash as q,randomBytes as J}from"node:crypto";import{createServer as ne}from"node:http";import{execFileSync as X}from"node:child_process";import{createHmac as Q}from"node:crypto";import{readFileSync as ee}from"node:fs";import{arch as F,cpus as M,hostname as N,platform as v,userInfo as O}from"node:os";var te="howtocode-cli-hwid-v1";function x(e){try{let t=ee(e,"utf8").trim();return t.length>0?t:void 0}catch{return}}function $(e,t){try{let r=X(e,t,{encoding:"utf8",timeout:3e3,stdio:["ignore","pipe","ignore"]});return r.trim().length>0?r.trim():void 0}catch{return}}function re(){let e=v();if(e==="linux"){let t=x("/etc/machine-id");if(t)return{value:t,source:"machine-id",strong:!0};let r=x("/var/lib/dbus/machine-id");if(r)return{value:r,source:"dbus-machine-id",strong:!0};let o=x("/sys/class/dmi/id/product_uuid");return o?{value:o,source:"dmi-product-uuid",strong:!0}:void 0}if(e==="win32"){let r=$("reg",["query","HKLM\\SOFTWARE\\Microsoft\\Cryptography","/v","MachineGuid"])?.match(/MachineGuid\s+REG_SZ\s+(\S+)/i);return r?.[1]?{value:r[1],source:"windows-machine-guid",strong:!0}:void 0}if(e==="darwin"){let r=$("ioreg",["-rd1","-c","IOPlatformExpertDevice"])?.match(/"IOPlatformUUID"\s*=\s*"([^"]+)"/);return r?.[1]?{value:r[1],source:"platform-uuid",strong:!0}:void 0}}function H(){let e=re(),t=e?.value??[N(),v(),F(),O().username].join("\0"),r=e?.source??"hostname";return{id:Q("sha256",te).update(t).digest("hex").slice(0,32),source:r,strong:e?.strong??!1}}function U(e){return[e.id,e.source,N(),v(),F(),O().username,String(M().length),M()[0]?.model??""]}var _="https://howtofix.id",se=300*1e3,G=3e3,K="/callback";function I(e){return e.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function oe(){return I(J(32))}function ie(e){return I(q("sha256").update(e).digest())}function ae(){return I(J(16))}var ce="howtocode-cli-",ue="x-howtocode-client",le="cli";function L(e){let t=e??U(H());return ce+q("sha256").update(t.join("\0")).digest("hex").slice(0,32)}function de(){return{"content-type":"application/json",[ue]:le}}var fe=()=>new Promise((e,t)=>{let r=ne();r.once("error",t),r.listen(0,"127.0.0.1",()=>{let{port:o}=r.address();e({port:o,close:()=>r.close(),waitForCode:(n,s)=>new Promise((i,a)=>{let c=(l,f)=>{let h=new URL(l.url??"/","http://127.0.0.1");if(h.pathname!==K){f.writeHead(404).end("not found");return}let y=(V,Z)=>f.writeHead(200,{"content-type":"text/html; charset=utf-8"}).end(`<!doctype html><meta charset="utf-8"><h2>${V}</h2><p>${Z}</p>`),S=h.searchParams.get("error")??"",E=h.searchParams.get("code")??"",Y=h.searchParams.get("state")??"";if(S){y("Sign-in was refused","You can close this tab."),u(new Error(`the browser reported: ${S}`));return}if(!E||Y!==n){y("This callback did not belong to the login","You can close this tab."),u(new Error("the callback carried the wrong state"));return}y("Signed in","You can close this tab and go back to HowToCode."),u(void 0,E)},u=(l,f)=>{r.off("request",c),s?.removeEventListener("abort",g),l?a(l):i(f)},g=()=>u(new Error("cancelled"));s?.addEventListener("abort",g,{once:!0}),r.on("request",c)})})})});function k(e,t){e.onProgress?.(t)}async function p(e,t,r,o){let n=await e(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(r),signal:o}),s={};try{s=await n.json()}catch{}let i=Number(n.headers?.get?.("retry-after"));return{status:n.status,body:s,retryAfterSeconds:Number.isFinite(i)&&i>0?i:void 0}}function d(...e){for(let t of e)if(typeof t=="string"&&t.trim()!=="")return t.trim()}function j(...e){for(let t of e)if(typeof t=="number"&&Number.isFinite(t))return t;return 0}function me(e){try{let t=new URL(e).searchParams.get("code");return t&&t.trim()!==""?t.trim():void 0}catch{return}}async function ge(e,t,r){let o=await e(t,{headers:de(),signal:r}),n={};try{n=await o.json()}catch{}let s=Number(o.headers?.get?.("retry-after"));return{status:o.status,body:n,retryAfterSeconds:Number.isFinite(s)&&s>0?s:void 0}}function A(e){let t=e.data,r=[e.token,e.api_key,e.apiKey,e.key,t?.token,t?.api_key,t?.apiKey,t?.key];for(let o of r)if(typeof o=="string"&&o.trim().startsWith("sk-"))return o.trim()}function pe(e){let t=e.data,r=d(e.token,t?.token),o=d(e.refresh_token,t?.refresh_token),n=d(e.device_id,t?.device_id);if(!r||!o||!n)return;let s=j(e.access_expires_at,t?.access_expires_at),i=j(e.refresh_expires_at,t?.refresh_expires_at);return{accessToken:r,accessExpiresAt:s,refreshToken:o,deviceId:n,refreshExpiresAt:i}}function m(e,t){let r=e.message??e.error;return typeof r=="string"&&r.trim()?r.trim():t}async function He(e){let t=e.fetchImpl??fetch,r=(e.panelUrl??_).replace(/\/+$/,""),o=e.timeoutMs??se,n={...e,panel:r,fetchImpl:t,timeoutMs:o},s=await ke(n);if(s.ok||s.terminal)return s.result;let i=await he(n);if(i.ok||i.terminal)return i.result;let a=await we(n);return a.ok?a:{ok:!1,message:`${s.result.ok?"":s.result.message}; ${i.result.ok?"":i.result.message}; ${a.message}. howtofix.id does not offer a browser login a local client can complete yet \u2014 run /connect and paste a token from ${r}/keys instead.`}}async function he(e){let t=oe(),r=ae(),o;try{o=await(e.loopback??fe)();let n=`http://127.0.0.1:${o.port}${K}`,s=await p(e.fetchImpl,`${e.panel}/api/oauth/device/start`,{redirect_uri:n,code_challenge:ie(t),code_challenge_method:"S256",state:r},e.signal);if(s.status===404)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel has no loopback login endpoint"}};if(s.status>=400)return{ok:!1,terminal:!1,result:{ok:!1,message:m(s.body,`the panel refused the login (${s.status})`)}};let i=typeof s.body.authorize_url=="string"?s.body.authorize_url:"";if(!i)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel did not say where to send the browser"}};k(e,{kind:"browser",url:i});let a=await be(o.waitForCode(r,e.signal),e.timeoutMs),c=await p(e.fetchImpl,`${e.panel}/api/oauth/device/token`,{flow_token:s.body.flow_token,code:a,code_verifier:t},e.signal);if(c.status>=400)return{ok:!1,terminal:!0,result:{ok:!1,message:m(c.body,`the panel refused the exchange (${c.status})`)}};let u=A(c.body);return u?{ok:!0,result:{ok:!0,token:u}}:{ok:!1,terminal:!0,result:{ok:!1,message:"the panel did not return an API key"}}}catch(n){let s=n instanceof Error?n.message:String(n);return{ok:!1,terminal:s==="cancelled",result:{ok:!1,message:s}}}finally{o?.close()}}async function ke(e){let t=e.fingerprintId??L(),r=e.clientInfo??T(),o=R(t,r);try{let n=await p(e.fetchImpl,`${e.panel}/api/auth/cli/code`,{fingerprintId:t,clientInfo:r,...o},e.signal);if(n.status===404)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel has no CLI login endpoint"}};if(n.status===401)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel did not recognise this build as the HowToCode CLI \u2014 update it with `npm install -g howtocode@latest`"}};if(n.status===429)return{ok:!1,terminal:!0,result:{ok:!1,message:`too many sign-in attempts from this machine right now.${n.retryAfterSeconds?` Try again in ${Math.ceil(n.retryAfterSeconds/60)} minute(s).`:""}`}};if(n.status>=400)return{ok:!1,terminal:!1,result:{ok:!1,message:m(n.body,`the panel refused the login (${n.status})`)}};let s=n.body.data??{},i=d(n.body.login_url,s.login_url),a=d(n.body.code,s.code)??(i?me(i):void 0),c=d(n.body.secret,s.secret);return!i||!a?{ok:!1,terminal:!1,result:{ok:!1,message:"the panel did not return a login URL"}}:c?(k(e,{kind:"browser",url:i}),await D(e,a,c)):(k(e,{kind:"browser",url:i}),await D(e,a,void 0))}catch(n){let s=n instanceof Error?n.message:String(n);return{ok:!1,terminal:s==="cancelled",result:{ok:!1,message:s}}}}async function D(e,t,r){let o=e.pollIntervalMs??G,n=Date.now()+e.timeoutMs;for(;Date.now()<n;){await w(o,e.signal);let s=new URLSearchParams(r?{code:t,secret:r}:{code:t});s.set("capability","device-refresh");let i=await ge(e.fetchImpl,`${e.panel}/api/auth/cli/status?${s}`,e.signal);if(i.status===404)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel has no CLI login status endpoint"}};if(i.status===403)return{ok:!1,terminal:!0,result:{ok:!1,message:"the panel rejected this poll \u2014 run /connect again"}};if(i.status===429){let u=Math.min(Math.max(i.retryAfterSeconds??5,1)*1e3,3e4);await w(u,e.signal);continue}let a=A(i.body);if(a)return{ok:!0,result:{ok:!0,token:a,credential:pe(i.body)}};if(d(i.body.data?.status,i.body.status)==="expired")return{ok:!1,terminal:!0,result:{ok:!1,message:"the sign-in link expired before it was approved"}};if(i.status>=400)return{ok:!1,terminal:!0,result:{ok:!1,message:m(i.body,`the panel refused the poll (${i.status})`)}}}return{ok:!1,terminal:!0,result:{ok:!1,message:"the sign-in was not approved in time"}}}async function we(e){let t=e.pollIntervalMs??G;try{let r=await p(e.fetchImpl,`${e.panel}/api/oauth/device`,{},e.signal);if(r.status===404)return{ok:!1,message:"the panel has no device-code endpoint"};if(r.status>=400)return{ok:!1,message:m(r.body,`the panel refused the request (${r.status})`)};let o=typeof r.body.device_code=="string"?r.body.device_code:"",n=typeof r.body.user_code=="string"?r.body.user_code:"",s=typeof r.body.verification_uri=="string"?r.body.verification_uri:`${e.panel}/oauth/device`;if(!o||!n)return{ok:!1,message:"the panel did not return a code to show"};k(e,{kind:"code",code:n,url:s});let i=Date.now()+e.timeoutMs;for(;Date.now()<i;){await w(t,e.signal);let a=await p(e.fetchImpl,`${e.panel}/api/oauth/device/poll`,{device_code:o},e.signal);if(a.status===404)return{ok:!1,message:"the panel has no device-code poll endpoint"};let c=typeof a.body.status=="string"?a.body.status:"";if(c==="pending")continue;if(c==="slow_down"){await w(t,e.signal);continue}if(c==="denied")return{ok:!1,message:"the sign-in was refused in the browser"};if(c==="expired")return{ok:!1,message:"the code expired; run /connect again"};let u=A(a.body);if(u)return{ok:!0,token:u};if(a.status>=400)return{ok:!1,message:m(a.body,`the panel refused the poll (${a.status})`)}}return{ok:!1,message:"the code was not approved in time"}}catch(r){return{ok:!1,message:r instanceof Error?r.message:String(r)}}}function be(e,t){return new Promise((r,o)=>{let n=setTimeout(()=>o(new Error("the sign-in was not finished in time")),t);e.then(s=>{clearTimeout(n),r(s)},s=>{clearTimeout(n),o(s)})})}function w(e,t){return new Promise((r,o)=>{let n=setTimeout(r,e);t?.addEventListener("abort",()=>{clearTimeout(n),o(new Error("cancelled"))},{once:!0})})}function b(e){return ve(e,"cli-credentials.json")}var _e=300*1e3;function Ie(e,t=Date.now()){return e.accessToken?!Number.isFinite(e.accessExpiresAt)||e.accessExpiresAt<=0?!0:e.accessExpiresAt*1e3-_e>t:!1}function Le(e,t=Date.now()){return!e.refreshToken||!e.deviceId?!1:!Number.isFinite(e.refreshExpiresAt)||e.refreshExpiresAt<=0?!0:e.refreshExpiresAt*1e3>t}function Ge(e){let t=b(e);if(!z(t))return;let r;try{r=JSON.parse(ye(t,"utf8"))}catch{return}if(!r||typeof r!="object"||Array.isArray(r))return;let o=r,n=typeof o.accessToken=="string"?o.accessToken.trim():"",s=typeof o.refreshToken=="string"?o.refreshToken.trim():"",i=typeof o.deviceId=="string"?o.deviceId.trim():"";if(!(!n||!s||!i))return{accessToken:n,accessExpiresAt:W(o.accessExpiresAt),refreshToken:s,deviceId:i,refreshExpiresAt:W(o.refreshExpiresAt)}}function Ae(e,t){try{return P(b(e),`${JSON.stringify(t,null,2)}
1
+ import{g as T,j as R}from"./chunk-YUOYDO5O.js";import{a as P}from"./chunk-UTYFLLSM.js";import{existsSync as z,readFileSync as ye,rmSync as xe}from"node:fs";import{join as ve}from"node:path";import{createHash as q,randomBytes as J}from"node:crypto";import{createServer as ne}from"node:http";import{execFileSync as X}from"node:child_process";import{createHmac as Q}from"node:crypto";import{readFileSync as ee}from"node:fs";import{arch as F,cpus as M,hostname as N,platform as v,userInfo as O}from"node:os";var te="howtocode-cli-hwid-v1";function x(e){try{let t=ee(e,"utf8").trim();return t.length>0?t:void 0}catch{return}}function $(e,t){try{let r=X(e,t,{encoding:"utf8",timeout:3e3,stdio:["ignore","pipe","ignore"]});return r.trim().length>0?r.trim():void 0}catch{return}}function re(){let e=v();if(e==="linux"){let t=x("/etc/machine-id");if(t)return{value:t,source:"machine-id",strong:!0};let r=x("/var/lib/dbus/machine-id");if(r)return{value:r,source:"dbus-machine-id",strong:!0};let o=x("/sys/class/dmi/id/product_uuid");return o?{value:o,source:"dmi-product-uuid",strong:!0}:void 0}if(e==="win32"){let r=$("reg",["query","HKLM\\SOFTWARE\\Microsoft\\Cryptography","/v","MachineGuid"])?.match(/MachineGuid\s+REG_SZ\s+(\S+)/i);return r?.[1]?{value:r[1],source:"windows-machine-guid",strong:!0}:void 0}if(e==="darwin"){let r=$("ioreg",["-rd1","-c","IOPlatformExpertDevice"])?.match(/"IOPlatformUUID"\s*=\s*"([^"]+)"/);return r?.[1]?{value:r[1],source:"platform-uuid",strong:!0}:void 0}}function H(){let e=re(),t=e?.value??[N(),v(),F(),O().username].join("\0"),r=e?.source??"hostname";return{id:Q("sha256",te).update(t).digest("hex").slice(0,32),source:r,strong:e?.strong??!1}}function U(e){return[e.id,e.source,N(),v(),F(),O().username,String(M().length),M()[0]?.model??""]}var _="https://howtofix.id",se=300*1e3,G=3e3,K="/callback";function I(e){return e.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function oe(){return I(J(32))}function ie(e){return I(q("sha256").update(e).digest())}function ae(){return I(J(16))}var ce="howtocode-cli-",ue="x-howtocode-client",le="cli";function L(e){let t=e??U(H());return ce+q("sha256").update(t.join("\0")).digest("hex").slice(0,32)}function de(){return{"content-type":"application/json",[ue]:le}}var fe=()=>new Promise((e,t)=>{let r=ne();r.once("error",t),r.listen(0,"127.0.0.1",()=>{let{port:o}=r.address();e({port:o,close:()=>r.close(),waitForCode:(n,s)=>new Promise((i,a)=>{let c=(l,f)=>{let h=new URL(l.url??"/","http://127.0.0.1");if(h.pathname!==K){f.writeHead(404).end("not found");return}let y=(V,Z)=>f.writeHead(200,{"content-type":"text/html; charset=utf-8"}).end(`<!doctype html><meta charset="utf-8"><h2>${V}</h2><p>${Z}</p>`),S=h.searchParams.get("error")??"",E=h.searchParams.get("code")??"",Y=h.searchParams.get("state")??"";if(S){y("Sign-in was refused","You can close this tab."),u(new Error(`the browser reported: ${S}`));return}if(!E||Y!==n){y("This callback did not belong to the login","You can close this tab."),u(new Error("the callback carried the wrong state"));return}y("Signed in","You can close this tab and go back to HowToCode."),u(void 0,E)},u=(l,f)=>{r.off("request",c),s?.removeEventListener("abort",g),l?a(l):i(f)},g=()=>u(new Error("cancelled"));s?.addEventListener("abort",g,{once:!0}),r.on("request",c)})})})});function k(e,t){e.onProgress?.(t)}async function p(e,t,r,o){let n=await e(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(r),signal:o}),s={};try{s=await n.json()}catch{}let i=Number(n.headers?.get?.("retry-after"));return{status:n.status,body:s,retryAfterSeconds:Number.isFinite(i)&&i>0?i:void 0}}function d(...e){for(let t of e)if(typeof t=="string"&&t.trim()!=="")return t.trim()}function j(...e){for(let t of e)if(typeof t=="number"&&Number.isFinite(t))return t;return 0}function me(e){try{let t=new URL(e).searchParams.get("code");return t&&t.trim()!==""?t.trim():void 0}catch{return}}async function ge(e,t,r){let o=await e(t,{headers:de(),signal:r}),n={};try{n=await o.json()}catch{}let s=Number(o.headers?.get?.("retry-after"));return{status:o.status,body:n,retryAfterSeconds:Number.isFinite(s)&&s>0?s:void 0}}function A(e){let t=e.data,r=[e.token,e.api_key,e.apiKey,e.key,t?.token,t?.api_key,t?.apiKey,t?.key];for(let o of r)if(typeof o=="string"&&o.trim().startsWith("sk-"))return o.trim()}function pe(e){let t=e.data,r=d(e.token,t?.token),o=d(e.refresh_token,t?.refresh_token),n=d(e.device_id,t?.device_id);if(!r||!o||!n)return;let s=j(e.access_expires_at,t?.access_expires_at),i=j(e.refresh_expires_at,t?.refresh_expires_at);return{accessToken:r,accessExpiresAt:s,refreshToken:o,deviceId:n,refreshExpiresAt:i}}function m(e,t){let r=e.message??e.error;return typeof r=="string"&&r.trim()?r.trim():t}async function He(e){let t=e.fetchImpl??fetch,r=(e.panelUrl??_).replace(/\/+$/,""),o=e.timeoutMs??se,n={...e,panel:r,fetchImpl:t,timeoutMs:o},s=await ke(n);if(s.ok||s.terminal)return s.result;let i=await he(n);if(i.ok||i.terminal)return i.result;let a=await we(n);return a.ok?a:{ok:!1,message:`${s.result.ok?"":s.result.message}; ${i.result.ok?"":i.result.message}; ${a.message}. howtofix.id does not offer a browser login a local client can complete yet \u2014 run /connect and paste a token from ${r}/keys instead.`}}async function he(e){let t=oe(),r=ae(),o;try{o=await(e.loopback??fe)();let n=`http://127.0.0.1:${o.port}${K}`,s=await p(e.fetchImpl,`${e.panel}/api/oauth/device/start`,{redirect_uri:n,code_challenge:ie(t),code_challenge_method:"S256",state:r},e.signal);if(s.status===404)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel has no loopback login endpoint"}};if(s.status>=400)return{ok:!1,terminal:!1,result:{ok:!1,message:m(s.body,`the panel refused the login (${s.status})`)}};let i=typeof s.body.authorize_url=="string"?s.body.authorize_url:"";if(!i)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel did not say where to send the browser"}};k(e,{kind:"browser",url:i});let a=await be(o.waitForCode(r,e.signal),e.timeoutMs),c=await p(e.fetchImpl,`${e.panel}/api/oauth/device/token`,{flow_token:s.body.flow_token,code:a,code_verifier:t},e.signal);if(c.status>=400)return{ok:!1,terminal:!0,result:{ok:!1,message:m(c.body,`the panel refused the exchange (${c.status})`)}};let u=A(c.body);return u?{ok:!0,result:{ok:!0,token:u}}:{ok:!1,terminal:!0,result:{ok:!1,message:"the panel did not return an API key"}}}catch(n){let s=n instanceof Error?n.message:String(n);return{ok:!1,terminal:s==="cancelled",result:{ok:!1,message:s}}}finally{o?.close()}}async function ke(e){let t=e.fingerprintId??L(),r=e.clientInfo??T(),o=R(t,r);try{let n=await p(e.fetchImpl,`${e.panel}/api/auth/cli/code`,{fingerprintId:t,clientInfo:r,...o},e.signal);if(n.status===404)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel has no CLI login endpoint"}};if(n.status===401)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel did not recognise this build as the HowToCode CLI \u2014 update it with `npm install -g howtocode@latest`"}};if(n.status===429)return{ok:!1,terminal:!0,result:{ok:!1,message:`too many sign-in attempts from this machine right now.${n.retryAfterSeconds?` Try again in ${Math.ceil(n.retryAfterSeconds/60)} minute(s).`:""}`}};if(n.status>=400)return{ok:!1,terminal:!1,result:{ok:!1,message:m(n.body,`the panel refused the login (${n.status})`)}};let s=n.body.data??{},i=d(n.body.login_url,s.login_url),a=d(n.body.code,s.code)??(i?me(i):void 0),c=d(n.body.secret,s.secret);return!i||!a?{ok:!1,terminal:!1,result:{ok:!1,message:"the panel did not return a login URL"}}:c?(k(e,{kind:"browser",url:i}),await D(e,a,c)):(k(e,{kind:"browser",url:i}),await D(e,a,void 0))}catch(n){let s=n instanceof Error?n.message:String(n);return{ok:!1,terminal:s==="cancelled",result:{ok:!1,message:s}}}}async function D(e,t,r){let o=e.pollIntervalMs??G,n=Date.now()+e.timeoutMs;for(;Date.now()<n;){await w(o,e.signal);let s=new URLSearchParams(r?{code:t,secret:r}:{code:t});s.set("capability","device-refresh");let i=await ge(e.fetchImpl,`${e.panel}/api/auth/cli/status?${s}`,e.signal);if(i.status===404)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel has no CLI login status endpoint"}};if(i.status===403)return{ok:!1,terminal:!0,result:{ok:!1,message:"the panel rejected this poll \u2014 run /connect again"}};if(i.status===429){let u=Math.min(Math.max(i.retryAfterSeconds??5,1)*1e3,3e4);await w(u,e.signal);continue}let a=A(i.body);if(a)return{ok:!0,result:{ok:!0,token:a,credential:pe(i.body)}};if(d(i.body.data?.status,i.body.status)==="expired")return{ok:!1,terminal:!0,result:{ok:!1,message:"the sign-in link expired before it was approved"}};if(i.status>=400)return{ok:!1,terminal:!0,result:{ok:!1,message:m(i.body,`the panel refused the poll (${i.status})`)}}}return{ok:!1,terminal:!0,result:{ok:!1,message:"the sign-in was not approved in time"}}}async function we(e){let t=e.pollIntervalMs??G;try{let r=await p(e.fetchImpl,`${e.panel}/api/oauth/device`,{},e.signal);if(r.status===404)return{ok:!1,message:"the panel has no device-code endpoint"};if(r.status>=400)return{ok:!1,message:m(r.body,`the panel refused the request (${r.status})`)};let o=typeof r.body.device_code=="string"?r.body.device_code:"",n=typeof r.body.user_code=="string"?r.body.user_code:"",s=typeof r.body.verification_uri=="string"?r.body.verification_uri:`${e.panel}/oauth/device`;if(!o||!n)return{ok:!1,message:"the panel did not return a code to show"};k(e,{kind:"code",code:n,url:s});let i=Date.now()+e.timeoutMs;for(;Date.now()<i;){await w(t,e.signal);let a=await p(e.fetchImpl,`${e.panel}/api/oauth/device/poll`,{device_code:o},e.signal);if(a.status===404)return{ok:!1,message:"the panel has no device-code poll endpoint"};let c=typeof a.body.status=="string"?a.body.status:"";if(c==="pending")continue;if(c==="slow_down"){await w(t,e.signal);continue}if(c==="denied")return{ok:!1,message:"the sign-in was refused in the browser"};if(c==="expired")return{ok:!1,message:"the code expired; run /connect again"};let u=A(a.body);if(u)return{ok:!0,token:u};if(a.status>=400)return{ok:!1,message:m(a.body,`the panel refused the poll (${a.status})`)}}return{ok:!1,message:"the code was not approved in time"}}catch(r){return{ok:!1,message:r instanceof Error?r.message:String(r)}}}function be(e,t){return new Promise((r,o)=>{let n=setTimeout(()=>o(new Error("the sign-in was not finished in time")),t);e.then(s=>{clearTimeout(n),r(s)},s=>{clearTimeout(n),o(s)})})}function w(e,t){return new Promise((r,o)=>{let n=setTimeout(r,e);t?.addEventListener("abort",()=>{clearTimeout(n),o(new Error("cancelled"))},{once:!0})})}function b(e){return ve(e,"cli-credentials.json")}var _e=300*1e3;function Ie(e,t=Date.now()){return e.accessToken?!Number.isFinite(e.accessExpiresAt)||e.accessExpiresAt<=0?!0:e.accessExpiresAt*1e3-_e>t:!1}function Le(e,t=Date.now()){return!e.refreshToken||!e.deviceId?!1:!Number.isFinite(e.refreshExpiresAt)||e.refreshExpiresAt<=0?!0:e.refreshExpiresAt*1e3>t}function Ge(e){let t=b(e);if(!z(t))return;let r;try{r=JSON.parse(ye(t,"utf8"))}catch{return}if(!r||typeof r!="object"||Array.isArray(r))return;let o=r,n=typeof o.accessToken=="string"?o.accessToken.trim():"",s=typeof o.refreshToken=="string"?o.refreshToken.trim():"",i=typeof o.deviceId=="string"?o.deviceId.trim():"";if(!(!n||!s||!i))return{accessToken:n,accessExpiresAt:W(o.accessExpiresAt),refreshToken:s,deviceId:i,refreshExpiresAt:W(o.refreshExpiresAt)}}function Ae(e,t){try{return P(b(e),`${JSON.stringify(t,null,2)}
2
2
  `,{mode:384}),!0}catch{return!1}}function Ce(e){try{let t=b(e);z(t)&&xe(t,{force:!0})}catch{}}function W(e){return typeof e=="number"&&Number.isFinite(e)?e:0}async function Se(e,t){let r=(t?.panelUrl??_).replace(/\/+$/,""),o=t?.fetchImpl??fetch,n=t?.timeoutMs??15e3,s=new AbortController,i=setTimeout(()=>s.abort(),n);try{let a=await o(`${r}/api/auth/cli/refresh`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({device_id:e.deviceId,refresh_token:e.refreshToken,fingerprint_id:L()}),signal:s.signal}),c=await a.json().catch(()=>({}));if(a.status===401||a.status===403)return{ok:!1,terminal:!0,message:"this sign-in is no longer valid; run /connect to sign in again"};if(!a.ok)return{ok:!1,terminal:!1,message:`the panel refused the renewal (${a.status})`};let u=c.data??{},g=C(c.token,u.token),l=C(c.refresh_token,u.refresh_token),f=C(c.device_id,u.device_id)??e.deviceId;return!g||!l?{ok:!1,terminal:!1,message:"the panel did not return a renewed credential"}:{ok:!0,terminal:!1,credential:{accessToken:g,accessExpiresAt:B(c.access_expires_at,u.access_expires_at),refreshToken:l,deviceId:f,refreshExpiresAt:B(c.refresh_expires_at,u.refresh_expires_at)}}}catch(a){return{ok:!1,terminal:!1,message:a instanceof Error&&a.name==="AbortError"?`the panel did not answer within ${Math.round(n/1e3)}s`:"could not reach the panel"}}finally{clearTimeout(i)}}function C(...e){for(let t of e)if(typeof t=="string"&&t.trim())return t.trim()}function B(...e){for(let t of e)if(typeof t=="number"&&Number.isFinite(t))return t;return 0}async function Ke(e,t,r){let o=r?.now??Date.now();if(Ie(t,o)||!Le(t,o))return{credential:t,renewed:!1,terminal:!1};let n=await Se(t,r);if(!n.ok||!n.credential)return n.terminal&&Ce(e),{credential:t,renewed:!1,terminal:n.terminal,message:n.message};let s=Ae(e,n.credential);return{credential:n.credential,renewed:!0,terminal:!1,message:s?void 0:`the renewed sign-in could not be saved to ${b(e)}`}}export{H as a,_ as b,He as c,b as d,_e as e,Ie as f,Le as g,Ge as h,Ae as i,Ce as j,Se as k,Ke as l};
@@ -0,0 +1,2 @@
1
+ import{a as u}from"./chunk-UTYFLLSM.js";import{existsSync as g,mkdirSync as f,readFileSync as c}from"node:fs";import{dirname as d,join as p}from"node:path";var a={skipPermissions:!1,autoUpdate:!0,rightClickPaste:"auto",welcomeSeen:!1,compressToolOutput:!1};function l(t){return p(t,"settings.json")}function k(t){try{let e=JSON.parse(c(l(t),"utf8")),n=r=>{let i=e[r];return typeof i=="boolean"?i:a[r]},o=e.rightClickPaste;return{skipPermissions:n("skipPermissions"),autoUpdate:n("autoUpdate"),rightClickPaste:o==="on"||o==="off"||o==="auto"?o:a.rightClickPaste,welcomeSeen:n("welcomeSeen"),compressToolOutput:n("compressToolOutput"),...typeof e.agents=="number"&&Number.isInteger(e.agents)&&e.agents>0?{agents:e.agents}:{},...typeof e.discordClientId=="string"&&e.discordClientId.trim().length>0?{discordClientId:e.discordClientId.trim()}:{}}}catch{return{...a}}}function h(t,e,n){return s(t,e,n)}function w(t){return s(t,"welcomeSeen",!0)}function C(t,e){return s(t,"rightClickPaste",e==="auto"?void 0:e)}function P(t){return t==="on"?!0:t==="off"?!1:process.platform!=="win32"}function y(t,e){let n=typeof e=="number"&&Number.isInteger(e)&&e>0?e:void 0;return s(t,"agents",n)}function x(t,e,n){let o=n.trim();return s(t,e,o===""?void 0:o)}function s(t,e,n){let o=l(t),r={};try{let i=JSON.parse(c(o,"utf8"));i&&typeof i=="object"&&!Array.isArray(i)&&(r=i)}catch{if(g(o))return!1}n===void 0?delete r[e]:r[e]=n;try{f(d(o),{recursive:!0}),u(o,`${JSON.stringify(r,null,2)}
2
+ `)}catch{return!1}return!0}export{a,k as b,h as c,w as d,C as e,P as f,y as g,x as h};
@@ -1,2 +1,2 @@
1
- import{b as o}from"./chunk-2YWKLZB6.js";import{createPrivateKey as p,createPublicKey as f,createHash as l,randomBytes as d,sign as y}from"node:crypto";import{arch as c,cpus as m,hostname as I,platform as s}from"node:os";var a="hf-cli-1",C="MC4CAQAwBQYDK2VwBCIEIDmKoNgInS7oDpncee1d1+Mnci1R/q4aE5xxHeCKq4Dc",x="howtocode-cli-auth-v1",i;function u(){return i||(i=p({key:Buffer.from(C,"base64"),format:"der",type:"pkcs8"})),i}function g(){return f(u())}function K(t,e,n,r){return Buffer.from([x,t,e,n,r].join(`
1
+ import{b as o}from"./chunk-WDMBTVK7.js";import{createPrivateKey as p,createPublicKey as f,createHash as l,randomBytes as d,sign as y}from"node:crypto";import{arch as c,cpus as m,hostname as I,platform as s}from"node:os";var a="hf-cli-1",C="MC4CAQAwBQYDK2VwBCIEIDmKoNgInS7oDpncee1d1+Mnci1R/q4aE5xxHeCKq4Dc",x="howtocode-cli-auth-v1",i;function u(){return i||(i=p({key:Buffer.from(C,"base64"),format:"der",type:"pkcs8"})),i}function g(){return f(u())}function K(t,e,n,r){return Buffer.from([x,t,e,n,r].join(`
2
2
  `),"utf8")}function h(){return d(16).toString("hex")}var E="tQ91uspGl0sw5Y8x+soLYnFNX6a9vEzSzCuuvalzdKk=";function P(){let t=g().export({format:"der",type:"spki"});return t.subarray(t.length-32).toString("base64")===E}function N(){let t=g().export({format:"der",type:"spki"});return l("sha256").update(t).digest("hex").slice(0,16)}function $(){let e=(m()[0]?.model??"").replace(/\s+/g," ").trim(),n=I(),r=e?`${n} (${s()}/${c()}, ${e})`:`${n} (${s()}/${c()})`;return`CLI (${o}, ${r})`}var k="X-HowToCode-Client";function A(){return`CLI (${o})`}function B(t,e){let n=h(),r=y(null,K(a,t,e,n),u());return{keyId:a,nonce:n,signature:r.toString("base64")}}export{a,g as b,K as c,h as d,P as e,N as f,$ as g,k as h,A as i,B as j};
package/dist/cli-auth.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j}from"./chunk-LQAHFJBU.js";import"./chunk-2YWKLZB6.js";import"./chunk-WOT6VMZA.js";export{h as CLI_CLIENT_HEADER,a as CLI_SIGNING_KEY_ID,i as cliClientHeader,c as cliSignaturePayload,f as cliSigningKeyFingerprint,e as cliSigningKeyMatchesPanel,b as cliSigningPublicKey,d as createNonce,g as describeClient,j as signLoginRequest};
1
+ import{a,b,c,d,e,f,g,h,i,j}from"./chunk-YUOYDO5O.js";import"./chunk-WDMBTVK7.js";import"./chunk-WOT6VMZA.js";export{h as CLI_CLIENT_HEADER,a as CLI_SIGNING_KEY_ID,i as cliClientHeader,c as cliSignaturePayload,f as cliSigningKeyFingerprint,e as cliSigningKeyMatchesPanel,b as cliSigningPublicKey,d as createNonce,g as describeClient,j as signLoginRequest};
package/dist/main-app.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{b as J,d as V,e as q}from"./chunk-EZNNALD3.js";import"./chunk-7LA2AMZB.js";import{e as B,f as D}from"./chunk-LQAHFJBU.js";import{c as K}from"./chunk-PH72JBBL.js";import{a as L,b as F}from"./chunk-MCAAX33K.js";import{a as r,b as k}from"./chunk-2YWKLZB6.js";import{H as $,P as H}from"./chunk-5FIFNXLT.js";import"./chunk-UTYFLLSM.js";import{j as G}from"./chunk-MVVEYKN6.js";import"./chunk-WOT6VMZA.js";import{existsSync as je,mkdirSync as Fe,readdirSync as se,statSync as Ie,writeFileSync as Ne}from"node:fs";import{join as j}from"node:path";var z={rpc:!0,acp:!0},X={off:!0,minimal:!0,low:!0,medium:!0,high:!0,xhigh:!0,max:!0},Y={suggest:!0,"auto-edit":!0,"full-auto":!0},Q={text:!0,json:!0,"stream-json":!0};function Te(l){let e=Number(l);if(!Number.isFinite(e)||e<=0)throw new Error(`--max-budget-usd needs a positive number of dollars, got '${l}'`);return e}function P(l,e,p){let i=l[e];if(i?.includes("="))return i.slice(i.indexOf("=")+1);let c=l[e+1];if(!c||c.startsWith("-"))throw new Error(`${p} needs a value`);return l.splice(e+1,1),c}function Z(l){let e={print:!1,continueSession:!1,noSession:!1,help:!1,version:!1,update:!1,checkUpdate:!1,outputFormat:"text",dangerouslySkipPermissions:!1,sandbox:!1,prompt:""},p=[],i=[...l];i[0]==="resume"&&i[1]&&!i[1].startsWith("-")&&(e.resumeId=i[1],i.splice(0,2));for(let c=0;c<i.length;c++){let s=i[c]??"";if(s==="--"){p.push(...i.slice(c+1));break}if(s==="-h"||s==="--help")e.help=!0;else if(s==="-v"||s==="--version")e.version=!0;else if(s==="-p"||s==="--print")e.print=!0;else if(s==="-c"||s==="--continue")e.continueSession=!0;else if(s==="--no-session")e.noSession=!0;else if(s==="--sandbox")e.sandbox=!0;else if(s==="--update")e.update=!0;else if(s==="--check-update")e.checkUpdate=!0;else if(s==="-r"||s==="--resume")e.continueSession=!0;else if(s==="--session"||s.startsWith("--session="))e.sessionPath=P(i,c,"--session");else if(s==="-m"||s==="--model"||s.startsWith("--model="))e.model=P(i,c,"--model");else if(s==="--thinking"||s.startsWith("--thinking="))e.thinking=P(i,c,"--thinking");else if(s==="--approval"||s.startsWith("--approval="))e.approval=P(i,c,"--approval");else if(s==="--output-format"||s.startsWith("--output-format="))e.outputFormat=P(i,c,"--output-format");else if(s==="--max-budget-usd"||s.startsWith("--max-budget-usd="))e.maxBudgetUsd=Te(P(i,c,"--max-budget-usd"));else if(s==="--mode"||s.startsWith("--mode=")){let h=P(i,c,"--mode");if(!z[h])throw new Error(`--mode must be one of: ${Object.keys(z).join(", ")}`);e.mode=h}else if(s==="--acp")e.mode="acp";else if(s==="--dangerously-skip-permissions")e.dangerouslySkipPermissions=!0;else{if(s.startsWith("-"))throw new Error(`unknown option ${s}`);p.push(s)}}if(e.thinking&&!X[e.thinking])throw new Error(`thinking must be one of: ${Object.keys(X).join(", ")}`);if(e.approval&&!Y[e.approval])throw new Error(`approval must be one of: ${Object.keys(Y).join(", ")}`);if(!Q[e.outputFormat])throw new Error(`output-format must be one of: ${Object.keys(Q).join(", ")}`);if(e.outputFormat!=="text"&&!e.print)throw new Error(`--output-format ${e.outputFormat} is a machine contract; it needs --print`);if(e.dangerouslySkipPermissions&&!e.print)throw new Error("--dangerously-skip-permissions is for unattended runs; it needs --print. interactively, pick an approval mode instead (/approval, or --approval)");if(e.prompt=p.join(" ").trim(),e.update&&e.checkUpdate)throw new Error("--update installs; --check-update only looks. pick one");if((e.update||e.checkUpdate)&&(e.print||e.continueSession||e.sessionPath||e.prompt))throw new Error("--update and --check-update act on the installation, not a session; they take no prompt");if(e.continueSession&&e.noSession)throw new Error("--continue and --no-session cannot be combined");if(e.sessionPath&&e.noSession)throw new Error("--session and --no-session cannot be combined");if(e.sessionPath&&e.continueSession)throw new Error("--session and --continue cannot be combined");if(e.resumeId&&e.sessionPath)throw new Error("resume <id> and --session cannot be combined");if(e.resumeId&&e.continueSession)throw new Error("resume <id> and --continue cannot be combined");if(e.print&&(e.continueSession||e.sessionPath||e.resumeId))throw new Error("--print runs one prompt in a throwaway session; it cannot be combined with --continue, --session, or resume <id>");if(e.mode&&(e.print||e.prompt))throw new Error(`--mode ${e.mode} is a protocol server: prompts arrive over the protocol, not the command line`);if(e.mode&&(e.continueSession||e.sessionPath))throw new Error(`--mode ${e.mode} opens its own sessions; it cannot be combined with --continue or --session`);if(e.sessionPath&&!e.sessionPath.endsWith(".jsonl"))throw new Error(`--session expects a session file, got '${e.sessionPath}'`);return e}function A(){return`${r} ${k}
2
+ import{b as q,d as Q,e as Z}from"./chunk-EZNNALD3.js";import"./chunk-7LA2AMZB.js";import{e as K,f as J}from"./chunk-YUOYDO5O.js";import{c as z}from"./chunk-PH72JBBL.js";import{a as V,b as F}from"./chunk-MCAAX33K.js";import{a as d,b as v}from"./chunk-WDMBTVK7.js";import{H as _,P as Y}from"./chunk-5FIFNXLT.js";import"./chunk-UTYFLLSM.js";import{j as X}from"./chunk-MVVEYKN6.js";import"./chunk-WOT6VMZA.js";import{existsSync as Xe,mkdirSync as ze,readdirSync as pe,statSync as qe,writeFileSync as Qe}from"node:fs";import{basename as Ze,join as N}from"node:path";var ee={rpc:!0,acp:!0},te={off:!0,minimal:!0,low:!0,medium:!0,high:!0,xhigh:!0,max:!0},se={suggest:!0,"auto-edit":!0,"full-auto":!0},oe={text:!0,json:!0,"stream-json":!0};function Ue(c){let e=Number(c);if(!Number.isFinite(e)||e<=0)throw new Error(`--max-budget-usd needs a positive number of dollars, got '${c}'`);return e}function E(c,e,t){let s=c[e];if(s?.includes("="))return s.slice(s.indexOf("=")+1);let i=c[e+1];if(!i||i.startsWith("-"))throw new Error(`${t} needs a value`);return c.splice(e+1,1),i}function ne(c){let e={print:!1,continueSession:!1,noSession:!1,help:!1,version:!1,update:!1,checkUpdate:!1,outputFormat:"text",dangerouslySkipPermissions:!1,sandbox:!1,prompt:""},t=[],s=[...c];s[0]==="resume"&&s[1]&&!s[1].startsWith("-")&&(e.resumeId=s[1],s.splice(0,2));for(let i=0;i<s.length;i++){let o=s[i]??"";if(o==="--"){t.push(...s.slice(i+1));break}if(o==="-h"||o==="--help")e.help=!0;else if(o==="-v"||o==="--version")e.version=!0;else if(o==="-p"||o==="--print")e.print=!0;else if(o==="-c"||o==="--continue")e.continueSession=!0;else if(o==="--no-session")e.noSession=!0;else if(o==="--sandbox")e.sandbox=!0;else if(o==="--update")e.update=!0;else if(o==="--check-update")e.checkUpdate=!0;else if(o==="-r"||o==="--resume")e.continueSession=!0;else if(o==="--session"||o.startsWith("--session="))e.sessionPath=E(s,i,"--session");else if(o==="-m"||o==="--model"||o.startsWith("--model="))e.model=E(s,i,"--model");else if(o==="--thinking"||o.startsWith("--thinking="))e.thinking=E(s,i,"--thinking");else if(o==="--approval"||o.startsWith("--approval="))e.approval=E(s,i,"--approval");else if(o==="--output-format"||o.startsWith("--output-format="))e.outputFormat=E(s,i,"--output-format");else if(o==="--max-budget-usd"||o.startsWith("--max-budget-usd="))e.maxBudgetUsd=Ue(E(s,i,"--max-budget-usd"));else if(o==="--mode"||o.startsWith("--mode=")){let h=E(s,i,"--mode");if(!ee[h])throw new Error(`--mode must be one of: ${Object.keys(ee).join(", ")}`);e.mode=h}else if(o==="--acp")e.mode="acp";else if(o==="--dangerously-skip-permissions")e.dangerouslySkipPermissions=!0;else{if(o.startsWith("-"))throw new Error(`unknown option ${o}`);t.push(o)}}if(e.thinking&&!te[e.thinking])throw new Error(`thinking must be one of: ${Object.keys(te).join(", ")}`);if(e.approval&&!se[e.approval])throw new Error(`approval must be one of: ${Object.keys(se).join(", ")}`);if(!oe[e.outputFormat])throw new Error(`output-format must be one of: ${Object.keys(oe).join(", ")}`);if(e.outputFormat!=="text"&&!e.print)throw new Error(`--output-format ${e.outputFormat} is a machine contract; it needs --print`);if(e.dangerouslySkipPermissions&&!e.print)throw new Error("--dangerously-skip-permissions is for unattended runs; it needs --print. interactively, pick an approval mode instead (/approval, or --approval)");if(e.prompt=t.join(" ").trim(),e.update&&e.checkUpdate)throw new Error("--update installs; --check-update only looks. pick one");if((e.update||e.checkUpdate)&&(e.print||e.continueSession||e.sessionPath||e.prompt))throw new Error("--update and --check-update act on the installation, not a session; they take no prompt");if(e.continueSession&&e.noSession)throw new Error("--continue and --no-session cannot be combined");if(e.sessionPath&&e.noSession)throw new Error("--session and --no-session cannot be combined");if(e.sessionPath&&e.continueSession)throw new Error("--session and --continue cannot be combined");if(e.resumeId&&e.sessionPath)throw new Error("resume <id> and --session cannot be combined");if(e.resumeId&&e.continueSession)throw new Error("resume <id> and --continue cannot be combined");if(e.print&&(e.continueSession||e.sessionPath||e.resumeId))throw new Error("--print runs one prompt in a throwaway session; it cannot be combined with --continue, --session, or resume <id>");if(e.mode&&(e.print||e.prompt))throw new Error(`--mode ${e.mode} is a protocol server: prompts arrive over the protocol, not the command line`);if(e.mode&&(e.continueSession||e.sessionPath))throw new Error(`--mode ${e.mode} opens its own sessions; it cannot be combined with --continue or --session`);if(e.sessionPath&&!e.sessionPath.endsWith(".jsonl"))throw new Error(`--session expects a session file, got '${e.sessionPath}'`);return e}function R(){return`${d} ${v}
3
3
  coding agent. layout is a workbench, not a chat log.
4
4
 
5
5
  usage:
@@ -90,13 +90,13 @@ an npm install checks for a newer release at startup and can install it itself;
90
90
  /update does it on demand. config and sessions live in ~/.howtocode/agent.
91
91
  /connect signs in to howtofix.id in your browser, and falls back to a pasted
92
92
  token; /login takes another provider's key.
93
- `}function Ae(l,e=!1){let{message:p,hint:i}=L(l),c=i?`${p}
94
- ${i}`:p;if(!e)return c;let s=l instanceof Error?l.stack:void 0;return s&&s.includes(`
95
- `)?`${c}
96
- ${s}`:c}function ee(l,e){let p=e?.debug??process.env.HOWTOCODE_DEBUG==="1",i=e?.exit??(s=>process.exit(s)),c=s=>{console.error(`${l}: ${Ae(s,p)}`),i(1)};process.on("uncaughtException",c),process.on("unhandledRejection",c)}function Ue(){try{return{cwd:process.cwd()}}catch{return{error:"the current directory no longer exists (it was deleted while the shell stayed in it). cd to a directory that exists, or pass one on the command line."}}}function We(){process.stdout.on("error",l=>{throw l.code==="EPIPE"&&process.exit(0),l})}function Be(){let l=j($,".welcomed");if(!je(l)){try{Fe($,{recursive:!0}),Ne(l,k)}catch{return}console.error(`${r} ${k} installed. Docs: https://howtofix.id/code`),console.error("Continue the last session here with: howtocode -c")}}async function oe(){B()||(console.error(`${r}: this build's CLI signing key (${D()}) does not match the key the panel verifies against, so sign-in will be refused.`),process.exitCode=1)}async function De(){We(),H();let l=performance.now(),e=Ue();if("error"in e){console.error(`${r}: ${e.error}`),process.exitCode=1;return}let p=e.cwd,i=process.env.HXF_FAKE_NODE??process.versions.node,[c,s]=i.split(".").map(t=>Number.parseInt(t,10));if(!Number.isFinite(c)||c<22||c===22&&Number.isFinite(s)&&s<19){console.error(`${r}: Node ${i} is too old. Node 22.19 or newer is required (run "node --version" to check yours), because undici needs zstd, which Node added in 22.19. Upgrade Node and run this again.`),process.exitCode=1;let t=process.argv.slice(2);if(t.some(n=>n==="-h"||n==="--help")){console.log(A());return}if(t.some(n=>n==="-v"||n==="--version")){console.log(`${r} ${k}`);return}return}let h=process.argv.slice(2);if(h[0]==="doctor"||h[0]==="models"||h[0]==="sessions"){let t=h[0];try{let n=await import("./chunk-5V2BWFMR.js");t==="doctor"?process.exitCode=await n.runDoctor():t==="models"?process.exitCode=n.runModels():process.exitCode=n.runSessions(h.slice(1))}catch(n){F(r,t,n),process.exitCode=1}return}if(h.some(t=>t==="-v"||t==="--version")){await oe(),console.log(`${r} ${k}`);return}let te=h[0]==="acp"?["--acp",...h.slice(1)]:h,E;try{E=Z(te)}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`${r}: ${n}
97
- ${A()}`),process.exitCode=2;return}if(E.print&&!E.prompt){console.error(`${r}: --print needs a prompt`),process.exitCode=2;return}let{repairGatewayModels:ne,ensureGatewaySettings:re,repairModelFacts:ie,syncGatewayModelsOnStart:ae,checkAccount:ce,fetchGatewayPrices:de,readProviderKey:le}=await import("./chunk-HI5WRS5W.js"),{tiersFrom:pe,writeReachable:ue}=await import("./chunk-XBVWQC7P.js"),{readCliCredential:me,renewCliCredentialIfNeeded:he}=await import("./chunk-IGRKX5US.js"),{AGENT_DIR:f,REACHABLE_CACHE_PATH:fe}=await import("./chunk-336TZTEK.js"),{readCachedPrices:ge,writeCachedPrices:we}=await import("./chunk-A3LZMZ3C.js"),I=ne(f);I>0&&console.error(`${r}: repaired ${I} howtocode model(s) that the gateway would have rejected`);let _,R,M=new Map,C=ge(f);if(C){_=C.prices;for(let[t,n]of C.groups)M.set(t,n)}try{let t=me(f),n=t?(await he(f,t)).credential.accessToken:le(f,"howtocode");if(n){let[m,u]=await Promise.all([C?Promise.resolve(_??new Map):de(n,{groups:M}),ce(n)]);!C&&m.size>0&&(_=m,we(f,m,M)),u.ok&&(R=u.models)}}catch{}let N=pe(M),O=await ie(f,{..._?{prices:_}:{},...N.size>0?{tiers:N}:{}});if(O.changed>0?console.error(`${r}: filled in the context window, reasoning flag and price for ${O.changed} model(s)`):O.message&&console.error(`${r}: model catalogue unavailable (${O.message}); context windows stay at their conservative defaults`),re(f)&&console.error(`${r}: set httpIdleTimeoutMs in settings.json so a stalled provider recovers instead of hanging`),R){ue(fe,R);try{let t=await ae(f,R,_);t.added>0&&console.error(`${r}: added ${t.added} model(s) this account can now reach`)}catch{}}let o=E;if(o.help){console.log(A());return}if(o.version){await oe(),console.log(`${r} ${k}`);return}if(o.sandbox&&!process.env.HOWTOCODE_SANDBOXED){let{detectSandbox:t,enterSandbox:n,describeSandbox:m}=await import("./chunk-GQYIIDKK.js"),u=t();if(!u){console.error(`${r}: --sandbox needs a working bubblewrap (Linux) or sandbox-exec (macOS). Neither could be used here \u2014 on Linux this usually means unprivileged user namespaces are disabled.`),process.exitCode=1;return}console.error(m(u)),process.exitCode=n(u,{cwd:p,agentDir:$,argv:[process.execPath,...process.argv.slice(1)]});return}let{installProxy:be}=await import("./chunk-WKUJ7CFO.js");be($);let{retireRobloxBridge:ke}=await import("./chunk-ULXYWUXZ.js");if(ke($),o.update||o.checkUpdate){let{PACKAGE_NAME:t,checkForUpdate:n,installUpdate:m,isInstalledCopy:u}=await import("./chunk-LYLJZVZ7.js"),w=await n(k);if(!w.latest){console.error(`${r}: ${w.message}`),process.exitCode=o.update?1:0;return}if(console.log(w.message),o.checkUpdate||!w.available)return;if(!u()){console.error(`${r}: this copy was not installed by npm, so npm cannot replace it. install it with: npm install -g ${t}`),process.exitCode=1;return}let v=await m({version:w.latest});console.log(v.message),v.ok||(process.exitCode=1);return}let U=process.argv.slice(2);if(U[0]==="preset"){let{runPresetCommand:t}=await import("./chunk-RJYOUCLJ.js");process.exitCode=t(U.slice(1));return}let{expandFileReferences:xe}=await import("./chunk-TSEKPGK4.js"),{isApprovalMode:ye,setApprovalMode:ve,setDangerousBypass:Se,isDangerousBypass:$e}=await import("./chunk-4SK7TRJW.js"),{openSession:Pe}=await import("./chunk-LVL53DBD.js");ve(o.approval&&ye(o.approval)?o.approval:"full-auto");let{readWorkbenchSettings:_e}=await import("./chunk-V3R4FYTJ.js");if((o.dangerouslySkipPermissions||_e(f).skipPermissions)&&Se(!0),$e()&&console.error(`${r}: permission checks are OFF \u2014 critical commands (filesystem wipes, fork bombs, host shutdown) and the repeated-call guard are NOT enforced for this run. Turn it off with /settings, or by removing skipPermissions from settings.json.`),o.mode){let{serveProtocol:t}=await import("./chunk-OTMGKZNV.js");await t(o.mode,{cwd:p,model:o.model,thinking:o.thinking});return}let W=t=>Pe({cwd:p,model:o.model,thinking:o.thinking,continueSession:t.continueSession??!1,noSession:t.noSession??!1,sessionPath:t.sessionPath,interactive:!o.print});if(o.resumeId&&!o.sessionPath){let t=j($,"sessions"),n=[];try{for(let m of se(t))for(let u of se(j(t,m))){if(!u.endsWith(".jsonl")||!u.includes(o.resumeId))continue;let w=j(t,m,u);try{n.push({path:w,mtime:Ie(w).mtimeMs})}catch{}}}catch{}if(n=n.sort((m,u)=>u.mtime-m.mtime),n.length===0){console.error(`${r}: no stored session matches '${o.resumeId}'. Run 'howtocode -c' to continue the latest one in this folder.`),process.exitCode=1;return}n.length>1&&console.error(`${r}: '${o.resumeId}' matches ${n.length} sessions; using the newest (${n[0].path}).`),o.sessionPath=n[0].path}let a=await W({continueSession:o.continueSession,sessionPath:o.sessionPath,noSession:o.noSession||o.print});if(o.print&&a.note&&console.error(a.note),o.maxBudgetUsd!==void 0&&!a.priced){console.error(`${r}: ${q(a.modelLabel,f)}`),await a.dispose(),process.exitCode=2;return}if(o.print){let t=o.prompt.trimStart();if(t.startsWith("/")){let b=t.slice(1).split(/\s+/)[0]??"",{skillInvocation:T}=await import("./chunk-E2UZLMQH.js"),S=a.session.resourceLoader.getSkills().skills.map(g=>g.name);if(!(T(t,S)!==void 0)){let{slashCommands:g}=await import("./chunk-5JWO32C6.js");if(g(a.session).some(d=>d.name===b)){console.error(`${r}: /${b} runs in the TUI only \u2014 --print sends prompts straight to the model. Run \`howtocode\` without --print for interactive commands.`),await a.dispose(),process.exitCode=2;return}}}let n=o.outputFormat==="stream-json",m=o.outputFormat==="json",u=n||m;if(n){let b={type:"system",subtype:"init",cwd:p,session_id:a.session.sessionId,model:a.modelLabel,output_format:o.outputFormat,max_budget_usd:o.maxBudgetUsd??null,dangerously_skip_permissions:o.dangerouslySkipPermissions,cli_version:k};process.stdout.write(`${JSON.stringify(b)}
98
- `)}let w,v,Oe=()=>{if(o.maxBudgetUsd===void 0||v!==void 0)return;let b=a.session.getSessionStats().cost;b>o.maxBudgetUsd&&(v={spent:b},a.session.abort())};try{let b,T=K();if(w=a.session.subscribe(d=>{if(n){let y=T.line(d);y!==void 0&&process.stdout.write(y)}if(d.type==="turn_end"&&d.message?.role==="assistant"){let y=d.message;y.stopReason==="error"||y.stopReason==="aborted"||y.errorMessage?b={stopReason:y.stopReason??"error",errorMessage:y.errorMessage}:b=void 0}Oe()}),await a.session.prompt(xe(o.prompt,p)),n){let d=T.finish();d!==void 0&&process.stdout.write(d)}let S=G(a.session.getLastAssistantText()??"");if(v){if(console.error(`${r}: ${V(v.spent,o.maxBudgetUsd)}`),u){let d=a.session.getSessionStats();process.stdout.write(`${JSON.stringify({type:"result",subtype:"error_max_budget_usd",is_error:!0,result:S,session_id:a.session.sessionId,duration_ms:Math.round(performance.now()-l),num_turns:d.assistantMessages,total_cost_usd:d.cost,usage:{input_tokens:d.tokens.input,output_tokens:d.tokens.output,cache_read_input_tokens:d.tokens.cacheRead,cache_creation_input_tokens:d.tokens.cacheWrite}})}
99
- `)}process.exitCode=1;return}let x=a.session.state.messages.at(-1),g=b??(x?.role==="assistant"&&(x.stopReason==="error"||x.stopReason==="aborted"||x.errorMessage)?{stopReason:x.stopReason??"error",errorMessage:x.errorMessage}:void 0);if(u){let d=a.session.getSessionStats();process.stdout.write(`${JSON.stringify({type:"result",subtype:g?g.stopReason==="aborted"?"error_aborted":"error_during_execution":"success",is_error:g!==void 0,result:S,session_id:a.session.sessionId,duration_ms:Math.round(performance.now()-l),num_turns:d.assistantMessages,total_cost_usd:d.cost,usage:{input_tokens:d.tokens.input,output_tokens:d.tokens.output,cache_read_input_tokens:d.tokens.cacheRead,cache_creation_input_tokens:d.tokens.cacheWrite},stop_reason:g?.stopReason??(x?.role==="assistant"?x.stopReason:void 0)})}
100
- `)}else process.stdout.write(S.endsWith(`
101
- `)?S:`${S}
102
- `);if(g&&(process.exitCode=1,g.errorMessage)){console.error(`${r}: ${g.errorMessage}`);let d=J(g.errorMessage);d!==void 0&&console.error(`${r}: ${d}`)}}finally{w?.(),await a.dispose()}return}if(!process.stdin.isTTY||!process.stdout.isTTY){console.error(`${r}: interactive mode needs a terminal. use --print for pipes.`),await a.dispose(),process.exitCode=2;return}Be();let{runWorkbench:Ce}=await import("./chunk-5JWO32C6.js"),{autoUpdateEnabled:Ee,isInstalledCopy:Re}=await import("./chunk-LYLJZVZ7.js"),Me=Re()&&Ee(`${f}/settings.json`);await Ce({cwd:p,modelLabel:a.modelLabel,session:a.session,dispose:()=>a.dispose(),setCompressToolOutput:a.setCompressToolOutput,initialPrompt:o.prompt||void 0,note:a.note,approval:o.approval,maxBudgetUsd:o.maxBudgetUsd,update:Me?{current:k,install:!0}:void 0,reopen:W})}ee(r);De().catch(l=>{F(r,void 0,l),process.exitCode=1});
93
+ `}function Be(c,e=!1){let{message:t,hint:s}=V(c),i=s?`${t}
94
+ ${s}`:t;if(!e)return i;let o=c instanceof Error?c.stack:void 0;return o&&o.includes(`
95
+ `)?`${i}
96
+ ${o}`:i}function re(c,e){let t=e?.debug??process.env.HOWTOCODE_DEBUG==="1",s=e?.exit??(o=>process.exit(o)),i=o=>{console.error(`${c}: ${Be(o,t)}`),s(1)};process.on("uncaughtException",i),process.on("unhandledRejection",i)}import{connect as He}from"node:net";var x={HANDSHAKE:0,FRAME:1,CLOSE:2,PING:3,PONG:4},de="1560641616753066135",ie=10,We=1e4,ae=1e3,Ge=3e4,Ke=3e4,Je=15e3;function Ve(c=process.platform){if(c==="win32")return Array.from({length:ie},(s,i)=>`\\\\?\\pipe\\discord-ipc-${i}`);let e=process.env.XDG_RUNTIME_DIR??process.env.TMPDIR??process.env.TMP??"/tmp";return[e,`${e}/app/com.discordapp.Discord`,`${e}/snap.discord`,`${e}/.flatpak/dev.vencord.Vesktop`,`${e}/.flatpak/com.discordapp.Discord`].flatMap(s=>Array.from({length:ie},(i,o)=>`${s.replace(/\/+$/,"")}/discord-ipc-${o}`))}function ce(c,e){let t=Buffer.from(JSON.stringify(e??{}),"utf8"),s=Buffer.allocUnsafe(8+t.length);return s.writeUInt32LE(c,0),s.writeUInt32LE(t.length,4),t.copy(s,8),s}function Ye(c){let e=[],t=c;for(;t.length>=8;){let s=t.readUInt32LE(0),i=t.readUInt32LE(4);if(t.length<8+i)break;let o=t.subarray(8,8+i).toString("utf8");t=t.subarray(8+i);let h;try{h=JSON.parse(o)}catch{h={raw:o}}e.push({op:s,payload:h})}return{frames:e,rest:t}}var M=class{clientId;activity;candidates;log;socket;buffer=Buffer.alloc(0);ready=!1;stopped=!1;reconnectTimer;pingTimer;handshakeTimer;reconnectDelay=ae;lastSent=0;applied="";constructor(e){this.clientId=e.clientId,this.activity=e.activity,this.candidates=e.candidates??Ve(),this.log=e.log??(()=>{})}start(){this.stopped||this.socket!==void 0||this.reconnectTimer!==void 0||this.clientId.trim().length!==0&&this.connectToAny(0)}update(e){this.activity=e,this.flush(!1)}stop(){if(this.stopped=!0,this.ready=!1,clearTimeout(this.reconnectTimer),clearTimeout(this.handshakeTimer),clearInterval(this.pingTimer),this.reconnectTimer=void 0,this.handshakeTimer=void 0,this.pingTimer=void 0,this.socket){try{this.socket.write(ce(x.CLOSE,{code:1e3,message:"HowToCode stopped"})),this.socket.end()}catch{}this.socket.destroy(),this.socket=void 0}}connectToAny(e){if(this.stopped)return;if(e>=this.candidates.length){this.log("Discord IPC socket not found; presence disabled"),this.scheduleReconnect();return}let t=this.candidates[e],s=He(t);s.once("connect",()=>{s.removeAllListeners("error"),this.attach(s)}),s.once("error",()=>{s.destroy(),this.connectToAny(e+1)})}attach(e){this.socket=e,this.buffer=Buffer.alloc(0),this.ready=!1,e.on("data",t=>this.onData(t)),e.on("close",()=>this.onDrop("Discord closed the socket")),e.on("error",t=>this.onDrop(t.message)),this.handshakeTimer=setTimeout(()=>this.onDrop("Discord handshake timed out"),We),this.write(x.HANDSHAKE,{v:1,client_id:this.clientId})}onData(e){this.buffer=Buffer.concat([this.buffer,e]);let t=Ye(this.buffer);this.buffer=t.rest;for(let s of t.frames)this.onFrame(s.op,s.payload)}onFrame(e,t){if(e===x.PING){this.write(x.PONG,t);return}if(e===x.CLOSE){let o=typeof t=="object"&&t!==null&&"code"in t?t.code:void 0;this.onDrop(`Discord closed the session${o===4e3?" (unknown application id)":""}`);return}if(e!==x.FRAME||typeof t!="object"||t===null)return;let s="evt"in t?t.evt:void 0,i="cmd"in t?t.cmd:void 0;if(s==="READY"){clearTimeout(this.handshakeTimer),this.handshakeTimer=void 0,this.ready=!0,this.reconnectDelay=ae,this.applied="",this.startPing(),this.flush(!0);return}i==="SET_ACTIVITY"&&this.log("presence updated")}write(e,t){let s=this.socket;if(!s||s.destroyed)return!1;try{return s.write(ce(e,t)),!0}catch(i){return this.onDrop(i instanceof Error?i.message:String(i)),!1}}startPing(){clearInterval(this.pingTimer),this.pingTimer=setInterval(()=>this.write(x.PING,{t:Date.now()}),Ke),this.pingTimer.unref?.()}flush(e){if(!this.ready||this.stopped)return;let t=Date.now();if(!e&&t-this.lastSent<Je)return;let s=JSON.stringify(this.activity);s!==this.applied&&(this.applied=s,this.lastSent=t,this.write(x.FRAME,{cmd:"SET_ACTIVITY",args:{pid:process.pid,activity:this.activity},nonce:`howtocode-${t}`}))}onDrop(e){this.ready=!1,clearTimeout(this.handshakeTimer),clearInterval(this.pingTimer),this.handshakeTimer=void 0,this.pingTimer=void 0;let t=this.socket;this.socket=void 0,t&&(t.removeAllListeners(),t.destroy()),!this.stopped&&(this.log(`Discord presence disconnected: ${e}`),this.scheduleReconnect())}scheduleReconnect(){if(this.stopped||this.reconnectTimer!==void 0)return;let e=this.reconnectDelay;this.reconnectDelay=Math.min(this.reconnectDelay*2,Ge),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=void 0,this.connectToAny(0)},e),this.reconnectTimer.unref?.()}};function et(){try{return{cwd:process.cwd()}}catch{return{error:"the current directory no longer exists (it was deleted while the shell stayed in it). cd to a directory that exists, or pass one on the command line."}}}function tt(){process.stdout.on("error",c=>{throw c.code==="EPIPE"&&process.exit(0),c})}function st(){let c=N(_,".welcomed");if(!Xe(c)){try{ze(_,{recursive:!0}),Qe(c,v)}catch{return}console.error(`${d} ${v} installed. Docs: https://howtofix.id/code`),console.error("Continue the last session here with: howtocode -c")}}async function le(){K()||(console.error(`${d}: this build's CLI signing key (${J()}) does not match the key the panel verifies against, so sign-in will be refused.`),process.exitCode=1)}async function ot(){tt(),Y();let c=performance.now(),e=et();if("error"in e){console.error(`${d}: ${e.error}`),process.exitCode=1;return}let t=e.cwd,s=process.env.HXF_FAKE_NODE??process.versions.node,[i,o]=s.split(".").map(r=>Number.parseInt(r,10));if(!Number.isFinite(i)||i<22||i===22&&Number.isFinite(o)&&o<19){console.error(`${d}: Node ${s} is too old. Node 22.19 or newer is required (run "node --version" to check yours), because undici needs zstd, which Node added in 22.19. Upgrade Node and run this again.`),process.exitCode=1;let r=process.argv.slice(2);if(r.some(a=>a==="-h"||a==="--help")){console.log(R());return}if(r.some(a=>a==="-v"||a==="--version")){console.log(`${d} ${v}`);return}return}let h=process.argv.slice(2);if(h[0]==="doctor"||h[0]==="models"||h[0]==="sessions"){let r=h[0];try{let a=await import("./chunk-DWHGMY6G.js");r==="doctor"?process.exitCode=await a.runDoctor():r==="models"?process.exitCode=a.runModels():process.exitCode=a.runSessions(h.slice(1))}catch(a){F(d,r,a),process.exitCode=1}return}if(h.some(r=>r==="-v"||r==="--version")){await le(),console.log(`${d} ${v}`);return}let ue=h[0]==="acp"?["--acp",...h.slice(1)]:h,P;try{P=ne(ue)}catch(r){let a=r instanceof Error?r.message:String(r);console.error(`${d}: ${a}
97
+ ${R()}`),process.exitCode=2;return}if(P.print&&!P.prompt){console.error(`${d}: --print needs a prompt`),process.exitCode=2;return}let{repairGatewayModels:he,ensureGatewaySettings:me,repairModelFacts:fe,syncGatewayModelsOnStart:ge,checkAccount:we,fetchGatewayPrices:ye,readProviderKey:ve}=await import("./chunk-PQB6KMLL.js"),{tiersFrom:be,writeReachable:ke}=await import("./chunk-XBVWQC7P.js"),{readCliCredential:xe,renewCliCredentialIfNeeded:Se}=await import("./chunk-U5EB7YZU.js"),{AGENT_DIR:f,REACHABLE_CACHE_PATH:Te}=await import("./chunk-336TZTEK.js"),{readCachedPrices:_e,writeCachedPrices:Ee}=await import("./chunk-A3LZMZ3C.js"),j=he(f);j>0&&console.error(`${d}: repaired ${j} howtocode model(s) that the gateway would have rejected`);let C,D,I=new Map,$=_e(f);if($){C=$.prices;for(let[r,a]of $.groups)I.set(r,a)}try{let r=xe(f),a=r?(await Se(f,r)).credential.accessToken:ve(f,"howtocode");if(a){let[m,u]=await Promise.all([$?Promise.resolve(C??new Map):ye(a,{groups:I}),we(a)]);!$&&m.size>0&&(C=m,Ee(f,m,I)),u.ok&&(D=u.models)}}catch{}let L=be(I),A=await fe(f,{...C?{prices:C}:{},...L.size>0?{tiers:L}:{}});if(A.changed>0?console.error(`${d}: filled in the context window, reasoning flag and price for ${A.changed} model(s)`):A.message&&console.error(`${d}: model catalogue unavailable (${A.message}); context windows stay at their conservative defaults`),me(f)&&console.error(`${d}: set httpIdleTimeoutMs in settings.json so a stalled provider recovers instead of hanging`),D){ke(Te,D);try{let r=await ge(f,D,C);r.added>0&&console.error(`${d}: added ${r.added} model(s) this account can now reach`)}catch{}}let n=P;if(n.help){console.log(R());return}if(n.version){await le(),console.log(`${d} ${v}`);return}if(n.sandbox&&!process.env.HOWTOCODE_SANDBOXED){let{detectSandbox:r,enterSandbox:a,describeSandbox:m}=await import("./chunk-GQYIIDKK.js"),u=r();if(!u){console.error(`${d}: --sandbox needs a working bubblewrap (Linux) or sandbox-exec (macOS). Neither could be used here \u2014 on Linux this usually means unprivileged user namespaces are disabled.`),process.exitCode=1;return}console.error(m(u)),process.exitCode=a(u,{cwd:t,agentDir:_,argv:[process.execPath,...process.argv.slice(1)]});return}let{installProxy:Ce}=await import("./chunk-WKUJ7CFO.js");Ce(_);let{retireRobloxBridge:$e}=await import("./chunk-ULXYWUXZ.js");if($e(_),n.update||n.checkUpdate){let{PACKAGE_NAME:r,checkForUpdate:a,installUpdate:m,isInstalledCopy:u}=await import("./chunk-LYLJZVZ7.js"),w=await a(v);if(!w.latest){console.error(`${d}: ${w.message}`),process.exitCode=n.update?1:0;return}if(console.log(w.message),n.checkUpdate||!w.available)return;if(!u()){console.error(`${d}: this copy was not installed by npm, so npm cannot replace it. install it with: npm install -g ${r}`),process.exitCode=1;return}let S=await m({version:w.latest});console.log(S.message),S.ok||(process.exitCode=1);return}let U=process.argv.slice(2);if(U[0]==="preset"){let{runPresetCommand:r}=await import("./chunk-RJYOUCLJ.js");process.exitCode=r(U.slice(1));return}let{expandFileReferences:Pe}=await import("./chunk-TSEKPGK4.js"),{isApprovalMode:De,setApprovalMode:Ie,setDangerousBypass:Ae,isDangerousBypass:Oe}=await import("./chunk-4SK7TRJW.js"),{openSession:Re}=await import("./chunk-HMCCBHIZ.js");Ie(n.approval&&De(n.approval)?n.approval:"full-auto");let{readWorkbenchSettings:B}=await import("./chunk-UDX555SX.js");if((n.dangerouslySkipPermissions||B(f).skipPermissions)&&Ae(!0),Oe()&&console.error(`${d}: permission checks are OFF \u2014 critical commands (filesystem wipes, fork bombs, host shutdown) and the repeated-call guard are NOT enforced for this run. Turn it off with /settings, or by removing skipPermissions from settings.json.`),n.mode){let{serveProtocol:r}=await import("./chunk-5JRLPRW5.js");await r(n.mode,{cwd:t,model:n.model,thinking:n.thinking});return}let H=r=>Re({cwd:t,model:n.model,thinking:n.thinking,continueSession:r.continueSession??!1,noSession:r.noSession??!1,sessionPath:r.sessionPath,interactive:!n.print});if(n.resumeId&&!n.sessionPath){let r=N(_,"sessions"),a=[];try{for(let m of pe(r))for(let u of pe(N(r,m))){if(!u.endsWith(".jsonl")||!u.includes(n.resumeId))continue;let w=N(r,m,u);try{a.push({path:w,mtime:qe(w).mtimeMs})}catch{}}}catch{}if(a=a.sort((m,u)=>u.mtime-m.mtime),a.length===0){console.error(`${d}: no stored session matches '${n.resumeId}'. Run 'howtocode -c' to continue the latest one in this folder.`),process.exitCode=1;return}a.length>1&&console.error(`${d}: '${n.resumeId}' matches ${a.length} sessions; using the newest (${a[0].path}).`),n.sessionPath=a[0].path}let p=await H({continueSession:n.continueSession,sessionPath:n.sessionPath,noSession:n.noSession||n.print});if(n.print&&p.note&&console.error(p.note),n.maxBudgetUsd!==void 0&&!p.priced){console.error(`${d}: ${Z(p.modelLabel,f)}`),await p.dispose(),process.exitCode=2;return}if(n.print){let r=n.prompt.trimStart();if(r.startsWith("/")){let y=r.slice(1).split(/\s+/)[0]??"",{skillInvocation:O}=await import("./chunk-E2UZLMQH.js"),T=p.session.resourceLoader.getSkills().skills.map(g=>g.name);if(!(O(r,T)!==void 0)){let{slashCommands:g}=await import("./chunk-MP3T3UKV.js");if(g(p.session).some(l=>l.name===y)){console.error(`${d}: /${y} runs in the TUI only \u2014 --print sends prompts straight to the model. Run \`howtocode\` without --print for interactive commands.`),await p.dispose(),process.exitCode=2;return}}}let a=n.outputFormat==="stream-json",m=n.outputFormat==="json",u=a||m;if(a){let y={type:"system",subtype:"init",cwd:t,session_id:p.session.sessionId,model:p.modelLabel,output_format:n.outputFormat,max_budget_usd:n.maxBudgetUsd??null,dangerously_skip_permissions:n.dangerouslySkipPermissions,cli_version:v};process.stdout.write(`${JSON.stringify(y)}
98
+ `)}let w,S,Le=()=>{if(n.maxBudgetUsd===void 0||S!==void 0)return;let y=p.session.getSessionStats().cost;y>n.maxBudgetUsd&&(S={spent:y},p.session.abort())};try{let y,O=z();if(w=p.session.subscribe(l=>{if(a){let k=O.line(l);k!==void 0&&process.stdout.write(k)}if(l.type==="turn_end"&&l.message?.role==="assistant"){let k=l.message;k.stopReason==="error"||k.stopReason==="aborted"||k.errorMessage?y={stopReason:k.stopReason??"error",errorMessage:k.errorMessage}:y=void 0}Le()}),await p.session.prompt(Pe(n.prompt,t)),a){let l=O.finish();l!==void 0&&process.stdout.write(l)}let T=X(p.session.getLastAssistantText()??"");if(S){if(console.error(`${d}: ${Q(S.spent,n.maxBudgetUsd)}`),u){let l=p.session.getSessionStats();process.stdout.write(`${JSON.stringify({type:"result",subtype:"error_max_budget_usd",is_error:!0,result:T,session_id:p.session.sessionId,duration_ms:Math.round(performance.now()-c),num_turns:l.assistantMessages,total_cost_usd:l.cost,usage:{input_tokens:l.tokens.input,output_tokens:l.tokens.output,cache_read_input_tokens:l.tokens.cacheRead,cache_creation_input_tokens:l.tokens.cacheWrite}})}
99
+ `)}process.exitCode=1;return}let b=p.session.state.messages.at(-1),g=y??(b?.role==="assistant"&&(b.stopReason==="error"||b.stopReason==="aborted"||b.errorMessage)?{stopReason:b.stopReason??"error",errorMessage:b.errorMessage}:void 0);if(u){let l=p.session.getSessionStats();process.stdout.write(`${JSON.stringify({type:"result",subtype:g?g.stopReason==="aborted"?"error_aborted":"error_during_execution":"success",is_error:g!==void 0,result:T,session_id:p.session.sessionId,duration_ms:Math.round(performance.now()-c),num_turns:l.assistantMessages,total_cost_usd:l.cost,usage:{input_tokens:l.tokens.input,output_tokens:l.tokens.output,cache_read_input_tokens:l.tokens.cacheRead,cache_creation_input_tokens:l.tokens.cacheWrite},stop_reason:g?.stopReason??(b?.role==="assistant"?b.stopReason:void 0)})}
100
+ `)}else process.stdout.write(T.endsWith(`
101
+ `)?T:`${T}
102
+ `);if(g&&(process.exitCode=1,g.errorMessage)){console.error(`${d}: ${g.errorMessage}`);let l=q(g.errorMessage);l!==void 0&&console.error(`${d}: ${l}`)}}finally{w?.(),await p.dispose()}return}if(!process.stdin.isTTY||!process.stdout.isTTY){console.error(`${d}: interactive mode needs a terminal. use --print for pipes.`),await p.dispose(),process.exitCode=2;return}st();let{runWorkbench:Me}=await import("./chunk-MP3T3UKV.js"),{autoUpdateEnabled:Ne,isInstalledCopy:Fe}=await import("./chunk-LYLJZVZ7.js"),je=Fe()&&Ne(`${f}/settings.json`),W=process.env.HOWTOCODE_DISCORD_DISABLE==="1"?"":process.env.HOWTOCODE_DISCORD_CLIENT_ID?.trim()||B(f).discordClientId||de,G=W?new M({clientId:W,activity:{details:"HowToCode",state:`${p.modelLabel} \u2022 ${Ze(t)}`.slice(0,128),timestamps:{start:Date.now()},...process.env.HOWTOCODE_DISCORD_LARGE_IMAGE?{assets:{large_image:process.env.HOWTOCODE_DISCORD_LARGE_IMAGE,large_text:"HowToCode"}}:{}}}):void 0;G?.start();try{await Me({cwd:t,modelLabel:p.modelLabel,session:p.session,dispose:()=>p.dispose(),setCompressToolOutput:p.setCompressToolOutput,initialPrompt:n.prompt||void 0,note:p.note,approval:n.approval,maxBudgetUsd:n.maxBudgetUsd,update:je?{current:v,install:!0}:void 0,reopen:H})}finally{G?.stop()}}re(d);ot().catch(c=>{F(d,void 0,c),process.exitCode=1});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "howtocode",
3
- "version": "0.7.72",
3
+ "version": "0.7.73",
4
4
  "type": "module",
5
5
  "description": "HowToCode coding agent. Workbench TUI, sessions, background agents.",
6
6
  "license": "UNLICENSED",
@@ -1,2 +0,0 @@
1
- import{a as u}from"./chunk-UTYFLLSM.js";import{existsSync as l,mkdirSync as f,readFileSync as c}from"node:fs";import{dirname as p,join as m}from"node:path";var a={skipPermissions:!1,autoUpdate:!0,rightClickPaste:"auto",welcomeSeen:!1,compressToolOutput:!1};function g(t){return m(t,"settings.json")}function k(t){try{let e=JSON.parse(c(g(t),"utf8")),n=r=>{let i=e[r];return typeof i=="boolean"?i:a[r]},o=e.rightClickPaste;return{skipPermissions:n("skipPermissions"),autoUpdate:n("autoUpdate"),rightClickPaste:o==="on"||o==="off"||o==="auto"?o:a.rightClickPaste,welcomeSeen:n("welcomeSeen"),compressToolOutput:n("compressToolOutput"),...typeof e.agents=="number"&&Number.isInteger(e.agents)&&e.agents>0?{agents:e.agents}:{}}}catch{return{...a}}}function h(t,e,n){return s(t,e,n)}function w(t){return s(t,"welcomeSeen",!0)}function P(t,e){return s(t,"rightClickPaste",e==="auto"?void 0:e)}function y(t){return t==="on"?!0:t==="off"?!1:process.platform!=="win32"}function x(t,e){let n=typeof e=="number"&&Number.isInteger(e)&&e>0?e:void 0;return s(t,"agents",n)}function C(t,e,n){let o=n.trim();return s(t,e,o===""?void 0:o)}function s(t,e,n){let o=g(t),r={};try{let i=JSON.parse(c(o,"utf8"));i&&typeof i=="object"&&!Array.isArray(i)&&(r=i)}catch{if(l(o))return!1}n===void 0?delete r[e]:r[e]=n;try{f(p(o),{recursive:!0}),u(o,`${JSON.stringify(r,null,2)}
2
- `)}catch{return!1}return!0}export{a,k as b,h as c,w as d,P as e,y as f,x as g,C as h};