@telepath-computer/television 1.5.1 → 1.5.2

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
@@ -54259,7 +54259,7 @@ function disabledTelemetryRuntime() {
54259
54259
 
54260
54260
  // ../server/src/updates/version.ts
54261
54261
  function readVersionStamp() {
54262
- if ("1.5.1".length > 0) return "1.5.1";
54262
+ if ("1.5.2".length > 0) return "1.5.2";
54263
54263
  return void 0;
54264
54264
  }
54265
54265
  function resolveUpdateReleaseVersion(env = process.env, stamp = readVersionStamp()) {
@@ -56683,8 +56683,8 @@ var Server = class {
56683
56683
  };
56684
56684
  };
56685
56685
  function readServerPackageVersion() {
56686
- if ("1.5.1".length > 0) {
56687
- return telemetryVersion("1.5.1");
56686
+ if ("1.5.2".length > 0) {
56687
+ return telemetryVersion("1.5.2");
56688
56688
  }
56689
56689
  const packageJsonPath = import_node_path17.default.resolve(import_node_path17.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url)), "..", "package.json");
56690
56690
  if (!(0, import_node_fs13.existsSync)(packageJsonPath)) return telemetryVersion("0.0.0");
@@ -59227,8 +59227,8 @@ function resolveVercelSkillsInstallerBin() {
59227
59227
  return localRequire.resolve("skills/bin/cli.mjs");
59228
59228
  }
59229
59229
  function readCLIVersion() {
59230
- if ("1.5.1".length > 0) {
59231
- return "1.5.1";
59230
+ if ("1.5.2".length > 0) {
59231
+ return "1.5.2";
59232
59232
  }
59233
59233
  const devPackageJsonPath = import_node_path24.default.join(getDevPackageDir(), "package.json");
59234
59234
  if (!(0, import_node_fs20.existsSync)(devPackageJsonPath)) {
@@ -62,7 +62,7 @@ var A4=Object.defineProperty;var Zv=n=>{throw TypeError(n)};var E4=(n,t,e)=>t in
62
62
  `)}v.write("payload.value = newResult;"),v.write("return payload;");const O=v.compile();return(P,B)=>O(y,P,B)};let s;const a=eu,l=!X8.jitless,u=l&&$T.value,f=t.catchall;let p;n._zod.parse=(y,v)=>{p??(p=r.value);const S=y.value;return a(S)?l&&u&&(v==null?void 0:v.async)===!1&&v.jitless!==!0?(s||(s=i(t.shape)),y=s(y,v),f?m6([],S,y,v,p,n):y):e(y,v):(y.issues.push({expected:"object",code:"invalid_type",input:S,inst:n}),y)}});function E2(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=>!Ma(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(a=>Is(a,r,Rs())))}),t)}const g6=I("$ZodUnion",(n,t)=>{Ue.init(n,t),Ae(n._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Ae(n._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Ae(n._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),Ae(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=>tv(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 a=!1;const l=[];for(const c of t.options){const u=c._zod.run({value:i.value,issues:[]},s);if(u instanceof Promise)l.push(u),a=!0;else{if(u.issues.length===0)return u;l.push(u)}}return a?Promise.all(l).then(c=>E2(c,i,n,s)):E2(l,i,n,s)}}),gR=I("$ZodDiscriminatedUnion",(n,t)=>{t.inclusive=!1,g6.init(n,t);const e=n._zod.parse;Ae(n._zod,"propValues",()=>{const i={};for(const s of t.options){const a=s._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[l,c]of Object.entries(a)){i[l]||(i[l]=new Set);for(const u of c)i[l].add(u)}}return i});const r=qf(()=>{var a;const i=t.options,s=new Map;for(const l of i){const c=(a=l._zod.propValues)==null?void 0:a[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(l)}"`);for(const u of c){if(s.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);s.set(u,l)}}return s});n._zod.parse=(i,s)=>{const a=i.value;if(!eu(a))return i.issues.push({code:"invalid_type",expected:"object",input:a,inst:n}),i;const l=r.value.get(a==null?void 0:a[t.discriminator]);return l?l._zod.run(i,s):t.unionFallback?e(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:n}),i)}}),vR=I("$ZodIntersection",(n,t)=>{Ue.init(n,t),n._zod.parse=(e,r)=>{const i=e.value,s=t.left._zod.run({value:i,issues:[]},r),a=t.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||a instanceof Promise?Promise.all([s,a]).then(([c,u])=>k2(e,c,u)):k2(e,s,a)}});function tg(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(Fl(n)&&Fl(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 a=tg(n[s],t[s]);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};i[s]=a.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],a=tg(i,s);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};e.push(a.data)}return{valid:!0,data:e}}return{valid:!1,mergeErrorPath:[]}}function k2(n,t,e){const r=new Map;let i;for(const l of t.issues)if(l.code==="unrecognized_keys"){i??(i=l);for(const c of l.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else n.issues.push(l);for(const l of e.issues)if(l.code==="unrecognized_keys")for(const c of l.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else n.issues.push(l);const s=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(s.length&&i&&n.issues.push({...i,keys:s}),Ma(n))return n;const a=tg(t.value,e.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return n.value=a.data,n}const yR=I("$ZodRecord",(n,t)=>{Ue.init(n,t),n._zod.parse=(e,r)=>{const i=e.value;if(!Fl(i))return e.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),e;const s=[],a=t.keyType._zod.values;if(a){e.value={};const l=new Set;for(const u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){l.add(typeof u=="number"?u.toString():u);const f=t.valueType._zod.run({value:i[u],issues:[]},r);f instanceof Promise?s.push(f.then(p=>{p.issues.length&&e.issues.push(...Na(u,p.issues)),e.value[u]=p.value})):(f.issues.length&&e.issues.push(...Na(u,f.issues)),e.value[u]=f.value)}let c;for(const u in i)l.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 l of Reflect.ownKeys(i)){if(l==="__proto__")continue;let c=t.keyType._zod.run({value:l,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof l=="string"&&l6.test(l)&&c.issues.length){const p=t.keyType._zod.run({value:Number(l),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(c=p)}if(c.issues.length){t.mode==="loose"?e.value[l]=i[l]:e.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(p=>Is(p,r,Rs())),input:l,path:[l],inst:n});continue}const f=t.valueType._zod.run({value:i[l],issues:[]},r);f instanceof Promise?s.push(f.then(p=>{p.issues.length&&e.issues.push(...Na(l,p.issues)),e.value[c.value]=p.value})):(f.issues.length&&e.issues.push(...Na(l,f.issues)),e.value[c.value]=f.value)}}return s.length?Promise.all(s).then(()=>e):e}}),wR=I("$ZodEnum",(n,t)=>{Ue.init(n,t);const e=Q8(t.entries),r=new Set(e);n._zod.values=r,n._zod.pattern=new RegExp(`^(${e.filter(i=>xT.has(typeof i)).map(i=>typeof i=="string"?ql(i):i.toString()).join("|")})$`),n._zod.parse=(i,s)=>{const a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:e,input:a,inst:n}),i}}),bR=I("$ZodLiteral",(n,t)=>{if(Ue.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"?ql(r):r?ql(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}}),SR=I("$ZodTransform",(n,t)=>{Ue.init(n,t),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new K8(n.constructor.name);const i=t.transform(e.value,e);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(a=>(e.value=a,e));if(i instanceof Promise)throw new Za;return e.value=i,e}});function T2(n,t){return n.issues.length&&t===void 0?{issues:[],value:void 0}:n}const v6=I("$ZodOptional",(n,t)=>{Ue.init(n,t),n._zod.optin="optional",n._zod.optout="optional",Ae(n._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ae(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${tv(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=>T2(s,e.value)):T2(i,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,r)}}),_R=I("$ZodExactOptional",(n,t)=>{v6.init(n,t),Ae(n._zod,"values",()=>t.innerType._zod.values),Ae(n._zod,"pattern",()=>t.innerType._zod.pattern),n._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),AR=I("$ZodNullable",(n,t)=>{Ue.init(n,t),Ae(n._zod,"optin",()=>t.innerType._zod.optin),Ae(n._zod,"optout",()=>t.innerType._zod.optout),Ae(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${tv(e.source)}|null)$`):void 0}),Ae(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)}),ER=I("$ZodDefault",(n,t)=>{Ue.init(n,t),n._zod.optin="optional",Ae(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=>C2(s,t)):C2(i,t)}});function C2(n,t){return n.value===void 0&&(n.value=t.defaultValue),n}const kR=I("$ZodPrefault",(n,t)=>{Ue.init(n,t),n._zod.optin="optional",Ae(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))}),TR=I("$ZodNonOptional",(n,t)=>{Ue.init(n,t),Ae(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=>R2(s,n)):R2(i,n)}});function R2(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 CR=I("$ZodCatch",(n,t)=>{Ue.init(n,t),Ae(n._zod,"optin",()=>t.innerType._zod.optin),Ae(n._zod,"optout",()=>t.innerType._zod.optout),Ae(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(a=>Is(a,r,Rs()))},input:e.value}),e.issues=[]),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(s=>Is(s,r,Rs()))},input:e.value}),e.issues=[]),e)}}),RR=I("$ZodPipe",(n,t)=>{Ue.init(n,t),Ae(n._zod,"values",()=>t.in._zod.values),Ae(n._zod,"optin",()=>t.in._zod.optin),Ae(n._zod,"optout",()=>t.out._zod.optout),Ae(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(a=>Zh(a,t.in,r)):Zh(s,t.in,r)}const i=t.in._zod.run(e,r);return i instanceof Promise?i.then(s=>Zh(s,t.out,r)):Zh(i,t.out,r)}});function Zh(n,t,e){return n.issues.length?(n.aborted=!0,n):t._zod.run({value:n.value,issues:n.issues},e)}const IR=I("$ZodReadonly",(n,t)=>{Ue.init(n,t),Ae(n._zod,"propValues",()=>t.innerType._zod.propValues),Ae(n._zod,"values",()=>t.innerType._zod.values),Ae(n._zod,"optin",()=>{var e,r;return(r=(e=t.innerType)==null?void 0:e._zod)==null?void 0:r.optin}),Ae(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(I2):I2(i)}});function I2(n){return n.value=Object.freeze(n.value),n}const $R=I("$ZodCustom",(n,t)=>{Jt.init(n,t),Ue.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=>$2(s,e,r,n));$2(i,e,r,n)}});function $2(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(tu(i))}}var x2;class xR{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 PR(){return new xR}(x2=globalThis).__zod_globalRegistry??(x2.__zod_globalRegistry=PR());const $c=globalThis.__zod_globalRegistry;function DR(n,t){return new n({type:"string",...Y(t)})}function OR(n,t){return new n({type:"string",format:"email",check:"string_format",abort:!1,...Y(t)})}function P2(n,t){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...Y(t)})}function LR(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...Y(t)})}function MR(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Y(t)})}function NR(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Y(t)})}function zR(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Y(t)})}function HR(n,t){return new n({type:"string",format:"url",check:"string_format",abort:!1,...Y(t)})}function ZR(n,t){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...Y(t)})}function UR(n,t){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...Y(t)})}function FR(n,t){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...Y(t)})}function qR(n,t){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...Y(t)})}function VR(n,t){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...Y(t)})}function BR(n,t){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...Y(t)})}function jR(n,t){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...Y(t)})}function WR(n,t){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...Y(t)})}function GR(n,t){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...Y(t)})}function JR(n,t){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Y(t)})}function YR(n,t){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Y(t)})}function KR(n,t){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...Y(t)})}function XR(n,t){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...Y(t)})}function QR(n,t){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...Y(t)})}function e3(n,t){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...Y(t)})}function t3(n,t){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Y(t)})}function n3(n,t){return new n({type:"string",format:"date",check:"string_format",...Y(t)})}function r3(n,t){return new n({type:"string",format:"time",check:"string_format",precision:null,...Y(t)})}function i3(n,t){return new n({type:"string",format:"duration",check:"string_format",...Y(t)})}function s3(n,t){return new n({type:"number",checks:[],...Y(t)})}function o3(n,t){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...Y(t)})}function a3(n,t){return new n({type:"boolean",...Y(t)})}function l3(n){return new n({type:"unknown"})}function c3(n,t){return new n({type:"never",...Y(t)})}function D2(n,t){return new u6({check:"less_than",...Y(t),value:n,inclusive:!1})}function Cm(n,t){return new u6({check:"less_than",...Y(t),value:n,inclusive:!0})}function O2(n,t){return new h6({check:"greater_than",...Y(t),value:n,inclusive:!1})}function Rm(n,t){return new h6({check:"greater_than",...Y(t),value:n,inclusive:!0})}function L2(n,t){return new EC({check:"multiple_of",...Y(t),value:n})}function y6(n,t){return new TC({check:"max_length",...Y(t),maximum:n})}function Dd(n,t){return new CC({check:"min_length",...Y(t),minimum:n})}function w6(n,t){return new RC({check:"length_equals",...Y(t),length:n})}function u3(n,t){return new IC({check:"string_format",format:"regex",...Y(t),pattern:n})}function h3(n){return new $C({check:"string_format",format:"lowercase",...Y(n)})}function d3(n){return new xC({check:"string_format",format:"uppercase",...Y(n)})}function f3(n,t){return new PC({check:"string_format",format:"includes",...Y(t),includes:n})}function p3(n,t){return new DC({check:"string_format",format:"starts_with",...Y(t),prefix:n})}function m3(n,t){return new OC({check:"string_format",format:"ends_with",...Y(t),suffix:n})}function ec(n){return new LC({check:"overwrite",tx:n})}function g3(n){return ec(t=>t.normalize(n))}function v3(){return ec(n=>n.trim())}function y3(){return ec(n=>n.toLowerCase())}function w3(){return ec(n=>n.toUpperCase())}function b3(){return ec(n=>IT(n))}function S3(n,t,e){return new n({type:"array",element:t,...Y(e)})}function _3(n,t,e){return new n({type:"custom",check:"custom",fn:t,...Y(e)})}function A3(n){const t=E3(e=>(e.addIssue=r=>{if(typeof r=="string")e.issues.push(tu(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(tu(i))}},n(e.value,e)));return t}function E3(n,t){const e=new Jt({check:"custom",...Y(t)});return e._zod.check=n,e}function b6(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)??$c,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 Xe(n,t,e={path:[],schemaPath:[]}){var f,p;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 a={schema:{},count:1,cycle:void 0,path:e.path};t.seen.set(n,a);const l=(p=(f=n._zod).toJSONSchema)==null?void 0:p.call(f);if(l)a.schema=l;else{const y={...e,schemaPath:[...e.schemaPath,n],path:e.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(t,a.schema,y);else{const S=a.schema,_=t.processors[i.type];if(!_)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);_(n,t,S,y)}const v=n._zod.parent;v&&(a.ref||(a.ref=v),Xe(v,t,y),t.seen.get(v).isParent=!0)}const c=t.metadataRegistry.get(n);return c&&Object.assign(a.schema,c),t.io==="input"&&At(n)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(n).schema}function S6(n,t){var a,l,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 f of n.seen.entries()){const p=(a=n.metadataRegistry.get(f[0]))==null?void 0:a.id;if(p){const y=r.get(p);if(y&&y!==f[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(p,f[0])}}const i=f=>{var _;const p=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const $=(_=n.external.registry.get(f[0]))==null?void 0:_.id,Z=n.external.uri??(z=>z);if($)return{ref:Z($)};const O=f[1].defId??f[1].schema.id??`schema${n.counter++}`;return f[1].defId=O,{defId:O,ref:`${Z("__shared")}#/${p}/${O}`}}if(f[1]===e)return{ref:"#"};const v=`#/${p}/`,S=f[1].schema.id??`__schema${n.counter++}`;return{defId:S,ref:v+S}},s=f=>{if(f[1].schema.$ref)return;const p=f[1],{ref:y,defId:v}=i(f);p.def={...p.schema},v&&(p.defId=v);const S=p.schema;for(const _ in S)delete S[_];S.$ref=y};if(n.cycles==="throw")for(const f of n.seen.entries()){const p=f[1];if(p.cycle)throw new Error(`Cycle detected: #/${(l=p.cycle)==null?void 0:l.join("/")}/<root>
63
63
 
64
64
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const f of n.seen.entries()){const p=f[1];if(t===f[0]){s(f);continue}if(n.external){const v=(c=n.external.registry.get(f[0]))==null?void 0:c.id;if(t!==f[0]&&v){s(f);continue}}if((u=n.metadataRegistry.get(f[0]))==null?void 0:u.id){s(f);continue}if(p.cycle){s(f);continue}if(p.count>1&&n.reused==="ref"){s(f);continue}}}function _6(n,t){var a,l,c;const e=n.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const f=n.seen.get(u);if(f.ref===null)return;const p=f.def??f.schema,y={...p},v=f.ref;if(f.ref=null,v){r(v);const _=n.seen.get(v),$=_.schema;if($.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push($)):Object.assign(p,$),Object.assign(p,y),u._zod.parent===v)for(const O in p)O==="$ref"||O==="allOf"||O in y||delete p[O];if($.$ref&&_.def)for(const O in p)O==="$ref"||O==="allOf"||O in _.def&&JSON.stringify(p[O])===JSON.stringify(_.def[O])&&delete p[O]}const S=u._zod.parent;if(S&&S!==v){r(S);const _=n.seen.get(S);if(_!=null&&_.schema.$ref&&(p.$ref=_.schema.$ref,_.def))for(const $ in p)$==="$ref"||$==="allOf"||$ in _.def&&JSON.stringify(p[$])===JSON.stringify(_.def[$])&&delete p[$]}n.override({zodSchema:u,jsonSchema:p,path:f.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,(a=n.external)!=null&&a.uri){const u=(l=n.external.registry.get(t))==null?void 0:l.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 f=u[1];f.def&&f.defId&&(s[f.defId]=f.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:Od(t,"input",n.processors),output:Od(t,"output",n.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function At(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 At(r.element,e);if(r.type==="set")return At(r.valueType,e);if(r.type==="lazy")return At(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 At(r.innerType,e);if(r.type==="intersection")return At(r.left,e)||At(r.right,e);if(r.type==="record"||r.type==="map")return At(r.keyType,e)||At(r.valueType,e);if(r.type==="pipe")return At(r.in,e)||At(r.out,e);if(r.type==="object"){for(const i in r.shape)if(At(r.shape[i],e))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(At(i,e))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(At(i,e))return!0;return!!(r.rest&&At(r.rest,e))}return!1}const k3=(n,t={})=>e=>{const r=b6({...e,processors:t});return Xe(n,r),S6(r,n),_6(r,n)},Od=(n,t,e={})=>r=>{const{libraryOptions:i,target:s}=r??{},a=b6({...i??{},target:s,io:t,processors:e});return Xe(n,a),S6(a,n),_6(a,n)},T3={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},C3=(n,t,e,r)=>{const i=e;i.type="string";const{minimum:s,maximum:a,format:l,patterns:c,contentEncoding:u}=n._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof a=="number"&&(i.maxLength=a),l&&(i.format=T3[l]??l,i.format===""&&delete i.format,l==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){const f=[...c];f.length===1?i.pattern=f[0].source:f.length>1&&(i.allOf=[...f.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},R3=(n,t,e,r)=>{const i=e,{minimum:s,maximum:a,format:l,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:f}=n._zod.bag;typeof l=="string"&&l.includes("int")?i.type="integer":i.type="number",typeof f=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=f,i.exclusiveMinimum=!0):i.exclusiveMinimum=f),typeof s=="number"&&(i.minimum=s,typeof f=="number"&&t.target!=="draft-04"&&(f>=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 a=="number"&&(i.maximum=a,typeof u=="number"&&t.target!=="draft-04"&&(u<=a?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},I3=(n,t,e,r)=>{e.type="boolean"},$3=(n,t,e,r)=>{e.not={}},x3=(n,t,e,r)=>{},P3=(n,t,e,r)=>{const i=n._zod.def,s=Q8(i.entries);s.every(a=>typeof a=="number")&&(e.type="number"),s.every(a=>typeof a=="string")&&(e.type="string"),e.enum=s},D3=(n,t,e,r)=>{const i=n._zod.def,s=[];for(const a of i.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(a))}else s.push(a);if(s.length!==0)if(s.length===1){const a=s[0];e.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?e.enum=[a]:e.const=a}else s.every(a=>typeof a=="number")&&(e.type="number"),s.every(a=>typeof a=="string")&&(e.type="string"),s.every(a=>typeof a=="boolean")&&(e.type="boolean"),s.every(a=>a===null)&&(e.type="null"),e.enum=s},O3=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},L3=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},M3=(n,t,e,r)=>{const i=e,s=n._zod.def,{minimum:a,maximum:l}=n._zod.bag;typeof a=="number"&&(i.minItems=a),typeof l=="number"&&(i.maxItems=l),i.type="array",i.items=Xe(s.element,t,{...r,path:[...r.path,"items"]})},N3=(n,t,e,r)=>{var u;const i=e,s=n._zod.def;i.type="object",i.properties={};const a=s.shape;for(const f in a)i.properties[f]=Xe(a[f],t,{...r,path:[...r.path,"properties",f]});const l=new Set(Object.keys(a)),c=new Set([...l].filter(f=>{const p=s.shape[f]._zod;return t.io==="input"?p.optin===void 0:p.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=Xe(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},z3=(n,t,e,r)=>{const i=n._zod.def,s=i.inclusive===!1,a=i.options.map((l,c)=>Xe(l,t,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?e.oneOf=a:e.anyOf=a},H3=(n,t,e,r)=>{const i=n._zod.def,s=Xe(i.left,t,{...r,path:[...r.path,"allOf",0]}),a=Xe(i.right,t,{...r,path:[...r.path,"allOf",1]}),l=u=>"allOf"in u&&Object.keys(u).length===1,c=[...l(s)?s.allOf:[s],...l(a)?a.allOf:[a]];e.allOf=c},Z3=(n,t,e,r)=>{const i=e,s=n._zod.def;i.type="object";const a=s.keyType,l=a._zod.bag,c=l==null?void 0:l.patterns;if(s.mode==="loose"&&c&&c.size>0){const f=Xe(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const p of c)i.patternProperties[p.source]=f}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Xe(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Xe(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=a._zod.values;if(u){const f=[...u].filter(p=>typeof p=="string"||typeof p=="number");f.length>0&&(i.required=f)}},U3=(n,t,e,r)=>{const i=n._zod.def,s=Xe(i.innerType,t,r),a=t.seen.get(n);t.target==="openapi-3.0"?(a.ref=i.innerType,e.nullable=!0):e.anyOf=[s,{type:"null"}]},F3=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},q3=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,e.default=JSON.parse(JSON.stringify(i.defaultValue))},V3=(n,t,e,r)=>{const i=n._zod.def;Xe(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)))},B3=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType;let a;try{a=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}e.default=a},j3=(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;Xe(s,t,r);const a=t.seen.get(n);a.ref=s},W3=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,e.readOnly=!0},A6=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},G3=I("ZodISODateTime",(n,t)=>{JC.init(n,t),qe.init(n,t)});function J3(n){return t3(G3,n)}const Y3=I("ZodISODate",(n,t)=>{YC.init(n,t),qe.init(n,t)});function K3(n){return n3(Y3,n)}const X3=I("ZodISOTime",(n,t)=>{KC.init(n,t),qe.init(n,t)});function Q3(n){return r3(X3,n)}const eI=I("ZodISODuration",(n,t)=>{XC.init(n,t),qe.init(n,t)});function tI(n){return i3(eI,n)}const E6=(n,t)=>{r6.init(n,t),n.name="ZodError",Object.defineProperties(n,{format:{value:e=>FT(n,e)},flatten:{value:e=>UT(n,e)},addIssue:{value:e=>{n.issues.push(e),n.message=JSON.stringify(n.issues,eg,2)}},addIssues:{value:e=>{n.issues.push(...e),n.message=JSON.stringify(n.issues,eg,2)}},isEmpty:{get(){return n.issues.length===0}}})},M2=I("ZodError",E6),xn=I("ZodError",E6,{Parent:Error}),nI=rv(xn),rI=iv(xn),iI=Vf(xn),sI=Bf(xn),oI=BT(xn),aI=jT(xn),lI=WT(xn),cI=GT(xn),uI=JT(xn),hI=YT(xn),dI=KT(xn),fI=XT(xn),Fe=I("ZodType",(n,t)=>(Ue.init(n,t),Object.assign(n["~standard"],{jsonSchema:{input:Od(n,"input"),output:Od(n,"output")}}),n.toJSONSchema=k3(n,{}),n.def=t,n.type=t.type,Object.defineProperty(n,"_def",{value:t}),n.check=(...e)=>n.clone(Ds(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)=>Os(n,e,r),n.brand=()=>n,n.register=((e,r)=>(e.add(n,r),n)),n.parse=(e,r)=>nI(n,e,r,{callee:n.parse}),n.safeParse=(e,r)=>iI(n,e,r),n.parseAsync=async(e,r)=>rI(n,e,r,{callee:n.parseAsync}),n.safeParseAsync=async(e,r)=>sI(n,e,r),n.spa=n.safeParseAsync,n.encode=(e,r)=>oI(n,e,r),n.decode=(e,r)=>aI(n,e,r),n.encodeAsync=async(e,r)=>lI(n,e,r),n.decodeAsync=async(e,r)=>cI(n,e,r),n.safeEncode=(e,r)=>uI(n,e,r),n.safeDecode=(e,r)=>hI(n,e,r),n.safeEncodeAsync=async(e,r)=>dI(n,e,r),n.safeDecodeAsync=async(e,r)=>fI(n,e,r),n.refine=(e,r)=>n.check(s$(e,r)),n.superRefine=e=>n.check(o$(e)),n.overwrite=e=>n.check(ec(e)),n.optional=()=>H2(n),n.exactOptional=()=>jI(n),n.nullable=()=>Z2(n),n.nullish=()=>H2(Z2(n)),n.nonoptional=e=>XI(n,e),n.array=()=>G(n),n.or=e=>ae([n,e]),n.and=e=>Wf(n,e),n.transform=e=>U2(n,VI(e)),n.default=e=>JI(n,e),n.prefault=e=>KI(n,e),n.catch=e=>e$(n,e),n.pipe=e=>U2(n,e),n.readonly=()=>r$(n),n.describe=e=>{const r=n.clone();return $c.add(r,{description:e}),r},Object.defineProperty(n,"description",{get(){var e;return(e=$c.get(n))==null?void 0:e.description},configurable:!0}),n.meta=(...e)=>{if(e.length===0)return $c.get(n);const r=n.clone();return $c.add(r,e[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=e=>e(n),n)),k6=I("_ZodString",(n,t)=>{sv.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(r,i,s)=>C3(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(u3(...r)),n.includes=(...r)=>n.check(f3(...r)),n.startsWith=(...r)=>n.check(p3(...r)),n.endsWith=(...r)=>n.check(m3(...r)),n.min=(...r)=>n.check(Dd(...r)),n.max=(...r)=>n.check(y6(...r)),n.length=(...r)=>n.check(w6(...r)),n.nonempty=(...r)=>n.check(Dd(1,...r)),n.lowercase=r=>n.check(h3(r)),n.uppercase=r=>n.check(d3(r)),n.trim=()=>n.check(v3()),n.normalize=(...r)=>n.check(g3(...r)),n.toLowerCase=()=>n.check(y3()),n.toUpperCase=()=>n.check(w3()),n.slugify=()=>n.check(b3())}),pI=I("ZodString",(n,t)=>{sv.init(n,t),k6.init(n,t),n.email=e=>n.check(OR(mI,e)),n.url=e=>n.check(HR(gI,e)),n.jwt=e=>n.check(e3(xI,e)),n.emoji=e=>n.check(ZR(vI,e)),n.guid=e=>n.check(P2(N2,e)),n.uuid=e=>n.check(LR(Uh,e)),n.uuidv4=e=>n.check(MR(Uh,e)),n.uuidv6=e=>n.check(NR(Uh,e)),n.uuidv7=e=>n.check(zR(Uh,e)),n.nanoid=e=>n.check(UR(yI,e)),n.guid=e=>n.check(P2(N2,e)),n.cuid=e=>n.check(FR(wI,e)),n.cuid2=e=>n.check(qR(bI,e)),n.ulid=e=>n.check(VR(SI,e)),n.base64=e=>n.check(KR(RI,e)),n.base64url=e=>n.check(XR(II,e)),n.xid=e=>n.check(BR(_I,e)),n.ksuid=e=>n.check(jR(AI,e)),n.ipv4=e=>n.check(WR(EI,e)),n.ipv6=e=>n.check(GR(kI,e)),n.cidrv4=e=>n.check(JR(TI,e)),n.cidrv6=e=>n.check(YR(CI,e)),n.e164=e=>n.check(QR($I,e)),n.datetime=e=>n.check(J3(e)),n.date=e=>n.check(K3(e)),n.time=e=>n.check(Q3(e)),n.duration=e=>n.check(tI(e))});function g(n){return DR(pI,n)}const qe=I("ZodStringFormat",(n,t)=>{Me.init(n,t),k6.init(n,t)}),mI=I("ZodEmail",(n,t)=>{ZC.init(n,t),qe.init(n,t)}),N2=I("ZodGUID",(n,t)=>{zC.init(n,t),qe.init(n,t)}),Uh=I("ZodUUID",(n,t)=>{HC.init(n,t),qe.init(n,t)}),gI=I("ZodURL",(n,t)=>{UC.init(n,t),qe.init(n,t)}),vI=I("ZodEmoji",(n,t)=>{FC.init(n,t),qe.init(n,t)}),yI=I("ZodNanoID",(n,t)=>{qC.init(n,t),qe.init(n,t)}),wI=I("ZodCUID",(n,t)=>{VC.init(n,t),qe.init(n,t)}),bI=I("ZodCUID2",(n,t)=>{BC.init(n,t),qe.init(n,t)}),SI=I("ZodULID",(n,t)=>{jC.init(n,t),qe.init(n,t)}),_I=I("ZodXID",(n,t)=>{WC.init(n,t),qe.init(n,t)}),AI=I("ZodKSUID",(n,t)=>{GC.init(n,t),qe.init(n,t)}),EI=I("ZodIPv4",(n,t)=>{QC.init(n,t),qe.init(n,t)}),kI=I("ZodIPv6",(n,t)=>{eR.init(n,t),qe.init(n,t)}),TI=I("ZodCIDRv4",(n,t)=>{tR.init(n,t),qe.init(n,t)}),CI=I("ZodCIDRv6",(n,t)=>{nR.init(n,t),qe.init(n,t)}),RI=I("ZodBase64",(n,t)=>{rR.init(n,t),qe.init(n,t)}),II=I("ZodBase64URL",(n,t)=>{sR.init(n,t),qe.init(n,t)}),$I=I("ZodE164",(n,t)=>{oR.init(n,t),qe.init(n,t)}),xI=I("ZodJWT",(n,t)=>{lR.init(n,t),qe.init(n,t)}),T6=I("ZodNumber",(n,t)=>{f6.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(r,i,s)=>R3(n,r,i),n.gt=(r,i)=>n.check(O2(r,i)),n.gte=(r,i)=>n.check(Rm(r,i)),n.min=(r,i)=>n.check(Rm(r,i)),n.lt=(r,i)=>n.check(D2(r,i)),n.lte=(r,i)=>n.check(Cm(r,i)),n.max=(r,i)=>n.check(Cm(r,i)),n.int=r=>n.check(z2(r)),n.safe=r=>n.check(z2(r)),n.positive=r=>n.check(O2(0,r)),n.nonnegative=r=>n.check(Rm(0,r)),n.negative=r=>n.check(D2(0,r)),n.nonpositive=r=>n.check(Cm(0,r)),n.multipleOf=(r,i)=>n.check(L2(r,i)),n.step=(r,i)=>n.check(L2(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 se(n){return s3(T6,n)}const PI=I("ZodNumberFormat",(n,t)=>{cR.init(n,t),T6.init(n,t)});function z2(n){return o3(PI,n)}const DI=I("ZodBoolean",(n,t)=>{uR.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>I3(n,e,r)});function ct(n){return a3(DI,n)}const OI=I("ZodUnknown",(n,t)=>{hR.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>x3()});function E(){return l3(OI)}const LI=I("ZodNever",(n,t)=>{dR.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>$3(n,e,r)});function MI(n){return c3(LI,n)}const NI=I("ZodArray",(n,t)=>{fR.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>M3(n,e,r,i),n.element=t.element,n.min=(e,r)=>n.check(Dd(e,r)),n.nonempty=e=>n.check(Dd(1,e)),n.max=(e,r)=>n.check(y6(e,r)),n.length=(e,r)=>n.check(w6(e,r)),n.unwrap=()=>n.element});function G(n,t){return S3(NI,n,t)}const C6=I("ZodObject",(n,t)=>{mR.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>N3(n,e,r,i),Ae(n,"shape",()=>t.shape),n.keyof=()=>ov(Object.keys(n._zod.def.shape)),n.catchall=e=>n.clone({...n._zod.def,catchall:e}),n.passthrough=()=>n.clone({...n._zod.def,catchall:E()}),n.loose=()=>n.clone({...n._zod.def,catchall:E()}),n.strict=()=>n.clone({...n._zod.def,catchall:MI()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=e=>MT(n,e),n.safeExtend=e=>NT(n,e),n.merge=e=>zT(n,e),n.pick=e=>OT(n,e),n.omit=e=>LT(n,e),n.partial=(...e)=>HT(I6,n,e[0]),n.required=(...e)=>ZT($6,n,e[0])});function ng(n,t){const e={type:"object",shape:n??{},...Y(t)};return new C6(e)}function b(n,t){return new C6({type:"object",shape:n,catchall:E(),...Y(t)})}const R6=I("ZodUnion",(n,t)=>{g6.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>z3(n,e,r,i),n.options=t.options});function ae(n,t){return new R6({type:"union",options:n,...Y(t)})}const zI=I("ZodDiscriminatedUnion",(n,t)=>{R6.init(n,t),gR.init(n,t)});function HI(n,t,e){return new zI({type:"union",options:t,discriminator:n,...Y(e)})}const ZI=I("ZodIntersection",(n,t)=>{vR.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>H3(n,e,r,i)});function Wf(n,t){return new ZI({type:"intersection",left:n,right:t})}const UI=I("ZodRecord",(n,t)=>{yR.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>Z3(n,e,r,i),n.keyType=t.keyType,n.valueType=t.valueType});function T(n,t,e){return new UI({type:"record",keyType:n,valueType:t,...Y(e)})}const rg=I("ZodEnum",(n,t)=>{wR.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(r,i,s)=>P3(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 a of r)if(e.has(a))s[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new rg({...t,checks:[],...Y(i),entries:s})},n.exclude=(r,i)=>{const s={...t.entries};for(const a of r)if(e.has(a))delete s[a];else throw new Error(`Key ${a} not found in enum`);return new rg({...t,checks:[],...Y(i),entries:s})}});function ov(n,t){const e=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new rg({type:"enum",entries:e,...Y(t)})}const FI=I("ZodLiteral",(n,t)=>{bR.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>D3(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 D(n,t){return new FI({type:"literal",values:Array.isArray(n)?n:[n],...Y(t)})}const qI=I("ZodTransform",(n,t)=>{SR.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>L3(n,e),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new K8(n.constructor.name);e.addIssue=s=>{if(typeof s=="string")e.issues.push(tu(s,e.value,t));else{const a=s;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=e.value),a.inst??(a.inst=n),e.issues.push(tu(a))}};const i=t.transform(e.value,e);return i instanceof Promise?i.then(s=>(e.value=s,e)):(e.value=i,e)}});function VI(n){return new qI({type:"transform",transform:n})}const I6=I("ZodOptional",(n,t)=>{v6.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>A6(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function H2(n){return new I6({type:"optional",innerType:n})}const BI=I("ZodExactOptional",(n,t)=>{_R.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>A6(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function jI(n){return new BI({type:"optional",innerType:n})}const WI=I("ZodNullable",(n,t)=>{AR.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>U3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function Z2(n){return new WI({type:"nullable",innerType:n})}const GI=I("ZodDefault",(n,t)=>{ER.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>q3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function JI(n,t){return new GI({type:"default",innerType:n,get defaultValue(){return typeof t=="function"?t():t6(t)}})}const YI=I("ZodPrefault",(n,t)=>{kR.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>V3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function KI(n,t){return new YI({type:"prefault",innerType:n,get defaultValue(){return typeof t=="function"?t():t6(t)}})}const $6=I("ZodNonOptional",(n,t)=>{TR.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>F3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function XI(n,t){return new $6({type:"nonoptional",innerType:n,...Y(t)})}const QI=I("ZodCatch",(n,t)=>{CR.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>B3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function e$(n,t){return new QI({type:"catch",innerType:n,catchValue:typeof t=="function"?t:()=>t})}const t$=I("ZodPipe",(n,t)=>{RR.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>j3(n,e,r,i),n.in=t.in,n.out=t.out});function U2(n,t){return new t$({type:"pipe",in:n,out:t})}const n$=I("ZodReadonly",(n,t)=>{IR.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>W3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function r$(n){return new n$({type:"readonly",innerType:n})}const i$=I("ZodCustom",(n,t)=>{$R.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>O3(n,e)});function s$(n,t={}){return _3(i$,n,t)}function o$(n){return A3(n)}const a$=[".md",".markdown"];function x6(n){if(n.length===0)return!1;const t=n.at(-1);return t==="/"||t==="\\"}function P6(n){const t=n.lastIndexOf("/"),e=n.lastIndexOf("\\");return n.slice(Math.max(t,e)+1)}function l$(n){return P6(n).toLowerCase()}function c$(n,t){const e=l$(n);return t.some(r=>e.endsWith(r))}function ig(n){return!x6(n)&&c$(n,a$)}function u$(n){let t;try{t=new URL(n)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}function qr(n){try{const{pathname:t}=new URL(n);return/^\/artifact\/[0-9A-Za-z]{26}(\/|$)/.test(t)}catch{return!1}}const h$=ng({id:g().min(1),kind:D("path"),title:g(),path:g(),store:g().optional(),share:ng({id:g().min(1),access:ov(["read","read-write"])}).strict().optional()}).strict(),d$=ng({id:g().min(1),kind:D("url"),title:g(),url:g().refine(u$,{message:"url must be an http(s) URL"})}).strict();HI("kind",[h$,d$]);const f$=new Set(["about:","blob:","chrome-extension:","chrome:","data:","devtools:","file:","filesystem:","javascript:","view-source:"]);function p$(n,t){try{const e=new URL(t),r=new URL(n,e);return r.protocol==="http:"||r.protocol==="https:"?{kind:"web",url:r.href}:f$.has(r.protocol)?{kind:"browser-local",url:r.href}:{kind:"application",url:r.href}}catch{return{kind:"invalid"}}}function F2(n,t){return p$(n,t).kind==="web"}const m$="/views/markdown/",g$="/views/url-unsupported/";function v$(n){try{const{protocol:t}=new URL(n);return t==="http:"||t==="https:"}catch{return!1}}function D6(n){return`/artifact/${encodeURIComponent(n)}`}function y$(n,t){return`${D6(n)}/${encodeURIComponent(t)}`}function w$(n){return`/markdown/${encodeURIComponent(n)}`}function nu(n,t={electron:!1}){if(n.kind==="url")return t.electron?{renderer:"url-webview",viewURL:n.url,contentURL:null}:qr(n.url)?{renderer:"proxy-iframe",viewURL:n.url,contentURL:null}:t.browserDemo&&v$(n.url)?{renderer:"url-direct",viewURL:n.url,contentURL:null}:{renderer:"url-unsupported",viewURL:g$,contentURL:null};if(ig(n.path)){const r={viewURL:m$,contentURL:w$(n.id)};return t.electron?{renderer:"url-webview",...r}:{renderer:"markdown",...r}}const e=x6(n.path)?`${D6(n.id)}/`:y$(n.id,P6(n.path));return t.electron?{renderer:"url-webview",viewURL:e,contentURL:null}:{renderer:"proxy-iframe",viewURL:e,contentURL:null}}const b$="token",S$="mode",_$="desktopAppVersion",A$="electron";function E$(n=window.location.search){return new URLSearchParams(n).get(b$)}function bi(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(S$)===A$}function O6(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(_$)}const q2="tv.telemetry.clientId",k$=5,T$=60,C$=1e3,R$=k$*T$*C$,V2=["pointerdown","scroll","keydown"],B2=["focus"],j2=["visibilitychange"],I$="hidden";function $$(n,t=L$){const e=n.getItem(q2);if(e)return e;const r=t();return n.setItem(q2,r),r}function x$(n){return{clientId:$$(n.storage,n.idFactory),userAgent:n.userAgent??(typeof navigator>"u"?"":navigator.userAgent),clientApp:n.clientApp,...n.desktopAppVersion?{desktopAppVersion:n.desktopAppVersion}:{}}}function P$(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 D$(n){return new O$(n)}var uu,Gr,Wi,hu,du,yn,po,fu,Wd,L6;class O${constructor(t){m(this,Wd);m(this,uu);m(this,Gr);m(this,Wi);m(this,hu);m(this,du);m(this,yn);m(this,po,!1);m(this,fu,Number.NEGATIVE_INFINITY);d(this,uu,t.meta),d(this,Gr,t.documentTarget),d(this,Wi,t.windowTarget),d(this,hu,t.send),d(this,du,t.nowMs??Date.now),d(this,yn,()=>h(this,Wd,L6).call(this))}start(){if(!o(this,po)){d(this,po,!0);for(const t of V2)o(this,Wi).addEventListener(t,o(this,yn)),o(this,Gr).addEventListener(t,o(this,yn));for(const t of B2)o(this,Wi).addEventListener(t,o(this,yn));for(const t of j2)o(this,Gr).addEventListener(t,o(this,yn))}}stop(){if(o(this,po)){d(this,po,!1);for(const t of V2)o(this,Wi).removeEventListener(t,o(this,yn)),o(this,Gr).removeEventListener(t,o(this,yn));for(const t of B2)o(this,Wi).removeEventListener(t,o(this,yn));for(const t of j2)o(this,Gr).removeEventListener(t,o(this,yn))}}}uu=new WeakMap,Gr=new WeakMap,Wi=new WeakMap,hu=new WeakMap,du=new WeakMap,yn=new WeakMap,po=new WeakMap,fu=new WeakMap,Wd=new WeakSet,L6=function(){if(o(this,Gr).visibilityState===I$)return;const t=o(this,du).call(this);t-o(this,fu)<R$||(d(this,fu,t),o(this,hu).call(this,{type:uk,clientId:o(this,uu).clientId}))};function L$(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Q1().toLowerCase()}const De={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"},Hr={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"},M$=1,N$=b({_meta:T(g(),E()).nullish(),terminal:ct().optional().default(!1)}),z$=b({_meta:T(g(),E()).nullish(),label:g().nullish(),name:g(),optional:ct().optional().default(!1),secret:ct().optional().default(!0)}),H$=b({_meta:T(g(),E()).nullish(),description:g().nullish(),id:g(),name:g()}),Z$=b({_meta:T(g(),E()).nullish(),description:g().nullish(),id:g(),link:g().nullish(),name:g(),vars:G(z$)}),U$=b({_meta:T(g(),E()).nullish(),args:G(g()).optional(),description:g().nullish(),env:T(g(),g()).optional(),id:g(),name:g()}),F$=ae([Z$.and(b({type:D("env_var")})),U$.and(b({type:D("terminal")})),H$]),q$=b({_meta:T(g(),E()).nullish(),methodId:g()}),V$=b({_meta:T(g(),E()).nullish()}),B$=b({_meta:T(g(),E()).nullish(),blob:g(),mimeType:g().nullish(),uri:g()}),j$=b({default:ct().nullish(),description:g().nullish(),title:g().nullish()}),W$=b({_meta:T(g(),E()).nullish()}),G$=b({_meta:T(g(),E()).nullish()}),J$=b({amount:se(),currency:g()}),Y$=b({_meta:T(g(),E()).nullish(),terminalId:g()}),K$=b({_meta:T(g(),E()).nullish(),newText:g(),oldText:g().nullish(),path:g()}),X$=ae([g(),se(),se(),ct(),G(g())]),Q$=b({content:T(g(),X$).nullish()}),ex=ae([Q$.and(b({action:D("accept")})),b({action:D("decline")}),b({action:D("cancel")})]),tx=b({_meta:T(g(),E()).nullish()}),M6=g(),nx=b({_meta:T(g(),E()).nullish(),elicitationId:M6}),rx=b({_meta:T(g(),E()).nullish(),action:ex}),ix=D("object"),sx=D("string"),ox=b({_meta:T(g(),E()).nullish()}),ax=b({_meta:T(g(),E()).nullish(),form:tx.nullish(),url:ox.nullish()}),lx=b({elicitationId:M6,url:g().url()}),N6=b({const:g(),title:g()}),z6=b({_meta:T(g(),E()).nullish(),name:g(),value:g()}),cx=ae([D(-32700),D(-32600),D(-32601),D(-32602),D(-32603),D(-32800),D(-32e3),D(-32002),D(-32042),se().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),H6=b({code:cx,data:E().optional(),message:g()}),Z6=E(),U6=E(),F6=E(),ux=b({_meta:T(g(),E()).nullish(),readTextFile:ct().optional().default(!1),writeTextFile:ct().optional().default(!1)}),q6=b({_meta:T(g(),E()).nullish(),name:g(),value:g()}),V6=b({_meta:T(g(),E()).nullish(),name:g(),title:g().nullish(),version:g()}),hx=b({default:se().nullish(),description:g().nullish(),maximum:se().nullish(),minimum:se().nullish(),title:g().nullish()}),dx=b({_meta:T(g(),E()).nullish()}),fx=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cursor:g().nullish(),cwd:g().nullish()}),px=b({_meta:T(g(),E()).nullish()}),mx=b({_meta:T(g(),E()).nullish(),logout:px.nullish()}),gx=b({_meta:T(g(),E()).nullish()}),vx=b({_meta:T(g(),E()).nullish()}),yx=b({_meta:T(g(),E()).nullish(),http:ct().optional().default(!1),sse:ct().optional().default(!1)}),wx=b({_meta:T(g(),E()).nullish(),headers:G(q6),name:g(),url:g()}),bx=b({_meta:T(g(),E()).nullish(),headers:G(q6),name:g(),url:g()}),Sx=b({_meta:T(g(),E()).nullish(),args:G(g()),command:g(),env:G(z6),name:g()}),Gf=ae([wx.and(b({type:D("http")})),bx.and(b({type:D("sse")})),Sx]),av=g(),_x=b({_meta:T(g(),E()).nullish(),description:g().nullish(),modelId:av,name:g()}),Ax=ae([D("error"),D("warning"),D("information"),D("hint")]),Ex=b({_meta:T(g(),E()).nullish()}),kx=b({_meta:T(g(),E()).nullish()}),Tx=b({_meta:T(g(),E()).nullish()}),Cx=b({_meta:T(g(),E()).nullish()}),Rx=b({_meta:T(g(),E()).nullish()}),Ix=b({_meta:T(g(),E()).nullish(),maxCount:se().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),$x=b({diff:g(),uri:g()}),xx=b({endLine:se().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:se().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:g()}),Px=b({_meta:T(g(),E()).nullish()}),Dx=b({_meta:T(g(),E()).nullish()}),Ox=b({languageId:g(),text:g(),uri:g()}),Lx=b({_meta:T(g(),E()).nullish(),maxCount:se().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),Mx=ae([D("rejected"),D("ignored"),D("replaced"),D("cancelled")]),Nx=b({excerpts:G(xx),uri:g()}),zx=b({_meta:T(g(),E()).nullish()}),Hx=b({_meta:T(g(),E()).nullish()}),Zx=b({name:g(),owner:g(),remoteUrl:g()}),Ux=b({_meta:T(g(),E()).nullish()}),Fx=b({_meta:T(g(),E()).nullish(),jump:Px.nullish(),rename:Hx.nullish(),searchAndReplace:Ux.nullish()}),qx=b({id:g(),isRegex:ct().nullish(),replace:g(),search:g(),uri:g()}),Vx=ae([D("automatic"),D("diagnostic"),D("manual")]),Bx=b({_meta:T(g(),E()).nullish(),maxCount:se().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),jx=b({_meta:T(g(),E()).nullish(),diagnostics:Ex.nullish(),editHistory:Ix.nullish(),openFiles:Dx.nullish(),recentFiles:Lx.nullish(),relatedSnippets:zx.nullish(),userActions:Bx.nullish()}),Wx=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),mcpServers:G(Gf)}),Gx=b({default:se().nullish(),description:g().nullish(),maximum:se().nullish(),minimum:se().nullish(),title:g().nullish()}),B6=g(),Jx=ae([D("allow_once"),D("allow_always"),D("reject_once"),D("reject_always")]),Yx=b({_meta:T(g(),E()).nullish(),kind:Jx,name:g(),optionId:B6}),Kx=ae([D("high"),D("medium"),D("low")]),Xx=ae([D("pending"),D("in_progress"),D("completed")]),Qx=b({_meta:T(g(),E()).nullish(),content:g(),priority:Kx,status:Xx}),eP=b({_meta:T(g(),E()).nullish(),entries:G(Qx)}),$s=b({character:se().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:se().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),tP=b({id:g(),position:$s,uri:g()}),nP=b({id:g(),newName:g(),position:$s,uri:g()}),rP=b({action:g(),position:$s,timestampMs:se(),uri:g()}),j6=ae([D("utf-16"),D("utf-32"),D("utf-8")]),iP=b({_meta:T(g(),E()).nullish(),auth:N$.optional().default({terminal:!1}),elicitation:ax.nullish(),fs:ux.optional().default({readTextFile:!1,writeTextFile:!1}),nes:Fx.nullish(),positionEncodings:G(j6).optional(),terminal:ct().optional().default(!1)}),sP=b({_meta:T(g(),E()).nullish(),audio:ct().optional().default(!1),embeddedContext:ct().optional().default(!1),image:ct().optional().default(!1)}),W6=se().int().gte(0).lte(65535),oP=b({_meta:T(g(),E()).nullish(),clientCapabilities:iP.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:V6.nullish(),protocolVersion:W6}),tc=b({end:$s,start:$s}),aP=b({message:g(),range:tc,severity:Ax,uri:g()}),lP=b({languageId:g(),lastFocusedMs:se().nullish(),uri:g(),visibleRange:tc.nullish()}),cP=b({_meta:T(g(),E()).nullish(),diagnostics:G(aP).nullish(),editHistory:G($x).nullish(),openFiles:G(lP).nullish(),recentFiles:G(Ox).nullish(),relatedSnippets:G(Nx).nullish(),userActions:G(rP).nullish()}),uP=b({newText:g(),range:tc}),hP=b({cursorPosition:$s.nullish(),edits:G(uP),id:g(),uri:g()}),dP=ae([hP.and(b({kind:D("edit")})),tP.and(b({kind:D("jump")})),nP.and(b({kind:D("rename")})),qx.and(b({kind:D("searchAndReplace")}))]),fP=b({_meta:T(g(),E()).nullish(),content:g()}),pP=b({_meta:T(g(),E()).nullish()}),na=ae([se(),g()]).nullable();b({_meta:T(g(),E()).nullish(),requestId:na});const mP=ov(["assistant","user"]),Ah=b({_meta:T(g(),E()).nullish(),audience:G(mP).nullish(),lastModified:g().nullish(),priority:se().nullish()}),gP=b({_meta:T(g(),E()).nullish(),annotations:Ah.nullish(),data:g(),mimeType:g()}),vP=b({_meta:T(g(),E()).nullish(),annotations:Ah.nullish(),data:g(),mimeType:g(),uri:g().nullish()}),yP=b({_meta:T(g(),E()).nullish(),annotations:Ah.nullish(),description:g().nullish(),mimeType:g().nullish(),name:g(),size:se().nullish(),title:g().nullish(),uri:g()}),wP=b({_meta:T(g(),E()).nullish(),optionId:B6}),bP=ae([b({outcome:D("cancelled")}),wP.and(b({outcome:D("selected")}))]),SP=b({_meta:T(g(),E()).nullish(),outcome:bP}),_P=b({_meta:T(g(),E()).nullish()}),AP=b({_meta:T(g(),E()).nullish()}),EP=b({currentValue:ct()}),kP=g(),G6=g(),TP=ae([D("mode"),D("model"),D("thought_level"),g()]),lv=g(),J6=b({_meta:T(g(),E()).nullish(),description:g().nullish(),name:g(),value:lv}),CP=b({_meta:T(g(),E()).nullish(),group:kP,name:g(),options:G(J6)}),RP=ae([G(J6),G(CP)]),IP=b({currentValue:lv,options:RP}),nc=Wf(ae([IP.and(b({type:D("select")})),EP.and(b({type:D("boolean")}))]),b({_meta:T(g(),E()).nullish(),category:TP.nullish(),description:g().nullish(),id:G6,name:g()})),$P=b({_meta:T(g(),E()).nullish(),configOptions:G(nc)}),xP=b({_meta:T(g(),E()).nullish()}),be=g(),PP=b({_meta:T(g(),E()).nullish(),id:g(),sessionId:be}),DP=b({_meta:T(g(),E()).nullish(),sessionId:be}),OP=b({_meta:T(g(),E()).nullish(),sessionId:be}),LP=b({_meta:T(g(),E()).nullish(),sessionId:be}),Y6=b({_meta:T(g(),E()).nullish(),args:G(g()).optional(),command:g(),cwd:g().nullish(),env:G(z6).optional(),outputByteLimit:se().nullish(),sessionId:be}),MP=b({_meta:T(g(),E()).nullish(),sessionId:be,uri:g()}),NP=b({_meta:T(g(),E()).nullish(),position:$s,sessionId:be,uri:g(),version:se(),visibleRange:tc}),zP=b({_meta:T(g(),E()).nullish(),languageId:g(),sessionId:be,text:g(),uri:g(),version:se()}),HP=b({_meta:T(g(),E()).nullish(),sessionId:be,uri:g()}),ZP=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),mcpServers:G(Gf).optional(),sessionId:be}),K6=b({_meta:T(g(),E()).nullish(),sessionId:be,terminalId:g()}),UP=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),mcpServers:G(Gf),sessionId:be}),X6=b({_meta:T(g(),E()).nullish(),limit:se().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:se().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:g(),sessionId:be}),FP=b({_meta:T(g(),E()).nullish(),id:g(),reason:Mx.nullish(),sessionId:be}),Q6=b({_meta:T(g(),E()).nullish(),sessionId:be,terminalId:g()}),qP=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),mcpServers:G(Gf).optional(),sessionId:be}),VP=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),sessionId:be,title:g().nullish(),updatedAt:g().nullish()}),BP=b({_meta:T(g(),E()).nullish(),nextCursor:g().nullish(),sessions:G(VP)}),jP=b({_meta:T(g(),E()).nullish(),title:g().nullish(),updatedAt:g().nullish()}),WP=b({_meta:T(g(),E()).nullish()}),Jf=g(),GP=b({_meta:T(g(),E()).nullish(),currentModeId:Jf}),JP=b({_meta:T(g(),E()).nullish(),description:g().nullish(),id:Jf,name:g()}),Yf=b({_meta:T(g(),E()).nullish(),availableModes:G(JP),currentModeId:Jf}),Kf=b({_meta:T(g(),E()).nullish(),availableModels:G(_x),currentModelId:av}),YP=b({_meta:T(g(),E()).nullish(),configOptions:G(nc).nullish(),models:Kf.nullish(),modes:Yf.nullish(),sessionId:be}),KP=b({_meta:T(g(),E()).nullish(),configOptions:G(nc).nullish(),models:Kf.nullish(),modes:Yf.nullish()}),XP=b({_meta:T(g(),E()).nullish(),configOptions:G(nc).nullish(),models:Kf.nullish(),modes:Yf.nullish(),sessionId:be}),QP=b({_meta:T(g(),E()).nullish(),configOptions:G(nc).nullish(),models:Kf.nullish(),modes:Yf.nullish()}),e5=b({_meta:T(g(),E()).nullish()}),t5=b({_meta:T(g(),E()).nullish(),additionalDirectories:_P.nullish(),close:AP.nullish(),fork:xP.nullish(),list:WP.nullish(),resume:e5.nullish()}),n5=Wf(ae([b({type:D("boolean"),value:ct()}),b({value:lv})]),b({_meta:T(g(),E()).nullish(),configId:G6,sessionId:be})),r5=b({_meta:T(g(),E()).nullish(),configOptions:G(nc)}),i5=b({_meta:T(g(),E()).nullish(),modeId:Jf,sessionId:be}),s5=b({_meta:T(g(),E()).nullish()}),o5=b({_meta:T(g(),E()).nullish(),modelId:av,sessionId:be}),a5=b({_meta:T(g(),E()).nullish()}),l5=b({_meta:T(g(),E()).nullish(),sessionId:be}),c5=ae([D("end_turn"),D("max_tokens"),D("max_turn_requests"),D("refusal"),D("cancelled")]),u5=ae([D("email"),D("uri"),D("date"),D("date-time")]),h5=b({default:g().nullish(),description:g().nullish(),enum:G(g()).nullish(),format:u5.nullish(),maxLength:se().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:se().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:G(N6).nullish(),pattern:g().nullish(),title:g().nullish()}),d5=b({_meta:T(g(),E()).nullish(),context:cP.nullish(),position:$s,selection:tc.nullish(),sessionId:be,triggerKind:Vx,uri:g(),version:se()}),f5=b({_meta:T(g(),E()).nullish(),suggestions:G(dP)}),p5=b({_meta:T(g(),E()).nullish(),terminalId:g()}),m5=b({_meta:T(g(),E()).nullish(),exitCode:se().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:g().nullish()}),eS=b({_meta:T(g(),E()).nullish(),sessionId:be,terminalId:g()}),g5=b({_meta:T(g(),E()).nullish(),exitStatus:m5.nullish(),output:g(),truncated:ct()}),v5=b({_meta:T(g(),E()).nullish(),annotations:Ah.nullish(),text:g()}),y5=b({range:tc.nullish(),text:g()}),w5=b({_meta:T(g(),E()).nullish(),contentChanges:G(y5),sessionId:be,uri:g(),version:se()});b({method:g(),params:ae([DP,zP,w5,MP,HP,NP,PP,FP,Z6]).nullish()});const b5=ae([D("full"),D("incremental")]),S5=b({_meta:T(g(),E()).nullish(),syncKind:b5}),_5=b({_meta:T(g(),E()).nullish(),didChange:S5.nullish(),didClose:kx.nullish(),didFocus:Tx.nullish(),didOpen:Cx.nullish(),didSave:Rx.nullish()}),A5=b({_meta:T(g(),E()).nullish(),document:_5.nullish()}),E5=b({_meta:T(g(),E()).nullish(),context:jx.nullish(),events:A5.nullish()}),k5=b({_meta:T(g(),E()).nullish(),auth:mx.optional().default({}),loadSession:ct().optional().default(!1),mcpCapabilities:yx.optional().default({http:!1,sse:!1}),nes:E5.nullish(),positionEncoding:j6.nullish(),promptCapabilities:sP.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:t5.optional().default({})}),T5=b({_meta:T(g(),E()).nullish(),agentCapabilities:k5.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:V6.nullish(),authMethods:G(F$).optional().default([]),protocolVersion:W6}),C5=b({_meta:T(g(),E()).nullish(),mimeType:g().nullish(),text:g(),uri:g()}),R5=ae([C5,B$]),I5=b({_meta:T(g(),E()).nullish(),annotations:Ah.nullish(),resource:R5}),cv=ae([v5.and(b({type:D("text")})),vP.and(b({type:D("image")})),gP.and(b({type:D("audio")})),yP.and(b({type:D("resource_link")})),I5.and(b({type:D("resource")}))]),$5=b({_meta:T(g(),E()).nullish(),content:cv}),Im=b({_meta:T(g(),E()).nullish(),content:cv,messageId:g().nullish()}),x5=b({_meta:T(g(),E()).nullish(),messageId:g().nullish(),prompt:G(cv),sessionId:be}),P5=b({anyOf:G(N6)}),tS=ae([$5.and(b({type:D("content")})),K$.and(b({type:D("diff")})),p5.and(b({type:D("terminal")}))]),nS=g(),rS=b({_meta:T(g(),E()).nullish(),line:se().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:g()}),iS=ae([D("pending"),D("in_progress"),D("completed"),D("failed")]),sS=ae([D("read"),D("edit"),D("delete"),D("move"),D("search"),D("execute"),D("think"),D("fetch"),D("switch_mode"),D("other")]),D5=b({_meta:T(g(),E()).nullish(),content:G(tS).optional(),kind:sS.optional(),locations:G(rS).optional(),rawInput:E().optional(),rawOutput:E().optional(),status:iS.optional(),title:g(),toolCallId:nS}),oS=b({_meta:T(g(),E()).nullish(),content:G(tS).nullish(),kind:sS.nullish(),locations:G(rS).nullish(),rawInput:E().optional(),rawOutput:E().optional(),status:iS.nullish(),title:g().nullish(),toolCallId:nS}),aS=b({_meta:T(g(),E()).nullish(),options:G(Yx),sessionId:be,toolCall:oS}),O5=b({_meta:T(g(),E()).nullish(),hint:g()}),L5=O5,M5=b({_meta:T(g(),E()).nullish(),description:g(),input:L5.nullish(),name:g()}),N5=b({_meta:T(g(),E()).nullish(),availableCommands:G(M5)}),z5=b({enum:G(g()),type:sx}),H5=ae([z5,P5]),Z5=b({default:G(g()).nullish(),description:g().nullish(),items:H5,maxItems:se().nullish(),minItems:se().nullish(),title:g().nullish()}),U5=ae([h5.and(b({type:D("string")})),Gx.and(b({type:D("number")})),hx.and(b({type:D("integer")})),j$.and(b({type:D("boolean")})),Z5.and(b({type:D("array")}))]),F5=b({description:g().nullish(),properties:T(g(),U5).optional().default({}),required:G(g()).nullish(),title:g().nullish(),type:ix.optional().default("object")}),q5=b({requestedSchema:F5}),V5=Wf(ae([q5.and(b({mode:D("form")})),lx.and(b({mode:D("url")}))]),b({_meta:T(g(),E()).nullish(),message:g(),sessionId:be})),B5=b({cachedReadTokens:se().nullish(),cachedWriteTokens:se().nullish(),inputTokens:se(),outputTokens:se(),thoughtTokens:se().nullish(),totalTokens:se()}),j5=b({_meta:T(g(),E()).nullish(),stopReason:c5,usage:B5.nullish(),userMessageId:g().nullish()});ae([b({id:na,result:ae([T5,V$,vx,XP,KP,BP,YP,QP,G$,s5,r5,j5,a5,l5,f5,W$,F6])}),b({error:H6,id:na})]);const W5=b({_meta:T(g(),E()).nullish(),cost:J$.nullish(),size:se(),used:se()}),G5=ae([Im.and(b({sessionUpdate:D("user_message_chunk")})),Im.and(b({sessionUpdate:D("agent_message_chunk")})),Im.and(b({sessionUpdate:D("agent_thought_chunk")})),D5.and(b({sessionUpdate:D("tool_call")})),oS.and(b({sessionUpdate:D("tool_call_update")})),eP.and(b({sessionUpdate:D("plan")})),N5.and(b({sessionUpdate:D("available_commands_update")})),GP.and(b({sessionUpdate:D("current_mode_update")})),$P.and(b({sessionUpdate:D("config_option_update")})),jP.and(b({sessionUpdate:D("session_info_update")})),W5.and(b({sessionUpdate:D("usage_update")}))]),lS=b({_meta:T(g(),E()).nullish(),sessionId:be,update:G5});b({method:g(),params:ae([lS,nx,Z6]).nullish()});const cS=b({_meta:T(g(),E()).nullish(),sessionId:be,terminalId:g()}),J5=b({_meta:T(g(),E()).nullish(),exitCode:se().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:g().nullish()}),Y5=b({name:g(),uri:g()}),K5=b({_meta:T(g(),E()).nullish(),repository:Zx.nullish(),workspaceFolders:G(Y5).nullish(),workspaceUri:g().nullish()});b({id:na,method:g(),params:ae([oP,q$,gx,Wx,UP,fx,ZP,qP,LP,i5,n5,x5,o5,K5,d5,OP,U6]).nullish()});const uS=b({_meta:T(g(),E()).nullish(),content:g(),path:g(),sessionId:be});b({id:na,method:g(),params:ae([uS,X6,aS,Y6,eS,Q6,cS,K6,V5,U6]).nullish()});const X5=b({_meta:T(g(),E()).nullish()});ae([b({id:na,result:ae([X5,fP,SP,Y$,g5,pP,J5,dx,rx,F6])}),b({error:H6,id:na})]);var we;class Q5{constructor(t,e){m(this,we);const r=t(this),i=async(a,l)=>{var c,u,f,p,y,v,S;switch(a){case Hr.fs_write_text_file:{const _=uS.parse(l);return(c=r.writeTextFile)==null?void 0:c.call(r,_)}case Hr.fs_read_text_file:{const _=X6.parse(l);return(u=r.readTextFile)==null?void 0:u.call(r,_)}case Hr.session_request_permission:{const _=aS.parse(l);return r.requestPermission(_)}case Hr.terminal_create:{const _=Y6.parse(l);return(f=r.createTerminal)==null?void 0:f.call(r,_)}case Hr.terminal_output:{const _=eS.parse(l);return(p=r.terminalOutput)==null?void 0:p.call(r,_)}case Hr.terminal_release:{const _=Q6.parse(l);return await((y=r.releaseTerminal)==null?void 0:y.call(r,_))??{}}case Hr.terminal_wait_for_exit:{const _=cS.parse(l);return(v=r.waitForTerminalExit)==null?void 0:v.call(r,_)}case Hr.terminal_kill:{const _=K6.parse(l);return await((S=r.killTerminal)==null?void 0:S.call(r,_))??{}}default:if(r.extMethod)return r.extMethod(a,l);throw rt.methodNotFound(a)}},s=async(a,l)=>{switch(a){case Hr.session_update:{const c=lS.parse(l);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(a,l);throw rt.methodNotFound(a)}};d(this,we,new eD(i,s,e))}async initialize(t){return await o(this,we).sendRequest(De.initialize,t)}async newSession(t){return await o(this,we).sendRequest(De.session_new,t)}async loadSession(t){return await o(this,we).sendRequest(De.session_load,t)??{}}async unstable_forkSession(t){return await o(this,we).sendRequest(De.session_fork,t)}async listSessions(t){return await o(this,we).sendRequest(De.session_list,t)}async unstable_resumeSession(t){return await o(this,we).sendRequest(De.session_resume,t)}async unstable_closeSession(t){return await o(this,we).sendRequest(De.session_close,t)}async setSessionMode(t){return await o(this,we).sendRequest(De.session_set_mode,t)??{}}async unstable_setSessionModel(t){return await o(this,we).sendRequest(De.session_set_model,t)??{}}async setSessionConfigOption(t){return await o(this,we).sendRequest(De.session_set_config_option,t)}async authenticate(t){return await o(this,we).sendRequest(De.authenticate,t)??{}}async unstable_logout(t){return await o(this,we).sendRequest(De.logout,t)??{}}async prompt(t){return await o(this,we).sendRequest(De.session_prompt,t)}async cancel(t){return await o(this,we).sendNotification(De.session_cancel,t)}async unstable_startNes(t){return await o(this,we).sendRequest(De.nes_start,t)}async unstable_suggestNes(t){return await o(this,we).sendRequest(De.nes_suggest,t)}async unstable_closeNes(t){return await o(this,we).sendRequest(De.nes_close,t)??{}}async unstable_didOpenDocument(t){return await o(this,we).sendNotification(De.document_did_open,t)}async unstable_didChangeDocument(t){return await o(this,we).sendNotification(De.document_did_change,t)}async unstable_didCloseDocument(t){return await o(this,we).sendNotification(De.document_did_close,t)}async unstable_didSaveDocument(t){return await o(this,we).sendNotification(De.document_did_save,t)}async unstable_didFocusDocument(t){return await o(this,we).sendNotification(De.document_did_focus,t)}async unstable_acceptNes(t){return await o(this,we).sendNotification(De.nes_accept,t)}async unstable_rejectNes(t){return await o(this,we).sendNotification(De.nes_reject,t)}async extMethod(t,e){return await o(this,we).sendRequest(t,e)}async extNotification(t,e){return await o(this,we).sendNotification(t,e)}get signal(){return o(this,we).signal}get closed(){return o(this,we).closed}}we=new WeakMap;var Gi,Gd,pu,mu,Ba,ja,or,gu,Ze,hS,sg,dS,fS,pS,mS,og,xc;class eD{constructor(t,e,r){m(this,Ze);m(this,Gi,new Map);m(this,Gd,0);m(this,pu);m(this,mu);m(this,Ba);m(this,ja,Promise.resolve());m(this,or,new AbortController);m(this,gu);d(this,pu,t),d(this,mu,e),d(this,Ba,r),d(this,gu,new Promise(i=>{o(this,or).signal.addEventListener("abort",()=>i())})),h(this,Ze,hS).call(this)}get signal(){return o(this,or).signal}get closed(){return o(this,gu)}async sendRequest(t,e){h(this,Ze,og).call(this);const r=Lh(this,Gd)._++,i=new Promise((s,a)=>{o(this,Gi).set(r,{resolve:s,reject:a})});return await h(this,Ze,xc).call(this,{jsonrpc:"2.0",id:r,method:t,params:e}),i}async sendNotification(t,e){h(this,Ze,og).call(this),await h(this,Ze,xc).call(this,{jsonrpc:"2.0",method:t,params:e})}}Gi=new WeakMap,Gd=new WeakMap,pu=new WeakMap,mu=new WeakMap,Ba=new WeakMap,ja=new WeakMap,or=new WeakMap,gu=new WeakMap,Ze=new WeakSet,hS=async function(){let t;try{const e=o(this,Ba).readable.getReader();try{for(;!o(this,or).signal.aborted;){const{value:r,done:i}=await e.read();if(i)break;if(r)try{h(this,Ze,dS).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&h(this,Ze,xc).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{e.releaseLock()}}catch(e){t=e}finally{h(this,Ze,sg).call(this,t)}},sg=function(t){if(o(this,or).signal.aborted)return;const e=t??new Error("ACP connection closed");for(const r of o(this,Gi).values())r.reject(e);o(this,Gi).clear(),o(this,or).abort(e)},dS=async function(t){if("method"in t&&"id"in t){const e=await h(this,Ze,fS).call(this,t.method,t.params);"error"in e&&console.error("Error handling request",t,e.error),await h(this,Ze,xc).call(this,{jsonrpc:"2.0",id:t.id,...e})}else if("method"in t){const e=await h(this,Ze,pS).call(this,t.method,t.params);"error"in e&&console.error("Error handling notification",t,e.error)}else"id"in t?h(this,Ze,mS).call(this,t):console.error("Invalid message",{message:t})},fS=async function(t,e){try{return{result:await o(this,pu).call(this,t,e)??null}}catch(r){if(r instanceof rt)return r.toResult();if(r instanceof M2)return rt.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 rt.internalError(i?JSON.parse(i):{}).toResult()}catch{return rt.internalError({details:i}).toResult()}}},pS=async function(t,e){try{return await o(this,mu).call(this,t,e),{result:null}}catch(r){if(r instanceof rt)return r.toResult();if(r instanceof M2)return rt.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 rt.internalError(i?JSON.parse(i):{}).toResult()}catch{return rt.internalError({details:i}).toResult()}}},mS=function(t){const e=o(this,Gi).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 rt(r,i,s))}o(this,Gi).delete(t.id)}else console.error("Got response to unknown request",t.id)},og=function(){if(o(this,or).signal.aborted)throw o(this,or).signal.reason??new Error("ACP connection closed")},xc=async function(t){return d(this,ja,o(this,ja).then(async()=>{const e=o(this,Ba).writable.getWriter();try{await e.write(t)}finally{e.releaseLock()}}).catch(e=>{h(this,Ze,sg).call(this,e)})),o(this,ja)};class rt extends Error{constructor(e,r,i){super(r);R(this,"code");R(this,"data");this.code=e,this.name="RequestError",this.data=i}static parseError(e,r){return new rt(-32700,`Parse error${r?`: ${r}`:""}`,e)}static invalidRequest(e,r){return new rt(-32600,`Invalid request${r?`: ${r}`:""}`,e)}static methodNotFound(e){return new rt(-32601,`"Method not found": ${e}`,{method:e})}static invalidParams(e,r){return new rt(-32602,`Invalid params${r?`: ${r}`:""}`,e)}static internalError(e,r){return new rt(-32603,`Internal error${r?`: ${r}`:""}`,e)}static authRequired(e,r){return new rt(-32e3,`Authentication required${r?`: ${r}`:""}`,e)}static resourceNotFound(e){return new rt(-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}}}function tD(n,t,e){const r=n.dispose.bind(n);n.dispose=(()=>{if(!t())return e(),r()})}function gS(n){var e;class t extends n{constructor(...s){super(...s);m(this,e,!1);tD(this,()=>o(this,e),()=>{d(this,e,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return o(this,e)}}return e=new WeakMap,t}const nD=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,rD=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,iD=/\[Television channel context\][\s\S]*?\[\/Television channel context\]\n*/,sD=/\b(tv|television|channel|artifact|artifacts|viewer|filmstrip|layout|focus)\b/i,oD=/^[A-Za-z0-9_@%+=:,./-]+$/,aD=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,lD="single_session",cD={name:"television-acp-client",version:"0.0.0"},vS="agent:main:television",uD=gS(Ri);var Wa,ar,rn,lr,Ji,Nn,Jr,cr,zn,Yi,Hn,Ga,Ja,ur,Et,Yr,Ya,mo,Kr,Ki,vu,Zn,hr,Jd,dr,L,ag,yS,wS,bS,ed,SS,_S,AS,ES,kS,TS,CS,Ws,Aa,Ea,Ur,RS,ka,lg,cg,td,IS,nd,ug,hg,yu,wu,rd,Ta,dg,$S;class hD extends uD{constructor(e){super();m(this,L);m(this,Wa,"disconnected");m(this,ar,null);m(this,rn,new Map);m(this,lr,null);m(this,Ji,null);m(this,Nn,null);m(this,Jr,null);m(this,cr,null);m(this,zn,null);m(this,Yi);m(this,Hn,null);m(this,Ga,0);m(this,Ja,1);m(this,ur,null);m(this,Et,null);m(this,Yr,!1);m(this,Ya,!1);m(this,mo,!1);m(this,Kr,null);m(this,Ki,new Set);m(this,vu);m(this,Zn);m(this,hr);m(this,Jd,e=>{h(this,L,wS).call(this,e)});m(this,dr,null);m(this,yu,()=>{h(this,L,Ta).call(this,"ACP bridge websocket closed")});m(this,wu,()=>{h(this,L,Ta).call(this,"ACP bridge websocket error")});d(this,Zn,e),d(this,hr,e.sessionMode??lD),d(this,Yi,e.mappedSessionStore??dD()),d(this,vu,e.createSocket??(r=>new WebSocket(r)))}get status(){return o(this,Wa)}get messages(){return[...o(this,rn).values()]}get enabled(){return o(this,Zn).enabled??!1}setToken(e){o(this,Zn).token=e??""}setEnabled(e){o(this,Zn).enabled=e,e||(h(this,L,rd).call(this),d(this,ar,null),h(this,L,Ur).call(this,"disconnected"))}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(this.enabled&&this.status==="disconnected"){o(this,Ji)===null&&(d(this,ar,null),d(this,Ji,h(this,L,yS).call(this)));try{await o(this,Ji),await h(this,L,ed).call(this)}catch(e){throw h(this,L,Ta).call(this,$m(e)),e}}}dispose(){h(this,L,rd).call(this),d(this,ar,null),h(this,L,Ur).call(this,"disposed")}async sendMessage(e){if(await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await h(this,L,ag).call(this,"ready")),(o(this,cr)===null||o(this,Hn)!==h(this,L,nd).call(this))&&await h(this,L,ed).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");h(this,L,Aa).call(this,{id:h(this,L,ka).call(this,"user"),kind:"user",text:r,status:"final"}),h(this,L,Ur).call(this,"running");try{const i=await h(this,L,td).call(this).prompt({sessionId:h(this,L,cg).call(this),prompt:[{type:"text",text:h(this,L,RS).call(this,r)}]});h(this,L,Ws).call(this,i.stopReason==="cancelled"?"cancelled":"final"),h(this,L,Ur).call(this,"ready")}catch(i){throw h(this,L,$S).call(this)||(h(this,L,Ws).call(this,"error"),h(this,L,Ur).call(this,"ready")),i}}async startNewSession(){var r;await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await h(this,L,ag).call(this,"ready"));const e=h(this,L,nd).call(this);((r=o(this,zn))==null?void 0:r.sessionIdStrategy)==="mapped"?o(this,Yi).clearActualSessionId(e):d(this,Ga,o(this,Ga)+1),d(this,Nn,null),d(this,Jr,null),d(this,cr,null),d(this,Hn,null),h(this,L,dg).call(this)}async cancel(){this.status==="running"&&(h(this,L,Ur).call(this,"cancelling"),await h(this,L,td).call(this).cancel({sessionId:h(this,L,cg).call(this)}))}setChannelContext(e){var s,a,l;if(e===null){if(o(this,Et)===null)return;d(this,Et,null),d(this,Yr,!1);return}const r={channelID:e.channelID,channelName:e.channelName};if(((s=o(this,Et))==null?void 0:s.channelID)===r.channelID&&((a=o(this,Et))==null?void 0:a.channelName)===r.channelName)return;const i=((l=o(this,Et))==null?void 0:l.channelID)??null;if(d(this,Et,r),o(this,hr)==="single_session"){(!o(this,Hn)||i!==r.channelID)&&d(this,Yr,!0);return}o(this,Hn)!==h(this,L,ug).call(this,r.channelID)&&(d(this,Nn,null),d(this,Jr,null),o(this,lr)&&this.status==="ready"&&h(this,L,ed).call(this).catch(c=>{h(this,L,Ta).call(this,$m(c))}))}}Wa=new WeakMap,ar=new WeakMap,rn=new WeakMap,lr=new WeakMap,Ji=new WeakMap,Nn=new WeakMap,Jr=new WeakMap,cr=new WeakMap,zn=new WeakMap,Yi=new WeakMap,Hn=new WeakMap,Ga=new WeakMap,Ja=new WeakMap,ur=new WeakMap,Et=new WeakMap,Yr=new WeakMap,Ya=new WeakMap,mo=new WeakMap,Kr=new WeakMap,Ki=new WeakMap,vu=new WeakMap,Zn=new WeakMap,hr=new WeakMap,Jd=new WeakMap,dr=new WeakMap,L=new WeakSet,ag=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(o(this,ar)??"ACPClient is disconnected");await new Promise((r,i)=>{const s=()=>{this.removeEventListener("status-changed",a)},a=()=>{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(o(this,ar)??"ACPClient is disconnected")))};this.addEventListener("status-changed",a)})}},yS=async function(){try{const{stream:e,socket:r,metadata:i}=await gD({serverURL:o(this,Zn).serverURL,token:o(this,Zn).token,createSocket:o(this,vu),onDisconnect:o(this,Jd)});d(this,zn,i),d(this,dr,r),r.addEventListener("close",o(this,yu)),r.addEventListener("error",o(this,wu)),d(this,lr,new Q5(s=>({connection:s,sessionUpdate:async a=>{await h(this,L,_S).call(this,a)},requestPermission:async a=>h(this,L,AS).call(this,a)}),e)),await o(this,lr).initialize({protocolVersion:M$,clientCapabilities:{},clientInfo:cD})}catch(e){throw e}},wS=function(e){h(this,L,Ta).call(this,$m(e))},bS=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})`)},ed=async function(){const e=h(this,L,nd).call(this);if(o(this,Nn)&&o(this,Jr)===e){await o(this,Nn);return}d(this,Jr,e),d(this,Nn,h(this,L,SS).call(this,e)),await o(this,Nn)},SS=async function(e){var c;const r=h(this,L,td).call(this);h(this,L,dg).call(this);let i,s=!1,a=null;const l={cwd:h(this,L,IS).call(this),mcpServers:[],_meta:{sessionKey:e}};try{if(d(this,mo,!0),d(this,Kr,null),((c=o(this,zn))==null?void 0:c.sessionIdStrategy)==="mapped"){const u=o(this,Yi).getActualSessionId(e);if(u)try{const f=await r.loadSession({...l,sessionId:u});if(fD(f))throw new Error("Mapped ACP session was not found");a=f,i=u,s=!0}catch{const f=await r.newSession(l);a=f,i=f.sessionId,o(this,Yi).setActualSessionId(e,i),s=!1}else{const f=await r.newSession(l);a=f,i=f.sessionId,o(this,Yi).setActualSessionId(e,i),s=!1}}else try{a=await r.loadSession({...l,sessionId:e}),i=e,s=o(this,rn).size>0}catch{const u=await r.newSession(l);a=u,i=u.sessionId,s=!1}}finally{d(this,mo,!1),d(this,Kr,null),h(this,L,Ws).call(this,"final")}h(this,L,bS).call(this,a),await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),d(this,cr,i),d(this,Hn,e),d(this,Ya,!0),s?(o(this,Ki).add(e),o(this,hr)==="single_session"&&d(this,Yr,!1)):(o(this,Ki).delete(e),d(this,Yr,o(this,hr)==="single_session")),d(this,ar,null),h(this,L,Ur).call(this,"ready")},_S=async function(e){const r=e.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&h(this,L,CS).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&h(this,L,ES).call(this,r.content.text);return;case"tool_call":h(this,L,kS).call(this,r);return;case"tool_call_update":h(this,L,TS).call(this,r);return;case"agent_thought_chunk":return;default:return}},AS=async function(e){return{outcome:{outcome:"cancelled"}}},ES=function(e){d(this,Kr,null);const r=mD(e);if(!r)return;if(!o(this,ur)){const s={id:h(this,L,ka).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};d(this,ur,s.id),h(this,L,Aa).call(this,s);return}const i=o(this,rn).get(o(this,ur));if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");h(this,L,Ea).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},kS=function(e){h(this,L,Ws).call(this,"final");const r=h(this,L,lg).call(this,e.toolCallId),i=G2("content"in e?e.content:void 0),s={id:(r==null?void 0:r.id)??h(this,L,ka).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){h(this,L,Ea).call(this,s);return}h(this,L,Aa).call(this,s)},TS=function(e){const r=h(this,L,lg).call(this,e.toolCallId),i=(r==null?void 0:r.text)??"",s=G2(e.content),a=s?`${i}${s}`:i,l={id:(r==null?void 0:r.id)??h(this,L,ka).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:a,locations:e.locations??(r==null?void 0:r.locations)};if(r){h(this,L,Ea).call(this,l);return}h(this,L,Aa).call(this,l)},CS=function(e){if(h(this,L,Ws).call(this,"final"),!e)return;const r=o(this,mo)?o(this,Kr):null;if(!r){const s=W2(e);if(!s)return;const a={id:h(this,L,ka).call(this,"user"),kind:"user",text:s,status:"final"};h(this,L,Aa).call(this,a),o(this,mo)&&d(this,Kr,a.id);return}const i=o(this,rn).get(r);if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");h(this,L,Ea).call(this,{...i,text:W2(`${i.text}${e}`)})},Ws=function(e){if(!o(this,ur))return;const r=o(this,rn).get(o(this,ur));(r==null?void 0:r.kind)==="assistant"&&h(this,L,Ea).call(this,{...r,status:e}),d(this,ur,null)},Aa=function(e){o(this,rn).set(e.id,e),this.dispatchEvent(new Tm("messages-changed"))},Ea=function(e){o(this,rn).set(e.id,e),this.dispatchEvent(new Tm("messages-changed"))},Ur=function(e){o(this,Wa)!==e&&(d(this,Wa,e),this.dispatchEvent(new bT("status-changed")))},RS=function(e){var u;const r=o(this,Hn);if(!r)return e;const i=o(this,Et)?o(this,hr)==="single_session"?o(this,Yr)||!o(this,Ki).has(r):!o(this,Ki).has(r):!1,s=o(this,Ya)&&(o(this,Et)!==null||sD.test(e));if(!(s||i))return e;s&&d(this,Ya,!1),i&&(d(this,Yr,!1),o(this,Ki).add(r));const l=["[Television channel 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>`."],c=((u=o(this,zn))==null?void 0:u.tvArgs)??[];return c.length>0&&l.push(`To reach this Television server, add these arguments to each tv command that contacts it: ${c.map(wD).join(" ")}`),o(this,Et)?(l.push("This conversation is currently attached to the channel below."),l.push(`channel_id: ${o(this,Et).channelID}`),l.push(`channel_name: ${o(this,Et).channelName??""}`),l.push("When the user asks to inspect or change Television state with the tv CLI, use this channel ID with the --channel argument.")):l.push("There is currently no active Television channel."),l.push("[/Television channel context]","",e),l.join(`
65
- `)},ka=function(e){const r=`${e}-${o(this,Ja)}`;return d(this,Ja,o(this,Ja)+1),r},lg=function(e){for(const r of o(this,rn).values())if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===e)return r;return null},cg=function(){if(!o(this,cr))throw new Error("ACP session is not ready");return o(this,cr)},td=function(){if(!o(this,lr))throw new Error("ACP connection is not ready");return o(this,lr)},IS=function(){var r;const e=(r=o(this,zn))==null?void 0:r.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},nd=function(){var r;if(o(this,hr)==="single_session")return h(this,L,hg).call(this,`${vS}-${(o(this,Zn).clientGUID??"default-client").toLowerCase()}`);const e=(r=o(this,Et))==null?void 0:r.channelID;if(!e)throw new Error("Channel context is required for per-channel session mode");return h(this,L,ug).call(this,e)},ug=function(e){return h(this,L,hg).call(this,pD(o(this,hr),e,o(this,Zn).clientGUID??"default-client"))},hg=function(e){var r;return((r=o(this,zn))==null?void 0:r.sessionIdStrategy)==="deterministic"&&o(this,Ga)>0?`${e}:epoch-${o(this,Ga)}`:e},yu=new WeakMap,wu=new WeakMap,rd=function(){d(this,lr,null),d(this,Ji,null),d(this,Nn,null),d(this,Jr,null),d(this,cr,null),d(this,Hn,null),d(this,zn,null),o(this,dr)&&(o(this,dr).removeEventListener("close",o(this,yu)),o(this,dr).removeEventListener("error",o(this,wu)),o(this,dr).close(),d(this,dr,null))},Ta=function(e){const r=o(this,lr)!==null||o(this,Ji)!==null||o(this,Nn)!==null||o(this,Jr)!==null||o(this,cr)!==null||o(this,Hn)!==null||o(this,zn)!==null||o(this,dr)!==null;this.disposed||this.status==="disconnected"&&!r||(h(this,L,Ws).call(this,"error"),h(this,L,rd).call(this),d(this,ar,e??null),h(this,L,Ur).call(this,"disconnected"))},dg=function(){const e=o(this,rn).size>0;d(this,ur,null),d(this,Kr,null),d(this,Ja,1),o(this,rn).clear(),e&&this.dispatchEvent(new Tm("messages-changed"))},$S=function(){return this.status==="disconnected"};function dD(){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 fD(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function pD(n,t,e){return n==="single_session"?`${vS}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function xS(n){return n.replace(/^(?:\s*\n)+/,"")}function W2(n){let t=n;return t=t.replace(nD,""),t=t.replace(rD,""),t=t.replace(iD,""),t=xS(t),t}function mD(n){let t=n;return t=t.replace(aD,""),t=xS(t),t}function G2(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function gD(n){const t=n.createSocket(SD(n.serverURL,n.token));let e=!1,r,i;const s=new Promise((u,f)=>{r=u,i=f}),a=new ReadableStream({start(u){let f=!1;const p=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},y=_=>{const $=bD(_);if(!$)return;let Z;try{Z=JSON.parse($)}catch(O){const z=O instanceof Error?O:new Error(String(O));i(z),u.error(z);return}switch(Z.type){case"acp-bridge-status":if(Z.status==="ready"){let O;try{O=vD(Z)}catch(z){const P=z instanceof Error?z:new Error(String(z));e||i(P),u.error(P);return}e||(e=!0,r(O));return}if(Z.status==="error"||Z.status==="exited"){const O=new Error(Z.error??`ACP bridge ${Z.status}`);e||i(O),u.error(O)}return;case"acp-bridge-message":u.enqueue(Z.message);return}},v=()=>{var $;if(f)return;f=!0;const _=new Error("ACP bridge websocket closed");e||i(_),($=n.onDisconnect)==null||$.call(n,_),u.close()},S=()=>{var $;if(f)return;f=!0;const _=new Error("ACP bridge websocket error");e||i(_),($=n.onDisconnect)==null||$.call(n,_),u.error(_)};t.addEventListener("open",p),t.addEventListener("message",y),t.addEventListener("close",v),t.addEventListener("error",S)}}),l=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:a,writable:l},socket:t,metadata:c}}function vD(n){const{agent:t,sessionIdStrategy:e,sessionCwd:r,tvArgs:i}=n;if((t==="openclaw"||t==="hermes")&&(e==="deterministic"||e==="mapped")&&typeof r=="string"&&r.length>0&&yD(i))return{agent:t,sessionIdStrategy:e,sessionCwd:r,tvArgs:i};throw new Error("ACP bridge ready status missing bootstrap metadata")}function yD(n){return Array.isArray(n)&&n.every(t=>typeof t=="string")}function wD(n){return oD.test(n)?n:`'${n.replace(/'/g,"'\\''")}'`}function bD(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 SD(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 $m(n){return n instanceof Error?n.message:String(n)}const J2="television.acpClientGUID",Y2="television.acpMappedSessions",K2=1;var Ka;class _D{constructor(){m(this,Ka,new Map)}getActualSessionId(t){return o(this,Ka).get(t)??null}setActualSessionId(t,e){o(this,Ka).set(t,e)}clearActualSessionId(t){o(this,Ka).delete(t)}}Ka=new WeakMap;var Xa,bu,hn,id,sd,fg;class AD{constructor(t,e){m(this,hn);m(this,Xa);m(this,bu);d(this,Xa,t),d(this,bu,e)}getActualSessionId(t){const e=h(this,hn,sd).call(this)[h(this,hn,id).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const r=h(this,hn,sd).call(this);r[h(this,hn,id).call(this,t)]=e,h(this,hn,fg).call(this,r)}clearActualSessionId(t){const e=h(this,hn,sd).call(this);delete e[h(this,hn,id).call(this,t)],h(this,hn,fg).call(this,e)}}Xa=new WeakMap,bu=new WeakMap,hn=new WeakSet,id=function(t){return JSON.stringify([o(this,bu),t])},sd=function(){const t=o(this,Xa).getItem(Y2);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!==K2?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},fg=function(t){const e={version:K2,entries:t};o(this,Xa).setItem(Y2,JSON.stringify(e))};function PS(){return typeof window>"u"?null:window.localStorage}function ED(n){const t=n.getItem(J2);if(t)return t;const e=Q1().toLowerCase();return n.setItem(J2,e),e}const X2=4401,kD=401,Fh=1e3,TD=3e4;class od extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class CD extends Ri{constructor(e){var a,l;super();R(this,"url");R(this,"name");R(this,"telemetryMeta");R(this,"status","unauthorized");R(this,"channels",new Map);R(this,"client");R(this,"acpClient");R(this,"_token");R(this,"attempting",!1);R(this,"nextRetryAt",null);R(this,"hasEverConnected",!1);R(this,"failedReconnectAttempts",0);R(this,"browserDemoMode",!1);R(this,"hasAuthRejected",!1);R(this,"bootState","pending");R(this,"serverVersion",null);R(this,"updateState",null);R(this,"decideBoot");R(this,"navigationPending");R(this,"createSocket");R(this,"createClient");R(this,"socket",null);R(this,"connectAttempt",0);R(this,"autoReconnect",!1);R(this,"retryTimer",null);R(this,"retryDelay",Fh);R(this,"visibilityEventTarget");R(this,"networkEventTarget");R(this,"onVisibilityChange");R(this,"onNetworkOnline");R(this,"telemetryActivityAgent");this.url=oa(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,f)=>new Wk(c,{token:u??void 0,onUnauthorized:()=>this.handleAuthRejected(),...f?{telemetryMeta:f}:{}})),this.client=this.createClient(this.url,this._token,this.telemetryMeta);const r=e.mappedSessionStore??(e.acpStorage?new AD(e.acpStorage,this.url):new _D);this.acpClient=new hD({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()},(a=this.visibilityEventTarget)==null||a.addEventListener("visibilitychange",this.onVisibilityChange),(l=this.networkEventTarget)==null||l.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?D$({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=Fh,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=nu(e,this.renderOptions());return bi()?new URL(r.viewURL,this.url).toString():r.renderer==="proxy-iframe"?new URL(r.viewURL,this.url).toString():r.viewURL}async readDemoMode(){try{return await this.client.demoMode()}catch{return null}}renderOptions(){return{electron:bi(),browserDemo:this.browserDemoMode}}getContentURL(e){const r=nu(e,this.renderOptions()).contentURL;return r===null?null:new URL(r,this.url).toString()}async createChannel(e){const{channel:r}=await this.client.channels.create({name:e});return this.channels.set(r.id,structuredClone(r)),r}applyServerEvent(e){switch(e.type){case"channel-created":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new Ic("channels-changed"));break;case"channel-updated":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new Ic("channels-changed"));break;case"channel-removed":this.channels.delete(e.channelID),this.dispatchEvent(new Ic("channels-changed"));break;case"artifact-created":{const r=this.channels.get(e.channelID);r&&!dk(r).includes(e.artifact.id)&&(r.layout=[...r.layout,{artifactIds:[e.artifact.id],geometry:{...P8},size:{...D8}}]);break}case"artifact-removed":{const r=this.channels.get(e.channelID);r&&(r.layout=Vm(r.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"channel-changed":case"pinned-channels-changed":case"theme-changed":case"appearance-changed":case"artifact-focus":break;default:return RD(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 Wt("change"));const r=this.createSocket(ID(this.url,this._token,this.telemetryMeta));return this.socket=r,await new Promise((s,a)=>{let l=!1,c=!1;const u=()=>{var y;l||this.connectAttempt!==e||(l=!0,c=!0,this.retryDelay=Fh,this.hasEverConnected=!0,this.failedReconnectAttempts=0,this.setStatus("connected"),(y=this.telemetryActivityAgent)==null||y.start(),s())},f=y=>{l||this.connectAttempt!==e||(l=!0,a(y))},p=async()=>{const y=this.hasEverConnected;try{const[{channels:v},S,_]=await Promise.all([this.client.channels.list(),this.client.display.get(),y?null:this.readDemoMode()]);y||(this.browserDemoMode=(_==null?void 0:_.browserExternalPages)===!0),this.channels=new Map(v.map($=>[$.id,structuredClone($)])),this.acpClient.setEnabled(S.acpEnabled),this.dispatchEvent(new Wt("change")),y&&this.dispatchEvent(new Ic("channels-changed")),this.dispatchEvent(new Xh("server-event",{event:{type:"channel-changed",channelID:S.focusedChannelId}})),this.dispatchEvent(new Xh("server-event",{event:{type:"pinned-channels-changed",pinnedChannelIds:[...S.pinnedChannelIds]}})),u(),y&&this.connectAttempt===e&&this.dispatchEvent(new J8("server-reconnected"))}catch(v){if(LD(v)){f(new od);return}f(v instanceof Error?v:new Error(String(v)))}};r.addEventListener("open",()=>{this.decideBoot===null&&(this.bootState="booted",this.navigationPending()||p())}),r.addEventListener("message",y=>{const v=OD(y);if(!v)return;if(v.type==="server-status"){const _=v;this.serverVersion=_.version,this.updateState=_.update??null;let $=!1;this.decideBoot!==null&&this.bootState==="pending"&&this.connectAttempt===e&&(this.decideBoot(_)==="boot"?(this.bootState="booted",$=!0):(this.bootState="halted",this.attempting=!1)),this.dispatchEvent(new Y8("server-status",{message:_})),$?this.navigationPending()||p():this.bootState==="halted"&&!this.navigationPending()&&this.dispatchEvent(new Wt("change"));return}if(!DD(v.type))return;const S=v;this.applyServerEvent(S),this.dispatchEvent(new Xh("server-event",{event:S}))}),r.addEventListener("close",y=>{if(this.connectAttempt!==e)return;this.socket=null;const v=$D(y);if(!l){f(v===X2?new od:new Error("Connection closed before initialization"));return}if(c){if(v===X2){this.handleAuthRejected();return}this.handleTransportFailure(new Error("Connection closed"))}}),r.addEventListener("error",()=>{if(this.connectAttempt===e){if(l){if(!c)return;this.handleTransportFailure(new Error("WebSocket error"));return}f(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 od){this.handleAuthRejected();return}this.autoReconnect&&(this.hasEverConnected&&(this.failedReconnectAttempts+=1),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,TD),this.nextRetryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},e),this.dispatchEvent(new Wt("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new Wt("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=Fh,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:hk,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 Wt("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function RD(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function ID(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 P$(e))r.searchParams.set(i,s);return r.hash="",r.toString()}function $D(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}const xD={"artifact-created":!0,"artifact-updated":!0,"artifact-content-changed":!0,"artifact-removed":!0,"channel-created":!0,"channel-updated":!0,"channel-removed":!0,"channel-changed":!0,"pinned-channels-changed":!0,"theme-changed":!0,"appearance-changed":!0,"artifact-focus":!0},PD=new Set(Object.keys(xD));function DD(n){return PD.has(n)}function OD(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 LD(n){return n instanceof Ql&&n.status===kD}const MD="Local";var fr,Un,Ei,DS,pg,OS,Su,_u,Au,Eu,ku;class ND extends Ri{constructor(e){super();m(this,Ei);R(this,"connection");R(this,"clientGUID");R(this,"acpStorage");R(this,"connectError",null);m(this,fr);m(this,Un,!1);m(this,Su,()=>{o(this,Un)||(h(this,Ei,OS).call(this),this.dispatchEvent(new Wt("change")))});m(this,_u,e=>{o(this,Un)||this.dispatchEvent(new Xh("server-event",{event:e.event}))});m(this,Au,()=>{o(this,Un)||this.dispatchEvent(new Ic("channels-changed"))});m(this,Eu,()=>{o(this,Un)||this.dispatchEvent(new J8("server-reconnected"))});m(this,ku,e=>{o(this,Un)||this.dispatchEvent(new Y8("server-status",{message:e.message}))});d(this,fr,e.localStore),this.acpStorage=e.acpStorage===void 0?PS():e.acpStorage,this.clientGUID=e.clientGUID??(this.acpStorage?ED(this.acpStorage):Q1().toLowerCase());const r=oa(e.serverURL);e.launchToken!==void 0&&e.launchToken!==null&&o(this,fr).set(ET(o(this,fr).get(),r,e.launchToken));const i=e.launchToken??w2(o(this,fr).get(),r),s=e.createSocket??(l=>new WebSocket(l)),a=e.createConnection??(l=>new CD(l));this.connection=a({url:r,name:e.connectionName??MD,token:i,createSocket:s,clientGUID:this.clientGUID,acpStorage:this.acpStorage,telemetryMeta:e.telemetryMeta??null,decideBoot:e.decideBoot,navigationPending:e.navigationPending}),this.connection.addEventListener("change",o(this,Su)),this.connection.addEventListener("server-event",o(this,_u)),this.connection.addEventListener("channels-changed",o(this,Au)),this.connection.addEventListener("server-reconnected",o(this,Eu)),this.connection.addEventListener("server-status",o(this,ku))}get storedAuthToken(){return w2(o(this,fr).get(),this.connection.url)}async connect(){await h(this,Ei,DS).call(this,this.connection.token)}dispose(){o(this,Un)||(d(this,Un,!0),this.connection.removeEventListener("change",o(this,Su)),this.connection.removeEventListener("server-event",o(this,_u)),this.connection.removeEventListener("channels-changed",o(this,Au)),this.connection.removeEventListener("server-reconnected",o(this,Eu)),this.connection.removeEventListener("server-status",o(this,ku)),this.connection.dispose())}}fr=new WeakMap,Un=new WeakMap,Ei=new WeakSet,DS=async function(e){if(!o(this,Un)){h(this,Ei,pg).call(this,null);try{await this.connection.connect(e)}catch(r){h(this,Ei,pg).call(this,r instanceof od?null:r instanceof Error?r.message:String(r))}}},pg=function(e){this.connectError!==e&&(this.connectError=e,this.dispatchEvent(new Wt("change")))},OS=function(){if(this.connection.status!=="unauthorized"||!this.connection.hasAuthRejected)return;const e=o(this,fr).get(),r=kT(e,this.connection.url);r!==e&&o(this,fr).set(r),this.connection.token!==null&&this.connection.clearToken()},Su=new WeakMap,_u=new WeakMap,Au=new WeakMap,Eu=new WeakMap,ku=new WeakMap;const mg="tv-nav:",Vl="tv-reload",Q2=100,zD=1e3,HD=60,ZD=60,UD=24,FD=30,qD=FD*UD*ZD*HD*zD;function Si(n){try{const t=new URL(n,window.location.href),e=t.searchParams.has(Vl);return t.searchParams.delete(Vl),t.origin===window.location.origin?`${t.pathname}${t.search}${t.hash}`:e?t.toString():n}catch{return n}}var Tu,Qa,$e,Ce,go,Ke,LS,zi,MS,gg,vg;class VD extends Ri{constructor(e,r){super();m(this,Ke);m(this,Tu);m(this,Qa);m(this,$e,[]);m(this,Ce,-1);m(this,go,0);d(this,Tu,e),d(this,Qa,Si(r)),h(this,Ke,LS).call(this)}get currentURL(){var e;return o(this,Ce)===-1?null:((e=o(this,$e)[o(this,Ce)])==null?void 0:e.url)??null}get canGoBack(){return o(this,Ce)>-1}get canGoForward(){return o(this,Ce)<o(this,$e).length-1}get entries(){return o(this,$e).map(e=>({...e}))}get cursor(){return o(this,Ce)}navigate(e){const r=Si(e);if(r===o(this,Qa)){if(o(this,Ce)===-1)return;d(this,Ce,-1),h(this,Ke,zi).call(this);return}o(this,Ce)<o(this,$e).length-1&&d(this,$e,o(this,$e).slice(0,o(this,Ce)+1)),o(this,$e).push({url:r}),d(this,Ce,o(this,$e).length-1),h(this,Ke,gg).call(this),h(this,Ke,zi).call(this)}replace(e){var i;if(o(this,Ce)===-1){this.navigate(e);return}const r=Si(e);if(r===o(this,Qa)){d(this,$e,o(this,$e).filter((s,a)=>a!==o(this,Ce))),d(this,Ce,-1),h(this,Ke,zi).call(this);return}((i=o(this,$e)[o(this,Ce)])==null?void 0:i.url)!==r&&(d(this,$e,o(this,$e).map((s,a)=>a===o(this,Ce)?{url:r}:s)),h(this,Ke,zi).call(this))}back(){o(this,Ce)!==-1&&(d(this,Ce,o(this,Ce)-1),h(this,Ke,zi).call(this))}forward(){this.canGoForward&&(d(this,Ce,o(this,Ce)+1),h(this,Ke,zi).call(this))}reset(){o(this,Ce)===-1&&o(this,$e).length===0||(d(this,$e,[]),d(this,Ce,-1),h(this,Ke,zi).call(this))}}Tu=new WeakMap,Qa=new WeakMap,$e=new WeakMap,Ce=new WeakMap,go=new WeakMap,Ke=new WeakSet,LS=function(){const e=localStorage.getItem(o(this,Ke,vg));if(e!==null)try{const r=JSON.parse(e);if(!NS(r))return;d(this,$e,r.entries.map(i=>({url:i.url}))),d(this,Ce,r.cursor),d(this,go,r.lastWritten),h(this,Ke,gg).call(this)}catch{d(this,$e,[]),d(this,Ce,-1),d(this,go,0)}},zi=function(){d(this,go,Date.now());try{localStorage.setItem(o(this,Ke,vg),JSON.stringify(h(this,Ke,MS).call(this)))}catch(e){if(!WD(e))throw e}this.dispatchEvent(new Wt("change"))},MS=function(){return{v:1,entries:o(this,$e).map(e=>({...e})),cursor:o(this,Ce),lastWritten:o(this,go)}},gg=function(){if(o(this,$e).length<=Q2)return;const e=o(this,$e).length-Q2;d(this,$e,o(this,$e).slice(e)),d(this,Ce,Math.max(-1,o(this,Ce)-e))},vg=function(){return BD(o(this,Tu))};function BD(n){return`${mg}${n}`}function jD(n){const t=Date.now()-qD,e=[];for(let r=0;r<localStorage.length;r+=1){const i=localStorage.key(r);if(!(i!=null&&i.startsWith(mg)))continue;const s=i.slice(mg.length),a=localStorage.getItem(i);if(a===null)continue;let l;try{l=JSON.parse(a)}catch{e.push(i);continue}if(!NS(l)){e.push(i);continue}!n.has(s)&&l.lastWritten<t&&e.push(i)}for(const r of e)localStorage.removeItem(r)}function WD(n){return n instanceof DOMException&&n.name==="QuotaExceededError"}function NS(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 xm="tv-channel-sidebar-collapsed";var vo;class GD{constructor(t){m(this,vo);d(this,vo,t)}read(){return o(this,vo).getItem(xm)==="true"}setCollapsed(t){try{t?o(this,vo).setItem(xm,"true"):o(this,vo).removeItem(xm)}catch{}}}vo=new WeakMap;const Pm="tv-channel-sidebar-width",yg=160,wg=350,qh=260,JD=/^-?\d+$/;var yo;class YD{constructor(t){m(this,yo);d(this,yo,t)}read(){const t=o(this,yo).getItem(Pm);if(t===null||!JD.test(t))return null;const e=BigInt(t);return e<BigInt(yg)?yg:e>BigInt(wg)?wg:Number(e)}commit(t){const e=zS(Math.round(t));try{o(this,yo).setItem(Pm,String(e))}catch{}return e}clear(){try{o(this,yo).removeItem(Pm)}catch{}}}yo=new WeakMap;function zS(n){return Math.min(Math.max(n,yg),wg)}const KD="1.5.1";function uv(n=KD){return n!==void 0&&n.length>0?n:"0.0.0"}function hv(){let n=!1;return{get pending(){return n},begin(t){n||(n=!0,t())}}}const bg="tv-reload-attempted";function XD(n){return n.marker!==null&&n.bundleVersion===n.serverVersion?{action:"signal-autoreloaded",fromVersion:n.marker.fromVersion,toVersion:n.bundleVersion}:Yk(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"}}function QD(n){const t=n.getItem(bg);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 eO(n){const t=n.storage!==void 0?n.storage:typeof sessionStorage<"u"?sessionStorage:null,e=n.reload??(()=>location.reload()),r=n.navigationLatch??hv(),i=n.bundleVersion??uv();if(t===null)return{dispose(){}};let s=null;const a=()=>{if(s===null)return;const u=n.owner.connection;if(u.status!=="connected")return;const f=s;s=null,u.sendTelemetrySignal("client_autoreloaded",{from_version:f.fromVersion,to_version:f.toVersion})},l=u=>{if(r.pending)return;const f=XD({bundleVersion:i,serverVersion:u.message.version,marker:QD(t)});switch(f.action){case"reload":t.setItem(bg,JSON.stringify(f.marker)),r.begin(e);return;case"signal-autoreloaded":t.removeItem(bg),s={fromVersion:f.fromVersion,toVersion:f.toVersion},a();return;case"none":return}},c=()=>{a()};return n.owner.addEventListener("server-status",l),n.owner.addEventListener("change",c),{dispose(){n.owner.removeEventListener("server-status",l),n.owner.removeEventListener("change",c)}}}function tO(n){const t=bi(n.search),e=O6(n.search),r=e!==null&&Ff(e)?e:null;return{electron:t,shellVersion:r}}function nO(n){return!n.electron||n.requiredDesktopVersion===null||!Ff(n.requiredDesktopVersion)?!1:n.shellVersion===null?!0:n.shellVersion===Id?!1:X1(n.requiredDesktopVersion,n.shellVersion)}const rO=`# Desktop app update required
65
+ `)},ka=function(e){const r=`${e}-${o(this,Ja)}`;return d(this,Ja,o(this,Ja)+1),r},lg=function(e){for(const r of o(this,rn).values())if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===e)return r;return null},cg=function(){if(!o(this,cr))throw new Error("ACP session is not ready");return o(this,cr)},td=function(){if(!o(this,lr))throw new Error("ACP connection is not ready");return o(this,lr)},IS=function(){var r;const e=(r=o(this,zn))==null?void 0:r.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},nd=function(){var r;if(o(this,hr)==="single_session")return h(this,L,hg).call(this,`${vS}-${(o(this,Zn).clientGUID??"default-client").toLowerCase()}`);const e=(r=o(this,Et))==null?void 0:r.channelID;if(!e)throw new Error("Channel context is required for per-channel session mode");return h(this,L,ug).call(this,e)},ug=function(e){return h(this,L,hg).call(this,pD(o(this,hr),e,o(this,Zn).clientGUID??"default-client"))},hg=function(e){var r;return((r=o(this,zn))==null?void 0:r.sessionIdStrategy)==="deterministic"&&o(this,Ga)>0?`${e}:epoch-${o(this,Ga)}`:e},yu=new WeakMap,wu=new WeakMap,rd=function(){d(this,lr,null),d(this,Ji,null),d(this,Nn,null),d(this,Jr,null),d(this,cr,null),d(this,Hn,null),d(this,zn,null),o(this,dr)&&(o(this,dr).removeEventListener("close",o(this,yu)),o(this,dr).removeEventListener("error",o(this,wu)),o(this,dr).close(),d(this,dr,null))},Ta=function(e){const r=o(this,lr)!==null||o(this,Ji)!==null||o(this,Nn)!==null||o(this,Jr)!==null||o(this,cr)!==null||o(this,Hn)!==null||o(this,zn)!==null||o(this,dr)!==null;this.disposed||this.status==="disconnected"&&!r||(h(this,L,Ws).call(this,"error"),h(this,L,rd).call(this),d(this,ar,e??null),h(this,L,Ur).call(this,"disconnected"))},dg=function(){const e=o(this,rn).size>0;d(this,ur,null),d(this,Kr,null),d(this,Ja,1),o(this,rn).clear(),e&&this.dispatchEvent(new Tm("messages-changed"))},$S=function(){return this.status==="disconnected"};function dD(){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 fD(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function pD(n,t,e){return n==="single_session"?`${vS}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function xS(n){return n.replace(/^(?:\s*\n)+/,"")}function W2(n){let t=n;return t=t.replace(nD,""),t=t.replace(rD,""),t=t.replace(iD,""),t=xS(t),t}function mD(n){let t=n;return t=t.replace(aD,""),t=xS(t),t}function G2(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function gD(n){const t=n.createSocket(SD(n.serverURL,n.token));let e=!1,r,i;const s=new Promise((u,f)=>{r=u,i=f}),a=new ReadableStream({start(u){let f=!1;const p=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},y=_=>{const $=bD(_);if(!$)return;let Z;try{Z=JSON.parse($)}catch(O){const z=O instanceof Error?O:new Error(String(O));i(z),u.error(z);return}switch(Z.type){case"acp-bridge-status":if(Z.status==="ready"){let O;try{O=vD(Z)}catch(z){const P=z instanceof Error?z:new Error(String(z));e||i(P),u.error(P);return}e||(e=!0,r(O));return}if(Z.status==="error"||Z.status==="exited"){const O=new Error(Z.error??`ACP bridge ${Z.status}`);e||i(O),u.error(O)}return;case"acp-bridge-message":u.enqueue(Z.message);return}},v=()=>{var $;if(f)return;f=!0;const _=new Error("ACP bridge websocket closed");e||i(_),($=n.onDisconnect)==null||$.call(n,_),u.close()},S=()=>{var $;if(f)return;f=!0;const _=new Error("ACP bridge websocket error");e||i(_),($=n.onDisconnect)==null||$.call(n,_),u.error(_)};t.addEventListener("open",p),t.addEventListener("message",y),t.addEventListener("close",v),t.addEventListener("error",S)}}),l=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:a,writable:l},socket:t,metadata:c}}function vD(n){const{agent:t,sessionIdStrategy:e,sessionCwd:r,tvArgs:i}=n;if((t==="openclaw"||t==="hermes")&&(e==="deterministic"||e==="mapped")&&typeof r=="string"&&r.length>0&&yD(i))return{agent:t,sessionIdStrategy:e,sessionCwd:r,tvArgs:i};throw new Error("ACP bridge ready status missing bootstrap metadata")}function yD(n){return Array.isArray(n)&&n.every(t=>typeof t=="string")}function wD(n){return oD.test(n)?n:`'${n.replace(/'/g,"'\\''")}'`}function bD(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 SD(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 $m(n){return n instanceof Error?n.message:String(n)}const J2="television.acpClientGUID",Y2="television.acpMappedSessions",K2=1;var Ka;class _D{constructor(){m(this,Ka,new Map)}getActualSessionId(t){return o(this,Ka).get(t)??null}setActualSessionId(t,e){o(this,Ka).set(t,e)}clearActualSessionId(t){o(this,Ka).delete(t)}}Ka=new WeakMap;var Xa,bu,hn,id,sd,fg;class AD{constructor(t,e){m(this,hn);m(this,Xa);m(this,bu);d(this,Xa,t),d(this,bu,e)}getActualSessionId(t){const e=h(this,hn,sd).call(this)[h(this,hn,id).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const r=h(this,hn,sd).call(this);r[h(this,hn,id).call(this,t)]=e,h(this,hn,fg).call(this,r)}clearActualSessionId(t){const e=h(this,hn,sd).call(this);delete e[h(this,hn,id).call(this,t)],h(this,hn,fg).call(this,e)}}Xa=new WeakMap,bu=new WeakMap,hn=new WeakSet,id=function(t){return JSON.stringify([o(this,bu),t])},sd=function(){const t=o(this,Xa).getItem(Y2);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!==K2?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},fg=function(t){const e={version:K2,entries:t};o(this,Xa).setItem(Y2,JSON.stringify(e))};function PS(){return typeof window>"u"?null:window.localStorage}function ED(n){const t=n.getItem(J2);if(t)return t;const e=Q1().toLowerCase();return n.setItem(J2,e),e}const X2=4401,kD=401,Fh=1e3,TD=3e4;class od extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class CD extends Ri{constructor(e){var a,l;super();R(this,"url");R(this,"name");R(this,"telemetryMeta");R(this,"status","unauthorized");R(this,"channels",new Map);R(this,"client");R(this,"acpClient");R(this,"_token");R(this,"attempting",!1);R(this,"nextRetryAt",null);R(this,"hasEverConnected",!1);R(this,"failedReconnectAttempts",0);R(this,"browserDemoMode",!1);R(this,"hasAuthRejected",!1);R(this,"bootState","pending");R(this,"serverVersion",null);R(this,"updateState",null);R(this,"decideBoot");R(this,"navigationPending");R(this,"createSocket");R(this,"createClient");R(this,"socket",null);R(this,"connectAttempt",0);R(this,"autoReconnect",!1);R(this,"retryTimer",null);R(this,"retryDelay",Fh);R(this,"visibilityEventTarget");R(this,"networkEventTarget");R(this,"onVisibilityChange");R(this,"onNetworkOnline");R(this,"telemetryActivityAgent");this.url=oa(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,f)=>new Wk(c,{token:u??void 0,onUnauthorized:()=>this.handleAuthRejected(),...f?{telemetryMeta:f}:{}})),this.client=this.createClient(this.url,this._token,this.telemetryMeta);const r=e.mappedSessionStore??(e.acpStorage?new AD(e.acpStorage,this.url):new _D);this.acpClient=new hD({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()},(a=this.visibilityEventTarget)==null||a.addEventListener("visibilitychange",this.onVisibilityChange),(l=this.networkEventTarget)==null||l.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?D$({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=Fh,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=nu(e,this.renderOptions());return bi()?new URL(r.viewURL,this.url).toString():r.renderer==="proxy-iframe"?new URL(r.viewURL,this.url).toString():r.viewURL}async readDemoMode(){try{return await this.client.demoMode()}catch{return null}}renderOptions(){return{electron:bi(),browserDemo:this.browserDemoMode}}getContentURL(e){const r=nu(e,this.renderOptions()).contentURL;return r===null?null:new URL(r,this.url).toString()}async createChannel(e){const{channel:r}=await this.client.channels.create({name:e});return this.channels.set(r.id,structuredClone(r)),r}applyServerEvent(e){switch(e.type){case"channel-created":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new Ic("channels-changed"));break;case"channel-updated":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new Ic("channels-changed"));break;case"channel-removed":this.channels.delete(e.channelID),this.dispatchEvent(new Ic("channels-changed"));break;case"artifact-created":{const r=this.channels.get(e.channelID);r&&!dk(r).includes(e.artifact.id)&&(r.layout=[...r.layout,{artifactIds:[e.artifact.id],geometry:{...P8},size:{...D8}}]);break}case"artifact-removed":{const r=this.channels.get(e.channelID);r&&(r.layout=Vm(r.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"channel-changed":case"pinned-channels-changed":case"theme-changed":case"appearance-changed":case"artifact-focus":break;default:return RD(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 Wt("change"));const r=this.createSocket(ID(this.url,this._token,this.telemetryMeta));return this.socket=r,await new Promise((s,a)=>{let l=!1,c=!1;const u=()=>{var y;l||this.connectAttempt!==e||(l=!0,c=!0,this.retryDelay=Fh,this.hasEverConnected=!0,this.failedReconnectAttempts=0,this.setStatus("connected"),(y=this.telemetryActivityAgent)==null||y.start(),s())},f=y=>{l||this.connectAttempt!==e||(l=!0,a(y))},p=async()=>{const y=this.hasEverConnected;try{const[{channels:v},S,_]=await Promise.all([this.client.channels.list(),this.client.display.get(),y?null:this.readDemoMode()]);y||(this.browserDemoMode=(_==null?void 0:_.browserExternalPages)===!0),this.channels=new Map(v.map($=>[$.id,structuredClone($)])),this.acpClient.setEnabled(S.acpEnabled),this.dispatchEvent(new Wt("change")),y&&this.dispatchEvent(new Ic("channels-changed")),this.dispatchEvent(new Xh("server-event",{event:{type:"channel-changed",channelID:S.focusedChannelId}})),this.dispatchEvent(new Xh("server-event",{event:{type:"pinned-channels-changed",pinnedChannelIds:[...S.pinnedChannelIds]}})),u(),y&&this.connectAttempt===e&&this.dispatchEvent(new J8("server-reconnected"))}catch(v){if(LD(v)){f(new od);return}f(v instanceof Error?v:new Error(String(v)))}};r.addEventListener("open",()=>{this.decideBoot===null&&(this.bootState="booted",this.navigationPending()||p())}),r.addEventListener("message",y=>{const v=OD(y);if(!v)return;if(v.type==="server-status"){const _=v;this.serverVersion=_.version,this.updateState=_.update??null;let $=!1;this.decideBoot!==null&&this.bootState==="pending"&&this.connectAttempt===e&&(this.decideBoot(_)==="boot"?(this.bootState="booted",$=!0):(this.bootState="halted",this.attempting=!1)),this.dispatchEvent(new Y8("server-status",{message:_})),$?this.navigationPending()||p():this.bootState==="halted"&&!this.navigationPending()&&this.dispatchEvent(new Wt("change"));return}if(!DD(v.type))return;const S=v;this.applyServerEvent(S),this.dispatchEvent(new Xh("server-event",{event:S}))}),r.addEventListener("close",y=>{if(this.connectAttempt!==e)return;this.socket=null;const v=$D(y);if(!l){f(v===X2?new od:new Error("Connection closed before initialization"));return}if(c){if(v===X2){this.handleAuthRejected();return}this.handleTransportFailure(new Error("Connection closed"))}}),r.addEventListener("error",()=>{if(this.connectAttempt===e){if(l){if(!c)return;this.handleTransportFailure(new Error("WebSocket error"));return}f(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 od){this.handleAuthRejected();return}this.autoReconnect&&(this.hasEverConnected&&(this.failedReconnectAttempts+=1),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,TD),this.nextRetryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},e),this.dispatchEvent(new Wt("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new Wt("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=Fh,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:hk,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 Wt("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function RD(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function ID(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 P$(e))r.searchParams.set(i,s);return r.hash="",r.toString()}function $D(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}const xD={"artifact-created":!0,"artifact-updated":!0,"artifact-content-changed":!0,"artifact-removed":!0,"channel-created":!0,"channel-updated":!0,"channel-removed":!0,"channel-changed":!0,"pinned-channels-changed":!0,"theme-changed":!0,"appearance-changed":!0,"artifact-focus":!0},PD=new Set(Object.keys(xD));function DD(n){return PD.has(n)}function OD(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 LD(n){return n instanceof Ql&&n.status===kD}const MD="Local";var fr,Un,Ei,DS,pg,OS,Su,_u,Au,Eu,ku;class ND extends Ri{constructor(e){super();m(this,Ei);R(this,"connection");R(this,"clientGUID");R(this,"acpStorage");R(this,"connectError",null);m(this,fr);m(this,Un,!1);m(this,Su,()=>{o(this,Un)||(h(this,Ei,OS).call(this),this.dispatchEvent(new Wt("change")))});m(this,_u,e=>{o(this,Un)||this.dispatchEvent(new Xh("server-event",{event:e.event}))});m(this,Au,()=>{o(this,Un)||this.dispatchEvent(new Ic("channels-changed"))});m(this,Eu,()=>{o(this,Un)||this.dispatchEvent(new J8("server-reconnected"))});m(this,ku,e=>{o(this,Un)||this.dispatchEvent(new Y8("server-status",{message:e.message}))});d(this,fr,e.localStore),this.acpStorage=e.acpStorage===void 0?PS():e.acpStorage,this.clientGUID=e.clientGUID??(this.acpStorage?ED(this.acpStorage):Q1().toLowerCase());const r=oa(e.serverURL);e.launchToken!==void 0&&e.launchToken!==null&&o(this,fr).set(ET(o(this,fr).get(),r,e.launchToken));const i=e.launchToken??w2(o(this,fr).get(),r),s=e.createSocket??(l=>new WebSocket(l)),a=e.createConnection??(l=>new CD(l));this.connection=a({url:r,name:e.connectionName??MD,token:i,createSocket:s,clientGUID:this.clientGUID,acpStorage:this.acpStorage,telemetryMeta:e.telemetryMeta??null,decideBoot:e.decideBoot,navigationPending:e.navigationPending}),this.connection.addEventListener("change",o(this,Su)),this.connection.addEventListener("server-event",o(this,_u)),this.connection.addEventListener("channels-changed",o(this,Au)),this.connection.addEventListener("server-reconnected",o(this,Eu)),this.connection.addEventListener("server-status",o(this,ku))}get storedAuthToken(){return w2(o(this,fr).get(),this.connection.url)}async connect(){await h(this,Ei,DS).call(this,this.connection.token)}dispose(){o(this,Un)||(d(this,Un,!0),this.connection.removeEventListener("change",o(this,Su)),this.connection.removeEventListener("server-event",o(this,_u)),this.connection.removeEventListener("channels-changed",o(this,Au)),this.connection.removeEventListener("server-reconnected",o(this,Eu)),this.connection.removeEventListener("server-status",o(this,ku)),this.connection.dispose())}}fr=new WeakMap,Un=new WeakMap,Ei=new WeakSet,DS=async function(e){if(!o(this,Un)){h(this,Ei,pg).call(this,null);try{await this.connection.connect(e)}catch(r){h(this,Ei,pg).call(this,r instanceof od?null:r instanceof Error?r.message:String(r))}}},pg=function(e){this.connectError!==e&&(this.connectError=e,this.dispatchEvent(new Wt("change")))},OS=function(){if(this.connection.status!=="unauthorized"||!this.connection.hasAuthRejected)return;const e=o(this,fr).get(),r=kT(e,this.connection.url);r!==e&&o(this,fr).set(r),this.connection.token!==null&&this.connection.clearToken()},Su=new WeakMap,_u=new WeakMap,Au=new WeakMap,Eu=new WeakMap,ku=new WeakMap;const mg="tv-nav:",Vl="tv-reload",Q2=100,zD=1e3,HD=60,ZD=60,UD=24,FD=30,qD=FD*UD*ZD*HD*zD;function Si(n){try{const t=new URL(n,window.location.href),e=t.searchParams.has(Vl);return t.searchParams.delete(Vl),t.origin===window.location.origin?`${t.pathname}${t.search}${t.hash}`:e?t.toString():n}catch{return n}}var Tu,Qa,$e,Ce,go,Ke,LS,zi,MS,gg,vg;class VD extends Ri{constructor(e,r){super();m(this,Ke);m(this,Tu);m(this,Qa);m(this,$e,[]);m(this,Ce,-1);m(this,go,0);d(this,Tu,e),d(this,Qa,Si(r)),h(this,Ke,LS).call(this)}get currentURL(){var e;return o(this,Ce)===-1?null:((e=o(this,$e)[o(this,Ce)])==null?void 0:e.url)??null}get canGoBack(){return o(this,Ce)>-1}get canGoForward(){return o(this,Ce)<o(this,$e).length-1}get entries(){return o(this,$e).map(e=>({...e}))}get cursor(){return o(this,Ce)}navigate(e){const r=Si(e);if(r===o(this,Qa)){if(o(this,Ce)===-1)return;d(this,Ce,-1),h(this,Ke,zi).call(this);return}o(this,Ce)<o(this,$e).length-1&&d(this,$e,o(this,$e).slice(0,o(this,Ce)+1)),o(this,$e).push({url:r}),d(this,Ce,o(this,$e).length-1),h(this,Ke,gg).call(this),h(this,Ke,zi).call(this)}replace(e){var i;if(o(this,Ce)===-1){this.navigate(e);return}const r=Si(e);if(r===o(this,Qa)){d(this,$e,o(this,$e).filter((s,a)=>a!==o(this,Ce))),d(this,Ce,-1),h(this,Ke,zi).call(this);return}((i=o(this,$e)[o(this,Ce)])==null?void 0:i.url)!==r&&(d(this,$e,o(this,$e).map((s,a)=>a===o(this,Ce)?{url:r}:s)),h(this,Ke,zi).call(this))}back(){o(this,Ce)!==-1&&(d(this,Ce,o(this,Ce)-1),h(this,Ke,zi).call(this))}forward(){this.canGoForward&&(d(this,Ce,o(this,Ce)+1),h(this,Ke,zi).call(this))}reset(){o(this,Ce)===-1&&o(this,$e).length===0||(d(this,$e,[]),d(this,Ce,-1),h(this,Ke,zi).call(this))}}Tu=new WeakMap,Qa=new WeakMap,$e=new WeakMap,Ce=new WeakMap,go=new WeakMap,Ke=new WeakSet,LS=function(){const e=localStorage.getItem(o(this,Ke,vg));if(e!==null)try{const r=JSON.parse(e);if(!NS(r))return;d(this,$e,r.entries.map(i=>({url:i.url}))),d(this,Ce,r.cursor),d(this,go,r.lastWritten),h(this,Ke,gg).call(this)}catch{d(this,$e,[]),d(this,Ce,-1),d(this,go,0)}},zi=function(){d(this,go,Date.now());try{localStorage.setItem(o(this,Ke,vg),JSON.stringify(h(this,Ke,MS).call(this)))}catch(e){if(!WD(e))throw e}this.dispatchEvent(new Wt("change"))},MS=function(){return{v:1,entries:o(this,$e).map(e=>({...e})),cursor:o(this,Ce),lastWritten:o(this,go)}},gg=function(){if(o(this,$e).length<=Q2)return;const e=o(this,$e).length-Q2;d(this,$e,o(this,$e).slice(e)),d(this,Ce,Math.max(-1,o(this,Ce)-e))},vg=function(){return BD(o(this,Tu))};function BD(n){return`${mg}${n}`}function jD(n){const t=Date.now()-qD,e=[];for(let r=0;r<localStorage.length;r+=1){const i=localStorage.key(r);if(!(i!=null&&i.startsWith(mg)))continue;const s=i.slice(mg.length),a=localStorage.getItem(i);if(a===null)continue;let l;try{l=JSON.parse(a)}catch{e.push(i);continue}if(!NS(l)){e.push(i);continue}!n.has(s)&&l.lastWritten<t&&e.push(i)}for(const r of e)localStorage.removeItem(r)}function WD(n){return n instanceof DOMException&&n.name==="QuotaExceededError"}function NS(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 xm="tv-channel-sidebar-collapsed";var vo;class GD{constructor(t){m(this,vo);d(this,vo,t)}read(){return o(this,vo).getItem(xm)==="true"}setCollapsed(t){try{t?o(this,vo).setItem(xm,"true"):o(this,vo).removeItem(xm)}catch{}}}vo=new WeakMap;const Pm="tv-channel-sidebar-width",yg=160,wg=350,qh=260,JD=/^-?\d+$/;var yo;class YD{constructor(t){m(this,yo);d(this,yo,t)}read(){const t=o(this,yo).getItem(Pm);if(t===null||!JD.test(t))return null;const e=BigInt(t);return e<BigInt(yg)?yg:e>BigInt(wg)?wg:Number(e)}commit(t){const e=zS(Math.round(t));try{o(this,yo).setItem(Pm,String(e))}catch{}return e}clear(){try{o(this,yo).removeItem(Pm)}catch{}}}yo=new WeakMap;function zS(n){return Math.min(Math.max(n,yg),wg)}const KD="1.5.2";function uv(n=KD){return n!==void 0&&n.length>0?n:"0.0.0"}function hv(){let n=!1;return{get pending(){return n},begin(t){n||(n=!0,t())}}}const bg="tv-reload-attempted";function XD(n){return n.marker!==null&&n.bundleVersion===n.serverVersion?{action:"signal-autoreloaded",fromVersion:n.marker.fromVersion,toVersion:n.bundleVersion}:Yk(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"}}function QD(n){const t=n.getItem(bg);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 eO(n){const t=n.storage!==void 0?n.storage:typeof sessionStorage<"u"?sessionStorage:null,e=n.reload??(()=>location.reload()),r=n.navigationLatch??hv(),i=n.bundleVersion??uv();if(t===null)return{dispose(){}};let s=null;const a=()=>{if(s===null)return;const u=n.owner.connection;if(u.status!=="connected")return;const f=s;s=null,u.sendTelemetrySignal("client_autoreloaded",{from_version:f.fromVersion,to_version:f.toVersion})},l=u=>{if(r.pending)return;const f=XD({bundleVersion:i,serverVersion:u.message.version,marker:QD(t)});switch(f.action){case"reload":t.setItem(bg,JSON.stringify(f.marker)),r.begin(e);return;case"signal-autoreloaded":t.removeItem(bg),s={fromVersion:f.fromVersion,toVersion:f.toVersion},a();return;case"none":return}},c=()=>{a()};return n.owner.addEventListener("server-status",l),n.owner.addEventListener("change",c),{dispose(){n.owner.removeEventListener("server-status",l),n.owner.removeEventListener("change",c)}}}function tO(n){const t=bi(n.search),e=O6(n.search),r=e!==null&&Ff(e)?e:null;return{electron:t,shellVersion:r}}function nO(n){return!n.electron||n.requiredDesktopVersion===null||!Ff(n.requiredDesktopVersion)?!1:n.shellVersion===null?!0:n.shellVersion===Id?!1:X1(n.requiredDesktopVersion,n.shellVersion)}const rO=`# Desktop app update required
66
66
 
67
67
  This version of the Television desktop app does not work with this server and needs to be updated. The new version has already downloaded and installs when you restart the app.`,iO=`# Desktop app update required
68
68
 
@@ -40,7 +40,7 @@
40
40
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
41
41
  <link rel="icon" type="image/svg+xml" href="./assets/favicon-DaYMFRha.svg" />
42
42
  <title>Television</title>
43
- <script type="module" crossorigin src="./assets/main-C0UptF4P.js"></script>
43
+ <script type="module" crossorigin src="./assets/main-Bjy8CPIZ.js"></script>
44
44
  <link rel="modulepreload" crossorigin href="./assets/artifact-bridge-DTPacxDw.js">
45
45
  <link rel="modulepreload" crossorigin href="./assets/missing-artifact-page-DVzJ41AE.js">
46
46
  <link rel="stylesheet" crossorigin href="./assets/main-CunC2_Nx.css">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telepath-computer/television",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",