@telepath-computer/television 0.1.192 → 0.1.193

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