@telepath-computer/television 1.4.27 → 1.4.29

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.
@@ -62,7 +62,7 @@ var bA=Object.defineProperty;var Zv=n=>{throw TypeError(n)};var SA=(n,t,e)=>t in
62
62
  `)}v.write("payload.value = newResult;"),v.write("return payload;");const L=v.compile();return(P,B)=>L(y,P,B)};let s;const a=eu,l=!X8.jitless,u=l&&RT.value,f=t.catchall;let p;n._zod.parse=(y,v)=>{p??(p=r.value);const S=y.value;return a(S)?l&&u&&(v==null?void 0:v.async)===!1&&v.jitless!==!0?(s||(s=i(t.shape)),y=s(y,v),f?m6([],S,y,v,p,n):y):e(y,v):(y.issues.push({expected:"object",code:"invalid_type",input:S,inst:n}),y)}});function k2(n,t,e,r){for(const s of n)if(s.issues.length===0)return t.value=s.value,t;const i=n.filter(s=>!Ma(s));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:e,errors:n.map(s=>s.issues.map(a=>$s(a,r,Is())))}),t)}const g6=I("$ZodUnion",(n,t)=>{Ze.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=>ev(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=>k2(c,i,n,s)):k2(l,i,n,s)}}),fC=I("$ZodDiscriminatedUnion",(n,t)=>{t.inclusive=!1,g6.init(n,t);const e=n._zod.parse;Ae(n._zod,"propValues",()=>{const i={};for(const s of t.options){const a=s._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[l,c]of Object.entries(a)){i[l]||(i[l]=new Set);for(const u of c)i[l].add(u)}}return i});const r=Vf(()=>{var a;const i=t.options,s=new Map;for(const l of i){const c=(a=l._zod.propValues)==null?void 0:a[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(l)}"`);for(const u of c){if(s.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);s.set(u,l)}}return s});n._zod.parse=(i,s)=>{const a=i.value;if(!eu(a))return i.issues.push({code:"invalid_type",expected:"object",input:a,inst:n}),i;const l=r.value.get(a==null?void 0:a[t.discriminator]);return l?l._zod.run(i,s):t.unionFallback?e(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:n}),i)}}),pC=I("$ZodIntersection",(n,t)=>{Ze.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])=>T2(e,c,u)):T2(e,s,a)}});function tg(n,t){if(n===t)return{valid:!0,data:n};if(n instanceof Date&&t instanceof Date&&+n==+t)return{valid:!0,data:n};if(ql(n)&&ql(t)){const e=Object.keys(t),r=Object.keys(n).filter(s=>e.indexOf(s)!==-1),i={...n,...t};for(const s of r){const a=tg(n[s],t[s]);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};i[s]=a.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(t)){if(n.length!==t.length)return{valid:!1,mergeErrorPath:[]};const e=[];for(let r=0;r<n.length;r++){const i=n[r],s=t[r],a=tg(i,s);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};e.push(a.data)}return{valid:!0,data:e}}return{valid:!1,mergeErrorPath:[]}}function T2(n,t,e){const r=new Map;let i;for(const l of t.issues)if(l.code==="unrecognized_keys"){i??(i=l);for(const c of l.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else n.issues.push(l);for(const l of e.issues)if(l.code==="unrecognized_keys")for(const c of l.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else n.issues.push(l);const s=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(s.length&&i&&n.issues.push({...i,keys:s}),Ma(n))return n;const a=tg(t.value,e.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return n.value=a.data,n}const mC=I("$ZodRecord",(n,t)=>{Ze.init(n,t),n._zod.parse=(e,r)=>{const i=e.value;if(!ql(i))return e.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),e;const s=[],a=t.keyType._zod.values;if(a){e.value={};const l=new Set;for(const u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){l.add(typeof u=="number"?u.toString():u);const f=t.valueType._zod.run({value:i[u],issues:[]},r);f instanceof Promise?s.push(f.then(p=>{p.issues.length&&e.issues.push(...Na(u,p.issues)),e.value[u]=p.value})):(f.issues.length&&e.issues.push(...Na(u,f.issues)),e.value[u]=f.value)}let c;for(const u in i)l.has(u)||(c=c??[],c.push(u));c&&c.length>0&&e.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:c})}else{e.value={};for(const l of Reflect.ownKeys(i)){if(l==="__proto__")continue;let c=t.keyType._zod.run({value:l,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof l=="string"&&l6.test(l)&&c.issues.length){const p=t.keyType._zod.run({value:Number(l),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(c=p)}if(c.issues.length){t.mode==="loose"?e.value[l]=i[l]:e.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(p=>$s(p,r,Is())),input:l,path:[l],inst:n});continue}const f=t.valueType._zod.run({value:i[l],issues:[]},r);f instanceof Promise?s.push(f.then(p=>{p.issues.length&&e.issues.push(...Na(l,p.issues)),e.value[c.value]=p.value})):(f.issues.length&&e.issues.push(...Na(l,f.issues)),e.value[c.value]=f.value)}}return s.length?Promise.all(s).then(()=>e):e}}),gC=I("$ZodEnum",(n,t)=>{Ze.init(n,t);const e=Q8(t.entries),r=new Set(e);n._zod.values=r,n._zod.pattern=new RegExp(`^(${e.filter(i=>CT.has(typeof i)).map(i=>typeof i=="string"?Vl(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}}),vC=I("$ZodLiteral",(n,t)=>{if(Ze.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"?Vl(r):r?Vl(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}}),yC=I("$ZodTransform",(n,t)=>{Ze.init(n,t),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new K8(n.constructor.name);const i=t.transform(e.value,e);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(a=>(e.value=a,e));if(i instanceof Promise)throw new Ha;return e.value=i,e}});function R2(n,t){return n.issues.length&&t===void 0?{issues:[],value:void 0}:n}const v6=I("$ZodOptional",(n,t)=>{Ze.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(`^(${ev(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=>R2(s,e.value)):R2(i,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,r)}}),wC=I("$ZodExactOptional",(n,t)=>{v6.init(n,t),Ae(n._zod,"values",()=>t.innerType._zod.values),Ae(n._zod,"pattern",()=>t.innerType._zod.pattern),n._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),bC=I("$ZodNullable",(n,t)=>{Ze.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(`^(${ev(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)}),SC=I("$ZodDefault",(n,t)=>{Ze.init(n,t),n._zod.optin="optional",Ae(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);if(e.value===void 0)return e.value=t.defaultValue,e;const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>C2(s,t)):C2(i,t)}});function C2(n,t){return n.value===void 0&&(n.value=t.defaultValue),n}const _C=I("$ZodPrefault",(n,t)=>{Ze.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))}),AC=I("$ZodNonOptional",(n,t)=>{Ze.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=>I2(s,n)):I2(i,n)}});function I2(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 EC=I("$ZodCatch",(n,t)=>{Ze.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=>$s(a,r,Is()))},input:e.value}),e.issues=[]),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(s=>$s(s,r,Is()))},input:e.value}),e.issues=[]),e)}}),kC=I("$ZodPipe",(n,t)=>{Ze.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=>Uh(a,t.in,r)):Uh(s,t.in,r)}const i=t.in._zod.run(e,r);return i instanceof Promise?i.then(s=>Uh(s,t.out,r)):Uh(i,t.out,r)}});function Uh(n,t,e){return n.issues.length?(n.aborted=!0,n):t._zod.run({value:n.value,issues:n.issues},e)}const TC=I("$ZodReadonly",(n,t)=>{Ze.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($2):$2(i)}});function $2(n){return n.value=Object.freeze(n.value),n}const RC=I("$ZodCustom",(n,t)=>{Gt.init(n,t),Ze.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=>x2(s,e,r,n));x2(i,e,r,n)}});function x2(n,t,e,r){if(!n){const i={code:"custom",input:e,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),t.issues.push(tu(i))}}var P2;class CC{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 IC(){return new CC}(P2=globalThis).__zod_globalRegistry??(P2.__zod_globalRegistry=IC());const $c=globalThis.__zod_globalRegistry;function $C(n,t){return new n({type:"string",...Y(t)})}function xC(n,t){return new n({type:"string",format:"email",check:"string_format",abort:!1,...Y(t)})}function D2(n,t){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...Y(t)})}function PC(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...Y(t)})}function DC(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Y(t)})}function LC(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Y(t)})}function OC(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Y(t)})}function MC(n,t){return new n({type:"string",format:"url",check:"string_format",abort:!1,...Y(t)})}function NC(n,t){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...Y(t)})}function zC(n,t){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...Y(t)})}function UC(n,t){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...Y(t)})}function HC(n,t){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...Y(t)})}function ZC(n,t){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...Y(t)})}function qC(n,t){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...Y(t)})}function VC(n,t){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...Y(t)})}function FC(n,t){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...Y(t)})}function BC(n,t){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...Y(t)})}function jC(n,t){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Y(t)})}function WC(n,t){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Y(t)})}function GC(n,t){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...Y(t)})}function JC(n,t){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...Y(t)})}function YC(n,t){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...Y(t)})}function KC(n,t){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...Y(t)})}function XC(n,t){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Y(t)})}function QC(n,t){return new n({type:"string",format:"date",check:"string_format",...Y(t)})}function e3(n,t){return new n({type:"string",format:"time",check:"string_format",precision:null,...Y(t)})}function t3(n,t){return new n({type:"string",format:"duration",check:"string_format",...Y(t)})}function n3(n,t){return new n({type:"number",checks:[],...Y(t)})}function r3(n,t){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...Y(t)})}function i3(n,t){return new n({type:"boolean",...Y(t)})}function s3(n){return new n({type:"unknown"})}function o3(n,t){return new n({type:"never",...Y(t)})}function L2(n,t){return new u6({check:"less_than",...Y(t),value:n,inclusive:!1})}function Rm(n,t){return new u6({check:"less_than",...Y(t),value:n,inclusive:!0})}function O2(n,t){return new h6({check:"greater_than",...Y(t),value:n,inclusive:!1})}function Cm(n,t){return new h6({check:"greater_than",...Y(t),value:n,inclusive:!0})}function M2(n,t){return new SR({check:"multiple_of",...Y(t),value:n})}function y6(n,t){return new AR({check:"max_length",...Y(t),maximum:n})}function Pd(n,t){return new ER({check:"min_length",...Y(t),minimum:n})}function w6(n,t){return new kR({check:"length_equals",...Y(t),length:n})}function a3(n,t){return new TR({check:"string_format",format:"regex",...Y(t),pattern:n})}function l3(n){return new RR({check:"string_format",format:"lowercase",...Y(n)})}function c3(n){return new CR({check:"string_format",format:"uppercase",...Y(n)})}function u3(n,t){return new IR({check:"string_format",format:"includes",...Y(t),includes:n})}function h3(n,t){return new $R({check:"string_format",format:"starts_with",...Y(t),prefix:n})}function d3(n,t){return new xR({check:"string_format",format:"ends_with",...Y(t),suffix:n})}function ec(n){return new PR({check:"overwrite",tx:n})}function f3(n){return ec(t=>t.normalize(n))}function p3(){return ec(n=>n.trim())}function m3(){return ec(n=>n.toLowerCase())}function g3(){return ec(n=>n.toUpperCase())}function v3(){return ec(n=>TT(n))}function y3(n,t,e){return new n({type:"array",element:t,...Y(e)})}function w3(n,t,e){return new n({type:"custom",check:"custom",fn:t,...Y(e)})}function b3(n){const t=S3(e=>(e.addIssue=r=>{if(typeof r=="string")e.issues.push(tu(r,e.value,t._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=e.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),e.issues.push(tu(i))}},n(e.value,e)));return t}function S3(n,t){const e=new Gt({check:"custom",...Y(t)});return e._zod.check=n,e}function b6(n){let t=(n==null?void 0:n.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:n.processors??{},metadataRegistry:(n==null?void 0:n.metadata)??$c,target:t,unrepresentable:(n==null?void 0:n.unrepresentable)??"throw",override:(n==null?void 0:n.override)??(()=>{}),io:(n==null?void 0:n.io)??"output",counter:0,seen:new Map,cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",external:(n==null?void 0:n.external)??void 0}}function Xe(n,t,e={path:[],schemaPath:[]}){var f,p;var r;const i=n._zod.def,s=t.seen.get(n);if(s)return s.count++,e.schemaPath.includes(n)&&(s.cycle=e.path),s.schema;const a={schema:{},count:1,cycle:void 0,path:e.path};t.seen.set(n,a);const l=(p=(f=n._zod).toJSONSchema)==null?void 0:p.call(f);if(l)a.schema=l;else{const y={...e,schemaPath:[...e.schemaPath,n],path:e.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(t,a.schema,y);else{const S=a.schema,_=t.processors[i.type];if(!_)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);_(n,t,S,y)}const v=n._zod.parent;v&&(a.ref||(a.ref=v),Xe(v,t,y),t.seen.get(v).isParent=!0)}const c=t.metadataRegistry.get(n);return c&&Object.assign(a.schema,c),t.io==="input"&&At(n)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(n).schema}function S6(n,t){var a,l,c,u;const e=n.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const f of n.seen.entries()){const p=(a=n.metadataRegistry.get(f[0]))==null?void 0:a.id;if(p){const y=r.get(p);if(y&&y!==f[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(p,f[0])}}const i=f=>{var _;const p=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const $=(_=n.external.registry.get(f[0]))==null?void 0:_.id,H=n.external.uri??(z=>z);if($)return{ref:H($)};const L=f[1].defId??f[1].schema.id??`schema${n.counter++}`;return f[1].defId=L,{defId:L,ref:`${H("__shared")}#/${p}/${L}`}}if(f[1]===e)return{ref:"#"};const v=`#/${p}/`,S=f[1].schema.id??`__schema${n.counter++}`;return{defId:S,ref:v+S}},s=f=>{if(f[1].schema.$ref)return;const p=f[1],{ref:y,defId:v}=i(f);p.def={...p.schema},v&&(p.defId=v);const S=p.schema;for(const _ in S)delete S[_];S.$ref=y};if(n.cycles==="throw")for(const f of n.seen.entries()){const p=f[1];if(p.cycle)throw new Error(`Cycle detected: #/${(l=p.cycle)==null?void 0:l.join("/")}/<root>
63
63
 
64
64
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const f of n.seen.entries()){const p=f[1];if(t===f[0]){s(f);continue}if(n.external){const v=(c=n.external.registry.get(f[0]))==null?void 0:c.id;if(t!==f[0]&&v){s(f);continue}}if((u=n.metadataRegistry.get(f[0]))==null?void 0:u.id){s(f);continue}if(p.cycle){s(f);continue}if(p.count>1&&n.reused==="ref"){s(f);continue}}}function _6(n,t){var a,l,c;const e=n.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const f=n.seen.get(u);if(f.ref===null)return;const p=f.def??f.schema,y={...p},v=f.ref;if(f.ref=null,v){r(v);const _=n.seen.get(v),$=_.schema;if($.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push($)):Object.assign(p,$),Object.assign(p,y),u._zod.parent===v)for(const L in p)L==="$ref"||L==="allOf"||L in y||delete p[L];if($.$ref&&_.def)for(const L in p)L==="$ref"||L==="allOf"||L in _.def&&JSON.stringify(p[L])===JSON.stringify(_.def[L])&&delete p[L]}const S=u._zod.parent;if(S&&S!==v){r(S);const _=n.seen.get(S);if(_!=null&&_.schema.$ref&&(p.$ref=_.schema.$ref,_.def))for(const $ in p)$==="$ref"||$==="allOf"||$ in _.def&&JSON.stringify(p[$])===JSON.stringify(_.def[$])&&delete p[$]}n.override({zodSchema:u,jsonSchema:p,path:f.path??[]})};for(const u of[...n.seen.entries()].reverse())r(u[0]);const i={};if(n.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":n.target,(a=n.external)!=null&&a.uri){const u=(l=n.external.registry.get(t))==null?void 0:l.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=n.external.uri(u)}Object.assign(i,e.def??e.schema);const s=((c=n.external)==null?void 0:c.defs)??{};for(const u of n.seen.entries()){const f=u[1];f.def&&f.defId&&(s[f.defId]=f.def)}n.external||Object.keys(s).length>0&&(n.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...t["~standard"],jsonSchema:{input:Dd(t,"input",n.processors),output:Dd(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 _3=(n,t={})=>e=>{const r=b6({...e,processors:t});return Xe(n,r),S6(r,n),_6(r,n)},Dd=(n,t,e={})=>r=>{const{libraryOptions:i,target:s}=r??{},a=b6({...i??{},target:s,io:t,processors:e});return Xe(n,a),S6(a,n),_6(a,n)},A3={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},E3=(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=A3[l]??l,i.format===""&&delete i.format,l==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){const f=[...c];f.length===1?i.pattern=f[0].source:f.length>1&&(i.allOf=[...f.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},k3=(n,t,e,r)=>{const i=e,{minimum:s,maximum:a,format:l,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:f}=n._zod.bag;typeof l=="string"&&l.includes("int")?i.type="integer":i.type="number",typeof f=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=f,i.exclusiveMinimum=!0):i.exclusiveMinimum=f),typeof s=="number"&&(i.minimum=s,typeof f=="number"&&t.target!=="draft-04"&&(f>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof a=="number"&&(i.maximum=a,typeof u=="number"&&t.target!=="draft-04"&&(u<=a?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},T3=(n,t,e,r)=>{e.type="boolean"},R3=(n,t,e,r)=>{e.not={}},C3=(n,t,e,r)=>{},I3=(n,t,e,r)=>{const i=n._zod.def,s=Q8(i.entries);s.every(a=>typeof a=="number")&&(e.type="number"),s.every(a=>typeof a=="string")&&(e.type="string"),e.enum=s},$3=(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},x3=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},P3=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},D3=(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"]})},L3=(n,t,e,r)=>{var u;const i=e,s=n._zod.def;i.type="object",i.properties={};const a=s.shape;for(const f in a)i.properties[f]=Xe(a[f],t,{...r,path:[...r.path,"properties",f]});const l=new Set(Object.keys(a)),c=new Set([...l].filter(f=>{const p=s.shape[f]._zod;return t.io==="input"?p.optin===void 0:p.optout===void 0}));c.size>0&&(i.required=Array.from(c)),((u=s.catchall)==null?void 0:u._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=Xe(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},O3=(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},M3=(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},N3=(n,t,e,r)=>{const i=e,s=n._zod.def;i.type="object";const a=s.keyType,l=a._zod.bag,c=l==null?void 0:l.patterns;if(s.mode==="loose"&&c&&c.size>0){const f=Xe(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const p of c)i.patternProperties[p.source]=f}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Xe(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Xe(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=a._zod.values;if(u){const f=[...u].filter(p=>typeof p=="string"||typeof p=="number");f.length>0&&(i.required=f)}},z3=(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"}]},U3=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},H3=(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))},Z3=(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)))},q3=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType;let a;try{a=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}e.default=a},V3=(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},F3=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,e.readOnly=!0},A6=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},B3=I("ZodISODateTime",(n,t)=>{jR.init(n,t),Ve.init(n,t)});function j3(n){return XC(B3,n)}const W3=I("ZodISODate",(n,t)=>{WR.init(n,t),Ve.init(n,t)});function G3(n){return QC(W3,n)}const J3=I("ZodISOTime",(n,t)=>{GR.init(n,t),Ve.init(n,t)});function Y3(n){return e3(J3,n)}const K3=I("ZodISODuration",(n,t)=>{JR.init(n,t),Ve.init(n,t)});function X3(n){return t3(K3,n)}const E6=(n,t)=>{r6.init(n,t),n.name="ZodError",Object.defineProperties(n,{format:{value:e=>UT(n,e)},flatten:{value:e=>zT(n,e)},addIssue:{value:e=>{n.issues.push(e),n.message=JSON.stringify(n.issues,eg,2)}},addIssues:{value:e=>{n.issues.push(...e),n.message=JSON.stringify(n.issues,eg,2)}},isEmpty:{get(){return n.issues.length===0}}})},N2=I("ZodError",E6),xn=I("ZodError",E6,{Parent:Error}),Q3=nv(xn),eI=rv(xn),tI=Ff(xn),nI=Bf(xn),rI=qT(xn),iI=VT(xn),sI=FT(xn),oI=BT(xn),aI=jT(xn),lI=WT(xn),cI=GT(xn),uI=JT(xn),qe=I("ZodType",(n,t)=>(Ze.init(n,t),Object.assign(n["~standard"],{jsonSchema:{input:Dd(n,"input"),output:Dd(n,"output")}}),n.toJSONSchema=_3(n,{}),n.def=t,n.type=t.type,Object.defineProperty(n,"_def",{value:t}),n.check=(...e)=>n.clone(Ls(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),n.with=n.check,n.clone=(e,r)=>Os(n,e,r),n.brand=()=>n,n.register=((e,r)=>(e.add(n,r),n)),n.parse=(e,r)=>Q3(n,e,r,{callee:n.parse}),n.safeParse=(e,r)=>tI(n,e,r),n.parseAsync=async(e,r)=>eI(n,e,r,{callee:n.parseAsync}),n.safeParseAsync=async(e,r)=>nI(n,e,r),n.spa=n.safeParseAsync,n.encode=(e,r)=>rI(n,e,r),n.decode=(e,r)=>iI(n,e,r),n.encodeAsync=async(e,r)=>sI(n,e,r),n.decodeAsync=async(e,r)=>oI(n,e,r),n.safeEncode=(e,r)=>aI(n,e,r),n.safeDecode=(e,r)=>lI(n,e,r),n.safeEncodeAsync=async(e,r)=>cI(n,e,r),n.safeDecodeAsync=async(e,r)=>uI(n,e,r),n.refine=(e,r)=>n.check(n$(e,r)),n.superRefine=e=>n.check(r$(e)),n.overwrite=e=>n.check(ec(e)),n.optional=()=>H2(n),n.exactOptional=()=>VI(n),n.nullable=()=>Z2(n),n.nullish=()=>H2(Z2(n)),n.nonoptional=e=>JI(n,e),n.array=()=>G(n),n.or=e=>ae([n,e]),n.and=e=>Wf(n,e),n.transform=e=>q2(n,ZI(e)),n.default=e=>jI(n,e),n.prefault=e=>GI(n,e),n.catch=e=>KI(n,e),n.pipe=e=>q2(n,e),n.readonly=()=>e$(n),n.describe=e=>{const r=n.clone();return $c.add(r,{description:e}),r},Object.defineProperty(n,"description",{get(){var e;return(e=$c.get(n))==null?void 0:e.description},configurable:!0}),n.meta=(...e)=>{if(e.length===0)return $c.get(n);const r=n.clone();return $c.add(r,e[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=e=>e(n),n)),k6=I("_ZodString",(n,t)=>{iv.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(r,i,s)=>E3(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(a3(...r)),n.includes=(...r)=>n.check(u3(...r)),n.startsWith=(...r)=>n.check(h3(...r)),n.endsWith=(...r)=>n.check(d3(...r)),n.min=(...r)=>n.check(Pd(...r)),n.max=(...r)=>n.check(y6(...r)),n.length=(...r)=>n.check(w6(...r)),n.nonempty=(...r)=>n.check(Pd(1,...r)),n.lowercase=r=>n.check(l3(r)),n.uppercase=r=>n.check(c3(r)),n.trim=()=>n.check(p3()),n.normalize=(...r)=>n.check(f3(...r)),n.toLowerCase=()=>n.check(m3()),n.toUpperCase=()=>n.check(g3()),n.slugify=()=>n.check(v3())}),hI=I("ZodString",(n,t)=>{iv.init(n,t),k6.init(n,t),n.email=e=>n.check(xC(dI,e)),n.url=e=>n.check(MC(fI,e)),n.jwt=e=>n.check(KC(CI,e)),n.emoji=e=>n.check(NC(pI,e)),n.guid=e=>n.check(D2(z2,e)),n.uuid=e=>n.check(PC(Hh,e)),n.uuidv4=e=>n.check(DC(Hh,e)),n.uuidv6=e=>n.check(LC(Hh,e)),n.uuidv7=e=>n.check(OC(Hh,e)),n.nanoid=e=>n.check(zC(mI,e)),n.guid=e=>n.check(D2(z2,e)),n.cuid=e=>n.check(UC(gI,e)),n.cuid2=e=>n.check(HC(vI,e)),n.ulid=e=>n.check(ZC(yI,e)),n.base64=e=>n.check(GC(kI,e)),n.base64url=e=>n.check(JC(TI,e)),n.xid=e=>n.check(qC(wI,e)),n.ksuid=e=>n.check(VC(bI,e)),n.ipv4=e=>n.check(FC(SI,e)),n.ipv6=e=>n.check(BC(_I,e)),n.cidrv4=e=>n.check(jC(AI,e)),n.cidrv6=e=>n.check(WC(EI,e)),n.e164=e=>n.check(YC(RI,e)),n.datetime=e=>n.check(j3(e)),n.date=e=>n.check(G3(e)),n.time=e=>n.check(Y3(e)),n.duration=e=>n.check(X3(e))});function g(n){return $C(hI,n)}const Ve=I("ZodStringFormat",(n,t)=>{Me.init(n,t),k6.init(n,t)}),dI=I("ZodEmail",(n,t)=>{NR.init(n,t),Ve.init(n,t)}),z2=I("ZodGUID",(n,t)=>{OR.init(n,t),Ve.init(n,t)}),Hh=I("ZodUUID",(n,t)=>{MR.init(n,t),Ve.init(n,t)}),fI=I("ZodURL",(n,t)=>{zR.init(n,t),Ve.init(n,t)}),pI=I("ZodEmoji",(n,t)=>{UR.init(n,t),Ve.init(n,t)}),mI=I("ZodNanoID",(n,t)=>{HR.init(n,t),Ve.init(n,t)}),gI=I("ZodCUID",(n,t)=>{ZR.init(n,t),Ve.init(n,t)}),vI=I("ZodCUID2",(n,t)=>{qR.init(n,t),Ve.init(n,t)}),yI=I("ZodULID",(n,t)=>{VR.init(n,t),Ve.init(n,t)}),wI=I("ZodXID",(n,t)=>{FR.init(n,t),Ve.init(n,t)}),bI=I("ZodKSUID",(n,t)=>{BR.init(n,t),Ve.init(n,t)}),SI=I("ZodIPv4",(n,t)=>{YR.init(n,t),Ve.init(n,t)}),_I=I("ZodIPv6",(n,t)=>{KR.init(n,t),Ve.init(n,t)}),AI=I("ZodCIDRv4",(n,t)=>{XR.init(n,t),Ve.init(n,t)}),EI=I("ZodCIDRv6",(n,t)=>{QR.init(n,t),Ve.init(n,t)}),kI=I("ZodBase64",(n,t)=>{eC.init(n,t),Ve.init(n,t)}),TI=I("ZodBase64URL",(n,t)=>{nC.init(n,t),Ve.init(n,t)}),RI=I("ZodE164",(n,t)=>{rC.init(n,t),Ve.init(n,t)}),CI=I("ZodJWT",(n,t)=>{sC.init(n,t),Ve.init(n,t)}),T6=I("ZodNumber",(n,t)=>{f6.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(r,i,s)=>k3(n,r,i),n.gt=(r,i)=>n.check(O2(r,i)),n.gte=(r,i)=>n.check(Cm(r,i)),n.min=(r,i)=>n.check(Cm(r,i)),n.lt=(r,i)=>n.check(L2(r,i)),n.lte=(r,i)=>n.check(Rm(r,i)),n.max=(r,i)=>n.check(Rm(r,i)),n.int=r=>n.check(U2(r)),n.safe=r=>n.check(U2(r)),n.positive=r=>n.check(O2(0,r)),n.nonnegative=r=>n.check(Cm(0,r)),n.negative=r=>n.check(L2(0,r)),n.nonpositive=r=>n.check(Rm(0,r)),n.multipleOf=(r,i)=>n.check(M2(r,i)),n.step=(r,i)=>n.check(M2(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 n3(T6,n)}const II=I("ZodNumberFormat",(n,t)=>{oC.init(n,t),T6.init(n,t)});function U2(n){return r3(II,n)}const $I=I("ZodBoolean",(n,t)=>{aC.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>T3(n,e,r)});function lt(n){return i3($I,n)}const xI=I("ZodUnknown",(n,t)=>{lC.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>C3()});function E(){return s3(xI)}const PI=I("ZodNever",(n,t)=>{cC.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>R3(n,e,r)});function DI(n){return o3(PI,n)}const LI=I("ZodArray",(n,t)=>{uC.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>D3(n,e,r,i),n.element=t.element,n.min=(e,r)=>n.check(Pd(e,r)),n.nonempty=e=>n.check(Pd(1,e)),n.max=(e,r)=>n.check(y6(e,r)),n.length=(e,r)=>n.check(w6(e,r)),n.unwrap=()=>n.element});function G(n,t){return y3(LI,n,t)}const R6=I("ZodObject",(n,t)=>{dC.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>L3(n,e,r,i),Ae(n,"shape",()=>t.shape),n.keyof=()=>sv(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:DI()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=e=>DT(n,e),n.safeExtend=e=>LT(n,e),n.merge=e=>OT(n,e),n.pick=e=>xT(n,e),n.omit=e=>PT(n,e),n.partial=(...e)=>MT(I6,n,e[0]),n.required=(...e)=>NT($6,n,e[0])});function ng(n,t){const e={type:"object",shape:n??{},...Y(t)};return new R6(e)}function b(n,t){return new R6({type:"object",shape:n,catchall:E(),...Y(t)})}const C6=I("ZodUnion",(n,t)=>{g6.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>O3(n,e,r,i),n.options=t.options});function ae(n,t){return new C6({type:"union",options:n,...Y(t)})}const OI=I("ZodDiscriminatedUnion",(n,t)=>{C6.init(n,t),fC.init(n,t)});function MI(n,t,e){return new OI({type:"union",options:t,discriminator:n,...Y(e)})}const NI=I("ZodIntersection",(n,t)=>{pC.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>M3(n,e,r,i)});function Wf(n,t){return new NI({type:"intersection",left:n,right:t})}const zI=I("ZodRecord",(n,t)=>{mC.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>N3(n,e,r,i),n.keyType=t.keyType,n.valueType=t.valueType});function T(n,t,e){return new zI({type:"record",keyType:n,valueType:t,...Y(e)})}const rg=I("ZodEnum",(n,t)=>{gC.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(r,i,s)=>I3(n,r,i),n.enum=t.entries,n.options=Object.values(t.entries);const e=new Set(Object.keys(t.entries));n.extract=(r,i)=>{const s={};for(const a of r)if(e.has(a))s[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new rg({...t,checks:[],...Y(i),entries:s})},n.exclude=(r,i)=>{const s={...t.entries};for(const a of r)if(e.has(a))delete s[a];else throw new Error(`Key ${a} not found in enum`);return new rg({...t,checks:[],...Y(i),entries:s})}});function sv(n,t){const e=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new rg({type:"enum",entries:e,...Y(t)})}const UI=I("ZodLiteral",(n,t)=>{vC.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>$3(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 UI({type:"literal",values:Array.isArray(n)?n:[n],...Y(t)})}const HI=I("ZodTransform",(n,t)=>{yC.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>P3(n,e),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new K8(n.constructor.name);e.addIssue=s=>{if(typeof s=="string")e.issues.push(tu(s,e.value,t));else{const a=s;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=e.value),a.inst??(a.inst=n),e.issues.push(tu(a))}};const i=t.transform(e.value,e);return i instanceof Promise?i.then(s=>(e.value=s,e)):(e.value=i,e)}});function ZI(n){return new HI({type:"transform",transform:n})}const I6=I("ZodOptional",(n,t)=>{v6.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>A6(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function H2(n){return new I6({type:"optional",innerType:n})}const qI=I("ZodExactOptional",(n,t)=>{wC.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>A6(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function VI(n){return new qI({type:"optional",innerType:n})}const FI=I("ZodNullable",(n,t)=>{bC.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>z3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function Z2(n){return new FI({type:"nullable",innerType:n})}const BI=I("ZodDefault",(n,t)=>{SC.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>H3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function jI(n,t){return new BI({type:"default",innerType:n,get defaultValue(){return typeof t=="function"?t():t6(t)}})}const WI=I("ZodPrefault",(n,t)=>{_C.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>Z3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function GI(n,t){return new WI({type:"prefault",innerType:n,get defaultValue(){return typeof t=="function"?t():t6(t)}})}const $6=I("ZodNonOptional",(n,t)=>{AC.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>U3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function JI(n,t){return new $6({type:"nonoptional",innerType:n,...Y(t)})}const YI=I("ZodCatch",(n,t)=>{EC.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>q3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function KI(n,t){return new YI({type:"catch",innerType:n,catchValue:typeof t=="function"?t:()=>t})}const XI=I("ZodPipe",(n,t)=>{kC.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>V3(n,e,r,i),n.in=t.in,n.out=t.out});function q2(n,t){return new XI({type:"pipe",in:n,out:t})}const QI=I("ZodReadonly",(n,t)=>{TC.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>F3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function e$(n){return new QI({type:"readonly",innerType:n})}const t$=I("ZodCustom",(n,t)=>{RC.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>x3(n,e)});function n$(n,t={}){return w3(t$,n,t)}function r$(n){return b3(n)}const i$=[".md",".markdown"];function x6(n){if(n.length===0)return!1;const t=n.at(-1);return t==="/"||t==="\\"}function P6(n){const t=n.lastIndexOf("/"),e=n.lastIndexOf("\\");return n.slice(Math.max(t,e)+1)}function s$(n){return P6(n).toLowerCase()}function o$(n,t){const e=s$(n);return t.some(r=>e.endsWith(r))}function ig(n){return!x6(n)&&o$(n,i$)}function a$(n){let t;try{t=new URL(n)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}function Vr(n){try{const{pathname:t}=new URL(n);return/^\/artifact\/[0-9A-Za-z]{26}(\/|$)/.test(t)}catch{return!1}}const l$=ng({id:g().min(1),kind:D("path"),title:g(),path:g(),store:g().optional(),share:ng({id:g().min(1),access:sv(["read","read-write"])}).strict().optional()}).strict(),c$=ng({id:g().min(1),kind:D("url"),title:g(),url:g().refine(a$,{message:"url must be an http(s) URL"})}).strict();MI("kind",[l$,c$]);const u$=new Set(["about:","blob:","chrome-extension:","chrome:","data:","devtools:","file:","filesystem:","javascript:","view-source:"]);function h$(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}:u$.has(r.protocol)?{kind:"browser-local",url:r.href}:{kind:"application",url:r.href}}catch{return{kind:"invalid"}}}function V2(n,t){return h$(n,t).kind==="web"}const d$="/views/markdown/",f$="/views/url-unsupported/";function p$(n){try{const{protocol:t}=new URL(n);return t==="http:"||t==="https:"}catch{return!1}}function D6(n){return`/artifact/${encodeURIComponent(n)}`}function m$(n,t){return`${D6(n)}/${encodeURIComponent(t)}`}function g$(n){return`/markdown/${encodeURIComponent(n)}`}function Ld(n,t={electron:!1}){if(n.kind==="url")return t.electron?{renderer:"url-webview",viewURL:n.url,contentURL:null}:Vr(n.url)?{renderer:"proxy-iframe",viewURL:n.url,contentURL:null}:t.browserDemo&&p$(n.url)?{renderer:"url-direct",viewURL:n.url,contentURL:null}:{renderer:"url-unsupported",viewURL:f$,contentURL:null};if(ig(n.path)){const r={viewURL:d$,contentURL:g$(n.id)};return t.electron?{renderer:"url-webview",...r}:{renderer:"markdown",...r}}const e=x6(n.path)?`${D6(n.id)}/`:m$(n.id,P6(n.path));return t.electron?{renderer:"url-webview",viewURL:e,contentURL:null}:{renderer:"proxy-iframe",viewURL:e,contentURL:null}}const v$="serverURL",y$="token",w$="mode",b$="desktopAppVersion",S$="electron";function _$(n=window.location.search,t=window.location.origin){const r=new URLSearchParams(n).get(v$);return r?new URL(r).origin:new URL(t).origin}function A$(n=window.location.search){return new URLSearchParams(n).get(y$)}function wi(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(w$)===S$}function L6(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(b$)}const F2="tv.telemetry.clientId",E$=5,k$=60,T$=1e3,R$=E$*k$*T$,B2=["pointerdown","scroll","keydown"],j2=["focus"],W2=["visibilitychange"],C$="hidden";function I$(n,t=L$){const e=n.getItem(F2);if(e)return e;const r=t();return n.setItem(F2,r),r}function $$(n){return{clientId:I$(n.storage,n.idFactory),userAgent:n.userAgent??(typeof navigator>"u"?"":navigator.userAgent),clientApp:n.clientApp,...n.desktopAppVersion?{desktopAppVersion:n.desktopAppVersion}:{}}}function x$(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 P$(n){return new D$(n)}var cu,Gr,ji,uu,hu,vn,mo,du,Wd,O6;class D${constructor(t){m(this,Wd);m(this,cu);m(this,Gr);m(this,ji);m(this,uu);m(this,hu);m(this,vn);m(this,mo,!1);m(this,du,Number.NEGATIVE_INFINITY);d(this,cu,t.meta),d(this,Gr,t.documentTarget),d(this,ji,t.windowTarget),d(this,uu,t.send),d(this,hu,t.nowMs??Date.now),d(this,vn,()=>h(this,Wd,O6).call(this))}start(){if(!o(this,mo)){d(this,mo,!0);for(const t of B2)o(this,ji).addEventListener(t,o(this,vn)),o(this,Gr).addEventListener(t,o(this,vn));for(const t of j2)o(this,ji).addEventListener(t,o(this,vn));for(const t of W2)o(this,Gr).addEventListener(t,o(this,vn))}}stop(){if(o(this,mo)){d(this,mo,!1);for(const t of B2)o(this,ji).removeEventListener(t,o(this,vn)),o(this,Gr).removeEventListener(t,o(this,vn));for(const t of j2)o(this,ji).removeEventListener(t,o(this,vn));for(const t of W2)o(this,Gr).removeEventListener(t,o(this,vn))}}}cu=new WeakMap,Gr=new WeakMap,ji=new WeakMap,uu=new WeakMap,hu=new WeakMap,vn=new WeakMap,mo=new WeakMap,du=new WeakMap,Wd=new WeakSet,O6=function(){if(o(this,Gr).visibilityState===C$)return;const t=o(this,hu).call(this);t-o(this,du)<R$||(d(this,du,t),o(this,uu).call(this,{type:ak,clientId:o(this,cu).clientId}))};function L$(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():X1().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"},Ur={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"},O$=1,M$=b({_meta:T(g(),E()).nullish(),terminal:lt().optional().default(!1)}),N$=b({_meta:T(g(),E()).nullish(),label:g().nullish(),name:g(),optional:lt().optional().default(!1),secret:lt().optional().default(!0)}),z$=b({_meta:T(g(),E()).nullish(),description:g().nullish(),id:g(),name:g()}),U$=b({_meta:T(g(),E()).nullish(),description:g().nullish(),id:g(),link:g().nullish(),name:g(),vars:G(N$)}),H$=b({_meta:T(g(),E()).nullish(),args:G(g()).optional(),description:g().nullish(),env:T(g(),g()).optional(),id:g(),name:g()}),Z$=ae([U$.and(b({type:D("env_var")})),H$.and(b({type:D("terminal")})),z$]),q$=b({_meta:T(g(),E()).nullish(),methodId:g()}),V$=b({_meta:T(g(),E()).nullish()}),F$=b({_meta:T(g(),E()).nullish(),blob:g(),mimeType:g().nullish(),uri:g()}),B$=b({default:lt().nullish(),description:g().nullish(),title:g().nullish()}),j$=b({_meta:T(g(),E()).nullish()}),W$=b({_meta:T(g(),E()).nullish()}),G$=b({amount:ie(),currency:g()}),J$=b({_meta:T(g(),E()).nullish(),terminalId:g()}),Y$=b({_meta:T(g(),E()).nullish(),newText:g(),oldText:g().nullish(),path:g()}),K$=ae([g(),ie(),ie(),lt(),G(g())]),X$=b({content:T(g(),K$).nullish()}),Q$=ae([X$.and(b({action:D("accept")})),b({action:D("decline")}),b({action:D("cancel")})]),ex=b({_meta:T(g(),E()).nullish()}),M6=g(),tx=b({_meta:T(g(),E()).nullish(),elicitationId:M6}),nx=b({_meta:T(g(),E()).nullish(),action:Q$}),rx=D("object"),ix=D("string"),sx=b({_meta:T(g(),E()).nullish()}),ox=b({_meta:T(g(),E()).nullish(),form:ex.nullish(),url:sx.nullish()}),ax=b({elicitationId:M6,url:g().url()}),N6=b({const:g(),title:g()}),z6=b({_meta:T(g(),E()).nullish(),name:g(),value:g()}),lx=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"})]),U6=b({code:lx,data:E().optional(),message:g()}),H6=E(),Z6=E(),q6=E(),cx=b({_meta:T(g(),E()).nullish(),readTextFile:lt().optional().default(!1),writeTextFile:lt().optional().default(!1)}),V6=b({_meta:T(g(),E()).nullish(),name:g(),value:g()}),F6=b({_meta:T(g(),E()).nullish(),name:g(),title:g().nullish(),version:g()}),ux=b({default:ie().nullish(),description:g().nullish(),maximum:ie().nullish(),minimum:ie().nullish(),title:g().nullish()}),hx=b({_meta:T(g(),E()).nullish()}),dx=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cursor:g().nullish(),cwd:g().nullish()}),fx=b({_meta:T(g(),E()).nullish()}),px=b({_meta:T(g(),E()).nullish(),logout:fx.nullish()}),mx=b({_meta:T(g(),E()).nullish()}),gx=b({_meta:T(g(),E()).nullish()}),vx=b({_meta:T(g(),E()).nullish(),http:lt().optional().default(!1),sse:lt().optional().default(!1)}),yx=b({_meta:T(g(),E()).nullish(),headers:G(V6),name:g(),url:g()}),wx=b({_meta:T(g(),E()).nullish(),headers:G(V6),name:g(),url:g()}),bx=b({_meta:T(g(),E()).nullish(),args:G(g()),command:g(),env:G(z6),name:g()}),Gf=ae([yx.and(b({type:D("http")})),wx.and(b({type:D("sse")})),bx]),ov=g(),Sx=b({_meta:T(g(),E()).nullish(),description:g().nullish(),modelId:ov,name:g()}),_x=ae([D("error"),D("warning"),D("information"),D("hint")]),Ax=b({_meta:T(g(),E()).nullish()}),Ex=b({_meta:T(g(),E()).nullish()}),kx=b({_meta:T(g(),E()).nullish()}),Tx=b({_meta:T(g(),E()).nullish()}),Rx=b({_meta:T(g(),E()).nullish()}),Cx=b({_meta:T(g(),E()).nullish(),maxCount:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),Ix=b({diff:g(),uri:g()}),$x=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()}),xx=b({_meta:T(g(),E()).nullish()}),Px=b({_meta:T(g(),E()).nullish()}),Dx=b({languageId:g(),text:g(),uri:g()}),Lx=b({_meta:T(g(),E()).nullish(),maxCount:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),Ox=ae([D("rejected"),D("ignored"),D("replaced"),D("cancelled")]),Mx=b({excerpts:G($x),uri:g()}),Nx=b({_meta:T(g(),E()).nullish()}),zx=b({_meta:T(g(),E()).nullish()}),Ux=b({name:g(),owner:g(),remoteUrl:g()}),Hx=b({_meta:T(g(),E()).nullish()}),Zx=b({_meta:T(g(),E()).nullish(),jump:xx.nullish(),rename:zx.nullish(),searchAndReplace:Hx.nullish()}),qx=b({id:g(),isRegex:lt().nullish(),replace:g(),search:g(),uri:g()}),Vx=ae([D("automatic"),D("diagnostic"),D("manual")]),Fx=b({_meta:T(g(),E()).nullish(),maxCount:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),Bx=b({_meta:T(g(),E()).nullish(),diagnostics:Ax.nullish(),editHistory:Cx.nullish(),openFiles:Px.nullish(),recentFiles:Lx.nullish(),relatedSnippets:Nx.nullish(),userActions:Fx.nullish()}),jx=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),mcpServers:G(Gf)}),Wx=b({default:ie().nullish(),description:g().nullish(),maximum:ie().nullish(),minimum:ie().nullish(),title:g().nullish()}),B6=g(),Gx=ae([D("allow_once"),D("allow_always"),D("reject_once"),D("reject_always")]),Jx=b({_meta:T(g(),E()).nullish(),kind:Gx,name:g(),optionId:B6}),Yx=ae([D("high"),D("medium"),D("low")]),Kx=ae([D("pending"),D("in_progress"),D("completed")]),Xx=b({_meta:T(g(),E()).nullish(),content:g(),priority:Yx,status:Kx}),Qx=b({_meta:T(g(),E()).nullish(),entries:G(Xx)}),xs=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"})}),eP=b({id:g(),position:xs,uri:g()}),tP=b({id:g(),newName:g(),position:xs,uri:g()}),nP=b({action:g(),position:xs,timestampMs:ie(),uri:g()}),j6=ae([D("utf-16"),D("utf-32"),D("utf-8")]),rP=b({_meta:T(g(),E()).nullish(),auth:M$.optional().default({terminal:!1}),elicitation:ox.nullish(),fs:cx.optional().default({readTextFile:!1,writeTextFile:!1}),nes:Zx.nullish(),positionEncodings:G(j6).optional(),terminal:lt().optional().default(!1)}),iP=b({_meta:T(g(),E()).nullish(),audio:lt().optional().default(!1),embeddedContext:lt().optional().default(!1),image:lt().optional().default(!1)}),W6=ie().int().gte(0).lte(65535),sP=b({_meta:T(g(),E()).nullish(),clientCapabilities:rP.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:F6.nullish(),protocolVersion:W6}),tc=b({end:xs,start:xs}),oP=b({message:g(),range:tc,severity:_x,uri:g()}),aP=b({languageId:g(),lastFocusedMs:ie().nullish(),uri:g(),visibleRange:tc.nullish()}),lP=b({_meta:T(g(),E()).nullish(),diagnostics:G(oP).nullish(),editHistory:G(Ix).nullish(),openFiles:G(aP).nullish(),recentFiles:G(Dx).nullish(),relatedSnippets:G(Mx).nullish(),userActions:G(nP).nullish()}),cP=b({newText:g(),range:tc}),uP=b({cursorPosition:xs.nullish(),edits:G(cP),id:g(),uri:g()}),hP=ae([uP.and(b({kind:D("edit")})),eP.and(b({kind:D("jump")})),tP.and(b({kind:D("rename")})),qx.and(b({kind:D("searchAndReplace")}))]),dP=b({_meta:T(g(),E()).nullish(),content:g()}),fP=b({_meta:T(g(),E()).nullish()}),ra=ae([ie(),g()]).nullable();b({_meta:T(g(),E()).nullish(),requestId:ra});const pP=sv(["assistant","user"]),_h=b({_meta:T(g(),E()).nullish(),audience:G(pP).nullish(),lastModified:g().nullish(),priority:ie().nullish()}),mP=b({_meta:T(g(),E()).nullish(),annotations:_h.nullish(),data:g(),mimeType:g()}),gP=b({_meta:T(g(),E()).nullish(),annotations:_h.nullish(),data:g(),mimeType:g(),uri:g().nullish()}),vP=b({_meta:T(g(),E()).nullish(),annotations:_h.nullish(),description:g().nullish(),mimeType:g().nullish(),name:g(),size:ie().nullish(),title:g().nullish(),uri:g()}),yP=b({_meta:T(g(),E()).nullish(),optionId:B6}),wP=ae([b({outcome:D("cancelled")}),yP.and(b({outcome:D("selected")}))]),bP=b({_meta:T(g(),E()).nullish(),outcome:wP}),SP=b({_meta:T(g(),E()).nullish()}),_P=b({_meta:T(g(),E()).nullish()}),AP=b({currentValue:lt()}),EP=g(),G6=g(),kP=ae([D("mode"),D("model"),D("thought_level"),g()]),av=g(),J6=b({_meta:T(g(),E()).nullish(),description:g().nullish(),name:g(),value:av}),TP=b({_meta:T(g(),E()).nullish(),group:EP,name:g(),options:G(J6)}),RP=ae([G(J6),G(TP)]),CP=b({currentValue:av,options:RP}),nc=Wf(ae([CP.and(b({type:D("select")})),AP.and(b({type:D("boolean")}))]),b({_meta:T(g(),E()).nullish(),category:kP.nullish(),description:g().nullish(),id:G6,name:g()})),IP=b({_meta:T(g(),E()).nullish(),configOptions:G(nc)}),$P=b({_meta:T(g(),E()).nullish()}),be=g(),xP=b({_meta:T(g(),E()).nullish(),id:g(),sessionId:be}),PP=b({_meta:T(g(),E()).nullish(),sessionId:be}),DP=b({_meta:T(g(),E()).nullish(),sessionId:be}),LP=b({_meta:T(g(),E()).nullish(),sessionId:be}),Y6=b({_meta:T(g(),E()).nullish(),args:G(g()).optional(),command:g(),cwd:g().nullish(),env:G(z6).optional(),outputByteLimit:ie().nullish(),sessionId:be}),OP=b({_meta:T(g(),E()).nullish(),sessionId:be,uri:g()}),MP=b({_meta:T(g(),E()).nullish(),position:xs,sessionId:be,uri:g(),version:ie(),visibleRange:tc}),NP=b({_meta:T(g(),E()).nullish(),languageId:g(),sessionId:be,text:g(),uri:g(),version:ie()}),zP=b({_meta:T(g(),E()).nullish(),sessionId:be,uri:g()}),UP=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),mcpServers:G(Gf).optional(),sessionId:be}),K6=b({_meta:T(g(),E()).nullish(),sessionId:be,terminalId:g()}),HP=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),mcpServers:G(Gf),sessionId:be}),X6=b({_meta:T(g(),E()).nullish(),limit: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}),ZP=b({_meta:T(g(),E()).nullish(),id:g(),reason:Ox.nullish(),sessionId:be}),Q6=b({_meta:T(g(),E()).nullish(),sessionId:be,terminalId:g()}),qP=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),mcpServers:G(Gf).optional(),sessionId:be}),VP=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),sessionId:be,title:g().nullish(),updatedAt:g().nullish()}),FP=b({_meta:T(g(),E()).nullish(),nextCursor:g().nullish(),sessions:G(VP)}),BP=b({_meta:T(g(),E()).nullish(),title:g().nullish(),updatedAt:g().nullish()}),jP=b({_meta:T(g(),E()).nullish()}),Jf=g(),WP=b({_meta:T(g(),E()).nullish(),currentModeId:Jf}),GP=b({_meta:T(g(),E()).nullish(),description:g().nullish(),id:Jf,name:g()}),Yf=b({_meta:T(g(),E()).nullish(),availableModes:G(GP),currentModeId:Jf}),Kf=b({_meta:T(g(),E()).nullish(),availableModels:G(Sx),currentModelId:ov}),JP=b({_meta:T(g(),E()).nullish(),configOptions:G(nc).nullish(),models:Kf.nullish(),modes:Yf.nullish(),sessionId:be}),YP=b({_meta:T(g(),E()).nullish(),configOptions:G(nc).nullish(),models:Kf.nullish(),modes:Yf.nullish()}),KP=b({_meta:T(g(),E()).nullish(),configOptions:G(nc).nullish(),models:Kf.nullish(),modes:Yf.nullish(),sessionId:be}),XP=b({_meta:T(g(),E()).nullish(),configOptions:G(nc).nullish(),models:Kf.nullish(),modes:Yf.nullish()}),QP=b({_meta:T(g(),E()).nullish()}),e5=b({_meta:T(g(),E()).nullish(),additionalDirectories:SP.nullish(),close:_P.nullish(),fork:$P.nullish(),list:jP.nullish(),resume:QP.nullish()}),t5=Wf(ae([b({type:D("boolean"),value:lt()}),b({value:av})]),b({_meta:T(g(),E()).nullish(),configId:G6,sessionId:be})),n5=b({_meta:T(g(),E()).nullish(),configOptions:G(nc)}),r5=b({_meta:T(g(),E()).nullish(),modeId:Jf,sessionId:be}),i5=b({_meta:T(g(),E()).nullish()}),s5=b({_meta:T(g(),E()).nullish(),modelId:ov,sessionId:be}),o5=b({_meta:T(g(),E()).nullish()}),a5=b({_meta:T(g(),E()).nullish(),sessionId:be}),l5=ae([D("end_turn"),D("max_tokens"),D("max_turn_requests"),D("refusal"),D("cancelled")]),c5=ae([D("email"),D("uri"),D("date"),D("date-time")]),u5=b({default:g().nullish(),description:g().nullish(),enum:G(g()).nullish(),format:c5.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(N6).nullish(),pattern:g().nullish(),title:g().nullish()}),h5=b({_meta:T(g(),E()).nullish(),context:lP.nullish(),position:xs,selection:tc.nullish(),sessionId:be,triggerKind:Vx,uri:g(),version:ie()}),d5=b({_meta:T(g(),E()).nullish(),suggestions:G(hP)}),f5=b({_meta:T(g(),E()).nullish(),terminalId:g()}),p5=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()}),eS=b({_meta:T(g(),E()).nullish(),sessionId:be,terminalId:g()}),m5=b({_meta:T(g(),E()).nullish(),exitStatus:p5.nullish(),output:g(),truncated:lt()}),g5=b({_meta:T(g(),E()).nullish(),annotations:_h.nullish(),text:g()}),v5=b({range:tc.nullish(),text:g()}),y5=b({_meta:T(g(),E()).nullish(),contentChanges:G(v5),sessionId:be,uri:g(),version:ie()});b({method:g(),params:ae([PP,NP,y5,OP,zP,MP,xP,ZP,H6]).nullish()});const w5=ae([D("full"),D("incremental")]),b5=b({_meta:T(g(),E()).nullish(),syncKind:w5}),S5=b({_meta:T(g(),E()).nullish(),didChange:b5.nullish(),didClose:Ex.nullish(),didFocus:kx.nullish(),didOpen:Tx.nullish(),didSave:Rx.nullish()}),_5=b({_meta:T(g(),E()).nullish(),document:S5.nullish()}),A5=b({_meta:T(g(),E()).nullish(),context:Bx.nullish(),events:_5.nullish()}),E5=b({_meta:T(g(),E()).nullish(),auth:px.optional().default({}),loadSession:lt().optional().default(!1),mcpCapabilities:vx.optional().default({http:!1,sse:!1}),nes:A5.nullish(),positionEncoding:j6.nullish(),promptCapabilities:iP.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:e5.optional().default({})}),k5=b({_meta:T(g(),E()).nullish(),agentCapabilities:E5.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:F6.nullish(),authMethods:G(Z$).optional().default([]),protocolVersion:W6}),T5=b({_meta:T(g(),E()).nullish(),mimeType:g().nullish(),text:g(),uri:g()}),R5=ae([T5,F$]),C5=b({_meta:T(g(),E()).nullish(),annotations:_h.nullish(),resource:R5}),lv=ae([g5.and(b({type:D("text")})),gP.and(b({type:D("image")})),mP.and(b({type:D("audio")})),vP.and(b({type:D("resource_link")})),C5.and(b({type:D("resource")}))]),I5=b({_meta:T(g(),E()).nullish(),content:lv}),Im=b({_meta:T(g(),E()).nullish(),content:lv,messageId:g().nullish()}),$5=b({_meta:T(g(),E()).nullish(),messageId:g().nullish(),prompt:G(lv),sessionId:be}),x5=b({anyOf:G(N6)}),tS=ae([I5.and(b({type:D("content")})),Y$.and(b({type:D("diff")})),f5.and(b({type:D("terminal")}))]),nS=g(),rS=b({_meta:T(g(),E()).nullish(),line:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:g()}),iS=ae([D("pending"),D("in_progress"),D("completed"),D("failed")]),sS=ae([D("read"),D("edit"),D("delete"),D("move"),D("search"),D("execute"),D("think"),D("fetch"),D("switch_mode"),D("other")]),P5=b({_meta:T(g(),E()).nullish(),content:G(tS).optional(),kind:sS.optional(),locations:G(rS).optional(),rawInput:E().optional(),rawOutput:E().optional(),status:iS.optional(),title:g(),toolCallId:nS}),oS=b({_meta:T(g(),E()).nullish(),content:G(tS).nullish(),kind:sS.nullish(),locations:G(rS).nullish(),rawInput:E().optional(),rawOutput:E().optional(),status:iS.nullish(),title:g().nullish(),toolCallId:nS}),aS=b({_meta:T(g(),E()).nullish(),options:G(Jx),sessionId:be,toolCall:oS}),D5=b({_meta:T(g(),E()).nullish(),hint:g()}),L5=D5,O5=b({_meta:T(g(),E()).nullish(),description:g(),input:L5.nullish(),name:g()}),M5=b({_meta:T(g(),E()).nullish(),availableCommands:G(O5)}),N5=b({enum:G(g()),type:ix}),z5=ae([N5,x5]),U5=b({default:G(g()).nullish(),description:g().nullish(),items:z5,maxItems:ie().nullish(),minItems:ie().nullish(),title:g().nullish()}),H5=ae([u5.and(b({type:D("string")})),Wx.and(b({type:D("number")})),ux.and(b({type:D("integer")})),B$.and(b({type:D("boolean")})),U5.and(b({type:D("array")}))]),Z5=b({description:g().nullish(),properties:T(g(),H5).optional().default({}),required:G(g()).nullish(),title:g().nullish(),type:rx.optional().default("object")}),q5=b({requestedSchema:Z5}),V5=Wf(ae([q5.and(b({mode:D("form")})),ax.and(b({mode:D("url")}))]),b({_meta:T(g(),E()).nullish(),message:g(),sessionId:be})),F5=b({cachedReadTokens:ie().nullish(),cachedWriteTokens:ie().nullish(),inputTokens:ie(),outputTokens:ie(),thoughtTokens:ie().nullish(),totalTokens:ie()}),B5=b({_meta:T(g(),E()).nullish(),stopReason:l5,usage:F5.nullish(),userMessageId:g().nullish()});ae([b({id:ra,result:ae([k5,V$,gx,KP,YP,FP,JP,XP,W$,i5,n5,B5,o5,a5,d5,j$,q6])}),b({error:U6,id:ra})]);const j5=b({_meta:T(g(),E()).nullish(),cost:G$.nullish(),size:ie(),used:ie()}),W5=ae([Im.and(b({sessionUpdate:D("user_message_chunk")})),Im.and(b({sessionUpdate:D("agent_message_chunk")})),Im.and(b({sessionUpdate:D("agent_thought_chunk")})),P5.and(b({sessionUpdate:D("tool_call")})),oS.and(b({sessionUpdate:D("tool_call_update")})),Qx.and(b({sessionUpdate:D("plan")})),M5.and(b({sessionUpdate:D("available_commands_update")})),WP.and(b({sessionUpdate:D("current_mode_update")})),IP.and(b({sessionUpdate:D("config_option_update")})),BP.and(b({sessionUpdate:D("session_info_update")})),j5.and(b({sessionUpdate:D("usage_update")}))]),lS=b({_meta:T(g(),E()).nullish(),sessionId:be,update:W5});b({method:g(),params:ae([lS,tx,H6]).nullish()});const cS=b({_meta:T(g(),E()).nullish(),sessionId:be,terminalId:g()}),G5=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()}),J5=b({name:g(),uri:g()}),Y5=b({_meta:T(g(),E()).nullish(),repository:Ux.nullish(),workspaceFolders:G(J5).nullish(),workspaceUri:g().nullish()});b({id:ra,method:g(),params:ae([sP,q$,mx,jx,HP,dx,UP,qP,LP,r5,t5,$5,s5,Y5,h5,DP,Z6]).nullish()});const uS=b({_meta:T(g(),E()).nullish(),content:g(),path:g(),sessionId:be});b({id:ra,method:g(),params:ae([uS,X6,aS,Y6,eS,Q6,cS,K6,V5,Z6]).nullish()});const K5=b({_meta:T(g(),E()).nullish()});ae([b({id:ra,result:ae([K5,dP,bP,J$,m5,fP,G5,hx,nx,q6])}),b({error:U6,id:ra})]);var we;class X5{constructor(t,e){m(this,we);const r=t(this),i=async(a,l)=>{var c,u,f,p,y,v,S;switch(a){case Ur.fs_write_text_file:{const _=uS.parse(l);return(c=r.writeTextFile)==null?void 0:c.call(r,_)}case Ur.fs_read_text_file:{const _=X6.parse(l);return(u=r.readTextFile)==null?void 0:u.call(r,_)}case Ur.session_request_permission:{const _=aS.parse(l);return r.requestPermission(_)}case Ur.terminal_create:{const _=Y6.parse(l);return(f=r.createTerminal)==null?void 0:f.call(r,_)}case Ur.terminal_output:{const _=eS.parse(l);return(p=r.terminalOutput)==null?void 0:p.call(r,_)}case Ur.terminal_release:{const _=Q6.parse(l);return await((y=r.releaseTerminal)==null?void 0:y.call(r,_))??{}}case Ur.terminal_wait_for_exit:{const _=cS.parse(l);return(v=r.waitForTerminalExit)==null?void 0:v.call(r,_)}case Ur.terminal_kill:{const _=K6.parse(l);return await((S=r.killTerminal)==null?void 0:S.call(r,_))??{}}default:if(r.extMethod)return r.extMethod(a,l);throw rt.methodNotFound(a)}},s=async(a,l)=>{switch(a){case Ur.session_update:{const c=lS.parse(l);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(a,l);throw rt.methodNotFound(a)}};d(this,we,new Q5(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 Wi,Gd,fu,pu,Ba,ja,ar,mu,He,hS,sg,dS,fS,pS,mS,og,xc;class Q5{constructor(t,e,r){m(this,He);m(this,Wi,new Map);m(this,Gd,0);m(this,fu);m(this,pu);m(this,Ba);m(this,ja,Promise.resolve());m(this,ar,new AbortController);m(this,mu);d(this,fu,t),d(this,pu,e),d(this,Ba,r),d(this,mu,new Promise(i=>{o(this,ar).signal.addEventListener("abort",()=>i())})),h(this,He,hS).call(this)}get signal(){return o(this,ar).signal}get closed(){return o(this,mu)}async sendRequest(t,e){h(this,He,og).call(this);const r=Lh(this,Gd)._++,i=new Promise((s,a)=>{o(this,Wi).set(r,{resolve:s,reject:a})});return await h(this,He,xc).call(this,{jsonrpc:"2.0",id:r,method:t,params:e}),i}async sendNotification(t,e){h(this,He,og).call(this),await h(this,He,xc).call(this,{jsonrpc:"2.0",method:t,params:e})}}Wi=new WeakMap,Gd=new WeakMap,fu=new WeakMap,pu=new WeakMap,Ba=new WeakMap,ja=new WeakMap,ar=new WeakMap,mu=new WeakMap,He=new WeakSet,hS=async function(){let t;try{const e=o(this,Ba).readable.getReader();try{for(;!o(this,ar).signal.aborted;){const{value:r,done:i}=await e.read();if(i)break;if(r)try{h(this,He,dS).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&h(this,He,xc).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{e.releaseLock()}}catch(e){t=e}finally{h(this,He,sg).call(this,t)}},sg=function(t){if(o(this,ar).signal.aborted)return;const e=t??new Error("ACP connection closed");for(const r of o(this,Wi).values())r.reject(e);o(this,Wi).clear(),o(this,ar).abort(e)},dS=async function(t){if("method"in t&&"id"in t){const e=await h(this,He,fS).call(this,t.method,t.params);"error"in e&&console.error("Error handling request",t,e.error),await h(this,He,xc).call(this,{jsonrpc:"2.0",id:t.id,...e})}else if("method"in t){const e=await h(this,He,pS).call(this,t.method,t.params);"error"in e&&console.error("Error handling notification",t,e.error)}else"id"in t?h(this,He,mS).call(this,t):console.error("Invalid message",{message:t})},fS=async function(t,e){try{return{result:await o(this,fu).call(this,t,e)??null}}catch(r){if(r instanceof rt)return r.toResult();if(r instanceof N2)return rt.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return rt.internalError(i?JSON.parse(i):{}).toResult()}catch{return rt.internalError({details:i}).toResult()}}},pS=async function(t,e){try{return await o(this,pu).call(this,t,e),{result:null}}catch(r){if(r instanceof rt)return r.toResult();if(r instanceof N2)return rt.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return rt.internalError(i?JSON.parse(i):{}).toResult()}catch{return rt.internalError({details:i}).toResult()}}},mS=function(t){const e=o(this,Wi).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,Wi).delete(t.id)}else console.error("Got response to unknown request",t.id)},og=function(){if(o(this,ar).signal.aborted)throw o(this,ar).signal.reason??new Error("ACP connection closed")},xc=async function(t){return d(this,ja,o(this,ja).then(async()=>{const e=o(this,Ba).writable.getWriter();try{await e.write(t)}finally{e.releaseLock()}}).catch(e=>{h(this,He,sg).call(this,e)})),o(this,ja)};class rt extends Error{constructor(e,r,i){super(r);C(this,"code");C(this,"data");this.code=e,this.name="RequestError",this.data=i}static parseError(e,r){return new 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 eD(n,t,e){const r=n.dispose.bind(n);n.dispose=(()=>{if(!t())return e(),r()})}function gS(n){var e;class t extends n{constructor(...s){super(...s);m(this,e,!1);eD(this,()=>o(this,e),()=>{d(this,e,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return o(this,e)}}return e=new WeakMap,t}const tD=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,nD=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,rD=/\[Television channel context\][\s\S]*?\[\/Television channel context\]\n*/,iD=/\b(tv|television|channel|artifact|artifacts|viewer|filmstrip|layout|focus)\b/i,sD=/^[A-Za-z0-9_@%+=:,./-]+$/,oD=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,aD="single_session",lD={name:"television-acp-client",version:"0.0.0"},vS="agent:main:television",cD=gS(Ri);var Wa,lr,nn,cr,Gi,Nn,Jr,ur,zn,Ji,Un,Ga,Ja,hr,Et,Yr,Ya,go,Kr,Yi,gu,Hn,dr,Jd,fr,O,ag,yS,wS,bS,Qh,SS,_S,AS,ES,kS,TS,RS,Gs,Aa,Ea,Zr,CS,ka,lg,cg,ed,IS,td,ug,hg,vu,yu,nd,Ta,dg,$S;class uD extends cD{constructor(e){super();m(this,O);m(this,Wa,"disconnected");m(this,lr,null);m(this,nn,new Map);m(this,cr,null);m(this,Gi,null);m(this,Nn,null);m(this,Jr,null);m(this,ur,null);m(this,zn,null);m(this,Ji);m(this,Un,null);m(this,Ga,0);m(this,Ja,1);m(this,hr,null);m(this,Et,null);m(this,Yr,!1);m(this,Ya,!1);m(this,go,!1);m(this,Kr,null);m(this,Yi,new Set);m(this,gu);m(this,Hn);m(this,dr);m(this,Jd,e=>{h(this,O,wS).call(this,e)});m(this,fr,null);m(this,vu,()=>{h(this,O,Ta).call(this,"ACP bridge websocket closed")});m(this,yu,()=>{h(this,O,Ta).call(this,"ACP bridge websocket error")});d(this,Hn,e),d(this,dr,e.sessionMode??aD),d(this,Ji,e.mappedSessionStore??hD()),d(this,gu,e.createSocket??(r=>new WebSocket(r)))}get status(){return o(this,Wa)}get messages(){return[...o(this,nn).values()]}get enabled(){return o(this,Hn).enabled??!1}setToken(e){o(this,Hn).token=e??""}setEnabled(e){o(this,Hn).enabled=e,e||(h(this,O,nd).call(this),d(this,lr,null),h(this,O,Zr).call(this,"disconnected"))}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(this.enabled&&this.status==="disconnected"){o(this,Gi)===null&&(d(this,lr,null),d(this,Gi,h(this,O,yS).call(this)));try{await o(this,Gi),await h(this,O,Qh).call(this)}catch(e){throw h(this,O,Ta).call(this,$m(e)),e}}}dispose(){h(this,O,nd).call(this),d(this,lr,null),h(this,O,Zr).call(this,"disposed")}async sendMessage(e){if(await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await h(this,O,ag).call(this,"ready")),(o(this,ur)===null||o(this,Un)!==h(this,O,td).call(this))&&await h(this,O,Qh).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,O,Aa).call(this,{id:h(this,O,ka).call(this,"user"),kind:"user",text:r,status:"final"}),h(this,O,Zr).call(this,"running");try{const i=await h(this,O,ed).call(this).prompt({sessionId:h(this,O,cg).call(this),prompt:[{type:"text",text:h(this,O,CS).call(this,r)}]});h(this,O,Gs).call(this,i.stopReason==="cancelled"?"cancelled":"final"),h(this,O,Zr).call(this,"ready")}catch(i){throw h(this,O,$S).call(this)||(h(this,O,Gs).call(this,"error"),h(this,O,Zr).call(this,"ready")),i}}async startNewSession(){var r;await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await h(this,O,ag).call(this,"ready"));const e=h(this,O,td).call(this);((r=o(this,zn))==null?void 0:r.sessionIdStrategy)==="mapped"?o(this,Ji).clearActualSessionId(e):d(this,Ga,o(this,Ga)+1),d(this,Nn,null),d(this,Jr,null),d(this,ur,null),d(this,Un,null),h(this,O,dg).call(this)}async cancel(){this.status==="running"&&(h(this,O,Zr).call(this,"cancelling"),await h(this,O,ed).call(this).cancel({sessionId:h(this,O,cg).call(this)}))}setChannelContext(e){var s,a,l;if(e===null){if(o(this,Et)===null)return;d(this,Et,null),d(this,Yr,!1);return}const r={channelID:e.channelID,channelName:e.channelName};if(((s=o(this,Et))==null?void 0:s.channelID)===r.channelID&&((a=o(this,Et))==null?void 0:a.channelName)===r.channelName)return;const i=((l=o(this,Et))==null?void 0:l.channelID)??null;if(d(this,Et,r),o(this,dr)==="single_session"){(!o(this,Un)||i!==r.channelID)&&d(this,Yr,!0);return}o(this,Un)!==h(this,O,ug).call(this,r.channelID)&&(d(this,Nn,null),d(this,Jr,null),o(this,cr)&&this.status==="ready"&&h(this,O,Qh).call(this).catch(c=>{h(this,O,Ta).call(this,$m(c))}))}}Wa=new WeakMap,lr=new WeakMap,nn=new WeakMap,cr=new WeakMap,Gi=new WeakMap,Nn=new WeakMap,Jr=new WeakMap,ur=new WeakMap,zn=new WeakMap,Ji=new WeakMap,Un=new WeakMap,Ga=new WeakMap,Ja=new WeakMap,hr=new WeakMap,Et=new WeakMap,Yr=new WeakMap,Ya=new WeakMap,go=new WeakMap,Kr=new WeakMap,Yi=new WeakMap,gu=new WeakMap,Hn=new WeakMap,dr=new WeakMap,Jd=new WeakMap,fr=new WeakMap,O=new WeakSet,ag=async function(e){if(this.status!==e){if(this.status==="disposed")throw new Error("ACPClient has been disposed");if(this.status==="disconnected")throw new Error(o(this,lr)??"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,lr)??"ACPClient is disconnected")))};this.addEventListener("status-changed",a)})}},yS=async function(){try{const{stream:e,socket:r,metadata:i}=await mD({serverURL:o(this,Hn).serverURL,token:o(this,Hn).token,createSocket:o(this,gu),onDisconnect:o(this,Jd)});d(this,zn,i),d(this,fr,r),r.addEventListener("close",o(this,vu)),r.addEventListener("error",o(this,yu)),d(this,cr,new X5(s=>({connection:s,sessionUpdate:async a=>{await h(this,O,_S).call(this,a)},requestPermission:async a=>h(this,O,AS).call(this,a)}),e)),await o(this,cr).initialize({protocolVersion:O$,clientCapabilities:{},clientInfo:lD})}catch(e){throw e}},wS=function(e){h(this,O,Ta).call(this,$m(e))},bS=function(e){const r=e==null?void 0:e.models;if(!(r!=null&&r.currentModelId))return;const i=r.availableModels.find(s=>s.modelId===r.currentModelId);console.info("[ACPClient] Current model:",(i==null?void 0:i.name)??r.currentModelId,`(${r.currentModelId})`)},Qh=async function(){const e=h(this,O,td).call(this);if(o(this,Nn)&&o(this,Jr)===e){await o(this,Nn);return}d(this,Jr,e),d(this,Nn,h(this,O,SS).call(this,e)),await o(this,Nn)},SS=async function(e){var c;const r=h(this,O,ed).call(this);h(this,O,dg).call(this);let i,s=!1,a=null;const l={cwd:h(this,O,IS).call(this),mcpServers:[],_meta:{sessionKey:e}};try{if(d(this,go,!0),d(this,Kr,null),((c=o(this,zn))==null?void 0:c.sessionIdStrategy)==="mapped"){const u=o(this,Ji).getActualSessionId(e);if(u)try{const f=await r.loadSession({...l,sessionId:u});if(dD(f))throw new Error("Mapped ACP session was not found");a=f,i=u,s=!0}catch{const f=await r.newSession(l);a=f,i=f.sessionId,o(this,Ji).setActualSessionId(e,i),s=!1}else{const f=await r.newSession(l);a=f,i=f.sessionId,o(this,Ji).setActualSessionId(e,i),s=!1}}else try{a=await r.loadSession({...l,sessionId:e}),i=e,s=o(this,nn).size>0}catch{const u=await r.newSession(l);a=u,i=u.sessionId,s=!1}}finally{d(this,go,!1),d(this,Kr,null),h(this,O,Gs).call(this,"final")}h(this,O,bS).call(this,a),await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),d(this,ur,i),d(this,Un,e),d(this,Ya,!0),s?(o(this,Yi).add(e),o(this,dr)==="single_session"&&d(this,Yr,!1)):(o(this,Yi).delete(e),d(this,Yr,o(this,dr)==="single_session")),d(this,lr,null),h(this,O,Zr).call(this,"ready")},_S=async function(e){const r=e.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&h(this,O,RS).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&h(this,O,ES).call(this,r.content.text);return;case"tool_call":h(this,O,kS).call(this,r);return;case"tool_call_update":h(this,O,TS).call(this,r);return;case"agent_thought_chunk":return;default:return}},AS=async function(e){return{outcome:{outcome:"cancelled"}}},ES=function(e){d(this,Kr,null);const r=pD(e);if(!r)return;if(!o(this,hr)){const s={id:h(this,O,ka).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};d(this,hr,s.id),h(this,O,Aa).call(this,s);return}const i=o(this,nn).get(o(this,hr));if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");h(this,O,Ea).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},kS=function(e){h(this,O,Gs).call(this,"final");const r=h(this,O,lg).call(this,e.toolCallId),i=J2("content"in e?e.content:void 0),s={id:(r==null?void 0:r.id)??h(this,O,ka).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:e.title,toolKind:e.kind??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??i,locations:e.locations??(r==null?void 0:r.locations)};if(r){h(this,O,Ea).call(this,s);return}h(this,O,Aa).call(this,s)},TS=function(e){const r=h(this,O,lg).call(this,e.toolCallId),i=(r==null?void 0:r.text)??"",s=J2(e.content),a=s?`${i}${s}`:i,l={id:(r==null?void 0:r.id)??h(this,O,ka).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:(r==null?void 0:r.title)??e.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:a,locations:e.locations??(r==null?void 0:r.locations)};if(r){h(this,O,Ea).call(this,l);return}h(this,O,Aa).call(this,l)},RS=function(e){if(h(this,O,Gs).call(this,"final"),!e)return;const r=o(this,go)?o(this,Kr):null;if(!r){const s=G2(e);if(!s)return;const a={id:h(this,O,ka).call(this,"user"),kind:"user",text:s,status:"final"};h(this,O,Aa).call(this,a),o(this,go)&&d(this,Kr,a.id);return}const i=o(this,nn).get(r);if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");h(this,O,Ea).call(this,{...i,text:G2(`${i.text}${e}`)})},Gs=function(e){if(!o(this,hr))return;const r=o(this,nn).get(o(this,hr));(r==null?void 0:r.kind)==="assistant"&&h(this,O,Ea).call(this,{...r,status:e}),d(this,hr,null)},Aa=function(e){o(this,nn).set(e.id,e),this.dispatchEvent(new Tm("messages-changed"))},Ea=function(e){o(this,nn).set(e.id,e),this.dispatchEvent(new Tm("messages-changed"))},Zr=function(e){o(this,Wa)!==e&&(d(this,Wa,e),this.dispatchEvent(new vT("status-changed")))},CS=function(e){var u;const r=o(this,Un);if(!r)return e;const i=o(this,Et)?o(this,dr)==="single_session"?o(this,Yr)||!o(this,Yi).has(r):!o(this,Yi).has(r):!1,s=o(this,Ya)&&(o(this,Et)!==null||iD.test(e));if(!(s||i))return e;s&&d(this,Ya,!1),i&&(d(this,Yr,!1),o(this,Yi).add(r));const l=["[Television channel context]","This chat session is coming from a Television client.","Using Television requires the knowledge in the `television` skill. Re-read it only if it is not already in context or you know it changed.","If the skill is not installed, it can be installed via `tv skills install <your agent skills path>`."],c=((u=o(this,zn))==null?void 0:u.tvArgs)??[];return c.length>0&&l.push(`To reach this Television server, add these arguments to each tv command that contacts it: ${c.map(yD).join(" ")}`),o(this,Et)?(l.push("This conversation is currently attached to the channel below."),l.push(`channel_id: ${o(this,Et).channelID}`),l.push(`channel_name: ${o(this,Et).channelName??""}`),l.push("When the user asks to inspect or change Television state with the tv CLI, use this channel ID with the --channel argument.")):l.push("There is currently no active Television channel."),l.push("[/Television channel context]","",e),l.join(`
65
- `)},ka=function(e){const r=`${e}-${o(this,Ja)}`;return d(this,Ja,o(this,Ja)+1),r},lg=function(e){for(const r of o(this,nn).values())if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===e)return r;return null},cg=function(){if(!o(this,ur))throw new Error("ACP session is not ready");return o(this,ur)},ed=function(){if(!o(this,cr))throw new Error("ACP connection is not ready");return o(this,cr)},IS=function(){var r;const e=(r=o(this,zn))==null?void 0:r.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},td=function(){var r;if(o(this,dr)==="single_session")return h(this,O,hg).call(this,`${vS}-${(o(this,Hn).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,O,ug).call(this,e)},ug=function(e){return h(this,O,hg).call(this,fD(o(this,dr),e,o(this,Hn).clientGUID??"default-client"))},hg=function(e){var r;return((r=o(this,zn))==null?void 0:r.sessionIdStrategy)==="deterministic"&&o(this,Ga)>0?`${e}:epoch-${o(this,Ga)}`:e},vu=new WeakMap,yu=new WeakMap,nd=function(){d(this,cr,null),d(this,Gi,null),d(this,Nn,null),d(this,Jr,null),d(this,ur,null),d(this,Un,null),d(this,zn,null),o(this,fr)&&(o(this,fr).removeEventListener("close",o(this,vu)),o(this,fr).removeEventListener("error",o(this,yu)),o(this,fr).close(),d(this,fr,null))},Ta=function(e){const r=o(this,cr)!==null||o(this,Gi)!==null||o(this,Nn)!==null||o(this,Jr)!==null||o(this,ur)!==null||o(this,Un)!==null||o(this,zn)!==null||o(this,fr)!==null;this.disposed||this.status==="disconnected"&&!r||(h(this,O,Gs).call(this,"error"),h(this,O,nd).call(this),d(this,lr,e??null),h(this,O,Zr).call(this,"disconnected"))},dg=function(){const e=o(this,nn).size>0;d(this,hr,null),d(this,Kr,null),d(this,Ja,1),o(this,nn).clear(),e&&this.dispatchEvent(new Tm("messages-changed"))},$S=function(){return this.status==="disconnected"};function hD(){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 dD(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function fD(n,t,e){return n==="single_session"?`${vS}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function xS(n){return n.replace(/^(?:\s*\n)+/,"")}function G2(n){let t=n;return t=t.replace(tD,""),t=t.replace(nD,""),t=t.replace(rD,""),t=xS(t),t}function pD(n){let t=n;return t=t.replace(oD,""),t=xS(t),t}function J2(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function mD(n){const t=n.createSocket(bD(n.serverURL,n.token));let e=!1,r,i;const s=new Promise((u,f)=>{r=u,i=f}),a=new ReadableStream({start(u){let f=!1;const p=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},y=_=>{const $=wD(_);if(!$)return;let H;try{H=JSON.parse($)}catch(L){const z=L instanceof Error?L:new Error(String(L));i(z),u.error(z);return}switch(H.type){case"acp-bridge-status":if(H.status==="ready"){let L;try{L=gD(H)}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(H.status==="error"||H.status==="exited"){const L=new Error(H.error??`ACP bridge ${H.status}`);e||i(L),u.error(L)}return;case"acp-bridge-message":u.enqueue(H.message);return}},v=()=>{var $;if(f)return;f=!0;const _=new Error("ACP bridge websocket closed");e||i(_),($=n.onDisconnect)==null||$.call(n,_),u.close()},S=()=>{var $;if(f)return;f=!0;const _=new Error("ACP bridge websocket error");e||i(_),($=n.onDisconnect)==null||$.call(n,_),u.error(_)};t.addEventListener("open",p),t.addEventListener("message",y),t.addEventListener("close",v),t.addEventListener("error",S)}}),l=new WritableStream({async write(u){await s,t.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){t.close()},abort(){t.close()}}),c=await s;return{stream:{readable:a,writable:l},socket:t,metadata:c}}function gD(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&&vD(i))return{agent:t,sessionIdStrategy:e,sessionCwd:r,tvArgs:i};throw new Error("ACP bridge ready status missing bootstrap metadata")}function vD(n){return Array.isArray(n)&&n.every(t=>typeof t=="string")}function yD(n){return sD.test(n)?n:`'${n.replace(/'/g,"'\\''")}'`}function wD(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 bD(n,t){const e=new URL(n);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/acp",e.search="",e.searchParams.set("token",t),e.hash="",e.toString()}function $m(n){return n instanceof Error?n.message:String(n)}const Y2="television.acpClientGUID",K2="television.acpMappedSessions",X2=1;var Ka;class SD{constructor(){m(this,Ka,new Map)}getActualSessionId(t){return o(this,Ka).get(t)??null}setActualSessionId(t,e){o(this,Ka).set(t,e)}clearActualSessionId(t){o(this,Ka).delete(t)}}Ka=new WeakMap;var Xa,wu,cn,rd,id,fg;class _D{constructor(t,e){m(this,cn);m(this,Xa);m(this,wu);d(this,Xa,t),d(this,wu,e)}getActualSessionId(t){const e=h(this,cn,id).call(this)[h(this,cn,rd).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const r=h(this,cn,id).call(this);r[h(this,cn,rd).call(this,t)]=e,h(this,cn,fg).call(this,r)}clearActualSessionId(t){const e=h(this,cn,id).call(this);delete e[h(this,cn,rd).call(this,t)],h(this,cn,fg).call(this,e)}}Xa=new WeakMap,wu=new WeakMap,cn=new WeakSet,rd=function(t){return JSON.stringify([o(this,wu),t])},id=function(){const t=o(this,Xa).getItem(K2);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!==X2?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},fg=function(t){const e={version:X2,entries:t};o(this,Xa).setItem(K2,JSON.stringify(e))};function PS(){return typeof window>"u"?null:window.localStorage}function AD(n){const t=n.getItem(Y2);if(t)return t;const e=X1().toLowerCase();return n.setItem(Y2,e),e}const Q2=4401,ED=401,Zh=1e3,kD=3e4;class sd extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class TD extends Ri{constructor(e){var a,l;super();C(this,"url");C(this,"name");C(this,"telemetryMeta");C(this,"status","unauthorized");C(this,"channels",new Map);C(this,"client");C(this,"acpClient");C(this,"_token");C(this,"attempting",!1);C(this,"nextRetryAt",null);C(this,"hasEverConnected",!1);C(this,"failedReconnectAttempts",0);C(this,"browserDemoMode",!1);C(this,"hasAuthRejected",!1);C(this,"bootState","pending");C(this,"serverVersion",null);C(this,"updateState",null);C(this,"decideBoot");C(this,"navigationPending");C(this,"createSocket");C(this,"createClient");C(this,"socket",null);C(this,"connectAttempt",0);C(this,"autoReconnect",!1);C(this,"retryTimer",null);C(this,"retryDelay",Zh);C(this,"visibilityEventTarget");C(this,"networkEventTarget");C(this,"onVisibilityChange");C(this,"onNetworkOnline");C(this,"telemetryActivityAgent");this.url=Cs(e.url),this.name=e.name,this.decideBoot=e.decideBoot??null,this.navigationPending=e.navigationPending??(()=>!1),this._token=e.token??null,this.telemetryMeta=e.telemetryMeta??null,this.createSocket=e.createSocket??(c=>new WebSocket(c)),this.createClient=e.createClient??((c,u,f)=>new Fk(c,{token:u??void 0,onUnauthorized:()=>this.handleAuthRejected(),...f?{telemetryMeta:f}:{}})),this.client=this.createClient(this.url,this._token,this.telemetryMeta);const r=e.mappedSessionStore??(e.acpStorage?new _D(e.acpStorage,this.url):new SD);this.acpClient=new uD({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?P$({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=Zh,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=Ld(e,this.renderOptions());return wi()?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:wi(),browserDemo:this.browserDemoMode}}getContentURL(e){const r=Ld(e,this.renderOptions()).contentURL;return r===null?null:new URL(r,this.url).toString()}async createChannel(e){const{channel:r}=await this.client.channels.create({name:e});return this.channels.set(r.id,structuredClone(r)),r}applyServerEvent(e){switch(e.type){case"channel-created":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new Ic("channels-changed"));break;case"channel-updated":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new Ic("channels-changed"));break;case"channel-removed":this.channels.delete(e.channelID),this.dispatchEvent(new Ic("channels-changed"));break;case"artifact-created":{const r=this.channels.get(e.channelID);r&&!ck(r).includes(e.artifact.id)&&(r.layout=[...r.layout,{artifactIds:[e.artifact.id],geometry:{...P8},size:{...D8}}]);break}case"artifact-removed":{const r=this.channels.get(e.channelID);r&&(r.layout=Fm(r.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"channel-changed":case"pinned-channels-changed":case"theme-changed":case"appearance-changed":case"artifact-focus":break;default:return RD(e,"server event")}}async attempt(){var i;this.attempting=!0,this.nextRetryAt=null,this.connectAttempt+=1,this.bootState="pending";const e=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this._token,this.telemetryMeta),this.setStatus("disconnected"),this.dispatchEvent(new jt("change"));const r=this.createSocket(CD(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=Zh,this.hasEverConnected=!0,this.failedReconnectAttempts=0,this.setStatus("connected"),(y=this.telemetryActivityAgent)==null||y.start(),s())},f=y=>{l||this.connectAttempt!==e||(l=!0,a(y))},p=async()=>{const y=this.hasEverConnected;try{const[{channels:v},S,_]=await Promise.all([this.client.channels.list(),this.client.display.get(),y?null:this.readDemoMode()]);y||(this.browserDemoMode=(_==null?void 0:_.browserExternalPages)===!0),this.channels=new Map(v.map($=>[$.id,structuredClone($)])),this.acpClient.setEnabled(S.acpEnabled),this.dispatchEvent(new jt("change")),y&&this.dispatchEvent(new Ic("channels-changed")),this.dispatchEvent(new Kh("server-event",{serverURL:this.url,event:{type:"channel-changed",channelID:S.focusedChannelId}})),this.dispatchEvent(new Kh("server-event",{serverURL:this.url,event:{type:"pinned-channels-changed",pinnedChannelIds:[...S.pinnedChannelIds]}})),u(),y&&this.connectAttempt===e&&this.dispatchEvent(new J8("server-reconnected",{serverURL:this.url}))}catch(v){if(LD(v)){f(new sd);return}f(v instanceof Error?v:new Error(String(v)))}};r.addEventListener("open",()=>{this.decideBoot===null&&(this.bootState="booted",this.navigationPending()||p())}),r.addEventListener("message",y=>{const v=DD(y);if(!v)return;if(v.type==="server-status"){const _=v;this.serverVersion=_.version,this.updateState=_.update??null;let $=!1;this.decideBoot!==null&&this.bootState==="pending"&&this.connectAttempt===e&&(this.decideBoot(_)==="boot"?(this.bootState="booted",$=!0):(this.bootState="halted",this.attempting=!1)),this.dispatchEvent(new Y8("server-status",{serverURL:this.url,message:_})),$?this.navigationPending()||p():this.bootState==="halted"&&!this.navigationPending()&&this.dispatchEvent(new jt("change"));return}if(!PD(v.type))return;const S=v;this.applyServerEvent(S),this.dispatchEvent(new Kh("server-event",{serverURL:this.url,event:S}))}),r.addEventListener("close",y=>{if(this.connectAttempt!==e)return;this.socket=null;const v=ID(y);if(!l){f(v===Q2?new sd:new Error("Connection closed before initialization"));return}if(c){if(v===Q2){this.handleAuthRejected();return}this.handleTransportFailure(new Error("Connection closed"))}}),r.addEventListener("error",()=>{if(this.connectAttempt===e){if(l){if(!c)return;this.handleTransportFailure(new Error("WebSocket error"));return}f(new Error("WebSocket connection failed"))}})}).then(()=>{this.attempting=!1},s=>{throw this.attempting=!1,this.handleAttemptFailure(s),s})}handleAuthRejected(){this.hasAuthRejected=!0,this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized")}handleAttemptFailure(e){if(e instanceof sd){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,kD),this.nextRetryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},e),this.dispatchEvent(new jt("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new jt("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=Zh,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:lk,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 jt("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function RD(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function CD(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 x$(e))r.searchParams.set(i,s);return r.hash="",r.toString()}function ID(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}const $D={"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},xD=new Set(Object.keys($D));function PD(n){return xD.has(n)}function DD(n){const t=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!t)return null;let e;try{e=JSON.parse(t)}catch{return null}return typeof e!="object"||e===null||!("type"in e)||typeof e.type!="string"?null:e}function LD(n){return n instanceof Ql&&n.status===ED}const OD="Local";var pr,Zn,Ai,DS,pg,LS,bu,Su,_u,Au,Eu;class MD extends Ri{constructor(e){super();m(this,Ai);C(this,"connection");C(this,"clientGUID");C(this,"acpStorage");C(this,"connectError",null);m(this,pr);m(this,Zn,!1);m(this,bu,()=>{o(this,Zn)||(h(this,Ai,LS).call(this),this.dispatchEvent(new jt("change")))});m(this,Su,e=>{o(this,Zn)||this.dispatchEvent(new Kh("server-event",{serverURL:e.serverURL,event:e.event}))});m(this,_u,()=>{o(this,Zn)||this.dispatchEvent(new Ic("channels-changed"))});m(this,Au,e=>{o(this,Zn)||this.dispatchEvent(new J8("server-reconnected",{serverURL:e.serverURL}))});m(this,Eu,e=>{o(this,Zn)||this.dispatchEvent(new Y8("server-status",{serverURL:e.serverURL,message:e.message}))});d(this,pr,e.localStore),this.acpStorage=e.acpStorage===void 0?PS():e.acpStorage,this.clientGUID=e.clientGUID??(this.acpStorage?AD(this.acpStorage):X1().toLowerCase());const r=Cs(e.serverURL);e.launchToken!==void 0&&e.launchToken!==null&&o(this,pr).set(ST(o(this,pr).get(),r,e.launchToken));const i=e.launchToken??b2(o(this,pr).get(),r),s=e.createSocket??(l=>new WebSocket(l)),a=e.createConnection??(l=>new TD(l));this.connection=a({url:r,name:e.connectionName??OD,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,bu)),this.connection.addEventListener("server-event",o(this,Su)),this.connection.addEventListener("channels-changed",o(this,_u)),this.connection.addEventListener("server-reconnected",o(this,Au)),this.connection.addEventListener("server-status",o(this,Eu))}get storedAuthToken(){return b2(o(this,pr).get(),this.connection.url)}async connect(){await h(this,Ai,DS).call(this,this.connection.token)}dispose(){o(this,Zn)||(d(this,Zn,!0),this.connection.removeEventListener("change",o(this,bu)),this.connection.removeEventListener("server-event",o(this,Su)),this.connection.removeEventListener("channels-changed",o(this,_u)),this.connection.removeEventListener("server-reconnected",o(this,Au)),this.connection.removeEventListener("server-status",o(this,Eu)),this.connection.dispose())}}pr=new WeakMap,Zn=new WeakMap,Ai=new WeakSet,DS=async function(e){if(!o(this,Zn)){h(this,Ai,pg).call(this,null);try{await this.connection.connect(e)}catch(r){h(this,Ai,pg).call(this,r instanceof sd?null:r instanceof Error?r.message:String(r))}}},pg=function(e){this.connectError!==e&&(this.connectError=e,this.dispatchEvent(new jt("change")))},LS=function(){if(this.connection.status!=="unauthorized"||!this.connection.hasAuthRejected)return;const e=o(this,pr).get(),r=_T(e,this.connection.url);r!==e&&o(this,pr).set(r),this.connection.token!==null&&this.connection.clearToken()},bu=new WeakMap,Su=new WeakMap,_u=new WeakMap,Au=new WeakMap,Eu=new WeakMap;const mg="tv-nav:",Fl="tv-reload",eb=100,ND=1e3,zD=60,UD=60,HD=24,ZD=30,qD=ZD*HD*UD*zD*ND;function bi(n){try{const t=new URL(n,window.location.href),e=t.searchParams.has(Fl);return t.searchParams.delete(Fl),t.origin===window.location.origin?`${t.pathname}${t.search}${t.hash}`:e?t.toString():n}catch{return n}}var ku,Qa,$e,Re,vo,Ke,OS,Ni,MS,gg,vg;class VD extends Ri{constructor(e,r){super();m(this,Ke);m(this,ku);m(this,Qa);m(this,$e,[]);m(this,Re,-1);m(this,vo,0);d(this,ku,e),d(this,Qa,bi(r)),h(this,Ke,OS).call(this)}get currentURL(){var e;return o(this,Re)===-1?null:((e=o(this,$e)[o(this,Re)])==null?void 0:e.url)??null}get canGoBack(){return o(this,Re)>-1}get canGoForward(){return o(this,Re)<o(this,$e).length-1}get entries(){return o(this,$e).map(e=>({...e}))}get cursor(){return o(this,Re)}navigate(e){const r=bi(e);if(r===o(this,Qa)){if(o(this,Re)===-1)return;d(this,Re,-1),h(this,Ke,Ni).call(this);return}o(this,Re)<o(this,$e).length-1&&d(this,$e,o(this,$e).slice(0,o(this,Re)+1)),o(this,$e).push({url:r}),d(this,Re,o(this,$e).length-1),h(this,Ke,gg).call(this),h(this,Ke,Ni).call(this)}replace(e){var i;if(o(this,Re)===-1){this.navigate(e);return}const r=bi(e);if(r===o(this,Qa)){d(this,$e,o(this,$e).filter((s,a)=>a!==o(this,Re))),d(this,Re,-1),h(this,Ke,Ni).call(this);return}((i=o(this,$e)[o(this,Re)])==null?void 0:i.url)!==r&&(d(this,$e,o(this,$e).map((s,a)=>a===o(this,Re)?{url:r}:s)),h(this,Ke,Ni).call(this))}back(){o(this,Re)!==-1&&(d(this,Re,o(this,Re)-1),h(this,Ke,Ni).call(this))}forward(){this.canGoForward&&(d(this,Re,o(this,Re)+1),h(this,Ke,Ni).call(this))}reset(){o(this,Re)===-1&&o(this,$e).length===0||(d(this,$e,[]),d(this,Re,-1),h(this,Ke,Ni).call(this))}}ku=new WeakMap,Qa=new WeakMap,$e=new WeakMap,Re=new WeakMap,vo=new WeakMap,Ke=new WeakSet,OS=function(){const e=localStorage.getItem(o(this,Ke,vg));if(e!==null)try{const r=JSON.parse(e);if(!NS(r))return;d(this,$e,r.entries.map(i=>({url:i.url}))),d(this,Re,r.cursor),d(this,vo,r.lastWritten),h(this,Ke,gg).call(this)}catch{d(this,$e,[]),d(this,Re,-1),d(this,vo,0)}},Ni=function(){d(this,vo,Date.now());try{localStorage.setItem(o(this,Ke,vg),JSON.stringify(h(this,Ke,MS).call(this)))}catch(e){if(!jD(e))throw e}this.dispatchEvent(new jt("change"))},MS=function(){return{v:1,entries:o(this,$e).map(e=>({...e})),cursor:o(this,Re),lastWritten:o(this,vo)}},gg=function(){if(o(this,$e).length<=eb)return;const e=o(this,$e).length-eb;d(this,$e,o(this,$e).slice(e)),d(this,Re,Math.max(-1,o(this,Re)-e))},vg=function(){return FD(o(this,ku))};function FD(n){return`${mg}${n}`}function BD(n){const t=Date.now()-qD,e=[];for(let r=0;r<localStorage.length;r+=1){const i=localStorage.key(r);if(!(i!=null&&i.startsWith(mg)))continue;const s=i.slice(mg.length),a=localStorage.getItem(i);if(a===null)continue;let l;try{l=JSON.parse(a)}catch{e.push(i);continue}if(!NS(l)){e.push(i);continue}!n.has(s)&&l.lastWritten<t&&e.push(i)}for(const r of e)localStorage.removeItem(r)}function jD(n){return n instanceof DOMException&&n.name==="QuotaExceededError"}function NS(n){if(typeof n!="object"||n===null)return!1;const t=n;if(t.v!==1||!Array.isArray(t.entries))return!1;const e=t.cursor;return typeof e!="number"||!Number.isInteger(e)||typeof t.lastWritten!="number"||!Number.isFinite(t.lastWritten)||e<-1||e>=t.entries.length?!1:t.entries.every(r=>typeof r=="object"&&r!==null&&typeof r.url=="string")}const xm="tv-channel-sidebar-collapsed";var yo;class WD{constructor(t){m(this,yo);d(this,yo,t)}read(){return o(this,yo).getItem(xm)==="true"}setCollapsed(t){try{t?o(this,yo).setItem(xm,"true"):o(this,yo).removeItem(xm)}catch{}}}yo=new WeakMap;const Pm="tv-channel-sidebar-width",yg=160,wg=350,qh=260,GD=/^-?\d+$/;var wo;class JD{constructor(t){m(this,wo);d(this,wo,t)}read(){const t=o(this,wo).getItem(Pm);if(t===null||!GD.test(t))return null;const e=BigInt(t);return e<BigInt(yg)?yg:e>BigInt(wg)?wg:Number(e)}commit(t){const e=zS(Math.round(t));try{o(this,wo).setItem(Pm,String(e))}catch{}return e}clear(){try{o(this,wo).removeItem(Pm)}catch{}}}wo=new WeakMap;function zS(n){return Math.min(Math.max(n,yg),wg)}const YD="1.4.27";function cv(n=YD){return n!==void 0&&n.length>0?n:"0.0.0"}function uv(){let n=!1;return{get pending(){return n},begin(t){n||(n=!0,t())}}}const bg="tv-reload-attempted";function KD(n){return n.originMatch?n.marker!==null&&n.bundleVersion===n.serverVersion?{action:"signal-autoreloaded",fromVersion:n.marker.fromVersion,toVersion:n.bundleVersion}:Wk(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 XD(n){const t=n.getItem(bg);if(t===null)return null;let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!="object")return null;const r=e;return typeof r.serverVersion!="string"||typeof r.fromVersion!="string"?null:{serverVersion:r.serverVersion,fromVersion:r.fromVersion}}function QD(n){const t=n.storage!==void 0?n.storage:typeof sessionStorage<"u"?sessionStorage:null,e=n.reload??(()=>location.reload()),r=n.navigationLatch??uv(),i=n.bundleVersion??cv();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 f=s;s=null,u.sendTelemetrySignal("client_autoreloaded",{from_version:f.fromVersion,to_version:f.toVersion})},l=u=>{if(r.pending)return;const f=KD({bundleVersion:i,serverVersion:u.message.version,originMatch:u.serverURL===n.primaryServerURL,marker:XD(t)});switch(f.action){case"reload":t.setItem(bg,JSON.stringify(f.marker)),r.begin(e);return;case"signal-autoreloaded":t.removeItem(bg),s={fromVersion:f.fromVersion,toVersion:f.toVersion},a();return;case"none":return}},c=()=>{a()};return n.owner.addEventListener("server-status",l),n.owner.addEventListener("change",c),{dispose(){n.owner.removeEventListener("server-status",l),n.owner.removeEventListener("change",c)}}}function eL(n){const t=wi(n.search),e=L6(n.search),r=e!==null&&qf(e)?e:null;return{electron:t,shellVersion:r}}function tL(n){return!n.electron||n.requiredDesktopVersion===null||!qf(n.requiredDesktopVersion)?!1:n.shellVersion===null?!0:n.shellVersion===Cd?!1:K1(n.requiredDesktopVersion,n.shellVersion)}const nL=`# Desktop app update required
65
+ `)},ka=function(e){const r=`${e}-${o(this,Ja)}`;return d(this,Ja,o(this,Ja)+1),r},lg=function(e){for(const r of o(this,nn).values())if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===e)return r;return null},cg=function(){if(!o(this,ur))throw new Error("ACP session is not ready");return o(this,ur)},ed=function(){if(!o(this,cr))throw new Error("ACP connection is not ready");return o(this,cr)},IS=function(){var r;const e=(r=o(this,zn))==null?void 0:r.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},td=function(){var r;if(o(this,dr)==="single_session")return h(this,O,hg).call(this,`${vS}-${(o(this,Hn).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,O,ug).call(this,e)},ug=function(e){return h(this,O,hg).call(this,fD(o(this,dr),e,o(this,Hn).clientGUID??"default-client"))},hg=function(e){var r;return((r=o(this,zn))==null?void 0:r.sessionIdStrategy)==="deterministic"&&o(this,Ga)>0?`${e}:epoch-${o(this,Ga)}`:e},vu=new WeakMap,yu=new WeakMap,nd=function(){d(this,cr,null),d(this,Gi,null),d(this,Nn,null),d(this,Jr,null),d(this,ur,null),d(this,Un,null),d(this,zn,null),o(this,fr)&&(o(this,fr).removeEventListener("close",o(this,vu)),o(this,fr).removeEventListener("error",o(this,yu)),o(this,fr).close(),d(this,fr,null))},Ta=function(e){const r=o(this,cr)!==null||o(this,Gi)!==null||o(this,Nn)!==null||o(this,Jr)!==null||o(this,ur)!==null||o(this,Un)!==null||o(this,zn)!==null||o(this,fr)!==null;this.disposed||this.status==="disconnected"&&!r||(h(this,O,Gs).call(this,"error"),h(this,O,nd).call(this),d(this,lr,e??null),h(this,O,Zr).call(this,"disconnected"))},dg=function(){const e=o(this,nn).size>0;d(this,hr,null),d(this,Kr,null),d(this,Ja,1),o(this,nn).clear(),e&&this.dispatchEvent(new Tm("messages-changed"))},$S=function(){return this.status==="disconnected"};function hD(){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 dD(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function fD(n,t,e){return n==="single_session"?`${vS}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function xS(n){return n.replace(/^(?:\s*\n)+/,"")}function G2(n){let t=n;return t=t.replace(tD,""),t=t.replace(nD,""),t=t.replace(rD,""),t=xS(t),t}function pD(n){let t=n;return t=t.replace(oD,""),t=xS(t),t}function J2(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function mD(n){const t=n.createSocket(bD(n.serverURL,n.token));let e=!1,r,i;const s=new Promise((u,f)=>{r=u,i=f}),a=new ReadableStream({start(u){let f=!1;const p=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},y=_=>{const $=wD(_);if(!$)return;let H;try{H=JSON.parse($)}catch(L){const z=L instanceof Error?L:new Error(String(L));i(z),u.error(z);return}switch(H.type){case"acp-bridge-status":if(H.status==="ready"){let L;try{L=gD(H)}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(H.status==="error"||H.status==="exited"){const L=new Error(H.error??`ACP bridge ${H.status}`);e||i(L),u.error(L)}return;case"acp-bridge-message":u.enqueue(H.message);return}},v=()=>{var $;if(f)return;f=!0;const _=new Error("ACP bridge websocket closed");e||i(_),($=n.onDisconnect)==null||$.call(n,_),u.close()},S=()=>{var $;if(f)return;f=!0;const _=new Error("ACP bridge websocket error");e||i(_),($=n.onDisconnect)==null||$.call(n,_),u.error(_)};t.addEventListener("open",p),t.addEventListener("message",y),t.addEventListener("close",v),t.addEventListener("error",S)}}),l=new WritableStream({async write(u){await s,t.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){t.close()},abort(){t.close()}}),c=await s;return{stream:{readable:a,writable:l},socket:t,metadata:c}}function gD(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&&vD(i))return{agent:t,sessionIdStrategy:e,sessionCwd:r,tvArgs:i};throw new Error("ACP bridge ready status missing bootstrap metadata")}function vD(n){return Array.isArray(n)&&n.every(t=>typeof t=="string")}function yD(n){return sD.test(n)?n:`'${n.replace(/'/g,"'\\''")}'`}function wD(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 bD(n,t){const e=new URL(n);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/acp",e.search="",e.searchParams.set("token",t),e.hash="",e.toString()}function $m(n){return n instanceof Error?n.message:String(n)}const Y2="television.acpClientGUID",K2="television.acpMappedSessions",X2=1;var Ka;class SD{constructor(){m(this,Ka,new Map)}getActualSessionId(t){return o(this,Ka).get(t)??null}setActualSessionId(t,e){o(this,Ka).set(t,e)}clearActualSessionId(t){o(this,Ka).delete(t)}}Ka=new WeakMap;var Xa,wu,cn,rd,id,fg;class _D{constructor(t,e){m(this,cn);m(this,Xa);m(this,wu);d(this,Xa,t),d(this,wu,e)}getActualSessionId(t){const e=h(this,cn,id).call(this)[h(this,cn,rd).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const r=h(this,cn,id).call(this);r[h(this,cn,rd).call(this,t)]=e,h(this,cn,fg).call(this,r)}clearActualSessionId(t){const e=h(this,cn,id).call(this);delete e[h(this,cn,rd).call(this,t)],h(this,cn,fg).call(this,e)}}Xa=new WeakMap,wu=new WeakMap,cn=new WeakSet,rd=function(t){return JSON.stringify([o(this,wu),t])},id=function(){const t=o(this,Xa).getItem(K2);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!==X2?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},fg=function(t){const e={version:X2,entries:t};o(this,Xa).setItem(K2,JSON.stringify(e))};function PS(){return typeof window>"u"?null:window.localStorage}function AD(n){const t=n.getItem(Y2);if(t)return t;const e=X1().toLowerCase();return n.setItem(Y2,e),e}const Q2=4401,ED=401,Zh=1e3,kD=3e4;class sd extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class TD extends Ri{constructor(e){var a,l;super();C(this,"url");C(this,"name");C(this,"telemetryMeta");C(this,"status","unauthorized");C(this,"channels",new Map);C(this,"client");C(this,"acpClient");C(this,"_token");C(this,"attempting",!1);C(this,"nextRetryAt",null);C(this,"hasEverConnected",!1);C(this,"failedReconnectAttempts",0);C(this,"browserDemoMode",!1);C(this,"hasAuthRejected",!1);C(this,"bootState","pending");C(this,"serverVersion",null);C(this,"updateState",null);C(this,"decideBoot");C(this,"navigationPending");C(this,"createSocket");C(this,"createClient");C(this,"socket",null);C(this,"connectAttempt",0);C(this,"autoReconnect",!1);C(this,"retryTimer",null);C(this,"retryDelay",Zh);C(this,"visibilityEventTarget");C(this,"networkEventTarget");C(this,"onVisibilityChange");C(this,"onNetworkOnline");C(this,"telemetryActivityAgent");this.url=Cs(e.url),this.name=e.name,this.decideBoot=e.decideBoot??null,this.navigationPending=e.navigationPending??(()=>!1),this._token=e.token??null,this.telemetryMeta=e.telemetryMeta??null,this.createSocket=e.createSocket??(c=>new WebSocket(c)),this.createClient=e.createClient??((c,u,f)=>new Fk(c,{token:u??void 0,onUnauthorized:()=>this.handleAuthRejected(),...f?{telemetryMeta:f}:{}})),this.client=this.createClient(this.url,this._token,this.telemetryMeta);const r=e.mappedSessionStore??(e.acpStorage?new _D(e.acpStorage,this.url):new SD);this.acpClient=new uD({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?P$({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=Zh,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=Ld(e,this.renderOptions());return wi()?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:wi(),browserDemo:this.browserDemoMode}}getContentURL(e){const r=Ld(e,this.renderOptions()).contentURL;return r===null?null:new URL(r,this.url).toString()}async createChannel(e){const{channel:r}=await this.client.channels.create({name:e});return this.channels.set(r.id,structuredClone(r)),r}applyServerEvent(e){switch(e.type){case"channel-created":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new Ic("channels-changed"));break;case"channel-updated":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new Ic("channels-changed"));break;case"channel-removed":this.channels.delete(e.channelID),this.dispatchEvent(new Ic("channels-changed"));break;case"artifact-created":{const r=this.channels.get(e.channelID);r&&!ck(r).includes(e.artifact.id)&&(r.layout=[...r.layout,{artifactIds:[e.artifact.id],geometry:{...P8},size:{...D8}}]);break}case"artifact-removed":{const r=this.channels.get(e.channelID);r&&(r.layout=Fm(r.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"channel-changed":case"pinned-channels-changed":case"theme-changed":case"appearance-changed":case"artifact-focus":break;default:return RD(e,"server event")}}async attempt(){var i;this.attempting=!0,this.nextRetryAt=null,this.connectAttempt+=1,this.bootState="pending";const e=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this._token,this.telemetryMeta),this.setStatus("disconnected"),this.dispatchEvent(new jt("change"));const r=this.createSocket(CD(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=Zh,this.hasEverConnected=!0,this.failedReconnectAttempts=0,this.setStatus("connected"),(y=this.telemetryActivityAgent)==null||y.start(),s())},f=y=>{l||this.connectAttempt!==e||(l=!0,a(y))},p=async()=>{const y=this.hasEverConnected;try{const[{channels:v},S,_]=await Promise.all([this.client.channels.list(),this.client.display.get(),y?null:this.readDemoMode()]);y||(this.browserDemoMode=(_==null?void 0:_.browserExternalPages)===!0),this.channels=new Map(v.map($=>[$.id,structuredClone($)])),this.acpClient.setEnabled(S.acpEnabled),this.dispatchEvent(new jt("change")),y&&this.dispatchEvent(new Ic("channels-changed")),this.dispatchEvent(new Kh("server-event",{serverURL:this.url,event:{type:"channel-changed",channelID:S.focusedChannelId}})),this.dispatchEvent(new Kh("server-event",{serverURL:this.url,event:{type:"pinned-channels-changed",pinnedChannelIds:[...S.pinnedChannelIds]}})),u(),y&&this.connectAttempt===e&&this.dispatchEvent(new J8("server-reconnected",{serverURL:this.url}))}catch(v){if(LD(v)){f(new sd);return}f(v instanceof Error?v:new Error(String(v)))}};r.addEventListener("open",()=>{this.decideBoot===null&&(this.bootState="booted",this.navigationPending()||p())}),r.addEventListener("message",y=>{const v=DD(y);if(!v)return;if(v.type==="server-status"){const _=v;this.serverVersion=_.version,this.updateState=_.update??null;let $=!1;this.decideBoot!==null&&this.bootState==="pending"&&this.connectAttempt===e&&(this.decideBoot(_)==="boot"?(this.bootState="booted",$=!0):(this.bootState="halted",this.attempting=!1)),this.dispatchEvent(new Y8("server-status",{serverURL:this.url,message:_})),$?this.navigationPending()||p():this.bootState==="halted"&&!this.navigationPending()&&this.dispatchEvent(new jt("change"));return}if(!PD(v.type))return;const S=v;this.applyServerEvent(S),this.dispatchEvent(new Kh("server-event",{serverURL:this.url,event:S}))}),r.addEventListener("close",y=>{if(this.connectAttempt!==e)return;this.socket=null;const v=ID(y);if(!l){f(v===Q2?new sd:new Error("Connection closed before initialization"));return}if(c){if(v===Q2){this.handleAuthRejected();return}this.handleTransportFailure(new Error("Connection closed"))}}),r.addEventListener("error",()=>{if(this.connectAttempt===e){if(l){if(!c)return;this.handleTransportFailure(new Error("WebSocket error"));return}f(new Error("WebSocket connection failed"))}})}).then(()=>{this.attempting=!1},s=>{throw this.attempting=!1,this.handleAttemptFailure(s),s})}handleAuthRejected(){this.hasAuthRejected=!0,this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized")}handleAttemptFailure(e){if(e instanceof sd){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,kD),this.nextRetryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},e),this.dispatchEvent(new jt("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new jt("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=Zh,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:lk,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 jt("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function RD(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function CD(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 x$(e))r.searchParams.set(i,s);return r.hash="",r.toString()}function ID(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}const $D={"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},xD=new Set(Object.keys($D));function PD(n){return xD.has(n)}function DD(n){const t=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!t)return null;let e;try{e=JSON.parse(t)}catch{return null}return typeof e!="object"||e===null||!("type"in e)||typeof e.type!="string"?null:e}function LD(n){return n instanceof Ql&&n.status===ED}const OD="Local";var pr,Zn,Ai,DS,pg,LS,bu,Su,_u,Au,Eu;class MD extends Ri{constructor(e){super();m(this,Ai);C(this,"connection");C(this,"clientGUID");C(this,"acpStorage");C(this,"connectError",null);m(this,pr);m(this,Zn,!1);m(this,bu,()=>{o(this,Zn)||(h(this,Ai,LS).call(this),this.dispatchEvent(new jt("change")))});m(this,Su,e=>{o(this,Zn)||this.dispatchEvent(new Kh("server-event",{serverURL:e.serverURL,event:e.event}))});m(this,_u,()=>{o(this,Zn)||this.dispatchEvent(new Ic("channels-changed"))});m(this,Au,e=>{o(this,Zn)||this.dispatchEvent(new J8("server-reconnected",{serverURL:e.serverURL}))});m(this,Eu,e=>{o(this,Zn)||this.dispatchEvent(new Y8("server-status",{serverURL:e.serverURL,message:e.message}))});d(this,pr,e.localStore),this.acpStorage=e.acpStorage===void 0?PS():e.acpStorage,this.clientGUID=e.clientGUID??(this.acpStorage?AD(this.acpStorage):X1().toLowerCase());const r=Cs(e.serverURL);e.launchToken!==void 0&&e.launchToken!==null&&o(this,pr).set(ST(o(this,pr).get(),r,e.launchToken));const i=e.launchToken??b2(o(this,pr).get(),r),s=e.createSocket??(l=>new WebSocket(l)),a=e.createConnection??(l=>new TD(l));this.connection=a({url:r,name:e.connectionName??OD,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,bu)),this.connection.addEventListener("server-event",o(this,Su)),this.connection.addEventListener("channels-changed",o(this,_u)),this.connection.addEventListener("server-reconnected",o(this,Au)),this.connection.addEventListener("server-status",o(this,Eu))}get storedAuthToken(){return b2(o(this,pr).get(),this.connection.url)}async connect(){await h(this,Ai,DS).call(this,this.connection.token)}dispose(){o(this,Zn)||(d(this,Zn,!0),this.connection.removeEventListener("change",o(this,bu)),this.connection.removeEventListener("server-event",o(this,Su)),this.connection.removeEventListener("channels-changed",o(this,_u)),this.connection.removeEventListener("server-reconnected",o(this,Au)),this.connection.removeEventListener("server-status",o(this,Eu)),this.connection.dispose())}}pr=new WeakMap,Zn=new WeakMap,Ai=new WeakSet,DS=async function(e){if(!o(this,Zn)){h(this,Ai,pg).call(this,null);try{await this.connection.connect(e)}catch(r){h(this,Ai,pg).call(this,r instanceof sd?null:r instanceof Error?r.message:String(r))}}},pg=function(e){this.connectError!==e&&(this.connectError=e,this.dispatchEvent(new jt("change")))},LS=function(){if(this.connection.status!=="unauthorized"||!this.connection.hasAuthRejected)return;const e=o(this,pr).get(),r=_T(e,this.connection.url);r!==e&&o(this,pr).set(r),this.connection.token!==null&&this.connection.clearToken()},bu=new WeakMap,Su=new WeakMap,_u=new WeakMap,Au=new WeakMap,Eu=new WeakMap;const mg="tv-nav:",Fl="tv-reload",eb=100,ND=1e3,zD=60,UD=60,HD=24,ZD=30,qD=ZD*HD*UD*zD*ND;function bi(n){try{const t=new URL(n,window.location.href),e=t.searchParams.has(Fl);return t.searchParams.delete(Fl),t.origin===window.location.origin?`${t.pathname}${t.search}${t.hash}`:e?t.toString():n}catch{return n}}var ku,Qa,$e,Re,vo,Ke,OS,Ni,MS,gg,vg;class VD extends Ri{constructor(e,r){super();m(this,Ke);m(this,ku);m(this,Qa);m(this,$e,[]);m(this,Re,-1);m(this,vo,0);d(this,ku,e),d(this,Qa,bi(r)),h(this,Ke,OS).call(this)}get currentURL(){var e;return o(this,Re)===-1?null:((e=o(this,$e)[o(this,Re)])==null?void 0:e.url)??null}get canGoBack(){return o(this,Re)>-1}get canGoForward(){return o(this,Re)<o(this,$e).length-1}get entries(){return o(this,$e).map(e=>({...e}))}get cursor(){return o(this,Re)}navigate(e){const r=bi(e);if(r===o(this,Qa)){if(o(this,Re)===-1)return;d(this,Re,-1),h(this,Ke,Ni).call(this);return}o(this,Re)<o(this,$e).length-1&&d(this,$e,o(this,$e).slice(0,o(this,Re)+1)),o(this,$e).push({url:r}),d(this,Re,o(this,$e).length-1),h(this,Ke,gg).call(this),h(this,Ke,Ni).call(this)}replace(e){var i;if(o(this,Re)===-1){this.navigate(e);return}const r=bi(e);if(r===o(this,Qa)){d(this,$e,o(this,$e).filter((s,a)=>a!==o(this,Re))),d(this,Re,-1),h(this,Ke,Ni).call(this);return}((i=o(this,$e)[o(this,Re)])==null?void 0:i.url)!==r&&(d(this,$e,o(this,$e).map((s,a)=>a===o(this,Re)?{url:r}:s)),h(this,Ke,Ni).call(this))}back(){o(this,Re)!==-1&&(d(this,Re,o(this,Re)-1),h(this,Ke,Ni).call(this))}forward(){this.canGoForward&&(d(this,Re,o(this,Re)+1),h(this,Ke,Ni).call(this))}reset(){o(this,Re)===-1&&o(this,$e).length===0||(d(this,$e,[]),d(this,Re,-1),h(this,Ke,Ni).call(this))}}ku=new WeakMap,Qa=new WeakMap,$e=new WeakMap,Re=new WeakMap,vo=new WeakMap,Ke=new WeakSet,OS=function(){const e=localStorage.getItem(o(this,Ke,vg));if(e!==null)try{const r=JSON.parse(e);if(!NS(r))return;d(this,$e,r.entries.map(i=>({url:i.url}))),d(this,Re,r.cursor),d(this,vo,r.lastWritten),h(this,Ke,gg).call(this)}catch{d(this,$e,[]),d(this,Re,-1),d(this,vo,0)}},Ni=function(){d(this,vo,Date.now());try{localStorage.setItem(o(this,Ke,vg),JSON.stringify(h(this,Ke,MS).call(this)))}catch(e){if(!jD(e))throw e}this.dispatchEvent(new jt("change"))},MS=function(){return{v:1,entries:o(this,$e).map(e=>({...e})),cursor:o(this,Re),lastWritten:o(this,vo)}},gg=function(){if(o(this,$e).length<=eb)return;const e=o(this,$e).length-eb;d(this,$e,o(this,$e).slice(e)),d(this,Re,Math.max(-1,o(this,Re)-e))},vg=function(){return FD(o(this,ku))};function FD(n){return`${mg}${n}`}function BD(n){const t=Date.now()-qD,e=[];for(let r=0;r<localStorage.length;r+=1){const i=localStorage.key(r);if(!(i!=null&&i.startsWith(mg)))continue;const s=i.slice(mg.length),a=localStorage.getItem(i);if(a===null)continue;let l;try{l=JSON.parse(a)}catch{e.push(i);continue}if(!NS(l)){e.push(i);continue}!n.has(s)&&l.lastWritten<t&&e.push(i)}for(const r of e)localStorage.removeItem(r)}function jD(n){return n instanceof DOMException&&n.name==="QuotaExceededError"}function NS(n){if(typeof n!="object"||n===null)return!1;const t=n;if(t.v!==1||!Array.isArray(t.entries))return!1;const e=t.cursor;return typeof e!="number"||!Number.isInteger(e)||typeof t.lastWritten!="number"||!Number.isFinite(t.lastWritten)||e<-1||e>=t.entries.length?!1:t.entries.every(r=>typeof r=="object"&&r!==null&&typeof r.url=="string")}const xm="tv-channel-sidebar-collapsed";var yo;class WD{constructor(t){m(this,yo);d(this,yo,t)}read(){return o(this,yo).getItem(xm)==="true"}setCollapsed(t){try{t?o(this,yo).setItem(xm,"true"):o(this,yo).removeItem(xm)}catch{}}}yo=new WeakMap;const Pm="tv-channel-sidebar-width",yg=160,wg=350,qh=260,GD=/^-?\d+$/;var wo;class JD{constructor(t){m(this,wo);d(this,wo,t)}read(){const t=o(this,wo).getItem(Pm);if(t===null||!GD.test(t))return null;const e=BigInt(t);return e<BigInt(yg)?yg:e>BigInt(wg)?wg:Number(e)}commit(t){const e=zS(Math.round(t));try{o(this,wo).setItem(Pm,String(e))}catch{}return e}clear(){try{o(this,wo).removeItem(Pm)}catch{}}}wo=new WeakMap;function zS(n){return Math.min(Math.max(n,yg),wg)}const YD="1.4.29";function cv(n=YD){return n!==void 0&&n.length>0?n:"0.0.0"}function uv(){let n=!1;return{get pending(){return n},begin(t){n||(n=!0,t())}}}const bg="tv-reload-attempted";function KD(n){return n.originMatch?n.marker!==null&&n.bundleVersion===n.serverVersion?{action:"signal-autoreloaded",fromVersion:n.marker.fromVersion,toVersion:n.bundleVersion}:Wk(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 XD(n){const t=n.getItem(bg);if(t===null)return null;let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!="object")return null;const r=e;return typeof r.serverVersion!="string"||typeof r.fromVersion!="string"?null:{serverVersion:r.serverVersion,fromVersion:r.fromVersion}}function QD(n){const t=n.storage!==void 0?n.storage:typeof sessionStorage<"u"?sessionStorage:null,e=n.reload??(()=>location.reload()),r=n.navigationLatch??uv(),i=n.bundleVersion??cv();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 f=s;s=null,u.sendTelemetrySignal("client_autoreloaded",{from_version:f.fromVersion,to_version:f.toVersion})},l=u=>{if(r.pending)return;const f=KD({bundleVersion:i,serverVersion:u.message.version,originMatch:u.serverURL===n.primaryServerURL,marker:XD(t)});switch(f.action){case"reload":t.setItem(bg,JSON.stringify(f.marker)),r.begin(e);return;case"signal-autoreloaded":t.removeItem(bg),s={fromVersion:f.fromVersion,toVersion:f.toVersion},a();return;case"none":return}},c=()=>{a()};return n.owner.addEventListener("server-status",l),n.owner.addEventListener("change",c),{dispose(){n.owner.removeEventListener("server-status",l),n.owner.removeEventListener("change",c)}}}function eL(n){const t=wi(n.search),e=L6(n.search),r=e!==null&&qf(e)?e:null;return{electron:t,shellVersion:r}}function tL(n){return!n.electron||n.requiredDesktopVersion===null||!qf(n.requiredDesktopVersion)?!1:n.shellVersion===null?!0:n.shellVersion===Cd?!1:K1(n.requiredDesktopVersion,n.shellVersion)}const nL=`# Desktop app update required
66
66
 
67
67
  This version of the Television desktop app does not work with this server and needs to be updated. The new version has already downloaded and installs when you restart the app.`,rL=`# Desktop app update required
68
68
 
@@ -259,7 +259,7 @@ Television updates its desktop app automatically. Version {version} has download
259
259
  </div>
260
260
  </nav>
261
261
  ${o(this,qn).overlayTemplate()}
262
- `}disconnected(){o(this,qn).disconnect()}}qn=new WeakMap,af=new WeakMap;const GM=dn(WM),JM=1280,YM=800,vb=.4,yb=.4,z_=280,wb=180,KM=14,XM=45,QM=16,bb=64,eN=90,tN=1,nN=24,rN=230,iN=230;function sN(n,t){const{expandedSidebarWidth:e,expandedToggleLeft:r,collapsedToggleLeft:i,toggleWidth:s,toggleSwitcherGap:a,collapsedLeadReservation:l,hasSwitcher:c}=t,u=e*(1-n),f=e-r,p=Math.max(u-f,i),y=i+f,v=Math.max(0,Math.min(s,u-p)),S=Bg((u-y)/(e-y)),_=s+a,$=i+_,H=c?Bg(($-u)/_):0;let L=n*l;if(l>e){const z=1-$/e,P=Math.min(1,n/z);L=n*e+P*(l-e)}return{sidebarBoundary:u,toggleLeft:p,toggleWipe:v,titlebarOpacity:S,switcherOpacity:H,leadReservation:L}}function oN(n,t,e,r){const i=r*Math.abs(t-n);if(i===0)return t;const a=1-(1-Bg(e/i))**2;return n+(t-n)*a}function Bg(n){return Math.max(0,Math.min(1,n))}var ei,is,ti,fl,pl,Io,_i,dd,jg;class aN{constructor(t){m(this,_i);m(this,ei,null);m(this,is,0);m(this,ti);m(this,fl);m(this,pl);m(this,Io,1);d(this,ti,t),d(this,fl,t),d(this,pl,t)}get boundary(){return h(this,_i,dd).call(this),o(this,ti)}move(t){const e=this.boundary;if(h(this,_i,jg).call(this),d(this,fl,e),d(this,pl,t.target),d(this,Io,t.width),t.onFrame(e),matchMedia("(prefers-reduced-motion: reduce)").matches||Math.abs(t.target-e)<Number.EPSILON){d(this,ti,t.target),t.onFrame(t.target),t.onFinish(t.target);return}const r=Math.abs(t.target-e)/t.width,i=t.root.animate([{},{}],{duration:wb*r,easing:"linear"});i.id="sidebar-collapse-boundary",d(this,ei,i);const s=()=>{if(o(this,ei)===i){if(h(this,_i,dd).call(this),t.onFrame(o(this,ti)),i.playState==="finished"){d(this,ei,null),d(this,is,0),d(this,ti,t.target),t.onFrame(t.target),t.onFinish(t.target);return}d(this,is,requestAnimationFrame(s))}};d(this,is,requestAnimationFrame(s))}cancel(){h(this,_i,dd).call(this),h(this,_i,jg).call(this)}}ei=new WeakMap,is=new WeakMap,ti=new WeakMap,fl=new WeakMap,pl=new WeakMap,Io=new WeakMap,_i=new WeakSet,dd=function(){const t=o(this,ei);if(t===null)return;const e=oN(1-o(this,fl)/o(this,Io),1-o(this,pl)/o(this,Io),Number(t.currentTime??0),wb);d(this,ti,o(this,Io)*(1-e))},jg=function(){var t;cancelAnimationFrame(o(this,is)),d(this,is,0),(t=o(this,ei))==null||t.cancel(),d(this,ei,null)};const U_="television-active-theme",fv="tv-theme";let Vi=null,Si=null,Ts=null,Rs=null,zi=null,Sb=0,Zd=0;function lN(n){const t=document.createElement("link"),e=new URL("/theme/theme.css",n);e.searchParams.set(fv,pv()),t.rel="stylesheet",t.href=e.toString(),t.dataset.televisionStyle=U_;const r=()=>{Vi===t&&document.dispatchEvent(new Event("television-theme-styles-changed"))};return t.addEventListener("load",r,{once:!0}),t.addEventListener("error",r,{once:!0}),Vi==null||Vi.remove(),document.head.append(t),Vi=t,t}function cN(){Vi&&(Vi.remove(),Vi=null,document.dispatchEvent(new Event("television-theme-styles-changed")))}function _b(n){const t=document.createElement("script"),e=new URL("/theme/main.js",n);return e.searchParams.set(fv,pv()),t.src=e.toString(),t.dataset.televisionScript=U_,Si==null||Si.remove(),document.head.append(t),Si=t,t}function uN(){Si==null||Si.remove(),Si=null}function hN(){return Si}async function dN(n,t,e){const r=H_();if(t===null)return;let i;try{i=await e()}catch{return}if(r!==Zd)return;const s=i.themes.find(f=>f.id===t);if(s===void 0)return;const a=document.querySelector("#app"),l=document.querySelector("#foreground-overlay");if(a===null||l===null)return;const c=s.enableIframeBackgroundJS===!0?Ab(n,"background"):null,u=s.enableIframeOverlayJS===!0?Ab(n,"overlay"):null;r===Zd&&(c!==null&&(a.before(c),Ts=c),u!==null&&(l.after(u),Rs=u))}function fN(){H_()}function H_(){return Zd+=1,Ts==null||Ts.remove(),Rs==null||Rs.remove(),Ts=null,Rs=null,Zd}function Ab(n,t){const e=t==="background"?new URL("/theme/iframe-background.js",n):new URL("/theme/iframe-overlay.js",n);e.searchParams.set(fv,pv());const r=document.createElement("iframe");return r.id=t==="background"?"theme-iframe-background":"theme-iframe-overlay",r.setAttribute("sandbox","allow-scripts"),r.setAttribute("inert",""),r.setAttribute("tabindex","-1"),r.setAttribute("aria-hidden","true"),r.srcdoc=mN(e.toString(),pN()),r}function pN(){const n=document.documentElement.dataset.theme;if(n!=="light"&&n!=="dark")throw new Error("Application root has no effective theme-frame appearance");return n}function mN(n,t){return`<!doctype html>
262
+ `}disconnected(){o(this,qn).disconnect()}}qn=new WeakMap,af=new WeakMap;const GM=dn(WM),JM=1280,YM=800,vb=.4,yb=.4,z_=280,wb=180,KM=14,XM=45,QM=16,bb=64,e9=90,t9=1,n9=24,r9=230,i9=230;function s9(n,t){const{expandedSidebarWidth:e,expandedToggleLeft:r,collapsedToggleLeft:i,toggleWidth:s,toggleSwitcherGap:a,collapsedLeadReservation:l,hasSwitcher:c}=t,u=e*(1-n),f=e-r,p=Math.max(u-f,i),y=i+f,v=Math.max(0,Math.min(s,u-p)),S=Bg((u-y)/(e-y)),_=s+a,$=i+_,H=c?Bg(($-u)/_):0;let L=n*l;if(l>e){const z=1-$/e,P=Math.min(1,n/z);L=n*e+P*(l-e)}return{sidebarBoundary:u,toggleLeft:p,toggleWipe:v,titlebarOpacity:S,switcherOpacity:H,leadReservation:L}}function o9(n,t,e,r){const i=r*Math.abs(t-n);if(i===0)return t;const a=1-(1-Bg(e/i))**2;return n+(t-n)*a}function Bg(n){return Math.max(0,Math.min(1,n))}var ei,is,ti,fl,pl,Io,_i,dd,jg;class a9{constructor(t){m(this,_i);m(this,ei,null);m(this,is,0);m(this,ti);m(this,fl);m(this,pl);m(this,Io,1);d(this,ti,t),d(this,fl,t),d(this,pl,t)}get boundary(){return h(this,_i,dd).call(this),o(this,ti)}move(t){const e=this.boundary;if(h(this,_i,jg).call(this),d(this,fl,e),d(this,pl,t.target),d(this,Io,t.width),t.onFrame(e),matchMedia("(prefers-reduced-motion: reduce)").matches||Math.abs(t.target-e)<Number.EPSILON){d(this,ti,t.target),t.onFrame(t.target),t.onFinish(t.target);return}const r=Math.abs(t.target-e)/t.width,i=t.root.animate([{},{}],{duration:wb*r,easing:"linear"});i.id="sidebar-collapse-boundary",d(this,ei,i);const s=()=>{if(o(this,ei)===i){if(h(this,_i,dd).call(this),t.onFrame(o(this,ti)),i.playState==="finished"){d(this,ei,null),d(this,is,0),d(this,ti,t.target),t.onFrame(t.target),t.onFinish(t.target);return}d(this,is,requestAnimationFrame(s))}};d(this,is,requestAnimationFrame(s))}cancel(){h(this,_i,dd).call(this),h(this,_i,jg).call(this)}}ei=new WeakMap,is=new WeakMap,ti=new WeakMap,fl=new WeakMap,pl=new WeakMap,Io=new WeakMap,_i=new WeakSet,dd=function(){const t=o(this,ei);if(t===null)return;const e=o9(1-o(this,fl)/o(this,Io),1-o(this,pl)/o(this,Io),Number(t.currentTime??0),wb);d(this,ti,o(this,Io)*(1-e))},jg=function(){var t;cancelAnimationFrame(o(this,is)),d(this,is,0),(t=o(this,ei))==null||t.cancel(),d(this,ei,null)};const U_="television-active-theme",fv="tv-theme";let Vi=null,Si=null,Ts=null,Rs=null,zi=null,Sb=0,Zd=0;function l9(n){const t=document.createElement("link"),e=new URL("/theme/theme.css",n);e.searchParams.set(fv,pv()),t.rel="stylesheet",t.href=e.toString(),t.dataset.televisionStyle=U_;const r=()=>{Vi===t&&document.dispatchEvent(new Event("television-theme-styles-changed"))};return t.addEventListener("load",r,{once:!0}),t.addEventListener("error",r,{once:!0}),Vi==null||Vi.remove(),document.head.append(t),Vi=t,t}function c9(){Vi&&(Vi.remove(),Vi=null,document.dispatchEvent(new Event("television-theme-styles-changed")))}function _b(n){const t=document.createElement("script"),e=new URL("/theme/main.js",n);return e.searchParams.set(fv,pv()),t.src=e.toString(),t.dataset.televisionScript=U_,Si==null||Si.remove(),document.head.append(t),Si=t,t}function u9(){Si==null||Si.remove(),Si=null}function h9(){return Si}async function d9(n,t,e){const r=H_();if(t===null)return;let i;try{i=await e()}catch{return}if(r!==Zd)return;const s=i.themes.find(f=>f.id===t);if(s===void 0)return;const a=document.querySelector("#app"),l=document.querySelector("#foreground-overlay");if(a===null||l===null)return;const c=s.enableIframeBackgroundJS===!0?Ab(n,"background"):null,u=s.enableIframeOverlayJS===!0?Ab(n,"overlay"):null;r===Zd&&(c!==null&&(a.before(c),Ts=c),u!==null&&(l.after(u),Rs=u))}function f9(){H_()}function H_(){return Zd+=1,Ts==null||Ts.remove(),Rs==null||Rs.remove(),Ts=null,Rs=null,Zd}function Ab(n,t){const e=t==="background"?new URL("/theme/iframe-background.js",n):new URL("/theme/iframe-overlay.js",n);e.searchParams.set(fv,pv());const r=document.createElement("iframe");return r.id=t==="background"?"theme-iframe-background":"theme-iframe-overlay",r.setAttribute("sandbox","allow-scripts"),r.setAttribute("inert",""),r.setAttribute("tabindex","-1"),r.setAttribute("aria-hidden","true"),r.srcdoc=m9(e.toString(),p9()),r}function p9(){const n=document.documentElement.dataset.theme;if(n!=="light"&&n!=="dark")throw new Error("Application root has no effective theme-frame appearance");return n}function m9(n,t){return`<!doctype html>
263
263
  <html data-theme="${t}">
264
264
  <head>
265
265
  <meta charset="utf-8">
@@ -277,7 +277,7 @@ html, body {
277
277
  <body>
278
278
  <script src="${n}"><\/script>
279
279
  </body>
280
- </html>`}function Z_(n){var s;let t,e=n.button,r=n.buttons;switch(n.eventType){case"pointermove":t="television-theme-pointer-move",e=-1;break;case"pointerdown":t="television-theme-pointer-down";break;case"pointerup":t="television-theme-pointer-up";break;case"pointercancel":t="television-theme-pointer-cancel",e=-1,r=0;break;case"click":t="television-theme-pointer-click",r=0;break}const i={type:t,clientX:n.clientX,clientY:n.clientY,button:e,buttons:r};for(const a of[Ts,Rs])(a==null?void 0:a.isConnected)===!0&&((s=a.contentWindow)==null||s.postMessage(i,"*"))}function Eh(n){n.isTrusted&&Z_({eventType:n.type,clientX:n.clientX,clientY:n.clientY,button:n.button,buttons:n.buttons})}document.addEventListener("pointermove",Eh,{capture:!0});document.addEventListener("pointerdown",Eh,{capture:!0});document.addEventListener("pointerup",Eh,{capture:!0});document.addEventListener("pointercancel",Eh,{capture:!0});document.addEventListener("click",Eh,{capture:!0});function q_(n){if(n!==Ts&&n!==Rs)return!1;const e=((zi==null?void 0:zi.isConnected)===!0&&zi!==Ts&&zi!==Rs&&zi.closest("#foreground-overlay")===null?zi:null)??document.querySelector("#app");return e==null||e.focus({preventScroll:!0}),!0}document.addEventListener("focusin",n=>{const t=n.target;t instanceof HTMLElement&&(q_(t)||t.isConnected&&t.closest("#foreground-overlay")===null&&(zi=t))},{capture:!0});window.addEventListener("blur",()=>{queueMicrotask(()=>q_(document.activeElement))},{capture:!0});function pv(){return Sb+=1,`${Date.now()}-${Sb}`}const gN=404,vN="/views/url-unsupported/";function fd(n){const t=Ld(n.artifact,{electron:n.electron,browserDemo:n.browserDemo??!1});let e;if(t.renderer==="url-direct")e=t;else if(n.currentURL===null){const r=n.viewURL??t.viewURL;t.renderer==="markdown"?e={renderer:"markdown",viewURL:r,contentURL:n.contentURL??t.contentURL}:t.renderer==="url-webview"&&t.contentURL!==null?e={renderer:"url-webview",viewURL:r,contentURL:n.contentURL??t.contentURL}:e={...t,viewURL:r}}else Eb(n.currentURL)&&!n.electron?e=Vr(n.currentURL)?{renderer:"proxy-iframe",viewURL:n.currentURL,contentURL:null}:{renderer:"proxy-iframe",viewURL:vN,contentURL:null}:Eb(n.currentURL)?e={renderer:"url-webview",viewURL:n.currentURL,contentURL:null}:e={renderer:n.electron?"url-webview":"proxy-iframe",viewURL:bN(n.currentURL,n.viewURL),contentURL:null};return n.frameSrcOverride?{...e,viewURL:n.frameSrcOverride}:e}var ut,_n,ml,$o,xo,Vn,Po,gl,Ht,vl,yl,vr,ss,os,Do,se,pd,V_,F_,Wg,B_,yr,md,zc,Gg,j_,Jg,Yg,Js;class yN extends hn{constructor(){super(...arguments);m(this,se);m(this,ut,null);m(this,_n,null);m(this,ml,"");m(this,$o,()=>{});m(this,xo,()=>{});m(this,Vn,null);m(this,Po,null);m(this,gl,null);m(this,Ht,null);m(this,vl,null);m(this,yl,null);m(this,vr,null);m(this,ss,null);m(this,os,null);m(this,Do,null);m(this,yr,()=>{!o(this,_n)||o(this,_n)!==o(this,Vn)||o(this,$o).call(this,!0)})}get currentFrame(){return o(this,_n)}connected(){h(this,se,md).call(this),h(this,se,Gg).call(this)}disconnected(){h(this,se,zc).call(this),h(this,se,Js).call(this)}template(e,r,i=()=>{}){return d(this,$o,r),d(this,xo,i),e(this),o(this,ml)}assignSource(e){const r=o(this,ut),i=r?!SN(r.artifact,e.artifact):!0;((r==null?void 0:r.artifact.id)!==e.artifact.id||(r==null?void 0:r.artifact.kind)==="path"&&e.artifact.kind==="path"&&r.artifact.path!==e.artifact.path)&&d(this,Do,null),i&&(d(this,vr,null),o(this,Ht)&&(o(this,Ht).content=""),d(this,ss,null),d(this,os,null)),d(this,ut,e),h(this,se,pd).call(this)}handleArtifactContentChanged(e){const r=o(this,ut);return e!==(r==null?void 0:r.artifact.id)||!o(this,Ht)&&!h(this,se,Yg).call(this)?!1:(h(this,se,Jg).call(this),!0)}handleThemeChanged(){var r;const e=(r=o(this,ut))==null?void 0:r.artifact;return(e==null?void 0:e.kind)!=="path"||!ig(e.path)||o(this,Ht)===null?!1:(o(this,Ht).notifyStylesChanged(),!0)}refreshFrameLoadState(){h(this,se,md).call(this)}}ut=new WeakMap,_n=new WeakMap,ml=new WeakMap,$o=new WeakMap,xo=new WeakMap,Vn=new WeakMap,Po=new WeakMap,gl=new WeakMap,Ht=new WeakMap,vl=new WeakMap,yl=new WeakMap,vr=new WeakMap,ss=new WeakMap,os=new WeakMap,Do=new WeakMap,se=new WeakSet,pd=function(){const e=o(this,ut);if(!e)return;if(e.artifact.kind==="path"&&h(this,se,Yg).call(this)){h(this,se,B_).call(this,e.artifact);return}const r=fd(e),i=h(this,se,V_).call(this,r.renderer);h(this,se,F_).call(this,i,r),h(this,se,Wg).call(this,i),h(this,se,md).call(this),h(this,se,Gg).call(this)},V_=function(e){var s;const r=e==="url-webview"?"webview":"iframe";if(((s=o(this,_n))==null?void 0:s.tagName.toLowerCase())===r)return o(this,_n);h(this,se,zc).call(this),h(this,se,Js).call(this);const i=document.createElement(r);return i.className="artifact-content",r==="webview"&&i.setAttribute("allowpopups",""),d(this,_n,i),i},F_=function(e,r){e.getAttribute("src")!==r.viewURL&&(o(this,xo).call(this,null),o(this,xo).call(this,e),e.setAttribute("src",r.viewURL)),r.contentURL===null?delete e.dataset.contentUrl:e.dataset.contentUrl=r.contentURL},Wg=function(e){o(this,ml)!==e&&(d(this,ml,e),this.render(e))},B_=function(e){o(this,xo).call(this,null),h(this,se,zc).call(this),h(this,se,Js).call(this),d(this,_n,null),o(this,$o).call(this,!1),h(this,se,Wg).call(this,W`
280
+ </html>`}function Z_(n){var s;let t,e=n.button,r=n.buttons;switch(n.eventType){case"pointermove":t="television-theme-pointer-move",e=-1;break;case"pointerdown":t="television-theme-pointer-down";break;case"pointerup":t="television-theme-pointer-up";break;case"pointercancel":t="television-theme-pointer-cancel",e=-1,r=0;break;case"click":t="television-theme-pointer-click",r=0;break}const i={type:t,clientX:n.clientX,clientY:n.clientY,button:e,buttons:r};for(const a of[Ts,Rs])(a==null?void 0:a.isConnected)===!0&&((s=a.contentWindow)==null||s.postMessage(i,"*"))}function Eh(n){n.isTrusted&&Z_({eventType:n.type,clientX:n.clientX,clientY:n.clientY,button:n.button,buttons:n.buttons})}document.addEventListener("pointermove",Eh,{capture:!0});document.addEventListener("pointerdown",Eh,{capture:!0});document.addEventListener("pointerup",Eh,{capture:!0});document.addEventListener("pointercancel",Eh,{capture:!0});document.addEventListener("click",Eh,{capture:!0});function q_(n){if(n!==Ts&&n!==Rs)return!1;const e=((zi==null?void 0:zi.isConnected)===!0&&zi!==Ts&&zi!==Rs&&zi.closest("#foreground-overlay")===null?zi:null)??document.querySelector("#app");return e==null||e.focus({preventScroll:!0}),!0}document.addEventListener("focusin",n=>{const t=n.target;t instanceof HTMLElement&&(q_(t)||t.isConnected&&t.closest("#foreground-overlay")===null&&(zi=t))},{capture:!0});window.addEventListener("blur",()=>{queueMicrotask(()=>q_(document.activeElement))},{capture:!0});function pv(){return Sb+=1,`${Date.now()}-${Sb}`}const g9=404,v9="/views/url-unsupported/";function fd(n){const t=Ld(n.artifact,{electron:n.electron,browserDemo:n.browserDemo??!1});let e;if(t.renderer==="url-direct")e=t;else if(n.currentURL===null){const r=n.viewURL??t.viewURL;t.renderer==="markdown"?e={renderer:"markdown",viewURL:r,contentURL:n.contentURL??t.contentURL}:t.renderer==="url-webview"&&t.contentURL!==null?e={renderer:"url-webview",viewURL:r,contentURL:n.contentURL??t.contentURL}:e={...t,viewURL:r}}else Eb(n.currentURL)&&!n.electron?e=Vr(n.currentURL)?{renderer:"proxy-iframe",viewURL:n.currentURL,contentURL:null}:{renderer:"proxy-iframe",viewURL:v9,contentURL:null}:Eb(n.currentURL)?e={renderer:"url-webview",viewURL:n.currentURL,contentURL:null}:e={renderer:n.electron?"url-webview":"proxy-iframe",viewURL:b9(n.currentURL,n.viewURL),contentURL:null};return n.frameSrcOverride?{...e,viewURL:n.frameSrcOverride}:e}var ut,_n,ml,$o,xo,Vn,Po,gl,Ht,vl,yl,vr,ss,os,Do,se,pd,V_,F_,Wg,B_,yr,md,zc,Gg,j_,Jg,Yg,Js;class y9 extends hn{constructor(){super(...arguments);m(this,se);m(this,ut,null);m(this,_n,null);m(this,ml,"");m(this,$o,()=>{});m(this,xo,()=>{});m(this,Vn,null);m(this,Po,null);m(this,gl,null);m(this,Ht,null);m(this,vl,null);m(this,yl,null);m(this,vr,null);m(this,ss,null);m(this,os,null);m(this,Do,null);m(this,yr,()=>{!o(this,_n)||o(this,_n)!==o(this,Vn)||o(this,$o).call(this,!0)})}get currentFrame(){return o(this,_n)}connected(){h(this,se,md).call(this),h(this,se,Gg).call(this)}disconnected(){h(this,se,zc).call(this),h(this,se,Js).call(this)}template(e,r,i=()=>{}){return d(this,$o,r),d(this,xo,i),e(this),o(this,ml)}assignSource(e){const r=o(this,ut),i=r?!S9(r.artifact,e.artifact):!0;((r==null?void 0:r.artifact.id)!==e.artifact.id||(r==null?void 0:r.artifact.kind)==="path"&&e.artifact.kind==="path"&&r.artifact.path!==e.artifact.path)&&d(this,Do,null),i&&(d(this,vr,null),o(this,Ht)&&(o(this,Ht).content=""),d(this,ss,null),d(this,os,null)),d(this,ut,e),h(this,se,pd).call(this)}handleArtifactContentChanged(e){const r=o(this,ut);return e!==(r==null?void 0:r.artifact.id)||!o(this,Ht)&&!h(this,se,Yg).call(this)?!1:(h(this,se,Jg).call(this),!0)}handleThemeChanged(){var r;const e=(r=o(this,ut))==null?void 0:r.artifact;return(e==null?void 0:e.kind)!=="path"||!ig(e.path)||o(this,Ht)===null?!1:(o(this,Ht).notifyStylesChanged(),!0)}refreshFrameLoadState(){h(this,se,md).call(this)}}ut=new WeakMap,_n=new WeakMap,ml=new WeakMap,$o=new WeakMap,xo=new WeakMap,Vn=new WeakMap,Po=new WeakMap,gl=new WeakMap,Ht=new WeakMap,vl=new WeakMap,yl=new WeakMap,vr=new WeakMap,ss=new WeakMap,os=new WeakMap,Do=new WeakMap,se=new WeakSet,pd=function(){const e=o(this,ut);if(!e)return;if(e.artifact.kind==="path"&&h(this,se,Yg).call(this)){h(this,se,B_).call(this,e.artifact);return}const r=fd(e),i=h(this,se,V_).call(this,r.renderer);h(this,se,F_).call(this,i,r),h(this,se,Wg).call(this,i),h(this,se,md).call(this),h(this,se,Gg).call(this)},V_=function(e){var s;const r=e==="url-webview"?"webview":"iframe";if(((s=o(this,_n))==null?void 0:s.tagName.toLowerCase())===r)return o(this,_n);h(this,se,zc).call(this),h(this,se,Js).call(this);const i=document.createElement(r);return i.className="artifact-content",r==="webview"&&i.setAttribute("allowpopups",""),d(this,_n,i),i},F_=function(e,r){e.getAttribute("src")!==r.viewURL&&(o(this,xo).call(this,null),o(this,xo).call(this,e),e.setAttribute("src",r.viewURL)),r.contentURL===null?delete e.dataset.contentUrl:e.dataset.contentUrl=r.contentURL},Wg=function(e){o(this,ml)!==e&&(d(this,ml,e),this.render(e))},B_=function(e){o(this,xo).call(this,null),h(this,se,zc).call(this),h(this,se,Js).call(this),d(this,_n,null),o(this,$o).call(this,!1),h(this,se,Wg).call(this,W`
281
281
  <section class="artifact-missing artifact-content" role="status" aria-label="Artifact file not found">
282
282
  <div class="artifact-missing-wrapper">
283
283
  <h1>${DA()}</h1>
@@ -289,7 +289,7 @@ html, body {
289
289
  <p>${OA()}</p>
290
290
  </div>
291
291
  </section>
292
- `)},yr=new WeakMap,md=function(){var s;const e=o(this,_n),r=e?`${e.tagName.toLowerCase()}:${e.getAttribute("src")??""}:${e.dataset.contentUrl??""}`:null;if(e&&e===o(this,Vn)&&r===o(this,Po)||(h(this,se,zc).call(this),o(this,$o).call(this,!1),!e||!r||!this.isConnected))return;if(d(this,Vn,e),d(this,Po,r),e.tagName.toLowerCase()==="webview"){e.addEventListener("did-finish-load",o(this,yr)),e.addEventListener("did-fail-load",o(this,yr));return}e.addEventListener("load",o(this,yr));const i=e;try{i.isConnected&&((s=i.contentDocument)==null?void 0:s.readyState)==="complete"&&o(this,yr).call(this)}catch{}},zc=function(){if(!o(this,Vn)){d(this,Po,null);return}o(this,Vn).removeEventListener("load",o(this,yr)),o(this,Vn).removeEventListener("did-finish-load",o(this,yr)),o(this,Vn).removeEventListener("did-fail-load",o(this,yr)),d(this,Vn,null),d(this,Po,null)},Gg=function(){const e=o(this,ut),r=o(this,_n),i=(r==null?void 0:r.dataset.contentUrl)??null,s=(e==null?void 0:e.artifact.id)??null;if(!e||!r||!i||!s){h(this,se,Js).call(this,{clearContent:!0});return}if(r!==o(this,gl)||s!==o(this,yl)){h(this,se,Js).call(this),d(this,gl,r),d(this,vl,i),d(this,yl,s);const a=r.tagName.toLowerCase()==="webview"?new fL(r):new dL(r);d(this,Ht,a),a.handleUpdateContent(async l=>{const c=o(this,ut),u=c==null?void 0:c.application;if(!c||!u)throw new Error("No markdown artifact selected");await u.writeMarkdown(c.artifact.id,l),d(this,vr,l),o(this,Ht)===a&&(a.content=l)}),o(this,vr)!==null&&(a.content=o(this,vr))}else d(this,vl,i);h(this,se,j_).call(this)},j_=function(){const e=o(this,ut),r=e==null?void 0:e.application;!e||!r||!o(this,Ht)||o(this,ss)===e.artifact.id&&o(this,os)===r||(d(this,ss,e.artifact.id),d(this,os,r),h(this,se,Jg).call(this))},Jg=async function(){var s,a;const e=o(this,ut),r=e==null?void 0:e.application;if(!e||!r)return;const i=e.artifact.id;try{const l=await r.readMarkdown(i);if(((s=o(this,ut))==null?void 0:s.artifact.id)!==i||o(this,ut).application!==r)return;d(this,Do,null),d(this,vr,l);const c=o(this,Ht);if(!c){h(this,se,pd).call(this);return}c.content=l}catch(l){if(((a=o(this,ut))==null?void 0:a.artifact.id)!==i||o(this,ut).application!==r)return;if(l instanceof Ql&&l.status===gN){d(this,Do,i),d(this,vr,null),h(this,se,Js).call(this),h(this,se,pd).call(this);return}d(this,ss,null),d(this,os,null)}},Yg=function(){var r;const e=(r=o(this,ut))==null?void 0:r.artifact;return o(this,Do)===(e==null?void 0:e.id)&&e.kind==="path"&&ig(e.path)},Js=function(e={}){var r;(r=o(this,Ht))==null||r.dispose(),d(this,Ht,null),d(this,gl,null),d(this,vl,null),d(this,yl,null),d(this,ss,null),d(this,os,null),e.clearContent&&d(this,vr,null)};const wN=dn(yN);function Eb(n){return n.startsWith("http://")||n.startsWith("https://")}function bN(n,t){if(!n.startsWith("/")||!t)return n;try{return new URL(n,t).toString()}catch{return n}}function SN(n,t){return n.id!==t.id||n.kind!==t.kind?!1:n.kind==="path"&&t.kind==="path"?n.path===t.path:n.kind==="url"&&t.kind==="url"?n.url===t.url:!0}var qu,wl,wr,ni,as,ls,cs,Vu,Fu,Bu,ju,un,Kg,gd,vd;class _N{constructor(t,e=()=>{}){m(this,un);m(this,qu);m(this,wl);m(this,wr,null);m(this,ni,null);m(this,as,null);m(this,ls,null);m(this,cs,!1);m(this,Vu,t=>{const e=Tb(t.data);if(!e)return;const r=o(this,as);if(!r||r.tagName.toLowerCase()!=="iframe"||!r.isConnected)return;const i=r,s=i.contentWindow;if(s===null)return;const a=e.type==="leaving",l=e.type==="navigation-request"&&e.native===!0&&e.sameDocument!==!0,c=s===t.source,u=(a||l)&&o(this,ni)!==null&&o(this,ni)===t.source,f=a&&EN(i)===t.origin;!c&&!u&&!f||h(this,un,Kg).call(this,e,i,{send:p=>{var y;return(y=i.contentWindow)==null?void 0:y.postMessage(p,"*")}})});m(this,Fu,t=>{var s;const e=t.detail??t;if(!e||e.channel!==kb)return;const r=Tb((s=e.args)==null?void 0:s[0]),i=o(this,ls);!r||!i||h(this,un,Kg).call(this,r,i,{send:a=>{var l;return(l=i.send)==null?void 0:l.call(i,kb,a)}})});m(this,Bu,t=>{const e=Rb(t);e.isMainFrame===!0&&e.isInPlace!==!0&&this.reset()});m(this,ju,t=>{Rb(t).isMainFrame!==!1&&this.reset()});d(this,qu,t),d(this,wl,e)}get currentGuid(){return o(this,wr)}get lifecycleWindow(){return o(this,ni)}get trustState(){return{currentGuid:o(this,wr),lifecycleWindow:o(this,ni)}}connect(){o(this,cs)||(d(this,cs,!0),window.addEventListener("message",o(this,Vu)),h(this,un,gd).call(this))}disconnect(){o(this,cs)&&(window.removeEventListener("message",o(this,Vu)),d(this,cs,!1),h(this,un,vd).call(this))}reset(){d(this,wr,null),d(this,ni,null),o(this,wl).call(this)}setCurrentFrame(t){if(t===o(this,as)){h(this,un,gd).call(this);return}h(this,un,vd).call(this),o(this,as)!==null&&this.reset(),d(this,as,AN(t)?t:null),h(this,un,gd).call(this)}}qu=new WeakMap,wl=new WeakMap,wr=new WeakMap,ni=new WeakMap,as=new WeakMap,ls=new WeakMap,cs=new WeakMap,Vu=new WeakMap,Fu=new WeakMap,Bu=new WeakMap,ju=new WeakMap,un=new WeakSet,Kg=function(t,e,r){t.type==="bridge-ready"&&t.guid!==o(this,wr)?(o(this,wr)!==null&&o(this,wl).call(this),d(this,wr,t.guid),d(this,ni,e.tagName.toLowerCase()==="iframe"?e.contentWindow:null)):t.type==="leaving"&&t.guid===o(this,wr)&&this.reset(),o(this,qu).call(this,t,r)},gd=function(){if(!o(this,cs))return;const t=o(this,as),e=(t==null?void 0:t.tagName.toLowerCase())==="webview"?t:null;e!==o(this,ls)&&(h(this,un,vd).call(this),e&&(e.addEventListener("ipc-message",o(this,Fu)),e.addEventListener("did-start-navigation",o(this,Bu)),e.addEventListener("did-fail-load",o(this,ju)),d(this,ls,e)))},vd=function(){const t=o(this,ls);t&&(t.removeEventListener("ipc-message",o(this,Fu)),t.removeEventListener("did-start-navigation",o(this,Bu)),t.removeEventListener("did-fail-load",o(this,ju)),d(this,ls,null))};const kb="television-artifact-bridge";function Tb(n){return _A(n)||AA(n)||EA(n)||kA(n)||TA(n)||RA(n)||CA(n)||IA(n)?n:null}function AN(n){if(!n)return!1;const t=n.tagName.toLowerCase();return t==="iframe"||t==="webview"}function EN(n){try{return new URL(n.getAttribute("src")??n.src,window.location.href).origin}catch{return null}}function Rb(n){return n.detail??n}const kN="/views/url-unsupported/";class TN extends hn{constructor(){super(...arguments);C(this,"_artifact",null);C(this,"_viewURL",null);C(this,"_contentURL",null);C(this,"_application",null);C(this,"_fullScreen",!1);C(this,"_inert",!1);C(this,"_onFullScreenChange",()=>{});C(this,"_connected",!1);C(this,"_deleteConfirmationOpen",!1);C(this,"_dialogPresentation",null);C(this,"_subscribedWebview",null);C(this,"_documentHost",null);C(this,"_pendingDocumentSource",null);C(this,"_rootRef",Jn());C(this,"_trustedChannel",new _N((e,r)=>{this.handleTrustedFrameMessage(e,r)},()=>{this._missingArtifactReplyTransport=null}));C(this,"_activeReloadFrameSrc",null);C(this,"_applicationSubscriptionsAttached",!1);C(this,"_proxyReloadVersion",0);C(this,"_navigationState",null);C(this,"_navigationArtifactId",null);C(this,"_navigationCanonicalURL",null);C(this,"_preserveFrameSrcOnNavigationRender",!1);C(this,"_missingArtifactReplyTransport",null);C(this,"handleNavigationChange",()=>{const e=this._preserveFrameSrcOnNavigationRender,r=!e;r&&!wi()?(this.renderArtifact({preserveFrameSrc:!0}),this.forceCurrentFrameSrc()):this.renderArtifact({preserveFrameSrc:e,resetTrust:r}),this._preserveFrameSrcOnNavigationRender=!1});C(this,"handleArtifactContentChanged",e=>{var s;const r=e.artifactID,i=this._artifact;!i||r!==i.id||i.kind!=="path"||typeof r=="string"&&((s=this._documentHost)!=null&&s.handleArtifactContentChanged(r))||this.reloadProxyFrame()});C(this,"handleThemeChanged",()=>{var e,r;((e=this._artifact)==null?void 0:e.kind)==="url"&&Vr(this._artifact.url)||this.isDemoPage()||(r=this._documentHost)!=null&&r.handleThemeChanged()||this.reloadProxyFrame()});C(this,"handleWebviewDidNavigate",e=>{this.handleWebviewNavigationEvent(e)});C(this,"handleWebviewDidNavigateInPage",e=>{if(e.isMainFrame===!1)return;this._preserveFrameSrcOnNavigationRender=!0,this.handleWebviewNavigationEvent(e)||(this._preserveFrameSrcOnNavigationRender=!1)});C(this,"captureDocumentHost",e=>{this._documentHost=e,this._pendingDocumentSource&&(e.assignSource(this._pendingDocumentSource),this.syncFrameSubscriptions())});C(this,"handleEmbedLoadChange",e=>{var r;(r=this._rootRef.value)==null||r.toggleAttribute("data-embed-loaded",e)});C(this,"handleDocumentFrameChange",e=>{e===null&&this.resetTrustedFrame(),this.syncFrameTitle(e),this._trustedChannel.setCurrentFrame(this.bridgeFrame(e)),this.syncWebviewSubscription(e)});C(this,"handleTitleBarDoubleClick",e=>{const r=e.target;r instanceof Element&&r.closest("button")||this.requestFullScreen(!this._fullScreen)})}update(e,r){var u;const[i,s,a]=r;let l=!1;this._application!==i&&(this.detachApplicationSubscriptions(),this._application=i,this.attachApplicationSubscriptions(),this._connected&&(this.assignDocumentSource({preserveFrameSrc:!0}),l=!0));const c=this._artifact;if(c!==s){const f=c?!IN(c,s):!0;if(f&&(this._activeReloadFrameSrc=null),this._artifact=s,this.syncNavigationState(),this._connected){if(this.renderArtifact({resetTrust:f}),l=!0,c&&$N(c,s)){const p=this.currentMissingArtifactMessage();p&&((u=this._missingArtifactReplyTransport)==null||u.send(p))}}else f&&this.resetTrustedFrame()}return this._viewURL!==a.viewURL&&(this._viewURL=a.viewURL,this.syncNavigationState(),this._connected?(this.renderArtifact({resetTrust:!0}),l=!0):this._trustedChannel.reset()),this._contentURL!==a.contentURL&&(this._contentURL=a.contentURL,this._connected&&(this.renderArtifact(),l=!0)),this._fullScreen!==a.fullScreen&&(this._fullScreen=a.fullScreen,this._connected&&this._artifact&&(this.renderArtifact({preserveFrameSrc:!0}),l=!0)),this._inert=a.inert,this._onFullScreenChange=a.onFullScreenChange,this._connected&&!l&&this.renderArtifact({preserveFrameSrc:!0}),super.update(e,r)}attachApplicationSubscriptions(){!this._application||this._applicationSubscriptionsAttached||(this._application.addEventListener("artifact-content-changed",this.handleArtifactContentChanged),this._application.addEventListener("theme-changed",this.handleThemeChanged),this._applicationSubscriptionsAttached=!0)}detachApplicationSubscriptions(){!this._application||!this._applicationSubscriptionsAttached||(this._application.removeEventListener("artifact-content-changed",this.handleArtifactContentChanged),this._application.removeEventListener("theme-changed",this.handleThemeChanged),this._applicationSubscriptionsAttached=!1)}get activeView(){return null}connected(){this._connected=!0,this._trustedChannel.connect(),this.attachApplicationSubscriptions(),this.resetTrustedFrame(),this.syncNavigationState(),this.renderArtifact(),this.syncFrameSubscriptions()}disconnected(){var e;this._connected=!1,(e=this._dialogPresentation)==null||e.withdraw(),this._dialogPresentation=null,this._deleteConfirmationOpen=!1,this.resetTrustedFrame(),this._trustedChannel.disconnect(),this.unsubscribeFromWebview(),this.syncNavigationState(),this.detachApplicationSubscriptions()}handleTrustedFrameMessage(e,r){var i;switch(e.type){case"url-target-request":r.send({type:$A,url:this.currentExternalTargetURL()});return;case"artifact-missing-request":{const s=this.currentMissingArtifactMessage();s&&(this._missingArtifactReplyTransport=r,r.send(s));return}case"proxy-content-changed":this.handleProxyContentChanged();return;case"navigation-request":this.handleNavigationRequest(e);return;case"navigation-key":(i=this._application)==null||i.handleNavigationKey(e.key);return;case"artifact-pointer":this.handleArtifactPointer(e);return;case"bridge-ready":case"leaving":return}}handleArtifactPointer(e){const r=this.currentFrame;if(r===null||r.clientWidth<=0||r.clientHeight<=0)return;const i=r.getBoundingClientRect();Z_({eventType:e.eventType,clientX:i.left+e.clientX*i.width/r.clientWidth,clientY:i.top+e.clientY*i.height/r.clientHeight,button:e.button,buttons:e.buttons})}currentExternalTargetURL(){var r,i;const e=((r=this._navigationState)==null?void 0:r.currentURL)??null;return e&&CN(e)?e:((i=this._artifact)==null?void 0:i.kind)==="url"?this._artifact.url:null}currentMissingArtifactMessage(){const e=this._artifact;return(e==null?void 0:e.kind)!=="path"?null:{type:xA,title:e.title,path:e.path}}handleProxyContentChanged(){var e;((e=this._artifact)==null?void 0:e.kind)!=="url"||!Vr(this._artifact.url)||this.reloadProxyFrame()}handleNavigationRequest(e){if(!V2(e.url,window.location.href))return;this.syncNavigationState();const r=this._navigationState;if(!r)return;const i=this.convertIframeNavigationURL(e.url);if(i===kN||i===r.currentURL)return;const s=e.native===!0;(e.sameDocument||s)&&(this._preserveFrameSrcOnNavigationRender=!0),e.replace?r.replace(i):r.navigate(i)}syncNavigationState(){if(!this._connected||!this._artifact||this.isDemoPage()){this.disposeNavigationState();return}const e=this.canonicalURLForArtifact(this._artifact);this._navigationState&&this._navigationArtifactId===this._artifact.id&&this._navigationCanonicalURL===e||(this.disposeNavigationState(),this._navigationState=new VD(this._artifact.id,e),this._navigationArtifactId=this._artifact.id,this._navigationCanonicalURL=e,this._navigationState.addEventListener("change",this.handleNavigationChange),this._navigationState.currentURL!==null?this.renderArtifact():this._navigationState.canGoForward&&this.renderArtifact({preserveFrameSrc:!0}))}disposeNavigationState(){var e;(e=this._navigationState)==null||e.removeEventListener("change",this.handleNavigationChange),this._navigationState=null,this._navigationArtifactId=null,this._navigationCanonicalURL=null,this._preserveFrameSrcOnNavigationRender=!1}canonicalURLForArtifact(e){const r=fd({artifact:e,application:this._application,electron:wi(),browserDemo:this.browserDemo,viewURL:this._viewURL,contentURL:this._contentURL,currentURL:null}),i=r.viewURL;return e.kind==="url"&&Vr(e.url)||r.renderer==="url-webview"?bi(i):Cb(i,i)}convertIframeNavigationURL(e){var r;return((r=this._artifact)==null?void 0:r.kind)==="url"&&Vr(this._artifact.url)&&Vr(e)?bi(e):Cb(e,this._viewURL??this._navigationCanonicalURL??null)}handleWebviewNavigationEvent(e){const r=e.url;if(typeof r!="string"||!V2(r,window.location.href))return!1;this.syncNavigationState();const i=this._navigationState;if(!i)return!1;const s=bi(r);return s===i.currentURL?!1:(i.navigate(s),!0)}syncWebviewSubscription(e=this.currentFrame){const r=(e==null?void 0:e.tagName.toLowerCase())==="webview"?e:null;r!==this._subscribedWebview&&(this.unsubscribeFromWebview(),r&&(r.addEventListener("did-navigate",this.handleWebviewDidNavigate),r.addEventListener("did-navigate-in-page",this.handleWebviewDidNavigateInPage),this._subscribedWebview=r))}unsubscribeFromWebview(){this._subscribedWebview&&(this._subscribedWebview.removeEventListener("did-navigate",this.handleWebviewDidNavigate),this._subscribedWebview.removeEventListener("did-navigate-in-page",this.handleWebviewDidNavigateInPage),this._subscribedWebview=null)}get currentFrame(){var e;return((e=this._documentHost)==null?void 0:e.currentFrame)??null}syncFrameSubscriptions(){const e=this.currentFrame;this.syncFrameTitle(e),this._trustedChannel.setCurrentFrame(this.bridgeFrame(e)),this.syncWebviewSubscription(e)}bridgeFrame(e){return this.isDemoPage()?null:e}get browserDemo(){var e;return((e=this._application)==null?void 0:e.browserDemoMode)===!0}isDemoPage(){const e=this._artifact;return e?Ld(e,{electron:wi(),browserDemo:this.browserDemo}).renderer==="url-direct":!1}returnToOriginalPage(){var i,s;const e=this._artifact,r=this.currentFrame;(e==null?void 0:e.kind)!=="url"||(r==null?void 0:r.tagName.toLowerCase())!=="iframe"||((i=this._rootRef.value)==null||i.removeAttribute("data-embed-loaded"),r.setAttribute("src",e.url),(s=this._documentHost)==null||s.refreshFrameLoadState())}syncFrameTitle(e){e&&this._artifact&&e.getAttribute("title")!==this._artifact.title&&e.setAttribute("title",this._artifact.title)}resetTrustedFrame(){this._missingArtifactReplyTransport=null,this._trustedChannel.reset()}assignDocumentSource(e={}){var f,p,y;const r=this._artifact;if(!r)return;e.resetTrust&&this.resetTrustedFrame();const i={artifact:r,application:this._application,electron:wi(),browserDemo:this.browserDemo,viewURL:this._viewURL,contentURL:this._contentURL,currentURL:((f=this._navigationState)==null?void 0:f.currentURL)??null},s=fd(i),a=(p=this.currentFrame)==null?void 0:p.getAttribute("src");let l=null;this._activeReloadFrameSrc&&(W_(this._activeReloadFrameSrc,s.viewURL)?l=this._activeReloadFrameSrc:this._activeReloadFrameSrc=null);const c=e.frameSrcOverride??l??(e.preserveFrameSrc&&a?a:s.viewURL),u={...i,frameSrcOverride:c};this._pendingDocumentSource=u,(y=this._documentHost)==null||y.assignSource(u),this.syncFrameSubscriptions()}reloadProxyFrame(){var a,l,c,u,f;const e=this.currentFrame;if(!e||e.hasAttribute("data-content-url")||e.tagName.toLowerCase()==="webview"&&!(((a=this._artifact)==null?void 0:a.kind)==="path"||((l=this._artifact)==null?void 0:l.kind)==="url"&&Vr(this._artifact.url)))return;const r=((c=this._artifact)==null?void 0:c.kind)==="url"&&Vr(this._artifact.url)?((u=this._navigationState)==null?void 0:u.currentURL)??e.getAttribute("src"):e.getAttribute("src");if(r===null)return;const i=new URL(r,window.location.href);i.searchParams.set(Fl,String(++this._proxyReloadVersion));const s=r.startsWith("/")?`${i.pathname}${i.search}${i.hash}`:i.href;this._activeReloadFrameSrc=s,(f=this._rootRef.value)==null||f.removeAttribute("data-embed-loaded"),this.renderArtifact({frameSrcOverride:s,resetTrust:!0})}forceCurrentFrameSrc(){var s,a,l;if(!this._artifact)return;const e=fd({artifact:this._artifact,application:this._application,electron:wi(),browserDemo:this.browserDemo,viewURL:this._viewURL,contentURL:this._contentURL,currentURL:((s=this._navigationState)==null?void 0:s.currentURL)??null});if(e.renderer==="url-webview")return;const r=this.currentFrame,i=(r==null?void 0:r.tagName.toLowerCase())==="iframe"?r:null;i&&(this.resetTrustedFrame(),this._activeReloadFrameSrc=null,(a=this._rootRef.value)==null||a.removeAttribute("data-embed-loaded"),i.setAttribute("src",e.viewURL),(l=this._documentHost)==null||l.refreshFrameLoadState())}menuEntries(){return[{label:this._fullScreen?"Exit full-screen":"Make full-screen",action:()=>this.requestFullScreen(!this._fullScreen)},{separator:!0},{label:"Delete",destructive:!0,action:()=>this.showDeleteConfirmation()}]}closeMenu(){var i;const e=this._rootRef.value,r=e==null?void 0:e.querySelector(".artifact-menu-trigger");r&&((i=e==null?void 0:e.ownerDocument.querySelector(`tv-menu[trigger="${r.id}"]`))==null||i.removeAttribute("open"))}requestFullScreen(e){this.closeMenu(),this._onFullScreenChange(e)}showDeleteConfirmation(){var r,i,s;if(this._deleteConfirmationOpen)return;this.closeMenu(),this._deleteConfirmationOpen=!0,this.renderArtifact({preserveFrameSrc:!0});const e=(r=this._rootRef.value)==null?void 0:r.querySelector("dialog");e&&(this._dialogPresentation=tp(e,()=>this.dismissDeleteConfirmation()),(s=(i=this._rootRef.value)==null?void 0:i.querySelector(".dialog-actions button"))==null||s.focus())}dismissDeleteConfirmation(){const e=this._dialogPresentation;this._dialogPresentation=null,this._deleteConfirmationOpen=!1,e==null||e.withdraw(),this.isConnected&&this._artifact&&this.renderArtifact({preserveFrameSrc:!0})}confirmDelete(){var i;const e=(i=this._artifact)==null?void 0:i.id,r=this._application;this.dismissDeleteConfirmation(),!(!e||!r)&&r.deleteArtifact(e).catch(()=>{})}artifactIconTemplate(){return this.isDemoPage()?W`
292
+ `)},yr=new WeakMap,md=function(){var s;const e=o(this,_n),r=e?`${e.tagName.toLowerCase()}:${e.getAttribute("src")??""}:${e.dataset.contentUrl??""}`:null;if(e&&e===o(this,Vn)&&r===o(this,Po)||(h(this,se,zc).call(this),o(this,$o).call(this,!1),!e||!r||!this.isConnected))return;if(d(this,Vn,e),d(this,Po,r),e.tagName.toLowerCase()==="webview"){e.addEventListener("did-finish-load",o(this,yr)),e.addEventListener("did-fail-load",o(this,yr));return}e.addEventListener("load",o(this,yr));const i=e;try{i.isConnected&&((s=i.contentDocument)==null?void 0:s.readyState)==="complete"&&o(this,yr).call(this)}catch{}},zc=function(){if(!o(this,Vn)){d(this,Po,null);return}o(this,Vn).removeEventListener("load",o(this,yr)),o(this,Vn).removeEventListener("did-finish-load",o(this,yr)),o(this,Vn).removeEventListener("did-fail-load",o(this,yr)),d(this,Vn,null),d(this,Po,null)},Gg=function(){const e=o(this,ut),r=o(this,_n),i=(r==null?void 0:r.dataset.contentUrl)??null,s=(e==null?void 0:e.artifact.id)??null;if(!e||!r||!i||!s){h(this,se,Js).call(this,{clearContent:!0});return}if(r!==o(this,gl)||s!==o(this,yl)){h(this,se,Js).call(this),d(this,gl,r),d(this,vl,i),d(this,yl,s);const a=r.tagName.toLowerCase()==="webview"?new fL(r):new dL(r);d(this,Ht,a),a.handleUpdateContent(async l=>{const c=o(this,ut),u=c==null?void 0:c.application;if(!c||!u)throw new Error("No markdown artifact selected");await u.writeMarkdown(c.artifact.id,l),d(this,vr,l),o(this,Ht)===a&&(a.content=l)}),o(this,vr)!==null&&(a.content=o(this,vr))}else d(this,vl,i);h(this,se,j_).call(this)},j_=function(){const e=o(this,ut),r=e==null?void 0:e.application;!e||!r||!o(this,Ht)||o(this,ss)===e.artifact.id&&o(this,os)===r||(d(this,ss,e.artifact.id),d(this,os,r),h(this,se,Jg).call(this))},Jg=async function(){var s,a;const e=o(this,ut),r=e==null?void 0:e.application;if(!e||!r)return;const i=e.artifact.id;try{const l=await r.readMarkdown(i);if(((s=o(this,ut))==null?void 0:s.artifact.id)!==i||o(this,ut).application!==r)return;d(this,Do,null),d(this,vr,l);const c=o(this,Ht);if(!c){h(this,se,pd).call(this);return}c.content=l}catch(l){if(((a=o(this,ut))==null?void 0:a.artifact.id)!==i||o(this,ut).application!==r)return;if(l instanceof Ql&&l.status===g9){d(this,Do,i),d(this,vr,null),h(this,se,Js).call(this),h(this,se,pd).call(this);return}d(this,ss,null),d(this,os,null)}},Yg=function(){var r;const e=(r=o(this,ut))==null?void 0:r.artifact;return o(this,Do)===(e==null?void 0:e.id)&&e.kind==="path"&&ig(e.path)},Js=function(e={}){var r;(r=o(this,Ht))==null||r.dispose(),d(this,Ht,null),d(this,gl,null),d(this,vl,null),d(this,yl,null),d(this,ss,null),d(this,os,null),e.clearContent&&d(this,vr,null)};const w9=dn(y9);function Eb(n){return n.startsWith("http://")||n.startsWith("https://")}function b9(n,t){if(!n.startsWith("/")||!t)return n;try{return new URL(n,t).toString()}catch{return n}}function S9(n,t){return n.id!==t.id||n.kind!==t.kind?!1:n.kind==="path"&&t.kind==="path"?n.path===t.path:n.kind==="url"&&t.kind==="url"?n.url===t.url:!0}var qu,wl,wr,ni,as,ls,cs,Vu,Fu,Bu,ju,un,Kg,gd,vd;class _9{constructor(t,e=()=>{}){m(this,un);m(this,qu);m(this,wl);m(this,wr,null);m(this,ni,null);m(this,as,null);m(this,ls,null);m(this,cs,!1);m(this,Vu,t=>{const e=Tb(t.data);if(!e)return;const r=o(this,as);if(!r||r.tagName.toLowerCase()!=="iframe"||!r.isConnected)return;const i=r,s=i.contentWindow;if(s===null)return;const a=e.type==="leaving",l=e.type==="navigation-request"&&e.native===!0&&e.sameDocument!==!0,c=s===t.source,u=(a||l)&&o(this,ni)!==null&&o(this,ni)===t.source,f=a&&E9(i)===t.origin;!c&&!u&&!f||h(this,un,Kg).call(this,e,i,{send:p=>{var y;return(y=i.contentWindow)==null?void 0:y.postMessage(p,"*")}})});m(this,Fu,t=>{var s;const e=t.detail??t;if(!e||e.channel!==kb)return;const r=Tb((s=e.args)==null?void 0:s[0]),i=o(this,ls);!r||!i||h(this,un,Kg).call(this,r,i,{send:a=>{var l;return(l=i.send)==null?void 0:l.call(i,kb,a)}})});m(this,Bu,t=>{const e=Rb(t);e.isMainFrame===!0&&e.isInPlace!==!0&&this.reset()});m(this,ju,t=>{Rb(t).isMainFrame!==!1&&this.reset()});d(this,qu,t),d(this,wl,e)}get currentGuid(){return o(this,wr)}get lifecycleWindow(){return o(this,ni)}get trustState(){return{currentGuid:o(this,wr),lifecycleWindow:o(this,ni)}}connect(){o(this,cs)||(d(this,cs,!0),window.addEventListener("message",o(this,Vu)),h(this,un,gd).call(this))}disconnect(){o(this,cs)&&(window.removeEventListener("message",o(this,Vu)),d(this,cs,!1),h(this,un,vd).call(this))}reset(){d(this,wr,null),d(this,ni,null),o(this,wl).call(this)}setCurrentFrame(t){if(t===o(this,as)){h(this,un,gd).call(this);return}h(this,un,vd).call(this),o(this,as)!==null&&this.reset(),d(this,as,A9(t)?t:null),h(this,un,gd).call(this)}}qu=new WeakMap,wl=new WeakMap,wr=new WeakMap,ni=new WeakMap,as=new WeakMap,ls=new WeakMap,cs=new WeakMap,Vu=new WeakMap,Fu=new WeakMap,Bu=new WeakMap,ju=new WeakMap,un=new WeakSet,Kg=function(t,e,r){t.type==="bridge-ready"&&t.guid!==o(this,wr)?(o(this,wr)!==null&&o(this,wl).call(this),d(this,wr,t.guid),d(this,ni,e.tagName.toLowerCase()==="iframe"?e.contentWindow:null)):t.type==="leaving"&&t.guid===o(this,wr)&&this.reset(),o(this,qu).call(this,t,r)},gd=function(){if(!o(this,cs))return;const t=o(this,as),e=(t==null?void 0:t.tagName.toLowerCase())==="webview"?t:null;e!==o(this,ls)&&(h(this,un,vd).call(this),e&&(e.addEventListener("ipc-message",o(this,Fu)),e.addEventListener("did-start-navigation",o(this,Bu)),e.addEventListener("did-fail-load",o(this,ju)),d(this,ls,e)))},vd=function(){const t=o(this,ls);t&&(t.removeEventListener("ipc-message",o(this,Fu)),t.removeEventListener("did-start-navigation",o(this,Bu)),t.removeEventListener("did-fail-load",o(this,ju)),d(this,ls,null))};const kb="television-artifact-bridge";function Tb(n){return _A(n)||AA(n)||EA(n)||kA(n)||TA(n)||RA(n)||CA(n)||IA(n)?n:null}function A9(n){if(!n)return!1;const t=n.tagName.toLowerCase();return t==="iframe"||t==="webview"}function E9(n){try{return new URL(n.getAttribute("src")??n.src,window.location.href).origin}catch{return null}}function Rb(n){return n.detail??n}const k9="/views/url-unsupported/";class T9 extends hn{constructor(){super(...arguments);C(this,"_artifact",null);C(this,"_viewURL",null);C(this,"_contentURL",null);C(this,"_application",null);C(this,"_fullScreen",!1);C(this,"_inert",!1);C(this,"_onFullScreenChange",()=>{});C(this,"_connected",!1);C(this,"_deleteConfirmationOpen",!1);C(this,"_dialogPresentation",null);C(this,"_subscribedWebview",null);C(this,"_documentHost",null);C(this,"_pendingDocumentSource",null);C(this,"_rootRef",Jn());C(this,"_trustedChannel",new _9((e,r)=>{this.handleTrustedFrameMessage(e,r)},()=>{this._missingArtifactReplyTransport=null}));C(this,"_activeReloadFrameSrc",null);C(this,"_applicationSubscriptionsAttached",!1);C(this,"_proxyReloadVersion",0);C(this,"_navigationState",null);C(this,"_navigationArtifactId",null);C(this,"_navigationCanonicalURL",null);C(this,"_preserveFrameSrcOnNavigationRender",!1);C(this,"_missingArtifactReplyTransport",null);C(this,"handleNavigationChange",()=>{const e=this._preserveFrameSrcOnNavigationRender,r=!e;r&&!wi()?(this.renderArtifact({preserveFrameSrc:!0}),this.forceCurrentFrameSrc()):this.renderArtifact({preserveFrameSrc:e,resetTrust:r}),this._preserveFrameSrcOnNavigationRender=!1});C(this,"handleArtifactContentChanged",e=>{var s;const r=e.artifactID,i=this._artifact;!i||r!==i.id||i.kind!=="path"||typeof r=="string"&&((s=this._documentHost)!=null&&s.handleArtifactContentChanged(r))||this.reloadProxyFrame()});C(this,"handleThemeChanged",()=>{var e,r;((e=this._artifact)==null?void 0:e.kind)==="url"&&Vr(this._artifact.url)||this.isDemoPage()||(r=this._documentHost)!=null&&r.handleThemeChanged()||this.reloadProxyFrame()});C(this,"handleWebviewDidNavigate",e=>{this.handleWebviewNavigationEvent(e)});C(this,"handleWebviewDidNavigateInPage",e=>{if(e.isMainFrame===!1)return;this._preserveFrameSrcOnNavigationRender=!0,this.handleWebviewNavigationEvent(e)||(this._preserveFrameSrcOnNavigationRender=!1)});C(this,"captureDocumentHost",e=>{this._documentHost=e,this._pendingDocumentSource&&(e.assignSource(this._pendingDocumentSource),this.syncFrameSubscriptions())});C(this,"handleEmbedLoadChange",e=>{var r;(r=this._rootRef.value)==null||r.toggleAttribute("data-embed-loaded",e)});C(this,"handleDocumentFrameChange",e=>{e===null&&this.resetTrustedFrame(),this.syncFrameTitle(e),this._trustedChannel.setCurrentFrame(this.bridgeFrame(e)),this.syncWebviewSubscription(e)});C(this,"handleTitleBarDoubleClick",e=>{const r=e.target;r instanceof Element&&r.closest("button")||this.requestFullScreen(!this._fullScreen)})}update(e,r){var u;const[i,s,a]=r;let l=!1;this._application!==i&&(this.detachApplicationSubscriptions(),this._application=i,this.attachApplicationSubscriptions(),this._connected&&(this.assignDocumentSource({preserveFrameSrc:!0}),l=!0));const c=this._artifact;if(c!==s){const f=c?!I9(c,s):!0;if(f&&(this._activeReloadFrameSrc=null),this._artifact=s,this.syncNavigationState(),this._connected){if(this.renderArtifact({resetTrust:f}),l=!0,c&&$9(c,s)){const p=this.currentMissingArtifactMessage();p&&((u=this._missingArtifactReplyTransport)==null||u.send(p))}}else f&&this.resetTrustedFrame()}return this._viewURL!==a.viewURL&&(this._viewURL=a.viewURL,this.syncNavigationState(),this._connected?(this.renderArtifact({resetTrust:!0}),l=!0):this._trustedChannel.reset()),this._contentURL!==a.contentURL&&(this._contentURL=a.contentURL,this._connected&&(this.renderArtifact(),l=!0)),this._fullScreen!==a.fullScreen&&(this._fullScreen=a.fullScreen,this._connected&&this._artifact&&(this.renderArtifact({preserveFrameSrc:!0}),l=!0)),this._inert=a.inert,this._onFullScreenChange=a.onFullScreenChange,this._connected&&!l&&this.renderArtifact({preserveFrameSrc:!0}),super.update(e,r)}attachApplicationSubscriptions(){!this._application||this._applicationSubscriptionsAttached||(this._application.addEventListener("artifact-content-changed",this.handleArtifactContentChanged),this._application.addEventListener("theme-changed",this.handleThemeChanged),this._applicationSubscriptionsAttached=!0)}detachApplicationSubscriptions(){!this._application||!this._applicationSubscriptionsAttached||(this._application.removeEventListener("artifact-content-changed",this.handleArtifactContentChanged),this._application.removeEventListener("theme-changed",this.handleThemeChanged),this._applicationSubscriptionsAttached=!1)}get activeView(){return null}connected(){this._connected=!0,this._trustedChannel.connect(),this.attachApplicationSubscriptions(),this.resetTrustedFrame(),this.syncNavigationState(),this.renderArtifact(),this.syncFrameSubscriptions()}disconnected(){var e;this._connected=!1,(e=this._dialogPresentation)==null||e.withdraw(),this._dialogPresentation=null,this._deleteConfirmationOpen=!1,this.resetTrustedFrame(),this._trustedChannel.disconnect(),this.unsubscribeFromWebview(),this.syncNavigationState(),this.detachApplicationSubscriptions()}handleTrustedFrameMessage(e,r){var i;switch(e.type){case"url-target-request":r.send({type:$A,url:this.currentExternalTargetURL()});return;case"artifact-missing-request":{const s=this.currentMissingArtifactMessage();s&&(this._missingArtifactReplyTransport=r,r.send(s));return}case"proxy-content-changed":this.handleProxyContentChanged();return;case"navigation-request":this.handleNavigationRequest(e);return;case"navigation-key":(i=this._application)==null||i.handleNavigationKey(e.key);return;case"artifact-pointer":this.handleArtifactPointer(e);return;case"bridge-ready":case"leaving":return}}handleArtifactPointer(e){const r=this.currentFrame;if(r===null||r.clientWidth<=0||r.clientHeight<=0)return;const i=r.getBoundingClientRect();Z_({eventType:e.eventType,clientX:i.left+e.clientX*i.width/r.clientWidth,clientY:i.top+e.clientY*i.height/r.clientHeight,button:e.button,buttons:e.buttons})}currentExternalTargetURL(){var r,i;const e=((r=this._navigationState)==null?void 0:r.currentURL)??null;return e&&C9(e)?e:((i=this._artifact)==null?void 0:i.kind)==="url"?this._artifact.url:null}currentMissingArtifactMessage(){const e=this._artifact;return(e==null?void 0:e.kind)!=="path"?null:{type:xA,title:e.title,path:e.path}}handleProxyContentChanged(){var e;((e=this._artifact)==null?void 0:e.kind)!=="url"||!Vr(this._artifact.url)||this.reloadProxyFrame()}handleNavigationRequest(e){if(!V2(e.url,window.location.href))return;this.syncNavigationState();const r=this._navigationState;if(!r)return;const i=this.convertIframeNavigationURL(e.url);if(i===k9||i===r.currentURL)return;const s=e.native===!0;(e.sameDocument||s)&&(this._preserveFrameSrcOnNavigationRender=!0),e.replace?r.replace(i):r.navigate(i)}syncNavigationState(){if(!this._connected||!this._artifact||this.isDemoPage()){this.disposeNavigationState();return}const e=this.canonicalURLForArtifact(this._artifact);this._navigationState&&this._navigationArtifactId===this._artifact.id&&this._navigationCanonicalURL===e||(this.disposeNavigationState(),this._navigationState=new VD(this._artifact.id,e),this._navigationArtifactId=this._artifact.id,this._navigationCanonicalURL=e,this._navigationState.addEventListener("change",this.handleNavigationChange),this._navigationState.currentURL!==null?this.renderArtifact():this._navigationState.canGoForward&&this.renderArtifact({preserveFrameSrc:!0}))}disposeNavigationState(){var e;(e=this._navigationState)==null||e.removeEventListener("change",this.handleNavigationChange),this._navigationState=null,this._navigationArtifactId=null,this._navigationCanonicalURL=null,this._preserveFrameSrcOnNavigationRender=!1}canonicalURLForArtifact(e){const r=fd({artifact:e,application:this._application,electron:wi(),browserDemo:this.browserDemo,viewURL:this._viewURL,contentURL:this._contentURL,currentURL:null}),i=r.viewURL;return e.kind==="url"&&Vr(e.url)||r.renderer==="url-webview"?bi(i):Cb(i,i)}convertIframeNavigationURL(e){var r;return((r=this._artifact)==null?void 0:r.kind)==="url"&&Vr(this._artifact.url)&&Vr(e)?bi(e):Cb(e,this._viewURL??this._navigationCanonicalURL??null)}handleWebviewNavigationEvent(e){const r=e.url;if(typeof r!="string"||!V2(r,window.location.href))return!1;this.syncNavigationState();const i=this._navigationState;if(!i)return!1;const s=bi(r);return s===i.currentURL?!1:(i.navigate(s),!0)}syncWebviewSubscription(e=this.currentFrame){const r=(e==null?void 0:e.tagName.toLowerCase())==="webview"?e:null;r!==this._subscribedWebview&&(this.unsubscribeFromWebview(),r&&(r.addEventListener("did-navigate",this.handleWebviewDidNavigate),r.addEventListener("did-navigate-in-page",this.handleWebviewDidNavigateInPage),this._subscribedWebview=r))}unsubscribeFromWebview(){this._subscribedWebview&&(this._subscribedWebview.removeEventListener("did-navigate",this.handleWebviewDidNavigate),this._subscribedWebview.removeEventListener("did-navigate-in-page",this.handleWebviewDidNavigateInPage),this._subscribedWebview=null)}get currentFrame(){var e;return((e=this._documentHost)==null?void 0:e.currentFrame)??null}syncFrameSubscriptions(){const e=this.currentFrame;this.syncFrameTitle(e),this._trustedChannel.setCurrentFrame(this.bridgeFrame(e)),this.syncWebviewSubscription(e)}bridgeFrame(e){return this.isDemoPage()?null:e}get browserDemo(){var e;return((e=this._application)==null?void 0:e.browserDemoMode)===!0}isDemoPage(){const e=this._artifact;return e?Ld(e,{electron:wi(),browserDemo:this.browserDemo}).renderer==="url-direct":!1}returnToOriginalPage(){var i,s;const e=this._artifact,r=this.currentFrame;(e==null?void 0:e.kind)!=="url"||(r==null?void 0:r.tagName.toLowerCase())!=="iframe"||((i=this._rootRef.value)==null||i.removeAttribute("data-embed-loaded"),r.setAttribute("src",e.url),(s=this._documentHost)==null||s.refreshFrameLoadState())}syncFrameTitle(e){e&&this._artifact&&e.getAttribute("title")!==this._artifact.title&&e.setAttribute("title",this._artifact.title)}resetTrustedFrame(){this._missingArtifactReplyTransport=null,this._trustedChannel.reset()}assignDocumentSource(e={}){var f,p,y;const r=this._artifact;if(!r)return;e.resetTrust&&this.resetTrustedFrame();const i={artifact:r,application:this._application,electron:wi(),browserDemo:this.browserDemo,viewURL:this._viewURL,contentURL:this._contentURL,currentURL:((f=this._navigationState)==null?void 0:f.currentURL)??null},s=fd(i),a=(p=this.currentFrame)==null?void 0:p.getAttribute("src");let l=null;this._activeReloadFrameSrc&&(W_(this._activeReloadFrameSrc,s.viewURL)?l=this._activeReloadFrameSrc:this._activeReloadFrameSrc=null);const c=e.frameSrcOverride??l??(e.preserveFrameSrc&&a?a:s.viewURL),u={...i,frameSrcOverride:c};this._pendingDocumentSource=u,(y=this._documentHost)==null||y.assignSource(u),this.syncFrameSubscriptions()}reloadProxyFrame(){var a,l,c,u,f;const e=this.currentFrame;if(!e||e.hasAttribute("data-content-url")||e.tagName.toLowerCase()==="webview"&&!(((a=this._artifact)==null?void 0:a.kind)==="path"||((l=this._artifact)==null?void 0:l.kind)==="url"&&Vr(this._artifact.url)))return;const r=((c=this._artifact)==null?void 0:c.kind)==="url"&&Vr(this._artifact.url)?((u=this._navigationState)==null?void 0:u.currentURL)??e.getAttribute("src"):e.getAttribute("src");if(r===null)return;const i=new URL(r,window.location.href);i.searchParams.set(Fl,String(++this._proxyReloadVersion));const s=r.startsWith("/")?`${i.pathname}${i.search}${i.hash}`:i.href;this._activeReloadFrameSrc=s,(f=this._rootRef.value)==null||f.removeAttribute("data-embed-loaded"),this.renderArtifact({frameSrcOverride:s,resetTrust:!0})}forceCurrentFrameSrc(){var s,a,l;if(!this._artifact)return;const e=fd({artifact:this._artifact,application:this._application,electron:wi(),browserDemo:this.browserDemo,viewURL:this._viewURL,contentURL:this._contentURL,currentURL:((s=this._navigationState)==null?void 0:s.currentURL)??null});if(e.renderer==="url-webview")return;const r=this.currentFrame,i=(r==null?void 0:r.tagName.toLowerCase())==="iframe"?r:null;i&&(this.resetTrustedFrame(),this._activeReloadFrameSrc=null,(a=this._rootRef.value)==null||a.removeAttribute("data-embed-loaded"),i.setAttribute("src",e.viewURL),(l=this._documentHost)==null||l.refreshFrameLoadState())}menuEntries(){return[{label:this._fullScreen?"Exit full-screen":"Make full-screen",action:()=>this.requestFullScreen(!this._fullScreen)},{separator:!0},{label:"Delete",destructive:!0,action:()=>this.showDeleteConfirmation()}]}closeMenu(){var i;const e=this._rootRef.value,r=e==null?void 0:e.querySelector(".artifact-menu-trigger");r&&((i=e==null?void 0:e.ownerDocument.querySelector(`tv-menu[trigger="${r.id}"]`))==null||i.removeAttribute("open"))}requestFullScreen(e){this.closeMenu(),this._onFullScreenChange(e)}showDeleteConfirmation(){var r,i,s;if(this._deleteConfirmationOpen)return;this.closeMenu(),this._deleteConfirmationOpen=!0,this.renderArtifact({preserveFrameSrc:!0});const e=(r=this._rootRef.value)==null?void 0:r.querySelector("dialog");e&&(this._dialogPresentation=tp(e,()=>this.dismissDeleteConfirmation()),(s=(i=this._rootRef.value)==null?void 0:i.querySelector(".dialog-actions button"))==null||s.focus())}dismissDeleteConfirmation(){const e=this._dialogPresentation;this._dialogPresentation=null,this._deleteConfirmationOpen=!1,e==null||e.withdraw(),this.isConnected&&this._artifact&&this.renderArtifact({preserveFrameSrc:!0})}confirmDelete(){var i;const e=(i=this._artifact)==null?void 0:i.id,r=this._application;this.dismissDeleteConfirmation(),!(!e||!r)&&r.deleteArtifact(e).catch(()=>{})}artifactIconTemplate(){return this.isDemoPage()?W`
293
293
  <button
294
294
  icon
295
295
  size="sm"
@@ -343,7 +343,7 @@ html, body {
343
343
  ${vt(this._rootRef)}
344
344
  >
345
345
  <div class="artifact-frame-clip">
346
- ${wN(this.captureDocumentHost,this.handleEmbedLoadChange,this.handleDocumentFrameChange)}
346
+ ${w9(this.captureDocumentHost,this.handleEmbedLoadChange,this.handleDocumentFrameChange)}
347
347
  <footer class="artifact-title-bar" @dblclick=${this.handleTitleBarDoubleClick}>
348
348
  ${this.artifactIconTemplate()}
349
349
  <span class="artifact-title">${s.title}</span>
@@ -364,7 +364,7 @@ html, body {
364
364
  </div>
365
365
  ${this.deleteConfirmationTemplate()}
366
366
  </div>
367
- `}renderArtifact(e={}){this._artifact&&(this.assignDocumentSource({preserveFrameSrc:e.preserveFrameSrc??!1,frameSrcOverride:e.frameSrcOverride,resetTrust:e.resetTrust}),this.render(),e.forceFrameSrc&&this.forceCurrentFrameSrc(),this.syncFrameSubscriptions())}}const RN=dn(TN);function CN(n){return n.startsWith("http://")||n.startsWith("https://")}function IN(n,t){return n.id!==t.id||n.kind!==t.kind?!1:n.kind==="path"&&t.kind==="path"?n.path===t.path:n.kind==="url"&&t.kind==="url"?W_(n.url,t.url):!0}function $N(n,t){return n.kind==="path"&&t.kind==="path"&&n.id===t.id&&(n.title!==t.title||n.path!==t.path)}function W_(n,t){try{const e=new URL(n,window.location.href),r=new URL(t,window.location.href);return e.searchParams.delete(Fl),r.searchParams.delete(Fl),e.origin===r.origin&&e.pathname===r.pathname&&e.search===r.search}catch{return!1}}function Cb(n,t){try{const e=new URL(n,window.location.href);if(t){const r=new URL(t,window.location.href);if(e.origin!=="null"&&e.origin===r.origin)return e.searchParams.delete(Fl),`${e.pathname}${e.search}${e.hash}`}}catch{return bi(n)}return bi(n)}function G_(n,t,e,r,i){const s=t.pages.map(a=>({artifactIds:[...a.artifactIds],geometry:{...a.geometry,full_screen:a===e?i:a.geometry.full_screen},size:a===e?{...r}:{...a.size}}));n.updateChannelPages(t.id,s).catch(()=>{})}function Xg(n,t,e,r){G_(n,t,e,e.size,r)}function mv(n){return{width:1-vb+vb*n.width/JM,height:1-yb+yb*n.height/YM}}function J_(n){return{width:Math.min(rN,n.width),height:Math.min(iN,n.height)}}function Ib(n,t){const e=mv(t),r=J_(t);return{width:Math.min(t.width,Math.max(r.width,n.width*e.width)),height:Math.min(t.height,Math.max(r.height,n.height*e.height))}}function xN(n,t){const e=mv(t);return{width:n.width/e.width,height:n.height/e.height}}const $b=.5,Fh=2,PN=120,DN=["left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"];var Lo,br,bl,ri,Sl,Oo,us,hs,ds,ii,Mo,No,Sr,_l,si,_r,Tt,oi,Ar,J,Y_,K_,Uc,X_,Hc,Qg,yd,Q_,Wu,Gu,Ju,Yu,zo,Ku,e1,Mn,t1,xa,e4,t4,Zc;class LN extends hn{constructor(){super(...arguments);m(this,J);m(this,Lo,Jn());m(this,br,Jn());m(this,bl);m(this,ri);m(this,Sl);m(this,Oo);m(this,us);m(this,hs,0);m(this,ds,0);m(this,ii,null);m(this,Mo,null);m(this,No,null);m(this,Sr,null);m(this,_l,[]);m(this,si,null);m(this,_r,null);m(this,Tt,null);m(this,oi,new Set);m(this,Ar,!1);m(this,Wu,e=>{const r=o(this,Tt);!r||e.pointerId!==r.pointerId||(r.lastPointer={x:e.clientX,y:e.clientY},r.option=e.altKey,h(this,J,e1).call(this,r))});m(this,Gu,e=>{var r;e.pointerId===((r=o(this,Tt))==null?void 0:r.pointerId)&&h(this,J,Mn).call(this,!0)});m(this,Ju,e=>{var r;e.pointerId===((r=o(this,Tt))==null?void 0:r.pointerId)&&h(this,J,Mn).call(this,!1)});m(this,Yu,e=>{var r;e.pointerId===((r=o(this,Tt))==null?void 0:r.pointerId)&&h(this,J,Mn).call(this,!1)});m(this,zo,e=>{const r=o(this,Tt);if(r){if(e.type==="keydown"&&e.key==="Escape"){e.preventDefault(),h(this,J,Mn).call(this,!1);return}r.option!==e.altKey&&(r.option=e.altKey,h(this,J,e1).call(this,r))}});m(this,Ku,()=>{const e=o(this,Tt);!e||xb(h(this,J,Uc).call(this,e.filmstrip),e.pageBox)||(h(this,J,Qg).call(this),h(this,J,Mn).call(this,!1))})}connected(){d(this,bl,void 0),d(this,ri,void 0),d(this,Sl,void 0),d(this,Oo,void 0),d(this,us,void 0)}template(e,r,i,s=!1){var Q;const a=!o(this,Ar)&&s;if(d(this,Ar,s),a){h(this,J,Mn).call(this,!1),h(this,J,Zc).call(this);for(const F of o(this,oi))F.cancel();o(this,oi).clear()}const l=(i==null?void 0:i.channelId)===(r==null?void 0:r.id)?i:null,c=MN(r,(l==null?void 0:l.pages)??(r==null?void 0:r.pages)),u=(r==null?void 0:r.selectedPage)??null,f=(r==null?void 0:r.id)??null,p=(u==null?void 0:u.artifactIds[0])??null,y=(u==null?void 0:u.geometry.full_screen)??null,v=o(this,Oo)!==void 0,S=c.map(({key:F,page:re})=>`${F}:${re.geometry.full_screen}:${re.size.width}:${re.size.height}`).sort().join("|"),_=l===null?null:c.map(({key:F})=>F).join("|"),$=f!==o(this,bl),H=p!==o(this,ri),L=y!==o(this,Sl),z=S!==o(this,Oo),P=_!==o(this,us),q=!o(this,Ar)&&l!==null&&o(this,us)!==void 0&&o(this,us)!==null&&P?h(this,J,e4).call(this):null,V=!o(this,Ar)&&H&&!$&&o(this,ri)!==void 0&&o(this,ri)!==null&&p!==null;return o(this,Tt)&&($||H||L)&&h(this,J,Mn).call(this,!1),d(this,bl,f),d(this,ri,p),d(this,Sl,y),d(this,Oo,S),d(this,us,_),d(this,_l,c),z&&v&&h(this,J,yd).call(this),$&&((Q=o(this,Sr))==null||Q.disconnect(),d(this,Mo,null),d(this,No,null),d(this,si,null)),queueMicrotask(()=>h(this,J,Hc).call(this)),$||H||z||a?queueMicrotask(()=>h(this,J,Y_).call(this,p,V)):P&&queueMicrotask(()=>{const F=o(this,br).value;F&&(h(this,J,xa).call(this,F,p,!1),q&&h(this,J,t4).call(this,q))}),W`
367
+ `}renderArtifact(e={}){this._artifact&&(this.assignDocumentSource({preserveFrameSrc:e.preserveFrameSrc??!1,frameSrcOverride:e.frameSrcOverride,resetTrust:e.resetTrust}),this.render(),e.forceFrameSrc&&this.forceCurrentFrameSrc(),this.syncFrameSubscriptions())}}const R9=dn(T9);function C9(n){return n.startsWith("http://")||n.startsWith("https://")}function I9(n,t){return n.id!==t.id||n.kind!==t.kind?!1:n.kind==="path"&&t.kind==="path"?n.path===t.path:n.kind==="url"&&t.kind==="url"?W_(n.url,t.url):!0}function $9(n,t){return n.kind==="path"&&t.kind==="path"&&n.id===t.id&&(n.title!==t.title||n.path!==t.path)}function W_(n,t){try{const e=new URL(n,window.location.href),r=new URL(t,window.location.href);return e.searchParams.delete(Fl),r.searchParams.delete(Fl),e.origin===r.origin&&e.pathname===r.pathname&&e.search===r.search}catch{return!1}}function Cb(n,t){try{const e=new URL(n,window.location.href);if(t){const r=new URL(t,window.location.href);if(e.origin!=="null"&&e.origin===r.origin)return e.searchParams.delete(Fl),`${e.pathname}${e.search}${e.hash}`}}catch{return bi(n)}return bi(n)}function G_(n,t,e,r,i){const s=t.pages.map(a=>({artifactIds:[...a.artifactIds],geometry:{...a.geometry,full_screen:a===e?i:a.geometry.full_screen},size:a===e?{...r}:{...a.size}}));n.updateChannelPages(t.id,s).catch(()=>{})}function Xg(n,t,e,r){G_(n,t,e,e.size,r)}function mv(n){return{width:1-vb+vb*n.width/JM,height:1-yb+yb*n.height/YM}}function J_(n){return{width:Math.min(r9,n.width),height:Math.min(i9,n.height)}}function Ib(n,t){const e=mv(t),r=J_(t);return{width:Math.min(t.width,Math.max(r.width,n.width*e.width)),height:Math.min(t.height,Math.max(r.height,n.height*e.height))}}function x9(n,t){const e=mv(t);return{width:n.width/e.width,height:n.height/e.height}}const $b=.5,Fh=2,P9=120,D9=["left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"];var Lo,br,bl,ri,Sl,Oo,us,hs,ds,ii,Mo,No,Sr,_l,si,_r,Tt,oi,Ar,J,Y_,K_,Uc,X_,Hc,Qg,yd,Q_,Wu,Gu,Ju,Yu,zo,Ku,e1,Mn,t1,xa,e4,t4,Zc;class L9 extends hn{constructor(){super(...arguments);m(this,J);m(this,Lo,Jn());m(this,br,Jn());m(this,bl);m(this,ri);m(this,Sl);m(this,Oo);m(this,us);m(this,hs,0);m(this,ds,0);m(this,ii,null);m(this,Mo,null);m(this,No,null);m(this,Sr,null);m(this,_l,[]);m(this,si,null);m(this,_r,null);m(this,Tt,null);m(this,oi,new Set);m(this,Ar,!1);m(this,Wu,e=>{const r=o(this,Tt);!r||e.pointerId!==r.pointerId||(r.lastPointer={x:e.clientX,y:e.clientY},r.option=e.altKey,h(this,J,e1).call(this,r))});m(this,Gu,e=>{var r;e.pointerId===((r=o(this,Tt))==null?void 0:r.pointerId)&&h(this,J,Mn).call(this,!0)});m(this,Ju,e=>{var r;e.pointerId===((r=o(this,Tt))==null?void 0:r.pointerId)&&h(this,J,Mn).call(this,!1)});m(this,Yu,e=>{var r;e.pointerId===((r=o(this,Tt))==null?void 0:r.pointerId)&&h(this,J,Mn).call(this,!1)});m(this,zo,e=>{const r=o(this,Tt);if(r){if(e.type==="keydown"&&e.key==="Escape"){e.preventDefault(),h(this,J,Mn).call(this,!1);return}r.option!==e.altKey&&(r.option=e.altKey,h(this,J,e1).call(this,r))}});m(this,Ku,()=>{const e=o(this,Tt);!e||xb(h(this,J,Uc).call(this,e.filmstrip),e.pageBox)||(h(this,J,Qg).call(this),h(this,J,Mn).call(this,!1))})}connected(){d(this,bl,void 0),d(this,ri,void 0),d(this,Sl,void 0),d(this,Oo,void 0),d(this,us,void 0)}template(e,r,i,s=!1){var Q;const a=!o(this,Ar)&&s;if(d(this,Ar,s),a){h(this,J,Mn).call(this,!1),h(this,J,Zc).call(this);for(const F of o(this,oi))F.cancel();o(this,oi).clear()}const l=(i==null?void 0:i.channelId)===(r==null?void 0:r.id)?i:null,c=M9(r,(l==null?void 0:l.pages)??(r==null?void 0:r.pages)),u=(r==null?void 0:r.selectedPage)??null,f=(r==null?void 0:r.id)??null,p=(u==null?void 0:u.artifactIds[0])??null,y=(u==null?void 0:u.geometry.full_screen)??null,v=o(this,Oo)!==void 0,S=c.map(({key:F,page:re})=>`${F}:${re.geometry.full_screen}:${re.size.width}:${re.size.height}`).sort().join("|"),_=l===null?null:c.map(({key:F})=>F).join("|"),$=f!==o(this,bl),H=p!==o(this,ri),L=y!==o(this,Sl),z=S!==o(this,Oo),P=_!==o(this,us),q=!o(this,Ar)&&l!==null&&o(this,us)!==void 0&&o(this,us)!==null&&P?h(this,J,e4).call(this):null,V=!o(this,Ar)&&H&&!$&&o(this,ri)!==void 0&&o(this,ri)!==null&&p!==null;return o(this,Tt)&&($||H||L)&&h(this,J,Mn).call(this,!1),d(this,bl,f),d(this,ri,p),d(this,Sl,y),d(this,Oo,S),d(this,us,_),d(this,_l,c),z&&v&&h(this,J,yd).call(this),$&&((Q=o(this,Sr))==null||Q.disconnect(),d(this,Mo,null),d(this,No,null),d(this,si,null)),queueMicrotask(()=>h(this,J,Hc).call(this)),$||H||z||a?queueMicrotask(()=>h(this,J,Y_).call(this,p,V)):P&&queueMicrotask(()=>{const F=o(this,br).value;F&&(h(this,J,xa).call(this,F,p,!1),q&&h(this,J,t4).call(this,q))}),W`
368
368
  <section
369
369
  class="stage"
370
370
  ${vt(o(this,Lo))}
@@ -388,10 +388,10 @@ html, body {
388
388
  style=${h(this,J,X_).call(this,F)}
389
389
  @click=${xe||re===null?null:()=>e.selectPage(r.id,re.id)}
390
390
  >
391
- ${re?RN(e,re,{viewURL:e.getArtifactViewURL(re),contentURL:e.getArtifactContentURL(re),fullScreen:F.geometry.full_screen,inert:!xe,onFullScreenChange:et=>Xg(e,r,F,et)}):null}
391
+ ${re?R9(e,re,{viewURL:e.getArtifactViewURL(re),contentURL:e.getArtifactContentURL(re),fullScreen:F.geometry.full_screen,inert:!xe,onFullScreenChange:et=>Xg(e,r,F,et)}):null}
392
392
  ${xe?W`
393
393
  <div class="page-handles" aria-hidden="true">
394
- ${DN.map(et=>W`
394
+ ${D9.map(et=>W`
395
395
  <span
396
396
  class="page-handle ${et}"
397
397
  @pointerdown=${le=>h(this,J,Q_).call(this,le,et,e,r,F,Ne)}
@@ -405,7 +405,7 @@ html, body {
405
405
  </div>
406
406
  `)}
407
407
  </section>
408
- `}disconnected(){var e;h(this,J,Mn).call(this,!1),h(this,J,yd).call(this),h(this,J,Zc).call(this),cancelAnimationFrame(o(this,hs)),d(this,hs,0),(e=o(this,Sr))==null||e.disconnect(),d(this,Sr,null),d(this,Mo,null),d(this,No,null),d(this,si,null),d(this,_l,[]);for(const r of o(this,oi))r.cancel();o(this,oi).clear()}}Lo=new WeakMap,br=new WeakMap,bl=new WeakMap,ri=new WeakMap,Sl=new WeakMap,Oo=new WeakMap,us=new WeakMap,hs=new WeakMap,ds=new WeakMap,ii=new WeakMap,Mo=new WeakMap,No=new WeakMap,Sr=new WeakMap,_l=new WeakMap,si=new WeakMap,_r=new WeakMap,Tt=new WeakMap,oi=new WeakMap,Ar=new WeakMap,J=new WeakSet,Y_=function(e,r){const i=o(this,br).value;i&&(cancelAnimationFrame(o(this,hs)),d(this,hs,requestAnimationFrame(()=>{d(this,hs,0),h(this,J,xa).call(this,i,e,r)})))},K_=function(e,r){var i;typeof ResizeObserver>"u"||e===o(this,Mo)&&r===o(this,No)||((i=o(this,Sr))==null||i.disconnect(),d(this,Mo,e),d(this,No,r),d(this,Sr,new ResizeObserver(()=>{const s=h(this,J,Uc).call(this,e);xb(s,o(this,si))||(h(this,J,Qg).call(this),o(this,Tt)&&h(this,J,Mn).call(this,!1),h(this,J,Hc).call(this,e)),o(this,ii)===null&&h(this,J,xa).call(this,e,o(this,ri)??null,!1)})),o(this,Sr).observe(e),o(this,Sr).observe(r))},Uc=function(e){const r=Number.parseFloat(getComputedStyle(e).getPropertyValue("--page-inset"))||0;return{width:Math.max(0,e.clientWidth-2*r),height:Math.max(0,e.clientHeight-r)}},X_=function(e){if(e.geometry.full_screen||o(this,si)===null)return"";const r=Ib(e.size,o(this,si));return`width: ${r.width}px; height: ${r.height}px;`},Hc=function(e=o(this,br).value){var s;if(!e)return;const r=h(this,J,Uc).call(this,e);d(this,si,r);const i=new Map(o(this,_l).map(a=>[a.key,a.page]));for(const a of e.querySelectorAll(".page")){if(a===((s=o(this,Tt))==null?void 0:s.pageElement))continue;const l=i.get(a.dataset.pageKey??"");if(!l)continue;if(l.geometry.full_screen){a.style.width="",a.style.height="";continue}const c=Ib(l.size,r);a.style.width=`${c.width}px`,a.style.height=`${c.height}px`}},Qg=function(){const e=o(this,Lo).value;e&&(e.setAttribute("window-tracking",""),o(this,_r)!==null&&clearTimeout(o(this,_r)),d(this,_r,setTimeout(()=>{d(this,_r,null),e.removeAttribute("window-tracking")},PN)))},yd=function(){var e;o(this,_r)!==null&&(clearTimeout(o(this,_r)),d(this,_r,null)),(e=o(this,Lo).value)==null||e.removeAttribute("window-tracking")},Q_=function(e,r,i,s,a,l){if(o(this,Ar)||e.button!==0||!e.isPrimary)return;const c=e.currentTarget,u=c.closest(".page"),f=o(this,br).value,p=o(this,Lo).value;if(!u||!f||!p)return;h(this,J,Mn).call(this,!1),h(this,J,yd).call(this),e.preventDefault(),e.stopPropagation();const y=u.getBoundingClientRect(),v=h(this,J,Uc).call(this,f),S=mv(v),_=a.geometry.full_screen,$=r.includes("left")||r.includes("right"),H=r.includes("top")||r.includes("bottom");d(this,Tt,{application:i,channel:s,page:a,pageKey:l,pageElement:u,filmstrip:f,stage:p,handle:c,pointerId:e.pointerId,startPointer:{x:e.clientX,y:e.clientY},lastPointer:{x:e.clientX,y:e.clientY},startRendered:{width:y.width,height:y.height},rendered:{width:y.width,height:y.height},baselineSize:_?{width:v.width/S.width,height:v.height/S.height}:{...a.size},pageBox:v,wasFullScreen:_,horizontal:$,vertical:H,leftish:r.includes("left"),topish:r.includes("top"),option:e.altKey,armed:!1,leftFullScreen:!1}),p.setAttribute("resizing",""),c.addEventListener("pointermove",o(this,Wu)),c.addEventListener("pointerup",o(this,Gu)),c.addEventListener("pointercancel",o(this,Ju)),c.addEventListener("lostpointercapture",o(this,Yu)),window.addEventListener("keydown",o(this,zo)),window.addEventListener("keyup",o(this,zo)),window.addEventListener("resize",o(this,Ku)),c.setPointerCapture(e.pointerId)},Wu=new WeakMap,Gu=new WeakMap,Ju=new WeakMap,Yu=new WeakMap,zo=new WeakMap,Ku=new WeakMap,e1=function(e){const r=e.lastPointer.x!==e.startPointer.x||e.lastPointer.y!==e.startPointer.y;if(e.wasFullScreen&&!e.leftFullScreen){if(!r)return;e.leftFullScreen=!0,e.pageElement.removeAttribute("full-screen")}const i=J_(e.pageBox);let s=e.startRendered.width,a=e.startRendered.height;if(e.horizontal){const l=e.leftish?-Fh:Fh;s=Math.min(e.pageBox.width,Math.max(i.width,e.startRendered.width+(e.lastPointer.x-e.startPointer.x)*l))}if(e.vertical){const l=e.topish?-Fh:Fh;a=Math.min(e.pageBox.height,Math.max(i.height,e.startRendered.height+(e.lastPointer.y-e.startPointer.y)*l))}e.armed=!e.option&&e.horizontal&&e.vertical&&s>=e.pageBox.width-bb&&a>=e.pageBox.height-bb,e.rendered=e.armed?{...e.pageBox}:{width:s,height:a},e.pageElement.style.width=`${e.rendered.width}px`,e.pageElement.style.height=`${e.rendered.height}px`,h(this,J,t1).call(this,e.stage,e.armed),h(this,J,xa).call(this,e.filmstrip,e.pageKey,!1)},Mn=function(e){const r=o(this,Tt);if(r){if(d(this,Tt,null),r.handle.removeEventListener("pointermove",o(this,Wu)),r.handle.removeEventListener("pointerup",o(this,Gu)),r.handle.removeEventListener("pointercancel",o(this,Ju)),r.handle.removeEventListener("lostpointercapture",o(this,Yu)),window.removeEventListener("keydown",o(this,zo)),window.removeEventListener("keyup",o(this,zo)),window.removeEventListener("resize",o(this,Ku)),r.handle.hasPointerCapture(r.pointerId)&&r.handle.releasePointerCapture(r.pointerId),h(this,J,t1).call(this,r.stage,!1),e&&r.armed)r.wasFullScreen&&r.pageElement.setAttribute("full-screen",""),Xg(r.application,r.channel,r.page,!0);else if(e){const i={...r.baselineSize},s=xN(r.rendered,r.pageBox);let a=r.wasFullScreen&&r.leftFullScreen;r.horizontal&&r.rendered.width!==r.startRendered.width&&(i.width=s.width,a=!0),r.vertical&&r.rendered.height!==r.startRendered.height&&(i.height=s.height,a=!0),a?G_(r.application,r.channel,r.page,i,!1):h(this,J,Hc).call(this,r.filmstrip)}else r.pageElement.toggleAttribute("full-screen",r.wasFullScreen),h(this,J,Hc).call(this,r.filmstrip);r.pageElement.getBoundingClientRect(),r.stage.removeAttribute("resizing"),h(this,J,xa).call(this,r.filmstrip,r.pageKey,!1)}},t1=function(e,r){const i=e.querySelector(":scope > .snap-outline");if(!r){i==null||i.remove();return}if(i)return;const s=document.createElement("div");s.className="snap-outline",s.setAttribute("aria-hidden","true"),e.append(s)},xa=function(e,r,i){const s=[...e.querySelectorAll(".page")].find(y=>y.dataset.pageKey===r);if(!s){h(this,J,Zc).call(this);return}h(this,J,K_).call(this,e,s);const a=s.getBoundingClientRect(),l=e.getBoundingClientRect(),c=Math.max(0,Math.min(e.scrollLeft+a.left+a.width/2-(l.left+l.width/2),e.scrollWidth-e.clientWidth));if(h(this,J,Zc).call(this),o(this,Ar)||!i||Math.abs(c-e.scrollLeft)<$b||matchMedia("(prefers-reduced-motion: reduce)").matches){e.scrollLeft=c;return}const u=e.scrollLeft,f=e.animate([{},{}],{duration:z_,easing:"ease"});d(this,ii,f);const p=()=>{var v;if(f!==o(this,ii))return;const y=f.playState==="finished"?1:((v=f.effect)==null?void 0:v.getComputedTiming().progress)??0;e.scrollLeft=u+(c-u)*y,f.playState==="finished"?(e.scrollLeft=c,d(this,ii,null),d(this,ds,0)):d(this,ds,requestAnimationFrame(p))};d(this,ds,requestAnimationFrame(p))},e4=function(){const e=o(this,br).value;return e?new Map([...e.querySelectorAll(".page")].map(r=>[r.dataset.pageKey??"",r.getBoundingClientRect().left])):new Map},t4=function(e){if(o(this,Ar))return;const r=o(this,br).value;if(r)for(const i of r.querySelectorAll(".page")){if(i.hasAttribute("selected"))continue;const s=e.get(i.dataset.pageKey??"");if(s===void 0)continue;const a=s-i.getBoundingClientRect().left;if(Math.abs(a)<=$b)continue;const l=i.animate({translate:[`${a}px 0`,"0px 0"]},{duration:za,easing:"ease"});o(this,oi).add(l),l.finished.finally(()=>{o(this,oi).delete(l)}).catch(()=>{})}},Zc=function(){var e;cancelAnimationFrame(o(this,ds)),d(this,ds,0),(e=o(this,ii))==null||e.cancel(),d(this,ii,null)};const ON=dn(LN);function MN(n,t){if(!n||!t)return[];const e=new Map(n.artifacts.map(r=>[r.id,r]));return t.map((r,i)=>{const s=r.artifactIds[0];return{page:r,artifact:s===void 0?null:e.get(s)??null,key:s??`empty-page-${i}`}})}function xb(n,t){return t!==null&&n.width===t.width&&n.height===t.height}const NN=250,zN=1e3;var fs,ps,Uo,ms,Wt,n4,n1,r4,r1,i4;class UN extends hn{constructor(){super(...arguments);m(this,Wt);m(this,fs,ZN());m(this,ps,null);m(this,Uo,!1);m(this,ms,null)}disconnected(){var e;h(this,Wt,r1).call(this),(e=o(this,ps))==null||e.withdraw(),d(this,ps,null),d(this,Uo,!1),Ag(null,o(this,fs))}template(e,r){return h(this,Wt,r4).call(this,e),Ag(ep(h(this,Wt,n4).call(this,e,r),s4(r.dragStrip)),o(this,fs)),h(this,Wt,i4).call(this),o(this,fs)}}fs=new WeakMap,ps=new WeakMap,Uo=new WeakMap,ms=new WeakMap,Wt=new WeakSet,n4=function(e,r){switch(e.kind){case"connecting":return W`
408
+ `}disconnected(){var e;h(this,J,Mn).call(this,!1),h(this,J,yd).call(this),h(this,J,Zc).call(this),cancelAnimationFrame(o(this,hs)),d(this,hs,0),(e=o(this,Sr))==null||e.disconnect(),d(this,Sr,null),d(this,Mo,null),d(this,No,null),d(this,si,null),d(this,_l,[]);for(const r of o(this,oi))r.cancel();o(this,oi).clear()}}Lo=new WeakMap,br=new WeakMap,bl=new WeakMap,ri=new WeakMap,Sl=new WeakMap,Oo=new WeakMap,us=new WeakMap,hs=new WeakMap,ds=new WeakMap,ii=new WeakMap,Mo=new WeakMap,No=new WeakMap,Sr=new WeakMap,_l=new WeakMap,si=new WeakMap,_r=new WeakMap,Tt=new WeakMap,oi=new WeakMap,Ar=new WeakMap,J=new WeakSet,Y_=function(e,r){const i=o(this,br).value;i&&(cancelAnimationFrame(o(this,hs)),d(this,hs,requestAnimationFrame(()=>{d(this,hs,0),h(this,J,xa).call(this,i,e,r)})))},K_=function(e,r){var i;typeof ResizeObserver>"u"||e===o(this,Mo)&&r===o(this,No)||((i=o(this,Sr))==null||i.disconnect(),d(this,Mo,e),d(this,No,r),d(this,Sr,new ResizeObserver(()=>{const s=h(this,J,Uc).call(this,e);xb(s,o(this,si))||(h(this,J,Qg).call(this),o(this,Tt)&&h(this,J,Mn).call(this,!1),h(this,J,Hc).call(this,e)),o(this,ii)===null&&h(this,J,xa).call(this,e,o(this,ri)??null,!1)})),o(this,Sr).observe(e),o(this,Sr).observe(r))},Uc=function(e){const r=Number.parseFloat(getComputedStyle(e).getPropertyValue("--page-inset"))||0;return{width:Math.max(0,e.clientWidth-2*r),height:Math.max(0,e.clientHeight-r)}},X_=function(e){if(e.geometry.full_screen||o(this,si)===null)return"";const r=Ib(e.size,o(this,si));return`width: ${r.width}px; height: ${r.height}px;`},Hc=function(e=o(this,br).value){var s;if(!e)return;const r=h(this,J,Uc).call(this,e);d(this,si,r);const i=new Map(o(this,_l).map(a=>[a.key,a.page]));for(const a of e.querySelectorAll(".page")){if(a===((s=o(this,Tt))==null?void 0:s.pageElement))continue;const l=i.get(a.dataset.pageKey??"");if(!l)continue;if(l.geometry.full_screen){a.style.width="",a.style.height="";continue}const c=Ib(l.size,r);a.style.width=`${c.width}px`,a.style.height=`${c.height}px`}},Qg=function(){const e=o(this,Lo).value;e&&(e.setAttribute("window-tracking",""),o(this,_r)!==null&&clearTimeout(o(this,_r)),d(this,_r,setTimeout(()=>{d(this,_r,null),e.removeAttribute("window-tracking")},P9)))},yd=function(){var e;o(this,_r)!==null&&(clearTimeout(o(this,_r)),d(this,_r,null)),(e=o(this,Lo).value)==null||e.removeAttribute("window-tracking")},Q_=function(e,r,i,s,a,l){if(o(this,Ar)||e.button!==0||!e.isPrimary)return;const c=e.currentTarget,u=c.closest(".page"),f=o(this,br).value,p=o(this,Lo).value;if(!u||!f||!p)return;h(this,J,Mn).call(this,!1),h(this,J,yd).call(this),e.preventDefault(),e.stopPropagation();const y=u.getBoundingClientRect(),v=h(this,J,Uc).call(this,f),S=mv(v),_=a.geometry.full_screen,$=r.includes("left")||r.includes("right"),H=r.includes("top")||r.includes("bottom");d(this,Tt,{application:i,channel:s,page:a,pageKey:l,pageElement:u,filmstrip:f,stage:p,handle:c,pointerId:e.pointerId,startPointer:{x:e.clientX,y:e.clientY},lastPointer:{x:e.clientX,y:e.clientY},startRendered:{width:y.width,height:y.height},rendered:{width:y.width,height:y.height},baselineSize:_?{width:v.width/S.width,height:v.height/S.height}:{...a.size},pageBox:v,wasFullScreen:_,horizontal:$,vertical:H,leftish:r.includes("left"),topish:r.includes("top"),option:e.altKey,armed:!1,leftFullScreen:!1}),p.setAttribute("resizing",""),c.addEventListener("pointermove",o(this,Wu)),c.addEventListener("pointerup",o(this,Gu)),c.addEventListener("pointercancel",o(this,Ju)),c.addEventListener("lostpointercapture",o(this,Yu)),window.addEventListener("keydown",o(this,zo)),window.addEventListener("keyup",o(this,zo)),window.addEventListener("resize",o(this,Ku)),c.setPointerCapture(e.pointerId)},Wu=new WeakMap,Gu=new WeakMap,Ju=new WeakMap,Yu=new WeakMap,zo=new WeakMap,Ku=new WeakMap,e1=function(e){const r=e.lastPointer.x!==e.startPointer.x||e.lastPointer.y!==e.startPointer.y;if(e.wasFullScreen&&!e.leftFullScreen){if(!r)return;e.leftFullScreen=!0,e.pageElement.removeAttribute("full-screen")}const i=J_(e.pageBox);let s=e.startRendered.width,a=e.startRendered.height;if(e.horizontal){const l=e.leftish?-Fh:Fh;s=Math.min(e.pageBox.width,Math.max(i.width,e.startRendered.width+(e.lastPointer.x-e.startPointer.x)*l))}if(e.vertical){const l=e.topish?-Fh:Fh;a=Math.min(e.pageBox.height,Math.max(i.height,e.startRendered.height+(e.lastPointer.y-e.startPointer.y)*l))}e.armed=!e.option&&e.horizontal&&e.vertical&&s>=e.pageBox.width-bb&&a>=e.pageBox.height-bb,e.rendered=e.armed?{...e.pageBox}:{width:s,height:a},e.pageElement.style.width=`${e.rendered.width}px`,e.pageElement.style.height=`${e.rendered.height}px`,h(this,J,t1).call(this,e.stage,e.armed),h(this,J,xa).call(this,e.filmstrip,e.pageKey,!1)},Mn=function(e){const r=o(this,Tt);if(r){if(d(this,Tt,null),r.handle.removeEventListener("pointermove",o(this,Wu)),r.handle.removeEventListener("pointerup",o(this,Gu)),r.handle.removeEventListener("pointercancel",o(this,Ju)),r.handle.removeEventListener("lostpointercapture",o(this,Yu)),window.removeEventListener("keydown",o(this,zo)),window.removeEventListener("keyup",o(this,zo)),window.removeEventListener("resize",o(this,Ku)),r.handle.hasPointerCapture(r.pointerId)&&r.handle.releasePointerCapture(r.pointerId),h(this,J,t1).call(this,r.stage,!1),e&&r.armed)r.wasFullScreen&&r.pageElement.setAttribute("full-screen",""),Xg(r.application,r.channel,r.page,!0);else if(e){const i={...r.baselineSize},s=x9(r.rendered,r.pageBox);let a=r.wasFullScreen&&r.leftFullScreen;r.horizontal&&r.rendered.width!==r.startRendered.width&&(i.width=s.width,a=!0),r.vertical&&r.rendered.height!==r.startRendered.height&&(i.height=s.height,a=!0),a?G_(r.application,r.channel,r.page,i,!1):h(this,J,Hc).call(this,r.filmstrip)}else r.pageElement.toggleAttribute("full-screen",r.wasFullScreen),h(this,J,Hc).call(this,r.filmstrip);r.pageElement.getBoundingClientRect(),r.stage.removeAttribute("resizing"),h(this,J,xa).call(this,r.filmstrip,r.pageKey,!1)}},t1=function(e,r){const i=e.querySelector(":scope > .snap-outline");if(!r){i==null||i.remove();return}if(i)return;const s=document.createElement("div");s.className="snap-outline",s.setAttribute("aria-hidden","true"),e.append(s)},xa=function(e,r,i){const s=[...e.querySelectorAll(".page")].find(y=>y.dataset.pageKey===r);if(!s){h(this,J,Zc).call(this);return}h(this,J,K_).call(this,e,s);const a=s.getBoundingClientRect(),l=e.getBoundingClientRect(),c=Math.max(0,Math.min(e.scrollLeft+a.left+a.width/2-(l.left+l.width/2),e.scrollWidth-e.clientWidth));if(h(this,J,Zc).call(this),o(this,Ar)||!i||Math.abs(c-e.scrollLeft)<$b||matchMedia("(prefers-reduced-motion: reduce)").matches){e.scrollLeft=c;return}const u=e.scrollLeft,f=e.animate([{},{}],{duration:z_,easing:"ease"});d(this,ii,f);const p=()=>{var v;if(f!==o(this,ii))return;const y=f.playState==="finished"?1:((v=f.effect)==null?void 0:v.getComputedTiming().progress)??0;e.scrollLeft=u+(c-u)*y,f.playState==="finished"?(e.scrollLeft=c,d(this,ii,null),d(this,ds,0)):d(this,ds,requestAnimationFrame(p))};d(this,ds,requestAnimationFrame(p))},e4=function(){const e=o(this,br).value;return e?new Map([...e.querySelectorAll(".page")].map(r=>[r.dataset.pageKey??"",r.getBoundingClientRect().left])):new Map},t4=function(e){if(o(this,Ar))return;const r=o(this,br).value;if(r)for(const i of r.querySelectorAll(".page")){if(i.hasAttribute("selected"))continue;const s=e.get(i.dataset.pageKey??"");if(s===void 0)continue;const a=s-i.getBoundingClientRect().left;if(Math.abs(a)<=$b)continue;const l=i.animate({translate:[`${a}px 0`,"0px 0"]},{duration:za,easing:"ease"});o(this,oi).add(l),l.finished.finally(()=>{o(this,oi).delete(l)}).catch(()=>{})}},Zc=function(){var e;cancelAnimationFrame(o(this,ds)),d(this,ds,0),(e=o(this,ii))==null||e.cancel(),d(this,ii,null)};const O9=dn(L9);function M9(n,t){if(!n||!t)return[];const e=new Map(n.artifacts.map(r=>[r.id,r]));return t.map((r,i)=>{const s=r.artifactIds[0];return{page:r,artifact:s===void 0?null:e.get(s)??null,key:s??`empty-page-${i}`}})}function xb(n,t){return t!==null&&n.width===t.width&&n.height===t.height}const N9=250,z9=1e3;var fs,ps,Uo,ms,Wt,n4,n1,r4,r1,i4;class U9 extends hn{constructor(){super(...arguments);m(this,Wt);m(this,fs,Z9());m(this,ps,null);m(this,Uo,!1);m(this,ms,null)}disconnected(){var e;h(this,Wt,r1).call(this),(e=o(this,ps))==null||e.withdraw(),d(this,ps,null),d(this,Uo,!1),Ag(null,o(this,fs))}template(e,r){return h(this,Wt,r4).call(this,e),Ag(ep(h(this,Wt,n4).call(this,e,r),s4(r.dragStrip)),o(this,fs)),h(this,Wt,i4).call(this),o(this,fs)}}fs=new WeakMap,ps=new WeakMap,Uo=new WeakMap,ms=new WeakMap,Wt=new WeakSet,n4=function(e,r){switch(e.kind){case"connecting":return W`
409
409
  <div class="system-modal" role="status" aria-live="polite">
410
410
  <tv-icon name="spinner" size="xl" spinning></tv-icon>
411
411
  <h2>Connecting</h2>
@@ -430,14 +430,14 @@ html, body {
430
430
  <p>Check your internet connection and that the server is running. ${Pb(e.nextRetryAt)}</p>
431
431
  ${h(this,Wt,n1).call(this,r)}
432
432
  </div>
433
- `}},n1=function(e){return e.context==="local"?W`<button intent="danger" class="system-modal-disconnect" @click=${e.onDisconnect}>Disconnect from Server</button>`:null},r4=function(e){const r=(e.kind==="disconnected"||e.kind==="error")&&e.nextRetryAt!==null;r&&o(this,ms)===null?d(this,ms,setInterval(()=>this.render(),NN)):r||h(this,Wt,r1).call(this)},r1=function(){o(this,ms)!==null&&(clearInterval(o(this,ms)),d(this,ms,null))},i4=function(){o(this,ps)!==null||o(this,Uo)||(d(this,Uo,!0),queueMicrotask(()=>{if(d(this,Uo,!1),!this.isConnected||!o(this,fs).isConnected||o(this,ps)!==null)return;const e=o(this,fs).querySelector("dialog");e!==null&&d(this,ps,tp(e,()=>{}))}))};const HN=dn(UN);function ZN(){const n=document.createElement("section");return n.className="system-modal-host",n}function Pb(n){if(n===null)return"Reconnecting now…";const t=n-Date.now();return t<=0?"Reconnecting now…":`Reconnecting in ${Math.ceil(t/zN)}s…`}function s4(n=!1){return n?W`<div class="window-drag-strip" electron-draggable aria-hidden="true"></div>`:null}/**
433
+ `}},n1=function(e){return e.context==="local"?W`<button intent="danger" class="system-modal-disconnect" @click=${e.onDisconnect}>Disconnect from Server</button>`:null},r4=function(e){const r=(e.kind==="disconnected"||e.kind==="error")&&e.nextRetryAt!==null;r&&o(this,ms)===null?d(this,ms,setInterval(()=>this.render(),N9)):r||h(this,Wt,r1).call(this)},r1=function(){o(this,ms)!==null&&(clearInterval(o(this,ms)),d(this,ms,null))},i4=function(){o(this,ps)!==null||o(this,Uo)||(d(this,Uo,!0),queueMicrotask(()=>{if(d(this,Uo,!1),!this.isConnected||!o(this,fs).isConnected||o(this,ps)!==null)return;const e=o(this,fs).querySelector("dialog");e!==null&&d(this,ps,tp(e,()=>{}))}))};const H9=dn(U9);function Z9(){const n=document.createElement("section");return n.className="system-modal-host",n}function Pb(n){if(n===null)return"Reconnecting now…";const t=n-Date.now();return t<=0?"Reconnecting now…":`Reconnecting in ${Math.ceil(t/z9)}s…`}function s4(n=!1){return n?W`<div class="window-drag-strip" electron-draggable aria-hidden="true"></div>`:null}/**
434
434
  * @license
435
435
  * Copyright 2017 Google LLC
436
436
  * SPDX-License-Identifier: BSD-3-Clause
437
- */class i1 extends Ah{constructor(t){if(super(t),this.it=de,t.type!==Ir.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===de||t==null)return this._t=void 0,this.it=t;if(t===$t)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}}i1.directiveName="unsafeHTML",i1.resultType=1;const o4=rc(i1);/*! @license DOMPurify 3.4.16 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.16/LICENSE */function Db(n,t){(t==null||t>n.length)&&(t=n.length);for(var e=0,r=Array(t);e<t;e++)r[e]=n[e];return r}function qN(n){if(Array.isArray(n))return n}function VN(n,t){var e=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(e!=null){var r,i,s,a,l=[],c=!0,u=!1;try{if(s=(e=e.call(n)).next,t!==0)for(;!(c=(r=s.call(e)).done)&&(l.push(r.value),l.length!==t);c=!0);}catch(f){u=!0,i=f}finally{try{if(!c&&e.return!=null&&(a=e.return(),Object(a)!==a))return}finally{if(u)throw i}}return l}}function FN(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
438
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */function BN(n,t){return qN(n)||VN(n,t)||jN(n,t)||FN()}function jN(n,t){if(n){if(typeof n=="string")return Db(n,t);var e={}.toString.call(n).slice(8,-1);return e==="Object"&&n.constructor&&(e=n.constructor.name),e==="Map"||e==="Set"?Array.from(n):e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Db(n,t):void 0}}const a4=Object.entries,Lb=Object.setPrototypeOf,WN=Object.isFrozen,GN=Object.getPrototypeOf,JN=Object.getOwnPropertyDescriptor;let ot=Object.freeze,ct=Object.seal,Pa=Object.create,l4=typeof Reflect<"u"&&Reflect,s1=l4.apply,o1=l4.construct;ot||(ot=function(t){return t});ct||(ct=function(t){return t});s1||(s1=function(t,e){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];return t.apply(e,i)});o1||(o1=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return new t(...r)});const Ys=Qe(Array.prototype.forEach),YN=Qe(Array.prototype.lastIndexOf),Ob=Qe(Array.prototype.pop),bc=Qe(Array.prototype.push),KN=Qe(Array.prototype.splice),Za=Array.isArray,qc=Qe(String.prototype.toLowerCase),Nm=Qe(String.prototype.toString),Mb=Qe(String.prototype.match),Sc=Qe(String.prototype.replace),Nb=Qe(String.prototype.indexOf),XN=Qe(String.prototype.trim),QN=Qe(Number.prototype.toString),e9=Qe(Boolean.prototype.toString),zb=typeof BigInt>"u"?null:Qe(BigInt.prototype.toString),Ub=typeof Symbol>"u"?null:Qe(Symbol.prototype.toString),Ft=Qe(Object.prototype.hasOwnProperty),_c=Qe(Object.prototype.toString),pt=Qe(RegExp.prototype.test),Oi=t9(TypeError);function Qe(n){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return s1(n,t,r)}}function t9(n){return function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return o1(n,e)}}function ve(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:qc;if(Lb&&Lb(n,null),!Za(t))return n;let r=t.length;for(;r--;){let i=t[r];if(typeof i=="string"){const s=e(i);s!==i&&(WN(t)||(t[r]=s),i=s)}n[i]=!0}return n}function n9(n){for(let t=0;t<n.length;t++)Ft(n,t)||(n[t]=null);return n}function Xt(n){const t=Pa(null);for(const r of a4(n)){var e=BN(r,2);const i=e[0],s=e[1];Ft(n,i)&&(Za(s)?t[i]=n9(s):s&&typeof s=="object"&&s.constructor===Object?t[i]=Xt(s):t[i]=s)}return t}function r9(n){switch(typeof n){case"string":return n;case"number":return QN(n);case"boolean":return e9(n);case"bigint":return zb?zb(n):"0";case"symbol":return Ub?Ub(n):"Symbol()";case"undefined":return _c(n);case"function":case"object":{if(n===null)return _c(n);const t=n,e=gn(t,"toString");if(typeof e=="function"){const r=e(t);return typeof r=="string"?r:_c(r)}return _c(n)}default:return _c(n)}}function gn(n,t){for(;n!==null;){const r=JN(n,t);if(r){if(r.get)return Qe(r.get);if(typeof r.value=="function")return Qe(r.value)}n=GN(n)}function e(){return null}return e}function i9(n){try{return pt(n,""),!0}catch{return!1}}const Hb=ot(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),zm=ot(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Um=ot(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),s9=ot(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Hm=ot(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),o9=ot(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Zb=ot(["#text"]),qb=ot(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Zm=ot(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Vb=ot(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Bh=ot(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),a9=ct(/{{[\w\W]*|^[\w\W]*}}/g),l9=ct(/<%[\w\W]*|^[\w\W]*%>/g),c9=ct(/\${[\w\W]*/g),u9=ct(/^data-[\-\w.\u00B7-\uFFFF]+$/),h9=ct(/^aria-[\-\w]+$/),Fb=ct(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),d9=ct(/^(?:\w+script|data):/i),f9=ct(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),p9=ct(/^html$/i),m9=ct(/^[a-z][.\w]*(-[.\w]+)+$/i),Bb=ct(/<[/\w!]/g),jb=ct(/<[/\w]/g),g9=ct(/<\/no(script|embed|frames)/i),v9=ct(/\/>/i),Kt={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},c4=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],y9=ot(ve({},c4)),w9=(function(){const n={};return Ys(c4,t=>{n[t]=ct(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),ot(n)})(),b9=function(){return typeof window>"u"?null:window},S9=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";e&&e.hasAttribute(i)&&(r=e.getAttribute(i));const s="dompurify"+(r?"#"+r:"");try{return t.createPolicy(s,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Wb=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Mi=function(t,e,r,i){return Ft(t,e)&&Za(t[e])?ve(i.base?Xt(i.base):{},t[e],i.transform):r},qm=function(t,e,r){const i=Ft(t,e)?t[e]:void 0;return i&&typeof i=="object"?Xt(i):r()};function u4(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:b9();const t=N=>u4(N);if(t.version="3.4.16",t.removed=[],!n||!n.document||n.document.nodeType!==Kt.document||!n.Element)return t.isSupported=!1,t;let e=n.document;const r=e,i=r.currentScript;n.DocumentFragment;const s=n.HTMLTemplateElement,a=n.Node,l=n.Element,c=n.NodeFilter;n.NamedNodeMap===void 0&&(n.NamedNodeMap||n.MozNamedAttrMap),n.HTMLFormElement;const u=n.DOMParser,f=n.trustedTypes,p=l.prototype,y=gn(p,"cloneNode"),v=gn(p,"remove"),S=gn(p,"removeAttributeNode"),_=gn(p,"nextSibling"),$=gn(p,"childNodes"),H=gn(p,"parentNode"),L=gn(p,"shadowRoot"),z=gn(p,"attributes"),P=a&&a.prototype?gn(a.prototype,"nodeType"):null,B=a&&a.prototype?gn(a.prototype,"nodeName"):null,q=a&&a.prototype?gn(a.prototype,"ownerDocument"):null,V=function(w){return P?P(w):w.nodeType},Q=function(w){return B?B(w):w.nodeName};if(typeof s=="function"){const N=e.createElement("template");N.content&&N.content.ownerDocument&&(e=N.content.ownerDocument)}let F,re="",Ne,xe=!1,et=0;const le=function(){if(et>0)throw Oi('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},We=function(w){le(),et++;try{return F.createHTML(w)}finally{et--}},Dt=function(w){le(),et++;try{return F.createScriptURL(w)}finally{et--}},Pn=function(){return xe||(Ne=S9(f,i),xe=!0),Ne},ht=e,wt=ht.implementation,Ms=ht.createNodeIterator,ca=ht.createDocumentFragment,Ns=ht.getElementsByTagName,Ci=r.importNode;let Ee=Wb();t.isSupported=typeof a4=="function"&&typeof H=="function"&&wt&&wt.createHTMLDocument!==void 0;const sc=a9,Dn=l9,zs=c9,oc=u9,bt=h9,Ce=d9,Be=f9,Pe=m9;let Ge=Fb,ce=null;const fn=ve({},[...Hb,...zm,...Um,...Hm,...Zb]);let oe=null;const at=ve({},[...qb,...Zm,...Vb,...Bh]);let ze=Object.seal(Pa(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),pn=null,Ln=null;const Je=Object.seal(Pa(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let xr=!0,Qn=!0,Pr=!1,Th=!0,er=!1,tr=!0,Dr=!1,Lr=!1,Ii=null,Us=null,ac=!1,$i=!1,xi=!1,Or=!1,k=!0,R=!1;const pe="user-content-";let Se=!0,ke=!1,te={},St=null;const nr=ve({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let dt=null;const On=ve({},["audio","video","img","source","image","track"]);let ua=null;const Mr=ve({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ft="http://www.w3.org/1998/Math/MathML",Hs="http://www.w3.org/2000/svg",Jt="http://www.w3.org/1999/xhtml";let Nr=Jt,zr=!1,Zs=null;const ha=ve({},[ft,Hs,Jt],Nm),da=ot(["mi","mo","mn","ms","mtext"]);let qs=ve({},da);const lc=ot(["annotation-xml"]);let fa=ve({},lc);const cc=ve({},["title","style","font","a","script"]);let Pi=null;const uc=["application/xhtml+xml","text/html"],Rh="text/html";let Ue=null,rr=null;const Di=e.createElement("form"),Vs=function(w){return w instanceof RegExp||w instanceof Function},hc=function(){let w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(rr&&rr===w)return;(!w||typeof w!="object")&&(w={}),w=Xt(w),Pi=uc.indexOf(w.PARSER_MEDIA_TYPE)===-1?Rh:w.PARSER_MEDIA_TYPE,Ue=Pi==="application/xhtml+xml"?Nm:qc,ce=Mi(w,"ALLOWED_TAGS",fn,{transform:Ue}),oe=Mi(w,"ALLOWED_ATTR",at,{transform:Ue}),Zs=Mi(w,"ALLOWED_NAMESPACES",ha,{transform:Nm}),ua=Mi(w,"ADD_URI_SAFE_ATTR",Mr,{transform:Ue,base:Mr}),dt=Mi(w,"ADD_DATA_URI_TAGS",On,{transform:Ue,base:On}),St=Mi(w,"FORBID_CONTENTS",nr,{transform:Ue}),pn=Mi(w,"FORBID_TAGS",Xt({}),{transform:Ue}),Ln=Mi(w,"FORBID_ATTR",Xt({}),{transform:Ue}),te=Ft(w,"USE_PROFILES")?w.USE_PROFILES&&typeof w.USE_PROFILES=="object"?Xt(w.USE_PROFILES):w.USE_PROFILES:!1,xr=w.ALLOW_ARIA_ATTR!==!1,Qn=w.ALLOW_DATA_ATTR!==!1,Pr=w.ALLOW_UNKNOWN_PROTOCOLS||!1,Th=w.ALLOW_SELF_CLOSE_IN_ATTR!==!1,er=w.SAFE_FOR_TEMPLATES||!1,tr=w.SAFE_FOR_XML!==!1,Dr=w.WHOLE_DOCUMENT||!1,$i=w.RETURN_DOM||!1,xi=w.RETURN_DOM_FRAGMENT||!1,Or=w.RETURN_TRUSTED_TYPE||!1,ac=w.FORCE_BODY||!1,k=w.SANITIZE_DOM!==!1,R=w.SANITIZE_NAMED_PROPS||!1,Se=w.KEEP_CONTENT!==!1,ke=w.IN_PLACE||!1,Ge=i9(w.ALLOWED_URI_REGEXP)?w.ALLOWED_URI_REGEXP:Fb,Nr=typeof w.NAMESPACE=="string"?w.NAMESPACE:Jt,qs=qm(w,"MATHML_TEXT_INTEGRATION_POINTS",()=>ve({},da)),fa=qm(w,"HTML_INTEGRATION_POINTS",()=>ve({},lc));const A=qm(w,"CUSTOM_ELEMENT_HANDLING",()=>Pa(null));if(ze=Pa(null),Ft(A,"tagNameCheck")&&Vs(A.tagNameCheck)&&(ze.tagNameCheck=A.tagNameCheck),Ft(A,"attributeNameCheck")&&Vs(A.attributeNameCheck)&&(ze.attributeNameCheck=A.attributeNameCheck),Ft(A,"allowCustomizedBuiltInElements")&&typeof A.allowCustomizedBuiltInElements=="boolean"&&(ze.allowCustomizedBuiltInElements=A.allowCustomizedBuiltInElements),ct(ze),er&&(Qn=!1),xi&&($i=!0),te&&(ce=ve({},Zb),oe=Pa(null),te.html===!0&&(ve(ce,Hb),ve(oe,qb)),te.svg===!0&&(ve(ce,zm),ve(oe,Zm),ve(oe,Bh)),te.svgFilters===!0&&(ve(ce,Um),ve(oe,Zm),ve(oe,Bh)),te.mathMl===!0&&(ve(ce,Hm),ve(oe,Vb),ve(oe,Bh))),Je.tagCheck=null,Je.attributeCheck=null,Ft(w,"ADD_TAGS")&&(typeof w.ADD_TAGS=="function"?Je.tagCheck=w.ADD_TAGS:Za(w.ADD_TAGS)&&(ce===fn&&(ce=Xt(ce)),ve(ce,w.ADD_TAGS,Ue))),Ft(w,"ADD_ATTR")&&(typeof w.ADD_ATTR=="function"?Je.attributeCheck=w.ADD_ATTR:Za(w.ADD_ATTR)&&(oe===at&&(oe=Xt(oe)),ve(oe,w.ADD_ATTR,Ue))),Ft(w,"ADD_FORBID_CONTENTS")&&Za(w.ADD_FORBID_CONTENTS)&&(St===nr&&(St=Xt(St)),ve(St,w.ADD_FORBID_CONTENTS,Ue)),Se&&(ce["#text"]=!0),Dr&&ve(ce,["html","head","body"]),ce.table&&(ve(ce,["tbody"]),delete pn.tbody),w.TRUSTED_TYPES_POLICY){if(typeof w.TRUSTED_TYPES_POLICY.createHTML!="function")throw Oi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof w.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Oi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const M=F;F=w.TRUSTED_TYPES_POLICY;try{re=We("")}catch(U){throw F=M,U}}else w.TRUSTED_TYPES_POLICY===null?(F=void 0,re=""):(F===void 0&&(F=Pn()),F&&typeof re=="string"&&(re=We("")));ot&&ot(w),rr=w},dc=ve({},[...zm,...Um,...s9]),$v=ve({},[...Hm,...o9]),cA=function(w,A,M){return A.namespaceURI===Jt?w==="svg":A.namespaceURI===ft?w==="svg"&&(M==="annotation-xml"||qs[M]):!!dc[w]},uA=function(w,A,M){return A.namespaceURI===Jt?w==="math":A.namespaceURI===Hs?w==="math"&&fa[M]:!!$v[w]},hA=function(w,A,M){return A.namespaceURI===Hs&&!fa[M]||A.namespaceURI===ft&&!qs[M]?!1:!$v[w]&&(cc[w]||!dc[w])},dA=function(w){let A=H(w);(!A||!A.tagName)&&(A={namespaceURI:Nr,tagName:"template"});const M=qc(w.tagName),U=qc(A.tagName);return Zs[w.namespaceURI]?w.namespaceURI===Hs?cA(M,A,U):w.namespaceURI===ft?uA(M,A,U):w.namespaceURI===Jt?hA(M,A,U):!!(Pi==="application/xhtml+xml"&&Zs[w.namespaceURI]):!1},Li=function(w){bc(t.removed,{element:w});try{H(w).removeChild(w)}catch{if(v(w),!H(w))throw Oi("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},xv=function(w,A,M){try{S(w,A)}catch{try{w.removeAttribute(M)}catch{}}},Ch=function(w){Ih(w);const A=$(w);if(A){const U=[];Ys(A,X=>{bc(U,X)}),Ys(U,X=>{try{v(X)}catch{}})}const M=z(w);if(M)for(let U=M.length-1;U>=0;--U){const X=M[U],ue=X&&X.name;typeof ue=="string"&&xv(w,X,ue)}},Fs=function(w,A,M){if(!M)try{M=A.getAttributeNode(w)}catch{M=null}bc(t.removed,{attribute:M||null,from:A});try{M?S(A,M):A.removeAttribute(w)}catch{try{A.removeAttribute(w)}catch{}}if(w==="is")if($i||xi)try{Li(A)}catch{}else try{A.setAttribute(w,"")}catch{}},fA=function(w){const A=z(w);if(A)for(let M=A.length-1;M>=0;--M){const U=A[M],X=U&&U.name;typeof X!="string"||oe[Ue(X)]||xv(w,U,X)}},Ih=function(w){const A=[w];for(;A.length>0;){const M=A.pop();V(M)===Kt.element&&fA(M);const U=$(M);if(U)for(let X=U.length-1;X>=0;--X)A.push(U[X])}},Pv=function(w,A){return tr?w==="patchsrc"?!0:w==="for"&&A!=="label"&&A!=="output":!1},pA=function(w){if(!tr)return;const A=[w];for(;A.length>0;){const M=A.pop(),U=V(M);if(U===Kt.processingInstruction||U===Kt.comment&&pt(jb,M.data)){try{v(M)}catch{}continue}if(U===Kt.element){const ue=M,me=Ue(Q(M));try{ue.hasAttribute&&ue.hasAttribute("patchsrc")&&ue.removeAttribute("patchsrc"),ue.hasAttribute&&ue.hasAttribute("for")&&Pv("for",me)&&ue.removeAttribute("for")}catch{}}const X=$(M);if(X)for(let ue=X.length-1;ue>=0;--ue)A.push(X[ue])}},Dv=function(w){let A=null,M=null;if(ac)w="<remove></remove>"+w;else{const ue=Mb(w,/^[\r\n\t ]+/);M=ue&&ue[0]}Pi==="application/xhtml+xml"&&Nr===Jt&&(w='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+w+"</body></html>");const U=F?We(w):w;if(Nr===Jt)try{A=new u().parseFromString(U,Pi)}catch{}if(!A||!A.documentElement){A=wt.createDocument(Nr,"template",null);try{A.documentElement.innerHTML=zr?re:U}catch{}}const X=A.body||A.documentElement;return w&&M&&X.insertBefore(e.createTextNode(M),X.childNodes[0]||null),Nr===Jt?Ns.call(A,Dr?"html":"body")[0]:Dr?A.documentElement:X},Lv=function(w){const A=q?q(w):w.ownerDocument;return Ms.call(A||w,w,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},$h=function(w){return w=Sc(w,sc," "),w=Sc(w,Dn," "),w=Sc(w,zs," "),w},sp=function(w){var A;w.normalize();const M=q?q(w):w.ownerDocument,U=Ms.call(M||w,w,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let X=U.nextNode();for(;X;)X.data=$h(X.data),X=U.nextNode();const ue=(A=w.querySelectorAll)===null||A===void 0?void 0:A.call(w,"template");ue&&Ys(ue,me=>{pa(me.content)&&sp(me.content)})},xh=function(w){const A=B?B(w):null;return typeof A!="string"||Ue(A)!=="form"?!1:typeof w.nodeName!="string"||typeof w.textContent!="string"||typeof w.removeChild!="function"||w.attributes!==z(w)||typeof w.removeAttribute!="function"||typeof w.removeAttributeNode!="function"||typeof w.getAttributeNode!="function"||typeof w.setAttribute!="function"||typeof w.namespaceURI!="string"||typeof w.insertBefore!="function"||typeof w.hasChildNodes!="function"||w.nodeType!==P(w)||w.childNodes!==$(w)},pa=function(w){if(!P||typeof w!="object"||w===null)return!1;try{return P(w)===Kt.documentFragment}catch{return!1}},fc=function(w){if(!P||typeof w!="object"||w===null)return!1;try{return typeof P(w)=="number"}catch{return!1}};function ir(N,w,A){N.length!==0&&Ys(N,M=>{M.call(t,w,A,rr)})}const mA=function(w,A){return!!(tr&&w.hasChildNodes()&&!fc(w.firstElementChild)&&pt(Bb,w.textContent)&&pt(Bb,w.innerHTML)||tr&&w.namespaceURI===Jt&&y9[A]&&(fc(w.firstElementChild)||typeof w.textContent=="string"&&pt(w9[A],w.textContent))||w.nodeType===Kt.processingInstruction||tr&&w.nodeType===Kt.comment&&pt(jb,w.data))},Ph=function(w,A){if(w instanceof RegExp)return pt(w,A);if(w instanceof Function){for(var M=arguments.length,U=new Array(M>2?M-2:0),X=2;X<M;X++)U[X-2]=arguments[X];return!!w(A,...U)}return!1},gA=function(w,A,M){if(!pn[A]&&zv(A)&&Ph(ze.tagNameCheck,A))return!1;if(Se&&!St[A]){const U=H(w),X=$(w);if(X&&U){const ue=X.length;for(let me=ue-1;me>=0;--me){const Fe=w===M?y(X[me],!0):X[me];U.insertBefore(Fe,_(w))}}}return Li(w),!0},Ov=function(w,A,M,U){return w.length===0?A:A===M||A===U?Xt(A):A},ma=function(w,A){return w===A||H(w)!==null?!1:(ke&&Ih(w),!0)},Mv=function(w,A){if(ir(Ee.beforeSanitizeElements,w,null),ma(w,A))return!0;if(xh(w))return Li(w),!0;const M=Ue(Q(w));if(ce=Ov(Ee.uponSanitizeElement,ce,fn,Ii),ir(Ee.uponSanitizeElement,w,{tagName:M,allowedTags:ce}),ma(w,A))return!0;if(mA(w,M))return Li(w),!0;if(pn[M]||!(Je.tagCheck instanceof Function&&Je.tagCheck(M))&&!ce[M]){const U=gA(w,M,A);return U===!1&&(ir(Ee.afterSanitizeElements,w,null),ma(w,A))?!0:U}if(V(w)===Kt.element&&!dA(w)||(M==="noscript"||M==="noembed"||M==="noframes")&&pt(g9,w.innerHTML))return Li(w),!0;if(er&&w.nodeType===Kt.text){const U=$h(w.textContent);w.textContent!==U&&(bc(t.removed,{element:w.cloneNode()}),w.textContent=U)}return ir(Ee.afterSanitizeElements,w,null),ma(w,A)},Nv=function(w,A,M){if(Ln[A]||Pv(A,w)||k&&(A==="id"||A==="name")&&(M in e||M in Di))return!1;const U=oe[A]||Je.attributeCheck instanceof Function&&Je.attributeCheck(A,w);return Qn&&pt(oc,A)||xr&&pt(bt,A)?!0:U?ua[A]||pt(Ge,Sc(M,Be,""))||(A==="src"||A==="xlink:href"||A==="href")&&w!=="script"&&Nb(M,"data:")===0&&dt[w]||Pr&&!pt(Ce,Sc(M,Be,""))?!0:!M:zv(w)&&Ph(ze.tagNameCheck,w)&&Ph(ze.attributeNameCheck,A,w)||A==="is"&&ze.allowCustomizedBuiltInElements&&Ph(ze.tagNameCheck,M)},vA=ve({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),zv=function(w){return!vA[qc(w)]&&pt(Pe,w)},yA=function(w,A,M,U){if(F&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!M)switch(f.getAttributeType(w,A)){case"TrustedHTML":return We(U);case"TrustedScriptURL":return Dt(U)}return U},wA=function(w,A,M,U){try{return M?w.setAttributeNS(M,A,U):w.setAttribute(A,U),xh(w)?(Li(w),!1):!0}catch{return Fs(A,w),!1}},Uv=function(w,A){if(ir(Ee.beforeSanitizeAttributes,w,null),ma(w,A))return;const M=w.attributes;if(!M||xh(w))return;oe=Ov(Ee.uponSanitizeAttribute,oe,at,Us);const U={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:oe,forceKeepAttr:void 0};let X=M.length;const ue=Ue(w.nodeName);for(;X--;){const me=M[X],Fe=me.name,mn=me.namespaceURI,Yt=me.value,ga=Ue(Fe),ap=Yt;let _t=Fe==="value"?ap:XN(ap),Hv=!1;if(U.attrName=ga,U.attrValue=_t,U.keepAttr=!0,U.forceKeepAttr=void 0,ir(Ee.uponSanitizeAttribute,w,U),_t=U.attrValue,R&&(ga==="id"||ga==="name")&&Nb(_t,pe)!==0&&(Fs(Fe,w,me),_t=pe+_t,Hv=!0),tr&&pt(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,_t)){Fs(Fe,w,me);continue}if(ga==="attributename"&&Mb(_t,"href")){Fs(Fe,w,me);continue}if(!U.forceKeepAttr){if(!U.keepAttr){Fs(Fe,w,me);continue}if(!Th&&pt(v9,_t)){Fs(Fe,w,me);continue}if(er&&(_t=$h(_t)),!Nv(ue,ga,_t)){Fs(Fe,w,me);continue}_t=yA(ue,ga,mn,_t),_t!==ap&&wA(w,Fe,mn,_t)&&Hv&&Ob(t.removed)}}ir(Ee.afterSanitizeAttributes,w,null),ma(w,A)},Dh=function(w){let A=null;const M=Lv(w);for(ir(Ee.beforeSanitizeShadowDOM,w,null);A=M.nextNode();)if(ir(Ee.uponSanitizeShadowNode,A,null),Mv(A,w),Uv(A,w),pa(A.content)&&Dh(A.content),V(A)===Kt.element){const U=L(A);pa(U)&&(op(U),Dh(U))}ir(Ee.afterSanitizeShadowDOM,w,null)},op=function(w){const A=[{node:w,shadow:null}];for(;A.length>0;){const M=A.pop();if(M.shadow){Dh(M.shadow);continue}const U=M.node,X=V(U)===Kt.element,ue=$(U);if(ue)for(let me=ue.length-1;me>=0;--me)A.push({node:ue[me],shadow:null});if(X){const me=B?B(U):null;if(typeof me=="string"&&Ue(me)==="template"){const Fe=U.content;pa(Fe)&&A.push({node:Fe,shadow:null})}}if(X){const me=L(U);pa(me)&&A.push({node:null,shadow:me},{node:me,shadow:null})}}};return t.sanitize=function(N){let w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},A=null,M=null,U=null,X=null;if(zr=!N,zr&&(N="<!-->"),typeof N!="string"&&!fc(N)&&(N=r9(N),typeof N!="string"))throw Oi("dirty is not a string, aborting");if(!t.isSupported)return N;Lr?(ce=Ii,oe=Us):hc(w),(Ee.uponSanitizeElement.length>0||Ee.uponSanitizeAttribute.length>0)&&(ce=Xt(ce)),Ee.uponSanitizeAttribute.length>0&&(oe=Xt(oe)),t.removed=[];const ue=ke&&typeof N!="string"&&fc(N);if(ue){pA(N);const mn=Q(N);if(typeof mn=="string"){const Yt=Ue(mn);if(!ce[Yt]||pn[Yt])throw Ch(N),Oi("root node is forbidden and cannot be sanitized in-place")}if(xh(N))throw Ch(N),Oi("root node is clobbered and cannot be sanitized in-place");try{op(N)}catch(Yt){throw Ch(N),Yt}}else if(fc(N))A=Dv("<!---->"),M=A.ownerDocument.importNode(N,!0),M.nodeType===Kt.element&&M.nodeName==="BODY"||M.nodeName==="HTML"?A=M:A.appendChild(M),op(A);else{if(!$i&&!er&&!Dr&&N.indexOf("<")===-1)return F&&Or?We(N):N;if(A=Dv(N),!A)return $i?null:Or?re:""}A&&ac&&Li(A.firstChild);const me=ue?N:A;try{const mn=Lv(me);for(;U=mn.nextNode();)Mv(U,me),Uv(U,me),pa(U.content)&&Dh(U.content)}catch(mn){throw ue&&(Ch(N),Ys(t.removed,Yt=>{Yt.element&&Ih(Yt.element)})),mn}if(ue){let mn=!1;if(Ys(t.removed,Yt=>{Yt.element&&(Yt.element===N&&(mn=!0),Ih(Yt.element))}),mn)throw Oi("a node selected for removal could not be safely returned; refusing to sanitize in place");return er&&sp(N),N}if($i){if(er&&sp(A),xi)for(X=ca.call(A.ownerDocument);A.firstChild;)X.appendChild(A.firstChild);else X=A;return(oe.shadowroot||oe.shadowrootmode)&&(X=Ci.call(r,X,!0)),X}let Fe=Dr?A.outerHTML:A.innerHTML;return Dr&&ce["!doctype"]&&A.ownerDocument&&A.ownerDocument.doctype&&A.ownerDocument.doctype.name&&pt(p9,A.ownerDocument.doctype.name)&&(Fe="<!DOCTYPE "+A.ownerDocument.doctype.name+`>
439
- `+Fe),er&&(Fe=$h(Fe)),F&&Or?We(Fe):Fe},t.setConfig=function(){let N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};hc(N),Lr=!0,Ii=ce,Us=oe},t.clearConfig=function(){rr=null,Lr=!1,Ii=null,Us=null,F=Ne,re=""},t.isValidAttribute=function(N,w,A){rr||hc({});const M=Ue(N),U=Ue(w);return Nv(M,U,A)},t.addHook=function(N,w){typeof w=="function"&&Ft(Ee,N)&&bc(Ee[N],w)},t.removeHook=function(N,w){if(Ft(Ee,N)){if(w!==void 0){const A=YN(Ee[N],w);return A===-1?void 0:KN(Ee[N],A,1)[0]}return Ob(Ee[N])}},t.removeHooks=function(N){Ft(Ee,N)&&(Ee[N]=[])},t.removeAllHooks=function(){Ee=Wb()},t}var h4=u4();function gv(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var la=gv();function d4(n){la=n}var to={exec:()=>null};function ge(n,t=""){let e=typeof n=="string"?n:n.source,r={replace:(i,s)=>{let a=typeof s=="string"?s:s.source;return a=a.replace(xt.caret,"$1"),e=e.replace(i,a),r},getRegex:()=>new RegExp(e,t)};return r}var _9=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),xt={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}>`)},A9=/^(?:[ \t]*(?:\n|$))+/,E9=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,k9=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,kh=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,T9=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,vv=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,f4=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,p4=ge(f4).replace(/bull/g,vv).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),R9=ge(f4).replace(/bull/g,vv).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),yv=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,C9=/^[^\n]+/,wv=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,I9=ge(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",wv).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),$9=ge(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,vv).getRegex(),np="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",bv=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,x9=ge("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",bv).replace("tag",np).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),m4=ge(yv).replace("hr",kh).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",np).getRegex(),P9=ge(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",m4).getRegex(),Sv={blockquote:P9,code:E9,def:I9,fences:k9,heading:T9,hr:kh,html:x9,lheading:p4,list:$9,newline:A9,paragraph:m4,table:to,text:C9},Gb=ge("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",kh).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",np).getRegex(),D9={...Sv,lheading:R9,table:Gb,paragraph:ge(yv).replace("hr",kh).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Gb).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",np).getRegex()},L9={...Sv,html:ge(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",bv).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:to,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ge(yv).replace("hr",kh).replace("heading",` *#{1,6} *[^
440
- ]`).replace("lheading",p4).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},O9=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,M9=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,g4=/^( {2,}|\\)\n(?!\s*$)/,N9=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ic=/[\p{P}\p{S}]/u,rp=/[\s\p{P}\p{S}]/u,_v=/[^\s\p{P}\p{S}]/u,z9=ge(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,rp).getRegex(),v4=/(?!~)[\p{P}\p{S}]/u,U9=/(?!~)[\s\p{P}\p{S}]/u,H9=/(?:[^\s\p{P}\p{S}]|~)/u,Z9=ge(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",_9?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),y4=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,q9=ge(y4,"u").replace(/punct/g,ic).getRegex(),V9=ge(y4,"u").replace(/punct/g,v4).getRegex(),w4="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",F9=ge(w4,"gu").replace(/notPunctSpace/g,_v).replace(/punctSpace/g,rp).replace(/punct/g,ic).getRegex(),B9=ge(w4,"gu").replace(/notPunctSpace/g,H9).replace(/punctSpace/g,U9).replace(/punct/g,v4).getRegex(),j9=ge("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,_v).replace(/punctSpace/g,rp).replace(/punct/g,ic).getRegex(),W9=ge(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,ic).getRegex(),G9="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",J9=ge(G9,"gu").replace(/notPunctSpace/g,_v).replace(/punctSpace/g,rp).replace(/punct/g,ic).getRegex(),Y9=ge(/\\(punct)/,"gu").replace(/punct/g,ic).getRegex(),K9=ge(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),X9=ge(bv).replace("(?:-->|$)","-->").getRegex(),Q9=ge("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",X9).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),qd=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,ez=ge(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",qd).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),b4=ge(/^!?\[(label)\]\[(ref)\]/).replace("label",qd).replace("ref",wv).getRegex(),S4=ge(/^!?\[(ref)\](?:\[\])?/).replace("ref",wv).getRegex(),tz=ge("reflink|nolink(?!\\()","g").replace("reflink",b4).replace("nolink",S4).getRegex(),Jb=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Av={_backpedal:to,anyPunctuation:Y9,autolink:K9,blockSkip:Z9,br:g4,code:M9,del:to,delLDelim:to,delRDelim:to,emStrongLDelim:q9,emStrongRDelimAst:F9,emStrongRDelimUnd:j9,escape:O9,link:ez,nolink:S4,punctuation:z9,reflink:b4,reflinkSearch:tz,tag:Q9,text:N9,url:to},nz={...Av,link:ge(/^!?\[(label)\]\((.*?)\)/).replace("label",qd).getRegex(),reflink:ge(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",qd).getRegex()},a1={...Av,emStrongRDelimAst:B9,emStrongLDelim:V9,delLDelim:W9,delRDelim:J9,url:ge(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Jb).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:ge(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Jb).getRegex()},rz={...a1,br:ge(g4).replace("{2,}","*").getRegex(),text:ge(a1.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},jh={normal:Sv,gfm:D9,pedantic:L9},Ac={normal:Av,gfm:a1,breaks:rz,pedantic:nz},iz={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Yb=n=>iz[n];function or(n,t){if(t){if(xt.escapeTest.test(n))return n.replace(xt.escapeReplace,Yb)}else if(xt.escapeTestNoEncode.test(n))return n.replace(xt.escapeReplaceNoEncode,Yb);return n}function Kb(n){try{n=encodeURI(n).replace(xt.percentDecode,"%")}catch{return null}return n}function Xb(n,t){var s;let e=n.replace(xt.findPipe,(a,l,c)=>{let u=!1,f=l;for(;--f>=0&&c[f]==="\\";)u=!u;return u?"|":" |"}),r=e.split(xt.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!((s=r.at(-1))!=null&&s.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(xt.slashPipe,"|");return r}function Ec(n,t,e){let r=n.length;if(r===0)return"";let i=0;for(;i<r&&n.charAt(r-i-1)===t;)i++;return n.slice(0,r-i)}function sz(n,t){if(n.indexOf(t[1])===-1)return-1;let e=0;for(let r=0;r<n.length;r++)if(n[r]==="\\")r++;else if(n[r]===t[0])e++;else if(n[r]===t[1]&&(e--,e<0))return r;return e>0?-2:-1}function oz(n,t=0){let e=t,r="";for(let i of n)if(i===" "){let s=4-e%4;r+=" ".repeat(s),e+=s}else r+=i,e++;return r}function Qb(n,t,e,r,i){let s=t.href,a=t.title||null,l=n[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let c={type:n[0].charAt(0)==="!"?"image":"link",raw:e,href:s,title:a,text:l,tokens:r.inlineTokens(l)};return r.state.inLink=!1,c}function az(n,t,e){let r=n.match(e.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
437
+ */class i1 extends Ah{constructor(t){if(super(t),this.it=de,t.type!==Ir.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===de||t==null)return this._t=void 0,this.it=t;if(t===$t)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}}i1.directiveName="unsafeHTML",i1.resultType=1;const o4=rc(i1);/*! @license DOMPurify 3.4.16 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.16/LICENSE */function Db(n,t){(t==null||t>n.length)&&(t=n.length);for(var e=0,r=Array(t);e<t;e++)r[e]=n[e];return r}function q9(n){if(Array.isArray(n))return n}function V9(n,t){var e=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(e!=null){var r,i,s,a,l=[],c=!0,u=!1;try{if(s=(e=e.call(n)).next,t!==0)for(;!(c=(r=s.call(e)).done)&&(l.push(r.value),l.length!==t);c=!0);}catch(f){u=!0,i=f}finally{try{if(!c&&e.return!=null&&(a=e.return(),Object(a)!==a))return}finally{if(u)throw i}}return l}}function F9(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
438
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */function B9(n,t){return q9(n)||V9(n,t)||j9(n,t)||F9()}function j9(n,t){if(n){if(typeof n=="string")return Db(n,t);var e={}.toString.call(n).slice(8,-1);return e==="Object"&&n.constructor&&(e=n.constructor.name),e==="Map"||e==="Set"?Array.from(n):e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Db(n,t):void 0}}const a4=Object.entries,Lb=Object.setPrototypeOf,W9=Object.isFrozen,G9=Object.getPrototypeOf,J9=Object.getOwnPropertyDescriptor;let ot=Object.freeze,ct=Object.seal,Pa=Object.create,l4=typeof Reflect<"u"&&Reflect,s1=l4.apply,o1=l4.construct;ot||(ot=function(t){return t});ct||(ct=function(t){return t});s1||(s1=function(t,e){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];return t.apply(e,i)});o1||(o1=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return new t(...r)});const Ys=Qe(Array.prototype.forEach),Y9=Qe(Array.prototype.lastIndexOf),Ob=Qe(Array.prototype.pop),bc=Qe(Array.prototype.push),K9=Qe(Array.prototype.splice),Za=Array.isArray,qc=Qe(String.prototype.toLowerCase),Nm=Qe(String.prototype.toString),Mb=Qe(String.prototype.match),Sc=Qe(String.prototype.replace),Nb=Qe(String.prototype.indexOf),X9=Qe(String.prototype.trim),Q9=Qe(Number.prototype.toString),eN=Qe(Boolean.prototype.toString),zb=typeof BigInt>"u"?null:Qe(BigInt.prototype.toString),Ub=typeof Symbol>"u"?null:Qe(Symbol.prototype.toString),Ft=Qe(Object.prototype.hasOwnProperty),_c=Qe(Object.prototype.toString),pt=Qe(RegExp.prototype.test),Oi=tN(TypeError);function Qe(n){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return s1(n,t,r)}}function tN(n){return function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return o1(n,e)}}function ve(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:qc;if(Lb&&Lb(n,null),!Za(t))return n;let r=t.length;for(;r--;){let i=t[r];if(typeof i=="string"){const s=e(i);s!==i&&(W9(t)||(t[r]=s),i=s)}n[i]=!0}return n}function nN(n){for(let t=0;t<n.length;t++)Ft(n,t)||(n[t]=null);return n}function Xt(n){const t=Pa(null);for(const r of a4(n)){var e=B9(r,2);const i=e[0],s=e[1];Ft(n,i)&&(Za(s)?t[i]=nN(s):s&&typeof s=="object"&&s.constructor===Object?t[i]=Xt(s):t[i]=s)}return t}function rN(n){switch(typeof n){case"string":return n;case"number":return Q9(n);case"boolean":return eN(n);case"bigint":return zb?zb(n):"0";case"symbol":return Ub?Ub(n):"Symbol()";case"undefined":return _c(n);case"function":case"object":{if(n===null)return _c(n);const t=n,e=gn(t,"toString");if(typeof e=="function"){const r=e(t);return typeof r=="string"?r:_c(r)}return _c(n)}default:return _c(n)}}function gn(n,t){for(;n!==null;){const r=J9(n,t);if(r){if(r.get)return Qe(r.get);if(typeof r.value=="function")return Qe(r.value)}n=G9(n)}function e(){return null}return e}function iN(n){try{return pt(n,""),!0}catch{return!1}}const Hb=ot(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),zm=ot(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Um=ot(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),sN=ot(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Hm=ot(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),oN=ot(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Zb=ot(["#text"]),qb=ot(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Zm=ot(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Vb=ot(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Bh=ot(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),aN=ct(/{{[\w\W]*|^[\w\W]*}}/g),lN=ct(/<%[\w\W]*|^[\w\W]*%>/g),cN=ct(/\${[\w\W]*/g),uN=ct(/^data-[\-\w.\u00B7-\uFFFF]+$/),hN=ct(/^aria-[\-\w]+$/),Fb=ct(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),dN=ct(/^(?:\w+script|data):/i),fN=ct(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),pN=ct(/^html$/i),mN=ct(/^[a-z][.\w]*(-[.\w]+)+$/i),Bb=ct(/<[/\w!]/g),jb=ct(/<[/\w]/g),gN=ct(/<\/no(script|embed|frames)/i),vN=ct(/\/>/i),Kt={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},c4=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],yN=ot(ve({},c4)),wN=(function(){const n={};return Ys(c4,t=>{n[t]=ct(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),ot(n)})(),bN=function(){return typeof window>"u"?null:window},SN=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";e&&e.hasAttribute(i)&&(r=e.getAttribute(i));const s="dompurify"+(r?"#"+r:"");try{return t.createPolicy(s,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Wb=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Mi=function(t,e,r,i){return Ft(t,e)&&Za(t[e])?ve(i.base?Xt(i.base):{},t[e],i.transform):r},qm=function(t,e,r){const i=Ft(t,e)?t[e]:void 0;return i&&typeof i=="object"?Xt(i):r()};function u4(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:bN();const t=N=>u4(N);if(t.version="3.4.16",t.removed=[],!n||!n.document||n.document.nodeType!==Kt.document||!n.Element)return t.isSupported=!1,t;let e=n.document;const r=e,i=r.currentScript;n.DocumentFragment;const s=n.HTMLTemplateElement,a=n.Node,l=n.Element,c=n.NodeFilter;n.NamedNodeMap===void 0&&(n.NamedNodeMap||n.MozNamedAttrMap),n.HTMLFormElement;const u=n.DOMParser,f=n.trustedTypes,p=l.prototype,y=gn(p,"cloneNode"),v=gn(p,"remove"),S=gn(p,"removeAttributeNode"),_=gn(p,"nextSibling"),$=gn(p,"childNodes"),H=gn(p,"parentNode"),L=gn(p,"shadowRoot"),z=gn(p,"attributes"),P=a&&a.prototype?gn(a.prototype,"nodeType"):null,B=a&&a.prototype?gn(a.prototype,"nodeName"):null,q=a&&a.prototype?gn(a.prototype,"ownerDocument"):null,V=function(w){return P?P(w):w.nodeType},Q=function(w){return B?B(w):w.nodeName};if(typeof s=="function"){const N=e.createElement("template");N.content&&N.content.ownerDocument&&(e=N.content.ownerDocument)}let F,re="",Ne,xe=!1,et=0;const le=function(){if(et>0)throw Oi('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},We=function(w){le(),et++;try{return F.createHTML(w)}finally{et--}},Dt=function(w){le(),et++;try{return F.createScriptURL(w)}finally{et--}},Pn=function(){return xe||(Ne=SN(f,i),xe=!0),Ne},ht=e,wt=ht.implementation,Ms=ht.createNodeIterator,ca=ht.createDocumentFragment,Ns=ht.getElementsByTagName,Ci=r.importNode;let Ee=Wb();t.isSupported=typeof a4=="function"&&typeof H=="function"&&wt&&wt.createHTMLDocument!==void 0;const sc=aN,Dn=lN,zs=cN,oc=uN,bt=hN,Ce=dN,Be=fN,Pe=mN;let Ge=Fb,ce=null;const fn=ve({},[...Hb,...zm,...Um,...Hm,...Zb]);let oe=null;const at=ve({},[...qb,...Zm,...Vb,...Bh]);let ze=Object.seal(Pa(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),pn=null,Ln=null;const Je=Object.seal(Pa(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let xr=!0,Qn=!0,Pr=!1,Th=!0,er=!1,tr=!0,Dr=!1,Lr=!1,Ii=null,Us=null,ac=!1,$i=!1,xi=!1,Or=!1,k=!0,R=!1;const pe="user-content-";let Se=!0,ke=!1,te={},St=null;const nr=ve({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let dt=null;const On=ve({},["audio","video","img","source","image","track"]);let ua=null;const Mr=ve({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ft="http://www.w3.org/1998/Math/MathML",Hs="http://www.w3.org/2000/svg",Jt="http://www.w3.org/1999/xhtml";let Nr=Jt,zr=!1,Zs=null;const ha=ve({},[ft,Hs,Jt],Nm),da=ot(["mi","mo","mn","ms","mtext"]);let qs=ve({},da);const lc=ot(["annotation-xml"]);let fa=ve({},lc);const cc=ve({},["title","style","font","a","script"]);let Pi=null;const uc=["application/xhtml+xml","text/html"],Rh="text/html";let Ue=null,rr=null;const Di=e.createElement("form"),Vs=function(w){return w instanceof RegExp||w instanceof Function},hc=function(){let w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(rr&&rr===w)return;(!w||typeof w!="object")&&(w={}),w=Xt(w),Pi=uc.indexOf(w.PARSER_MEDIA_TYPE)===-1?Rh:w.PARSER_MEDIA_TYPE,Ue=Pi==="application/xhtml+xml"?Nm:qc,ce=Mi(w,"ALLOWED_TAGS",fn,{transform:Ue}),oe=Mi(w,"ALLOWED_ATTR",at,{transform:Ue}),Zs=Mi(w,"ALLOWED_NAMESPACES",ha,{transform:Nm}),ua=Mi(w,"ADD_URI_SAFE_ATTR",Mr,{transform:Ue,base:Mr}),dt=Mi(w,"ADD_DATA_URI_TAGS",On,{transform:Ue,base:On}),St=Mi(w,"FORBID_CONTENTS",nr,{transform:Ue}),pn=Mi(w,"FORBID_TAGS",Xt({}),{transform:Ue}),Ln=Mi(w,"FORBID_ATTR",Xt({}),{transform:Ue}),te=Ft(w,"USE_PROFILES")?w.USE_PROFILES&&typeof w.USE_PROFILES=="object"?Xt(w.USE_PROFILES):w.USE_PROFILES:!1,xr=w.ALLOW_ARIA_ATTR!==!1,Qn=w.ALLOW_DATA_ATTR!==!1,Pr=w.ALLOW_UNKNOWN_PROTOCOLS||!1,Th=w.ALLOW_SELF_CLOSE_IN_ATTR!==!1,er=w.SAFE_FOR_TEMPLATES||!1,tr=w.SAFE_FOR_XML!==!1,Dr=w.WHOLE_DOCUMENT||!1,$i=w.RETURN_DOM||!1,xi=w.RETURN_DOM_FRAGMENT||!1,Or=w.RETURN_TRUSTED_TYPE||!1,ac=w.FORCE_BODY||!1,k=w.SANITIZE_DOM!==!1,R=w.SANITIZE_NAMED_PROPS||!1,Se=w.KEEP_CONTENT!==!1,ke=w.IN_PLACE||!1,Ge=iN(w.ALLOWED_URI_REGEXP)?w.ALLOWED_URI_REGEXP:Fb,Nr=typeof w.NAMESPACE=="string"?w.NAMESPACE:Jt,qs=qm(w,"MATHML_TEXT_INTEGRATION_POINTS",()=>ve({},da)),fa=qm(w,"HTML_INTEGRATION_POINTS",()=>ve({},lc));const A=qm(w,"CUSTOM_ELEMENT_HANDLING",()=>Pa(null));if(ze=Pa(null),Ft(A,"tagNameCheck")&&Vs(A.tagNameCheck)&&(ze.tagNameCheck=A.tagNameCheck),Ft(A,"attributeNameCheck")&&Vs(A.attributeNameCheck)&&(ze.attributeNameCheck=A.attributeNameCheck),Ft(A,"allowCustomizedBuiltInElements")&&typeof A.allowCustomizedBuiltInElements=="boolean"&&(ze.allowCustomizedBuiltInElements=A.allowCustomizedBuiltInElements),ct(ze),er&&(Qn=!1),xi&&($i=!0),te&&(ce=ve({},Zb),oe=Pa(null),te.html===!0&&(ve(ce,Hb),ve(oe,qb)),te.svg===!0&&(ve(ce,zm),ve(oe,Zm),ve(oe,Bh)),te.svgFilters===!0&&(ve(ce,Um),ve(oe,Zm),ve(oe,Bh)),te.mathMl===!0&&(ve(ce,Hm),ve(oe,Vb),ve(oe,Bh))),Je.tagCheck=null,Je.attributeCheck=null,Ft(w,"ADD_TAGS")&&(typeof w.ADD_TAGS=="function"?Je.tagCheck=w.ADD_TAGS:Za(w.ADD_TAGS)&&(ce===fn&&(ce=Xt(ce)),ve(ce,w.ADD_TAGS,Ue))),Ft(w,"ADD_ATTR")&&(typeof w.ADD_ATTR=="function"?Je.attributeCheck=w.ADD_ATTR:Za(w.ADD_ATTR)&&(oe===at&&(oe=Xt(oe)),ve(oe,w.ADD_ATTR,Ue))),Ft(w,"ADD_FORBID_CONTENTS")&&Za(w.ADD_FORBID_CONTENTS)&&(St===nr&&(St=Xt(St)),ve(St,w.ADD_FORBID_CONTENTS,Ue)),Se&&(ce["#text"]=!0),Dr&&ve(ce,["html","head","body"]),ce.table&&(ve(ce,["tbody"]),delete pn.tbody),w.TRUSTED_TYPES_POLICY){if(typeof w.TRUSTED_TYPES_POLICY.createHTML!="function")throw Oi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof w.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Oi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const M=F;F=w.TRUSTED_TYPES_POLICY;try{re=We("")}catch(U){throw F=M,U}}else w.TRUSTED_TYPES_POLICY===null?(F=void 0,re=""):(F===void 0&&(F=Pn()),F&&typeof re=="string"&&(re=We("")));ot&&ot(w),rr=w},dc=ve({},[...zm,...Um,...sN]),$v=ve({},[...Hm,...oN]),cA=function(w,A,M){return A.namespaceURI===Jt?w==="svg":A.namespaceURI===ft?w==="svg"&&(M==="annotation-xml"||qs[M]):!!dc[w]},uA=function(w,A,M){return A.namespaceURI===Jt?w==="math":A.namespaceURI===Hs?w==="math"&&fa[M]:!!$v[w]},hA=function(w,A,M){return A.namespaceURI===Hs&&!fa[M]||A.namespaceURI===ft&&!qs[M]?!1:!$v[w]&&(cc[w]||!dc[w])},dA=function(w){let A=H(w);(!A||!A.tagName)&&(A={namespaceURI:Nr,tagName:"template"});const M=qc(w.tagName),U=qc(A.tagName);return Zs[w.namespaceURI]?w.namespaceURI===Hs?cA(M,A,U):w.namespaceURI===ft?uA(M,A,U):w.namespaceURI===Jt?hA(M,A,U):!!(Pi==="application/xhtml+xml"&&Zs[w.namespaceURI]):!1},Li=function(w){bc(t.removed,{element:w});try{H(w).removeChild(w)}catch{if(v(w),!H(w))throw Oi("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},xv=function(w,A,M){try{S(w,A)}catch{try{w.removeAttribute(M)}catch{}}},Ch=function(w){Ih(w);const A=$(w);if(A){const U=[];Ys(A,X=>{bc(U,X)}),Ys(U,X=>{try{v(X)}catch{}})}const M=z(w);if(M)for(let U=M.length-1;U>=0;--U){const X=M[U],ue=X&&X.name;typeof ue=="string"&&xv(w,X,ue)}},Fs=function(w,A,M){if(!M)try{M=A.getAttributeNode(w)}catch{M=null}bc(t.removed,{attribute:M||null,from:A});try{M?S(A,M):A.removeAttribute(w)}catch{try{A.removeAttribute(w)}catch{}}if(w==="is")if($i||xi)try{Li(A)}catch{}else try{A.setAttribute(w,"")}catch{}},fA=function(w){const A=z(w);if(A)for(let M=A.length-1;M>=0;--M){const U=A[M],X=U&&U.name;typeof X!="string"||oe[Ue(X)]||xv(w,U,X)}},Ih=function(w){const A=[w];for(;A.length>0;){const M=A.pop();V(M)===Kt.element&&fA(M);const U=$(M);if(U)for(let X=U.length-1;X>=0;--X)A.push(U[X])}},Pv=function(w,A){return tr?w==="patchsrc"?!0:w==="for"&&A!=="label"&&A!=="output":!1},pA=function(w){if(!tr)return;const A=[w];for(;A.length>0;){const M=A.pop(),U=V(M);if(U===Kt.processingInstruction||U===Kt.comment&&pt(jb,M.data)){try{v(M)}catch{}continue}if(U===Kt.element){const ue=M,me=Ue(Q(M));try{ue.hasAttribute&&ue.hasAttribute("patchsrc")&&ue.removeAttribute("patchsrc"),ue.hasAttribute&&ue.hasAttribute("for")&&Pv("for",me)&&ue.removeAttribute("for")}catch{}}const X=$(M);if(X)for(let ue=X.length-1;ue>=0;--ue)A.push(X[ue])}},Dv=function(w){let A=null,M=null;if(ac)w="<remove></remove>"+w;else{const ue=Mb(w,/^[\r\n\t ]+/);M=ue&&ue[0]}Pi==="application/xhtml+xml"&&Nr===Jt&&(w='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+w+"</body></html>");const U=F?We(w):w;if(Nr===Jt)try{A=new u().parseFromString(U,Pi)}catch{}if(!A||!A.documentElement){A=wt.createDocument(Nr,"template",null);try{A.documentElement.innerHTML=zr?re:U}catch{}}const X=A.body||A.documentElement;return w&&M&&X.insertBefore(e.createTextNode(M),X.childNodes[0]||null),Nr===Jt?Ns.call(A,Dr?"html":"body")[0]:Dr?A.documentElement:X},Lv=function(w){const A=q?q(w):w.ownerDocument;return Ms.call(A||w,w,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},$h=function(w){return w=Sc(w,sc," "),w=Sc(w,Dn," "),w=Sc(w,zs," "),w},sp=function(w){var A;w.normalize();const M=q?q(w):w.ownerDocument,U=Ms.call(M||w,w,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let X=U.nextNode();for(;X;)X.data=$h(X.data),X=U.nextNode();const ue=(A=w.querySelectorAll)===null||A===void 0?void 0:A.call(w,"template");ue&&Ys(ue,me=>{pa(me.content)&&sp(me.content)})},xh=function(w){const A=B?B(w):null;return typeof A!="string"||Ue(A)!=="form"?!1:typeof w.nodeName!="string"||typeof w.textContent!="string"||typeof w.removeChild!="function"||w.attributes!==z(w)||typeof w.removeAttribute!="function"||typeof w.removeAttributeNode!="function"||typeof w.getAttributeNode!="function"||typeof w.setAttribute!="function"||typeof w.namespaceURI!="string"||typeof w.insertBefore!="function"||typeof w.hasChildNodes!="function"||w.nodeType!==P(w)||w.childNodes!==$(w)},pa=function(w){if(!P||typeof w!="object"||w===null)return!1;try{return P(w)===Kt.documentFragment}catch{return!1}},fc=function(w){if(!P||typeof w!="object"||w===null)return!1;try{return typeof P(w)=="number"}catch{return!1}};function ir(N,w,A){N.length!==0&&Ys(N,M=>{M.call(t,w,A,rr)})}const mA=function(w,A){return!!(tr&&w.hasChildNodes()&&!fc(w.firstElementChild)&&pt(Bb,w.textContent)&&pt(Bb,w.innerHTML)||tr&&w.namespaceURI===Jt&&yN[A]&&(fc(w.firstElementChild)||typeof w.textContent=="string"&&pt(wN[A],w.textContent))||w.nodeType===Kt.processingInstruction||tr&&w.nodeType===Kt.comment&&pt(jb,w.data))},Ph=function(w,A){if(w instanceof RegExp)return pt(w,A);if(w instanceof Function){for(var M=arguments.length,U=new Array(M>2?M-2:0),X=2;X<M;X++)U[X-2]=arguments[X];return!!w(A,...U)}return!1},gA=function(w,A,M){if(!pn[A]&&zv(A)&&Ph(ze.tagNameCheck,A))return!1;if(Se&&!St[A]){const U=H(w),X=$(w);if(X&&U){const ue=X.length;for(let me=ue-1;me>=0;--me){const Fe=w===M?y(X[me],!0):X[me];U.insertBefore(Fe,_(w))}}}return Li(w),!0},Ov=function(w,A,M,U){return w.length===0?A:A===M||A===U?Xt(A):A},ma=function(w,A){return w===A||H(w)!==null?!1:(ke&&Ih(w),!0)},Mv=function(w,A){if(ir(Ee.beforeSanitizeElements,w,null),ma(w,A))return!0;if(xh(w))return Li(w),!0;const M=Ue(Q(w));if(ce=Ov(Ee.uponSanitizeElement,ce,fn,Ii),ir(Ee.uponSanitizeElement,w,{tagName:M,allowedTags:ce}),ma(w,A))return!0;if(mA(w,M))return Li(w),!0;if(pn[M]||!(Je.tagCheck instanceof Function&&Je.tagCheck(M))&&!ce[M]){const U=gA(w,M,A);return U===!1&&(ir(Ee.afterSanitizeElements,w,null),ma(w,A))?!0:U}if(V(w)===Kt.element&&!dA(w)||(M==="noscript"||M==="noembed"||M==="noframes")&&pt(gN,w.innerHTML))return Li(w),!0;if(er&&w.nodeType===Kt.text){const U=$h(w.textContent);w.textContent!==U&&(bc(t.removed,{element:w.cloneNode()}),w.textContent=U)}return ir(Ee.afterSanitizeElements,w,null),ma(w,A)},Nv=function(w,A,M){if(Ln[A]||Pv(A,w)||k&&(A==="id"||A==="name")&&(M in e||M in Di))return!1;const U=oe[A]||Je.attributeCheck instanceof Function&&Je.attributeCheck(A,w);return Qn&&pt(oc,A)||xr&&pt(bt,A)?!0:U?ua[A]||pt(Ge,Sc(M,Be,""))||(A==="src"||A==="xlink:href"||A==="href")&&w!=="script"&&Nb(M,"data:")===0&&dt[w]||Pr&&!pt(Ce,Sc(M,Be,""))?!0:!M:zv(w)&&Ph(ze.tagNameCheck,w)&&Ph(ze.attributeNameCheck,A,w)||A==="is"&&ze.allowCustomizedBuiltInElements&&Ph(ze.tagNameCheck,M)},vA=ve({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),zv=function(w){return!vA[qc(w)]&&pt(Pe,w)},yA=function(w,A,M,U){if(F&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!M)switch(f.getAttributeType(w,A)){case"TrustedHTML":return We(U);case"TrustedScriptURL":return Dt(U)}return U},wA=function(w,A,M,U){try{return M?w.setAttributeNS(M,A,U):w.setAttribute(A,U),xh(w)?(Li(w),!1):!0}catch{return Fs(A,w),!1}},Uv=function(w,A){if(ir(Ee.beforeSanitizeAttributes,w,null),ma(w,A))return;const M=w.attributes;if(!M||xh(w))return;oe=Ov(Ee.uponSanitizeAttribute,oe,at,Us);const U={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:oe,forceKeepAttr:void 0};let X=M.length;const ue=Ue(w.nodeName);for(;X--;){const me=M[X],Fe=me.name,mn=me.namespaceURI,Yt=me.value,ga=Ue(Fe),ap=Yt;let _t=Fe==="value"?ap:X9(ap),Hv=!1;if(U.attrName=ga,U.attrValue=_t,U.keepAttr=!0,U.forceKeepAttr=void 0,ir(Ee.uponSanitizeAttribute,w,U),_t=U.attrValue,R&&(ga==="id"||ga==="name")&&Nb(_t,pe)!==0&&(Fs(Fe,w,me),_t=pe+_t,Hv=!0),tr&&pt(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,_t)){Fs(Fe,w,me);continue}if(ga==="attributename"&&Mb(_t,"href")){Fs(Fe,w,me);continue}if(!U.forceKeepAttr){if(!U.keepAttr){Fs(Fe,w,me);continue}if(!Th&&pt(vN,_t)){Fs(Fe,w,me);continue}if(er&&(_t=$h(_t)),!Nv(ue,ga,_t)){Fs(Fe,w,me);continue}_t=yA(ue,ga,mn,_t),_t!==ap&&wA(w,Fe,mn,_t)&&Hv&&Ob(t.removed)}}ir(Ee.afterSanitizeAttributes,w,null),ma(w,A)},Dh=function(w){let A=null;const M=Lv(w);for(ir(Ee.beforeSanitizeShadowDOM,w,null);A=M.nextNode();)if(ir(Ee.uponSanitizeShadowNode,A,null),Mv(A,w),Uv(A,w),pa(A.content)&&Dh(A.content),V(A)===Kt.element){const U=L(A);pa(U)&&(op(U),Dh(U))}ir(Ee.afterSanitizeShadowDOM,w,null)},op=function(w){const A=[{node:w,shadow:null}];for(;A.length>0;){const M=A.pop();if(M.shadow){Dh(M.shadow);continue}const U=M.node,X=V(U)===Kt.element,ue=$(U);if(ue)for(let me=ue.length-1;me>=0;--me)A.push({node:ue[me],shadow:null});if(X){const me=B?B(U):null;if(typeof me=="string"&&Ue(me)==="template"){const Fe=U.content;pa(Fe)&&A.push({node:Fe,shadow:null})}}if(X){const me=L(U);pa(me)&&A.push({node:null,shadow:me},{node:me,shadow:null})}}};return t.sanitize=function(N){let w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},A=null,M=null,U=null,X=null;if(zr=!N,zr&&(N="<!-->"),typeof N!="string"&&!fc(N)&&(N=rN(N),typeof N!="string"))throw Oi("dirty is not a string, aborting");if(!t.isSupported)return N;Lr?(ce=Ii,oe=Us):hc(w),(Ee.uponSanitizeElement.length>0||Ee.uponSanitizeAttribute.length>0)&&(ce=Xt(ce)),Ee.uponSanitizeAttribute.length>0&&(oe=Xt(oe)),t.removed=[];const ue=ke&&typeof N!="string"&&fc(N);if(ue){pA(N);const mn=Q(N);if(typeof mn=="string"){const Yt=Ue(mn);if(!ce[Yt]||pn[Yt])throw Ch(N),Oi("root node is forbidden and cannot be sanitized in-place")}if(xh(N))throw Ch(N),Oi("root node is clobbered and cannot be sanitized in-place");try{op(N)}catch(Yt){throw Ch(N),Yt}}else if(fc(N))A=Dv("<!---->"),M=A.ownerDocument.importNode(N,!0),M.nodeType===Kt.element&&M.nodeName==="BODY"||M.nodeName==="HTML"?A=M:A.appendChild(M),op(A);else{if(!$i&&!er&&!Dr&&N.indexOf("<")===-1)return F&&Or?We(N):N;if(A=Dv(N),!A)return $i?null:Or?re:""}A&&ac&&Li(A.firstChild);const me=ue?N:A;try{const mn=Lv(me);for(;U=mn.nextNode();)Mv(U,me),Uv(U,me),pa(U.content)&&Dh(U.content)}catch(mn){throw ue&&(Ch(N),Ys(t.removed,Yt=>{Yt.element&&Ih(Yt.element)})),mn}if(ue){let mn=!1;if(Ys(t.removed,Yt=>{Yt.element&&(Yt.element===N&&(mn=!0),Ih(Yt.element))}),mn)throw Oi("a node selected for removal could not be safely returned; refusing to sanitize in place");return er&&sp(N),N}if($i){if(er&&sp(A),xi)for(X=ca.call(A.ownerDocument);A.firstChild;)X.appendChild(A.firstChild);else X=A;return(oe.shadowroot||oe.shadowrootmode)&&(X=Ci.call(r,X,!0)),X}let Fe=Dr?A.outerHTML:A.innerHTML;return Dr&&ce["!doctype"]&&A.ownerDocument&&A.ownerDocument.doctype&&A.ownerDocument.doctype.name&&pt(pN,A.ownerDocument.doctype.name)&&(Fe="<!DOCTYPE "+A.ownerDocument.doctype.name+`>
439
+ `+Fe),er&&(Fe=$h(Fe)),F&&Or?We(Fe):Fe},t.setConfig=function(){let N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};hc(N),Lr=!0,Ii=ce,Us=oe},t.clearConfig=function(){rr=null,Lr=!1,Ii=null,Us=null,F=Ne,re=""},t.isValidAttribute=function(N,w,A){rr||hc({});const M=Ue(N),U=Ue(w);return Nv(M,U,A)},t.addHook=function(N,w){typeof w=="function"&&Ft(Ee,N)&&bc(Ee[N],w)},t.removeHook=function(N,w){if(Ft(Ee,N)){if(w!==void 0){const A=Y9(Ee[N],w);return A===-1?void 0:K9(Ee[N],A,1)[0]}return Ob(Ee[N])}},t.removeHooks=function(N){Ft(Ee,N)&&(Ee[N]=[])},t.removeAllHooks=function(){Ee=Wb()},t}var h4=u4();function gv(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var la=gv();function d4(n){la=n}var to={exec:()=>null};function ge(n,t=""){let e=typeof n=="string"?n:n.source,r={replace:(i,s)=>{let a=typeof s=="string"?s:s.source;return a=a.replace(xt.caret,"$1"),e=e.replace(i,a),r},getRegex:()=>new RegExp(e,t)};return r}var _N=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),xt={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}>`)},AN=/^(?:[ \t]*(?:\n|$))+/,EN=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,kN=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,kh=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,TN=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,vv=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,f4=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,p4=ge(f4).replace(/bull/g,vv).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),RN=ge(f4).replace(/bull/g,vv).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),yv=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,CN=/^[^\n]+/,wv=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,IN=ge(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",wv).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),$N=ge(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,vv).getRegex(),np="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",bv=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,xN=ge("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",bv).replace("tag",np).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),m4=ge(yv).replace("hr",kh).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",np).getRegex(),PN=ge(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",m4).getRegex(),Sv={blockquote:PN,code:EN,def:IN,fences:kN,heading:TN,hr:kh,html:xN,lheading:p4,list:$N,newline:AN,paragraph:m4,table:to,text:CN},Gb=ge("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",kh).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",np).getRegex(),DN={...Sv,lheading:RN,table:Gb,paragraph:ge(yv).replace("hr",kh).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Gb).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",np).getRegex()},LN={...Sv,html:ge(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",bv).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:to,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ge(yv).replace("hr",kh).replace("heading",` *#{1,6} *[^
440
+ ]`).replace("lheading",p4).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ON=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,MN=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,g4=/^( {2,}|\\)\n(?!\s*$)/,NN=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ic=/[\p{P}\p{S}]/u,rp=/[\s\p{P}\p{S}]/u,_v=/[^\s\p{P}\p{S}]/u,zN=ge(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,rp).getRegex(),v4=/(?!~)[\p{P}\p{S}]/u,UN=/(?!~)[\s\p{P}\p{S}]/u,HN=/(?:[^\s\p{P}\p{S}]|~)/u,ZN=ge(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",_N?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),y4=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,qN=ge(y4,"u").replace(/punct/g,ic).getRegex(),VN=ge(y4,"u").replace(/punct/g,v4).getRegex(),w4="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",FN=ge(w4,"gu").replace(/notPunctSpace/g,_v).replace(/punctSpace/g,rp).replace(/punct/g,ic).getRegex(),BN=ge(w4,"gu").replace(/notPunctSpace/g,HN).replace(/punctSpace/g,UN).replace(/punct/g,v4).getRegex(),jN=ge("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,_v).replace(/punctSpace/g,rp).replace(/punct/g,ic).getRegex(),WN=ge(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,ic).getRegex(),GN="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",JN=ge(GN,"gu").replace(/notPunctSpace/g,_v).replace(/punctSpace/g,rp).replace(/punct/g,ic).getRegex(),YN=ge(/\\(punct)/,"gu").replace(/punct/g,ic).getRegex(),KN=ge(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),XN=ge(bv).replace("(?:-->|$)","-->").getRegex(),QN=ge("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",XN).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),qd=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,ez=ge(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",qd).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),b4=ge(/^!?\[(label)\]\[(ref)\]/).replace("label",qd).replace("ref",wv).getRegex(),S4=ge(/^!?\[(ref)\](?:\[\])?/).replace("ref",wv).getRegex(),tz=ge("reflink|nolink(?!\\()","g").replace("reflink",b4).replace("nolink",S4).getRegex(),Jb=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Av={_backpedal:to,anyPunctuation:YN,autolink:KN,blockSkip:ZN,br:g4,code:MN,del:to,delLDelim:to,delRDelim:to,emStrongLDelim:qN,emStrongRDelimAst:FN,emStrongRDelimUnd:jN,escape:ON,link:ez,nolink:S4,punctuation:zN,reflink:b4,reflinkSearch:tz,tag:QN,text:NN,url:to},nz={...Av,link:ge(/^!?\[(label)\]\((.*?)\)/).replace("label",qd).getRegex(),reflink:ge(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",qd).getRegex()},a1={...Av,emStrongRDelimAst:BN,emStrongLDelim:VN,delLDelim:WN,delRDelim:JN,url:ge(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Jb).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:ge(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Jb).getRegex()},rz={...a1,br:ge(g4).replace("{2,}","*").getRegex(),text:ge(a1.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},jh={normal:Sv,gfm:DN,pedantic:LN},Ac={normal:Av,gfm:a1,breaks:rz,pedantic:nz},iz={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Yb=n=>iz[n];function or(n,t){if(t){if(xt.escapeTest.test(n))return n.replace(xt.escapeReplace,Yb)}else if(xt.escapeTestNoEncode.test(n))return n.replace(xt.escapeReplaceNoEncode,Yb);return n}function Kb(n){try{n=encodeURI(n).replace(xt.percentDecode,"%")}catch{return null}return n}function Xb(n,t){var s;let e=n.replace(xt.findPipe,(a,l,c)=>{let u=!1,f=l;for(;--f>=0&&c[f]==="\\";)u=!u;return u?"|":" |"}),r=e.split(xt.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!((s=r.at(-1))!=null&&s.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(xt.slashPipe,"|");return r}function Ec(n,t,e){let r=n.length;if(r===0)return"";let i=0;for(;i<r&&n.charAt(r-i-1)===t;)i++;return n.slice(0,r-i)}function sz(n,t){if(n.indexOf(t[1])===-1)return-1;let e=0;for(let r=0;r<n.length;r++)if(n[r]==="\\")r++;else if(n[r]===t[0])e++;else if(n[r]===t[1]&&(e--,e<0))return r;return e>0?-2:-1}function oz(n,t=0){let e=t,r="";for(let i of n)if(i===" "){let s=4-e%4;r+=" ".repeat(s),e+=s}else r+=i,e++;return r}function Qb(n,t,e,r,i){let s=t.href,a=t.title||null,l=n[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let c={type:n[0].charAt(0)==="!"?"image":"link",raw:e,href:s,title:a,text:l,tokens:r.inlineTokens(l)};return r.state.inLink=!1,c}function az(n,t,e){let r=n.match(e.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
441
441
  `).map(s=>{let a=s.match(e.other.beginningSpace);if(a===null)return s;let[l]=a;return l.length>=i.length?s.slice(i.length):s}).join(`
442
442
  `)}var Vd=class{constructor(n){C(this,"options");C(this,"rules");C(this,"lexer");this.options=n||la}space(n){let t=this.rules.block.newline.exec(n);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(n){let t=this.rules.block.code.exec(n);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:Ec(e,`
443
443
  `)}}}fences(n){let t=this.rules.block.fences.exec(n);if(t){let e=t[0],r=az(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(n){let t=this.rules.block.heading.exec(n);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let r=Ec(e,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(e=r.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(n){let t=this.rules.block.hr.exec(n);if(t)return{type:"hr",raw:Ec(t[0],`
@@ -738,7 +738,7 @@ From then on, open Television from Applications, not with \`tv-desktop\`.`;funct
738
738
  </div>
739
739
  `})}
740
740
  </div>
741
- `}disconnected(){var e,r,i,s;d(this,Yo,!1),typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(o(this,ws)),d(this,ws,0),d(this,Tr,!1),d(this,fi,!1),d(this,pi,!1),h(this,j,Oa).call(this),d(this,gi,!1),d(this,Bn,!1),(e=o(this,_s))==null||e.disconnect(),d(this,_s,null),d(this,Ml,null),(r=o(this,As))==null||r.dispose(),d(this,As,null),(i=o(this,Ko))==null||i.disconnect(),d(this,Ko,null),document.removeEventListener("television-theme-styles-changed",o(this,Nl)),typeof document<"u"&&((s=document.fonts)==null||s.removeEventListener("loadingdone",o(this,hh))),window.removeEventListener("pointermove",o(this,ah)),window.removeEventListener("pointerup",o(this,lh)),window.removeEventListener("pointercancel",o(this,ch)),window.removeEventListener("keydown",o(this,uh)),h(this,j,La).call(this,!1,!1),d(this,mi,!1)}}qt=new WeakMap,Ll=new WeakMap,Ol=new WeakMap,Yo=new WeakMap,ws=new WeakMap,Tr=new WeakMap,fi=new WeakMap,pi=new WeakMap,bs=new WeakMap,Ss=new WeakMap,Bn=new WeakMap,_s=new WeakMap,Ml=new WeakMap,As=new WeakMap,Ko=new WeakMap,oh=new WeakMap,nt=new WeakMap,mi=new WeakMap,gi=new WeakMap,En=new WeakMap,_f=new WeakMap,j=new WeakSet,L4=function(e,r,i,s,a){o(this,En)||o(this,nt)!==null||i===null||s.artifactId===null||e.button!==0||!e.isPrimary||(d(this,mi,!1),d(this,nt,{pointerId:e.pointerId,originX:e.clientX,originY:e.clientY,tab:e.currentTarget,application:r,channelId:i.id,artifactId:s.artifactId,originalPages:i.pages,onReorderChange:a,displacementAnimations:new Set,provisionalPages:[...i.pages],slot:i.pages.indexOf(s.page),currentX:e.clientX,currentY:e.clientY,tabLeft:0,tabTop:0,tabWidth:0,tabHeight:0,edgeScrollFrame:0,edgeScrollTimestamp:null,edgeScrollRemainder:0,edgeScrollMoved:!1,dragging:!1}))},O4=function(e,r,i,s){var a;if(e.detail!==0&&o(this,mi)){d(this,mi,!1);return}d(this,mi,!1),!((a=o(this,nt))!=null&&a.dragging||i===null||s.artifactId===null)&&r.selectPage(i.id,s.artifactId)},ah=new WeakMap,lh=new WeakMap,ch=new WeakMap,Af=new WeakMap,uh=new WeakMap,La=function(e,r){var a;const i=o(this,nt);if(i===null)return;if(h(this,j,Ed).call(this,i),i.edgeScrollMoved&&d(this,gi,!0),i.dragging&&(d(this,Tr,o(this,fi)),o(this,fi)||d(this,pi,!1)),i.dragging&&e&&!Bz(i.originalPages,i.provisionalPages)){const l=i.provisionalPages.map(c=>({artifactIds:[...c.artifactIds],geometry:{...c.geometry},size:{...c.size}}));i.application.updateChannelPages(i.channelId,l).catch(()=>{})}if(!e)for(const l of i.displacementAnimations)l.cancel();d(this,nt,null),(a=i.onReorderChange)==null||a.call(i,null);const s=o(this,qt).value;i.dragging&&(s!=null&&s.hasPointerCapture(i.pointerId))&&s.releasePointerCapture(i.pointerId),r&&this.render()},E1=function(e){const r=o(this,qt).value,i=r?h(this,j,k1).call(this,r,e.currentX):0,s=r?Math.max(0,r.scrollWidth-r.clientWidth):0,a=i<0?((r==null?void 0:r.scrollLeft)??0)<=Tc:((r==null?void 0:r.scrollLeft)??0)>=s-Tc;if(o(this,En)||!e.dragging||i===0||s===0||a||typeof requestAnimationFrame!="function"){h(this,j,Ed).call(this,e);return}e.edgeScrollFrame===0&&(e.edgeScrollFrame=requestAnimationFrame(l=>{h(this,j,M4).call(this,e,l)}))},M4=function(e,r){if(e.edgeScrollFrame=0,o(this,En)||o(this,nt)!==e||!e.dragging){e.edgeScrollTimestamp=null;return}const i=o(this,qt).value;if(!i){e.edgeScrollTimestamp=null;return}const s=h(this,j,k1).call(this,i,e.currentX),a=e.edgeScrollTimestamp;if(e.edgeScrollTimestamp=r,s!==0&&a!==null){const l=Math.max(0,r-a)/1e3,c=Math.max(0,i.scrollWidth-i.clientWidth),u=i.scrollLeft,f=s*l+e.edgeScrollRemainder,p=Math.max(0,Math.min(c,u+f));i.scrollLeft=p;const y=i.scrollLeft-u;y!==0&&(e.edgeScrollMoved=!0),e.edgeScrollRemainder=p===0||p===c?0:f-y,y!==0&&(h(this,j,jc).call(this,i),h(this,j,T1).call(this,e))}h(this,j,E1).call(this,e)},Ed=function(e){e.edgeScrollFrame!==0&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(e.edgeScrollFrame),e.edgeScrollFrame=0,e.edgeScrollTimestamp=null,e.edgeScrollRemainder=0},k1=function(e,r){const i=e.getBoundingClientRect();return r>=i.left&&r<i.left+Cn?-Ud*(i.left+Cn-r)/Cn:r>i.right-Cn&&r<=i.right?Ud*(r-(i.right-Cn))/Cn:0},T1=function(e){var S;const r=o(this,qt).value,i=r==null?void 0:r.querySelector(".tab-placeholder");if(!r||!i)return;const s=i.nextElementSibling,a=e.tab.getBoundingClientRect(),l=a.left+a.width/2;let c=e.slot,u=i.previousElementSibling;for(;u!=null&&u.classList.contains("tab");){const _=u.getBoundingClientRect();if(l>=_.left+_.width/2)break;c-=1,u=u.previousElementSibling}let f=s==null?void 0:s.nextElementSibling;for(;f!=null&&f.classList.contains("tab");){const _=f.getBoundingClientRect();if(l<=_.left+_.width/2)break;c+=1,f=f.nextElementSibling}if(c===e.slot)return;const p=h(this,j,N4).call(this,r),y=[...e.provisionalPages],[v]=y.splice(e.slot,1);v&&(y.splice(c,0,v),e.provisionalPages=y,e.slot=c,this.render(),(S=e.onReorderChange)==null||S.call(e,h(this,j,R1).call(this,e)),queueMicrotask(()=>h(this,j,z4).call(this,e,p)))},R1=function(e){return{channelId:e.channelId,pages:e.provisionalPages,carriedArtifactId:e.artifactId}},N4=function(e){return new Map([...e.querySelectorAll(".tab:not([dragging])")].map(r=>[r.dataset.artifactId??"",r.getBoundingClientRect().left]))},z4=function(e,r){if(o(this,En))return;const i=o(this,qt).value;if(i)for(const s of i.querySelectorAll(".tab:not([dragging])")){const a=r.get(s.dataset.artifactId??"");if(a===void 0)continue;const l=a-s.getBoundingClientRect().left;if(Math.abs(l)<=Tc)continue;const c=s.animate({translate:[`${l}px 0`,"0px 0"]},{duration:za,easing:"ease"});e.displacementAnimations.add(c),c.finished.finally(()=>{e.displacementAnimations.delete(c)}).catch(()=>{})}},Nl=new WeakMap,hh=new WeakMap,U4=function(){o(this,oh)||typeof document>"u"||!document.fonts||(d(this,oh,!0),document.fonts.ready.then(()=>{this.isConnected&&(d(this,Bn,!0),h(this,j,Ks).call(this,!0))}))},Ks=function(e,r=!1,i=!1){o(this,Tr)||d(this,Tr,e),e&&r&&(d(this,fi,!0),d(this,pi,i&&!o(this,En))),!(o(this,Yo)||o(this,ws)!==0)&&(d(this,Yo,!0),queueMicrotask(()=>{if(d(this,Yo,!1),!!this.isConnected){if(typeof requestAnimationFrame!="function"){h(this,j,kd).call(this);return}d(this,ws,requestAnimationFrame(()=>{d(this,ws,0),h(this,j,kd).call(this)}))}}))},kd=function(){var l,c;const e=o(this,qt).value;if(!e)return;o(this,Bn)&&(d(this,Bn,!1),h(this,j,Z4).call(this,e)),h(this,j,q4).call(this,e),h(this,j,H4).call(this,e);const r=((l=o(this,nt))==null?void 0:l.dragging)===!0,i=o(this,fi),s=i&&o(this,pi),a=!r&&(i||o(this,Tr)&&!o(this,gi));r?d(this,Tr,i):(d(this,Tr,!1),d(this,fi,!1),d(this,pi,!1),i&&d(this,gi,!1)),a&&h(this,j,V4).call(this,e,s),h(this,j,jc).call(this,e),(c=o(this,As))==null||c.refresh()},H4=function(e){for(const r of e.querySelectorAll(".tab-label"))r.toggleAttribute("data-overflow",r.scrollWidth>r.clientWidth)},Z4=function(e){var r;for(const i of e.querySelectorAll(".tab")){const s=i.querySelector(".tab-label");if(!s)continue;const a=document.createRange();a.selectNodeContents(s);const l=(r=a.getBoundingClientRect)==null?void 0:r.call(a);if(!l||l.width<=0)continue;const c=getComputedStyle(i),u=Rc(c.paddingLeft)+Rc(c.paddingRight)+Rc(c.borderLeftWidth)+Rc(c.borderRightWidth),p=Math.ceil(l.width)+u>eN+tN?"capped":"hugging";i.dataset.compression!==p&&(i.dataset.compression=p)}},q4=function(e){var r,i;typeof ResizeObserver>"u"||o(this,Ml)===e||((r=o(this,_s))==null||r.disconnect(),o(this,_s)??d(this,_s,new ResizeObserver(()=>{o(this,En)?(d(this,Tr,!0),h(this,j,kd).call(this)):h(this,j,Ks).call(this,!0)})),o(this,_s).observe(e),d(this,Ml,e),(i=o(this,As))==null||i.dispose(),d(this,As,Zz(e,{items:".tab:not(.dragged)",distance:nN,edges:"both"})))},V4=function(e,r){const i=e.querySelector('.tab[aria-selected="true"]');if(!i){h(this,j,Oa).call(this);return}const s=e.getBoundingClientRect(),a=i.getBoundingClientRect(),l=Rc(getComputedStyle(i).translate),c=Math.max(0,Math.min(e.scrollLeft+a.left-l+a.width/2-(s.left+s.width/2),e.scrollWidth-e.clientWidth));if(h(this,j,Oa).call(this),o(this,En)||!r||Math.abs(e.scrollLeft-c)<=Tc||matchMedia("(prefers-reduced-motion: reduce)").matches){e.scrollLeft=c;return}const u=e.scrollLeft,f=e.animate([{},{}],{duration:z_,easing:"ease"});d(this,Ss,f);const p=()=>{var v;if(f!==o(this,Ss))return;const y=f.playState==="finished"?1:((v=f.effect)==null?void 0:v.getComputedTiming().progress)??0;e.scrollLeft=u+(c-u)*y,f.playState==="finished"?(e.scrollLeft=c,d(this,Ss,null),d(this,bs,0),h(this,j,jc).call(this,e)):d(this,bs,requestAnimationFrame(p))};d(this,bs,requestAnimationFrame(p))},Oa=function(){var e;typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(o(this,bs)),d(this,bs,0),(e=o(this,Ss))==null||e.cancel(),d(this,Ss,null)},F4=function(e){var i;if(o(this,En)===e||(d(this,En,e),!e))return;h(this,j,Oa).call(this),d(this,pi,!1),d(this,gi,!1);const r=o(this,nt);if(r!==null){h(this,j,Ed).call(this,r);for(const s of r.displacementAnimations)s.cancel();r.displacementAnimations.clear(),d(this,nt,null),r.dragging&&((i=o(this,qt).value)!=null&&i.hasPointerCapture(r.pointerId))&&o(this,qt).value.releasePointerCapture(r.pointerId),queueMicrotask(()=>{var s;return(s=r.onReorderChange)==null?void 0:s.call(r,null)})}h(this,j,Ks).call(this,!0,!0,!1)},jc=function(e=o(this,qt).value){if(!e)return;const r=Math.max(0,e.scrollWidth-e.clientWidth);e.toggleAttribute("data-overflow",r>Tc)};const Vz=dn(qz);function Fz(n,t){if(!n||!t)return[];const e=new Map(n.artifacts.map(r=>[r.id,r]));return t.map((r,i)=>{var a;const s=r.artifactIds[0]??null;return{page:r,artifactId:s,label:s===null?"":((a=e.get(s))==null?void 0:a.title)??"",key:s??`empty-page-${i}`}})}function Bz(n,t){return n.length===t.length&&n.every((e,r)=>e===t[r])}function Rc(n){const t=Number.parseFloat(n);return Number.isFinite(t)?t:0}let jz=0;var Xo,Vt,dh,Ct,vi,Rr,zl,yi,fh,kn,Ef,kf,ph,jl,B4,Tf,Rf,j4,Cf,If;class Wz extends hn{constructor(){super(...arguments);m(this,jl);m(this,Xo,new Ez(()=>this.render()));m(this,Vt,new y_(()=>this.render()));m(this,dh,`channel-switcher-trigger-${++jz}`);m(this,Ct,null);m(this,vi,null);m(this,Rr,!1);m(this,zl,null);m(this,yi,null);m(this,fh,Jn());m(this,kn,null);m(this,Ef,e=>{var r,i,s;(r=o(this,Ct))==null||r.removeAttribute("open"),((i=o(this,yi))==null?void 0:i.display.focusedChannelId)!==e&&((s=o(this,zl))==null||s.focusChannel(e).catch(()=>{}))});m(this,kf,e=>{o(this,Rr)||(d(this,Rr,!0),this.render(),e.detail===0&&requestAnimationFrame(()=>{var r;(r=o(this,Ct))!=null&&r.hasAttribute("open")&&h(this,jl,B4).call(this,0)}))});m(this,ph,e=>{const r=o(this,Ct);r===null||!r.hasAttribute("open")||o(this,Vt).dragging||r.querySelector("input, tv-menu[open]")||u_(e,[...r.querySelectorAll('.channel[role="option"]')])});m(this,Tf,e=>{var r,i;d(this,kn,{channelId:e,scrollTop:((i=(r=o(this,Ct))==null?void 0:r.querySelector(".channel-switcher-pop-body"))==null?void 0:i.scrollTop)??0,result:null})});m(this,Rf,(e,r)=>{var i;((i=o(this,kn))==null?void 0:i.channelId)===e&&(o(this,kn).result=r?"deleted":"cancelled",this.render())});m(this,Cf,e=>{var r;(r=o(this,vi))==null||r.disconnect(),d(this,vi,null),o(this,Ct)!==null&&o(this,kn)===null&&o(this,Vt).disconnect(),d(this,Ct,e instanceof HTMLElement?e:null),o(this,Ct)!==null&&(o(this,Vt).connect(),d(this,vi,new MutationObserver(o(this,If))),o(this,vi).observe(o(this,Ct),{attributes:!0,attributeFilter:["open"]}))});m(this,If,()=>{var e;(((e=o(this,Ct))==null?void 0:e.hasAttribute("open"))??!0)||o(this,kn)===null&&(d(this,Rr,!1),this.render())})}connected(){o(this,Xo).connect(),document.addEventListener("keydown",o(this,ph))}template(e,r,i={}){var l;d(this,zl,e),d(this,yi,r);const s=i.collapsed||i.sidebarTransitioning;(i.sidebarTransitioning||!s||r.focusedChannel===null)&&d(this,Rr,!1),o(this,Vt).update(e,r,{management:!0,dragging:!0,revealMovedRow:!0,onDeleteStart:o(this,Tf),onDeleteEnd:o(this,Rf),selectChannel:o(this,Ef),highlightOnPointerMove:!0,motionSuppressed:i.sidebarTransitioning});const a=o(this,kn);return a!=null&&a.result&&(r.channels.length===0||r.focusedChannel!==null)&&(a.result==="cancelled"||!r.channels.some(({id:c})=>c===a.channelId))&&queueMicrotask(()=>h(this,jl,j4).call(this,a)),o(this,Xo).configure({connectionOwner:i.connectionOwner,primaryServerURL:i.primaryServerURL,presentation:i.updatePresentation,desktopRecommendation:i.desktopRecommendation,desktopUpdate:i.desktopUpdate,dismissalStorage:i.dismissalStorage}),i.onRenderComplete&&queueMicrotask(i.onRenderComplete),W`
741
+ `}disconnected(){var e,r,i,s;d(this,Yo,!1),typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(o(this,ws)),d(this,ws,0),d(this,Tr,!1),d(this,fi,!1),d(this,pi,!1),h(this,j,Oa).call(this),d(this,gi,!1),d(this,Bn,!1),(e=o(this,_s))==null||e.disconnect(),d(this,_s,null),d(this,Ml,null),(r=o(this,As))==null||r.dispose(),d(this,As,null),(i=o(this,Ko))==null||i.disconnect(),d(this,Ko,null),document.removeEventListener("television-theme-styles-changed",o(this,Nl)),typeof document<"u"&&((s=document.fonts)==null||s.removeEventListener("loadingdone",o(this,hh))),window.removeEventListener("pointermove",o(this,ah)),window.removeEventListener("pointerup",o(this,lh)),window.removeEventListener("pointercancel",o(this,ch)),window.removeEventListener("keydown",o(this,uh)),h(this,j,La).call(this,!1,!1),d(this,mi,!1)}}qt=new WeakMap,Ll=new WeakMap,Ol=new WeakMap,Yo=new WeakMap,ws=new WeakMap,Tr=new WeakMap,fi=new WeakMap,pi=new WeakMap,bs=new WeakMap,Ss=new WeakMap,Bn=new WeakMap,_s=new WeakMap,Ml=new WeakMap,As=new WeakMap,Ko=new WeakMap,oh=new WeakMap,nt=new WeakMap,mi=new WeakMap,gi=new WeakMap,En=new WeakMap,_f=new WeakMap,j=new WeakSet,L4=function(e,r,i,s,a){o(this,En)||o(this,nt)!==null||i===null||s.artifactId===null||e.button!==0||!e.isPrimary||(d(this,mi,!1),d(this,nt,{pointerId:e.pointerId,originX:e.clientX,originY:e.clientY,tab:e.currentTarget,application:r,channelId:i.id,artifactId:s.artifactId,originalPages:i.pages,onReorderChange:a,displacementAnimations:new Set,provisionalPages:[...i.pages],slot:i.pages.indexOf(s.page),currentX:e.clientX,currentY:e.clientY,tabLeft:0,tabTop:0,tabWidth:0,tabHeight:0,edgeScrollFrame:0,edgeScrollTimestamp:null,edgeScrollRemainder:0,edgeScrollMoved:!1,dragging:!1}))},O4=function(e,r,i,s){var a;if(e.detail!==0&&o(this,mi)){d(this,mi,!1);return}d(this,mi,!1),!((a=o(this,nt))!=null&&a.dragging||i===null||s.artifactId===null)&&r.selectPage(i.id,s.artifactId)},ah=new WeakMap,lh=new WeakMap,ch=new WeakMap,Af=new WeakMap,uh=new WeakMap,La=function(e,r){var a;const i=o(this,nt);if(i===null)return;if(h(this,j,Ed).call(this,i),i.edgeScrollMoved&&d(this,gi,!0),i.dragging&&(d(this,Tr,o(this,fi)),o(this,fi)||d(this,pi,!1)),i.dragging&&e&&!Bz(i.originalPages,i.provisionalPages)){const l=i.provisionalPages.map(c=>({artifactIds:[...c.artifactIds],geometry:{...c.geometry},size:{...c.size}}));i.application.updateChannelPages(i.channelId,l).catch(()=>{})}if(!e)for(const l of i.displacementAnimations)l.cancel();d(this,nt,null),(a=i.onReorderChange)==null||a.call(i,null);const s=o(this,qt).value;i.dragging&&(s!=null&&s.hasPointerCapture(i.pointerId))&&s.releasePointerCapture(i.pointerId),r&&this.render()},E1=function(e){const r=o(this,qt).value,i=r?h(this,j,k1).call(this,r,e.currentX):0,s=r?Math.max(0,r.scrollWidth-r.clientWidth):0,a=i<0?((r==null?void 0:r.scrollLeft)??0)<=Tc:((r==null?void 0:r.scrollLeft)??0)>=s-Tc;if(o(this,En)||!e.dragging||i===0||s===0||a||typeof requestAnimationFrame!="function"){h(this,j,Ed).call(this,e);return}e.edgeScrollFrame===0&&(e.edgeScrollFrame=requestAnimationFrame(l=>{h(this,j,M4).call(this,e,l)}))},M4=function(e,r){if(e.edgeScrollFrame=0,o(this,En)||o(this,nt)!==e||!e.dragging){e.edgeScrollTimestamp=null;return}const i=o(this,qt).value;if(!i){e.edgeScrollTimestamp=null;return}const s=h(this,j,k1).call(this,i,e.currentX),a=e.edgeScrollTimestamp;if(e.edgeScrollTimestamp=r,s!==0&&a!==null){const l=Math.max(0,r-a)/1e3,c=Math.max(0,i.scrollWidth-i.clientWidth),u=i.scrollLeft,f=s*l+e.edgeScrollRemainder,p=Math.max(0,Math.min(c,u+f));i.scrollLeft=p;const y=i.scrollLeft-u;y!==0&&(e.edgeScrollMoved=!0),e.edgeScrollRemainder=p===0||p===c?0:f-y,y!==0&&(h(this,j,jc).call(this,i),h(this,j,T1).call(this,e))}h(this,j,E1).call(this,e)},Ed=function(e){e.edgeScrollFrame!==0&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(e.edgeScrollFrame),e.edgeScrollFrame=0,e.edgeScrollTimestamp=null,e.edgeScrollRemainder=0},k1=function(e,r){const i=e.getBoundingClientRect();return r>=i.left&&r<i.left+Cn?-Ud*(i.left+Cn-r)/Cn:r>i.right-Cn&&r<=i.right?Ud*(r-(i.right-Cn))/Cn:0},T1=function(e){var S;const r=o(this,qt).value,i=r==null?void 0:r.querySelector(".tab-placeholder");if(!r||!i)return;const s=i.nextElementSibling,a=e.tab.getBoundingClientRect(),l=a.left+a.width/2;let c=e.slot,u=i.previousElementSibling;for(;u!=null&&u.classList.contains("tab");){const _=u.getBoundingClientRect();if(l>=_.left+_.width/2)break;c-=1,u=u.previousElementSibling}let f=s==null?void 0:s.nextElementSibling;for(;f!=null&&f.classList.contains("tab");){const _=f.getBoundingClientRect();if(l<=_.left+_.width/2)break;c+=1,f=f.nextElementSibling}if(c===e.slot)return;const p=h(this,j,N4).call(this,r),y=[...e.provisionalPages],[v]=y.splice(e.slot,1);v&&(y.splice(c,0,v),e.provisionalPages=y,e.slot=c,this.render(),(S=e.onReorderChange)==null||S.call(e,h(this,j,R1).call(this,e)),queueMicrotask(()=>h(this,j,z4).call(this,e,p)))},R1=function(e){return{channelId:e.channelId,pages:e.provisionalPages,carriedArtifactId:e.artifactId}},N4=function(e){return new Map([...e.querySelectorAll(".tab:not([dragging])")].map(r=>[r.dataset.artifactId??"",r.getBoundingClientRect().left]))},z4=function(e,r){if(o(this,En))return;const i=o(this,qt).value;if(i)for(const s of i.querySelectorAll(".tab:not([dragging])")){const a=r.get(s.dataset.artifactId??"");if(a===void 0)continue;const l=a-s.getBoundingClientRect().left;if(Math.abs(l)<=Tc)continue;const c=s.animate({translate:[`${l}px 0`,"0px 0"]},{duration:za,easing:"ease"});e.displacementAnimations.add(c),c.finished.finally(()=>{e.displacementAnimations.delete(c)}).catch(()=>{})}},Nl=new WeakMap,hh=new WeakMap,U4=function(){o(this,oh)||typeof document>"u"||!document.fonts||(d(this,oh,!0),document.fonts.ready.then(()=>{this.isConnected&&(d(this,Bn,!0),h(this,j,Ks).call(this,!0))}))},Ks=function(e,r=!1,i=!1){o(this,Tr)||d(this,Tr,e),e&&r&&(d(this,fi,!0),d(this,pi,i&&!o(this,En))),!(o(this,Yo)||o(this,ws)!==0)&&(d(this,Yo,!0),queueMicrotask(()=>{if(d(this,Yo,!1),!!this.isConnected){if(typeof requestAnimationFrame!="function"){h(this,j,kd).call(this);return}d(this,ws,requestAnimationFrame(()=>{d(this,ws,0),h(this,j,kd).call(this)}))}}))},kd=function(){var l,c;const e=o(this,qt).value;if(!e)return;o(this,Bn)&&(d(this,Bn,!1),h(this,j,Z4).call(this,e)),h(this,j,q4).call(this,e),h(this,j,H4).call(this,e);const r=((l=o(this,nt))==null?void 0:l.dragging)===!0,i=o(this,fi),s=i&&o(this,pi),a=!r&&(i||o(this,Tr)&&!o(this,gi));r?d(this,Tr,i):(d(this,Tr,!1),d(this,fi,!1),d(this,pi,!1),i&&d(this,gi,!1)),a&&h(this,j,V4).call(this,e,s),h(this,j,jc).call(this,e),(c=o(this,As))==null||c.refresh()},H4=function(e){for(const r of e.querySelectorAll(".tab-label"))r.toggleAttribute("data-overflow",r.scrollWidth>r.clientWidth)},Z4=function(e){var r;for(const i of e.querySelectorAll(".tab")){const s=i.querySelector(".tab-label");if(!s)continue;const a=document.createRange();a.selectNodeContents(s);const l=(r=a.getBoundingClientRect)==null?void 0:r.call(a);if(!l||l.width<=0)continue;const c=getComputedStyle(i),u=Rc(c.paddingLeft)+Rc(c.paddingRight)+Rc(c.borderLeftWidth)+Rc(c.borderRightWidth),p=Math.ceil(l.width)+u>e9+t9?"capped":"hugging";i.dataset.compression!==p&&(i.dataset.compression=p)}},q4=function(e){var r,i;typeof ResizeObserver>"u"||o(this,Ml)===e||((r=o(this,_s))==null||r.disconnect(),o(this,_s)??d(this,_s,new ResizeObserver(()=>{o(this,En)?(d(this,Tr,!0),h(this,j,kd).call(this)):h(this,j,Ks).call(this,!0)})),o(this,_s).observe(e),d(this,Ml,e),(i=o(this,As))==null||i.dispose(),d(this,As,Zz(e,{items:".tab:not(.dragged)",distance:n9,edges:"both"})))},V4=function(e,r){const i=e.querySelector('.tab[aria-selected="true"]');if(!i){h(this,j,Oa).call(this);return}const s=e.getBoundingClientRect(),a=i.getBoundingClientRect(),l=Rc(getComputedStyle(i).translate),c=Math.max(0,Math.min(e.scrollLeft+a.left-l+a.width/2-(s.left+s.width/2),e.scrollWidth-e.clientWidth));if(h(this,j,Oa).call(this),o(this,En)||!r||Math.abs(e.scrollLeft-c)<=Tc||matchMedia("(prefers-reduced-motion: reduce)").matches){e.scrollLeft=c;return}const u=e.scrollLeft,f=e.animate([{},{}],{duration:z_,easing:"ease"});d(this,Ss,f);const p=()=>{var v;if(f!==o(this,Ss))return;const y=f.playState==="finished"?1:((v=f.effect)==null?void 0:v.getComputedTiming().progress)??0;e.scrollLeft=u+(c-u)*y,f.playState==="finished"?(e.scrollLeft=c,d(this,Ss,null),d(this,bs,0),h(this,j,jc).call(this,e)):d(this,bs,requestAnimationFrame(p))};d(this,bs,requestAnimationFrame(p))},Oa=function(){var e;typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(o(this,bs)),d(this,bs,0),(e=o(this,Ss))==null||e.cancel(),d(this,Ss,null)},F4=function(e){var i;if(o(this,En)===e||(d(this,En,e),!e))return;h(this,j,Oa).call(this),d(this,pi,!1),d(this,gi,!1);const r=o(this,nt);if(r!==null){h(this,j,Ed).call(this,r);for(const s of r.displacementAnimations)s.cancel();r.displacementAnimations.clear(),d(this,nt,null),r.dragging&&((i=o(this,qt).value)!=null&&i.hasPointerCapture(r.pointerId))&&o(this,qt).value.releasePointerCapture(r.pointerId),queueMicrotask(()=>{var s;return(s=r.onReorderChange)==null?void 0:s.call(r,null)})}h(this,j,Ks).call(this,!0,!0,!1)},jc=function(e=o(this,qt).value){if(!e)return;const r=Math.max(0,e.scrollWidth-e.clientWidth);e.toggleAttribute("data-overflow",r>Tc)};const Vz=dn(qz);function Fz(n,t){if(!n||!t)return[];const e=new Map(n.artifacts.map(r=>[r.id,r]));return t.map((r,i)=>{var a;const s=r.artifactIds[0]??null;return{page:r,artifactId:s,label:s===null?"":((a=e.get(s))==null?void 0:a.title)??"",key:s??`empty-page-${i}`}})}function Bz(n,t){return n.length===t.length&&n.every((e,r)=>e===t[r])}function Rc(n){const t=Number.parseFloat(n);return Number.isFinite(t)?t:0}let jz=0;var Xo,Vt,dh,Ct,vi,Rr,zl,yi,fh,kn,Ef,kf,ph,jl,B4,Tf,Rf,j4,Cf,If;class Wz extends hn{constructor(){super(...arguments);m(this,jl);m(this,Xo,new Ez(()=>this.render()));m(this,Vt,new y_(()=>this.render()));m(this,dh,`channel-switcher-trigger-${++jz}`);m(this,Ct,null);m(this,vi,null);m(this,Rr,!1);m(this,zl,null);m(this,yi,null);m(this,fh,Jn());m(this,kn,null);m(this,Ef,e=>{var r,i,s;(r=o(this,Ct))==null||r.removeAttribute("open"),((i=o(this,yi))==null?void 0:i.display.focusedChannelId)!==e&&((s=o(this,zl))==null||s.focusChannel(e).catch(()=>{}))});m(this,kf,e=>{o(this,Rr)||(d(this,Rr,!0),this.render(),e.detail===0&&requestAnimationFrame(()=>{var r;(r=o(this,Ct))!=null&&r.hasAttribute("open")&&h(this,jl,B4).call(this,0)}))});m(this,ph,e=>{const r=o(this,Ct);r===null||!r.hasAttribute("open")||o(this,Vt).dragging||r.querySelector("input, tv-menu[open]")||u_(e,[...r.querySelectorAll('.channel[role="option"]')])});m(this,Tf,e=>{var r,i;d(this,kn,{channelId:e,scrollTop:((i=(r=o(this,Ct))==null?void 0:r.querySelector(".channel-switcher-pop-body"))==null?void 0:i.scrollTop)??0,result:null})});m(this,Rf,(e,r)=>{var i;((i=o(this,kn))==null?void 0:i.channelId)===e&&(o(this,kn).result=r?"deleted":"cancelled",this.render())});m(this,Cf,e=>{var r;(r=o(this,vi))==null||r.disconnect(),d(this,vi,null),o(this,Ct)!==null&&o(this,kn)===null&&o(this,Vt).disconnect(),d(this,Ct,e instanceof HTMLElement?e:null),o(this,Ct)!==null&&(o(this,Vt).connect(),d(this,vi,new MutationObserver(o(this,If))),o(this,vi).observe(o(this,Ct),{attributes:!0,attributeFilter:["open"]}))});m(this,If,()=>{var e;(((e=o(this,Ct))==null?void 0:e.hasAttribute("open"))??!0)||o(this,kn)===null&&(d(this,Rr,!1),this.render())})}connected(){o(this,Xo).connect(),document.addEventListener("keydown",o(this,ph))}template(e,r,i={}){var l;d(this,zl,e),d(this,yi,r);const s=i.collapsed||i.sidebarTransitioning;(i.sidebarTransitioning||!s||r.focusedChannel===null)&&d(this,Rr,!1),o(this,Vt).update(e,r,{management:!0,dragging:!0,revealMovedRow:!0,onDeleteStart:o(this,Tf),onDeleteEnd:o(this,Rf),selectChannel:o(this,Ef),highlightOnPointerMove:!0,motionSuppressed:i.sidebarTransitioning});const a=o(this,kn);return a!=null&&a.result&&(r.channels.length===0||r.focusedChannel!==null)&&(a.result==="cancelled"||!r.channels.some(({id:c})=>c===a.channelId))&&queueMicrotask(()=>h(this,jl,j4).call(this,a)),o(this,Xo).configure({connectionOwner:i.connectionOwner,primaryServerURL:i.primaryServerURL,presentation:i.updatePresentation,desktopRecommendation:i.desktopRecommendation,desktopUpdate:i.desktopUpdate,dismissalStorage:i.dismissalStorage}),i.onRenderComplete&&queueMicrotask(i.onRenderComplete),W`
742
742
  <header class="top-bar" ${vt(o(this,fh))}>
743
743
  ${s?W`
744
744
  <div class="top-bar-lead">
@@ -809,7 +809,7 @@ From then on, open Television from Applications, not with \`tv-desktop\`.`;funct
809
809
  </div>
810
810
  </header>
811
811
  ${o(this,Vt).overlayTemplate()}
812
- `}disconnected(){var e;o(this,Xo).disconnect(),document.removeEventListener("keydown",o(this,ph)),o(this,Vt).disconnect(),(e=o(this,vi))==null||e.disconnect(),d(this,vi,null),d(this,Ct,null),d(this,Rr,!1),d(this,zl,null),d(this,yi,null),d(this,kn,null)}}Xo=new WeakMap,Vt=new WeakMap,dh=new WeakMap,Ct=new WeakMap,vi=new WeakMap,Rr=new WeakMap,zl=new WeakMap,yi=new WeakMap,fh=new WeakMap,kn=new WeakMap,Ef=new WeakMap,kf=new WeakMap,ph=new WeakMap,jl=new WeakSet,B4=function(e){var r;su((r=o(this,Ct))==null?void 0:r.querySelectorAll('.channel[role="option"]')[e])},Tf=new WeakMap,Rf=new WeakMap,j4=function(e){var u,f;if(o(this,kn)!==e||o(this,yi)===null)return;d(this,kn,null);const r=o(this,yi).focusedChannel;d(this,Rr,r!==null),this.render();const i=o(this,Ct);if(i===null){o(this,Vt).disconnect(),(f=(u=o(this,fh).value)==null?void 0:u.querySelector(".sidebar-expand"))==null||f.focus();return}i.setAttribute("open","");const s=i.querySelector(".channel-switcher-pop-body");s&&(s.scrollTop=e.scrollTop);const a=e.result==="cancelled"&&o(this,yi).channels.some(({id:p})=>p===e.channelId)?e.channelId:r==null?void 0:r.id,l=[...i.querySelectorAll(".channel-row")].find(p=>p.dataset.channelId===a),c=l==null?void 0:l.querySelector(".channel");c==null||c.focus({preventScroll:!0}),e.result==="deleted"&&(c==null||c.scrollIntoView({block:"nearest"}))},Cf=new WeakMap,If=new WeakMap;const Gz=dn(Wz);var Cr,mh,Qo,Ul,It,ln,Tn,Rn,ea,Ie,jn,Es,Hl,ks,gh,$f,ta,xf,Pf,Df,K,Td,C1,W4,vh,Lf,Zi,Xs,Wc,Rd,I1,G4,J4,Of,Mf,Nf,yh,zf,Qs,Gc,Y4;class Jz extends hn{constructor(){super(...arguments);m(this,K);m(this,Cr,null);m(this,mh);m(this,Qo,null);m(this,Ul,null);m(this,It,qh);m(this,ln,!1);m(this,Tn,null);m(this,Rn,null);m(this,ea,null);m(this,Ie,!1);m(this,jn,!1);m(this,Es,qh);m(this,Hl,0);m(this,ks,null);m(this,gh,e=>{var r;if(e.key==="Escape"&&o(this,Tn)!==null){e.preventDefault(),e.stopPropagation(),h(this,K,Qs).call(this);return}PA(e,navigator.platform)&&(e.preventDefault(),e.stopPropagation(),(r=o(this,Cr))==null||r.handleNavigationKey(e.key))});m(this,$f,e=>{d(this,mh,e??void 0),this.render()});m(this,ta,()=>{this.render()});m(this,xf,()=>h(this,K,Td).call(this,!0));m(this,Pf,()=>h(this,K,Td).call(this,!1));m(this,Df,()=>{const e=o(this,Ie)?!o(this,jn):!o(this,ln);h(this,K,Td).call(this,e)});m(this,vh,e=>{const r=o(this,ks),i=h(this,K,Xs).call(this).closest("#app");if(!r||!i)return;d(this,Es,e);const s=sN(1-e/r.expandedSidebarWidth,r),a=(c,u)=>{i.style.setProperty(`--motion-${c}`,`${u}px`)};a("boundary",s.sidebarBoundary),a("toggle-left",s.toggleLeft),a("toggle-top",r.toggleTop),a("toggle-width",r.toggleWidth),a("toggle-height",r.toggleHeight),a("toggle-wipe",s.toggleWipe),a("lead-reservation",s.leadReservation),a("switcher-left",r.collapsedToggleLeft+r.toggleWidth+r.toggleSwitcherGap-s.sidebarBoundary-r.barInset),i.style.setProperty("--motion-titlebar-opacity",String(s.titlebarOpacity)),i.style.setProperty("--motion-switcher-opacity",String(s.switcherOpacity));const l=h(this,K,Xs).call(this);l.style.removeProperty("left"),l.style.removeProperty("top")});m(this,Lf,e=>{var s;if(!o(this,Ie))return;const r=e===0;if(r!==o(this,jn))return;const i=document.activeElement===o(this,Rn);h(this,K,Zi).call(this,r),this.render(),i&&((s=o(this,Rn))==null||s.focus({preventScroll:!0}))});m(this,Of,e=>{if(e.button!==0||o(this,Tn)!==null)return;const r=e.currentTarget,i=r.closest("#app");i!==null&&(r.setPointerCapture(e.pointerId),d(this,Tn,{pointerId:e.pointerId,startX:e.clientX,startWidth:o(this,It),root:i}),e.preventDefault())});m(this,Mf,e=>{const r=o(this,Tn);r===null||e.pointerId!==r.pointerId||h(this,K,Gc).call(this,r.root,r.startWidth+e.clientX-r.startX)});m(this,Nf,e=>{var s;const r=o(this,Tn);if(r===null||e.pointerId!==r.pointerId)return;d(this,Tn,null);const i=((s=o(this,Qo))==null?void 0:s.commit(o(this,It)))??o(this,It);h(this,K,Gc).call(this,r.root,i)});m(this,yh,e=>{const r=o(this,Tn);r===null||e.pointerId!==r.pointerId||h(this,K,Qs).call(this)});m(this,zf,e=>{var i;const r=e.currentTarget.closest("#app");r!==null&&((i=o(this,Qo))==null||i.clear(),h(this,K,Gc).call(this,r,qh))})}update(e,r){const i=r[0],s=r[1].sidebarWidthPreference,a=r[1].sidebarCollapsedPreference;o(this,Cr)!==i&&(o(this,Cr)!==null&&this.isConnected&&(o(this,Cr).removeEventListener("change",o(this,ta)),i.addEventListener("change",o(this,ta))),d(this,Cr,i));const l=o(this,Qo)!==s,c=o(this,Ul)!==a;return l&&(h(this,K,Qs).call(this),d(this,Qo,s),d(this,It,s.read()??qh)),c&&(h(this,K,Qs).call(this),d(this,Ul,a),d(this,ln,a.read())),(l||c)&&h(this,K,Zi).call(this,o(this,ln)),super.update(e,r)}connected(){var e;(e=o(this,Cr))==null||e.addEventListener("change",o(this,ta)),document.addEventListener("keydown",o(this,gh),{capture:!0})}disconnected(){var e,r;h(this,K,Qs).call(this),o(this,Ie)?h(this,K,Zi).call(this,o(this,jn)):(e=o(this,ea))==null||e.cancel(),(r=o(this,Cr))==null||r.removeEventListener("change",o(this,ta)),document.removeEventListener("keydown",o(this,gh),{capture:!0})}template(e,r){const i=xL(e.snapshot,r.runtimeServerURL),s=e.snapshot,a=Kz(i,s.connection.hasEverConnected);return r.onRenderComplete&&queueMicrotask(()=>{var l;this.isConnected&&((l=r.onRenderComplete)==null||l.call(r,i.kind))}),W`
812
+ `}disconnected(){var e;o(this,Xo).disconnect(),document.removeEventListener("keydown",o(this,ph)),o(this,Vt).disconnect(),(e=o(this,vi))==null||e.disconnect(),d(this,vi,null),d(this,Ct,null),d(this,Rr,!1),d(this,zl,null),d(this,yi,null),d(this,kn,null)}}Xo=new WeakMap,Vt=new WeakMap,dh=new WeakMap,Ct=new WeakMap,vi=new WeakMap,Rr=new WeakMap,zl=new WeakMap,yi=new WeakMap,fh=new WeakMap,kn=new WeakMap,Ef=new WeakMap,kf=new WeakMap,ph=new WeakMap,jl=new WeakSet,B4=function(e){var r;su((r=o(this,Ct))==null?void 0:r.querySelectorAll('.channel[role="option"]')[e])},Tf=new WeakMap,Rf=new WeakMap,j4=function(e){var u,f;if(o(this,kn)!==e||o(this,yi)===null)return;d(this,kn,null);const r=o(this,yi).focusedChannel;d(this,Rr,r!==null),this.render();const i=o(this,Ct);if(i===null){o(this,Vt).disconnect(),(f=(u=o(this,fh).value)==null?void 0:u.querySelector(".sidebar-expand"))==null||f.focus();return}i.setAttribute("open","");const s=i.querySelector(".channel-switcher-pop-body");s&&(s.scrollTop=e.scrollTop);const a=e.result==="cancelled"&&o(this,yi).channels.some(({id:p})=>p===e.channelId)?e.channelId:r==null?void 0:r.id,l=[...i.querySelectorAll(".channel-row")].find(p=>p.dataset.channelId===a),c=l==null?void 0:l.querySelector(".channel");c==null||c.focus({preventScroll:!0}),e.result==="deleted"&&(c==null||c.scrollIntoView({block:"nearest"}))},Cf=new WeakMap,If=new WeakMap;const Gz=dn(Wz);var Cr,mh,Qo,Ul,It,ln,Tn,Rn,ea,Ie,jn,Es,Hl,ks,gh,$f,ta,xf,Pf,Df,K,Td,C1,W4,vh,Lf,Zi,Xs,Wc,Rd,I1,G4,J4,Of,Mf,Nf,yh,zf,Qs,Gc,Y4;class Jz extends hn{constructor(){super(...arguments);m(this,K);m(this,Cr,null);m(this,mh);m(this,Qo,null);m(this,Ul,null);m(this,It,qh);m(this,ln,!1);m(this,Tn,null);m(this,Rn,null);m(this,ea,null);m(this,Ie,!1);m(this,jn,!1);m(this,Es,qh);m(this,Hl,0);m(this,ks,null);m(this,gh,e=>{var r;if(e.key==="Escape"&&o(this,Tn)!==null){e.preventDefault(),e.stopPropagation(),h(this,K,Qs).call(this);return}PA(e,navigator.platform)&&(e.preventDefault(),e.stopPropagation(),(r=o(this,Cr))==null||r.handleNavigationKey(e.key))});m(this,$f,e=>{d(this,mh,e??void 0),this.render()});m(this,ta,()=>{this.render()});m(this,xf,()=>h(this,K,Td).call(this,!0));m(this,Pf,()=>h(this,K,Td).call(this,!1));m(this,Df,()=>{const e=o(this,Ie)?!o(this,jn):!o(this,ln);h(this,K,Td).call(this,e)});m(this,vh,e=>{const r=o(this,ks),i=h(this,K,Xs).call(this).closest("#app");if(!r||!i)return;d(this,Es,e);const s=s9(1-e/r.expandedSidebarWidth,r),a=(c,u)=>{i.style.setProperty(`--motion-${c}`,`${u}px`)};a("boundary",s.sidebarBoundary),a("toggle-left",s.toggleLeft),a("toggle-top",r.toggleTop),a("toggle-width",r.toggleWidth),a("toggle-height",r.toggleHeight),a("toggle-wipe",s.toggleWipe),a("lead-reservation",s.leadReservation),a("switcher-left",r.collapsedToggleLeft+r.toggleWidth+r.toggleSwitcherGap-s.sidebarBoundary-r.barInset),i.style.setProperty("--motion-titlebar-opacity",String(s.titlebarOpacity)),i.style.setProperty("--motion-switcher-opacity",String(s.switcherOpacity));const l=h(this,K,Xs).call(this);l.style.removeProperty("left"),l.style.removeProperty("top")});m(this,Lf,e=>{var s;if(!o(this,Ie))return;const r=e===0;if(r!==o(this,jn))return;const i=document.activeElement===o(this,Rn);h(this,K,Zi).call(this,r),this.render(),i&&((s=o(this,Rn))==null||s.focus({preventScroll:!0}))});m(this,Of,e=>{if(e.button!==0||o(this,Tn)!==null)return;const r=e.currentTarget,i=r.closest("#app");i!==null&&(r.setPointerCapture(e.pointerId),d(this,Tn,{pointerId:e.pointerId,startX:e.clientX,startWidth:o(this,It),root:i}),e.preventDefault())});m(this,Mf,e=>{const r=o(this,Tn);r===null||e.pointerId!==r.pointerId||h(this,K,Gc).call(this,r.root,r.startWidth+e.clientX-r.startX)});m(this,Nf,e=>{var s;const r=o(this,Tn);if(r===null||e.pointerId!==r.pointerId)return;d(this,Tn,null);const i=((s=o(this,Qo))==null?void 0:s.commit(o(this,It)))??o(this,It);h(this,K,Gc).call(this,r.root,i)});m(this,yh,e=>{const r=o(this,Tn);r===null||e.pointerId!==r.pointerId||h(this,K,Qs).call(this)});m(this,zf,e=>{var i;const r=e.currentTarget.closest("#app");r!==null&&((i=o(this,Qo))==null||i.clear(),h(this,K,Gc).call(this,r,qh))})}update(e,r){const i=r[0],s=r[1].sidebarWidthPreference,a=r[1].sidebarCollapsedPreference;o(this,Cr)!==i&&(o(this,Cr)!==null&&this.isConnected&&(o(this,Cr).removeEventListener("change",o(this,ta)),i.addEventListener("change",o(this,ta))),d(this,Cr,i));const l=o(this,Qo)!==s,c=o(this,Ul)!==a;return l&&(h(this,K,Qs).call(this),d(this,Qo,s),d(this,It,s.read()??qh)),c&&(h(this,K,Qs).call(this),d(this,Ul,a),d(this,ln,a.read())),(l||c)&&h(this,K,Zi).call(this,o(this,ln)),super.update(e,r)}connected(){var e;(e=o(this,Cr))==null||e.addEventListener("change",o(this,ta)),document.addEventListener("keydown",o(this,gh),{capture:!0})}disconnected(){var e,r;h(this,K,Qs).call(this),o(this,Ie)?h(this,K,Zi).call(this,o(this,jn)):(e=o(this,ea))==null||e.cancel(),(r=o(this,Cr))==null||r.removeEventListener("change",o(this,ta)),document.removeEventListener("keydown",o(this,gh),{capture:!0})}template(e,r){const i=xL(e.snapshot,r.runtimeServerURL),s=e.snapshot,a=Kz(i,s.connection.hasEverConnected);return r.onRenderComplete&&queueMicrotask(()=>{var l;this.isConnected&&((l=r.onRenderComplete)==null||l.call(r,i.kind))}),W`
813
813
  <div
814
814
  id="app"
815
815
  tabindex="-1"
@@ -819,10 +819,10 @@ From then on, open Television from Applications, not with \`tv-desktop\`.`;funct
819
819
  style=${h(this,K,J4).call(this)}
820
820
  >
821
821
  ${a?h(this,K,Y4).call(this,e,s,r):null}
822
- ${i.kind==="needs-upgrade"?uz(i.instructions,r.desktopUpdate,s4(r.electronMode&&!a)):Xz(i)?HN(i,{context:r.electronMode?"desktop":"browser",dragStrip:r.electronMode&&!a}):null}
822
+ ${i.kind==="needs-upgrade"?uz(i.instructions,r.desktopUpdate,s4(r.electronMode&&!a)):Xz(i)?H9(i,{context:r.electronMode?"desktop":"browser",dragStrip:r.electronMode&&!a}):null}
823
823
  </div>
824
824
  <div id="foreground-overlay" inert aria-hidden="true"></div>
825
- `}}Cr=new WeakMap,mh=new WeakMap,Qo=new WeakMap,Ul=new WeakMap,It=new WeakMap,ln=new WeakMap,Tn=new WeakMap,Rn=new WeakMap,ea=new WeakMap,Ie=new WeakMap,jn=new WeakMap,Es=new WeakMap,Hl=new WeakMap,ks=new WeakMap,gh=new WeakMap,$f=new WeakMap,ta=new WeakMap,xf=new WeakMap,Pf=new WeakMap,Df=new WeakMap,K=new WeakSet,Td=function(e){var c,u;if(!o(this,Ie)&&o(this,ln)===e||o(this,Ie)&&o(this,jn)===e)return;h(this,K,Qs).call(this);const r=document.activeElement===o(this,Rn);if((c=o(this,Ul))==null||c.setCollapsed(e),matchMedia("(prefers-reduced-motion: reduce)").matches){h(this,K,Zi).call(this,e),this.render(),r&&((u=o(this,Rn))==null||u.focus({preventScroll:!0}));return}if(d(this,jn,e),o(this,Ie)){h(this,K,Wc).call(this),h(this,K,C1).call(this);return}const i=h(this,K,Xs).call(this),s=i.closest("#app"),a=i.getBoundingClientRect(),l=s==null?void 0:s.getBoundingClientRect();if(!s||!l||a.width===0){h(this,K,Zi).call(this,e),this.render();return}for(const f of s.getAnimations({subtree:!0}))f.cancel();d(this,Ie,!0),d(this,Hl,a.top-l.top),d(this,ks,null),i.style.left=`${a.left-l.left}px`,i.style.top=`${o(this,Hl)}px`,h(this,K,Wc).call(this),this.render(),queueMicrotask(()=>{o(this,Ie)&&(h(this,K,W4).call(this),r&&i.focus({preventScroll:!0}),h(this,K,C1).call(this))})},C1=function(){const e=h(this,K,Xs).call(this).closest("#app"),r=o(this,ea);if(!e||!r||!o(this,ks))return;const i=o(this,jn)?0:o(this,It);r.move({root:e,width:o(this,It),target:i,onFrame:o(this,vh),onFinish:o(this,Lf)})},W4=function(){const r=h(this,K,Xs).call(this).closest("#app"),i=r==null?void 0:r.querySelector(".sidebar-titlebar > .sidebar-toggle-seat"),s=r==null?void 0:r.querySelector(".top-bar > .top-bar-lead"),a=s==null?void 0:s.querySelector(":scope > .sidebar-toggle-seat"),l=s==null?void 0:s.querySelector(":scope > .channel-switcher"),c=s==null?void 0:s.closest(".top-bar");if(!r||!i||!s||!a||!c){h(this,K,Zi).call(this,o(this,jn)),this.render();return}const u=i.closest(".app-sidebar");r.removeAttribute("data-sidebar-motion");const f=r.getBoundingClientRect(),p=s.style.display;s.style.display="none";const y=i.getBoundingClientRect();u.style.marginLeft=`${-o(this,It)}px`,s.style.display=p;const v=a.getBoundingClientRect(),S=l==null?void 0:l.getBoundingClientRect();d(this,ks,{expandedSidebarWidth:o(this,It),expandedToggleLeft:y.left-f.left,collapsedToggleLeft:v.left-f.left,toggleTop:o(this,Hl),toggleWidth:v.width,toggleHeight:v.height,toggleSwitcherGap:S?S.left-v.right:0,collapsedLeadReservation:s.getBoundingClientRect().width,hasSwitcher:!!l,barInset:c.getBoundingClientRect().left-f.left}),u.style.removeProperty("margin-left"),r.setAttribute("data-sidebar-motion",""),o(this,vh).call(this,o(this,Es))},vh=new WeakMap,Lf=new WeakMap,Zi=function(e){var r;(r=o(this,ea))==null||r.cancel(),d(this,ln,e),d(this,Ie,!1),d(this,Es,e?0:o(this,It)),d(this,ea,new aN(o(this,Es))),d(this,ks,null),h(this,K,G4).call(this),h(this,K,Wc).call(this)},Xs=function(){if(o(this,Rn)!==null)return o(this,Rn);const e=document.createElement("button");return e.type="button",e.setAttribute("variant","ghost"),e.setAttribute("icon",""),e.append(h(this,K,Rd).call(this)),e.addEventListener("pointerdown",r=>{r.button===0&&e.setPointerCapture(r.pointerId)}),e.addEventListener("click",o(this,Df)),d(this,Rn,e),h(this,K,Wc).call(this),e},Wc=function(){var s;const e=o(this,Rn);if(e===null)return;const r=o(this,Ie)?o(this,jn):o(this,ln);e.className=o(this,Ie)?"sidebar-motion-toggle sidebar-toggle":r?"sidebar-expand":"sidebar-collapse",o(this,Ie)?e.querySelectorAll(":scope > .sidebar-toggle-paint").length!==2&&e.replaceChildren(h(this,K,I1).call(this,"expanded-paint"),h(this,K,I1).call(this,"collapsed-paint")):(e.children.length!==1||!((s=e.firstElementChild)!=null&&s.matches("tv-icon[name='sidebar']")))&&e.replaceChildren(h(this,K,Rd).call(this));const i=r?"Show sidebar":"Collapse sidebar";e.setAttribute("aria-label",i),e.title=i},Rd=function(){const e=document.createElement("tv-icon");return e.setAttribute("name","sidebar"),e.setAttribute("size","sm"),e},I1=function(e){const r=document.createElement("span");return r.className=`sidebar-toggle-paint ${e}`,r.setAttribute("aria-hidden","true"),r.append(h(this,K,Rd).call(this)),r},G4=function(){const e=o(this,Rn);e!==null&&(e.style.removeProperty("left"),e.style.removeProperty("top"))},J4=function(){const e=[`--sidebar-width: ${o(this,It)}px`];return o(this,Ie)&&e.push(`--motion-boundary: ${o(this,Es)}px`),e.join("; ")},Of=new WeakMap,Mf=new WeakMap,Nf=new WeakMap,yh=new WeakMap,zf=new WeakMap,Qs=function(){const e=o(this,Tn);if(e===null)return;d(this,Tn,null),h(this,K,Gc).call(this,e.root,e.startWidth);const r=e.root.querySelector(".app-sidebar-resize");r!=null&&r.hasPointerCapture(e.pointerId)&&r.releasePointerCapture(e.pointerId)},Gc=function(e,r){d(this,It,zS(r)),h(this,K,Zi).call(this,o(this,ln)),e.style.setProperty("--sidebar-width",`${o(this,It)}px`)},Y4=function(e,r,i){const s=!o(this,ln)||o(this,Ie),a=h(this,K,Xs).call(this);return W`
825
+ `}}Cr=new WeakMap,mh=new WeakMap,Qo=new WeakMap,Ul=new WeakMap,It=new WeakMap,ln=new WeakMap,Tn=new WeakMap,Rn=new WeakMap,ea=new WeakMap,Ie=new WeakMap,jn=new WeakMap,Es=new WeakMap,Hl=new WeakMap,ks=new WeakMap,gh=new WeakMap,$f=new WeakMap,ta=new WeakMap,xf=new WeakMap,Pf=new WeakMap,Df=new WeakMap,K=new WeakSet,Td=function(e){var c,u;if(!o(this,Ie)&&o(this,ln)===e||o(this,Ie)&&o(this,jn)===e)return;h(this,K,Qs).call(this);const r=document.activeElement===o(this,Rn);if((c=o(this,Ul))==null||c.setCollapsed(e),matchMedia("(prefers-reduced-motion: reduce)").matches){h(this,K,Zi).call(this,e),this.render(),r&&((u=o(this,Rn))==null||u.focus({preventScroll:!0}));return}if(d(this,jn,e),o(this,Ie)){h(this,K,Wc).call(this),h(this,K,C1).call(this);return}const i=h(this,K,Xs).call(this),s=i.closest("#app"),a=i.getBoundingClientRect(),l=s==null?void 0:s.getBoundingClientRect();if(!s||!l||a.width===0){h(this,K,Zi).call(this,e),this.render();return}for(const f of s.getAnimations({subtree:!0}))f.cancel();d(this,Ie,!0),d(this,Hl,a.top-l.top),d(this,ks,null),i.style.left=`${a.left-l.left}px`,i.style.top=`${o(this,Hl)}px`,h(this,K,Wc).call(this),this.render(),queueMicrotask(()=>{o(this,Ie)&&(h(this,K,W4).call(this),r&&i.focus({preventScroll:!0}),h(this,K,C1).call(this))})},C1=function(){const e=h(this,K,Xs).call(this).closest("#app"),r=o(this,ea);if(!e||!r||!o(this,ks))return;const i=o(this,jn)?0:o(this,It);r.move({root:e,width:o(this,It),target:i,onFrame:o(this,vh),onFinish:o(this,Lf)})},W4=function(){const r=h(this,K,Xs).call(this).closest("#app"),i=r==null?void 0:r.querySelector(".sidebar-titlebar > .sidebar-toggle-seat"),s=r==null?void 0:r.querySelector(".top-bar > .top-bar-lead"),a=s==null?void 0:s.querySelector(":scope > .sidebar-toggle-seat"),l=s==null?void 0:s.querySelector(":scope > .channel-switcher"),c=s==null?void 0:s.closest(".top-bar");if(!r||!i||!s||!a||!c){h(this,K,Zi).call(this,o(this,jn)),this.render();return}const u=i.closest(".app-sidebar");r.removeAttribute("data-sidebar-motion");const f=r.getBoundingClientRect(),p=s.style.display;s.style.display="none";const y=i.getBoundingClientRect();u.style.marginLeft=`${-o(this,It)}px`,s.style.display=p;const v=a.getBoundingClientRect(),S=l==null?void 0:l.getBoundingClientRect();d(this,ks,{expandedSidebarWidth:o(this,It),expandedToggleLeft:y.left-f.left,collapsedToggleLeft:v.left-f.left,toggleTop:o(this,Hl),toggleWidth:v.width,toggleHeight:v.height,toggleSwitcherGap:S?S.left-v.right:0,collapsedLeadReservation:s.getBoundingClientRect().width,hasSwitcher:!!l,barInset:c.getBoundingClientRect().left-f.left}),u.style.removeProperty("margin-left"),r.setAttribute("data-sidebar-motion",""),o(this,vh).call(this,o(this,Es))},vh=new WeakMap,Lf=new WeakMap,Zi=function(e){var r;(r=o(this,ea))==null||r.cancel(),d(this,ln,e),d(this,Ie,!1),d(this,Es,e?0:o(this,It)),d(this,ea,new a9(o(this,Es))),d(this,ks,null),h(this,K,G4).call(this),h(this,K,Wc).call(this)},Xs=function(){if(o(this,Rn)!==null)return o(this,Rn);const e=document.createElement("button");return e.type="button",e.setAttribute("variant","ghost"),e.setAttribute("icon",""),e.append(h(this,K,Rd).call(this)),e.addEventListener("pointerdown",r=>{r.button===0&&e.setPointerCapture(r.pointerId)}),e.addEventListener("click",o(this,Df)),d(this,Rn,e),h(this,K,Wc).call(this),e},Wc=function(){var s;const e=o(this,Rn);if(e===null)return;const r=o(this,Ie)?o(this,jn):o(this,ln);e.className=o(this,Ie)?"sidebar-motion-toggle sidebar-toggle":r?"sidebar-expand":"sidebar-collapse",o(this,Ie)?e.querySelectorAll(":scope > .sidebar-toggle-paint").length!==2&&e.replaceChildren(h(this,K,I1).call(this,"expanded-paint"),h(this,K,I1).call(this,"collapsed-paint")):(e.children.length!==1||!((s=e.firstElementChild)!=null&&s.matches("tv-icon[name='sidebar']")))&&e.replaceChildren(h(this,K,Rd).call(this));const i=r?"Show sidebar":"Collapse sidebar";e.setAttribute("aria-label",i),e.title=i},Rd=function(){const e=document.createElement("tv-icon");return e.setAttribute("name","sidebar"),e.setAttribute("size","sm"),e},I1=function(e){const r=document.createElement("span");return r.className=`sidebar-toggle-paint ${e}`,r.setAttribute("aria-hidden","true"),r.append(h(this,K,Rd).call(this)),r},G4=function(){const e=o(this,Rn);e!==null&&(e.style.removeProperty("left"),e.style.removeProperty("top"))},J4=function(){const e=[`--sidebar-width: ${o(this,It)}px`];return o(this,Ie)&&e.push(`--motion-boundary: ${o(this,Es)}px`),e.join("; ")},Of=new WeakMap,Mf=new WeakMap,Nf=new WeakMap,yh=new WeakMap,zf=new WeakMap,Qs=function(){const e=o(this,Tn);if(e===null)return;d(this,Tn,null),h(this,K,Gc).call(this,e.root,e.startWidth);const r=e.root.querySelector(".app-sidebar-resize");r!=null&&r.hasPointerCapture(e.pointerId)&&r.releasePointerCapture(e.pointerId)},Gc=function(e,r){d(this,It,zS(r)),h(this,K,Zi).call(this,o(this,ln)),e.style.setProperty("--sidebar-width",`${o(this,It)}px`)},Y4=function(e,r,i){const s=!o(this,ln)||o(this,Ie),a=h(this,K,Xs).call(this);return W`
826
826
  ${s?W`
827
827
  <aside class="app-sidebar">
828
828
  ${GM(e,r,i.electronMode,o(this,xf),o(this,Ie)?null:a,o(this,Ie))}
@@ -842,7 +842,7 @@ From then on, open Television from Applications, not with \`tv-desktop\`.`;funct
842
842
  `:null}
843
843
  <main class="app-main">
844
844
  ${Gz(e,r,{connectionOwner:i.connectionOwner,primaryServerURL:i.primaryServerURL,updatePresentation:i.updatePresentation,desktopRecommendation:i.desktopRecommendation,desktopUpdate:i.desktopUpdate,onTabReorderChange:o(this,$f),collapsed:o(this,ln),onExpandSidebar:o(this,Pf),sidebarToggle:o(this,Ie)?null:o(this,ln)?a:void 0,sidebarTransitioning:o(this,Ie)})}
845
- ${ON(e,r.focusedChannel,o(this,mh),o(this,Ie))}
845
+ ${O9(e,r.focusedChannel,o(this,mh),o(this,Ie))}
846
846
  </main>
847
847
  ${o(this,Ie)?a:null}
848
- `};const Yz=dn(Jz);function Kz(n,t){return n.kind==="connected"||n.kind==="no-channel"||n.kind==="empty-channel"||n.kind==="disconnected"||n.kind==="error"&&t}function Xz(n){return n.kind!=="connected"&&n.kind!=="no-channel"&&n.kind!=="empty-channel"}const K4="television-appearance-mode";function Qz(n){return n==="system"||n==="light"||n==="dark"}function e7(){try{const n=window.localStorage.getItem(K4);return Qz(n)?n:"system"}catch{return"system"}}function X4(){return window.__televisionAppearanceResolver??hL(e7())}function t7(n,t){return t==="light"||t==="dark"?t:n}function n7(n){X4().setPreference(n);try{window.localStorage.setItem(K4,n)}catch{}}document.documentElement.dataset.tvBundleVersion=cv();Object.defineProperty(window,"__tvVersion",{value:cv(),writable:!1,configurable:!1});X4();const r7=y7(),Kn=wi();Kn?document.documentElement.dataset.platform="electron":delete document.documentElement.dataset.platform;const kv=_$(),Q4=A$(),i7=new bT(Kn?"television-electron":"television-browser",wT()),s7=new JD(window.localStorage),o7=new WD(window.localStorage),a8=PS(),a7=a8?$$({storage:a8,clientApp:Kn?"desktop":"browser",desktopAppVersion:Kn?L6():null}):null,Tv=Cs(Kn?kv:window.location.origin),Rv=eL({search:window.location.search}),Xn=uv(),eA=new oL,Cv=sL({detection:Rv,primaryServerURL:Tv,navigationLatch:Xn,presentation:eA}),Oe=new MD({localStore:i7,serverURL:kv,launchToken:Q4,telemetryMeta:a7,navigationPending:()=>Xn.pending,...Rv.electron?{decideBoot:n=>Cv.decideBoot(n)}:{}}),l7=n=>{lT(yt,n)},yt=new Xk({connectionOwner:Oe,navigationKeyHandler:l7,retainedGateHalted:()=>Cv.gated}),so=globalThis.__televisionNativeBridge;Kn&&so&&so.onNavigationKey(n=>yt.handleNavigationKey(n));const c7=new uL({electron:Kn,bridge:so});if(Q4){const n=new URL(window.location.href);n.searchParams.delete("token"),window.history.replaceState(window.history.state,"",`${n.pathname}${n.search}${n.hash}`)}QD({owner:Oe,primaryServerURL:Tv,navigationLatch:Xn});Cv.attach(Oe);const u7=()=>{const n=Oe.connection;n.status==="connected"&&n.client.artifacts.list().then(({artifacts:t})=>{const e=new Set(t.map(r=>r.id));BD(e)}).catch(()=>{})},tA=()=>{Oe.connection.status==="connected"&&lN(Oe.connection.url)};let Bd=null,$1=null,nA=Oe.connection.status;const h7=()=>{Xn.pending||Xn.begin(()=>{const n=document.querySelector("#settings-popover");if(n!=null&&n.hasAttribute("open")){const t=new URL(window.location.href);t.searchParams.set("reopenSettings","1"),window.history.replaceState(window.history.state,"",`${t.pathname}${t.search}${t.hash}`)}window.location.reload()})},rA=(n,t,e)=>{if(Xn.pending||Oe.connection.status!=="connected"||yt.snapshot.connection.status!=="connected"||!yt.snapshot.ready)return;const r={activeThemeName:n,consentIds:new Set(t)},i=Bd,s=hN(),a=i!==null&&i.activeThemeName!==r.activeThemeName,l=(i==null?void 0:i.activeThemeName)!==null&&(i==null?void 0:i.activeThemeName)!==void 0&&i.consentIds.has(i.activeThemeName),c=r.activeThemeName!==null&&r.consentIds.has(r.activeThemeName),u=i!==null&&!a&&l&&!c,f=i!==null&&lA(i.consentIds,r.consentIds);if(Bd=r,s!==null&&(a||u)){h7();return}if(s===null&&c){_b(Oe.connection.url);return}s!==null&&c&&e&&!a&&f&&_b(Oe.connection.url)},d7=()=>{const n=document.documentElement.dataset.theme;if(n!=="light"&&n!=="dark")throw new Error("Application root has no effective theme-frame appearance");return n},iA=(n,t)=>{if(Xn.pending||Oe.connection.status!=="connected"||yt.snapshot.connection.status!=="connected"||!yt.snapshot.ready)return;const e={activeThemeName:n,serverURL:Oe.connection.url,appearance:d7()},r=$1;$1=e,!(!t&&(r==null?void 0:r.activeThemeName)===e.activeThemeName&&r.serverURL===e.serverURL&&r.appearance===e.appearance)&&dN(e.serverURL,e.activeThemeName,()=>yt.listThemes())},sA=()=>{if(!Xn.pending){if(nA=Oe.connection.status,Oe.connection.status!=="connected"){cN(),uN(),fN(),Bd=null,$1=null;return}tA(),u7()}};let x1,P1;const Iv=(n,t)=>{const e=t7(n,t);e!==x1&&(n7(e),x1=e),e!==P1&&Kn&&typeof(so==null?void 0:so.setAppearanceMode)=="function"&&(so.setAppearanceMode(e),P1=e)},ip=()=>{const n=yt.snapshot;if(n.connection.status!=="connected"){x1=void 0,P1=void 0;return}n.ready&&(Iv(n.display.appearanceMode,n.display.activeThemeColorScheme),nA===Oe.connection.status&&(rA(n.display.activeThemeName,n.display.themeJavaScriptConsentIds,!1),iA(n.display.activeThemeName,!1)))},f7=n=>{if(Xn.pending)return;Iv(yt.snapshot.display.appearanceMode,n.activeThemeColorScheme);const t=Bd,e=t!==null&&t.activeThemeName===n.themeName&&!lA(t.consentIds,new Set(n.themeJavaScriptConsentIds));rA(n.themeName,n.themeJavaScriptConsentIds,!0),!(Xn.pending||e)&&(tA(),iA(n.themeName,!0))},p7=n=>{Xn.pending||Iv(n.appearanceMode,yt.snapshot.display.activeThemeColorScheme)};sA();ip();Oe.addEventListener("change",sA);yt.addEventListener("change",ip);yt.addEventListener("theme-changed",f7);yt.addEventListener("appearance-changed",p7);const m7=new MutationObserver(()=>{ip()});m7.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});x8.register("ServerConnectionOwner",()=>Oe);x8.register("ApplicationService",()=>yt);const Kc=globalThis.__telepath??(globalThis.__telepath={});Kc.applicationService=yt;Kc.connectionOwner=Oe;const g7=Kc.renderCompleteCallbacks??(Kc.renderCompleteCallbacks=new Set);Kn&&document.body.classList.add("electron");let l8=!1,c8=!1;const v7=n=>{if(!r7||c8||n!=="connected"&&n!=="no-channel"&&n!=="empty-channel")return;const t=document.querySelector("#settings-popover");t!==null&&(c8=!0,t.setAttribute("open",""))},oA=()=>{l8||(Ag(Yz(yt,{runtimeServerURL:kv,electronMode:Kn,connectionOwner:Oe,primaryServerURL:Tv,updatePresentation:eA,desktopRecommendation:Rv,desktopUpdate:c7,sidebarWidthPreference:s7,sidebarCollapsedPreference:o7,onRenderComplete(n){v7(n);for(const t of g7)t(n)}}),document.body),l8=!0,ip())},aA=()=>{const n=Oe.connection;n.bootState==="pending"&&!n.hasAuthRejected&&Oe.connectError===null||(Oe.removeEventListener("change",aA),oA())};Kn?Oe.addEventListener("change",aA):oA();Oe.connect();function y7(){const n=new URL(window.location.href);return n.searchParams.get("reopenSettings")!=="1"?!1:(n.searchParams.delete("reopenSettings"),window.history.replaceState(window.history.state,"",`${n.pathname}${n.search}${n.hash}`),!0)}function lA(n,t){if(n.size!==t.size)return!1;for(const e of n)if(!t.has(e))return!1;return!0}
848
+ `};const Yz=dn(Jz);function Kz(n,t){return n.kind==="connected"||n.kind==="no-channel"||n.kind==="empty-channel"||n.kind==="disconnected"||n.kind==="error"&&t}function Xz(n){return n.kind!=="connected"&&n.kind!=="no-channel"&&n.kind!=="empty-channel"}const K4="television-appearance-mode";function Qz(n){return n==="system"||n==="light"||n==="dark"}function e7(){try{const n=window.localStorage.getItem(K4);return Qz(n)?n:"system"}catch{return"system"}}function X4(){return window.__televisionAppearanceResolver??hL(e7())}function t7(n,t){return t==="light"||t==="dark"?t:n}function n7(n){X4().setPreference(n);try{window.localStorage.setItem(K4,n)}catch{}}document.documentElement.dataset.tvBundleVersion=cv();Object.defineProperty(window,"__tvVersion",{value:cv(),writable:!1,configurable:!1});X4();const r7=y7(),Kn=wi();Kn?document.documentElement.dataset.platform="electron":delete document.documentElement.dataset.platform;const kv=_$(),Q4=A$(),i7=new bT(Kn?"television-electron":"television-browser",wT()),s7=new JD(window.localStorage),o7=new WD(window.localStorage),a8=PS(),a7=a8?$$({storage:a8,clientApp:Kn?"desktop":"browser",desktopAppVersion:Kn?L6():null}):null,Tv=Cs(Kn?kv:window.location.origin),Rv=eL({search:window.location.search}),Xn=uv(),eA=new oL,Cv=sL({detection:Rv,primaryServerURL:Tv,navigationLatch:Xn,presentation:eA}),Oe=new MD({localStore:i7,serverURL:kv,launchToken:Q4,telemetryMeta:a7,navigationPending:()=>Xn.pending,...Rv.electron?{decideBoot:n=>Cv.decideBoot(n)}:{}}),l7=n=>{lT(yt,n)},yt=new Xk({connectionOwner:Oe,navigationKeyHandler:l7,retainedGateHalted:()=>Cv.gated}),so=globalThis.__televisionNativeBridge;Kn&&so&&so.onNavigationKey(n=>yt.handleNavigationKey(n));const c7=new uL({electron:Kn,bridge:so});if(Q4){const n=new URL(window.location.href);n.searchParams.delete("token"),window.history.replaceState(window.history.state,"",`${n.pathname}${n.search}${n.hash}`)}QD({owner:Oe,primaryServerURL:Tv,navigationLatch:Xn});Cv.attach(Oe);const u7=()=>{const n=Oe.connection;n.status==="connected"&&n.client.artifacts.list().then(({artifacts:t})=>{const e=new Set(t.map(r=>r.id));BD(e)}).catch(()=>{})},tA=()=>{Oe.connection.status==="connected"&&l9(Oe.connection.url)};let Bd=null,$1=null,nA=Oe.connection.status;const h7=()=>{Xn.pending||Xn.begin(()=>{const n=document.querySelector("#settings-popover");if(n!=null&&n.hasAttribute("open")){const t=new URL(window.location.href);t.searchParams.set("reopenSettings","1"),window.history.replaceState(window.history.state,"",`${t.pathname}${t.search}${t.hash}`)}window.location.reload()})},rA=(n,t,e)=>{if(Xn.pending||Oe.connection.status!=="connected"||yt.snapshot.connection.status!=="connected"||!yt.snapshot.ready)return;const r={activeThemeName:n,consentIds:new Set(t)},i=Bd,s=h9(),a=i!==null&&i.activeThemeName!==r.activeThemeName,l=(i==null?void 0:i.activeThemeName)!==null&&(i==null?void 0:i.activeThemeName)!==void 0&&i.consentIds.has(i.activeThemeName),c=r.activeThemeName!==null&&r.consentIds.has(r.activeThemeName),u=i!==null&&!a&&l&&!c,f=i!==null&&lA(i.consentIds,r.consentIds);if(Bd=r,s!==null&&(a||u)){h7();return}if(s===null&&c){_b(Oe.connection.url);return}s!==null&&c&&e&&!a&&f&&_b(Oe.connection.url)},d7=()=>{const n=document.documentElement.dataset.theme;if(n!=="light"&&n!=="dark")throw new Error("Application root has no effective theme-frame appearance");return n},iA=(n,t)=>{if(Xn.pending||Oe.connection.status!=="connected"||yt.snapshot.connection.status!=="connected"||!yt.snapshot.ready)return;const e={activeThemeName:n,serverURL:Oe.connection.url,appearance:d7()},r=$1;$1=e,!(!t&&(r==null?void 0:r.activeThemeName)===e.activeThemeName&&r.serverURL===e.serverURL&&r.appearance===e.appearance)&&d9(e.serverURL,e.activeThemeName,()=>yt.listThemes())},sA=()=>{if(!Xn.pending){if(nA=Oe.connection.status,Oe.connection.status!=="connected"){c9(),u9(),f9(),Bd=null,$1=null;return}tA(),u7()}};let x1,P1;const Iv=(n,t)=>{const e=t7(n,t);e!==x1&&(n7(e),x1=e),e!==P1&&Kn&&typeof(so==null?void 0:so.setAppearanceMode)=="function"&&(so.setAppearanceMode(e),P1=e)},ip=()=>{const n=yt.snapshot;if(n.connection.status!=="connected"){x1=void 0,P1=void 0;return}n.ready&&(Iv(n.display.appearanceMode,n.display.activeThemeColorScheme),nA===Oe.connection.status&&(rA(n.display.activeThemeName,n.display.themeJavaScriptConsentIds,!1),iA(n.display.activeThemeName,!1)))},f7=n=>{if(Xn.pending)return;Iv(yt.snapshot.display.appearanceMode,n.activeThemeColorScheme);const t=Bd,e=t!==null&&t.activeThemeName===n.themeName&&!lA(t.consentIds,new Set(n.themeJavaScriptConsentIds));rA(n.themeName,n.themeJavaScriptConsentIds,!0),!(Xn.pending||e)&&(tA(),iA(n.themeName,!0))},p7=n=>{Xn.pending||Iv(n.appearanceMode,yt.snapshot.display.activeThemeColorScheme)};sA();ip();Oe.addEventListener("change",sA);yt.addEventListener("change",ip);yt.addEventListener("theme-changed",f7);yt.addEventListener("appearance-changed",p7);const m7=new MutationObserver(()=>{ip()});m7.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});x8.register("ServerConnectionOwner",()=>Oe);x8.register("ApplicationService",()=>yt);const Kc=globalThis.__telepath??(globalThis.__telepath={});Kc.applicationService=yt;Kc.connectionOwner=Oe;const g7=Kc.renderCompleteCallbacks??(Kc.renderCompleteCallbacks=new Set);Kn&&document.body.classList.add("electron");let l8=!1,c8=!1;const v7=n=>{if(!r7||c8||n!=="connected"&&n!=="no-channel"&&n!=="empty-channel")return;const t=document.querySelector("#settings-popover");t!==null&&(c8=!0,t.setAttribute("open",""))},oA=()=>{l8||(Ag(Yz(yt,{runtimeServerURL:kv,electronMode:Kn,connectionOwner:Oe,primaryServerURL:Tv,updatePresentation:eA,desktopRecommendation:Rv,desktopUpdate:c7,sidebarWidthPreference:s7,sidebarCollapsedPreference:o7,onRenderComplete(n){v7(n);for(const t of g7)t(n)}}),document.body),l8=!0,ip())},aA=()=>{const n=Oe.connection;n.bootState==="pending"&&!n.hasAuthRejected&&Oe.connectError===null||(Oe.removeEventListener("change",aA),oA())};Kn?Oe.addEventListener("change",aA):oA();Oe.connect();function y7(){const n=new URL(window.location.href);return n.searchParams.get("reopenSettings")!=="1"?!1:(n.searchParams.delete("reopenSettings"),window.history.replaceState(window.history.state,"",`${n.pathname}${n.search}${n.hash}`),!0)}function lA(n,t){if(n.size!==t.size)return!1;for(const e of n)if(!t.has(e))return!1;return!0}