omo-ai 5.1.12 → 5.1.13

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.
@@ -0,0 +1,2 @@
1
+ // omo:Ip8jMHx84o25YCHFHXxaYeJSA5Q1UPMjuu1o5i4Ackg:UPxDo3aLbw2tsFydwCP7Bj5JHXaMHAyNFpu7kcfRK38
2
+ import{existsSync as e}from"node:fs";import{dirname as t,join as n}from"node:path";import{fileURLToPath as r,pathToFileURL as i}from"node:url";import{randomUUID as o}from"node:crypto";import{existsSync as u}from"node:fs";import{fileURLToPath as s}from"node:url";import{Worker as a}from"node:worker_threads";var d=1048576,c="gateway-store-worker.mjs";function l(e){let t,n,r={agent_dir:e.agentDir,busy_timeout_ms:e._test?.busyTimeoutMs??5e3,lock_wait_max_ms:e._test?.lockWaitMaxMs??3e4,instance_id:e.instanceId??o(),runtime_instance:e.runtimeInstance??null,legacy_mailbox_directories:e.legacyMailboxDirectories??[],test_hooks:{...void 0===e._test?.beforeDbCommit?{}:{beforeDbCommit:e._test.beforeDbCommit},...void 0===e._test?.afterDbCommit?{}:{afterDbCommit:e._test.afterDbCommit},...void 0===e._test?.announceBarrier?{}:{announceBarrier:e._test.announceBarrier}}},i=e.now??Date.now,d=new Map,l=new Set,f=1,p=!1;function m(e,t){for(let[n,r]of d)r.worker===e&&(d.delete(n),r.reject(t))}function h(e,n){let r=t;if(void 0===r)return Promise.reject(Error("the gateway store is closed"));let i=f++,o=new Promise((e,t)=>d.set(i,{worker:r,resolve:e,reject:t}));return r.ref(),r.postMessage({type:"request",id:i,op:e,args:n}),o}function _(){if(p)return Promise.reject(Error("the gateway store is disposed"));if(void 0!==n)return n;let o=process.execArgv.filter(e=>!e.startsWith("--input-type")),f=new a(function(e=import.meta.url){let t=new URL(`./${c}`,e);return u(s(t))?t:new URL("./store-worker.ts",e)}(e._test?.moduleUrl??e.workerModuleUrl),{execArgv:o});t=f,f.unref(),f.on("message",e=>{if("event"===e.type){for(let t of l)t(e.event);return}let t=d.get(e.id);void 0!==t&&(d.delete(e.id),0===d.size&&f.unref(),e.ok?t.resolve(e.value):t.reject(Object.assign(Error(e.error.message),{workerStack:e.error.stack,...void 0===e.error.code?{}:{code:e.error.code}})))}),f.on("error",e=>m(f,e instanceof Error?e:Error(String(e)))),f.on("exit",e=>{t===f&&(t=void 0,n=void 0),m(f,Error(`the gateway store worker exited (${e})`))}),e._test?.onWorkerStarted?.(f);let _=h("init",{config:r,now:i()});return n=_,_.catch(()=>{n===_&&(n=void 0,t===f&&(t=void 0),f.terminate())}),_}async function g(e,t){return await _(),await h(e,t)}return{busyTimeoutMs:r.busy_timeout_ms,now:i,identity:async()=>(await _()).self,enqueue:e=>g("enqueue",e),reconcile:e=>g("reconcile",e),claim:e=>g("claim",e),recordOutcome:e=>g("record_outcome",e),refuseQueued:e=>g("refuse_queued",e),completeReceipt:e=>g("complete_receipt",e),abandonReceipt:e=>g("abandon_receipt",e),deliveryView:e=>g("delivery_view",e),deliveryReceipt:e=>g("delivery_receipt",e),recoverDelivery:e=>g("recover_delivery",e),list:(e={})=>g("list",e),isReferenced:e=>g("is_referenced",e),journalMode:()=>g("journal_mode"),stats:()=>g("stats"),legacyMigrated:async()=>(await _()).legacy_migrated,toolReceiptBegin:e=>g("tool_receipt_begin",e),toolReceiptSettle:e=>g("tool_receipt_settle",e),bind:e=>g("bind",e),unbind:e=>g("unbind",e),rebind:e=>g("rebind",e),listBindings:e=>g("list_bindings",e),bindingView:e=>g("binding_view",e),registerIncarnation:e=>g("register_incarnation",e),clearEndpoint:e=>g("clear_endpoint",e),sessionOwner:e=>g("session_owner",e),report:e=>g("report",e),emitCompletions:e=>g("emit_completions",e),pendingCompletionArms:e=>g("pending_completion_arms",e),latestCompletionArm:e=>g("latest_completion_arm",e),readOutbox:e=>g("read_outbox",e),ackOutbox:e=>g("ack_outbox",e),claimAnswer:e=>g("claim_answer",e),releaseAnswer:e=>g("release_answer",e),confirmAnswer:e=>g("confirm_answer",e),markPriorDelivered:e=>g("mark_prior_delivered",e),onEvent:e=>(l.add(e),()=>l.delete(e)),resume:e=>t?.postMessage({type:"resume",hook:e}),dispose:async()=>{if(p)return;p=!0;let e=t;void 0!==e&&(await h("close",null).catch(()=>{}),t=void 0,await e.terminate())}}}import{randomUUID as f}from"node:crypto";import{join as p}from"node:path";var m=new Set(["invalid_arguments","caller_context_missing","not_found","ambiguous_target","scope_denied","name_conflict","not_resumable","orphaned","foreign_live_owner","no_active_turn","turn_conflict","not_steerable","message_too_large","queue_full","cursor_invalid","cursor_stale","idempotency_conflict","idempotency_in_progress","idempotency_uncertain","approval_unavailable","approval_route_locked","partial_commit","unsupported","overloaded","transport_closed","host_unavailable","internal_error","model_not_found","model_ambiguous","thinking_level_unsupported","loop_detected","binding_conflict","binding_mismatch","binding_inactive","stale_revision","stale_token","already_answered","answer_in_progress"]);function h(e,t,n,r){if("string"!=typeof(i=e)||!m.has(i))throw Error(`unknown thread error code: ${String(e)}`);var i;return{code:e,message:t,next_action:n,...void 0===r?{}:{details:r}}}var _=["question","select","confirm","input","editor"];var g=new Map([["yes",!0],["y",!0],["true",!0],["no",!1],["n",!1],["false",!1]]);function y(e){return""===e.replace(/[\s\p{Cf}]/gu,"")}function v(e){let t=g.get(e.trim().toLowerCase());return void 0===t?{value:e,answers:{},comment:e}:{value:e,answers:{},comment:e,confirmed:t}}function b(e,t){switch(e){case null:return y(t)?{ok:!1,reason:"The question declared no request kind, so the answer needs text; this one is blank. An input or editor that takes an empty answer must be reported with its request kind."}:{ok:!0,fields:v(t)};case"input":case"editor":return{ok:!0,fields:{value:t}};case"select":return y(t)?{ok:!1,reason:"A select answer names one of its options; the text is blank."}:{ok:!0,fields:{value:t}};case"question":return y(t)?{ok:!1,reason:"A question answer needs text; this one is blank."}:{ok:!0,fields:{answers:{},comment:t}};case"confirm":{let e=g.get(t.trim().toLowerCase());return void 0===e?{ok:!1,reason:"A confirm answer is yes or no (also y/n, true/false; any case, surrounding spaces ignored)."}:{ok:!0,fields:{confirmed:e}}}default:return function(e){throw Error(`unknown extension UI request kind: ${String(e)}`)}(e)}}import{createHash as w,createHmac as k,randomUUID as x,timingSafeEqual as $}from"node:crypto";var A=["discord","telegram","slack","notion","feishu","herdr","custom"],S=["milestone","report","question","completion"],O=["auto","follow_up"],I=31622400,E=32768;function R(e){return{kind:"refused",code:"invalid_arguments",message:e}}function P(e,t){return"string"!=typeof t||0===t.trim().length?R(`${e} must be a non-empty string.`):t.length>256?R(`${e} is longer than 256 characters.`):/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/.test(t)?R(`${e} carries a control character or a line separator.`):t}function q(e,t){return null==t?null:P(e,t)}function M(e){return"object"==typeof e&&null!==e&&"refused"===e.kind}function T(e){if(null===e||"object"!=typeof e)return JSON.stringify(e)??"null";if(Array.isArray(e))return`[${e.map(T).join(",")}]`;let t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${T(t[e])}`).join(",")}}`}import{execFile as C}from"node:child_process";import{createConnection as N}from"node:net";import{randomUUID as j}from"node:crypto";import{existsSync as L,readFileSync as B}from"node:fs";import{resolve as z}from"node:path";import{join as D}from"node:path";var U=["OMO_RPC_SOCKET","SENPI_RPC_SOCKET","PI_RPC_SOCKET","OMO_RPC_SOCKET_PATH"];import{existsSync as F}from"node:fs";import{homedir as W}from"node:os";import{join as G,resolve as K}from"node:path";var J=["OMO_CODING_AGENT_DIR","SENPI_CODING_AGENT_DIR","PI_CODING_AGENT_DIR"],H="settings.json";function V(e){let{env:t,homeDir:n=W(),exists:r=F}=e;for(let e of J){let n=t[e]?.trim();if(n)return K(n)}let i=G(n,".omo"),o=G(i,"agent");return r(G(o,H))?o:r(G(i,H))?i:G(n,".senpi","agent")}import*as Z from"node:fs";import*as X from"node:fs/promises";function Q(e){if(e instanceof Error&&"code"in e)return"string"==typeof e.code?e.code:void 0}function Y(e){for(let t=0;;t+=1)try{return e()}catch(e){if("EINTR"!==Q(e)||t>=128)throw e}}function ee(e){return"function"==typeof e}function te(e){return(...t)=>async function(e){for(let t=0;;t+=1)try{return await e()}catch(e){if("EINTR"!==Q(e)||t>=128)throw e}}(async()=>e(...t))}function ne(e){return(...t)=>Y(()=>e(...t))}function re(e,t){let n="async"===t?te:ne,r=new Map;return new Proxy(e,{get(e,t){if(r.has(t))return r.get(t);let i=Reflect.get(e,t);if(!ee(i))return i;let o=n(i),u=Reflect.get(i,"native");return ee(u)&&Object.assign(o,{native:n(u)}),r.set(t,o),o}})}var ie=re(X,"async"),oe=re(Z,"sync"),{access:ue,chmod:se,copyFile:ae,cp:de,link:ce,lstat:le,mkdir:fe,mkdtemp:pe,readFile:me,readdir:he,realpath:_e,rename:ge,rm:ye,rmdir:ve,stat:be,unlink:we}=ie,{accessSync:ke,chmodSync:xe,fsyncSync:$e,linkSync:Ae,lstatSync:Se,mkdirSync:Oe,readFileSync:Ie,readdirSync:Ee,realpathSync:Re,statSync:Pe,unlinkSync:qe,writeFileSync:Me,writeSync:Te}=oe;function Ce(e){try{return Y(()=>Z.statSync(e)),!0}catch{return!1}}import{createRequire as Ne}from"node:module";import{isAbsolute as je,join as Le,relative as Be}from"node:path";import{createRequire as ze}from"node:module";import{existsSync as De,readFileSync as Ue,realpathSync as Fe,statSync as We}from"node:fs";import{createRequire as Ge}from"node:module";import{delimiter as Ke,dirname as Je,isAbsolute as He,join as Ve,resolve as Ze,sep as Xe}from"node:path";Ge(import.meta.url);function Qe(e){return e.includes("$bunfs")||e.includes("~BUN")||e.includes("%7EBUN")}function Ye(){return typeof Bun<"u"&&Bun.embeddedFiles.length>0}function et(e,t,n){for(let r of(t??"").split(Ke)){if(0===r.length)continue;let t=tt(Ve(r,e));if(null!==t&&(void 0===n||n(t)))return t}return null}function tt(e){try{let t=Fe.native(Ze(e));return We(t).isFile()?t:null}catch{return null}}function nt(e,t){let n=t.engineVersion;if(void 0===n||0===n.length)return!0;let r=function(e){let t=Je(e);for(let e=0;e<=3;e+=1){try{let e=JSON.parse(Ue(Ve(t,"package.json"),"utf8"));if("@code-yeongyu/senpi"===e.name&&"string"==typeof e.version&&e.version.length>0)return e.version}catch{}let e=Je(t);if(e===t)break;t=e}}(e);return void 0===r||(r===n||(t.onWarning?.(`Skipping senpi executable ${e} version ${r}; running engine is ${n}`),!1))}function rt(e){let t="win32"===e.platform?"senpi.exe":"senpi",n=e.parentEnv.SENPI_BIN?.trim();if(void 0!==n&&n.length>0)return n.includes("/")||n.includes(Xe)||He(n)?tt(n):et(n,e.parentEnv.PATH);if(!0===e.isCompiledEngine)return tt(e.execPath);let r=t=>nt(t,e);if(e.isBunBinary){let n=tt(Ve(Je(e.execPath),t));return null!==n&&r(n)?n:null}return et(t,e.parentEnv.PATH,r)}function it(e,t){if("win32"!==t.platform||e.toLowerCase().endsWith(".exe"))return{command:e,prefixArgs:[]};let n=Je(e),r=[Ve(n,"node_modules","@code-yeongyu","senpi","dist","cli.js"),Ve(n,"..","@code-yeongyu","senpi","dist","cli.js")].find(e=>De(e));return void 0===r?null:{command:t.execPath,prefixArgs:[r]}}function ot(e){let t=(e.resolveSenpiExecutable??rt)(e);if(null!==t){if(function(e,t){return!0===t.isCompiledEngine&&tt(t.execPath)===e}(t,e))return{command:t,prefixArgs:[]};let n=it(t,e);if(null!==n)return n}if("win32"!==e.platform)return null;for(let t of["senpi.cmd","senpi"]){let n=et(t,e.parentEnv.PATH);if(null===n)continue;let r=it(n,e);if(null!==r)return r}return null}ze(import.meta.url);var ut=Le("@code-yeongyu","senpi"),st=Le("dist","cli.js");function at(e,t=function(){return{isBunBinary:Qe(import.meta.url),isCompiledEngine:Ye(),execPath:process.execPath,platform:process.platform,argv:process.argv,resolveInstalledCli:pt}}()){let n=ot({isBunBinary:t.isBunBinary,isCompiledEngine:t.isCompiledEngine,execPath:t.execPath,platform:t.platform,parentEnv:e,resolveRpcEntry:()=>""});if(null!==n)return n;let r=t.resolveInstalledCli();if(null!==r)return{command:t.execPath,prefixArgs:[r]};let i=t.argv[1];if(void 0!==i&&je(i)&&Ce(i))return{command:t.execPath,prefixArgs:[i]};throw Error("Unable to resolve a runnable Senpi launcher")}var dt=["OMO_PACKAGE_DIR","SENPI_PACKAGE_DIR","PI_PACKAGE_DIR"];function ct(e){try{return Re.native(e)}catch{return e}}function lt(e,t){let n=Be(ct(e),ct(t));return n.length>0&&!n.startsWith("..")&&!je(n)}function ft(e,t){let n=t.prefixArgs[0]??t.command,r={...e};for(let e of dt){let t=r[e];void 0!==t&&0!==t.length&&(lt(t,n)||delete r[e])}return r}function pt(){let e=Ne(import.meta.url);for(let t of e.resolve.paths(Le(ut,"package.json"))??[]){let e=Le(t,ut,st);if(Ce(e))return e}return null}import{readdirSync as mt,readFileSync as ht}from"node:fs";import{basename as _t,join as gt,resolve as yt}from"node:path";import{execFileSync as vt}from"node:child_process";import{realpathSync as bt}from"node:fs";var wt=/[\u0000-\u0008\u000e-\u001f\u007f]/;function kt(e){return e.normalize("NFKC").trim().toLowerCase().replace(/\s+/g," ")}function xt(e,t,n,r){let i=h(e,t,n,void 0===r?void 0:{candidates:r});return void 0===r?{kind:"error",...i}:{kind:"error",...i,candidates:r}}function $t(e){return{id:e.thread_id,name:e.name,cwd:e.cwd,preview:e.preview??"",updatedAt:e.updated_at,state:e.status}}function At(e){try{return bt(e)}catch{return e}}function St(e){try{let t=vt("git",["-C",e,"rev-parse","--show-toplevel"],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:5e3,windowsHide:!0}).trim();return 0===t.length?null:t}catch{return null}}function Ot(){let e=new Map;return t=>{if(e.has(t))return e.get(t)??null;let n=St(t);return e.set(t,n),n}}function It(e,t,n){let r=n(e),i=n(t);return null!==r&&null!==i?At(r)===At(i):At(e)===At(t)}function Et(e){let t=e.trim();if(0===t.length)return[];let n=St(t);return[...new Set((null===n?[t]:[t,n]).flatMap(e=>[e,At(e)]))]}function Rt(e,t,n={}){let r=function(e,t){if("string"!=typeof e)return{ok:!1,error:xt("invalid_arguments",`The ${t} must be a string.`,`Pass a thread_id or a unique name from thread_list as the ${t}.`)};if(wt.test(e))return{ok:!1,error:xt("invalid_arguments",`The ${t} contains control characters.`,"Remove the control characters and retry, or pass an address from thread_list.")};let n=kt(e);return 0===n.length?{ok:!1,error:xt("invalid_arguments",`The ${t} is empty.`,`Pass a thread_id or a unique name from thread_list as the ${t}.`)}:{ok:!0,normalized:n}}(t,"thread address");if(!r.ok)return r.error;let i,o="string"==typeof n.callerWorkspaceRoot?n.callerWorkspaceRoot.trim():"",u=o.length>0,s=Ot(),a=e.find(e=>e.thread_id===t);if(void 0!==a)return!0===n.all_scope?{kind:"ok",entry:a,resolution:"id"}:u?It(a.cwd,o,s)?{kind:"ok",entry:a,resolution:"id"}:xt("scope_denied",`Thread ${a.thread_id} exists outside this workspace.`,"Call thread_list with all_scope to confirm the id, then retry with all_scope set, or target a thread in this workspace."):xt("caller_context_missing","Scoping an id hit needs the caller's workspace root, which this call did not provide.","Set all_scope to address every workspace, or call thread_list from a session that knows its workspace.");if(!0===n.all_scope)i=e;else{if(!u)return xt("caller_context_missing","Scoped address resolution needs the caller's workspace root, which this call did not provide.","Set all_scope to address every workspace, or call thread_list from a session that knows its workspace.");i=e.filter(e=>It(e.cwd,o,s))}let d=i.filter(e=>kt(e.name)===r.normalized);return 1===d.length?{kind:"ok",entry:d[0],resolution:"name"}:d.length>=2?xt("ambiguous_target",`${d.length} visible threads share the name "${t}".`,"Call thread_list and pass the exact thread_id of the intended thread.",function(e){return[...e].sort((e,t)=>e.updated_at===t.updated_at?e.thread_id<t.thread_id?-1:1:null===e.updated_at?1:null===t.updated_at?-1:e.updated_at<t.updated_at?1:-1).slice(0,10).map($t)}(d)):xt("not_found",`No visible thread matches "${t}" in ${!0===n.all_scope?"the daemon-wide scope":"this workspace"}.`,"Call thread_list and pass the thread_id or a unique name it returned.")}import{closeSync as Pt,fstatSync as qt,openSync as Mt,readSync as Tt}from"node:fs";var Ct=65536,Nt=262144;function jt(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Lt(e){return"string"==typeof e?e:Array.isArray(e)?e.flatMap(e=>jt(e)&&"text"===e.type&&"string"==typeof e.text?[e.text]:[]).join(" "):""}function Bt(e,t){let n=e?.trim();if(void 0!==n&&n.length>0)return n;let r=t?.replace(/\s+/g," ").trim();return void 0===r||0===r.length?null:[...r].slice(0,60).join("")}function zt(e,t=!1,n=!1){let r=e.split("\n");return t&&r.shift(),n&&r.pop(),r.flatMap(e=>{if(0===e.trim().length)return[];try{let t=JSON.parse(e);return jt(t)?[t]:[]}catch{return[]}})}function Dt(e){let t=null,n=null,r=null,i="";for(let o of e){if(null===t&&"session"===o.type&&"string"==typeof o.id&&(t=o),"session_info"===o.type&&(n="string"==typeof o.name&&o.name.trim().length>0?o.name.trim():null),null===r&&"message"===o.type&&jt(o.message)&&"user"===o.message.role){let e=Lt(o.message.content).trim();e.length>0&&(r=e)}"string"==typeof o.timestamp&&o.timestamp>i&&(i=o.timestamp)}return{header:t,name:n,first_user_text:r,newest_timestamp:i}}function Ut(e,t=Tt){let n;try{n=Mt(e,"r")}catch{return null}try{let e=qt(n),r=e.size,i=Math.min(r,Ct),o=Buffer.alloc(i);t(n,o,0,i,0);let u=r<=Ct,s=zt(o.toString("utf8"),!1,!u),a=s[0];if(void 0===a||"session"!==a.type||"string"!=typeof a.id||"string"!=typeof a.cwd||"string"!=typeof a.timestamp)return null;let d=[];if(!u){let e=Math.max(i,r-Ct),o=Buffer.alloc(r-e+1);t(n,o,0,o.length,e-1),d=zt(o.subarray(1).toString("utf8"),10!==o[0],!1)}let c=Dt([...s,...d]),l=function(e,t,n){if(0===t)return null;let r=Buffer.allocUnsafe(1);if(1!==n(e,r,0,1,t-1)||10!==r[0])return null;let i=t-1,o=0,u=[];for(;i>0&&o<Nt;){let t=Math.min(Ct,i,Nt-o),r=i-t,s=Buffer.allocUnsafe(t);if(n(e,s,0,t,r)!==t)return null;let a=s.lastIndexOf(10);if(u.unshift(-1===a?s:s.subarray(a+1)),-1!==a||0===r)return Buffer.concat(u);o+=t,i=r}return null}(n,r,t),f=qt(n),p=f.size===e.size&&f.mtimeMs===e.mtimeMs?function(e){if(null===e)return null;try{let t=JSON.parse(e.toString("utf8"));return jt(t)&&"string"==typeof t.timestamp&&t.timestamp.length>0?t.timestamp:null}catch{return null}}(l):null;return{durable_id:a.id,cwd:a.cwd,created_at:a.timestamp,updated_at:p,name:c.name,first_user_text:c.first_user_text}}catch{return null}finally{Pt(n)}}function Ft(e,t,n){if("tui"===e)return"tui";if("worker"===t)return"child";let r=_t(n);return r.startsWith("i-")?"desktop":r.startsWith("p-")?"child":"daemon"}function Wt(e){if(e instanceof Error)return e.message;if("string"==typeof e)return e;if("object"==typeof e&&null!==e){let t=e.message;if("string"==typeof t)return t;let n=e.error;if(void 0!==n)return Wt(n)}return String(e)}function Gt(e){return e.list_sessions??e.result}function Kt(e){if(void 0!==e.error)return null;let t=Gt(e);return void 0===t||"kind"in t&&"error"===t.kind?null:"data"in t?t.data.sessions:t.sessions}function Jt(e){if("live_unresponsive"===e.reason)return"live_unresponsive";if(void 0!==e.error)return Wt(e.error);let t=Gt(e);return void 0===t?"host unavailable":"kind"in t&&"error"===t.kind?Wt(t.error):null}function Ht(e,t){return"string"==typeof e&&e.length>0?e:t}function Vt(e,t,n){let r=null===e.source_host?null:{kind:t?.endpoint_kind??"rpc_host",socket:e.source_host,routing_id:null};return{durable_id:e.durable_id,routing_id:null,name:e.name,cwd:e.cwd,status:"resumable",liveness:"resumable",source_host:e.source_host,session_path:e.session_path,created_at:e.created_at,updated_at:e.updated_at,thread_id:e.durable_id,...void 0===n?{}:{error_note:n},endpoint:r,surface:null===r?null:Ft(r.kind,void 0,r.socket),alive:!1,title:Bt(e.name,e.first_user_text)}}function Zt(e){return e.map(e=>({thread_id:e.thread_id,name:e.name??"",status:e.status,cwd:e.cwd,created_at:e.created_at,updated_at:e.updated_at}))}function Xt(e){return e.map(e=>({thread_id:e.thread_id,name:e.name??"",status:e.status,cwd:e.cwd,created_at:e.created_at,updated_at:e.updated_at,endpoint:e.endpoint,liveness:e.alive?"routable":"live_unresponsive"===e.error_note?"live_unresponsive":"dead"}))}function Qt(e){return`--${yt(e).replace(/^[/\\]/,"").replace(/[/\\:]/g,"-")}-`}function Yt(e){let t=Ut(e);return null===t?null:{durable_id:t.durable_id,name:t.name,cwd:t.cwd,created_at:t.created_at,updated_at:t.updated_at,session_path:e,source_host:null,...null===t.first_user_text?{}:{first_user_text:t.first_user_text}}}import{createHash as en}from"node:crypto";import{realpathSync as tn}from"node:fs";import{readdir as nn,readFile as rn}from"node:fs/promises";import{basename as on,dirname as un,join as sn}from"node:path";var an=/^[0-9a-f]{16}$/,dn=/^t-[0-9a-f]{16}\.sock$/;function cn(e){return dn.test(on(e))}function ln(e){return e.startsWith("\0")?e:sn(function(e){let t=[],n=e;for(;;)try{return sn(tn(n),...t.reverse())}catch{let r=un(n);if(r===n)return e;t.push(on(n)),n=r}}(un(e)),on(e))}function fn(e){return en("sha256").update(e,"utf8").digest("hex").slice(0,16)}async function pn(e){let t;try{t=await rn(e,"utf8")}catch{return}try{let e=JSON.parse(t);return"object"!=typeof e||null===e||Array.isArray(e)?void 0:e}catch{return}}async function mn(e,t){let n=await pn(e),r=n?.socket;if(void 0!==n&&"string"==typeof r&&""!==r)return function(e,t){return fn(ln(e))===t||fn(e)===t}(r,on(t))?{socket:r,record:n}:void 0}async function hn(e){let t=sn(e,"rpc-host-daemon");if(2!==(await pn(sn(t,"layout.json")))?.layout)return[];let n=(await nn(t,{withFileTypes:!0}).catch(()=>[])).filter(e=>e.isDirectory()&&an.test(e.name)).map(e=>sn(t,e.name)).sort();return await Promise.all(n.map(e=>async function(e){let t=await mn(sn(e,"endpoint.json"),e);if(void 0!==t)return{socket:t.socket,dir:e,identity:"endpoint",endpoint_kind:"tui"===t.record.endpoint_kind?"tui":"rpc_host",registry_version:"number"==typeof t.record.registry_version?t.record.registry_version:null};let n=await mn(sn(e,"settings.json"),e);if(void 0!==n)return{socket:n.socket,dir:e,identity:"settings",endpoint_kind:"rpc_host",registry_version:null};let r=await nn(sn(e,"generations")).catch(()=>[]);for(let t of r.sort()){let n=await mn(sn(e,"generations",t,"settings.json"),e);if(void 0!==n)return{socket:n.socket,dir:e,identity:"generation-settings",endpoint_kind:"rpc_host",registry_version:null}}return{socket:null,dir:e,identity:"unknown",endpoint_kind:"rpc_host",registry_version:null}}(e)))}function _n(e,t){if(cn(e))return"tui";let n=ln(e);return t.find(t=>null!==t.socket&&(t.socket===e||ln(t.socket)===n))?.endpoint_kind??"rpc_host"}function gn(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var yn=1500,vn=["host","status","--all","--include-workers","--json"],bn={observe:!0},wn=new Set(["get_protocol_info","list_sessions","get_state","get_messages","set_session_name","wake","subscribe","extension_ui_response"]);function kn(e=process.env){return function(e,t){for(let t of U){let n=e[t]?.trim();if(n)return n}return D(t,"rpc","rpc.sock")}(e,V({env:e}))}function xn(e,t){return Array.isArray(e)?e.flatMap(e=>gn(e)&&"string"==typeof e[t]&&""!==e[t]?[e[t]]:[]):[]}function $n(e){if(!gn(e)||!gn(e.session))return[];let t=e.session.path;return"string"==typeof t&&""!==t?[t]:[]}function An(e){let t,n=e?.trim().split("\n").filter(e=>""!==e.trim()).pop();if(void 0!==n){try{t=JSON.parse(n)}catch{return}return gn(t)&&Array.isArray(t.endpoints)?t.endpoints.flatMap(e=>gn(e)?[{socket:"string"==typeof e.socket&&""!==e.socket?e.socket:null,reachable:!0===e.reachable,session_paths:[...new Set([...xn(e.session_rows,"session_path"),...xn(e.claims,"session_path"),...$n(e.owner)])],..."tui"===e.endpoint_kind||"rpc_host"===e.endpoint_kind?{endpoint_kind:e.endpoint_kind}:{},..."boolean"==typeof e.alive?{alive:e.alive}:{},..."live_unresponsive"===e.reason||"dead"===e.reason?{reason:e.reason}:null===e.reason?{reason:null}:{}}]:[]):void 0}}function Sn(e){let t=gn(e)?e.code:void 0;return"ENOENT"===t||"ECONNREFUSED"===t}function On(e){if(!0===e.success&&gn(e.data)&&!0===e.data.released&&"string"==typeof e.data.session_path)return{success:!0,data:e.data};let t="string"==typeof e.error?e.error:"release_failed";return gn(e.errorData)?{success:!1,error:t,errorData:e.errorData}:{success:!1,error:t}}var In=new Set(["started","queued","steered","turn_conflict","held_draft","already_admitted"]);function En(e){return Array.isArray(e.admitted)?{admitted:e.admitted.flatMap(e=>gn(e)&&"string"==typeof e.delivery_id&&"string"==typeof e.kind&&In.has(e.kind)?[{delivery_id:e.delivery_id,kind:e.kind}]:[])}:{admitted:[]}}function Rn(e,t={}){let n,r=t.env??process.env,i=t.exists??L,o=t.connect??(e=>N(e)),u=t.now??Date.now,s=t.statusAll??function(e){return async()=>{let t;try{t=at({...e})}catch{return}return An(await new Promise(n=>{C(t.command,[...t.prefixArgs,...vn],{env:ft({...e},t),timeout:3e4,maxBuffer:16777216,windowsHide:!0},(e,t)=>n("string"==typeof t?t:void 0))}))}}(r),a=t.registry??(()=>hn(V({env:r}))),d=t.readSecret??(e=>B(function(e){return`${e}.secret`}(e))),c=kn(t.env),l=new Map,f=new Map,p=async(e,t,n={},r)=>{let u,s="tui"===(e=>f.get(z(e))??(cn(e)?"tui":"rpc_host"))(e);if(s&&!wn.has(t))throw Error(`unsupported:${t}`);if(!i(e))throw Error(`host_unavailable:${e}`);if(s)try{u=d(e)}catch{throw Error(`host_unavailable:${e}`)}return await async function(e,t,n,r={}){let i=j();return await new Promise((o,u)=>{let s=n(e),a="",d=setTimeout(()=>{s.destroy(),u(Error("thread RPC request timed out"))},r.timeoutMs??6e4),c=(e,t)=>{clearTimeout(d),s.destroy(),void 0===e?o(t):u(e)};s.once("error",e=>c(e)),s.once("close",()=>c(Error(`thread RPC connection closed before the ${String(t.type)} response arrived`))),s.once("connect",()=>{void 0!==r.secret&&s.write(Buffer.from(r.secret)),s.write(`${JSON.stringify({...t,id:i})}\n`)}),s.on("data",e=>{a+=e.toString("utf8");let t=a.indexOf("\n");for(;t>=0;){let e,n=a.slice(0,t);if(a=a.slice(t+1),t=a.indexOf("\n"),""!==n.trim()){try{e=JSON.parse(n)}catch(e){return void c(e instanceof Error?e:Error(String(e)))}if(gn(e)&&e.id===i)return void c(void 0,e)}}})})}(e,{type:t,...n},o,{timeoutMs:r??(s?yn:void 0),secret:u})},m=async(e,t,n={},r)=>function(e,t){if(!1===e.success&&"set_thinking_level"===t&&"string"==typeof e.error&&/^Thinking level .+ is not supported by the active model\.$/.test(e.error))throw Error(`thinking_level_unsupported:${e.error}`);if(!1===e.success&&"unsupported"===e.error)throw Error(`unsupported:${String(t)}`);if(e.success&&void 0===e.data&&("set_session_name"===t||"set_thinking_level"===t))return{};if(!e.success||!gn(e.data))throw Error(`thread RPC request failed: ${JSON.stringify(e.error??e)}`);return e.data}(await p(e,t,n,r),t),h=(e,t={})=>m(c,e,t),_=async()=>{let[e,t]=await Promise.all([s().catch(()=>{}),a().catch(()=>[])]),n=void 0===e?t.flatMap(e=>null===e.socket?[]:[{socket:e.socket,paths:[],kind:e.endpoint_kind,verdict:{}}]):e.flatMap(e=>null===e.socket?[]:[{socket:e.socket,paths:e.session_paths,kind:e.endpoint_kind??_n(e.socket,t),verdict:{...void 0===e.alive?{}:{alive:e.alive},...void 0===e.reason?{}:{reason:e.reason}}}]),r=e=>z(e.socket)===z(c),i=[...new Set(n.filter(r).flatMap(e=>e.paths))];return[{socket:c,paths:i,kind:_n(c,t),verdict:{}},...n.filter(e=>!r(e))]},g=async()=>{(void 0===n||n.expiresAt<=u())&&(n={expiresAt:u()+5e3,endpoints:_()});let e=await n.endpoints;for(let t of e)f.set(z(t.socket),t.kind);return e},y=(e,t,n)=>{let r=[...new Set([...e.paths,...l.get(e.socket)??[]])].flatMap(t=>{let n=function(e,t){let n;try{n=ht(e,"utf8")}catch{return null}let r=Ut(e);if(null===r)return null;let{name:i,first_user_text:o}=Dt(zt(n));return{durable_id:r.durable_id,name:i,cwd:r.cwd,created_at:r.created_at,updated_at:r.updated_at,session_path:e,source_host:t,...null===o?{}:{first_user_text:o}}}(t,e.socket);return null===n?[]:[n]});return{host:{socket:e.socket,error:t instanceof Error?t.message:String(t),endpoint_kind:e.kind,alive:!1,reason:n,legacy:e.socket===c},sessions:[],disk:r,failure:t}},v=async e=>{let t="tui"===e.kind;if(t&&!1===e.verdict.alive)return y(e,Error(e.verdict.reason??"live_unresponsive"),e.verdict.reason??"live_unresponsive");try{let{sessions:n}=await m(e.socket,"list_sessions",t?{}:bn,t?yn:1e4),r=n.map(n=>({...n,socket:e.socket,endpoint_kind:e.kind,...t&&void 0===n.durableSessionId?{durableSessionId:n.sessionId}:{}}));return l.set(e.socket,r.flatMap(e=>"string"==typeof e.sessionPath?[e.sessionPath]:[])),{host:{socket:e.socket,list_sessions:{sessions:r},endpoint_kind:e.kind,alive:!0,reason:null,legacy:e.socket===c},sessions:r,disk:[]}}catch(n){if(t&&!i(e.socket))return y(e,Error("dead"),"dead");let r=n instanceof Error&&"thread RPC request timed out"===n.message;return y(e,n,e.verdict.reason??(r?"live_unresponsive":Sn(n)?"dead":null))}},b=async(e={})=>{let t=await g(),n=await Promise.all(t.map(e=>v(e)));for(let e of[...l.keys()])t.some(t=>t.socket===e)||l.delete(e);if(!0!==e.offline&&n.every(e=>void 0!==e.failure))throw n[0]?.failure;return{sessions:n.flatMap(e=>e.sessions),hosts:n.map(e=>e.host),disk:n.flatMap(e=>e.disk)}},w=(e,t)=>({getMessages:async e=>(await t("get_messages",{sessionId:e})).messages,getState:e=>t("get_state",{sessionId:e}),prompt:(e,n,r)=>t("prompt",{sessionId:e,message:n,...r}),interrupt:(e,n)=>t("interrupt",{sessionId:e,...void 0===n?{}:{turnId:n}}),setSessionName:async(e,n)=>{await t("set_session_name",{sessionId:e,name:n})},setModel:(e,n,r)=>t("set_model",{sessionId:e,provider:n,modelId:r}),getAvailableModels:async e=>{let{models:n}=await t("get_available_models",{sessionId:e});return n.map(({provider:e,id:t,name:n})=>({provider:e,id:t,...void 0===n?{}:{name:n}}))},setThinkingLevel:async(e,n,r)=>{await t("set_thinking_level",{sessionId:e,level:n,..."turn"===r?{scope:r}:{}})},getAvailableThinkingLevels:async e=>(await t("get_available_thinking_levels",{sessionId:e})).levels,wake:async(e,n)=>En(await t("wake",{sessionId:e,delivery_ids:[...n]})),releaseSession:async(t,n)=>On(await p(e??c,"release_session",{sessionId:t,...n}))});return{socket:c,listTarget:async(e,t)=>{f.set(z(t.socket),t.kind);let r=("tui"===t.kind&&void 0!==n&&n.expiresAt>u()?await n.endpoints:void 0)?.find(e=>z(e.socket)===z(t.socket))?.verdict,i=await v({socket:t.socket,paths:[],kind:t.kind,verdict:r??{}}),o=i.sessions.filter(t=>(t.durableSessionId??t.sessionId)===e&&"closed"!==t.status);return{sessions:o,hosts:[void 0===i.failure?{...i.host,list_sessions:{sessions:o}}:i.host],disk:[]}},listSessions:async()=>(await b()).sessions,listView:b,endpoint:e=>w(e,(t,n)=>m(e,t,n)),gateway:{wake:async(e,t)=>{f.set(z(e.socket),e.kind);let n="rpc_host"===e.kind&&null!==e.routing_id?{sessionId:e.routing_id}:{};return En(await m(e.socket,"wake",{...n,delivery_ids:[...t]}))},releaseSession:async(e,t)=>{if("rpc_host"!==e.kind||null===e.routing_id)throw Error("unsupported:release_session");return On(await p(e.socket,"release_session",{sessionId:e.routing_id,...t}))},classifyLiveness:async e=>{let t=(await g()).find(t=>z(t.socket)===z(e.socket));if(!0===t?.verdict.alive)return"routable";if("live_unresponsive"===t?.verdict.reason||"dead"===t?.verdict.reason)return t.verdict.reason;try{return await m(e.socket,"get_protocol_info",{},"tui"===e.kind?yn:1e4),"routable"}catch(e){return e instanceof Error&&e.message.startsWith("host_unavailable:")||Sn(e)?"dead":"live_unresponsive"}},respondUi:async(e,t)=>(f.set(z(e.socket),e.kind),await async function(e,t,n){let r="rpc_host"===t.kind&&null!==t.routing_id?{sessionId:t.routing_id}:{},i=await e(t.socket,"extension_ui_response",{...r,uiRequestId:n.ui_request_id,...n.fields});return!0===i.success?{delivered:!0}:{delivered:!1,error:"string"==typeof i.error?i.error:"refused"}}(p,e,t))},openSession:async e=>{let t=await h("open_session",{...e,retain_on_disconnect:!0}),n=t.sessionId,r=e.name;void 0!==r&&""!==r.trim()&&await h("set_session_name",{sessionId:n,name:r});let{sessions:i}=await h("list_sessions",bn),o=i.find(e=>e.sessionId===n);return{...t.state,...o??{},sessionId:n,socket:c,endpoint_kind:"rpc_host"}},...w(void 0,h)}}import{createHash as Pn,randomUUID as qn}from"node:crypto";var Mn={not_steerable:{code:"not_steerable",next:"Send with delivery auto or follow_up; a steer needs a running turn."},turn_conflict:{code:"turn_conflict",next:"Read the target again and retry with its current turn id, or send with delivery auto."},expired:{code:"not_resumable",next:"The target did not take the message within its lifetime; send it again if it still matters."},binding_closed:{code:"invalid_arguments",next:"The binding this message was queued under was detached or rebound; re-read the binding and send again."}};function Tn(e,t,n,r,i){let o={kind:"ok",thread_id:e.target_durable_id,delivery_id:e.delivery_id,message_seq:e.seq,effective_mode:e.mode_effective??e.mode_requested,endpoint_kind:n,deduplicated:r};if("admitted"===e.state||"applied"===e.state)return"started"===e.admission_kind||"steered"===e.admission_kind?{...o,delivery:{kind:e.admission_kind,turn_id:String(e.turn_epoch??0)}}:{...o,delivery:{kind:"queued",queue_position:Math.max(t,1)}};if("refused"===e.state){let t=Mn[e.reason??""]??{code:"internal_error",next:"Call thread_list and check the target."};return{kind:"error",error:h(t.code,`Delivery ${e.delivery_id} was refused: ${e.reason??"unknown"}.`,t.next,{delivery_id:e.delivery_id})}}return"uncertain"===e.state?{kind:"error",error:h("idempotency_uncertain",`Delivery ${e.delivery_id} may or may not have reached the target.`,"Read the target transcript before deciding whether to send again.",{delivery_id:e.delivery_id})}:{...o,delivery:{kind:i?"queued_offline":"queued",queue_position:Math.max(t,1)}}}var Cn={loop_detected:"Stop relaying here: a direct reply to the session that messaged you is a cycle. That session reads your answer with thread_read; a bound external thread gets it through thread_report, and its questions come back through thread_answer.",overloaded:"Wait before sending to this session again.",queue_full:"Wait for the target to take its queued messages, then send again.",idempotency_conflict:"Retry with a new idempotency_key.",idempotency_in_progress:"Wait for the earlier call to settle, then retry.",idempotency_uncertain:"Read the target transcript before deciding whether to send again; the gateway never resends.",invalid_arguments:"Fix the arguments and send again."};function Nn(e,t,n){return{kind:"error",error:h(e,t,Cn[e]??"Call thread_list and retry after checking the target.",n)}}function jn(e){return t={target:e.target,text:e.text,mode:e.mode,expected_turn_id:e.expected_turn_id,binding:e.binding,author:e.author},Pn("sha256").update(JSON.stringify(t)).digest("hex");var t}function Ln(e){return"object"==typeof e&&null!==e&&"gateway_lock_wait_exceeded"===e.code}var Bn=/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/;function zn(e){return{kind:"refused",code:"invalid_arguments",message:e}}function Dn(e,t,n){return"string"!=typeof t||0===t.trim().length?zn(`author.${e} must be a non-empty string.`):t.length>n?zn(`author.${e} is longer than ${n} characters.`):Bn.test(t)?zn(`author.${e} carries a control character or line break.`):t.trim()}var Un={binding_conflict:"Call thread_bindings to find the binding that holds this thread, then thread_rebind it with its revision, or thread_unbind it first.",binding_mismatch:"Answer through the binding that asked the question; the question stays pending.",binding_inactive:"Bind the thread again with thread_bind.",stale_revision:"Call thread_bindings for the current revision and retry with it.",stale_token:"The question was asked under an earlier binding revision or session runtime; wait for the session to ask again.",already_answered:"Nothing to do: the question has its answer.",answer_in_progress:"Retry after a moment: another answer is still being handed to the session, and the question goes back to pending if that fails.",idempotency_conflict:"Retry with a new idempotency_key.",idempotency_uncertain:"Call thread_bindings or thread_outbox to see the current state before retrying with a new key.",scope_denied:"Report through a binding attached to this session; thread_bindings lists them.",unsupported:"Report only the events the binding subscribes to, through a binding with an outbound direction.",not_found:"Call thread_bindings for the binding ids that exist.",cursor_invalid:"Read thread_outbox again and ack a cursor it returned.",host_unavailable:"Retry when the session is running; the question stays pending.",invalid_arguments:"Fix the arguments and call again."},Fn=new Set(["question_already_resolved","unknown_extension_ui_request","unknown_request"]);function Wn(e,t,n,r){return{kind:"error",error:h(e,t,r??Un[e]??"Call thread_bindings and retry after checking the binding.",n)}}function Gn(e){return"refused"===e.kind?Wn(e.code,e.message,e.details):e}function Kn(e){if(void 0===e)return;let t=function(e){let t=Dn("platform_user_id",e.platform_user_id,256);if("string"!=typeof t)return t;let n=Dn("display",e.display,256);if("string"!=typeof n)return n;if(void 0===e.user_id)return{platform_user_id:t,display:n};let r=Dn("user_id",e.user_id,256);return"string"!=typeof r?r:{platform_user_id:t,display:n,user_id:r}}(e);return"kind"in t?Wn("invalid_arguments",t.message):t}function Jn(e){let t=Buffer.byteLength(e);return t>E?Wn("message_too_large",`The text is ${t} bytes, above the 32768-byte limit.`):void 0}function Hn(e,t,n){return void 0===e.idempotency_key?null:{principal:e.principal,operation:t,idempotency_key:e.idempotency_key,args_hash:(r=n,w("sha256").update(T(r)).digest("hex"))};var r}function Vn(e){let t=e.store,n=e.now??t.now,r=new Set,i=!1;async function o(e){await u(()=>t.releaseAnswer(e))}async function u(e){try{await e()}catch(n){if(!Ln(n)||i)throw n;let o=function(e,t,n){let r,i=!1,o=()=>{r=setTimeout(()=>{r=void 0,i||e().catch(e=>{i||(Ln(e)?o():n(e))})},t()),r.unref?.()};return o(),{cancel:()=>{i=!0,clearTimeout(r)}}}(()=>e().then(()=>{r.delete(o)}),()=>t.busyTimeoutMs,()=>{r.delete(o)});r.add(o)}}return{bind:async e=>{let r=function(e){if(!A.includes(e.platform))return R(`platform must be one of ${A.join(", ")}.`);let t={account_id:P("account_id",e.account_id),chat_id:P("chat_id",e.chat_id),thread_id:P("thread_id",e.thread_id??"@chat"),root_message_id:q("root_message_id",e.root_message_id),progress_message_id:q("progress_message_id",e.progress_message_id),session_durable_id:P("session",e.session_durable_id),policy_id:P("policy_id",e.policy_id??"default")};for(let e of Object.values(t))if(M(e))return e;let n=e.direction??{inbound:!0,outbound:!0};if(!0!==n.inbound&&!0!==n.outbound)return R("A binding needs at least one direction: inbound, outbound, or both.");let r=e.inbound_mode??"auto";if(!O.includes(r))return R(`inbound_mode must be one of ${O.join(", ")}.`);let i=e.outbound_events??(n.outbound?S:[]);if(i.some(e=>!S.includes(e)))return R(`outbound_events may only name ${S.join(", ")}.`);if(new Set(i).size!==i.length)return R("outbound_events must not repeat an event.");if(n.outbound&&0===i.length)return R("An outbound binding needs at least one outbound event.");let o=void 0===e.ttl_seconds?604800:e.ttl_seconds;return null!==o&&(!Number.isInteger(o)||o<1||o>I)?R("ttl_seconds must be an integer from 1 to 31622400, or null for a binding that never expires."):{platform:e.platform,account_id:t.account_id,chat_id:t.chat_id,thread_id:t.thread_id,root_message_id:t.root_message_id,progress_message_id:t.progress_message_id,session_durable_id:t.session_durable_id,direction:{inbound:!0===n.inbound,outbound:!0===n.outbound},inbound_mode:r,outbound_events:S.filter(e=>i.includes(e)),policy_id:t.policy_id,ttl_seconds:o}}(e.binding);return Gn("kind"in r?r:await t.bind({now:n(),receipt:Hn(e,"thread_bind",r),binding:r}))},unbind:async e=>{let r={binding_id:e.binding_id,expected_revision:e.expected_revision};return Gn(await t.unbind({now:n(),receipt:Hn(e,"thread_unbind",r),...r}))},rebind:async e=>{let r={binding_id:e.binding_id,expected_revision:e.expected_revision,session_durable_id:e.session_durable_id};return Gn(await t.rebind({now:n(),receipt:Hn(e,"thread_rebind",r),...r}))},bindings:async e=>Gn(await t.listBindings({now:n(),...e})),report:async e=>{let r=Jn(e.text);if(void 0!==r)return r;let i={session_durable_id:e.session_durable_id,binding_id:e.binding_id??null,origin_delivery_ids:e.origin_delivery_ids??[],origin_local_input:!0===e.origin_local_input,event:e.event,text:e.text,ui_request_id:e.request_id??null,ui_request_kind:e.request_kind??null};return Gn(await t.report({now:n(),receipt:Hn(e,"thread_report",i),...i}))},outbox:async e=>Gn(await t.readOutbox({now:n(),...e})),ack:async e=>Gn(await t.ackOutbox({now:n(),...e})),answer:async r=>{let i=Jn(r.answer);if(void 0!==i)return i;let s=Kn(r.author);if(void 0!==s&&"kind"in s)return s;let a=s??null,d=await t.claimAnswer({now:n(),binding_id:r.binding_id,reply_token:r.reply_token,answer:r.answer,answered_by:a});if("ok"!==d.kind)return Gn(d);let c={reply_token:r.reply_token,claimed_at:d.claimed_at},l=e.endpoints.respondUi,f=null,p="";if(void 0!==l)try{f=await e.locate(d.session_durable_id)}catch(e){p=`: ${e instanceof Error?e.message:String(e)}`}if(void 0===l||null===f)return await o(c),Wn(void 0===l?"unsupported":"host_unavailable",`The session that asked is not reachable to take the answer${p}.`,{session:d.session_durable_id});let m,h=b(d.ui_request_kind,r.answer);if(!h.ok)return await o(c),Wn("invalid_arguments",h.reason,{session:d.session_durable_id,ui_request_kind:d.ui_request_kind});try{m=await l(f,{ui_request_id:d.ui_request_id,fields:h.fields})}catch(e){return await o(c),Wn("host_unavailable",`The answer could not be handed to the session: ${e instanceof Error?e.message:String(e)}`,{session:d.session_durable_id})}if(!m.delivered){let e=d.taken_over;if(null!==e&&Fn.has(m.error))return"question_already_resolved"===m.error?(await u(()=>t.markPriorDelivered({...c,prior:e})),Wn("already_answered",`The session already took an earlier answer to this question (${m.error}).`,{session:d.session_durable_id,reason:m.error})):(await u(()=>t.markPriorDelivered({...c,prior:{answer:null,answered_at:c.claimed_at}})),Wn("already_answered",`The session no longer waits for this question (answered or closed elsewhere) (${m.error}).`,{session:d.session_durable_id,reason:m.error},"Nothing to do: the session no longer waits for this question."));await o(c);let n="invalid_response"===m.error||"question_incomplete"===m.error;return Wn(n?"invalid_arguments":"stale_token",`The session refused the answer: ${m.error}`,{session:d.session_durable_id,reason:m.error},n?`The session could not read this answer (${m.error}); answer again with text it can take. The question stays pending.`:`The session refused the answer (${m.error}): it no longer waits on this question. Read thread_outbox for a newer question and answer that one.`)}return await async function(e){await u(()=>t.confirmAnswer(e))}({...c,answer:r.answer,answered_by:a}),{kind:"ok",binding_id:r.binding_id,cursor:d.cursor,session_durable_id:d.session_durable_id,answered_by:a}},inbound:async r=>{if(void 0!==r.mode&&!O.includes(r.mode))return Wn("invalid_arguments",`A binding message is delivered as ${O.join(" or ")}, never ${String(r.mode)}.`,{mode:r.mode},"Send with mode auto or follow_up, or omit it for the binding's inbound_mode.");let i=Kn(r.author);if(void 0!==i&&"kind"in i)return i;let o=await t.bindingView({now:n(),binding_id:r.binding_id});if(null===o)return Wn("not_found","No binding has this id.",{binding_id:r.binding_id});let u={principal:`binding:${o.binding_id}`,idempotency_key:`event:${r.event_id}`},s=await t.deliveryReceipt({now:n(),...u});if(null!==s&&null!==s.binding_revision&&s.args_hash===jn({target:s.target_durable_id,text:r.text,mode:r.mode??o.inbound_mode,expected_turn_id:null,binding:{binding_id:o.binding_id,revision:s.binding_revision},author:i})){let e=s.completed?{kind:"replay",result:s.result}:await t.recoverDelivery({now:n(),...u,args_hash:s.args_hash});if("replay"===e?.kind){let t=e.result;return"ok"===t.kind?{...t,deduplicated:!0}:t}if("refused"===e?.kind)return Wn(e.code,e.message,e.details)}if("active"!==o.status)return Wn("binding_inactive",`The binding is ${o.status}.`,{binding_id:o.binding_id,status:o.status});if(!o.direction.inbound)return Wn("unsupported","The binding carries no inbound direction.",{binding_id:o.binding_id});let a=r.mode??o.inbound_mode;return"auto"===a&&"follow_up"===o.inbound_mode?Wn("invalid_arguments","The binding delivers at most follow_up; a message cannot ask for more than its binding's inbound_mode.",{binding_id:o.binding_id,mode:a,inbound_mode:o.inbound_mode},"Send with mode follow_up (or omit it), or rebind the thread with inbound_mode auto."):await e.engine.deliver({sender:{kind:"external",origin:{platform:o.platform,account_id:o.account_id,chat_id:o.chat_id,thread_id:o.thread_id,message_id:r.event_id,...void 0===i?{}:{author:i}},binding_id:o.binding_id,binding_revision:o.revision},target:o.session_durable_id,text:r.text,mode:a,all_scope:!0,idempotency_key:`event:${r.event_id}`})},settle:e=>t.emitCompletions({now:n(),...e}),dispose:()=>{i=!0;for(let e of r)e.cancel();r.clear()}}}var Zn="unknown-caller";async function Xn(e,t,n){let r=await e.store.sessionOwner(t);return null===r?await n():null===r.endpoint||void 0===e.host.listTarget?{sessions:[],hosts:[],disk:[]}:await e.host.listTarget(t,r.endpoint)}async function Qn(e,t={}){if(void 0!==e.host.listView)return await e.host.listView(t);let n;try{n=await e.host.listSessions()}catch(n){if(!0!==t.offline)throw n;return{sessions:[],hosts:[{socket:e.host.socket,error:n}],disk:[]}}return{sessions:n,hosts:[{socket:e.host.socket,list_sessions:{sessions:n}}],disk:[]}}function Yn(e,t,n=[]){return function(e,t,n={}){let r=n.assembled_at??(new Date).toISOString(),i=new Map,o=new Map,u=new Map(e.map(e=>[e.socket,e]));for(let t of e){let e=Jt(t);null!==e&&o.set(t.socket,e)}for(let e of t){if(0===e.durable_id.length)continue;let t=null===e.source_host?void 0:o.get(e.source_host);i.set(e.durable_id,Vt(e,null===e.source_host?void 0:u.get(e.source_host),t))}for(let t of e){let e=Kt(t);if(null!==e)for(let o of e){if("closed"===o.status)continue;let e=o.durableSessionId??("tui"===t.endpoint_kind?o.sessionId:void 0);if("string"!=typeof e||0===e.length)continue;let u=i.get(e),s=o.sessionPath??u?.session_path??null,a={name:o.name??null,created:o.created_at??o.createdAt,updated:o.updated_at??o.updatedAt},d=null!==a.name&&"string"==typeof a.created&&"string"==typeof a.updated||null===s?null:n.facts?.(s)??null,c=Ht(a.created,d?.created_at??u?.created_at??r),l=Ht(a.updated,null===d?u?.updated_at??null:d.updated_at),f=a.name??u?.name??d?.name??null;i.set(e,{durable_id:e,routing_id:o.sessionId,name:f,cwd:o.cwd,status:"live",liveness:"live",source_host:t.socket,session_path:s,created_at:c,updated_at:l,thread_id:e,endpoint:{kind:t.endpoint_kind??"rpc_host",socket:t.socket,routing_id:o.sessionId},surface:Ft(t.endpoint_kind,o.kind,t.socket),alive:!1!==t.alive,title:Bt(f,d?.first_user_text)??u?.title??null})}}return[...i.values()].sort((e,t)=>e.updated_at!==t.updated_at?null===e.updated_at?1:null===t.updated_at?-1:e.updated_at<t.updated_at?1:-1:e.durable_id.localeCompare(t.durable_id))}(t.hosts,[...e.diskSessions?.()??[],...t.disk,...n],{facts:Ut})}function er(e,t,n,r){let i=Yn(e,t),o=e.sessionsDirectory?.();if(void 0===o||"self"===n)return i;let u=new Set(i.map(e=>e.durable_id));if(u.has(n))return i;let s=e.callerWorkspaceRoot(),a=Rt(Zt(i),n,{all_scope:r,callerWorkspaceRoot:s}),d="error"!==a.kind||"not_found"!==a.code,c=function(e,t,n={}){let r;try{r=mt(e,{withFileTypes:!0}).filter(e=>(e.isDirectory()||e.isSymbolicLink())&&/^--.*--$/.test(e.name)).map(e=>e.name)}catch{return[]}let i=new Map,o=t=>{let n=i.get(t);if(void 0===n){try{n=mt(gt(e,t)).filter(e=>e.endsWith(".jsonl"))}catch{n=[]}i.set(t,n)}return n},u=`_${t}.jsonl`,s=r.flatMap(n=>o(n).flatMap(r=>{if(!r.endsWith(u))return[];let i=Yt(gt(e,n,r));return null!==i&&i.durable_id===t?[i]:[]}));if(s.length>0||!0===n.id_only)return s;let a=kt(t);if(0===a.length)return[];let d=!0===n.all_scope?void 0:(n.workspaceRoots??[]).map(Qt);return(void 0===d?r:r.filter(e=>d.some(t=>e.startsWith(t)))).flatMap(t=>o(t).flatMap(n=>{let r=Yt(gt(e,t,n));return null!==r&&null!==r.name&&kt(r.name)===a?[r]:[]}))}(o,n,{all_scope:r,workspaceRoots:Et(s),id_only:d}).filter(e=>!u.has(e.durable_id));return 0===c.length?i:Yn(e,t,c)}function tr(e){return{sessionId:e.durable_id,durableSessionId:e.durable_id,...null===e.session_path?{}:{sessionPath:e.session_path},...null===e.source_host?{}:{socket:e.source_host},cwd:e.cwd,thread_id:e.thread_id,name:e.title??"",status:"resumable",created_at:e.created_at,updated_at:e.updated_at,endpoint:e.endpoint,surface:e.surface,alive:e.alive,...void 0===e.error_note?{}:{error_note:e.error_note}}}function nr(e,t){return Zt(Yn(e,t))}function rr(e,t,n,r,i){if("self"===n){let e=r===Zn?void 0:t.find(e=>e.thread_id===r);if(void 0===e)return{kind:"error",...h("caller_context_missing","The caller's durable session id is not in the thread address book.","Call thread_list and pass an explicit thread_id, or retry from a session with caller context.")};n=e.thread_id}return Rt(t,n,{all_scope:i,callerWorkspaceRoot:e.callerWorkspaceRoot()})}function ir(e){return"user"===e||"assistant"===e?e:"toolResult"===e?"tool":"system"}var or={wake:async e=>{throw Error(`host_unavailable:${e.socket}`)}};function ur(e,t){let n=e.store,r=e.now??n.now,i=e.host.gateway??or,o=function(e){let t=e.store,n=e.now??t.now;return{deliver:async function(r){let i=r.mode??"auto";if("steer"===i&&void 0===r.expected_turn_id)return Nn("invalid_arguments","A steer needs expected_turn_id (the target's current turn_epoch).");let o=Buffer.byteLength(r.text);if(o>d)return Nn("message_too_large",`The message is ${o} bytes, above the 1048576-byte limit.`);let u=await e.resolve(r.target,{all_scope:r.all_scope});if("error"===u.kind)return u;let s=u.target,a="routable"===s.liveness?s.endpoint:null;if(null===a&&"refuse"===function(e,t,n,r){return"offline"===e?"steer"===t?{kind:"refuse",reason:"turn_conflict"}:{kind:"queued_offline"}:"steer"===t?"mid_turn"!==e?{kind:"refuse",reason:"not_steerable"}:null===n||null===r||n!==r?{kind:"refuse",reason:"turn_conflict"}:{kind:"admit",deliverAs:"steer",expected_turn_id:n,expect:"steered"}:{kind:"admit",deliverAs:"followUp",expect:"idle"===e?"started":"queued"}}("offline",i,r.expected_turn_id??null,null).kind)return Nn("turn_conflict","The target has no live turn to steer.",{target:s.durable_id});let c=function(e){if("session"===e.kind)return{principal:`session:${e.durable_id}`,rate_principal:`session:${e.durable_id}`,node:e.durable_id,turn:e.turn_id??null,cause:e.cause_delivery_id??null,actor:e.name??e.durable_id,origin:()=>({session:e.durable_id}),binding:null};if("cli"===e.kind){let t=`cli:${e.uid}`;return{principal:t,rate_principal:t,node:t,turn:null,cause:null,actor:e.user,origin:t=>({external:{platform:"cli",account_id:e.user,chat_id:"@cli",thread_id:"@chat",message_id:t}}),binding:null}}let t=`binding:${e.binding_id}`,n=e.origin.author;return{principal:t,rate_principal:void 0===n?t:`${t}#author:${n.platform_user_id}`,node:t,turn:null,cause:null,actor:e.origin.account_id,origin:()=>({external:e.origin}),binding:{binding_id:e.binding_id,revision:e.binding_revision}}}(r.sender),l=qn(),f=r.idempotency_key??`auto:${l}`,p=await t.enqueue({now:n(),delivery_id:l,target_durable_id:s.durable_id,sender_principal:c.principal,rate_principal:c.rate_principal,sender_node:c.node,sender_turn:c.turn,cause_delivery_id:c.cause,claimed_root_id:r.root_id??null,origin:c.origin(l),actor:c.actor,body:r.text,mode:i,expected_turn_id:r.expected_turn_id??null,binding:c.binding,receipt:{idempotency_key:f,args_hash:jn({target:s.durable_id,text:r.text,mode:i,expected_turn_id:r.expected_turn_id??null,binding:c.binding,author:"external"===r.sender.kind?r.sender.origin.author:void 0})},endpoint_kind:a?.kind??null});if("busy"===p.kind)return Nn("overloaded","The gateway store is locked by a suspended writer; nothing was sent.",{budget:"store_lock"});if("refused"===p.kind)return Nn(p.code,p.message,p.details);if("replay"===p.kind){let e=p.result;return"ok"===e.kind?{...e,deduplicated:!0}:e}let m=async e=>(await t.completeReceipt({now:n(),principal:c.principal,idempotency_key:f,result:e}),e);try{if(null===a)return await m(Tn(p.row,p.queue_position,null,!1,!0));let n=!0;try{await e.endpoints.wake(a,[l])}catch{n=!1}let r=await t.deliveryView(l);if(null===r)throw Error(`delivery ${l} vanished after commit`);return await m(Tn(r.row,r.queue_position,a.kind,!1,!n))}catch(e){throw await t.abandonReceipt({now:n(),principal:c.principal,idempotency_key:f,error_note:e instanceof Error?e.message:String(e)}).catch(()=>!1),e}}}}({store:n,endpoints:i,resolve:async(n,r)=>{let i=await Xn(e,n,t);return await function(e,t){return async(n,r)=>{let i=Rt(await e(),n,{all_scope:r.all_scope,callerWorkspaceRoot:t()});if("ok"!==i.kind){let e=void 0===i.candidates?void 0:{candidates:i.candidates};return{kind:"error",error:h(i.code,i.message,i.next_action,e)}}let o=i.entry;return{kind:"ok",target:{durable_id:o.thread_id,endpoint:o.endpoint,liveness:o.liveness}}}}(()=>Xt(er(e,i,n,r.all_scope)),e.callerWorkspaceRoot)(n,r)},now:r}),u=async n=>{let r=(await(async()=>Xt(Yn(e,await t())))()).find(e=>e.thread_id===n);return void 0===r||"routable"!==r.liveness?null:r.endpoint};return{store:n,endpoints:i,engine:o,relay:Vn({store:n,engine:o,endpoints:i,locate:u,now:r}),locate:u}}import{closeSync as sr,openSync as ar,readSync as dr}from"node:fs";import{StringDecoder as cr}from"node:string_decoder";var lr={assign:0,create:0,clone:0,discard:0,update:0};function fr(e){let t=0,n=0,r=0;for(;n<e.length;){let i=e.charCodeAt(n++)>>10;t+=+(13879!=(r<<8|i)),r=i}return t}function pr(e){return Array.isArray(e)}function mr(e){return Sr(typeof e,"bigint")}function hr(e){return Sr(typeof e,"boolean")}function _r(e){if(Ar(e)||!gr(e))return!1;let t=Function.prototype.toString.call(e);return!!/^class\s/.test(t)||!!/\[native code\]/.test(t)}function gr(e){return Sr(typeof e,"function")}function yr(e){return Number.isInteger(e)}function vr(e){return Sr(e,null)}function br(e){return Number.isFinite(e)}function wr(e){return kr(e)&&!pr(e)}function kr(e){return Sr(typeof e,"object")&&!vr(e)}function xr(e){return Sr(typeof e,"string")}function $r(e){return Sr(typeof e,"symbol")}function Ar(e){return Sr(e,void 0)}function Sr(e,t){return e===t}function Or(e,t){return e>t}function Ir(e,t){return e<t}function Er(e,t){return e<=t}function Rr(e,t){return e>=t}function Pr(e){return mr(e)||hr(e)||vr(e)||br(e)||xr(e)||Ar(e)}function qr(e,t){return function(e,t){return e.length<=t||e.length<=t<<1&&fr(e)<=t}(e,t)}function Mr(e,t){return function(e,t){return e.length>=t<<1||e.length>=t&&fr(e)>=t}(e,t)}function Tr(e,t,n){return e.every((e,r)=>r<t||n(e,r))}function Cr(e,t,n){let r=!0;return e.forEach((e,i)=>{i>=t&&!n(e,i)&&(r=!1)}),r}function Nr(e,t){return e.some((e,n)=>t(e,n))}function jr(e,t){return e.reduce((e,n,r)=>t(n,r)?++e:e,0)}function Lr(e,t,n){return Sr(e.length,0)?n():t(e[0],e.slice(1))}function Br(e){return Sr(e,"__proto__")||Sr(e,"constructor")||Sr(e,"prototype")}function zr(e,t){return Br(t)?Object.prototype.hasOwnProperty.call(e,t):t in e}function Dr(e){return Fr(e).map(t=>[new RegExp(`^${t}$`),e[t]])}function Ur(e){return Object.entries(e)}function Fr(e){return Object.getOwnPropertyNames(e)}function Wr(e){return Object.values(e)}function Gr(e,t){return pr(e)?function(e,t){return pr(t)&&Sr(e.length,t.length)&&e.every((n,r)=>Gr(e[r],t[r]))}(e,t):kr(e)?function(e,t){if(!kr(t))return!1;let n=Fr(e);return Sr(n.length,Fr(t).length)&&n.every(n=>Gr(e[n],t[n]))}(e,t):Sr(e,t)}function Kr(e){return globalThis.ArrayBuffer.isView(e)}function Jr(e){return e instanceof globalThis.RegExp}var Hr={immutableTypes:!1,maxErrors:8,maxParseErrors:1,maxInstantiationCount:128,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1,unionPrioritySort:!0};function Vr(){return Hr}function Zr(e){return Vr().immutableTypes?Object.freeze(e):e}function Xr(e,t){return lr.assign+=1,Zr({...e,...t})}function Qr(e){let t={};for(let n of Fr(e))Br(n)||(t[n]=ei(e[n]));for(let n of function(e){return Object.getOwnPropertySymbols(e)}(e))t[n]=ei(e[n]);return t}function Yr(e){return function(e){if(!kr(e))return!1;let t=globalThis.Object.getPrototypeOf(e);return!vr(t)&&Sr(typeof t.constructor,"function")&&!(Sr(t.constructor,globalThis.Object)||Sr(t.constructor.name,"Object"))}(e)?e:function(e){return zr(e,"~kind")||zr(e,"~unsafe")}(e)?function(e){let t={};for(let n of Fr(e)){if(Br(n))continue;let r=Object.getOwnPropertyDescriptor(e,n);r.value=ei(r.value),Sr(r.enumerable,!0)?t[n]=r.value:Object.defineProperty(t,n,r)}return t}(e):Qr(e)}function ei(e){return Kr(e)?function(e){return e.slice()}(e):Jr(e)?function(e){return new RegExp(e.source,e.flags)}(e):function(e){return e instanceof globalThis.Map}(e)?function(e){return new Map(ei([...e.entries()]))}(e):function(e){return e instanceof globalThis.Set}(e)?function(e){return new Set(ei([...e.values()]))}(e):pr(e)?function(e){return e.map(e=>ei(e))}(e):kr(e)?Yr(e):e}function ti(e){return lr.clone+=1,ei(e)}function ni(e,t){return{...e,...t}}function ri(e,t,n={}){lr.create+=1;let r=ni(t,n);return Zr(Vr().enumerableKind?ni(r,e):function(e,t){for(let n of Object.keys(t))Object.defineProperty(e,n,{configurable:!0,writable:!0,enumerable:!1,value:t[n]});return e}(r,e))}function ii(e,t){lr.discard+=1;let n={};for(let r of Fr(e)){if(t.includes(r))continue;let i=Object.getOwnPropertyDescriptor(e,r);i.value=ti(i.value),Object.defineProperty(n,r,i)}return Zr(n)}function oi(e,t,n){lr.update+=1;let r=Vr(),i=ti(e);for(let e of Object.keys(t))Object.defineProperty(i,e,{configurable:!0,writable:!0,enumerable:r.enumerableKind,value:t[e]});for(let e of Object.keys(n))Object.defineProperty(i,e,{configurable:!0,enumerable:!0,writable:!0,value:n[e]});return Zr(i)}function ui(e,t){return kr(e)&&zr(e,"~kind")&&Sr(e["~kind"],t)}function si(e){return kr(e)}function ai(e,t,n){return ri({"~kind":"Deferred"},{type:"deferred",action:e,parameters:t,options:n},{})}function di(e){return ui(e,"Deferred")}function ci(e,t){return oi(function(e){return oi(e,{"~readonly":!0},{})}(e),{},t)}function li(e,t){return oi(function(e){return oi(e,{"~optional":!0},{})}(e),{},t)}function fi(e,t){return ri({"~kind":"Array"},{type:"array",items:e},t)}function pi(e){return ui(e,"Array")}function mi(e){return ii(e,["~kind","type","items"])}function hi(e,t,n={}){return ri({"~kind":"Constructor"},{type:"constructor",parameters:e,instanceType:t},n)}function _i(e){return ui(e,"Constructor")}function gi(e,t,n={}){return ri({"~kind":"Function"},{type:"function",parameters:e,returnType:t},n)}function yi(e){return ui(e,"Function")}function vi(e,t){return ri({"~kind":"Ref"},{$ref:e},t)}function bi(e){return ui(e,"Ref")}function wi(e,t){return ri({"~kind":"Generic"},{type:"generic",parameters:e,expression:t})}function ki(e){return ui(e,"Generic")}function xi(e){return ui(e,"Any")}var $i,Ai="(?!)";function Si(e){return ri({"~kind":"Never"},{not:{}},e)}function Oi(e){return ui(e,"Never")}function Ii(e,t={}){return li(e,t)}function Ei(e){return Ii(e)}function Ri(e){return si(e)&&zr(e,"~optional")}function Pi(e){return Fr(e)}function qi(e){return Wr(e)}function Mi(e,t={}){let n=function(e){return Fr(e).filter(t=>!Ri(e[t]))}(e);return ri({"~kind":"Object"},{type:"object",...n.length>0?{required:n}:{},properties:e},t)}function Ti(e){return ui(e,"Object")}function Ci(e){return ri({"~kind":"Unknown"},{},e)}function Ni(e){return ui(e,"Unknown")}function ji(e,t,n){return ri({"~kind":"Cyclic"},{$defs:Fr(e).reduce((t,n)=>({...t,[n]:oi(e[n],{},{$id:n})}),{}),$ref:t},n)}function Li(e){return ui(e,"Cyclic")}function Bi(e,t){return t[e.length]?.(...e)??(()=>{throw Error("Invalid Arguments")})()}function zi(e){return ui(e,"Infer")}function Di(e){return ui(e,"Dependent")}function Ui(e){return ui(e,"Enum")}function Fi(e,t={}){return ri({"~kind":"Intersect"},{allOf:e},t)}function Wi(e){return ui(e,"Intersect")}function Gi(){throw Error("Unreachable")}!function(e){e[e.Array=0]="Array",e[e.BigInt=1]="BigInt",e[e.Boolean=2]="Boolean",e[e.Date=3]="Date",e[e.Constructor=4]="Constructor",e[e.Function=5]="Function",e[e.Null=6]="Null",e[e.Number=7]="Number",e[e.Object=8]="Object",e[e.RegExp=9]="RegExp",e[e.String=10]="String",e[e.Symbol=11]="Symbol",e[e.TypeArray=12]="TypeArray",e[e.Undefined=13]="Undefined"}($i||($i={}));var Ki=BigInt("14695981039346656037"),[Ji,Hi]=[BigInt("1099511628211"),BigInt("18446744073709551616")],Vi=Array.from({length:256}).map((e,t)=>BigInt(t)),Zi=new Float64Array(1),Xi=new DataView(Zi.buffer),Qi=new Uint8Array(Zi.buffer);function Yi(e){Ki=(Ki^=Vi[e])*Ji%Hi}function eo(e){Yi($i.Boolean),Yi(e?1:0)}function to(e){Yi($i.Number),Xi.setFloat64(0,e,!0);for(let e of Qi)Yi(e)}function no(e){Yi($i.Object);for(let t of function(e){let t=new Set,n=e;for(;n&&n!==Object.prototype;){for(let e of Reflect.ownKeys(n))"constructor"!==e&&"symbol"!=typeof e&&t.add(e);n=Object.getPrototypeOf(n)}return[...t]}(e).sort())oo(t),oo(e[t])}var ro=new TextEncoder;function io(e){Yi($i.String);for(let t of ro.encode(e))Yi(t)}function oo(e){return Kr(e)?function(e){Yi($i.TypeArray);let t=new Uint8Array(e.buffer);for(let e=0;e<t.length;e++)Yi(t[e])}(e):function(e){return e instanceof globalThis.Date}(e)?function(e){Yi($i.Date),oo(e.getTime())}(e):Jr(e)?function(e){Yi($i.RegExp),io(e.toString())}(e):function(e){return e instanceof Boolean}(e)?eo(e.valueOf()):function(e){return e instanceof String}(e)?io(e.valueOf()):function(e){return e instanceof Number}(e)?to(e.valueOf()):function(e){return"number"==typeof e}(e)?to(e):pr(e)?function(e){Yi($i.Array);for(let t of e)oo(t)}(e):hr(e)?eo(e):mr(e)?function(e){Yi($i.BigInt),Xi.setBigInt64(0,e);for(let e of Qi)Yi(e)}(e):_r(e)?function(e){Yi($i.Constructor),oo(e.toString())}(e):vr(e)?void Yi($i.Null):kr(e)?no(e):xr(e)?io(e):$r(e)?function(e){Yi($i.Symbol),oo(e.toString())}(e):Ar(e)?Yi($i.Undefined):gr(e)?function(e){Yi($i.Function),oo(e.toString())}(e):Gi()}function uo(e){return function(e){return Ki=BigInt("14695981039346656037"),oo(e),Ki}(e).toString(16).padStart(16,"0")}var so=function(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":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":case"exclusiveMinimum":case"maximum":case"minimum":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"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"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"string"==typeof e.params.type?`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"}};function ao(){return so}function co(e){return si(e)&&zr(e,"~immutable")}function lo(e,t={}){return ci(e,t)}function fo(e){return si(e)&&zr(e,"~readonly")}var po="-?(?:0|[1-9][0-9]*)n";function mo(e){return ui(e,"BigInt")}function ho(e){return ri({"~kind":"Boolean"},{type:"boolean"},e)}function _o(e){return ui(e,"Boolean")}var go="-?(?:0|[1-9][0-9]*)";function yo(e){return ri({"~kind":"Integer"},{type:"integer"},e)}function vo(e){return ui(e,"Integer")}class bo extends Error{constructor(e){super("Invalid Literal value"),Object.defineProperty(this,"cause",{value:{value:e},writable:!1,configurable:!1,enumerable:!1})}}function wo(e){return mr(e)?"bigint":hr(e)?"boolean":br(e)?"number":xr(e)?"string":(()=>{throw new bo(e)})()}function ko(e,t){return ri({"~kind":"Literal"},{type:wo(e),const:e},t)}function xo(e){return Ao(e)&&br(e.const)}function $o(e){return Ao(e)&&xr(e.const)}function Ao(e){return ui(e,"Literal")}function So(e){return ri({"~kind":"Null"},{type:"null"},e)}function Oo(e){return ui(e,"Null")}var Io="-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?";function Eo(e){return ri({"~kind":"Number"},{type:"number"},e)}function Ro(e){return ui(e,"Number")}function Po(e){return ui(e,"Symbol")}var qo=".*";function Mo(e){return ri({"~kind":"String"},{type:"string"},e)}function To(e){return ui(e,"String")}function Co(e,t={}){return ri({"~kind":"Union"},{anyOf:e},t)}function No(e){return ui(e,"Union")}function jo(e){let t=fs(e);return Sr(t.length,2)?t[0]:[]}function Lo(e){return Lr(e,(e,t)=>{return!!(No(n=e)?Bo(n.anyOf):Ao(n)&&(n.const,1))&&Lo(t);var n},()=>!0)}function Bo(e){return!Sr(e.length,0)&&Lo(e)}function zo(e){return Bo(e)}function Do(e){return ri({"~kind":"TemplateLiteral"},{type:"string",pattern:e},{})}function Uo(e,t,n=[]){return Lr(e,(e,r)=>Uo(r,t,[...n,`${e}${t}`]),()=>n)}function Fo(e,t){return Sr(e.length,0)?[`${t}`]:Uo(e,t)}function Wo(e,t,n=[]){return Lr(t,(t,r)=>Wo(e,r,[...n,...Go(e,t)]),()=>n)}function Go(e,t){return No(t)?Wo(e,t.anyOf):Ao(t)?Fo(e,t.const):Gi()}function Ko(e,t){return Lr(t,(t,n)=>Ko(Go(e,t),n),()=>e)}function Jo(e){let t=function(e){return e.map(e=>ko(e))}(Ko([],e));return Co(t)}function Ho(e){let t=jo(e);return Sr(t.length,0)?Mo():zo(t)?function(e){return Sr(e.length,0)?Gi():Sr(e.length,1)&&Ao(e[0])?e[0]:Jo(e)}(t):Do(e)}function Vo(e,t){return ri({"~kind":"Record"},{type:"object",patternProperties:{[e]:t}})}function Zo(e,t={}){let[n,r,i]=[e,e.length,!1];return ri({"~kind":"Tuple"},{type:"array",additionalItems:i,items:n,minItems:r},t)}function Xo(e){return ui(e,"Tuple")}function Qo(e,t){return oi(function(e){return ii(e,["~readonly"])}(e),{},t)}function Yo(e,t){return oi(function(e){return ii(e,["~optional"])}(e),{},t)}function eu(e,t={}){return Yo(e,t)}function tu(e){return e.reduceRight((e,t,n)=>({[n]:t,...e}),{})}function nu(e){return Ti(e)||Xo(e)}function ru(e,t){let n=function(e,t){return!!fo(e)&&!!fo(t)}(e,t),r=function(e,t){return!!Ri(e)&&!!Ri(t)}(e,t),i=function(e,t={}){return Qo(e,t)}(eu(gu([e,t])));return n&&r?lo(Ii(i)):n&&!r?lo(i):!n&&r?Ii(i):i}function iu(e,t,n){return n in e?n in t?ru(e[n],t[n]):e[n]:n in t?t[n]:Si()}function ou(e){return Ti(e)?e.properties:Xo(e)?tu(e.items):{}}function uu(e,t){let n=function(e,t){return[...new Set([...Fr(e),...Fr(t)])].reduce((n,r)=>({...n,[r]:iu(e,t,r)}),{})}(ou(e),ou(t));return Mi(n)}function su(e,t){let n=nu(e),r=nu(t);return n&&r?uu(e,t):n&&!r?e:!n&&r?t:function(e,t){let n=Aa(e,t);return Sr(n,xa)?e:Sr(n,$a)||Sr(n,wa)?t:Si()}(e,t)}function au(e,t){let n=bu(e),r=bu(t);return function(e,t){return No(e)||No(t)}(n,r)?gu([n,r]):function(e,t){return Oi(e)||xi(e)?e:Ni(e)||Oi(t)||xi(t)?t:Ni(t)?e:su(e,t)}(n,r)}function du(e,t,n=[]){return Lr(t,(t,r)=>du(e,r,[...n,au(t,e)]),()=>Sr(n.length,0)?[e]:n)}function cu(e,t,n=[]){return Lr(e,(e,r)=>cu(r,t,[...n,...lu([e],t)]),()=>n)}function lu(e,t=[]){return Lr(e,(e,n)=>No(e)?lu(n,cu(e.anyOf,t)):lu(n,du(e,t)),()=>t)}function fu(e,t){return $s(ba({},e,t))?[]:[e]}function pu(e,t,n=[]){return Lr(e,(e,r)=>pu(r,t,[...n,...fu(e,t)]),()=>n)}function mu(e,t){let n=bu(e);return vu(pu(No(n)?n.anyOf:[n],t))}function hu(e,t,n){return vu([gu([e,t]),mu(n,e)])}function _u(e,t=[]){return Lr(e,(e,n)=>_u(n,[...t,ko(e)]),()=>vu(t))}function gu(e){return vu(Ea(lu(e)))}function yu(e){let t=function(e){let t=Ho(e);return ys(t)?Mo():t}(e);return bu(t)}function vu(e){return wu(Ea(e))}function bu(e){return Di(e)?hu(e.if,e.then,e.else):Ui(e)?_u(e.enum):Wi(e)?gu(e.allOf):ys(e)?yu(e.pattern):No(e)?vu(e.anyOf):e}function wu(e){return Sr(e.length,1)?e[0]:Sr(e.length,0)?Si():Co(e)}function ku(e,t=[]){return Lr(e,(e,n)=>{return ku(n,[...t,...(r=e,No(r)?ku(r.anyOf):[r])]);var r},()=>t)}function xu(e,t){return Sr(function(e){return e.some(e=>To(e)||Ro(e)||vo(e))}(e),!0)?Vo(Eu,t):void 0}function $u(e,t){let n=function(e,t){return e.reduce((e,n)=>Ao(n)&&(xr(n.const)||br(n.const))?{...e,[n.const]:t}:e,{})}(e,t);return Mi(n)}function Au(e,t){return xi(e)?function(e){return Vo(Eu,e)}(t):_o(e)?function(e){return Mi({true:e,false:e})}(t):Ui(e)?function(e,t){return Au(_u(e),t)}(e.enum,t):vo(e)?function(e,t){return Vo(Ou,t)}(0,t):Wi(e)?function(e,t){return Au(gu(e),t)}(e.allOf,t):Ao(e)?function(e,t){return xr(e)||br(e)?Mi({[e]:t}):Sr(e,!1)?Mi({false:t}):Sr(e,!0)?Mi({true:t}):Mi({})}(e.const,t):Ro(e)?function(e,t){return Vo(Iu,t)}(0,t):No(e)?function(e,t){let n=ku(e),r=xu(n,t);return si(r)?r:$u(n,t)}(e.anyOf,t):To(e)?function(e,t){return zr(e,"pattern")&&(xr(e.pattern)||e.pattern instanceof RegExp)?Vo(e.pattern.toString(),t):Vo(Eu,t)}(e,t):ys(e)?function(e,t){return zo(jo(e))?Au(yu(e),t):Vo(e,t)}(e.pattern,t):Mi({})}function Su(e,t,n){return cc([e])?oi(Au(e,t),{},n):function(e,t,n={}){return ai("Record",[e,t],n)}(e,t,n)}var Ou=`^${go}$`,Iu=`^${Io}$`,Eu=`^${qo}$`;function Ru(e,t,n={}){return Su(e,t,n)}function Pu(e){return Sr(e,Eu)?Mo():Sr(e,Ou)?yo():Sr(e,Iu)?Eo():Ho(e)}function qu(e){return Fr(e.patternProperties)[0]}function Mu(e){return Pu(qu(e))}function Tu(e){return e.patternProperties[qu(e)]}function Cu(e){return ui(e,"Record")}function Nu(e){return ui(e,"Rest")}function ju(e){return ui(e,"Undefined")}function Lu(e){return ui(e,"Void")}function Bu(e){return ri({"~kind":"BigInt"},{type:"bigint"},t);var t}function zu(e){return ko(e)}function Du(e){return Co(e[1])}function Uu(e){return 3===e.length?[...e[0],...e[2]]:1===e.length?[...e[0]]:[]}function Fu(e){return[e[0],...e[1]]}function Wu(e){return e[1]}function Gu(e){return Sr(e.length,2)}function Ku(e,t,n){return Gu(e)?t(e[0],e[1]):n()}function Ju(e,t){return Sr(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function Hu(e,t){return Array.from({length:t-e+1},(t,n)=>String.fromCharCode(e+n))}var Vu=[...Hu(97,122),...Hu(65,90)],Zu=["0",...Hu(49,57)];function Xu(e){let t=e.indexOf("*/");return Sr(t,-1)?"":e.slice(t+2)}function Qu(e){let t=e.indexOf("\n");return Sr(t,-1)?"":e.slice(t)}function Yu(e){let t=function(e){return e.replace(/^[ \t\r\f\v]+/,"")}(e);return t.startsWith("/*")?Yu(Xu(t.slice(2))):t.startsWith("//")?Yu(Qu(t.slice(2))):t}function es(e){let t=e.trimStart();return t.startsWith("/*")?es(Xu(t.slice(2))):t.startsWith("//")?es(Qu(t.slice(2))):t}function ts(e,t){return function(e,t){for(let n=0;n<e.length;n++){let r=Ju(e[n],t);if(Gu(r))return r}return[]}([e],t)}function ns(e,t){return Sr(e,"")?["",t]:e.startsWith("\n")?ts(e,Yu(t)):e.startsWith(" ")?ts(e,t):ts(e,es(t))}function rs(e,t){return Lr(e,(e,n)=>!!t.startsWith(e)||rs(n,t),()=>!1)}function is(e,t,n=""){return Ku(function(e){return Sr(e,"")?[]:[e.slice(0,1),e.slice(1)]}(t),(r,i)=>rs(e,t)?[n,t]:is(e,i,`${n}${r}`),()=>[])}var os=(e,t,n=()=>[])=>2===e.length?t(e):n(),us=e=>os(function(e,t){return Ku(is(e,t),(e,t)=>Sr(e,"")?[]:[e,t],()=>[])}(["-?(?:0|[1-9][0-9]*)n",".*","-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?","-?(?:0|[1-9][0-9]*)","(?!)","(",")","$","|"],e),([e,t])=>[zu(e),t]),ss=e=>os(os((e=>os(ns("-?(?:0|[1-9][0-9]*)n",e),([e,t])=>[Bu(),t]))(e),([e,t])=>[e,t],()=>os((e=>os(ns(".*",e),([e,t])=>[Mo(),t]))(e),([e,t])=>[e,t],()=>os((e=>os(ns("-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?",e),([e,t])=>[Eo(),t]))(e),([e,t])=>[e,t],()=>os((e=>os(ns("-?(?:0|[1-9][0-9]*)",e),([e,t])=>[yo(),t]))(e),([e,t])=>[e,t],()=>os((e=>os(ns("(?!)",e),([e,t])=>[Si(),t]))(e),([e,t])=>[e,t],()=>os(as(e),([e,t])=>[e,t],()=>os(us(e),([e,t])=>[e,t],()=>[]))))))),([e,t])=>[e,t]),as=e=>os(os(ns("(",e),([e,t])=>os(ls(t),([t,n])=>os(ns(")",n),([n,r])=>[[e,t,n],r]))),([e,t])=>[Du(e),t]),ds=e=>os(os(os(cs(e),([e,t])=>os(ns("|",t),([t,n])=>os(ds(n),([n,r])=>[[e,t,n],r]))),([e,t])=>[e,t],()=>os(os(cs(e),([e,t])=>[[e],t]),([e,t])=>[e,t],()=>os([[],e],([e,t])=>[e,t],()=>[]))),([e,t])=>[Uu(e),t]),cs=e=>os(os(ss(e),([e,t])=>os(ls(t),([t,n])=>[[e,t],n])),([e,t])=>[Fu(e),t]),ls=e=>os(os(ds(e),([e,t])=>[e,t],()=>os(cs(e),([e,t])=>[e,t],()=>[])),([e,t])=>[e,t]),fs=e=>os(os(ns("^",e),([e,t])=>os(ls(t),([t,n])=>os(ns("$",n),([n,r])=>[[e,t,n],r]))),([e,t])=>[Wu(e),t]);function ps(e,t,n,r=[]){return Lr(e,(e,i)=>ps(i,t,n,[...r,ms(e,[],"")]),()=>{return hs(t,`${n}(${e=r,e.join("|")})`);var e})}function ms(e,t,n){return Ui(e)?function(e,t,n){return ms(_u(e),t,n)}(e.enum,t,n):vo(e)?function(e,t){return hs(e,`${t}${go}`)}(t,n):Ao(e)?function(e,t,n){return hs(t,`${n}${e}`)}(e.const,t,n):mo(e)?function(e,t){return hs(e,`${t}${po}`)}(t,n):_o(e)?function(e,t){return ms(Co([ko("false"),ko("true")]),e,t)}(t,n):Ro(e)?function(e,t){return hs(e,`${t}${Io}`)}(t,n):To(e)?function(e,t){return hs(e,`${t}${qo}`)}(t,n):ys(e)?function(e,t,n){return hs(t,`${n}${function(e){return e.slice(1,e.length-1)}(e)}`)}(e.pattern,t,n):si(r=e)&&zr(r,"action")&&Sr(r.action,"TemplateLiteral")?function(e,t,n){return ms(gs(e,{}),t,n)}(e.parameters[0],t,n):No(e)?ps(e.anyOf,t,n):Ai;var r}function hs(e,t){return Lr(e,(e,n)=>ms(e,n,t),()=>t)}function _s(e){let t=function(e){return`^${hs(e,"")}$`}(e);return Do(t)}function gs(e,t){return cc(e)?oi(_s(e),{},t):function(e,t={}){return ai("TemplateLiteral",[e],t)}(e,t)}function ys(e){return ui(e,"TemplateLiteral")}function vs(e){return kr(e)&&zr(e,"~kind")&&zr(e,"inferred")&&Sr(e["~kind"],"ExtendsUnion")&&kr(e.inferred)}function bs(e){return ri({"~kind":"ExtendsTrue"},{inferred:e})}function ws(e){return kr(e)&&zr(e,"~kind")&&zr(e,"inferred")&&Sr(e["~kind"],"ExtendsTrue")&&kr(e.inferred)}function ks(){return ri({"~kind":"ExtendsFalse"},{})}function xs(e){return kr(e)&&zr(e,"~kind")&&Sr(e["~kind"],"ExtendsFalse")}function $s(e){return vs(e)||ws(e)}function As(e,t,n){return $s(e)?t(e.inferred):n()}function Ss(e,t,n){return Lr(n,(n,r)=>As(ta(e,t,n),e=>Ss(e,t,r),()=>ks()),()=>bs(e))}function Os(e,t,n){return Lr(n,(n,r)=>As(ta(e,t,n),e=>bs(e),()=>Os(e,t,r)),()=>ks())}function Is(e,t,n){return xi(n)?function(e){return bs(e)}(e):Di(n)?function(e,t,n,r,i){return As(ta(e,t,n),e=>As(ta(e,t,r),e=>bs(e),()=>ks()),()=>As(ta(e,t,i),e=>bs(e),()=>ks()))}(e,t,n.if,n.then,n.else):Ui(n)?function(e,t,n){return ta(e,t,_u(n))}(e,t,n.enum):zi(n)?function(e,t,n,r){return As(ta(e,n,r),r=>bs(Xr(Xr(e,r),{[t]:n})),()=>ks())}(e,n.name,t,n.extends):Wi(n)?Ss(e,t,n.allOf):ys(n)?function(e,t,n){return ta(e,t,yu(n))}(e,t,n.pattern):No(n)?Os(e,t,n.anyOf):Ni(n)?bs(e):ks()}function Es(e,t,n){return zi(n)?Is(e,t,n):xi(n)||Ni(n)?bs(e):function(e){return ri({"~kind":"ExtendsUnion"},{inferred:e})}(e)}function Rs(e,t,n,r){return pi(r)?function(e,t){let n=co(e),r=co(t);return!(!n||!r)||!(n||!r)||!(n&&!r)}(t,r)?ta(e,n,r.items):ks():Is(e,t,r)}function Ps(e,t,n,r){return Lr(r,(r,i)=>function(e,t,n,r,i){let o=zi(r)?t:r,u=zi(r)?r:t,s=Ri(t),a=Ri(r);return!s&&a?ks():As(ta(e,o,u),e=>qs(e,n,i),()=>ks())}(e,t,n,r,i),()=>Ri(t)?bs(e):ks())}function qs(e,t,n){return function(e,t,n){return Lr(t,(t,r)=>Ps(e,t,r,n),()=>bs(e))}(e,t,n)}function Ms(e,t,n){return Lu(n)?bs(e):ta(e,t,n)}function Ts(e,t,n){return t===n?bs(e):ks()}function Cs(e,t,n){return mr(t.const)?function(e,t,n){return Ao(n)?Ts(e,t,n.const):mo(n)?bs(e):Is(e,ko(t),n)}(e,t.const,n):hr(t.const)?function(e,t,n){return Ao(n)?Ts(e,t,n.const):_o(n)?bs(e):Is(e,ko(t),n)}(e,t.const,n):br(t.const)?function(e,t,n){return Ao(n)?Ts(e,t,n.const):Ro(n)?bs(e):Is(e,ko(t),n)}(e,t.const,n):xr(t.const)?function(e,t,n){return Ao(n)?Ts(e,t,n.const):To(n)?bs(e):Is(e,ko(t),n)}(e,t.const,n):Gi()}function Ns(e,t,n){return zi(n)&&Oi(n.extends)?ks():As(ta(e,t,n),e=>function(e,t,n){return Ri(t)?Ri(n)?bs(e):ks():bs(e)}(e,t,n),()=>ks())}function js(e,t,n){let r={};for(let i of Fr(n))r[i]=i in t?Ns({},t[i],n[i]):Ri(n[i])?zi(n[i])?bs(Xr(e,{[n[i].name]:n[i].extends})):bs(e):ks();let i=Wr(r).every(e=>$s(e)),o=i?function(e,t){return e.reduce((e,n)=>n in t&&$s(t[n])?{...e,...t[n].inferred}:Gi(),{})}(Fr(r),r):{};return i?bs(o):ks()}function Ls(e,t,n){return function(e,t,n){let r=js(e,t,n);return $s(r)?bs(Xr(e,r.inferred)):ks()}(e,t,n)}function Bs(e,t,n,r){return Lr(t,(t,i)=>As(ta({},e[t],n),t=>Bs(e,i,n,function(e,t){return Fr(t).reduce((n,r)=>({...n,[r]:zr(e,r)?No(n[r])?Co([...n[r].anyOf,t[r]]):Co([e[r],t[r]]):t[r]}),e)}(r,t)),()=>ks()),()=>bs(r))}function zs(e,t,n){return Cu(n)?function(e,t,n,r){return Bs(t,Fr(t),r,e)}(e,t,qu(n),Tu(n)):Ti(n)?Ls(e,t,n.properties):Is(e,Mi(t),n)}function Ds(e,t,n,r){return Cu(r)?function(e,t,n,r,i){return ta(e,n,i)}(e,Pu(t),n,Pu(qu(r)),Tu(r)):Ti(r)?function(e,t){return Sr(Fr(t).length,0)?bs(e):ks()}(e,r.properties):xi(r)||Ni(r)?bs(e):ks()}function Us(e,t){return ri({"~kind":"Inferrable"},{name:e,type:t},{})}function Fs(e){return kr(e)&&zr(e,"~kind")&&zr(e,"name")&&zr(e,"type")&&Sr(e["~kind"],"Inferrable")&&xr(e.name)&&kr(e.type)}function Ws(e){return Nu(e)?zi(e.items)?pi(e.items.extends)?Us(e.items.name,e.items.extends.items):Ni(e.items.extends)?Us(e.items.name,e.items.extends):void 0:Gi():void 0}function Gs(e){return zi(e)?Us(e.name,e.extends):void 0}function Ks(e,t){let n=[];for(let r of e){if(!$s(ta({},r,t)))return;n.push(r)}return n}function Js(e,t,n,r){let i=Ks(n,r);return pr(i)?bs(Xr(e,{[t]:Co(i)})):ks()}function Hs(e,t){return t?function(e){return[...e].reverse()}(e):e}function Vs(e,t,n,r,i){let o=Ws(r);return Fs(o)?function(e,t,n,r){let i=Ks(n,r);return pr(i)?bs(Xr(e,{[t]:Zo(i)})):ks()}(e,o.name,Hs(n,t),o.type):Lr(n,(n,o)=>function(e,t,n,r,i,o){return As(ta(e,n,i),e=>Zs(e,t,r,o),()=>ks())}(e,t,n,o,r,i),()=>ks())}function Zs(e,t,n,r){return function(e,t,n,r){return Lr(r,(r,i)=>Vs(e,t,n,r,i),()=>Sr(n.length,0)?bs(e):ks())}(e,t,n,r)}function Xs(e,t,n){let r=fc(e,dc([],[]),n),i=function(e){let t=e.length>0?e[0]:void 0,n=si(t)?Ws(t):void 0;return si(n)}(r);return Zs(e,i,Hs(t,i),Hs(r,i))}function Qs(e,t,n){let r=Gs(n);return Fs(r)?Js(e,r.name,t,r.type):function(e,t,n){for(let r of t){let t=ta(e,r,n);if(!$s(t))return t;e=t.inferred}return bs(e)}(e,t,n)}function Ys(e,t,n){return Lr(n,(n,r)=>As(ta(e,t,n),e=>bs(e),()=>Ys(e,t,r)),()=>ks())}function ea(e,t,n){return Lr(t,(t,r)=>As(Ys(e,t,n),e=>ea(e,r,n),()=>ks()),()=>bs(e))}function ta(e,t,n){return xi(t)?Es(e,t,n):pi(t)?Rs(e,t,t.items,n):mo(t)?function(e,t,n){return mo(n)?bs(e):Is(e,t,n)}(e,t,n):_o(t)?function(e,t,n){return _o(n)?bs(e):Is(e,t,n)}(e,t,n):_i(t)?function(e,t,n,r){return xi(r)||Ni(r)?bs(e):_i(r)?As(qs(e,t,r.parameters),e=>Ms(e,n,r.instanceType),()=>ks()):ks()}(e,t.parameters,t.instanceType,n):Di(t)?function(e,t,n,r,i){return As(ta(e,t,i),()=>ta(e,n,i),()=>ta(e,r,i))}(e,t.if,t.then,t.else,n):Ui(t)?function(e,t,n){return ta(e,_u(t),n)}(e,t.enum,n):yi(t)?function(e,t,n,r){return xi(r)||Ni(r)?bs(e):yi(r)?As(qs(e,t,r.parameters),e=>Ms(e,n,r.returnType),()=>ks()):ks()}(e,t.parameters,t.returnType,n):vo(t)?function(e,t,n){return vo(n)||Ro(n)?bs(e):Is(e,t,n)}(e,t,n):Wi(t)?function(e,t,n){return ta(e,gu(t),n)}(e,t.allOf,n):Ao(t)?Cs(e,t,n):Oi(t)?function(e,t,n){return zi(n)?Is(e,t,n):bs(e)}(e,t,n):Oo(t)?function(e,t,n){return Oo(n)?bs(e):Is(e,t,n)}(e,t,n):Ro(t)?function(e,t,n){return Ro(n)?bs(e):Is(e,t,n)}(e,t,n):Ti(t)?zs(e,t.properties,n):Cu(t)?Ds(e,qu(t),Tu(t),n):To(t)?function(e,t,n){return To(n)?bs(e):Is(e,t,n)}(e,t,n):Po(t)?function(e,t,n){return Po(n)?bs(e):Is(e,t,n)}(e,t,n):ys(t)?function(e,t,n){return ta(e,yu(t),n)}(e,t.pattern,n):Xo(t)?function(e,t,n){let r=fc(e,dc([],[]),t);return Xo(n)?Xs(e,r,n.items):pi(n)?Qs(e,r,n.items):Is(e,Zo(r),n)}(e,t.items,n):ju(t)?function(e,t,n){return Lu(n)||ju(n)?bs(e):Is(e,t,n)}(e,t,n):No(t)?function(e,t,n){let r=Gs(n);return Fs(r)?Js(e,r.name,t,r.type):No(n)?ea(e,t,n.anyOf):ea(e,t,[n])}(e,t.anyOf,n):Ni(t)?function(e,t,n){return zi(n)?Is(e,t,n):xi(n)||Ni(n)?bs(e):ks()}(e,t,n):Lu(t)?function(e,t,n){return Lu(n)?bs(e):Is(e,t,n)}(e,t,n):ks()}function na(e,t,n){return cc(e)?oi(function(e,t){return gu([...e,Mi(t)])}(e,t),{},n):function(e,t,n={}){return ai("Interface",[e,t],n)}(e,t,n)}function ra(e){return si(e)&&zr(e,"action")&&Sr(e.action,"Interface")}function ia(e,t,n){return oa(e,t,qi(n))}function oa(e,t,n){return Lr(n,(n,r)=>!!ua(e,t,n)||oa(e,t,r),()=>!1)}function ua(e,t,n){return bi(n)?function(e,t,n){return!!e.includes(n)||ua([...e,n],t,t[n])}(e,t,n.$ref):pi(n)?ua(e,t,n.items):_i(n)?oa(e,t,[...n.parameters,n.instanceType]):yi(n)?oa(e,t,[...n.parameters,n.returnType]):ra(n)?ia(e,t,n.parameters[1]):Wi(n)?oa(e,t,n.allOf):Ti(n)?ia(e,t,n.properties):No(n)?oa(e,t,n.anyOf):Xo(n)?oa(e,t,n.items):!!Cu(n)&&ua(e,t,Tu(n))}function sa(e,t){return t.reduce((t,n)=>function(e,t,n){return ua(e,t,n)}([n],e,e[n])?[...t,n]:t,[])}function aa(e,t,n){return da(e,qi(t),n)}function da(e,t,n){return t.reduce((t,n)=>ca(e,n,t),n)}function ca(e,t,n){return bi(t)?function(e,t,n){return n.includes(t)?n:t in e?ca(e,e[t],[...n,t]):Gi()}(e,t.$ref,n):pi(t)?ca(e,t.items,n):_i(t)?da(e,[...t.parameters,t.instanceType],n):yi(t)?da(e,[...t.parameters,t.returnType],n):ra(t)?aa(e,t.parameters[1],n):Wi(t)?da(e,t.allOf,n):Ti(t)?aa(e,t.properties,n):No(t)?da(e,t.anyOf,n):Xo(t)?da(e,t.items,n):Cu(t)?ca(e,Tu(t),n):n}function la(e){return ri({"~kind":"Any"},{},t);var t}function fa(e){return e.reduce((e,t)=>[...e,pa(t)],[])}function pa(e){return bi(e)?la(e.$ref):pi(e)?fi(pa(e.items),mi(e)):_i(e)?hi(fa(e.parameters),pa(e.instanceType)):yi(e)?gi(fa(e.parameters),pa(e.returnType)):Wi(e)?Fi(fa(e.allOf)):Ti(e)?Mi(Fr(t=e.properties).reduce((e,n)=>({...e,[n]:pa(t[n])}),{})):Cu(e)?Ru(Mu(e),pa(Tu(e))):No(e)?Co(fa(e.anyOf)):Xo(e)?Zo(fa(e.items)):e;var t}function ma(e){return t=e.$defs,(n=e.$ref)in t?pa(t[n]):Ci();var t,n}function ha(e,t){return Fr(e).filter(e=>t.includes(e)).reduce((t,n)=>{let r=e[n],i=ra(r)?function(e,t,n){return gu([...pc(e,dc([],[]),t),Mi(lc({},dc([],[]),n))])}(e,r.parameters[0],r.parameters[1]):r;return{...t,[n]:i}},{})}function _a(e,t,n){let r=function(e,t,n){return ca(e,n,[t])}(e,t,n);return ji(ha(e,r),t)}function ga(e,t){return t in e?bi(e[t])?ga(e,e[t].$ref):e[t]:Si()}function ya(e,t){return ga(e,t)}function va(e){return Li(e)?ma(e):wr(t=e)&&zr(t,"~unsafe")&&vr(t["~unsafe"])?Ci():e;var t}function ba(e,t,n){return ta(e,va(t),va(n))}var wa=0,ka=1,xa=2,$a=3;function Aa(e,t){let n=[ba({},e,t),ba({},t,e)];return $s(n[0])&&$s(n[1])?wa:$s(n[0])&&xs(n[1])?xa:xs(n[0])&&$s(n[1])?$a:ka}function Sa(e,t,n=[],r=t){return Lr(t,(t,i)=>{let o=Aa(e,t);return Sr(o,xa)||Sr(o,wa)?r:Sr(o,ka)?Sa(e,i,[...n,t],r):Sa(e,i,n,r)},()=>[...n,e])}function Oa(e,t,n){let r=bu(e);return xi(r)||Ni(r)?[r]:Oi(r)?Ia(t,n):Ti(r)?Ia(t,[...n,r]):Ia(t,Sa(r,n))}function Ia(e,t=[]){return Lr(e,(e,n)=>Oa(e,n,t),()=>t)}function Ea(e){return ku(Ia(e))}function Ra(e,t){return oi(bu(e),{},t)}function Pa(e,t=[]){return di(e)&&Sr(e.action,"Conditional")?bi(e.parameters[0])?Pa(e.parameters[2],Pa(e.parameters[3],[...t,e.parameters[0].$ref])):Pa(e.parameters[2],Pa(e.parameters[3],t)):di(e)&&Sr(e.action,"Mapped")&&di(e.parameters[1])&&Sr(e.parameters[1].action,"KeyOf")&&bi(e.parameters[1].parameters[0])?[...t,e.parameters[1].parameters[0].$ref]:t}function qa(e,t,n=[]){return Lr(e,(e,r)=>Lr(t,(t,i)=>qa(r,i,[...n,[t,e]]),()=>n),()=>n)}function Ma(e){let t=function(e){return ys(e)?yu(e.pattern):Ui(e)?_u(e.enum):e}(e);return No(t)?[...t.anyOf]:[t]}function Ta(e,t){return e.reduce((e,n)=>[...e,[...n,t]],[])}function Ca(e,t){return t.reduce((t,n)=>[...t,...Ta(e,n)],[])}function Na(e){return e.reduce((e,t)=>Sr(t[0],!0)?Ca(e,Ma(t[1])):Ca(e,[t[1]]),[[]])}function ja(e,t,n){let r=function(e,t){return e.reduce((e,n)=>[...e,t.includes(n.name)],[])}(e,Pa(n)),i=qa(t,r);return di(n)&&Sr(n.action,"Conditional")||di(n)&&Sr(n.action,"Mapped")?Na(i):[t]}function La(e,t,n){return t in e?Ba(e,t,e[t],n):["(not-resolvable)",Si()]}function Ba(e,t,n,r){return ki(n)?function(e,t,n){return[e,wi(t,n)]}(t,n.parameters,n.expression):bi(n)?La(e,n.$ref,r):["(not-generic)",Si()]}function za(e,t,n,r,i){let o=_c(e,t,i);return function(e,t,n){if(zi(t)||Za(t)||$s(ba({},t,n)))return;throw Error(`Argument for parameter ${e} does not satisfy constraint`,{cause:{parameter:e,expect:n,actual:t}})}(n,o,r),Xr(e,{[n]:o})}function Da(e,t,n,r){return Lr(n,(n,i)=>function(e,t,n,r,i){let o=_c(e,t,n.extends),u=_c(e,t,n.equals);return Lr(i,(i,u)=>Da(za(e,t,n.name,o,i),t,r,u),()=>Da(za(e,t,n.name,o,u),t,r,[]))}(e,t,n,i,r),()=>e)}var Ua=0,Fa=0;function Wa(){(function(){if(!Ir(Fa,Vr().maxInstantiationCount))throw Error("Type instantiation is excessively deep and possibly infinite")})(),Fa++,Ua++}function Ga(e,t){return Sr(function(e){return Or(e.callstack.length,0)?e.callstack[e.callstack.length-1]:""}(e),t)}function Ka(e,t,n,r,i,o){Wa();try{let u=function(e,t,n,r){return Da(e,t,n,r)}(e,t,r,o),s=_c(u,dc([...t.callstack,n.$ref],t.visited),i);return _c(u,dc([],[]),s)}finally{Sr(--Ua,0)&&(Fa=0)}}function Ja(e,t,n,r,i,o){let u=function(e,t,n,r,i,o){return o.reduce((o,u)=>[...o,Ka(e,t,n,r,i,u)],[])}(e,t,n,r,i,ja(r,o,i));return Sr(u.length,1)?u[0]:vu(u)}function Ha(e,t,n,r){let i=pc(e,t,r),o=function(e,t,n){return Ba(e,"(anonymous)",t,n)}(e,n,r),u=o[0],s=o[1];return ki(s)?Ga(t,u)?Va(vi(u),i):Ja(e,t,vi(u),s.parameters,s.expression,i):Va(n,i)}function Va(e,t){return ri({"~kind":"Call"},{type:"call",target:e,arguments:t},{})}function Za(e){return ui(e,"Call")}function Xa(e,t){return oi(function(e){return ii(e,["~immutable"])}(e),{},t)}function Qa(e,t){return Ao(t)?function(e,t){return xr(t)?ko(function(e,t){return e(t)}(e,t)):ko(t)}(e,t.const):ys(t)?function(e,t){return Qa(e,yu(t))}(e,t.pattern):No(t)?function(e,t){return Co(t.map(t=>Qa(e,t)))}(e,t.anyOf):t}var Ya=e=>e[0].toUpperCase()+e.slice(1),ed=e=>e.toLowerCase(),td=e=>e[0].toLowerCase()+e.slice(1),nd=e=>e.toUpperCase();function rd(e,t){return cc([e])?oi(Qa(Ya,e),{},t):function(e,t={}){return ai("Capitalize",[e],t)}(e,t)}function id(e,t){return cc([e])?oi(Qa(ed,e),{},t):function(e,t={}){return ai("Lowercase",[e],t)}(e,t)}function od(e,t){return cc([e])?oi(Qa(td,e),{},t):function(e,t={}){return ai("Uncapitalize",[e],t)}(e,t)}function ud(e,t){return cc([e])?oi(Qa(nd,e),{},t):function(e,t={}){return ai("Uppercase",[e],t)}(e,t)}function sd(e,t,n,r,i,o,u){return cc([n,r])?oi(function(e,t,n,r,i,o){let u=ba(e,n,r);return vs(u)?Co([_c(u.inferred,t,i),_c(e,t,o)]):ws(u)?_c(u.inferred,t,i):_c(e,t,o)}(e,t,n,r,i,o),{},u):function(e,t,n,r,i={}){return ai("Conditional",[e,t,n,r],i)}(n,r,i,o,u)}function ad(e,t){return cc([e])?oi(function(e){let t=_i(e)?e.parameters:[];return Zo(fc({},dc([],[]),t))}(e),{},t):function(e,t={}){return ai("ConstructorParameters",[e],t)}(e,t)}function dd(e,t,n){return cc([e,t])?oi(mu(e,t),{},n):function(e,t,n={}){return ai("Exclude",[e,t],n)}(e,t,n)}function cd(e,t){return $s(ba({},e,t))?[e]:[]}function ld(e,t,n=[]){return Lr(e,(e,r)=>ld(r,t,[...n,...cd(e,t)]),()=>n)}function fd(e,t){let n=bu(e);return vu(ld(No(n)?n.anyOf:[n],t))}function pd(e,t,n){return cc([e,t])?oi(fd(e,t),{},n):function(e,t,n={}){return ai("Extract",[e,t],n)}(e,t,n)}function md(e){return e.reduce((e,t)=>function(e,t){let n=Fr(e).filter(e=>!zr(t,e)),r=Fr(t).filter(t=>!zr(e,t)),i=Fr(e).filter(e=>zr(t,e)),o=n.reduce((t,n)=>({...t,[n]:e[n]}),{}),u=r.reduce((e,n)=>({...e,[n]:t[n]}),{}),s=i.reduce((n,r)=>({...n,[r]:gu([e[r],t[r]])}),{}),a=Xr(o,u);return Xr(a,s)}(e,gd(t)),{})}function hd(e){return gd(Mi(tu(Zo(e).items)))}function _d(e,t){return Lr(e,(e,n)=>_d(n,function(e,t){return Fr(e).filter(e=>e in t).reduce((n,r)=>({...n,[r]:vu([e[r],t[r]])}),{})}(t,gd(e))),()=>t)}function gd(e){return Li(e)?(i=e.$defs,o=e.$ref,gd(ya(i,o))):Di(e)?(t=e.if,n=e.then,r=e.else,gd(hu(t,n,r))):Wi(e)?md(e.allOf):No(e)?Lr(e.anyOf,(e,t)=>_d(t,gd(e)),()=>Gi()):Xo(e)?hd(e.items):Ti(e)?e.properties:{};var t,n,r,i,o}function yd(e){return Mi(gd(e))}var vd=new RegExp("^(?:0|[1-9][0-9]*)$");function bd(e){let t=`${e}`;return vd.test(t)?parseInt(t):e}function wd(e){return e.map(e=>kd(e))}function kd(e){return Wi(e)?Fi(wd(e.allOf)):No(e)?Co(wd(e.anyOf)):Ao(e)?ko(bd(e.const)):e}function xd(e){return Li(e)?(i=e.$defs,o=e.$ref,xd(ya(i,o))):Di(e)?(t=e.if,n=e.then,r=e.else,xd(hu(t,n,r))):Ui(e)?xd(_u(e.enum)):Wi(e)?xd(gu(e.allOf)):Ao(e)?[`${e.const}`]:ys(e)?xd(yu(e.pattern)):No(e)?function(e){return e.reduce((e,t)=>[...e,...xd(t)],[])}(e.anyOf):[];var t,n,r,i,o}function $d(e){return xd(e)}function Ad(e,t){return t.map(t=>Sd(e,t))}function Sd(e,t){return pi(t)?fi(Sd(e,t.items)):_i(t)?hi(Ad(e,t.parameters),Sd(e,t.instanceType)):yi(t)?gi(Ad(e,t.parameters),Sd(e,t.returnType)):Xo(t)?Zo(Ad(e,t.items)):No(t)?Co(Ad(e,t.anyOf)):Wi(t)?Fi(Ad(e,t.allOf)):ui(t,"This")?Mi(e):t}function Od(e,t){return function(e,t){return Sd(e,t)}(e,t in e?e[t]:Si())}function Id(e,t){return t.reduce((t,n)=>[...t,Od(e,n)],[])}var Ed=new RegExp(Ou);function Rd(e){let t=function(e){return e.filter(e=>Ed.test(e))}(Pi(e));return vu(Id(e,t))}function Pd(e,t){return Ro(t)?Rd(e):function(e,t){return vu(Id(e,$d(t)))}(e,t)}function qd(e){return e.map(e=>Md(e))}function Md(e){return Wi(e)?Fi(qd(e.allOf)):No(e)?Co(qd(e.anyOf)):Ao(e)?ko(bd(e.const)):e}function Td(e,t){let n=function(e,t){return e.reduceRight((e,n,r)=>$s(ba({},ko(r),t))?[n,...e]:e,[])}(e,Md(t));return wu(n)}function Cd(e,t){return Ao(t)&&Sr(t.const,"length")?ko(e.length):Ro(t)||vo(t)?function(e){return wu(e)}(e):Td(e,t)}function Nd(e,t){return pi(e)?function(e,t){return $s(ba({},kd(t),Eo()))?e:Ao(t)&&Sr(t.const,"length")?Eo():Si()}(e.items,t):Ti(e)?Pd(e.properties,t):Xo(e)?Cd(e.items,t):Si()}function jd(e,t,n){return cc([e,t])?oi(Nd(function(e){return Li(e)||Di(e)||Wi(e)||No(e)?yd(e):e}(e),t),{},n):function(e,t,n={}){return ai("Index",[e,t],n)}(e,t,n)}function Ld(e,t){return cc([e])?oi(function(e){return _i(e)?e.instanceType:Si()}(e),{},t):function(e,t={}){return ai("InstanceType",[e],t)}(e,t)}function Bd(e){return e.reduce((e,t)=>{return mr(n=t)||hr(n)||br(n)||xr(n)?[...e,ko(bd(t))]:Gi();var n},[])}function zd(e){return xi(e)?Co([Eo(),Mo(),ri({"~kind":"Symbol"},{type:"symbol"},t)]):pi(e)?(e.items,Eo()):Ti(e)?wu(Bd(Fr(e.properties))):Cu(e)?function(e){return Mu(e)}(e):Xo(e)?wu(e.items.map((e,t)=>ko(t))):Si();var t}function Dd(e,t){return cc([e])?oi(zd(function(e){return Li(e)||Di(e)||Wi(e)||No(e)?yd(e):e}(e)),{},t):function(e,t={}){return ai("KeyOf",[e],t)}(e,t)}function Ud(e){return Ui(e)?Ud(_u(e.enum)):Ao(e)?br(t=e.const)?[ko(`${t}`)]:[ko(t)]:ys(e)?Ud(yu(e.pattern)):No(e)?e.anyOf.reduce((e,t)=>[...e,...Ud(t)],[]):[e];var t}function Fd(e,t,n,r,i,o){let u=Xr(e,{[n.name]:r}),s=function(e){return ys(e)?yu(e.pattern):e}(_c(u,t,i)),a=_c(u,t,o);return xo(s)||$o(s)?{[s.const]:a}:{}}function Wd(e,t,n,r,i,o){let u=function(e){return Ud(e)}(r),s=function(e,t,n,r,i,o){return r.reduce((r,u)=>[...r,Fd(e,t,n,u,i,o)],[])}(e,t,n,u,i,o);return gu(s.reduce((e,t)=>[...e,Mi(t)],[]))}function Gd(e,t,n,r,i,o,u){return cc([r])?oi(Wd(e,t,n,r,i,o),{},u):function(e,t,n,r,i={}){return ai("Mapped",[e,t,n,r],i)}(n,r,i,o,u)}function Kd(e,t,n){let r=function(e){return sa(e,Pi(e))}(t),i=function(e,t,n){let r=Xr(e,t);return Fr(t).filter(e=>n.includes(e)).reduce((e,n)=>({...e,[n]:_a(r,n,t[n])}),{})}(e,t,r),o=function(e,t,n){let r=Xr(e,t);return Fr(t).filter(e=>!n.includes(e)).reduce((e,n)=>({...e,[n]:_c(r,dc([],[]),t[n])}),{})}(e,t,r);return oi({...i,...o},{},n)}function Jd(e,t){return cc([e])?oi(function(e){var t;return dd(e,Co([So(),ri({"~kind":"Undefined"},{type:"undefined"},t)]),{})}(e),{},t):function(e,t={}){return ai("NonNullable",[e],t)}(e,t)}function Hd(e){let t=yd(e);return Ti(t)?t.properties:Gi()}function Vd(e,t){let n=Hd(e),r=$d(t);var i,o;return Mi((o=r,Fr(i=n).reduce((e,t)=>o.includes(t)?e:{...e,[t]:i[t]},{})))}function Zd(e,t,n){return cc([e,t])?oi(Vd(e,t),{},n):function(e,t,n={}){return ai("Omit",[e,t],n)}(e,t,n)}function Xd(e,t){return cc([e])?oi(function(e){let t=yi(e)?e.parameters:[];return Zo(fc({},dc([],[]),t))}(e),{},t):function(e,t={}){return ai("Parameters",[e],t)}(e,t)}function Qd(e){return Li(e)?function(e,t){let n=Qd(ya(e,t));return ji(Xr(e,{[t]:n}),t)}(e.$defs,e.$ref):Di(e)?(n=e.if,r=e.then,i=e.else,Qd(hu(n,r,i))):Wi(e)?Qd(gu(e.allOf)):No(e)?function(e){return Co(e.map(e=>Qd(e)))}(e.anyOf):Ti(e)?Mi(Fr(t=e.properties).reduce((e,n)=>({...e,[n]:Ii(t[n])}),{})):Mi({});var t,n,r,i}function Yd(e,t){return cc([e])?oi(Qd(e),{},t):function(e,t={}){return ai("Partial",[e],t)}(e,t)}function ec(e,t){let n=function(e,t){return Fr(e).reduce((n,r)=>t.includes(r)?Xr(n,{[r]:e[r]}):n,{})}(Hd(e),$d(t));return Mi(n)}function tc(e,t,n){return cc([e,t])?oi(ec(e,t),{},n):function(e,t,n={}){return ai("Pick",[e,t],n)}(e,t,n)}function nc(e){return pi(e)?function(e){return vc(fi(e))}(e.items):Li(e)?function(e,t){let n=nc(ya(e,t));return ji(Xr(e,{[t]:n}),t)}(e.$defs,e.$ref):Di(e)?(n=e.if,r=e.then,i=e.else,nc(hu(n,r,i))):Wi(e)?nc(gu(e.allOf)):Ti(e)?Mi(Fr(t=e.properties).reduce((e,n)=>({...e,[n]:lo(t[n])}),{})):Xo(e)?function(e){return vc(Zo(e))}(e.items):No(e)?function(e){return Co(e.map(e=>nc(e)))}(e.anyOf):e;var t,n,r,i}function rc(e,t){return cc([e])?oi(nc(e),{},t):function(e,t={}){return ai("ReadonlyObject",[e],t)}(e)}function ic(e){return Li(e)?function(e,t){let n=ic(ya(e,t));return ji(Xr(e,{[t]:n}),t)}(e.$defs,e.$ref):Di(e)?(n=e.if,r=e.then,i=e.else,ic(hu(n,r,i))):Wi(e)?ic(gu(e.allOf)):No(e)?function(e){return Co(e.map(e=>ic(e)))}(e.anyOf):Ti(e)?Mi(Fr(t=e.properties).reduce((e,n)=>({...e,[n]:eu(t[n])}),{})):Mi({});var t,n,r,i}function oc(e,t){return cc([e])?oi(ic(e),{},t):function(e,t={}){return ai("Required",[e],t)}(e,t)}function uc(e,t){return cc([e])?oi(function(e){return yi(e)?e.returnType:Si()}(e),{},t):function(e,t={}){return ai("ReturnType",[e],t)}(e,t)}function sc(e,t){return cc([e])?oi(e,{},t):function(e,t){return ai("With",[e,t],{})}(e,t)}function ac(e){return e.reduce((e,t)=>{return[...e,...(n=t,Nu(n)?Xo(n.items)?ac(n.items.items):zi(n.items)||bi(n.items)?[n]:[Si()]:[n])];var n},[])}function dc(e,t){return{callstack:e,visited:t}}function cc(e){return Lr(e,(e,t)=>!bi(e)&&cc(t),()=>!0)}function lc(e,t,n){return Fr(n).reduce((r,i)=>({...r,[i]:_c(e,t,n[i])}),{})}function fc(e,t,n){return ac(pc(e,t,n))}function pc(e,t,n){return n.map(n=>_c(e,t,n))}function mc(e,t,n,r,i){return Sr(n,"AddImmutable")?function(e,t,n,r){let i=_c(e,t,n);return yc(i,r)}(e,t,r[0],i):Sr(n,"RemoveImmutable")?function(e,t,n,r){return Xa(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"AddReadonly")?function(e,t,n,r){return ci(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"RemoveReadonly")?function(e,t,n,r){return Qo(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"AddOptional")?function(e,t,n,r){return li(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"RemoveOptional")?function(e,t,n,r){return Yo(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Capitalize")?function(e,t,n,r){return rd(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Conditional")?function(e,t,n,r,i,o,u){return sd(e,t,_c(e,t,n),_c(e,t,r),i,o,u)}(e,t,r[0],r[1],r[2],r[3],i):Sr(n,"ConstructorParameters")?function(e,t,n,r){return ad(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Evaluate")?function(e,t,n,r){return Ra(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Exclude")?function(e,t,n,r,i){return dd(_c(e,t,n),_c(e,t,r),i)}(e,t,r[0],r[1],i):Sr(n,"Extract")?function(e,t,n,r,i){return pd(_c(e,t,n),_c(e,t,r),i)}(e,t,r[0],r[1],i):Sr(n,"Index")?function(e,t,n,r,i){return jd(_c(e,t,n),_c(e,t,r),i)}(e,t,r[0],r[1],i):Sr(n,"InstanceType")?function(e,t,n,r={}){return Ld(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Interface")?function(e,t,n,r,i){return na(pc(e,t,n),lc(e,t,r),i)}(e,t,r[0],r[1],i):Sr(n,"KeyOf")?function(e,t,n,r){return Dd(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Lowercase")?function(e,t,n,r){return id(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Mapped")?function(e,t,n,r,i,o,u){return Gd(e,t,n,_c(e,t,r),i,o,u)}(e,t,r[0],r[1],r[2],r[3],i):Sr(n,"Module")?function(e,t,n,r){return Kd(e,n,r)}(e,0,r[0],i):Sr(n,"NonNullable")?function(e,t,n,r){return Jd(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Pick")?function(e,t,n,r,i){return tc(_c(e,t,n),_c(e,t,r),i)}(e,t,r[0],r[1],i):Sr(n,"Parameters")?function(e,t,n,r){return Xd(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Partial")?function(e,t,n,r){return Yd(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Omit")?function(e,t,n,r,i){return Zd(_c(e,t,n),_c(e,t,r),i)}(e,t,r[0],r[1],i):Sr(n,"ReadonlyObject")?function(e,t,n,r){return rc(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Record")?function(e,t,n,r,i){return Su(_c(e,t,n),_c(e,t,r),i)}(e,t,r[0],r[1],i):Sr(n,"Required")?function(e,t,n,r){return oc(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"ReturnType")?function(e,t,n,r={}){return uc(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"TemplateLiteral")?function(e,t,n,r){return gs(pc(e,t,n),r)}(e,t,r[0],i):Sr(n,"Uncapitalize")?function(e,t,n,r){return od(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"Uppercase")?function(e,t,n,r){return ud(_c(e,t,n),r)}(e,t,r[0],i):Sr(n,"With")?function(e,t,n,r){return sc(_c(e,t,n),r)}(e,t,r[0],r[1]):ai(n,r,i)}function hc(e,t,n){let r=bi(n)?function(e,t,n,r){return t.visited.includes(r)?n:r in e?_c(e,dc(t.callstack,[...t.visited,r]),e[r]):n}(e,t,n,n.$ref):pi(n)?fi(_c(e,t,n.items),mi(n)):Za(n)?Ha(e,t,n.target,n.arguments):_i(n)?hi(pc(e,t,n.parameters),_c(e,t,n.instanceType),function(e){return ii(e,["~kind","type","parameters","instanceType"])}(n)):yi(n)?gi(pc(e,t,n.parameters),_c(e,t,n.returnType),function(e){return ii(e,["~kind","type","parameters","returnType"])}(n)):Di(n)?function(e,t,n,r={}){return ri({"~kind":"Dependent"},{if:e,then:t,else:n},r)}(_c(e,t,n.if),_c(e,t,n.then),_c(e,t,n.else),function(e){return ii(e,["~kind","if","then","else"])}(n)):Wi(n)?Fi(pc(e,t,n.allOf),function(e){return ii(e,["~kind","allOf"])}(n)):Ti(n)?Mi(lc(e,t,n.properties),function(e){return ii(e,["~kind","type","properties","required"])}(n)):Cu(n)?(i=qu(n),o=_c(e,t,Tu(n)),Vo(i,o)):Nu(n)?function(e){return ri({"~kind":"Rest"},{type:"rest",items:e},{})}(_c(e,t,n.items)):Xo(n)?Zo(fc(e,t,n.items),function(e){return ii(e,["~kind","type","items","minItems","additionalItems"])}(n)):No(n)?Co(pc(e,t,n.anyOf),function(e){return ii(e,["~kind","anyOf"])}(n)):n;var i,o;return function(e,t){let n=Ri(e)?li(t,{}):t,r=fo(e)?ci(n,{}):n;return co(e)?yc(r,{}):r}(n,r)}function _c(e,t,n){return di(n)?mc(e,t,n.action,n.parameters,n.options):hc(e,t,n)}function gc(e,t){return _c(e,dc([],[]),t)}function yc(e,t){return oi(function(e){return oi(e,{"~immutable":!0},{})}(e),{},t)}function vc(e,t={}){return yc(e,t)}function bc(e,t={}){return Ra(e,t)}function wc(e,t,n=[]){return Lr(t,(r,i)=>Sr(function(e,t){let n=Aa(e,t);return Sr(n,$a)||Sr(n,ka)?1:0}(e,r),1)?wc(e,i,[...n,r]):[...n,e,...t],()=>[...n,e])}function kc(e,t=[]){return Lr(e,(e,n)=>kc(n,wc(e,t)),()=>t)}function xc(e){return kc(e)}var $c=131072,Ac=1048576,Sc=Mo({description:"Recipient thread id or unique name as returned by thread_list; a name shared by several threads returns ambiguous_target with candidates."}),Oc=Ei(ho({description:"Address threads in every workspace on this machine instead of only the caller's workspace; left unset, an exact id from another workspace returns scope_denied."})),Ic=Ei(Mo({description:"Caller-chosen key that makes a retried call return the earlier result instead of repeating the side effect; reusing the key with different arguments returns idempotency_conflict."})),Ec=Ei(Mo({description:"Turn id the steer applies to; required with delivery steer, and a changed active turn returns turn_conflict with the message held undelivered."})),Rc=Ei(Mo({maxLength:200,description:"One-line preview shown to the caller when the completion notice arrives."})),Pc=Mo({maxLength:32768,description:"Instruction to deliver to the target thread; longer than 32768 UTF-8 bytes returns message_too_large."}),qc=Mo({minLength:1,description:"Binding id as returned by thread_bind or thread_bindings."}),Mc=yo({minimum:1,description:"Revision the caller last saw for this binding; a binding that moved since returns stale_revision."}),Tc=Mo({description:"Text relayed to or from the external thread; longer than 32768 UTF-8 bytes returns message_too_large."}),Cc=Co([ko("auto"),ko("steer"),ko("follow_up")],{description:"auto steers the running turn when one is active and starts a new turn otherwise; steer requires expected_turn_id and becomes turn_conflict when the active turn changed; follow_up queues the message behind the running turn."}),Nc=Co([ko("discord"),ko("telegram"),ko("slack"),ko("notion"),ko("feishu"),ko("herdr"),ko("custom")],{description:"Chat platform of the external conversation; custom covers any other connector."}),jc=Co([ko("milestone"),ko("report"),ko("question"),ko("completion")]),Lc=Ei(Mo({description:"Thread id or unique name of the session to attach, as returned by thread_list; self or leaving it unset attaches the calling session."}));Mi({name:Ei(Mo({description:"Display label for the new thread; an existing thread with the same normalized name returns name_conflict, and later renames change only the label while thread_id stays the address."})),cwd:Ei(Mo({description:"Working directory the new thread runs in; leaving it unset keeps the thread inside the caller's workspace."})),fork_from:Ei(Mo({description:"Durable id of an existing thread to fork; the new thread starts with that transcript as prior context."})),idempotency_key:Ic}),Mi({all_scope:Ei(ho({description:"List threads from every workspace on this machine; the default scope returns only the caller's workspace."}))}),Mi({thread:Sc,cursor:Ei(Mo({description:"Opaque cursor from an earlier thread_read to continue a truncated transcript; a transcript revision that moved past it returns cursor_stale."})),max_bytes:Ei(yo({minimum:1,maximum:Ac,description:"Byte budget for the returned transcript slice, default 131072 and capped at 1048576; a longer transcript returns truncated with next_cursor."})),all_scope:Oc}),Mi({thread:Sc,message:Pc,delivery:Ei(Cc),expected_turn_id:Ec,summary:Rc,idempotency_key:Ic,all_scope:Oc}),Mi({thread:Sc,turn_id:Ei(Mo({description:"Running turn to stop, defaulting to the newest running turn; interrupting an idle thread returns success with interrupted false."})),all_scope:Oc}),Mi({thread:Mo({description:"Thread id or name to reopen after a pause; the fuzzy resolver also accepts partial names and workspace basenames, and a close runner-up returns ambiguous_target with candidates."}),match:Ei(Co([ko("exact"),ko("fuzzy")],{description:"exact resolves a thread id or a unique name; fuzzy additionally ranks partial names and workspace basenames and returns the top match only when it clearly leads its runner-up."})),message:Pc,delivery:Ei(Cc),expected_turn_id:Ec,summary:Rc,idempotency_key:Ic,all_scope:Oc}),Mi({thread:Sc,name:Mo({minLength:1,maxLength:200,description:"New display label for the thread; the thread keeps its id as its address, and a label already used by another visible thread returns name_conflict."}),all_scope:Oc,idempotency_key:Ic}),Mi({thread:Sc,model:Mo({minLength:1,description:"Model to switch the thread to, as provider/id, an exact model id, or a case-insensitive fragment of the id or display name resolved against the host's model catalog; no match returns model_not_found with the available list, several matches return model_ambiguous with candidates."}),provider:Ei(Mo({description:"Restricts resolution to one provider when the fragment alone would match models from several providers."})),all_scope:Oc,idempotency_key:Ic}),Mi({thread:Sc,level:Co([ko("off"),ko("minimal"),ko("low"),ko("medium"),ko("high"),ko("xhigh"),ko("max")],{description:"Thinking level to apply; a level the thread's active model cannot run returns thinking_level_unsupported with the supported list and leaves the thread unchanged."}),scope:Ei(Co([ko("session"),ko("turn")],{description:"session (default) changes the thread's remembered level for its model; turn changes only the current session level without rewriting the model's remembered level."})),all_scope:Oc,idempotency_key:Ic}),Mi({platform:Nc,account_id:Mo({minLength:1,maxLength:256,description:"Bot or account id the connector speaks as on that platform."}),chat_id:Mo({minLength:1,maxLength:256,description:"Channel, group or direct-chat id on the platform."}),thread_id:Ei(Mo({minLength:1,maxLength:256,description:"Thread id inside the chat; @chat (the default) binds the whole chat on platforms without threads."})),root_message_id:Ei(Mo({minLength:1,maxLength:256,description:"Platform id of the message that started the thread, when there is one."})),progress_message_id:Ei(Mo({minLength:1,maxLength:256,description:"Platform id of an existing progress message that milestone reports edit in place."})),session:Lc,direction:Ei(Mi({inbound:ho(),outbound:ho()},{description:"inbound lets the thread's messages reach the session, outbound lets the session report to the thread; both default to true and at least one is required."})),inbound_mode:Ei(Co([ko("auto"),ko("follow_up")],{description:"How inbound messages are delivered: auto starts a turn when the session is idle and queues behind a running one; follow_up always queues behind the running turn."})),outbound_events:Ei(fi(jc,{maxItems:4,description:"Report kinds this thread receives, each at most once; defaults to all four for an outbound binding."})),policy_id:Ei(Mo({minLength:1,maxLength:256,description:"Connector policy label stored with the binding; default is default."})),ttl_seconds:Ei(Co([yo({minimum:1}),So()],{description:"Lifetime in seconds from now, default 604800 (one week) and never extended; null keeps the binding until it is unbound."})),all_scope:Oc,idempotency_key:Ic}),Mi({binding_id:qc,expected_revision:Mc,idempotency_key:Ic}),Mi({binding_id:qc,expected_revision:Mc,session:Mo({minLength:1,description:"Thread id or unique name of the session that takes the binding over, as returned by thread_list."}),all_scope:Oc,idempotency_key:Ic}),Mi({session:Ei(Mo({minLength:1,description:"Only bindings attached to this session (thread id, unique name, or self)."})),platform:Ei(Nc),account_id:Ei(Mo({minLength:1,description:"Only bindings of this platform account."})),chat_id:Ei(Mo({minLength:1,description:"Only bindings in this chat."})),thread_id:Ei(Mo({minLength:1,description:"Only bindings of this thread id."})),status:Ei(Co([ko("active"),ko("detached"),ko("expired")],{description:"Only bindings in this status; all statuses when unset."})),cursor:Ei(Mo({description:"next_cursor from an earlier thread_bindings call, to continue the same snapshot."})),limit:Ei(yo({minimum:1,maximum:200,description:"Page size, default 50 and at most 200."})),all_scope:Oc}),Mi({binding_id:Ei(Mo({minLength:1,description:"Binding to report to; defaults to the originating binding, the one the message this session is answering now arrived through; refused when that is ambiguous."})),kind:Co([ko("milestone"),ko("report"),ko("question"),ko("completion")],{description:"milestone updates the thread's progress message, report posts a result, question relays a pending question of this session and returns a reply_token, completion is written once when this session's run settles, with the run's real outcome."}),text:Tc,request_id:Ei(Mo({minLength:1,description:"For kind question: the id of this session's pending extension UI request the answer resolves."})),request_kind:Ei(Co([ko("question"),ko("select"),ko("confirm"),ko("input"),ko("editor")],{description:"For kind question: which extension UI request request_id is. It decides the answer forms thread_answer accepts: confirm takes yes/no (any case, surrounding spaces ignored), input and editor take any text including empty, question and select take non-blank text. Without it the answer goes out in every text form at once, so a question, select, input or editor each reads its own and the text must be non-blank; a yes/no word also goes out as the confirm field, so an undeclared confirm reads yes/no too (any other text reads as no)."})),idempotency_key:Ic}),Mi({binding_id:qc,after_cursor:Ei(yo({minimum:0,description:"Read rows after this cursor; unset continues after the binding's acknowledged cursor."})),limit:Ei(yo({minimum:1,maximum:500,description:"Rows per read, default 100 and at most 500."}))}),Mi({binding_id:qc,cursor:yo({minimum:1,description:"Every outbox row up to this cursor is marked delivered; an older cursor changes nothing."}),provider_message_id:Ei(Mo({minLength:1,maxLength:256,description:"Platform id of the message posted for the row at cursor; the first one for a milestone becomes the progress message later milestones edit."}))}),Mi({binding_id:Mo({minLength:1,description:"Binding the answer arrived through; it must be the binding that asked the question."}),reply_token:Mo({minLength:1,description:"reply_token of the question row being answered."}),answer:Tc});function Bc(e){return zr(e,"~refine")&&pr(e["~refine"])&&Tr(e["~refine"],0,e=>kr(e)&&zr(e,"check")&&zr(e,"error")&&gr(e.check)&&gr(e.error))}function zc(e){return kr(e)&&!pr(e)}function Dc(e){return hr(e)}function Uc(e){return zc(e)||Dc(e)}function Fc(e){return zr(e,"additionalItems")&&Uc(e.additionalItems)}function Wc(e){return zr(e,"additionalProperties")&&Uc(e.additionalProperties)}function Gc(e){return zr(e,"allOf")&&pr(e.allOf)&&e.allOf.every(e=>Uc(e))}function Kc(e){return zr(e,"anyOf")&&pr(e.anyOf)&&e.anyOf.every(e=>Uc(e))}function Jc(e){return zr(e,"const")}function Hc(e){return zr(e,"contains")&&Uc(e.contains)}function Vc(e){return zr(e,"default")}function Zc(e){return zr(e,"dependencies")&&kr(e.dependencies)&&Object.values(e.dependencies).every(e=>Uc(e)||pr(e)&&e.every(e=>xr(e)))}function Xc(e){return zr(e,"dependentRequired")&&kr(e.dependentRequired)&&Object.values(e.dependentRequired).every(e=>pr(e)&&e.every(e=>xr(e)))}function Qc(e){return zr(e,"dependentSchemas")&&kr(e.dependentSchemas)&&Object.values(e.dependentSchemas).every(e=>Uc(e))}function Yc(e){return zr(e,"$dynamicAnchor")&&xr(e.$dynamicAnchor)}function el(e){return zr(e,"$dynamicRef")&&xr(e.$dynamicRef)}function tl(e){return zr(e,"else")&&Uc(e.else)}function nl(e){return zr(e,"enum")&&pr(e.enum)}function rl(e){return zr(e,"exclusiveMaximum")&&(br(e.exclusiveMaximum)||mr(e.exclusiveMaximum))}function il(e){return zr(e,"exclusiveMinimum")&&(br(e.exclusiveMinimum)||mr(e.exclusiveMinimum))}function ol(e){return zr(e,"format")&&xr(e.format)}function ul(e){return zr(e,"$id")&&xr(e.$id)}function sl(e){return zr(e,"if")&&Uc(e.if)}function al(e){return zr(e,"items")&&(Uc(e.items)||pr(e.items)&&e.items.every(e=>Uc(e)))}function dl(e){return al(e)&&pr(e.items)}function cl(e){return zr(e,"maximum")&&(br(e.maximum)||mr(e.maximum))}function ll(e){return zr(e,"maxContains")&&br(e.maxContains)}function fl(e){return zr(e,"maxItems")&&br(e.maxItems)}function pl(e){return zr(e,"maxLength")&&br(e.maxLength)}function ml(e){return zr(e,"maxProperties")&&br(e.maxProperties)}function hl(e){return zr(e,"minimum")&&(br(e.minimum)||mr(e.minimum))}function _l(e){return zr(e,"minContains")&&br(e.minContains)}function gl(e){return zr(e,"minItems")&&br(e.minItems)}function yl(e){return zr(e,"minLength")&&br(e.minLength)}function vl(e){return zr(e,"minProperties")&&br(e.minProperties)}function bl(e){return zr(e,"multipleOf")&&(br(e.multipleOf)||mr(e.multipleOf))}function wl(e){return zr(e,"not")&&Uc(e.not)}function kl(e){return zr(e,"oneOf")&&pr(e.oneOf)&&e.oneOf.every(e=>Uc(e))}function xl(e){return zr(e,"pattern")&&(xr(e.pattern)||e.pattern instanceof RegExp)}function $l(e){return zr(e,"patternProperties")&&kr(e.patternProperties)&&Object.values(e.patternProperties).every(e=>Uc(e))}function Al(e){return zr(e,"prefixItems")&&pr(e.prefixItems)&&e.prefixItems.every(e=>Uc(e))}function Sl(e){return zr(e,"properties")&&kr(e.properties)&&Object.values(e.properties).every(e=>Uc(e))}function Ol(e){return zr(e,"propertyNames")&&(kr(e.propertyNames)||Uc(e.propertyNames))}function Il(e){return function(e){return zr(e,"$recursiveAnchor")&&hr(e.$recursiveAnchor)}(e)&&Sr(e.$recursiveAnchor,!0)}function El(e){return zr(e,"$recursiveRef")&&xr(e.$recursiveRef)}function Rl(e){return zr(e,"$ref")&&xr(e.$ref)}function Pl(e){return zr(e,"required")&&pr(e.required)&&e.required.every(e=>xr(e))}function ql(e){return zr(e,"then")&&Uc(e.then)}function Ml(e){return zr(e,"type")&&(xr(e.type)||pr(e.type)&&e.type.every(e=>xr(e)))}function Tl(e){return zr(e,"uniqueItems")&&hr(e.uniqueItems)}function Cl(e){return zr(e,"unevaluatedItems")&&Uc(e.unevaluatedItems)}function Nl(e){return zr(e,"unevaluatedProperties")&&Uc(e.unevaluatedProperties)}class jl{constructor(){let e=new Set,t=new Set;this.stack=[{indices:e,keys:t}]}Push(){let e=new Set,t=new Set;return this.stack.push({indices:e,keys:t}),!0}Pop(){return this.stack.pop(),!0}AddIndex(e){return this.GetIndices().add(e),!0}AddKey(e){return this.GetKeys().add(e),!0}GetIndices(){return this.stack[this.stack.length-1].indices}GetKeys(){return this.stack[this.stack.length-1].keys}Merge(e){for(let t of e)t.GetIndices().forEach(e=>this.GetIndices().add(e)),t.GetKeys().forEach(e=>this.GetKeys().add(e));return!0}}class Ll extends jl{constructor(){super(),this.errors=[]}AtCapacity(){return this.errors.length>=Vr().maxErrors}AddError(e,t,n,r){return this.AddErrorObject({keyword:e,schemaPath:t,instancePath:n,params:r})}AddErrors(e){return e.forEach(e=>this.AddErrorObject(e)),!1}GetErrors(){return this.errors}AddErrorObject(e){return this.AtCapacity()||this.errors.push(e),!1}}var Bl="urn:typebox:root";function zl(e,t){return URL.canParse(e,t)?new URL(e,t):Sr(t,Bl)?new URL(`${t}:${e}`):new URL(`${t.slice(0,t.lastIndexOf(":"))}:${e}`)}function Dl(e,t){let n=zc(t)&&ul(t)?zl(t.$id,Bl).href:Bl;return{context:e,schema:t,lexicalSchema:t,lexicalBase:n,resourceBase:n,referenceBase:n,ids:[],useResourceBaseForReference:!0,recursiveAnchor:void 0,dynamicAnchors:[],resourceEntries:new Map,pendingResource:!0,enteredResource:!1}}function Ul(e,t,n=!0){if(Dc(t))return e;if(Array.isArray(t))return t.reduce((e,t)=>Ul(e,t,!1),e);if(!zc(t))return e;if(!n&&ul(t))return e;let r=!n&&Yc(t)?[...e,t]:e;return Object.keys(t).reduce((e,n)=>Ul(e,t[n],!1),r)}function Fl(e,t){return e.resourceEntries.get(t)}function Wl(e,t){return e.enteredResource||void 0!==Fl(e,t)}function Gl(e,t){return ul(t)?[...e.ids,t]:e.ids}function Kl(e,t){return e.recursiveAnchor??(Il(t)?t:void 0)}function Jl(e,t){let n=ul(t)?Ul(e.dynamicAnchors,t):e.dynamicAnchors;return Yc(t)?[...n,t]:n}function Hl(e,t){return!ul(t)&&e.pendingResource}function Vl(e,t){let n=Fl(e,t);return n?n.base:ul(t)?zl(t.$id,e.lexicalBase).href:e.lexicalBase}function Zl(e,t){let n=Fl(e,t);return n?n.base:ul(t)&&e.pendingResource?zl(t.$id,e.resourceBase).href:e.resourceBase}function Xl(e,t){return ul(t)?!function(e){return!/^[A-Za-z][A-Za-z0-9+.-]*:/.test(e.$id)}(t):e.useResourceBaseForReference}function Ql(e,t){let n=Wl(e,t),r=Xl(e,t);return n||r?Zl(e,t):Vl(e,t)}function Yl(e,t){let n=Fl(e,t);return n?n.root:ul(t)?t:e.lexicalSchema}function ef(e,t){return function(e,t){return zc(t)&&(ul(t)||Yc(t)||Ar(e.recursiveAnchor)&&Il(t)||!Ar(Fl(e,t)))}(e,t)?{...e,ids:Gl(e,t),dynamicAnchors:Jl(e,t),recursiveAnchor:Kl(e,t),pendingResource:Hl(e,t),lexicalBase:Vl(e,t),resourceBase:Zl(e,t),useResourceBaseForReference:Xl(e,t),referenceBase:Ql(e,t),lexicalSchema:Yl(e,t),enteredResource:Wl(e,t)}:e}function tf(e){return al(e)&&pr(e.items)}function nf(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function rf(e){return new RegExp(e,"u")}function of(e){return`^${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}$`}function uf(e){let t=[];return $l(e)&&t.push(...Fr(e.patternProperties)),Sl(e)&&t.push(...Fr(e.properties).map(of)),Sr(t.length,0)?"(?!)":`(${t.join("|")})`}function sf(e,t,n,r){return n}function af(e,t,n,r){return Pr(n.const)?Sr(r,n.const):Gr(r,n.const)}function df(e,t,n,r){return!function(e){return!(_l(e)&&Sr(e.minContains,0))}(n)||!Sr(r.length,0)&&function(e,t){let n=!1;return e.forEach((e,r)=>{t(e,r)&&(n=!0)}),n}(r,(r,i)=>wm(e,t,n.contains,r)&&t.AddIndex(i))}function cf(e,t){return zc(e)&&ul(e)?zl(e.$id,t.href):t}function lf(e){return zl(e,Bl)}function ff(e){return e.href.split("#")[0]}function pf(e,t,n){return hf(e,lf(t),n)}function mf(e,t){if(kr(e)&&Yc(e)&&Sr(e.$dynamicAnchor,t))return e;if(kr(e))for(let n of Fr(e)){let r=mf(e[n],t);if(r)return r}}function hf(e,t,n){if(Sr(e,n))return t.href;let r=cf(e,t);if(pr(e))for(let t of e){let e=hf(t,r,n);if(!Ar(e))return e}else if(kr(e))for(let t of Fr(e)){let i=hf(e[t],r,n);if(!Ar(i))return i}}function _f(e,t){if(t.href.endsWith("#"))return e;if(!t.hash.startsWith("#"))return;let n=decodeURIComponent(t.hash.slice(1));return n.startsWith("/")?function(e,t){let n=e;for(let e of function(e){let t=e.split("/").map(e=>e.replace(/~1/g,"/").replace(/~0/g,"~"));return""===t[0]?t.slice(1):t}(t)){if(!kr(n)||Br(e))return;n=n[e]}return n}(e,n):void 0}function gf(e,t,n){if(!function(e){return zr(e,"$anchor")&&xr(e.$anchor)}(e))return;let r=new URL(`#${e.$anchor}`,t.href),i=new URL(n.href,t.href);return Sr(r.href,i.href)?e:void 0}function yf(e,t,n){if(zc(e))return function(e,t,n){if(!ul(e))return;if(Sr(e.$id,n.hash))return e;let r=new URL(n.href,t.href);return Sr(t.pathname,r.pathname)?n.hash.startsWith("#")?_f(e,n):e:void 0}(e,t,n)??gf(e,t,n)??function(e,t,n){if(!Yc(e))return;let r=new URL(`#${e.$dynamicAnchor}`,t.href),i=new URL(n.href,t.href);return Sr(r.href,i.href)?e:void 0}(e,t,n)??_f(e,n)}function vf(e,t,n){let r=cf(e,t);return yf(e,r,n)??function(e,t,n){if(pr(e))return e.reduce((e,r)=>{let i=vf(r,t,n);return Ar(i)?e:i},void 0)}(e,r,n)??function(e,t,n){if(kr(e))return Fr(e).reduce((r,i)=>{if(Sr(i,"const")||Sr(i,"enum"))return r;let o=vf(e[i],t,n);return Ar(o)?r:o},void 0)}(e,r,n)}function bf(e,t,n,r,i){let o=i?function(e,t,n){let r=e.context[t];if(zc(r))return{target:n,base:t,root:r}}(e,r,n):void 0;return Ar(o)?function(e,t,n){if(!t.$ref.startsWith("#"))return;if(!zc(e.schema)||zr(e.schema,"$schema"))return;let r=pf(e.lexicalSchema,e.referenceBase,n);return Ar(r)||Sr(r,e.referenceBase)?void 0:{target:n,base:r,root:e.lexicalSchema}}(e,t,n):o}function wf(e,t,n){if(ul(n))return;let r=function(e,t,n,r){let i=kf(e,t,n,r);return zc(i)&&ul(i)?i:void 0}(e.context,e.schema,e.referenceBase,t);return r&&!e.ids.includes(r)?{resource:r}:void 0}function kf(e,t,n,r){let i=lf(n),o=zl(r,i.href);return function(e,t){return zr(e,t)?e[t]:void 0}(e,r)??function(e,t,n){return vf(e,t,n)}(t,i,o)??function(e,t,n){let r=ff(n);if(!zr(e,r)||Sr(r,ff(t)))return;let i=e[r],o=cf(i,new URL(r));return Sr(n.hash,"")?i:vf(i,o,n)}(e,i,o)}function xf(e,t,n,r){let i=function(e,t){if(!t)return e;let n=new Map(e.resourceEntries);return n.set(t.target,{base:t.base,root:t.root}),{...e,resourceEntries:n}}({...e,pendingResource:t},n);return function(e,t){return t?ef(e,t.resource):e}(i,r)}function $f(e,t){let n=kf(e.context,function(e,t){return t.$ref.startsWith("#")||e.enteredResource?e.lexicalSchema:e.schema}(e,t),e.referenceBase,t.$ref);return zc(n)?function(e,t,n){let r=ff(zl(t.$ref,e.referenceBase)),i=!Sr(r,e.resourceBase);return{schema:n,stack:xf(e,!0,bf(e,t,n,r,i),i?wf(e,r,n):void 0)}}(e,t,n):function(e,t){return{schema:t,stack:xf(e,!Ar(t))}}(e,n)}function Af(e,t){let n=function(e){return zc(e.lexicalSchema)&&Il(e.lexicalSchema)}(e)?e.recursiveAnchor:e.lexicalSchema;return kf(e.context,n,e.lexicalBase,t.$recursiveRef)}function Sf(e,t){return zl(t.$dynamicRef,lf(e.lexicalBase).href).hash}function Of(e,t){return e.dynamicAnchors.find(e=>Sr(e.$dynamicAnchor,t))??mf(e.schema,t)}function If(e,t){let n=t.$dynamicRef.startsWith("#")?e.lexicalSchema:e.schema,r=kf(e.context,n,e.lexicalBase,t.$dynamicRef);return Ar(r)?function(e,t){let n=Sf(e,t);return Of(e,decodeURIComponent(n.slice(1)))}(e,t):function(e,t,n){return zc(n)&&Yc(n)?function(e){return e.startsWith("#/")}(Sf(e,t))?n:Of(e,n.$dynamicAnchor):n}(e,t,r)}function Ef(e,t,n,r){return Nr(n.enum,e=>Pr(e)?Sr(r,e):Gr(r,e))}function Rf(e,t,n,r){return Ir(r,n.exclusiveMaximum)}function Pf(e,t,n,r){return Or(r,n.exclusiveMinimum)}var qf=[0,31,28,31,30,31,30,31,31,30,31,30,31],Mf=/^(\d\d\d\d)-(\d\d)-(\d\d)$/;function Tf(e){let t=Mf.exec(e);if(!t)return!1;let n=+t[1],r=+t[2],i=+t[3];return r>=1&&r<=12&&i>=1&&i<=(2===r&&function(e){return e%4==0&&(e%100!=0||e%400==0)}(n)?29:qf[r])}var Cf=/^(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:([Zz])|([+-])(\d\d):(\d\d))?$/;function Nf(e,t=!0){let n=Cf.exec(e);if(!n)return!1;if(t&&!n[4]&&!n[5])return!1;let r=+n[1],i=+n[2],o=+n[3];if(r>23||i>59||o>60)return!1;if(n[5]){let e=+n[6],t=+n[7];if(e>23||t>59)return!1}return o<60||((60*r+i-("-"===n[5]?-1:1)*(60*+(n[6]||0)+ +(n[7]||0)))%1440+1440)%1440==1439}function jf(e){let t=e.split(/T/i);return 2===t.length&&Tf(t[0])&&Nf(t[1])}var Lf=/^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 Bf(e){return Lf.test(e)}var zf=/^(?:[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 Df(e){return zf.test(e)}var Uf=/^(?!-).*(?<!-)$/,Ff=/^(?!..--)/,Wf=/^[a-zA-Z0-9-]*$/,Gf=/[^\p{ASCII}]/u,Kf=/[\u{0660}-\u{0669}]/u,Jf=/\p{Mn}/u,Hf=/[\p{Mn}\p{Mc}\p{Me}]/u,Vf=/\p{L}/u,Zf=/\p{Script=Greek}/u,Xf=/\p{Script=Hebrew}/u,Qf=/[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u,Yf=/[\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Mandaic}]/u,ep=/[\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,tp=/[\u{0640}\u{07fa}\u{302e}\u{302f}\u{3031}\u{3032}\u{3033}\u{3034}\u{3035}\u{303b}]/u,np=new RegExp([/[0-9]/,/[\u{06f0}-\u{06f9}]/u].map(e=>e.source).join("|"),"u"),rp=new RegExp([Vf,/[\u{002d}\u{002b}]/u,/[\u{002e}\u{002c}\u{003a}\u{002f}]/u,/\p{Nd}/u,Jf,/\p{Mc}/u,/[\u{00b7}\u{0375}\u{05f3}\u{05f4}\u{200c}\u{200d}\u{30fb}]/u,/[\u{00df}\u{03c2}\u{06fd}\u{06fe}\u{0f0b}\u{3007}]/u].map(e=>e.source).join("|"),"u");var ip=36;function op(){throw null}function up(e){return e.toLowerCase().startsWith("xn--")}function sp(e,t,n){e=n?Math.floor(e/700):e>>1,e+=Math.floor(e/t);let r=0;for(;e>455;)e=Math.floor(e/35),r+=ip;return r+Math.floor(36*e/(e+38))}function ap(e){let t=[],n=128,r=0,i=72,o=e.lastIndexOf("-");if(o>0)for(let n=0;n<o;n++){let r=e.charCodeAt(n);r>=128&&op(),t.push(r)}let u=o<0?0:o+1;for(;u<e.length;){let o=r,s=1,a=ip;for(;;){u>=e.length&&op();let t,n=e.charCodeAt(u++);n>=97&&n<=122?t=n-97:n>=48&&n<=57?t=n-48+26:op(),r+=t*s;let o=a<=i?1:a>=i+26?26:a-i;if(t<o)break;s*=ip-o,a+=ip}let d=t.length+1;i=sp(r-o,d,0===o),n+=Math.floor(r/d),r%=d,t.splice(r,0,n),r++}return String.fromCodePoint(...t)}function dp(e){return e<26?String.fromCharCode(e+97):String.fromCharCode(e-26+48)}var cp=new RegExp(Gf.source,"gu");var lp=/^(?:R|AL|AN|EN|ES|CS|ET|ON|BN|NSM)$/,fp=/^(?:L|EN|ES|CS|ET|ON|BN|NSM)$/,pp=/^(?:R|AL|AN)$/;function mp(e){let t=String.fromCodePoint(e);return np.test(t)?"EN":Kf.test(t)?"AN":Jf.test(t)?"NSM":Xf.test(t)?"R":Yf.test(t)?"AL":Vf.test(t)?"L":"ON"}function hp(e){for(let t of e)if(pp.test(mp(t.codePointAt(0))))return!0;return!1}function _p(e){let t=!1,n=fp,r=!1,i=!1,o=!0;for(let u of e){let e=mp(u.codePointAt(0));if(o){if("L"!==e&&"R"!==e&&"AL"!==e)return!1;t="R"===e||"AL"===e,n=t?lp:fp,o=!1}if(!n.test(e))return!1;"EN"===e?r=!0:"AN"===e&&(i=!0)}return!(t&&r&&i)}function gp(e){return Gf.test(e)&&function(e){let t=e.replace(cp,""),n=t.length,r=n>0?[t,"-"]:[],i=Array.from(e,e=>e.codePointAt(0)),o=128,u=0,s=72,a=n;for(;a<i.length;){let e=1/0;for(let t of i)t>=o&&t<e&&(e=t);u+=(e-o)*(a+1),o=e;for(let e of i)if(e<o&&u++,e===o){let e=u;for(let t=ip;;t+=ip){let n=t<=s?1:t>=s+26?26:t-s;if(e<n)break;let i=n+(e-n)%(ip-n);r.push(dp(i)),e=Math.floor((e-n)/(ip-n))}r.push(dp(e)),s=sp(u,a+1,a===n),u=0,a++}u++,o++}return r.join("")}(e).length+4>63}function yp(e){if(gp(e))return!1;if(hp(e)&&!_p(e))return!1;let t=[...e],n=t.map(e=>e.codePointAt(0)),r=n.length;if(function(e){return"-"===e[0]||"-"===e[e.length-1]||e.slice(2).join("").startsWith("--")}(t))return!1;if(Hf.test(t[0]))return!1;let i=!1;for(let e=0;e<r;e++){let r=n[e],o=t[e];if(tp.test(o))return!1;if(!rp.test(o))return!1;Qf.test(o)&&(i=!0);let u=n[e-1],s=n[e+1];switch(r){case 183:if(108!==u||108!==s)return!1;break;case 885:if(!s||!Zf.test(t[e+1]))return!1;break;case 1523:case 1524:if(!u||!Xf.test(t[e-1]))return!1;break;case 8204:if(!u||u<128&&!ep.test(t[e-1]))return!1;break;case 8205:if(!u||!ep.test(t[e-1]))return!1}}return!(e.includes("・")&&!i)}function vp(e){if(!up(e))return!1;try{let t=e.slice(4).toLowerCase();if(0===t.lastIndexOf("-"))return!1;let n=ap(t);return!!Gf.test(n)&&yp(n)}catch{return!1}}function bp(e){return function(e){return e.length>0&&e.length<=63}(e)&&(vp(e)||function(e){return Uf.test(e)&&Ff.test(e)&&Wf.test(e)}(e))}function wp(e){if(0===e.length||e.includes(" "))return!1;let t=function(e){return e.replace(/[\uff01-\uff5e]/g,e=>String.fromCharCode(e.charCodeAt(0)-65248)).normalize("NFC").replace(/[\u00ad\u034f\u180b-\u180d\u200b\ufe00-\ufe0f\u{e0100}-\u{e01ef}]/gu,"").replace(/[\u002E\u3002\uFF0E\uFF61]/g,".")}(e);if(t.length>253)return!1;let n=t.split("."),r=n.some(e=>function(e){if(up(e))try{return hp(ap(e.slice(4).toLowerCase()))}catch{return!1}return hp(e)}(e));return n.every(e=>function(e){return function(e){return e.length>0&&e.length<=63}(e)&&(vp(e)||yp(e))}(e)&&(!r||_p(e)))}function kp(e){return function(e){return!(0===e.length||e.length>253)&&46!==e.charCodeAt(e.length-1)&&e.split(".").every(e=>bp(e))}(e)}var xp=/^(?:[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 $p(e){return xp.test(e.normalize("NFC"))}function Ap(e){return wp(e)}var Sp=/^(?:(?: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 Op(e){return Sp.test(e)}var Ip=/^(?:(?:(?:[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 Ep(e){return Ip.test(e)}var Rp=/[\x00-\x20\x7F\\]|%(?![0-9a-fA-F]{2})/,Pp=/^[a-zA-Z][a-zA-Z0-9+\-.]*\/\//;function qp(e){return!Rp.test(e)&&!Pp.test(e)&&URL.canParse(e,"http://example.com")}var Mp=/[\x00-\x20<>\^`{|}\\]/,Tp=/%(?![0-9a-fA-F]{2})/;function Cp(e){return!Mp.test(e)&&(!Tp.test(e)&&URL.canParse(e))}var Np=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;function jp(e){return Np.test(e)}var Lp=/^(?:\/(?:[^~/]|~0|~1)*)*$/;function Bp(e){return Lp.test(e)}function zp(e){try{return new RegExp(e,"u"),!0}catch{return!1}}var Dp=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;function Up(e){return Dp.test(e)}var Fp=/^(?:[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 Wp(e){return Fp.test(e)}var Gp=/^(?:(?:[^\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 Kp(e){return Gp.test(e)}var Jp=/^[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 Hp(e){return Jp.test(e)}function Vp(e){return URL.canParse(e)}var Zp=/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;function Xp(e){return Zp.test(e)}var Qp=new Map;function Yp(e,t,n,r){return function(e,t){return Qp.get(e)?.(t)??!0}(n.format,r)}function em(e,t,n,r){return dl(n)?function(e,t,n,r){return Tr(n.items,0,(n,i)=>Er(r.length,i)||bm(e,t,n,r[i])&&t.AddIndex(i))}(e,t,n,r):function(e,t,n,r){return Tr(r,Al(n)?n.prefixItems.length:0,(r,i)=>bm(e,t,n.items,r)&&t.AddIndex(i))}(e,t,n,r)}function tm(e,t,n,r,i,o){return dl(i)?function(e,t,n,r,i,o){return Cr(i.items,0,(i,u)=>{let s=`${n}/items/${u}`,a=`${r}/${u}`;return Er(o.length,u)||km(e,t,s,a,i,o[u])&&t.AddIndex(u)})}(e,t,n,r,i,o):function(e,t,n,r,i,o){return Cr(o,Al(i)?i.prefixItems.length:0,(o,u)=>km(e,t,`${n}/items`,`${r}/${u}`,i.items,o)&&t.AddIndex(u))}(e,t,n,r,i,o)}function nm(e,t,n,r){if(!function(e){return Hc(e)}(n))return!0;return Er(jr(r,r=>wm(e,t,n.contains,r)),n.maxContains)}function rm(e,t,n,r){return Er(r,n.maximum)}function im(e,t,n,r){return Er(r.length,n.maxItems)}function om(e,t,n,r){return qr(r,n.maxLength)}function um(e,t,n,r){return Er(Fr(r).length,n.maxProperties)}function sm(e,t,n,r){if(!function(e){return Hc(e)}(n))return!0;return Rr(jr(r,(r,i)=>wm(e,t,n.contains,r)&&t.AddIndex(i)),n.minContains)}function am(e,t,n,r){return Rr(r,n.minimum)}function dm(e,t,n,r){return Rr(r.length,n.minItems)}function cm(e,t,n,r){return Mr(r,n.minLength)}function lm(e,t,n,r){return Rr(Fr(r).length,n.minProperties)}function fm(e,t,n,r){return function(e,t){if(mr(e)||mr(t))return BigInt(e)%BigInt(t)===0n;if(!br(e))return!0;if(yr(e)&&1/t%1==0)return!0;let n=e%t;return Math.min(Math.abs(n),Math.abs(n-t),Math.abs(n+t))<1e-10}(r,n.multipleOf)}function pm(e,t,n,r){let i=new jl;return!wm(e,i,n.not,r)&&t.Merge([i])}function mm(e,t,n,r){return(xr(n.pattern)?rf(n.pattern):n.pattern).test(r)}function hm(e,t){return e.includes(t)||Vr().exactOptionalPropertyTypes}function _m(e,t){return Ar(e[t])}function gm(e,t,n,r,i){return Sr(n,"object")?wr(i):Sr(n,"array")?pr(i):Sr(n,"boolean")?hr(i):Sr(n,"integer")?yr(i):Sr(n,"number")?br(i):Sr(n,"null")?vr(i):Sr(n,"string")?xr(i):Sr(n,"bigint")?mr(i):Sr(n,"constructor")?_r(i):Sr(n,"function")?gr(i):Sr(n,"symbol")?$r(i):Sr(n,"undefined")?Ar(i):!Sr(n,"void")||Ar(i)}function ym(e,t,n,r,i){return Nr(n,e=>gm(0,0,e,0,i))}function vm(e){return!Sr(e.uniqueItems,!1)}function bm(e,t,n,r){return t.Push()&&wm(e,t,n,r)&&t.Pop()}function wm(e,t,n,r){let i=ef(e,n);return Dc(n)?sf(0,0,n):(!Ml(n)||function(e,t,n,r){return pr(n.type)?ym(0,0,n.type,0,r):gm(0,0,n.type,0,r)}(0,0,n,r))&&(!(kr(r)&&!pr(r))||(!Pl(n)||function(e,t,n,r){return Tr(n.required,0,e=>zr(r,e))}(0,0,n,r))&&(!Wc(n)||function(e,t,n,r){let i=rf(uf(n));return Tr(Fr(r),0,(o,u)=>i.test(o)||bm(e,t,n.additionalProperties,r[o])&&t.AddKey(o))}(i,t,n,r))&&(!Zc(n)||function(e,t,n,r){let i=Sr(Fr(r).length,0),o=Tr(Ur(n.dependencies),0,([n,i])=>!zr(r,n)||(pr(i)?i.every(e=>zr(r,e)):wm(e,t,i,r)));return i||o}(i,t,n,r))&&(!Xc(n)||function(e,t,n,r){let i=Sr(Fr(r).length,0),o=Tr(Ur(n.dependentRequired),0,([e,t])=>!zr(r,e)||t.every(e=>zr(r,e)));return i||o}(0,0,n,r))&&(!Qc(n)||function(e,t,n,r){let i=Sr(Fr(r).length,0),o=Tr(Ur(n.dependentSchemas),0,([n,i])=>!zr(r,n)||wm(e,t,i,r));return i||o}(i,t,n,r))&&(!$l(n)||function(e,t,n,r){return Tr(Ur(n.patternProperties),0,([n,i])=>{let o=rf(n);return Tr(Ur(r),0,([n,r])=>!o.test(n)||bm(e,t,i,r)&&t.AddKey(n))})}(i,t,n,r))&&(!Sl(n)||function(e,t,n,r){let i=Pl(n)?n.required:[];return Tr(Ur(n.properties),0,([n,o])=>{let u=!zr(r,n)||bm(e,t,o,r[n])&&t.AddKey(n);return hm(i,n)?u:_m(r,n)||u})}(i,t,n,r))&&(!Ol(n)||function(e,t,n,r){return Tr(Fr(r),0,(r,i)=>wm(e,t,n.propertyNames,r))}(i,t,n,r))&&(!vl(n)||lm(0,0,n,r))&&(!ml(n)||um(0,0,n,r)))&&(!pr(r)||(!Fc(n)||function(e,t,n,r){return!tf(n)||Tr(r,0,(r,i)=>Ir(i,n.items.length)||bm(e,t,n.additionalItems,r)&&t.AddIndex(i))}(i,t,n,r))&&(!Hc(n)||df(i,t,n,r))&&(!al(n)||em(i,t,n,r))&&(!_l(n)||sm(i,t,n,r))&&(!ll(n)||nm(i,t,n,r))&&(!gl(n)||dm(0,0,n,r))&&(!fl(n)||im(0,0,n,r))&&(!Al(n)||function(e,t,n,r){return Sr(r.length,0)||Tr(n.prefixItems,0,(n,i)=>Er(r.length,i)||bm(e,t,n,r[i])&&t.AddIndex(i))}(i,t,n,r))&&(!Tl(n)||function(e,t,n,r){return!vm(n)||Sr(new Set(r.map(uo)).size,r.length)}(0,0,n,r)))&&(!xr(r)||(!yl(n)||cm(0,0,n,r))&&(!pl(n)||om(0,0,n,r))&&(!ol(n)||Yp(0,0,n,r))&&(!xl(n)||mm(0,0,n,r)))&&(!(br(r)||mr(r))||(!il(n)||Pf(0,0,n,r))&&(!rl(n)||Rf(0,0,n,r))&&(!hl(n)||am(0,0,n,r))&&(!cl(n)||rm(0,0,n,r))&&(!bl(n)||fm(0,0,n,r)))&&(!Rl(n)||function(e,t,n,r){let i=$f(e,n),o=i.schema??!1,u=new jl,s=Uc(o)&&wm(i.stack,u,o,r);return s&&t.Merge([u]),s}(i,t,n,r))&&(!El(n)||function(e,t,n,r){let i=Af(e,n)??!1,o=i?{...e,pendingResource:!0}:e;return Uc(i)&&wm(o,t,i,r)}(i,t,n,r))&&(!el(n)||function(e,t,n,r){let i=If(e,n)??!1,o=i?{...e,pendingResource:!0}:e;return Uc(i)&&wm(o,t,i,r)}(i,t,n,r))&&(!Jc(n)||af(0,0,n,r))&&(!nl(n)||Ef(0,0,n,r))&&(!sl(n)||function(e,t,n,r){let i=!ql(n)||n.then,o=!tl(n)||n.else;return wm(e,t,n.if,r)?wm(e,t,i,r):wm(e,t,o,r)}(i,t,n,r))&&(!wl(n)||pm(i,t,n,r))&&(!Gc(n)||function(e,t,n,r){let i=n.allOf.reduce((t,n)=>{let i=new jl;return wm(e,i,n,r)?[...t,i]:t},[]);return Sr(i.length,n.allOf.length)&&t.Merge(i)}(i,t,n,r))&&(!Kc(n)||function(e,t,n,r){let i=n.anyOf.reduce((t,n)=>{let i=new jl;return wm(e,i,n,r)?[...t,i]:t},[]);return Or(i.length,0)&&t.Merge(i)}(i,t,n,r))&&(!kl(n)||function(e,t,n,r){let i=n.oneOf.reduce((t,n)=>{let i=new jl;return wm(e,i,n,r)?[...t,i]:t},[]);return Sr(i.length,1)&&t.Merge(i)}(i,t,n,r))&&(!Cl(n)||!pr(r)||function(e,t,n,r){let i=t.GetIndices();return Tr(r,0,(r,o)=>(i.has(o)||wm(e,t,n.unevaluatedItems,r))&&t.AddIndex(o))}(i,t,n,r))&&(!Nl(n)||!kr(r)||function(e,t,n,r){let i=t.GetKeys();return Tr(Ur(r),0,([r,o])=>i.has(r)||wm(e,t,n.unevaluatedProperties,o)&&t.AddKey(r))}(i,t,n,r))&&(!Bc(n)||function(e,t,n,r){return Tr(n["~refine"],0,(e,t)=>e.check(r))}(0,0,n,r))}function km(e,t,n,r,i,o){return t.Push()&&xm(e,t,n,r,i,o)&&t.Pop()}function xm(e,t,n,r,i,o){if(t.AtCapacity())return!1;let u=ef(e,i);return Dc(i)?function(e,t,n,r,i){return sf(0,0,i)||t.AddError("boolean",n,r,{})}(0,t,n,r,i):!!(+(!Ml(i)||function(e,t,n,r,i,o){return(pr(i.type)?ym(0,0,i.type,0,o):gm(0,0,i.type,0,o))||t.AddError("type",n,r,{type:i.type})}(0,t,n,r,i,o))&+!(kr(o)&&!pr(o)&&!(+(!Pl(i)||function(e,t,n,r,i,o){let u=[];return Cr(i.required,0,e=>{let t=zr(o,e);return t||u.push(e),t})||t.AddError("required",n,r,{requiredProperties:u})}(0,t,n,r,i,o))&+(!Wc(i)||function(e,t,n,r,i,o){let u=rf(uf(i)),s=[];return Cr(Fr(o),0,(a,d)=>{let c=`${n}/additionalProperties`,l=`${r}/${nf(a)}`,f=u.test(a)||km(e,t,c,l,i.additionalProperties,o[a])&&t.AddKey(a);return f||s.push(a),f})||t.AddError("additionalProperties",n,r,{additionalProperties:s})}(u,t,n,r,i,o))&+(!Zc(i)||function(e,t,n,r,i,o){let u=Sr(Fr(o).length,0),s=Cr(Ur(i.dependencies),0,([i,u])=>{let s=`${n}/dependencies/${nf(i)}`;return!zr(o,i)||(pr(u)?u.every(e=>zr(o,e)||t.AddError("dependencies",n,r,{property:i,dependencies:u})):xm(e,t,s,r,u,o))});return u||s}(u,t,n,r,i,o))&+(!Xc(i)||function(e,t,n,r,i,o){let u=Sr(Fr(o).length,0),s=Cr(Ur(i.dependentRequired),0,([e,i])=>!zr(o,e)||Cr(i,0,u=>zr(o,u)||t.AddError("dependentRequired",n,r,{property:e,dependencies:i})));return u||s}(0,t,n,r,i,o))&+(!Qc(i)||function(e,t,n,r,i,o){let u=Sr(Fr(o).length,0),s=Cr(Ur(i.dependentSchemas),0,([i,u])=>{let s=`${n}/dependentSchemas/${nf(i)}`;return!zr(o,i)||xm(e,t,s,r,u,o)});return u||s}(u,t,n,r,i,o))&+(!$l(i)||function(e,t,n,r,i,o){return Cr(Ur(i.patternProperties),0,([i,u])=>{let s=`${n}/patternProperties/${nf(i)}`,a=rf(i);return Cr(Ur(o),0,([n,i])=>{let o=`${r}/${nf(n)}`;return!a.test(n)||km(e,t,s,o,u,i)&&t.AddKey(n)})})}(u,t,n,r,i,o))&+(!Sl(i)||function(e,t,n,r,i,o){let u=Pl(i)?i.required:[];return Cr(Ur(i.properties),0,([i,s])=>{let a=`${n}/properties/${nf(i)}`,d=`${r}/${nf(i)}`,c=()=>!zr(o,i)||km(e,t,a,d,s,o[i])&&t.AddKey(i);return hm(u,i)?c():_m(o,i)||c()})}(u,t,n,r,i,o))&+(!Ol(i)||function(e,t,n,r,i,o){let u=[];return Cr(Fr(o),0,(o,s)=>{let a=`${r}/${nf(o)}`,d=xm(e,t,`${n}/propertyNames`,a,i.propertyNames,o);return d||u.push(o),d})||t.AddError("propertyNames",n,r,{propertyNames:u})}(u,t,n,r,i,o))&+(!vl(i)||function(e,t,n,r,i,o){return lm(0,0,i,o)||t.AddError("minProperties",n,r,{limit:i.minProperties})}(0,t,n,r,i,o))&+(!ml(i)||function(e,t,n,r,i,o){return um(0,0,i,o)||t.AddError("maxProperties",n,r,{limit:i.maxProperties})}(0,t,n,r,i,o))))&+(!pr(o)||!!(+(!Fc(i)||function(e,t,n,r,i,o){return!tf(i)||Tr(o,0,(o,u)=>{let s=`${n}/additionalItems`,a=`${r}/${u}`;return Ir(u,i.items.length)||km(e,t,s,a,i.additionalItems,o)&&t.AddIndex(u)})}(u,t,n,r,i,o))&+(!Hc(i)||function(e,t,n,r,i,o){return df(e,t,i,o)||t.AddError("contains",n,r,{minContains:1})}(u,t,n,r,i,o))&+(!al(i)||tm(u,t,n,r,i,o))&+(!_l(i)||function(e,t,n,r,i,o){return sm(e,t,i,o)||t.AddError("contains",n,r,{minContains:i.minContains})}(u,t,n,r,i,o))&+(!ll(i)||function(e,t,n,r,i,o){let u=_l(i)?i.minContains:1;return nm(e,t,i,o)||t.AddError("contains",n,r,{minContains:u,maxContains:i.maxContains})}(u,t,n,r,i,o))&+(!gl(i)||function(e,t,n,r,i,o){return dm(0,0,i,o)||t.AddError("minItems",n,r,{limit:i.minItems})}(0,t,n,r,i,o))&+(!fl(i)||function(e,t,n,r,i,o){return im(0,0,i,o)||t.AddError("maxItems",n,r,{limit:i.maxItems})}(0,t,n,r,i,o))&+(!Al(i)||function(e,t,n,r,i,o){return Sr(o.length,0)||Cr(i.prefixItems,0,(i,u)=>{let s=`${n}/prefixItems/${u}`,a=`${r}/${u}`;return Er(o.length,u)||km(e,t,s,a,i,o[u])&&t.AddIndex(u)})}(u,t,n,r,i,o))&+(!Tl(i)||function(e,t,n,r,i,o){if(!vm(i))return!0;let u=new Set,s=o.reduce((e,t,n)=>{let r=uo(t);return u.has(r)?[...e,n]:(u.add(r),e)},[]);return Sr(s.length,0)||t.AddError("uniqueItems",n,r,{duplicateItems:s})}(0,t,n,r,i,o))))&+(!xr(o)||!!(+(!yl(i)||function(e,t,n,r,i,o){return cm(0,0,i,o)||t.AddError("minLength",n,r,{limit:i.minLength})}(0,t,n,r,i,o))&+(!pl(i)||function(e,t,n,r,i,o){return om(0,0,i,o)||t.AddError("maxLength",n,r,{limit:i.maxLength})}(0,t,n,r,i,o))&+(!ol(i)||function(e,t,n,r,i,o){return Yp(0,0,i,o)||t.AddError("format",n,r,{format:i.format})}(0,t,n,r,i,o))&+(!xl(i)||function(e,t,n,r,i,o){return mm(0,0,i,o)||t.AddError("pattern",n,r,{pattern:i.pattern})}(0,t,n,r,i,o))))&+(!(br(o)||mr(o))||!!(+(!il(i)||function(e,t,n,r,i,o){return Pf(0,0,i,o)||t.AddError("exclusiveMinimum",n,r,{comparison:">",limit:i.exclusiveMinimum})}(0,t,n,r,i,o))&+(!rl(i)||function(e,t,n,r,i,o){return Rf(0,0,i,o)||t.AddError("exclusiveMaximum",n,r,{comparison:"<",limit:i.exclusiveMaximum})}(0,t,n,r,i,o))&+(!hl(i)||function(e,t,n,r,i,o){return am(0,0,i,o)||t.AddError("minimum",n,r,{comparison:">=",limit:i.minimum})}(0,t,n,r,i,o))&+(!cl(i)||function(e,t,n,r,i,o){return rm(0,0,i,o)||t.AddError("maximum",n,r,{comparison:"<=",limit:i.maximum})}(0,t,n,r,i,o))&+(!bl(i)||function(e,t,n,r,i,o){return fm(0,0,i,o)||t.AddError("multipleOf",n,r,{multipleOf:i.multipleOf})}(0,t,n,r,i,o))))&+(!Rl(i)||function(e,t,n,r,i,o){let u=$f(e,i),s=u.schema??!1,a=new Ll,d=Uc(s)&&xm(u.stack,a,n,r,s,o);return d&&t.Merge([a]),d||t.AddErrors(a.GetErrors()),d}(u,t,n,r,i,o))&+(!El(i)||function(e,t,n,r,i,o){let u=Af(e,i)??!1,s=u?{...e,pendingResource:!0}:e;return Uc(u)&&xm(s,t,n,r,u,o)}(u,t,n,r,i,o))&+(!el(i)||function(e,t,n,r,i,o){let u=If(e,i)??!1,s=u?{...e,pendingResource:!0}:e;return Uc(u)&&xm(s,t,n,r,u,o)}(u,t,n,r,i,o))&+(!Jc(i)||function(e,t,n,r,i,o){return af(0,0,i,o)||t.AddError("const",n,r,{allowedValue:i.const})}(0,t,n,r,i,o))&+(!nl(i)||function(e,t,n,r,i,o){return Ef(0,0,i,o)||t.AddError("enum",n,r,{allowedValues:i.enum})}(0,t,n,r,i,o))&+(!sl(i)||function(e,t,n,r,i,o){let u=!ql(i)||i.then,s=!tl(i)||i.else,a=new Ll,d=xm(e,a,`${n}/if`,r,i.if,o)?xm(e,a,`${n}/then`,r,u,o)||t.AddError("if",n,r,{failingKeyword:"then"}):xm(e,t,`${n}/else`,r,s,o)||t.AddError("if",n,r,{failingKeyword:"else"});return d&&t.Merge([a]),d}(u,t,n,r,i,o))&+(!wl(i)||function(e,t,n,r,i,o){return pm(e,t,i,o)||t.AddError("not",n,r,{})}(u,t,n,r,i,o))&+(!Gc(i)||function(e,t,n,r,i,o){let u=[],s=i.allOf.reduce((t,i,s)=>{let a=`${n}/allOf/${s}`,d=new Ll,c=xm(e,d,a,r,i,o);return c||u.push(d),c?[...t,d]:t},[]),a=Sr(s.length,i.allOf.length)&&t.Merge(s);return a||u.forEach(e=>t.AddErrors(e.GetErrors())),a}(u,t,n,r,i,o))&+(!Kc(i)||function(e,t,n,r,i,o){let u=[],s=i.anyOf.reduce((t,i,s)=>{let a=new Ll,d=xm(e,a,`${n}/anyOf/${s}`,r,i,o);return d||u.push(a),d?[...t,a]:t},[]),a=Or(s.length,0)&&t.Merge(s);return a||u.forEach(e=>t.AddErrors(e.GetErrors())),a||t.AddError("anyOf",n,r,{})}(u,t,n,r,i,o))&+(!kl(i)||function(e,t,n,r,i,o){let u=[],s=[],a=i.oneOf.reduce((t,i,a)=>{let d=new Ll,c=xm(e,d,`${n}/oneOf/${a}`,r,i,o);return c&&s.push(a),c||u.push(d),c?[...t,d]:t},[]),d=Sr(a.length,1)&&t.Merge(a);return!d&&Sr(s.length,0)&&u.forEach(e=>t.AddErrors(e.GetErrors())),d||t.AddError("oneOf",n,r,{passingSchemas:s})}(u,t,n,r,i,o))&+(!Cl(i)||!pr(o)||function(e,t,n,r,i,o){let u=t.GetIndices(),s=[];return Cr(o,0,(o,a)=>{let d=new Ll,c=(u.has(a)||xm(e,d,n,r,i.unevaluatedItems,o))&&t.AddIndex(a);return c||s.push(a),c})||t.AddError("unevaluatedItems",n,r,{unevaluatedItems:s})}(u,t,n,r,i,o))&+(!Nl(i)||!kr(o)||function(e,t,n,r,i,o){let u=t.GetKeys(),s=[];return Cr(Ur(o),0,([o,a])=>{let d=new Ll,c=u.has(o)||xm(e,d,n,r,i.unevaluatedProperties,a)&&t.AddKey(o);return c||s.push(o),c})||t.AddError("unevaluatedProperties",n,r,{unevaluatedProperties:s})}(u,t,n,r,i,o)))&&(!Bc(i)||function(e,t,n,r,i,o){return Cr(i["~refine"],0,(e,i)=>e.check(o)||t.AddError("~refine",n,r,{index:i,message:e.error(o)}))}(0,t,n,r,i,o))}Qp.clear(),Qp.set("date-time",jf),Qp.set("date",Tf),Qp.set("duration",Bf),Qp.set("email",Df),Qp.set("hostname",kp),Qp.set("idn-email",$p),Qp.set("idn-hostname",Ap),Qp.set("ipv4",Op),Qp.set("ipv6",Ep),Qp.set("iri-reference",qp),Qp.set("iri",Cp),Qp.set("json-pointer-uri-fragment",jp),Qp.set("json-pointer",Bp),Qp.set("regex",zp),Qp.set("relative-json-pointer",Up),Qp.set("time",Nf),Qp.set("uri-reference",Wp),Qp.set("uri-template",Kp),Qp.set("uri",Hp),Qp.set("url",Vp),Qp.set("uuid",Xp);var $m=0;function Am(...e){let[t,n,r]=Bi(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return function(...e){let[t,n,r]=Bi(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return wm(Dl(t,n),new jl,n,r)}(t,n,r)}function Sm(...e){let[t,n,r]=Bi(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]}),[i,o]=function(...e){let[t,n,r]=Bi(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]}),i=Dl(t,n),o=new Ll,u=xm(i,o,"#","",n,r),s=o.GetErrors(),a=ao();return[u,s.map(e=>({...e,message:a(e)}))]}(t,n,r);return o}class Om extends Error{constructor(e,t,n){super(e),Object.defineProperty(this,"cause",{value:{source:e,errors:n,value:t},writable:!1,configurable:!1,enumerable:!1})}}function Im(e,t){let n=zr(t,"unevaluatedProperties")?{additionalProperties:t.unevaluatedProperties}:{},r=bc(gc(e,t));return Ti(r)?function(e,t){return sc(e,t)}(r,n):r}function Em(e){return zr(e,"additionalProperties")?e.additionalProperties:void 0}function Rm(e){return ti(e)}function Pm(e,t,n){return pi(t)?function(e,t,n){return pr(n)?n.map(n=>Pm(e,t.items,n)):n}(e,t,n):Li(t)?function(e,t,n){return Pm({...e,...t.$defs},vi(t.$ref),n)}(e,t,n):Wi(t)?function(e,t,n){return Pm(e,Im(e,t),n)}(e,t,n):Ti(t)?function(e,t,n){if(!kr(n)||pr(n))return n;let r=Em(t);for(let i of Fr(n))zr(t.properties,i)?n[i]=Pm(e,t.properties[i],n[i]):hr(r)&&Sr(r,!0)||si(r)&&Am(e,r,n[i])?n[i]=Pm(e,r,n[i]):delete n[i];return n}(e,t,n):Cu(t)?function(e,t,n){if(!kr(n))return n;let r=Em(t),[i,o]=[new RegExp(qu(t)),Tu(t)];for(let t of Fr(n))i.test(t)?n[t]=Pm(e,o,n[t]):hr(r)&&Sr(r,!0)||si(r)&&Am(e,r,n[t])?n[t]=Pm(e,r,n[t]):delete n[t];return n}(e,t,n):bi(t)?function(e,t,n){return zr(e,t.$ref)?Pm(e,e[t.$ref],n):n}(e,t,n):Xo(t)?function(e,t,n){if(!pr(n))return n;let r=Math.min(n.length,t.items.length);for(let i=0;i<r;i++)n[i]=Pm(e,t.items[i],n[i]);return Or(n.length,r)?n.slice(0,r):n}(e,t,n):No(t)?function(e,t,n){for(let r of t.anyOf){let t=Pm(e,r,Rm(n));if(Am(e,r,t))return t}return n}(e,t,n):n}function qm(e){return e.map(e=>Mm(e))}function Mm(e){return function(e,t){for(let n of Fr(e))zr(t,n)||(t[n]=e[n]);return t}(e,pi(e)?fi(Mm(e.items),mi(e)):Wi(e)?Fi(qm(e.allOf)):No(e)?Co(qm(xc(e.anyOf))):Ti(e)?Mi(function(e){let t={};for(let n of Fr(e))t[n]=Mm(e[n]);return t}(e.properties)):Cu(e)?Ru(Mu(e),Mm(Tu(e))):Xo(e)?Zo(qm(e.items)):e)}function Tm(e){return Mm(e)}function Cm(...e){let[t,n,r]=Bi(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return Pm(t,Vr().unionPrioritySort?Tm(n):n,r)}function Nm(e){return kr(e)&&zr(e,"value")}function jm(e){return{value:e}}var Lm=/^-?(0|[1-9]\d*)n$/,Bm=/^-?(0|[1-9]\d*)\.\d+$/,zm=/^-?(0|[1-9]\d*)$/;function Dm(e){let t=e.toLowerCase();return function(e){return Lm.test(e)}(e)?jm(BigInt(e.slice(0,e.length-1))):function(e){return Bm.test(e)}(e)?jm(BigInt(e.split(".")[0])):function(e){return zm.test(e)}(e)?jm(BigInt(e)):Sr(t,"false")?jm(BigInt(0)):Sr(t,"true")?jm(BigInt(1)):void 0}function Um(e){return mr(e)?jm(e):hr(e)?function(e){return Sr(e,!0)?jm(BigInt(1)):jm(BigInt(0))}(e):br(e)?jm(BigInt(Math.trunc(e))):vr(e)?jm(BigInt(0)):xr(e)?Dm(e):Ar(e)?jm(BigInt(0)):void 0}function Fm(e){return mr(e)?function(e){return Sr(e,BigInt(0))?jm(!1):Sr(e,BigInt(1))?jm(!0):void 0}(e):hr(e)?jm(e):br(e)?function(e){return Sr(e,0)?jm(!1):Sr(e,1)?jm(!0):void 0}(e):vr(e)?jm(!1):xr(e)?function(e){return Sr(e.toLowerCase(),"false")?jm(!1):Sr(e.toLowerCase(),"true")?jm(!0):Sr(e,"0")?jm(!1):Sr(e,"1")?jm(!0):void 0}(e):Ar(e)?jm(!1):void 0}function Wm(e){return mr(e)?function(e){return Sr(e,BigInt(0))?jm(null):void 0}(e):hr(e)?function(e){return Sr(e,!1)?jm(null):void 0}(e):br(e)?function(e){return Sr(e,0)?jm(null):void 0}(e):vr(e)?jm(null):xr(e)?function(e){let t=e.toLowerCase();return Sr(t,"undefined")||Sr(t,"null")||Sr(e,"")||Sr(e,"0")?jm(null):void 0}(e):Ar(e)?jm(null):void 0}var Gm=BigInt(Number.MAX_SAFE_INTEGER),Km=BigInt(Number.MIN_SAFE_INTEGER);function Jm(e){return mr(e)?function(e){return e<=Gm&&e>=Km?jm(Number(e)):void 0}(e):hr(e)?function(e){return jm(e?1:0)}(e):br(e)?jm(e):vr(e)?jm(0):xr(e)?function(e){let t=+e;if(br(t))return jm(t);let n=e.toLowerCase();if(Sr(n,"false"))return jm(0);if(Sr(n,"true"))return jm(1);let r=Um(e);return Nm(r)&&r.value<=Gm&&r.value>=Km?jm(Number(r.value)):void 0}(e):Ar(e)?jm(0):void 0}function Hm(e){return mr(e)||hr(e)||br(e)?jm(e.toString()):vr(e)?jm("null"):xr(e)?jm(e):Ar(e)?jm(""):void 0}function Vm(e){return mr(e)?function(e){return Sr(e,BigInt(0))?jm(void 0):void 0}(e):hr(e)?function(e){return Sr(e,!1)?jm(void 0):void 0}(e):br(e)?function(e){return Sr(e,0)?jm(void 0):void 0}(e):vr(e)?jm(void 0):xr(e)?function(e){let t=e.toLowerCase();return Sr(t,"undefined")||Sr(t,"null")||Sr(e,"")||Sr(e,"0")?jm(void 0):void 0}(e):Ar(e)?jm(e):void 0}function Zm(e,t,n){return function(e){return pr(e)?jm(e):jm([e])}(n).value.map(n=>nh(e,t.items,n))}function Xm(e,t,n){return Sr(t.const,n)?n:function(e){return Ao(e)&&mr(e.const)}(t)?function(e,t,n){let r=Um(n);return Nm(r)&&Sr(t.const,r.value)?r.value:n}(0,t,n):function(e){return Ao(e)&&hr(e.const)}(t)?function(e,t,n){let r=Fm(n);return Nm(r)&&Sr(t.const,r.value)?r.value:n}(0,t,n):xo(t)?function(e,t,n){let r=Jm(n);return Nm(r)&&Sr(t.const,r.value)?r.value:n}(0,t,n):$o(t)?function(e,t,n){let r=Hm(n);return Nm(r)&&Sr(t.const,r.value)?r.value:n}(0,t,n):Gi()}function Qm(e,t,n,r){let i=Fr(r);for(let[o,u]of t)for(let t of i)o.test(t)||(r[t]=nh(e,n,r[t]));return r}function Ym(e,t,n){return Ri(e)&&Ar(n[t])}function eh(e,t,n){return wr(n)?function(e,t,n){let r=Dr(t.properties),i=Fr(n);for(let[t,o]of r)for(let r of i)t.test(r)&&!Ym(o,r,n)&&(n[r]=nh(e,o,n[r]));return zr(t,"additionalProperties")&&kr(t.additionalProperties)?Qm(e,r,t.additionalProperties,n):n}(e,t,n):n}function th(e,t,n){return wr(n)?function(e,t,n){let r=Dr(t.patternProperties),i=Fr(n);for(let[t,o]of r)for(let r of i)t.test(r)&&(n[r]=nh(e,o,n[r]));return zr(t,"additionalProperties")&&kr(t.additionalProperties)?Qm(e,r,t.additionalProperties,n):n}(e,t,n):n}function nh(e,t,n){return pi(t)?Zm(e,t,n):mo(t)?function(e,t,n){let r=Um(n);return Nm(r)?r.value:n}(0,0,n):_o(t)?function(e,t,n){let r=Fm(n);return Nm(r)?r.value:n}(0,0,n):Li(t)?function(e,t,n){return nh({...e,...t.$defs},vi(t.$ref),n)}(e,t,n):Ui(t)?function(e,t,n){return nh(e,bc(t),n)}(e,t,n):vo(t)?function(e,t,n){let r=Jm(n);return Nm(r)?Math.trunc(r.value):n}(0,0,n):Wi(t)?function(e,t,n){return nh(e,bc(gc(e,t)),n)}(e,t,n):Ao(t)?Xm(0,t,n):Oo(t)?function(e,t,n){let r=Wm(n);return Nm(r)?r.value:n}(0,0,n):Ro(t)?function(e,t,n){let r=Jm(n);return Nm(r)?r.value:n}(0,0,n):Ti(t)?eh(e,t,n):Cu(t)?th(e,t,n):bi(t)?function(e,t,n){return zr(e,t.$ref)?nh(e,e[t.$ref],n):n}(e,t,n):To(t)?function(e,t,n){let r=Hm(n);return Nm(r)?r.value:n}(0,0,n):ys(t)?function(e,t,n){return nh(e,bc(t),n)}(e,t,n):Xo(t)?function(e,t,n){if(!pr(n))return n;for(let r=0;r<Math.min(t.items.length,n.length);r++)n[r]=nh(e,t.items[r],n[r]);return n}(e,t,n):ju(t)?function(e,t,n){let r=Vm(n);return Nm(r)?r.value:n}(0,0,n):No(t)?function(e,t,n){if(t.anyOf.some(t=>Am(e,t,n)))return n;let r=t.anyOf.map(t=>nh(e,t,Rm(n))).find(n=>Am(e,t,n));return Ar(r)?n:r}(e,t,n):Lu(t)?function(e,t,n){return Nm(Vm(n))?void 0:n}(0,0,n):n}function rh(...e){let[t,n,r]=Bi(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return nh(t,n,r)}function ih(e,t,n){let r=Vc(t)?function(e,t){return Ar(t)?gr(e.default)?e.default():Rm(e.default):t}(t,n):n;return pi(t)?function(e,t,n){if(!pr(n))return n;for(let r=0;r<n.length;r++)n[r]=ih(e,t.items,n[r]);return n}(e,t,r):Li(t)?function(e,t,n){return ih({...e,...t.$defs},vi(t.$ref),n)}(e,t,r):Wi(t)?function(e,t,n){return ih(e,bc(gc(e,t)),n)}(e,t,r):Ti(t)?function(e,t,n){if(!kr(n))return n;let r=Fr(t.properties);for(let i of r){let r=ih(e,t.properties[i],n[i]);(!Ar(r)||!Ri(t.properties[i])&&zr(t.properties[i],"default"))&&(n[i]=r)}if(!Wc(t)||hr(t.additionalProperties))return n;for(let i of Fr(n))r.includes(i)||(n[i]=ih(e,t.additionalProperties,n[i]));return n}(e,t,r):Cu(t)?function(e,t,n){if(!kr(n))return n;let[r,i]=[new RegExp(qu(t)),Tu(t)];for(let t of Fr(n))r.test(t)&&Vc(i)&&(n[t]=ih(e,i,n[t]));if(!Wc(t))return n;for(let i of Fr(n))r.test(i)||(n[i]=ih(e,t.additionalProperties,n[i]));return n}(e,t,r):bi(t)?function(e,t,n){return zr(e,t.$ref)?ih(e,e[t.$ref],n):n}(e,t,r):Xo(t)?function(e,t,n){if(!pr(n))return n;let[r,i]=[t.items,Math.max(t.items.length,n.length)];for(let t=0;t<i;t++)t<r.length&&(n[t]=ih(e,r[t],n[t]));return n}(e,t,r):No(t)?function(e,t,n){for(let r of t.anyOf){let t=ih(e,r,Rm(n));if(Am(e,r,t))return t}return n}(e,t,r):r}function oh(...e){let[t,n,r]=Bi(e,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return ih(t,n,r)}function uh(e){return(...t)=>{let[n,r,i]=Bi(t,{3:(e,t,n)=>[e,t,n],2:(e,t)=>[{},e,t]});return e.reduce((e,t)=>t(n,r,e),i)}}function sh(e,t,n,r){return function(e){return si(e)&&zr(e,"~codec")&&kr(e["~codec"])&&zr(e["~codec"],"encode")&&zr(e["~codec"],"decode")}(n)?Sr(e,"Decode")?function(e,t,n){return t["~codec"].decode(n)}(0,n,r):function(e,t,n){return t["~codec"].encode(n)}(0,n,r):r}function ah(e,t,n,r){return Sr(e,"Decode")?function(e,t,n,r){if(!pr(r))return r;for(let i=0;i<r.length;i++)r[i]=gh(e,t,n.items,r[i]);return sh(e,0,n,r)}(e,t,n,r):function(e,t,n,r){let i=sh(e,0,n,r);if(!pr(i))return i;for(let r=0;r<i.length;r++)i[r]=gh(e,t,n.items,i[r]);return i}(e,t,n,r)}function dh(e){return e.reduce((e,t)=>({...e,...t}),{})}function ch(e,t){for(let n of t)if(!Gr(e,n))return n;return e}function lh(e,t,n,r){return Sr(e,"Decode")?function(e,t,n,r){if(Sr(n.allOf.length,0))return sh(e,0,n,r);let i=n.allOf.map(n=>gh(e,t,n,Cm(n,Rm(r)))),o=i.every(e=>kr(e))?dh(i):ch(r,i);return sh(e,0,n,o)}(e,t,n,r):function(e,t,n,r){if(Sr(n.allOf.length,0))return sh(e,0,n,r);let i=sh(e,0,n,r),o=n.allOf.map(n=>gh(e,t,n,Cm(n,Rm(i))));return o.every(e=>kr(e))?dh(o):ch(i,o)}(e,t,n,r)}function fh(e,t,n,r){return Sr(e,"Decode")?function(e,t,n,r){if(!wr(r))return r;for(let i of Fr(n.properties))zr(r,i)&&!Ym(n.properties[i],i,r)&&(r[i]=gh(e,t,n.properties[i],r[i]));return sh(e,0,n,r)}(e,t,n,r):function(e,t,n,r){let i=sh(e,0,n,r);if(!wr(i))return i;for(let r of Fr(n.properties))zr(i,r)&&!Ym(n.properties[r],r,i)&&(i[r]=gh(e,t,n.properties[r],i[r]));return i}(e,t,n,r)}function ph(e,t,n,r){return Sr(e,"Decode")?function(e,t,n,r){if(!wr(r))return r;let i=new RegExp(qu(n));for(let o of Fr(r))i.test(o)&&(r[o]=gh(e,t,Tu(n),r[o]));return sh(e,0,n,r)}(e,t,n,r):function(e,t,n,r){let i=sh(e,0,n,r);if(!wr(i))return i;let o=new RegExp(qu(n));for(let r of Fr(i))o.test(r)&&(i[r]=gh(e,t,Tu(n),i[r]));return i}(e,t,n,r)}function mh(e,t,n,r){return zr(t,n.$ref)?gh(e,t,t[n.$ref],r):r}function hh(e,t,n,r){return Sr(e,"Decode")?function(e,t,n,r){if(!pr(r))return r;for(let i=0;i<Math.min(n.items.length,r.length);i++)r[i]=gh(e,t,n.items[i],r[i]);return sh(e,0,n,r)}(e,t,n,r):function(e,t,n,r){let i=sh(e,0,n,r);if(!pr(i))return r;for(let r=0;r<Math.min(n.items.length,i.length);r++)i[r]=gh(e,t,n.items[r],i[r]);return i}(e,t,n,r)}function _h(e,t,n,r){return Sr(e,"Decode")?function(e,t,n,r){for(let i of n.anyOf)if(Am(t,i,r))return sh(e,0,n,gh(e,t,i,r));return r}(e,t,n,r):function(e,t,n,r){let i=sh(e,0,n,r);for(let r of n.anyOf){let n=gh(e,t,r,Rm(i));if(Am(t,r,n))return n}return i}(e,t,n,r)}function gh(e,t,n,r){return pi(n)?ah(e,t,n,r):Li(n)?function(e,t,n,r){return sh(e,0,n,r=gh(e,{...t,...n.$defs},vi(n.$ref),r))}(e,t,n,r):Wi(n)?lh(e,t,n,r):Ti(n)?fh(e,t,n,r):Cu(n)?ph(e,t,n,r):bi(n)?function(e,t,n,r){return Sr(e,"Decode")?sh(e,0,n,mh(e,t,n,r)):mh(e,t,n,sh(e,0,n,r))}(e,t,n,r):Xo(n)?hh(e,t,n,r):No(n)?_h(e,t,n,r):sh(e,0,n,r)}class yh extends Om{constructor(e,t){super("Decode",e,t)}}uh([(e,t,n)=>Rm(n),(e,t,n)=>oh(e,t,n),(e,t,n)=>rh(e,t,n),(e,t,n)=>Cm(e,t,n),(e,t,n)=>function(e,t,n){if(!Am(e,t,n))throw new yh(n,Sm(e,t,n));return n}(e,t,n),(e,t,n)=>function(e,t,n){return gh("Decode",e,Vr().unionPrioritySort?Tm(t):t,n)}(e,t,n)]);class vh extends Om{constructor(e,t){super("Encode",e,t)}}uh([(e,t,n)=>Rm(n),(e,t,n)=>function(e,t,n){return gh("Encode",e,Vr().unionPrioritySort?Tm(t):t,n)}(e,t,n),(e,t,n)=>oh(e,t,n),(e,t,n)=>rh(e,t,n),(e,t,n)=>Cm(e,t,n),(e,t,n)=>function(e,t,n){if(!Am(e,t,n))throw new vh(n,Sm(e,t,n));return n}(e,t,n)]);class bh extends Om{constructor(e,t){super("Parse",e,t)}}function wh(e,t,n){!function(){let e=Vr();$m=e.maxErrors,e.maxErrors=e.maxParseErrors}();let r=Sm(e,t,n);if(Vr().maxErrors=$m,!Am(e,t,n))throw new bh(n,r);return n}uh([(e,t,n)=>Rm(n),(e,t,n)=>oh(e,t,n),(e,t,n)=>rh(e,t,n),(e,t,n)=>Cm(e,t,n),(e,t,n)=>wh(e,t,n)]),Co([Mi({type:ko("insert"),path:Mo(),value:Ci()}),Object({type:ko("update"),path:Mo(),value:Ci()}),Mi({type:ko("delete"),path:Mo()})]);var kh=200;function xh(e,t,n){return{kind:"error",error:h(e,t,n)}}function $h(e){return Number.isSafeInteger(e)&&e>0}function Ah(e){return Buffer.from(`t1:${e.revision}:${e.offset}`,"utf8").toString("base64url")}function Sh(e,t={}){let n=t.mode??"tail";if("status"!==n&&"tail"!==n&&"page"!==n)return xh("invalid_arguments",`Unknown read mode "${String(n)}".`,'Retry with mode set to "status", "tail", or "page", or call thread_list to confirm the thread first.');if(void 0!==t.tail_items){if(!$h(t.tail_items))return xh("invalid_arguments",`tail_items must be a positive whole number; received ${String(t.tail_items)}.`,"Retry with tail_items between 1 and 200, or omit it to take the default 60.");if(t.tail_items>kh)return xh("invalid_arguments",`tail_items ${t.tail_items} exceeds the 200-item cap.`,"Retry with tail_items at most 200, then page backward with the returned cursor if you need more.")}if(void 0!==t.max_bytes){if(!$h(t.max_bytes))return xh("invalid_arguments",`max_bytes must be a positive whole number; received ${String(t.max_bytes)}.`,"Retry with max_bytes between 1 and 1048576, or omit it to take the default 131072.");if(t.max_bytes>Ac)return xh("message_too_large",`max_bytes ${t.max_bytes} exceeds the 1048576-byte hard cap.`,"Re-read with max_bytes at most 1048576 and follow next_cursor for the rest of the transcript.")}let r,i,o,u=t.max_bytes??$c,s=t.tail_items??60,a=null;if(void 0!==t.cursor&&(a=function(e){if("string"!=typeof e||0===e.length)return null;let t;try{t=Buffer.from(e,"base64url").toString("utf8")}catch{return null}let n=t.split(":");if(3!==n.length)return null;let[r,i,o]=n;if("t1"!==r)return null;if(!/^\d+\.[0-9a-z]+$/.test(i))return null;let u=Number(o);return!Number.isSafeInteger(u)||u<0?null:{revision:i,offset:u}}(t.cursor),null===a))return xh("cursor_invalid","The cursor is not a cursor this reader issued.","Re-read the thread without a cursor to get a fresh next_cursor, or call thread_list to confirm the thread address.");if("live"===e.kind)i="live_host",o=!1,r={entries:e.entries(),skippedLines:0};else{i="session_jsonl",o=!0!==e.live_host_present;let t=function(e){let t;try{t=ar(e,"r")}catch{return"missing"}try{let e=[],n=0,r="",i=new cr("utf8"),o=Buffer.allocUnsafe(65536),u=t=>{let r,i=t.trim();if(0!==i.length){try{r=JSON.parse(i)}catch{return void(n+=1)}"object"!=typeof r||null===r||Array.isArray(r)?n+=1:e.push(r)}};for(;;){let e=dr(t,o,0,o.length,null);if(0===e)break;r+=i.write(o.subarray(0,e));let n=0,s=r.indexOf("\n",n);for(;-1!==s;)u(r.slice(n,s)),n=s+1,s=r.indexOf("\n",n);r=r.slice(n)}return u(r+i.end()),{entries:e,skippedLines:n}}catch{return{entries:[],skippedLines:0}}finally{void 0!==t&&sr(t)}}(e.path);if("missing"===t)return xh("not_found",`No session transcript exists at ${e.path}.`,"Call thread_list to get a current thread_id, then read that thread instead.");r=t}let d=r.entries,c=function(e){let t=2166136261;for(let n of e){let e=`${String(n.id??"")}|${String(n.timestamp??"")}`;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619)}return`${e.length}.${(t>>>0).toString(36)}`}(d);if(null!==a&&a.revision!==c)return xh("cursor_stale","The transcript changed after this cursor was issued, so its position no longer names the same entries.","Re-read the thread without a cursor to restart from a current revision.");let l={kind:"ok",source:i,source_incomplete:o,mode:n,total_items:d.length,max_bytes:u,skipped_lines:r.skippedLines};if("status"===n)return{...l,items:[],truncated:!1,next_cursor:null,encoded_bytes:0};let f="tail"===n?Math.max(0,d.length-s):a?.offset??0,p=d.slice(f),m=[],h=0,_=0;for(let e of p){let t=Buffer.byteLength(JSON.stringify(e),"utf8");if(m.length>0&&h+t>u)break;m.push(e),h+=t,_+=1}let g=f+_,y=g<d.length;return{...l,items:m,truncated:y,next_cursor:y?Ah({revision:c,offset:g}):null,encoded_bytes:h}}function Oh(e,t,n){let r=function(e,t){let n="string"==typeof t?t.trim():"";if(0===n.length)return[];let r=Ot();return e.filter(e=>It(e.cwd,n,r))}(nr(e,t),e.callerWorkspaceRoot()),i=e=>!0===n||r.some(t=>t.thread_id===e),o=t.sessions.filter(e=>i(e.durableSessionId??e.sessionId)),u=Yn(e,t),s=u.filter(e=>void 0!==e.error_note&&"live"!==e.status&&i(e.thread_id)),a=new Map(u.map((e,t)=>[e.thread_id,t]));return{kind:"ok",threads:[...o.map(e=>function(e,t){let n=e.durableSessionId??e.sessionId,{name:r,createdAt:i,updatedAt:o,created_at:u,updated_at:s,...a}=e,d=t?.created_at??e.created_at??e.createdAt??(new Date).toISOString();return{...a,thread_id:n,name:t?.title??Bt(e.name,null)??"",status:"closed"===e.status?"resumable":"live",created_at:d,updated_at:void 0===t?e.updated_at??e.updatedAt??d:t.updated_at,...void 0===t?{}:{endpoint:t.endpoint,surface:t.surface,alive:t.alive}}}(e,(e=>u.find(t=>t.thread_id===(e.durableSessionId??e.sessionId)&&t.source_host===(e.socket??t.source_host)))(e))),...s.map(tr)].sort((e,t)=>(a.get(e.thread_id)??Number.MAX_SAFE_INTEGER)-(a.get(t.thread_id)??Number.MAX_SAFE_INTEGER)),scope:!0===n?"all":"workspace"}}async function Ih(e,t,n,r){let i=rr(e,nr(e,t),n.thread,r,n.all_scope);if("error"===i.kind)return{kind:"error",error:i};let o=(u=t,s=i.entry.thread_id,u.sessions.find(e=>(e.durableSessionId??e.sessionId)===s));var u,s;if(void 0===o)return function(e,t,n,r){let i=Yn(e,t).find(e=>e.thread_id===n);if(void 0===i||void 0===i.error_note||null===i.session_path)return o="not_resumable",u="The thread has no live owner.",s="Retry when the target is live.",{kind:"error",error:h(o,u,s,a)};var o,u,s,a;let d=Sh({kind:"jsonl",path:i.session_path,live_host_present:!1},{mode:"tail",max_bytes:r.max_bytes,cursor:r.cursor});if("error"===d.kind)return{kind:"error",error:d.error};let c=d.items.flatMap(e=>{let t=e.message;return"message"!==e.type||"object"!=typeof t||null===t||Array.isArray(t)?[]:"user"===t.role||"assistant"===t.role||"toolResult"===t.role?[t]:[]}).map((e,t)=>({seq:t+1,role:ir(e.role),content:JSON.stringify(e.content??e)}));return{kind:"ok",thread_id:n,items:c,truncated:d.truncated,...null===d.next_cursor?{}:{next_cursor:d.next_cursor},source:d.source,source_incomplete:d.source_incomplete,error_note:i.error_note}}(e,t,i.entry.thread_id,n);let a=await function(e,t){return void 0!==t.socket&&void 0!==e.host.endpoint?e.host.endpoint(t.socket):e.host}(e,o).getMessages(function(e){return e.sessionId}(o)),d=Sh({kind:"live",entries:()=>a},{mode:"tail",max_bytes:n.max_bytes,cursor:n.cursor});return"error"===d.kind?{kind:"error",error:d.error}:{kind:"ok",thread_id:i.entry.thread_id,items:d.items.map((e,t)=>({seq:t+1,role:ir(e.role),content:JSON.stringify(e.content??e)})),truncated:d.truncated,...null===d.next_cursor?{}:{next_cursor:d.next_cursor},source:d.source}}function Eh(e,t,n,r){return{kind:"error",error:h(e,t,n,r)}}function Rh(e){let t=e instanceof Error?e.message:String(e);return t.startsWith("host_unavailable:")?Eh("host_unavailable",`The thread host is unavailable at ${t.slice(17)}.`,"Retry when a host or terminal session is running."):t.startsWith("unsupported:")?Eh("unsupported",`The target's endpoint does not accept ${t.slice(12)}.`,"Use thread read to follow the session.",{command:t.slice(12)}):Eh("internal_error",`Thread operation failed: ${t}`,"Run omo thread list and retry after checking the target.")}async function Ph(e){try{return await e()}catch(e){return Rh(e)}}function qh(e){let t=`cli:${e.uid}`,n={...e.env??process.env,OMO_CODING_AGENT_DIR:e.agentDir},r=e.engineStatusAll,i=e.host??Rn(0,{env:n,...void 0===r?{}:{statusAll:async()=>An(await r())}}),o=e.store??l({agentDir:e.agentDir,...void 0===e.workerModuleUrl?{}:{workerModuleUrl:e.workerModuleUrl}}),u=e.now??o.now,s={host:i,store:o,stateDirectory:e.agentDir,sessionsDirectory:()=>p(e.agentDir,"sessions"),callerSessionId:()=>Zn,callerWorkspaceRoot:()=>e.cwd,now:u},a=()=>Qn(s),{engine:d,relay:c,endpoints:m,locate:h}=ur(s,()=>Qn(s,{offline:!0}));async function g(e,t){let n=await async function(e,t,n,r,i){return rr(e,Zt(er(e,await Xn(e,n,()=>t({offline:!0})),n,i)),n,r,i)}(s,e=>Qn(s,e),e,Zn,t);return"error"===n.kind?{kind:"error",error:n}:{id:n.entry.thread_id}}return{principal:t,list:e=>Ph(async()=>Oh(s,await a(),e.all_scope)),read:e=>Ph(async()=>Ih(s,await a(),{thread:e.thread,max_bytes:e.max_bytes,cursor:e.cursor,all_scope:e.all_scope},Zn)),send:t=>Ph(async()=>void 0!==t.binding_id?await async function(e){if(void 0!==e.thread){let t=await o.bindingView({now:u(),binding_id:e.binding_id});if(null===t||t.session_durable_id!==e.thread){let n=await g(e.thread,e.all_scope);if("kind"in n)return n;if(null!==t&&t.session_durable_id!==n.id)return Eh("invalid_arguments",`Binding ${t.binding_id} delivers to session ${t.session_durable_id}, not ${n.id}.`,"Drop the target (the binding names its session) or pass the binding of that session.",{binding_id:t.binding_id,session:t.session_durable_id})}}return void 0!==e.expected_turn_id?Eh("invalid_arguments","A binding message never steers, so it takes no expected_turn_id.","Drop expected_turn_id."):"steer"===e.mode?Eh("invalid_arguments","A binding message is delivered as auto or follow_up, never steer.","Send with mode auto or follow_up, or omit it for the binding's inbound_mode."):await c.inbound({binding_id:e.binding_id,event_id:e.idempotency_key??f(),text:e.text,...void 0===e.author?{}:{author:e.author},...void 0===e.mode?{}:{mode:e.mode}})}({...t,binding_id:t.binding_id}):void 0===t.thread?Eh("invalid_arguments","A send without a binding needs a target session.","Pass the target session, or --binding to deliver through a binding."):void 0!==t.author?Eh("invalid_arguments","An author names a human in a bound external thread; a send without a binding has none.","Pass binding_id with the author, or drop the author."):await d.deliver({sender:{kind:"cli",uid:e.uid,user:e.user},target:t.thread,text:t.text,...void 0===t.mode?{}:{mode:t.mode},...void 0===t.expected_turn_id?{}:{expected_turn_id:t.expected_turn_id},...void 0===t.all_scope?{}:{all_scope:t.all_scope},...void 0===t.idempotency_key?{}:{idempotency_key:t.idempotency_key}})),bind:e=>Ph(async()=>{let n=await g(e.session,e.all_scope);return"kind"in n?n:await c.bind({principal:t,...Mh(e),binding:{...e.binding,session_durable_id:n.id}})}),unbind:e=>Ph(()=>c.unbind({principal:t,...Mh(e),binding_id:e.binding_id,expected_revision:e.expected_revision})),rebind:e=>Ph(async()=>{let n=await g(e.session,e.all_scope);return"kind"in n?n:await c.rebind({principal:t,...Mh(e),binding_id:e.binding_id,expected_revision:e.expected_revision,session_durable_id:n.id})}),bindings:e=>Ph(async()=>{let{session:t,all_scope:n,cursor:r,limit:i,...o}=e,u=void 0===t?void 0:await g(t,n);return void 0!==u&&"kind"in u?u:await c.bindings({filter:{...o,...void 0===u?{}:{session_durable_id:u.id}},...void 0===r?{}:{cursor:r},...void 0===i?{}:{limit:i}})}),report:e=>Ph(async()=>{let n=S.find(t=>t===e.kind);if(void 0===n)return Eh("invalid_arguments",`The report kind must be one of ${S.join(", ")}.`,"Pass milestone, report, question or completion.");let r=e.request_kind;if(void 0!==r&&("string"!=typeof(i=r)||!_.includes(i)))return Eh("invalid_arguments",`The request kind must be one of ${_.join(", ")}.`,"Pass question, select, confirm, input or editor.");var i;let o=await g(e.session,e.all_scope);if("kind"in o)return o;let u=await c.report({principal:t,...Mh(e),session_durable_id:o.id,event:n,text:e.text,...void 0===e.binding_id?{}:{binding_id:e.binding_id},...void 0===e.request_id?{}:{request_id:e.request_id},...void 0===r?{}:{request_kind:r}});if("ok"!==u.kind)return u;let{arm_seq:s,...a}=u;return a.armed&&await async function(e){let t=await h(e).catch(()=>null);null!==t&&await m.wake(t,[]).catch(()=>{})}(o.id),a}),outbox:e=>Ph(()=>c.outbox(e)),ack:e=>Ph(()=>c.ack(e)),answer:e=>Ph(()=>c.answer({binding_id:e.binding_id,reply_token:e.reply_token,answer:e.answer,...void 0===e.author?{}:{author:e.author}})),locate:e=>Ph(async()=>{let t=await a(),n=rr(s,nr(s,t),e.thread,Zn,e.all_scope);if("error"===n.kind)return{kind:"error",error:n};let r=Yn(s,t).filter(e=>e.thread_id===n.entry.thread_id),i=r.find(e=>e.alive)??r[0];if(void 0===i)return Eh("not_found",`Thread ${n.entry.thread_id} is not in the address book.`,"Run omo thread list --all-scope.");let{thread_id:o,title:u,cwd:d,status:c,session_path:l,endpoint:f,surface:p,alive:m}=i;return{kind:"ok",thread:{thread_id:o,title:u,cwd:d,status:c,session_path:l,endpoint:f,surface:p,alive:m}}}),release:async(e,t)=>{let n=i.gateway?.releaseSession;if(void 0===n||null===e.endpoint)return{success:!1,error:"release_unsupported"};try{return await n(e.endpoint,{reason:"takeover",...t})}catch(e){let t=Rh(e);return{success:!1,error:t.error.code,errorData:{hint:t.error.message}}}},dispose:()=>(c.dispose(),o.dispose())}}function Mh(e){return void 0===e.idempotency_key?{}:{idempotency_key:e.idempotency_key}}var Th="5.1.13",Ch=i(n(t(r(import.meta.url)),"..","..","extensions","omo.js")),Nh=e(r(new URL(`./${c}`,Ch)));function jh(e){return qh(void 0===e.workerModuleUrl&&Nh?{...e,workerModuleUrl:Ch}:e)}export{Th as SDK_VERSION,jh as createThreadSdk,Ut as readSessionFacts};
@@ -293,6 +293,7 @@ var REQUIRED_PLUGIN_ARTIFACTS = [
293
293
  join4("extensions", "assets.generated.json"),
294
294
  join4("extensions", "omo-member.js"),
295
295
  join4("extensions", "memory-run-supervisor.mjs"),
296
+ join4("extensions", "gateway-store-worker.mjs"),
296
297
  ...PERSONA_ASSET_FILES.map((filename) => join4("extensions", filename)),
297
298
  join4("skills", "ast-grep", "SKILL.md"),
298
299
  join4("skills", "browser", "SKILL.md"),
@@ -315,6 +316,7 @@ var REQUIRED_PLUGIN_ARTIFACTS = [
315
316
  join4("skills", "visual-qa", "SKILL.md"),
316
317
  join4("skills-conditional", "x-search", "SKILL.md"),
317
318
  join4("runtime", "agent-toolkit-sdk", "sdk.js"),
319
+ join4("runtime", "thread-sdk", "sdk.js"),
318
320
  join4("runtime", "ast-grep-mcp", "cli.js"),
319
321
  join4("runtime", "lsp-daemon", "dist", "cli.js"),
320
322
  join4("runtime", "lsp-daemon", "dist", "index.js"),
@@ -5,5 +5,5 @@
5
5
  "index.js": "b6b064fab277031c6c51f5a58b84b31040f9960bf767bf646adc0540c1d25c1b",
6
6
  "page-bundle.js": "bfd51e8383cf47200d57387bbbed258bce5a3a3d00c38fc108034d2888e23f0c"
7
7
  },
8
- "stagedAtUtc": "2026-10-03T02:23:11.058Z"
8
+ "stagedAtUtc": "2026-10-03T10:05:36.975Z"
9
9
  }