@telepath-computer/television 0.1.186 → 0.1.187

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
@@ -52493,7 +52493,7 @@ function disabledTelemetryRuntime() {
52493
52493
 
52494
52494
  // ../server/src/updates/version.ts
52495
52495
  function readVersionStamp() {
52496
- if ("0.1.186".length > 0) return "0.1.186";
52496
+ if ("0.1.187".length > 0) return "0.1.187";
52497
52497
  return void 0;
52498
52498
  }
52499
52499
  function resolveUpdateReleaseVersion(env = process.env, stamp = readVersionStamp()) {
@@ -52995,8 +52995,8 @@ var Server = class {
52995
52995
  };
52996
52996
  };
52997
52997
  function readServerPackageVersion() {
52998
- if ("0.1.186".length > 0) {
52999
- return telemetryVersion("0.1.186");
52998
+ if ("0.1.187".length > 0) {
52999
+ return telemetryVersion("0.1.187");
53000
53000
  }
53001
53001
  const packageJsonPath = import_node_path11.default.resolve(import_node_path11.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url)), "..", "package.json");
53002
53002
  if (!(0, import_node_fs9.existsSync)(packageJsonPath)) return telemetryVersion("0.0.0");
@@ -54567,8 +54567,8 @@ function resolveVercelSkillsInstallerBin() {
54567
54567
  return localRequire.resolve("skills/bin/cli.mjs");
54568
54568
  }
54569
54569
  function readCLIVersion() {
54570
- if ("0.1.186".length > 0) {
54571
- return "0.1.186";
54570
+ if ("0.1.187".length > 0) {
54571
+ return "0.1.187";
54572
54572
  }
54573
54573
  const devPackageJsonPath = import_node_path17.default.join(getDevPackageDir(), "package.json");
54574
54574
  if (!(0, import_node_fs14.existsSync)(devPackageJsonPath)) {
@@ -40,7 +40,7 @@ var X_=Object.defineProperty;var sg=n=>{throw TypeError(n)};var Q_=(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=!n0.jitless,u=a&&rI.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?b0([],E,v,y,f,n):v):e(v,y):(v.issues.push({expected:"object",code:"invalid_type",input:E,inst:n}),v)}});function Jm(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 w0=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=>Jm(c,i,n,s)):Jm(a,i,n,s)}}),ZR=A("$ZodDiscriminatedUnion",(n,t)=>{t.inclusive=!1,w0.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)}}),BR=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])=>Xm(e,c,u)):Xm(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 Xm(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 WR=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"&&d0.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}}),jR=A("$ZodEnum",(n,t)=>{ye.init(n,t);const e=r0(t.entries),r=new Set(e);n._zod.values=r,n._zod.pattern=new RegExp(`^(${e.filter(i=>iI.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}}),GR=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}}),qR=A("$ZodTransform",(n,t)=>{ye.init(n,t),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new t0(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 Qm(n,t){return n.issues.length&&t===void 0?{issues:[],value:void 0}:n}const S0=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=>Qm(s,e.value)):Qm(i,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,r)}}),YR=A("$ZodExactOptional",(n,t)=>{S0.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)}),KR=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)}),JR=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=>ev(s,t)):ev(i,t)}});function ev(n,t){return n.value===void 0&&(n.value=t.defaultValue),n}const XR=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))}),QR=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=>tv(s,n)):tv(i,n)}});function tv(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 eP=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)}}),tP=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 nP=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(nv):nv(i)}});function nv(n){return n.value=Object.freeze(n.value),n}const rP=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=>rv(s,e,r,n));rv(i,e,r,n)}});function rv(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 iv;class iP{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 sP(){return new iP}(iv=globalThis).__zod_globalRegistry??(iv.__zod_globalRegistry=sP());const ko=globalThis.__zod_globalRegistry;function oP(n,t){return new n({type:"string",...z(t)})}function aP(n,t){return new n({type:"string",format:"email",check:"string_format",abort:!1,...z(t)})}function sv(n,t){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...z(t)})}function lP(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...z(t)})}function cP(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(t)})}function uP(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(t)})}function hP(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(t)})}function dP(n,t){return new n({type:"string",format:"url",check:"string_format",abort:!1,...z(t)})}function pP(n,t){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...z(t)})}function fP(n,t){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(t)})}function gP(n,t){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...z(t)})}function mP(n,t){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(t)})}function vP(n,t){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...z(t)})}function yP(n,t){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...z(t)})}function bP(n,t){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(t)})}function wP(n,t){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(t)})}function SP(n,t){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(t)})}function _P(n,t){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(t)})}function kP(n,t){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(t)})}function EP(n,t){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...z(t)})}function xP(n,t){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...z(t)})}function AP(n,t){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...z(t)})}function TP(n,t){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...z(t)})}function $P(n,t){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(t)})}function CP(n,t){return new n({type:"string",format:"date",check:"string_format",...z(t)})}function IP(n,t){return new n({type:"string",format:"time",check:"string_format",precision:null,...z(t)})}function RP(n,t){return new n({type:"string",format:"duration",check:"string_format",...z(t)})}function PP(n,t){return new n({type:"number",checks:[],...z(t)})}function LP(n,t){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...z(t)})}function DP(n,t){return new n({type:"boolean",...z(t)})}function MP(n){return new n({type:"unknown"})}function zP(n,t){return new n({type:"never",...z(t)})}function ov(n,t){return new f0({check:"less_than",...z(t),value:n,inclusive:!1})}function Sh(n,t){return new f0({check:"less_than",...z(t),value:n,inclusive:!0})}function av(n,t){return new g0({check:"greater_than",...z(t),value:n,inclusive:!1})}function _h(n,t){return new g0({check:"greater_than",...z(t),value:n,inclusive:!0})}function lv(n,t){return new JI({check:"multiple_of",...z(t),value:n})}function _0(n,t){return new QI({check:"max_length",...z(t),maximum:n})}function xc(n,t){return new eR({check:"min_length",...z(t),minimum:n})}function k0(n,t){return new tR({check:"length_equals",...z(t),length:n})}function OP(n,t){return new nR({check:"string_format",format:"regex",...z(t),pattern:n})}function NP(n){return new rR({check:"string_format",format:"lowercase",...z(n)})}function UP(n){return new iR({check:"string_format",format:"uppercase",...z(n)})}function FP(n,t){return new sR({check:"string_format",format:"includes",...z(t),includes:n})}function HP(n,t){return new oR({check:"string_format",format:"starts_with",...z(t),prefix:n})}function VP(n,t){return new aR({check:"string_format",format:"ends_with",...z(t),suffix:n})}function eo(n){return new lR({check:"overwrite",tx:n})}function ZP(n){return eo(t=>t.normalize(n))}function BP(){return eo(n=>n.trim())}function WP(){return eo(n=>n.toLowerCase())}function jP(){return eo(n=>n.toUpperCase())}function GP(){return eo(n=>nI(n))}function qP(n,t,e){return new n({type:"array",element:t,...z(e)})}function YP(n,t,e){return new n({type:"custom",check:"custom",fn:t,...z(e)})}function KP(n){const t=JP(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 JP(n,t){const e=new ht({check:"custom",...z(t)});return e._zod.check=n,e}function E0(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 x0(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 A0(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 XP=(n,t={})=>e=>{const r=E0({...e,processors:t});return $e(n,r),x0(r,n),A0(r,n)},Ac=(n,t,e={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=E0({...i??{},target:s,io:t,processors:e});return $e(n,o),x0(o,n),A0(o,n)},QP={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},e2=(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=QP[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}))])}},t2=(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)},n2=(n,t,e,r)=>{e.type="boolean"},r2=(n,t,e,r)=>{e.not={}},i2=(n,t,e,r)=>{},s2=(n,t,e,r)=>{const i=n._zod.def,s=r0(i.entries);s.every(o=>typeof o=="number")&&(e.type="number"),s.every(o=>typeof o=="string")&&(e.type="string"),e.enum=s},o2=(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},a2=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},l2=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},c2=(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"]})},u2=(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)},h2=(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},d2=(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},p2=(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)}},f2=(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"}]},g2=(n,t,e,r)=>{const i=n._zod.def;$e(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},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,e.default=JSON.parse(JSON.stringify(i.defaultValue))},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,t.io==="input"&&(e._prefault=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;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}e.default=o},b2=(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},w2=(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},T0=(n,t,e,r)=>{const i=n._zod.def;$e(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},S2=A("ZodISODateTime",(n,t)=>{_R.init(n,t),we.init(n,t)});function _2(n){return $P(S2,n)}const k2=A("ZodISODate",(n,t)=>{kR.init(n,t),we.init(n,t)});function E2(n){return CP(k2,n)}const x2=A("ZodISOTime",(n,t)=>{ER.init(n,t),we.init(n,t)});function A2(n){return IP(x2,n)}const T2=A("ZodISODuration",(n,t)=>{xR.init(n,t),we.init(n,t)});function $2(n){return RP(T2,n)}const $0=(n,t)=>{a0.init(n,t),n.name="ZodError",Object.defineProperties(n,{format:{value:e=>gI(n,e)},flatten:{value:e=>fI(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}}})},cv=A("ZodError",$0),Rt=A("ZodError",$0,{Parent:Error}),C2=uf(Rt),I2=hf(Rt),R2=mu(Rt),P2=vu(Rt),L2=yI(Rt),D2=bI(Rt),M2=wI(Rt),z2=SI(Rt),O2=_I(Rt),N2=kI(Rt),U2=EI(Rt),F2=xI(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=XP(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)=>C2(n,e,r,{callee:n.parse}),n.safeParse=(e,r)=>R2(n,e,r),n.parseAsync=async(e,r)=>I2(n,e,r,{callee:n.parseAsync}),n.safeParseAsync=async(e,r)=>P2(n,e,r),n.spa=n.safeParseAsync,n.encode=(e,r)=>L2(n,e,r),n.decode=(e,r)=>D2(n,e,r),n.encodeAsync=async(e,r)=>M2(n,e,r),n.decodeAsync=async(e,r)=>z2(n,e,r),n.safeEncode=(e,r)=>O2(n,e,r),n.safeDecode=(e,r)=>N2(n,e,r),n.safeEncodeAsync=async(e,r)=>U2(n,e,r),n.safeDecodeAsync=async(e,r)=>F2(n,e,r),n.refine=(e,r)=>n.check(PL(e,r)),n.superRefine=e=>n.check(LL(e)),n.overwrite=e=>n.check(eo(e)),n.optional=()=>dv(n),n.exactOptional=()=>bL(n),n.nullable=()=>pv(n),n.nullish=()=>dv(pv(n)),n.nonoptional=e=>xL(n,e),n.array=()=>M(n),n.or=e=>j([n,e]),n.and=e=>bu(n,e),n.transform=e=>fv(n,vL(e)),n.default=e=>_L(n,e),n.prefault=e=>EL(n,e),n.catch=e=>TL(n,e),n.pipe=e=>fv(n,e),n.readonly=()=>IL(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)),C0=A("_ZodString",(n,t)=>{df.init(n,t),be.init(n,t),n._zod.processJSONSchema=(r,i,s)=>e2(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(OP(...r)),n.includes=(...r)=>n.check(FP(...r)),n.startsWith=(...r)=>n.check(HP(...r)),n.endsWith=(...r)=>n.check(VP(...r)),n.min=(...r)=>n.check(xc(...r)),n.max=(...r)=>n.check(_0(...r)),n.length=(...r)=>n.check(k0(...r)),n.nonempty=(...r)=>n.check(xc(1,...r)),n.lowercase=r=>n.check(NP(r)),n.uppercase=r=>n.check(UP(r)),n.trim=()=>n.check(BP()),n.normalize=(...r)=>n.check(ZP(...r)),n.toLowerCase=()=>n.check(WP()),n.toUpperCase=()=>n.check(jP()),n.slugify=()=>n.check(GP())}),H2=A("ZodString",(n,t)=>{df.init(n,t),C0.init(n,t),n.email=e=>n.check(aP(V2,e)),n.url=e=>n.check(dP(Z2,e)),n.jwt=e=>n.check(TP(iL,e)),n.emoji=e=>n.check(pP(B2,e)),n.guid=e=>n.check(sv(uv,e)),n.uuid=e=>n.check(lP(Fl,e)),n.uuidv4=e=>n.check(cP(Fl,e)),n.uuidv6=e=>n.check(uP(Fl,e)),n.uuidv7=e=>n.check(hP(Fl,e)),n.nanoid=e=>n.check(fP(W2,e)),n.guid=e=>n.check(sv(uv,e)),n.cuid=e=>n.check(gP(j2,e)),n.cuid2=e=>n.check(mP(G2,e)),n.ulid=e=>n.check(vP(q2,e)),n.base64=e=>n.check(EP(tL,e)),n.base64url=e=>n.check(xP(nL,e)),n.xid=e=>n.check(yP(Y2,e)),n.ksuid=e=>n.check(bP(K2,e)),n.ipv4=e=>n.check(wP(J2,e)),n.ipv6=e=>n.check(SP(X2,e)),n.cidrv4=e=>n.check(_P(Q2,e)),n.cidrv6=e=>n.check(kP(eL,e)),n.e164=e=>n.check(AP(rL,e)),n.datetime=e=>n.check(_2(e)),n.date=e=>n.check(E2(e)),n.time=e=>n.check(A2(e)),n.duration=e=>n.check($2(e))});function p(n){return oP(H2,n)}const we=A("ZodStringFormat",(n,t)=>{me.init(n,t),C0.init(n,t)}),V2=A("ZodEmail",(n,t)=>{pR.init(n,t),we.init(n,t)}),uv=A("ZodGUID",(n,t)=>{hR.init(n,t),we.init(n,t)}),Fl=A("ZodUUID",(n,t)=>{dR.init(n,t),we.init(n,t)}),Z2=A("ZodURL",(n,t)=>{fR.init(n,t),we.init(n,t)}),B2=A("ZodEmoji",(n,t)=>{gR.init(n,t),we.init(n,t)}),W2=A("ZodNanoID",(n,t)=>{mR.init(n,t),we.init(n,t)}),j2=A("ZodCUID",(n,t)=>{vR.init(n,t),we.init(n,t)}),G2=A("ZodCUID2",(n,t)=>{yR.init(n,t),we.init(n,t)}),q2=A("ZodULID",(n,t)=>{bR.init(n,t),we.init(n,t)}),Y2=A("ZodXID",(n,t)=>{wR.init(n,t),we.init(n,t)}),K2=A("ZodKSUID",(n,t)=>{SR.init(n,t),we.init(n,t)}),J2=A("ZodIPv4",(n,t)=>{AR.init(n,t),we.init(n,t)}),X2=A("ZodIPv6",(n,t)=>{TR.init(n,t),we.init(n,t)}),Q2=A("ZodCIDRv4",(n,t)=>{$R.init(n,t),we.init(n,t)}),eL=A("ZodCIDRv6",(n,t)=>{CR.init(n,t),we.init(n,t)}),tL=A("ZodBase64",(n,t)=>{IR.init(n,t),we.init(n,t)}),nL=A("ZodBase64URL",(n,t)=>{PR.init(n,t),we.init(n,t)}),rL=A("ZodE164",(n,t)=>{LR.init(n,t),we.init(n,t)}),iL=A("ZodJWT",(n,t)=>{MR.init(n,t),we.init(n,t)}),I0=A("ZodNumber",(n,t)=>{v0.init(n,t),be.init(n,t),n._zod.processJSONSchema=(r,i,s)=>t2(n,r,i),n.gt=(r,i)=>n.check(av(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(ov(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(hv(r)),n.safe=r=>n.check(hv(r)),n.positive=r=>n.check(av(0,r)),n.nonnegative=r=>n.check(_h(0,r)),n.negative=r=>n.check(ov(0,r)),n.nonpositive=r=>n.check(Sh(0,r)),n.multipleOf=(r,i)=>n.check(lv(r,i)),n.step=(r,i)=>n.check(lv(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 PP(I0,n)}const sL=A("ZodNumberFormat",(n,t)=>{zR.init(n,t),I0.init(n,t)});function hv(n){return LP(sL,n)}const oL=A("ZodBoolean",(n,t)=>{OR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>n2(n,e,r)});function Ne(n){return DP(oL,n)}const aL=A("ZodUnknown",(n,t)=>{NR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>i2()});function _(){return MP(aL)}const lL=A("ZodNever",(n,t)=>{UR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>r2(n,e,r)});function cL(n){return zP(lL,n)}const uL=A("ZodArray",(n,t)=>{FR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>c2(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(_0(e,r)),n.length=(e,r)=>n.check(k0(e,r)),n.unwrap=()=>n.element});function M(n,t){return qP(uL,n,t)}const R0=A("ZodObject",(n,t)=>{VR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>u2(n,e,r,i),re(n,"shape",()=>t.shape),n.keyof=()=>D0(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:cL()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=e=>cI(n,e),n.safeExtend=e=>uI(n,e),n.merge=e=>hI(n,e),n.pick=e=>aI(n,e),n.omit=e=>lI(n,e),n.partial=(...e)=>dI(M0,n,e[0]),n.required=(...e)=>pI(z0,n,e[0])});function P0(n,t){const e={type:"object",shape:n??{},...z(t)};return new R0(e)}function w(n,t){return new R0({type:"object",shape:n,catchall:_(),...z(t)})}const L0=A("ZodUnion",(n,t)=>{w0.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>h2(n,e,r,i),n.options=t.options});function j(n,t){return new L0({type:"union",options:n,...z(t)})}const hL=A("ZodDiscriminatedUnion",(n,t)=>{L0.init(n,t),ZR.init(n,t)});function dL(n,t,e){return new hL({type:"union",options:t,discriminator:n,...z(e)})}const pL=A("ZodIntersection",(n,t)=>{BR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>d2(n,e,r,i)});function bu(n,t){return new pL({type:"intersection",left:n,right:t})}const fL=A("ZodRecord",(n,t)=>{WR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>p2(n,e,r,i),n.keyType=t.keyType,n.valueType=t.valueType});function k(n,t,e){return new fL({type:"record",keyType:n,valueType:t,...z(e)})}const cd=A("ZodEnum",(n,t)=>{jR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(r,i,s)=>s2(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 D0(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 gL=A("ZodLiteral",(n,t)=>{GR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>o2(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 gL({type:"literal",values:Array.isArray(n)?n:[n],...z(t)})}const mL=A("ZodTransform",(n,t)=>{qR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>l2(n,e),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new t0(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 vL(n){return new mL({type:"transform",transform:n})}const M0=A("ZodOptional",(n,t)=>{S0.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>T0(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function dv(n){return new M0({type:"optional",innerType:n})}const yL=A("ZodExactOptional",(n,t)=>{YR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>T0(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function bL(n){return new yL({type:"optional",innerType:n})}const wL=A("ZodNullable",(n,t)=>{KR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>f2(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function pv(n){return new wL({type:"nullable",innerType:n})}const SL=A("ZodDefault",(n,t)=>{JR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>m2(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function _L(n,t){return new SL({type:"default",innerType:n,get defaultValue(){return typeof t=="function"?t():s0(t)}})}const kL=A("ZodPrefault",(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});function EL(n,t){return new kL({type:"prefault",innerType:n,get defaultValue(){return typeof t=="function"?t():s0(t)}})}const z0=A("ZodNonOptional",(n,t)=>{QR.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 xL(n,t){return new z0({type:"nonoptional",innerType:n,...z(t)})}const AL=A("ZodCatch",(n,t)=>{eP.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>y2(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function TL(n,t){return new AL({type:"catch",innerType:n,catchValue:typeof t=="function"?t:()=>t})}const $L=A("ZodPipe",(n,t)=>{tP.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>b2(n,e,r,i),n.in=t.in,n.out=t.out});function fv(n,t){return new $L({type:"pipe",in:n,out:t})}const CL=A("ZodReadonly",(n,t)=>{nP.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>w2(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function IL(n){return new CL({type:"readonly",innerType:n})}const RL=A("ZodCustom",(n,t)=>{rP.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>a2(n,e)});function PL(n,t={}){return YP(RL,n,t)}function LL(n){return KP(n)}const DL=[".md",".markdown"];function O0(n){if(n.length===0)return!1;const t=n.at(-1);return t==="/"||t==="\\"}function N0(n){const t=n.lastIndexOf("/"),e=n.lastIndexOf("\\");return n.slice(Math.max(t,e)+1)}function ML(n){return N0(n).toLowerCase()}function zL(n,t){const e=ML(n);return t.some(r=>e.endsWith(r))}function U0(n){return!O0(n)&&zL(n,DL)}function OL(n){let t;try{t=new URL(n)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}function xn(n){try{const{pathname:t}=new URL(n);return/^\/artifact\/[0-9A-Za-z]{26}(\/|$)/.test(t)}catch{return!1}}const NL=P0({id:p().min(1),kind:T("path"),title:p(),path:p()}).strict(),UL=P0({id:p().min(1),kind:T("url"),title:p(),url:p().refine(OL,{message:"url must be an http(s) URL"})}).strict();dL("kind",[NL,UL]);function F0(n){return typeof n=="object"&&n!==null}function H0(n){return!F0(n)||n.type!=="ready"?!1:!("id"in n)}function V0(n){return!(!F0(n)||n.type!=="update-content"||typeof n.id!="string"||typeof n.content!="string")}const FL="/views/markdown/",HL="/views/url-unsupported/";function Z0(n){return`/artifact/${encodeURIComponent(n)}`}function VL(n,t){return`${Z0(n)}/${encodeURIComponent(t)}`}function ZL(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}:xn(n.url)?{renderer:"proxy-iframe",viewURL:n.url,contentURL:null}:{renderer:"url-unsupported",viewURL:HL,contentURL:null};if(U0(n.path)){const r={viewURL:FL,contentURL:ZL(n.id)};return t.electron?{renderer:"url-webview",...r}:{renderer:"markdown",...r}}const e=O0(n.path)?`${Z0(n.id)}/`:VL(n.id,N0(n.path));return t.electron?{renderer:"url-webview",viewURL:e,contentURL:null}:{renderer:"proxy-iframe",viewURL:e,contentURL:null}}const BL="serverURL",WL="token",jL="mode",GL="desktopAppVersion",qL="electron";function B0(n=window.location.search,t=window.location.origin){const r=new URLSearchParams(n).get(BL);return r?new URL(r).origin:new URL(t).origin}function YL(n=window.location.search){return new URLSearchParams(n).get(WL)}function Wt(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(jL)===qL}function W0(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(GL)}const gv="tv.telemetry.clientId",KL=5,JL=60,XL=1e3,QL=KL*JL*XL,mv=["pointerdown","scroll","keydown"],vv=["focus"],yv=["visibilitychange"],eD="hidden";function tD(n,t=oD){const e=n.getItem(gv);if(e)return e;const r=t();return n.setItem(gv,r),r}function nD(n){return{clientId:tD(n.storage,n.idFactory),userAgent:n.userAgent??(typeof navigator>"u"?"":navigator.userAgent),clientApp:n.clientApp,...n.desktopAppVersion?{desktopAppVersion:n.desktopAppVersion}:{}}}function rD(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 iD(n){return new sD(n)}var ra,Rn,Qn,ia,sa,yt,Yr,oa,Oc,j0;class sD{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,j0).call(this))}start(){if(!l(this,Yr)){m(this,Yr,!0);for(const t of mv)l(this,Qn).addEventListener(t,l(this,yt)),l(this,Rn).addEventListener(t,l(this,yt));for(const t of vv)l(this,Qn).addEventListener(t,l(this,yt));for(const t of yv)l(this,Rn).addEventListener(t,l(this,yt))}}stop(){if(l(this,Yr)){m(this,Yr,!1);for(const t of mv)l(this,Qn).removeEventListener(t,l(this,yt)),l(this,Rn).removeEventListener(t,l(this,yt));for(const t of vv)l(this,Qn).removeEventListener(t,l(this,yt));for(const t of yv)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,j0=function(){if(l(this,Rn).visibilityState===eD)return;const t=l(this,sa).call(this);t-l(this,oa)<QL||(m(this,oa,t),l(this,ia).call(this,{type:dC,clientId:l(this,ra).clientId}))};function oD(){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"},En={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"},aD=1,lD=w({_meta:k(p(),_()).nullish(),terminal:Ne().optional().default(!1)}),cD=w({_meta:k(p(),_()).nullish(),label:p().nullish(),name:p(),optional:Ne().optional().default(!1),secret:Ne().optional().default(!0)}),uD=w({_meta:k(p(),_()).nullish(),description:p().nullish(),id:p(),name:p()}),hD=w({_meta:k(p(),_()).nullish(),description:p().nullish(),id:p(),link:p().nullish(),name:p(),vars:M(cD)}),dD=w({_meta:k(p(),_()).nullish(),args:M(p()).optional(),description:p().nullish(),env:k(p(),p()).optional(),id:p(),name:p()}),pD=j([hD.and(w({type:T("env_var")})),dD.and(w({type:T("terminal")})),uD]),fD=w({_meta:k(p(),_()).nullish(),methodId:p()}),gD=w({_meta:k(p(),_()).nullish()}),mD=w({_meta:k(p(),_()).nullish(),blob:p(),mimeType:p().nullish(),uri:p()}),vD=w({default:Ne().nullish(),description:p().nullish(),title:p().nullish()}),yD=w({_meta:k(p(),_()).nullish()}),bD=w({_meta:k(p(),_()).nullish()}),wD=w({amount:B(),currency:p()}),SD=w({_meta:k(p(),_()).nullish(),terminalId:p()}),_D=w({_meta:k(p(),_()).nullish(),newText:p(),oldText:p().nullish(),path:p()}),kD=j([p(),B(),B(),Ne(),M(p())]),ED=w({content:k(p(),kD).nullish()}),xD=j([ED.and(w({action:T("accept")})),w({action:T("decline")}),w({action:T("cancel")})]),AD=w({_meta:k(p(),_()).nullish()}),G0=p(),TD=w({_meta:k(p(),_()).nullish(),elicitationId:G0}),$D=w({_meta:k(p(),_()).nullish(),action:xD}),CD=T("object"),ID=T("string"),RD=w({_meta:k(p(),_()).nullish()}),PD=w({_meta:k(p(),_()).nullish(),form:AD.nullish(),url:RD.nullish()}),LD=w({elicitationId:G0,url:p().url()}),q0=w({const:p(),title:p()}),Y0=w({_meta:k(p(),_()).nullish(),name:p(),value:p()}),DD=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"})]),K0=w({code:DD,data:_().optional(),message:p()}),J0=_(),X0=_(),Q0=_(),MD=w({_meta:k(p(),_()).nullish(),readTextFile:Ne().optional().default(!1),writeTextFile:Ne().optional().default(!1)}),ew=w({_meta:k(p(),_()).nullish(),name:p(),value:p()}),tw=w({_meta:k(p(),_()).nullish(),name:p(),title:p().nullish(),version:p()}),zD=w({default:B().nullish(),description:p().nullish(),maximum:B().nullish(),minimum:B().nullish(),title:p().nullish()}),OD=w({_meta:k(p(),_()).nullish()}),ND=w({_meta:k(p(),_()).nullish(),additionalDirectories:M(p()).optional(),cursor:p().nullish(),cwd:p().nullish()}),UD=w({_meta:k(p(),_()).nullish()}),FD=w({_meta:k(p(),_()).nullish(),logout:UD.nullish()}),HD=w({_meta:k(p(),_()).nullish()}),VD=w({_meta:k(p(),_()).nullish()}),ZD=w({_meta:k(p(),_()).nullish(),http:Ne().optional().default(!1),sse:Ne().optional().default(!1)}),BD=w({_meta:k(p(),_()).nullish(),headers:M(ew),name:p(),url:p()}),WD=w({_meta:k(p(),_()).nullish(),headers:M(ew),name:p(),url:p()}),jD=w({_meta:k(p(),_()).nullish(),args:M(p()),command:p(),env:M(Y0),name:p()}),wu=j([BD.and(w({type:T("http")})),WD.and(w({type:T("sse")})),jD]),pf=p(),GD=w({_meta:k(p(),_()).nullish(),description:p().nullish(),modelId:pf,name:p()}),qD=j([T("error"),T("warning"),T("information"),T("hint")]),YD=w({_meta:k(p(),_()).nullish()}),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(),maxCount:B().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),t6=w({diff:p(),uri:p()}),n6=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()}),r6=w({_meta:k(p(),_()).nullish()}),i6=w({_meta:k(p(),_()).nullish()}),s6=w({languageId:p(),text:p(),uri:p()}),o6=w({_meta:k(p(),_()).nullish(),maxCount:B().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),a6=j([T("rejected"),T("ignored"),T("replaced"),T("cancelled")]),l6=w({excerpts:M(n6),uri:p()}),c6=w({_meta:k(p(),_()).nullish()}),u6=w({_meta:k(p(),_()).nullish()}),h6=w({name:p(),owner:p(),remoteUrl:p()}),d6=w({_meta:k(p(),_()).nullish()}),p6=w({_meta:k(p(),_()).nullish(),jump:r6.nullish(),rename:u6.nullish(),searchAndReplace:d6.nullish()}),f6=w({id:p(),isRegex:Ne().nullish(),replace:p(),search:p(),uri:p()}),g6=j([T("automatic"),T("diagnostic"),T("manual")]),m6=w({_meta:k(p(),_()).nullish(),maxCount:B().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),v6=w({_meta:k(p(),_()).nullish(),diagnostics:YD.nullish(),editHistory:e6.nullish(),openFiles:i6.nullish(),recentFiles:o6.nullish(),relatedSnippets:c6.nullish(),userActions:m6.nullish()}),y6=w({_meta:k(p(),_()).nullish(),additionalDirectories:M(p()).optional(),cwd:p(),mcpServers:M(wu)}),b6=w({default:B().nullish(),description:p().nullish(),maximum:B().nullish(),minimum:B().nullish(),title:p().nullish()}),nw=p(),w6=j([T("allow_once"),T("allow_always"),T("reject_once"),T("reject_always")]),S6=w({_meta:k(p(),_()).nullish(),kind:w6,name:p(),optionId:nw}),_6=j([T("high"),T("medium"),T("low")]),k6=j([T("pending"),T("in_progress"),T("completed")]),E6=w({_meta:k(p(),_()).nullish(),content:p(),priority:_6,status:k6}),x6=w({_meta:k(p(),_()).nullish(),entries:M(E6)}),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"})}),A6=w({id:p(),position:gr,uri:p()}),T6=w({id:p(),newName:p(),position:gr,uri:p()}),$6=w({action:p(),position:gr,timestampMs:B(),uri:p()}),rw=j([T("utf-16"),T("utf-32"),T("utf-8")]),C6=w({_meta:k(p(),_()).nullish(),auth:lD.optional().default({terminal:!1}),elicitation:PD.nullish(),fs:MD.optional().default({readTextFile:!1,writeTextFile:!1}),nes:p6.nullish(),positionEncodings:M(rw).optional(),terminal:Ne().optional().default(!1)}),I6=w({_meta:k(p(),_()).nullish(),audio:Ne().optional().default(!1),embeddedContext:Ne().optional().default(!1),image:Ne().optional().default(!1)}),iw=B().int().gte(0).lte(65535),R6=w({_meta:k(p(),_()).nullish(),clientCapabilities:C6.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:tw.nullish(),protocolVersion:iw}),to=w({end:gr,start:gr}),P6=w({message:p(),range:to,severity:qD,uri:p()}),L6=w({languageId:p(),lastFocusedMs:B().nullish(),uri:p(),visibleRange:to.nullish()}),D6=w({_meta:k(p(),_()).nullish(),diagnostics:M(P6).nullish(),editHistory:M(t6).nullish(),openFiles:M(L6).nullish(),recentFiles:M(s6).nullish(),relatedSnippets:M(l6).nullish(),userActions:M($6).nullish()}),M6=w({newText:p(),range:to}),z6=w({cursorPosition:gr.nullish(),edits:M(M6),id:p(),uri:p()}),O6=j([z6.and(w({kind:T("edit")})),A6.and(w({kind:T("jump")})),T6.and(w({kind:T("rename")})),f6.and(w({kind:T("searchAndReplace")}))]),N6=w({_meta:k(p(),_()).nullish(),content:p()}),U6=w({_meta:k(p(),_()).nullish()}),bi=j([B(),p()]).nullable();w({_meta:k(p(),_()).nullish(),requestId:bi});const F6=D0(["assistant","user"]),ml=w({_meta:k(p(),_()).nullish(),audience:M(F6).nullish(),lastModified:p().nullish(),priority:B().nullish()}),H6=w({_meta:k(p(),_()).nullish(),annotations:ml.nullish(),data:p(),mimeType:p()}),V6=w({_meta:k(p(),_()).nullish(),annotations:ml.nullish(),data:p(),mimeType:p(),uri:p().nullish()}),Z6=w({_meta:k(p(),_()).nullish(),annotations:ml.nullish(),description:p().nullish(),mimeType:p().nullish(),name:p(),size:B().nullish(),title:p().nullish(),uri:p()}),B6=w({_meta:k(p(),_()).nullish(),optionId:nw}),W6=j([w({outcome:T("cancelled")}),B6.and(w({outcome:T("selected")}))]),j6=w({_meta:k(p(),_()).nullish(),outcome:W6}),G6=w({_meta:k(p(),_()).nullish()}),q6=w({_meta:k(p(),_()).nullish()}),Y6=w({currentValue:Ne()}),K6=p(),sw=p(),J6=j([T("mode"),T("model"),T("thought_level"),p()]),ff=p(),ow=w({_meta:k(p(),_()).nullish(),description:p().nullish(),name:p(),value:ff}),X6=w({_meta:k(p(),_()).nullish(),group:K6,name:p(),options:M(ow)}),Q6=j([M(ow),M(X6)]),eM=w({currentValue:ff,options:Q6}),no=bu(j([eM.and(w({type:T("select")})),Y6.and(w({type:T("boolean")}))]),w({_meta:k(p(),_()).nullish(),category:J6.nullish(),description:p().nullish(),id:sw,name:p()})),tM=w({_meta:k(p(),_()).nullish(),configOptions:M(no)}),nM=w({_meta:k(p(),_()).nullish()}),te=p(),rM=w({_meta:k(p(),_()).nullish(),id:p(),sessionId:te}),iM=w({_meta:k(p(),_()).nullish(),sessionId:te}),sM=w({_meta:k(p(),_()).nullish(),sessionId:te}),oM=w({_meta:k(p(),_()).nullish(),sessionId:te}),aw=w({_meta:k(p(),_()).nullish(),args:M(p()).optional(),command:p(),cwd:p().nullish(),env:M(Y0).optional(),outputByteLimit:B().nullish(),sessionId:te}),aM=w({_meta:k(p(),_()).nullish(),sessionId:te,uri:p()}),lM=w({_meta:k(p(),_()).nullish(),position:gr,sessionId:te,uri:p(),version:B(),visibleRange:to}),cM=w({_meta:k(p(),_()).nullish(),languageId:p(),sessionId:te,text:p(),uri:p(),version:B()}),uM=w({_meta:k(p(),_()).nullish(),sessionId:te,uri:p()}),hM=w({_meta:k(p(),_()).nullish(),additionalDirectories:M(p()).optional(),cwd:p(),mcpServers:M(wu).optional(),sessionId:te}),lw=w({_meta:k(p(),_()).nullish(),sessionId:te,terminalId:p()}),dM=w({_meta:k(p(),_()).nullish(),additionalDirectories:M(p()).optional(),cwd:p(),mcpServers:M(wu),sessionId:te}),cw=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}),pM=w({_meta:k(p(),_()).nullish(),id:p(),reason:a6.nullish(),sessionId:te}),uw=w({_meta:k(p(),_()).nullish(),sessionId:te,terminalId:p()}),fM=w({_meta:k(p(),_()).nullish(),additionalDirectories:M(p()).optional(),cwd:p(),mcpServers:M(wu).optional(),sessionId:te}),gM=w({_meta:k(p(),_()).nullish(),additionalDirectories:M(p()).optional(),cwd:p(),sessionId:te,title:p().nullish(),updatedAt:p().nullish()}),mM=w({_meta:k(p(),_()).nullish(),nextCursor:p().nullish(),sessions:M(gM)}),vM=w({_meta:k(p(),_()).nullish(),title:p().nullish(),updatedAt:p().nullish()}),yM=w({_meta:k(p(),_()).nullish()}),Su=p(),bM=w({_meta:k(p(),_()).nullish(),currentModeId:Su}),wM=w({_meta:k(p(),_()).nullish(),description:p().nullish(),id:Su,name:p()}),_u=w({_meta:k(p(),_()).nullish(),availableModes:M(wM),currentModeId:Su}),ku=w({_meta:k(p(),_()).nullish(),availableModels:M(GD),currentModelId:pf}),SM=w({_meta:k(p(),_()).nullish(),configOptions:M(no).nullish(),models:ku.nullish(),modes:_u.nullish(),sessionId:te}),_M=w({_meta:k(p(),_()).nullish(),configOptions:M(no).nullish(),models:ku.nullish(),modes:_u.nullish()}),kM=w({_meta:k(p(),_()).nullish(),configOptions:M(no).nullish(),models:ku.nullish(),modes:_u.nullish(),sessionId:te}),EM=w({_meta:k(p(),_()).nullish(),configOptions:M(no).nullish(),models:ku.nullish(),modes:_u.nullish()}),xM=w({_meta:k(p(),_()).nullish()}),AM=w({_meta:k(p(),_()).nullish(),additionalDirectories:G6.nullish(),close:q6.nullish(),fork:nM.nullish(),list:yM.nullish(),resume:xM.nullish()}),TM=bu(j([w({type:T("boolean"),value:Ne()}),w({value:ff})]),w({_meta:k(p(),_()).nullish(),configId:sw,sessionId:te})),$M=w({_meta:k(p(),_()).nullish(),configOptions:M(no)}),CM=w({_meta:k(p(),_()).nullish(),modeId:Su,sessionId:te}),IM=w({_meta:k(p(),_()).nullish()}),RM=w({_meta:k(p(),_()).nullish(),modelId:pf,sessionId:te}),PM=w({_meta:k(p(),_()).nullish()}),LM=w({_meta:k(p(),_()).nullish(),sessionId:te}),DM=j([T("end_turn"),T("max_tokens"),T("max_turn_requests"),T("refusal"),T("cancelled")]),MM=j([T("email"),T("uri"),T("date"),T("date-time")]),zM=w({default:p().nullish(),description:p().nullish(),enum:M(p()).nullish(),format:MM.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(q0).nullish(),pattern:p().nullish(),title:p().nullish()}),OM=w({_meta:k(p(),_()).nullish(),context:D6.nullish(),position:gr,selection:to.nullish(),sessionId:te,triggerKind:g6,uri:p(),version:B()}),NM=w({_meta:k(p(),_()).nullish(),suggestions:M(O6)}),UM=w({_meta:k(p(),_()).nullish(),terminalId:p()}),FM=w({_meta:k(p(),_()).nullish(),exitCode:B().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:p().nullish()}),hw=w({_meta:k(p(),_()).nullish(),sessionId:te,terminalId:p()}),HM=w({_meta:k(p(),_()).nullish(),exitStatus:FM.nullish(),output:p(),truncated:Ne()}),VM=w({_meta:k(p(),_()).nullish(),annotations:ml.nullish(),text:p()}),ZM=w({range:to.nullish(),text:p()}),BM=w({_meta:k(p(),_()).nullish(),contentChanges:M(ZM),sessionId:te,uri:p(),version:B()});w({method:p(),params:j([iM,cM,BM,aM,uM,lM,rM,pM,J0]).nullish()});const WM=j([T("full"),T("incremental")]),jM=w({_meta:k(p(),_()).nullish(),syncKind:WM}),GM=w({_meta:k(p(),_()).nullish(),didChange:jM.nullish(),didClose:KD.nullish(),didFocus:JD.nullish(),didOpen:XD.nullish(),didSave:QD.nullish()}),qM=w({_meta:k(p(),_()).nullish(),document:GM.nullish()}),YM=w({_meta:k(p(),_()).nullish(),context:v6.nullish(),events:qM.nullish()}),KM=w({_meta:k(p(),_()).nullish(),auth:FD.optional().default({}),loadSession:Ne().optional().default(!1),mcpCapabilities:ZD.optional().default({http:!1,sse:!1}),nes:YM.nullish(),positionEncoding:rw.nullish(),promptCapabilities:I6.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:AM.optional().default({})}),JM=w({_meta:k(p(),_()).nullish(),agentCapabilities:KM.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:tw.nullish(),authMethods:M(pD).optional().default([]),protocolVersion:iw}),XM=w({_meta:k(p(),_()).nullish(),mimeType:p().nullish(),text:p(),uri:p()}),QM=j([XM,mD]),ez=w({_meta:k(p(),_()).nullish(),annotations:ml.nullish(),resource:QM}),gf=j([VM.and(w({type:T("text")})),V6.and(w({type:T("image")})),H6.and(w({type:T("audio")})),Z6.and(w({type:T("resource_link")})),ez.and(w({type:T("resource")}))]),tz=w({_meta:k(p(),_()).nullish(),content:gf}),kh=w({_meta:k(p(),_()).nullish(),content:gf,messageId:p().nullish()}),nz=w({_meta:k(p(),_()).nullish(),messageId:p().nullish(),prompt:M(gf),sessionId:te}),rz=w({anyOf:M(q0)}),dw=j([tz.and(w({type:T("content")})),_D.and(w({type:T("diff")})),UM.and(w({type:T("terminal")}))]),pw=p(),fw=w({_meta:k(p(),_()).nullish(),line:B().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:p()}),gw=j([T("pending"),T("in_progress"),T("completed"),T("failed")]),mw=j([T("read"),T("edit"),T("delete"),T("move"),T("search"),T("execute"),T("think"),T("fetch"),T("switch_mode"),T("other")]),iz=w({_meta:k(p(),_()).nullish(),content:M(dw).optional(),kind:mw.optional(),locations:M(fw).optional(),rawInput:_().optional(),rawOutput:_().optional(),status:gw.optional(),title:p(),toolCallId:pw}),vw=w({_meta:k(p(),_()).nullish(),content:M(dw).nullish(),kind:mw.nullish(),locations:M(fw).nullish(),rawInput:_().optional(),rawOutput:_().optional(),status:gw.nullish(),title:p().nullish(),toolCallId:pw}),yw=w({_meta:k(p(),_()).nullish(),options:M(S6),sessionId:te,toolCall:vw}),sz=w({_meta:k(p(),_()).nullish(),hint:p()}),oz=sz,az=w({_meta:k(p(),_()).nullish(),description:p(),input:oz.nullish(),name:p()}),lz=w({_meta:k(p(),_()).nullish(),availableCommands:M(az)}),cz=w({enum:M(p()),type:ID}),uz=j([cz,rz]),hz=w({default:M(p()).nullish(),description:p().nullish(),items:uz,maxItems:B().nullish(),minItems:B().nullish(),title:p().nullish()}),dz=j([zM.and(w({type:T("string")})),b6.and(w({type:T("number")})),zD.and(w({type:T("integer")})),vD.and(w({type:T("boolean")})),hz.and(w({type:T("array")}))]),pz=w({description:p().nullish(),properties:k(p(),dz).optional().default({}),required:M(p()).nullish(),title:p().nullish(),type:CD.optional().default("object")}),fz=w({requestedSchema:pz}),gz=bu(j([fz.and(w({mode:T("form")})),LD.and(w({mode:T("url")}))]),w({_meta:k(p(),_()).nullish(),message:p(),sessionId:te})),mz=w({cachedReadTokens:B().nullish(),cachedWriteTokens:B().nullish(),inputTokens:B(),outputTokens:B(),thoughtTokens:B().nullish(),totalTokens:B()}),vz=w({_meta:k(p(),_()).nullish(),stopReason:DM,usage:mz.nullish(),userMessageId:p().nullish()});j([w({id:bi,result:j([JM,gD,VD,kM,_M,mM,SM,EM,bD,IM,$M,vz,PM,LM,NM,yD,Q0])}),w({error:K0,id:bi})]);const yz=w({_meta:k(p(),_()).nullish(),cost:wD.nullish(),size:B(),used:B()}),bz=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")})),iz.and(w({sessionUpdate:T("tool_call")})),vw.and(w({sessionUpdate:T("tool_call_update")})),x6.and(w({sessionUpdate:T("plan")})),lz.and(w({sessionUpdate:T("available_commands_update")})),bM.and(w({sessionUpdate:T("current_mode_update")})),tM.and(w({sessionUpdate:T("config_option_update")})),vM.and(w({sessionUpdate:T("session_info_update")})),yz.and(w({sessionUpdate:T("usage_update")}))]),bw=w({_meta:k(p(),_()).nullish(),sessionId:te,update:bz});w({method:p(),params:j([bw,TD,J0]).nullish()});const ww=w({_meta:k(p(),_()).nullish(),sessionId:te,terminalId:p()}),wz=w({_meta:k(p(),_()).nullish(),exitCode:B().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:p().nullish()}),Sz=w({name:p(),uri:p()}),_z=w({_meta:k(p(),_()).nullish(),repository:h6.nullish(),workspaceFolders:M(Sz).nullish(),workspaceUri:p().nullish()});w({id:bi,method:p(),params:j([R6,fD,HD,y6,dM,ND,hM,fM,oM,CM,TM,nz,RM,_z,OM,sM,X0]).nullish()});const Sw=w({_meta:k(p(),_()).nullish(),content:p(),path:p(),sessionId:te});w({id:bi,method:p(),params:j([Sw,cw,yw,aw,hw,uw,ww,lw,gz,X0]).nullish()});const kz=w({_meta:k(p(),_()).nullish()});j([w({id:bi,result:j([kz,N6,j6,SD,HM,U6,wz,OD,$D,Q0])}),w({error:K0,id:bi})]);var Q;class Ez{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 En.fs_write_text_file:{const x=Sw.parse(a);return(c=r.writeTextFile)==null?void 0:c.call(r,x)}case En.fs_read_text_file:{const x=cw.parse(a);return(u=r.readTextFile)==null?void 0:u.call(r,x)}case En.session_request_permission:{const x=yw.parse(a);return r.requestPermission(x)}case En.terminal_create:{const x=aw.parse(a);return(h=r.createTerminal)==null?void 0:h.call(r,x)}case En.terminal_output:{const x=hw.parse(a);return(f=r.terminalOutput)==null?void 0:f.call(r,x)}case En.terminal_release:{const x=uw.parse(a);return await((v=r.releaseTerminal)==null?void 0:v.call(r,x))??{}}case En.terminal_wait_for_exit:{const x=ww.parse(a);return(y=r.waitForTerminalExit)==null?void 0:y.call(r,x)}case En.terminal_kill:{const x=lw.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 En.session_update:{const c=bw.parse(a);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(o,a);throw Le.methodNotFound(o)}};m(this,Q,new xz(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,nn,ca,ve,_w,ud,kw,Ew,xw,Aw,hd,Eo;class xz{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,nn,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,nn).signal.addEventListener("abort",()=>i())})),d(this,ve,_w).call(this)}get signal(){return l(this,nn).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,nn=new WeakMap,ca=new WeakMap,ve=new WeakSet,_w=async function(){let t;try{const e=l(this,cs).readable.getReader();try{for(;!l(this,nn).signal.aborted;){const{value:r,done:i}=await e.read();if(i)break;if(r)try{d(this,ve,kw).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,nn).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,nn).abort(e)},kw=async function(t){if("method"in t&&"id"in t){const e=await d(this,ve,Ew).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,xw).call(this,t.method,t.params);"error"in e&&console.error("Error handling notification",t,e.error)}else"id"in t?d(this,ve,Aw).call(this,t):console.error("Invalid message",{message:t})},Ew=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 cv)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()}}},xw=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 cv)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()}}},Aw=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,nn).signal.aborted)throw l(this,nn).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 Az=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,Tz=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,$z=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,Cz=/\b(tv|television|screen|artifact|artifacts|viewer|filmstrip|layout|focus)\b/i,Iz=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,Rz="single_session",Pz={name:"television-acp-client",version:"0.0.0"},Tw="agent:main:television",Lz=gl(It);var hs,rn,pt,sn,tr,Mt,Pn,on,an,nr,zt,ds,ps,ln,et,Ln,fs,Kr,Dn,rr,ua,Ot,cn,Uc,un,$,dd,$w,Cw,Iw,rc,Rw,Pw,Lw,Dw,Mw,zw,Ow,Rr,ji,Gi,An,Nw,qi,pd,fd,ic,Uw,sc,gd,md,ha,da,oc,Yi,vd,Fw;class Dz extends Lz{constructor(e){super();b(this,$);b(this,hs,"disconnected");b(this,rn,null);b(this,pt,new Map);b(this,sn,null);b(this,tr,null);b(this,Mt,null);b(this,Pn,null);b(this,on,null);b(this,an,null);b(this,nr);b(this,zt,null);b(this,ds,0);b(this,ps,1);b(this,ln,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,cn);b(this,Uc,e=>{d(this,$,Cw).call(this,e)});b(this,un,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,cn,e.sessionMode??Rz),m(this,nr,e.mappedSessionStore??Mz()),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,rn,null),d(this,$,An).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,rn,null),m(this,tr,d(this,$,$w).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,rn,null),d(this,$,An).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,on)===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,$,An).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,$,Nw).call(this,r)}]});d(this,$,Rr).call(this,i.stopReason==="cancelled"?"cancelled":"final"),d(this,$,An).call(this,"ready")}catch(i){throw d(this,$,Fw).call(this)||(d(this,$,Rr).call(this,"error"),d(this,$,An).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,an))==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,on,null),m(this,zt,null),d(this,$,vd).call(this)}async cancel(){this.status==="running"&&(d(this,$,An).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,cn)==="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,sn)&&this.status==="ready"&&d(this,$,rc).call(this).catch(c=>{d(this,$,Yi).call(this,Eh(c))}))}}hs=new WeakMap,rn=new WeakMap,pt=new WeakMap,sn=new WeakMap,tr=new WeakMap,Mt=new WeakMap,Pn=new WeakMap,on=new WeakMap,an=new WeakMap,nr=new WeakMap,zt=new WeakMap,ds=new WeakMap,ps=new WeakMap,ln=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,cn=new WeakMap,Uc=new WeakMap,un=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,rn)??"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,rn)??"ACPClient is disconnected")))};this.addEventListener("status-changed",o)})}},$w=async function(){try{const{stream:e,socket:r,metadata:i}=await Uz({serverURL:l(this,Ot).serverURL,token:l(this,Ot).token,createSocket:l(this,ua),onDisconnect:l(this,Uc)});m(this,an,i),m(this,un,r),r.addEventListener("close",l(this,ha)),r.addEventListener("error",l(this,da)),m(this,sn,new Ez(s=>({connection:s,sessionUpdate:async o=>{await d(this,$,Pw).call(this,o)},requestPermission:async o=>d(this,$,Lw).call(this,o)}),e)),await l(this,sn).initialize({protocolVersion:aD,clientCapabilities:{},clientInfo:Pz})}catch(e){throw e}},Cw=function(e){d(this,$,Yi).call(this,Eh(e))},Iw=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,$,Rw).call(this,e)),await l(this,Mt)},Rw=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,$,Uw).call(this),mcpServers:[],_meta:{sessionKey:e}};try{if(m(this,Kr,!0),m(this,Dn,null),((c=l(this,an))==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(zz(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,$,Iw).call(this,o),await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),m(this,on,i),m(this,zt,e),m(this,fs,!0),s?(l(this,rr).add(e),l(this,cn)==="single_session"&&m(this,Ln,!1)):(l(this,rr).delete(e),m(this,Ln,l(this,cn)==="single_session")),m(this,rn,null),d(this,$,An).call(this,"ready")},Pw=async function(e){const r=e.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&d(this,$,Ow).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&d(this,$,Dw).call(this,r.content.text);return;case"tool_call":d(this,$,Mw).call(this,r);return;case"tool_call_update":d(this,$,zw).call(this,r);return;case"agent_thought_chunk":return;default:return}},Lw=async function(e){return{outcome:{outcome:"cancelled"}}},Dw=function(e){m(this,Dn,null);const r=Nz(e);if(!r)return;if(!l(this,ln)){const s={id:d(this,$,qi).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};m(this,ln,s.id),d(this,$,ji).call(this,s);return}const i=l(this,pt).get(l(this,ln));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"})},Mw=function(e){d(this,$,Rr).call(this,"final");const r=d(this,$,pd).call(this,e.toolCallId),i=wv("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)},zw=function(e){const r=d(this,$,pd).call(this,e.toolCallId),i=(r==null?void 0:r.text)??"",s=wv(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)},Ow=function(e){if(d(this,$,Rr).call(this,"final"),!e)return;const r=l(this,Kr)?l(this,Dn):null;if(!r){const s=bv(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:bv(`${i.text}${e}`)})},Rr=function(e){if(!l(this,ln))return;const r=l(this,pt).get(l(this,ln));(r==null?void 0:r.kind)==="assistant"&&d(this,$,Gi).call(this,{...r,status:e}),m(this,ln,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"))},An=function(e){l(this,hs)!==e&&(m(this,hs,e),this.dispatchEvent(new X$("status-changed")))},Nw=function(e){const r=l(this,zt);if(!r)return e;const i=l(this,et)?l(this,cn)==="single_session"?l(this,Ln)||!l(this,rr).has(r):!l(this,rr).has(r):!1,s=l(this,fs)&&(l(this,et)!==null||Cz.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,on))throw new Error("ACP session is not ready");return l(this,on)},ic=function(){if(!l(this,sn))throw new Error("ACP connection is not ready");return l(this,sn)},Uw=function(){var r;const e=(r=l(this,an))==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,cn)==="single_session")return d(this,$,md).call(this,`${Tw}-${(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,Oz(l(this,cn),e,l(this,Ot).clientGUID??"default-client"))},md=function(e){var r;return((r=l(this,an))==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,sn,null),m(this,tr,null),m(this,Mt,null),m(this,Pn,null),m(this,on,null),m(this,zt,null),m(this,an,null),l(this,un)&&(l(this,un).removeEventListener("close",l(this,ha)),l(this,un).removeEventListener("error",l(this,da)),l(this,un).close(),m(this,un,null))},Yi=function(e){const r=l(this,sn)!==null||l(this,tr)!==null||l(this,Mt)!==null||l(this,Pn)!==null||l(this,on)!==null||l(this,zt)!==null||l(this,an)!==null||l(this,un)!==null;this.disposed||this.status==="disconnected"&&!r||(d(this,$,Rr).call(this,"error"),d(this,$,oc).call(this),m(this,rn,e??null),d(this,$,An).call(this,"disconnected"))},vd=function(){const e=l(this,pt).size>0;m(this,ln,null),m(this,Dn,null),m(this,ps,1),l(this,pt).clear(),e&&this.dispatchEvent(new yh("messages-changed"))},Fw=function(){return this.status==="disconnected"};function Mz(){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 zz(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function Oz(n,t,e){return n==="single_session"?`${Tw}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function Hw(n){return n.replace(/^(?:\s*\n)+/,"")}function bv(n){let t=n;return t=t.replace(Az,""),t=t.replace(Tz,""),t=t.replace($z,""),t=Hw(t),t}function Nz(n){let t=n;return t=t.replace(Iz,""),t=Hw(t),t}function wv(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function Uz(n){const t=n.createSocket(Vz(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=Hz(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=Fz(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 Fz(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 Hz(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 Vz(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 Sv="television.acpClientGUID",_v="television.acpMappedSessions",kv=1;var gs;class Zz{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 Bz{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(_v);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!==kv?{}: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:kv,entries:t};l(this,ms).setItem(_v,JSON.stringify(e))};function Vw(){return typeof window>"u"?null:window.localStorage}function Wz(n){const t=n.getItem(Sv);if(t)return t;const e=fu().toLowerCase();return n.setItem(Sv,e),e}const Ev=4401,jz=401,Hl=1e3,Gz=3e4;class Oo extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class Zw 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 xC(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 Bz(e.acpStorage,this.url):new Zz);this.acpClient=new Dz({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?iD({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,Zb(e.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(e.screenID);r&&(r.layout=Lb(r.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"screen-changed":case"theme-changed":case"artifact-focus":break;default:return qz(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(Yz(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 Ib("server-reconnected",{serverURL:this.url}))}catch(v){if(tO(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=eO(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 Rb("server-status",{serverURL:this.url,message:E})),x?this.navigationPending()||h():C&&this.dispatchEvent(new ie("change"));return}if(!Qz(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=Kz(f);if(!a){u(v===Ev?new Oo:new Error("Connection closed before initialization"));return}if(v===Ev){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,Gz),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:pC,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 qz(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function Yz(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 rD(e))r.searchParams.set(i,s);return r.hash="",r.toString()}function Kz(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}const Jz={"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},Xz=new Set(Object.keys(Jz));function Qz(n){return Xz.has(n)}function eO(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 tO(n){return n instanceof sf&&n.status===jz}const nO="Local";var fa,bd;class rO 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?Vw():e.acpStorage;this.acpStorage=r,this.clientGUID=e.clientGUID??(r?Wz(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 Ib("server-reconnected",{serverURL:h.serverURL}))},u=h=>{this.dispatchEvent(new Rb("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(UC(this.localStore.get(),e,r))}clearStoredAuthToken(e){const r=this.localStore.get(),i=FC(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:nO}]})}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 Zw({url:e.url,name:e.name,token:e.token,createSocket:this.createSocket,clientGUID:this.clientGUID,acpStorage:this.acpStorage,telemetryMeta:this.telemetryMeta})};var ga;class iO extends It{constructor(){super();b(this,ga,e=>{const r=sO(e);r!==null&&(e.preventDefault(),this.dispatchEvent(new J$("shortcut-triggered",{shortcut:r})))});document.addEventListener("keydown",l(this,ga))}dispose(){document.removeEventListener("keydown",l(this,ga))}}ga=new WeakMap;function sO(n){for(const[t,e]of Object.entries(AC))if(oO(n,e.trigger))return t;return null}function oO(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",xv=100,aO=1e3,lO=60,cO=60,uO=24,hO=30,dO=hO*uO*cO*lO*aO;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,Bw,Gn,Ww,Sd,_d;class pO 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,Bw).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,Bw=function(){const e=localStorage.getItem(l(this,Ae,_d));if(e!==null)try{const r=JSON.parse(e);if(!jw(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,Ww).call(this)))}catch(e){if(!mO(e))throw e}this.dispatchEvent(new ie("change"))},Ww=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<=xv)return;const e=l(this,de).length-xv;m(this,de,l(this,de).slice(e)),m(this,oe,Math.max(-1,l(this,oe)-e))},_d=function(){return fO(l(this,ma))};function fO(n){return`${wd}${n}`}function gO(n){const t=Date.now()-dO,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(!jw(a)){e.push(i);continue}!n.has(s)&&a.lastWritten<t&&e.push(i)}for(const r of e)localStorage.removeItem(r)}function mO(n){return n instanceof DOMException&&n.name==="QuotaExceededError"}function jw(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 vO="0.1.186";function mf(n=vO){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 yO(n){return n.originMatch?n.marker!==null&&n.bundleVersion===n.serverVersion?{action:"signal-autoreloaded",fromVersion:n.marker.fromVersion,toVersion:n.bundleVersion}:CC(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 bO(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 wO(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=yO({bundleVersion:i,serverVersion:u.message.version,originMatch:u.serverURL===n.primaryServerURL,marker:bO(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 SO(n){const t=Wt(n.search),e=W0(n.search),r=e!==null&&of(e)?e:null;return{electron:t,shellVersion:r}}function _O(n){return!n.electron||n.requiredDesktopVersion===null||!of(n.requiredDesktopVersion)?!1:n.shellVersion===null?!0:n.shellVersion===nd?!1:jb(n.requiredDesktopVersion,n.shellVersion)}const kO=`# 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,on))throw new Error("ACP session is not ready");return l(this,on)},ic=function(){if(!l(this,sn))throw new Error("ACP connection is not ready");return l(this,sn)},Uw=function(){var r;const e=(r=l(this,an))==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,cn)==="single_session")return d(this,$,md).call(this,`${Tw}-${(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,Oz(l(this,cn),e,l(this,Ot).clientGUID??"default-client"))},md=function(e){var r;return((r=l(this,an))==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,sn,null),m(this,tr,null),m(this,Mt,null),m(this,Pn,null),m(this,on,null),m(this,zt,null),m(this,an,null),l(this,un)&&(l(this,un).removeEventListener("close",l(this,ha)),l(this,un).removeEventListener("error",l(this,da)),l(this,un).close(),m(this,un,null))},Yi=function(e){const r=l(this,sn)!==null||l(this,tr)!==null||l(this,Mt)!==null||l(this,Pn)!==null||l(this,on)!==null||l(this,zt)!==null||l(this,an)!==null||l(this,un)!==null;this.disposed||this.status==="disconnected"&&!r||(d(this,$,Rr).call(this,"error"),d(this,$,oc).call(this),m(this,rn,e??null),d(this,$,An).call(this,"disconnected"))},vd=function(){const e=l(this,pt).size>0;m(this,ln,null),m(this,Dn,null),m(this,ps,1),l(this,pt).clear(),e&&this.dispatchEvent(new yh("messages-changed"))},Fw=function(){return this.status==="disconnected"};function Mz(){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 zz(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function Oz(n,t,e){return n==="single_session"?`${Tw}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function Hw(n){return n.replace(/^(?:\s*\n)+/,"")}function bv(n){let t=n;return t=t.replace(Az,""),t=t.replace(Tz,""),t=t.replace($z,""),t=Hw(t),t}function Nz(n){let t=n;return t=t.replace(Iz,""),t=Hw(t),t}function wv(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function Uz(n){const t=n.createSocket(Vz(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=Hz(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=Fz(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 Fz(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 Hz(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 Vz(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 Sv="television.acpClientGUID",_v="television.acpMappedSessions",kv=1;var gs;class Zz{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 Bz{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(_v);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!==kv?{}: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:kv,entries:t};l(this,ms).setItem(_v,JSON.stringify(e))};function Vw(){return typeof window>"u"?null:window.localStorage}function Wz(n){const t=n.getItem(Sv);if(t)return t;const e=fu().toLowerCase();return n.setItem(Sv,e),e}const Ev=4401,jz=401,Hl=1e3,Gz=3e4;class Oo extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class Zw 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 xC(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 Bz(e.acpStorage,this.url):new Zz);this.acpClient=new Dz({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?iD({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,Zb(e.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(e.screenID);r&&(r.layout=Lb(r.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"screen-changed":case"theme-changed":case"artifact-focus":break;default:return qz(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(Yz(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 Ib("server-reconnected",{serverURL:this.url}))}catch(v){if(tO(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=eO(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 Rb("server-status",{serverURL:this.url,message:E})),x?this.navigationPending()||h():C&&this.dispatchEvent(new ie("change"));return}if(!Qz(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=Kz(f);if(!a){u(v===Ev?new Oo:new Error("Connection closed before initialization"));return}if(v===Ev){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,Gz),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:pC,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 qz(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function Yz(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 rD(e))r.searchParams.set(i,s);return r.hash="",r.toString()}function Kz(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}const Jz={"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},Xz=new Set(Object.keys(Jz));function Qz(n){return Xz.has(n)}function eO(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 tO(n){return n instanceof sf&&n.status===jz}const nO="Local";var fa,bd;class rO 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?Vw():e.acpStorage;this.acpStorage=r,this.clientGUID=e.clientGUID??(r?Wz(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 Ib("server-reconnected",{serverURL:h.serverURL}))},u=h=>{this.dispatchEvent(new Rb("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(UC(this.localStore.get(),e,r))}clearStoredAuthToken(e){const r=this.localStore.get(),i=FC(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:nO}]})}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 Zw({url:e.url,name:e.name,token:e.token,createSocket:this.createSocket,clientGUID:this.clientGUID,acpStorage:this.acpStorage,telemetryMeta:this.telemetryMeta})};var ga;class iO extends It{constructor(){super();b(this,ga,e=>{const r=sO(e);r!==null&&(e.preventDefault(),this.dispatchEvent(new J$("shortcut-triggered",{shortcut:r})))});document.addEventListener("keydown",l(this,ga))}dispose(){document.removeEventListener("keydown",l(this,ga))}}ga=new WeakMap;function sO(n){for(const[t,e]of Object.entries(AC))if(oO(n,e.trigger))return t;return null}function oO(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",xv=100,aO=1e3,lO=60,cO=60,uO=24,hO=30,dO=hO*uO*cO*lO*aO;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,Bw,Gn,Ww,Sd,_d;class pO 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,Bw).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,Bw=function(){const e=localStorage.getItem(l(this,Ae,_d));if(e!==null)try{const r=JSON.parse(e);if(!jw(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,Ww).call(this)))}catch(e){if(!mO(e))throw e}this.dispatchEvent(new ie("change"))},Ww=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<=xv)return;const e=l(this,de).length-xv;m(this,de,l(this,de).slice(e)),m(this,oe,Math.max(-1,l(this,oe)-e))},_d=function(){return fO(l(this,ma))};function fO(n){return`${wd}${n}`}function gO(n){const t=Date.now()-dO,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(!jw(a)){e.push(i);continue}!n.has(s)&&a.lastWritten<t&&e.push(i)}for(const r of e)localStorage.removeItem(r)}function mO(n){return n instanceof DOMException&&n.name==="QuotaExceededError"}function jw(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 vO="0.1.187";function mf(n=vO){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 yO(n){return n.originMatch?n.marker!==null&&n.bundleVersion===n.serverVersion?{action:"signal-autoreloaded",fromVersion:n.marker.fromVersion,toVersion:n.bundleVersion}:CC(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 bO(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 wO(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=yO({bundleVersion:i,serverVersion:u.message.version,originMatch:u.serverURL===n.primaryServerURL,marker:bO(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 SO(n){const t=Wt(n.search),e=W0(n.search),r=e!==null&&of(e)?e:null;return{electron:t,shellVersion:r}}function _O(n){return!n.electron||n.requiredDesktopVersion===null||!of(n.requiredDesktopVersion)?!1:n.shellVersion===null?!0:n.shellVersion===nd?!1:jb(n.requiredDesktopVersion,n.shellVersion)}const kO=`# 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:
@@ -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-DW472eVb.js"></script>
8
+ <script type="module" crossorigin src="./assets/main-DRxP1qsF.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">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telepath-computer/television",
3
- "version": "0.1.186",
3
+ "version": "0.1.187",
4
4
  "type": "module",
5
5
  "main": "dist/cli.cjs",
6
6
  "bin": {