@telepath-computer/television 1.3.5 → 1.3.7

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
@@ -53970,7 +53970,7 @@ function disabledTelemetryRuntime() {
53970
53970
 
53971
53971
  // ../server/src/updates/version.ts
53972
53972
  function readVersionStamp() {
53973
- if ("1.3.5".length > 0) return "1.3.5";
53973
+ if ("1.3.7".length > 0) return "1.3.7";
53974
53974
  return void 0;
53975
53975
  }
53976
53976
  function resolveUpdateReleaseVersion(env = process.env, stamp = readVersionStamp()) {
@@ -54516,8 +54516,8 @@ var Server = class {
54516
54516
  };
54517
54517
  };
54518
54518
  function readServerPackageVersion() {
54519
- if ("1.3.5".length > 0) {
54520
- return telemetryVersion("1.3.5");
54519
+ if ("1.3.7".length > 0) {
54520
+ return telemetryVersion("1.3.7");
54521
54521
  }
54522
54522
  const packageJsonPath = import_node_path12.default.resolve(import_node_path12.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url)), "..", "package.json");
54523
54523
  if (!(0, import_node_fs10.existsSync)(packageJsonPath)) return telemetryVersion("0.0.0");
@@ -56723,8 +56723,8 @@ function resolveVercelSkillsInstallerBin() {
56723
56723
  return localRequire.resolve("skills/bin/cli.mjs");
56724
56724
  }
56725
56725
  function readCLIVersion() {
56726
- if ("1.3.5".length > 0) {
56727
- return "1.3.5";
56726
+ if ("1.3.7".length > 0) {
56727
+ return "1.3.7";
56728
56728
  }
56729
56729
  const devPackageJsonPath = import_node_path19.default.join(getDevPackageDir(), "package.json");
56730
56730
  if (!(0, import_node_fs17.existsSync)(devPackageJsonPath)) {
@@ -40,7 +40,7 @@ var R_=Object.defineProperty;var qg=n=>{throw TypeError(n)};var I_=(n,t,e)=>t in
40
40
  `)}y.write("payload.value = newResult;"),y.write("return payload;");const D=y.compile();return(F,G)=>D(v,F,G)};let s;const a=pl,l=!bw.jitless,u=l&&S$.value,p=t.catchall;let g;n._zod.parse=(v,y)=>{g??(g=r.value);const E=v.value;return a(E)?l&&u&&(y==null?void 0:y.async)===!1&&y.jitless!==!0?(s||(s=i(t.shape)),v=s(v,y),p?Nw([],E,v,y,g,n):v):e(v,y):(v.issues.push({expected:"object",code:"invalid_type",input:E,inst:n}),v)}});function Iv(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=>!ro(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=>hi(a,r,ui())))}),t)}const zw=k("$ZodUnion",(n,t)=>{we.init(n,t),ce(n._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),ce(n._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),ce(n._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),ce(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=>jm(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=>Iv(c,i,n,s)):Iv(l,i,n,s)}}),aR=k("$ZodDiscriminatedUnion",(n,t)=>{t.inclusive=!1,zw.init(n,t);const e=n._zod.parse;ce(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=ad(()=>{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(!pl(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)}}),lR=k("$ZodIntersection",(n,t)=>{we.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])=>xv(e,c,u)):xv(e,s,a)}});function qp(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(ia(n)&&ia(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=qp(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=qp(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 xv(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}),ro(n))return n;const a=qp(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 cR=k("$ZodRecord",(n,t)=>{we.init(n,t),n._zod.parse=(e,r)=>{const i=e.value;if(!ia(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 p=t.valueType._zod.run({value:i[u],issues:[]},r);p instanceof Promise?s.push(p.then(g=>{g.issues.length&&e.issues.push(...io(u,g.issues)),e.value[u]=g.value})):(p.issues.length&&e.issues.push(...io(u,p.issues)),e.value[u]=p.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"&&Iw.test(l)&&c.issues.length){const g=t.keyType._zod.run({value:Number(l),issues:[]},r);if(g instanceof Promise)throw new Error("Async schemas not supported in object keys currently");g.issues.length===0&&(c=g)}if(c.issues.length){t.mode==="loose"?e.value[l]=i[l]:e.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(g=>hi(g,r,ui())),input:l,path:[l],inst:n});continue}const p=t.valueType._zod.run({value:i[l],issues:[]},r);p instanceof Promise?s.push(p.then(g=>{g.issues.length&&e.issues.push(...io(l,g.issues)),e.value[c.value]=g.value})):(p.issues.length&&e.issues.push(...io(l,p.issues)),e.value[c.value]=p.value)}}return s.length?Promise.all(s).then(()=>e):e}}),uR=k("$ZodEnum",(n,t)=>{we.init(n,t);const e=Sw(t.entries),r=new Set(e);n._zod.values=r,n._zod.pattern=new RegExp(`^(${e.filter(i=>_$.has(typeof i)).map(i=>typeof i=="string"?sa(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}}),hR=k("$ZodLiteral",(n,t)=>{if(we.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"?sa(r):r?sa(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}}),dR=k("$ZodTransform",(n,t)=>{we.init(n,t),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new ww(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 co;return e.value=i,e}});function Pv(n,t){return n.issues.length&&t===void 0?{issues:[],value:void 0}:n}const Uw=k("$ZodOptional",(n,t)=>{we.init(n,t),n._zod.optin="optional",n._zod.optout="optional",ce(n._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ce(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${jm(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=>Pv(s,e.value)):Pv(i,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,r)}}),pR=k("$ZodExactOptional",(n,t)=>{Uw.init(n,t),ce(n._zod,"values",()=>t.innerType._zod.values),ce(n._zod,"pattern",()=>t.innerType._zod.pattern),n._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),fR=k("$ZodNullable",(n,t)=>{we.init(n,t),ce(n._zod,"optin",()=>t.innerType._zod.optin),ce(n._zod,"optout",()=>t.innerType._zod.optout),ce(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${jm(e.source)}|null)$`):void 0}),ce(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)}),mR=k("$ZodDefault",(n,t)=>{we.init(n,t),n._zod.optin="optional",ce(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=>Lv(s,t)):Lv(i,t)}});function Lv(n,t){return n.value===void 0&&(n.value=t.defaultValue),n}const gR=k("$ZodPrefault",(n,t)=>{we.init(n,t),n._zod.optin="optional",ce(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))}),vR=k("$ZodNonOptional",(n,t)=>{we.init(n,t),ce(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=>Dv(s,n)):Dv(i,n)}});function Dv(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 yR=k("$ZodCatch",(n,t)=>{we.init(n,t),ce(n._zod,"optin",()=>t.innerType._zod.optin),ce(n._zod,"optout",()=>t.innerType._zod.optout),ce(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=>hi(a,r,ui()))},input:e.value}),e.issues=[]),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(s=>hi(s,r,ui()))},input:e.value}),e.issues=[]),e)}}),wR=k("$ZodPipe",(n,t)=>{we.init(n,t),ce(n._zod,"values",()=>t.in._zod.values),ce(n._zod,"optin",()=>t.in._zod.optin),ce(n._zod,"optout",()=>t.out._zod.optout),ce(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=>tu(a,t.in,r)):tu(s,t.in,r)}const i=t.in._zod.run(e,r);return i instanceof Promise?i.then(s=>tu(s,t.out,r)):tu(i,t.out,r)}});function tu(n,t,e){return n.issues.length?(n.aborted=!0,n):t._zod.run({value:n.value,issues:n.issues},e)}const bR=k("$ZodReadonly",(n,t)=>{we.init(n,t),ce(n._zod,"propValues",()=>t.innerType._zod.propValues),ce(n._zod,"values",()=>t.innerType._zod.values),ce(n._zod,"optin",()=>{var e,r;return(r=(e=t.innerType)==null?void 0:e._zod)==null?void 0:r.optin}),ce(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(Ov):Ov(i)}});function Ov(n){return n.value=Object.freeze(n.value),n}const SR=k("$ZodCustom",(n,t)=>{ht.init(n,t),we.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=>Mv(s,e,r,n));Mv(i,e,r,n)}});function Mv(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(fl(i))}}var Nv;class _R{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 AR(){return new _R}(Nv=globalThis).__zod_globalRegistry??(Nv.__zod_globalRegistry=AR());const Ha=globalThis.__zod_globalRegistry;function ER(n,t){return new n({type:"string",...U(t)})}function kR(n,t){return new n({type:"string",format:"email",check:"string_format",abort:!1,...U(t)})}function zv(n,t){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...U(t)})}function CR(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...U(t)})}function $R(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...U(t)})}function TR(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...U(t)})}function RR(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...U(t)})}function IR(n,t){return new n({type:"string",format:"url",check:"string_format",abort:!1,...U(t)})}function xR(n,t){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...U(t)})}function PR(n,t){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...U(t)})}function LR(n,t){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...U(t)})}function DR(n,t){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...U(t)})}function OR(n,t){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...U(t)})}function MR(n,t){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...U(t)})}function NR(n,t){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...U(t)})}function zR(n,t){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...U(t)})}function UR(n,t){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...U(t)})}function FR(n,t){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...U(t)})}function ZR(n,t){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...U(t)})}function HR(n,t){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...U(t)})}function VR(n,t){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...U(t)})}function BR(n,t){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...U(t)})}function WR(n,t){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...U(t)})}function qR(n,t){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...U(t)})}function jR(n,t){return new n({type:"string",format:"date",check:"string_format",...U(t)})}function GR(n,t){return new n({type:"string",format:"time",check:"string_format",precision:null,...U(t)})}function YR(n,t){return new n({type:"string",format:"duration",check:"string_format",...U(t)})}function JR(n,t){return new n({type:"number",checks:[],...U(t)})}function KR(n,t){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...U(t)})}function XR(n,t){return new n({type:"boolean",...U(t)})}function QR(n){return new n({type:"unknown"})}function eI(n,t){return new n({type:"never",...U(t)})}function Uv(n,t){return new Pw({check:"less_than",...U(t),value:n,inclusive:!1})}function hp(n,t){return new Pw({check:"less_than",...U(t),value:n,inclusive:!0})}function Fv(n,t){return new Lw({check:"greater_than",...U(t),value:n,inclusive:!1})}function dp(n,t){return new Lw({check:"greater_than",...U(t),value:n,inclusive:!0})}function Zv(n,t){return new mT({check:"multiple_of",...U(t),value:n})}function Fw(n,t){return new vT({check:"max_length",...U(t),maximum:n})}function ah(n,t){return new yT({check:"min_length",...U(t),minimum:n})}function Zw(n,t){return new wT({check:"length_equals",...U(t),length:n})}function tI(n,t){return new bT({check:"string_format",format:"regex",...U(t),pattern:n})}function nI(n){return new ST({check:"string_format",format:"lowercase",...U(n)})}function rI(n){return new _T({check:"string_format",format:"uppercase",...U(n)})}function iI(n,t){return new AT({check:"string_format",format:"includes",...U(t),includes:n})}function sI(n,t){return new ET({check:"string_format",format:"starts_with",...U(t),prefix:n})}function oI(n,t){return new kT({check:"string_format",format:"ends_with",...U(t),suffix:n})}function va(n){return new CT({check:"overwrite",tx:n})}function aI(n){return va(t=>t.normalize(n))}function lI(){return va(n=>n.trim())}function cI(){return va(n=>n.toLowerCase())}function uI(){return va(n=>n.toUpperCase())}function hI(){return va(n=>b$(n))}function dI(n,t,e){return new n({type:"array",element:t,...U(e)})}function pI(n,t,e){return new n({type:"custom",check:"custom",fn:t,...U(e)})}function fI(n){const t=mI(e=>(e.addIssue=r=>{if(typeof r=="string")e.issues.push(fl(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(fl(i))}},n(e.value,e)));return t}function mI(n,t){const e=new ht({check:"custom",...U(t)});return e._zod.check=n,e}function Hw(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)??Ha,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 Te(n,t,e={path:[],schemaPath:[]}){var p,g;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=(g=(p=n._zod).toJSONSchema)==null?void 0:g.call(p);if(l)a.schema=l;else{const v={...e,schemaPath:[...e.schemaPath,n],path:e.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(t,a.schema,v);else{const E=a.schema,A=t.processors[i.type];if(!A)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);A(n,t,E,v)}const y=n._zod.parent;y&&(a.ref||(a.ref=y),Te(y,t,v),t.seen.get(y).isParent=!0)}const c=t.metadataRegistry.get(n);return c&&Object.assign(a.schema,c),t.io==="input"&&qe(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 Vw(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 p of n.seen.entries()){const g=(a=n.metadataRegistry.get(p[0]))==null?void 0:a.id;if(g){const v=r.get(g);if(v&&v!==p[0])throw new Error(`Duplicate schema id "${g}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(g,p[0])}}const i=p=>{var A;const g=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const x=(A=n.external.registry.get(p[0]))==null?void 0:A.id,L=n.external.uri??(V=>V);if(x)return{ref:L(x)};const D=p[1].defId??p[1].schema.id??`schema${n.counter++}`;return p[1].defId=D,{defId:D,ref:`${L("__shared")}#/${g}/${D}`}}if(p[1]===e)return{ref:"#"};const y=`#/${g}/`,E=p[1].schema.id??`__schema${n.counter++}`;return{defId:E,ref:y+E}},s=p=>{if(p[1].schema.$ref)return;const g=p[1],{ref:v,defId:y}=i(p);g.def={...g.schema},y&&(g.defId=y);const E=g.schema;for(const A in E)delete E[A];E.$ref=v};if(n.cycles==="throw")for(const p of n.seen.entries()){const g=p[1];if(g.cycle)throw new Error(`Cycle detected: #/${(l=g.cycle)==null?void 0:l.join("/")}/<root>
41
41
 
42
42
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const p of n.seen.entries()){const g=p[1];if(t===p[0]){s(p);continue}if(n.external){const y=(c=n.external.registry.get(p[0]))==null?void 0:c.id;if(t!==p[0]&&y){s(p);continue}}if((u=n.metadataRegistry.get(p[0]))==null?void 0:u.id){s(p);continue}if(g.cycle){s(p);continue}if(g.count>1&&n.reused==="ref"){s(p);continue}}}function Bw(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 p=n.seen.get(u);if(p.ref===null)return;const g=p.def??p.schema,v={...g},y=p.ref;if(p.ref=null,y){r(y);const A=n.seen.get(y),x=A.schema;if(x.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(g.allOf=g.allOf??[],g.allOf.push(x)):Object.assign(g,x),Object.assign(g,v),u._zod.parent===y)for(const D in g)D==="$ref"||D==="allOf"||D in v||delete g[D];if(x.$ref&&A.def)for(const D in g)D==="$ref"||D==="allOf"||D in A.def&&JSON.stringify(g[D])===JSON.stringify(A.def[D])&&delete g[D]}const E=u._zod.parent;if(E&&E!==y){r(E);const A=n.seen.get(E);if(A!=null&&A.schema.$ref&&(g.$ref=A.schema.$ref,A.def))for(const x in g)x==="$ref"||x==="allOf"||x in A.def&&JSON.stringify(g[x])===JSON.stringify(A.def[x])&&delete g[x]}n.override({zodSchema:u,jsonSchema:g,path:p.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 p=u[1];p.def&&p.defId&&(s[p.defId]=p.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:lh(t,"input",n.processors),output:lh(t,"output",n.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function qe(n,t){const e=t??{seen:new Set};if(e.seen.has(n))return!1;e.seen.add(n);const r=n._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return qe(r.element,e);if(r.type==="set")return qe(r.valueType,e);if(r.type==="lazy")return qe(r.getter(),e);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return qe(r.innerType,e);if(r.type==="intersection")return qe(r.left,e)||qe(r.right,e);if(r.type==="record"||r.type==="map")return qe(r.keyType,e)||qe(r.valueType,e);if(r.type==="pipe")return qe(r.in,e)||qe(r.out,e);if(r.type==="object"){for(const i in r.shape)if(qe(r.shape[i],e))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(qe(i,e))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(qe(i,e))return!0;return!!(r.rest&&qe(r.rest,e))}return!1}const gI=(n,t={})=>e=>{const r=Hw({...e,processors:t});return Te(n,r),Vw(r,n),Bw(r,n)},lh=(n,t,e={})=>r=>{const{libraryOptions:i,target:s}=r??{},a=Hw({...i??{},target:s,io:t,processors:e});return Te(n,a),Vw(a,n),Bw(a,n)},vI={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},yI=(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=vI[l]??l,i.format===""&&delete i.format,l==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){const p=[...c];p.length===1?i.pattern=p[0].source:p.length>1&&(i.allOf=[...p.map(g=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},wI=(n,t,e,r)=>{const i=e,{minimum:s,maximum:a,format:l,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:p}=n._zod.bag;typeof l=="string"&&l.includes("int")?i.type="integer":i.type="number",typeof p=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=p,i.exclusiveMinimum=!0):i.exclusiveMinimum=p),typeof s=="number"&&(i.minimum=s,typeof p=="number"&&t.target!=="draft-04"&&(p>=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)},bI=(n,t,e,r)=>{e.type="boolean"},SI=(n,t,e,r)=>{e.not={}},_I=(n,t,e,r)=>{},AI=(n,t,e,r)=>{const i=n._zod.def,s=Sw(i.entries);s.every(a=>typeof a=="number")&&(e.type="number"),s.every(a=>typeof a=="string")&&(e.type="string"),e.enum=s},EI=(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},kI=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},CI=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},$I=(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=Te(s.element,t,{...r,path:[...r.path,"items"]})},TI=(n,t,e,r)=>{var u;const i=e,s=n._zod.def;i.type="object",i.properties={};const a=s.shape;for(const p in a)i.properties[p]=Te(a[p],t,{...r,path:[...r.path,"properties",p]});const l=new Set(Object.keys(a)),c=new Set([...l].filter(p=>{const g=s.shape[p]._zod;return t.io==="input"?g.optin===void 0:g.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=Te(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},RI=(n,t,e,r)=>{const i=n._zod.def,s=i.inclusive===!1,a=i.options.map((l,c)=>Te(l,t,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?e.oneOf=a:e.anyOf=a},II=(n,t,e,r)=>{const i=n._zod.def,s=Te(i.left,t,{...r,path:[...r.path,"allOf",0]}),a=Te(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},xI=(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 p=Te(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const g of c)i.patternProperties[g.source]=p}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Te(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Te(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=a._zod.values;if(u){const p=[...u].filter(g=>typeof g=="string"||typeof g=="number");p.length>0&&(i.required=p)}},PI=(n,t,e,r)=>{const i=n._zod.def,s=Te(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"}]},LI=(n,t,e,r)=>{const i=n._zod.def;Te(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},DI=(n,t,e,r)=>{const i=n._zod.def;Te(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,e.default=JSON.parse(JSON.stringify(i.defaultValue))},OI=(n,t,e,r)=>{const i=n._zod.def;Te(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)))},MI=(n,t,e,r)=>{const i=n._zod.def;Te(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},NI=(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;Te(s,t,r);const a=t.seen.get(n);a.ref=s},zI=(n,t,e,r)=>{const i=n._zod.def;Te(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,e.readOnly=!0},Ww=(n,t,e,r)=>{const i=n._zod.def;Te(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},UI=k("ZodISODateTime",(n,t)=>{FT.init(n,t),Se.init(n,t)});function FI(n){return qR(UI,n)}const ZI=k("ZodISODate",(n,t)=>{ZT.init(n,t),Se.init(n,t)});function HI(n){return jR(ZI,n)}const VI=k("ZodISOTime",(n,t)=>{HT.init(n,t),Se.init(n,t)});function BI(n){return GR(VI,n)}const WI=k("ZodISODuration",(n,t)=>{VT.init(n,t),Se.init(n,t)});function qI(n){return YR(WI,n)}const qw=(n,t)=>{kw.init(n,t),n.name="ZodError",Object.defineProperties(n,{format:{value:e=>L$(n,e)},flatten:{value:e=>P$(n,e)},addIssue:{value:e=>{n.issues.push(e),n.message=JSON.stringify(n.issues,Wp,2)}},addIssues:{value:e=>{n.issues.push(...e),n.message=JSON.stringify(n.issues,Wp,2)}},isEmpty:{get(){return n.issues.length===0}}})},Hv=k("ZodError",qw),Ft=k("ZodError",qw,{Parent:Error}),jI=Ym(Ft),GI=Jm(Ft),YI=ld(Ft),JI=cd(Ft),KI=M$(Ft),XI=N$(Ft),QI=z$(Ft),e3=U$(Ft),t3=F$(Ft),n3=Z$(Ft),r3=H$(Ft),i3=V$(Ft),be=k("ZodType",(n,t)=>(we.init(n,t),Object.assign(n["~standard"],{jsonSchema:{input:lh(n,"input"),output:lh(n,"output")}}),n.toJSONSchema=gI(n,{}),n.def=t,n.type=t.type,Object.defineProperty(n,"_def",{value:t}),n.check=(...e)=>n.clone(gi(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)=>vi(n,e,r),n.brand=()=>n,n.register=(e,r)=>(e.add(n,r),n),n.parse=(e,r)=>jI(n,e,r,{callee:n.parse}),n.safeParse=(e,r)=>YI(n,e,r),n.parseAsync=async(e,r)=>GI(n,e,r,{callee:n.parseAsync}),n.safeParseAsync=async(e,r)=>JI(n,e,r),n.spa=n.safeParseAsync,n.encode=(e,r)=>KI(n,e,r),n.decode=(e,r)=>XI(n,e,r),n.encodeAsync=async(e,r)=>QI(n,e,r),n.decodeAsync=async(e,r)=>e3(n,e,r),n.safeEncode=(e,r)=>t3(n,e,r),n.safeDecode=(e,r)=>n3(n,e,r),n.safeEncodeAsync=async(e,r)=>r3(n,e,r),n.safeDecodeAsync=async(e,r)=>i3(n,e,r),n.refine=(e,r)=>n.check(J3(e,r)),n.superRefine=e=>n.check(K3(e)),n.overwrite=e=>n.check(va(e)),n.optional=()=>Wv(n),n.exactOptional=()=>N3(n),n.nullable=()=>qv(n),n.nullish=()=>Wv(qv(n)),n.nonoptional=e=>V3(n,e),n.array=()=>M(n),n.or=e=>K([n,e]),n.and=e=>hd(n,e),n.transform=e=>jv(n,O3(e)),n.default=e=>F3(n,e),n.prefault=e=>H3(n,e),n.catch=e=>W3(n,e),n.pipe=e=>jv(n,e),n.readonly=()=>G3(n),n.describe=e=>{const r=n.clone();return Ha.add(r,{description:e}),r},Object.defineProperty(n,"description",{get(){var e;return(e=Ha.get(n))==null?void 0:e.description},configurable:!0}),n.meta=(...e)=>{if(e.length===0)return Ha.get(n);const r=n.clone();return Ha.add(r,e[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=e=>e(n),n)),jw=k("_ZodString",(n,t)=>{Km.init(n,t),be.init(n,t),n._zod.processJSONSchema=(r,i,s)=>yI(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(tI(...r)),n.includes=(...r)=>n.check(iI(...r)),n.startsWith=(...r)=>n.check(sI(...r)),n.endsWith=(...r)=>n.check(oI(...r)),n.min=(...r)=>n.check(ah(...r)),n.max=(...r)=>n.check(Fw(...r)),n.length=(...r)=>n.check(Zw(...r)),n.nonempty=(...r)=>n.check(ah(1,...r)),n.lowercase=r=>n.check(nI(r)),n.uppercase=r=>n.check(rI(r)),n.trim=()=>n.check(lI()),n.normalize=(...r)=>n.check(aI(...r)),n.toLowerCase=()=>n.check(cI()),n.toUpperCase=()=>n.check(uI()),n.slugify=()=>n.check(hI())}),s3=k("ZodString",(n,t)=>{Km.init(n,t),jw.init(n,t),n.email=e=>n.check(kR(o3,e)),n.url=e=>n.check(IR(a3,e)),n.jwt=e=>n.check(WR(_3,e)),n.emoji=e=>n.check(xR(l3,e)),n.guid=e=>n.check(zv(Vv,e)),n.uuid=e=>n.check(CR(nu,e)),n.uuidv4=e=>n.check($R(nu,e)),n.uuidv6=e=>n.check(TR(nu,e)),n.uuidv7=e=>n.check(RR(nu,e)),n.nanoid=e=>n.check(PR(c3,e)),n.guid=e=>n.check(zv(Vv,e)),n.cuid=e=>n.check(LR(u3,e)),n.cuid2=e=>n.check(DR(h3,e)),n.ulid=e=>n.check(OR(d3,e)),n.base64=e=>n.check(HR(w3,e)),n.base64url=e=>n.check(VR(b3,e)),n.xid=e=>n.check(MR(p3,e)),n.ksuid=e=>n.check(NR(f3,e)),n.ipv4=e=>n.check(zR(m3,e)),n.ipv6=e=>n.check(UR(g3,e)),n.cidrv4=e=>n.check(FR(v3,e)),n.cidrv6=e=>n.check(ZR(y3,e)),n.e164=e=>n.check(BR(S3,e)),n.datetime=e=>n.check(FI(e)),n.date=e=>n.check(HI(e)),n.time=e=>n.check(BI(e)),n.duration=e=>n.check(qI(e))});function f(n){return ER(s3,n)}const Se=k("ZodStringFormat",(n,t)=>{ve.init(n,t),jw.init(n,t)}),o3=k("ZodEmail",(n,t)=>{xT.init(n,t),Se.init(n,t)}),Vv=k("ZodGUID",(n,t)=>{RT.init(n,t),Se.init(n,t)}),nu=k("ZodUUID",(n,t)=>{IT.init(n,t),Se.init(n,t)}),a3=k("ZodURL",(n,t)=>{PT.init(n,t),Se.init(n,t)}),l3=k("ZodEmoji",(n,t)=>{LT.init(n,t),Se.init(n,t)}),c3=k("ZodNanoID",(n,t)=>{DT.init(n,t),Se.init(n,t)}),u3=k("ZodCUID",(n,t)=>{OT.init(n,t),Se.init(n,t)}),h3=k("ZodCUID2",(n,t)=>{MT.init(n,t),Se.init(n,t)}),d3=k("ZodULID",(n,t)=>{NT.init(n,t),Se.init(n,t)}),p3=k("ZodXID",(n,t)=>{zT.init(n,t),Se.init(n,t)}),f3=k("ZodKSUID",(n,t)=>{UT.init(n,t),Se.init(n,t)}),m3=k("ZodIPv4",(n,t)=>{BT.init(n,t),Se.init(n,t)}),g3=k("ZodIPv6",(n,t)=>{WT.init(n,t),Se.init(n,t)}),v3=k("ZodCIDRv4",(n,t)=>{qT.init(n,t),Se.init(n,t)}),y3=k("ZodCIDRv6",(n,t)=>{jT.init(n,t),Se.init(n,t)}),w3=k("ZodBase64",(n,t)=>{GT.init(n,t),Se.init(n,t)}),b3=k("ZodBase64URL",(n,t)=>{JT.init(n,t),Se.init(n,t)}),S3=k("ZodE164",(n,t)=>{KT.init(n,t),Se.init(n,t)}),_3=k("ZodJWT",(n,t)=>{QT.init(n,t),Se.init(n,t)}),Gw=k("ZodNumber",(n,t)=>{Ow.init(n,t),be.init(n,t),n._zod.processJSONSchema=(r,i,s)=>wI(n,r,i),n.gt=(r,i)=>n.check(Fv(r,i)),n.gte=(r,i)=>n.check(dp(r,i)),n.min=(r,i)=>n.check(dp(r,i)),n.lt=(r,i)=>n.check(Uv(r,i)),n.lte=(r,i)=>n.check(hp(r,i)),n.max=(r,i)=>n.check(hp(r,i)),n.int=r=>n.check(Bv(r)),n.safe=r=>n.check(Bv(r)),n.positive=r=>n.check(Fv(0,r)),n.nonnegative=r=>n.check(dp(0,r)),n.negative=r=>n.check(Uv(0,r)),n.nonpositive=r=>n.check(hp(0,r)),n.multipleOf=(r,i)=>n.check(Zv(r,i)),n.step=(r,i)=>n.check(Zv(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 j(n){return JR(Gw,n)}const A3=k("ZodNumberFormat",(n,t)=>{eR.init(n,t),Gw.init(n,t)});function Bv(n){return KR(A3,n)}const E3=k("ZodBoolean",(n,t)=>{tR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>bI(n,e,r)});function Oe(n){return XR(E3,n)}const k3=k("ZodUnknown",(n,t)=>{nR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>_I()});function S(){return QR(k3)}const C3=k("ZodNever",(n,t)=>{rR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>SI(n,e,r)});function $3(n){return eI(C3,n)}const T3=k("ZodArray",(n,t)=>{iR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>$I(n,e,r,i),n.element=t.element,n.min=(e,r)=>n.check(ah(e,r)),n.nonempty=e=>n.check(ah(1,e)),n.max=(e,r)=>n.check(Fw(e,r)),n.length=(e,r)=>n.check(Zw(e,r)),n.unwrap=()=>n.element});function M(n,t){return dI(T3,n,t)}const Yw=k("ZodObject",(n,t)=>{oR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>TI(n,e,r,i),ce(n,"shape",()=>t.shape),n.keyof=()=>Xw(Object.keys(n._zod.def.shape)),n.catchall=e=>n.clone({...n._zod.def,catchall:e}),n.passthrough=()=>n.clone({...n._zod.def,catchall:S()}),n.loose=()=>n.clone({...n._zod.def,catchall:S()}),n.strict=()=>n.clone({...n._zod.def,catchall:$3()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=e=>$$(n,e),n.safeExtend=e=>T$(n,e),n.merge=e=>R$(n,e),n.pick=e=>k$(n,e),n.omit=e=>C$(n,e),n.partial=(...e)=>I$(Qw,n,e[0]),n.required=(...e)=>x$(eb,n,e[0])});function Jw(n,t){const e={type:"object",shape:n??{},...U(t)};return new Yw(e)}function w(n,t){return new Yw({type:"object",shape:n,catchall:S(),...U(t)})}const Kw=k("ZodUnion",(n,t)=>{zw.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>RI(n,e,r,i),n.options=t.options});function K(n,t){return new Kw({type:"union",options:n,...U(t)})}const R3=k("ZodDiscriminatedUnion",(n,t)=>{Kw.init(n,t),aR.init(n,t)});function I3(n,t,e){return new R3({type:"union",options:t,discriminator:n,...U(e)})}const x3=k("ZodIntersection",(n,t)=>{lR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>II(n,e,r,i)});function hd(n,t){return new x3({type:"intersection",left:n,right:t})}const P3=k("ZodRecord",(n,t)=>{cR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>xI(n,e,r,i),n.keyType=t.keyType,n.valueType=t.valueType});function _(n,t,e){return new P3({type:"record",keyType:n,valueType:t,...U(e)})}const jp=k("ZodEnum",(n,t)=>{uR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(r,i,s)=>AI(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 jp({...t,checks:[],...U(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 jp({...t,checks:[],...U(i),entries:s})}});function Xw(n,t){const e=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new jp({type:"enum",entries:e,...U(t)})}const L3=k("ZodLiteral",(n,t)=>{hR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>EI(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 $(n,t){return new L3({type:"literal",values:Array.isArray(n)?n:[n],...U(t)})}const D3=k("ZodTransform",(n,t)=>{dR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>CI(n,e),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new ww(n.constructor.name);e.addIssue=s=>{if(typeof s=="string")e.issues.push(fl(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(fl(a))}};const i=t.transform(e.value,e);return i instanceof Promise?i.then(s=>(e.value=s,e)):(e.value=i,e)}});function O3(n){return new D3({type:"transform",transform:n})}const Qw=k("ZodOptional",(n,t)=>{Uw.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>Ww(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function Wv(n){return new Qw({type:"optional",innerType:n})}const M3=k("ZodExactOptional",(n,t)=>{pR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>Ww(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function N3(n){return new M3({type:"optional",innerType:n})}const z3=k("ZodNullable",(n,t)=>{fR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>PI(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function qv(n){return new z3({type:"nullable",innerType:n})}const U3=k("ZodDefault",(n,t)=>{mR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>DI(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function F3(n,t){return new U3({type:"default",innerType:n,get defaultValue(){return typeof t=="function"?t():Aw(t)}})}const Z3=k("ZodPrefault",(n,t)=>{gR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>OI(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function H3(n,t){return new Z3({type:"prefault",innerType:n,get defaultValue(){return typeof t=="function"?t():Aw(t)}})}const eb=k("ZodNonOptional",(n,t)=>{vR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>LI(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function V3(n,t){return new eb({type:"nonoptional",innerType:n,...U(t)})}const B3=k("ZodCatch",(n,t)=>{yR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>MI(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function W3(n,t){return new B3({type:"catch",innerType:n,catchValue:typeof t=="function"?t:()=>t})}const q3=k("ZodPipe",(n,t)=>{wR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>NI(n,e,r,i),n.in=t.in,n.out=t.out});function jv(n,t){return new q3({type:"pipe",in:n,out:t})}const j3=k("ZodReadonly",(n,t)=>{bR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>zI(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function G3(n){return new j3({type:"readonly",innerType:n})}const Y3=k("ZodCustom",(n,t)=>{SR.init(n,t),be.init(n,t),n._zod.processJSONSchema=(e,r,i)=>kI(n,e)});function J3(n,t={}){return pI(Y3,n,t)}function K3(n){return fI(n)}const X3=[".md",".markdown"];function tb(n){if(n.length===0)return!1;const t=n.at(-1);return t==="/"||t==="\\"}function nb(n){const t=n.lastIndexOf("/"),e=n.lastIndexOf("\\");return n.slice(Math.max(t,e)+1)}function Q3(n){return nb(n).toLowerCase()}function ex(n,t){const e=Q3(n);return t.some(r=>e.endsWith(r))}function Gp(n){return!tb(n)&&ex(n,X3)}function tx(n){let t;try{t=new URL(n)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}function Wn(n){try{const{pathname:t}=new URL(n);return/^\/artifact\/[0-9A-Za-z]{26}(\/|$)/.test(t)}catch{return!1}}const nx=Jw({id:f().min(1),kind:$("path"),title:f(),path:f()}).strict(),rx=Jw({id:f().min(1),kind:$("url"),title:f(),url:f().refine(tx,{message:"url must be an http(s) URL"})}).strict();I3("kind",[nx,rx]);const ix=new Set(["about:","blob:","chrome-extension:","chrome:","data:","devtools:","file:","filesystem:","javascript:","view-source:"]);function sx(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}:ix.has(r.protocol)?{kind:"browser-local",url:r.href}:{kind:"application",url:r.href}}catch{return{kind:"invalid"}}}function Gv(n,t){return sx(n,t).kind==="web"}const ox="/views/markdown/",ax="/views/url-unsupported/";function rb(n){return`/artifact/${encodeURIComponent(n)}`}function lx(n,t){return`${rb(n)}/${encodeURIComponent(t)}`}function cx(n){return`/markdown/${encodeURIComponent(n)}`}function Yp(n,t={electron:!1}){if(n.kind==="url")return t.electron?{renderer:"url-webview",viewURL:n.url,contentURL:null}:Wn(n.url)?{renderer:"proxy-iframe",viewURL:n.url,contentURL:null}:{renderer:"url-unsupported",viewURL:ax,contentURL:null};if(Gp(n.path)){const r={viewURL:ox,contentURL:cx(n.id)};return t.electron?{renderer:"url-webview",...r}:{renderer:"markdown",...r}}const e=tb(n.path)?`${rb(n.id)}/`:lx(n.id,nb(n.path));return t.electron?{renderer:"url-webview",viewURL:e,contentURL:null}:{renderer:"proxy-iframe",viewURL:e,contentURL:null}}const ux="serverURL",hx="token",dx="mode",px="desktopAppVersion",fx="electron";function mx(n=window.location.search,t=window.location.origin){const r=new URLSearchParams(n).get(ux);return r?new URL(r).origin:new URL(t).origin}function gx(n=window.location.search){return new URLSearchParams(n).get(hx)}function mr(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(dx)===fx}function ib(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(px)}const Yv="tv.telemetry.clientId",vx=5,yx=60,wx=1e3,bx=vx*yx*wx,Jv=["pointerdown","scroll","keydown"],Kv=["focus"],Xv=["visibilitychange"],Sx="hidden";function _x(n,t=$x){const e=n.getItem(Yv);if(e)return e;const r=t();return n.setItem(Yv,r),r}function Ax(n){return{clientId:_x(n.storage,n.idFactory),userAgent:n.userAgent??(typeof navigator>"u"?"":navigator.userAgent),clientApp:n.clientApp,...n.desktopAppVersion?{desktopAppVersion:n.desktopAppVersion}:{}}}function Ex(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 kx(n){return new Cx(n)}var Sl,Jn,Ir,_l,Al,Et,Mi,El,Sh,sb;class Cx{constructor(t){m(this,Sh);m(this,Sl);m(this,Jn);m(this,Ir);m(this,_l);m(this,Al);m(this,Et);m(this,Mi,!1);m(this,El,Number.NEGATIVE_INFINITY);d(this,Sl,t.meta),d(this,Jn,t.documentTarget),d(this,Ir,t.windowTarget),d(this,_l,t.send),d(this,Al,t.nowMs??Date.now),d(this,Et,()=>h(this,Sh,sb).call(this))}start(){if(!o(this,Mi)){d(this,Mi,!0);for(const t of Jv)o(this,Ir).addEventListener(t,o(this,Et)),o(this,Jn).addEventListener(t,o(this,Et));for(const t of Kv)o(this,Ir).addEventListener(t,o(this,Et));for(const t of Xv)o(this,Jn).addEventListener(t,o(this,Et))}}stop(){if(o(this,Mi)){d(this,Mi,!1);for(const t of Jv)o(this,Ir).removeEventListener(t,o(this,Et)),o(this,Jn).removeEventListener(t,o(this,Et));for(const t of Kv)o(this,Ir).removeEventListener(t,o(this,Et));for(const t of Xv)o(this,Jn).removeEventListener(t,o(this,Et))}}}Sl=new WeakMap,Jn=new WeakMap,Ir=new WeakMap,_l=new WeakMap,Al=new WeakMap,Et=new WeakMap,Mi=new WeakMap,El=new WeakMap,Sh=new WeakSet,sb=function(){if(o(this,Jn).visibilityState===Sx)return;const t=o(this,Al).call(this);t-o(this,El)<bx||(d(this,El,t),o(this,_l).call(this,{type:bC,clientId:o(this,Sl).clientId}))};function $x(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Wm().toLowerCase()}const me={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"},Zn={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"},Tx=1,Rx=w({_meta:_(f(),S()).nullish(),terminal:Oe().optional().default(!1)}),Ix=w({_meta:_(f(),S()).nullish(),label:f().nullish(),name:f(),optional:Oe().optional().default(!1),secret:Oe().optional().default(!0)}),xx=w({_meta:_(f(),S()).nullish(),description:f().nullish(),id:f(),name:f()}),Px=w({_meta:_(f(),S()).nullish(),description:f().nullish(),id:f(),link:f().nullish(),name:f(),vars:M(Ix)}),Lx=w({_meta:_(f(),S()).nullish(),args:M(f()).optional(),description:f().nullish(),env:_(f(),f()).optional(),id:f(),name:f()}),Dx=K([Px.and(w({type:$("env_var")})),Lx.and(w({type:$("terminal")})),xx]),Ox=w({_meta:_(f(),S()).nullish(),methodId:f()}),Mx=w({_meta:_(f(),S()).nullish()}),Nx=w({_meta:_(f(),S()).nullish(),blob:f(),mimeType:f().nullish(),uri:f()}),zx=w({default:Oe().nullish(),description:f().nullish(),title:f().nullish()}),Ux=w({_meta:_(f(),S()).nullish()}),Fx=w({_meta:_(f(),S()).nullish()}),Zx=w({amount:j(),currency:f()}),Hx=w({_meta:_(f(),S()).nullish(),terminalId:f()}),Vx=w({_meta:_(f(),S()).nullish(),newText:f(),oldText:f().nullish(),path:f()}),Bx=K([f(),j(),j(),Oe(),M(f())]),Wx=w({content:_(f(),Bx).nullish()}),qx=K([Wx.and(w({action:$("accept")})),w({action:$("decline")}),w({action:$("cancel")})]),jx=w({_meta:_(f(),S()).nullish()}),ob=f(),Gx=w({_meta:_(f(),S()).nullish(),elicitationId:ob}),Yx=w({_meta:_(f(),S()).nullish(),action:qx}),Jx=$("object"),Kx=$("string"),Xx=w({_meta:_(f(),S()).nullish()}),Qx=w({_meta:_(f(),S()).nullish(),form:jx.nullish(),url:Xx.nullish()}),eP=w({elicitationId:ob,url:f().url()}),ab=w({const:f(),title:f()}),lb=w({_meta:_(f(),S()).nullish(),name:f(),value:f()}),tP=K([$(-32700),$(-32600),$(-32601),$(-32602),$(-32603),$(-32800),$(-32e3),$(-32002),$(-32042),j().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),cb=w({code:tP,data:S().optional(),message:f()}),ub=S(),hb=S(),db=S(),nP=w({_meta:_(f(),S()).nullish(),readTextFile:Oe().optional().default(!1),writeTextFile:Oe().optional().default(!1)}),pb=w({_meta:_(f(),S()).nullish(),name:f(),value:f()}),fb=w({_meta:_(f(),S()).nullish(),name:f(),title:f().nullish(),version:f()}),rP=w({default:j().nullish(),description:f().nullish(),maximum:j().nullish(),minimum:j().nullish(),title:f().nullish()}),iP=w({_meta:_(f(),S()).nullish()}),sP=w({_meta:_(f(),S()).nullish(),additionalDirectories:M(f()).optional(),cursor:f().nullish(),cwd:f().nullish()}),oP=w({_meta:_(f(),S()).nullish()}),aP=w({_meta:_(f(),S()).nullish(),logout:oP.nullish()}),lP=w({_meta:_(f(),S()).nullish()}),cP=w({_meta:_(f(),S()).nullish()}),uP=w({_meta:_(f(),S()).nullish(),http:Oe().optional().default(!1),sse:Oe().optional().default(!1)}),hP=w({_meta:_(f(),S()).nullish(),headers:M(pb),name:f(),url:f()}),dP=w({_meta:_(f(),S()).nullish(),headers:M(pb),name:f(),url:f()}),pP=w({_meta:_(f(),S()).nullish(),args:M(f()),command:f(),env:M(lb),name:f()}),dd=K([hP.and(w({type:$("http")})),dP.and(w({type:$("sse")})),pP]),Xm=f(),fP=w({_meta:_(f(),S()).nullish(),description:f().nullish(),modelId:Xm,name:f()}),mP=K([$("error"),$("warning"),$("information"),$("hint")]),gP=w({_meta:_(f(),S()).nullish()}),vP=w({_meta:_(f(),S()).nullish()}),yP=w({_meta:_(f(),S()).nullish()}),wP=w({_meta:_(f(),S()).nullish()}),bP=w({_meta:_(f(),S()).nullish()}),SP=w({_meta:_(f(),S()).nullish(),maxCount:j().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),_P=w({diff:f(),uri:f()}),AP=w({endLine:j().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:j().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:f()}),EP=w({_meta:_(f(),S()).nullish()}),kP=w({_meta:_(f(),S()).nullish()}),CP=w({languageId:f(),text:f(),uri:f()}),$P=w({_meta:_(f(),S()).nullish(),maxCount:j().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),TP=K([$("rejected"),$("ignored"),$("replaced"),$("cancelled")]),RP=w({excerpts:M(AP),uri:f()}),IP=w({_meta:_(f(),S()).nullish()}),xP=w({_meta:_(f(),S()).nullish()}),PP=w({name:f(),owner:f(),remoteUrl:f()}),LP=w({_meta:_(f(),S()).nullish()}),DP=w({_meta:_(f(),S()).nullish(),jump:EP.nullish(),rename:xP.nullish(),searchAndReplace:LP.nullish()}),OP=w({id:f(),isRegex:Oe().nullish(),replace:f(),search:f(),uri:f()}),MP=K([$("automatic"),$("diagnostic"),$("manual")]),NP=w({_meta:_(f(),S()).nullish(),maxCount:j().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),zP=w({_meta:_(f(),S()).nullish(),diagnostics:gP.nullish(),editHistory:SP.nullish(),openFiles:kP.nullish(),recentFiles:$P.nullish(),relatedSnippets:IP.nullish(),userActions:NP.nullish()}),UP=w({_meta:_(f(),S()).nullish(),additionalDirectories:M(f()).optional(),cwd:f(),mcpServers:M(dd)}),FP=w({default:j().nullish(),description:f().nullish(),maximum:j().nullish(),minimum:j().nullish(),title:f().nullish()}),mb=f(),ZP=K([$("allow_once"),$("allow_always"),$("reject_once"),$("reject_always")]),HP=w({_meta:_(f(),S()).nullish(),kind:ZP,name:f(),optionId:mb}),VP=K([$("high"),$("medium"),$("low")]),BP=K([$("pending"),$("in_progress"),$("completed")]),WP=w({_meta:_(f(),S()).nullish(),content:f(),priority:VP,status:BP}),qP=w({_meta:_(f(),S()).nullish(),entries:M(WP)}),di=w({character:j().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:j().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),jP=w({id:f(),position:di,uri:f()}),GP=w({id:f(),newName:f(),position:di,uri:f()}),YP=w({action:f(),position:di,timestampMs:j(),uri:f()}),gb=K([$("utf-16"),$("utf-32"),$("utf-8")]),JP=w({_meta:_(f(),S()).nullish(),auth:Rx.optional().default({terminal:!1}),elicitation:Qx.nullish(),fs:nP.optional().default({readTextFile:!1,writeTextFile:!1}),nes:DP.nullish(),positionEncodings:M(gb).optional(),terminal:Oe().optional().default(!1)}),KP=w({_meta:_(f(),S()).nullish(),audio:Oe().optional().default(!1),embeddedContext:Oe().optional().default(!1),image:Oe().optional().default(!1)}),vb=j().int().gte(0).lte(65535),XP=w({_meta:_(f(),S()).nullish(),clientCapabilities:JP.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:fb.nullish(),protocolVersion:vb}),ya=w({end:di,start:di}),QP=w({message:f(),range:ya,severity:mP,uri:f()}),eL=w({languageId:f(),lastFocusedMs:j().nullish(),uri:f(),visibleRange:ya.nullish()}),tL=w({_meta:_(f(),S()).nullish(),diagnostics:M(QP).nullish(),editHistory:M(_P).nullish(),openFiles:M(eL).nullish(),recentFiles:M(CP).nullish(),relatedSnippets:M(RP).nullish(),userActions:M(YP).nullish()}),nL=w({newText:f(),range:ya}),rL=w({cursorPosition:di.nullish(),edits:M(nL),id:f(),uri:f()}),iL=K([rL.and(w({kind:$("edit")})),jP.and(w({kind:$("jump")})),GP.and(w({kind:$("rename")})),OP.and(w({kind:$("searchAndReplace")}))]),sL=w({_meta:_(f(),S()).nullish(),content:f()}),oL=w({_meta:_(f(),S()).nullish()}),As=K([j(),f()]).nullable();w({_meta:_(f(),S()).nullish(),requestId:As});const aL=Xw(["assistant","user"]),Pc=w({_meta:_(f(),S()).nullish(),audience:M(aL).nullish(),lastModified:f().nullish(),priority:j().nullish()}),lL=w({_meta:_(f(),S()).nullish(),annotations:Pc.nullish(),data:f(),mimeType:f()}),cL=w({_meta:_(f(),S()).nullish(),annotations:Pc.nullish(),data:f(),mimeType:f(),uri:f().nullish()}),uL=w({_meta:_(f(),S()).nullish(),annotations:Pc.nullish(),description:f().nullish(),mimeType:f().nullish(),name:f(),size:j().nullish(),title:f().nullish(),uri:f()}),hL=w({_meta:_(f(),S()).nullish(),optionId:mb}),dL=K([w({outcome:$("cancelled")}),hL.and(w({outcome:$("selected")}))]),pL=w({_meta:_(f(),S()).nullish(),outcome:dL}),fL=w({_meta:_(f(),S()).nullish()}),mL=w({_meta:_(f(),S()).nullish()}),gL=w({currentValue:Oe()}),vL=f(),yb=f(),yL=K([$("mode"),$("model"),$("thought_level"),f()]),Qm=f(),wb=w({_meta:_(f(),S()).nullish(),description:f().nullish(),name:f(),value:Qm}),wL=w({_meta:_(f(),S()).nullish(),group:vL,name:f(),options:M(wb)}),bL=K([M(wb),M(wL)]),SL=w({currentValue:Qm,options:bL}),wa=hd(K([SL.and(w({type:$("select")})),gL.and(w({type:$("boolean")}))]),w({_meta:_(f(),S()).nullish(),category:yL.nullish(),description:f().nullish(),id:yb,name:f()})),_L=w({_meta:_(f(),S()).nullish(),configOptions:M(wa)}),AL=w({_meta:_(f(),S()).nullish()}),ae=f(),EL=w({_meta:_(f(),S()).nullish(),id:f(),sessionId:ae}),kL=w({_meta:_(f(),S()).nullish(),sessionId:ae}),CL=w({_meta:_(f(),S()).nullish(),sessionId:ae}),$L=w({_meta:_(f(),S()).nullish(),sessionId:ae}),bb=w({_meta:_(f(),S()).nullish(),args:M(f()).optional(),command:f(),cwd:f().nullish(),env:M(lb).optional(),outputByteLimit:j().nullish(),sessionId:ae}),TL=w({_meta:_(f(),S()).nullish(),sessionId:ae,uri:f()}),RL=w({_meta:_(f(),S()).nullish(),position:di,sessionId:ae,uri:f(),version:j(),visibleRange:ya}),IL=w({_meta:_(f(),S()).nullish(),languageId:f(),sessionId:ae,text:f(),uri:f(),version:j()}),xL=w({_meta:_(f(),S()).nullish(),sessionId:ae,uri:f()}),PL=w({_meta:_(f(),S()).nullish(),additionalDirectories:M(f()).optional(),cwd:f(),mcpServers:M(dd).optional(),sessionId:ae}),Sb=w({_meta:_(f(),S()).nullish(),sessionId:ae,terminalId:f()}),LL=w({_meta:_(f(),S()).nullish(),additionalDirectories:M(f()).optional(),cwd:f(),mcpServers:M(dd),sessionId:ae}),_b=w({_meta:_(f(),S()).nullish(),limit:j().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:j().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:f(),sessionId:ae}),DL=w({_meta:_(f(),S()).nullish(),id:f(),reason:TP.nullish(),sessionId:ae}),Ab=w({_meta:_(f(),S()).nullish(),sessionId:ae,terminalId:f()}),OL=w({_meta:_(f(),S()).nullish(),additionalDirectories:M(f()).optional(),cwd:f(),mcpServers:M(dd).optional(),sessionId:ae}),ML=w({_meta:_(f(),S()).nullish(),additionalDirectories:M(f()).optional(),cwd:f(),sessionId:ae,title:f().nullish(),updatedAt:f().nullish()}),NL=w({_meta:_(f(),S()).nullish(),nextCursor:f().nullish(),sessions:M(ML)}),zL=w({_meta:_(f(),S()).nullish(),title:f().nullish(),updatedAt:f().nullish()}),UL=w({_meta:_(f(),S()).nullish()}),pd=f(),FL=w({_meta:_(f(),S()).nullish(),currentModeId:pd}),ZL=w({_meta:_(f(),S()).nullish(),description:f().nullish(),id:pd,name:f()}),fd=w({_meta:_(f(),S()).nullish(),availableModes:M(ZL),currentModeId:pd}),md=w({_meta:_(f(),S()).nullish(),availableModels:M(fP),currentModelId:Xm}),HL=w({_meta:_(f(),S()).nullish(),configOptions:M(wa).nullish(),models:md.nullish(),modes:fd.nullish(),sessionId:ae}),VL=w({_meta:_(f(),S()).nullish(),configOptions:M(wa).nullish(),models:md.nullish(),modes:fd.nullish()}),BL=w({_meta:_(f(),S()).nullish(),configOptions:M(wa).nullish(),models:md.nullish(),modes:fd.nullish(),sessionId:ae}),WL=w({_meta:_(f(),S()).nullish(),configOptions:M(wa).nullish(),models:md.nullish(),modes:fd.nullish()}),qL=w({_meta:_(f(),S()).nullish()}),jL=w({_meta:_(f(),S()).nullish(),additionalDirectories:fL.nullish(),close:mL.nullish(),fork:AL.nullish(),list:UL.nullish(),resume:qL.nullish()}),GL=hd(K([w({type:$("boolean"),value:Oe()}),w({value:Qm})]),w({_meta:_(f(),S()).nullish(),configId:yb,sessionId:ae})),YL=w({_meta:_(f(),S()).nullish(),configOptions:M(wa)}),JL=w({_meta:_(f(),S()).nullish(),modeId:pd,sessionId:ae}),KL=w({_meta:_(f(),S()).nullish()}),XL=w({_meta:_(f(),S()).nullish(),modelId:Xm,sessionId:ae}),QL=w({_meta:_(f(),S()).nullish()}),eD=w({_meta:_(f(),S()).nullish(),sessionId:ae}),tD=K([$("end_turn"),$("max_tokens"),$("max_turn_requests"),$("refusal"),$("cancelled")]),nD=K([$("email"),$("uri"),$("date"),$("date-time")]),rD=w({default:f().nullish(),description:f().nullish(),enum:M(f()).nullish(),format:nD.nullish(),maxLength:j().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:j().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:M(ab).nullish(),pattern:f().nullish(),title:f().nullish()}),iD=w({_meta:_(f(),S()).nullish(),context:tL.nullish(),position:di,selection:ya.nullish(),sessionId:ae,triggerKind:MP,uri:f(),version:j()}),sD=w({_meta:_(f(),S()).nullish(),suggestions:M(iL)}),oD=w({_meta:_(f(),S()).nullish(),terminalId:f()}),aD=w({_meta:_(f(),S()).nullish(),exitCode:j().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:f().nullish()}),Eb=w({_meta:_(f(),S()).nullish(),sessionId:ae,terminalId:f()}),lD=w({_meta:_(f(),S()).nullish(),exitStatus:aD.nullish(),output:f(),truncated:Oe()}),cD=w({_meta:_(f(),S()).nullish(),annotations:Pc.nullish(),text:f()}),uD=w({range:ya.nullish(),text:f()}),hD=w({_meta:_(f(),S()).nullish(),contentChanges:M(uD),sessionId:ae,uri:f(),version:j()});w({method:f(),params:K([kL,IL,hD,TL,xL,RL,EL,DL,ub]).nullish()});const dD=K([$("full"),$("incremental")]),pD=w({_meta:_(f(),S()).nullish(),syncKind:dD}),fD=w({_meta:_(f(),S()).nullish(),didChange:pD.nullish(),didClose:vP.nullish(),didFocus:yP.nullish(),didOpen:wP.nullish(),didSave:bP.nullish()}),mD=w({_meta:_(f(),S()).nullish(),document:fD.nullish()}),gD=w({_meta:_(f(),S()).nullish(),context:zP.nullish(),events:mD.nullish()}),vD=w({_meta:_(f(),S()).nullish(),auth:aP.optional().default({}),loadSession:Oe().optional().default(!1),mcpCapabilities:uP.optional().default({http:!1,sse:!1}),nes:gD.nullish(),positionEncoding:gb.nullish(),promptCapabilities:KP.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:jL.optional().default({})}),yD=w({_meta:_(f(),S()).nullish(),agentCapabilities:vD.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:fb.nullish(),authMethods:M(Dx).optional().default([]),protocolVersion:vb}),wD=w({_meta:_(f(),S()).nullish(),mimeType:f().nullish(),text:f(),uri:f()}),bD=K([wD,Nx]),SD=w({_meta:_(f(),S()).nullish(),annotations:Pc.nullish(),resource:bD}),eg=K([cD.and(w({type:$("text")})),cL.and(w({type:$("image")})),lL.and(w({type:$("audio")})),uL.and(w({type:$("resource_link")})),SD.and(w({type:$("resource")}))]),_D=w({_meta:_(f(),S()).nullish(),content:eg}),pp=w({_meta:_(f(),S()).nullish(),content:eg,messageId:f().nullish()}),AD=w({_meta:_(f(),S()).nullish(),messageId:f().nullish(),prompt:M(eg),sessionId:ae}),ED=w({anyOf:M(ab)}),kb=K([_D.and(w({type:$("content")})),Vx.and(w({type:$("diff")})),oD.and(w({type:$("terminal")}))]),Cb=f(),$b=w({_meta:_(f(),S()).nullish(),line:j().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:f()}),Tb=K([$("pending"),$("in_progress"),$("completed"),$("failed")]),Rb=K([$("read"),$("edit"),$("delete"),$("move"),$("search"),$("execute"),$("think"),$("fetch"),$("switch_mode"),$("other")]),kD=w({_meta:_(f(),S()).nullish(),content:M(kb).optional(),kind:Rb.optional(),locations:M($b).optional(),rawInput:S().optional(),rawOutput:S().optional(),status:Tb.optional(),title:f(),toolCallId:Cb}),Ib=w({_meta:_(f(),S()).nullish(),content:M(kb).nullish(),kind:Rb.nullish(),locations:M($b).nullish(),rawInput:S().optional(),rawOutput:S().optional(),status:Tb.nullish(),title:f().nullish(),toolCallId:Cb}),xb=w({_meta:_(f(),S()).nullish(),options:M(HP),sessionId:ae,toolCall:Ib}),CD=w({_meta:_(f(),S()).nullish(),hint:f()}),$D=CD,TD=w({_meta:_(f(),S()).nullish(),description:f(),input:$D.nullish(),name:f()}),RD=w({_meta:_(f(),S()).nullish(),availableCommands:M(TD)}),ID=w({enum:M(f()),type:Kx}),xD=K([ID,ED]),PD=w({default:M(f()).nullish(),description:f().nullish(),items:xD,maxItems:j().nullish(),minItems:j().nullish(),title:f().nullish()}),LD=K([rD.and(w({type:$("string")})),FP.and(w({type:$("number")})),rP.and(w({type:$("integer")})),zx.and(w({type:$("boolean")})),PD.and(w({type:$("array")}))]),DD=w({description:f().nullish(),properties:_(f(),LD).optional().default({}),required:M(f()).nullish(),title:f().nullish(),type:Jx.optional().default("object")}),OD=w({requestedSchema:DD}),MD=hd(K([OD.and(w({mode:$("form")})),eP.and(w({mode:$("url")}))]),w({_meta:_(f(),S()).nullish(),message:f(),sessionId:ae})),ND=w({cachedReadTokens:j().nullish(),cachedWriteTokens:j().nullish(),inputTokens:j(),outputTokens:j(),thoughtTokens:j().nullish(),totalTokens:j()}),zD=w({_meta:_(f(),S()).nullish(),stopReason:tD,usage:ND.nullish(),userMessageId:f().nullish()});K([w({id:As,result:K([yD,Mx,cP,BL,VL,NL,HL,WL,Fx,KL,YL,zD,QL,eD,sD,Ux,db])}),w({error:cb,id:As})]);const UD=w({_meta:_(f(),S()).nullish(),cost:Zx.nullish(),size:j(),used:j()}),FD=K([pp.and(w({sessionUpdate:$("user_message_chunk")})),pp.and(w({sessionUpdate:$("agent_message_chunk")})),pp.and(w({sessionUpdate:$("agent_thought_chunk")})),kD.and(w({sessionUpdate:$("tool_call")})),Ib.and(w({sessionUpdate:$("tool_call_update")})),qP.and(w({sessionUpdate:$("plan")})),RD.and(w({sessionUpdate:$("available_commands_update")})),FL.and(w({sessionUpdate:$("current_mode_update")})),_L.and(w({sessionUpdate:$("config_option_update")})),zL.and(w({sessionUpdate:$("session_info_update")})),UD.and(w({sessionUpdate:$("usage_update")}))]),Pb=w({_meta:_(f(),S()).nullish(),sessionId:ae,update:FD});w({method:f(),params:K([Pb,Gx,ub]).nullish()});const Lb=w({_meta:_(f(),S()).nullish(),sessionId:ae,terminalId:f()}),ZD=w({_meta:_(f(),S()).nullish(),exitCode:j().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:f().nullish()}),HD=w({name:f(),uri:f()}),VD=w({_meta:_(f(),S()).nullish(),repository:PP.nullish(),workspaceFolders:M(HD).nullish(),workspaceUri:f().nullish()});w({id:As,method:f(),params:K([XP,Ox,lP,UP,LL,sP,PL,OL,$L,JL,GL,AD,XL,VD,iD,CL,hb]).nullish()});const Db=w({_meta:_(f(),S()).nullish(),content:f(),path:f(),sessionId:ae});w({id:As,method:f(),params:K([Db,_b,xb,bb,Eb,Ab,Lb,Sb,MD,hb]).nullish()});const BD=w({_meta:_(f(),S()).nullish()});K([w({id:As,result:K([BD,sL,pL,Hx,lD,oL,ZD,iP,Yx,db])}),w({error:cb,id:As})]);var se;class WD{constructor(t,e){m(this,se);const r=t(this),i=async(a,l)=>{var c,u,p,g,v,y,E;switch(a){case Zn.fs_write_text_file:{const A=Db.parse(l);return(c=r.writeTextFile)==null?void 0:c.call(r,A)}case Zn.fs_read_text_file:{const A=_b.parse(l);return(u=r.readTextFile)==null?void 0:u.call(r,A)}case Zn.session_request_permission:{const A=xb.parse(l);return r.requestPermission(A)}case Zn.terminal_create:{const A=bb.parse(l);return(p=r.createTerminal)==null?void 0:p.call(r,A)}case Zn.terminal_output:{const A=Eb.parse(l);return(g=r.terminalOutput)==null?void 0:g.call(r,A)}case Zn.terminal_release:{const A=Ab.parse(l);return await((v=r.releaseTerminal)==null?void 0:v.call(r,A))??{}}case Zn.terminal_wait_for_exit:{const A=Lb.parse(l);return(y=r.waitForTerminalExit)==null?void 0:y.call(r,A)}case Zn.terminal_kill:{const A=Sb.parse(l);return await((E=r.killTerminal)==null?void 0:E.call(r,A))??{}}default:if(r.extMethod)return r.extMethod(a,l);throw Ie.methodNotFound(a)}},s=async(a,l)=>{switch(a){case Zn.session_update:{const c=Pb.parse(l);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(a,l);throw Ie.methodNotFound(a)}};d(this,se,new qD(i,s,e))}async initialize(t){return await o(this,se).sendRequest(me.initialize,t)}async newSession(t){return await o(this,se).sendRequest(me.session_new,t)}async loadSession(t){return await o(this,se).sendRequest(me.session_load,t)??{}}async unstable_forkSession(t){return await o(this,se).sendRequest(me.session_fork,t)}async listSessions(t){return await o(this,se).sendRequest(me.session_list,t)}async unstable_resumeSession(t){return await o(this,se).sendRequest(me.session_resume,t)}async unstable_closeSession(t){return await o(this,se).sendRequest(me.session_close,t)}async setSessionMode(t){return await o(this,se).sendRequest(me.session_set_mode,t)??{}}async unstable_setSessionModel(t){return await o(this,se).sendRequest(me.session_set_model,t)??{}}async setSessionConfigOption(t){return await o(this,se).sendRequest(me.session_set_config_option,t)}async authenticate(t){return await o(this,se).sendRequest(me.authenticate,t)??{}}async unstable_logout(t){return await o(this,se).sendRequest(me.logout,t)??{}}async prompt(t){return await o(this,se).sendRequest(me.session_prompt,t)}async cancel(t){return await o(this,se).sendNotification(me.session_cancel,t)}async unstable_startNes(t){return await o(this,se).sendRequest(me.nes_start,t)}async unstable_suggestNes(t){return await o(this,se).sendRequest(me.nes_suggest,t)}async unstable_closeNes(t){return await o(this,se).sendRequest(me.nes_close,t)??{}}async unstable_didOpenDocument(t){return await o(this,se).sendNotification(me.document_did_open,t)}async unstable_didChangeDocument(t){return await o(this,se).sendNotification(me.document_did_change,t)}async unstable_didCloseDocument(t){return await o(this,se).sendNotification(me.document_did_close,t)}async unstable_didSaveDocument(t){return await o(this,se).sendNotification(me.document_did_save,t)}async unstable_didFocusDocument(t){return await o(this,se).sendNotification(me.document_did_focus,t)}async unstable_acceptNes(t){return await o(this,se).sendNotification(me.nes_accept,t)}async unstable_rejectNes(t){return await o(this,se).sendNotification(me.nes_reject,t)}async extMethod(t,e){return await o(this,se).sendRequest(t,e)}async extNotification(t,e){return await o(this,se).sendNotification(t,e)}get signal(){return o(this,se).signal}get closed(){return o(this,se).closed}}se=new WeakMap;var xr,_h,kl,Cl,fo,mo,cn,$l,ye,Ob,Jp,Mb,Nb,zb,Ub,Kp,Va;class qD{constructor(t,e,r){m(this,ye);m(this,xr,new Map);m(this,_h,0);m(this,kl);m(this,Cl);m(this,fo);m(this,mo,Promise.resolve());m(this,cn,new AbortController);m(this,$l);d(this,kl,t),d(this,Cl,e),d(this,fo,r),d(this,$l,new Promise(i=>{o(this,cn).signal.addEventListener("abort",()=>i())})),h(this,ye,Ob).call(this)}get signal(){return o(this,cn).signal}get closed(){return o(this,$l)}async sendRequest(t,e){h(this,ye,Kp).call(this);const r=Wc(this,_h)._++,i=new Promise((s,a)=>{o(this,xr).set(r,{resolve:s,reject:a})});return await h(this,ye,Va).call(this,{jsonrpc:"2.0",id:r,method:t,params:e}),i}async sendNotification(t,e){h(this,ye,Kp).call(this),await h(this,ye,Va).call(this,{jsonrpc:"2.0",method:t,params:e})}}xr=new WeakMap,_h=new WeakMap,kl=new WeakMap,Cl=new WeakMap,fo=new WeakMap,mo=new WeakMap,cn=new WeakMap,$l=new WeakMap,ye=new WeakSet,Ob=async function(){let t;try{const e=o(this,fo).readable.getReader();try{for(;!o(this,cn).signal.aborted;){const{value:r,done:i}=await e.read();if(i)break;if(r)try{h(this,ye,Mb).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&h(this,ye,Va).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{e.releaseLock()}}catch(e){t=e}finally{h(this,ye,Jp).call(this,t)}},Jp=function(t){if(o(this,cn).signal.aborted)return;const e=t??new Error("ACP connection closed");for(const r of o(this,xr).values())r.reject(e);o(this,xr).clear(),o(this,cn).abort(e)},Mb=async function(t){if("method"in t&&"id"in t){const e=await h(this,ye,Nb).call(this,t.method,t.params);"error"in e&&console.error("Error handling request",t,e.error),await h(this,ye,Va).call(this,{jsonrpc:"2.0",id:t.id,...e})}else if("method"in t){const e=await h(this,ye,zb).call(this,t.method,t.params);"error"in e&&console.error("Error handling notification",t,e.error)}else"id"in t?h(this,ye,Ub).call(this,t):console.error("Invalid message",{message:t})},Nb=async function(t,e){try{return{result:await o(this,kl).call(this,t,e)??null}}catch(r){if(r instanceof Ie)return r.toResult();if(r instanceof Hv)return Ie.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 Ie.internalError(i?JSON.parse(i):{}).toResult()}catch{return Ie.internalError({details:i}).toResult()}}},zb=async function(t,e){try{return await o(this,Cl).call(this,t,e),{result:null}}catch(r){if(r instanceof Ie)return r.toResult();if(r instanceof Hv)return Ie.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 Ie.internalError(i?JSON.parse(i):{}).toResult()}catch{return Ie.internalError({details:i}).toResult()}}},Ub=function(t){const e=o(this,xr).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 Ie(r,i,s))}o(this,xr).delete(t.id)}else console.error("Got response to unknown request",t.id)},Kp=function(){if(o(this,cn).signal.aborted)throw o(this,cn).signal.reason??new Error("ACP connection closed")},Va=async function(t){return d(this,mo,o(this,mo).then(async()=>{const e=o(this,fo).writable.getWriter();try{await e.write(t)}finally{e.releaseLock()}}).catch(e=>{h(this,ye,Jp).call(this,e)})),o(this,mo)};class Ie extends Error{constructor(e,r,i){super(r);C(this,"code");C(this,"data");this.code=e,this.name="RequestError",this.data=i}static parseError(e,r){return new Ie(-32700,`Parse error${r?`: ${r}`:""}`,e)}static invalidRequest(e,r){return new Ie(-32600,`Invalid request${r?`: ${r}`:""}`,e)}static methodNotFound(e){return new Ie(-32601,`"Method not found": ${e}`,{method:e})}static invalidParams(e,r){return new Ie(-32602,`Invalid params${r?`: ${r}`:""}`,e)}static internalError(e,r){return new Ie(-32603,`Internal error${r?`: ${r}`:""}`,e)}static authRequired(e,r){return new Ie(-32e3,`Authentication required${r?`: ${r}`:""}`,e)}static resourceNotFound(e){return new Ie(-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 jD(n,t,e){const r=n.dispose.bind(n);n.dispose=()=>{if(!t())return e(),r()}}function Fb(n){var e;class t extends n{constructor(...s){super(...s);m(this,e,!1);jD(this,()=>o(this,e),()=>{d(this,e,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return o(this,e)}}return e=new WeakMap,t}const GD=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,YD=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,JD=/\[Television channel context\][\s\S]*?\[\/Television channel context\]\n*/,KD=/\b(tv|television|channel|artifact|artifacts|viewer|filmstrip|layout|focus)\b/i,XD=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,QD="single_session",e5={name:"television-acp-client",version:"0.0.0"},Zb="agent:main:television",t5=Fb(mi);var go,un,ft,hn,Pr,Vt,Kn,dn,pn,Lr,Bt,vo,yo,fn,je,Xn,wo,Ni,Qn,Dr,Tl,Wt,mn,Ah,gn,R,Xp,Hb,Vb,Bb,Eu,Wb,qb,jb,Gb,Yb,Jb,Kb,_i,Ws,qs,Vn,Xb,js,Qp,ef,ku,Qb,Cu,tf,nf,Rl,Il,$u,Gs,rf,e2;class n5 extends t5{constructor(e){super();m(this,R);m(this,go,"disconnected");m(this,un,null);m(this,ft,new Map);m(this,hn,null);m(this,Pr,null);m(this,Vt,null);m(this,Kn,null);m(this,dn,null);m(this,pn,null);m(this,Lr);m(this,Bt,null);m(this,vo,0);m(this,yo,1);m(this,fn,null);m(this,je,null);m(this,Xn,!1);m(this,wo,!1);m(this,Ni,!1);m(this,Qn,null);m(this,Dr,new Set);m(this,Tl);m(this,Wt);m(this,mn);m(this,Ah,e=>{h(this,R,Vb).call(this,e)});m(this,gn,null);m(this,Rl,()=>{h(this,R,Gs).call(this,"ACP bridge websocket closed")});m(this,Il,()=>{h(this,R,Gs).call(this,"ACP bridge websocket error")});d(this,Wt,e),d(this,mn,e.sessionMode??QD),d(this,Lr,e.mappedSessionStore??r5()),d(this,Tl,e.createSocket??(r=>new WebSocket(r)))}get status(){return o(this,go)}get messages(){return[...o(this,ft).values()]}get enabled(){return o(this,Wt).enabled??!1}setToken(e){o(this,Wt).token=e??""}setEnabled(e){o(this,Wt).enabled=e,e||(h(this,R,$u).call(this),d(this,un,null),h(this,R,Vn).call(this,"disconnected"))}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(this.enabled&&this.status==="disconnected"){o(this,Pr)===null&&(d(this,un,null),d(this,Pr,h(this,R,Hb).call(this)));try{await o(this,Pr),await h(this,R,Eu).call(this)}catch(e){throw h(this,R,Gs).call(this,fp(e)),e}}}dispose(){h(this,R,$u).call(this),d(this,un,null),h(this,R,Vn).call(this,"disposed")}async sendMessage(e){if(await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await h(this,R,Xp).call(this,"ready")),(o(this,dn)===null||o(this,Bt)!==h(this,R,Cu).call(this))&&await h(this,R,Eu).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,R,Ws).call(this,{id:h(this,R,js).call(this,"user"),kind:"user",text:r,status:"final"}),h(this,R,Vn).call(this,"running");try{const i=await h(this,R,ku).call(this).prompt({sessionId:h(this,R,ef).call(this),prompt:[{type:"text",text:h(this,R,Xb).call(this,r)}]});h(this,R,_i).call(this,i.stopReason==="cancelled"?"cancelled":"final"),h(this,R,Vn).call(this,"ready")}catch(i){throw h(this,R,e2).call(this)||(h(this,R,_i).call(this,"error"),h(this,R,Vn).call(this,"ready")),i}}async startNewSession(){var r;await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await h(this,R,Xp).call(this,"ready"));const e=h(this,R,Cu).call(this);((r=o(this,pn))==null?void 0:r.sessionIdStrategy)==="mapped"?o(this,Lr).clearActualSessionId(e):d(this,vo,o(this,vo)+1),d(this,Vt,null),d(this,Kn,null),d(this,dn,null),d(this,Bt,null),h(this,R,rf).call(this)}async cancel(){this.status==="running"&&(h(this,R,Vn).call(this,"cancelling"),await h(this,R,ku).call(this).cancel({sessionId:h(this,R,ef).call(this)}))}setChannelContext(e){var s,a,l;if(e===null){if(o(this,je)===null)return;d(this,je,null),d(this,Xn,!1);return}const r={channelID:e.channelID,channelName:e.channelName};if(((s=o(this,je))==null?void 0:s.channelID)===r.channelID&&((a=o(this,je))==null?void 0:a.channelName)===r.channelName)return;const i=((l=o(this,je))==null?void 0:l.channelID)??null;if(d(this,je,r),o(this,mn)==="single_session"){(!o(this,Bt)||i!==r.channelID)&&d(this,Xn,!0);return}o(this,Bt)!==h(this,R,tf).call(this,r.channelID)&&(d(this,Vt,null),d(this,Kn,null),o(this,hn)&&this.status==="ready"&&h(this,R,Eu).call(this).catch(c=>{h(this,R,Gs).call(this,fp(c))}))}}go=new WeakMap,un=new WeakMap,ft=new WeakMap,hn=new WeakMap,Pr=new WeakMap,Vt=new WeakMap,Kn=new WeakMap,dn=new WeakMap,pn=new WeakMap,Lr=new WeakMap,Bt=new WeakMap,vo=new WeakMap,yo=new WeakMap,fn=new WeakMap,je=new WeakMap,Xn=new WeakMap,wo=new WeakMap,Ni=new WeakMap,Qn=new WeakMap,Dr=new WeakMap,Tl=new WeakMap,Wt=new WeakMap,mn=new WeakMap,Ah=new WeakMap,gn=new WeakMap,R=new WeakSet,Xp=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,un)??"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,un)??"ACPClient is disconnected")))};this.addEventListener("status-changed",a)})}},Hb=async function(){try{const{stream:e,socket:r,metadata:i}=await a5({serverURL:o(this,Wt).serverURL,token:o(this,Wt).token,createSocket:o(this,Tl),onDisconnect:o(this,Ah)});d(this,pn,i),d(this,gn,r),r.addEventListener("close",o(this,Rl)),r.addEventListener("error",o(this,Il)),d(this,hn,new WD(s=>({connection:s,sessionUpdate:async a=>{await h(this,R,qb).call(this,a)},requestPermission:async a=>h(this,R,jb).call(this,a)}),e)),await o(this,hn).initialize({protocolVersion:Tx,clientCapabilities:{},clientInfo:e5})}catch(e){throw e}},Vb=function(e){h(this,R,Gs).call(this,fp(e))},Bb=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})`)},Eu=async function(){const e=h(this,R,Cu).call(this);if(o(this,Vt)&&o(this,Kn)===e){await o(this,Vt);return}d(this,Kn,e),d(this,Vt,h(this,R,Wb).call(this,e)),await o(this,Vt)},Wb=async function(e){var c;const r=h(this,R,ku).call(this);h(this,R,rf).call(this);let i,s=!1,a=null;const l={cwd:h(this,R,Qb).call(this),mcpServers:[],_meta:{sessionKey:e}};try{if(d(this,Ni,!0),d(this,Qn,null),((c=o(this,pn))==null?void 0:c.sessionIdStrategy)==="mapped"){const u=o(this,Lr).getActualSessionId(e);if(u)try{const p=await r.loadSession({...l,sessionId:u});if(i5(p))throw new Error("Mapped ACP session was not found");a=p,i=u,s=!0}catch{const p=await r.newSession(l);a=p,i=p.sessionId,o(this,Lr).setActualSessionId(e,i),s=!1}else{const p=await r.newSession(l);a=p,i=p.sessionId,o(this,Lr).setActualSessionId(e,i),s=!1}}else try{a=await r.loadSession({...l,sessionId:e}),i=e,s=o(this,ft).size>0}catch{const u=await r.newSession(l);a=u,i=u.sessionId,s=!1}}finally{d(this,Ni,!1),d(this,Qn,null),h(this,R,_i).call(this,"final")}h(this,R,Bb).call(this,a),await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),d(this,dn,i),d(this,Bt,e),d(this,wo,!0),s?(o(this,Dr).add(e),o(this,mn)==="single_session"&&d(this,Xn,!1)):(o(this,Dr).delete(e),d(this,Xn,o(this,mn)==="single_session")),d(this,un,null),h(this,R,Vn).call(this,"ready")},qb=async function(e){const r=e.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&h(this,R,Kb).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&h(this,R,Gb).call(this,r.content.text);return;case"tool_call":h(this,R,Yb).call(this,r);return;case"tool_call_update":h(this,R,Jb).call(this,r);return;case"agent_thought_chunk":return;default:return}},jb=async function(e){return{outcome:{outcome:"cancelled"}}},Gb=function(e){d(this,Qn,null);const r=o5(e);if(!r)return;if(!o(this,fn)){const s={id:h(this,R,js).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};d(this,fn,s.id),h(this,R,Ws).call(this,s);return}const i=o(this,ft).get(o(this,fn));if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");h(this,R,qs).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},Yb=function(e){h(this,R,_i).call(this,"final");const r=h(this,R,Qp).call(this,e.toolCallId),i=e1("content"in e?e.content:void 0),s={id:(r==null?void 0:r.id)??h(this,R,js).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,R,qs).call(this,s);return}h(this,R,Ws).call(this,s)},Jb=function(e){const r=h(this,R,Qp).call(this,e.toolCallId),i=(r==null?void 0:r.text)??"",s=e1(e.content),a=s?`${i}${s}`:i,l={id:(r==null?void 0:r.id)??h(this,R,js).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,R,qs).call(this,l);return}h(this,R,Ws).call(this,l)},Kb=function(e){if(h(this,R,_i).call(this,"final"),!e)return;const r=o(this,Ni)?o(this,Qn):null;if(!r){const s=Qv(e);if(!s)return;const a={id:h(this,R,js).call(this,"user"),kind:"user",text:s,status:"final"};h(this,R,Ws).call(this,a),o(this,Ni)&&d(this,Qn,a.id);return}const i=o(this,ft).get(r);if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");h(this,R,qs).call(this,{...i,text:Qv(`${i.text}${e}`)})},_i=function(e){if(!o(this,fn))return;const r=o(this,ft).get(o(this,fn));(r==null?void 0:r.kind)==="assistant"&&h(this,R,qs).call(this,{...r,status:e}),d(this,fn,null)},Ws=function(e){o(this,ft).set(e.id,e),this.dispatchEvent(new up("messages-changed"))},qs=function(e){o(this,ft).set(e.id,e),this.dispatchEvent(new up("messages-changed"))},Vn=function(e){o(this,go)!==e&&(d(this,go,e),this.dispatchEvent(new d$("status-changed")))},Xb=function(e){const r=o(this,Bt);if(!r)return e;const i=o(this,je)?o(this,mn)==="single_session"?o(this,Xn)||!o(this,Dr).has(r):!o(this,Dr).has(r):!1,s=o(this,wo)&&(o(this,je)!==null||KD.test(e));if(!(s||i))return e;s&&d(this,wo,!1),i&&(d(this,Xn,!1),o(this,Dr).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>`."];return o(this,je)?(l.push("This conversation is currently attached to the channel below."),l.push(`channel_id: ${o(this,je).channelID}`),l.push(`channel_name: ${o(this,je).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(`
43
- `)},js=function(e){const r=`${e}-${o(this,yo)}`;return d(this,yo,o(this,yo)+1),r},Qp=function(e){for(const r of o(this,ft).values())if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===e)return r;return null},ef=function(){if(!o(this,dn))throw new Error("ACP session is not ready");return o(this,dn)},ku=function(){if(!o(this,hn))throw new Error("ACP connection is not ready");return o(this,hn)},Qb=function(){var r;const e=(r=o(this,pn))==null?void 0:r.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},Cu=function(){var r;if(o(this,mn)==="single_session")return h(this,R,nf).call(this,`${Zb}-${(o(this,Wt).clientGUID??"default-client").toLowerCase()}`);const e=(r=o(this,je))==null?void 0:r.channelID;if(!e)throw new Error("Channel context is required for per-channel session mode");return h(this,R,tf).call(this,e)},tf=function(e){return h(this,R,nf).call(this,s5(o(this,mn),e,o(this,Wt).clientGUID??"default-client"))},nf=function(e){var r;return((r=o(this,pn))==null?void 0:r.sessionIdStrategy)==="deterministic"&&o(this,vo)>0?`${e}:epoch-${o(this,vo)}`:e},Rl=new WeakMap,Il=new WeakMap,$u=function(){d(this,hn,null),d(this,Pr,null),d(this,Vt,null),d(this,Kn,null),d(this,dn,null),d(this,Bt,null),d(this,pn,null),o(this,gn)&&(o(this,gn).removeEventListener("close",o(this,Rl)),o(this,gn).removeEventListener("error",o(this,Il)),o(this,gn).close(),d(this,gn,null))},Gs=function(e){const r=o(this,hn)!==null||o(this,Pr)!==null||o(this,Vt)!==null||o(this,Kn)!==null||o(this,dn)!==null||o(this,Bt)!==null||o(this,pn)!==null||o(this,gn)!==null;this.disposed||this.status==="disconnected"&&!r||(h(this,R,_i).call(this,"error"),h(this,R,$u).call(this),d(this,un,e??null),h(this,R,Vn).call(this,"disconnected"))},rf=function(){const e=o(this,ft).size>0;d(this,fn,null),d(this,Qn,null),d(this,yo,1),o(this,ft).clear(),e&&this.dispatchEvent(new up("messages-changed"))},e2=function(){return this.status==="disconnected"};function r5(){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 i5(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function s5(n,t,e){return n==="single_session"?`${Zb}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function t2(n){return n.replace(/^(?:\s*\n)+/,"")}function Qv(n){let t=n;return t=t.replace(GD,""),t=t.replace(YD,""),t=t.replace(JD,""),t=t2(t),t}function o5(n){let t=n;return t=t.replace(XD,""),t=t2(t),t}function e1(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function a5(n){const t=n.createSocket(u5(n.serverURL,n.token));let e=!1,r,i;const s=new Promise((u,p)=>{r=u,i=p}),a=new ReadableStream({start(u){let p=!1;const g=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},v=A=>{const x=c5(A);if(!x)return;let L;try{L=JSON.parse(x)}catch(D){const V=D instanceof Error?D:new Error(String(D));i(V),u.error(V);return}switch(L.type){case"acp-bridge-status":if(L.status==="ready"){let D;try{D=l5(L)}catch(V){const F=V instanceof Error?V:new Error(String(V));e||i(F),u.error(F);return}e||(e=!0,r(D));return}if(L.status==="error"||L.status==="exited"){const D=new Error(L.error??`ACP bridge ${L.status}`);e||i(D),u.error(D)}return;case"acp-bridge-message":u.enqueue(L.message);return}},y=()=>{var x;if(p)return;p=!0;const A=new Error("ACP bridge websocket closed");e||i(A),(x=n.onDisconnect)==null||x.call(n,A),u.close()},E=()=>{var x;if(p)return;p=!0;const A=new Error("ACP bridge websocket error");e||i(A),(x=n.onDisconnect)==null||x.call(n,A),u.error(A)};t.addEventListener("open",g),t.addEventListener("message",v),t.addEventListener("close",y),t.addEventListener("error",E)}}),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 l5(n){const{agent:t,sessionIdStrategy:e,sessionCwd:r}=n;if((t==="openclaw"||t==="hermes")&&(e==="deterministic"||e==="mapped")&&typeof r=="string"&&r.length>0)return{agent:t,sessionIdStrategy:e,sessionCwd:r};throw new Error("ACP bridge ready status missing bootstrap metadata")}function c5(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 u5(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 fp(n){return n instanceof Error?n.message:String(n)}const t1="television.acpClientGUID",n1="television.acpMappedSessions",r1=1;var bo;class h5{constructor(){m(this,bo,new Map)}getActualSessionId(t){return o(this,bo).get(t)??null}setActualSessionId(t,e){o(this,bo).set(t,e)}clearActualSessionId(t){o(this,bo).delete(t)}}bo=new WeakMap;var So,xl,yt,Tu,Ru,sf;class d5{constructor(t,e){m(this,yt);m(this,So);m(this,xl);d(this,So,t),d(this,xl,e)}getActualSessionId(t){const e=h(this,yt,Ru).call(this)[h(this,yt,Tu).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const r=h(this,yt,Ru).call(this);r[h(this,yt,Tu).call(this,t)]=e,h(this,yt,sf).call(this,r)}clearActualSessionId(t){const e=h(this,yt,Ru).call(this);delete e[h(this,yt,Tu).call(this,t)],h(this,yt,sf).call(this,e)}}So=new WeakMap,xl=new WeakMap,yt=new WeakSet,Tu=function(t){return JSON.stringify([o(this,xl),t])},Ru=function(){const t=o(this,So).getItem(n1);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!==r1?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},sf=function(t){const e={version:r1,entries:t};o(this,So).setItem(n1,JSON.stringify(e))};function n2(){return typeof window>"u"?null:window.localStorage}function p5(n){const t=n.getItem(t1);if(t)return t;const e=Wm().toLowerCase();return n.setItem(t1,e),e}const i1=4401,f5=401,ru=1e3,m5=3e4;class Iu extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class g5 extends mi{constructor(e){var a,l;super();C(this,"url");C(this,"name");C(this,"telemetryMeta");C(this,"status","unauthorized");C(this,"channels",new Map);C(this,"client");C(this,"acpClient");C(this,"_token");C(this,"attempting",!1);C(this,"nextRetryAt",null);C(this,"hasEverConnected",!1);C(this,"hasAuthRejected",!1);C(this,"hasAuthTokenRejected",!1);C(this,"bootState","pending");C(this,"serverVersion",null);C(this,"updateState",null);C(this,"decideBoot");C(this,"navigationPending");C(this,"createSocket");C(this,"createClient");C(this,"socket",null);C(this,"connectAttempt",0);C(this,"autoReconnect",!1);C(this,"retryTimer",null);C(this,"retryDelay",ru);C(this,"visibilityEventTarget");C(this,"networkEventTarget");C(this,"onVisibilityChange");C(this,"onNetworkOnline");C(this,"telemetryActivityAgent");this.url=ci(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,p)=>new UC(c,{token:u??void 0,onUnauthorized:()=>this.handleAuthRejected(),...p?{telemetryMeta:p}:{}})),this.client=this.createClient(this.url,this._token,this.telemetryMeta);const r=e.mappedSessionStore??(e.acpStorage?new d5(e.acpStorage,this.url):new h5);this.acpClient=new n5({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?kx({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.hasAuthTokenRejected=!1,this.acpClient.setToken(e),this.cancelRetryTimer(),this.retryDelay=ru,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=Yp(e,{electron:mr()});return mr()?new URL(r.viewURL,this.url).toString():r.renderer==="proxy-iframe"?new URL(r.viewURL,this.url).toString():r.viewURL}getContentURL(e){const r=Yp(e,{electron:mr()}).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 Za("channels-changed"));break;case"channel-updated":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new Za("channels-changed"));break;case"channel-removed":this.channels.delete(e.channelID),this.dispatchEvent(new Za("channels-changed"));break;case"artifact-created":{const r=this.channels.get(e.channelID);r&&!_C(r).includes(e.artifact.id)&&(r.layout=[...r.layout,{artifactIds:[e.artifact.id],geometry:{...sw},size:{...ow}}]);break}case"artifact-removed":{const r=this.channels.get(e.channelID);r&&(r.layout=zp(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 v5(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 Lt("change"));const r=this.createSocket(y5(this.url,this._token,this.telemetryMeta));return this.socket=r,await new Promise((s,a)=>{let l=!1;const c=()=>{var g;l||this.connectAttempt!==e||(l=!0,this.retryDelay=ru,this.hasEverConnected=!0,this.setStatus("connected"),(g=this.telemetryActivityAgent)==null||g.start(),s())},u=g=>{l||this.connectAttempt!==e||(l=!0,a(g))},p=async()=>{const g=this.hasEverConnected;try{const[{channels:v},y]=await Promise.all([this.client.channels.list(),this.client.display.get()]);this.channels=new Map(v.map(E=>[E.id,structuredClone(E)])),this.acpClient.setEnabled(y.acpEnabled),this.dispatchEvent(new Lt("change")),g&&this.dispatchEvent(new Za("channels-changed")),this.dispatchEvent(new _u("server-event",{serverURL:this.url,event:{type:"channel-changed",channelID:y.focusedChannelId}})),this.dispatchEvent(new _u("server-event",{serverURL:this.url,event:{type:"pinned-channels-changed",pinnedChannelIds:[...y.pinnedChannelIds]}})),c(),g&&this.connectAttempt===e&&this.dispatchEvent(new vw("server-reconnected",{serverURL:this.url}))}catch(v){if(E5(v)){u(new Iu);return}u(v instanceof Error?v:new Error(String(v)))}};r.addEventListener("open",()=>{this.decideBoot===null&&(this.bootState="booted",this.navigationPending()||p())}),r.addEventListener("message",g=>{const v=A5(g);if(!v)return;if(v.type==="server-status"){const E=v;this.serverVersion=E.version,this.updateState=E.update??null;let A=!1;this.decideBoot!==null&&this.bootState==="pending"&&this.connectAttempt===e&&(this.decideBoot(E)==="boot"?(this.bootState="booted",A=!0):(this.bootState="halted",this.attempting=!1)),this.dispatchEvent(new yw("server-status",{serverURL:this.url,message:E})),A?this.navigationPending()||p():this.bootState==="halted"&&!this.navigationPending()&&this.dispatchEvent(new Lt("change"));return}if(!_5(v.type))return;const y=v;this.applyServerEvent(y),this.dispatchEvent(new _u("server-event",{serverURL:this.url,event:y}))}),r.addEventListener("close",g=>{if(this.connectAttempt!==e)return;this.socket=null;const v=w5(g);if(!l){u(v===i1?new Iu:new Error("Connection closed before initialization"));return}if(v===i1){this.handleAuthRejected();return}this.handleTransportFailure(new Error("Connection closed"))}),r.addEventListener("error",()=>{if(this.connectAttempt===e){if(l){this.handleTransportFailure(new Error("WebSocket error"));return}u(new Error("WebSocket connection failed"))}})}).then(()=>{this.attempting=!1},s=>{throw this.attempting=!1,this.handleAttemptFailure(s),s})}handleAuthRejected(){this.hasAuthRejected=!0,this.hasAuthTokenRejected=this._token!==null,this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized")}handleAttemptFailure(e){if(e instanceof Iu){this.handleAuthRejected();return}this.autoReconnect&&this.scheduleRetry()}handleTransportFailure(e){this.autoReconnect&&(this.setStatus("disconnected"),this.scheduleRetry())}scheduleRetry(){this.cancelRetryTimer(),this.connectAttempt+=1;const e=this.retryDelay;this.retryDelay=Math.min(this.retryDelay*2,m5),this.nextRetryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},e),this.dispatchEvent(new Lt("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new Lt("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=ru,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:SC,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 Lt("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function v5(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function y5(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 Ex(e))r.searchParams.set(i,s);return r.hash="",r.toString()}function w5(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}const b5={"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},S5=new Set(Object.keys(b5));function _5(n){return S5.has(n)}function A5(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 E5(n){return n instanceof ga&&n.status===f5}const k5="Local";var kt,qt,On,of,af,r2,Pl,Ll,Dl,Ol,Ml;class C5 extends mi{constructor(e){super();m(this,On);C(this,"connection");C(this,"clientGUID");C(this,"acpStorage");C(this,"connectError",null);m(this,kt);m(this,qt,!1);m(this,Pl,()=>{o(this,qt)||(h(this,On,r2).call(this),this.dispatchEvent(new Lt("change")))});m(this,Ll,e=>{o(this,qt)||this.dispatchEvent(new _u("server-event",{serverURL:e.serverURL,event:e.event}))});m(this,Dl,()=>{o(this,qt)||this.dispatchEvent(new Za("channels-changed"))});m(this,Ol,e=>{o(this,qt)||this.dispatchEvent(new vw("server-reconnected",{serverURL:e.serverURL}))});m(this,Ml,e=>{o(this,qt)||this.dispatchEvent(new yw("server-status",{serverURL:e.serverURL,message:e.message}))});d(this,kt,e.localStore),this.acpStorage=e.acpStorage===void 0?n2():e.acpStorage,this.clientGUID=e.clientGUID??(this.acpStorage?p5(this.acpStorage):Wm().toLowerCase());const r=ci(e.serverURL);e.launchToken!==void 0&&e.launchToken!==null&&o(this,kt).set(kv(o(this,kt).get(),r,e.launchToken));const i=e.launchToken??Ev(o(this,kt).get(),r),s=e.createSocket??(l=>new WebSocket(l)),a=e.createConnection??(l=>new g5(l));this.connection=a({url:r,name:e.connectionName??k5,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,Pl)),this.connection.addEventListener("server-event",o(this,Ll)),this.connection.addEventListener("channels-changed",o(this,Dl)),this.connection.addEventListener("server-reconnected",o(this,Ol)),this.connection.addEventListener("server-status",o(this,Ml))}get storedAuthToken(){return Ev(o(this,kt).get(),this.connection.url)}async connect(){await h(this,On,of).call(this,this.connection.token)}async authenticate(e){o(this,kt).set(kv(o(this,kt).get(),this.connection.url,e)),await h(this,On,of).call(this,e)}dispose(){o(this,qt)||(d(this,qt,!0),this.connection.removeEventListener("change",o(this,Pl)),this.connection.removeEventListener("server-event",o(this,Ll)),this.connection.removeEventListener("channels-changed",o(this,Dl)),this.connection.removeEventListener("server-reconnected",o(this,Ol)),this.connection.removeEventListener("server-status",o(this,Ml)),this.connection.dispose())}}kt=new WeakMap,qt=new WeakMap,On=new WeakSet,of=async function(e){if(!o(this,qt)){h(this,On,af).call(this,null);try{await this.connection.connect(e)}catch(r){h(this,On,af).call(this,r instanceof Iu?null:r instanceof Error?r.message:String(r))}}},af=function(e){this.connectError!==e&&(this.connectError=e,this.dispatchEvent(new Lt("change")))},r2=function(){if(this.connection.status!=="unauthorized"||!this.connection.hasAuthRejected)return;const e=o(this,kt).get(),r=g$(e,this.connection.url);r!==e&&o(this,kt).set(r),this.connection.token!==null&&this.connection.clearToken()},Pl=new WeakMap,Ll=new WeakMap,Dl=new WeakMap,Ol=new WeakMap,Ml=new WeakMap;const lf="tv-nav:",oa="tv-reload",s1=100,$5=1e3,T5=60,R5=60,I5=24,x5=30,P5=x5*I5*R5*T5*$5;function gr(n){try{const t=new URL(n,window.location.href),e=t.searchParams.has(oa);return t.searchParams.delete(oa),t.origin===window.location.origin?`${t.pathname}${t.search}${t.hash}`:e?t.toString():n}catch{return n}}var Nl,_o,pe,de,zi,$e,i2,Ar,s2,cf,uf;class L5 extends mi{constructor(e,r){super();m(this,$e);m(this,Nl);m(this,_o);m(this,pe,[]);m(this,de,-1);m(this,zi,0);d(this,Nl,e),d(this,_o,gr(r)),h(this,$e,i2).call(this)}get currentURL(){var e;return o(this,de)===-1?null:((e=o(this,pe)[o(this,de)])==null?void 0:e.url)??null}get canGoBack(){return o(this,de)>-1}get canGoForward(){return o(this,de)<o(this,pe).length-1}get entries(){return o(this,pe).map(e=>({...e}))}get cursor(){return o(this,de)}navigate(e){const r=gr(e);if(r===o(this,_o)){if(o(this,de)===-1)return;d(this,de,-1),h(this,$e,Ar).call(this);return}o(this,de)<o(this,pe).length-1&&d(this,pe,o(this,pe).slice(0,o(this,de)+1)),o(this,pe).push({url:r}),d(this,de,o(this,pe).length-1),h(this,$e,cf).call(this),h(this,$e,Ar).call(this)}replace(e){var i;if(o(this,de)===-1){this.navigate(e);return}const r=gr(e);if(r===o(this,_o)){d(this,pe,o(this,pe).filter((s,a)=>a!==o(this,de))),d(this,de,-1),h(this,$e,Ar).call(this);return}((i=o(this,pe)[o(this,de)])==null?void 0:i.url)!==r&&(d(this,pe,o(this,pe).map((s,a)=>a===o(this,de)?{url:r}:s)),h(this,$e,Ar).call(this))}back(){o(this,de)!==-1&&(d(this,de,o(this,de)-1),h(this,$e,Ar).call(this))}forward(){this.canGoForward&&(d(this,de,o(this,de)+1),h(this,$e,Ar).call(this))}reset(){o(this,de)===-1&&o(this,pe).length===0||(d(this,pe,[]),d(this,de,-1),h(this,$e,Ar).call(this))}}Nl=new WeakMap,_o=new WeakMap,pe=new WeakMap,de=new WeakMap,zi=new WeakMap,$e=new WeakSet,i2=function(){const e=localStorage.getItem(o(this,$e,uf));if(e!==null)try{const r=JSON.parse(e);if(!o2(r))return;d(this,pe,r.entries.map(i=>({url:i.url}))),d(this,de,r.cursor),d(this,zi,r.lastWritten),h(this,$e,cf).call(this)}catch{d(this,pe,[]),d(this,de,-1),d(this,zi,0)}},Ar=function(){d(this,zi,Date.now());try{localStorage.setItem(o(this,$e,uf),JSON.stringify(h(this,$e,s2).call(this)))}catch(e){if(!M5(e))throw e}this.dispatchEvent(new Lt("change"))},s2=function(){return{v:1,entries:o(this,pe).map(e=>({...e})),cursor:o(this,de),lastWritten:o(this,zi)}},cf=function(){if(o(this,pe).length<=s1)return;const e=o(this,pe).length-s1;d(this,pe,o(this,pe).slice(e)),d(this,de,Math.max(-1,o(this,de)-e))},uf=function(){return D5(o(this,Nl))};function D5(n){return`${lf}${n}`}function O5(n){const t=Date.now()-P5,e=[];for(let r=0;r<localStorage.length;r+=1){const i=localStorage.key(r);if(!(i!=null&&i.startsWith(lf)))continue;const s=i.slice(lf.length),a=localStorage.getItem(i);if(a===null)continue;let l;try{l=JSON.parse(a)}catch{e.push(i);continue}if(!o2(l)){e.push(i);continue}!n.has(s)&&l.lastWritten<t&&e.push(i)}for(const r of e)localStorage.removeItem(r)}function M5(n){return n instanceof DOMException&&n.name==="QuotaExceededError"}function o2(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 mp="tv-channel-sidebar-width",hf=160,df=350,gp=260,N5=/^-?\d+$/;var Ui;class z5{constructor(t){m(this,Ui);d(this,Ui,t)}read(){const t=o(this,Ui).getItem(mp);if(t===null||!N5.test(t))return null;const e=BigInt(t);return e<BigInt(hf)?hf:e>BigInt(df)?df:Number(e)}commit(t){const e=a2(Math.round(t));try{o(this,Ui).setItem(mp,String(e))}catch{}return e}clear(){try{o(this,Ui).removeItem(mp)}catch{}}}Ui=new WeakMap;function a2(n){return Math.min(Math.max(n,hf),df)}const U5="1.3.5";function tg(n=U5){return n!==void 0&&n.length>0?n:"0.0.0"}function ng(){let n=!1;return{get pending(){return n},begin(t){n||(n=!0,t())}}}const pf="tv-reload-attempted";function F5(n){return n.originMatch?n.marker!==null&&n.bundleVersion===n.serverVersion?{action:"signal-autoreloaded",fromVersion:n.marker.fromVersion,toVersion:n.bundleVersion}:HC(n.bundleVersion,n.serverVersion)?n.marker!==null&&n.marker.serverVersion===n.serverVersion?{action:"none"}:{action:"reload",marker:{serverVersion:n.serverVersion,fromVersion:n.bundleVersion}}:{action:"none"}:{action:"none"}}function Z5(n){const t=n.getItem(pf);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 H5(n){const t=n.storage!==void 0?n.storage:typeof sessionStorage<"u"?sessionStorage:null,e=n.reload??(()=>location.reload()),r=n.navigationLatch??ng(),i=n.bundleVersion??tg();if(t===null)return{dispose(){}};let s=null;const a=()=>{if(s===null)return;const u=n.owner.connection;if(u.url!==n.primaryServerURL||u.status!=="connected")return;const p=s;s=null,u.sendTelemetrySignal("client_autoreloaded",{from_version:p.fromVersion,to_version:p.toVersion})},l=u=>{if(r.pending)return;const p=F5({bundleVersion:i,serverVersion:u.message.version,originMatch:u.serverURL===n.primaryServerURL,marker:Z5(t)});switch(p.action){case"reload":t.setItem(pf,JSON.stringify(p.marker)),r.begin(e);return;case"signal-autoreloaded":t.removeItem(pf),s={fromVersion:p.fromVersion,toVersion:p.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 V5(n){const t=mr(n.search),e=ib(n.search),r=e!==null&&od(e)?e:null;return{electron:t,shellVersion:r}}function B5(n){return!n.electron||n.requiredDesktopVersion===null||!od(n.requiredDesktopVersion)?!1:n.shellVersion===null?!0:n.shellVersion===rh?!1:Bm(n.requiredDesktopVersion,n.shellVersion)}const W5=`# Desktop app upgrade required
43
+ `)},js=function(e){const r=`${e}-${o(this,yo)}`;return d(this,yo,o(this,yo)+1),r},Qp=function(e){for(const r of o(this,ft).values())if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===e)return r;return null},ef=function(){if(!o(this,dn))throw new Error("ACP session is not ready");return o(this,dn)},ku=function(){if(!o(this,hn))throw new Error("ACP connection is not ready");return o(this,hn)},Qb=function(){var r;const e=(r=o(this,pn))==null?void 0:r.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},Cu=function(){var r;if(o(this,mn)==="single_session")return h(this,R,nf).call(this,`${Zb}-${(o(this,Wt).clientGUID??"default-client").toLowerCase()}`);const e=(r=o(this,je))==null?void 0:r.channelID;if(!e)throw new Error("Channel context is required for per-channel session mode");return h(this,R,tf).call(this,e)},tf=function(e){return h(this,R,nf).call(this,s5(o(this,mn),e,o(this,Wt).clientGUID??"default-client"))},nf=function(e){var r;return((r=o(this,pn))==null?void 0:r.sessionIdStrategy)==="deterministic"&&o(this,vo)>0?`${e}:epoch-${o(this,vo)}`:e},Rl=new WeakMap,Il=new WeakMap,$u=function(){d(this,hn,null),d(this,Pr,null),d(this,Vt,null),d(this,Kn,null),d(this,dn,null),d(this,Bt,null),d(this,pn,null),o(this,gn)&&(o(this,gn).removeEventListener("close",o(this,Rl)),o(this,gn).removeEventListener("error",o(this,Il)),o(this,gn).close(),d(this,gn,null))},Gs=function(e){const r=o(this,hn)!==null||o(this,Pr)!==null||o(this,Vt)!==null||o(this,Kn)!==null||o(this,dn)!==null||o(this,Bt)!==null||o(this,pn)!==null||o(this,gn)!==null;this.disposed||this.status==="disconnected"&&!r||(h(this,R,_i).call(this,"error"),h(this,R,$u).call(this),d(this,un,e??null),h(this,R,Vn).call(this,"disconnected"))},rf=function(){const e=o(this,ft).size>0;d(this,fn,null),d(this,Qn,null),d(this,yo,1),o(this,ft).clear(),e&&this.dispatchEvent(new up("messages-changed"))},e2=function(){return this.status==="disconnected"};function r5(){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 i5(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function s5(n,t,e){return n==="single_session"?`${Zb}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function t2(n){return n.replace(/^(?:\s*\n)+/,"")}function Qv(n){let t=n;return t=t.replace(GD,""),t=t.replace(YD,""),t=t.replace(JD,""),t=t2(t),t}function o5(n){let t=n;return t=t.replace(XD,""),t=t2(t),t}function e1(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function a5(n){const t=n.createSocket(u5(n.serverURL,n.token));let e=!1,r,i;const s=new Promise((u,p)=>{r=u,i=p}),a=new ReadableStream({start(u){let p=!1;const g=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},v=A=>{const x=c5(A);if(!x)return;let L;try{L=JSON.parse(x)}catch(D){const V=D instanceof Error?D:new Error(String(D));i(V),u.error(V);return}switch(L.type){case"acp-bridge-status":if(L.status==="ready"){let D;try{D=l5(L)}catch(V){const F=V instanceof Error?V:new Error(String(V));e||i(F),u.error(F);return}e||(e=!0,r(D));return}if(L.status==="error"||L.status==="exited"){const D=new Error(L.error??`ACP bridge ${L.status}`);e||i(D),u.error(D)}return;case"acp-bridge-message":u.enqueue(L.message);return}},y=()=>{var x;if(p)return;p=!0;const A=new Error("ACP bridge websocket closed");e||i(A),(x=n.onDisconnect)==null||x.call(n,A),u.close()},E=()=>{var x;if(p)return;p=!0;const A=new Error("ACP bridge websocket error");e||i(A),(x=n.onDisconnect)==null||x.call(n,A),u.error(A)};t.addEventListener("open",g),t.addEventListener("message",v),t.addEventListener("close",y),t.addEventListener("error",E)}}),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 l5(n){const{agent:t,sessionIdStrategy:e,sessionCwd:r}=n;if((t==="openclaw"||t==="hermes")&&(e==="deterministic"||e==="mapped")&&typeof r=="string"&&r.length>0)return{agent:t,sessionIdStrategy:e,sessionCwd:r};throw new Error("ACP bridge ready status missing bootstrap metadata")}function c5(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 u5(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 fp(n){return n instanceof Error?n.message:String(n)}const t1="television.acpClientGUID",n1="television.acpMappedSessions",r1=1;var bo;class h5{constructor(){m(this,bo,new Map)}getActualSessionId(t){return o(this,bo).get(t)??null}setActualSessionId(t,e){o(this,bo).set(t,e)}clearActualSessionId(t){o(this,bo).delete(t)}}bo=new WeakMap;var So,xl,yt,Tu,Ru,sf;class d5{constructor(t,e){m(this,yt);m(this,So);m(this,xl);d(this,So,t),d(this,xl,e)}getActualSessionId(t){const e=h(this,yt,Ru).call(this)[h(this,yt,Tu).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const r=h(this,yt,Ru).call(this);r[h(this,yt,Tu).call(this,t)]=e,h(this,yt,sf).call(this,r)}clearActualSessionId(t){const e=h(this,yt,Ru).call(this);delete e[h(this,yt,Tu).call(this,t)],h(this,yt,sf).call(this,e)}}So=new WeakMap,xl=new WeakMap,yt=new WeakSet,Tu=function(t){return JSON.stringify([o(this,xl),t])},Ru=function(){const t=o(this,So).getItem(n1);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!==r1?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},sf=function(t){const e={version:r1,entries:t};o(this,So).setItem(n1,JSON.stringify(e))};function n2(){return typeof window>"u"?null:window.localStorage}function p5(n){const t=n.getItem(t1);if(t)return t;const e=Wm().toLowerCase();return n.setItem(t1,e),e}const i1=4401,f5=401,ru=1e3,m5=3e4;class Iu extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class g5 extends mi{constructor(e){var a,l;super();C(this,"url");C(this,"name");C(this,"telemetryMeta");C(this,"status","unauthorized");C(this,"channels",new Map);C(this,"client");C(this,"acpClient");C(this,"_token");C(this,"attempting",!1);C(this,"nextRetryAt",null);C(this,"hasEverConnected",!1);C(this,"hasAuthRejected",!1);C(this,"hasAuthTokenRejected",!1);C(this,"bootState","pending");C(this,"serverVersion",null);C(this,"updateState",null);C(this,"decideBoot");C(this,"navigationPending");C(this,"createSocket");C(this,"createClient");C(this,"socket",null);C(this,"connectAttempt",0);C(this,"autoReconnect",!1);C(this,"retryTimer",null);C(this,"retryDelay",ru);C(this,"visibilityEventTarget");C(this,"networkEventTarget");C(this,"onVisibilityChange");C(this,"onNetworkOnline");C(this,"telemetryActivityAgent");this.url=ci(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,p)=>new UC(c,{token:u??void 0,onUnauthorized:()=>this.handleAuthRejected(),...p?{telemetryMeta:p}:{}})),this.client=this.createClient(this.url,this._token,this.telemetryMeta);const r=e.mappedSessionStore??(e.acpStorage?new d5(e.acpStorage,this.url):new h5);this.acpClient=new n5({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?kx({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.hasAuthTokenRejected=!1,this.acpClient.setToken(e),this.cancelRetryTimer(),this.retryDelay=ru,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=Yp(e,{electron:mr()});return mr()?new URL(r.viewURL,this.url).toString():r.renderer==="proxy-iframe"?new URL(r.viewURL,this.url).toString():r.viewURL}getContentURL(e){const r=Yp(e,{electron:mr()}).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 Za("channels-changed"));break;case"channel-updated":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new Za("channels-changed"));break;case"channel-removed":this.channels.delete(e.channelID),this.dispatchEvent(new Za("channels-changed"));break;case"artifact-created":{const r=this.channels.get(e.channelID);r&&!_C(r).includes(e.artifact.id)&&(r.layout=[...r.layout,{artifactIds:[e.artifact.id],geometry:{...sw},size:{...ow}}]);break}case"artifact-removed":{const r=this.channels.get(e.channelID);r&&(r.layout=zp(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 v5(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 Lt("change"));const r=this.createSocket(y5(this.url,this._token,this.telemetryMeta));return this.socket=r,await new Promise((s,a)=>{let l=!1;const c=()=>{var g;l||this.connectAttempt!==e||(l=!0,this.retryDelay=ru,this.hasEverConnected=!0,this.setStatus("connected"),(g=this.telemetryActivityAgent)==null||g.start(),s())},u=g=>{l||this.connectAttempt!==e||(l=!0,a(g))},p=async()=>{const g=this.hasEverConnected;try{const[{channels:v},y]=await Promise.all([this.client.channels.list(),this.client.display.get()]);this.channels=new Map(v.map(E=>[E.id,structuredClone(E)])),this.acpClient.setEnabled(y.acpEnabled),this.dispatchEvent(new Lt("change")),g&&this.dispatchEvent(new Za("channels-changed")),this.dispatchEvent(new _u("server-event",{serverURL:this.url,event:{type:"channel-changed",channelID:y.focusedChannelId}})),this.dispatchEvent(new _u("server-event",{serverURL:this.url,event:{type:"pinned-channels-changed",pinnedChannelIds:[...y.pinnedChannelIds]}})),c(),g&&this.connectAttempt===e&&this.dispatchEvent(new vw("server-reconnected",{serverURL:this.url}))}catch(v){if(E5(v)){u(new Iu);return}u(v instanceof Error?v:new Error(String(v)))}};r.addEventListener("open",()=>{this.decideBoot===null&&(this.bootState="booted",this.navigationPending()||p())}),r.addEventListener("message",g=>{const v=A5(g);if(!v)return;if(v.type==="server-status"){const E=v;this.serverVersion=E.version,this.updateState=E.update??null;let A=!1;this.decideBoot!==null&&this.bootState==="pending"&&this.connectAttempt===e&&(this.decideBoot(E)==="boot"?(this.bootState="booted",A=!0):(this.bootState="halted",this.attempting=!1)),this.dispatchEvent(new yw("server-status",{serverURL:this.url,message:E})),A?this.navigationPending()||p():this.bootState==="halted"&&!this.navigationPending()&&this.dispatchEvent(new Lt("change"));return}if(!_5(v.type))return;const y=v;this.applyServerEvent(y),this.dispatchEvent(new _u("server-event",{serverURL:this.url,event:y}))}),r.addEventListener("close",g=>{if(this.connectAttempt!==e)return;this.socket=null;const v=w5(g);if(!l){u(v===i1?new Iu:new Error("Connection closed before initialization"));return}if(v===i1){this.handleAuthRejected();return}this.handleTransportFailure(new Error("Connection closed"))}),r.addEventListener("error",()=>{if(this.connectAttempt===e){if(l){this.handleTransportFailure(new Error("WebSocket error"));return}u(new Error("WebSocket connection failed"))}})}).then(()=>{this.attempting=!1},s=>{throw this.attempting=!1,this.handleAttemptFailure(s),s})}handleAuthRejected(){this.hasAuthRejected=!0,this.hasAuthTokenRejected=this._token!==null,this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized")}handleAttemptFailure(e){if(e instanceof Iu){this.handleAuthRejected();return}this.autoReconnect&&this.scheduleRetry()}handleTransportFailure(e){this.autoReconnect&&(this.setStatus("disconnected"),this.scheduleRetry())}scheduleRetry(){this.cancelRetryTimer(),this.connectAttempt+=1;const e=this.retryDelay;this.retryDelay=Math.min(this.retryDelay*2,m5),this.nextRetryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},e),this.dispatchEvent(new Lt("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new Lt("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=ru,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:SC,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 Lt("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function v5(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function y5(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 Ex(e))r.searchParams.set(i,s);return r.hash="",r.toString()}function w5(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}const b5={"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},S5=new Set(Object.keys(b5));function _5(n){return S5.has(n)}function A5(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 E5(n){return n instanceof ga&&n.status===f5}const k5="Local";var kt,qt,On,of,af,r2,Pl,Ll,Dl,Ol,Ml;class C5 extends mi{constructor(e){super();m(this,On);C(this,"connection");C(this,"clientGUID");C(this,"acpStorage");C(this,"connectError",null);m(this,kt);m(this,qt,!1);m(this,Pl,()=>{o(this,qt)||(h(this,On,r2).call(this),this.dispatchEvent(new Lt("change")))});m(this,Ll,e=>{o(this,qt)||this.dispatchEvent(new _u("server-event",{serverURL:e.serverURL,event:e.event}))});m(this,Dl,()=>{o(this,qt)||this.dispatchEvent(new Za("channels-changed"))});m(this,Ol,e=>{o(this,qt)||this.dispatchEvent(new vw("server-reconnected",{serverURL:e.serverURL}))});m(this,Ml,e=>{o(this,qt)||this.dispatchEvent(new yw("server-status",{serverURL:e.serverURL,message:e.message}))});d(this,kt,e.localStore),this.acpStorage=e.acpStorage===void 0?n2():e.acpStorage,this.clientGUID=e.clientGUID??(this.acpStorage?p5(this.acpStorage):Wm().toLowerCase());const r=ci(e.serverURL);e.launchToken!==void 0&&e.launchToken!==null&&o(this,kt).set(kv(o(this,kt).get(),r,e.launchToken));const i=e.launchToken??Ev(o(this,kt).get(),r),s=e.createSocket??(l=>new WebSocket(l)),a=e.createConnection??(l=>new g5(l));this.connection=a({url:r,name:e.connectionName??k5,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,Pl)),this.connection.addEventListener("server-event",o(this,Ll)),this.connection.addEventListener("channels-changed",o(this,Dl)),this.connection.addEventListener("server-reconnected",o(this,Ol)),this.connection.addEventListener("server-status",o(this,Ml))}get storedAuthToken(){return Ev(o(this,kt).get(),this.connection.url)}async connect(){await h(this,On,of).call(this,this.connection.token)}async authenticate(e){o(this,kt).set(kv(o(this,kt).get(),this.connection.url,e)),await h(this,On,of).call(this,e)}dispose(){o(this,qt)||(d(this,qt,!0),this.connection.removeEventListener("change",o(this,Pl)),this.connection.removeEventListener("server-event",o(this,Ll)),this.connection.removeEventListener("channels-changed",o(this,Dl)),this.connection.removeEventListener("server-reconnected",o(this,Ol)),this.connection.removeEventListener("server-status",o(this,Ml)),this.connection.dispose())}}kt=new WeakMap,qt=new WeakMap,On=new WeakSet,of=async function(e){if(!o(this,qt)){h(this,On,af).call(this,null);try{await this.connection.connect(e)}catch(r){h(this,On,af).call(this,r instanceof Iu?null:r instanceof Error?r.message:String(r))}}},af=function(e){this.connectError!==e&&(this.connectError=e,this.dispatchEvent(new Lt("change")))},r2=function(){if(this.connection.status!=="unauthorized"||!this.connection.hasAuthRejected)return;const e=o(this,kt).get(),r=g$(e,this.connection.url);r!==e&&o(this,kt).set(r),this.connection.token!==null&&this.connection.clearToken()},Pl=new WeakMap,Ll=new WeakMap,Dl=new WeakMap,Ol=new WeakMap,Ml=new WeakMap;const lf="tv-nav:",oa="tv-reload",s1=100,$5=1e3,T5=60,R5=60,I5=24,x5=30,P5=x5*I5*R5*T5*$5;function gr(n){try{const t=new URL(n,window.location.href),e=t.searchParams.has(oa);return t.searchParams.delete(oa),t.origin===window.location.origin?`${t.pathname}${t.search}${t.hash}`:e?t.toString():n}catch{return n}}var Nl,_o,pe,de,zi,$e,i2,Ar,s2,cf,uf;class L5 extends mi{constructor(e,r){super();m(this,$e);m(this,Nl);m(this,_o);m(this,pe,[]);m(this,de,-1);m(this,zi,0);d(this,Nl,e),d(this,_o,gr(r)),h(this,$e,i2).call(this)}get currentURL(){var e;return o(this,de)===-1?null:((e=o(this,pe)[o(this,de)])==null?void 0:e.url)??null}get canGoBack(){return o(this,de)>-1}get canGoForward(){return o(this,de)<o(this,pe).length-1}get entries(){return o(this,pe).map(e=>({...e}))}get cursor(){return o(this,de)}navigate(e){const r=gr(e);if(r===o(this,_o)){if(o(this,de)===-1)return;d(this,de,-1),h(this,$e,Ar).call(this);return}o(this,de)<o(this,pe).length-1&&d(this,pe,o(this,pe).slice(0,o(this,de)+1)),o(this,pe).push({url:r}),d(this,de,o(this,pe).length-1),h(this,$e,cf).call(this),h(this,$e,Ar).call(this)}replace(e){var i;if(o(this,de)===-1){this.navigate(e);return}const r=gr(e);if(r===o(this,_o)){d(this,pe,o(this,pe).filter((s,a)=>a!==o(this,de))),d(this,de,-1),h(this,$e,Ar).call(this);return}((i=o(this,pe)[o(this,de)])==null?void 0:i.url)!==r&&(d(this,pe,o(this,pe).map((s,a)=>a===o(this,de)?{url:r}:s)),h(this,$e,Ar).call(this))}back(){o(this,de)!==-1&&(d(this,de,o(this,de)-1),h(this,$e,Ar).call(this))}forward(){this.canGoForward&&(d(this,de,o(this,de)+1),h(this,$e,Ar).call(this))}reset(){o(this,de)===-1&&o(this,pe).length===0||(d(this,pe,[]),d(this,de,-1),h(this,$e,Ar).call(this))}}Nl=new WeakMap,_o=new WeakMap,pe=new WeakMap,de=new WeakMap,zi=new WeakMap,$e=new WeakSet,i2=function(){const e=localStorage.getItem(o(this,$e,uf));if(e!==null)try{const r=JSON.parse(e);if(!o2(r))return;d(this,pe,r.entries.map(i=>({url:i.url}))),d(this,de,r.cursor),d(this,zi,r.lastWritten),h(this,$e,cf).call(this)}catch{d(this,pe,[]),d(this,de,-1),d(this,zi,0)}},Ar=function(){d(this,zi,Date.now());try{localStorage.setItem(o(this,$e,uf),JSON.stringify(h(this,$e,s2).call(this)))}catch(e){if(!M5(e))throw e}this.dispatchEvent(new Lt("change"))},s2=function(){return{v:1,entries:o(this,pe).map(e=>({...e})),cursor:o(this,de),lastWritten:o(this,zi)}},cf=function(){if(o(this,pe).length<=s1)return;const e=o(this,pe).length-s1;d(this,pe,o(this,pe).slice(e)),d(this,de,Math.max(-1,o(this,de)-e))},uf=function(){return D5(o(this,Nl))};function D5(n){return`${lf}${n}`}function O5(n){const t=Date.now()-P5,e=[];for(let r=0;r<localStorage.length;r+=1){const i=localStorage.key(r);if(!(i!=null&&i.startsWith(lf)))continue;const s=i.slice(lf.length),a=localStorage.getItem(i);if(a===null)continue;let l;try{l=JSON.parse(a)}catch{e.push(i);continue}if(!o2(l)){e.push(i);continue}!n.has(s)&&l.lastWritten<t&&e.push(i)}for(const r of e)localStorage.removeItem(r)}function M5(n){return n instanceof DOMException&&n.name==="QuotaExceededError"}function o2(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 mp="tv-channel-sidebar-width",hf=160,df=350,gp=260,N5=/^-?\d+$/;var Ui;class z5{constructor(t){m(this,Ui);d(this,Ui,t)}read(){const t=o(this,Ui).getItem(mp);if(t===null||!N5.test(t))return null;const e=BigInt(t);return e<BigInt(hf)?hf:e>BigInt(df)?df:Number(e)}commit(t){const e=a2(Math.round(t));try{o(this,Ui).setItem(mp,String(e))}catch{}return e}clear(){try{o(this,Ui).removeItem(mp)}catch{}}}Ui=new WeakMap;function a2(n){return Math.min(Math.max(n,hf),df)}const U5="1.3.7";function tg(n=U5){return n!==void 0&&n.length>0?n:"0.0.0"}function ng(){let n=!1;return{get pending(){return n},begin(t){n||(n=!0,t())}}}const pf="tv-reload-attempted";function F5(n){return n.originMatch?n.marker!==null&&n.bundleVersion===n.serverVersion?{action:"signal-autoreloaded",fromVersion:n.marker.fromVersion,toVersion:n.bundleVersion}:HC(n.bundleVersion,n.serverVersion)?n.marker!==null&&n.marker.serverVersion===n.serverVersion?{action:"none"}:{action:"reload",marker:{serverVersion:n.serverVersion,fromVersion:n.bundleVersion}}:{action:"none"}:{action:"none"}}function Z5(n){const t=n.getItem(pf);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 H5(n){const t=n.storage!==void 0?n.storage:typeof sessionStorage<"u"?sessionStorage:null,e=n.reload??(()=>location.reload()),r=n.navigationLatch??ng(),i=n.bundleVersion??tg();if(t===null)return{dispose(){}};let s=null;const a=()=>{if(s===null)return;const u=n.owner.connection;if(u.url!==n.primaryServerURL||u.status!=="connected")return;const p=s;s=null,u.sendTelemetrySignal("client_autoreloaded",{from_version:p.fromVersion,to_version:p.toVersion})},l=u=>{if(r.pending)return;const p=F5({bundleVersion:i,serverVersion:u.message.version,originMatch:u.serverURL===n.primaryServerURL,marker:Z5(t)});switch(p.action){case"reload":t.setItem(pf,JSON.stringify(p.marker)),r.begin(e);return;case"signal-autoreloaded":t.removeItem(pf),s={fromVersion:p.fromVersion,toVersion:p.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 V5(n){const t=mr(n.search),e=ib(n.search),r=e!==null&&od(e)?e:null;return{electron:t,shellVersion:r}}function B5(n){return!n.electron||n.requiredDesktopVersion===null||!od(n.requiredDesktopVersion)?!1:n.shellVersion===null?!0:n.shellVersion===rh?!1:Bm(n.requiredDesktopVersion,n.shellVersion)}const W5=`# Desktop app upgrade required
44
44
 
45
45
  Your Television server requires a newer version of this desktop app.
46
46
  In a terminal, please upgrade:
@@ -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-q6WrAU7d.js"></script>
43
+ <script type="module" crossorigin src="./assets/main-XOCJlYqJ.js"></script>
44
44
  <link rel="modulepreload" crossorigin href="./assets/artifact-bridge-BEUWXKq7.js">
45
45
  <link rel="modulepreload" crossorigin href="./assets/missing-artifact-page-DVzJ41AE.js">
46
46
  <link rel="stylesheet" crossorigin href="./assets/main-ClOW3LGh.css">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telepath-computer/television",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": ">=22.12.0"