@telepath-computer/television 0.1.196 → 0.1.198
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs
CHANGED
|
@@ -52569,7 +52569,7 @@ function disabledTelemetryRuntime() {
|
|
|
52569
52569
|
|
|
52570
52570
|
// ../server/src/updates/version.ts
|
|
52571
52571
|
function readVersionStamp() {
|
|
52572
|
-
if ("0.1.
|
|
52572
|
+
if ("0.1.198".length > 0) return "0.1.198";
|
|
52573
52573
|
return void 0;
|
|
52574
52574
|
}
|
|
52575
52575
|
function resolveUpdateReleaseVersion(env = process.env, stamp = readVersionStamp()) {
|
|
@@ -53069,8 +53069,8 @@ var Server = class {
|
|
|
53069
53069
|
};
|
|
53070
53070
|
};
|
|
53071
53071
|
function readServerPackageVersion() {
|
|
53072
|
-
if ("0.1.
|
|
53073
|
-
return telemetryVersion("0.1.
|
|
53072
|
+
if ("0.1.198".length > 0) {
|
|
53073
|
+
return telemetryVersion("0.1.198");
|
|
53074
53074
|
}
|
|
53075
53075
|
const packageJsonPath = import_node_path11.default.resolve(import_node_path11.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url)), "..", "package.json");
|
|
53076
53076
|
if (!(0, import_node_fs9.existsSync)(packageJsonPath)) return telemetryVersion("0.0.0");
|
|
@@ -54649,8 +54649,8 @@ function resolveVercelSkillsInstallerBin() {
|
|
|
54649
54649
|
return localRequire.resolve("skills/bin/cli.mjs");
|
|
54650
54650
|
}
|
|
54651
54651
|
function readCLIVersion() {
|
|
54652
|
-
if ("0.1.
|
|
54653
|
-
return "0.1.
|
|
54652
|
+
if ("0.1.198".length > 0) {
|
|
54653
|
+
return "0.1.198";
|
|
54654
54654
|
}
|
|
54655
54655
|
const devPackageJsonPath = import_node_path17.default.join(getDevPackageDir(), "package.json");
|
|
54656
54656
|
if (!(0, import_node_fs14.existsSync)(devPackageJsonPath)) {
|
|
@@ -40,7 +40,7 @@ var ek=Object.defineProperty;var sg=n=>{throw TypeError(n)};var tk=(n,t,e)=>t in
|
|
|
40
40
|
`)}y.write("payload.value = newResult;"),y.write("return payload;");const R=y.compile();return(N,V)=>R(v,N,V)};let s;const o=Bo,a=!i0.jitless,u=a&&iI.value,h=t.catchall;let f;n._zod.parse=(v,y)=>{f??(f=r.value);const E=v.value;return o(E)?a&&u&&(y==null?void 0:y.async)===!1&&y.jitless!==!0?(s||(s=i(t.shape)),v=s(v,y),h?S0([],E,v,y,f,n):v):e(v,y):(v.issues.push({expected:"object",code:"invalid_type",input:E,inst:n}),v)}});function Xm(n,t,e,r){for(const s of n)if(s.issues.length===0)return t.value=s.value,t;const i=n.filter(s=>!ts(s));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:e,errors:n.map(s=>s.issues.map(o=>fr(o,r,pr())))}),t)}const _0=A("$ZodUnion",(n,t)=>{ye.init(n,t),re(n._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),re(n._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),re(n._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),re(n._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>lf(s.source)).join("|")})$`)}});const e=t.options.length===1,r=t.options[0]._zod.run;n._zod.parse=(i,s)=>{if(e)return r(i,s);let o=!1;const a=[];for(const c of t.options){const u=c._zod.run({value:i.value,issues:[]},s);if(u instanceof Promise)a.push(u),o=!0;else{if(u.issues.length===0)return u;a.push(u)}}return o?Promise.all(a).then(c=>Xm(c,i,n,s)):Xm(a,i,n,s)}}),BR=A("$ZodDiscriminatedUnion",(n,t)=>{t.inclusive=!1,_0.init(n,t);const e=n._zod.parse;re(n._zod,"propValues",()=>{const i={};for(const s of t.options){const o=s._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[a,c]of Object.entries(o)){i[a]||(i[a]=new Set);for(const u of c)i[a].add(u)}}return i});const r=gu(()=>{var o;const i=t.options,s=new Map;for(const a of i){const c=(o=a._zod.propValues)==null?void 0:o[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const u of c){if(s.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);s.set(u,a)}}return s});n._zod.parse=(i,s)=>{const o=i.value;if(!Bo(o))return i.issues.push({code:"invalid_type",expected:"object",input:o,inst:n}),i;const a=r.value.get(o==null?void 0:o[t.discriminator]);return a?a._zod.run(i,s):t.unionFallback?e(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:o,path:[t.discriminator],inst:n}),i)}}),WR=A("$ZodIntersection",(n,t)=>{ye.init(n,t),n._zod.parse=(e,r)=>{const i=e.value,s=t.left._zod.run({value:i,issues:[]},r),o=t.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([c,u])=>Qm(e,c,u)):Qm(e,s,o)}});function ld(n,t){if(n===t)return{valid:!0,data:n};if(n instanceof Date&&t instanceof Date&&+n==+t)return{valid:!0,data:n};if(Hs(n)&&Hs(t)){const e=Object.keys(t),r=Object.keys(n).filter(s=>e.indexOf(s)!==-1),i={...n,...t};for(const s of r){const o=ld(n[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(t)){if(n.length!==t.length)return{valid:!1,mergeErrorPath:[]};const e=[];for(let r=0;r<n.length;r++){const i=n[r],s=t[r],o=ld(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};e.push(o.data)}return{valid:!0,data:e}}return{valid:!1,mergeErrorPath:[]}}function Qm(n,t,e){const r=new Map;let i;for(const a of t.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else n.issues.push(a);for(const a of e.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else n.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&n.issues.push({...i,keys:s}),ts(n))return n;const o=ld(t.value,e.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return n.value=o.data,n}const jR=A("$ZodRecord",(n,t)=>{ye.init(n,t),n._zod.parse=(e,r)=>{const i=e.value;if(!Hs(i))return e.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),e;const s=[],o=t.keyType._zod.values;if(o){e.value={};const a=new Set;for(const u of o)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const h=t.valueType._zod.run({value:i[u],issues:[]},r);h instanceof Promise?s.push(h.then(f=>{f.issues.length&&e.issues.push(...ns(u,f.issues)),e.value[u]=f.value})):(h.issues.length&&e.issues.push(...ns(u,h.issues)),e.value[u]=h.value)}let c;for(const u in i)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&e.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:c})}else{e.value={};for(const a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&f0.test(a)&&c.issues.length){const f=t.keyType._zod.run({value:Number(a),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(c=f)}if(c.issues.length){t.mode==="loose"?e.value[a]=i[a]:e.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(f=>fr(f,r,pr())),input:a,path:[a],inst:n});continue}const h=t.valueType._zod.run({value:i[a],issues:[]},r);h instanceof Promise?s.push(h.then(f=>{f.issues.length&&e.issues.push(...ns(a,f.issues)),e.value[c.value]=f.value})):(h.issues.length&&e.issues.push(...ns(a,h.issues)),e.value[c.value]=h.value)}}return s.length?Promise.all(s).then(()=>e):e}}),GR=A("$ZodEnum",(n,t)=>{ye.init(n,t);const e=s0(t.entries),r=new Set(e);n._zod.values=r,n._zod.pattern=new RegExp(`^(${e.filter(i=>sI.has(typeof i)).map(i=>typeof i=="string"?Vs(i):i.toString()).join("|")})$`),n._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:e,input:o,inst:n}),i}}),qR=A("$ZodLiteral",(n,t)=>{if(ye.init(n,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const e=new Set(t.values);n._zod.values=e,n._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Vs(r):r?Vs(r.toString()):String(r)).join("|")})$`),n._zod.parse=(r,i)=>{const s=r.value;return e.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:n}),r}}),YR=A("$ZodTransform",(n,t)=>{ye.init(n,t),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new r0(n.constructor.name);const i=t.transform(e.value,e);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(e.value=o,e));if(i instanceof Promise)throw new ss;return e.value=i,e}});function ev(n,t){return n.issues.length&&t===void 0?{issues:[],value:void 0}:n}const k0=A("$ZodOptional",(n,t)=>{ye.init(n,t),n._zod.optin="optional",n._zod.optout="optional",re(n._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),re(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${lf(e.source)})?$`):void 0}),n._zod.parse=(e,r)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>ev(s,e.value)):ev(i,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,r)}}),KR=A("$ZodExactOptional",(n,t)=>{k0.init(n,t),re(n._zod,"values",()=>t.innerType._zod.values),re(n._zod,"pattern",()=>t.innerType._zod.pattern),n._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),JR=A("$ZodNullable",(n,t)=>{ye.init(n,t),re(n._zod,"optin",()=>t.innerType._zod.optin),re(n._zod,"optout",()=>t.innerType._zod.optout),re(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${lf(e.source)}|null)$`):void 0}),re(n._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),n._zod.parse=(e,r)=>e.value===null?e:t.innerType._zod.run(e,r)}),XR=A("$ZodDefault",(n,t)=>{ye.init(n,t),n._zod.optin="optional",re(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);if(e.value===void 0)return e.value=t.defaultValue,e;const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>tv(s,t)):tv(i,t)}});function tv(n,t){return n.value===void 0&&(n.value=t.defaultValue),n}const QR=A("$ZodPrefault",(n,t)=>{ye.init(n,t),n._zod.optin="optional",re(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>(r.direction==="backward"||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))}),eP=A("$ZodNonOptional",(n,t)=>{ye.init(n,t),re(n._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(r=>r!==void 0)):void 0}),n._zod.parse=(e,r)=>{const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>nv(s,n)):nv(i,n)}});function nv(n,t){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:t}),n}const tP=A("$ZodCatch",(n,t)=>{ye.init(n,t),re(n._zod,"optin",()=>t.innerType._zod.optin),re(n._zod,"optout",()=>t.innerType._zod.optout),re(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>(e.value=s.value,s.issues.length&&(e.value=t.catchValue({...e,error:{issues:s.issues.map(o=>fr(o,r,pr()))},input:e.value}),e.issues=[]),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(s=>fr(s,r,pr()))},input:e.value}),e.issues=[]),e)}}),nP=A("$ZodPipe",(n,t)=>{ye.init(n,t),re(n._zod,"values",()=>t.in._zod.values),re(n._zod,"optin",()=>t.in._zod.optin),re(n._zod,"optout",()=>t.out._zod.optout),re(n._zod,"propValues",()=>t.in._zod.propValues),n._zod.parse=(e,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(e,r);return s instanceof Promise?s.then(o=>Ul(o,t.in,r)):Ul(s,t.in,r)}const i=t.in._zod.run(e,r);return i instanceof Promise?i.then(s=>Ul(s,t.out,r)):Ul(i,t.out,r)}});function Ul(n,t,e){return n.issues.length?(n.aborted=!0,n):t._zod.run({value:n.value,issues:n.issues},e)}const rP=A("$ZodReadonly",(n,t)=>{ye.init(n,t),re(n._zod,"propValues",()=>t.innerType._zod.propValues),re(n._zod,"values",()=>t.innerType._zod.values),re(n._zod,"optin",()=>{var e,r;return(r=(e=t.innerType)==null?void 0:e._zod)==null?void 0:r.optin}),re(n._zod,"optout",()=>{var e,r;return(r=(e=t.innerType)==null?void 0:e._zod)==null?void 0:r.optout}),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(rv):rv(i)}});function rv(n){return n.value=Object.freeze(n.value),n}const iP=A("$ZodCustom",(n,t)=>{ht.init(n,t),ye.init(n,t),n._zod.parse=(e,r)=>e,n._zod.check=e=>{const r=e.value,i=t.fn(r);if(i instanceof Promise)return i.then(s=>iv(s,e,r,n));iv(i,e,r,n)}});function iv(n,t,e,r){if(!n){const i={code:"custom",input:e,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),t.issues.push(Wo(i))}}var sv;class sP{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...e){const r=e[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const e=this._map.get(t);return e&&typeof e=="object"&&"id"in e&&this._idmap.delete(e.id),this._map.delete(t),this}get(t){const e=t._zod.parent;if(e){const r={...this.get(e)??{}};delete r.id;const i={...r,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function oP(){return new sP}(sv=globalThis).__zod_globalRegistry??(sv.__zod_globalRegistry=oP());const ko=globalThis.__zod_globalRegistry;function aP(n,t){return new n({type:"string",...z(t)})}function lP(n,t){return new n({type:"string",format:"email",check:"string_format",abort:!1,...z(t)})}function ov(n,t){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...z(t)})}function cP(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...z(t)})}function uP(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(t)})}function hP(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(t)})}function dP(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(t)})}function pP(n,t){return new n({type:"string",format:"url",check:"string_format",abort:!1,...z(t)})}function fP(n,t){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...z(t)})}function gP(n,t){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(t)})}function mP(n,t){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...z(t)})}function vP(n,t){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(t)})}function yP(n,t){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...z(t)})}function bP(n,t){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...z(t)})}function wP(n,t){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(t)})}function SP(n,t){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(t)})}function _P(n,t){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(t)})}function kP(n,t){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(t)})}function EP(n,t){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(t)})}function xP(n,t){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...z(t)})}function AP(n,t){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...z(t)})}function TP(n,t){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...z(t)})}function $P(n,t){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...z(t)})}function CP(n,t){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(t)})}function IP(n,t){return new n({type:"string",format:"date",check:"string_format",...z(t)})}function RP(n,t){return new n({type:"string",format:"time",check:"string_format",precision:null,...z(t)})}function PP(n,t){return new n({type:"string",format:"duration",check:"string_format",...z(t)})}function LP(n,t){return new n({type:"number",checks:[],...z(t)})}function DP(n,t){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...z(t)})}function MP(n,t){return new n({type:"boolean",...z(t)})}function zP(n){return new n({type:"unknown"})}function OP(n,t){return new n({type:"never",...z(t)})}function av(n,t){return new m0({check:"less_than",...z(t),value:n,inclusive:!1})}function Sh(n,t){return new m0({check:"less_than",...z(t),value:n,inclusive:!0})}function lv(n,t){return new v0({check:"greater_than",...z(t),value:n,inclusive:!1})}function _h(n,t){return new v0({check:"greater_than",...z(t),value:n,inclusive:!0})}function cv(n,t){return new XI({check:"multiple_of",...z(t),value:n})}function E0(n,t){return new eR({check:"max_length",...z(t),maximum:n})}function xc(n,t){return new tR({check:"min_length",...z(t),minimum:n})}function x0(n,t){return new nR({check:"length_equals",...z(t),length:n})}function NP(n,t){return new rR({check:"string_format",format:"regex",...z(t),pattern:n})}function UP(n){return new iR({check:"string_format",format:"lowercase",...z(n)})}function FP(n){return new sR({check:"string_format",format:"uppercase",...z(n)})}function HP(n,t){return new oR({check:"string_format",format:"includes",...z(t),includes:n})}function VP(n,t){return new aR({check:"string_format",format:"starts_with",...z(t),prefix:n})}function ZP(n,t){return new lR({check:"string_format",format:"ends_with",...z(t),suffix:n})}function eo(n){return new cR({check:"overwrite",tx:n})}function BP(n){return eo(t=>t.normalize(n))}function WP(){return eo(n=>n.trim())}function jP(){return eo(n=>n.toLowerCase())}function GP(){return eo(n=>n.toUpperCase())}function qP(){return eo(n=>rI(n))}function YP(n,t,e){return new n({type:"array",element:t,...z(e)})}function KP(n,t,e){return new n({type:"custom",check:"custom",fn:t,...z(e)})}function JP(n){const t=XP(e=>(e.addIssue=r=>{if(typeof r=="string")e.issues.push(Wo(r,e.value,t._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=e.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),e.issues.push(Wo(i))}},n(e.value,e)));return t}function XP(n,t){const e=new ht({check:"custom",...z(t)});return e._zod.check=n,e}function A0(n){let t=(n==null?void 0:n.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:n.processors??{},metadataRegistry:(n==null?void 0:n.metadata)??ko,target:t,unrepresentable:(n==null?void 0:n.unrepresentable)??"throw",override:(n==null?void 0:n.override)??(()=>{}),io:(n==null?void 0:n.io)??"output",counter:0,seen:new Map,cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",external:(n==null?void 0:n.external)??void 0}}function $e(n,t,e={path:[],schemaPath:[]}){var h,f;var r;const i=n._zod.def,s=t.seen.get(n);if(s)return s.count++,e.schemaPath.includes(n)&&(s.cycle=e.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:e.path};t.seen.set(n,o);const a=(f=(h=n._zod).toJSONSchema)==null?void 0:f.call(h);if(a)o.schema=a;else{const v={...e,schemaPath:[...e.schemaPath,n],path:e.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(t,o.schema,v);else{const E=o.schema,x=t.processors[i.type];if(!x)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);x(n,t,E,v)}const y=n._zod.parent;y&&(o.ref||(o.ref=y),$e(y,t,v),t.seen.get(y).isParent=!0)}const c=t.metadataRegistry.get(n);return c&&Object.assign(o.schema,c),t.io==="input"&&Qe(n)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(n).schema}function T0(n,t){var o,a,c,u;const e=n.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const h of n.seen.entries()){const f=(o=n.metadataRegistry.get(h[0]))==null?void 0:o.id;if(f){const v=r.get(f);if(v&&v!==h[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(f,h[0])}}const i=h=>{var x;const f=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const C=(x=n.external.registry.get(h[0]))==null?void 0:x.id,L=n.external.uri??(W=>W);if(C)return{ref:L(C)};const R=h[1].defId??h[1].schema.id??`schema${n.counter++}`;return h[1].defId=R,{defId:R,ref:`${L("__shared")}#/${f}/${R}`}}if(h[1]===e)return{ref:"#"};const y=`#/${f}/`,E=h[1].schema.id??`__schema${n.counter++}`;return{defId:E,ref:y+E}},s=h=>{if(h[1].schema.$ref)return;const f=h[1],{ref:v,defId:y}=i(h);f.def={...f.schema},y&&(f.defId=y);const E=f.schema;for(const x in E)delete E[x];E.$ref=v};if(n.cycles==="throw")for(const h of n.seen.entries()){const f=h[1];if(f.cycle)throw new Error(`Cycle detected: #/${(a=f.cycle)==null?void 0:a.join("/")}/<root>
|
|
41
41
|
|
|
42
42
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const h of n.seen.entries()){const f=h[1];if(t===h[0]){s(h);continue}if(n.external){const y=(c=n.external.registry.get(h[0]))==null?void 0:c.id;if(t!==h[0]&&y){s(h);continue}}if((u=n.metadataRegistry.get(h[0]))==null?void 0:u.id){s(h);continue}if(f.cycle){s(h);continue}if(f.count>1&&n.reused==="ref"){s(h);continue}}}function $0(n,t){var o,a,c;const e=n.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const h=n.seen.get(u);if(h.ref===null)return;const f=h.def??h.schema,v={...f},y=h.ref;if(h.ref=null,y){r(y);const x=n.seen.get(y),C=x.schema;if(C.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(C)):Object.assign(f,C),Object.assign(f,v),u._zod.parent===y)for(const R in f)R==="$ref"||R==="allOf"||R in v||delete f[R];if(C.$ref&&x.def)for(const R in f)R==="$ref"||R==="allOf"||R in x.def&&JSON.stringify(f[R])===JSON.stringify(x.def[R])&&delete f[R]}const E=u._zod.parent;if(E&&E!==y){r(E);const x=n.seen.get(E);if(x!=null&&x.schema.$ref&&(f.$ref=x.schema.$ref,x.def))for(const C in f)C==="$ref"||C==="allOf"||C in x.def&&JSON.stringify(f[C])===JSON.stringify(x.def[C])&&delete f[C]}n.override({zodSchema:u,jsonSchema:f,path:h.path??[]})};for(const u of[...n.seen.entries()].reverse())r(u[0]);const i={};if(n.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":n.target,(o=n.external)!=null&&o.uri){const u=(a=n.external.registry.get(t))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=n.external.uri(u)}Object.assign(i,e.def??e.schema);const s=((c=n.external)==null?void 0:c.defs)??{};for(const u of n.seen.entries()){const h=u[1];h.def&&h.defId&&(s[h.defId]=h.def)}n.external||Object.keys(s).length>0&&(n.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ac(t,"input",n.processors),output:Ac(t,"output",n.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Qe(n,t){const e=t??{seen:new Set};if(e.seen.has(n))return!1;e.seen.add(n);const r=n._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Qe(r.element,e);if(r.type==="set")return Qe(r.valueType,e);if(r.type==="lazy")return Qe(r.getter(),e);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Qe(r.innerType,e);if(r.type==="intersection")return Qe(r.left,e)||Qe(r.right,e);if(r.type==="record"||r.type==="map")return Qe(r.keyType,e)||Qe(r.valueType,e);if(r.type==="pipe")return Qe(r.in,e)||Qe(r.out,e);if(r.type==="object"){for(const i in r.shape)if(Qe(r.shape[i],e))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(Qe(i,e))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(Qe(i,e))return!0;return!!(r.rest&&Qe(r.rest,e))}return!1}const QP=(n,t={})=>e=>{const r=A0({...e,processors:t});return $e(n,r),T0(r,n),$0(r,n)},Ac=(n,t,e={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=A0({...i??{},target:s,io:t,processors:e});return $e(n,o),T0(o,n),$0(o,n)},e2={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},t2=(n,t,e,r)=>{const i=e;i.type="string";const{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:u}=n._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=e2[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){const h=[...c];h.length===1?i.pattern=h[0].source:h.length>1&&(i.allOf=[...h.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},n2=(n,t,e,r)=>{const i=e,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:h}=n._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=h,i.exclusiveMinimum=!0):i.exclusiveMinimum=h),typeof s=="number"&&(i.minimum=s,typeof h=="number"&&t.target!=="draft-04"&&(h>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof o=="number"&&(i.maximum=o,typeof u=="number"&&t.target!=="draft-04"&&(u<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},r2=(n,t,e,r)=>{e.type="boolean"},i2=(n,t,e,r)=>{e.not={}},s2=(n,t,e,r)=>{},o2=(n,t,e,r)=>{const i=n._zod.def,s=s0(i.entries);s.every(o=>typeof o=="number")&&(e.type="number"),s.every(o=>typeof o=="string")&&(e.type="string"),e.enum=s},a2=(n,t,e,r)=>{const i=n._zod.def,s=[];for(const o of i.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];e.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?e.enum=[o]:e.const=o}else s.every(o=>typeof o=="number")&&(e.type="number"),s.every(o=>typeof o=="string")&&(e.type="string"),s.every(o=>typeof o=="boolean")&&(e.type="boolean"),s.every(o=>o===null)&&(e.type="null"),e.enum=s},l2=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},c2=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},u2=(n,t,e,r)=>{const i=e,s=n._zod.def,{minimum:o,maximum:a}=n._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=$e(s.element,t,{...r,path:[...r.path,"items"]})},h2=(n,t,e,r)=>{var u;const i=e,s=n._zod.def;i.type="object",i.properties={};const o=s.shape;for(const h in o)i.properties[h]=$e(o[h],t,{...r,path:[...r.path,"properties",h]});const a=new Set(Object.keys(o)),c=new Set([...a].filter(h=>{const f=s.shape[h]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));c.size>0&&(i.required=Array.from(c)),((u=s.catchall)==null?void 0:u._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=$e(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},d2=(n,t,e,r)=>{const i=n._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>$e(a,t,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?e.oneOf=o:e.anyOf=o},p2=(n,t,e,r)=>{const i=n._zod.def,s=$e(i.left,t,{...r,path:[...r.path,"allOf",0]}),o=$e(i.right,t,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];e.allOf=c},f2=(n,t,e,r)=>{const i=e,s=n._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag,c=a==null?void 0:a.patterns;if(s.mode==="loose"&&c&&c.size>0){const h=$e(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const f of c)i.patternProperties[f.source]=h}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=$e(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=$e(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=o._zod.values;if(u){const h=[...u].filter(f=>typeof f=="string"||typeof f=="number");h.length>0&&(i.required=h)}},g2=(n,t,e,r)=>{const i=n._zod.def,s=$e(i.innerType,t,r),o=t.seen.get(n);t.target==="openapi-3.0"?(o.ref=i.innerType,e.nullable=!0):e.anyOf=[s,{type:"null"}]},m2=(n,t,e,r)=>{const i=n._zod.def;$e(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},v2=(n,t,e,r)=>{const i=n._zod.def;$e(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,e.default=JSON.parse(JSON.stringify(i.defaultValue))},y2=(n,t,e,r)=>{const i=n._zod.def;$e(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,t.io==="input"&&(e._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},b2=(n,t,e,r)=>{const i=n._zod.def;$e(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}e.default=o},w2=(n,t,e,r)=>{const i=n._zod.def,s=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;$e(s,t,r);const o=t.seen.get(n);o.ref=s},S2=(n,t,e,r)=>{const i=n._zod.def;$e(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,e.readOnly=!0},C0=(n,t,e,r)=>{const i=n._zod.def;$e(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},_2=A("ZodISODateTime",(n,t)=>{kR.init(n,t),we.init(n,t)});function k2(n){return CP(_2,n)}const E2=A("ZodISODate",(n,t)=>{ER.init(n,t),we.init(n,t)});function x2(n){return IP(E2,n)}const A2=A("ZodISOTime",(n,t)=>{xR.init(n,t),we.init(n,t)});function T2(n){return RP(A2,n)}const $2=A("ZodISODuration",(n,t)=>{AR.init(n,t),we.init(n,t)});function C2(n){return PP($2,n)}const I0=(n,t)=>{c0.init(n,t),n.name="ZodError",Object.defineProperties(n,{format:{value:e=>mI(n,e)},flatten:{value:e=>gI(n,e)},addIssue:{value:e=>{n.issues.push(e),n.message=JSON.stringify(n.issues,ad,2)}},addIssues:{value:e=>{n.issues.push(...e),n.message=JSON.stringify(n.issues,ad,2)}},isEmpty:{get(){return n.issues.length===0}}})},uv=A("ZodError",I0),Rt=A("ZodError",I0,{Parent:Error}),I2=uf(Rt),R2=hf(Rt),P2=mu(Rt),L2=vu(Rt),D2=bI(Rt),M2=wI(Rt),z2=SI(Rt),O2=_I(Rt),N2=kI(Rt),U2=EI(Rt),F2=xI(Rt),H2=AI(Rt),be=A("ZodType",(n,t)=>(ye.init(n,t),Object.assign(n["~standard"],{jsonSchema:{input:Ac(n,"input"),output:Ac(n,"output")}}),n.toJSONSchema=QP(n,{}),n.def=t,n.type=t.type,Object.defineProperty(n,"_def",{value:t}),n.check=(...e)=>n.clone(wr(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),n.with=n.check,n.clone=(e,r)=>Sr(n,e,r),n.brand=()=>n,n.register=(e,r)=>(e.add(n,r),n),n.parse=(e,r)=>I2(n,e,r,{callee:n.parse}),n.safeParse=(e,r)=>P2(n,e,r),n.parseAsync=async(e,r)=>R2(n,e,r,{callee:n.parseAsync}),n.safeParseAsync=async(e,r)=>L2(n,e,r),n.spa=n.safeParseAsync,n.encode=(e,r)=>D2(n,e,r),n.decode=(e,r)=>M2(n,e,r),n.encodeAsync=async(e,r)=>z2(n,e,r),n.decodeAsync=async(e,r)=>O2(n,e,r),n.safeEncode=(e,r)=>N2(n,e,r),n.safeDecode=(e,r)=>U2(n,e,r),n.safeEncodeAsync=async(e,r)=>F2(n,e,r),n.safeDecodeAsync=async(e,r)=>H2(n,e,r),n.refine=(e,r)=>n.check(LL(e,r)),n.superRefine=e=>n.check(DL(e)),n.overwrite=e=>n.check(eo(e)),n.optional=()=>pv(n),n.exactOptional=()=>wL(n),n.nullable=()=>fv(n),n.nullish=()=>pv(fv(n)),n.nonoptional=e=>AL(n,e),n.array=()=>M(n),n.or=e=>j([n,e]),n.and=e=>bu(n,e),n.transform=e=>gv(n,yL(e)),n.default=e=>kL(n,e),n.prefault=e=>xL(n,e),n.catch=e=>$L(n,e),n.pipe=e=>gv(n,e),n.readonly=()=>RL(n),n.describe=e=>{const r=n.clone();return ko.add(r,{description:e}),r},Object.defineProperty(n,"description",{get(){var e;return(e=ko.get(n))==null?void 0:e.description},configurable:!0}),n.meta=(...e)=>{if(e.length===0)return ko.get(n);const r=n.clone();return ko.add(r,e[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=e=>e(n),n)),R0=A("_ZodString",(n,t)=>{df.init(n,t),be.init(n,t),n._zod.processJSONSchema=(r,i,s)=>t2(n,r,i);const e=n._zod.bag;n.format=e.format??null,n.minLength=e.minimum??null,n.maxLength=e.maximum??null,n.regex=(...r)=>n.check(NP(...r)),n.includes=(...r)=>n.check(HP(...r)),n.startsWith=(...r)=>n.check(VP(...r)),n.endsWith=(...r)=>n.check(ZP(...r)),n.min=(...r)=>n.check(xc(...r)),n.max=(...r)=>n.check(E0(...r)),n.length=(...r)=>n.check(x0(...r)),n.nonempty=(...r)=>n.check(xc(1,...r)),n.lowercase=r=>n.check(UP(r)),n.uppercase=r=>n.check(FP(r)),n.trim=()=>n.check(WP()),n.normalize=(...r)=>n.check(BP(...r)),n.toLowerCase=()=>n.check(jP()),n.toUpperCase=()=>n.check(GP()),n.slugify=()=>n.check(qP())}),V2=A("ZodString",(n,t)=>{df.init(n,t),R0.init(n,t),n.email=e=>n.check(lP(Z2,e)),n.url=e=>n.check(pP(B2,e)),n.jwt=e=>n.check($P(sL,e)),n.emoji=e=>n.check(fP(W2,e)),n.guid=e=>n.check(ov(hv,e)),n.uuid=e=>n.check(cP(Fl,e)),n.uuidv4=e=>n.check(uP(Fl,e)),n.uuidv6=e=>n.check(hP(Fl,e)),n.uuidv7=e=>n.check(dP(Fl,e)),n.nanoid=e=>n.check(gP(j2,e)),n.guid=e=>n.check(ov(hv,e)),n.cuid=e=>n.check(mP(G2,e)),n.cuid2=e=>n.check(vP(q2,e)),n.ulid=e=>n.check(yP(Y2,e)),n.base64=e=>n.check(xP(nL,e)),n.base64url=e=>n.check(AP(rL,e)),n.xid=e=>n.check(bP(K2,e)),n.ksuid=e=>n.check(wP(J2,e)),n.ipv4=e=>n.check(SP(X2,e)),n.ipv6=e=>n.check(_P(Q2,e)),n.cidrv4=e=>n.check(kP(eL,e)),n.cidrv6=e=>n.check(EP(tL,e)),n.e164=e=>n.check(TP(iL,e)),n.datetime=e=>n.check(k2(e)),n.date=e=>n.check(x2(e)),n.time=e=>n.check(T2(e)),n.duration=e=>n.check(C2(e))});function p(n){return aP(V2,n)}const we=A("ZodStringFormat",(n,t)=>{me.init(n,t),R0.init(n,t)}),Z2=A("ZodEmail",(n,t)=>{fR.init(n,t),we.init(n,t)}),hv=A("ZodGUID",(n,t)=>{dR.init(n,t),we.init(n,t)}),Fl=A("ZodUUID",(n,t)=>{pR.init(n,t),we.init(n,t)}),B2=A("ZodURL",(n,t)=>{gR.init(n,t),we.init(n,t)}),W2=A("ZodEmoji",(n,t)=>{mR.init(n,t),we.init(n,t)}),j2=A("ZodNanoID",(n,t)=>{vR.init(n,t),we.init(n,t)}),G2=A("ZodCUID",(n,t)=>{yR.init(n,t),we.init(n,t)}),q2=A("ZodCUID2",(n,t)=>{bR.init(n,t),we.init(n,t)}),Y2=A("ZodULID",(n,t)=>{wR.init(n,t),we.init(n,t)}),K2=A("ZodXID",(n,t)=>{SR.init(n,t),we.init(n,t)}),J2=A("ZodKSUID",(n,t)=>{_R.init(n,t),we.init(n,t)}),X2=A("ZodIPv4",(n,t)=>{TR.init(n,t),we.init(n,t)}),Q2=A("ZodIPv6",(n,t)=>{$R.init(n,t),we.init(n,t)}),eL=A("ZodCIDRv4",(n,t)=>{CR.init(n,t),we.init(n,t)}),tL=A("ZodCIDRv6",(n,t)=>{IR.init(n,t),we.init(n,t)}),nL=A("ZodBase64",(n,t)=>{RR.init(n,t),we.init(n,t)}),rL=A("ZodBase64URL",(n,t)=>{LR.init(n,t),we.init(n,t)}),iL=A("ZodE164",(n,t)=>{DR.init(n,t),we.init(n,t)}),sL=A("ZodJWT",(n,t)=>{zR.init(n,t),we.init(n,t)}),P0=A("ZodNumber",(n,t)=>{b0.init(n,t),be.init(n,t),n._zod.processJSONSchema=(r,i,s)=>n2(n,r,i),n.gt=(r,i)=>n.check(lv(r,i)),n.gte=(r,i)=>n.check(_h(r,i)),n.min=(r,i)=>n.check(_h(r,i)),n.lt=(r,i)=>n.check(av(r,i)),n.lte=(r,i)=>n.check(Sh(r,i)),n.max=(r,i)=>n.check(Sh(r,i)),n.int=r=>n.check(dv(r)),n.safe=r=>n.check(dv(r)),n.positive=r=>n.check(lv(0,r)),n.nonnegative=r=>n.check(_h(0,r)),n.negative=r=>n.check(av(0,r)),n.nonpositive=r=>n.check(Sh(0,r)),n.multipleOf=(r,i)=>n.check(cv(r,i)),n.step=(r,i)=>n.check(cv(r,i)),n.finite=()=>n;const e=n._zod.bag;n.minValue=Math.max(e.minimum??Number.NEGATIVE_INFINITY,e.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(e.maximum??Number.POSITIVE_INFINITY,e.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(e.format??"").includes("int")||Number.isSafeInteger(e.multipleOf??.5),n.isFinite=!0,n.format=e.format??null});function B(n){return LP(P0,n)}const oL=A("ZodNumberFormat",(n,t)=>{OR.init(n,t),P0.init(n,t)});function dv(n){return DP(oL,n)}const aL=A("ZodBoolean",(n,t)=>{NR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>r2(n,e,r)});function Ne(n){return MP(aL,n)}const lL=A("ZodUnknown",(n,t)=>{UR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>s2()});function _(){return zP(lL)}const cL=A("ZodNever",(n,t)=>{FR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>i2(n,e,r)});function uL(n){return OP(cL,n)}const hL=A("ZodArray",(n,t)=>{HR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>u2(n,e,r,i),n.element=t.element,n.min=(e,r)=>n.check(xc(e,r)),n.nonempty=e=>n.check(xc(1,e)),n.max=(e,r)=>n.check(E0(e,r)),n.length=(e,r)=>n.check(x0(e,r)),n.unwrap=()=>n.element});function M(n,t){return YP(hL,n,t)}const L0=A("ZodObject",(n,t)=>{ZR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>h2(n,e,r,i),re(n,"shape",()=>t.shape),n.keyof=()=>z0(Object.keys(n._zod.def.shape)),n.catchall=e=>n.clone({...n._zod.def,catchall:e}),n.passthrough=()=>n.clone({...n._zod.def,catchall:_()}),n.loose=()=>n.clone({...n._zod.def,catchall:_()}),n.strict=()=>n.clone({...n._zod.def,catchall:uL()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=e=>uI(n,e),n.safeExtend=e=>hI(n,e),n.merge=e=>dI(n,e),n.pick=e=>lI(n,e),n.omit=e=>cI(n,e),n.partial=(...e)=>pI(O0,n,e[0]),n.required=(...e)=>fI(N0,n,e[0])});function D0(n,t){const e={type:"object",shape:n??{},...z(t)};return new L0(e)}function w(n,t){return new L0({type:"object",shape:n,catchall:_(),...z(t)})}const M0=A("ZodUnion",(n,t)=>{_0.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>d2(n,e,r,i),n.options=t.options});function j(n,t){return new M0({type:"union",options:n,...z(t)})}const dL=A("ZodDiscriminatedUnion",(n,t)=>{M0.init(n,t),BR.init(n,t)});function pL(n,t,e){return new dL({type:"union",options:t,discriminator:n,...z(e)})}const fL=A("ZodIntersection",(n,t)=>{WR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>p2(n,e,r,i)});function bu(n,t){return new fL({type:"intersection",left:n,right:t})}const gL=A("ZodRecord",(n,t)=>{jR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>f2(n,e,r,i),n.keyType=t.keyType,n.valueType=t.valueType});function k(n,t,e){return new gL({type:"record",keyType:n,valueType:t,...z(e)})}const cd=A("ZodEnum",(n,t)=>{GR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(r,i,s)=>o2(n,r,i),n.enum=t.entries,n.options=Object.values(t.entries);const e=new Set(Object.keys(t.entries));n.extract=(r,i)=>{const s={};for(const o of r)if(e.has(o))s[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new cd({...t,checks:[],...z(i),entries:s})},n.exclude=(r,i)=>{const s={...t.entries};for(const o of r)if(e.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new cd({...t,checks:[],...z(i),entries:s})}});function z0(n,t){const e=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new cd({type:"enum",entries:e,...z(t)})}const mL=A("ZodLiteral",(n,t)=>{qR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>a2(n,e,r),n.values=new Set(t.values),Object.defineProperty(n,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function T(n,t){return new mL({type:"literal",values:Array.isArray(n)?n:[n],...z(t)})}const vL=A("ZodTransform",(n,t)=>{YR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>c2(n,e),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new r0(n.constructor.name);e.addIssue=s=>{if(typeof s=="string")e.issues.push(Wo(s,e.value,t));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=e.value),o.inst??(o.inst=n),e.issues.push(Wo(o))}};const i=t.transform(e.value,e);return i instanceof Promise?i.then(s=>(e.value=s,e)):(e.value=i,e)}});function yL(n){return new vL({type:"transform",transform:n})}const O0=A("ZodOptional",(n,t)=>{k0.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>C0(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function pv(n){return new O0({type:"optional",innerType:n})}const bL=A("ZodExactOptional",(n,t)=>{KR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>C0(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function wL(n){return new bL({type:"optional",innerType:n})}const SL=A("ZodNullable",(n,t)=>{JR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>g2(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function fv(n){return new SL({type:"nullable",innerType:n})}const _L=A("ZodDefault",(n,t)=>{XR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>v2(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function kL(n,t){return new _L({type:"default",innerType:n,get defaultValue(){return typeof t=="function"?t():a0(t)}})}const EL=A("ZodPrefault",(n,t)=>{QR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>y2(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function xL(n,t){return new EL({type:"prefault",innerType:n,get defaultValue(){return typeof t=="function"?t():a0(t)}})}const N0=A("ZodNonOptional",(n,t)=>{eP.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>m2(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function AL(n,t){return new N0({type:"nonoptional",innerType:n,...z(t)})}const TL=A("ZodCatch",(n,t)=>{tP.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>b2(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function $L(n,t){return new TL({type:"catch",innerType:n,catchValue:typeof t=="function"?t:()=>t})}const CL=A("ZodPipe",(n,t)=>{nP.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>w2(n,e,r,i),n.in=t.in,n.out=t.out});function gv(n,t){return new CL({type:"pipe",in:n,out:t})}const IL=A("ZodReadonly",(n,t)=>{rP.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>S2(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function RL(n){return new IL({type:"readonly",innerType:n})}const PL=A("ZodCustom",(n,t)=>{iP.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>l2(n,e)});function LL(n,t={}){return KP(PL,n,t)}function DL(n){return JP(n)}const ML=[".md",".markdown"];function U0(n){if(n.length===0)return!1;const t=n.at(-1);return t==="/"||t==="\\"}function F0(n){const t=n.lastIndexOf("/"),e=n.lastIndexOf("\\");return n.slice(Math.max(t,e)+1)}function zL(n){return F0(n).toLowerCase()}function OL(n,t){const e=zL(n);return t.some(r=>e.endsWith(r))}function H0(n){return!U0(n)&&OL(n,ML)}function NL(n){let t;try{t=new URL(n)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}function En(n){try{const{pathname:t}=new URL(n);return/^\/artifact\/[0-9A-Za-z]{26}(\/|$)/.test(t)}catch{return!1}}const UL=D0({id:p().min(1),kind:T("path"),title:p(),path:p()}).strict(),FL=D0({id:p().min(1),kind:T("url"),title:p(),url:p().refine(NL,{message:"url must be an http(s) URL"})}).strict();pL("kind",[UL,FL]);function V0(n){return typeof n=="object"&&n!==null}function Z0(n){return!V0(n)||n.type!=="ready"?!1:!("id"in n)}function B0(n){return!(!V0(n)||n.type!=="update-content"||typeof n.id!="string"||typeof n.content!="string")}const HL="/views/markdown/",VL="/views/url-unsupported/";function W0(n){return`/artifact/${encodeURIComponent(n)}`}function ZL(n,t){return`${W0(n)}/${encodeURIComponent(t)}`}function BL(n){return`/markdown/${encodeURIComponent(n)}`}function Tc(n,t={electron:!1}){if(n.kind==="url")return t.electron?{renderer:"url-webview",viewURL:n.url,contentURL:null}:En(n.url)?{renderer:"proxy-iframe",viewURL:n.url,contentURL:null}:{renderer:"url-unsupported",viewURL:VL,contentURL:null};if(H0(n.path)){const r={viewURL:HL,contentURL:BL(n.id)};return t.electron?{renderer:"url-webview",...r}:{renderer:"markdown",...r}}const e=U0(n.path)?`${W0(n.id)}/`:ZL(n.id,F0(n.path));return t.electron?{renderer:"url-webview",viewURL:e,contentURL:null}:{renderer:"proxy-iframe",viewURL:e,contentURL:null}}const WL="serverURL",jL="token",GL="mode",qL="desktopAppVersion",YL="electron";function j0(n=window.location.search,t=window.location.origin){const r=new URLSearchParams(n).get(WL);return r?new URL(r).origin:new URL(t).origin}function KL(n=window.location.search){return new URLSearchParams(n).get(jL)}function Wt(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(GL)===YL}function G0(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(qL)}const mv="tv.telemetry.clientId",JL=5,XL=60,QL=1e3,eD=JL*XL*QL,vv=["pointerdown","scroll","keydown"],yv=["focus"],bv=["visibilitychange"],tD="hidden";function nD(n,t=aD){const e=n.getItem(mv);if(e)return e;const r=t();return n.setItem(mv,r),r}function rD(n){return{clientId:nD(n.storage,n.idFactory),userAgent:n.userAgent??(typeof navigator>"u"?"":navigator.userAgent),clientApp:n.clientApp,...n.desktopAppVersion?{desktopAppVersion:n.desktopAppVersion}:{}}}function iD(n){const t=new URLSearchParams;return t.set("clientId",n.clientId),t.set("userAgent",n.userAgent),t.set("clientApp",n.clientApp),n.desktopAppVersion&&t.set("desktopAppVersion",n.desktopAppVersion),t}function sD(n){return new oD(n)}var ra,Rn,Qn,ia,sa,yt,Yr,oa,Oc,q0;class oD{constructor(t){b(this,Oc);b(this,ra);b(this,Rn);b(this,Qn);b(this,ia);b(this,sa);b(this,yt);b(this,Yr,!1);b(this,oa,Number.NEGATIVE_INFINITY);m(this,ra,t.meta),m(this,Rn,t.documentTarget),m(this,Qn,t.windowTarget),m(this,ia,t.send),m(this,sa,t.nowMs??Date.now),m(this,yt,()=>d(this,Oc,q0).call(this))}start(){if(!l(this,Yr)){m(this,Yr,!0);for(const t of vv)l(this,Qn).addEventListener(t,l(this,yt)),l(this,Rn).addEventListener(t,l(this,yt));for(const t of yv)l(this,Qn).addEventListener(t,l(this,yt));for(const t of bv)l(this,Rn).addEventListener(t,l(this,yt))}}stop(){if(l(this,Yr)){m(this,Yr,!1);for(const t of vv)l(this,Qn).removeEventListener(t,l(this,yt)),l(this,Rn).removeEventListener(t,l(this,yt));for(const t of yv)l(this,Qn).removeEventListener(t,l(this,yt));for(const t of bv)l(this,Rn).removeEventListener(t,l(this,yt))}}}ra=new WeakMap,Rn=new WeakMap,Qn=new WeakMap,ia=new WeakMap,sa=new WeakMap,yt=new WeakMap,Yr=new WeakMap,oa=new WeakMap,Oc=new WeakSet,q0=function(){if(l(this,Rn).visibilityState===tD)return;const t=l(this,sa).call(this);t-l(this,oa)<eD||(m(this,oa,t),l(this,ia).call(this,{type:fC,clientId:l(this,ra).clientId}))};function aD(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():fu().toLowerCase()}const fe={authenticate:"authenticate",document_did_change:"document/didChange",document_did_close:"document/didClose",document_did_focus:"document/didFocus",document_did_open:"document/didOpen",document_did_save:"document/didSave",initialize:"initialize",logout:"logout",nes_accept:"nes/accept",nes_close:"nes/close",nes_reject:"nes/reject",nes_start:"nes/start",nes_suggest:"nes/suggest",session_cancel:"session/cancel",session_close:"session/close",session_fork:"session/fork",session_list:"session/list",session_load:"session/load",session_new:"session/new",session_prompt:"session/prompt",session_resume:"session/resume",session_set_config_option:"session/set_config_option",session_set_mode:"session/set_mode",session_set_model:"session/set_model"},kn={fs_read_text_file:"fs/read_text_file",fs_write_text_file:"fs/write_text_file",session_request_permission:"session/request_permission",session_update:"session/update",terminal_create:"terminal/create",terminal_kill:"terminal/kill",terminal_output:"terminal/output",terminal_release:"terminal/release",terminal_wait_for_exit:"terminal/wait_for_exit"},lD=1,cD=w({_meta:k(p(),_()).nullish(),terminal:Ne().optional().default(!1)}),uD=w({_meta:k(p(),_()).nullish(),label:p().nullish(),name:p(),optional:Ne().optional().default(!1),secret:Ne().optional().default(!0)}),hD=w({_meta:k(p(),_()).nullish(),description:p().nullish(),id:p(),name:p()}),dD=w({_meta:k(p(),_()).nullish(),description:p().nullish(),id:p(),link:p().nullish(),name:p(),vars:M(uD)}),pD=w({_meta:k(p(),_()).nullish(),args:M(p()).optional(),description:p().nullish(),env:k(p(),p()).optional(),id:p(),name:p()}),fD=j([dD.and(w({type:T("env_var")})),pD.and(w({type:T("terminal")})),hD]),gD=w({_meta:k(p(),_()).nullish(),methodId:p()}),mD=w({_meta:k(p(),_()).nullish()}),vD=w({_meta:k(p(),_()).nullish(),blob:p(),mimeType:p().nullish(),uri:p()}),yD=w({default:Ne().nullish(),description:p().nullish(),title:p().nullish()}),bD=w({_meta:k(p(),_()).nullish()}),wD=w({_meta:k(p(),_()).nullish()}),SD=w({amount:B(),currency:p()}),_D=w({_meta:k(p(),_()).nullish(),terminalId:p()}),kD=w({_meta:k(p(),_()).nullish(),newText:p(),oldText:p().nullish(),path:p()}),ED=j([p(),B(),B(),Ne(),M(p())]),xD=w({content:k(p(),ED).nullish()}),AD=j([xD.and(w({action:T("accept")})),w({action:T("decline")}),w({action:T("cancel")})]),TD=w({_meta:k(p(),_()).nullish()}),Y0=p(),$D=w({_meta:k(p(),_()).nullish(),elicitationId:Y0}),CD=w({_meta:k(p(),_()).nullish(),action:AD}),ID=T("object"),RD=T("string"),PD=w({_meta:k(p(),_()).nullish()}),LD=w({_meta:k(p(),_()).nullish(),form:TD.nullish(),url:PD.nullish()}),DD=w({elicitationId:Y0,url:p().url()}),K0=w({const:p(),title:p()}),J0=w({_meta:k(p(),_()).nullish(),name:p(),value:p()}),MD=j([T(-32700),T(-32600),T(-32601),T(-32602),T(-32603),T(-32800),T(-32e3),T(-32002),T(-32042),B().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),X0=w({code:MD,data:_().optional(),message:p()}),Q0=_(),ew=_(),tw=_(),zD=w({_meta:k(p(),_()).nullish(),readTextFile:Ne().optional().default(!1),writeTextFile:Ne().optional().default(!1)}),nw=w({_meta:k(p(),_()).nullish(),name:p(),value:p()}),rw=w({_meta:k(p(),_()).nullish(),name:p(),title:p().nullish(),version:p()}),OD=w({default:B().nullish(),description:p().nullish(),maximum:B().nullish(),minimum:B().nullish(),title:p().nullish()}),ND=w({_meta:k(p(),_()).nullish()}),UD=w({_meta:k(p(),_()).nullish(),additionalDirectories:M(p()).optional(),cursor:p().nullish(),cwd:p().nullish()}),FD=w({_meta:k(p(),_()).nullish()}),HD=w({_meta:k(p(),_()).nullish(),logout:FD.nullish()}),VD=w({_meta:k(p(),_()).nullish()}),ZD=w({_meta:k(p(),_()).nullish()}),BD=w({_meta:k(p(),_()).nullish(),http:Ne().optional().default(!1),sse:Ne().optional().default(!1)}),WD=w({_meta:k(p(),_()).nullish(),headers:M(nw),name:p(),url:p()}),jD=w({_meta:k(p(),_()).nullish(),headers:M(nw),name:p(),url:p()}),GD=w({_meta:k(p(),_()).nullish(),args:M(p()),command:p(),env:M(J0),name:p()}),wu=j([WD.and(w({type:T("http")})),jD.and(w({type:T("sse")})),GD]),pf=p(),qD=w({_meta:k(p(),_()).nullish(),description:p().nullish(),modelId:pf,name:p()}),YD=j([T("error"),T("warning"),T("information"),T("hint")]),KD=w({_meta:k(p(),_()).nullish()}),JD=w({_meta:k(p(),_()).nullish()}),XD=w({_meta:k(p(),_()).nullish()}),QD=w({_meta:k(p(),_()).nullish()}),e6=w({_meta:k(p(),_()).nullish()}),t6=w({_meta:k(p(),_()).nullish(),maxCount:B().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),n6=w({diff:p(),uri:p()}),r6=w({endLine:B().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:B().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:p()}),i6=w({_meta:k(p(),_()).nullish()}),s6=w({_meta:k(p(),_()).nullish()}),o6=w({languageId:p(),text:p(),uri:p()}),a6=w({_meta:k(p(),_()).nullish(),maxCount:B().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),l6=j([T("rejected"),T("ignored"),T("replaced"),T("cancelled")]),c6=w({excerpts:M(r6),uri:p()}),u6=w({_meta:k(p(),_()).nullish()}),h6=w({_meta:k(p(),_()).nullish()}),d6=w({name:p(),owner:p(),remoteUrl:p()}),p6=w({_meta:k(p(),_()).nullish()}),f6=w({_meta:k(p(),_()).nullish(),jump:i6.nullish(),rename:h6.nullish(),searchAndReplace:p6.nullish()}),g6=w({id:p(),isRegex:Ne().nullish(),replace:p(),search:p(),uri:p()}),m6=j([T("automatic"),T("diagnostic"),T("manual")]),v6=w({_meta:k(p(),_()).nullish(),maxCount:B().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),y6=w({_meta:k(p(),_()).nullish(),diagnostics:KD.nullish(),editHistory:t6.nullish(),openFiles:s6.nullish(),recentFiles:a6.nullish(),relatedSnippets:u6.nullish(),userActions:v6.nullish()}),b6=w({_meta:k(p(),_()).nullish(),additionalDirectories:M(p()).optional(),cwd:p(),mcpServers:M(wu)}),w6=w({default:B().nullish(),description:p().nullish(),maximum:B().nullish(),minimum:B().nullish(),title:p().nullish()}),iw=p(),S6=j([T("allow_once"),T("allow_always"),T("reject_once"),T("reject_always")]),_6=w({_meta:k(p(),_()).nullish(),kind:S6,name:p(),optionId:iw}),k6=j([T("high"),T("medium"),T("low")]),E6=j([T("pending"),T("in_progress"),T("completed")]),x6=w({_meta:k(p(),_()).nullish(),content:p(),priority:k6,status:E6}),A6=w({_meta:k(p(),_()).nullish(),entries:M(x6)}),gr=w({character:B().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:B().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),T6=w({id:p(),position:gr,uri:p()}),$6=w({id:p(),newName:p(),position:gr,uri:p()}),C6=w({action:p(),position:gr,timestampMs:B(),uri:p()}),sw=j([T("utf-16"),T("utf-32"),T("utf-8")]),I6=w({_meta:k(p(),_()).nullish(),auth:cD.optional().default({terminal:!1}),elicitation:LD.nullish(),fs:zD.optional().default({readTextFile:!1,writeTextFile:!1}),nes:f6.nullish(),positionEncodings:M(sw).optional(),terminal:Ne().optional().default(!1)}),R6=w({_meta:k(p(),_()).nullish(),audio:Ne().optional().default(!1),embeddedContext:Ne().optional().default(!1),image:Ne().optional().default(!1)}),ow=B().int().gte(0).lte(65535),P6=w({_meta:k(p(),_()).nullish(),clientCapabilities:I6.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:rw.nullish(),protocolVersion:ow}),to=w({end:gr,start:gr}),L6=w({message:p(),range:to,severity:YD,uri:p()}),D6=w({languageId:p(),lastFocusedMs:B().nullish(),uri:p(),visibleRange:to.nullish()}),M6=w({_meta:k(p(),_()).nullish(),diagnostics:M(L6).nullish(),editHistory:M(n6).nullish(),openFiles:M(D6).nullish(),recentFiles:M(o6).nullish(),relatedSnippets:M(c6).nullish(),userActions:M(C6).nullish()}),z6=w({newText:p(),range:to}),O6=w({cursorPosition:gr.nullish(),edits:M(z6),id:p(),uri:p()}),N6=j([O6.and(w({kind:T("edit")})),T6.and(w({kind:T("jump")})),$6.and(w({kind:T("rename")})),g6.and(w({kind:T("searchAndReplace")}))]),U6=w({_meta:k(p(),_()).nullish(),content:p()}),F6=w({_meta:k(p(),_()).nullish()}),bi=j([B(),p()]).nullable();w({_meta:k(p(),_()).nullish(),requestId:bi});const H6=z0(["assistant","user"]),ml=w({_meta:k(p(),_()).nullish(),audience:M(H6).nullish(),lastModified:p().nullish(),priority:B().nullish()}),V6=w({_meta:k(p(),_()).nullish(),annotations:ml.nullish(),data:p(),mimeType:p()}),Z6=w({_meta:k(p(),_()).nullish(),annotations:ml.nullish(),data:p(),mimeType:p(),uri:p().nullish()}),B6=w({_meta:k(p(),_()).nullish(),annotations:ml.nullish(),description:p().nullish(),mimeType:p().nullish(),name:p(),size:B().nullish(),title:p().nullish(),uri:p()}),W6=w({_meta:k(p(),_()).nullish(),optionId:iw}),j6=j([w({outcome:T("cancelled")}),W6.and(w({outcome:T("selected")}))]),G6=w({_meta:k(p(),_()).nullish(),outcome:j6}),q6=w({_meta:k(p(),_()).nullish()}),Y6=w({_meta:k(p(),_()).nullish()}),K6=w({currentValue:Ne()}),J6=p(),aw=p(),X6=j([T("mode"),T("model"),T("thought_level"),p()]),ff=p(),lw=w({_meta:k(p(),_()).nullish(),description:p().nullish(),name:p(),value:ff}),Q6=w({_meta:k(p(),_()).nullish(),group:J6,name:p(),options:M(lw)}),eM=j([M(lw),M(Q6)]),tM=w({currentValue:ff,options:eM}),no=bu(j([tM.and(w({type:T("select")})),K6.and(w({type:T("boolean")}))]),w({_meta:k(p(),_()).nullish(),category:X6.nullish(),description:p().nullish(),id:aw,name:p()})),nM=w({_meta:k(p(),_()).nullish(),configOptions:M(no)}),rM=w({_meta:k(p(),_()).nullish()}),te=p(),iM=w({_meta:k(p(),_()).nullish(),id:p(),sessionId:te}),sM=w({_meta:k(p(),_()).nullish(),sessionId:te}),oM=w({_meta:k(p(),_()).nullish(),sessionId:te}),aM=w({_meta:k(p(),_()).nullish(),sessionId:te}),cw=w({_meta:k(p(),_()).nullish(),args:M(p()).optional(),command:p(),cwd:p().nullish(),env:M(J0).optional(),outputByteLimit:B().nullish(),sessionId:te}),lM=w({_meta:k(p(),_()).nullish(),sessionId:te,uri:p()}),cM=w({_meta:k(p(),_()).nullish(),position:gr,sessionId:te,uri:p(),version:B(),visibleRange:to}),uM=w({_meta:k(p(),_()).nullish(),languageId:p(),sessionId:te,text:p(),uri:p(),version:B()}),hM=w({_meta:k(p(),_()).nullish(),sessionId:te,uri:p()}),dM=w({_meta:k(p(),_()).nullish(),additionalDirectories:M(p()).optional(),cwd:p(),mcpServers:M(wu).optional(),sessionId:te}),uw=w({_meta:k(p(),_()).nullish(),sessionId:te,terminalId:p()}),pM=w({_meta:k(p(),_()).nullish(),additionalDirectories:M(p()).optional(),cwd:p(),mcpServers:M(wu),sessionId:te}),hw=w({_meta:k(p(),_()).nullish(),limit:B().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:B().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:p(),sessionId:te}),fM=w({_meta:k(p(),_()).nullish(),id:p(),reason:l6.nullish(),sessionId:te}),dw=w({_meta:k(p(),_()).nullish(),sessionId:te,terminalId:p()}),gM=w({_meta:k(p(),_()).nullish(),additionalDirectories:M(p()).optional(),cwd:p(),mcpServers:M(wu).optional(),sessionId:te}),mM=w({_meta:k(p(),_()).nullish(),additionalDirectories:M(p()).optional(),cwd:p(),sessionId:te,title:p().nullish(),updatedAt:p().nullish()}),vM=w({_meta:k(p(),_()).nullish(),nextCursor:p().nullish(),sessions:M(mM)}),yM=w({_meta:k(p(),_()).nullish(),title:p().nullish(),updatedAt:p().nullish()}),bM=w({_meta:k(p(),_()).nullish()}),Su=p(),wM=w({_meta:k(p(),_()).nullish(),currentModeId:Su}),SM=w({_meta:k(p(),_()).nullish(),description:p().nullish(),id:Su,name:p()}),_u=w({_meta:k(p(),_()).nullish(),availableModes:M(SM),currentModeId:Su}),ku=w({_meta:k(p(),_()).nullish(),availableModels:M(qD),currentModelId:pf}),_M=w({_meta:k(p(),_()).nullish(),configOptions:M(no).nullish(),models:ku.nullish(),modes:_u.nullish(),sessionId:te}),kM=w({_meta:k(p(),_()).nullish(),configOptions:M(no).nullish(),models:ku.nullish(),modes:_u.nullish()}),EM=w({_meta:k(p(),_()).nullish(),configOptions:M(no).nullish(),models:ku.nullish(),modes:_u.nullish(),sessionId:te}),xM=w({_meta:k(p(),_()).nullish(),configOptions:M(no).nullish(),models:ku.nullish(),modes:_u.nullish()}),AM=w({_meta:k(p(),_()).nullish()}),TM=w({_meta:k(p(),_()).nullish(),additionalDirectories:q6.nullish(),close:Y6.nullish(),fork:rM.nullish(),list:bM.nullish(),resume:AM.nullish()}),$M=bu(j([w({type:T("boolean"),value:Ne()}),w({value:ff})]),w({_meta:k(p(),_()).nullish(),configId:aw,sessionId:te})),CM=w({_meta:k(p(),_()).nullish(),configOptions:M(no)}),IM=w({_meta:k(p(),_()).nullish(),modeId:Su,sessionId:te}),RM=w({_meta:k(p(),_()).nullish()}),PM=w({_meta:k(p(),_()).nullish(),modelId:pf,sessionId:te}),LM=w({_meta:k(p(),_()).nullish()}),DM=w({_meta:k(p(),_()).nullish(),sessionId:te}),MM=j([T("end_turn"),T("max_tokens"),T("max_turn_requests"),T("refusal"),T("cancelled")]),zM=j([T("email"),T("uri"),T("date"),T("date-time")]),OM=w({default:p().nullish(),description:p().nullish(),enum:M(p()).nullish(),format:zM.nullish(),maxLength:B().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:B().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:M(K0).nullish(),pattern:p().nullish(),title:p().nullish()}),NM=w({_meta:k(p(),_()).nullish(),context:M6.nullish(),position:gr,selection:to.nullish(),sessionId:te,triggerKind:m6,uri:p(),version:B()}),UM=w({_meta:k(p(),_()).nullish(),suggestions:M(N6)}),FM=w({_meta:k(p(),_()).nullish(),terminalId:p()}),HM=w({_meta:k(p(),_()).nullish(),exitCode:B().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:p().nullish()}),pw=w({_meta:k(p(),_()).nullish(),sessionId:te,terminalId:p()}),VM=w({_meta:k(p(),_()).nullish(),exitStatus:HM.nullish(),output:p(),truncated:Ne()}),ZM=w({_meta:k(p(),_()).nullish(),annotations:ml.nullish(),text:p()}),BM=w({range:to.nullish(),text:p()}),WM=w({_meta:k(p(),_()).nullish(),contentChanges:M(BM),sessionId:te,uri:p(),version:B()});w({method:p(),params:j([sM,uM,WM,lM,hM,cM,iM,fM,Q0]).nullish()});const jM=j([T("full"),T("incremental")]),GM=w({_meta:k(p(),_()).nullish(),syncKind:jM}),qM=w({_meta:k(p(),_()).nullish(),didChange:GM.nullish(),didClose:JD.nullish(),didFocus:XD.nullish(),didOpen:QD.nullish(),didSave:e6.nullish()}),YM=w({_meta:k(p(),_()).nullish(),document:qM.nullish()}),KM=w({_meta:k(p(),_()).nullish(),context:y6.nullish(),events:YM.nullish()}),JM=w({_meta:k(p(),_()).nullish(),auth:HD.optional().default({}),loadSession:Ne().optional().default(!1),mcpCapabilities:BD.optional().default({http:!1,sse:!1}),nes:KM.nullish(),positionEncoding:sw.nullish(),promptCapabilities:R6.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:TM.optional().default({})}),XM=w({_meta:k(p(),_()).nullish(),agentCapabilities:JM.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:rw.nullish(),authMethods:M(fD).optional().default([]),protocolVersion:ow}),QM=w({_meta:k(p(),_()).nullish(),mimeType:p().nullish(),text:p(),uri:p()}),ez=j([QM,vD]),tz=w({_meta:k(p(),_()).nullish(),annotations:ml.nullish(),resource:ez}),gf=j([ZM.and(w({type:T("text")})),Z6.and(w({type:T("image")})),V6.and(w({type:T("audio")})),B6.and(w({type:T("resource_link")})),tz.and(w({type:T("resource")}))]),nz=w({_meta:k(p(),_()).nullish(),content:gf}),kh=w({_meta:k(p(),_()).nullish(),content:gf,messageId:p().nullish()}),rz=w({_meta:k(p(),_()).nullish(),messageId:p().nullish(),prompt:M(gf),sessionId:te}),iz=w({anyOf:M(K0)}),fw=j([nz.and(w({type:T("content")})),kD.and(w({type:T("diff")})),FM.and(w({type:T("terminal")}))]),gw=p(),mw=w({_meta:k(p(),_()).nullish(),line:B().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:p()}),vw=j([T("pending"),T("in_progress"),T("completed"),T("failed")]),yw=j([T("read"),T("edit"),T("delete"),T("move"),T("search"),T("execute"),T("think"),T("fetch"),T("switch_mode"),T("other")]),sz=w({_meta:k(p(),_()).nullish(),content:M(fw).optional(),kind:yw.optional(),locations:M(mw).optional(),rawInput:_().optional(),rawOutput:_().optional(),status:vw.optional(),title:p(),toolCallId:gw}),bw=w({_meta:k(p(),_()).nullish(),content:M(fw).nullish(),kind:yw.nullish(),locations:M(mw).nullish(),rawInput:_().optional(),rawOutput:_().optional(),status:vw.nullish(),title:p().nullish(),toolCallId:gw}),ww=w({_meta:k(p(),_()).nullish(),options:M(_6),sessionId:te,toolCall:bw}),oz=w({_meta:k(p(),_()).nullish(),hint:p()}),az=oz,lz=w({_meta:k(p(),_()).nullish(),description:p(),input:az.nullish(),name:p()}),cz=w({_meta:k(p(),_()).nullish(),availableCommands:M(lz)}),uz=w({enum:M(p()),type:RD}),hz=j([uz,iz]),dz=w({default:M(p()).nullish(),description:p().nullish(),items:hz,maxItems:B().nullish(),minItems:B().nullish(),title:p().nullish()}),pz=j([OM.and(w({type:T("string")})),w6.and(w({type:T("number")})),OD.and(w({type:T("integer")})),yD.and(w({type:T("boolean")})),dz.and(w({type:T("array")}))]),fz=w({description:p().nullish(),properties:k(p(),pz).optional().default({}),required:M(p()).nullish(),title:p().nullish(),type:ID.optional().default("object")}),gz=w({requestedSchema:fz}),mz=bu(j([gz.and(w({mode:T("form")})),DD.and(w({mode:T("url")}))]),w({_meta:k(p(),_()).nullish(),message:p(),sessionId:te})),vz=w({cachedReadTokens:B().nullish(),cachedWriteTokens:B().nullish(),inputTokens:B(),outputTokens:B(),thoughtTokens:B().nullish(),totalTokens:B()}),yz=w({_meta:k(p(),_()).nullish(),stopReason:MM,usage:vz.nullish(),userMessageId:p().nullish()});j([w({id:bi,result:j([XM,mD,ZD,EM,kM,vM,_M,xM,wD,RM,CM,yz,LM,DM,UM,bD,tw])}),w({error:X0,id:bi})]);const bz=w({_meta:k(p(),_()).nullish(),cost:SD.nullish(),size:B(),used:B()}),wz=j([kh.and(w({sessionUpdate:T("user_message_chunk")})),kh.and(w({sessionUpdate:T("agent_message_chunk")})),kh.and(w({sessionUpdate:T("agent_thought_chunk")})),sz.and(w({sessionUpdate:T("tool_call")})),bw.and(w({sessionUpdate:T("tool_call_update")})),A6.and(w({sessionUpdate:T("plan")})),cz.and(w({sessionUpdate:T("available_commands_update")})),wM.and(w({sessionUpdate:T("current_mode_update")})),nM.and(w({sessionUpdate:T("config_option_update")})),yM.and(w({sessionUpdate:T("session_info_update")})),bz.and(w({sessionUpdate:T("usage_update")}))]),Sw=w({_meta:k(p(),_()).nullish(),sessionId:te,update:wz});w({method:p(),params:j([Sw,$D,Q0]).nullish()});const _w=w({_meta:k(p(),_()).nullish(),sessionId:te,terminalId:p()}),Sz=w({_meta:k(p(),_()).nullish(),exitCode:B().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:p().nullish()}),_z=w({name:p(),uri:p()}),kz=w({_meta:k(p(),_()).nullish(),repository:d6.nullish(),workspaceFolders:M(_z).nullish(),workspaceUri:p().nullish()});w({id:bi,method:p(),params:j([P6,gD,VD,b6,pM,UD,dM,gM,aM,IM,$M,rz,PM,kz,NM,oM,ew]).nullish()});const kw=w({_meta:k(p(),_()).nullish(),content:p(),path:p(),sessionId:te});w({id:bi,method:p(),params:j([kw,hw,ww,cw,pw,dw,_w,uw,mz,ew]).nullish()});const Ez=w({_meta:k(p(),_()).nullish()});j([w({id:bi,result:j([Ez,U6,G6,_D,VM,F6,Sz,ND,CD,tw])}),w({error:X0,id:bi})]);var Q;class xz{constructor(t,e){b(this,Q);const r=t(this),i=async(o,a)=>{var c,u,h,f,v,y,E;switch(o){case kn.fs_write_text_file:{const x=kw.parse(a);return(c=r.writeTextFile)==null?void 0:c.call(r,x)}case kn.fs_read_text_file:{const x=hw.parse(a);return(u=r.readTextFile)==null?void 0:u.call(r,x)}case kn.session_request_permission:{const x=ww.parse(a);return r.requestPermission(x)}case kn.terminal_create:{const x=cw.parse(a);return(h=r.createTerminal)==null?void 0:h.call(r,x)}case kn.terminal_output:{const x=pw.parse(a);return(f=r.terminalOutput)==null?void 0:f.call(r,x)}case kn.terminal_release:{const x=dw.parse(a);return await((v=r.releaseTerminal)==null?void 0:v.call(r,x))??{}}case kn.terminal_wait_for_exit:{const x=_w.parse(a);return(y=r.waitForTerminalExit)==null?void 0:y.call(r,x)}case kn.terminal_kill:{const x=uw.parse(a);return await((E=r.killTerminal)==null?void 0:E.call(r,x))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw Le.methodNotFound(o)}},s=async(o,a)=>{switch(o){case kn.session_update:{const c=Sw.parse(a);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(o,a);throw Le.methodNotFound(o)}};m(this,Q,new Az(i,s,e))}async initialize(t){return await l(this,Q).sendRequest(fe.initialize,t)}async newSession(t){return await l(this,Q).sendRequest(fe.session_new,t)}async loadSession(t){return await l(this,Q).sendRequest(fe.session_load,t)??{}}async unstable_forkSession(t){return await l(this,Q).sendRequest(fe.session_fork,t)}async listSessions(t){return await l(this,Q).sendRequest(fe.session_list,t)}async unstable_resumeSession(t){return await l(this,Q).sendRequest(fe.session_resume,t)}async unstable_closeSession(t){return await l(this,Q).sendRequest(fe.session_close,t)}async setSessionMode(t){return await l(this,Q).sendRequest(fe.session_set_mode,t)??{}}async unstable_setSessionModel(t){return await l(this,Q).sendRequest(fe.session_set_model,t)??{}}async setSessionConfigOption(t){return await l(this,Q).sendRequest(fe.session_set_config_option,t)}async authenticate(t){return await l(this,Q).sendRequest(fe.authenticate,t)??{}}async unstable_logout(t){return await l(this,Q).sendRequest(fe.logout,t)??{}}async prompt(t){return await l(this,Q).sendRequest(fe.session_prompt,t)}async cancel(t){return await l(this,Q).sendNotification(fe.session_cancel,t)}async unstable_startNes(t){return await l(this,Q).sendRequest(fe.nes_start,t)}async unstable_suggestNes(t){return await l(this,Q).sendRequest(fe.nes_suggest,t)}async unstable_closeNes(t){return await l(this,Q).sendRequest(fe.nes_close,t)??{}}async unstable_didOpenDocument(t){return await l(this,Q).sendNotification(fe.document_did_open,t)}async unstable_didChangeDocument(t){return await l(this,Q).sendNotification(fe.document_did_change,t)}async unstable_didCloseDocument(t){return await l(this,Q).sendNotification(fe.document_did_close,t)}async unstable_didSaveDocument(t){return await l(this,Q).sendNotification(fe.document_did_save,t)}async unstable_didFocusDocument(t){return await l(this,Q).sendNotification(fe.document_did_focus,t)}async unstable_acceptNes(t){return await l(this,Q).sendNotification(fe.nes_accept,t)}async unstable_rejectNes(t){return await l(this,Q).sendNotification(fe.nes_reject,t)}async extMethod(t,e){return await l(this,Q).sendRequest(t,e)}async extNotification(t,e){return await l(this,Q).sendNotification(t,e)}get signal(){return l(this,Q).signal}get closed(){return l(this,Q).closed}}Q=new WeakMap;var er,Nc,aa,la,cs,us,tn,ca,ve,Ew,ud,xw,Aw,Tw,$w,hd,Eo;class Az{constructor(t,e,r){b(this,ve);b(this,er,new Map);b(this,Nc,0);b(this,aa);b(this,la);b(this,cs);b(this,us,Promise.resolve());b(this,tn,new AbortController);b(this,ca);m(this,aa,t),m(this,la,e),m(this,cs,r),m(this,ca,new Promise(i=>{l(this,tn).signal.addEventListener("abort",()=>i())})),d(this,ve,Ew).call(this)}get signal(){return l(this,tn).signal}get closed(){return l(this,ca)}async sendRequest(t,e){d(this,ve,hd).call(this);const r=Bu(this,Nc)._++,i=new Promise((s,o)=>{l(this,er).set(r,{resolve:s,reject:o})});return await d(this,ve,Eo).call(this,{jsonrpc:"2.0",id:r,method:t,params:e}),i}async sendNotification(t,e){d(this,ve,hd).call(this),await d(this,ve,Eo).call(this,{jsonrpc:"2.0",method:t,params:e})}}er=new WeakMap,Nc=new WeakMap,aa=new WeakMap,la=new WeakMap,cs=new WeakMap,us=new WeakMap,tn=new WeakMap,ca=new WeakMap,ve=new WeakSet,Ew=async function(){let t;try{const e=l(this,cs).readable.getReader();try{for(;!l(this,tn).signal.aborted;){const{value:r,done:i}=await e.read();if(i)break;if(r)try{d(this,ve,xw).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&d(this,ve,Eo).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{e.releaseLock()}}catch(e){t=e}finally{d(this,ve,ud).call(this,t)}},ud=function(t){if(l(this,tn).signal.aborted)return;const e=t??new Error("ACP connection closed");for(const r of l(this,er).values())r.reject(e);l(this,er).clear(),l(this,tn).abort(e)},xw=async function(t){if("method"in t&&"id"in t){const e=await d(this,ve,Aw).call(this,t.method,t.params);"error"in e&&console.error("Error handling request",t,e.error),await d(this,ve,Eo).call(this,{jsonrpc:"2.0",id:t.id,...e})}else if("method"in t){const e=await d(this,ve,Tw).call(this,t.method,t.params);"error"in e&&console.error("Error handling notification",t,e.error)}else"id"in t?d(this,ve,$w).call(this,t):console.error("Invalid message",{message:t})},Aw=async function(t,e){try{return{result:await l(this,aa).call(this,t,e)??null}}catch(r){if(r instanceof Le)return r.toResult();if(r instanceof uv)return Le.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return Le.internalError(i?JSON.parse(i):{}).toResult()}catch{return Le.internalError({details:i}).toResult()}}},Tw=async function(t,e){try{return await l(this,la).call(this,t,e),{result:null}}catch(r){if(r instanceof Le)return r.toResult();if(r instanceof uv)return Le.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return Le.internalError(i?JSON.parse(i):{}).toResult()}catch{return Le.internalError({details:i}).toResult()}}},$w=function(t){const e=l(this,er).get(t.id);if(e){if("result"in t)e.resolve(t.result);else if("error"in t){const{code:r,message:i,data:s}=t.error;e.reject(new Le(r,i,s))}l(this,er).delete(t.id)}else console.error("Got response to unknown request",t.id)},hd=function(){if(l(this,tn).signal.aborted)throw l(this,tn).signal.reason??new Error("ACP connection closed")},Eo=async function(t){return m(this,us,l(this,us).then(async()=>{const e=l(this,cs).writable.getWriter();try{await e.write(t)}finally{e.releaseLock()}}).catch(e=>{d(this,ve,ud).call(this,e)})),l(this,us)};class Le extends Error{constructor(e,r,i){super(r);g(this,"code");g(this,"data");this.code=e,this.name="RequestError",this.data=i}static parseError(e,r){return new Le(-32700,`Parse error${r?`: ${r}`:""}`,e)}static invalidRequest(e,r){return new Le(-32600,`Invalid request${r?`: ${r}`:""}`,e)}static methodNotFound(e){return new Le(-32601,`"Method not found": ${e}`,{method:e})}static invalidParams(e,r){return new Le(-32602,`Invalid params${r?`: ${r}`:""}`,e)}static internalError(e,r){return new Le(-32603,`Internal error${r?`: ${r}`:""}`,e)}static authRequired(e,r){return new Le(-32e3,`Authentication required${r?`: ${r}`:""}`,e)}static resourceNotFound(e){return new Le(-32002,`Resource not found${e?`: ${e}`:""}`,e&&{uri:e})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const Tz=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,$z=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,Cz=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,Iz=/\b(tv|television|screen|artifact|artifacts|viewer|filmstrip|layout|focus)\b/i,Rz=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,Pz="single_session",Lz={name:"television-acp-client",version:"0.0.0"},Cw="agent:main:television",Dz=gl(It);var hs,nn,pt,rn,tr,Mt,Pn,sn,on,nr,zt,ds,ps,an,et,Ln,fs,Kr,Dn,rr,ua,Ot,ln,Uc,cn,$,dd,Iw,Rw,Pw,rc,Lw,Dw,Mw,zw,Ow,Nw,Uw,Rr,ji,Gi,xn,Fw,qi,pd,fd,ic,Hw,sc,gd,md,ha,da,oc,Yi,vd,Vw;class Mz extends Dz{constructor(e){super();b(this,$);b(this,hs,"disconnected");b(this,nn,null);b(this,pt,new Map);b(this,rn,null);b(this,tr,null);b(this,Mt,null);b(this,Pn,null);b(this,sn,null);b(this,on,null);b(this,nr);b(this,zt,null);b(this,ds,0);b(this,ps,1);b(this,an,null);b(this,et,null);b(this,Ln,!1);b(this,fs,!1);b(this,Kr,!1);b(this,Dn,null);b(this,rr,new Set);b(this,ua);b(this,Ot);b(this,ln);b(this,Uc,e=>{d(this,$,Rw).call(this,e)});b(this,cn,null);b(this,ha,()=>{d(this,$,Yi).call(this,"ACP bridge websocket closed")});b(this,da,()=>{d(this,$,Yi).call(this,"ACP bridge websocket error")});m(this,Ot,e),m(this,ln,e.sessionMode??Pz),m(this,nr,e.mappedSessionStore??zz()),m(this,ua,e.createSocket??(r=>new WebSocket(r)))}get status(){return l(this,hs)}get messages(){return[...l(this,pt).values()]}get enabled(){return l(this,Ot).enabled??!1}setToken(e){l(this,Ot).token=e??""}setEnabled(e){l(this,Ot).enabled=e,e||(d(this,$,oc).call(this),m(this,nn,null),d(this,$,xn).call(this,"disconnected"))}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(this.enabled&&this.status==="disconnected"){l(this,tr)===null&&(m(this,nn,null),m(this,tr,d(this,$,Iw).call(this)));try{await l(this,tr),await d(this,$,rc).call(this)}catch(e){throw d(this,$,Yi).call(this,Eh(e)),e}}}dispose(){d(this,$,oc).call(this),m(this,nn,null),d(this,$,xn).call(this,"disposed")}async sendMessage(e){if(await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await d(this,$,dd).call(this,"ready")),(l(this,sn)===null||l(this,zt)!==d(this,$,sc).call(this))&&await d(this,$,rc).call(this),this.status!=="ready")throw new Error("ACPClient is not ready to send a new message");const r=e.text.trim();if(!r)throw new Error("Cannot send an empty message");d(this,$,ji).call(this,{id:d(this,$,qi).call(this,"user"),kind:"user",text:r,status:"final"}),d(this,$,xn).call(this,"running");try{const i=await d(this,$,ic).call(this).prompt({sessionId:d(this,$,fd).call(this),prompt:[{type:"text",text:d(this,$,Fw).call(this,r)}]});d(this,$,Rr).call(this,i.stopReason==="cancelled"?"cancelled":"final"),d(this,$,xn).call(this,"ready")}catch(i){throw d(this,$,Vw).call(this)||(d(this,$,Rr).call(this,"error"),d(this,$,xn).call(this,"ready")),i}}async startNewSession(){var r;await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await d(this,$,dd).call(this,"ready"));const e=d(this,$,sc).call(this);((r=l(this,on))==null?void 0:r.sessionIdStrategy)==="mapped"?l(this,nr).clearActualSessionId(e):m(this,ds,l(this,ds)+1),m(this,Mt,null),m(this,Pn,null),m(this,sn,null),m(this,zt,null),d(this,$,vd).call(this)}async cancel(){this.status==="running"&&(d(this,$,xn).call(this,"cancelling"),await d(this,$,ic).call(this).cancel({sessionId:d(this,$,fd).call(this)}))}setScreenContext(e){var s,o,a;if(e===null){if(l(this,et)===null)return;m(this,et,null),m(this,Ln,!1);return}const r={screenID:e.screenID,screenName:e.screenName};if(((s=l(this,et))==null?void 0:s.screenID)===r.screenID&&((o=l(this,et))==null?void 0:o.screenName)===r.screenName)return;const i=((a=l(this,et))==null?void 0:a.screenID)??null;if(m(this,et,r),l(this,ln)==="single_session"){(!l(this,zt)||i!==r.screenID)&&m(this,Ln,!0);return}l(this,zt)!==d(this,$,gd).call(this,r.screenID)&&(m(this,Mt,null),m(this,Pn,null),l(this,rn)&&this.status==="ready"&&d(this,$,rc).call(this).catch(c=>{d(this,$,Yi).call(this,Eh(c))}))}}hs=new WeakMap,nn=new WeakMap,pt=new WeakMap,rn=new WeakMap,tr=new WeakMap,Mt=new WeakMap,Pn=new WeakMap,sn=new WeakMap,on=new WeakMap,nr=new WeakMap,zt=new WeakMap,ds=new WeakMap,ps=new WeakMap,an=new WeakMap,et=new WeakMap,Ln=new WeakMap,fs=new WeakMap,Kr=new WeakMap,Dn=new WeakMap,rr=new WeakMap,ua=new WeakMap,Ot=new WeakMap,ln=new WeakMap,Uc=new WeakMap,cn=new WeakMap,$=new WeakSet,dd=async function(e){if(this.status!==e){if(this.status==="disposed")throw new Error("ACPClient has been disposed");if(this.status==="disconnected")throw new Error(l(this,nn)??"ACPClient is disconnected");await new Promise((r,i)=>{const s=()=>{this.removeEventListener("status-changed",o)},o=()=>{if(this.status===e){s(),r();return}if(this.status==="disposed"){s(),i(new Error("ACPClient has been disposed"));return}this.status==="disconnected"&&(s(),i(new Error(l(this,nn)??"ACPClient is disconnected")))};this.addEventListener("status-changed",o)})}},Iw=async function(){try{const{stream:e,socket:r,metadata:i}=await Fz({serverURL:l(this,Ot).serverURL,token:l(this,Ot).token,createSocket:l(this,ua),onDisconnect:l(this,Uc)});m(this,on,i),m(this,cn,r),r.addEventListener("close",l(this,ha)),r.addEventListener("error",l(this,da)),m(this,rn,new xz(s=>({connection:s,sessionUpdate:async o=>{await d(this,$,Dw).call(this,o)},requestPermission:async o=>d(this,$,Mw).call(this,o)}),e)),await l(this,rn).initialize({protocolVersion:lD,clientCapabilities:{},clientInfo:Lz})}catch(e){throw e}},Rw=function(e){d(this,$,Yi).call(this,Eh(e))},Pw=function(e){const r=e==null?void 0:e.models;if(!(r!=null&&r.currentModelId))return;const i=r.availableModels.find(s=>s.modelId===r.currentModelId);console.info("[ACPClient] Current model:",(i==null?void 0:i.name)??r.currentModelId,`(${r.currentModelId})`)},rc=async function(){const e=d(this,$,sc).call(this);if(l(this,Mt)&&l(this,Pn)===e){await l(this,Mt);return}m(this,Pn,e),m(this,Mt,d(this,$,Lw).call(this,e)),await l(this,Mt)},Lw=async function(e){var c;const r=d(this,$,ic).call(this);d(this,$,vd).call(this);let i,s=!1,o=null;const a={cwd:d(this,$,Hw).call(this),mcpServers:[],_meta:{sessionKey:e}};try{if(m(this,Kr,!0),m(this,Dn,null),((c=l(this,on))==null?void 0:c.sessionIdStrategy)==="mapped"){const u=l(this,nr).getActualSessionId(e);if(u)try{const h=await r.loadSession({...a,sessionId:u});if(Oz(h))throw new Error("Mapped ACP session was not found");o=h,i=u,s=!0}catch{const h=await r.newSession(a);o=h,i=h.sessionId,l(this,nr).setActualSessionId(e,i),s=!1}else{const h=await r.newSession(a);o=h,i=h.sessionId,l(this,nr).setActualSessionId(e,i),s=!1}}else try{o=await r.loadSession({...a,sessionId:e}),i=e,s=l(this,pt).size>0}catch{const u=await r.newSession(a);o=u,i=u.sessionId,s=!1}}finally{m(this,Kr,!1),m(this,Dn,null),d(this,$,Rr).call(this,"final")}d(this,$,Pw).call(this,o),await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),m(this,sn,i),m(this,zt,e),m(this,fs,!0),s?(l(this,rr).add(e),l(this,ln)==="single_session"&&m(this,Ln,!1)):(l(this,rr).delete(e),m(this,Ln,l(this,ln)==="single_session")),m(this,nn,null),d(this,$,xn).call(this,"ready")},Dw=async function(e){const r=e.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&d(this,$,Uw).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&d(this,$,zw).call(this,r.content.text);return;case"tool_call":d(this,$,Ow).call(this,r);return;case"tool_call_update":d(this,$,Nw).call(this,r);return;case"agent_thought_chunk":return;default:return}},Mw=async function(e){return{outcome:{outcome:"cancelled"}}},zw=function(e){m(this,Dn,null);const r=Uz(e);if(!r)return;if(!l(this,an)){const s={id:d(this,$,qi).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};m(this,an,s.id),d(this,$,ji).call(this,s);return}const i=l(this,pt).get(l(this,an));if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");d(this,$,Gi).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},Ow=function(e){d(this,$,Rr).call(this,"final");const r=d(this,$,pd).call(this,e.toolCallId),i=Sv("content"in e?e.content:void 0),s={id:(r==null?void 0:r.id)??d(this,$,qi).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:e.title,toolKind:e.kind??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??i,locations:e.locations??(r==null?void 0:r.locations)};if(r){d(this,$,Gi).call(this,s);return}d(this,$,ji).call(this,s)},Nw=function(e){const r=d(this,$,pd).call(this,e.toolCallId),i=(r==null?void 0:r.text)??"",s=Sv(e.content),o=s?`${i}${s}`:i,a={id:(r==null?void 0:r.id)??d(this,$,qi).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:(r==null?void 0:r.title)??e.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:o,locations:e.locations??(r==null?void 0:r.locations)};if(r){d(this,$,Gi).call(this,a);return}d(this,$,ji).call(this,a)},Uw=function(e){if(d(this,$,Rr).call(this,"final"),!e)return;const r=l(this,Kr)?l(this,Dn):null;if(!r){const s=wv(e);if(!s)return;const o={id:d(this,$,qi).call(this,"user"),kind:"user",text:s,status:"final"};d(this,$,ji).call(this,o),l(this,Kr)&&m(this,Dn,o.id);return}const i=l(this,pt).get(r);if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");d(this,$,Gi).call(this,{...i,text:wv(`${i.text}${e}`)})},Rr=function(e){if(!l(this,an))return;const r=l(this,pt).get(l(this,an));(r==null?void 0:r.kind)==="assistant"&&d(this,$,Gi).call(this,{...r,status:e}),m(this,an,null)},ji=function(e){l(this,pt).set(e.id,e),this.dispatchEvent(new yh("messages-changed"))},Gi=function(e){l(this,pt).set(e.id,e),this.dispatchEvent(new yh("messages-changed"))},xn=function(e){l(this,hs)!==e&&(m(this,hs,e),this.dispatchEvent(new eC("status-changed")))},Fw=function(e){const r=l(this,zt);if(!r)return e;const i=l(this,et)?l(this,ln)==="single_session"?l(this,Ln)||!l(this,rr).has(r):!l(this,rr).has(r):!1,s=l(this,fs)&&(l(this,et)!==null||Iz.test(e));if(!(s||i))return e;s&&m(this,fs,!1),i&&(m(this,Ln,!1),l(this,rr).add(r));const a=["[Television screen context]","This chat session is coming from a Television client.","Using Television requires the knowledge in the `television` skill. Re-read it only if it is not already in context or you know it changed.","If the skill is not installed, it can be installed via `tv skills install <your agent skills path>`."];return l(this,et)?(a.push("This conversation is currently attached to the screen below."),a.push(`screen_id: ${l(this,et).screenID}`),a.push(`screen_name: ${l(this,et).screenName??""}`),a.push("When the user asks to inspect or change Television state with the tv CLI, use this screen ID with the --screen argument.")):a.push("There is currently no active Television screen."),a.push("[/Television screen context]","",e),a.join(`
|
|
43
|
-
`)},qi=function(e){const r=`${e}-${l(this,ps)}`;return m(this,ps,l(this,ps)+1),r},pd=function(e){for(const r of l(this,pt).values())if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===e)return r;return null},fd=function(){if(!l(this,sn))throw new Error("ACP session is not ready");return l(this,sn)},ic=function(){if(!l(this,rn))throw new Error("ACP connection is not ready");return l(this,rn)},Hw=function(){var r;const e=(r=l(this,on))==null?void 0:r.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},sc=function(){var r;if(l(this,ln)==="single_session")return d(this,$,md).call(this,`${Cw}-${(l(this,Ot).clientGUID??"default-client").toLowerCase()}`);const e=(r=l(this,et))==null?void 0:r.screenID;if(!e)throw new Error("Screen context is required for per-screen session mode");return d(this,$,gd).call(this,e)},gd=function(e){return d(this,$,md).call(this,Nz(l(this,ln),e,l(this,Ot).clientGUID??"default-client"))},md=function(e){var r;return((r=l(this,on))==null?void 0:r.sessionIdStrategy)==="deterministic"&&l(this,ds)>0?`${e}:epoch-${l(this,ds)}`:e},ha=new WeakMap,da=new WeakMap,oc=function(){m(this,rn,null),m(this,tr,null),m(this,Mt,null),m(this,Pn,null),m(this,sn,null),m(this,zt,null),m(this,on,null),l(this,cn)&&(l(this,cn).removeEventListener("close",l(this,ha)),l(this,cn).removeEventListener("error",l(this,da)),l(this,cn).close(),m(this,cn,null))},Yi=function(e){const r=l(this,rn)!==null||l(this,tr)!==null||l(this,Mt)!==null||l(this,Pn)!==null||l(this,sn)!==null||l(this,zt)!==null||l(this,on)!==null||l(this,cn)!==null;this.disposed||this.status==="disconnected"&&!r||(d(this,$,Rr).call(this,"error"),d(this,$,oc).call(this),m(this,nn,e??null),d(this,$,xn).call(this,"disconnected"))},vd=function(){const e=l(this,pt).size>0;m(this,an,null),m(this,Dn,null),m(this,ps,1),l(this,pt).clear(),e&&this.dispatchEvent(new yh("messages-changed"))},Vw=function(){return this.status==="disconnected"};function zz(){const n=new Map;return{getActualSessionId(t){return n.get(t)??null},setActualSessionId(t,e){n.set(t,e)},clearActualSessionId(t){n.delete(t)}}}function Oz(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function Nz(n,t,e){return n==="single_session"?`${Cw}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function Zw(n){return n.replace(/^(?:\s*\n)+/,"")}function wv(n){let t=n;return t=t.replace(Tz,""),t=t.replace($z,""),t=t.replace(Cz,""),t=Zw(t),t}function Uz(n){let t=n;return t=t.replace(Rz,""),t=Zw(t),t}function Sv(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function Fz(n){const t=n.createSocket(Zz(n.serverURL,n.token));let e=!1,r,i;const s=new Promise((u,h)=>{r=u,i=h}),o=new ReadableStream({start(u){let h=!1;const f=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},v=x=>{const C=Vz(x);if(!C)return;let L;try{L=JSON.parse(C)}catch(R){const W=R instanceof Error?R:new Error(String(R));i(W),u.error(W);return}switch(L.type){case"acp-bridge-status":if(L.status==="ready"){let R;try{R=Hz(L)}catch(W){const N=W instanceof Error?W:new Error(String(W));e||i(N),u.error(N);return}e||(e=!0,r(R));return}if(L.status==="error"||L.status==="exited"){const R=new Error(L.error??`ACP bridge ${L.status}`);e||i(R),u.error(R)}return;case"acp-bridge-message":u.enqueue(L.message);return}},y=()=>{var C;if(h)return;h=!0;const x=new Error("ACP bridge websocket closed");e||i(x),(C=n.onDisconnect)==null||C.call(n,x),u.close()},E=()=>{var C;if(h)return;h=!0;const x=new Error("ACP bridge websocket error");e||i(x),(C=n.onDisconnect)==null||C.call(n,x),u.error(x)};t.addEventListener("open",f),t.addEventListener("message",v),t.addEventListener("close",y),t.addEventListener("error",E)}}),a=new WritableStream({async write(u){await s,t.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){t.close()},abort(){t.close()}}),c=await s;return{stream:{readable:o,writable:a},socket:t,metadata:c}}function Hz(n){const{agent:t,sessionIdStrategy:e,sessionCwd:r}=n;if((t==="openclaw"||t==="hermes")&&(e==="deterministic"||e==="mapped")&&typeof r=="string"&&r.length>0)return{agent:t,sessionIdStrategy:e,sessionCwd:r};throw new Error("ACP bridge ready status missing bootstrap metadata")}function Vz(n){if(typeof n=="string")return n;if(n instanceof Uint8Array)return new TextDecoder().decode(n);if(typeof Buffer<"u"&&n instanceof Buffer)return n.toString("utf8");if(typeof n=="object"&&n!==null&&"data"in n){const t=n.data;if(typeof t=="string")return t;if(t instanceof Uint8Array)return new TextDecoder().decode(t);if(Array.isArray(t))return Buffer.concat(t).toString("utf8")}return null}function Zz(n,t){const e=new URL(n);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/acp",e.search="",e.searchParams.set("token",t),e.hash="",e.toString()}function Eh(n){return n instanceof Error?n.message:String(n)}const _v="television.acpClientGUID",kv="television.acpMappedSessions",Ev=1;var gs;class Bz{constructor(){b(this,gs,new Map)}getActualSessionId(t){return l(this,gs).get(t)??null}setActualSessionId(t,e){l(this,gs).set(t,e)}clearActualSessionId(t){l(this,gs).delete(t)}}gs=new WeakMap;var ms,pa,mt,ac,lc,yd;class Wz{constructor(t,e){b(this,mt);b(this,ms);b(this,pa);m(this,ms,t),m(this,pa,e)}getActualSessionId(t){const e=d(this,mt,lc).call(this)[d(this,mt,ac).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const r=d(this,mt,lc).call(this);r[d(this,mt,ac).call(this,t)]=e,d(this,mt,yd).call(this,r)}clearActualSessionId(t){const e=d(this,mt,lc).call(this);delete e[d(this,mt,ac).call(this,t)],d(this,mt,yd).call(this,e)}}ms=new WeakMap,pa=new WeakMap,mt=new WeakSet,ac=function(t){return JSON.stringify([l(this,pa),t])},lc=function(){const t=l(this,ms).getItem(kv);if(!t)return{};let e;try{e=JSON.parse(t)}catch{return{}}if(typeof e!="object"||e===null||Array.isArray(e))return{};const r=e;return r.version!==Ev?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},yd=function(t){const e={version:Ev,entries:t};l(this,ms).setItem(kv,JSON.stringify(e))};function Bw(){return typeof window>"u"?null:window.localStorage}function jz(n){const t=n.getItem(_v);if(t)return t;const e=fu().toLowerCase();return n.setItem(_v,e),e}const xv=4401,Gz=401,Hl=1e3,qz=3e4;class Oo extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class Ww extends It{constructor(e){var o,a;super();g(this,"url");g(this,"name");g(this,"telemetryMeta");g(this,"status","unauthorized");g(this,"screens",new Map);g(this,"client");g(this,"acpClient");g(this,"_token");g(this,"attempting",!1);g(this,"nextRetryAt",null);g(this,"hasEverConnected",!1);g(this,"hasAuthRejected",!1);g(this,"bootState","pending");g(this,"serverVersion",null);g(this,"updateState",null);g(this,"decideBoot");g(this,"navigationPending");g(this,"createSocket");g(this,"createClient");g(this,"socket",null);g(this,"connectAttempt",0);g(this,"autoReconnect",!1);g(this,"retryTimer",null);g(this,"retryDelay",Hl);g(this,"visibilityEventTarget");g(this,"networkEventTarget");g(this,"onVisibilityChange");g(this,"onNetworkOnline");g(this,"telemetryActivityAgent");this.url=ee(e.url),this.name=e.name,this.decideBoot=e.decideBoot??null,this.navigationPending=e.navigationPending??(()=>!1),this._token=e.token??null,this.telemetryMeta=e.telemetryMeta??null,this.createSocket=e.createSocket??(c=>new WebSocket(c)),this.createClient=e.createClient??((c,u,h)=>new AC(c,{token:u??void 0,onUnauthorized:()=>this.handleAuthRejected(),...h?{telemetryMeta:h}:{}})),this.client=this.createClient(this.url,this._token,this.telemetryMeta);const r=e.mappedSessionStore??(e.acpStorage?new Wz(e.acpStorage,this.url):new Bz);this.acpClient=new Mz({serverURL:this.url,token:this._token??"",...e.createACPSocket?{createSocket:e.createACPSocket}:e.createSocket?{createSocket:e.createSocket}:{},...e.clientGUID?{clientGUID:e.clientGUID}:{},mappedSessionStore:r}),this.visibilityEventTarget=e.visibilityEventTarget!==void 0?e.visibilityEventTarget:typeof document<"u"?document:null,this.networkEventTarget=e.networkEventTarget!==void 0?e.networkEventTarget:typeof window<"u"?window:null,this.onVisibilityChange=()=>{this.isPageVisible()&&this.kickReconnect()},this.onNetworkOnline=()=>{this.kickReconnect()},(o=this.visibilityEventTarget)==null||o.addEventListener("visibilitychange",this.onVisibilityChange),(a=this.networkEventTarget)==null||a.addEventListener("online",this.onNetworkOnline);const i=e.telemetryDocumentTarget!==void 0?e.telemetryDocumentTarget:typeof document<"u"?document:null,s=e.telemetryWindowTarget!==void 0?e.telemetryWindowTarget:typeof window<"u"?window:null;this.telemetryActivityAgent=this.telemetryMeta&&i&&s?sD({meta:this.telemetryMeta,documentTarget:i,windowTarget:s,send:c=>this.sendTelemetryActivity(c)}):null}get token(){return this._token}clearToken(){this._token=null,this.acpClient.setToken(null),this.client=this.createClient(this.url,null,this.telemetryMeta)}async connect(e){this._token=e,this.hasAuthRejected=!1,this.acpClient.setToken(e),this.cancelRetryTimer(),this.retryDelay=Hl,this.autoReconnect=!0,await this.attempt()}dispose(){var e,r,i,s;this.autoReconnect=!1,this.connectAttempt+=1,this.cancelRetryTimer(),(e=this.socket)==null||e.close(),this.socket=null,this.setStatus("unauthorized"),(r=this.visibilityEventTarget)==null||r.removeEventListener("visibilitychange",this.onVisibilityChange),(i=this.networkEventTarget)==null||i.removeEventListener("online",this.onNetworkOnline),(s=this.telemetryActivityAgent)==null||s.stop(),this.acpClient.dispose()}getViewURL(e){const r=Tc(e,{electron:Wt()});return Wt()?new URL(r.viewURL,this.url).toString():r.renderer==="proxy-iframe"?new URL(r.viewURL,this.url).toString():r.viewURL}getContentURL(e){const r=Tc(e,{electron:Wt()}).contentURL;return r===null?null:new URL(r,this.url).toString()}async createScreen(e){const{screen:r}=await this.client.screens.create({name:e});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(e){switch(e.type){case"screen-created":this.screens.set(e.screen.id,structuredClone(e.screen)),this.dispatchEvent(new So("screens-changed"));break;case"screen-updated":this.screens.set(e.screen.id,structuredClone(e.screen)),this.dispatchEvent(new So("screens-changed"));break;case"screen-removed":this.screens.delete(e.screenID),this.dispatchEvent(new So("screens-changed"));break;case"artifact-created":{const r=this.screens.get(e.screenID);r&&!ec(r).includes(e.artifact.id)&&(r.layout=[...r.layout,Bb(e.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(e.screenID);r&&(r.layout=Db(r.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"screen-changed":case"theme-changed":case"artifact-focus":break;default:return Yz(e,"server event")}}async attempt(){var i;this.attempting=!0,this.nextRetryAt=null,this.connectAttempt+=1,this.bootState="pending";const e=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this._token,this.telemetryMeta),this.setStatus("disconnected"),this.dispatchEvent(new ie("change"));const r=this.createSocket(Kz(this.url,this._token,this.telemetryMeta));return this.socket=r,await new Promise((s,o)=>{let a=!1;const c=()=>{var f;a||this.connectAttempt!==e||(a=!0,this.retryDelay=Hl,this.hasEverConnected=!0,this.setStatus("connected"),(f=this.telemetryActivityAgent)==null||f.start(),s())},u=f=>{a||this.connectAttempt!==e||(a=!0,o(f))},h=async()=>{const f=this.hasEverConnected;try{const[{screens:v},y]=await Promise.all([this.client.screens.list(),this.client.display.get()]);this.screens=new Map(v.map(E=>[E.id,structuredClone(E)])),this.acpClient.setEnabled(y.acpEnabled),this.dispatchEvent(new ie("change")),f&&this.dispatchEvent(new So("screens-changed")),this.dispatchEvent(new td("server-event",{serverURL:this.url,event:{type:"screen-changed",screenID:y.activeScreenID}})),c(),f&&this.connectAttempt===e&&this.dispatchEvent(new Rb("server-reconnected",{serverURL:this.url}))}catch(v){if(nO(v)){u(new Oo);return}u(v instanceof Error?v:new Error(String(v)))}};r.addEventListener("open",()=>{this.decideBoot===null&&(this.bootState="booted",this.navigationPending()||h())}),r.addEventListener("message",f=>{const v=tO(f);if(!v)return;if(v.type==="server-status"){const E=v;this.serverVersion=E.version,this.updateState=E.update??null;let x=!1,C=!1;this.decideBoot!==null&&this.bootState==="pending"&&this.connectAttempt===e&&(this.decideBoot(E)==="boot"?(this.bootState="booted",x=!0):(this.bootState="halted",this.attempting=!1,C=!0)),this.dispatchEvent(new Pb("server-status",{serverURL:this.url,message:E})),x?this.navigationPending()||h():C&&this.dispatchEvent(new ie("change"));return}if(!eO(v.type))return;const y=v;this.applyServerEvent(y),this.dispatchEvent(new td("server-event",{serverURL:this.url,event:y}))}),r.addEventListener("close",f=>{if(this.connectAttempt!==e)return;this.socket=null;const v=Jz(f);if(!a){u(v===xv?new Oo:new Error("Connection closed before initialization"));return}if(v===xv){this.handleAuthRejected();return}this.handleTransportFailure(new Error("Connection closed"))}),r.addEventListener("error",()=>{if(this.connectAttempt===e){if(a){this.handleTransportFailure(new Error("WebSocket error"));return}u(new Error("WebSocket connection failed"))}})}).then(()=>{this.attempting=!1},s=>{throw this.attempting=!1,this.handleAttemptFailure(s),s})}handleAuthRejected(){this.hasAuthRejected=!0,this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized")}handleAttemptFailure(e){if(e instanceof Oo){this.handleAuthRejected();return}this.autoReconnect&&this.scheduleRetry()}handleTransportFailure(e){this.autoReconnect&&(this.setStatus("disconnected"),this.scheduleRetry())}scheduleRetry(){this.cancelRetryTimer(),this.connectAttempt+=1;const e=this.retryDelay;this.retryDelay=Math.min(this.retryDelay*2,qz),this.nextRetryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},e),this.dispatchEvent(new ie("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new ie("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=Hl,this.attempt().catch(()=>{})))}sendTelemetryActivity(e){var r;this.status==="connected"&&((r=this.socket)==null||r.send(JSON.stringify(e)))}sendTelemetrySignal(e,r){var s;if(!this.telemetryMeta||this.status!=="connected"&&this.bootState!=="halted")return;const i={type:gC,clientId:this.telemetryMeta.clientId,event:e,properties:r};(s=this.socket)==null||s.send(JSON.stringify(i))}setStatus(e){this.status!==e&&(this.status=e,this.dispatchEvent(new ie("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function Yz(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function Kz(n,t,e=null){const r=new URL(n);if(r.protocol=r.protocol==="https:"?"wss:":"ws:",r.pathname="/events",r.search="",t&&r.searchParams.set("token",t),e)for(const[i,s]of iD(e))r.searchParams.set(i,s);return r.hash="",r.toString()}function Jz(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}const Xz={"artifact-created":!0,"artifact-updated":!0,"artifact-content-changed":!0,"artifact-removed":!0,"screen-created":!0,"screen-updated":!0,"screen-removed":!0,"screen-changed":!0,"theme-changed":!0,"artifact-focus":!0},Qz=new Set(Object.keys(Xz));function eO(n){return Qz.has(n)}function tO(n){const t=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!t)return null;let e;try{e=JSON.parse(t)}catch{return null}return typeof e!="object"||e===null||!("type"in e)||typeof e.type!="string"?null:e}function nO(n){return n instanceof sf&&n.status===Gz}const rO="Local";var fa,bd;class iO extends It{constructor(e){super();b(this,fa);g(this,"servers",new Map);g(this,"localServerURL");g(this,"clientGUID");g(this,"acpStorage");g(this,"telemetryMeta");g(this,"localStore");g(this,"bootBarrier");g(this,"navigationPending");g(this,"createSocket");g(this,"lastActiveServerURL");g(this,"serverListeners",new Map);g(this,"handleLocalStoreChange",()=>{const e=this.localStore.get().activeServerURL;e!==this.lastActiveServerURL&&(this.lastActiveServerURL=e,this.dispatchEvent(new ie("change")))});this.localStore=e.localStore,this.bootBarrier=e.bootBarrier??null,this.navigationPending=e.navigationPending??null,this.localServerURL=e.localServerURL?ee(e.localServerURL):null,this.createSocket=e.createSocket??(i=>new WebSocket(i)),this.lastActiveServerURL=this.localStore.get().activeServerURL;const r=e.acpStorage===void 0?Bw():e.acpStorage;this.acpStorage=r,this.clientGUID=e.clientGUID??(r?jz(r):fu().toLowerCase()),this.telemetryMeta=e.telemetryMeta??null,this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const e=this.localStore.get().activeServerURL;return e===null?null:this.servers.get(e)??null}add(e){const r=ee(e.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,e),this.bootBarrier&&ee(this.bootBarrier.serverURL)===r&&(e.decideBoot=this.bootBarrier.decideBoot),this.navigationPending!==null&&(e.navigationPending=this.navigationPending);const s=()=>{this.dispatchEvent(new ie("change"))},o=h=>{this.dispatchEvent(new td("server-event",{serverURL:h.serverURL,event:h.event}))},a=()=>{this.dispatchEvent(new So("screens-changed"))},c=h=>{this.dispatchEvent(new Rb("server-reconnected",{serverURL:h.serverURL}))},u=h=>{this.dispatchEvent(new Pb("server-status",{serverURL:h.serverURL,message:h.message}))};e.addEventListener("change",s),e.addEventListener("server-event",o),e.addEventListener("screens-changed",a),e.addEventListener("server-reconnected",c),e.addEventListener("server-status",u),this.serverListeners.set(r,{onServerChange:s,onServerEvent:o,onScreensChanged:a,onServerReconnected:c,onServerStatus:u}),this.dispatchEvent(new ie("change"))}remove(e){const r=ee(e);if(this.localServerURL&&r===this.localServerURL)return;const i=this.servers.get(r);if(!i)return;const s=this.serverListeners.get(r);s&&(i.removeEventListener("change",s.onServerChange),i.removeEventListener("server-event",s.onServerEvent),i.removeEventListener("screens-changed",s.onScreensChanged),i.removeEventListener("server-reconnected",s.onServerReconnected),i.removeEventListener("server-status",s.onServerStatus),this.serverListeners.delete(r)),i.dispose(),this.servers.delete(r);const o=this.localStore.get(),a=o.activeServerURL===r;this.localStore.set({...o,servers:o.servers.filter(c=>c.url!==r),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new ie("change"))}getStoredAuthToken(e){return wh(this.localStore.get(),e)}setStoredAuthToken(e,r){this.localStore.set(FC(this.localStore.get(),e,r))}clearStoredAuthToken(e){const r=this.localStore.get(),i=HC(r,e);i!==r&&this.localStore.set(i)}setActive(e){const r=this.localStore.get(),i=e?ee(e.url):null;r.activeServerURL!==i&&this.localStore.set({...r,activeServerURL:i})}connectConfiguredServers(e,r){const i=e?ee(e):null;if(i){const a=this.localStore.get();a.servers.some(u=>ee(u.url)===i)||this.localStore.set({...a,servers:[...a.servers,{url:i,name:rO}]})}const s=this.localStore.get().servers;for(const a of s){const c=ee(a.url),h=i!==null&&c===i?r??wh(this.localStore.get(),c):wh(this.localStore.get(),c),f=d(this,fa,bd).call(this,{url:a.url,name:a.name,token:h});this.add(f),f.connect(h).catch(()=>{})}const o=i?this.servers.get(i)??null:null;this.setActive(o??this.servers.values().next().value??null)}addServer(e,r){const i=ee(e);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>ee(a.url)!==i),{url:i,name:r}]});const o=d(this,fa,bd).call(this,{url:i,name:r,token:this.getStoredAuthToken(i)});this.add(o),this.setActive(o),o.connect(o.token).catch(()=>{})}removeServer(e){this.remove(e)}}fa=new WeakSet,bd=function(e){return new Ww({url:e.url,name:e.name,token:e.token,createSocket:this.createSocket,clientGUID:this.clientGUID,acpStorage:this.acpStorage,telemetryMeta:this.telemetryMeta})};var ga;class sO extends It{constructor(){super();b(this,ga,e=>{const r=oO(e);r!==null&&(e.preventDefault(),this.dispatchEvent(new Q$("shortcut-triggered",{shortcut:r})))});document.addEventListener("keydown",l(this,ga))}dispose(){document.removeEventListener("keydown",l(this,ga))}}ga=new WeakMap;function oO(n){for(const[t,e]of Object.entries(TC))if(aO(n,e.trigger))return t;return null}function aO(n,t){return!(n.key.toLowerCase()!==t.key.toLowerCase()||n.metaKey!==!!t.meta||n.ctrlKey!==!!t.ctrl||n.shiftKey!==!!t.shift||n.altKey!==!!t.alt)}const wd="tv-nav:",Zs="tv-reload",Av=100,lO=1e3,cO=60,uO=60,hO=24,dO=30,pO=dO*hO*uO*cO*lO;function Fn(n){try{const t=new URL(n,window.location.href),e=t.searchParams.has(Zs);return t.searchParams.delete(Zs),t.origin===window.location.origin?`${t.pathname}${t.search}${t.hash}`:e?t.toString():n}catch{return n}}var ma,vs,de,oe,Jr,Ae,jw,Gn,Gw,Sd,_d;class fO extends It{constructor(e,r){super();b(this,Ae);b(this,ma);b(this,vs);b(this,de,[]);b(this,oe,-1);b(this,Jr,0);m(this,ma,e),m(this,vs,Fn(r)),d(this,Ae,jw).call(this)}get currentURL(){var e;return l(this,oe)===-1?null:((e=l(this,de)[l(this,oe)])==null?void 0:e.url)??null}get canGoBack(){return l(this,oe)>-1}get canGoForward(){return l(this,oe)<l(this,de).length-1}get entries(){return l(this,de).map(e=>({...e}))}get cursor(){return l(this,oe)}navigate(e){const r=Fn(e);if(r===l(this,vs)){if(l(this,oe)===-1)return;m(this,oe,-1),d(this,Ae,Gn).call(this);return}l(this,oe)<l(this,de).length-1&&m(this,de,l(this,de).slice(0,l(this,oe)+1)),l(this,de).push({url:r}),m(this,oe,l(this,de).length-1),d(this,Ae,Sd).call(this),d(this,Ae,Gn).call(this)}replace(e){var i;if(l(this,oe)===-1){this.navigate(e);return}const r=Fn(e);if(r===l(this,vs)){m(this,de,l(this,de).filter((s,o)=>o!==l(this,oe))),m(this,oe,-1),d(this,Ae,Gn).call(this);return}((i=l(this,de)[l(this,oe)])==null?void 0:i.url)!==r&&(m(this,de,l(this,de).map((s,o)=>o===l(this,oe)?{url:r}:s)),d(this,Ae,Gn).call(this))}back(){l(this,oe)!==-1&&(m(this,oe,l(this,oe)-1),d(this,Ae,Gn).call(this))}forward(){this.canGoForward&&(m(this,oe,l(this,oe)+1),d(this,Ae,Gn).call(this))}reset(){l(this,oe)===-1&&l(this,de).length===0||(m(this,de,[]),m(this,oe,-1),d(this,Ae,Gn).call(this))}}ma=new WeakMap,vs=new WeakMap,de=new WeakMap,oe=new WeakMap,Jr=new WeakMap,Ae=new WeakSet,jw=function(){const e=localStorage.getItem(l(this,Ae,_d));if(e!==null)try{const r=JSON.parse(e);if(!qw(r))return;m(this,de,r.entries.map(i=>({url:i.url}))),m(this,oe,r.cursor),m(this,Jr,r.lastWritten),d(this,Ae,Sd).call(this)}catch{m(this,de,[]),m(this,oe,-1),m(this,Jr,0)}},Gn=function(){m(this,Jr,Date.now());try{localStorage.setItem(l(this,Ae,_d),JSON.stringify(d(this,Ae,Gw).call(this)))}catch(e){if(!vO(e))throw e}this.dispatchEvent(new ie("change"))},Gw=function(){return{v:1,entries:l(this,de).map(e=>({...e})),cursor:l(this,oe),lastWritten:l(this,Jr)}},Sd=function(){if(l(this,de).length<=Av)return;const e=l(this,de).length-Av;m(this,de,l(this,de).slice(e)),m(this,oe,Math.max(-1,l(this,oe)-e))},_d=function(){return gO(l(this,ma))};function gO(n){return`${wd}${n}`}function mO(n){const t=Date.now()-pO,e=[];for(let r=0;r<localStorage.length;r+=1){const i=localStorage.key(r);if(!(i!=null&&i.startsWith(wd)))continue;const s=i.slice(wd.length),o=localStorage.getItem(i);if(o===null)continue;let a;try{a=JSON.parse(o)}catch{e.push(i);continue}if(!qw(a)){e.push(i);continue}!n.has(s)&&a.lastWritten<t&&e.push(i)}for(const r of e)localStorage.removeItem(r)}function vO(n){return n instanceof DOMException&&n.name==="QuotaExceededError"}function qw(n){if(typeof n!="object"||n===null)return!1;const t=n;if(t.v!==1||!Array.isArray(t.entries))return!1;const e=t.cursor;return typeof e!="number"||!Number.isInteger(e)||typeof t.lastWritten!="number"||!Number.isFinite(t.lastWritten)||e<-1||e>=t.entries.length?!1:t.entries.every(r=>typeof r=="object"&&r!==null&&typeof r.url=="string")}const yO="0.1.196";function mf(n=yO){return n!==void 0&&n.length>0?n:"0.0.0"}function vf(){let n=!1;return{get pending(){return n},begin(t){n||(n=!0,t())}}}const kd="tv-reload-attempted";function bO(n){return n.originMatch?n.marker!==null&&n.bundleVersion===n.serverVersion?{action:"signal-autoreloaded",fromVersion:n.marker.fromVersion,toVersion:n.bundleVersion}:IC(n.bundleVersion,n.serverVersion)?n.marker!==null&&n.marker.serverVersion===n.serverVersion?{action:"none"}:{action:"reload",marker:{serverVersion:n.serverVersion,fromVersion:n.bundleVersion}}:{action:"none"}:{action:"none"}}function wO(n){const t=n.getItem(kd);if(t===null)return null;let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!="object")return null;const r=e;return typeof r.serverVersion!="string"||typeof r.fromVersion!="string"?null:{serverVersion:r.serverVersion,fromVersion:r.fromVersion}}function SO(n){const t=n.storage!==void 0?n.storage:typeof sessionStorage<"u"?sessionStorage:null,e=n.reload??(()=>location.reload()),r=n.navigationLatch??vf(),i=n.bundleVersion??mf();if(t===null)return{dispose(){}};let s=null;const o=()=>{if(s===null)return;const u=n.manager.servers.get(n.primaryServerURL);if(!u||u.status!=="connected")return;const h=s;s=null,u.sendTelemetrySignal("client_autoreloaded",{from_version:h.fromVersion,to_version:h.toVersion})},a=u=>{if(r.pending)return;const h=bO({bundleVersion:i,serverVersion:u.message.version,originMatch:u.serverURL===n.primaryServerURL,marker:wO(t)});switch(h.action){case"reload":t.setItem(kd,JSON.stringify(h.marker)),r.begin(e);return;case"signal-autoreloaded":t.removeItem(kd),s={fromVersion:h.fromVersion,toVersion:h.toVersion},o();return;case"none":return}},c=()=>{o()};return n.manager.addEventListener("server-status",a),n.manager.addEventListener("change",c),{dispose(){n.manager.removeEventListener("server-status",a),n.manager.removeEventListener("change",c)}}}function _O(n){const t=Wt(n.search),e=G0(n.search),r=e!==null&&of(e)?e:null;return{electron:t,shellVersion:r}}function kO(n){return!n.electron||n.requiredDesktopVersion===null||!of(n.requiredDesktopVersion)?!1:n.shellVersion===null?!0:n.shellVersion===nd?!1:qb(n.requiredDesktopVersion,n.shellVersion)}const EO=`# Desktop app upgrade required
|
|
43
|
+
`)},qi=function(e){const r=`${e}-${l(this,ps)}`;return m(this,ps,l(this,ps)+1),r},pd=function(e){for(const r of l(this,pt).values())if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===e)return r;return null},fd=function(){if(!l(this,sn))throw new Error("ACP session is not ready");return l(this,sn)},ic=function(){if(!l(this,rn))throw new Error("ACP connection is not ready");return l(this,rn)},Hw=function(){var r;const e=(r=l(this,on))==null?void 0:r.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},sc=function(){var r;if(l(this,ln)==="single_session")return d(this,$,md).call(this,`${Cw}-${(l(this,Ot).clientGUID??"default-client").toLowerCase()}`);const e=(r=l(this,et))==null?void 0:r.screenID;if(!e)throw new Error("Screen context is required for per-screen session mode");return d(this,$,gd).call(this,e)},gd=function(e){return d(this,$,md).call(this,Nz(l(this,ln),e,l(this,Ot).clientGUID??"default-client"))},md=function(e){var r;return((r=l(this,on))==null?void 0:r.sessionIdStrategy)==="deterministic"&&l(this,ds)>0?`${e}:epoch-${l(this,ds)}`:e},ha=new WeakMap,da=new WeakMap,oc=function(){m(this,rn,null),m(this,tr,null),m(this,Mt,null),m(this,Pn,null),m(this,sn,null),m(this,zt,null),m(this,on,null),l(this,cn)&&(l(this,cn).removeEventListener("close",l(this,ha)),l(this,cn).removeEventListener("error",l(this,da)),l(this,cn).close(),m(this,cn,null))},Yi=function(e){const r=l(this,rn)!==null||l(this,tr)!==null||l(this,Mt)!==null||l(this,Pn)!==null||l(this,sn)!==null||l(this,zt)!==null||l(this,on)!==null||l(this,cn)!==null;this.disposed||this.status==="disconnected"&&!r||(d(this,$,Rr).call(this,"error"),d(this,$,oc).call(this),m(this,nn,e??null),d(this,$,xn).call(this,"disconnected"))},vd=function(){const e=l(this,pt).size>0;m(this,an,null),m(this,Dn,null),m(this,ps,1),l(this,pt).clear(),e&&this.dispatchEvent(new yh("messages-changed"))},Vw=function(){return this.status==="disconnected"};function zz(){const n=new Map;return{getActualSessionId(t){return n.get(t)??null},setActualSessionId(t,e){n.set(t,e)},clearActualSessionId(t){n.delete(t)}}}function Oz(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function Nz(n,t,e){return n==="single_session"?`${Cw}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function Zw(n){return n.replace(/^(?:\s*\n)+/,"")}function wv(n){let t=n;return t=t.replace(Tz,""),t=t.replace($z,""),t=t.replace(Cz,""),t=Zw(t),t}function Uz(n){let t=n;return t=t.replace(Rz,""),t=Zw(t),t}function Sv(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function Fz(n){const t=n.createSocket(Zz(n.serverURL,n.token));let e=!1,r,i;const s=new Promise((u,h)=>{r=u,i=h}),o=new ReadableStream({start(u){let h=!1;const f=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},v=x=>{const C=Vz(x);if(!C)return;let L;try{L=JSON.parse(C)}catch(R){const W=R instanceof Error?R:new Error(String(R));i(W),u.error(W);return}switch(L.type){case"acp-bridge-status":if(L.status==="ready"){let R;try{R=Hz(L)}catch(W){const N=W instanceof Error?W:new Error(String(W));e||i(N),u.error(N);return}e||(e=!0,r(R));return}if(L.status==="error"||L.status==="exited"){const R=new Error(L.error??`ACP bridge ${L.status}`);e||i(R),u.error(R)}return;case"acp-bridge-message":u.enqueue(L.message);return}},y=()=>{var C;if(h)return;h=!0;const x=new Error("ACP bridge websocket closed");e||i(x),(C=n.onDisconnect)==null||C.call(n,x),u.close()},E=()=>{var C;if(h)return;h=!0;const x=new Error("ACP bridge websocket error");e||i(x),(C=n.onDisconnect)==null||C.call(n,x),u.error(x)};t.addEventListener("open",f),t.addEventListener("message",v),t.addEventListener("close",y),t.addEventListener("error",E)}}),a=new WritableStream({async write(u){await s,t.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){t.close()},abort(){t.close()}}),c=await s;return{stream:{readable:o,writable:a},socket:t,metadata:c}}function Hz(n){const{agent:t,sessionIdStrategy:e,sessionCwd:r}=n;if((t==="openclaw"||t==="hermes")&&(e==="deterministic"||e==="mapped")&&typeof r=="string"&&r.length>0)return{agent:t,sessionIdStrategy:e,sessionCwd:r};throw new Error("ACP bridge ready status missing bootstrap metadata")}function Vz(n){if(typeof n=="string")return n;if(n instanceof Uint8Array)return new TextDecoder().decode(n);if(typeof Buffer<"u"&&n instanceof Buffer)return n.toString("utf8");if(typeof n=="object"&&n!==null&&"data"in n){const t=n.data;if(typeof t=="string")return t;if(t instanceof Uint8Array)return new TextDecoder().decode(t);if(Array.isArray(t))return Buffer.concat(t).toString("utf8")}return null}function Zz(n,t){const e=new URL(n);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/acp",e.search="",e.searchParams.set("token",t),e.hash="",e.toString()}function Eh(n){return n instanceof Error?n.message:String(n)}const _v="television.acpClientGUID",kv="television.acpMappedSessions",Ev=1;var gs;class Bz{constructor(){b(this,gs,new Map)}getActualSessionId(t){return l(this,gs).get(t)??null}setActualSessionId(t,e){l(this,gs).set(t,e)}clearActualSessionId(t){l(this,gs).delete(t)}}gs=new WeakMap;var ms,pa,mt,ac,lc,yd;class Wz{constructor(t,e){b(this,mt);b(this,ms);b(this,pa);m(this,ms,t),m(this,pa,e)}getActualSessionId(t){const e=d(this,mt,lc).call(this)[d(this,mt,ac).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const r=d(this,mt,lc).call(this);r[d(this,mt,ac).call(this,t)]=e,d(this,mt,yd).call(this,r)}clearActualSessionId(t){const e=d(this,mt,lc).call(this);delete e[d(this,mt,ac).call(this,t)],d(this,mt,yd).call(this,e)}}ms=new WeakMap,pa=new WeakMap,mt=new WeakSet,ac=function(t){return JSON.stringify([l(this,pa),t])},lc=function(){const t=l(this,ms).getItem(kv);if(!t)return{};let e;try{e=JSON.parse(t)}catch{return{}}if(typeof e!="object"||e===null||Array.isArray(e))return{};const r=e;return r.version!==Ev?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},yd=function(t){const e={version:Ev,entries:t};l(this,ms).setItem(kv,JSON.stringify(e))};function Bw(){return typeof window>"u"?null:window.localStorage}function jz(n){const t=n.getItem(_v);if(t)return t;const e=fu().toLowerCase();return n.setItem(_v,e),e}const xv=4401,Gz=401,Hl=1e3,qz=3e4;class Oo extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class Ww extends It{constructor(e){var o,a;super();g(this,"url");g(this,"name");g(this,"telemetryMeta");g(this,"status","unauthorized");g(this,"screens",new Map);g(this,"client");g(this,"acpClient");g(this,"_token");g(this,"attempting",!1);g(this,"nextRetryAt",null);g(this,"hasEverConnected",!1);g(this,"hasAuthRejected",!1);g(this,"bootState","pending");g(this,"serverVersion",null);g(this,"updateState",null);g(this,"decideBoot");g(this,"navigationPending");g(this,"createSocket");g(this,"createClient");g(this,"socket",null);g(this,"connectAttempt",0);g(this,"autoReconnect",!1);g(this,"retryTimer",null);g(this,"retryDelay",Hl);g(this,"visibilityEventTarget");g(this,"networkEventTarget");g(this,"onVisibilityChange");g(this,"onNetworkOnline");g(this,"telemetryActivityAgent");this.url=ee(e.url),this.name=e.name,this.decideBoot=e.decideBoot??null,this.navigationPending=e.navigationPending??(()=>!1),this._token=e.token??null,this.telemetryMeta=e.telemetryMeta??null,this.createSocket=e.createSocket??(c=>new WebSocket(c)),this.createClient=e.createClient??((c,u,h)=>new AC(c,{token:u??void 0,onUnauthorized:()=>this.handleAuthRejected(),...h?{telemetryMeta:h}:{}})),this.client=this.createClient(this.url,this._token,this.telemetryMeta);const r=e.mappedSessionStore??(e.acpStorage?new Wz(e.acpStorage,this.url):new Bz);this.acpClient=new Mz({serverURL:this.url,token:this._token??"",...e.createACPSocket?{createSocket:e.createACPSocket}:e.createSocket?{createSocket:e.createSocket}:{},...e.clientGUID?{clientGUID:e.clientGUID}:{},mappedSessionStore:r}),this.visibilityEventTarget=e.visibilityEventTarget!==void 0?e.visibilityEventTarget:typeof document<"u"?document:null,this.networkEventTarget=e.networkEventTarget!==void 0?e.networkEventTarget:typeof window<"u"?window:null,this.onVisibilityChange=()=>{this.isPageVisible()&&this.kickReconnect()},this.onNetworkOnline=()=>{this.kickReconnect()},(o=this.visibilityEventTarget)==null||o.addEventListener("visibilitychange",this.onVisibilityChange),(a=this.networkEventTarget)==null||a.addEventListener("online",this.onNetworkOnline);const i=e.telemetryDocumentTarget!==void 0?e.telemetryDocumentTarget:typeof document<"u"?document:null,s=e.telemetryWindowTarget!==void 0?e.telemetryWindowTarget:typeof window<"u"?window:null;this.telemetryActivityAgent=this.telemetryMeta&&i&&s?sD({meta:this.telemetryMeta,documentTarget:i,windowTarget:s,send:c=>this.sendTelemetryActivity(c)}):null}get token(){return this._token}clearToken(){this._token=null,this.acpClient.setToken(null),this.client=this.createClient(this.url,null,this.telemetryMeta)}async connect(e){this._token=e,this.hasAuthRejected=!1,this.acpClient.setToken(e),this.cancelRetryTimer(),this.retryDelay=Hl,this.autoReconnect=!0,await this.attempt()}dispose(){var e,r,i,s;this.autoReconnect=!1,this.connectAttempt+=1,this.cancelRetryTimer(),(e=this.socket)==null||e.close(),this.socket=null,this.setStatus("unauthorized"),(r=this.visibilityEventTarget)==null||r.removeEventListener("visibilitychange",this.onVisibilityChange),(i=this.networkEventTarget)==null||i.removeEventListener("online",this.onNetworkOnline),(s=this.telemetryActivityAgent)==null||s.stop(),this.acpClient.dispose()}getViewURL(e){const r=Tc(e,{electron:Wt()});return Wt()?new URL(r.viewURL,this.url).toString():r.renderer==="proxy-iframe"?new URL(r.viewURL,this.url).toString():r.viewURL}getContentURL(e){const r=Tc(e,{electron:Wt()}).contentURL;return r===null?null:new URL(r,this.url).toString()}async createScreen(e){const{screen:r}=await this.client.screens.create({name:e});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(e){switch(e.type){case"screen-created":this.screens.set(e.screen.id,structuredClone(e.screen)),this.dispatchEvent(new So("screens-changed"));break;case"screen-updated":this.screens.set(e.screen.id,structuredClone(e.screen)),this.dispatchEvent(new So("screens-changed"));break;case"screen-removed":this.screens.delete(e.screenID),this.dispatchEvent(new So("screens-changed"));break;case"artifact-created":{const r=this.screens.get(e.screenID);r&&!ec(r).includes(e.artifact.id)&&(r.layout=[...r.layout,Bb(e.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(e.screenID);r&&(r.layout=Db(r.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"screen-changed":case"theme-changed":case"artifact-focus":break;default:return Yz(e,"server event")}}async attempt(){var i;this.attempting=!0,this.nextRetryAt=null,this.connectAttempt+=1,this.bootState="pending";const e=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this._token,this.telemetryMeta),this.setStatus("disconnected"),this.dispatchEvent(new ie("change"));const r=this.createSocket(Kz(this.url,this._token,this.telemetryMeta));return this.socket=r,await new Promise((s,o)=>{let a=!1;const c=()=>{var f;a||this.connectAttempt!==e||(a=!0,this.retryDelay=Hl,this.hasEverConnected=!0,this.setStatus("connected"),(f=this.telemetryActivityAgent)==null||f.start(),s())},u=f=>{a||this.connectAttempt!==e||(a=!0,o(f))},h=async()=>{const f=this.hasEverConnected;try{const[{screens:v},y]=await Promise.all([this.client.screens.list(),this.client.display.get()]);this.screens=new Map(v.map(E=>[E.id,structuredClone(E)])),this.acpClient.setEnabled(y.acpEnabled),this.dispatchEvent(new ie("change")),f&&this.dispatchEvent(new So("screens-changed")),this.dispatchEvent(new td("server-event",{serverURL:this.url,event:{type:"screen-changed",screenID:y.activeScreenID}})),c(),f&&this.connectAttempt===e&&this.dispatchEvent(new Rb("server-reconnected",{serverURL:this.url}))}catch(v){if(nO(v)){u(new Oo);return}u(v instanceof Error?v:new Error(String(v)))}};r.addEventListener("open",()=>{this.decideBoot===null&&(this.bootState="booted",this.navigationPending()||h())}),r.addEventListener("message",f=>{const v=tO(f);if(!v)return;if(v.type==="server-status"){const E=v;this.serverVersion=E.version,this.updateState=E.update??null;let x=!1,C=!1;this.decideBoot!==null&&this.bootState==="pending"&&this.connectAttempt===e&&(this.decideBoot(E)==="boot"?(this.bootState="booted",x=!0):(this.bootState="halted",this.attempting=!1,C=!0)),this.dispatchEvent(new Pb("server-status",{serverURL:this.url,message:E})),x?this.navigationPending()||h():C&&this.dispatchEvent(new ie("change"));return}if(!eO(v.type))return;const y=v;this.applyServerEvent(y),this.dispatchEvent(new td("server-event",{serverURL:this.url,event:y}))}),r.addEventListener("close",f=>{if(this.connectAttempt!==e)return;this.socket=null;const v=Jz(f);if(!a){u(v===xv?new Oo:new Error("Connection closed before initialization"));return}if(v===xv){this.handleAuthRejected();return}this.handleTransportFailure(new Error("Connection closed"))}),r.addEventListener("error",()=>{if(this.connectAttempt===e){if(a){this.handleTransportFailure(new Error("WebSocket error"));return}u(new Error("WebSocket connection failed"))}})}).then(()=>{this.attempting=!1},s=>{throw this.attempting=!1,this.handleAttemptFailure(s),s})}handleAuthRejected(){this.hasAuthRejected=!0,this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized")}handleAttemptFailure(e){if(e instanceof Oo){this.handleAuthRejected();return}this.autoReconnect&&this.scheduleRetry()}handleTransportFailure(e){this.autoReconnect&&(this.setStatus("disconnected"),this.scheduleRetry())}scheduleRetry(){this.cancelRetryTimer(),this.connectAttempt+=1;const e=this.retryDelay;this.retryDelay=Math.min(this.retryDelay*2,qz),this.nextRetryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},e),this.dispatchEvent(new ie("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new ie("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=Hl,this.attempt().catch(()=>{})))}sendTelemetryActivity(e){var r;this.status==="connected"&&((r=this.socket)==null||r.send(JSON.stringify(e)))}sendTelemetrySignal(e,r){var s;if(!this.telemetryMeta||this.status!=="connected"&&this.bootState!=="halted")return;const i={type:gC,clientId:this.telemetryMeta.clientId,event:e,properties:r};(s=this.socket)==null||s.send(JSON.stringify(i))}setStatus(e){this.status!==e&&(this.status=e,this.dispatchEvent(new ie("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function Yz(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function Kz(n,t,e=null){const r=new URL(n);if(r.protocol=r.protocol==="https:"?"wss:":"ws:",r.pathname="/events",r.search="",t&&r.searchParams.set("token",t),e)for(const[i,s]of iD(e))r.searchParams.set(i,s);return r.hash="",r.toString()}function Jz(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}const Xz={"artifact-created":!0,"artifact-updated":!0,"artifact-content-changed":!0,"artifact-removed":!0,"screen-created":!0,"screen-updated":!0,"screen-removed":!0,"screen-changed":!0,"theme-changed":!0,"artifact-focus":!0},Qz=new Set(Object.keys(Xz));function eO(n){return Qz.has(n)}function tO(n){const t=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!t)return null;let e;try{e=JSON.parse(t)}catch{return null}return typeof e!="object"||e===null||!("type"in e)||typeof e.type!="string"?null:e}function nO(n){return n instanceof sf&&n.status===Gz}const rO="Local";var fa,bd;class iO extends It{constructor(e){super();b(this,fa);g(this,"servers",new Map);g(this,"localServerURL");g(this,"clientGUID");g(this,"acpStorage");g(this,"telemetryMeta");g(this,"localStore");g(this,"bootBarrier");g(this,"navigationPending");g(this,"createSocket");g(this,"lastActiveServerURL");g(this,"serverListeners",new Map);g(this,"handleLocalStoreChange",()=>{const e=this.localStore.get().activeServerURL;e!==this.lastActiveServerURL&&(this.lastActiveServerURL=e,this.dispatchEvent(new ie("change")))});this.localStore=e.localStore,this.bootBarrier=e.bootBarrier??null,this.navigationPending=e.navigationPending??null,this.localServerURL=e.localServerURL?ee(e.localServerURL):null,this.createSocket=e.createSocket??(i=>new WebSocket(i)),this.lastActiveServerURL=this.localStore.get().activeServerURL;const r=e.acpStorage===void 0?Bw():e.acpStorage;this.acpStorage=r,this.clientGUID=e.clientGUID??(r?jz(r):fu().toLowerCase()),this.telemetryMeta=e.telemetryMeta??null,this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const e=this.localStore.get().activeServerURL;return e===null?null:this.servers.get(e)??null}add(e){const r=ee(e.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,e),this.bootBarrier&&ee(this.bootBarrier.serverURL)===r&&(e.decideBoot=this.bootBarrier.decideBoot),this.navigationPending!==null&&(e.navigationPending=this.navigationPending);const s=()=>{this.dispatchEvent(new ie("change"))},o=h=>{this.dispatchEvent(new td("server-event",{serverURL:h.serverURL,event:h.event}))},a=()=>{this.dispatchEvent(new So("screens-changed"))},c=h=>{this.dispatchEvent(new Rb("server-reconnected",{serverURL:h.serverURL}))},u=h=>{this.dispatchEvent(new Pb("server-status",{serverURL:h.serverURL,message:h.message}))};e.addEventListener("change",s),e.addEventListener("server-event",o),e.addEventListener("screens-changed",a),e.addEventListener("server-reconnected",c),e.addEventListener("server-status",u),this.serverListeners.set(r,{onServerChange:s,onServerEvent:o,onScreensChanged:a,onServerReconnected:c,onServerStatus:u}),this.dispatchEvent(new ie("change"))}remove(e){const r=ee(e);if(this.localServerURL&&r===this.localServerURL)return;const i=this.servers.get(r);if(!i)return;const s=this.serverListeners.get(r);s&&(i.removeEventListener("change",s.onServerChange),i.removeEventListener("server-event",s.onServerEvent),i.removeEventListener("screens-changed",s.onScreensChanged),i.removeEventListener("server-reconnected",s.onServerReconnected),i.removeEventListener("server-status",s.onServerStatus),this.serverListeners.delete(r)),i.dispose(),this.servers.delete(r);const o=this.localStore.get(),a=o.activeServerURL===r;this.localStore.set({...o,servers:o.servers.filter(c=>c.url!==r),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new ie("change"))}getStoredAuthToken(e){return wh(this.localStore.get(),e)}setStoredAuthToken(e,r){this.localStore.set(FC(this.localStore.get(),e,r))}clearStoredAuthToken(e){const r=this.localStore.get(),i=HC(r,e);i!==r&&this.localStore.set(i)}setActive(e){const r=this.localStore.get(),i=e?ee(e.url):null;r.activeServerURL!==i&&this.localStore.set({...r,activeServerURL:i})}connectConfiguredServers(e,r){const i=e?ee(e):null;if(i){const a=this.localStore.get();a.servers.some(u=>ee(u.url)===i)||this.localStore.set({...a,servers:[...a.servers,{url:i,name:rO}]})}const s=this.localStore.get().servers;for(const a of s){const c=ee(a.url),h=i!==null&&c===i?r??wh(this.localStore.get(),c):wh(this.localStore.get(),c),f=d(this,fa,bd).call(this,{url:a.url,name:a.name,token:h});this.add(f),f.connect(h).catch(()=>{})}const o=i?this.servers.get(i)??null:null;this.setActive(o??this.servers.values().next().value??null)}addServer(e,r){const i=ee(e);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>ee(a.url)!==i),{url:i,name:r}]});const o=d(this,fa,bd).call(this,{url:i,name:r,token:this.getStoredAuthToken(i)});this.add(o),this.setActive(o),o.connect(o.token).catch(()=>{})}removeServer(e){this.remove(e)}}fa=new WeakSet,bd=function(e){return new Ww({url:e.url,name:e.name,token:e.token,createSocket:this.createSocket,clientGUID:this.clientGUID,acpStorage:this.acpStorage,telemetryMeta:this.telemetryMeta})};var ga;class sO extends It{constructor(){super();b(this,ga,e=>{const r=oO(e);r!==null&&(e.preventDefault(),this.dispatchEvent(new Q$("shortcut-triggered",{shortcut:r})))});document.addEventListener("keydown",l(this,ga))}dispose(){document.removeEventListener("keydown",l(this,ga))}}ga=new WeakMap;function oO(n){for(const[t,e]of Object.entries(TC))if(aO(n,e.trigger))return t;return null}function aO(n,t){return!(n.key.toLowerCase()!==t.key.toLowerCase()||n.metaKey!==!!t.meta||n.ctrlKey!==!!t.ctrl||n.shiftKey!==!!t.shift||n.altKey!==!!t.alt)}const wd="tv-nav:",Zs="tv-reload",Av=100,lO=1e3,cO=60,uO=60,hO=24,dO=30,pO=dO*hO*uO*cO*lO;function Fn(n){try{const t=new URL(n,window.location.href),e=t.searchParams.has(Zs);return t.searchParams.delete(Zs),t.origin===window.location.origin?`${t.pathname}${t.search}${t.hash}`:e?t.toString():n}catch{return n}}var ma,vs,de,oe,Jr,Ae,jw,Gn,Gw,Sd,_d;class fO extends It{constructor(e,r){super();b(this,Ae);b(this,ma);b(this,vs);b(this,de,[]);b(this,oe,-1);b(this,Jr,0);m(this,ma,e),m(this,vs,Fn(r)),d(this,Ae,jw).call(this)}get currentURL(){var e;return l(this,oe)===-1?null:((e=l(this,de)[l(this,oe)])==null?void 0:e.url)??null}get canGoBack(){return l(this,oe)>-1}get canGoForward(){return l(this,oe)<l(this,de).length-1}get entries(){return l(this,de).map(e=>({...e}))}get cursor(){return l(this,oe)}navigate(e){const r=Fn(e);if(r===l(this,vs)){if(l(this,oe)===-1)return;m(this,oe,-1),d(this,Ae,Gn).call(this);return}l(this,oe)<l(this,de).length-1&&m(this,de,l(this,de).slice(0,l(this,oe)+1)),l(this,de).push({url:r}),m(this,oe,l(this,de).length-1),d(this,Ae,Sd).call(this),d(this,Ae,Gn).call(this)}replace(e){var i;if(l(this,oe)===-1){this.navigate(e);return}const r=Fn(e);if(r===l(this,vs)){m(this,de,l(this,de).filter((s,o)=>o!==l(this,oe))),m(this,oe,-1),d(this,Ae,Gn).call(this);return}((i=l(this,de)[l(this,oe)])==null?void 0:i.url)!==r&&(m(this,de,l(this,de).map((s,o)=>o===l(this,oe)?{url:r}:s)),d(this,Ae,Gn).call(this))}back(){l(this,oe)!==-1&&(m(this,oe,l(this,oe)-1),d(this,Ae,Gn).call(this))}forward(){this.canGoForward&&(m(this,oe,l(this,oe)+1),d(this,Ae,Gn).call(this))}reset(){l(this,oe)===-1&&l(this,de).length===0||(m(this,de,[]),m(this,oe,-1),d(this,Ae,Gn).call(this))}}ma=new WeakMap,vs=new WeakMap,de=new WeakMap,oe=new WeakMap,Jr=new WeakMap,Ae=new WeakSet,jw=function(){const e=localStorage.getItem(l(this,Ae,_d));if(e!==null)try{const r=JSON.parse(e);if(!qw(r))return;m(this,de,r.entries.map(i=>({url:i.url}))),m(this,oe,r.cursor),m(this,Jr,r.lastWritten),d(this,Ae,Sd).call(this)}catch{m(this,de,[]),m(this,oe,-1),m(this,Jr,0)}},Gn=function(){m(this,Jr,Date.now());try{localStorage.setItem(l(this,Ae,_d),JSON.stringify(d(this,Ae,Gw).call(this)))}catch(e){if(!vO(e))throw e}this.dispatchEvent(new ie("change"))},Gw=function(){return{v:1,entries:l(this,de).map(e=>({...e})),cursor:l(this,oe),lastWritten:l(this,Jr)}},Sd=function(){if(l(this,de).length<=Av)return;const e=l(this,de).length-Av;m(this,de,l(this,de).slice(e)),m(this,oe,Math.max(-1,l(this,oe)-e))},_d=function(){return gO(l(this,ma))};function gO(n){return`${wd}${n}`}function mO(n){const t=Date.now()-pO,e=[];for(let r=0;r<localStorage.length;r+=1){const i=localStorage.key(r);if(!(i!=null&&i.startsWith(wd)))continue;const s=i.slice(wd.length),o=localStorage.getItem(i);if(o===null)continue;let a;try{a=JSON.parse(o)}catch{e.push(i);continue}if(!qw(a)){e.push(i);continue}!n.has(s)&&a.lastWritten<t&&e.push(i)}for(const r of e)localStorage.removeItem(r)}function vO(n){return n instanceof DOMException&&n.name==="QuotaExceededError"}function qw(n){if(typeof n!="object"||n===null)return!1;const t=n;if(t.v!==1||!Array.isArray(t.entries))return!1;const e=t.cursor;return typeof e!="number"||!Number.isInteger(e)||typeof t.lastWritten!="number"||!Number.isFinite(t.lastWritten)||e<-1||e>=t.entries.length?!1:t.entries.every(r=>typeof r=="object"&&r!==null&&typeof r.url=="string")}const yO="0.1.198";function mf(n=yO){return n!==void 0&&n.length>0?n:"0.0.0"}function vf(){let n=!1;return{get pending(){return n},begin(t){n||(n=!0,t())}}}const kd="tv-reload-attempted";function bO(n){return n.originMatch?n.marker!==null&&n.bundleVersion===n.serverVersion?{action:"signal-autoreloaded",fromVersion:n.marker.fromVersion,toVersion:n.bundleVersion}:IC(n.bundleVersion,n.serverVersion)?n.marker!==null&&n.marker.serverVersion===n.serverVersion?{action:"none"}:{action:"reload",marker:{serverVersion:n.serverVersion,fromVersion:n.bundleVersion}}:{action:"none"}:{action:"none"}}function wO(n){const t=n.getItem(kd);if(t===null)return null;let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!="object")return null;const r=e;return typeof r.serverVersion!="string"||typeof r.fromVersion!="string"?null:{serverVersion:r.serverVersion,fromVersion:r.fromVersion}}function SO(n){const t=n.storage!==void 0?n.storage:typeof sessionStorage<"u"?sessionStorage:null,e=n.reload??(()=>location.reload()),r=n.navigationLatch??vf(),i=n.bundleVersion??mf();if(t===null)return{dispose(){}};let s=null;const o=()=>{if(s===null)return;const u=n.manager.servers.get(n.primaryServerURL);if(!u||u.status!=="connected")return;const h=s;s=null,u.sendTelemetrySignal("client_autoreloaded",{from_version:h.fromVersion,to_version:h.toVersion})},a=u=>{if(r.pending)return;const h=bO({bundleVersion:i,serverVersion:u.message.version,originMatch:u.serverURL===n.primaryServerURL,marker:wO(t)});switch(h.action){case"reload":t.setItem(kd,JSON.stringify(h.marker)),r.begin(e);return;case"signal-autoreloaded":t.removeItem(kd),s={fromVersion:h.fromVersion,toVersion:h.toVersion},o();return;case"none":return}},c=()=>{o()};return n.manager.addEventListener("server-status",a),n.manager.addEventListener("change",c),{dispose(){n.manager.removeEventListener("server-status",a),n.manager.removeEventListener("change",c)}}}function _O(n){const t=Wt(n.search),e=G0(n.search),r=e!==null&&of(e)?e:null;return{electron:t,shellVersion:r}}function kO(n){return!n.electron||n.requiredDesktopVersion===null||!of(n.requiredDesktopVersion)?!1:n.shellVersion===null?!0:n.shellVersion===nd?!1:qb(n.requiredDesktopVersion,n.shellVersion)}const EO=`# Desktop app upgrade required
|
|
44
44
|
|
|
45
45
|
Your Television server requires a newer version of this desktop app.
|
|
46
46
|
In a terminal, please upgrade:
|
package/dist/web/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
|
6
6
|
<link rel="icon" type="image/svg+xml" href="./assets/favicon-DaYMFRha.svg" />
|
|
7
7
|
<title>Television</title>
|
|
8
|
-
<script type="module" crossorigin src="./assets/main-
|
|
8
|
+
<script type="module" crossorigin src="./assets/main-JJ7IhAg1.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="./assets/artifact-bridge-BhiFDvPj.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="./assets/missing-artifact-page-DVzJ41AE.js">
|
|
11
11
|
<link rel="stylesheet" crossorigin href="./assets/main-5017mprd.css">
|