@telepath-computer/television 1.4.20 → 1.4.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs
CHANGED
|
@@ -53345,7 +53345,7 @@ function disabledTelemetryRuntime() {
|
|
|
53345
53345
|
|
|
53346
53346
|
// ../server/src/updates/version.ts
|
|
53347
53347
|
function readVersionStamp() {
|
|
53348
|
-
if ("1.4.
|
|
53348
|
+
if ("1.4.21".length > 0) return "1.4.21";
|
|
53349
53349
|
return void 0;
|
|
53350
53350
|
}
|
|
53351
53351
|
function resolveUpdateReleaseVersion(env = process.env, stamp = readVersionStamp()) {
|
|
@@ -53887,8 +53887,8 @@ var Server = class {
|
|
|
53887
53887
|
};
|
|
53888
53888
|
};
|
|
53889
53889
|
function readServerPackageVersion() {
|
|
53890
|
-
if ("1.4.
|
|
53891
|
-
return telemetryVersion("1.4.
|
|
53890
|
+
if ("1.4.21".length > 0) {
|
|
53891
|
+
return telemetryVersion("1.4.21");
|
|
53892
53892
|
}
|
|
53893
53893
|
const packageJsonPath = import_node_path13.default.resolve(import_node_path13.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url)), "..", "package.json");
|
|
53894
53894
|
if (!(0, import_node_fs11.existsSync)(packageJsonPath)) return telemetryVersion("0.0.0");
|
|
@@ -56119,8 +56119,8 @@ function resolveVercelSkillsInstallerBin() {
|
|
|
56119
56119
|
return localRequire.resolve("skills/bin/cli.mjs");
|
|
56120
56120
|
}
|
|
56121
56121
|
function readCLIVersion() {
|
|
56122
|
-
if ("1.4.
|
|
56123
|
-
return "1.4.
|
|
56122
|
+
if ("1.4.21".length > 0) {
|
|
56123
|
+
return "1.4.21";
|
|
56124
56124
|
}
|
|
56125
56125
|
const devPackageJsonPath = import_node_path20.default.join(getDevPackageDir(), "package.json");
|
|
56126
56126
|
if (!(0, import_node_fs18.existsSync)(devPackageJsonPath)) {
|
|
@@ -40,7 +40,7 @@ var J4=Object.defineProperty;var kv=n=>{throw TypeError(n)};var X4=(n,t,e)=>t in
|
|
|
40
40
|
`)}v.write("payload.value = newResult;"),v.write("return payload;");const L=v.compile();return(P,B)=>L(y,P,B)};let s;const a=qc,l=!C8.jitless,u=l&&Zk.value,p=t.catchall;let f;n._zod.parse=(y,v)=>{f??(f=r.value);const S=y.value;return a(S)?l&&u&&(v==null?void 0:v.async)===!1&&v.jitless!==!0?(s||(s=i(t.shape)),y=s(y,v),p?V8([],S,y,v,f,n):y):e(y,v):(y.issues.push({expected:"object",code:"invalid_type",input:S,inst:n}),y)}});function s2(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=>!Ia(s));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:e,errors:n.map(s=>s.issues.map(a=>Ts(a,r,ks())))}),t)}const B8=R("$ZodUnion",(n,t)=>{Ue.init(n,t),Ae(n._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Ae(n._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Ae(n._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),Ae(n._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>H1(s.source)).join("|")})$`)}});const e=t.options.length===1,r=t.options[0]._zod.run;n._zod.parse=(i,s)=>{if(e)return r(i,s);let a=!1;const l=[];for(const c of t.options){const u=c._zod.run({value:i.value,issues:[]},s);if(u instanceof Promise)l.push(u),a=!0;else{if(u.issues.length===0)return u;l.push(u)}}return a?Promise.all(l).then(c=>s2(c,i,n,s)):s2(l,i,n,s)}}),TC=R("$ZodDiscriminatedUnion",(n,t)=>{t.inclusive=!1,B8.init(n,t);const e=n._zod.parse;Ae(n._zod,"propValues",()=>{const i={};for(const s of t.options){const a=s._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[l,c]of Object.entries(a)){i[l]||(i[l]=new Set);for(const u of c)i[l].add(u)}}return i});const r=xp(()=>{var a;const i=t.options,s=new Map;for(const l of i){const c=(a=l._zod.propValues)==null?void 0:a[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(l)}"`);for(const u of c){if(s.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);s.set(u,l)}}return s});n._zod.parse=(i,s)=>{const a=i.value;if(!qc(a))return i.issues.push({code:"invalid_type",expected:"object",input:a,inst:n}),i;const l=r.value.get(a==null?void 0:a[t.discriminator]);return l?l._zod.run(i,s):t.unionFallback?e(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:n}),i)}}),CC=R("$ZodIntersection",(n,t)=>{Ue.init(n,t),n._zod.parse=(e,r)=>{const i=e.value,s=t.left._zod.run({value:i,issues:[]},r),a=t.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||a instanceof Promise?Promise.all([s,a]).then(([c,u])=>o2(e,c,u)):o2(e,s,a)}});function Um(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(Ll(n)&&Ll(t)){const e=Object.keys(t),r=Object.keys(n).filter(s=>e.indexOf(s)!==-1),i={...n,...t};for(const s of r){const a=Um(n[s],t[s]);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};i[s]=a.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(t)){if(n.length!==t.length)return{valid:!1,mergeErrorPath:[]};const e=[];for(let r=0;r<n.length;r++){const i=n[r],s=t[r],a=Um(i,s);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};e.push(a.data)}return{valid:!0,data:e}}return{valid:!1,mergeErrorPath:[]}}function o2(n,t,e){const r=new Map;let i;for(const l of t.issues)if(l.code==="unrecognized_keys"){i??(i=l);for(const c of l.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else n.issues.push(l);for(const l of e.issues)if(l.code==="unrecognized_keys")for(const c of l.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else n.issues.push(l);const s=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(s.length&&i&&n.issues.push({...i,keys:s}),Ia(n))return n;const a=Um(t.value,e.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return n.value=a.data,n}const RC=R("$ZodRecord",(n,t)=>{Ue.init(n,t),n._zod.parse=(e,r)=>{const i=e.value;if(!Ll(i))return e.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),e;const s=[],a=t.keyType._zod.values;if(a){e.value={};const l=new Set;for(const u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){l.add(typeof u=="number"?u.toString():u);const p=t.valueType._zod.run({value:i[u],issues:[]},r);p instanceof Promise?s.push(p.then(f=>{f.issues.length&&e.issues.push(...$a(u,f.issues)),e.value[u]=f.value})):(p.issues.length&&e.issues.push(...$a(u,p.issues)),e.value[u]=p.value)}let c;for(const u in i)l.has(u)||(c=c??[],c.push(u));c&&c.length>0&&e.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:c})}else{e.value={};for(const l of Reflect.ownKeys(i)){if(l==="__proto__")continue;let c=t.keyType._zod.run({value:l,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof l=="string"&&N8.test(l)&&c.issues.length){const f=t.keyType._zod.run({value:Number(l),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[l]=i[l]:e.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(f=>Ts(f,r,ks())),input:l,path:[l],inst:n});continue}const p=t.valueType._zod.run({value:i[l],issues:[]},r);p instanceof Promise?s.push(p.then(f=>{f.issues.length&&e.issues.push(...$a(l,f.issues)),e.value[c.value]=f.value})):(p.issues.length&&e.issues.push(...$a(l,p.issues)),e.value[c.value]=p.value)}}return s.length?Promise.all(s).then(()=>e):e}}),IC=R("$ZodEnum",(n,t)=>{Ue.init(n,t);const e=R8(t.entries),r=new Set(e);n._zod.values=r,n._zod.pattern=new RegExp(`^(${e.filter(i=>Uk.has(typeof i)).map(i=>typeof i=="string"?Ml(i):i.toString()).join("|")})$`),n._zod.parse=(i,s)=>{const a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:e,input:a,inst:n}),i}}),$C=R("$ZodLiteral",(n,t)=>{if(Ue.init(n,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const e=new Set(t.values);n._zod.values=e,n._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Ml(r):r?Ml(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}}),xC=R("$ZodTransform",(n,t)=>{Ue.init(n,t),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new T8(n.constructor.name);const i=t.transform(e.value,e);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(a=>(e.value=a,e));if(i instanceof Promise)throw new Da;return e.value=i,e}});function a2(n,t){return n.issues.length&&t===void 0?{issues:[],value:void 0}:n}const W8=R("$ZodOptional",(n,t)=>{Ue.init(n,t),n._zod.optin="optional",n._zod.optout="optional",Ae(n._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ae(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${H1(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=>a2(s,e.value)):a2(i,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,r)}}),PC=R("$ZodExactOptional",(n,t)=>{W8.init(n,t),Ae(n._zod,"values",()=>t.innerType._zod.values),Ae(n._zod,"pattern",()=>t.innerType._zod.pattern),n._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),DC=R("$ZodNullable",(n,t)=>{Ue.init(n,t),Ae(n._zod,"optin",()=>t.innerType._zod.optin),Ae(n._zod,"optout",()=>t.innerType._zod.optout),Ae(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${H1(e.source)}|null)$`):void 0}),Ae(n._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),n._zod.parse=(e,r)=>e.value===null?e:t.innerType._zod.run(e,r)}),LC=R("$ZodDefault",(n,t)=>{Ue.init(n,t),n._zod.optin="optional",Ae(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);if(e.value===void 0)return e.value=t.defaultValue,e;const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>l2(s,t)):l2(i,t)}});function l2(n,t){return n.value===void 0&&(n.value=t.defaultValue),n}const MC=R("$ZodPrefault",(n,t)=>{Ue.init(n,t),n._zod.optin="optional",Ae(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>(r.direction==="backward"||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))}),OC=R("$ZodNonOptional",(n,t)=>{Ue.init(n,t),Ae(n._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(r=>r!==void 0)):void 0}),n._zod.parse=(e,r)=>{const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>c2(s,n)):c2(i,n)}});function c2(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 NC=R("$ZodCatch",(n,t)=>{Ue.init(n,t),Ae(n._zod,"optin",()=>t.innerType._zod.optin),Ae(n._zod,"optout",()=>t.innerType._zod.optout),Ae(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>(e.value=s.value,s.issues.length&&(e.value=t.catchValue({...e,error:{issues:s.issues.map(a=>Ts(a,r,ks()))},input:e.value}),e.issues=[]),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(s=>Ts(s,r,ks()))},input:e.value}),e.issues=[]),e)}}),zC=R("$ZodPipe",(n,t)=>{Ue.init(n,t),Ae(n._zod,"values",()=>t.in._zod.values),Ae(n._zod,"optin",()=>t.in._zod.optin),Ae(n._zod,"optout",()=>t.out._zod.optout),Ae(n._zod,"propValues",()=>t.in._zod.propValues),n._zod.parse=(e,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(e,r);return s instanceof Promise?s.then(a=>Rh(a,t.in,r)):Rh(s,t.in,r)}const i=t.in._zod.run(e,r);return i instanceof Promise?i.then(s=>Rh(s,t.out,r)):Rh(i,t.out,r)}});function Rh(n,t,e){return n.issues.length?(n.aborted=!0,n):t._zod.run({value:n.value,issues:n.issues},e)}const HC=R("$ZodReadonly",(n,t)=>{Ue.init(n,t),Ae(n._zod,"propValues",()=>t.innerType._zod.propValues),Ae(n._zod,"values",()=>t.innerType._zod.values),Ae(n._zod,"optin",()=>{var e,r;return(r=(e=t.innerType)==null?void 0:e._zod)==null?void 0:r.optin}),Ae(n._zod,"optout",()=>{var e,r;return(r=(e=t.innerType)==null?void 0:e._zod)==null?void 0:r.optout}),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(u2):u2(i)}});function u2(n){return n.value=Object.freeze(n.value),n}const ZC=R("$ZodCustom",(n,t)=>{jt.init(n,t),Ue.init(n,t),n._zod.parse=(e,r)=>e,n._zod.check=e=>{const r=e.value,i=t.fn(r);if(i instanceof Promise)return i.then(s=>h2(s,e,r,n));h2(i,e,r,n)}});function h2(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(Vc(i))}}var d2;class UC{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 FC(){return new UC}(d2=globalThis).__zod_globalRegistry??(d2.__zod_globalRegistry=FC());const bc=globalThis.__zod_globalRegistry;function qC(n,t){return new n({type:"string",...K(t)})}function VC(n,t){return new n({type:"string",format:"email",check:"string_format",abort:!1,...K(t)})}function p2(n,t){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...K(t)})}function BC(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...K(t)})}function WC(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...K(t)})}function jC(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...K(t)})}function GC(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...K(t)})}function YC(n,t){return new n({type:"string",format:"url",check:"string_format",abort:!1,...K(t)})}function KC(n,t){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...K(t)})}function JC(n,t){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...K(t)})}function XC(n,t){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...K(t)})}function QC(n,t){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...K(t)})}function eR(n,t){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...K(t)})}function tR(n,t){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...K(t)})}function nR(n,t){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...K(t)})}function rR(n,t){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...K(t)})}function iR(n,t){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...K(t)})}function sR(n,t){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...K(t)})}function oR(n,t){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...K(t)})}function aR(n,t){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...K(t)})}function lR(n,t){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...K(t)})}function cR(n,t){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...K(t)})}function uR(n,t){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...K(t)})}function hR(n,t){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...K(t)})}function dR(n,t){return new n({type:"string",format:"date",check:"string_format",...K(t)})}function pR(n,t){return new n({type:"string",format:"time",check:"string_format",precision:null,...K(t)})}function fR(n,t){return new n({type:"string",format:"duration",check:"string_format",...K(t)})}function mR(n,t){return new n({type:"number",checks:[],...K(t)})}function gR(n,t){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...K(t)})}function vR(n,t){return new n({type:"boolean",...K(t)})}function yR(n){return new n({type:"unknown"})}function wR(n,t){return new n({type:"never",...K(t)})}function f2(n,t){return new H8({check:"less_than",...K(t),value:n,inclusive:!1})}function gm(n,t){return new H8({check:"less_than",...K(t),value:n,inclusive:!0})}function m2(n,t){return new Z8({check:"greater_than",...K(t),value:n,inclusive:!1})}function vm(n,t){return new Z8({check:"greater_than",...K(t),value:n,inclusive:!0})}function g2(n,t){return new LT({check:"multiple_of",...K(t),value:n})}function j8(n,t){return new OT({check:"max_length",...K(t),maximum:n})}function Sd(n,t){return new NT({check:"min_length",...K(t),minimum:n})}function G8(n,t){return new zT({check:"length_equals",...K(t),length:n})}function bR(n,t){return new HT({check:"string_format",format:"regex",...K(t),pattern:n})}function SR(n){return new ZT({check:"string_format",format:"lowercase",...K(n)})}function _R(n){return new UT({check:"string_format",format:"uppercase",...K(n)})}function AR(n,t){return new FT({check:"string_format",format:"includes",...K(t),includes:n})}function ER(n,t){return new qT({check:"string_format",format:"starts_with",...K(t),prefix:n})}function kR(n,t){return new VT({check:"string_format",format:"ends_with",...K(t),suffix:n})}function Wl(n){return new BT({check:"overwrite",tx:n})}function TR(n){return Wl(t=>t.normalize(n))}function CR(){return Wl(n=>n.trim())}function RR(){return Wl(n=>n.toLowerCase())}function IR(){return Wl(n=>n.toUpperCase())}function $R(){return Wl(n=>Hk(n))}function xR(n,t,e){return new n({type:"array",element:t,...K(e)})}function PR(n,t,e){return new n({type:"custom",check:"custom",fn:t,...K(e)})}function DR(n){const t=LR(e=>(e.addIssue=r=>{if(typeof r=="string")e.issues.push(Vc(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(Vc(i))}},n(e.value,e)));return t}function LR(n,t){const e=new jt({check:"custom",...K(t)});return e._zod.check=n,e}function Y8(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)??bc,target:t,unrepresentable:(n==null?void 0:n.unrepresentable)??"throw",override:(n==null?void 0:n.override)??(()=>{}),io:(n==null?void 0:n.io)??"output",counter:0,seen:new Map,cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",external:(n==null?void 0:n.external)??void 0}}function Xe(n,t,e={path:[],schemaPath:[]}){var p,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 a={schema:{},count:1,cycle:void 0,path:e.path};t.seen.set(n,a);const l=(f=(p=n._zod).toJSONSchema)==null?void 0:f.call(p);if(l)a.schema=l;else{const y={...e,schemaPath:[...e.schemaPath,n],path:e.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(t,a.schema,y);else{const S=a.schema,_=t.processors[i.type];if(!_)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);_(n,t,S,y)}const v=n._zod.parent;v&&(a.ref||(a.ref=v),Xe(v,t,y),t.seen.get(v).isParent=!0)}const c=t.metadataRegistry.get(n);return c&&Object.assign(a.schema,c),t.io==="input"&&At(n)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(n).schema}function K8(n,t){var a,l,c,u;const e=n.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const p of n.seen.entries()){const f=(a=n.metadataRegistry.get(p[0]))==null?void 0:a.id;if(f){const y=r.get(f);if(y&&y!==p[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,p[0])}}const i=p=>{var _;const f=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const I=(_=n.external.registry.get(p[0]))==null?void 0:_.id,Z=n.external.uri??(z=>z);if(I)return{ref:Z(I)};const L=p[1].defId??p[1].schema.id??`schema${n.counter++}`;return p[1].defId=L,{defId:L,ref:`${Z("__shared")}#/${f}/${L}`}}if(p[1]===e)return{ref:"#"};const v=`#/${f}/`,S=p[1].schema.id??`__schema${n.counter++}`;return{defId:S,ref:v+S}},s=p=>{if(p[1].schema.$ref)return;const f=p[1],{ref:y,defId:v}=i(p);f.def={...f.schema},v&&(f.defId=v);const S=f.schema;for(const _ in S)delete S[_];S.$ref=y};if(n.cycles==="throw")for(const p of n.seen.entries()){const f=p[1];if(f.cycle)throw new Error(`Cycle detected: #/${(l=f.cycle)==null?void 0:l.join("/")}/<root>
|
|
41
41
|
|
|
42
42
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const p of n.seen.entries()){const f=p[1];if(t===p[0]){s(p);continue}if(n.external){const v=(c=n.external.registry.get(p[0]))==null?void 0:c.id;if(t!==p[0]&&v){s(p);continue}}if((u=n.metadataRegistry.get(p[0]))==null?void 0:u.id){s(p);continue}if(f.cycle){s(p);continue}if(f.count>1&&n.reused==="ref"){s(p);continue}}}function J8(n,t){var a,l,c;const e=n.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const p=n.seen.get(u);if(p.ref===null)return;const f=p.def??p.schema,y={...f},v=p.ref;if(p.ref=null,v){r(v);const _=n.seen.get(v),I=_.schema;if(I.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(I)):Object.assign(f,I),Object.assign(f,y),u._zod.parent===v)for(const L in f)L==="$ref"||L==="allOf"||L in y||delete f[L];if(I.$ref&&_.def)for(const L in f)L==="$ref"||L==="allOf"||L in _.def&&JSON.stringify(f[L])===JSON.stringify(_.def[L])&&delete f[L]}const S=u._zod.parent;if(S&&S!==v){r(S);const _=n.seen.get(S);if(_!=null&&_.schema.$ref&&(f.$ref=_.schema.$ref,_.def))for(const I in f)I==="$ref"||I==="allOf"||I in _.def&&JSON.stringify(f[I])===JSON.stringify(_.def[I])&&delete f[I]}n.override({zodSchema:u,jsonSchema:f,path:p.path??[]})};for(const u of[...n.seen.entries()].reverse())r(u[0]);const i={};if(n.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":n.target,(a=n.external)!=null&&a.uri){const u=(l=n.external.registry.get(t))==null?void 0:l.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=n.external.uri(u)}Object.assign(i,e.def??e.schema);const s=((c=n.external)==null?void 0:c.defs)??{};for(const u of n.seen.entries()){const p=u[1];p.def&&p.defId&&(s[p.defId]=p.def)}n.external||Object.keys(s).length>0&&(n.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...t["~standard"],jsonSchema:{input:_d(t,"input",n.processors),output:_d(t,"output",n.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function At(n,t){const e=t??{seen:new Set};if(e.seen.has(n))return!1;e.seen.add(n);const r=n._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return At(r.element,e);if(r.type==="set")return At(r.valueType,e);if(r.type==="lazy")return At(r.getter(),e);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return At(r.innerType,e);if(r.type==="intersection")return At(r.left,e)||At(r.right,e);if(r.type==="record"||r.type==="map")return At(r.keyType,e)||At(r.valueType,e);if(r.type==="pipe")return At(r.in,e)||At(r.out,e);if(r.type==="object"){for(const i in r.shape)if(At(r.shape[i],e))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(At(i,e))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(At(i,e))return!0;return!!(r.rest&&At(r.rest,e))}return!1}const MR=(n,t={})=>e=>{const r=Y8({...e,processors:t});return Xe(n,r),K8(r,n),J8(r,n)},_d=(n,t,e={})=>r=>{const{libraryOptions:i,target:s}=r??{},a=Y8({...i??{},target:s,io:t,processors:e});return Xe(n,a),K8(a,n),J8(a,n)},OR={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},NR=(n,t,e,r)=>{const i=e;i.type="string";const{minimum:s,maximum:a,format:l,patterns:c,contentEncoding:u}=n._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof a=="number"&&(i.maxLength=a),l&&(i.format=OR[l]??l,i.format===""&&delete i.format,l==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){const p=[...c];p.length===1?i.pattern=p[0].source:p.length>1&&(i.allOf=[...p.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},zR=(n,t,e,r)=>{const i=e,{minimum:s,maximum:a,format:l,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:p}=n._zod.bag;typeof l=="string"&&l.includes("int")?i.type="integer":i.type="number",typeof p=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=p,i.exclusiveMinimum=!0):i.exclusiveMinimum=p),typeof s=="number"&&(i.minimum=s,typeof p=="number"&&t.target!=="draft-04"&&(p>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof a=="number"&&(i.maximum=a,typeof u=="number"&&t.target!=="draft-04"&&(u<=a?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},HR=(n,t,e,r)=>{e.type="boolean"},ZR=(n,t,e,r)=>{e.not={}},UR=(n,t,e,r)=>{},FR=(n,t,e,r)=>{const i=n._zod.def,s=R8(i.entries);s.every(a=>typeof a=="number")&&(e.type="number"),s.every(a=>typeof a=="string")&&(e.type="string"),e.enum=s},qR=(n,t,e,r)=>{const i=n._zod.def,s=[];for(const a of i.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(a))}else s.push(a);if(s.length!==0)if(s.length===1){const a=s[0];e.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?e.enum=[a]:e.const=a}else s.every(a=>typeof a=="number")&&(e.type="number"),s.every(a=>typeof a=="string")&&(e.type="string"),s.every(a=>typeof a=="boolean")&&(e.type="boolean"),s.every(a=>a===null)&&(e.type="null"),e.enum=s},VR=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},BR=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},WR=(n,t,e,r)=>{const i=e,s=n._zod.def,{minimum:a,maximum:l}=n._zod.bag;typeof a=="number"&&(i.minItems=a),typeof l=="number"&&(i.maxItems=l),i.type="array",i.items=Xe(s.element,t,{...r,path:[...r.path,"items"]})},jR=(n,t,e,r)=>{var u;const i=e,s=n._zod.def;i.type="object",i.properties={};const a=s.shape;for(const p in a)i.properties[p]=Xe(a[p],t,{...r,path:[...r.path,"properties",p]});const l=new Set(Object.keys(a)),c=new Set([...l].filter(p=>{const f=s.shape[p]._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=Xe(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},GR=(n,t,e,r)=>{const i=n._zod.def,s=i.inclusive===!1,a=i.options.map((l,c)=>Xe(l,t,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?e.oneOf=a:e.anyOf=a},YR=(n,t,e,r)=>{const i=n._zod.def,s=Xe(i.left,t,{...r,path:[...r.path,"allOf",0]}),a=Xe(i.right,t,{...r,path:[...r.path,"allOf",1]}),l=u=>"allOf"in u&&Object.keys(u).length===1,c=[...l(s)?s.allOf:[s],...l(a)?a.allOf:[a]];e.allOf=c},KR=(n,t,e,r)=>{const i=e,s=n._zod.def;i.type="object";const a=s.keyType,l=a._zod.bag,c=l==null?void 0:l.patterns;if(s.mode==="loose"&&c&&c.size>0){const p=Xe(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const f of c)i.patternProperties[f.source]=p}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Xe(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Xe(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=a._zod.values;if(u){const p=[...u].filter(f=>typeof f=="string"||typeof f=="number");p.length>0&&(i.required=p)}},JR=(n,t,e,r)=>{const i=n._zod.def,s=Xe(i.innerType,t,r),a=t.seen.get(n);t.target==="openapi-3.0"?(a.ref=i.innerType,e.nullable=!0):e.anyOf=[s,{type:"null"}]},XR=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},QR=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,e.default=JSON.parse(JSON.stringify(i.defaultValue))},e3=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,t.io==="input"&&(e._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},t3=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType;let a;try{a=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}e.default=a},n3=(n,t,e,r)=>{const i=n._zod.def,s=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;Xe(s,t,r);const a=t.seen.get(n);a.ref=s},r3=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,e.readOnly=!0},X8=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},i3=R("ZodISODateTime",(n,t)=>{sC.init(n,t),qe.init(n,t)});function s3(n){return hR(i3,n)}const o3=R("ZodISODate",(n,t)=>{oC.init(n,t),qe.init(n,t)});function a3(n){return dR(o3,n)}const l3=R("ZodISOTime",(n,t)=>{aC.init(n,t),qe.init(n,t)});function c3(n){return pR(l3,n)}const u3=R("ZodISODuration",(n,t)=>{lC.init(n,t),qe.init(n,t)});function h3(n){return fR(u3,n)}const Q8=(n,t)=>{P8.init(n,t),n.name="ZodError",Object.defineProperties(n,{format:{value:e=>Xk(n,e)},flatten:{value:e=>Jk(n,e)},addIssue:{value:e=>{n.issues.push(e),n.message=JSON.stringify(n.issues,Zm,2)}},addIssues:{value:e=>{n.issues.push(...e),n.message=JSON.stringify(n.issues,Zm,2)}},isEmpty:{get(){return n.issues.length===0}}})},v2=R("ZodError",Q8),In=R("ZodError",Q8,{Parent:Error}),d3=U1(In),p3=F1(In),f3=Pp(In),m3=Dp(In),g3=tT(In),v3=nT(In),y3=rT(In),w3=iT(In),b3=sT(In),S3=oT(In),_3=aT(In),A3=lT(In),Fe=R("ZodType",(n,t)=>(Ue.init(n,t),Object.assign(n["~standard"],{jsonSchema:{input:_d(n,"input"),output:_d(n,"output")}}),n.toJSONSchema=MR(n,{}),n.def=t,n.type=t.type,Object.defineProperty(n,"_def",{value:t}),n.check=(...e)=>n.clone($s(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)=>xs(n,e,r),n.brand=()=>n,n.register=((e,r)=>(e.add(n,r),n)),n.parse=(e,r)=>d3(n,e,r,{callee:n.parse}),n.safeParse=(e,r)=>f3(n,e,r),n.parseAsync=async(e,r)=>p3(n,e,r,{callee:n.parseAsync}),n.safeParseAsync=async(e,r)=>m3(n,e,r),n.spa=n.safeParseAsync,n.encode=(e,r)=>g3(n,e,r),n.decode=(e,r)=>v3(n,e,r),n.encodeAsync=async(e,r)=>y3(n,e,r),n.decodeAsync=async(e,r)=>w3(n,e,r),n.safeEncode=(e,r)=>b3(n,e,r),n.safeDecode=(e,r)=>S3(n,e,r),n.safeEncodeAsync=async(e,r)=>_3(n,e,r),n.safeDecodeAsync=async(e,r)=>A3(n,e,r),n.refine=(e,r)=>n.check(mI(e,r)),n.superRefine=e=>n.check(gI(e)),n.overwrite=e=>n.check(Wl(e)),n.optional=()=>b2(n),n.exactOptional=()=>nI(n),n.nullable=()=>S2(n),n.nullish=()=>b2(S2(n)),n.nonoptional=e=>lI(n,e),n.array=()=>G(n),n.or=e=>ae([n,e]),n.and=e=>Mp(n,e),n.transform=e=>_2(n,eI(e)),n.default=e=>sI(n,e),n.prefault=e=>aI(n,e),n.catch=e=>uI(n,e),n.pipe=e=>_2(n,e),n.readonly=()=>pI(n),n.describe=e=>{const r=n.clone();return bc.add(r,{description:e}),r},Object.defineProperty(n,"description",{get(){var e;return(e=bc.get(n))==null?void 0:e.description},configurable:!0}),n.meta=(...e)=>{if(e.length===0)return bc.get(n);const r=n.clone();return bc.add(r,e[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=e=>e(n),n)),e6=R("_ZodString",(n,t)=>{q1.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(r,i,s)=>NR(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(bR(...r)),n.includes=(...r)=>n.check(AR(...r)),n.startsWith=(...r)=>n.check(ER(...r)),n.endsWith=(...r)=>n.check(kR(...r)),n.min=(...r)=>n.check(Sd(...r)),n.max=(...r)=>n.check(j8(...r)),n.length=(...r)=>n.check(G8(...r)),n.nonempty=(...r)=>n.check(Sd(1,...r)),n.lowercase=r=>n.check(SR(r)),n.uppercase=r=>n.check(_R(r)),n.trim=()=>n.check(CR()),n.normalize=(...r)=>n.check(TR(...r)),n.toLowerCase=()=>n.check(RR()),n.toUpperCase=()=>n.check(IR()),n.slugify=()=>n.check($R())}),E3=R("ZodString",(n,t)=>{q1.init(n,t),e6.init(n,t),n.email=e=>n.check(VC(k3,e)),n.url=e=>n.check(YC(T3,e)),n.jwt=e=>n.check(uR(U3,e)),n.emoji=e=>n.check(KC(C3,e)),n.guid=e=>n.check(p2(y2,e)),n.uuid=e=>n.check(BC(Ih,e)),n.uuidv4=e=>n.check(WC(Ih,e)),n.uuidv6=e=>n.check(jC(Ih,e)),n.uuidv7=e=>n.check(GC(Ih,e)),n.nanoid=e=>n.check(JC(R3,e)),n.guid=e=>n.check(p2(y2,e)),n.cuid=e=>n.check(XC(I3,e)),n.cuid2=e=>n.check(QC($3,e)),n.ulid=e=>n.check(eR(x3,e)),n.base64=e=>n.check(aR(z3,e)),n.base64url=e=>n.check(lR(H3,e)),n.xid=e=>n.check(tR(P3,e)),n.ksuid=e=>n.check(nR(D3,e)),n.ipv4=e=>n.check(rR(L3,e)),n.ipv6=e=>n.check(iR(M3,e)),n.cidrv4=e=>n.check(sR(O3,e)),n.cidrv6=e=>n.check(oR(N3,e)),n.e164=e=>n.check(cR(Z3,e)),n.datetime=e=>n.check(s3(e)),n.date=e=>n.check(a3(e)),n.time=e=>n.check(c3(e)),n.duration=e=>n.check(h3(e))});function g(n){return qC(E3,n)}const qe=R("ZodStringFormat",(n,t)=>{Oe.init(n,t),e6.init(n,t)}),k3=R("ZodEmail",(n,t)=>{KT.init(n,t),qe.init(n,t)}),y2=R("ZodGUID",(n,t)=>{GT.init(n,t),qe.init(n,t)}),Ih=R("ZodUUID",(n,t)=>{YT.init(n,t),qe.init(n,t)}),T3=R("ZodURL",(n,t)=>{JT.init(n,t),qe.init(n,t)}),C3=R("ZodEmoji",(n,t)=>{XT.init(n,t),qe.init(n,t)}),R3=R("ZodNanoID",(n,t)=>{QT.init(n,t),qe.init(n,t)}),I3=R("ZodCUID",(n,t)=>{eC.init(n,t),qe.init(n,t)}),$3=R("ZodCUID2",(n,t)=>{tC.init(n,t),qe.init(n,t)}),x3=R("ZodULID",(n,t)=>{nC.init(n,t),qe.init(n,t)}),P3=R("ZodXID",(n,t)=>{rC.init(n,t),qe.init(n,t)}),D3=R("ZodKSUID",(n,t)=>{iC.init(n,t),qe.init(n,t)}),L3=R("ZodIPv4",(n,t)=>{cC.init(n,t),qe.init(n,t)}),M3=R("ZodIPv6",(n,t)=>{uC.init(n,t),qe.init(n,t)}),O3=R("ZodCIDRv4",(n,t)=>{hC.init(n,t),qe.init(n,t)}),N3=R("ZodCIDRv6",(n,t)=>{dC.init(n,t),qe.init(n,t)}),z3=R("ZodBase64",(n,t)=>{pC.init(n,t),qe.init(n,t)}),H3=R("ZodBase64URL",(n,t)=>{mC.init(n,t),qe.init(n,t)}),Z3=R("ZodE164",(n,t)=>{gC.init(n,t),qe.init(n,t)}),U3=R("ZodJWT",(n,t)=>{yC.init(n,t),qe.init(n,t)}),t6=R("ZodNumber",(n,t)=>{F8.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(r,i,s)=>zR(n,r,i),n.gt=(r,i)=>n.check(m2(r,i)),n.gte=(r,i)=>n.check(vm(r,i)),n.min=(r,i)=>n.check(vm(r,i)),n.lt=(r,i)=>n.check(f2(r,i)),n.lte=(r,i)=>n.check(gm(r,i)),n.max=(r,i)=>n.check(gm(r,i)),n.int=r=>n.check(w2(r)),n.safe=r=>n.check(w2(r)),n.positive=r=>n.check(m2(0,r)),n.nonnegative=r=>n.check(vm(0,r)),n.negative=r=>n.check(f2(0,r)),n.nonpositive=r=>n.check(gm(0,r)),n.multipleOf=(r,i)=>n.check(g2(r,i)),n.step=(r,i)=>n.check(g2(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 ie(n){return mR(t6,n)}const F3=R("ZodNumberFormat",(n,t)=>{wC.init(n,t),t6.init(n,t)});function w2(n){return gR(F3,n)}const q3=R("ZodBoolean",(n,t)=>{bC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>HR(n,e,r)});function lt(n){return vR(q3,n)}const V3=R("ZodUnknown",(n,t)=>{SC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>UR()});function E(){return yR(V3)}const B3=R("ZodNever",(n,t)=>{_C.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>ZR(n,e,r)});function W3(n){return wR(B3,n)}const j3=R("ZodArray",(n,t)=>{AC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>WR(n,e,r,i),n.element=t.element,n.min=(e,r)=>n.check(Sd(e,r)),n.nonempty=e=>n.check(Sd(1,e)),n.max=(e,r)=>n.check(j8(e,r)),n.length=(e,r)=>n.check(G8(e,r)),n.unwrap=()=>n.element});function G(n,t){return xR(j3,n,t)}const n6=R("ZodObject",(n,t)=>{kC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>jR(n,e,r,i),Ae(n,"shape",()=>t.shape),n.keyof=()=>s6(Object.keys(n._zod.def.shape)),n.catchall=e=>n.clone({...n._zod.def,catchall:e}),n.passthrough=()=>n.clone({...n._zod.def,catchall:E()}),n.loose=()=>n.clone({...n._zod.def,catchall:E()}),n.strict=()=>n.clone({...n._zod.def,catchall:W3()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=e=>Wk(n,e),n.safeExtend=e=>jk(n,e),n.merge=e=>Gk(n,e),n.pick=e=>Vk(n,e),n.omit=e=>Bk(n,e),n.partial=(...e)=>Yk(o6,n,e[0]),n.required=(...e)=>Kk(a6,n,e[0])});function r6(n,t){const e={type:"object",shape:n??{},...K(t)};return new n6(e)}function b(n,t){return new n6({type:"object",shape:n,catchall:E(),...K(t)})}const i6=R("ZodUnion",(n,t)=>{B8.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>GR(n,e,r,i),n.options=t.options});function ae(n,t){return new i6({type:"union",options:n,...K(t)})}const G3=R("ZodDiscriminatedUnion",(n,t)=>{i6.init(n,t),TC.init(n,t)});function Y3(n,t,e){return new G3({type:"union",options:t,discriminator:n,...K(e)})}const K3=R("ZodIntersection",(n,t)=>{CC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>YR(n,e,r,i)});function Mp(n,t){return new K3({type:"intersection",left:n,right:t})}const J3=R("ZodRecord",(n,t)=>{RC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>KR(n,e,r,i),n.keyType=t.keyType,n.valueType=t.valueType});function T(n,t,e){return new J3({type:"record",keyType:n,valueType:t,...K(e)})}const Fm=R("ZodEnum",(n,t)=>{IC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(r,i,s)=>FR(n,r,i),n.enum=t.entries,n.options=Object.values(t.entries);const e=new Set(Object.keys(t.entries));n.extract=(r,i)=>{const s={};for(const a of r)if(e.has(a))s[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Fm({...t,checks:[],...K(i),entries:s})},n.exclude=(r,i)=>{const s={...t.entries};for(const a of r)if(e.has(a))delete s[a];else throw new Error(`Key ${a} not found in enum`);return new Fm({...t,checks:[],...K(i),entries:s})}});function s6(n,t){const e=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new Fm({type:"enum",entries:e,...K(t)})}const X3=R("ZodLiteral",(n,t)=>{$C.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>qR(n,e,r),n.values=new Set(t.values),Object.defineProperty(n,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function D(n,t){return new X3({type:"literal",values:Array.isArray(n)?n:[n],...K(t)})}const Q3=R("ZodTransform",(n,t)=>{xC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>BR(n,e),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new T8(n.constructor.name);e.addIssue=s=>{if(typeof s=="string")e.issues.push(Vc(s,e.value,t));else{const a=s;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=e.value),a.inst??(a.inst=n),e.issues.push(Vc(a))}};const i=t.transform(e.value,e);return i instanceof Promise?i.then(s=>(e.value=s,e)):(e.value=i,e)}});function eI(n){return new Q3({type:"transform",transform:n})}const o6=R("ZodOptional",(n,t)=>{W8.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>X8(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function b2(n){return new o6({type:"optional",innerType:n})}const tI=R("ZodExactOptional",(n,t)=>{PC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>X8(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function nI(n){return new tI({type:"optional",innerType:n})}const rI=R("ZodNullable",(n,t)=>{DC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>JR(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function S2(n){return new rI({type:"nullable",innerType:n})}const iI=R("ZodDefault",(n,t)=>{LC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>QR(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function sI(n,t){return new iI({type:"default",innerType:n,get defaultValue(){return typeof t=="function"?t():$8(t)}})}const oI=R("ZodPrefault",(n,t)=>{MC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>e3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function aI(n,t){return new oI({type:"prefault",innerType:n,get defaultValue(){return typeof t=="function"?t():$8(t)}})}const a6=R("ZodNonOptional",(n,t)=>{OC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>XR(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function lI(n,t){return new a6({type:"nonoptional",innerType:n,...K(t)})}const cI=R("ZodCatch",(n,t)=>{NC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>t3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function uI(n,t){return new cI({type:"catch",innerType:n,catchValue:typeof t=="function"?t:()=>t})}const hI=R("ZodPipe",(n,t)=>{zC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>n3(n,e,r,i),n.in=t.in,n.out=t.out});function _2(n,t){return new hI({type:"pipe",in:n,out:t})}const dI=R("ZodReadonly",(n,t)=>{HC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>r3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function pI(n){return new dI({type:"readonly",innerType:n})}const fI=R("ZodCustom",(n,t)=>{ZC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>VR(n,e)});function mI(n,t={}){return PR(fI,n,t)}function gI(n){return DR(n)}const vI=[".md",".markdown"];function l6(n){if(n.length===0)return!1;const t=n.at(-1);return t==="/"||t==="\\"}function c6(n){const t=n.lastIndexOf("/"),e=n.lastIndexOf("\\");return n.slice(Math.max(t,e)+1)}function yI(n){return c6(n).toLowerCase()}function wI(n,t){const e=yI(n);return t.some(r=>e.endsWith(r))}function qm(n){return!l6(n)&&wI(n,vI)}function bI(n){let t;try{t=new URL(n)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}function Zr(n){try{const{pathname:t}=new URL(n);return/^\/artifact\/[0-9A-Za-z]{26}(\/|$)/.test(t)}catch{return!1}}const SI=r6({id:g().min(1),kind:D("path"),title:g(),path:g()}).strict(),_I=r6({id:g().min(1),kind:D("url"),title:g(),url:g().refine(bI,{message:"url must be an http(s) URL"})}).strict();Y3("kind",[SI,_I]);const AI=new Set(["about:","blob:","chrome-extension:","chrome:","data:","devtools:","file:","filesystem:","javascript:","view-source:"]);function EI(n,t){try{const e=new URL(t),r=new URL(n,e);return r.protocol==="http:"||r.protocol==="https:"?{kind:"web",url:r.href}:AI.has(r.protocol)?{kind:"browser-local",url:r.href}:{kind:"application",url:r.href}}catch{return{kind:"invalid"}}}function A2(n,t){return EI(n,t).kind==="web"}const kI="/views/markdown/",TI="/views/url-unsupported/";function CI(n){try{const{protocol:t}=new URL(n);return t==="http:"||t==="https:"}catch{return!1}}function u6(n){return`/artifact/${encodeURIComponent(n)}`}function RI(n,t){return`${u6(n)}/${encodeURIComponent(t)}`}function II(n){return`/markdown/${encodeURIComponent(n)}`}function Ad(n,t={electron:!1}){if(n.kind==="url")return t.electron?{renderer:"url-webview",viewURL:n.url,contentURL:null}:Zr(n.url)?{renderer:"proxy-iframe",viewURL:n.url,contentURL:null}:t.browserDemo&&CI(n.url)?{renderer:"url-direct",viewURL:n.url,contentURL:null}:{renderer:"url-unsupported",viewURL:TI,contentURL:null};if(qm(n.path)){const r={viewURL:kI,contentURL:II(n.id)};return t.electron?{renderer:"url-webview",...r}:{renderer:"markdown",...r}}const e=l6(n.path)?`${u6(n.id)}/`:RI(n.id,c6(n.path));return t.electron?{renderer:"url-webview",viewURL:e,contentURL:null}:{renderer:"proxy-iframe",viewURL:e,contentURL:null}}const $I="serverURL",xI="token",PI="mode",DI="desktopAppVersion",LI="electron";function MI(n=window.location.search,t=window.location.origin){const r=new URLSearchParams(n).get($I);return r?new URL(r).origin:new URL(t).origin}function OI(n=window.location.search){return new URLSearchParams(n).get(xI)}function gi(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(PI)===LI}function h6(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(DI)}const E2="tv.telemetry.clientId",NI=5,zI=60,HI=1e3,ZI=NI*zI*HI,k2=["pointerdown","scroll","keydown"],T2=["focus"],C2=["visibilitychange"],UI="hidden";function FI(n,t=jI){const e=n.getItem(E2);if(e)return e;const r=t();return n.setItem(E2,r),r}function qI(n){return{clientId:FI(n.storage,n.idFactory),userAgent:n.userAgent??(typeof navigator>"u"?"":navigator.userAgent),clientApp:n.clientApp,...n.desktopAppVersion?{desktopAppVersion:n.desktopAppVersion}:{}}}function VI(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 BI(n){return new WI(n)}var Xc,Br,Fi,Qc,eu,mn,co,tu,Od,d6;class WI{constructor(t){m(this,Od);m(this,Xc);m(this,Br);m(this,Fi);m(this,Qc);m(this,eu);m(this,mn);m(this,co,!1);m(this,tu,Number.NEGATIVE_INFINITY);d(this,Xc,t.meta),d(this,Br,t.documentTarget),d(this,Fi,t.windowTarget),d(this,Qc,t.send),d(this,eu,t.nowMs??Date.now),d(this,mn,()=>h(this,Od,d6).call(this))}start(){if(!o(this,co)){d(this,co,!0);for(const t of k2)o(this,Fi).addEventListener(t,o(this,mn)),o(this,Br).addEventListener(t,o(this,mn));for(const t of T2)o(this,Fi).addEventListener(t,o(this,mn));for(const t of C2)o(this,Br).addEventListener(t,o(this,mn))}}stop(){if(o(this,co)){d(this,co,!1);for(const t of k2)o(this,Fi).removeEventListener(t,o(this,mn)),o(this,Br).removeEventListener(t,o(this,mn));for(const t of T2)o(this,Fi).removeEventListener(t,o(this,mn));for(const t of C2)o(this,Br).removeEventListener(t,o(this,mn))}}}Xc=new WeakMap,Br=new WeakMap,Fi=new WeakMap,Qc=new WeakMap,eu=new WeakMap,mn=new WeakMap,co=new WeakMap,tu=new WeakMap,Od=new WeakSet,d6=function(){if(o(this,Br).visibilityState===UI)return;const t=o(this,eu).call(this);t-o(this,tu)<ZI||(d(this,tu,t),o(this,Qc).call(this,{type:zE,clientId:o(this,Xc).clientId}))};function jI(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():N1().toLowerCase()}const De={authenticate:"authenticate",document_did_change:"document/didChange",document_did_close:"document/didClose",document_did_focus:"document/didFocus",document_did_open:"document/didOpen",document_did_save:"document/didSave",initialize:"initialize",logout:"logout",nes_accept:"nes/accept",nes_close:"nes/close",nes_reject:"nes/reject",nes_start:"nes/start",nes_suggest:"nes/suggest",session_cancel:"session/cancel",session_close:"session/close",session_fork:"session/fork",session_list:"session/list",session_load:"session/load",session_new:"session/new",session_prompt:"session/prompt",session_resume:"session/resume",session_set_config_option:"session/set_config_option",session_set_mode:"session/set_mode",session_set_model:"session/set_model"},Nr={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"},GI=1,YI=b({_meta:T(g(),E()).nullish(),terminal:lt().optional().default(!1)}),KI=b({_meta:T(g(),E()).nullish(),label:g().nullish(),name:g(),optional:lt().optional().default(!1),secret:lt().optional().default(!0)}),JI=b({_meta:T(g(),E()).nullish(),description:g().nullish(),id:g(),name:g()}),XI=b({_meta:T(g(),E()).nullish(),description:g().nullish(),id:g(),link:g().nullish(),name:g(),vars:G(KI)}),QI=b({_meta:T(g(),E()).nullish(),args:G(g()).optional(),description:g().nullish(),env:T(g(),g()).optional(),id:g(),name:g()}),e$=ae([XI.and(b({type:D("env_var")})),QI.and(b({type:D("terminal")})),JI]),t$=b({_meta:T(g(),E()).nullish(),methodId:g()}),n$=b({_meta:T(g(),E()).nullish()}),r$=b({_meta:T(g(),E()).nullish(),blob:g(),mimeType:g().nullish(),uri:g()}),i$=b({default:lt().nullish(),description:g().nullish(),title:g().nullish()}),s$=b({_meta:T(g(),E()).nullish()}),o$=b({_meta:T(g(),E()).nullish()}),a$=b({amount:ie(),currency:g()}),l$=b({_meta:T(g(),E()).nullish(),terminalId:g()}),c$=b({_meta:T(g(),E()).nullish(),newText:g(),oldText:g().nullish(),path:g()}),u$=ae([g(),ie(),ie(),lt(),G(g())]),h$=b({content:T(g(),u$).nullish()}),d$=ae([h$.and(b({action:D("accept")})),b({action:D("decline")}),b({action:D("cancel")})]),p$=b({_meta:T(g(),E()).nullish()}),p6=g(),f$=b({_meta:T(g(),E()).nullish(),elicitationId:p6}),m$=b({_meta:T(g(),E()).nullish(),action:d$}),g$=D("object"),v$=D("string"),y$=b({_meta:T(g(),E()).nullish()}),w$=b({_meta:T(g(),E()).nullish(),form:p$.nullish(),url:y$.nullish()}),b$=b({elicitationId:p6,url:g().url()}),f6=b({const:g(),title:g()}),m6=b({_meta:T(g(),E()).nullish(),name:g(),value:g()}),S$=ae([D(-32700),D(-32600),D(-32601),D(-32602),D(-32603),D(-32800),D(-32e3),D(-32002),D(-32042),ie().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),g6=b({code:S$,data:E().optional(),message:g()}),v6=E(),y6=E(),w6=E(),_$=b({_meta:T(g(),E()).nullish(),readTextFile:lt().optional().default(!1),writeTextFile:lt().optional().default(!1)}),b6=b({_meta:T(g(),E()).nullish(),name:g(),value:g()}),S6=b({_meta:T(g(),E()).nullish(),name:g(),title:g().nullish(),version:g()}),A$=b({default:ie().nullish(),description:g().nullish(),maximum:ie().nullish(),minimum:ie().nullish(),title:g().nullish()}),E$=b({_meta:T(g(),E()).nullish()}),k$=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cursor:g().nullish(),cwd:g().nullish()}),T$=b({_meta:T(g(),E()).nullish()}),C$=b({_meta:T(g(),E()).nullish(),logout:T$.nullish()}),R$=b({_meta:T(g(),E()).nullish()}),I$=b({_meta:T(g(),E()).nullish()}),$$=b({_meta:T(g(),E()).nullish(),http:lt().optional().default(!1),sse:lt().optional().default(!1)}),x$=b({_meta:T(g(),E()).nullish(),headers:G(b6),name:g(),url:g()}),P$=b({_meta:T(g(),E()).nullish(),headers:G(b6),name:g(),url:g()}),D$=b({_meta:T(g(),E()).nullish(),args:G(g()),command:g(),env:G(m6),name:g()}),Op=ae([x$.and(b({type:D("http")})),P$.and(b({type:D("sse")})),D$]),V1=g(),L$=b({_meta:T(g(),E()).nullish(),description:g().nullish(),modelId:V1,name:g()}),M$=ae([D("error"),D("warning"),D("information"),D("hint")]),O$=b({_meta:T(g(),E()).nullish()}),N$=b({_meta:T(g(),E()).nullish()}),z$=b({_meta:T(g(),E()).nullish()}),H$=b({_meta:T(g(),E()).nullish()}),Z$=b({_meta:T(g(),E()).nullish()}),U$=b({_meta:T(g(),E()).nullish(),maxCount:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),F$=b({diff:g(),uri:g()}),q$=b({endLine:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:g()}),V$=b({_meta:T(g(),E()).nullish()}),B$=b({_meta:T(g(),E()).nullish()}),W$=b({languageId:g(),text:g(),uri:g()}),j$=b({_meta:T(g(),E()).nullish(),maxCount:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),G$=ae([D("rejected"),D("ignored"),D("replaced"),D("cancelled")]),Y$=b({excerpts:G(q$),uri:g()}),K$=b({_meta:T(g(),E()).nullish()}),J$=b({_meta:T(g(),E()).nullish()}),X$=b({name:g(),owner:g(),remoteUrl:g()}),Q$=b({_meta:T(g(),E()).nullish()}),ex=b({_meta:T(g(),E()).nullish(),jump:V$.nullish(),rename:J$.nullish(),searchAndReplace:Q$.nullish()}),tx=b({id:g(),isRegex:lt().nullish(),replace:g(),search:g(),uri:g()}),nx=ae([D("automatic"),D("diagnostic"),D("manual")]),rx=b({_meta:T(g(),E()).nullish(),maxCount:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),ix=b({_meta:T(g(),E()).nullish(),diagnostics:O$.nullish(),editHistory:U$.nullish(),openFiles:B$.nullish(),recentFiles:j$.nullish(),relatedSnippets:K$.nullish(),userActions:rx.nullish()}),sx=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),mcpServers:G(Op)}),ox=b({default:ie().nullish(),description:g().nullish(),maximum:ie().nullish(),minimum:ie().nullish(),title:g().nullish()}),_6=g(),ax=ae([D("allow_once"),D("allow_always"),D("reject_once"),D("reject_always")]),lx=b({_meta:T(g(),E()).nullish(),kind:ax,name:g(),optionId:_6}),cx=ae([D("high"),D("medium"),D("low")]),ux=ae([D("pending"),D("in_progress"),D("completed")]),hx=b({_meta:T(g(),E()).nullish(),content:g(),priority:cx,status:ux}),dx=b({_meta:T(g(),E()).nullish(),entries:G(hx)}),Cs=b({character:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),px=b({id:g(),position:Cs,uri:g()}),fx=b({id:g(),newName:g(),position:Cs,uri:g()}),mx=b({action:g(),position:Cs,timestampMs:ie(),uri:g()}),A6=ae([D("utf-16"),D("utf-32"),D("utf-8")]),gx=b({_meta:T(g(),E()).nullish(),auth:YI.optional().default({terminal:!1}),elicitation:w$.nullish(),fs:_$.optional().default({readTextFile:!1,writeTextFile:!1}),nes:ex.nullish(),positionEncodings:G(A6).optional(),terminal:lt().optional().default(!1)}),vx=b({_meta:T(g(),E()).nullish(),audio:lt().optional().default(!1),embeddedContext:lt().optional().default(!1),image:lt().optional().default(!1)}),E6=ie().int().gte(0).lte(65535),yx=b({_meta:T(g(),E()).nullish(),clientCapabilities:gx.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:S6.nullish(),protocolVersion:E6}),jl=b({end:Cs,start:Cs}),wx=b({message:g(),range:jl,severity:M$,uri:g()}),bx=b({languageId:g(),lastFocusedMs:ie().nullish(),uri:g(),visibleRange:jl.nullish()}),Sx=b({_meta:T(g(),E()).nullish(),diagnostics:G(wx).nullish(),editHistory:G(F$).nullish(),openFiles:G(bx).nullish(),recentFiles:G(W$).nullish(),relatedSnippets:G(Y$).nullish(),userActions:G(mx).nullish()}),_x=b({newText:g(),range:jl}),Ax=b({cursorPosition:Cs.nullish(),edits:G(_x),id:g(),uri:g()}),Ex=ae([Ax.and(b({kind:D("edit")})),px.and(b({kind:D("jump")})),fx.and(b({kind:D("rename")})),tx.and(b({kind:D("searchAndReplace")}))]),kx=b({_meta:T(g(),E()).nullish(),content:g()}),Tx=b({_meta:T(g(),E()).nullish()}),Xo=ae([ie(),g()]).nullable();b({_meta:T(g(),E()).nullish(),requestId:Xo});const Cx=s6(["assistant","user"]),hh=b({_meta:T(g(),E()).nullish(),audience:G(Cx).nullish(),lastModified:g().nullish(),priority:ie().nullish()}),Rx=b({_meta:T(g(),E()).nullish(),annotations:hh.nullish(),data:g(),mimeType:g()}),Ix=b({_meta:T(g(),E()).nullish(),annotations:hh.nullish(),data:g(),mimeType:g(),uri:g().nullish()}),$x=b({_meta:T(g(),E()).nullish(),annotations:hh.nullish(),description:g().nullish(),mimeType:g().nullish(),name:g(),size:ie().nullish(),title:g().nullish(),uri:g()}),xx=b({_meta:T(g(),E()).nullish(),optionId:_6}),Px=ae([b({outcome:D("cancelled")}),xx.and(b({outcome:D("selected")}))]),Dx=b({_meta:T(g(),E()).nullish(),outcome:Px}),Lx=b({_meta:T(g(),E()).nullish()}),Mx=b({_meta:T(g(),E()).nullish()}),Ox=b({currentValue:lt()}),Nx=g(),k6=g(),zx=ae([D("mode"),D("model"),D("thought_level"),g()]),B1=g(),T6=b({_meta:T(g(),E()).nullish(),description:g().nullish(),name:g(),value:B1}),Hx=b({_meta:T(g(),E()).nullish(),group:Nx,name:g(),options:G(T6)}),Zx=ae([G(T6),G(Hx)]),Ux=b({currentValue:B1,options:Zx}),Gl=Mp(ae([Ux.and(b({type:D("select")})),Ox.and(b({type:D("boolean")}))]),b({_meta:T(g(),E()).nullish(),category:zx.nullish(),description:g().nullish(),id:k6,name:g()})),Fx=b({_meta:T(g(),E()).nullish(),configOptions:G(Gl)}),qx=b({_meta:T(g(),E()).nullish()}),be=g(),Vx=b({_meta:T(g(),E()).nullish(),id:g(),sessionId:be}),Bx=b({_meta:T(g(),E()).nullish(),sessionId:be}),Wx=b({_meta:T(g(),E()).nullish(),sessionId:be}),jx=b({_meta:T(g(),E()).nullish(),sessionId:be}),C6=b({_meta:T(g(),E()).nullish(),args:G(g()).optional(),command:g(),cwd:g().nullish(),env:G(m6).optional(),outputByteLimit:ie().nullish(),sessionId:be}),Gx=b({_meta:T(g(),E()).nullish(),sessionId:be,uri:g()}),Yx=b({_meta:T(g(),E()).nullish(),position:Cs,sessionId:be,uri:g(),version:ie(),visibleRange:jl}),Kx=b({_meta:T(g(),E()).nullish(),languageId:g(),sessionId:be,text:g(),uri:g(),version:ie()}),Jx=b({_meta:T(g(),E()).nullish(),sessionId:be,uri:g()}),Xx=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),mcpServers:G(Op).optional(),sessionId:be}),R6=b({_meta:T(g(),E()).nullish(),sessionId:be,terminalId:g()}),Qx=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),mcpServers:G(Op),sessionId:be}),I6=b({_meta:T(g(),E()).nullish(),limit:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:g(),sessionId:be}),eP=b({_meta:T(g(),E()).nullish(),id:g(),reason:G$.nullish(),sessionId:be}),$6=b({_meta:T(g(),E()).nullish(),sessionId:be,terminalId:g()}),tP=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),mcpServers:G(Op).optional(),sessionId:be}),nP=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),sessionId:be,title:g().nullish(),updatedAt:g().nullish()}),rP=b({_meta:T(g(),E()).nullish(),nextCursor:g().nullish(),sessions:G(nP)}),iP=b({_meta:T(g(),E()).nullish(),title:g().nullish(),updatedAt:g().nullish()}),sP=b({_meta:T(g(),E()).nullish()}),Np=g(),oP=b({_meta:T(g(),E()).nullish(),currentModeId:Np}),aP=b({_meta:T(g(),E()).nullish(),description:g().nullish(),id:Np,name:g()}),zp=b({_meta:T(g(),E()).nullish(),availableModes:G(aP),currentModeId:Np}),Hp=b({_meta:T(g(),E()).nullish(),availableModels:G(L$),currentModelId:V1}),lP=b({_meta:T(g(),E()).nullish(),configOptions:G(Gl).nullish(),models:Hp.nullish(),modes:zp.nullish(),sessionId:be}),cP=b({_meta:T(g(),E()).nullish(),configOptions:G(Gl).nullish(),models:Hp.nullish(),modes:zp.nullish()}),uP=b({_meta:T(g(),E()).nullish(),configOptions:G(Gl).nullish(),models:Hp.nullish(),modes:zp.nullish(),sessionId:be}),hP=b({_meta:T(g(),E()).nullish(),configOptions:G(Gl).nullish(),models:Hp.nullish(),modes:zp.nullish()}),dP=b({_meta:T(g(),E()).nullish()}),pP=b({_meta:T(g(),E()).nullish(),additionalDirectories:Lx.nullish(),close:Mx.nullish(),fork:qx.nullish(),list:sP.nullish(),resume:dP.nullish()}),fP=Mp(ae([b({type:D("boolean"),value:lt()}),b({value:B1})]),b({_meta:T(g(),E()).nullish(),configId:k6,sessionId:be})),mP=b({_meta:T(g(),E()).nullish(),configOptions:G(Gl)}),gP=b({_meta:T(g(),E()).nullish(),modeId:Np,sessionId:be}),vP=b({_meta:T(g(),E()).nullish()}),yP=b({_meta:T(g(),E()).nullish(),modelId:V1,sessionId:be}),wP=b({_meta:T(g(),E()).nullish()}),bP=b({_meta:T(g(),E()).nullish(),sessionId:be}),SP=ae([D("end_turn"),D("max_tokens"),D("max_turn_requests"),D("refusal"),D("cancelled")]),_P=ae([D("email"),D("uri"),D("date"),D("date-time")]),AP=b({default:g().nullish(),description:g().nullish(),enum:G(g()).nullish(),format:_P.nullish(),maxLength:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:G(f6).nullish(),pattern:g().nullish(),title:g().nullish()}),EP=b({_meta:T(g(),E()).nullish(),context:Sx.nullish(),position:Cs,selection:jl.nullish(),sessionId:be,triggerKind:nx,uri:g(),version:ie()}),kP=b({_meta:T(g(),E()).nullish(),suggestions:G(Ex)}),TP=b({_meta:T(g(),E()).nullish(),terminalId:g()}),CP=b({_meta:T(g(),E()).nullish(),exitCode:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:g().nullish()}),x6=b({_meta:T(g(),E()).nullish(),sessionId:be,terminalId:g()}),RP=b({_meta:T(g(),E()).nullish(),exitStatus:CP.nullish(),output:g(),truncated:lt()}),IP=b({_meta:T(g(),E()).nullish(),annotations:hh.nullish(),text:g()}),$P=b({range:jl.nullish(),text:g()}),xP=b({_meta:T(g(),E()).nullish(),contentChanges:G($P),sessionId:be,uri:g(),version:ie()});b({method:g(),params:ae([Bx,Kx,xP,Gx,Jx,Yx,Vx,eP,v6]).nullish()});const PP=ae([D("full"),D("incremental")]),DP=b({_meta:T(g(),E()).nullish(),syncKind:PP}),LP=b({_meta:T(g(),E()).nullish(),didChange:DP.nullish(),didClose:N$.nullish(),didFocus:z$.nullish(),didOpen:H$.nullish(),didSave:Z$.nullish()}),MP=b({_meta:T(g(),E()).nullish(),document:LP.nullish()}),OP=b({_meta:T(g(),E()).nullish(),context:ix.nullish(),events:MP.nullish()}),NP=b({_meta:T(g(),E()).nullish(),auth:C$.optional().default({}),loadSession:lt().optional().default(!1),mcpCapabilities:$$.optional().default({http:!1,sse:!1}),nes:OP.nullish(),positionEncoding:A6.nullish(),promptCapabilities:vx.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:pP.optional().default({})}),zP=b({_meta:T(g(),E()).nullish(),agentCapabilities:NP.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:S6.nullish(),authMethods:G(e$).optional().default([]),protocolVersion:E6}),HP=b({_meta:T(g(),E()).nullish(),mimeType:g().nullish(),text:g(),uri:g()}),ZP=ae([HP,r$]),UP=b({_meta:T(g(),E()).nullish(),annotations:hh.nullish(),resource:ZP}),W1=ae([IP.and(b({type:D("text")})),Ix.and(b({type:D("image")})),Rx.and(b({type:D("audio")})),$x.and(b({type:D("resource_link")})),UP.and(b({type:D("resource")}))]),FP=b({_meta:T(g(),E()).nullish(),content:W1}),ym=b({_meta:T(g(),E()).nullish(),content:W1,messageId:g().nullish()}),qP=b({_meta:T(g(),E()).nullish(),messageId:g().nullish(),prompt:G(W1),sessionId:be}),VP=b({anyOf:G(f6)}),P6=ae([FP.and(b({type:D("content")})),c$.and(b({type:D("diff")})),TP.and(b({type:D("terminal")}))]),D6=g(),L6=b({_meta:T(g(),E()).nullish(),line:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:g()}),M6=ae([D("pending"),D("in_progress"),D("completed"),D("failed")]),O6=ae([D("read"),D("edit"),D("delete"),D("move"),D("search"),D("execute"),D("think"),D("fetch"),D("switch_mode"),D("other")]),BP=b({_meta:T(g(),E()).nullish(),content:G(P6).optional(),kind:O6.optional(),locations:G(L6).optional(),rawInput:E().optional(),rawOutput:E().optional(),status:M6.optional(),title:g(),toolCallId:D6}),N6=b({_meta:T(g(),E()).nullish(),content:G(P6).nullish(),kind:O6.nullish(),locations:G(L6).nullish(),rawInput:E().optional(),rawOutput:E().optional(),status:M6.nullish(),title:g().nullish(),toolCallId:D6}),z6=b({_meta:T(g(),E()).nullish(),options:G(lx),sessionId:be,toolCall:N6}),WP=b({_meta:T(g(),E()).nullish(),hint:g()}),jP=WP,GP=b({_meta:T(g(),E()).nullish(),description:g(),input:jP.nullish(),name:g()}),YP=b({_meta:T(g(),E()).nullish(),availableCommands:G(GP)}),KP=b({enum:G(g()),type:v$}),JP=ae([KP,VP]),XP=b({default:G(g()).nullish(),description:g().nullish(),items:JP,maxItems:ie().nullish(),minItems:ie().nullish(),title:g().nullish()}),QP=ae([AP.and(b({type:D("string")})),ox.and(b({type:D("number")})),A$.and(b({type:D("integer")})),i$.and(b({type:D("boolean")})),XP.and(b({type:D("array")}))]),e5=b({description:g().nullish(),properties:T(g(),QP).optional().default({}),required:G(g()).nullish(),title:g().nullish(),type:g$.optional().default("object")}),t5=b({requestedSchema:e5}),n5=Mp(ae([t5.and(b({mode:D("form")})),b$.and(b({mode:D("url")}))]),b({_meta:T(g(),E()).nullish(),message:g(),sessionId:be})),r5=b({cachedReadTokens:ie().nullish(),cachedWriteTokens:ie().nullish(),inputTokens:ie(),outputTokens:ie(),thoughtTokens:ie().nullish(),totalTokens:ie()}),i5=b({_meta:T(g(),E()).nullish(),stopReason:SP,usage:r5.nullish(),userMessageId:g().nullish()});ae([b({id:Xo,result:ae([zP,n$,I$,uP,cP,rP,lP,hP,o$,vP,mP,i5,wP,bP,kP,s$,w6])}),b({error:g6,id:Xo})]);const s5=b({_meta:T(g(),E()).nullish(),cost:a$.nullish(),size:ie(),used:ie()}),o5=ae([ym.and(b({sessionUpdate:D("user_message_chunk")})),ym.and(b({sessionUpdate:D("agent_message_chunk")})),ym.and(b({sessionUpdate:D("agent_thought_chunk")})),BP.and(b({sessionUpdate:D("tool_call")})),N6.and(b({sessionUpdate:D("tool_call_update")})),dx.and(b({sessionUpdate:D("plan")})),YP.and(b({sessionUpdate:D("available_commands_update")})),oP.and(b({sessionUpdate:D("current_mode_update")})),Fx.and(b({sessionUpdate:D("config_option_update")})),iP.and(b({sessionUpdate:D("session_info_update")})),s5.and(b({sessionUpdate:D("usage_update")}))]),H6=b({_meta:T(g(),E()).nullish(),sessionId:be,update:o5});b({method:g(),params:ae([H6,f$,v6]).nullish()});const Z6=b({_meta:T(g(),E()).nullish(),sessionId:be,terminalId:g()}),a5=b({_meta:T(g(),E()).nullish(),exitCode:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:g().nullish()}),l5=b({name:g(),uri:g()}),c5=b({_meta:T(g(),E()).nullish(),repository:X$.nullish(),workspaceFolders:G(l5).nullish(),workspaceUri:g().nullish()});b({id:Xo,method:g(),params:ae([yx,t$,R$,sx,Qx,k$,Xx,tP,jx,gP,fP,qP,yP,c5,EP,Wx,y6]).nullish()});const U6=b({_meta:T(g(),E()).nullish(),content:g(),path:g(),sessionId:be});b({id:Xo,method:g(),params:ae([U6,I6,z6,C6,x6,$6,Z6,R6,n5,y6]).nullish()});const u5=b({_meta:T(g(),E()).nullish()});ae([b({id:Xo,result:ae([u5,kx,Dx,l$,RP,Tx,a5,E$,m$,w6])}),b({error:g6,id:Xo})]);var we;class h5{constructor(t,e){m(this,we);const r=t(this),i=async(a,l)=>{var c,u,p,f,y,v,S;switch(a){case Nr.fs_write_text_file:{const _=U6.parse(l);return(c=r.writeTextFile)==null?void 0:c.call(r,_)}case Nr.fs_read_text_file:{const _=I6.parse(l);return(u=r.readTextFile)==null?void 0:u.call(r,_)}case Nr.session_request_permission:{const _=z6.parse(l);return r.requestPermission(_)}case Nr.terminal_create:{const _=C6.parse(l);return(p=r.createTerminal)==null?void 0:p.call(r,_)}case Nr.terminal_output:{const _=x6.parse(l);return(f=r.terminalOutput)==null?void 0:f.call(r,_)}case Nr.terminal_release:{const _=$6.parse(l);return await((y=r.releaseTerminal)==null?void 0:y.call(r,_))??{}}case Nr.terminal_wait_for_exit:{const _=Z6.parse(l);return(v=r.waitForTerminalExit)==null?void 0:v.call(r,_)}case Nr.terminal_kill:{const _=R6.parse(l);return await((S=r.killTerminal)==null?void 0:S.call(r,_))??{}}default:if(r.extMethod)return r.extMethod(a,l);throw rt.methodNotFound(a)}},s=async(a,l)=>{switch(a){case Nr.session_update:{const c=H6.parse(l);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(a,l);throw rt.methodNotFound(a)}};d(this,we,new d5(i,s,e))}async initialize(t){return await o(this,we).sendRequest(De.initialize,t)}async newSession(t){return await o(this,we).sendRequest(De.session_new,t)}async loadSession(t){return await o(this,we).sendRequest(De.session_load,t)??{}}async unstable_forkSession(t){return await o(this,we).sendRequest(De.session_fork,t)}async listSessions(t){return await o(this,we).sendRequest(De.session_list,t)}async unstable_resumeSession(t){return await o(this,we).sendRequest(De.session_resume,t)}async unstable_closeSession(t){return await o(this,we).sendRequest(De.session_close,t)}async setSessionMode(t){return await o(this,we).sendRequest(De.session_set_mode,t)??{}}async unstable_setSessionModel(t){return await o(this,we).sendRequest(De.session_set_model,t)??{}}async setSessionConfigOption(t){return await o(this,we).sendRequest(De.session_set_config_option,t)}async authenticate(t){return await o(this,we).sendRequest(De.authenticate,t)??{}}async unstable_logout(t){return await o(this,we).sendRequest(De.logout,t)??{}}async prompt(t){return await o(this,we).sendRequest(De.session_prompt,t)}async cancel(t){return await o(this,we).sendNotification(De.session_cancel,t)}async unstable_startNes(t){return await o(this,we).sendRequest(De.nes_start,t)}async unstable_suggestNes(t){return await o(this,we).sendRequest(De.nes_suggest,t)}async unstable_closeNes(t){return await o(this,we).sendRequest(De.nes_close,t)??{}}async unstable_didOpenDocument(t){return await o(this,we).sendNotification(De.document_did_open,t)}async unstable_didChangeDocument(t){return await o(this,we).sendNotification(De.document_did_change,t)}async unstable_didCloseDocument(t){return await o(this,we).sendNotification(De.document_did_close,t)}async unstable_didSaveDocument(t){return await o(this,we).sendNotification(De.document_did_save,t)}async unstable_didFocusDocument(t){return await o(this,we).sendNotification(De.document_did_focus,t)}async unstable_acceptNes(t){return await o(this,we).sendNotification(De.nes_accept,t)}async unstable_rejectNes(t){return await o(this,we).sendNotification(De.nes_reject,t)}async extMethod(t,e){return await o(this,we).sendRequest(t,e)}async extNotification(t,e){return await o(this,we).sendNotification(t,e)}get signal(){return o(this,we).signal}get closed(){return o(this,we).closed}}we=new WeakMap;var qi,Nd,nu,ru,za,Ha,sr,iu,Ze,F6,Vm,q6,V6,B6,W6,Bm,Sc;class d5{constructor(t,e,r){m(this,Ze);m(this,qi,new Map);m(this,Nd,0);m(this,nu);m(this,ru);m(this,za);m(this,Ha,Promise.resolve());m(this,sr,new AbortController);m(this,iu);d(this,nu,t),d(this,ru,e),d(this,za,r),d(this,iu,new Promise(i=>{o(this,sr).signal.addEventListener("abort",()=>i())})),h(this,Ze,F6).call(this)}get signal(){return o(this,sr).signal}get closed(){return o(this,iu)}async sendRequest(t,e){h(this,Ze,Bm).call(this);const r=Ah(this,Nd)._++,i=new Promise((s,a)=>{o(this,qi).set(r,{resolve:s,reject:a})});return await h(this,Ze,Sc).call(this,{jsonrpc:"2.0",id:r,method:t,params:e}),i}async sendNotification(t,e){h(this,Ze,Bm).call(this),await h(this,Ze,Sc).call(this,{jsonrpc:"2.0",method:t,params:e})}}qi=new WeakMap,Nd=new WeakMap,nu=new WeakMap,ru=new WeakMap,za=new WeakMap,Ha=new WeakMap,sr=new WeakMap,iu=new WeakMap,Ze=new WeakSet,F6=async function(){let t;try{const e=o(this,za).readable.getReader();try{for(;!o(this,sr).signal.aborted;){const{value:r,done:i}=await e.read();if(i)break;if(r)try{h(this,Ze,q6).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&h(this,Ze,Sc).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{e.releaseLock()}}catch(e){t=e}finally{h(this,Ze,Vm).call(this,t)}},Vm=function(t){if(o(this,sr).signal.aborted)return;const e=t??new Error("ACP connection closed");for(const r of o(this,qi).values())r.reject(e);o(this,qi).clear(),o(this,sr).abort(e)},q6=async function(t){if("method"in t&&"id"in t){const e=await h(this,Ze,V6).call(this,t.method,t.params);"error"in e&&console.error("Error handling request",t,e.error),await h(this,Ze,Sc).call(this,{jsonrpc:"2.0",id:t.id,...e})}else if("method"in t){const e=await h(this,Ze,B6).call(this,t.method,t.params);"error"in e&&console.error("Error handling notification",t,e.error)}else"id"in t?h(this,Ze,W6).call(this,t):console.error("Invalid message",{message:t})},V6=async function(t,e){try{return{result:await o(this,nu).call(this,t,e)??null}}catch(r){if(r instanceof rt)return r.toResult();if(r instanceof v2)return rt.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return rt.internalError(i?JSON.parse(i):{}).toResult()}catch{return rt.internalError({details:i}).toResult()}}},B6=async function(t,e){try{return await o(this,ru).call(this,t,e),{result:null}}catch(r){if(r instanceof rt)return r.toResult();if(r instanceof v2)return rt.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return rt.internalError(i?JSON.parse(i):{}).toResult()}catch{return rt.internalError({details:i}).toResult()}}},W6=function(t){const e=o(this,qi).get(t.id);if(e){if("result"in t)e.resolve(t.result);else if("error"in t){const{code:r,message:i,data:s}=t.error;e.reject(new rt(r,i,s))}o(this,qi).delete(t.id)}else console.error("Got response to unknown request",t.id)},Bm=function(){if(o(this,sr).signal.aborted)throw o(this,sr).signal.reason??new Error("ACP connection closed")},Sc=async function(t){return d(this,Ha,o(this,Ha).then(async()=>{const e=o(this,za).writable.getWriter();try{await e.write(t)}finally{e.releaseLock()}}).catch(e=>{h(this,Ze,Vm).call(this,e)})),o(this,Ha)};class rt extends Error{constructor(e,r,i){super(r);$(this,"code");$(this,"data");this.code=e,this.name="RequestError",this.data=i}static parseError(e,r){return new rt(-32700,`Parse error${r?`: ${r}`:""}`,e)}static invalidRequest(e,r){return new rt(-32600,`Invalid request${r?`: ${r}`:""}`,e)}static methodNotFound(e){return new rt(-32601,`"Method not found": ${e}`,{method:e})}static invalidParams(e,r){return new rt(-32602,`Invalid params${r?`: ${r}`:""}`,e)}static internalError(e,r){return new rt(-32603,`Internal error${r?`: ${r}`:""}`,e)}static authRequired(e,r){return new rt(-32e3,`Authentication required${r?`: ${r}`:""}`,e)}static resourceNotFound(e){return new rt(-32002,`Resource not found${e?`: ${e}`:""}`,e&&{uri:e})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}function p5(n,t,e){const r=n.dispose.bind(n);n.dispose=(()=>{if(!t())return e(),r()})}function j6(n){var e;class t extends n{constructor(...s){super(...s);m(this,e,!1);p5(this,()=>o(this,e),()=>{d(this,e,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return o(this,e)}}return e=new WeakMap,t}const f5=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,m5=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,g5=/\[Television channel context\][\s\S]*?\[\/Television channel context\]\n*/,v5=/\b(tv|television|channel|artifact|artifacts|viewer|filmstrip|layout|focus)\b/i,y5=/^[A-Za-z0-9_@%+=:,./-]+$/,w5=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,b5="single_session",S5={name:"television-acp-client",version:"0.0.0"},G6="agent:main:television",_5=j6(Ei);var Za,or,Qt,ar,Vi,Mn,Wr,lr,On,Bi,Nn,Ua,Fa,cr,Et,jr,qa,uo,Gr,Wi,su,zn,ur,zd,hr,M,Wm,Y6,K6,J6,Fh,X6,Q6,eS,tS,nS,rS,iS,Vs,ga,va,Hr,sS,ya,jm,Gm,qh,oS,Vh,Ym,Km,ou,au,Bh,wa,Jm,aS;class A5 extends _5{constructor(e){super();m(this,M);m(this,Za,"disconnected");m(this,or,null);m(this,Qt,new Map);m(this,ar,null);m(this,Vi,null);m(this,Mn,null);m(this,Wr,null);m(this,lr,null);m(this,On,null);m(this,Bi);m(this,Nn,null);m(this,Ua,0);m(this,Fa,1);m(this,cr,null);m(this,Et,null);m(this,jr,!1);m(this,qa,!1);m(this,uo,!1);m(this,Gr,null);m(this,Wi,new Set);m(this,su);m(this,zn);m(this,ur);m(this,zd,e=>{h(this,M,K6).call(this,e)});m(this,hr,null);m(this,ou,()=>{h(this,M,wa).call(this,"ACP bridge websocket closed")});m(this,au,()=>{h(this,M,wa).call(this,"ACP bridge websocket error")});d(this,zn,e),d(this,ur,e.sessionMode??b5),d(this,Bi,e.mappedSessionStore??E5()),d(this,su,e.createSocket??(r=>new WebSocket(r)))}get status(){return o(this,Za)}get messages(){return[...o(this,Qt).values()]}get enabled(){return o(this,zn).enabled??!1}setToken(e){o(this,zn).token=e??""}setEnabled(e){o(this,zn).enabled=e,e||(h(this,M,Bh).call(this),d(this,or,null),h(this,M,Hr).call(this,"disconnected"))}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(this.enabled&&this.status==="disconnected"){o(this,Vi)===null&&(d(this,or,null),d(this,Vi,h(this,M,Y6).call(this)));try{await o(this,Vi),await h(this,M,Fh).call(this)}catch(e){throw h(this,M,wa).call(this,wm(e)),e}}}dispose(){h(this,M,Bh).call(this),d(this,or,null),h(this,M,Hr).call(this,"disposed")}async sendMessage(e){if(await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await h(this,M,Wm).call(this,"ready")),(o(this,lr)===null||o(this,Nn)!==h(this,M,Vh).call(this))&&await h(this,M,Fh).call(this),this.status!=="ready")throw new Error("ACPClient is not ready to send a new message");const r=e.text.trim();if(!r)throw new Error("Cannot send an empty message");h(this,M,ga).call(this,{id:h(this,M,ya).call(this,"user"),kind:"user",text:r,status:"final"}),h(this,M,Hr).call(this,"running");try{const i=await h(this,M,qh).call(this).prompt({sessionId:h(this,M,Gm).call(this),prompt:[{type:"text",text:h(this,M,sS).call(this,r)}]});h(this,M,Vs).call(this,i.stopReason==="cancelled"?"cancelled":"final"),h(this,M,Hr).call(this,"ready")}catch(i){throw h(this,M,aS).call(this)||(h(this,M,Vs).call(this,"error"),h(this,M,Hr).call(this,"ready")),i}}async startNewSession(){var r;await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await h(this,M,Wm).call(this,"ready"));const e=h(this,M,Vh).call(this);((r=o(this,On))==null?void 0:r.sessionIdStrategy)==="mapped"?o(this,Bi).clearActualSessionId(e):d(this,Ua,o(this,Ua)+1),d(this,Mn,null),d(this,Wr,null),d(this,lr,null),d(this,Nn,null),h(this,M,Jm).call(this)}async cancel(){this.status==="running"&&(h(this,M,Hr).call(this,"cancelling"),await h(this,M,qh).call(this).cancel({sessionId:h(this,M,Gm).call(this)}))}setChannelContext(e){var s,a,l;if(e===null){if(o(this,Et)===null)return;d(this,Et,null),d(this,jr,!1);return}const r={channelID:e.channelID,channelName:e.channelName};if(((s=o(this,Et))==null?void 0:s.channelID)===r.channelID&&((a=o(this,Et))==null?void 0:a.channelName)===r.channelName)return;const i=((l=o(this,Et))==null?void 0:l.channelID)??null;if(d(this,Et,r),o(this,ur)==="single_session"){(!o(this,Nn)||i!==r.channelID)&&d(this,jr,!0);return}o(this,Nn)!==h(this,M,Ym).call(this,r.channelID)&&(d(this,Mn,null),d(this,Wr,null),o(this,ar)&&this.status==="ready"&&h(this,M,Fh).call(this).catch(c=>{h(this,M,wa).call(this,wm(c))}))}}Za=new WeakMap,or=new WeakMap,Qt=new WeakMap,ar=new WeakMap,Vi=new WeakMap,Mn=new WeakMap,Wr=new WeakMap,lr=new WeakMap,On=new WeakMap,Bi=new WeakMap,Nn=new WeakMap,Ua=new WeakMap,Fa=new WeakMap,cr=new WeakMap,Et=new WeakMap,jr=new WeakMap,qa=new WeakMap,uo=new WeakMap,Gr=new WeakMap,Wi=new WeakMap,su=new WeakMap,zn=new WeakMap,ur=new WeakMap,zd=new WeakMap,hr=new WeakMap,M=new WeakSet,Wm=async function(e){if(this.status!==e){if(this.status==="disposed")throw new Error("ACPClient has been disposed");if(this.status==="disconnected")throw new Error(o(this,or)??"ACPClient is disconnected");await new Promise((r,i)=>{const s=()=>{this.removeEventListener("status-changed",a)},a=()=>{if(this.status===e){s(),r();return}if(this.status==="disposed"){s(),i(new Error("ACPClient has been disposed"));return}this.status==="disconnected"&&(s(),i(new Error(o(this,or)??"ACPClient is disconnected")))};this.addEventListener("status-changed",a)})}},Y6=async function(){try{const{stream:e,socket:r,metadata:i}=await R5({serverURL:o(this,zn).serverURL,token:o(this,zn).token,createSocket:o(this,su),onDisconnect:o(this,zd)});d(this,On,i),d(this,hr,r),r.addEventListener("close",o(this,ou)),r.addEventListener("error",o(this,au)),d(this,ar,new h5(s=>({connection:s,sessionUpdate:async a=>{await h(this,M,Q6).call(this,a)},requestPermission:async a=>h(this,M,eS).call(this,a)}),e)),await o(this,ar).initialize({protocolVersion:GI,clientCapabilities:{},clientInfo:S5})}catch(e){throw e}},K6=function(e){h(this,M,wa).call(this,wm(e))},J6=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})`)},Fh=async function(){const e=h(this,M,Vh).call(this);if(o(this,Mn)&&o(this,Wr)===e){await o(this,Mn);return}d(this,Wr,e),d(this,Mn,h(this,M,X6).call(this,e)),await o(this,Mn)},X6=async function(e){var c;const r=h(this,M,qh).call(this);h(this,M,Jm).call(this);let i,s=!1,a=null;const l={cwd:h(this,M,oS).call(this),mcpServers:[],_meta:{sessionKey:e}};try{if(d(this,uo,!0),d(this,Gr,null),((c=o(this,On))==null?void 0:c.sessionIdStrategy)==="mapped"){const u=o(this,Bi).getActualSessionId(e);if(u)try{const p=await r.loadSession({...l,sessionId:u});if(k5(p))throw new Error("Mapped ACP session was not found");a=p,i=u,s=!0}catch{const p=await r.newSession(l);a=p,i=p.sessionId,o(this,Bi).setActualSessionId(e,i),s=!1}else{const p=await r.newSession(l);a=p,i=p.sessionId,o(this,Bi).setActualSessionId(e,i),s=!1}}else try{a=await r.loadSession({...l,sessionId:e}),i=e,s=o(this,Qt).size>0}catch{const u=await r.newSession(l);a=u,i=u.sessionId,s=!1}}finally{d(this,uo,!1),d(this,Gr,null),h(this,M,Vs).call(this,"final")}h(this,M,J6).call(this,a),await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),d(this,lr,i),d(this,Nn,e),d(this,qa,!0),s?(o(this,Wi).add(e),o(this,ur)==="single_session"&&d(this,jr,!1)):(o(this,Wi).delete(e),d(this,jr,o(this,ur)==="single_session")),d(this,or,null),h(this,M,Hr).call(this,"ready")},Q6=async function(e){const r=e.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&h(this,M,iS).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&h(this,M,tS).call(this,r.content.text);return;case"tool_call":h(this,M,nS).call(this,r);return;case"tool_call_update":h(this,M,rS).call(this,r);return;case"agent_thought_chunk":return;default:return}},eS=async function(e){return{outcome:{outcome:"cancelled"}}},tS=function(e){d(this,Gr,null);const r=C5(e);if(!r)return;if(!o(this,cr)){const s={id:h(this,M,ya).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};d(this,cr,s.id),h(this,M,ga).call(this,s);return}const i=o(this,Qt).get(o(this,cr));if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");h(this,M,va).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},nS=function(e){h(this,M,Vs).call(this,"final");const r=h(this,M,jm).call(this,e.toolCallId),i=I2("content"in e?e.content:void 0),s={id:(r==null?void 0:r.id)??h(this,M,ya).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:e.title,toolKind:e.kind??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??i,locations:e.locations??(r==null?void 0:r.locations)};if(r){h(this,M,va).call(this,s);return}h(this,M,ga).call(this,s)},rS=function(e){const r=h(this,M,jm).call(this,e.toolCallId),i=(r==null?void 0:r.text)??"",s=I2(e.content),a=s?`${i}${s}`:i,l={id:(r==null?void 0:r.id)??h(this,M,ya).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:(r==null?void 0:r.title)??e.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:a,locations:e.locations??(r==null?void 0:r.locations)};if(r){h(this,M,va).call(this,l);return}h(this,M,ga).call(this,l)},iS=function(e){if(h(this,M,Vs).call(this,"final"),!e)return;const r=o(this,uo)?o(this,Gr):null;if(!r){const s=R2(e);if(!s)return;const a={id:h(this,M,ya).call(this,"user"),kind:"user",text:s,status:"final"};h(this,M,ga).call(this,a),o(this,uo)&&d(this,Gr,a.id);return}const i=o(this,Qt).get(r);if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");h(this,M,va).call(this,{...i,text:R2(`${i.text}${e}`)})},Vs=function(e){if(!o(this,cr))return;const r=o(this,Qt).get(o(this,cr));(r==null?void 0:r.kind)==="assistant"&&h(this,M,va).call(this,{...r,status:e}),d(this,cr,null)},ga=function(e){o(this,Qt).set(e.id,e),this.dispatchEvent(new mm("messages-changed"))},va=function(e){o(this,Qt).set(e.id,e),this.dispatchEvent(new mm("messages-changed"))},Hr=function(e){o(this,Za)!==e&&(d(this,Za,e),this.dispatchEvent(new $k("status-changed")))},sS=function(e){var u;const r=o(this,Nn);if(!r)return e;const i=o(this,Et)?o(this,ur)==="single_session"?o(this,jr)||!o(this,Wi).has(r):!o(this,Wi).has(r):!1,s=o(this,qa)&&(o(this,Et)!==null||v5.test(e));if(!(s||i))return e;s&&d(this,qa,!1),i&&(d(this,jr,!1),o(this,Wi).add(r));const l=["[Television channel context]","This chat session is coming from a Television client.","Using Television requires the knowledge in the `television` skill. Re-read it only if it is not already in context or you know it changed.","If the skill is not installed, it can be installed via `tv skills install <your agent skills path>`."],c=((u=o(this,On))==null?void 0:u.tvArgs)??[];return c.length>0&&l.push(`To reach this Television server, add these arguments to each tv command that contacts it: ${c.map(x5).join(" ")}`),o(this,Et)?(l.push("This conversation is currently attached to the channel below."),l.push(`channel_id: ${o(this,Et).channelID}`),l.push(`channel_name: ${o(this,Et).channelName??""}`),l.push("When the user asks to inspect or change Television state with the tv CLI, use this channel ID with the --channel argument.")):l.push("There is currently no active Television channel."),l.push("[/Television channel context]","",e),l.join(`
|
|
43
|
-
`)},ya=function(e){const r=`${e}-${o(this,Fa)}`;return d(this,Fa,o(this,Fa)+1),r},jm=function(e){for(const r of o(this,Qt).values())if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===e)return r;return null},Gm=function(){if(!o(this,lr))throw new Error("ACP session is not ready");return o(this,lr)},qh=function(){if(!o(this,ar))throw new Error("ACP connection is not ready");return o(this,ar)},oS=function(){var r;const e=(r=o(this,On))==null?void 0:r.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},Vh=function(){var r;if(o(this,ur)==="single_session")return h(this,M,Km).call(this,`${G6}-${(o(this,zn).clientGUID??"default-client").toLowerCase()}`);const e=(r=o(this,Et))==null?void 0:r.channelID;if(!e)throw new Error("Channel context is required for per-channel session mode");return h(this,M,Ym).call(this,e)},Ym=function(e){return h(this,M,Km).call(this,T5(o(this,ur),e,o(this,zn).clientGUID??"default-client"))},Km=function(e){var r;return((r=o(this,On))==null?void 0:r.sessionIdStrategy)==="deterministic"&&o(this,Ua)>0?`${e}:epoch-${o(this,Ua)}`:e},ou=new WeakMap,au=new WeakMap,Bh=function(){d(this,ar,null),d(this,Vi,null),d(this,Mn,null),d(this,Wr,null),d(this,lr,null),d(this,Nn,null),d(this,On,null),o(this,hr)&&(o(this,hr).removeEventListener("close",o(this,ou)),o(this,hr).removeEventListener("error",o(this,au)),o(this,hr).close(),d(this,hr,null))},wa=function(e){const r=o(this,ar)!==null||o(this,Vi)!==null||o(this,Mn)!==null||o(this,Wr)!==null||o(this,lr)!==null||o(this,Nn)!==null||o(this,On)!==null||o(this,hr)!==null;this.disposed||this.status==="disconnected"&&!r||(h(this,M,Vs).call(this,"error"),h(this,M,Bh).call(this),d(this,or,e??null),h(this,M,Hr).call(this,"disconnected"))},Jm=function(){const e=o(this,Qt).size>0;d(this,cr,null),d(this,Gr,null),d(this,Fa,1),o(this,Qt).clear(),e&&this.dispatchEvent(new mm("messages-changed"))},aS=function(){return this.status==="disconnected"};function E5(){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 k5(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function T5(n,t,e){return n==="single_session"?`${G6}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function lS(n){return n.replace(/^(?:\s*\n)+/,"")}function R2(n){let t=n;return t=t.replace(f5,""),t=t.replace(m5,""),t=t.replace(g5,""),t=lS(t),t}function C5(n){let t=n;return t=t.replace(w5,""),t=lS(t),t}function I2(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function R5(n){const t=n.createSocket(D5(n.serverURL,n.token));let e=!1,r,i;const s=new Promise((u,p)=>{r=u,i=p}),a=new ReadableStream({start(u){let p=!1;const f=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},y=_=>{const I=P5(_);if(!I)return;let Z;try{Z=JSON.parse(I)}catch(L){const z=L instanceof Error?L:new Error(String(L));i(z),u.error(z);return}switch(Z.type){case"acp-bridge-status":if(Z.status==="ready"){let L;try{L=I5(Z)}catch(z){const P=z instanceof Error?z:new Error(String(z));e||i(P),u.error(P);return}e||(e=!0,r(L));return}if(Z.status==="error"||Z.status==="exited"){const L=new Error(Z.error??`ACP bridge ${Z.status}`);e||i(L),u.error(L)}return;case"acp-bridge-message":u.enqueue(Z.message);return}},v=()=>{var I;if(p)return;p=!0;const _=new Error("ACP bridge websocket closed");e||i(_),(I=n.onDisconnect)==null||I.call(n,_),u.close()},S=()=>{var I;if(p)return;p=!0;const _=new Error("ACP bridge websocket error");e||i(_),(I=n.onDisconnect)==null||I.call(n,_),u.error(_)};t.addEventListener("open",f),t.addEventListener("message",y),t.addEventListener("close",v),t.addEventListener("error",S)}}),l=new WritableStream({async write(u){await s,t.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){t.close()},abort(){t.close()}}),c=await s;return{stream:{readable:a,writable:l},socket:t,metadata:c}}function I5(n){const{agent:t,sessionIdStrategy:e,sessionCwd:r,tvArgs:i}=n;if((t==="openclaw"||t==="hermes")&&(e==="deterministic"||e==="mapped")&&typeof r=="string"&&r.length>0&&$5(i))return{agent:t,sessionIdStrategy:e,sessionCwd:r,tvArgs:i};throw new Error("ACP bridge ready status missing bootstrap metadata")}function $5(n){return Array.isArray(n)&&n.every(t=>typeof t=="string")}function x5(n){return y5.test(n)?n:`'${n.replace(/'/g,"'\\''")}'`}function P5(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 D5(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 wm(n){return n instanceof Error?n.message:String(n)}const $2="television.acpClientGUID",x2="television.acpMappedSessions",P2=1;var Va;class L5{constructor(){m(this,Va,new Map)}getActualSessionId(t){return o(this,Va).get(t)??null}setActualSessionId(t,e){o(this,Va).set(t,e)}clearActualSessionId(t){o(this,Va).delete(t)}}Va=new WeakMap;var Ba,lu,on,Wh,jh,Xm;class M5{constructor(t,e){m(this,on);m(this,Ba);m(this,lu);d(this,Ba,t),d(this,lu,e)}getActualSessionId(t){const e=h(this,on,jh).call(this)[h(this,on,Wh).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const r=h(this,on,jh).call(this);r[h(this,on,Wh).call(this,t)]=e,h(this,on,Xm).call(this,r)}clearActualSessionId(t){const e=h(this,on,jh).call(this);delete e[h(this,on,Wh).call(this,t)],h(this,on,Xm).call(this,e)}}Ba=new WeakMap,lu=new WeakMap,on=new WeakSet,Wh=function(t){return JSON.stringify([o(this,lu),t])},jh=function(){const t=o(this,Ba).getItem(x2);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!==P2?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},Xm=function(t){const e={version:P2,entries:t};o(this,Ba).setItem(x2,JSON.stringify(e))};function cS(){return typeof window>"u"?null:window.localStorage}function O5(n){const t=n.getItem($2);if(t)return t;const e=N1().toLowerCase();return n.setItem($2,e),e}const D2=4401,N5=401,$h=1e3,z5=3e4;class Gh extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class H5 extends Ei{constructor(e){var a,l;super();$(this,"url");$(this,"name");$(this,"telemetryMeta");$(this,"status","unauthorized");$(this,"channels",new Map);$(this,"client");$(this,"acpClient");$(this,"_token");$(this,"attempting",!1);$(this,"nextRetryAt",null);$(this,"hasEverConnected",!1);$(this,"failedReconnectAttempts",0);$(this,"browserDemoMode",!1);$(this,"hasAuthRejected",!1);$(this,"bootState","pending");$(this,"serverVersion",null);$(this,"updateState",null);$(this,"decideBoot");$(this,"navigationPending");$(this,"createSocket");$(this,"createClient");$(this,"socket",null);$(this,"connectAttempt",0);$(this,"autoReconnect",!1);$(this,"retryTimer",null);$(this,"retryDelay",$h);$(this,"visibilityEventTarget");$(this,"networkEventTarget");$(this,"onVisibilityChange");$(this,"onNetworkOnline");$(this,"telemetryActivityAgent");this.url=Es(e.url),this.name=e.name,this.decideBoot=e.decideBoot??null,this.navigationPending=e.navigationPending??(()=>!1),this._token=e.token??null,this.telemetryMeta=e.telemetryMeta??null,this.createSocket=e.createSocket??(c=>new WebSocket(c)),this.createClient=e.createClient??((c,u,p)=>new rk(c,{token:u??void 0,onUnauthorized:()=>this.handleAuthRejected(),...p?{telemetryMeta:p}:{}})),this.client=this.createClient(this.url,this._token,this.telemetryMeta);const r=e.mappedSessionStore??(e.acpStorage?new M5(e.acpStorage,this.url):new L5);this.acpClient=new A5({serverURL:this.url,token:this._token??"",...e.createACPSocket?{createSocket:e.createACPSocket}:e.createSocket?{createSocket:e.createSocket}:{},...e.clientGUID?{clientGUID:e.clientGUID}:{},mappedSessionStore:r}),this.visibilityEventTarget=e.visibilityEventTarget!==void 0?e.visibilityEventTarget:typeof document<"u"?document:null,this.networkEventTarget=e.networkEventTarget!==void 0?e.networkEventTarget:typeof window<"u"?window:null,this.onVisibilityChange=()=>{this.isPageVisible()&&this.kickReconnect()},this.onNetworkOnline=()=>{this.kickReconnect()},(a=this.visibilityEventTarget)==null||a.addEventListener("visibilitychange",this.onVisibilityChange),(l=this.networkEventTarget)==null||l.addEventListener("online",this.onNetworkOnline);const i=e.telemetryDocumentTarget!==void 0?e.telemetryDocumentTarget:typeof document<"u"?document:null,s=e.telemetryWindowTarget!==void 0?e.telemetryWindowTarget:typeof window<"u"?window:null;this.telemetryActivityAgent=this.telemetryMeta&&i&&s?BI({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=$h,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=Ad(e,this.renderOptions());return gi()?new URL(r.viewURL,this.url).toString():r.renderer==="proxy-iframe"?new URL(r.viewURL,this.url).toString():r.viewURL}async readDemoMode(){try{return await this.client.demoMode()}catch{return null}}renderOptions(){return{electron:gi(),browserDemo:this.browserDemoMode}}getContentURL(e){const r=Ad(e,this.renderOptions()).contentURL;return r===null?null:new URL(r,this.url).toString()}async createChannel(e){const{channel:r}=await this.client.channels.create({name:e});return this.channels.set(r.id,structuredClone(r)),r}applyServerEvent(e){switch(e.type){case"channel-created":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new wc("channels-changed"));break;case"channel-updated":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new wc("channels-changed"));break;case"channel-removed":this.channels.delete(e.channelID),this.dispatchEvent(new wc("channels-changed"));break;case"artifact-created":{const r=this.channels.get(e.channelID);r&&!ZE(r).includes(e.artifact.id)&&(r.layout=[...r.layout,{artifactIds:[e.artifact.id],geometry:{...d8},size:{...p8}}]);break}case"artifact-removed":{const r=this.channels.get(e.channelID);r&&(r.layout=Dm(r.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"channel-changed":case"pinned-channels-changed":case"theme-changed":case"appearance-changed":case"artifact-focus":break;default:return Z5(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 Bt("change"));const r=this.createSocket(U5(this.url,this._token,this.telemetryMeta));return this.socket=r,await new Promise((s,a)=>{let l=!1,c=!1;const u=()=>{var y;l||this.connectAttempt!==e||(l=!0,c=!0,this.retryDelay=$h,this.hasEverConnected=!0,this.failedReconnectAttempts=0,this.setStatus("connected"),(y=this.telemetryActivityAgent)==null||y.start(),s())},p=y=>{l||this.connectAttempt!==e||(l=!0,a(y))},f=async()=>{const y=this.hasEverConnected;try{const[{channels:v},S,_]=await Promise.all([this.client.channels.list(),this.client.display.get(),y?null:this.readDemoMode()]);y||(this.browserDemoMode=(_==null?void 0:_.browserExternalPages)===!0),this.channels=new Map(v.map(I=>[I.id,structuredClone(I)])),this.acpClient.setEnabled(S.acpEnabled),this.dispatchEvent(new Bt("change")),y&&this.dispatchEvent(new wc("channels-changed")),this.dispatchEvent(new Zh("server-event",{serverURL:this.url,event:{type:"channel-changed",channelID:S.focusedChannelId}})),this.dispatchEvent(new Zh("server-event",{serverURL:this.url,event:{type:"pinned-channels-changed",pinnedChannelIds:[...S.pinnedChannelIds]}})),u(),y&&this.connectAttempt===e&&this.dispatchEvent(new E8("server-reconnected",{serverURL:this.url}))}catch(v){if(j5(v)){p(new Gh);return}p(v instanceof Error?v:new Error(String(v)))}};r.addEventListener("open",()=>{this.decideBoot===null&&(this.bootState="booted",this.navigationPending()||f())}),r.addEventListener("message",y=>{const v=W5(y);if(!v)return;if(v.type==="server-status"){const _=v;this.serverVersion=_.version,this.updateState=_.update??null;let I=!1;this.decideBoot!==null&&this.bootState==="pending"&&this.connectAttempt===e&&(this.decideBoot(_)==="boot"?(this.bootState="booted",I=!0):(this.bootState="halted",this.attempting=!1)),this.dispatchEvent(new k8("server-status",{serverURL:this.url,message:_})),I?this.navigationPending()||f():this.bootState==="halted"&&!this.navigationPending()&&this.dispatchEvent(new Bt("change"));return}if(!B5(v.type))return;const S=v;this.applyServerEvent(S),this.dispatchEvent(new Zh("server-event",{serverURL:this.url,event:S}))}),r.addEventListener("close",y=>{if(this.connectAttempt!==e)return;this.socket=null;const v=F5(y);if(!l){p(v===D2?new Gh:new Error("Connection closed before initialization"));return}if(c){if(v===D2){this.handleAuthRejected();return}this.handleTransportFailure(new Error("Connection closed"))}}),r.addEventListener("error",()=>{if(this.connectAttempt===e){if(l){if(!c)return;this.handleTransportFailure(new Error("WebSocket error"));return}p(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 Gh){this.handleAuthRejected();return}this.autoReconnect&&(this.hasEverConnected&&(this.failedReconnectAttempts+=1),this.scheduleRetry())}handleTransportFailure(e){this.autoReconnect&&(this.setStatus("disconnected"),this.scheduleRetry())}scheduleRetry(){this.cancelRetryTimer(),this.connectAttempt+=1;const e=this.retryDelay;this.retryDelay=Math.min(this.retryDelay*2,z5),this.nextRetryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},e),this.dispatchEvent(new Bt("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new Bt("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=$h,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:HE,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 Bt("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function Z5(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function U5(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 VI(e))r.searchParams.set(i,s);return r.hash="",r.toString()}function F5(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}const q5={"artifact-created":!0,"artifact-updated":!0,"artifact-content-changed":!0,"artifact-removed":!0,"channel-created":!0,"channel-updated":!0,"channel-removed":!0,"channel-changed":!0,"pinned-channels-changed":!0,"theme-changed":!0,"appearance-changed":!0,"artifact-focus":!0},V5=new Set(Object.keys(q5));function B5(n){return V5.has(n)}function W5(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 j5(n){return n instanceof Bl&&n.status===N5}const G5="Local";var dr,Hn,bi,uS,Qm,hS,cu,uu,hu,du,pu;class Y5 extends Ei{constructor(e){super();m(this,bi);$(this,"connection");$(this,"clientGUID");$(this,"acpStorage");$(this,"connectError",null);m(this,dr);m(this,Hn,!1);m(this,cu,()=>{o(this,Hn)||(h(this,bi,hS).call(this),this.dispatchEvent(new Bt("change")))});m(this,uu,e=>{o(this,Hn)||this.dispatchEvent(new Zh("server-event",{serverURL:e.serverURL,event:e.event}))});m(this,hu,()=>{o(this,Hn)||this.dispatchEvent(new wc("channels-changed"))});m(this,du,e=>{o(this,Hn)||this.dispatchEvent(new E8("server-reconnected",{serverURL:e.serverURL}))});m(this,pu,e=>{o(this,Hn)||this.dispatchEvent(new k8("server-status",{serverURL:e.serverURL,message:e.message}))});d(this,dr,e.localStore),this.acpStorage=e.acpStorage===void 0?cS():e.acpStorage,this.clientGUID=e.clientGUID??(this.acpStorage?O5(this.acpStorage):N1().toLowerCase());const r=Es(e.serverURL);e.launchToken!==void 0&&e.launchToken!==null&&o(this,dr).set(Lk(o(this,dr).get(),r,e.launchToken));const i=e.launchToken??e2(o(this,dr).get(),r),s=e.createSocket??(l=>new WebSocket(l)),a=e.createConnection??(l=>new H5(l));this.connection=a({url:r,name:e.connectionName??G5,token:i,createSocket:s,clientGUID:this.clientGUID,acpStorage:this.acpStorage,telemetryMeta:e.telemetryMeta??null,decideBoot:e.decideBoot,navigationPending:e.navigationPending}),this.connection.addEventListener("change",o(this,cu)),this.connection.addEventListener("server-event",o(this,uu)),this.connection.addEventListener("channels-changed",o(this,hu)),this.connection.addEventListener("server-reconnected",o(this,du)),this.connection.addEventListener("server-status",o(this,pu))}get storedAuthToken(){return e2(o(this,dr).get(),this.connection.url)}async connect(){await h(this,bi,uS).call(this,this.connection.token)}dispose(){o(this,Hn)||(d(this,Hn,!0),this.connection.removeEventListener("change",o(this,cu)),this.connection.removeEventListener("server-event",o(this,uu)),this.connection.removeEventListener("channels-changed",o(this,hu)),this.connection.removeEventListener("server-reconnected",o(this,du)),this.connection.removeEventListener("server-status",o(this,pu)),this.connection.dispose())}}dr=new WeakMap,Hn=new WeakMap,bi=new WeakSet,uS=async function(e){if(!o(this,Hn)){h(this,bi,Qm).call(this,null);try{await this.connection.connect(e)}catch(r){h(this,bi,Qm).call(this,r instanceof Gh?null:r instanceof Error?r.message:String(r))}}},Qm=function(e){this.connectError!==e&&(this.connectError=e,this.dispatchEvent(new Bt("change")))},hS=function(){if(this.connection.status!=="unauthorized"||!this.connection.hasAuthRejected)return;const e=o(this,dr).get(),r=Mk(e,this.connection.url);r!==e&&o(this,dr).set(r),this.connection.token!==null&&this.connection.clearToken()},cu=new WeakMap,uu=new WeakMap,hu=new WeakMap,du=new WeakMap,pu=new WeakMap;const eg="tv-nav:",Ol="tv-reload",L2=100,K5=1e3,J5=60,X5=60,Q5=24,eD=30,tD=eD*Q5*X5*J5*K5;function vi(n){try{const t=new URL(n,window.location.href),e=t.searchParams.has(Ol);return t.searchParams.delete(Ol),t.origin===window.location.origin?`${t.pathname}${t.search}${t.hash}`:e?t.toString():n}catch{return n}}var fu,Wa,$e,Ce,ho,Je,dS,Li,pS,tg,ng;class nD extends Ei{constructor(e,r){super();m(this,Je);m(this,fu);m(this,Wa);m(this,$e,[]);m(this,Ce,-1);m(this,ho,0);d(this,fu,e),d(this,Wa,vi(r)),h(this,Je,dS).call(this)}get currentURL(){var e;return o(this,Ce)===-1?null:((e=o(this,$e)[o(this,Ce)])==null?void 0:e.url)??null}get canGoBack(){return o(this,Ce)>-1}get canGoForward(){return o(this,Ce)<o(this,$e).length-1}get entries(){return o(this,$e).map(e=>({...e}))}get cursor(){return o(this,Ce)}navigate(e){const r=vi(e);if(r===o(this,Wa)){if(o(this,Ce)===-1)return;d(this,Ce,-1),h(this,Je,Li).call(this);return}o(this,Ce)<o(this,$e).length-1&&d(this,$e,o(this,$e).slice(0,o(this,Ce)+1)),o(this,$e).push({url:r}),d(this,Ce,o(this,$e).length-1),h(this,Je,tg).call(this),h(this,Je,Li).call(this)}replace(e){var i;if(o(this,Ce)===-1){this.navigate(e);return}const r=vi(e);if(r===o(this,Wa)){d(this,$e,o(this,$e).filter((s,a)=>a!==o(this,Ce))),d(this,Ce,-1),h(this,Je,Li).call(this);return}((i=o(this,$e)[o(this,Ce)])==null?void 0:i.url)!==r&&(d(this,$e,o(this,$e).map((s,a)=>a===o(this,Ce)?{url:r}:s)),h(this,Je,Li).call(this))}back(){o(this,Ce)!==-1&&(d(this,Ce,o(this,Ce)-1),h(this,Je,Li).call(this))}forward(){this.canGoForward&&(d(this,Ce,o(this,Ce)+1),h(this,Je,Li).call(this))}reset(){o(this,Ce)===-1&&o(this,$e).length===0||(d(this,$e,[]),d(this,Ce,-1),h(this,Je,Li).call(this))}}fu=new WeakMap,Wa=new WeakMap,$e=new WeakMap,Ce=new WeakMap,ho=new WeakMap,Je=new WeakSet,dS=function(){const e=localStorage.getItem(o(this,Je,ng));if(e!==null)try{const r=JSON.parse(e);if(!fS(r))return;d(this,$e,r.entries.map(i=>({url:i.url}))),d(this,Ce,r.cursor),d(this,ho,r.lastWritten),h(this,Je,tg).call(this)}catch{d(this,$e,[]),d(this,Ce,-1),d(this,ho,0)}},Li=function(){d(this,ho,Date.now());try{localStorage.setItem(o(this,Je,ng),JSON.stringify(h(this,Je,pS).call(this)))}catch(e){if(!sD(e))throw e}this.dispatchEvent(new Bt("change"))},pS=function(){return{v:1,entries:o(this,$e).map(e=>({...e})),cursor:o(this,Ce),lastWritten:o(this,ho)}},tg=function(){if(o(this,$e).length<=L2)return;const e=o(this,$e).length-L2;d(this,$e,o(this,$e).slice(e)),d(this,Ce,Math.max(-1,o(this,Ce)-e))},ng=function(){return rD(o(this,fu))};function rD(n){return`${eg}${n}`}function iD(n){const t=Date.now()-tD,e=[];for(let r=0;r<localStorage.length;r+=1){const i=localStorage.key(r);if(!(i!=null&&i.startsWith(eg)))continue;const s=i.slice(eg.length),a=localStorage.getItem(i);if(a===null)continue;let l;try{l=JSON.parse(a)}catch{e.push(i);continue}if(!fS(l)){e.push(i);continue}!n.has(s)&&l.lastWritten<t&&e.push(i)}for(const r of e)localStorage.removeItem(r)}function sD(n){return n instanceof DOMException&&n.name==="QuotaExceededError"}function fS(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 bm="tv-channel-sidebar-collapsed";var po;class oD{constructor(t){m(this,po);d(this,po,t)}read(){return o(this,po).getItem(bm)==="true"}setCollapsed(t){try{t?o(this,po).setItem(bm,"true"):o(this,po).removeItem(bm)}catch{}}}po=new WeakMap;const Sm="tv-channel-sidebar-width",rg=160,ig=350,xh=260,aD=/^-?\d+$/;var fo;class lD{constructor(t){m(this,fo);d(this,fo,t)}read(){const t=o(this,fo).getItem(Sm);if(t===null||!aD.test(t))return null;const e=BigInt(t);return e<BigInt(rg)?rg:e>BigInt(ig)?ig:Number(e)}commit(t){const e=mS(Math.round(t));try{o(this,fo).setItem(Sm,String(e))}catch{}return e}clear(){try{o(this,fo).removeItem(Sm)}catch{}}}fo=new WeakMap;function mS(n){return Math.min(Math.max(n,rg),ig)}const cD="1.4.20";function j1(n=cD){return n!==void 0&&n.length>0?n:"0.0.0"}function G1(){let n=!1;return{get pending(){return n},begin(t){n||(n=!0,t())}}}const sg="tv-reload-attempted";function uD(n){return n.originMatch?n.marker!==null&&n.bundleVersion===n.serverVersion?{action:"signal-autoreloaded",fromVersion:n.marker.fromVersion,toVersion:n.bundleVersion}:ok(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 hD(n){const t=n.getItem(sg);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 dD(n){const t=n.storage!==void 0?n.storage:typeof sessionStorage<"u"?sessionStorage:null,e=n.reload??(()=>location.reload()),r=n.navigationLatch??G1(),i=n.bundleVersion??j1();if(t===null)return{dispose(){}};let s=null;const a=()=>{if(s===null)return;const u=n.owner.connection;if(u.url!==n.primaryServerURL||u.status!=="connected")return;const p=s;s=null,u.sendTelemetrySignal("client_autoreloaded",{from_version:p.fromVersion,to_version:p.toVersion})},l=u=>{if(r.pending)return;const p=uD({bundleVersion:i,serverVersion:u.message.version,originMatch:u.serverURL===n.primaryServerURL,marker:hD(t)});switch(p.action){case"reload":t.setItem(sg,JSON.stringify(p.marker)),r.begin(e);return;case"signal-autoreloaded":t.removeItem(sg),s={fromVersion:p.fromVersion,toVersion:p.toVersion},a();return;case"none":return}},c=()=>{a()};return n.owner.addEventListener("server-status",l),n.owner.addEventListener("change",c),{dispose(){n.owner.removeEventListener("server-status",l),n.owner.removeEventListener("change",c)}}}function pD(n){const t=gi(n.search),e=h6(n.search),r=e!==null&&$p(e)?e:null;return{electron:t,shellVersion:r}}function fD(n){return!n.electron||n.requiredDesktopVersion===null||!$p(n.requiredDesktopVersion)?!1:n.shellVersion===null?!0:n.shellVersion===vd?!1:O1(n.requiredDesktopVersion,n.shellVersion)}const mD=`# Desktop app update required
|
|
43
|
+
`)},ya=function(e){const r=`${e}-${o(this,Fa)}`;return d(this,Fa,o(this,Fa)+1),r},jm=function(e){for(const r of o(this,Qt).values())if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===e)return r;return null},Gm=function(){if(!o(this,lr))throw new Error("ACP session is not ready");return o(this,lr)},qh=function(){if(!o(this,ar))throw new Error("ACP connection is not ready");return o(this,ar)},oS=function(){var r;const e=(r=o(this,On))==null?void 0:r.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},Vh=function(){var r;if(o(this,ur)==="single_session")return h(this,M,Km).call(this,`${G6}-${(o(this,zn).clientGUID??"default-client").toLowerCase()}`);const e=(r=o(this,Et))==null?void 0:r.channelID;if(!e)throw new Error("Channel context is required for per-channel session mode");return h(this,M,Ym).call(this,e)},Ym=function(e){return h(this,M,Km).call(this,T5(o(this,ur),e,o(this,zn).clientGUID??"default-client"))},Km=function(e){var r;return((r=o(this,On))==null?void 0:r.sessionIdStrategy)==="deterministic"&&o(this,Ua)>0?`${e}:epoch-${o(this,Ua)}`:e},ou=new WeakMap,au=new WeakMap,Bh=function(){d(this,ar,null),d(this,Vi,null),d(this,Mn,null),d(this,Wr,null),d(this,lr,null),d(this,Nn,null),d(this,On,null),o(this,hr)&&(o(this,hr).removeEventListener("close",o(this,ou)),o(this,hr).removeEventListener("error",o(this,au)),o(this,hr).close(),d(this,hr,null))},wa=function(e){const r=o(this,ar)!==null||o(this,Vi)!==null||o(this,Mn)!==null||o(this,Wr)!==null||o(this,lr)!==null||o(this,Nn)!==null||o(this,On)!==null||o(this,hr)!==null;this.disposed||this.status==="disconnected"&&!r||(h(this,M,Vs).call(this,"error"),h(this,M,Bh).call(this),d(this,or,e??null),h(this,M,Hr).call(this,"disconnected"))},Jm=function(){const e=o(this,Qt).size>0;d(this,cr,null),d(this,Gr,null),d(this,Fa,1),o(this,Qt).clear(),e&&this.dispatchEvent(new mm("messages-changed"))},aS=function(){return this.status==="disconnected"};function E5(){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 k5(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function T5(n,t,e){return n==="single_session"?`${G6}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function lS(n){return n.replace(/^(?:\s*\n)+/,"")}function R2(n){let t=n;return t=t.replace(f5,""),t=t.replace(m5,""),t=t.replace(g5,""),t=lS(t),t}function C5(n){let t=n;return t=t.replace(w5,""),t=lS(t),t}function I2(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function R5(n){const t=n.createSocket(D5(n.serverURL,n.token));let e=!1,r,i;const s=new Promise((u,p)=>{r=u,i=p}),a=new ReadableStream({start(u){let p=!1;const f=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},y=_=>{const I=P5(_);if(!I)return;let Z;try{Z=JSON.parse(I)}catch(L){const z=L instanceof Error?L:new Error(String(L));i(z),u.error(z);return}switch(Z.type){case"acp-bridge-status":if(Z.status==="ready"){let L;try{L=I5(Z)}catch(z){const P=z instanceof Error?z:new Error(String(z));e||i(P),u.error(P);return}e||(e=!0,r(L));return}if(Z.status==="error"||Z.status==="exited"){const L=new Error(Z.error??`ACP bridge ${Z.status}`);e||i(L),u.error(L)}return;case"acp-bridge-message":u.enqueue(Z.message);return}},v=()=>{var I;if(p)return;p=!0;const _=new Error("ACP bridge websocket closed");e||i(_),(I=n.onDisconnect)==null||I.call(n,_),u.close()},S=()=>{var I;if(p)return;p=!0;const _=new Error("ACP bridge websocket error");e||i(_),(I=n.onDisconnect)==null||I.call(n,_),u.error(_)};t.addEventListener("open",f),t.addEventListener("message",y),t.addEventListener("close",v),t.addEventListener("error",S)}}),l=new WritableStream({async write(u){await s,t.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){t.close()},abort(){t.close()}}),c=await s;return{stream:{readable:a,writable:l},socket:t,metadata:c}}function I5(n){const{agent:t,sessionIdStrategy:e,sessionCwd:r,tvArgs:i}=n;if((t==="openclaw"||t==="hermes")&&(e==="deterministic"||e==="mapped")&&typeof r=="string"&&r.length>0&&$5(i))return{agent:t,sessionIdStrategy:e,sessionCwd:r,tvArgs:i};throw new Error("ACP bridge ready status missing bootstrap metadata")}function $5(n){return Array.isArray(n)&&n.every(t=>typeof t=="string")}function x5(n){return y5.test(n)?n:`'${n.replace(/'/g,"'\\''")}'`}function P5(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 D5(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 wm(n){return n instanceof Error?n.message:String(n)}const $2="television.acpClientGUID",x2="television.acpMappedSessions",P2=1;var Va;class L5{constructor(){m(this,Va,new Map)}getActualSessionId(t){return o(this,Va).get(t)??null}setActualSessionId(t,e){o(this,Va).set(t,e)}clearActualSessionId(t){o(this,Va).delete(t)}}Va=new WeakMap;var Ba,lu,on,Wh,jh,Xm;class M5{constructor(t,e){m(this,on);m(this,Ba);m(this,lu);d(this,Ba,t),d(this,lu,e)}getActualSessionId(t){const e=h(this,on,jh).call(this)[h(this,on,Wh).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const r=h(this,on,jh).call(this);r[h(this,on,Wh).call(this,t)]=e,h(this,on,Xm).call(this,r)}clearActualSessionId(t){const e=h(this,on,jh).call(this);delete e[h(this,on,Wh).call(this,t)],h(this,on,Xm).call(this,e)}}Ba=new WeakMap,lu=new WeakMap,on=new WeakSet,Wh=function(t){return JSON.stringify([o(this,lu),t])},jh=function(){const t=o(this,Ba).getItem(x2);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!==P2?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},Xm=function(t){const e={version:P2,entries:t};o(this,Ba).setItem(x2,JSON.stringify(e))};function cS(){return typeof window>"u"?null:window.localStorage}function O5(n){const t=n.getItem($2);if(t)return t;const e=N1().toLowerCase();return n.setItem($2,e),e}const D2=4401,N5=401,$h=1e3,z5=3e4;class Gh extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class H5 extends Ei{constructor(e){var a,l;super();$(this,"url");$(this,"name");$(this,"telemetryMeta");$(this,"status","unauthorized");$(this,"channels",new Map);$(this,"client");$(this,"acpClient");$(this,"_token");$(this,"attempting",!1);$(this,"nextRetryAt",null);$(this,"hasEverConnected",!1);$(this,"failedReconnectAttempts",0);$(this,"browserDemoMode",!1);$(this,"hasAuthRejected",!1);$(this,"bootState","pending");$(this,"serverVersion",null);$(this,"updateState",null);$(this,"decideBoot");$(this,"navigationPending");$(this,"createSocket");$(this,"createClient");$(this,"socket",null);$(this,"connectAttempt",0);$(this,"autoReconnect",!1);$(this,"retryTimer",null);$(this,"retryDelay",$h);$(this,"visibilityEventTarget");$(this,"networkEventTarget");$(this,"onVisibilityChange");$(this,"onNetworkOnline");$(this,"telemetryActivityAgent");this.url=Es(e.url),this.name=e.name,this.decideBoot=e.decideBoot??null,this.navigationPending=e.navigationPending??(()=>!1),this._token=e.token??null,this.telemetryMeta=e.telemetryMeta??null,this.createSocket=e.createSocket??(c=>new WebSocket(c)),this.createClient=e.createClient??((c,u,p)=>new rk(c,{token:u??void 0,onUnauthorized:()=>this.handleAuthRejected(),...p?{telemetryMeta:p}:{}})),this.client=this.createClient(this.url,this._token,this.telemetryMeta);const r=e.mappedSessionStore??(e.acpStorage?new M5(e.acpStorage,this.url):new L5);this.acpClient=new A5({serverURL:this.url,token:this._token??"",...e.createACPSocket?{createSocket:e.createACPSocket}:e.createSocket?{createSocket:e.createSocket}:{},...e.clientGUID?{clientGUID:e.clientGUID}:{},mappedSessionStore:r}),this.visibilityEventTarget=e.visibilityEventTarget!==void 0?e.visibilityEventTarget:typeof document<"u"?document:null,this.networkEventTarget=e.networkEventTarget!==void 0?e.networkEventTarget:typeof window<"u"?window:null,this.onVisibilityChange=()=>{this.isPageVisible()&&this.kickReconnect()},this.onNetworkOnline=()=>{this.kickReconnect()},(a=this.visibilityEventTarget)==null||a.addEventListener("visibilitychange",this.onVisibilityChange),(l=this.networkEventTarget)==null||l.addEventListener("online",this.onNetworkOnline);const i=e.telemetryDocumentTarget!==void 0?e.telemetryDocumentTarget:typeof document<"u"?document:null,s=e.telemetryWindowTarget!==void 0?e.telemetryWindowTarget:typeof window<"u"?window:null;this.telemetryActivityAgent=this.telemetryMeta&&i&&s?BI({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=$h,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=Ad(e,this.renderOptions());return gi()?new URL(r.viewURL,this.url).toString():r.renderer==="proxy-iframe"?new URL(r.viewURL,this.url).toString():r.viewURL}async readDemoMode(){try{return await this.client.demoMode()}catch{return null}}renderOptions(){return{electron:gi(),browserDemo:this.browserDemoMode}}getContentURL(e){const r=Ad(e,this.renderOptions()).contentURL;return r===null?null:new URL(r,this.url).toString()}async createChannel(e){const{channel:r}=await this.client.channels.create({name:e});return this.channels.set(r.id,structuredClone(r)),r}applyServerEvent(e){switch(e.type){case"channel-created":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new wc("channels-changed"));break;case"channel-updated":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new wc("channels-changed"));break;case"channel-removed":this.channels.delete(e.channelID),this.dispatchEvent(new wc("channels-changed"));break;case"artifact-created":{const r=this.channels.get(e.channelID);r&&!ZE(r).includes(e.artifact.id)&&(r.layout=[...r.layout,{artifactIds:[e.artifact.id],geometry:{...d8},size:{...p8}}]);break}case"artifact-removed":{const r=this.channels.get(e.channelID);r&&(r.layout=Dm(r.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"channel-changed":case"pinned-channels-changed":case"theme-changed":case"appearance-changed":case"artifact-focus":break;default:return Z5(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 Bt("change"));const r=this.createSocket(U5(this.url,this._token,this.telemetryMeta));return this.socket=r,await new Promise((s,a)=>{let l=!1,c=!1;const u=()=>{var y;l||this.connectAttempt!==e||(l=!0,c=!0,this.retryDelay=$h,this.hasEverConnected=!0,this.failedReconnectAttempts=0,this.setStatus("connected"),(y=this.telemetryActivityAgent)==null||y.start(),s())},p=y=>{l||this.connectAttempt!==e||(l=!0,a(y))},f=async()=>{const y=this.hasEverConnected;try{const[{channels:v},S,_]=await Promise.all([this.client.channels.list(),this.client.display.get(),y?null:this.readDemoMode()]);y||(this.browserDemoMode=(_==null?void 0:_.browserExternalPages)===!0),this.channels=new Map(v.map(I=>[I.id,structuredClone(I)])),this.acpClient.setEnabled(S.acpEnabled),this.dispatchEvent(new Bt("change")),y&&this.dispatchEvent(new wc("channels-changed")),this.dispatchEvent(new Zh("server-event",{serverURL:this.url,event:{type:"channel-changed",channelID:S.focusedChannelId}})),this.dispatchEvent(new Zh("server-event",{serverURL:this.url,event:{type:"pinned-channels-changed",pinnedChannelIds:[...S.pinnedChannelIds]}})),u(),y&&this.connectAttempt===e&&this.dispatchEvent(new E8("server-reconnected",{serverURL:this.url}))}catch(v){if(j5(v)){p(new Gh);return}p(v instanceof Error?v:new Error(String(v)))}};r.addEventListener("open",()=>{this.decideBoot===null&&(this.bootState="booted",this.navigationPending()||f())}),r.addEventListener("message",y=>{const v=W5(y);if(!v)return;if(v.type==="server-status"){const _=v;this.serverVersion=_.version,this.updateState=_.update??null;let I=!1;this.decideBoot!==null&&this.bootState==="pending"&&this.connectAttempt===e&&(this.decideBoot(_)==="boot"?(this.bootState="booted",I=!0):(this.bootState="halted",this.attempting=!1)),this.dispatchEvent(new k8("server-status",{serverURL:this.url,message:_})),I?this.navigationPending()||f():this.bootState==="halted"&&!this.navigationPending()&&this.dispatchEvent(new Bt("change"));return}if(!B5(v.type))return;const S=v;this.applyServerEvent(S),this.dispatchEvent(new Zh("server-event",{serverURL:this.url,event:S}))}),r.addEventListener("close",y=>{if(this.connectAttempt!==e)return;this.socket=null;const v=F5(y);if(!l){p(v===D2?new Gh:new Error("Connection closed before initialization"));return}if(c){if(v===D2){this.handleAuthRejected();return}this.handleTransportFailure(new Error("Connection closed"))}}),r.addEventListener("error",()=>{if(this.connectAttempt===e){if(l){if(!c)return;this.handleTransportFailure(new Error("WebSocket error"));return}p(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 Gh){this.handleAuthRejected();return}this.autoReconnect&&(this.hasEverConnected&&(this.failedReconnectAttempts+=1),this.scheduleRetry())}handleTransportFailure(e){this.autoReconnect&&(this.setStatus("disconnected"),this.scheduleRetry())}scheduleRetry(){this.cancelRetryTimer(),this.connectAttempt+=1;const e=this.retryDelay;this.retryDelay=Math.min(this.retryDelay*2,z5),this.nextRetryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},e),this.dispatchEvent(new Bt("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new Bt("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=$h,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:HE,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 Bt("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function Z5(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function U5(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 VI(e))r.searchParams.set(i,s);return r.hash="",r.toString()}function F5(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}const q5={"artifact-created":!0,"artifact-updated":!0,"artifact-content-changed":!0,"artifact-removed":!0,"channel-created":!0,"channel-updated":!0,"channel-removed":!0,"channel-changed":!0,"pinned-channels-changed":!0,"theme-changed":!0,"appearance-changed":!0,"artifact-focus":!0},V5=new Set(Object.keys(q5));function B5(n){return V5.has(n)}function W5(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 j5(n){return n instanceof Bl&&n.status===N5}const G5="Local";var dr,Hn,bi,uS,Qm,hS,cu,uu,hu,du,pu;class Y5 extends Ei{constructor(e){super();m(this,bi);$(this,"connection");$(this,"clientGUID");$(this,"acpStorage");$(this,"connectError",null);m(this,dr);m(this,Hn,!1);m(this,cu,()=>{o(this,Hn)||(h(this,bi,hS).call(this),this.dispatchEvent(new Bt("change")))});m(this,uu,e=>{o(this,Hn)||this.dispatchEvent(new Zh("server-event",{serverURL:e.serverURL,event:e.event}))});m(this,hu,()=>{o(this,Hn)||this.dispatchEvent(new wc("channels-changed"))});m(this,du,e=>{o(this,Hn)||this.dispatchEvent(new E8("server-reconnected",{serverURL:e.serverURL}))});m(this,pu,e=>{o(this,Hn)||this.dispatchEvent(new k8("server-status",{serverURL:e.serverURL,message:e.message}))});d(this,dr,e.localStore),this.acpStorage=e.acpStorage===void 0?cS():e.acpStorage,this.clientGUID=e.clientGUID??(this.acpStorage?O5(this.acpStorage):N1().toLowerCase());const r=Es(e.serverURL);e.launchToken!==void 0&&e.launchToken!==null&&o(this,dr).set(Lk(o(this,dr).get(),r,e.launchToken));const i=e.launchToken??e2(o(this,dr).get(),r),s=e.createSocket??(l=>new WebSocket(l)),a=e.createConnection??(l=>new H5(l));this.connection=a({url:r,name:e.connectionName??G5,token:i,createSocket:s,clientGUID:this.clientGUID,acpStorage:this.acpStorage,telemetryMeta:e.telemetryMeta??null,decideBoot:e.decideBoot,navigationPending:e.navigationPending}),this.connection.addEventListener("change",o(this,cu)),this.connection.addEventListener("server-event",o(this,uu)),this.connection.addEventListener("channels-changed",o(this,hu)),this.connection.addEventListener("server-reconnected",o(this,du)),this.connection.addEventListener("server-status",o(this,pu))}get storedAuthToken(){return e2(o(this,dr).get(),this.connection.url)}async connect(){await h(this,bi,uS).call(this,this.connection.token)}dispose(){o(this,Hn)||(d(this,Hn,!0),this.connection.removeEventListener("change",o(this,cu)),this.connection.removeEventListener("server-event",o(this,uu)),this.connection.removeEventListener("channels-changed",o(this,hu)),this.connection.removeEventListener("server-reconnected",o(this,du)),this.connection.removeEventListener("server-status",o(this,pu)),this.connection.dispose())}}dr=new WeakMap,Hn=new WeakMap,bi=new WeakSet,uS=async function(e){if(!o(this,Hn)){h(this,bi,Qm).call(this,null);try{await this.connection.connect(e)}catch(r){h(this,bi,Qm).call(this,r instanceof Gh?null:r instanceof Error?r.message:String(r))}}},Qm=function(e){this.connectError!==e&&(this.connectError=e,this.dispatchEvent(new Bt("change")))},hS=function(){if(this.connection.status!=="unauthorized"||!this.connection.hasAuthRejected)return;const e=o(this,dr).get(),r=Mk(e,this.connection.url);r!==e&&o(this,dr).set(r),this.connection.token!==null&&this.connection.clearToken()},cu=new WeakMap,uu=new WeakMap,hu=new WeakMap,du=new WeakMap,pu=new WeakMap;const eg="tv-nav:",Ol="tv-reload",L2=100,K5=1e3,J5=60,X5=60,Q5=24,eD=30,tD=eD*Q5*X5*J5*K5;function vi(n){try{const t=new URL(n,window.location.href),e=t.searchParams.has(Ol);return t.searchParams.delete(Ol),t.origin===window.location.origin?`${t.pathname}${t.search}${t.hash}`:e?t.toString():n}catch{return n}}var fu,Wa,$e,Ce,ho,Je,dS,Li,pS,tg,ng;class nD extends Ei{constructor(e,r){super();m(this,Je);m(this,fu);m(this,Wa);m(this,$e,[]);m(this,Ce,-1);m(this,ho,0);d(this,fu,e),d(this,Wa,vi(r)),h(this,Je,dS).call(this)}get currentURL(){var e;return o(this,Ce)===-1?null:((e=o(this,$e)[o(this,Ce)])==null?void 0:e.url)??null}get canGoBack(){return o(this,Ce)>-1}get canGoForward(){return o(this,Ce)<o(this,$e).length-1}get entries(){return o(this,$e).map(e=>({...e}))}get cursor(){return o(this,Ce)}navigate(e){const r=vi(e);if(r===o(this,Wa)){if(o(this,Ce)===-1)return;d(this,Ce,-1),h(this,Je,Li).call(this);return}o(this,Ce)<o(this,$e).length-1&&d(this,$e,o(this,$e).slice(0,o(this,Ce)+1)),o(this,$e).push({url:r}),d(this,Ce,o(this,$e).length-1),h(this,Je,tg).call(this),h(this,Je,Li).call(this)}replace(e){var i;if(o(this,Ce)===-1){this.navigate(e);return}const r=vi(e);if(r===o(this,Wa)){d(this,$e,o(this,$e).filter((s,a)=>a!==o(this,Ce))),d(this,Ce,-1),h(this,Je,Li).call(this);return}((i=o(this,$e)[o(this,Ce)])==null?void 0:i.url)!==r&&(d(this,$e,o(this,$e).map((s,a)=>a===o(this,Ce)?{url:r}:s)),h(this,Je,Li).call(this))}back(){o(this,Ce)!==-1&&(d(this,Ce,o(this,Ce)-1),h(this,Je,Li).call(this))}forward(){this.canGoForward&&(d(this,Ce,o(this,Ce)+1),h(this,Je,Li).call(this))}reset(){o(this,Ce)===-1&&o(this,$e).length===0||(d(this,$e,[]),d(this,Ce,-1),h(this,Je,Li).call(this))}}fu=new WeakMap,Wa=new WeakMap,$e=new WeakMap,Ce=new WeakMap,ho=new WeakMap,Je=new WeakSet,dS=function(){const e=localStorage.getItem(o(this,Je,ng));if(e!==null)try{const r=JSON.parse(e);if(!fS(r))return;d(this,$e,r.entries.map(i=>({url:i.url}))),d(this,Ce,r.cursor),d(this,ho,r.lastWritten),h(this,Je,tg).call(this)}catch{d(this,$e,[]),d(this,Ce,-1),d(this,ho,0)}},Li=function(){d(this,ho,Date.now());try{localStorage.setItem(o(this,Je,ng),JSON.stringify(h(this,Je,pS).call(this)))}catch(e){if(!sD(e))throw e}this.dispatchEvent(new Bt("change"))},pS=function(){return{v:1,entries:o(this,$e).map(e=>({...e})),cursor:o(this,Ce),lastWritten:o(this,ho)}},tg=function(){if(o(this,$e).length<=L2)return;const e=o(this,$e).length-L2;d(this,$e,o(this,$e).slice(e)),d(this,Ce,Math.max(-1,o(this,Ce)-e))},ng=function(){return rD(o(this,fu))};function rD(n){return`${eg}${n}`}function iD(n){const t=Date.now()-tD,e=[];for(let r=0;r<localStorage.length;r+=1){const i=localStorage.key(r);if(!(i!=null&&i.startsWith(eg)))continue;const s=i.slice(eg.length),a=localStorage.getItem(i);if(a===null)continue;let l;try{l=JSON.parse(a)}catch{e.push(i);continue}if(!fS(l)){e.push(i);continue}!n.has(s)&&l.lastWritten<t&&e.push(i)}for(const r of e)localStorage.removeItem(r)}function sD(n){return n instanceof DOMException&&n.name==="QuotaExceededError"}function fS(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 bm="tv-channel-sidebar-collapsed";var po;class oD{constructor(t){m(this,po);d(this,po,t)}read(){return o(this,po).getItem(bm)==="true"}setCollapsed(t){try{t?o(this,po).setItem(bm,"true"):o(this,po).removeItem(bm)}catch{}}}po=new WeakMap;const Sm="tv-channel-sidebar-width",rg=160,ig=350,xh=260,aD=/^-?\d+$/;var fo;class lD{constructor(t){m(this,fo);d(this,fo,t)}read(){const t=o(this,fo).getItem(Sm);if(t===null||!aD.test(t))return null;const e=BigInt(t);return e<BigInt(rg)?rg:e>BigInt(ig)?ig:Number(e)}commit(t){const e=mS(Math.round(t));try{o(this,fo).setItem(Sm,String(e))}catch{}return e}clear(){try{o(this,fo).removeItem(Sm)}catch{}}}fo=new WeakMap;function mS(n){return Math.min(Math.max(n,rg),ig)}const cD="1.4.21";function j1(n=cD){return n!==void 0&&n.length>0?n:"0.0.0"}function G1(){let n=!1;return{get pending(){return n},begin(t){n||(n=!0,t())}}}const sg="tv-reload-attempted";function uD(n){return n.originMatch?n.marker!==null&&n.bundleVersion===n.serverVersion?{action:"signal-autoreloaded",fromVersion:n.marker.fromVersion,toVersion:n.bundleVersion}:ok(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 hD(n){const t=n.getItem(sg);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 dD(n){const t=n.storage!==void 0?n.storage:typeof sessionStorage<"u"?sessionStorage:null,e=n.reload??(()=>location.reload()),r=n.navigationLatch??G1(),i=n.bundleVersion??j1();if(t===null)return{dispose(){}};let s=null;const a=()=>{if(s===null)return;const u=n.owner.connection;if(u.url!==n.primaryServerURL||u.status!=="connected")return;const p=s;s=null,u.sendTelemetrySignal("client_autoreloaded",{from_version:p.fromVersion,to_version:p.toVersion})},l=u=>{if(r.pending)return;const p=uD({bundleVersion:i,serverVersion:u.message.version,originMatch:u.serverURL===n.primaryServerURL,marker:hD(t)});switch(p.action){case"reload":t.setItem(sg,JSON.stringify(p.marker)),r.begin(e);return;case"signal-autoreloaded":t.removeItem(sg),s={fromVersion:p.fromVersion,toVersion:p.toVersion},a();return;case"none":return}},c=()=>{a()};return n.owner.addEventListener("server-status",l),n.owner.addEventListener("change",c),{dispose(){n.owner.removeEventListener("server-status",l),n.owner.removeEventListener("change",c)}}}function pD(n){const t=gi(n.search),e=h6(n.search),r=e!==null&&$p(e)?e:null;return{electron:t,shellVersion:r}}function fD(n){return!n.electron||n.requiredDesktopVersion===null||!$p(n.requiredDesktopVersion)?!1:n.shellVersion===null?!0:n.shellVersion===vd?!1:O1(n.requiredDesktopVersion,n.shellVersion)}const mD=`# Desktop app update required
|
|
44
44
|
|
|
45
45
|
This version of the Television desktop app does not work with this server and needs to be updated. The new version has already downloaded and installs when you restart the app.`,gD=`# Desktop app update required
|
|
46
46
|
|
package/dist/web/index.html
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
|
41
41
|
<link rel="icon" type="image/svg+xml" href="./assets/favicon-DaYMFRha.svg" />
|
|
42
42
|
<title>Television</title>
|
|
43
|
-
<script type="module" crossorigin src="./assets/main-
|
|
43
|
+
<script type="module" crossorigin src="./assets/main-C-QwK-7S.js"></script>
|
|
44
44
|
<link rel="modulepreload" crossorigin href="./assets/artifact-bridge-BEUWXKq7.js">
|
|
45
45
|
<link rel="modulepreload" crossorigin href="./assets/missing-artifact-page-DVzJ41AE.js">
|
|
46
46
|
<link rel="stylesheet" crossorigin href="./assets/main-286-L5XK.css">
|