@telepath-computer/television 0.1.40 → 0.1.42

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.
@@ -0,0 +1,468 @@
1
+ var zv=Object.defineProperty;var Eh=n=>{throw TypeError(n)};var Lv=(n,e,t)=>e in n?zv(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var b=(n,e,t)=>Lv(n,typeof e!="symbol"?e+"":e,t),ol=(n,e,t)=>e.has(n)||Eh("Cannot "+t);var l=(n,e,t)=>(ol(n,e,"read from private field"),t?t.call(n):e.get(n)),_=(n,e,t)=>e.has(n)?Eh("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),E=(n,e,t,r)=>(ol(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),m=(n,e,t)=>(ol(n,e,"access private method"),t);var $h=(n,e,t,r)=>({set _(i){E(n,e,i,t)},get _(){return l(n,e,r)}});(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function t(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=t(i);fetch(i.href,s)}})();var In=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Mv(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),t}var Ah=Object.prototype.toString,up=function(e){var t=Ah.call(e),r=t==="[object Arguments]";return r||(r=t!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Ah.call(e.callee)==="[object Function]"),r},al,xh;function Nv(){if(xh)return al;xh=1;var n;if(!Object.keys){var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,r=up,i=Object.prototype.propertyIsEnumerable,s=!i.call({toString:null},"toString"),o=i.call(function(){},"prototype"),a=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],c=function(v){var y=v.constructor;return y&&y.prototype===v},u={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},d=function(){if(typeof window>"u")return!1;for(var v in window)try{if(!u["$"+v]&&e.call(window,v)&&window[v]!==null&&typeof window[v]=="object")try{c(window[v])}catch{return!0}}catch{return!0}return!1}(),f=function(v){if(typeof window>"u"||!d)return c(v);try{return c(v)}catch{return!1}};n=function(y){var A=y!==null&&typeof y=="object",k=t.call(y)==="[object Function]",I=r(y),B=A&&t.call(y)==="[object String]",P=[];if(!A&&!k&&!I)throw new TypeError("Object.keys called on a non-object");var le=o&&k;if(B&&y.length>0&&!e.call(y,0))for(var M=0;M<y.length;++M)P.push(String(M));if(I&&y.length>0)for(var Z=0;Z<y.length;++Z)P.push(String(Z));else for(var U in y)!(le&&U==="prototype")&&e.call(y,U)&&P.push(String(U));if(s)for(var ge=f(y),ce=0;ce<a.length;++ce)!(ge&&a[ce]==="constructor")&&e.call(y,a[ce])&&P.push(a[ce]);return P}}return al=n,al}var Uv=Array.prototype.slice,Fv=up,Th=Object.keys,Po=Th?function(e){return Th(e)}:Nv(),Ch=Object.keys;Po.shim=function(){if(Object.keys){var e=function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2);e||(Object.keys=function(r){return Fv(r)?Ch(Uv.call(r)):Ch(r)})}else Object.keys=Po;return Object.keys||Po};var Zv=Po,Ro=Object.defineProperty||!1;if(Ro)try{Ro({},"a",{value:1})}catch{Ro=!1}var Hs=Ro,qt=SyntaxError,G=TypeError,Hv=Object.getOwnPropertyDescriptor,Do=Hv;if(Do)try{Do([],"length")}catch{Do=null}var ii=Do,Ih=Hs,Vv=qt,yr=G,Ph=ii,hp=function(e,t,r){if(!e||typeof e!="object"&&typeof e!="function")throw new yr("`obj` must be an object or a function`");if(typeof t!="string"&&typeof t!="symbol")throw new yr("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new yr("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new yr("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new yr("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new yr("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,c=!!Ph&&Ph(e,t);if(Ih)Ih(e,t,{configurable:o===null&&c?c.configurable:!o,enumerable:i===null&&c?c.enumerable:!i,value:r,writable:s===null&&c?c.writable:!s});else if(a||!i&&!s&&!o)e[t]=r;else throw new Vv("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Kl=Hs,dp=function(){return!!Kl};dp.hasArrayLengthDefineBug=function(){if(!Kl)return null;try{return Kl([],"length",{value:1}).length!==1}catch{return!0}};var Ca=dp,jv=Zv,Bv=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Gv=Object.prototype.toString,Wv=Array.prototype.concat,Rh=hp,qv=function(n){return typeof n=="function"&&Gv.call(n)==="[object Function]"},fp=Ca(),Yv=function(n,e,t,r){if(e in n){if(r===!0){if(n[e]===t)return}else if(!qv(r)||!r())return}fp?Rh(n,e,t,!0):Rh(n,e,t)},pp=function(n,e){var t=arguments.length>2?arguments[2]:{},r=jv(e);Bv&&(r=Wv.call(r,Object.getOwnPropertySymbols(e)));for(var i=0;i<r.length;i+=1)Yv(n,r[i],e[r[i]],t[r[i]])};pp.supportsDescriptors=!!fp;var ar=pp,Oo={exports:{}};typeof self<"u"?Oo.exports=self:typeof window<"u"?Oo.exports=window:Oo.exports=Function("return this")();var gp=Oo.exports,Kv=gp,mp=function(){return typeof In!="object"||!In||In.Math!==Math||In.Array!==Array?Kv:In},Jv=ar,Xv=ii,Qv=mp,eb=function(){var e=Qv();if(Jv.supportsDescriptors){var t=Xv(e,"globalThis");(!t||t.configurable&&(t.enumerable||!t.writable||globalThis!==e))&&Object.defineProperty(e,"globalThis",{configurable:!0,enumerable:!1,value:e,writable:!0})}else(typeof globalThis!="object"||globalThis!==e)&&(e.globalThis=e);return e},tb=ar,nb=gp,yp=mp,rb=eb,ib=yp(),vp=function(){return ib};tb(vp,{getPolyfill:yp,implementation:nb,shim:rb});var Jc=vp,Yt=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},Xc=Object,bp=Error,sb=EvalError,ob=RangeError,Qc=ReferenceError,ab=URIError,lb=Math.abs,cb=Math.floor,ub=Math.max,hb=Math.min,db=Math.pow,fb=Math.round,eu=Number.isNaN||function(e){return e!==e},pb=eu,gb=function(e){return pb(e)||e===0?e:e<0?-1:1},si=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},t=Symbol("test"),r=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var i=42;e[t]=i;for(var s in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,t);if(a.value!==i||a.enumerable!==!0)return!1}return!0},Dh=typeof Symbol<"u"&&Symbol,mb=si,tu=function(){return typeof Dh!="function"||typeof Symbol!="function"||typeof Dh("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:mb()},wp=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,yb=Xc,_p=yb.getPrototypeOf||null,vb="Function.prototype.bind called on incompatible ",bb=Object.prototype.toString,wb=Math.max,_b="[object Function]",Oh=function(e,t){for(var r=[],i=0;i<e.length;i+=1)r[i]=e[i];for(var s=0;s<t.length;s+=1)r[s+e.length]=t[s];return r},Sb=function(e,t){for(var r=[],i=t,s=0;i<e.length;i+=1,s+=1)r[s]=e[i];return r},kb=function(n,e){for(var t="",r=0;r<n.length;r+=1)t+=n[r],r+1<n.length&&(t+=e);return t},Eb=function(e){var t=this;if(typeof t!="function"||bb.apply(t)!==_b)throw new TypeError(vb+t);for(var r=Sb(arguments,1),i,s=function(){if(this instanceof i){var d=t.apply(this,Oh(r,arguments));return Object(d)===d?d:this}return t.apply(e,Oh(r,arguments))},o=wb(0,t.length-r.length),a=[],c=0;c<o;c++)a[c]="$"+c;if(i=Function("binder","return function ("+kb(a,",")+"){ return binder.apply(this,arguments); }")(s),t.prototype){var u=function(){};u.prototype=t.prototype,i.prototype=new u,u.prototype=null}return i},$b=Eb,Vs=Function.prototype.bind||$b,nu=Function.prototype.call,ru=Function.prototype.apply,Ab=typeof Reflect<"u"&&Reflect&&Reflect.apply,xb=Vs,Tb=ru,Cb=nu,Ib=Ab,Sp=Ib||xb.call(Cb,Tb),Pb=Vs,Rb=G,Db=nu,Ob=Sp,Ia=function(e){if(e.length<1||typeof e[0]!="function")throw new Rb("a function is required");return Ob(Pb,Db,e)},zb=Ia,zh=ii,kp;try{kp=[].__proto__===Array.prototype}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var ll=!!kp&&zh&&zh(Object.prototype,"__proto__"),Ep=Object,Lh=Ep.getPrototypeOf,Lb=ll&&typeof ll.get=="function"?zb([ll.get]):typeof Lh=="function"?function(e){return Lh(e==null?e:Ep(e))}:!1,Mh=wp,Nh=_p,Uh=Lb,$p=Mh?function(e){return Mh(e)}:Nh?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return Nh(e)}:Uh?function(e){return Uh(e)}:null,Mb=Function.prototype.call,Nb=Object.prototype.hasOwnProperty,Ub=Vs,Kt=Ub.call(Mb,Nb),j,Fb=Xc,Zb=bp,Hb=sb,Vb=ob,jb=Qc,Jr=qt,Pr=G,Bb=ab,Gb=lb,Wb=cb,qb=ub,Yb=hb,Kb=db,Jb=fb,Xb=gb,Ap=Function,cl=function(n){try{return Ap('"use strict"; return ('+n+").constructor;")()}catch{}},Ki=ii,Qb=Hs,ul=function(){throw new Pr},ew=Ki?function(){try{return arguments.callee,ul}catch{try{return Ki(arguments,"callee").get}catch{return ul}}}():ul,vr=tu(),Se=$p,tw=_p,nw=wp,xp=ru,js=nu,_r={},rw=typeof Uint8Array>"u"||!Se?j:Se(Uint8Array),er={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?j:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?j:ArrayBuffer,"%ArrayIteratorPrototype%":vr&&Se?Se([][Symbol.iterator]()):j,"%AsyncFromSyncIteratorPrototype%":j,"%AsyncFunction%":_r,"%AsyncGenerator%":_r,"%AsyncGeneratorFunction%":_r,"%AsyncIteratorPrototype%":_r,"%Atomics%":typeof Atomics>"u"?j:Atomics,"%BigInt%":typeof BigInt>"u"?j:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?j:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?j:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?j:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Zb,"%eval%":eval,"%EvalError%":Hb,"%Float16Array%":typeof Float16Array>"u"?j:Float16Array,"%Float32Array%":typeof Float32Array>"u"?j:Float32Array,"%Float64Array%":typeof Float64Array>"u"?j:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?j:FinalizationRegistry,"%Function%":Ap,"%GeneratorFunction%":_r,"%Int8Array%":typeof Int8Array>"u"?j:Int8Array,"%Int16Array%":typeof Int16Array>"u"?j:Int16Array,"%Int32Array%":typeof Int32Array>"u"?j:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":vr&&Se?Se(Se([][Symbol.iterator]())):j,"%JSON%":typeof JSON=="object"?JSON:j,"%Map%":typeof Map>"u"?j:Map,"%MapIteratorPrototype%":typeof Map>"u"||!vr||!Se?j:Se(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Fb,"%Object.getOwnPropertyDescriptor%":Ki,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?j:Promise,"%Proxy%":typeof Proxy>"u"?j:Proxy,"%RangeError%":Vb,"%ReferenceError%":jb,"%Reflect%":typeof Reflect>"u"?j:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?j:Set,"%SetIteratorPrototype%":typeof Set>"u"||!vr||!Se?j:Se(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?j:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":vr&&Se?Se(""[Symbol.iterator]()):j,"%Symbol%":vr?Symbol:j,"%SyntaxError%":Jr,"%ThrowTypeError%":ew,"%TypedArray%":rw,"%TypeError%":Pr,"%Uint8Array%":typeof Uint8Array>"u"?j:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?j:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?j:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?j:Uint32Array,"%URIError%":Bb,"%WeakMap%":typeof WeakMap>"u"?j:WeakMap,"%WeakRef%":typeof WeakRef>"u"?j:WeakRef,"%WeakSet%":typeof WeakSet>"u"?j:WeakSet,"%Function.prototype.call%":js,"%Function.prototype.apply%":xp,"%Object.defineProperty%":Qb,"%Object.getPrototypeOf%":tw,"%Math.abs%":Gb,"%Math.floor%":Wb,"%Math.max%":qb,"%Math.min%":Yb,"%Math.pow%":Kb,"%Math.round%":Jb,"%Math.sign%":Xb,"%Reflect.getPrototypeOf%":nw};if(Se)try{null.error}catch(n){var iw=Se(Se(n));er["%Error.prototype%"]=iw}var sw=function n(e){var t;if(e==="%AsyncFunction%")t=cl("async function () {}");else if(e==="%GeneratorFunction%")t=cl("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=cl("async function* () {}");else if(e==="%AsyncGenerator%"){var r=n("%AsyncGeneratorFunction%");r&&(t=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=n("%AsyncGenerator%");i&&Se&&(t=Se(i.prototype))}return er[e]=t,t},Fh={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},Bs=Vs,Go=Kt,ow=Bs.call(js,Array.prototype.concat),aw=Bs.call(xp,Array.prototype.splice),Zh=Bs.call(js,String.prototype.replace),Wo=Bs.call(js,String.prototype.slice),lw=Bs.call(js,RegExp.prototype.exec),cw=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,uw=/\\(\\)?/g,hw=function(e){var t=Wo(e,0,1),r=Wo(e,-1);if(t==="%"&&r!=="%")throw new Jr("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&t!=="%")throw new Jr("invalid intrinsic syntax, expected opening `%`");var i=[];return Zh(e,cw,function(s,o,a,c){i[i.length]=a?Zh(c,uw,"$1"):o||s}),i},dw=function(e,t){var r=e,i;if(Go(Fh,r)&&(i=Fh[r],r="%"+i[0]+"%"),Go(er,r)){var s=er[r];if(s===_r&&(s=sw(r)),typeof s>"u"&&!t)throw new Pr("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:s}}throw new Jr("intrinsic "+e+" does not exist!")},st=function(e,t){if(typeof e!="string"||e.length===0)throw new Pr("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof t!="boolean")throw new Pr('"allowMissing" argument must be a boolean');if(lw(/^%?[^%]*%?$/,e)===null)throw new Jr("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=hw(e),i=r.length>0?r[0]:"",s=dw("%"+i+"%",t),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],aw(r,ow([0,1],u)));for(var d=1,f=!0;d<r.length;d+=1){var v=r[d],y=Wo(v,0,1),A=Wo(v,-1);if((y==='"'||y==="'"||y==="`"||A==='"'||A==="'"||A==="`")&&y!==A)throw new Jr("property names with quotes must have matching quotes");if((v==="constructor"||!f)&&(c=!0),i+="."+v,o="%"+i+"%",Go(er,o))a=er[o];else if(a!=null){if(!(v in a)){if(!t)throw new Pr("base intrinsic for "+e+" exists, but the property is not available.");return}if(Ki&&d+1>=r.length){var k=Ki(a,v);f=!!k,f&&"get"in k&&!("originalValue"in k.get)?a=k.get:a=a[v]}else f=Go(a,v),a=a[v];f&&!c&&(er[o]=a)}}return a},Tp=st,Cp=Ia,fw=Cp([Tp("%String.prototype.indexOf%")]),bn=function(e,t){var r=Tp(e,!!t);return typeof r=="function"&&fw(e,".prototype.")>-1?Cp([r]):r},hl,Hh;function iu(){if(Hh)return hl;Hh=1;var n=st,e=n("%Array%"),t=!e.isArray&&bn("Object.prototype.toString");return hl=e.isArray||function(i){return t(i)==="[object Array]"},hl}var pw=Ca,Vh=Hs,Ip=pw.hasArrayLengthDefineBug(),gw=Ip&&iu(),mw=bn,yw=mw("Object.prototype.propertyIsEnumerable"),su=function(e,t,r,i,s,o){if(!Vh){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&yw(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,t(i[s],a)}return Ip&&s==="length"&&"[[Value]]"in o&&gw(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(Vh(i,s,r(o)),!0)},vw=G,_i=Kt,bw={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},oi=function(e){if(!e||typeof e!="object")return!1;for(var t in e)if(_i(e,t)&&!bw[t])return!1;var r=_i(e,"[[Value]]")||_i(e,"[[Writable]]"),i=_i(e,"[[Get]]")||_i(e,"[[Set]]");if(r&&i)throw new vw("Property Descriptors may not be both accessor and data descriptors");return!0},Pp=function(e){if(typeof e>"u")return e;var t={};return"[[Value]]"in e&&(t.value=e["[[Value]]"]),"[[Writable]]"in e&&(t.writable=!!e["[[Writable]]"]),"[[Get]]"in e&&(t.get=e["[[Get]]"]),"[[Set]]"in e&&(t.set=e["[[Set]]"]),"[[Enumerable]]"in e&&(t.enumerable=!!e["[[Enumerable]]"]),"[[Configurable]]"in e&&(t.configurable=!!e["[[Configurable]]"]),t},ww=G,_w=oi,Sw=Pp,Rp=function(e){if(typeof e<"u"&&!_w(e))throw new ww("Assertion failed: `Desc` must be a Property Descriptor");return Sw(e)},kw=G,jh=Kt,Ew=oi,Dp=function(e){if(typeof e>"u")return!1;if(!Ew(e))throw new kw("Assertion failed: `Desc` must be a Property Descriptor");return!(!jh(e,"[[Value]]")&&!jh(e,"[[Writable]]"))},ai=function(e){return typeof e=="string"||typeof e=="symbol"},Bh=eu,Op=function(e,t){return e===t?e===0?1/e===1/t:!0:Bh(e)&&Bh(t)},Gh=G,$w=Yt,Aw=su,xw=Rp,Tw=Dp,Cw=ai,Iw=Op,ou=function(e,t,r){if(!$w(e))throw new Gh("Assertion failed: Type(O) is not Object");if(!Cw(t))throw new Gh("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return Aw(Tw,Iw,xw,e,t,i)},zp=Function.prototype.toString,Tr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,Jl,zo;if(typeof Tr=="function"&&typeof Object.defineProperty=="function")try{Jl=Object.defineProperty({},"length",{get:function(){throw zo}}),zo={},Tr(function(){throw 42},null,Jl)}catch(n){n!==zo&&(Tr=null)}else Tr=null;var Pw=/^\s*class\b/,Xl=function(e){try{var t=zp.call(e);return Pw.test(t)}catch{return!1}},dl=function(e){try{return Xl(e)?!1:(zp.call(e),!0)}catch{return!1}},Lo=Object.prototype.toString,Rw="[object Object]",Dw="[object Function]",Ow="[object GeneratorFunction]",zw="[object HTMLAllCollection]",Lw="[object HTML document.all class]",Mw="[object HTMLCollection]",Nw=typeof Symbol=="function"&&!!Symbol.toStringTag,Uw=!(0 in[,]),Ql=function(){return!1};if(typeof document=="object"){var Fw=document.all;Lo.call(Fw)===Lo.call(document.all)&&(Ql=function(e){if((Uw||!e)&&(typeof e>"u"||typeof e=="object"))try{var t=Lo.call(e);return(t===zw||t===Lw||t===Mw||t===Rw)&&e("")==null}catch{}return!1})}var Lp=Tr?function(e){if(Ql(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{Tr(e,null,Jl)}catch(t){if(t!==zo)return!1}return!Xl(e)&&dl(e)}:function(e){if(Ql(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(Nw)return dl(e);if(Xl(e))return!1;var t=Lo.call(e);return t!==Dw&&t!==Ow&&!/^\[object HTML/.test(t)?!1:dl(e)},Zw=Lp,Hw=function(e){return!!e},bt=Kt,ho=G,Vw=Yt,Wh=Zw,fl=Hw,jw=function(e){if(!Vw(e))throw new ho("ToPropertyDescriptor requires an object");var t={};if(bt(e,"enumerable")&&(t["[[Enumerable]]"]=fl(e.enumerable)),bt(e,"configurable")&&(t["[[Configurable]]"]=fl(e.configurable)),bt(e,"value")&&(t["[[Value]]"]=e.value),bt(e,"writable")&&(t["[[Writable]]"]=fl(e.writable)),bt(e,"get")){var r=e.get;if(typeof r<"u"&&!Wh(r))throw new ho("getter must be a function");t["[[Get]]"]=r}if(bt(e,"set")){var i=e.set;if(typeof i<"u"&&!Wh(i))throw new ho("setter must be a function");t["[[Set]]"]=i}if((bt(t,"[[Get]]")||bt(t,"[[Set]]"))&&(bt(t,"[[Value]]")||bt(t,"[[Writable]]")))throw new ho("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},pl=G,Bw=Yt,qh=oi,Gw=su,Ww=Rp,qw=Dp,Yw=ai,Kw=Op,Jw=jw,Xw=function(e,t,r){if(!Bw(e))throw new pl("Assertion failed: Type(O) is not Object");if(!Yw(t))throw new pl("Assertion failed: P is not a Property Key");var i=qh(r)?r:Jw(r);if(!qh(i))throw new pl("Assertion failed: Desc is not a valid Property Descriptor");return Gw(qw,Kw,Ww,e,t,i)},Yh=G,Qw=Yt,e_=Xw,t_=ai,n_=function(e,t,r){if(!Qw(e))throw new Yh("Assertion failed: Type(O) is not Object");if(!t_(t))throw new Yh("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return e_(e,t,i)},r_=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,i_=Xc,s_=i_.setPrototypeOf||null,o_=Ia,Kh=ii,a_=G,Mp={};try{Mp.__proto__=null}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var l_=!("toString"in Mp),gl=Kh&&Kh(Object.prototype,"__proto__"),c_=l_&&(!!gl&&typeof gl.set=="function"&&o_([gl.set])||function(e,t){if(e==null)throw new a_("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=t,t}),Jh=r_,u_=s_,Xh=c_,h_=G,d_=Jh?function(e,t){if(Jh(e,t))return e;throw new h_("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:u_||(Xh?function(e,t){return Xh(e,t),e}:null),Qh=G,f_=Yt,ed=$p,p_=function(e){if(!f_(e))throw new Qh("Assertion failed: O must be an Object");if(!ed)throw new Qh("This environment does not support fetching prototypes.");return ed(e)},g_=G,m_=d_,y_=Yt,v_=p_,b_=function(e,t){if(t!==null&&!y_(t))throw new g_("Assertion failed: V must be Object or Null");try{m_(e,t)}catch{return!1}return v_(e)===t},ml=ou,td=n_,Np=b_,w_=Ca(),au=bp;function Gs(n,e,t){var r=new au(t);return Np(r,Mo),delete r.constructor,td(r,"error",n),td(r,"suppressed",e),r}w_&&Object.defineProperty(Gs,"prototype",{writable:!1});var Mo=Gs.prototype;if(!ml(Mo,"constructor",Gs)||!ml(Mo,"message","")||!ml(Mo,"name","SuppressedError"))throw new au("unable to install SuppressedError.prototype properties; please report this!");Np(Gs.prototype,au.prototype);var __=Gs,S_=__,Up=function(){return typeof SuppressedError=="function"?SuppressedError:S_},k_=ar,nd=Jc(),E_=Up,$_=function(){var e=E_();return k_(nd,{SuppressedError:e},{SuppressedError:function(){return nd.SuppressedError!==e}}),e};$_();var A_=G,x_=oi,T_=Pp,C_=function(e){if(typeof e<"u"&&!x_(e))throw new A_("Assertion failed: `Desc` must be a Property Descriptor");return T_(e)},I_=G,rd=Kt,P_=oi,R_=function(e){if(typeof e>"u")return!1;if(!P_(e))throw new I_("Assertion failed: `Desc` must be a Property Descriptor");return!(!rd(e,"[[Value]]")&&!rd(e,"[[Writable]]"))},id=eu,D_=function(e,t){return e===t?e===0?1/e===1/t:!0:id(e)&&id(t)},li=Lp,O_=function(e){return!!e},wt=Kt,fo=G,z_=Yt,sd=li,yl=O_,L_=function(e){if(!z_(e))throw new fo("ToPropertyDescriptor requires an object");var t={};if(wt(e,"enumerable")&&(t["[[Enumerable]]"]=yl(e.enumerable)),wt(e,"configurable")&&(t["[[Configurable]]"]=yl(e.configurable)),wt(e,"value")&&(t["[[Value]]"]=e.value),wt(e,"writable")&&(t["[[Writable]]"]=yl(e.writable)),wt(e,"get")){var r=e.get;if(typeof r<"u"&&!sd(r))throw new fo("getter must be a function");t["[[Get]]"]=r}if(wt(e,"set")){var i=e.set;if(typeof i<"u"&&!sd(i))throw new fo("setter must be a function");t["[[Set]]"]=i}if((wt(t,"[[Get]]")||wt(t,"[[Set]]"))&&(wt(t,"[[Value]]")||wt(t,"[[Writable]]")))throw new fo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},vl=G,M_=Yt,od=oi,N_=su,U_=C_,F_=R_,Z_=ai,H_=D_,V_=L_,Ws=function(e,t,r){if(!M_(e))throw new vl("Assertion failed: Type(O) is not Object");if(!Z_(t))throw new vl("Assertion failed: P is not a Property Key");var i=od(r)?r:V_(r);if(!od(i))throw new vl("Assertion failed: Desc is not a valid Property Descriptor");return N_(F_,H_,U_,e,t,i)},j_=si(),B_=j_?Symbol.dispose||Symbol("Symbol.dispose"):null,G_=si,W_=B_,lu=function(){return G_()&&Symbol.dispose||W_},q_=tu,Y_=Ws,K_=lu,J_=function(){var e=K_();return q_()&&Y_(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},X_=si(),Q_=X_?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,eS=si,tS=Q_,cu=function(){return eS()&&Symbol.asyncDispose||tS},nS=tu,rS=Ws,iS=cu,sS=function(){var e=iS();return nS()&&rS(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},oS=iu(),aS=st,lS=bn,cS=G,uS=oS,hS=aS("%Reflect.apply%",!0)||lS("Function.prototype.apply"),Pa=function(e,t){var r=arguments.length>2?arguments[2]:[];if(!uS(r))throw new cS("Assertion failed: optional `argumentsList`, if provided, must be a List");return hS(e,t,r)};const dS={},fS=Object.freeze(Object.defineProperty({__proto__:null,default:dS},Symbol.toStringTag,{value:"Module"})),pS=Mv(fS);var uu=typeof Map=="function"&&Map.prototype,bl=Object.getOwnPropertyDescriptor&&uu?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,qo=uu&&bl&&typeof bl.get=="function"?bl.get:null,ad=uu&&Map.prototype.forEach,hu=typeof Set=="function"&&Set.prototype,wl=Object.getOwnPropertyDescriptor&&hu?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Yo=hu&&wl&&typeof wl.get=="function"?wl.get:null,ld=hu&&Set.prototype.forEach,gS=typeof WeakMap=="function"&&WeakMap.prototype,ji=gS?WeakMap.prototype.has:null,mS=typeof WeakSet=="function"&&WeakSet.prototype,Bi=mS?WeakSet.prototype.has:null,yS=typeof WeakRef=="function"&&WeakRef.prototype,cd=yS?WeakRef.prototype.deref:null,vS=Boolean.prototype.valueOf,bS=Object.prototype.toString,wS=Function.prototype.toString,_S=String.prototype.match,du=String.prototype.slice,hn=String.prototype.replace,SS=String.prototype.toUpperCase,ud=String.prototype.toLowerCase,Fp=RegExp.prototype.test,hd=Array.prototype.concat,Tt=Array.prototype.join,kS=Array.prototype.slice,dd=Math.floor,ec=typeof BigInt=="function"?BigInt.prototype.valueOf:null,_l=Object.getOwnPropertySymbols,tc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Xr=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Gi=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Xr||!0)?Symbol.toStringTag:null,Zp=Object.prototype.propertyIsEnumerable,fd=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(n){return n.__proto__}:null);function pd(n,e){if(n===1/0||n===-1/0||n!==n||n&&n>-1e3&&n<1e3||Fp.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof n=="number"){var r=n<0?-dd(-n):dd(n);if(r!==n){var i=String(r),s=du.call(e,i.length+1);return hn.call(i,t,"$&_")+"."+hn.call(hn.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return hn.call(e,t,"$&_")}var nc=pS,gd=nc.custom,md=jp(gd)?gd:null,Hp={__proto__:null,double:'"',single:"'"},ES={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},ci=function n(e,t,r,i){var s=t||{};if(Lt(s,"quoteStyle")&&!Lt(Hp,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Lt(s,"maxStringLength")&&(typeof s.maxStringLength=="number"?s.maxStringLength<0&&s.maxStringLength!==1/0:s.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=Lt(s,"customInspect")?s.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Lt(s,"indent")&&s.indent!==null&&s.indent!==" "&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Lt(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=s.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return Gp(e,s);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var c=String(e);return a?pd(e,c):c}if(typeof e=="bigint"){var u=String(e)+"n";return a?pd(e,u):u}var d=typeof s.depth>"u"?5:s.depth;if(typeof r>"u"&&(r=0),r>=d&&d>0&&typeof e=="object")return rc(e)?"[Array]":"[Object]";var f=HS(s,r);if(typeof i>"u")i=[];else if(Bp(i,e)>=0)return"[Circular]";function v(mt,Xt,qa){if(Xt&&(i=kS.call(i),i.push(Xt)),qa){var no={depth:s.depth};return Lt(s,"quoteStyle")&&(no.quoteStyle=s.quoteStyle),n(mt,no,r+1,i)}return n(mt,s,r+1,i)}if(typeof e=="function"&&!yd(e)){var y=DS(e),A=po(e,v);return"[Function"+(y?": "+y:" (anonymous)")+"]"+(A.length>0?" { "+Tt.call(A,", ")+" }":"")}if(jp(e)){var k=Xr?hn.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):tc.call(e);return typeof e=="object"&&!Xr?Si(k):k}if(US(e)){for(var I="<"+ud.call(String(e.nodeName)),B=e.attributes||[],P=0;P<B.length;P++)I+=" "+B[P].name+"="+Vp($S(B[P].value),"double",s);return I+=">",e.childNodes&&e.childNodes.length&&(I+="..."),I+="</"+ud.call(String(e.nodeName))+">",I}if(rc(e)){if(e.length===0)return"[]";var le=po(e,v);return f&&!ZS(le)?"["+ic(le,f)+"]":"[ "+Tt.call(le,", ")+" ]"}if(xS(e)){var M=po(e,v);return!("cause"in Error.prototype)&&"cause"in e&&!Zp.call(e,"cause")?"{ ["+String(e)+"] "+Tt.call(hd.call("[cause]: "+v(e.cause),M),", ")+" }":M.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+Tt.call(M,", ")+" }"}if(typeof e=="object"&&o){if(md&&typeof e[md]=="function"&&nc)return nc(e,{depth:d-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(OS(e)){var Z=[];return ad&&ad.call(e,function(mt,Xt){Z.push(v(Xt,e,!0)+" => "+v(mt,e))}),vd("Map",qo.call(e),Z,f)}if(MS(e)){var U=[];return ld&&ld.call(e,function(mt){U.push(v(mt,e))}),vd("Set",Yo.call(e),U,f)}if(zS(e))return Sl("WeakMap");if(NS(e))return Sl("WeakSet");if(LS(e))return Sl("WeakRef");if(CS(e))return Si(v(Number(e)));if(PS(e))return Si(v(ec.call(e)));if(IS(e))return Si(vS.call(e));if(TS(e))return Si(v(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof In<"u"&&e===In)return"{ [object globalThis] }";if(!AS(e)&&!yd(e)){var ge=po(e,v),ce=fd?fd(e)===Object.prototype:e instanceof Object||e.constructor===Object,yi=e instanceof Object?"":"null prototype",to=!ce&&Gi&&Object(e)===e&&Gi in e?du.call(wn(e),8,-1):yi?"Object":"",$e=ce||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",kn=$e+(to||yi?"["+Tt.call(hd.call([],to||[],yi||[]),": ")+"] ":"");return ge.length===0?kn+"{}":f?kn+"{"+ic(ge,f)+"}":kn+"{ "+Tt.call(ge,", ")+" }"}return String(e)};function Vp(n,e,t){var r=t.quoteStyle||e,i=Hp[r];return i+n+i}function $S(n){return hn.call(String(n),/"/g,"&quot;")}function lr(n){return!Gi||!(typeof n=="object"&&(Gi in n||typeof n[Gi]<"u"))}function rc(n){return wn(n)==="[object Array]"&&lr(n)}function AS(n){return wn(n)==="[object Date]"&&lr(n)}function yd(n){return wn(n)==="[object RegExp]"&&lr(n)}function xS(n){return wn(n)==="[object Error]"&&lr(n)}function TS(n){return wn(n)==="[object String]"&&lr(n)}function CS(n){return wn(n)==="[object Number]"&&lr(n)}function IS(n){return wn(n)==="[object Boolean]"&&lr(n)}function jp(n){if(Xr)return n&&typeof n=="object"&&n instanceof Symbol;if(typeof n=="symbol")return!0;if(!n||typeof n!="object"||!tc)return!1;try{return tc.call(n),!0}catch{}return!1}function PS(n){if(!n||typeof n!="object"||!ec)return!1;try{return ec.call(n),!0}catch{}return!1}var RS=Object.prototype.hasOwnProperty||function(n){return n in this};function Lt(n,e){return RS.call(n,e)}function wn(n){return bS.call(n)}function DS(n){if(n.name)return n.name;var e=_S.call(wS.call(n),/^function\s*([\w$]+)/);return e?e[1]:null}function Bp(n,e){if(n.indexOf)return n.indexOf(e);for(var t=0,r=n.length;t<r;t++)if(n[t]===e)return t;return-1}function OS(n){if(!qo||!n||typeof n!="object")return!1;try{qo.call(n);try{Yo.call(n)}catch{return!0}return n instanceof Map}catch{}return!1}function zS(n){if(!ji||!n||typeof n!="object")return!1;try{ji.call(n,ji);try{Bi.call(n,Bi)}catch{return!0}return n instanceof WeakMap}catch{}return!1}function LS(n){if(!cd||!n||typeof n!="object")return!1;try{return cd.call(n),!0}catch{}return!1}function MS(n){if(!Yo||!n||typeof n!="object")return!1;try{Yo.call(n);try{qo.call(n)}catch{return!0}return n instanceof Set}catch{}return!1}function NS(n){if(!Bi||!n||typeof n!="object")return!1;try{Bi.call(n,Bi);try{ji.call(n,ji)}catch{return!0}return n instanceof WeakSet}catch{}return!1}function US(n){return!n||typeof n!="object"?!1:typeof HTMLElement<"u"&&n instanceof HTMLElement?!0:typeof n.nodeName=="string"&&typeof n.getAttribute=="function"}function Gp(n,e){if(n.length>e.maxStringLength){var t=n.length-e.maxStringLength,r="... "+t+" more character"+(t>1?"s":"");return Gp(du.call(n,0,e.maxStringLength),e)+r}var i=ES[e.quoteStyle||"single"];i.lastIndex=0;var s=hn.call(hn.call(n,i,"\\$1"),/[\x00-\x1f]/g,FS);return Vp(s,"single",e)}function FS(n){var e=n.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+SS.call(e.toString(16))}function Si(n){return"Object("+n+")"}function Sl(n){return n+" { ? }"}function vd(n,e,t,r){var i=r?ic(t,r):Tt.call(t,", ");return n+" ("+e+") {"+i+"}"}function ZS(n){for(var e=0;e<n.length;e++)if(Bp(n[e],`
2
+ `)>=0)return!1;return!0}function HS(n,e){var t;if(n.indent===" ")t=" ";else if(typeof n.indent=="number"&&n.indent>0)t=Tt.call(Array(n.indent+1)," ");else return null;return{base:t,prev:Tt.call(Array(e+1),t)}}function ic(n,e){if(n.length===0)return"";var t=`
3
+ `+e.prev+e.base;return t+Tt.call(n,","+t)+`
4
+ `+e.prev}function po(n,e){var t=rc(n),r=[];if(t){r.length=n.length;for(var i=0;i<n.length;i++)r[i]=Lt(n,i)?e(n[i],n):""}var s=typeof _l=="function"?_l(n):[],o;if(Xr){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in n)Lt(n,c)&&(t&&String(Number(c))===c&&c<n.length||Xr&&o["$"+c]instanceof Symbol||(Fp.call(/[^\w$]/,c)?r.push(e(c,n)+": "+e(n[c],n)):r.push(c+": "+e(n[c],n))));if(typeof _l=="function")for(var u=0;u<s.length;u++)Zp.call(n,s[u])&&r.push("["+e(s[u])+"]: "+e(n[s[u]],n));return r}var VS=ci,jS=G,Ra=function(n,e,t){for(var r=n,i;(i=r.next)!=null;r=i)if(i.key===e)return r.next=i.next,t||(i.next=n.next,n.next=i),i},BS=function(n,e){if(n){var t=Ra(n,e);return t&&t.value}},GS=function(n,e,t){var r=Ra(n,e);r?r.value=t:n.next={key:e,next:n.next,value:t}},WS=function(n,e){return n?!!Ra(n,e):!1},qS=function(n,e){if(n)return Ra(n,e,!0)},YS=function(){var e,t={assert:function(r){if(!t.has(r))throw new jS("Side channel does not contain "+VS(r))},delete:function(r){var i=e&&e.next,s=qS(e,r);return s&&i&&i===s&&(e=void 0),!!s},get:function(r){return BS(e,r)},has:function(r){return WS(e,r)},set:function(r,i){e||(e={next:void 0}),GS(e,r,i)}};return t},KS=st,qs=bn,JS=ci,XS=G,bd=KS("%Map%",!0),QS=qs("Map.prototype.get",!0),ek=qs("Map.prototype.set",!0),tk=qs("Map.prototype.has",!0),nk=qs("Map.prototype.delete",!0),rk=qs("Map.prototype.size",!0),Wp=!!bd&&function(){var e,t={assert:function(r){if(!t.has(r))throw new XS("Side channel does not contain "+JS(r))},delete:function(r){if(e){var i=nk(e,r);return rk(e)===0&&(e=void 0),i}return!1},get:function(r){if(e)return QS(e,r)},has:function(r){return e?tk(e,r):!1},set:function(r,i){e||(e=new bd),ek(e,r,i)}};return t},ik=st,Da=bn,sk=ci,go=Wp,ok=G,br=ik("%WeakMap%",!0),ak=Da("WeakMap.prototype.get",!0),lk=Da("WeakMap.prototype.set",!0),ck=Da("WeakMap.prototype.has",!0),uk=Da("WeakMap.prototype.delete",!0),hk=br?function(){var e,t,r={assert:function(i){if(!r.has(i))throw new ok("Side channel does not contain "+sk(i))},delete:function(i){if(br&&i&&(typeof i=="object"||typeof i=="function")){if(e)return uk(e,i)}else if(go&&t)return t.delete(i);return!1},get:function(i){return br&&i&&(typeof i=="object"||typeof i=="function")&&e?ak(e,i):t&&t.get(i)},has:function(i){return br&&i&&(typeof i=="object"||typeof i=="function")&&e?ck(e,i):!!t&&t.has(i)},set:function(i,s){br&&i&&(typeof i=="object"||typeof i=="function")?(e||(e=new br),lk(e,i,s)):go&&(t||(t=go()),t.set(i,s))}};return r}:go,dk=G,fk=ci,pk=YS,gk=Wp,mk=hk,yk=mk||gk||pk,vk=function(){var e,t={assert:function(r){if(!t.has(r))throw new dk("Side channel does not contain "+fk(r))},delete:function(r){return!!e&&e.delete(r)},get:function(r){return e&&e.get(r)},has:function(r){return!!e&&e.has(r)},set:function(r,i){e||(e=yk()),e.set(r,i)}};return t},bk=Kt,ki=vk(),Dt=G,fu={assert:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Dt("`O` is not an object");if(typeof e!="string")throw new Dt("`slot` must be a string");if(ki.assert(n),!fu.has(n,e))throw new Dt("`"+e+"` is not present on `O`")},get:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Dt("`O` is not an object");if(typeof e!="string")throw new Dt("`slot` must be a string");var t=ki.get(n);return t&&t["$"+e]},has:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Dt("`O` is not an object");if(typeof e!="string")throw new Dt("`slot` must be a string");var t=ki.get(n);return!!t&&bk(t,"$"+e)},set:function(n,e,t){if(!n||typeof n!="object"&&typeof n!="function")throw new Dt("`O` is not an object");if(typeof e!="string")throw new Dt("`slot` must be a string");var r=ki.get(n);r||(r={},ki.set(n,r)),r["$"+e]=t}};Object.freeze&&Object.freeze(fu);var pu=fu,qp=qt,dn=pu,Ys=function n(e,t){if(!(this instanceof n))return new n(e,t);if(e!=="normal"&&e!=="break"&&e!=="continue"&&e!=="return"&&e!=="throw")throw new qp('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');dn.set(this,"[[Type]]",e),dn.set(this,"[[Value]]",t)};Ys.prototype.type=function(){return dn.get(this,"[[Type]]")};Ys.prototype.value=function(){return dn.get(this,"[[Value]]")};Ys.prototype["?"]=function(){var e=dn.get(this,"[[Type]]"),t=dn.get(this,"[[Value]]");if(e==="throw")throw t;return t};Ys.prototype["!"]=function(){var e=dn.get(this,"[[Type]]");if(e!=="normal")throw new qp('Assertion failed: Completion Record is not of type "normal"');return dn.get(this,"[[Value]]")};var gu=Ys,wk=gu,mu=function(e){return new wk("normal",e)},kl,wd;function _k(){if(wd)return kl;wd=1;var n=si;return kl=function(){return n()&&!!Symbol.toStringTag},kl}var Sk=st,_d=Sk("%Object.defineProperty%",!0),kk=_k()(),Ek=Kt,$k=G,mo=kk?Symbol.toStringTag:null,Yp=function(e,t){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,i=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof r<"u"&&typeof r!="boolean"||typeof i<"u"&&typeof i!="boolean")throw new $k("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");mo&&(r||!Ek(e,mo))&&(_d?_d(e,mo,{configurable:!i,enumerable:!1,value:t,writable:!1}):e[mo]=t)},Kp={exports:{}},Ak=st,Sd=hp,xk=Ca(),kd=ii,Ed=G,Tk=Ak("%Math.floor%"),Ck=function(e,t){if(typeof e!="function")throw new Ed("`fn` is not a function");if(typeof t!="number"||t<0||t>4294967295||Tk(t)!==t)throw new Ed("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in e&&kd){var o=kd(e,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!r)&&(xk?Sd(e,"length",t,!0,!0):Sd(e,"length",t)),e},Ik=Vs,Pk=ru,Rk=Sp,Dk=function(){return Rk(Ik,Pk,arguments)};(function(n){var e=Ck,t=Hs,r=Ia,i=Dk;n.exports=function(o){var a=r(arguments),c=1+o.length-(arguments.length-1);return e(a,c>0?c:0,!0)},t?t(n.exports,"apply",{value:i}):n.exports.apply=i})(Kp);var yu=Kp.exports,Ok=function(e,t){for(var r=0;r<e.length;r+=1)if(!t(e[r],r,e))return!1;return!0},zk=Object,Lk=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||zk(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},Mk=Kt,Nk=iu(),Uk=Ok,Fk=Lk,Zk=function(e){return e&&typeof e=="object"&&Mk(e,"[[DisposableResourceStack]]")&&Nk(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||Uk(e["[[DisposableResourceStack]]"],Fk))},Hk=Yt,Vk=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(Hk(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},jk=Vk,vu=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":jk(e)},Bk=G,Gk=ci,Wk=ai,qk=function(e,t){if(!Wk(t))throw new Bk("Assertion failed: P is not a Property Key, got "+Gk(t));return e[t]},$d=G,Yk=qk,Kk=li,Jk=ai,Ad=ci,Xk=function(e,t){if(!Jk(t))throw new $d("Assertion failed: P is not a Property Key");var r=Yk(e,t);if(r!=null){if(!Kk(r))throw new $d(Ad(t)+" is not a function: "+Ad(r));return r}},sc={exports:{}},Qk=st,eE=Qk,xd=eE("%Reflect.construct%",!0),Ko=Ws;try{Ko({},"",{"[[Get]]":function(){}})}catch{Ko=null}if(Ko&&xd){var Td={},Cd={};Ko(Cd,"length",{"[[Get]]":function(){throw Td},"[[Enumerable]]":!0}),sc.exports=function(e){try{xd(e,Cd)}catch(t){return t===Td}}}else sc.exports=function(e){return typeof e=="function"&&!!e.prototype};var tE=sc.exports,El=G,Id=li,nE=tE,rE=function(e){if(!nE(e))throw new El("C must be a constructor");var t={"[[Resolve]]":void 0,"[[Reject]]":void 0},r=new e(function(i,s){if(typeof t["[[Resolve]]"]<"u"||typeof t["[[Reject]]"]<"u")throw new El("executor has already been called");t["[[Resolve]]"]=i,t["[[Reject]]"]=s});if(!Id(t["[[Resolve]]"])||!Id(t["[[Reject]]"]))throw new El("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":t["[[Resolve]]"],"[[Reject]]":t["[[Reject]]"]}},Pd=qt,iE=G,$l=Pa,Rd=Xk,sE=rE,oE=vu,Dd=lu(),Od=cu(),aE=function(e,t){if(oE(e)!=="Object")throw new iE("`V` must be an Object");if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new Pd("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(t==="ASYNC-DISPOSE"&&Od&&(r=Rd(e,Od)),!r){if(!Dd)throw new Pd("`Symbol.dispose` is not supported");if(r=Rd(e,Dd),typeof r<"u")return function(){var i=this;if(t==="ASYNC-DISPOSE"){var s=sE(Promise);try{$l(r,i),$l(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}$l(r,i)}}return r},lE=qt,Al=G,cE=li,uE=vu,hE=aE,dE=function(e,t){if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new lE("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(arguments.length<3)if(e==null)e=void 0,r=void 0;else{if(typeof e<"u"&&uE(e)!=="Object")throw new Al("`V` must be an Object, or `null` or `undefined`");if(r=hE(e,t),typeof r>"u")throw new Al("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!cE(r))throw new Al("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":t,"[[DisposeMethod]]":r}},fE=qt,yo=G,pE=Zk,zd=dE,gE=bn,mE=gE("Array.prototype.push"),Jp=function(e,t,r){if(!pE(e))throw new yo("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new fE("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var i=arguments.length>3?arguments[3]:void 0;if(arguments.length>3&&typeof i!="function")throw new yo("Assertion failed: `method`, when present, must be a function");if(!e["[[DisposableResourceStack]]"])throw new yo("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var s;if(arguments.length<4){if(t==null&&r==="SYNC_DISPOSE")return"UNUSED";s=zd(t,r)}else{if(typeof t<"u")throw new yo("Assertion failed: `V` must be undefined when `method` is present");s=zd(void 0,r,i)}return mE(e["[[DisposableResourceStack]]"],s),"UNUSED"},xl,Ld;function bu(){if(Ld)return xl;Ld=1;var n=st,e=yu,t=qt,r=n("%Promise.resolve%",!0),i=r&&e(r);return xl=function(o,a){if(!i)throw new t("This environment does not support Promises.");return i(o,a)},xl}var Tl,Md;function yE(){if(Md)return Tl;Md=1;var n=st,e=qt,t=n("%Promise%",!0),r=Pa,i=bu(),s=vu;return Tl=function(a,c,u){if(typeof a<"u"&&s(a)!=="Object")throw new e("Assertion failed: `V` must be `undefined` or an Object");if(c!=="SYNC-DISPOSE"&&c!=="ASYNC-DISPOSE")throw new e("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");if(typeof u<"u"&&typeof u!="function")throw new e("Assertion failed: `method` must be `undefined` or a function");var d=typeof u>"u"?u:r(u,a);if(c==="ASYNC-DISPOSE")return i(t,d)},Tl}var Cl,Nd;function vE(){if(Nd)return Cl;Nd=1;var n=gu;return Cl=function(t){return new n("throw",t)},Cl}var bE=st,Il=qt,Ud=G,wE=bE("%Promise%",!0),_E=bn,Fd=_E("Promise.prototype.then",!0),SE=gu,Zd=yE(),kE=mu,EE=bu(),Hd=vE(),$E=Up(),Xp=function(e,t){if(!(t instanceof SE))throw new Ud("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new Ud("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var i,s=r.length-1;s>=0;s-=1)if(!i)i=r[s]["[[Hint]]"];else if(i!==r[s]["[[Hint]]"])throw new Il("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&EE(wE,t),a=function(v){if(t.type()==="throw"){var y=t.value(),A=new $E(v,y);t=Hd(A)}else t=Hd(v)},c=i==="ASYNC-DISPOSE"&&function(y){return Fd(o,function(){var A=Zd(y["[[ResourceValue]]"],y["[[Hint]]"],y["[[DisposeMethod]]"]);if(!A)throw new Il("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return Fd(A,kE)},a)},u=r.length-1;u>=0;u-=1)if(i==="ASYNC-DISPOSE")o=c(r[u]);else{var d=r[u];try{var f=Zd(d["[[ResourceValue]]"],d["[[Hint]]"],d["[[DisposeMethod]]"]);if(f)throw new Il("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(v){a(v)}}return e["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:t},Qp=function(){var e=[];return{"[[DisposableResourceStack]]":e}},Oa=Qc,wu=G,AE=Pa,ui=ou,xE=Ws,eg=li,TE=mu,je=pu,CE=Yp,tg=ar.supportsDescriptors,IE=yu,_u=Jp,PE=Xp,ng=Qp,Vd=lu(),nt=function n(){if(!(this instanceof n)||je.has(this,"[[DisposableState]]")||je.has(this,"[[DisposeCapability]]"))throw new wu("can only be used with new");je.set(this,"[[DisposableState]]","PENDING"),je.set(this,"[[DisposeCapability]]",ng())},rg=function(){var e=this;return je.assert(e,"[[DisposableState]]"),je.get(e,"[[DisposableState]]")==="DISPOSED"},Ks=IE(rg);tg?xE(nt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":rg}):nt.prototype.disposed=!1;var ig=function(e){je.set(e,"[[DisposableState]]","DISPOSED"),tg||(e.disposed=!0)};ui(nt.prototype,"dispose",function(){var e=this;if(!Ks(e))return ig(e),PE(je.get(e,"[[DisposeCapability]]"),TE())["?"]()});ui(nt.prototype,"use",function(e){var t=this;if(Ks(t))throw new Oa("a disposed stack can not use anything new");return _u(je.get(t,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});ui(nt.prototype,"adopt",function(e,t){var r=this;if(Ks(r))throw new Oa("a disposed stack can not use anything new");if(!eg(t))throw new wu("`onDispose` must be a function");var i=function(){return AE(t,void 0,[e])};return _u(je.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),e});ui(nt.prototype,"defer",function(e){var t=this;if(Ks(t))throw new Oa("a disposed stack can not defer anything new");if(!eg(e))throw new wu("`onDispose` must be a function");_u(je.get(t,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});ui(nt.prototype,"move",function(){var e=this;if(Ks(e))throw new Oa("a disposed stack can not use anything new");var t=new nt;return je.set(t,"[[DisposeCapability]]",je.get(e,"[[DisposeCapability]]")),je.set(e,"[[DisposeCapability]]",ng()),ig(e),t});Vd&&ui(nt.prototype,Vd,nt.prototype.dispose);CE(nt.prototype,"DisposableStack");var RE=nt,DE=RE,OE=function(){return typeof DisposableStack=="function"?DisposableStack:DE},zE=ar,LE=Jc(),ME=OE,NE=function(){var e=ME();return zE(LE,{DisposableStack:e},{DisposableStack:!0}),e},UE=st,za=Qc,Su=G,jd=UE("%Promise%",!0),ku=Jp,FE=Pa,hi=ou,ZE=Ws,HE=Xp,sg=li,og=Qp,VE=mu,Bd=bu(),Be=pu,jE=Yp,ag=ar.supportsDescriptors,BE=yu,GE=bn,WE=GE("Promise.prototype.then",!0),Gd=cu(),rt=function n(){if(!(this instanceof n)||Be.has(this,"[[AsyncDisposableState]]")||Be.has(this,"[[DisposeCapability]]"))throw new Su("can only be used with new");Be.set(this,"[[AsyncDisposableState]]","pending"),Be.set(this,"[[DisposeCapability]]",og())},lg=function(){var e=this;return Be.assert(e,"[[AsyncDisposableState]]"),Be.get(e,"[[AsyncDisposableState]]")==="disposed"},Js=BE(lg);ag?ZE(rt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":lg}):rt.prototype.disposed=!1;var cg=function(e){Be.set(e,"[[AsyncDisposableState]]","disposed"),ag||(e.disposed=!0)};hi(rt.prototype,"disposeAsync",function(){var e=this;return Js(e)?Bd(jd):(cg(e),WE(Bd(jd,HE(Be.get(e,"[[DisposeCapability]]"),VE())),function(t){return t["?"]()}))});hi(rt.prototype,"use",function(e){var t=this;if(Js(t))throw new za("a disposed stack can not use anything new");return ku(Be.get(t,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});hi(rt.prototype,"adopt",function(e,t){var r=this;if(Js(r))throw new za("a disposed stack can not use anything new");if(!sg(t))throw new Su("`onDisposeAsync` must be a function");var i=function(){return FE(t,void 0,[e])};return i.value=e,ku(Be.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),e});hi(rt.prototype,"defer",function(e){var t=this;if(Js(t))throw new za("a disposed stack can not defer anything new");if(!sg(e))throw new Su("`onDispose` must be a function");ku(Be.get(t,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});hi(rt.prototype,"move",function(){var e=this;if(Js(e))throw new za("a disposed stack can not use anything new");var t=new rt;return Be.set(t,"[[DisposeCapability]]",Be.get(e,"[[DisposeCapability]]")),Be.set(e,"[[DisposeCapability]]",og()),cg(e),t});Gd&&hi(rt.prototype,Gd,rt.prototype.disposeAsync);jE(rt.prototype,"AsyncDisposableStack");var qE=rt,YE=qE,KE=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:YE},JE=ar,XE=Jc(),QE=KE,e0=function(){var e=QE();return JE(XE,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},t0=J_,n0=sS,r0=NE,i0=e0,s0=function(){t0(),n0(),r0(),i0()};s0();const Wd=new WeakMap;function o0(n){return(typeof n=="object"||typeof n=="function")&&n!==null&&"then"in n&&typeof n.then=="function"}function wr(n){return typeof n=="string"?n:typeof n=="symbol"?n.description??n.toString():n.name||"(anonymous class)"}function qd(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function a0(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class l0{constructor(){b(this,"entries",new Map);b(this,"constructionStack",[])}register(e,t){if(t===void 0){if(typeof e!="function")throw qd();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof t!="function")throw qd();if(t.constructor.name==="AsyncFunction")throw a0();this.storeFactory(e,t)}has(e){var t;return((t=this.entries.get(e))==null?void 0:t.factory)!==void 0}resolve(e){return this.resolveAny(e)}storeFactory(e,t){const r=this.getOrCreateEntry(e);r.factory=t,r.instance=void 0,r.error=void 0}validateClassRegistration(e){const t=Wd.get(e);if(t){if(e.length!==t.length)throw new Error(`${wr(e)} cannot be registered with register(Class). @injectable(...) declared ${t.length} dependencies but constructor arity is ${e.length}. Use register(Key, () => value) instead.`);return}if(e.length!==0)throw new Error(`${wr(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const t=Wd.get(e);if(!t)return new e;const r=t.map(i=>this.resolveAny(i));return new e(...r)}resolveAny(e){return this.getOrCreateEntry(e).proxy}getOrCreateEntry(e){let t=this.entries.get(e);return t||(t={key:e},t.proxy=this.createProxy(t),this.entries.set(e,t),t)}createProxy(e){return new Proxy({},{get:(t,r)=>{if(r==="then")return;const i=this.getInstance(e),s=Reflect.get(i,r,i);return typeof s=="function"?s.bind(i):s},set:(t,r,i)=>{const s=this.getInstance(e);return Reflect.set(s,r,i,s)},has:(t,r)=>{const i=this.getInstance(e);return r in i}})}getInstance(e){if(e.instance)return e.instance;if(e.error)throw e.error;if(!e.factory)throw new Error(`${wr(e.key)} was resolved but never registered`);const t=this.constructionStack.indexOf(e.key);if(t!==-1){const r=[...this.constructionStack.slice(t),e.key].map(i=>wr(i)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(e.key);try{const r=e.factory();if(o0(r))throw new Error(`Factory for ${wr(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${wr(e.key)} returned a non-object value. Wrap primitives in an object.`);return e.instance=r,r}catch(r){throw e.error=r,r}finally{this.constructionStack.pop()}}}const Ge=new l0,c0=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function u0(n){for(const e of Object.keys(n))if(c0.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function h0(n,e){u0(e);for(const t of Object.keys(e))Object.defineProperty(n,t,{value:e[t],writable:!0,enumerable:!0,configurable:!0})}function pt(){class n extends Event{constructor(t,r){const{type:i,bubbles:s,cancelable:o,composed:a,...c}=r??{};if(i!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(t,{bubbles:s,cancelable:o,composed:a}),h0(this,c)}}return n}class gt extends globalThis.EventTarget{}function d0(n,e,t){const r=n.dispose.bind(n);n.dispose=()=>{if(!e())return t(),r()}}function di(n){var t;class e extends n{constructor(...s){super(...s);_(this,t,!1);d0(this,()=>l(this,t),()=>{E(this,t,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return l(this,t)}}return t=new WeakMap,e}const f0=pt(),p0=pt(),No=pt(),ug="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Jo=32,g0=16,hg=10,Yd=0xffffffffffff;var zn;(function(n){n.Base32IncorrectEncoding="B32_ENC_INVALID",n.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",n.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",n.EncodeTimeNegative="ENC_TIME_NEG",n.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",n.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",n.PRNGDetectFailure="PRNG_DETECT",n.ULIDInvalid="ULID_INVALID",n.Unexpected="UNEXPECTED",n.UUIDInvalid="UUID_INVALID"})(zn||(zn={}));class Oi extends Error{constructor(e,t){super(`${t} (${e})`),this.name="ULIDError",this.code=e}}function m0(n){const e=Math.floor(n()*Jo)%Jo;return ug.charAt(e)}function y0(n){const e=v0(),t=e&&(e.crypto||e.msCrypto)||null;if(typeof(t==null?void 0:t.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return t.getRandomValues(r),r[0]/256};if(typeof(t==null?void 0:t.randomBytes)=="function")return()=>t.randomBytes(1).readUInt8()/256;throw new Oi(zn.PRNGDetectFailure,"Failed to find a reliable PRNG")}function v0(){return _0()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function b0(n,e){let t="";for(;n>0;n--)t=m0(e)+t;return t}function w0(n,e=hg){if(isNaN(n))throw new Oi(zn.EncodeTimeValueMalformed,`Time must be a number: ${n}`);if(n>Yd)throw new Oi(zn.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Yd}: ${n}`);if(n<0)throw new Oi(zn.EncodeTimeNegative,`Time must be positive: ${n}`);if(Number.isInteger(n)===!1)throw new Oi(zn.EncodeTimeValueMalformed,`Time must be an integer: ${n}`);let t,r="";for(let i=e;i>0;i--)t=n%Jo,r=ug.charAt(t)+r,n=(n-t)/Jo;return r}function _0(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Eu(n,e){const t=y0(),r=Date.now();return w0(r,hg)+b0(g0,t)}const Ct=4,Xe=6,dg=2,oc=2,S0=Ct,k0=Xe,$u="auto",fn="auto",Pn=120,Kd=75,pe=16,tr=Pn*Ct+pe*(Ct-1),Xo=Pn*Xe+pe*(Xe-1),E0=200,$0=4,vo=150,A0=10,Jd=2,x0=4;function fg(n){return mg(n)}function pg(n,e){return mg(n.flatMap(t=>vg(t,e)))}function gg(n){const e=[],t=new Set;for(const r of n){if(r.type==="row"){e.push(`Top-level rows are invalid: ${r.id}`);continue}bg(r,"strip",e,t)}return{valid:e.length===0,errors:e}}function Wi(n){const e=fg(n),t=gg(e);if(!t.valid)throw new Error(`Invalid layout: ${t.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(P0)}}function mg(n){const e=[];for(const t of n){const r=yg(t);for(const i of r){if(i.type==="row"){e.push(...i.children.map(Gt));continue}e.push(i)}}return e}function yg(n){switch(n.type){case"card":return[Gt(n)];case"row":{const e=n.children.map(Gt);return e.length===0?[]:e.length===1?[e[0]]:[{...n,children:e}]}case"stack":{const e=[];for(const t of n.children){const r=yg(t);for(const i of r){if(i.type==="stack"){e.push(...i.children.map(ac));continue}if(i.type==="row"){e.push({...i,children:i.children.map(Gt)});continue}e.push(Gt(i))}}return e.length===0?[]:e.length===1?[ac(e[0])]:[{...n,children:e}]}}}function vg(n,e){switch(n.type){case"card":return n.artifactID===e?[]:[Gt(n)];case"row":{const t=n.children.filter(r=>r.artifactID!==e).map(Gt);return t.length===0?[]:t.length===1?[t[0]]:[{...n,children:t}]}case"stack":{const t=n.children.flatMap(r=>vg(r,e).filter(s=>s.type!=="stack"));return t.length===0?[]:t.length===1?[ac(t[0])]:[{...n,children:t}]}}}function bg(n,e,t,r){switch(n.type){case"card":wg(n,e,t,r);return;case"row":T0(n,e,t,r);return;case"stack":C0(n,e,t,r);return}}function wg(n,e,t,r){Au(n.id,t),typeof n.artifactID!="string"||n.artifactID.length===0?t.push(`Card ${n.id} is missing artifactID`):r.has(n.artifactID)?t.push(`Duplicate artifactID in layout: ${n.artifactID}`):r.add(n.artifactID),I0(n.width)||t.push(`Card ${n.id} width must be an integer in the range 2-4`),_g(n.height)||t.push(`Card ${n.id} height must be an integer in the range 2-6 or "auto"`);const i=Rn(n.width);e==="row"&&i<dg&&t.push(`Row child ${n.id} must be at least 2 columns wide`)}function T0(n,e,t,r){if(Au(n.id,t),e!=="stack"&&t.push(`Row ${n.id} may only appear inside a stack`),_g(n.height,x0)||t.push(`Row ${n.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(n.children)||n.children.length===0){t.push(`Row ${n.id} must contain card nodes`);return}let i=0;for(const s of n.children){if(s.type!=="card"){t.push(`Row ${n.id} must contain only card nodes`);continue}wg(s,"row",t,r),i+=Rn(s.width)}i!==Ct&&t.push(`Row ${n.id} children must sum to 4 columns`)}function C0(n,e,t,r){if(Au(n.id,t),e!=="strip"&&t.push(`Invalid nested stack at ${n.id}; stack children cannot contain another nested stack`),!Array.isArray(n.children)||n.children.length===0){t.push(`Stack ${n.id} must contain at least one child`);return}let i=0,s=0;for(const a of n.children){if(a.type==="stack"){t.push(`Stack ${n.id} cannot contain another nested stack`);continue}if(bg(a,"stack",t,r),a.height===fn){s+=1;continue}i+=a.height}if(i>Xe&&t.push(`Stack ${n.id} exceeds the 6-row budget`),s===0)return;const o=Xe-i;if(o<s*oc||o%s!==0){t.push(`Stack ${n.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<oc&&t.push(`Stack ${n.id} has auto-height children below the minimum row size`)}function Au(n,e){(typeof n!="string"||n.length===0)&&e.push(`Node id must be a non-empty string: ${String(n)}`)}function I0(n){return n===$u||Number.isInteger(n)&&n>=dg&&n<=S0}function _g(n,e=k0){return n===fn||Number.isInteger(n)&&n>=oc&&n<=e}function Rn(n){return n===$u?Ct:n}function P0(n){if(n.type==="card")return{id:n.id,type:"card",width:Rn(n.width),cards:[{id:n.id,artifactID:n.artifactID,col:1,row:1,width:Rn(n.width),height:Sg(n.height,Xe)}]};const e=R0(n.children),t=[];let r=1;for(let i=0;i<n.children.length;i+=1){const s=n.children[i],o=e[i];if(s.type==="card")t.push({id:s.id,artifactID:s.artifactID,col:1,row:r,width:Rn(s.width),height:o});else{let a=1;for(const c of s.children)t.push({id:c.id,artifactID:c.artifactID,col:a,row:r,width:Rn(c.width),height:o}),a+=Rn(c.width)}r+=o}return{id:n.id,type:"stack",width:t.reduce((i,s)=>Math.max(i,s.col+s.width-1),1),cards:t}}function R0(n){let e=0,t=0;for(const i of n)i.height===fn?t+=1:e+=i.height;const r=t>0?(Xe-e)/t:0;return n.map(i=>Sg(i.height,r))}function Sg(n,e){return n===fn?e:n}function Gt(n){return{...n}}function ac(n){return n.type==="card"?Gt(n):{...n,children:n.children.map(Gt)}}function kg(n,e={}){return{id:e.id??Eu(),type:"card",artifactID:n,width:e.width??$u,height:e.height??fn}}function Eg(n,e){return n.some(t=>$g(t,e))}function $g(n,e){switch(n.type){case"card":return n.artifactID===e;case"row":return n.children.some(t=>t.artifactID===e);case"stack":return n.children.some(t=>$g(t,e))}}function Xd(n){return n.layout.flatMap(Ag)}function Ag(n){switch(n.type){case"card":return[n.artifactID];case"row":return n.children.map(e=>e.artifactID);case"stack":return n.children.flatMap(Ag)}}const Q=pt(),xg=pt(),Ei=pt(),D0=pt();function O0(n){class e extends Error{constructor(r,i){super(r),this.name=n,i&&Object.assign(this,i)}}return e}const z0=O0("RequestError"),L0=200,M0=300;class N0{constructor(e,t){b(this,"serverURL");b(this,"token");this.serverURL=e.replace(/\/$/,""),this.token=t.token}async requestJSON(e,t,r){const i=await this.request(e,t,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),s=await U0(i);if(!i.ok||i.status<L0||i.status>=M0)throw this.createError(typeof s.error=="string"?s.error:i.statusText,i.status);return s}async requestVoid(e,t){const r=await this.request(e,t);if(!r.ok)throw this.createError(await Pl(r,r.statusText),r.status)}async requestText(e,t){const r=await this.request(e,t);if(!r.ok)throw this.createError(await Pl(r,r.statusText),r.status);return r.text()}async requestRawVoid(e,t,r){const i=await this.request(e,t,r,{"content-type":"text/plain"});if(!i.ok)throw this.createError(await Pl(i,i.statusText),i.status)}createError(e,t){const r={serverURL:this.serverURL};return t!==void 0&&(r.status=t),new z0(e,r)}async request(e,t,r,i){const s=`${this.serverURL}${t}`;try{return await fetch(s,{method:e,headers:this.buildHeaders(i),body:r})}catch(o){throw this.createError(o instanceof Error?o.message:"Failed to reach server")}}buildHeaders(e){const t={...e??{}};return this.token&&(t.Authorization=`Bearer ${this.token}`),Object.keys(t).length>0?t:void 0}}async function U0(n){try{return await n.json()}catch{const e=await n.text().catch(()=>"");return e?{message:e}:{}}}async function Pl(n,e){try{const t=await n.json();if(typeof t.error=="string")return t.error;if(typeof t.message=="string")return t.message}catch{}return e}function Tg(n){return n.map(e=>`${e.name} (${e.id})`).join(", ")}var Et,ua,Cg;class F0{constructor(e){_(this,ua);_(this,Et);E(this,Et,e)}list(){return l(this,Et).requestJSON("GET","/screens")}async get(e={}){const t=await m(this,ua,Cg).call(this,e.screenID);return l(this,Et).requestJSON("GET",`/screens/${encodeURIComponent(t)}`)}create(e){const t={name:e.name};return e.id!==void 0&&(t.id=e.id),l(this,Et).requestJSON("POST","/screens",t)}update(e){const t={};return e.name!==void 0&&(t.name=e.name),e.layout!==void 0&&(t.layout=e.layout),l(this,Et).requestJSON("PATCH",`/screens/${encodeURIComponent(e.screenID)}`,t)}remove(e){return l(this,Et).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}Et=new WeakMap,ua=new WeakSet,Cg=async function(e){if(e!==void 0)return e;const{screens:t}=await this.list();if(t.length===1)return t[0].id;throw l(this,Et).createError(`screenID is required when multiple screens exist. Available screens: ${Tg(t)}`)};var Ze,ns,ha,Ig;class Z0{constructor(e,t){_(this,ha);_(this,Ze);_(this,ns);E(this,Ze,e),E(this,ns,t)}async create(e){const t=await m(this,ha,Ig).call(this,e.screenID);return l(this,Ze).requestJSON("POST",`/screens/${encodeURIComponent(t)}/artifact`,{type:e.type,title:e.title,externalFilePath:e.externalFilePath})}get(e){return l(this,Ze).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const t={};return e.title!==void 0&&(t.title=e.title),l(this,Ze).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,t)}edit(e){return l(this,Ze).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return l(this,Ze).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return l(this,Ze).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}remove(e){return l(this,Ze).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return l(this,Ze).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return l(this,Ze).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}Ze=new WeakMap,ns=new WeakMap,ha=new WeakSet,Ig=async function(e){if(e!==void 0)return e;const{screens:t}=await l(this,ns).list();if(t.length===1)return t[0].id;throw l(this,Ze).createError(`screenID is required when multiple screens exist. Available screens: ${Tg(t)}`)};var rs;class H0{constructor(e){_(this,rs);E(this,rs,e)}async list(){const{views:e}=await l(this,rs).requestJSON("GET","/views");return e}}rs=new WeakMap;var tn;class V0{constructor(e,t={}){b(this,"screens");b(this,"artifacts");b(this,"views");_(this,tn);E(this,tn,new N0(e,t)),this.screens=new F0(l(this,tn)),this.artifacts=new Z0(l(this,tn),this.screens),this.views=new H0(l(this,tn))}health(){return l(this,tn).requestJSON("GET","/health")}}tn=new WeakMap;const j0={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},B0=di(gt);var Mn,He,Nn,ze,nn,rn,J,Sr,Pg,is,Rg,Dg,Og,zg,lc,cc,uc,Lg;class G0 extends B0{constructor(t){var i;super();_(this,J);b(this,"id");b(this,"server");_(this,Mn);_(this,He,new Map);_(this,Nn);_(this,ze);_(this,nn);_(this,rn,null);_(this,is,t=>{if(this.disposed)return;const r=t.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&m(this,J,Rg).call(this,r.screen);break;case"artifact-created":r.screenID===this.id&&m(this,J,Dg).call(this,r.artifact);break;case"artifact-updated":m(this,J,Og).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&m(this,J,zg).call(this,r.artifactID);break;case"artifact-content-changed":l(this,He).has(r.artifactID)&&this.dispatchEvent(new D0("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=t.screen.id,this.server=t.server,E(this,Mn,t.localStore),E(this,Nn,t.screen.name),E(this,ze,structuredClone(t.screen.layout));const r=((i=l(this,Mn).get().screens[this.id])==null?void 0:i.scrollPosition)??0;E(this,nn,Math.max(0,r)),this.server.addEventListener("server-event",l(this,is)),m(this,J,Pg).call(this)}get name(){return l(this,Nn)}get layout(){return l(this,ze)}get scrollPosition(){return l(this,nn)}get artifacts(){return l(this,He)}setScrollPosition(t){m(this,J,Sr).call(this);const r=Math.max(0,t);r!==l(this,nn)&&(E(this,nn,r),m(this,J,Lg).call(this),this.dispatchEvent(new Q("change")))}setLayout(t){m(this,J,Sr).call(this);const r=fg(t);if(!gg(r).valid)return;const s=m(this,J,cc).call(this);E(this,ze,r),E(this,rn,{layout:r,snapshot:s}),this.dispatchEvent(new Q("change")),this.server.client.screens.update({screenID:this.id,layout:r.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=l(this,rn))==null?void 0:o.layout)===r&&(E(this,rn,null),m(this,J,uc).call(this,s),this.dispatchEvent(new Q("change")))})}rename(t){m(this,J,Sr).call(this),E(this,Nn,t),this.dispatchEvent(new Q("change")),this.server.client.screens.update({screenID:this.id,name:t}).catch(()=>{})}async remove(){m(this,J,Sr).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(t){if(m(this,J,Sr).call(this),!l(this,He).has(t))return;const r=m(this,J,cc).call(this);m(this,J,lc).call(this,t),this.dispatchEvent(new Q("change")),this.server.client.artifacts.remove({artifactID:t,screenID:this.id}).catch(()=>{this.disposed||(m(this,J,uc).call(this,r),this.dispatchEvent(new Q("change")))})}dispose(){this.server.removeEventListener("server-event",l(this,is))}}Mn=new WeakMap,He=new WeakMap,Nn=new WeakMap,ze=new WeakMap,nn=new WeakMap,rn=new WeakMap,J=new WeakSet,Sr=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Pg=async function(){try{const t=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of t.artifacts)l(this,He).set(r.id,r);this.dispatchEvent(new Q("change"))}catch{}},is=new WeakMap,Rg=function(t){l(this,rn)&&E(this,rn,null),E(this,Nn,t.name),E(this,ze,structuredClone(t.layout)),this.dispatchEvent(new Q("change"))},Dg=function(t){Eg(l(this,ze),t.id)||E(this,ze,[...l(this,ze),kg(t.id)]),l(this,He).set(t.id,t),this.dispatchEvent(new Q("change"))},Og=function(t){const r=l(this,He).get(t.id);r&&(l(this,He).set(t.id,{...r,...t}),this.dispatchEvent(new Q("change")))},zg=function(t){m(this,J,lc).call(this,t)&&this.dispatchEvent(new Q("change"))},lc=function(t){const r=l(this,He).delete(t),i=Xd({layout:l(this,ze)}).length,s=pg(l(this,ze),t),o=Xd({layout:s}).length;return E(this,ze,s),r||i!==o},cc=function(){return{layout:structuredClone(l(this,ze)),artifacts:new Map([...l(this,He).entries()].map(([t,r])=>[t,structuredClone(r)]))}},uc=function(t){E(this,ze,structuredClone(t.layout)),l(this,He).clear();for(const[r,i]of t.artifacts)l(this,He).set(r,structuredClone(i))},Lg=function(){const t=l(this,Mn).get();l(this,Mn).set({...t,screens:{...t.screens,[this.id]:{scrollPosition:l(this,nn)}}})};const W0=di(gt);var Qe,Mt,at,ss,os,as,Dr,Uo;class q0 extends W0{constructor(t){super();_(this,Dr);_(this,Qe);_(this,Mt);_(this,at,null);_(this,ss,()=>{this.disposed||m(this,Dr,Uo).call(this)});_(this,os,()=>{this.disposed||m(this,Dr,Uo).call(this)});_(this,as,t=>{var i;if(this.disposed)return;const r=t.event;r.type==="screen-removed"&&((i=l(this,at))==null?void 0:i.id)===r.screenID&&this.clearActive()});E(this,Qe,t.localStore),E(this,Mt,t.serverManager),l(this,Qe).addEventListener("change",l(this,ss)),l(this,Mt).addEventListener("change",l(this,os)),l(this,Mt).addEventListener("server-event",l(this,as)),m(this,Dr,Uo).call(this)}get activeScreen(){return l(this,at)}setActive(t,r){const i=l(this,Qe).get();i.activeServerURL===t&&i.activeScreenID===r||l(this,Qe).set({...i,activeServerURL:t,activeScreenID:r})}clearActive(){const t=l(this,Qe).get();t.activeScreenID!==null&&l(this,Qe).set({...t,activeScreenID:null})}dispose(){var t;l(this,Qe).removeEventListener("change",l(this,ss)),l(this,Mt).removeEventListener("change",l(this,os)),l(this,Mt).removeEventListener("server-event",l(this,as)),(t=l(this,at))==null||t.dispose(),E(this,at,null)}}Qe=new WeakMap,Mt=new WeakMap,at=new WeakMap,ss=new WeakMap,os=new WeakMap,as=new WeakMap,Dr=new WeakSet,Uo=function(){var c,u,d;const{activeServerURL:t,activeScreenID:r}=l(this,Qe).get(),i=t?l(this,Mt).servers.get(t)??null:null,s=i&&r?i.screens.get(r)??null:null,o=((c=l(this,at))==null?void 0:c.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=l(this,at))==null?void 0:u.server)===i||((d=l(this,at))==null||d.dispose(),E(this,at,i&&s?new G0({screen:s,server:i,localStore:l(this,Qe)}):null),this.dispatchEvent(new f0("active-screen-changed")))};const Y0="Local",K0="store-";function kt(n){return new URL(n).origin}function J0(n){return{servers:[{url:kt(n),name:Y0}],activeServerURL:null,activeScreenID:null,screens:{}}}var Un,Fn,Zn;class X0 extends gt{constructor(t,r,i={}){super();_(this,Un);_(this,Fn);_(this,Zn);E(this,Un,`${K0}${t}`),E(this,Fn,i.storage??Q0());const s=l(this,Fn).getItem(l(this,Un));s===null?(E(this,Zn,r),l(this,Fn).setItem(l(this,Un),JSON.stringify(r))):E(this,Zn,JSON.parse(s))}get(){return l(this,Zn)}set(t){E(this,Zn,t),l(this,Fn).setItem(l(this,Un),JSON.stringify(t)),this.dispatchEvent(new Q("change"))}}Un=new WeakMap,Fn=new WeakMap,Zn=new WeakMap;function Q0(){const n=globalThis.localStorage;if(!n)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return n}function $(n,e,t){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(n))return;a._zod.traits.add(n),e(a,c);const u=o.prototype,d=Object.keys(u);for(let f=0;f<d.length;f++){const v=d[f];v in a||(a[v]=u[v].bind(a))}}const i=(t==null?void 0:t.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:n});function o(a){var c;const u=t!=null&&t.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var c,u;return t!=null&&t.Parent&&a instanceof t.Parent?!0:(u=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:u.has(n)}}),Object.defineProperty(o,"name",{value:n}),o}class Rr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Mg extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Ng={};function pn(n){return Ng}function Ug(n){const e=Object.values(n).filter(r=>typeof r=="number");return Object.entries(n).filter(([r,i])=>e.indexOf(+r)===-1).map(([r,i])=>i)}function hc(n,e){return typeof e=="bigint"?e.toString():e}function xu(n){return{get value(){{const e=n();return Object.defineProperty(this,"value",{value:e}),e}}}}function Tu(n){return n==null}function Cu(n){const e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function e$(n,e){const t=(n.toString().split(".")[1]||"").length,r=e.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c!=null&&c[1]&&(i=Number.parseInt(c[1]))}const s=t>i?t:i,o=Number.parseInt(n.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return o%a/10**s}const Qd=Symbol("evaluating");function X(n,e,t){let r;Object.defineProperty(n,e,{get(){if(r!==Qd)return r===void 0&&(r=Qd,r=t()),r},set(i){Object.defineProperty(n,e,{value:i})},configurable:!0})}function cr(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function _n(...n){const e={};for(const t of n){const r=Object.getOwnPropertyDescriptors(t);Object.assign(e,r)}return Object.defineProperties({},e)}function ef(n){return JSON.stringify(n)}function t$(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Fg="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function Qo(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const n$=xu(()=>{var n;if(typeof navigator<"u"&&((n=navigator==null?void 0:navigator.userAgent)!=null&&n.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Qr(n){if(Qo(n)===!1)return!1;const e=n.constructor;if(e===void 0||typeof e!="function")return!0;const t=e.prototype;return!(Qo(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}function Zg(n){return Qr(n)?{...n}:Array.isArray(n)?[...n]:n}const r$=new Set(["string","number","symbol"]);function ei(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Sn(n,e,t){const r=new n._zod.constr(e??n._zod.def);return(!e||t!=null&&t.parent)&&(r._zod.parent=n),r}function O(n){const e=n;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function i$(n){return Object.keys(n).filter(e=>n[e]._zod.optin==="optional"&&n[e]._zod.optout==="optional")}const s$={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function o$(n,e){const t=n._zod.def,r=t.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=_n(n._zod.def,{get shape(){const o={};for(const a in e){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(o[a]=t.shape[a])}return cr(this,"shape",o),o},checks:[]});return Sn(n,s)}function a$(n,e){const t=n._zod.def,r=t.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=_n(n._zod.def,{get shape(){const o={...n._zod.def.shape};for(const a in e){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete o[a]}return cr(this,"shape",o),o},checks:[]});return Sn(n,s)}function l$(n,e){if(!Qr(e))throw new Error("Invalid input to extend: expected a plain object");const t=n._zod.def.checks;if(t&&t.length>0){const s=n._zod.def.shape;for(const o in e)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=_n(n._zod.def,{get shape(){const s={...n._zod.def.shape,...e};return cr(this,"shape",s),s}});return Sn(n,i)}function c$(n,e){if(!Qr(e))throw new Error("Invalid input to safeExtend: expected a plain object");const t=_n(n._zod.def,{get shape(){const r={...n._zod.def.shape,...e};return cr(this,"shape",r),r}});return Sn(n,t)}function u$(n,e){const t=_n(n._zod.def,{get shape(){const r={...n._zod.def.shape,...e._zod.def.shape};return cr(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return Sn(n,t)}function h$(n,e,t){const i=e._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=_n(e._zod.def,{get shape(){const a=e._zod.def.shape,c={...a};if(t)for(const u in t){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);t[u]&&(c[u]=n?new n({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=n?new n({type:"optional",innerType:a[u]}):a[u];return cr(this,"shape",c),c},checks:[]});return Sn(e,o)}function d$(n,e,t){const r=_n(e._zod.def,{get shape(){const i=e._zod.def.shape,s={...i};if(t)for(const o in t){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(s[o]=new n({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new n({type:"nonoptional",innerType:i[o]});return cr(this,"shape",s),s}});return Sn(e,r)}function Cr(n,e=0){var t;if(n.aborted===!0)return!0;for(let r=e;r<n.issues.length;r++)if(((t=n.issues[r])==null?void 0:t.continue)!==!0)return!0;return!1}function Ir(n,e){return e.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(n),t})}function bo(n){return typeof n=="string"?n:n==null?void 0:n.message}function gn(n,e,t){var i,s,o,a,c,u;const r={...n,path:n.path??[]};if(!n.message){const d=bo((o=(s=(i=n.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,n))??bo((a=e==null?void 0:e.error)==null?void 0:a.call(e,n))??bo((c=t.customError)==null?void 0:c.call(t,n))??bo((u=t.localeError)==null?void 0:u.call(t,n))??"Invalid input";r.message=d}return delete r.inst,delete r.continue,e!=null&&e.reportInput||delete r.input,r}function Iu(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function Ji(...n){const[e,t,r]=n;return typeof e=="string"?{message:e,code:"custom",input:t,inst:r}:{...e}}const Hg=(n,e)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:e,enumerable:!1}),n.message=JSON.stringify(e,hc,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},Vg=$("$ZodError",Hg),jg=$("$ZodError",Hg,{Parent:Error});function f$(n,e=t=>t.message){const t={},r=[];for(const i of n.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):r.push(e(i));return{formErrors:r,fieldErrors:t}}function p$(n,e=t=>t.message){const t={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>r({issues:o}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)t._errors.push(e(s));else{let o=t,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(e(s))):o[c]=o[c]||{_errors:[]},o=o[c],a++}}};return r(n),t}const Pu=n=>(e,t,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},o=e._zod.run({value:t,issues:[]},s);if(o instanceof Promise)throw new Rr;if(o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(c=>gn(c,s,pn())));throw Fg(a,i==null?void 0:i.callee),a}return o.value},Ru=n=>async(e,t,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=e._zod.run({value:t,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(c=>gn(c,s,pn())));throw Fg(a,i==null?void 0:i.callee),a}return o.value},La=n=>(e,t,r)=>{const i=r?{...r,async:!1}:{async:!1},s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new Rr;return s.issues.length?{success:!1,error:new(n??Vg)(s.issues.map(o=>gn(o,i,pn())))}:{success:!0,data:s.value}},g$=La(jg),Ma=n=>async(e,t,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=e._zod.run({value:t,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new n(s.issues.map(o=>gn(o,i,pn())))}:{success:!0,data:s.value}},m$=Ma(jg),y$=n=>(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Pu(n)(e,t,i)},v$=n=>(e,t,r)=>Pu(n)(e,t,r),b$=n=>async(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ru(n)(e,t,i)},w$=n=>async(e,t,r)=>Ru(n)(e,t,r),_$=n=>(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return La(n)(e,t,i)},S$=n=>(e,t,r)=>La(n)(e,t,r),k$=n=>async(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ma(n)(e,t,i)},E$=n=>async(e,t,r)=>Ma(n)(e,t,r),$$=/^[cC][^\s-]{8,}$/,A$=/^[0-9a-z]+$/,x$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,T$=/^[0-9a-vA-V]{20}$/,C$=/^[A-Za-z0-9]{27}$/,I$=/^[a-zA-Z0-9_-]{21}$/,P$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,R$=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,tf=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,D$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,O$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function z$(){return new RegExp(O$,"u")}const L$=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,M$=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,N$=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,U$=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,F$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Bg=/^[A-Za-z0-9_-]*$/,Z$=/^\+[1-9]\d{6,14}$/,Gg="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",H$=new RegExp(`^${Gg}$`);function Wg(n){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${e}`:n.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${n.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function V$(n){return new RegExp(`^${Wg(n)}$`)}function j$(n){const e=Wg({precision:n.precision}),t=["Z"];n.local&&t.push(""),n.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${e}(?:${t.join("|")})`;return new RegExp(`^${Gg}T(?:${r})$`)}const B$=n=>{const e=n?`[\\s\\S]{${(n==null?void 0:n.minimum)??0},${(n==null?void 0:n.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},G$=/^-?\d+$/,qg=/^-?\d+(?:\.\d+)?$/,W$=/^(?:true|false)$/i,q$=/^[^A-Z]*$/,Y$=/^[^a-z]*$/,We=$("$ZodCheck",(n,e)=>{var t;n._zod??(n._zod={}),n._zod.def=e,(t=n._zod).onattach??(t.onattach=[])}),Yg={number:"number",bigint:"bigint",object:"date"},Kg=$("$ZodCheckLessThan",(n,e)=>{We.init(n,e);const t=Yg[typeof e.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?i.maximum=e.value:i.exclusiveMaximum=e.value)}),n._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:t,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),Jg=$("$ZodCheckGreaterThan",(n,e)=>{We.init(n,e);const t=Yg[typeof e.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?i.minimum=e.value:i.exclusiveMinimum=e.value)}),n._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:t,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),K$=$("$ZodCheckMultipleOf",(n,e)=>{We.init(n,e),n._zod.onattach.push(t=>{var r;(r=t._zod.bag).multipleOf??(r.multipleOf=e.value)}),n._zod.check=t=>{if(typeof t.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof t.value=="bigint"?t.value%e.value===BigInt(0):e$(t.value,e.value)===0)||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:e.value,input:t.value,inst:n,continue:!e.abort})}}),J$=$("$ZodCheckNumberFormat",(n,e)=>{var o;We.init(n,e),e.format=e.format||"float64";const t=(o=e.format)==null?void 0:o.includes("int"),r=t?"int":"number",[i,s]=s$[e.format];n._zod.onattach.push(a=>{const c=a._zod.bag;c.format=e.format,c.minimum=i,c.maximum=s,t&&(c.pattern=G$)}),n._zod.check=a=>{const c=a.value;if(t){if(!Number.isInteger(c)){a.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:c,inst:n});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!e.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!e.abort});return}}c<i&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!e.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:n,continue:!e.abort})}}),X$=$("$ZodCheckMaxLength",(n,e)=>{var t;We.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Tu(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<i&&(r._zod.bag.maximum=e.maximum)}),n._zod.check=r=>{const i=r.value;if(i.length<=e.maximum)return;const o=Iu(i);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),Q$=$("$ZodCheckMinLength",(n,e)=>{var t;We.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Tu(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(r._zod.bag.minimum=e.minimum)}),n._zod.check=r=>{const i=r.value;if(i.length>=e.minimum)return;const o=Iu(i);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),eA=$("$ZodCheckLengthEquals",(n,e)=>{var t;We.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Tu(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=e.length,i.maximum=e.length,i.length=e.length}),n._zod.check=r=>{const i=r.value,s=i.length;if(s===e.length)return;const o=Iu(i),a=s>e.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:r.value,inst:n,continue:!e.abort})}}),Na=$("$ZodCheckStringFormat",(n,e)=>{var t,r;We.init(n,e),n._zod.onattach.push(i=>{const s=i._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(t=n._zod).check??(t.check=i=>{e.pattern.lastIndex=0,!e.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:e.format,input:i.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:n,continue:!e.abort})}):(r=n._zod).check??(r.check=()=>{})}),tA=$("$ZodCheckRegex",(n,e)=>{Na.init(n,e),n._zod.check=t=>{e.pattern.lastIndex=0,!e.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:e.pattern.toString(),inst:n,continue:!e.abort})}}),nA=$("$ZodCheckLowerCase",(n,e)=>{e.pattern??(e.pattern=q$),Na.init(n,e)}),rA=$("$ZodCheckUpperCase",(n,e)=>{e.pattern??(e.pattern=Y$),Na.init(n,e)}),iA=$("$ZodCheckIncludes",(n,e)=>{We.init(n,e);const t=ei(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position}}${t}`:t);e.pattern=r,n._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),n._zod.check=i=>{i.value.includes(e.includes,e.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:i.value,inst:n,continue:!e.abort})}}),sA=$("$ZodCheckStartsWith",(n,e)=>{We.init(n,e);const t=new RegExp(`^${ei(e.prefix)}.*`);e.pattern??(e.pattern=t),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._zod.check=r=>{r.value.startsWith(e.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:r.value,inst:n,continue:!e.abort})}}),oA=$("$ZodCheckEndsWith",(n,e)=>{We.init(n,e);const t=new RegExp(`.*${ei(e.suffix)}$`);e.pattern??(e.pattern=t),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._zod.check=r=>{r.value.endsWith(e.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:r.value,inst:n,continue:!e.abort})}}),aA=$("$ZodCheckOverwrite",(n,e)=>{We.init(n,e),n._zod.check=t=>{t.value=e.tx(t.value)}});class lA{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const r=e.split(`
5
+ `).filter(o=>o),i=Math.min(...r.map(o=>o.length-o.trimStart().length)),s=r.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const e=Function,t=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new e(...t,i.join(`
6
+ `))}}const cA={major:4,minor:3,patch:6},he=$("$ZodType",(n,e)=>{var i;var t;n??(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=cA;const r=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&r.unshift(n);for(const s of r)for(const o of s._zod.onattach)o(n);if(r.length===0)(t=n._zod).deferred??(t.deferred=[]),(i=n._zod.deferred)==null||i.push(()=>{n._zod.run=n._zod.parse});else{const s=(a,c,u)=>{let d=Cr(a),f;for(const v of c){if(v._zod.def.when){if(!v._zod.def.when(a))continue}else if(d)continue;const y=a.issues.length,A=v._zod.check(a);if(A instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Rr;if(f||A instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await A,a.issues.length!==y&&(d||(d=Cr(a,y)))});else{if(a.issues.length===y)continue;d||(d=Cr(a,y))}}return f?f.then(()=>a):a},o=(a,c,u)=>{if(Cr(a))return a.aborted=!0,a;const d=s(c,r,u);if(d instanceof Promise){if(u.async===!1)throw new Rr;return d.then(f=>n._zod.parse(f,u))}return n._zod.parse(d,u)};n._zod.run=(a,c)=>{if(c.skipChecks)return n._zod.parse(a,c);if(c.direction==="backward"){const d=n._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(f=>o(f,a,c)):o(d,a,c)}const u=n._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new Rr;return u.then(d=>s(d,r,c))}return s(u,r,c)}}X(n,"~standard",()=>({validate:s=>{var o;try{const a=g$(n,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return m$(n,s).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),Du=$("$ZodString",(n,e)=>{var t;he.init(n,e),n._zod.pattern=[...((t=n==null?void 0:n._zod.bag)==null?void 0:t.patterns)??[]].pop()??B$(n._zod.bag),n._zod.parse=(r,i)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:n}),r}}),ae=$("$ZodStringFormat",(n,e)=>{Na.init(n,e),Du.init(n,e)}),uA=$("$ZodGUID",(n,e)=>{e.pattern??(e.pattern=R$),ae.init(n,e)}),hA=$("$ZodUUID",(n,e)=>{if(e.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(r===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=tf(r))}else e.pattern??(e.pattern=tf());ae.init(n,e)}),dA=$("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=D$),ae.init(n,e)}),fA=$("$ZodURL",(n,e)=>{ae.init(n,e),n._zod.check=t=>{try{const r=t.value.trim(),i=new URL(r);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(i.hostname)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:t.value,inst:n,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:t.value,inst:n,continue:!e.abort})),e.normalize?t.value=i.href:t.value=r;return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort})}}}),pA=$("$ZodEmoji",(n,e)=>{e.pattern??(e.pattern=z$()),ae.init(n,e)}),gA=$("$ZodNanoID",(n,e)=>{e.pattern??(e.pattern=I$),ae.init(n,e)}),mA=$("$ZodCUID",(n,e)=>{e.pattern??(e.pattern=$$),ae.init(n,e)}),yA=$("$ZodCUID2",(n,e)=>{e.pattern??(e.pattern=A$),ae.init(n,e)}),vA=$("$ZodULID",(n,e)=>{e.pattern??(e.pattern=x$),ae.init(n,e)}),bA=$("$ZodXID",(n,e)=>{e.pattern??(e.pattern=T$),ae.init(n,e)}),wA=$("$ZodKSUID",(n,e)=>{e.pattern??(e.pattern=C$),ae.init(n,e)}),_A=$("$ZodISODateTime",(n,e)=>{e.pattern??(e.pattern=j$(e)),ae.init(n,e)}),SA=$("$ZodISODate",(n,e)=>{e.pattern??(e.pattern=H$),ae.init(n,e)}),kA=$("$ZodISOTime",(n,e)=>{e.pattern??(e.pattern=V$(e)),ae.init(n,e)}),EA=$("$ZodISODuration",(n,e)=>{e.pattern??(e.pattern=P$),ae.init(n,e)}),$A=$("$ZodIPv4",(n,e)=>{e.pattern??(e.pattern=L$),ae.init(n,e),n._zod.bag.format="ipv4"}),AA=$("$ZodIPv6",(n,e)=>{e.pattern??(e.pattern=M$),ae.init(n,e),n._zod.bag.format="ipv6",n._zod.check=t=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:n,continue:!e.abort})}}}),xA=$("$ZodCIDRv4",(n,e)=>{e.pattern??(e.pattern=N$),ae.init(n,e)}),TA=$("$ZodCIDRv6",(n,e)=>{e.pattern??(e.pattern=U$),ae.init(n,e),n._zod.check=t=>{const r=t.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:n,continue:!e.abort})}}});function Xg(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}const CA=$("$ZodBase64",(n,e)=>{e.pattern??(e.pattern=F$),ae.init(n,e),n._zod.bag.contentEncoding="base64",n._zod.check=t=>{Xg(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:n,continue:!e.abort})}});function IA(n){if(!Bg.test(n))return!1;const e=n.replace(/[-_]/g,r=>r==="-"?"+":"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return Xg(t)}const PA=$("$ZodBase64URL",(n,e)=>{e.pattern??(e.pattern=Bg),ae.init(n,e),n._zod.bag.contentEncoding="base64url",n._zod.check=t=>{IA(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:n,continue:!e.abort})}}),RA=$("$ZodE164",(n,e)=>{e.pattern??(e.pattern=Z$),ae.init(n,e)});function DA(n,e=null){try{const t=n.split(".");if(t.length!==3)return!1;const[r]=t;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&(!("alg"in i)||i.alg!==e))}catch{return!1}}const OA=$("$ZodJWT",(n,e)=>{ae.init(n,e),n._zod.check=t=>{DA(t.value,e.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:n,continue:!e.abort})}}),Qg=$("$ZodNumber",(n,e)=>{he.init(n,e),n._zod.pattern=n._zod.bag.pattern??qg,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=Number(t.value)}catch{}const i=t.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return t;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return t.issues.push({expected:"number",code:"invalid_type",input:i,inst:n,...s?{received:s}:{}}),t}}),zA=$("$ZodNumberFormat",(n,e)=>{J$.init(n,e),Qg.init(n,e)}),LA=$("$ZodBoolean",(n,e)=>{he.init(n,e),n._zod.pattern=W$,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=!!t.value}catch{}const i=t.value;return typeof i=="boolean"||t.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:n}),t}}),MA=$("$ZodUnknown",(n,e)=>{he.init(n,e),n._zod.parse=t=>t}),NA=$("$ZodNever",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:n}),t)});function nf(n,e,t){n.issues.length&&e.issues.push(...Ir(t,n.issues)),e.value[t]=n.value}const UA=$("$ZodArray",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>{const i=t.value;if(!Array.isArray(i))return t.issues.push({expected:"array",code:"invalid_type",input:i,inst:n}),t;t.value=Array(i.length);const s=[];for(let o=0;o<i.length;o++){const a=i[o],c=e.element._zod.run({value:a,issues:[]},r);c instanceof Promise?s.push(c.then(u=>nf(u,t,o))):nf(c,t,o)}return s.length?Promise.all(s).then(()=>t):t}});function ea(n,e,t,r,i){if(n.issues.length){if(i&&!(t in r))return;e.issues.push(...Ir(t,n.issues))}n.value===void 0?t in r&&(e.value[t]=void 0):e.value[t]=n.value}function em(n){var r,i,s,o;const e=Object.keys(n.shape);for(const a of e)if(!((o=(s=(i=(r=n.shape)==null?void 0:r[a])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const t=i$(n.shape);return{...n,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(t)}}function tm(n,e,t,r,i,s){const o=[],a=i.keySet,c=i.catchall._zod,u=c.def.type,d=c.optout==="optional";for(const f in e){if(a.has(f))continue;if(u==="never"){o.push(f);continue}const v=c.run({value:e[f],issues:[]},r);v instanceof Promise?n.push(v.then(y=>ea(y,t,f,e,d))):ea(v,t,f,e,d)}return o.length&&t.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:s}),n.length?Promise.all(n).then(()=>t):t}const FA=$("$ZodObject",(n,e)=>{he.init(n,e);const t=Object.getOwnPropertyDescriptor(e,"shape");if(!(t!=null&&t.get)){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const c={...a};return Object.defineProperty(e,"shape",{value:c}),c}})}const r=xu(()=>em(e));X(n._zod,"propValues",()=>{const a=e.shape,c={};for(const u in a){const d=a[u]._zod;if(d.values){c[u]??(c[u]=new Set);for(const f of d.values)c[u].add(f)}}return c});const i=Qo,s=e.catchall;let o;n._zod.parse=(a,c)=>{o??(o=r.value);const u=a.value;if(!i(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:n}),a;a.value={};const d=[],f=o.shape;for(const v of o.keys){const y=f[v],A=y._zod.optout==="optional",k=y._zod.run({value:u[v],issues:[]},c);k instanceof Promise?d.push(k.then(I=>ea(I,a,v,u,A))):ea(k,a,v,u,A)}return s?tm(d,u,a,c,r.value,n):d.length?Promise.all(d).then(()=>a):a}}),ZA=$("$ZodObjectJIT",(n,e)=>{FA.init(n,e);const t=n._zod.parse,r=xu(()=>em(e)),i=v=>{var le;const y=new lA(["shape","payload","ctx"]),A=r.value,k=M=>{const Z=ef(M);return`shape[${Z}]._zod.run({ value: input[${Z}], issues: [] }, ctx)`};y.write("const input = payload.value;");const I=Object.create(null);let B=0;for(const M of A.keys)I[M]=`key_${B++}`;y.write("const newResult = {};");for(const M of A.keys){const Z=I[M],U=ef(M),ge=v[M],ce=((le=ge==null?void 0:ge._zod)==null?void 0:le.optout)==="optional";y.write(`const ${Z} = ${k(M)};`),ce?y.write(`
7
+ if (${Z}.issues.length) {
8
+ if (${U} in input) {
9
+ payload.issues = payload.issues.concat(${Z}.issues.map(iss => ({
10
+ ...iss,
11
+ path: iss.path ? [${U}, ...iss.path] : [${U}]
12
+ })));
13
+ }
14
+ }
15
+
16
+ if (${Z}.value === undefined) {
17
+ if (${U} in input) {
18
+ newResult[${U}] = undefined;
19
+ }
20
+ } else {
21
+ newResult[${U}] = ${Z}.value;
22
+ }
23
+
24
+ `):y.write(`
25
+ if (${Z}.issues.length) {
26
+ payload.issues = payload.issues.concat(${Z}.issues.map(iss => ({
27
+ ...iss,
28
+ path: iss.path ? [${U}, ...iss.path] : [${U}]
29
+ })));
30
+ }
31
+
32
+ if (${Z}.value === undefined) {
33
+ if (${U} in input) {
34
+ newResult[${U}] = undefined;
35
+ }
36
+ } else {
37
+ newResult[${U}] = ${Z}.value;
38
+ }
39
+
40
+ `)}y.write("payload.value = newResult;"),y.write("return payload;");const P=y.compile();return(M,Z)=>P(v,M,Z)};let s;const o=Qo,a=!Ng.jitless,u=a&&n$.value,d=e.catchall;let f;n._zod.parse=(v,y)=>{f??(f=r.value);const A=v.value;return o(A)?a&&u&&(y==null?void 0:y.async)===!1&&y.jitless!==!0?(s||(s=i(e.shape)),v=s(v,y),d?tm([],A,v,y,f,n):v):t(v,y):(v.issues.push({expected:"object",code:"invalid_type",input:A,inst:n}),v)}});function rf(n,e,t,r){for(const s of n)if(s.issues.length===0)return e.value=s.value,e;const i=n.filter(s=>!Cr(s));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:n.map(s=>s.issues.map(o=>gn(o,r,pn())))}),e)}const HA=$("$ZodUnion",(n,e)=>{he.init(n,e),X(n._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),X(n._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),X(n._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),X(n._zod,"pattern",()=>{if(e.options.every(i=>i._zod.pattern)){const i=e.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>Cu(s.source)).join("|")})$`)}});const t=e.options.length===1,r=e.options[0]._zod.run;n._zod.parse=(i,s)=>{if(t)return r(i,s);let o=!1;const a=[];for(const c of e.options){const u=c._zod.run({value:i.value,issues:[]},s);if(u instanceof Promise)a.push(u),o=!0;else{if(u.issues.length===0)return u;a.push(u)}}return o?Promise.all(a).then(c=>rf(c,i,n,s)):rf(a,i,n,s)}}),VA=$("$ZodIntersection",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>{const i=t.value,s=e.left._zod.run({value:i,issues:[]},r),o=e.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([c,u])=>sf(t,c,u)):sf(t,s,o)}});function dc(n,e){if(n===e)return{valid:!0,data:n};if(n instanceof Date&&e instanceof Date&&+n==+e)return{valid:!0,data:n};if(Qr(n)&&Qr(e)){const t=Object.keys(e),r=Object.keys(n).filter(s=>t.indexOf(s)!==-1),i={...n,...e};for(const s of r){const o=dc(n[s],e[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let r=0;r<n.length;r++){const i=n[r],s=e[r],o=dc(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};t.push(o.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function sf(n,e,t){const r=new Map;let i;for(const a of e.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else n.issues.push(a);for(const a of t.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else n.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&n.issues.push({...i,keys:s}),Cr(n))return n;const o=dc(e.value,t.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return n.value=o.data,n}const jA=$("$ZodRecord",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>{const i=t.value;if(!Qr(i))return t.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),t;const s=[],o=e.keyType._zod.values;if(o){t.value={};const a=new Set;for(const u of o)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const d=e.valueType._zod.run({value:i[u],issues:[]},r);d instanceof Promise?s.push(d.then(f=>{f.issues.length&&t.issues.push(...Ir(u,f.issues)),t.value[u]=f.value})):(d.issues.length&&t.issues.push(...Ir(u,d.issues)),t.value[u]=d.value)}let c;for(const u in i)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&t.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:c})}else{t.value={};for(const a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let c=e.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&qg.test(a)&&c.issues.length){const f=e.keyType._zod.run({value:Number(a),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(c=f)}if(c.issues.length){e.mode==="loose"?t.value[a]=i[a]:t.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(f=>gn(f,r,pn())),input:a,path:[a],inst:n});continue}const d=e.valueType._zod.run({value:i[a],issues:[]},r);d instanceof Promise?s.push(d.then(f=>{f.issues.length&&t.issues.push(...Ir(a,f.issues)),t.value[c.value]=f.value})):(d.issues.length&&t.issues.push(...Ir(a,d.issues)),t.value[c.value]=d.value)}}return s.length?Promise.all(s).then(()=>t):t}}),BA=$("$ZodEnum",(n,e)=>{he.init(n,e);const t=Ug(e.entries),r=new Set(t);n._zod.values=r,n._zod.pattern=new RegExp(`^(${t.filter(i=>r$.has(typeof i)).map(i=>typeof i=="string"?ei(i):i.toString()).join("|")})$`),n._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:t,input:o,inst:n}),i}}),GA=$("$ZodLiteral",(n,e)=>{if(he.init(n,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const t=new Set(e.values);n._zod.values=t,n._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?ei(r):r?ei(r.toString()):String(r)).join("|")})$`),n._zod.parse=(r,i)=>{const s=r.value;return t.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:n}),r}}),WA=$("$ZodTransform",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new Mg(n.constructor.name);const i=e.transform(t.value,t);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(t.value=o,t));if(i instanceof Promise)throw new Rr;return t.value=i,t}});function of(n,e){return n.issues.length&&e===void 0?{issues:[],value:void 0}:n}const nm=$("$ZodOptional",(n,e)=>{he.init(n,e),n._zod.optin="optional",n._zod.optout="optional",X(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),X(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${Cu(t.source)})?$`):void 0}),n._zod.parse=(t,r)=>{if(e.innerType._zod.optin==="optional"){const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>of(s,t.value)):of(i,t.value)}return t.value===void 0?t:e.innerType._zod.run(t,r)}}),qA=$("$ZodExactOptional",(n,e)=>{nm.init(n,e),X(n._zod,"values",()=>e.innerType._zod.values),X(n._zod,"pattern",()=>e.innerType._zod.pattern),n._zod.parse=(t,r)=>e.innerType._zod.run(t,r)}),YA=$("$ZodNullable",(n,e)=>{he.init(n,e),X(n._zod,"optin",()=>e.innerType._zod.optin),X(n._zod,"optout",()=>e.innerType._zod.optout),X(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${Cu(t.source)}|null)$`):void 0}),X(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),n._zod.parse=(t,r)=>t.value===null?t:e.innerType._zod.run(t,r)}),KA=$("$ZodDefault",(n,e)=>{he.init(n,e),n._zod.optin="optional",X(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);if(t.value===void 0)return t.value=e.defaultValue,t;const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>af(s,e)):af(i,e)}});function af(n,e){return n.value===void 0&&(n.value=e.defaultValue),n}const JA=$("$ZodPrefault",(n,e)=>{he.init(n,e),n._zod.optin="optional",X(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>(r.direction==="backward"||t.value===void 0&&(t.value=e.defaultValue),e.innerType._zod.run(t,r))}),XA=$("$ZodNonOptional",(n,e)=>{he.init(n,e),X(n._zod,"values",()=>{const t=e.innerType._zod.values;return t?new Set([...t].filter(r=>r!==void 0)):void 0}),n._zod.parse=(t,r)=>{const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>lf(s,n)):lf(i,n)}});function lf(n,e){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:e}),n}const QA=$("$ZodCatch",(n,e)=>{he.init(n,e),X(n._zod,"optin",()=>e.innerType._zod.optin),X(n._zod,"optout",()=>e.innerType._zod.optout),X(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>(t.value=s.value,s.issues.length&&(t.value=e.catchValue({...t,error:{issues:s.issues.map(o=>gn(o,r,pn()))},input:t.value}),t.issues=[]),t)):(t.value=i.value,i.issues.length&&(t.value=e.catchValue({...t,error:{issues:i.issues.map(s=>gn(s,r,pn()))},input:t.value}),t.issues=[]),t)}}),ex=$("$ZodPipe",(n,e)=>{he.init(n,e),X(n._zod,"values",()=>e.in._zod.values),X(n._zod,"optin",()=>e.in._zod.optin),X(n._zod,"optout",()=>e.out._zod.optout),X(n._zod,"propValues",()=>e.in._zod.propValues),n._zod.parse=(t,r)=>{if(r.direction==="backward"){const s=e.out._zod.run(t,r);return s instanceof Promise?s.then(o=>wo(o,e.in,r)):wo(s,e.in,r)}const i=e.in._zod.run(t,r);return i instanceof Promise?i.then(s=>wo(s,e.out,r)):wo(i,e.out,r)}});function wo(n,e,t){return n.issues.length?(n.aborted=!0,n):e._zod.run({value:n.value,issues:n.issues},t)}const tx=$("$ZodReadonly",(n,e)=>{he.init(n,e),X(n._zod,"propValues",()=>e.innerType._zod.propValues),X(n._zod,"values",()=>e.innerType._zod.values),X(n._zod,"optin",()=>{var t,r;return(r=(t=e.innerType)==null?void 0:t._zod)==null?void 0:r.optin}),X(n._zod,"optout",()=>{var t,r;return(r=(t=e.innerType)==null?void 0:t._zod)==null?void 0:r.optout}),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(cf):cf(i)}});function cf(n){return n.value=Object.freeze(n.value),n}const nx=$("$ZodCustom",(n,e)=>{We.init(n,e),he.init(n,e),n._zod.parse=(t,r)=>t,n._zod.check=t=>{const r=t.value,i=e.fn(r);if(i instanceof Promise)return i.then(s=>uf(s,t,r,n));uf(i,t,r,n)}});function uf(n,e,t,r){if(!n){const i={code:"custom",input:t,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),e.issues.push(Ji(i))}}var hf;class rx{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const r=t[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};delete r.id;const i={...r,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function ix(){return new rx}(hf=globalThis).__zod_globalRegistry??(hf.__zod_globalRegistry=ix());const zi=globalThis.__zod_globalRegistry;function sx(n,e){return new n({type:"string",...O(e)})}function ox(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...O(e)})}function df(n,e){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...O(e)})}function ax(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...O(e)})}function lx(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(e)})}function cx(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(e)})}function ux(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(e)})}function hx(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...O(e)})}function dx(n,e){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...O(e)})}function fx(n,e){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(e)})}function px(n,e){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...O(e)})}function gx(n,e){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(e)})}function mx(n,e){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...O(e)})}function yx(n,e){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...O(e)})}function vx(n,e){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(e)})}function bx(n,e){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(e)})}function wx(n,e){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(e)})}function _x(n,e){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(e)})}function Sx(n,e){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(e)})}function kx(n,e){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...O(e)})}function Ex(n,e){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...O(e)})}function $x(n,e){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...O(e)})}function Ax(n,e){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...O(e)})}function xx(n,e){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(e)})}function Tx(n,e){return new n({type:"string",format:"date",check:"string_format",...O(e)})}function Cx(n,e){return new n({type:"string",format:"time",check:"string_format",precision:null,...O(e)})}function Ix(n,e){return new n({type:"string",format:"duration",check:"string_format",...O(e)})}function Px(n,e){return new n({type:"number",checks:[],...O(e)})}function Rx(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...O(e)})}function Dx(n,e){return new n({type:"boolean",...O(e)})}function Ox(n){return new n({type:"unknown"})}function zx(n,e){return new n({type:"never",...O(e)})}function ff(n,e){return new Kg({check:"less_than",...O(e),value:n,inclusive:!1})}function Rl(n,e){return new Kg({check:"less_than",...O(e),value:n,inclusive:!0})}function pf(n,e){return new Jg({check:"greater_than",...O(e),value:n,inclusive:!1})}function Dl(n,e){return new Jg({check:"greater_than",...O(e),value:n,inclusive:!0})}function gf(n,e){return new K$({check:"multiple_of",...O(e),value:n})}function rm(n,e){return new X$({check:"max_length",...O(e),maximum:n})}function ta(n,e){return new Q$({check:"min_length",...O(e),minimum:n})}function im(n,e){return new eA({check:"length_equals",...O(e),length:n})}function Lx(n,e){return new tA({check:"string_format",format:"regex",...O(e),pattern:n})}function Mx(n){return new nA({check:"string_format",format:"lowercase",...O(n)})}function Nx(n){return new rA({check:"string_format",format:"uppercase",...O(n)})}function Ux(n,e){return new iA({check:"string_format",format:"includes",...O(e),includes:n})}function Fx(n,e){return new sA({check:"string_format",format:"starts_with",...O(e),prefix:n})}function Zx(n,e){return new oA({check:"string_format",format:"ends_with",...O(e),suffix:n})}function fi(n){return new aA({check:"overwrite",tx:n})}function Hx(n){return fi(e=>e.normalize(n))}function Vx(){return fi(n=>n.trim())}function jx(){return fi(n=>n.toLowerCase())}function Bx(){return fi(n=>n.toUpperCase())}function Gx(){return fi(n=>t$(n))}function Wx(n,e,t){return new n({type:"array",element:e,...O(t)})}function qx(n,e,t){return new n({type:"custom",check:"custom",fn:e,...O(t)})}function Yx(n){const e=Kx(t=>(t.addIssue=r=>{if(typeof r=="string")t.issues.push(Ji(r,t.value,e._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=t.value),i.inst??(i.inst=e),i.continue??(i.continue=!e._zod.def.abort),t.issues.push(Ji(i))}},n(t.value,t)));return e}function Kx(n,e){const t=new We({check:"custom",...O(e)});return t._zod.check=n,t}function sm(n){let e=(n==null?void 0:n.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:n.processors??{},metadataRegistry:(n==null?void 0:n.metadata)??zi,target:e,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 ve(n,e,t={path:[],schemaPath:[]}){var d,f;var r;const i=n._zod.def,s=e.seen.get(n);if(s)return s.count++,t.schemaPath.includes(n)&&(s.cycle=t.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:t.path};e.seen.set(n,o);const a=(f=(d=n._zod).toJSONSchema)==null?void 0:f.call(d);if(a)o.schema=a;else{const v={...t,schemaPath:[...t.schemaPath,n],path:t.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(e,o.schema,v);else{const A=o.schema,k=e.processors[i.type];if(!k)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);k(n,e,A,v)}const y=n._zod.parent;y&&(o.ref||(o.ref=y),ve(y,e,v),e.seen.get(y).isParent=!0)}const c=e.metadataRegistry.get(n);return c&&Object.assign(o.schema,c),e.io==="input"&&Oe(n)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(n).schema}function om(n,e){var o,a,c,u;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const d of n.seen.entries()){const f=(o=n.metadataRegistry.get(d[0]))==null?void 0:o.id;if(f){const v=r.get(f);if(v&&v!==d[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(f,d[0])}}const i=d=>{var k;const f=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const I=(k=n.external.registry.get(d[0]))==null?void 0:k.id,B=n.external.uri??(le=>le);if(I)return{ref:B(I)};const P=d[1].defId??d[1].schema.id??`schema${n.counter++}`;return d[1].defId=P,{defId:P,ref:`${B("__shared")}#/${f}/${P}`}}if(d[1]===t)return{ref:"#"};const y=`#/${f}/`,A=d[1].schema.id??`__schema${n.counter++}`;return{defId:A,ref:y+A}},s=d=>{if(d[1].schema.$ref)return;const f=d[1],{ref:v,defId:y}=i(d);f.def={...f.schema},y&&(f.defId=y);const A=f.schema;for(const k in A)delete A[k];A.$ref=v};if(n.cycles==="throw")for(const d of n.seen.entries()){const f=d[1];if(f.cycle)throw new Error(`Cycle detected: #/${(a=f.cycle)==null?void 0:a.join("/")}/<root>
41
+
42
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of n.seen.entries()){const f=d[1];if(e===d[0]){s(d);continue}if(n.external){const y=(c=n.external.registry.get(d[0]))==null?void 0:c.id;if(e!==d[0]&&y){s(d);continue}}if((u=n.metadataRegistry.get(d[0]))==null?void 0:u.id){s(d);continue}if(f.cycle){s(d);continue}if(f.count>1&&n.reused==="ref"){s(d);continue}}}function am(n,e){var o,a,c;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const d=n.seen.get(u);if(d.ref===null)return;const f=d.def??d.schema,v={...f},y=d.ref;if(d.ref=null,y){r(y);const k=n.seen.get(y),I=k.schema;if(I.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(I)):Object.assign(f,I),Object.assign(f,v),u._zod.parent===y)for(const P in f)P==="$ref"||P==="allOf"||P in v||delete f[P];if(I.$ref&&k.def)for(const P in f)P==="$ref"||P==="allOf"||P in k.def&&JSON.stringify(f[P])===JSON.stringify(k.def[P])&&delete f[P]}const A=u._zod.parent;if(A&&A!==y){r(A);const k=n.seen.get(A);if(k!=null&&k.schema.$ref&&(f.$ref=k.schema.$ref,k.def))for(const I in f)I==="$ref"||I==="allOf"||I in k.def&&JSON.stringify(f[I])===JSON.stringify(k.def[I])&&delete f[I]}n.override({zodSchema:u,jsonSchema:f,path:d.path??[]})};for(const u of[...n.seen.entries()].reverse())r(u[0]);const i={};if(n.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":n.target,(o=n.external)!=null&&o.uri){const u=(a=n.external.registry.get(e))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=n.external.uri(u)}Object.assign(i,t.def??t.schema);const s=((c=n.external)==null?void 0:c.defs)??{};for(const u of n.seen.entries()){const d=u[1];d.def&&d.defId&&(s[d.defId]=d.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:{...e["~standard"],jsonSchema:{input:na(e,"input",n.processors),output:na(e,"output",n.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Oe(n,e){const t=e??{seen:new Set};if(t.seen.has(n))return!1;t.seen.add(n);const r=n._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Oe(r.element,t);if(r.type==="set")return Oe(r.valueType,t);if(r.type==="lazy")return Oe(r.getter(),t);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Oe(r.innerType,t);if(r.type==="intersection")return Oe(r.left,t)||Oe(r.right,t);if(r.type==="record"||r.type==="map")return Oe(r.keyType,t)||Oe(r.valueType,t);if(r.type==="pipe")return Oe(r.in,t)||Oe(r.out,t);if(r.type==="object"){for(const i in r.shape)if(Oe(r.shape[i],t))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(Oe(i,t))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(Oe(i,t))return!0;return!!(r.rest&&Oe(r.rest,t))}return!1}const Jx=(n,e={})=>t=>{const r=sm({...t,processors:e});return ve(n,r),om(r,n),am(r,n)},na=(n,e,t={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=sm({...i??{},target:s,io:e,processors:t});return ve(n,o),om(o,n),am(o,n)},Xx={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Qx=(n,e,t,r)=>{const i=t;i.type="string";const{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:u}=n._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=Xx[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){const d=[...c];d.length===1?i.pattern=d[0].source:d.length>1&&(i.allOf=[...d.map(f=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},eT=(n,e,t,r)=>{const i=t,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=n._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof d=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.minimum=d,i.exclusiveMinimum=!0):i.exclusiveMinimum=d),typeof s=="number"&&(i.minimum=s,typeof d=="number"&&e.target!=="draft-04"&&(d>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof o=="number"&&(i.maximum=o,typeof u=="number"&&e.target!=="draft-04"&&(u<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},tT=(n,e,t,r)=>{t.type="boolean"},nT=(n,e,t,r)=>{t.not={}},rT=(n,e,t,r)=>{},iT=(n,e,t,r)=>{const i=n._zod.def,s=Ug(i.entries);s.every(o=>typeof o=="number")&&(t.type="number"),s.every(o=>typeof o=="string")&&(t.type="string"),t.enum=s},sT=(n,e,t,r)=>{const i=n._zod.def,s=[];for(const o of i.values)if(o===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];t.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?t.enum=[o]:t.const=o}else s.every(o=>typeof o=="number")&&(t.type="number"),s.every(o=>typeof o=="string")&&(t.type="string"),s.every(o=>typeof o=="boolean")&&(t.type="boolean"),s.every(o=>o===null)&&(t.type="null"),t.enum=s},oT=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},aT=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},lT=(n,e,t,r)=>{const i=t,s=n._zod.def,{minimum:o,maximum:a}=n._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=ve(s.element,e,{...r,path:[...r.path,"items"]})},cT=(n,e,t,r)=>{var u;const i=t,s=n._zod.def;i.type="object",i.properties={};const o=s.shape;for(const d in o)i.properties[d]=ve(o[d],e,{...r,path:[...r.path,"properties",d]});const a=new Set(Object.keys(o)),c=new Set([...a].filter(d=>{const f=s.shape[d]._zod;return e.io==="input"?f.optin===void 0:f.optout===void 0}));c.size>0&&(i.required=Array.from(c)),((u=s.catchall)==null?void 0:u._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=ve(s.catchall,e,{...r,path:[...r.path,"additionalProperties"]})):e.io==="output"&&(i.additionalProperties=!1)},uT=(n,e,t,r)=>{const i=n._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>ve(a,e,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?t.oneOf=o:t.anyOf=o},hT=(n,e,t,r)=>{const i=n._zod.def,s=ve(i.left,e,{...r,path:[...r.path,"allOf",0]}),o=ve(i.right,e,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];t.allOf=c},dT=(n,e,t,r)=>{const i=t,s=n._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag,c=a==null?void 0:a.patterns;if(s.mode==="loose"&&c&&c.size>0){const d=ve(s.valueType,e,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const f of c)i.patternProperties[f.source]=d}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(i.propertyNames=ve(s.keyType,e,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=ve(s.valueType,e,{...r,path:[...r.path,"additionalProperties"]});const u=o._zod.values;if(u){const d=[...u].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(i.required=d)}},fT=(n,e,t,r)=>{const i=n._zod.def,s=ve(i.innerType,e,r),o=e.seen.get(n);e.target==="openapi-3.0"?(o.ref=i.innerType,t.nullable=!0):t.anyOf=[s,{type:"null"}]},pT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType},gT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,t.default=JSON.parse(JSON.stringify(i.defaultValue))},mT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,e.io==="input"&&(t._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},yT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}t.default=o},vT=(n,e,t,r)=>{const i=n._zod.def,s=e.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;ve(s,e,r);const o=e.seen.get(n);o.ref=s},bT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,t.readOnly=!0},lm=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType},wT=$("ZodISODateTime",(n,e)=>{_A.init(n,e),fe.init(n,e)});function _T(n){return xx(wT,n)}const ST=$("ZodISODate",(n,e)=>{SA.init(n,e),fe.init(n,e)});function kT(n){return Tx(ST,n)}const ET=$("ZodISOTime",(n,e)=>{kA.init(n,e),fe.init(n,e)});function $T(n){return Cx(ET,n)}const AT=$("ZodISODuration",(n,e)=>{EA.init(n,e),fe.init(n,e)});function xT(n){return Ix(AT,n)}const cm=(n,e)=>{Vg.init(n,e),n.name="ZodError",Object.defineProperties(n,{format:{value:t=>p$(n,t)},flatten:{value:t=>f$(n,t)},addIssue:{value:t=>{n.issues.push(t),n.message=JSON.stringify(n.issues,hc,2)}},addIssues:{value:t=>{n.issues.push(...t),n.message=JSON.stringify(n.issues,hc,2)}},isEmpty:{get(){return n.issues.length===0}}})},mf=$("ZodError",cm),ot=$("ZodError",cm,{Parent:Error}),TT=Pu(ot),CT=Ru(ot),IT=La(ot),PT=Ma(ot),RT=y$(ot),DT=v$(ot),OT=b$(ot),zT=w$(ot),LT=_$(ot),MT=S$(ot),NT=k$(ot),UT=E$(ot),de=$("ZodType",(n,e)=>(he.init(n,e),Object.assign(n["~standard"],{jsonSchema:{input:na(n,"input"),output:na(n,"output")}}),n.toJSONSchema=Jx(n,{}),n.def=e,n.type=e.type,Object.defineProperty(n,"_def",{value:e}),n.check=(...t)=>n.clone(_n(e,{checks:[...e.checks??[],...t.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),n.with=n.check,n.clone=(t,r)=>Sn(n,t,r),n.brand=()=>n,n.register=(t,r)=>(t.add(n,r),n),n.parse=(t,r)=>TT(n,t,r,{callee:n.parse}),n.safeParse=(t,r)=>IT(n,t,r),n.parseAsync=async(t,r)=>CT(n,t,r,{callee:n.parseAsync}),n.safeParseAsync=async(t,r)=>PT(n,t,r),n.spa=n.safeParseAsync,n.encode=(t,r)=>RT(n,t,r),n.decode=(t,r)=>DT(n,t,r),n.encodeAsync=async(t,r)=>OT(n,t,r),n.decodeAsync=async(t,r)=>zT(n,t,r),n.safeEncode=(t,r)=>LT(n,t,r),n.safeDecode=(t,r)=>MT(n,t,r),n.safeEncodeAsync=async(t,r)=>NT(n,t,r),n.safeDecodeAsync=async(t,r)=>UT(n,t,r),n.refine=(t,r)=>n.check(IC(t,r)),n.superRefine=t=>n.check(PC(t)),n.overwrite=t=>n.check(fi(t)),n.optional=()=>bf(n),n.exactOptional=()=>yC(n),n.nullable=()=>wf(n),n.nullish=()=>bf(wf(n)),n.nonoptional=t=>kC(n,t),n.array=()=>D(n),n.or=t=>H([n,t]),n.and=t=>Ua(n,t),n.transform=t=>_f(n,gC(t)),n.default=t=>wC(n,t),n.prefault=t=>SC(n,t),n.catch=t=>$C(n,t),n.pipe=t=>_f(n,t),n.readonly=()=>TC(n),n.describe=t=>{const r=n.clone();return zi.add(r,{description:t}),r},Object.defineProperty(n,"description",{get(){var t;return(t=zi.get(n))==null?void 0:t.description},configurable:!0}),n.meta=(...t)=>{if(t.length===0)return zi.get(n);const r=n.clone();return zi.add(r,t[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=t=>t(n),n)),um=$("_ZodString",(n,e)=>{Du.init(n,e),de.init(n,e),n._zod.processJSONSchema=(r,i,s)=>Qx(n,r,i);const t=n._zod.bag;n.format=t.format??null,n.minLength=t.minimum??null,n.maxLength=t.maximum??null,n.regex=(...r)=>n.check(Lx(...r)),n.includes=(...r)=>n.check(Ux(...r)),n.startsWith=(...r)=>n.check(Fx(...r)),n.endsWith=(...r)=>n.check(Zx(...r)),n.min=(...r)=>n.check(ta(...r)),n.max=(...r)=>n.check(rm(...r)),n.length=(...r)=>n.check(im(...r)),n.nonempty=(...r)=>n.check(ta(1,...r)),n.lowercase=r=>n.check(Mx(r)),n.uppercase=r=>n.check(Nx(r)),n.trim=()=>n.check(Vx()),n.normalize=(...r)=>n.check(Hx(...r)),n.toLowerCase=()=>n.check(jx()),n.toUpperCase=()=>n.check(Bx()),n.slugify=()=>n.check(Gx())}),FT=$("ZodString",(n,e)=>{Du.init(n,e),um.init(n,e),n.email=t=>n.check(ox(ZT,t)),n.url=t=>n.check(hx(HT,t)),n.jwt=t=>n.check(Ax(rC,t)),n.emoji=t=>n.check(dx(VT,t)),n.guid=t=>n.check(df(yf,t)),n.uuid=t=>n.check(ax(_o,t)),n.uuidv4=t=>n.check(lx(_o,t)),n.uuidv6=t=>n.check(cx(_o,t)),n.uuidv7=t=>n.check(ux(_o,t)),n.nanoid=t=>n.check(fx(jT,t)),n.guid=t=>n.check(df(yf,t)),n.cuid=t=>n.check(px(BT,t)),n.cuid2=t=>n.check(gx(GT,t)),n.ulid=t=>n.check(mx(WT,t)),n.base64=t=>n.check(kx(eC,t)),n.base64url=t=>n.check(Ex(tC,t)),n.xid=t=>n.check(yx(qT,t)),n.ksuid=t=>n.check(vx(YT,t)),n.ipv4=t=>n.check(bx(KT,t)),n.ipv6=t=>n.check(wx(JT,t)),n.cidrv4=t=>n.check(_x(XT,t)),n.cidrv6=t=>n.check(Sx(QT,t)),n.e164=t=>n.check($x(nC,t)),n.datetime=t=>n.check(_T(t)),n.date=t=>n.check(kT(t)),n.time=t=>n.check($T(t)),n.duration=t=>n.check(xT(t))});function h(n){return sx(FT,n)}const fe=$("ZodStringFormat",(n,e)=>{ae.init(n,e),um.init(n,e)}),ZT=$("ZodEmail",(n,e)=>{dA.init(n,e),fe.init(n,e)}),yf=$("ZodGUID",(n,e)=>{uA.init(n,e),fe.init(n,e)}),_o=$("ZodUUID",(n,e)=>{hA.init(n,e),fe.init(n,e)}),HT=$("ZodURL",(n,e)=>{fA.init(n,e),fe.init(n,e)}),VT=$("ZodEmoji",(n,e)=>{pA.init(n,e),fe.init(n,e)}),jT=$("ZodNanoID",(n,e)=>{gA.init(n,e),fe.init(n,e)}),BT=$("ZodCUID",(n,e)=>{mA.init(n,e),fe.init(n,e)}),GT=$("ZodCUID2",(n,e)=>{yA.init(n,e),fe.init(n,e)}),WT=$("ZodULID",(n,e)=>{vA.init(n,e),fe.init(n,e)}),qT=$("ZodXID",(n,e)=>{bA.init(n,e),fe.init(n,e)}),YT=$("ZodKSUID",(n,e)=>{wA.init(n,e),fe.init(n,e)}),KT=$("ZodIPv4",(n,e)=>{$A.init(n,e),fe.init(n,e)}),JT=$("ZodIPv6",(n,e)=>{AA.init(n,e),fe.init(n,e)}),XT=$("ZodCIDRv4",(n,e)=>{xA.init(n,e),fe.init(n,e)}),QT=$("ZodCIDRv6",(n,e)=>{TA.init(n,e),fe.init(n,e)}),eC=$("ZodBase64",(n,e)=>{CA.init(n,e),fe.init(n,e)}),tC=$("ZodBase64URL",(n,e)=>{PA.init(n,e),fe.init(n,e)}),nC=$("ZodE164",(n,e)=>{RA.init(n,e),fe.init(n,e)}),rC=$("ZodJWT",(n,e)=>{OA.init(n,e),fe.init(n,e)}),hm=$("ZodNumber",(n,e)=>{Qg.init(n,e),de.init(n,e),n._zod.processJSONSchema=(r,i,s)=>eT(n,r,i),n.gt=(r,i)=>n.check(pf(r,i)),n.gte=(r,i)=>n.check(Dl(r,i)),n.min=(r,i)=>n.check(Dl(r,i)),n.lt=(r,i)=>n.check(ff(r,i)),n.lte=(r,i)=>n.check(Rl(r,i)),n.max=(r,i)=>n.check(Rl(r,i)),n.int=r=>n.check(vf(r)),n.safe=r=>n.check(vf(r)),n.positive=r=>n.check(pf(0,r)),n.nonnegative=r=>n.check(Dl(0,r)),n.negative=r=>n.check(ff(0,r)),n.nonpositive=r=>n.check(Rl(0,r)),n.multipleOf=(r,i)=>n.check(gf(r,i)),n.step=(r,i)=>n.check(gf(r,i)),n.finite=()=>n;const t=n._zod.bag;n.minValue=Math.max(t.minimum??Number.NEGATIVE_INFINITY,t.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(t.maximum??Number.POSITIVE_INFINITY,t.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(t.format??"").includes("int")||Number.isSafeInteger(t.multipleOf??.5),n.isFinite=!0,n.format=t.format??null});function N(n){return Px(hm,n)}const iC=$("ZodNumberFormat",(n,e)=>{zA.init(n,e),hm.init(n,e)});function vf(n){return Rx(iC,n)}const sC=$("ZodBoolean",(n,e)=>{LA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>tT(n,t,r)});function Ee(n){return Dx(sC,n)}const oC=$("ZodUnknown",(n,e)=>{MA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>rT()});function w(){return Ox(oC)}const aC=$("ZodNever",(n,e)=>{NA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>nT(n,t,r)});function lC(n){return zx(aC,n)}const cC=$("ZodArray",(n,e)=>{UA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>lT(n,t,r,i),n.element=e.element,n.min=(t,r)=>n.check(ta(t,r)),n.nonempty=t=>n.check(ta(1,t)),n.max=(t,r)=>n.check(rm(t,r)),n.length=(t,r)=>n.check(im(t,r)),n.unwrap=()=>n.element});function D(n,e){return Wx(cC,n,e)}const dm=$("ZodObject",(n,e)=>{ZA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>cT(n,t,r,i),X(n,"shape",()=>e.shape),n.keyof=()=>ra(Object.keys(n._zod.def.shape)),n.catchall=t=>n.clone({...n._zod.def,catchall:t}),n.passthrough=()=>n.clone({...n._zod.def,catchall:w()}),n.loose=()=>n.clone({...n._zod.def,catchall:w()}),n.strict=()=>n.clone({...n._zod.def,catchall:lC()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=t=>l$(n,t),n.safeExtend=t=>c$(n,t),n.merge=t=>u$(n,t),n.pick=t=>o$(n,t),n.omit=t=>a$(n,t),n.partial=(...t)=>h$(pm,n,t[0]),n.required=(...t)=>d$(gm,n,t[0])});function fm(n,e){const t={type:"object",shape:n??{},...O(e)};return new dm(t)}function p(n,e){return new dm({type:"object",shape:n,catchall:w(),...O(e)})}const uC=$("ZodUnion",(n,e)=>{HA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>uT(n,t,r,i),n.options=e.options});function H(n,e){return new uC({type:"union",options:n,...O(e)})}const hC=$("ZodIntersection",(n,e)=>{VA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>hT(n,t,r,i)});function Ua(n,e){return new hC({type:"intersection",left:n,right:e})}const dC=$("ZodRecord",(n,e)=>{jA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>dT(n,t,r,i),n.keyType=e.keyType,n.valueType=e.valueType});function S(n,e,t){return new dC({type:"record",keyType:n,valueType:e,...O(t)})}const fc=$("ZodEnum",(n,e)=>{BA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(r,i,s)=>iT(n,r,i),n.enum=e.entries,n.options=Object.values(e.entries);const t=new Set(Object.keys(e.entries));n.extract=(r,i)=>{const s={};for(const o of r)if(t.has(o))s[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new fc({...e,checks:[],...O(i),entries:s})},n.exclude=(r,i)=>{const s={...e.entries};for(const o of r)if(t.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new fc({...e,checks:[],...O(i),entries:s})}});function ra(n,e){const t=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new fc({type:"enum",entries:t,...O(e)})}const fC=$("ZodLiteral",(n,e)=>{GA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>sT(n,t,r),n.values=new Set(e.values),Object.defineProperty(n,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function x(n,e){return new fC({type:"literal",values:Array.isArray(n)?n:[n],...O(e)})}const pC=$("ZodTransform",(n,e)=>{WA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>aT(n,t),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new Mg(n.constructor.name);t.addIssue=s=>{if(typeof s=="string")t.issues.push(Ji(s,t.value,e));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=t.value),o.inst??(o.inst=n),t.issues.push(Ji(o))}};const i=e.transform(t.value,t);return i instanceof Promise?i.then(s=>(t.value=s,t)):(t.value=i,t)}});function gC(n){return new pC({type:"transform",transform:n})}const pm=$("ZodOptional",(n,e)=>{nm.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>lm(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function bf(n){return new pm({type:"optional",innerType:n})}const mC=$("ZodExactOptional",(n,e)=>{qA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>lm(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function yC(n){return new mC({type:"optional",innerType:n})}const vC=$("ZodNullable",(n,e)=>{YA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>fT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function wf(n){return new vC({type:"nullable",innerType:n})}const bC=$("ZodDefault",(n,e)=>{KA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>gT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function wC(n,e){return new bC({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():Zg(e)}})}const _C=$("ZodPrefault",(n,e)=>{JA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>mT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function SC(n,e){return new _C({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():Zg(e)}})}const gm=$("ZodNonOptional",(n,e)=>{XA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>pT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function kC(n,e){return new gm({type:"nonoptional",innerType:n,...O(e)})}const EC=$("ZodCatch",(n,e)=>{QA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>yT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function $C(n,e){return new EC({type:"catch",innerType:n,catchValue:typeof e=="function"?e:()=>e})}const AC=$("ZodPipe",(n,e)=>{ex.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>vT(n,t,r,i),n.in=e.in,n.out=e.out});function _f(n,e){return new AC({type:"pipe",in:n,out:e})}const xC=$("ZodReadonly",(n,e)=>{tx.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>bT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function TC(n){return new xC({type:"readonly",innerType:n})}const CC=$("ZodCustom",(n,e)=>{nx.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>oT(n,t)});function IC(n,e={}){return qx(CC,n,e)}function PC(n){return Yx(n)}const RC=["text/markdown","text/html"],DC=["committed","pending"];fm({id:h().min(1),type:ra(RC),title:h(),status:ra(DC),externalFilePath:h().optional()});fm({name:h().min(1),description:h(),accepts:D(h().min(1)).min(1)});function Ou(n){return typeof n=="object"&&n!==null}function OC(n){return!Ou(n)||n.type!=="ready"?!1:!("id"in n)}function zC(n){return!(!Ou(n)||n.type!=="update-content"||typeof n.id!="string"||typeof n.content!="string")}function LC(n){return!Ou(n)||n.type!=="wheel"||typeof n.deltaX!="number"||typeof n.deltaY!="number"||typeof n.shiftKey!="boolean"?!1:!("id"in n)}function MC(n,e){if(n===e)return 2;if(n==="*/*")return 0;const t=n.indexOf("/");if(t>0&&n.slice(t+1)==="*"){const r=n.slice(0,t),i=e.indexOf("/");if(i>0&&e.slice(0,i)===r)return 1}return null}function NC(n,e){let t=null;for(const r of n.accepts){const i=MC(r,e);i!==null&&(t===null||i>t)&&(t=i)}return t}function UC(n,e){let t=-1,r=null;for(const i of e){const s=NC(i,n);s!==null&&(s>t||s===t&&r!==null&&i.id<r.id)&&(t=s,r=i)}return r}const FC=4401;class pc extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class gc extends gt{constructor(t){super();b(this,"url");b(this,"name");b(this,"token");b(this,"status","disconnected");b(this,"screens",new Map);b(this,"views",[]);b(this,"client");b(this,"createSocket");b(this,"createClient");b(this,"socket",null);b(this,"connectAttempt",0);this.url=kt(t.url),this.name=t.name,this.token=t.token??null,this.createSocket=t.createSocket??(r=>new WebSocket(r)),this.createClient=t.createClient??((r,i)=>new V0(r,{token:i??void 0})),this.client=this.createClient(this.url,this.token)}async connect(){var i;this.connectAttempt+=1;const t=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this.token),this.status="connecting",this.dispatchEvent(new Q("change"));const r=this.createSocket(ZC(this.url,this.token));return this.socket=r,await new Promise((s,o)=>{let a=!1;const c=()=>{a||this.connectAttempt!==t||(a=!0,this.status="connected",this.dispatchEvent(new Q("change")),s())},u=f=>{a||this.connectAttempt!==t||(a=!0,this.status="disconnected",this.dispatchEvent(new Q("change")),o(f))},d=async()=>{try{const[{screens:f},v]=await Promise.all([this.client.screens.list(),this.client.views.list()]);this.screens=new Map(f.map(y=>[y.id,structuredClone(y)])),this.views=v,this.dispatchEvent(new Q("change")),c()}catch(f){u(f instanceof Error?f:new Error(String(f)))}};r.addEventListener("open",()=>{d()}),r.addEventListener("message",f=>{const v=VC(f);v&&(this.applyServerEvent(v),this.dispatchEvent(new xg("server-event",{serverURL:this.url,event:v})))}),r.addEventListener("close",f=>{if(this.connectAttempt===t){if(this.socket=null,HC(f)===FC){u(new pc);return}if(!a){u(new Error("Connection closed before initialization"));return}this.status="disconnected",this.dispatchEvent(new Q("change"))}}),r.addEventListener("error",()=>{u(new Error("WebSocket connection failed"))})})}disconnect(){var t;this.connectAttempt+=1,(t=this.socket)==null||t.close(),this.socket=null,this.status="disconnected",this.dispatchEvent(new Q("change"))}getViewURL(t){const r=UC(t.type,this.views);if(!r)return null;const i=`${this.url}/views/${encodeURIComponent(r.id)}/`;return this.token===null?i:`${i}?token=${encodeURIComponent(this.token)}`}getContentURL(t){const r=`${this.url}/artifacts/${encodeURIComponent(t)}/content`;return this.token===null?r:`${r}?token=${encodeURIComponent(this.token)}`}async createScreen(t){const{screen:r}=await this.client.screens.create({name:t});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(t){switch(t.type){case"screen-created":this.screens.set(t.screen.id,structuredClone(t.screen)),this.dispatchEvent(new No("screens-changed"));break;case"screen-updated":this.screens.set(t.screen.id,structuredClone(t.screen)),this.dispatchEvent(new No("screens-changed"));break;case"screen-removed":this.screens.delete(t.screenID),this.dispatchEvent(new No("screens-changed"));break;case"artifact-created":{const r=this.screens.get(t.screenID);r&&!Eg(r.layout,t.artifact.id)&&(r.layout=[...r.layout,kg(t.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(t.screenID);r&&(r.layout=pg(r.layout,t.artifactID));break}}}}function ZC(n,e){const t=new URL(n);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/events",t.search="",e&&t.searchParams.set("token",e),t.hash="",t.toString()}function HC(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}function VC(n){const e=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!e)return null;try{return JSON.parse(e)}catch{return null}}class jC extends gt{constructor(t){super();b(this,"servers",new Map);b(this,"localServerURL");b(this,"localStore");b(this,"createSocket");b(this,"lastActiveServerURL");b(this,"serverListeners",new Map);b(this,"handleLocalStoreChange",()=>{const t=this.localStore.get().activeServerURL;t!==this.lastActiveServerURL&&(this.lastActiveServerURL=t,this.dispatchEvent(new Q("change")))});this.localStore=t.localStore,this.localServerURL=t.localServerURL?kt(t.localServerURL):null,this.createSocket=t.createSocket??(r=>new WebSocket(r)),this.lastActiveServerURL=this.localStore.get().activeServerURL,this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const t=this.localStore.get().activeServerURL;return t===null?null:this.servers.get(t)??null}add(t){const r=kt(t.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,t);const s=()=>{this.dispatchEvent(new Q("change"))},o=c=>{this.dispatchEvent(new xg("server-event",{serverURL:c.serverURL,event:c.event}))},a=()=>{this.dispatchEvent(new No("screens-changed"))};t.addEventListener("change",s),t.addEventListener("server-event",o),t.addEventListener("screens-changed",a),this.serverListeners.set(r,{onServerChange:s,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new Q("change"))}remove(t){const r=kt(t);if(this.localServerURL&&r===this.localServerURL)return;const i=this.servers.get(r);if(!i)return;const s=this.serverListeners.get(r);s&&(i.removeEventListener("change",s.onServerChange),i.removeEventListener("server-event",s.onServerEvent),i.removeEventListener("screens-changed",s.onScreensChanged),this.serverListeners.delete(r)),i.disconnect(),this.servers.delete(r);const o=this.localStore.get(),a=o.activeServerURL===r;this.localStore.set({...o,servers:o.servers.filter(c=>c.url!==r),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new Q("change"))}setActive(t){const r=this.localStore.get(),i=t?kt(t.url):null;r.activeServerURL!==i&&this.localStore.set({...r,activeServerURL:i})}connectConfiguredServers(t,r){const i=this.localStore.get().servers,s=t?kt(t):null;for(const a of i){const c=kt(a.url),u=s!==null&&c===s,d=new gc({url:a.url,name:a.name,token:u?r??null:null,createSocket:this.createSocket});this.add(d),d.connect().catch(()=>{})}const o=s?this.servers.get(s)??null:null;this.setActive(o??this.servers.values().next().value??null)}addServer(t,r){const i=kt(t);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>kt(a.url)!==i),{url:i,name:r}]});const o=new gc({url:i,name:r,createSocket:this.createSocket});this.add(o),this.setActive(o),o.connect().catch(()=>{})}removeServer(t){this.remove(t)}}const se={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"},Ot={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"},BC=1,GC=p({_meta:S(h(),w()).nullish(),terminal:Ee().optional().default(!1)}),WC=p({_meta:S(h(),w()).nullish(),label:h().nullish(),name:h(),optional:Ee().optional().default(!1),secret:Ee().optional().default(!0)}),qC=p({_meta:S(h(),w()).nullish(),description:h().nullish(),id:h(),name:h()}),YC=p({_meta:S(h(),w()).nullish(),description:h().nullish(),id:h(),link:h().nullish(),name:h(),vars:D(WC)}),KC=p({_meta:S(h(),w()).nullish(),args:D(h()).optional(),description:h().nullish(),env:S(h(),h()).optional(),id:h(),name:h()}),JC=H([YC.and(p({type:x("env_var")})),KC.and(p({type:x("terminal")})),qC]),XC=p({_meta:S(h(),w()).nullish(),methodId:h()}),QC=p({_meta:S(h(),w()).nullish()}),eI=p({_meta:S(h(),w()).nullish(),blob:h(),mimeType:h().nullish(),uri:h()}),tI=p({default:Ee().nullish(),description:h().nullish(),title:h().nullish()}),nI=p({_meta:S(h(),w()).nullish()}),rI=p({_meta:S(h(),w()).nullish()}),iI=p({amount:N(),currency:h()}),sI=p({_meta:S(h(),w()).nullish(),terminalId:h()}),oI=p({_meta:S(h(),w()).nullish(),newText:h(),oldText:h().nullish(),path:h()}),aI=H([h(),N(),N(),Ee(),D(h())]),lI=p({content:S(h(),aI).nullish()}),cI=H([lI.and(p({action:x("accept")})),p({action:x("decline")}),p({action:x("cancel")})]),uI=p({_meta:S(h(),w()).nullish()}),mm=h(),hI=p({_meta:S(h(),w()).nullish(),elicitationId:mm}),dI=p({_meta:S(h(),w()).nullish(),action:cI}),fI=x("object"),pI=x("string"),gI=p({_meta:S(h(),w()).nullish()}),mI=p({_meta:S(h(),w()).nullish(),form:uI.nullish(),url:gI.nullish()}),yI=p({elicitationId:mm,url:h().url()}),ym=p({const:h(),title:h()}),vm=p({_meta:S(h(),w()).nullish(),name:h(),value:h()}),vI=H([x(-32700),x(-32600),x(-32601),x(-32602),x(-32603),x(-32800),x(-32e3),x(-32002),x(-32042),N().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),bm=p({code:vI,data:w().optional(),message:h()}),wm=w(),_m=w(),Sm=w(),bI=p({_meta:S(h(),w()).nullish(),readTextFile:Ee().optional().default(!1),writeTextFile:Ee().optional().default(!1)}),km=p({_meta:S(h(),w()).nullish(),name:h(),value:h()}),Em=p({_meta:S(h(),w()).nullish(),name:h(),title:h().nullish(),version:h()}),wI=p({default:N().nullish(),description:h().nullish(),maximum:N().nullish(),minimum:N().nullish(),title:h().nullish()}),_I=p({_meta:S(h(),w()).nullish()}),SI=p({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cursor:h().nullish(),cwd:h().nullish()}),kI=p({_meta:S(h(),w()).nullish()}),EI=p({_meta:S(h(),w()).nullish(),logout:kI.nullish()}),$I=p({_meta:S(h(),w()).nullish()}),AI=p({_meta:S(h(),w()).nullish()}),xI=p({_meta:S(h(),w()).nullish(),http:Ee().optional().default(!1),sse:Ee().optional().default(!1)}),TI=p({_meta:S(h(),w()).nullish(),headers:D(km),name:h(),url:h()}),CI=p({_meta:S(h(),w()).nullish(),headers:D(km),name:h(),url:h()}),II=p({_meta:S(h(),w()).nullish(),args:D(h()),command:h(),env:D(vm),name:h()}),Fa=H([TI.and(p({type:x("http")})),CI.and(p({type:x("sse")})),II]),zu=h(),PI=p({_meta:S(h(),w()).nullish(),description:h().nullish(),modelId:zu,name:h()}),RI=H([x("error"),x("warning"),x("information"),x("hint")]),DI=p({_meta:S(h(),w()).nullish()}),OI=p({_meta:S(h(),w()).nullish()}),zI=p({_meta:S(h(),w()).nullish()}),LI=p({_meta:S(h(),w()).nullish()}),MI=p({_meta:S(h(),w()).nullish()}),NI=p({_meta:S(h(),w()).nullish(),maxCount:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),UI=p({diff:h(),uri:h()}),FI=p({endLine:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:h()}),ZI=p({_meta:S(h(),w()).nullish()}),HI=p({_meta:S(h(),w()).nullish()}),VI=p({languageId:h(),text:h(),uri:h()}),jI=p({_meta:S(h(),w()).nullish(),maxCount:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),BI=H([x("rejected"),x("ignored"),x("replaced"),x("cancelled")]),GI=p({excerpts:D(FI),uri:h()}),WI=p({_meta:S(h(),w()).nullish()}),qI=p({_meta:S(h(),w()).nullish()}),YI=p({name:h(),owner:h(),remoteUrl:h()}),KI=p({_meta:S(h(),w()).nullish()}),JI=p({_meta:S(h(),w()).nullish(),jump:ZI.nullish(),rename:qI.nullish(),searchAndReplace:KI.nullish()}),XI=p({id:h(),isRegex:Ee().nullish(),replace:h(),search:h(),uri:h()}),QI=H([x("automatic"),x("diagnostic"),x("manual")]),eP=p({_meta:S(h(),w()).nullish(),maxCount:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),tP=p({_meta:S(h(),w()).nullish(),diagnostics:DI.nullish(),editHistory:NI.nullish(),openFiles:HI.nullish(),recentFiles:jI.nullish(),relatedSnippets:WI.nullish(),userActions:eP.nullish()}),nP=p({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Fa)}),rP=p({default:N().nullish(),description:h().nullish(),maximum:N().nullish(),minimum:N().nullish(),title:h().nullish()}),$m=h(),iP=H([x("allow_once"),x("allow_always"),x("reject_once"),x("reject_always")]),sP=p({_meta:S(h(),w()).nullish(),kind:iP,name:h(),optionId:$m}),oP=H([x("high"),x("medium"),x("low")]),aP=H([x("pending"),x("in_progress"),x("completed")]),lP=p({_meta:S(h(),w()).nullish(),content:h(),priority:oP,status:aP}),cP=p({_meta:S(h(),w()).nullish(),entries:D(lP)}),mn=p({character:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),uP=p({id:h(),position:mn,uri:h()}),hP=p({id:h(),newName:h(),position:mn,uri:h()}),dP=p({action:h(),position:mn,timestampMs:N(),uri:h()}),Am=H([x("utf-16"),x("utf-32"),x("utf-8")]),fP=p({_meta:S(h(),w()).nullish(),auth:GC.optional().default({terminal:!1}),elicitation:mI.nullish(),fs:bI.optional().default({readTextFile:!1,writeTextFile:!1}),nes:JI.nullish(),positionEncodings:D(Am).optional(),terminal:Ee().optional().default(!1)}),pP=p({_meta:S(h(),w()).nullish(),audio:Ee().optional().default(!1),embeddedContext:Ee().optional().default(!1),image:Ee().optional().default(!1)}),xm=N().int().gte(0).lte(65535),gP=p({_meta:S(h(),w()).nullish(),clientCapabilities:fP.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Em.nullish(),protocolVersion:xm}),pi=p({end:mn,start:mn}),mP=p({message:h(),range:pi,severity:RI,uri:h()}),yP=p({languageId:h(),lastFocusedMs:N().nullish(),uri:h(),visibleRange:pi.nullish()}),vP=p({_meta:S(h(),w()).nullish(),diagnostics:D(mP).nullish(),editHistory:D(UI).nullish(),openFiles:D(yP).nullish(),recentFiles:D(VI).nullish(),relatedSnippets:D(GI).nullish(),userActions:D(dP).nullish()}),bP=p({newText:h(),range:pi}),wP=p({cursorPosition:mn.nullish(),edits:D(bP),id:h(),uri:h()}),_P=H([wP.and(p({kind:x("edit")})),uP.and(p({kind:x("jump")})),hP.and(p({kind:x("rename")})),XI.and(p({kind:x("searchAndReplace")}))]),SP=p({_meta:S(h(),w()).nullish(),content:h()}),kP=p({_meta:S(h(),w()).nullish()}),nr=H([N(),h()]).nullable();p({_meta:S(h(),w()).nullish(),requestId:nr});const EP=ra(["assistant","user"]),Xs=p({_meta:S(h(),w()).nullish(),audience:D(EP).nullish(),lastModified:h().nullish(),priority:N().nullish()}),$P=p({_meta:S(h(),w()).nullish(),annotations:Xs.nullish(),data:h(),mimeType:h()}),AP=p({_meta:S(h(),w()).nullish(),annotations:Xs.nullish(),data:h(),mimeType:h(),uri:h().nullish()}),xP=p({_meta:S(h(),w()).nullish(),annotations:Xs.nullish(),description:h().nullish(),mimeType:h().nullish(),name:h(),size:N().nullish(),title:h().nullish(),uri:h()}),TP=p({_meta:S(h(),w()).nullish(),optionId:$m}),CP=H([p({outcome:x("cancelled")}),TP.and(p({outcome:x("selected")}))]),IP=p({_meta:S(h(),w()).nullish(),outcome:CP}),PP=p({_meta:S(h(),w()).nullish()}),RP=p({_meta:S(h(),w()).nullish()}),DP=p({currentValue:Ee()}),OP=h(),Tm=h(),zP=H([x("mode"),x("model"),x("thought_level"),h()]),Lu=h(),Cm=p({_meta:S(h(),w()).nullish(),description:h().nullish(),name:h(),value:Lu}),LP=p({_meta:S(h(),w()).nullish(),group:OP,name:h(),options:D(Cm)}),MP=H([D(Cm),D(LP)]),NP=p({currentValue:Lu,options:MP}),gi=Ua(H([NP.and(p({type:x("select")})),DP.and(p({type:x("boolean")}))]),p({_meta:S(h(),w()).nullish(),category:zP.nullish(),description:h().nullish(),id:Tm,name:h()})),UP=p({_meta:S(h(),w()).nullish(),configOptions:D(gi)}),FP=p({_meta:S(h(),w()).nullish()}),Y=h(),ZP=p({_meta:S(h(),w()).nullish(),id:h(),sessionId:Y}),HP=p({_meta:S(h(),w()).nullish(),sessionId:Y}),VP=p({_meta:S(h(),w()).nullish(),sessionId:Y}),jP=p({_meta:S(h(),w()).nullish(),sessionId:Y}),Im=p({_meta:S(h(),w()).nullish(),args:D(h()).optional(),command:h(),cwd:h().nullish(),env:D(vm).optional(),outputByteLimit:N().nullish(),sessionId:Y}),BP=p({_meta:S(h(),w()).nullish(),sessionId:Y,uri:h()}),GP=p({_meta:S(h(),w()).nullish(),position:mn,sessionId:Y,uri:h(),version:N(),visibleRange:pi}),WP=p({_meta:S(h(),w()).nullish(),languageId:h(),sessionId:Y,text:h(),uri:h(),version:N()}),qP=p({_meta:S(h(),w()).nullish(),sessionId:Y,uri:h()}),YP=p({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Fa).optional(),sessionId:Y}),Pm=p({_meta:S(h(),w()).nullish(),sessionId:Y,terminalId:h()}),KP=p({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Fa),sessionId:Y}),Rm=p({_meta:S(h(),w()).nullish(),limit:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h(),sessionId:Y}),JP=p({_meta:S(h(),w()).nullish(),id:h(),reason:BI.nullish(),sessionId:Y}),Dm=p({_meta:S(h(),w()).nullish(),sessionId:Y,terminalId:h()}),XP=p({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Fa).optional(),sessionId:Y}),QP=p({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),sessionId:Y,title:h().nullish(),updatedAt:h().nullish()}),e1=p({_meta:S(h(),w()).nullish(),nextCursor:h().nullish(),sessions:D(QP)}),t1=p({_meta:S(h(),w()).nullish(),title:h().nullish(),updatedAt:h().nullish()}),n1=p({_meta:S(h(),w()).nullish()}),Za=h(),r1=p({_meta:S(h(),w()).nullish(),currentModeId:Za}),i1=p({_meta:S(h(),w()).nullish(),description:h().nullish(),id:Za,name:h()}),Ha=p({_meta:S(h(),w()).nullish(),availableModes:D(i1),currentModeId:Za}),Va=p({_meta:S(h(),w()).nullish(),availableModels:D(PI),currentModelId:zu}),s1=p({_meta:S(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Va.nullish(),modes:Ha.nullish(),sessionId:Y}),o1=p({_meta:S(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Va.nullish(),modes:Ha.nullish()}),a1=p({_meta:S(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Va.nullish(),modes:Ha.nullish(),sessionId:Y}),l1=p({_meta:S(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Va.nullish(),modes:Ha.nullish()}),c1=p({_meta:S(h(),w()).nullish()}),u1=p({_meta:S(h(),w()).nullish(),additionalDirectories:PP.nullish(),close:RP.nullish(),fork:FP.nullish(),list:n1.nullish(),resume:c1.nullish()}),h1=Ua(H([p({type:x("boolean"),value:Ee()}),p({value:Lu})]),p({_meta:S(h(),w()).nullish(),configId:Tm,sessionId:Y})),d1=p({_meta:S(h(),w()).nullish(),configOptions:D(gi)}),f1=p({_meta:S(h(),w()).nullish(),modeId:Za,sessionId:Y}),p1=p({_meta:S(h(),w()).nullish()}),g1=p({_meta:S(h(),w()).nullish(),modelId:zu,sessionId:Y}),m1=p({_meta:S(h(),w()).nullish()}),y1=p({_meta:S(h(),w()).nullish(),sessionId:Y}),v1=H([x("end_turn"),x("max_tokens"),x("max_turn_requests"),x("refusal"),x("cancelled")]),b1=H([x("email"),x("uri"),x("date"),x("date-time")]),w1=p({default:h().nullish(),description:h().nullish(),enum:D(h()).nullish(),format:b1.nullish(),maxLength:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:D(ym).nullish(),pattern:h().nullish(),title:h().nullish()}),_1=p({_meta:S(h(),w()).nullish(),context:vP.nullish(),position:mn,selection:pi.nullish(),sessionId:Y,triggerKind:QI,uri:h(),version:N()}),S1=p({_meta:S(h(),w()).nullish(),suggestions:D(_P)}),k1=p({_meta:S(h(),w()).nullish(),terminalId:h()}),E1=p({_meta:S(h(),w()).nullish(),exitCode:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),Om=p({_meta:S(h(),w()).nullish(),sessionId:Y,terminalId:h()}),$1=p({_meta:S(h(),w()).nullish(),exitStatus:E1.nullish(),output:h(),truncated:Ee()}),A1=p({_meta:S(h(),w()).nullish(),annotations:Xs.nullish(),text:h()}),x1=p({range:pi.nullish(),text:h()}),T1=p({_meta:S(h(),w()).nullish(),contentChanges:D(x1),sessionId:Y,uri:h(),version:N()});p({method:h(),params:H([HP,WP,T1,BP,qP,GP,ZP,JP,wm]).nullish()});const C1=H([x("full"),x("incremental")]),I1=p({_meta:S(h(),w()).nullish(),syncKind:C1}),P1=p({_meta:S(h(),w()).nullish(),didChange:I1.nullish(),didClose:OI.nullish(),didFocus:zI.nullish(),didOpen:LI.nullish(),didSave:MI.nullish()}),R1=p({_meta:S(h(),w()).nullish(),document:P1.nullish()}),D1=p({_meta:S(h(),w()).nullish(),context:tP.nullish(),events:R1.nullish()}),O1=p({_meta:S(h(),w()).nullish(),auth:EI.optional().default({}),loadSession:Ee().optional().default(!1),mcpCapabilities:xI.optional().default({http:!1,sse:!1}),nes:D1.nullish(),positionEncoding:Am.nullish(),promptCapabilities:pP.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:u1.optional().default({})}),z1=p({_meta:S(h(),w()).nullish(),agentCapabilities:O1.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Em.nullish(),authMethods:D(JC).optional().default([]),protocolVersion:xm}),L1=p({_meta:S(h(),w()).nullish(),mimeType:h().nullish(),text:h(),uri:h()}),M1=H([L1,eI]),N1=p({_meta:S(h(),w()).nullish(),annotations:Xs.nullish(),resource:M1}),Mu=H([A1.and(p({type:x("text")})),AP.and(p({type:x("image")})),$P.and(p({type:x("audio")})),xP.and(p({type:x("resource_link")})),N1.and(p({type:x("resource")}))]),U1=p({_meta:S(h(),w()).nullish(),content:Mu}),Ol=p({_meta:S(h(),w()).nullish(),content:Mu,messageId:h().nullish()}),F1=p({_meta:S(h(),w()).nullish(),messageId:h().nullish(),prompt:D(Mu),sessionId:Y}),Z1=p({anyOf:D(ym)}),zm=H([U1.and(p({type:x("content")})),oI.and(p({type:x("diff")})),k1.and(p({type:x("terminal")}))]),Lm=h(),Mm=p({_meta:S(h(),w()).nullish(),line:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h()}),Nm=H([x("pending"),x("in_progress"),x("completed"),x("failed")]),Um=H([x("read"),x("edit"),x("delete"),x("move"),x("search"),x("execute"),x("think"),x("fetch"),x("switch_mode"),x("other")]),H1=p({_meta:S(h(),w()).nullish(),content:D(zm).optional(),kind:Um.optional(),locations:D(Mm).optional(),rawInput:w().optional(),rawOutput:w().optional(),status:Nm.optional(),title:h(),toolCallId:Lm}),Fm=p({_meta:S(h(),w()).nullish(),content:D(zm).nullish(),kind:Um.nullish(),locations:D(Mm).nullish(),rawInput:w().optional(),rawOutput:w().optional(),status:Nm.nullish(),title:h().nullish(),toolCallId:Lm}),Zm=p({_meta:S(h(),w()).nullish(),options:D(sP),sessionId:Y,toolCall:Fm}),V1=p({_meta:S(h(),w()).nullish(),hint:h()}),j1=V1,B1=p({_meta:S(h(),w()).nullish(),description:h(),input:j1.nullish(),name:h()}),G1=p({_meta:S(h(),w()).nullish(),availableCommands:D(B1)}),W1=p({enum:D(h()),type:pI}),q1=H([W1,Z1]),Y1=p({default:D(h()).nullish(),description:h().nullish(),items:q1,maxItems:N().nullish(),minItems:N().nullish(),title:h().nullish()}),K1=H([w1.and(p({type:x("string")})),rP.and(p({type:x("number")})),wI.and(p({type:x("integer")})),tI.and(p({type:x("boolean")})),Y1.and(p({type:x("array")}))]),J1=p({description:h().nullish(),properties:S(h(),K1).optional().default({}),required:D(h()).nullish(),title:h().nullish(),type:fI.optional().default("object")}),X1=p({requestedSchema:J1}),Q1=Ua(H([X1.and(p({mode:x("form")})),yI.and(p({mode:x("url")}))]),p({_meta:S(h(),w()).nullish(),message:h(),sessionId:Y})),eR=p({cachedReadTokens:N().nullish(),cachedWriteTokens:N().nullish(),inputTokens:N(),outputTokens:N(),thoughtTokens:N().nullish(),totalTokens:N()}),tR=p({_meta:S(h(),w()).nullish(),stopReason:v1,usage:eR.nullish(),userMessageId:h().nullish()});H([p({id:nr,result:H([z1,QC,AI,a1,o1,e1,s1,l1,rI,p1,d1,tR,m1,y1,S1,nI,Sm])}),p({error:bm,id:nr})]);const nR=p({_meta:S(h(),w()).nullish(),cost:iI.nullish(),size:N(),used:N()}),rR=H([Ol.and(p({sessionUpdate:x("user_message_chunk")})),Ol.and(p({sessionUpdate:x("agent_message_chunk")})),Ol.and(p({sessionUpdate:x("agent_thought_chunk")})),H1.and(p({sessionUpdate:x("tool_call")})),Fm.and(p({sessionUpdate:x("tool_call_update")})),cP.and(p({sessionUpdate:x("plan")})),G1.and(p({sessionUpdate:x("available_commands_update")})),r1.and(p({sessionUpdate:x("current_mode_update")})),UP.and(p({sessionUpdate:x("config_option_update")})),t1.and(p({sessionUpdate:x("session_info_update")})),nR.and(p({sessionUpdate:x("usage_update")}))]),Hm=p({_meta:S(h(),w()).nullish(),sessionId:Y,update:rR});p({method:h(),params:H([Hm,hI,wm]).nullish()});const Vm=p({_meta:S(h(),w()).nullish(),sessionId:Y,terminalId:h()}),iR=p({_meta:S(h(),w()).nullish(),exitCode:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),sR=p({name:h(),uri:h()}),oR=p({_meta:S(h(),w()).nullish(),repository:YI.nullish(),workspaceFolders:D(sR).nullish(),workspaceUri:h().nullish()});p({id:nr,method:h(),params:H([gP,XC,$I,nP,KP,SI,YP,XP,jP,f1,h1,F1,g1,oR,_1,VP,_m]).nullish()});const jm=p({_meta:S(h(),w()).nullish(),content:h(),path:h(),sessionId:Y});p({id:nr,method:h(),params:H([jm,Rm,Zm,Im,Om,Dm,Vm,Pm,Q1,_m]).nullish()});const aR=p({_meta:S(h(),w()).nullish()});H([p({id:nr,result:H([aR,SP,IP,sI,$1,kP,iR,_I,dI,Sm])}),p({error:bm,id:nr})]);var q;class lR{constructor(e,t){_(this,q);const r=e(this),i=async(o,a)=>{var c,u,d,f,v,y,A;switch(o){case Ot.fs_write_text_file:{const k=jm.parse(a);return(c=r.writeTextFile)==null?void 0:c.call(r,k)}case Ot.fs_read_text_file:{const k=Rm.parse(a);return(u=r.readTextFile)==null?void 0:u.call(r,k)}case Ot.session_request_permission:{const k=Zm.parse(a);return r.requestPermission(k)}case Ot.terminal_create:{const k=Im.parse(a);return(d=r.createTerminal)==null?void 0:d.call(r,k)}case Ot.terminal_output:{const k=Om.parse(a);return(f=r.terminalOutput)==null?void 0:f.call(r,k)}case Ot.terminal_release:{const k=Dm.parse(a);return await((v=r.releaseTerminal)==null?void 0:v.call(r,k))??{}}case Ot.terminal_wait_for_exit:{const k=Vm.parse(a);return(y=r.waitForTerminalExit)==null?void 0:y.call(r,k)}case Ot.terminal_kill:{const k=Pm.parse(a);return await((A=r.killTerminal)==null?void 0:A.call(r,k))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw we.methodNotFound(o)}},s=async(o,a)=>{switch(o){case Ot.session_update:{const c=Hm.parse(a);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(o,a);throw we.methodNotFound(o)}};E(this,q,new cR(i,s,t))}async initialize(e){return await l(this,q).sendRequest(se.initialize,e)}async newSession(e){return await l(this,q).sendRequest(se.session_new,e)}async loadSession(e){return await l(this,q).sendRequest(se.session_load,e)??{}}async unstable_forkSession(e){return await l(this,q).sendRequest(se.session_fork,e)}async listSessions(e){return await l(this,q).sendRequest(se.session_list,e)}async unstable_resumeSession(e){return await l(this,q).sendRequest(se.session_resume,e)}async unstable_closeSession(e){return await l(this,q).sendRequest(se.session_close,e)}async setSessionMode(e){return await l(this,q).sendRequest(se.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await l(this,q).sendRequest(se.session_set_model,e)??{}}async setSessionConfigOption(e){return await l(this,q).sendRequest(se.session_set_config_option,e)}async authenticate(e){return await l(this,q).sendRequest(se.authenticate,e)??{}}async unstable_logout(e){return await l(this,q).sendRequest(se.logout,e)??{}}async prompt(e){return await l(this,q).sendRequest(se.session_prompt,e)}async cancel(e){return await l(this,q).sendNotification(se.session_cancel,e)}async unstable_startNes(e){return await l(this,q).sendRequest(se.nes_start,e)}async unstable_suggestNes(e){return await l(this,q).sendRequest(se.nes_suggest,e)}async unstable_closeNes(e){return await l(this,q).sendRequest(se.nes_close,e)??{}}async unstable_didOpenDocument(e){return await l(this,q).sendNotification(se.document_did_open,e)}async unstable_didChangeDocument(e){return await l(this,q).sendNotification(se.document_did_change,e)}async unstable_didCloseDocument(e){return await l(this,q).sendNotification(se.document_did_close,e)}async unstable_didSaveDocument(e){return await l(this,q).sendNotification(se.document_did_save,e)}async unstable_didFocusDocument(e){return await l(this,q).sendNotification(se.document_did_focus,e)}async unstable_acceptNes(e){return await l(this,q).sendNotification(se.nes_accept,e)}async unstable_rejectNes(e){return await l(this,q).sendNotification(se.nes_reject,e)}async extMethod(e,t){return await l(this,q).sendRequest(e,t)}async extNotification(e,t){return await l(this,q).sendNotification(e,t)}get signal(){return l(this,q).signal}get closed(){return l(this,q).closed}}q=new WeakMap;var sn,da,ls,cs,Or,zr,$t,us,ue,Bm,mc,Gm,Wm,qm,Ym,yc,Li;class cR{constructor(e,t,r){_(this,ue);_(this,sn,new Map);_(this,da,0);_(this,ls);_(this,cs);_(this,Or);_(this,zr,Promise.resolve());_(this,$t,new AbortController);_(this,us);E(this,ls,e),E(this,cs,t),E(this,Or,r),E(this,us,new Promise(i=>{l(this,$t).signal.addEventListener("abort",()=>i())})),m(this,ue,Bm).call(this)}get signal(){return l(this,$t).signal}get closed(){return l(this,us)}async sendRequest(e,t){m(this,ue,yc).call(this);const r=$h(this,da)._++,i=new Promise((s,o)=>{l(this,sn).set(r,{resolve:s,reject:o})});return await m(this,ue,Li).call(this,{jsonrpc:"2.0",id:r,method:e,params:t}),i}async sendNotification(e,t){m(this,ue,yc).call(this),await m(this,ue,Li).call(this,{jsonrpc:"2.0",method:e,params:t})}}sn=new WeakMap,da=new WeakMap,ls=new WeakMap,cs=new WeakMap,Or=new WeakMap,zr=new WeakMap,$t=new WeakMap,us=new WeakMap,ue=new WeakSet,Bm=async function(){let e;try{const t=l(this,Or).readable.getReader();try{for(;!l(this,$t).signal.aborted;){const{value:r,done:i}=await t.read();if(i)break;if(r)try{m(this,ue,Gm).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&m(this,ue,Li).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{t.releaseLock()}}catch(t){e=t}finally{m(this,ue,mc).call(this,e)}},mc=function(e){if(l(this,$t).signal.aborted)return;const t=e??new Error("ACP connection closed");for(const r of l(this,sn).values())r.reject(t);l(this,sn).clear(),l(this,$t).abort(t)},Gm=async function(e){if("method"in e&&"id"in e){const t=await m(this,ue,Wm).call(this,e.method,e.params);"error"in t&&console.error("Error handling request",e,t.error),await m(this,ue,Li).call(this,{jsonrpc:"2.0",id:e.id,...t})}else if("method"in e){const t=await m(this,ue,qm).call(this,e.method,e.params);"error"in t&&console.error("Error handling notification",e,t.error)}else"id"in e?m(this,ue,Ym).call(this,e):console.error("Invalid message",{message:e})},Wm=async function(e,t){try{return{result:await l(this,ls).call(this,e,t)??null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof mf)return we.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 we.internalError(i?JSON.parse(i):{}).toResult()}catch{return we.internalError({details:i}).toResult()}}},qm=async function(e,t){try{return await l(this,cs).call(this,e,t),{result:null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof mf)return we.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 we.internalError(i?JSON.parse(i):{}).toResult()}catch{return we.internalError({details:i}).toResult()}}},Ym=function(e){const t=l(this,sn).get(e.id);if(t){if("result"in e)t.resolve(e.result);else if("error"in e){const{code:r,message:i,data:s}=e.error;t.reject(new we(r,i,s))}l(this,sn).delete(e.id)}else console.error("Got response to unknown request",e.id)},yc=function(){if(l(this,$t).signal.aborted)throw l(this,$t).signal.reason??new Error("ACP connection closed")},Li=async function(e){return E(this,zr,l(this,zr).then(async()=>{const t=l(this,Or).writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(t=>{m(this,ue,mc).call(this,t)})),l(this,zr)};class we extends Error{constructor(t,r,i){super(r);b(this,"code");b(this,"data");this.code=t,this.name="RequestError",this.data=i}static parseError(t,r){return new we(-32700,`Parse error${r?`: ${r}`:""}`,t)}static invalidRequest(t,r){return new we(-32600,`Invalid request${r?`: ${r}`:""}`,t)}static methodNotFound(t){return new we(-32601,`"Method not found": ${t}`,{method:t})}static invalidParams(t,r){return new we(-32602,`Invalid params${r?`: ${r}`:""}`,t)}static internalError(t,r){return new we(-32603,`Internal error${r?`: ${r}`:""}`,t)}static authRequired(t,r){return new we(-32e3,`Authentication required${r?`: ${r}`:""}`,t)}static resourceNotFound(t){return new we(-32002,`Resource not found${t?`: ${t}`:""}`,t&&{uri:t})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const uR=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,hR=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,dR=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,fR=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,pR="single_session",gR={name:"television-acp-client",version:"0.0.0"},Km="agent:main:television",mR=di(gt);var ee,Nt,Lr,Ut,Hn,Vn,on,Mr,At,lt,an,jn,Ft,ln,hs,Zt,ct,fa,Ht,C,Jm,Xm,vc,Qm,ey,ty,ny,ry,iy,sy,Tn,kr,Er,qe,oy,$r,bc,wc,Fo,ay,ds,fs,_c,Ar,ly,cy;class yR extends mR{constructor(t){super();_(this,C);_(this,ee,vR());_(this,Nt,null);_(this,Lr,null);_(this,Ut,null);_(this,Hn,null);_(this,Vn,null);_(this,on,null);_(this,Mr,1);_(this,At,null);_(this,lt,null);_(this,an,!1);_(this,jn,!1);_(this,Ft,null);_(this,ln,new Set);_(this,hs);_(this,Zt);_(this,ct);_(this,fa,t=>{m(this,C,Xm).call(this,t)});_(this,Ht,null);_(this,ds,()=>{m(this,C,Ar).call(this,"ACP bridge websocket closed")});_(this,fs,()=>{m(this,C,Ar).call(this,"ACP bridge websocket error")});E(this,Zt,t),E(this,ct,t.sessionMode??pR),E(this,hs,t.createSocket??(r=>new WebSocket(r)))}getState(){return l(this,ee)}get messages(){return l(this,ee).messageOrder.map(t=>l(this,ee).messagesById[t]).filter(t=>t!==void 0)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(l(this,ee).lifecycle.status!=="ready"){m(this,C,qe).call(this,{lifecycle:{status:"connecting"}}),l(this,Lr)??E(this,Lr,m(this,C,Jm).call(this));try{await l(this,Lr),await m(this,C,vc).call(this)}catch(t){throw m(this,C,Ar).call(this,So(t)),t}}}dispose(){m(this,C,_c).call(this),m(this,C,qe).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null}})}async sendMessage(t){if(await this.connect(),l(this,ee).lifecycle.status!=="ready"||l(this,ee).run.status==="running"||l(this,ee).run.status==="cancelling")throw new Error("ACPClient is not ready to send a new message");const r=t.text.trim();if(!r)throw new Error("Cannot send an empty message");m(this,C,kr).call(this,{id:m(this,C,$r).call(this,"user"),kind:"user",text:r,status:"final"}),m(this,C,qe).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const i=await m(this,C,Fo).call(this).prompt({sessionId:m(this,C,wc).call(this),prompt:[{type:"text",text:m(this,C,oy).call(this,r)}]});m(this,C,Tn).call(this,i.stopReason==="cancelled"?"cancelled":"final"),m(this,C,qe).call(this,{run:{status:i.stopReason==="cancelled"?"cancelled":"completed",stopReason:i.stopReason,canCancel:!1,error:null}})}catch(i){throw m(this,C,cy).call(this)||(m(this,C,Tn).call(this,"error"),m(this,C,qe).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:So(i)}})),i}}async cancel(){if(await this.connect(),!l(this,ee).run.canCancel||l(this,ee).run.status!=="running")throw new Error("No active cancellable run");m(this,C,qe).call(this,{run:{...l(this,ee).run,status:"cancelling"}}),await m(this,C,Fo).call(this).cancel({sessionId:m(this,C,wc).call(this)})}setScreenContext(t){var s,o,a;const r={screenID:t.screenID,screenName:t.screenName};if(((s=l(this,lt))==null?void 0:s.screenID)===r.screenID&&((o=l(this,lt))==null?void 0:o.screenName)===r.screenName)return;const i=((a=l(this,lt))==null?void 0:a.screenID)??null;if(E(this,lt,r),l(this,ct)==="single_session"){(!l(this,on)||i!==r.screenID)&&E(this,an,!0);return}l(this,on)!==Sf(l(this,ct),r.screenID,l(this,Zt).clientGUID??"default-client")&&(E(this,Ut,null),E(this,Hn,null),l(this,Nt)&&l(this,ee).run.status==="idle"&&m(this,C,vc).call(this).catch(c=>{m(this,C,Ar).call(this,So(c))}))}}ee=new WeakMap,Nt=new WeakMap,Lr=new WeakMap,Ut=new WeakMap,Hn=new WeakMap,Vn=new WeakMap,on=new WeakMap,Mr=new WeakMap,At=new WeakMap,lt=new WeakMap,an=new WeakMap,jn=new WeakMap,Ft=new WeakMap,ln=new WeakMap,hs=new WeakMap,Zt=new WeakMap,ct=new WeakMap,fa=new WeakMap,Ht=new WeakMap,C=new WeakSet,Jm=async function(){try{m(this,C,qe).call(this,{lifecycle:{status:"connecting"}});const{stream:t,socket:r}=await _R({serverURL:l(this,Zt).serverURL,token:l(this,Zt).token,createSocket:l(this,hs),onDisconnect:l(this,fa)});E(this,Ht,r),r.addEventListener("close",l(this,ds)),r.addEventListener("error",l(this,fs)),E(this,Nt,new lR(i=>({connection:i,sessionUpdate:async s=>{await m(this,C,ey).call(this,s)},requestPermission:async s=>m(this,C,ty).call(this,s)}),t)),await l(this,Nt).initialize({protocolVersion:BC,clientCapabilities:{},clientInfo:gR})}catch(t){throw t}},Xm=function(t){m(this,C,Ar).call(this,So(t))},vc=async function(){const t=m(this,C,ay).call(this);if(l(this,Ut)&&l(this,Hn)===t){await l(this,Ut);return}E(this,Hn,t),E(this,Ut,m(this,C,Qm).call(this,t)),await l(this,Ut)},Qm=async function(t){const r=m(this,C,Fo).call(this);m(this,C,ly).call(this);let i,s=!1;try{E(this,jn,!0),E(this,Ft,null),await r.loadSession({sessionId:t,cwd:"/",mcpServers:[],_meta:{sessionKey:t}}),i=t,s=l(this,ee).messageOrder.length>0}catch{i=(await r.newSession({cwd:"/",mcpServers:[],_meta:{sessionKey:t}})).sessionId,s=!1}finally{E(this,jn,!1),E(this,Ft,null),m(this,C,Tn).call(this,"final")}await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),E(this,Vn,i),E(this,on,t),s?(l(this,ln).add(t),l(this,ct)==="single_session"&&E(this,an,!1)):(l(this,ln).delete(t),E(this,an,l(this,ct)==="single_session")),m(this,C,qe).call(this,{lifecycle:{status:"ready"}})},ey=async function(t){const r=t.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&m(this,C,sy).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&m(this,C,ny).call(this,r.content.text);return;case"tool_call":m(this,C,ry).call(this,r);return;case"tool_call_update":m(this,C,iy).call(this,r);return;case"agent_thought_chunk":return;default:return}},ty=async function(t){return{outcome:{outcome:"cancelled"}}},ny=function(t){E(this,Ft,null);const r=bR(t);if(!r)return;if(!l(this,At)){const s={id:m(this,C,$r).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};E(this,At,s.id),m(this,C,kr).call(this,s);return}const i=l(this,ee).messagesById[l(this,At)];if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");m(this,C,Er).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},ry=function(t){m(this,C,Tn).call(this,"final");const r=m(this,C,bc).call(this,t.toolCallId),i={id:(r==null?void 0:r.id)??m(this,C,$r).call(this,"tool"),kind:"tool_call",toolCallId:t.toolCallId,title:t.title,toolKind:t.kind??"other",status:t.status==="failed"?"failed":t.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??"",locations:t.locations??(r==null?void 0:r.locations)};if(r){m(this,C,Er).call(this,i);return}m(this,C,kr).call(this,i)},iy=function(t){const r=m(this,C,bc).call(this,t.toolCallId),i=(r==null?void 0:r.text)??"",s=wR(t.content),o=s?`${i}${s}`:i,a={id:(r==null?void 0:r.id)??m(this,C,$r).call(this,"tool"),kind:"tool_call",toolCallId:t.toolCallId,title:(r==null?void 0:r.title)??t.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:t.status==="failed"?"failed":t.status==="completed"?"completed":"in_progress",text:o,locations:t.locations??(r==null?void 0:r.locations)};if(r){m(this,C,Er).call(this,a);return}m(this,C,kr).call(this,a)},sy=function(t){if(m(this,C,Tn).call(this,"final"),!t)return;const r=l(this,jn)?l(this,Ft):null;if(!r){const s=kf(t);if(!s)return;const o={id:m(this,C,$r).call(this,"user"),kind:"user",text:s,status:"final"};m(this,C,kr).call(this,o),l(this,jn)&&E(this,Ft,o.id);return}const i=l(this,ee).messagesById[r];if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");m(this,C,Er).call(this,{...i,text:kf(`${i.text}${t}`)})},Tn=function(t){if(!l(this,At))return;const r=l(this,ee).messagesById[l(this,At)];(r==null?void 0:r.kind)==="assistant"&&m(this,C,Er).call(this,{...r,status:t}),E(this,At,null)},kr=function(t){m(this,C,qe).call(this,{messagesById:{...l(this,ee).messagesById,[t.id]:t},messageOrder:[...l(this,ee).messageOrder,t.id]})},Er=function(t){m(this,C,qe).call(this,{messagesById:{...l(this,ee).messagesById,[t.id]:t}})},qe=function(t){const r={...l(this,ee),...t};E(this,ee,{...r,sendDisabled:r.lifecycle.status!=="ready"||r.run.status==="running"||r.run.status==="cancelling",cancelDisabled:!(r.run.status==="running"||r.run.status==="cancelling")||!r.run.canCancel}),this.dispatchEvent(new Q("change"))},oy=function(t){const r=l(this,on);return!l(this,lt)||!r||!(l(this,ct)==="single_session"?l(this,an)||!l(this,ln).has(r):!l(this,ln).has(r))?t:(E(this,an,!1),l(this,ln).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${l(this,lt).screenID}`,`screen_name: ${l(this,lt).screenName??""}`,"When the user asks to inspect or change Television state with the tv CLI, use this screen ID with the --screen argument.","[/Television screen context]","",t].join(`
43
+ `))},$r=function(t){const r=`${t}-${l(this,Mr)}`;return E(this,Mr,l(this,Mr)+1),r},bc=function(t){for(const r of l(this,ee).messageOrder){const i=l(this,ee).messagesById[r];if((i==null?void 0:i.kind)==="tool_call"&&i.toolCallId===t)return i}return null},wc=function(){if(!l(this,Vn))throw new Error("ACP session is not ready");return l(this,Vn)},Fo=function(){if(!l(this,Nt))throw new Error("ACP connection is not ready");return l(this,Nt)},ay=function(){var r;if(l(this,ct)==="single_session")return`${Km}-${(l(this,Zt).clientGUID??"default-client").toLowerCase()}`;const t=(r=l(this,lt))==null?void 0:r.screenID;if(!t)throw new Error("Screen context is required for per-screen session mode");return Sf(l(this,ct),t,l(this,Zt).clientGUID??"default-client")},ds=new WeakMap,fs=new WeakMap,_c=function(){E(this,Nt,null),E(this,Lr,null),E(this,Ut,null),E(this,Hn,null),E(this,Vn,null),E(this,on,null),l(this,Ht)&&(l(this,Ht).removeEventListener("close",l(this,ds)),l(this,Ht).removeEventListener("error",l(this,fs)),l(this,Ht).close(),E(this,Ht,null))},Ar=function(t){this.disposed||l(this,ee).lifecycle.status==="disconnected"||(m(this,C,Tn).call(this,"error"),m(this,C,_c).call(this),m(this,C,qe).call(this,{lifecycle:{status:"disconnected",...t?{error:t}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null}}))},ly=function(){E(this,At,null),E(this,Ft,null),E(this,Mr,1),m(this,C,qe).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},cy=function(){return l(this,ee).lifecycle.status==="disconnected"};function vR(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function Sf(n,e,t){return n==="single_session"?`${Km}-${t.toLowerCase()}`:`agent:main:television-${t.toLowerCase()}-${e.toLowerCase()}`}function uy(n){return n.replace(/^(?:\s*\n)+/,"")}function kf(n){let e=n;return e=e.replace(uR,""),e=e.replace(hR,""),e=e.replace(dR,""),e=uy(e),e}function bR(n){let e=n;return e=e.replace(fR,""),e=uy(e),e}function wR(n){return!n||n.length===0?"":n.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function _R(n){const e=n.createSocket(kR(n.serverURL,n.token));let t=!1,r,i;const s=new Promise((c,u)=>{r=c,i=u}),o=new ReadableStream({start(c){let u=!1;const d=()=>{e.send(JSON.stringify({type:"acp-bridge-connect"}))},f=A=>{const k=SR(A);if(!k)return;let I;try{I=JSON.parse(k)}catch(B){const P=B instanceof Error?B:new Error(String(B));i(P),c.error(P);return}switch(I.type){case"acp-bridge-status":if(I.status==="ready"){t||(t=!0,r());return}if(I.status==="error"||I.status==="exited"){const B=new Error(I.error??`ACP bridge ${I.status}`);t||i(B),c.error(B)}return;case"acp-bridge-message":c.enqueue(I.message);return}},v=()=>{var k;if(u)return;u=!0;const A=new Error("ACP bridge websocket closed");t||i(A),(k=n.onDisconnect)==null||k.call(n,A),c.close()},y=()=>{var k;if(u)return;u=!0;const A=new Error("ACP bridge websocket error");t||i(A),(k=n.onDisconnect)==null||k.call(n,A),c.error(A)};e.addEventListener("open",d),e.addEventListener("message",f),e.addEventListener("close",v),e.addEventListener("error",y)}}),a=new WritableStream({async write(c){await s,e.send(JSON.stringify({type:"acp-bridge-message",message:c}))},close(){e.close()},abort(){e.close()}});return await s,{stream:{readable:o,writable:a},socket:e}}function SR(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 e=n.data;if(typeof e=="string")return e;if(e instanceof Uint8Array)return new TextDecoder().decode(e);if(Array.isArray(e))return Buffer.concat(e).toString("utf8")}return null}function kR(n,e){const t=new URL(n);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/acp",t.search="",t.searchParams.set("token",e),t.hash="",t.toString()}function So(n){return n instanceof Error?n.message:String(n)}const Ef="television.acpClientGUID",ER=di(gt);class $R extends ER{constructor(t){super();b(this,"screenManager");b(this,"clients",new Map);b(this,"options");b(this,"sessionMode");b(this,"clientGUID");b(this,"activeClient",null);b(this,"handleActiveScreenChanged",()=>{this.syncActiveClient()});this.screenManager=t.screenManager,this.sessionMode=t.sessionMode??"single_session",this.options={serverURL:t.serverURL,token:t.token,...t.createSocket?{createSocket:t.createSocket}:{},...t.sessionMode?{sessionMode:t.sessionMode}:{}},this.clientGUID=t.clientGUID??AR(t.storage??window.localStorage),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.syncActiveClient()}getActiveClient(){return this.activeClient}dispose(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged);for(const t of this.clients.values())t.dispose();this.clients.clear(),this.activeClient=null}syncActiveClient(){const t=this.screenManager.activeScreen,r=t?this.getClientForScreen(t):null;this.activeClient!==r&&(this.activeClient=r,this.dispatchEvent(new Q("change")))}getClientForScreen(t){const r=this.sessionMode==="single_session"?"single_session":t.id;let i=this.clients.get(r);return i||(i=new yR({...this.options,sessionMode:this.sessionMode,clientGUID:this.clientGUID}),this.clients.set(r,i)),i.setScreenContext({screenID:t.id,screenName:t.name}),i}}function AR(n){const e=n.getItem(Ef);if(e)return e;const t=Eu().toLowerCase();return n.setItem(Ef,t),t}var ps;class xR extends gt{constructor(){super();_(this,ps,t=>{const r=TR(t);r!==null&&(t.preventDefault(),this.dispatchEvent(new p0("shortcut-triggered",{shortcut:r})))});document.addEventListener("keydown",l(this,ps))}dispose(){document.removeEventListener("keydown",l(this,ps))}}ps=new WeakMap;function TR(n){for(const[e,t]of Object.entries(j0))if(CR(n,t.trigger))return e;return null}function CR(n,e){return!(n.key.toLowerCase()!==e.key.toLowerCase()||n.metaKey!==!!e.meta||n.ctrlKey!==!!e.ctrl||n.shiftKey!==!!e.shift||n.altKey!==!!e.alt)}const IR="serverURL",PR="token",RR="mode",DR="electron";function hy(n=window.location.search,e=window.location.origin){const r=new URLSearchParams(n).get(IR);return r?new URL(r).origin:new URL(e).origin}function Sc(n=window.location.search){return new URLSearchParams(n).get(PR)}function dy(n=window.location.search){return new URLSearchParams(n).get(RR)===DR}/**
44
+ * @license
45
+ * Copyright 2017 Google LLC
46
+ * SPDX-License-Identifier: BSD-3-Clause
47
+ */const qi=globalThis,$f=n=>n,ia=qi.trustedTypes,Af=ia?ia.createPolicy("lit-html",{createHTML:n=>n}):void 0,fy="$lit$",en=`lit$${Math.random().toFixed(9).slice(2)}$`,py="?"+en,OR=`<${py}>`,rr=document,Xi=()=>rr.createComment(""),Qi=n=>n===null||typeof n!="object"&&typeof n!="function",Nu=Array.isArray,zR=n=>Nu(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",zl=`[
48
+ \f\r]`,$i=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,xf=/-->/g,Tf=/>/g,An=RegExp(`>|${zl}(?:([^\\s"'>=/]+)(${zl}*=${zl}*(?:[^
49
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Cf=/'/g,If=/"/g,gy=/^(?:script|style|textarea|title)$/i,LR=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),F=LR(1),ti=Symbol.for("lit-noChange"),oe=Symbol.for("lit-nothing"),Pf=new WeakMap,Ln=rr.createTreeWalker(rr,129);function my(n,e){if(!Nu(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return Af!==void 0?Af.createHTML(e):e}const MR=(n,e)=>{const t=n.length-1,r=[];let i,s=e===2?"<svg>":e===3?"<math>":"",o=$i;for(let a=0;a<t;a++){const c=n[a];let u,d,f=-1,v=0;for(;v<c.length&&(o.lastIndex=v,d=o.exec(c),d!==null);)v=o.lastIndex,o===$i?d[1]==="!--"?o=xf:d[1]!==void 0?o=Tf:d[2]!==void 0?(gy.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=An):d[3]!==void 0&&(o=An):o===An?d[0]===">"?(o=i??$i,f=-1):d[1]===void 0?f=-2:(f=o.lastIndex-d[2].length,u=d[1],o=d[3]===void 0?An:d[3]==='"'?If:Cf):o===If||o===Cf?o=An:o===xf||o===Tf?o=$i:(o=An,i=void 0);const y=o===An&&n[a+1].startsWith("/>")?" ":"";s+=o===$i?c+OR:f>=0?(r.push(u),c.slice(0,f)+fy+c.slice(f)+en+y):c+en+(f===-2?a:y)}return[my(n,s+(n[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class es{constructor({strings:e,_$litType$:t},r){let i;this.parts=[];let s=0,o=0;const a=e.length-1,c=this.parts,[u,d]=MR(e,t);if(this.el=es.createElement(u,r),Ln.currentNode=this.el.content,t===2||t===3){const f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(i=Ln.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const f of i.getAttributeNames())if(f.endsWith(fy)){const v=d[o++],y=i.getAttribute(f).split(en),A=/([.?@])?(.*)/.exec(v);c.push({type:1,index:s,name:A[2],strings:y,ctor:A[1]==="."?UR:A[1]==="?"?FR:A[1]==="@"?ZR:ja}),i.removeAttribute(f)}else f.startsWith(en)&&(c.push({type:6,index:s}),i.removeAttribute(f));if(gy.test(i.tagName)){const f=i.textContent.split(en),v=f.length-1;if(v>0){i.textContent=ia?ia.emptyScript:"";for(let y=0;y<v;y++)i.append(f[y],Xi()),Ln.nextNode(),c.push({type:2,index:++s});i.append(f[v],Xi())}}}else if(i.nodeType===8)if(i.data===py)c.push({type:2,index:s});else{let f=-1;for(;(f=i.data.indexOf(en,f+1))!==-1;)c.push({type:7,index:s}),f+=en.length-1}s++}}static createElement(e,t){const r=rr.createElement("template");return r.innerHTML=e,r}}function ni(n,e,t=n,r){var o,a;if(e===ti)return e;let i=r!==void 0?(o=t._$Co)==null?void 0:o[r]:t._$Cl;const s=Qi(e)?void 0:e._$litDirective$;return(i==null?void 0:i.constructor)!==s&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),s===void 0?i=void 0:(i=new s(n),i._$AT(n,t,r)),r!==void 0?(t._$Co??(t._$Co=[]))[r]=i:t._$Cl=i),i!==void 0&&(e=ni(n,i._$AS(n,e.values),i,r)),e}class NR{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:r}=this._$AD,i=((e==null?void 0:e.creationScope)??rr).importNode(t,!0);Ln.currentNode=i;let s=Ln.nextNode(),o=0,a=0,c=r[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new Uu(s,s.nextSibling,this,e):c.type===1?u=new c.ctor(s,c.name,c.strings,this,e):c.type===6&&(u=new HR(s,this,e)),this._$AV.push(u),c=r[++a]}o!==(c==null?void 0:c.index)&&(s=Ln.nextNode(),o++)}return Ln.currentNode=rr,i}p(e){let t=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,t),t+=r.strings.length-2):r._$AI(e[t])),t++}}let Uu=class yy{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,r,i){this.type=2,this._$AH=oe,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=r,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=ni(this,e,t),Qi(e)?e===oe||e==null||e===""?(this._$AH!==oe&&this._$AR(),this._$AH=oe):e!==this._$AH&&e!==ti&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):zR(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==oe&&Qi(this._$AH)?this._$AA.nextSibling.data=e:this.T(rr.createTextNode(e)),this._$AH=e}$(e){var s;const{values:t,_$litType$:r}=e,i=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=es.createElement(my(r.h,r.h[0]),this.options)),r);if(((s=this._$AH)==null?void 0:s._$AD)===i)this._$AH.p(t);else{const o=new NR(i,this),a=o.u(this.options);o.p(t),this.T(a),this._$AH=o}}_$AC(e){let t=Pf.get(e.strings);return t===void 0&&Pf.set(e.strings,t=new es(e)),t}k(e){Nu(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let r,i=0;for(const s of e)i===t.length?t.push(r=new yy(this.O(Xi()),this.O(Xi()),this,this.options)):r=t[i],r._$AI(s),i++;i<t.length&&(this._$AR(r&&r._$AB.nextSibling,i),t.length=i)}_$AR(e=this._$AA.nextSibling,t){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,t);e!==this._$AB;){const i=$f(e).nextSibling;$f(e).remove(),e=i}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},ja=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,r,i,s){this.type=1,this._$AH=oe,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=s,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=oe}_$AI(e,t=this,r,i){const s=this.strings;let o=!1;if(s===void 0)e=ni(this,e,t,0),o=!Qi(e)||e!==this._$AH&&e!==ti,o&&(this._$AH=e);else{const a=e;let c,u;for(e=s[0],c=0;c<s.length-1;c++)u=ni(this,a[r+c],t,c),u===ti&&(u=this._$AH[c]),o||(o=!Qi(u)||u!==this._$AH[c]),u===oe?e=oe:e!==oe&&(e+=(u??"")+s[c+1]),this._$AH[c]=u}o&&!i&&this.j(e)}j(e){e===oe?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},UR=class extends ja{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===oe?void 0:e}},FR=class extends ja{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==oe)}},ZR=class extends ja{constructor(e,t,r,i,s){super(e,t,r,i,s),this.type=5}_$AI(e,t=this){if((e=ni(this,e,t,0)??oe)===ti)return;const r=this._$AH,i=e===oe&&r!==oe||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,s=e!==oe&&(r===oe||i);i&&this.element.removeEventListener(this.name,this,r),s&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}};class HR{constructor(e,t,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){ni(this,e)}}const Ll=qi.litHtmlPolyfillSupport;Ll==null||Ll(es,Uu),(qi.litHtmlVersions??(qi.litHtmlVersions=[])).push("3.3.2");const Pe=(n,e,t)=>{const r=e;let i=r._$litPart$;return i===void 0&&(r._$litPart$=i=new Uu(e.insertBefore(Xi(),null),null,void 0,{})),i._$AI(n),i};/**
50
+ * @license
51
+ * Copyright 2017 Google LLC
52
+ * SPDX-License-Identifier: BSD-3-Clause
53
+ */const vy={CHILD:2},Fu=n=>(...e)=>({_$litDirective$:n,values:e});class by{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,r){this._$Ct=e,this._$AM=t,this._$Ci=r}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}/**
54
+ * @license
55
+ * Copyright 2017 Google LLC
56
+ * SPDX-License-Identifier: BSD-3-Clause
57
+ */let sa=class extends by{constructor(e){if(super(e),this.it=oe,e.type!==vy.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===oe||e==null)return this._t=void 0,this.it=e;if(e===ti)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};sa.directiveName="unsafeHTML",sa.resultType=1;const VR=Fu(sa);/**
58
+ * @license
59
+ * Copyright 2017 Google LLC
60
+ * SPDX-License-Identifier: BSD-3-Clause
61
+ */class kc extends sa{}kc.directiveName="unsafeSVG",kc.resultType=2;const jR=Fu(kc),BR={size:16,color:"currentColor",weight:"regular"};function GR(n){return typeof n=="string"?{regular:n}:n}function Jt(n,e="0 0 256 256"){const t=GR(n);return r=>{const{size:i,color:s,weight:o}={...BR,...r},a=t[o]??t.regular;return F`<svg
62
+ xmlns="http://www.w3.org/2000/svg"
63
+ data-ui-icon=""
64
+ width="${i}"
65
+ height="${i}"
66
+ viewBox="${e}"
67
+ fill="${s}"
68
+ >${jR(a)}</svg>`}}const WR=Jt('<path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" d="M200 224H56C53.8783 224 51.8434 223.157 50.3431 221.657C48.8429 220.157 48 218.122 48 216V40C48 37.8783 48.8429 35.8434 50.3431 34.3431C51.8434 32.8429 53.8783 32 56 32H152L208 88V216C208 218.122 207.157 220.157 205.657 221.657C204.157 223.157 202.122 224 200 224Z"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" d="M152 32V88H208"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" d="M80 88H124.5"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" d="M80 128H175"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" d="M80 169H175"/>'),wy=Jt('<path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"/>'),qR=Jt('<path d="M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z"/>'),_y=Jt('<path d="M213.66,93.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,82.34L128,156.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"/>'),YR=Jt('<path d="M213.66,162.34l-80-80a8,8,0,0,0-11.32,0l-80,80A8,8,0,0,0,53.66,173.66L128,99.31l74.34,74.35a8,8,0,0,0,11.32-11.32Z"/>'),KR=Jt('<path d="M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"/>'),JR=Jt({regular:'<path d="M219.31,108.68l-80-80a16,16,0,0,0-22.62,0l-80,80A15.87,15.87,0,0,0,32,120v96a8,8,0,0,0,8,8h64a8,8,0,0,0,8-8V160h32v56a8,8,0,0,0,8,8h64a8,8,0,0,0,8-8V120A15.87,15.87,0,0,0,219.31,108.68ZM208,208H160V152a8,8,0,0,0-8-8H104a8,8,0,0,0-8,8v56H48V120l80-80,80,80Z"/>',bold:'<path d="M222.14,105.85l-80-80a20,20,0,0,0-28.28,0l-80,80A19.86,19.86,0,0,0,28,120v96a12,12,0,0,0,12,12h64a12,12,0,0,0,12-12V164h24v52a12,12,0,0,0,12,12h64a12,12,0,0,0,12-12V120A19.86,19.86,0,0,0,222.14,105.85ZM204,204H164V152a12,12,0,0,0-12-12H104a12,12,0,0,0-12,12v52H52V121.65l76-76,76,76Z"/>',fill:'<path d="M224,120v96a8,8,0,0,1-8,8H160a8,8,0,0,1-8-8V164a4,4,0,0,0-4-4H108a4,4,0,0,0-4,4v52a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V120a16,16,0,0,1,4.69-11.31l80-80a16,16,0,0,1,22.62,0l80,80A16,16,0,0,1,224,120Z"/>'}),XR=Jt({regular:'<path d="M227.31,73.37,182.63,28.68a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H92.69A15.86,15.86,0,0,0,104,219.31L227.31,96a16,16,0,0,0,0-22.63ZM51.31,160,136,75.31,152.69,92,68,176.68ZM48,179.31,76.69,208H48Zm48,25.38L79.31,188,164,103.31,180.69,120Zm96-96L147.31,64l24-24L216,84.68Z"/>',bold:'<path d="M230.14,70.54,185.46,25.85a20,20,0,0,0-28.29,0L33.86,149.17A19.85,19.85,0,0,0,28,163.31V208a20,20,0,0,0,20,20H92.69a19.86,19.86,0,0,0,14.14-5.86L230.14,98.82a20,20,0,0,0,0-28.28ZM93,180l71-71,11,11-71,71ZM76,163,65,152l71-71,11,11ZM52,173l15.51,15.51h0L83,204H52ZM192,103,153,64l18.34-18.34,39,39Z"/>'}),QR=Jt({regular:'<path d="M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z"/>',bold:'<path d="M216,44H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v4H40a12,12,0,0,0,0,24h4V208a20,20,0,0,0,20,20H192a20,20,0,0,0,20-20V68h4a12,12,0,0,0,0-24ZM104,40h48v4H104Zm84,164H68V68H188Zm-84-48V120a12,12,0,0,1,24,0v36a12,12,0,0,1-24,0Zm40,0V120a12,12,0,0,1,24,0v36a12,12,0,0,1-24,0Z"/>'});class Sy extends Event{constructor(t){super("dropdown-item-select",{bubbles:!0,composed:!0});b(this,"value");this.value=t}}class eD extends Event{constructor(t){super("select",{bubbles:!0,composed:!0});b(this,"value");this.value=t}}var Ke,ut,cn,Nr,te,gs,z,Ey,Mi,$y,Ay,Ec,xy,Ni,Cn,Bn,ms,ys,vs,pa,Ty,Cy,$c,Ui,Iy,Ac,zt;class ky extends HTMLElement{constructor(){super();_(this,z);_(this,Ke,!1);_(this,ut,null);_(this,cn,null);_(this,Nr);_(this,te,null);_(this,gs,new MutationObserver(t=>m(this,z,Ty).call(this,t)));_(this,Bn,()=>{m(this,z,Ni).call(this,!l(this,Ke))});_(this,ms,t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),l(this,Bn).call(this))});_(this,ys,t=>{l(this,Ke)&&(t.composedPath().includes(this)||m(this,z,Ni).call(this,!1))});_(this,vs,t=>{t instanceof Sy&&(t.stopPropagation(),E(this,Ke,!1),m(this,z,Mi).call(this,t.value),m(this,z,zt).call(this),this.dispatchEvent(new eD(t.value)))});_(this,pa,()=>{m(this,z,$c).call(this)});E(this,Nr,this.attachShadow({mode:"open"}))}connectedCallback(){this.addEventListener("dropdown-item-select",l(this,vs)),document.addEventListener("click",l(this,ys),!0),m(this,z,Ey).call(this),l(this,gs).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),m(this,z,zt).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",l(this,vs)),document.removeEventListener("click",l(this,ys),!0),l(this,gs).disconnect(),m(this,z,Ac).call(this)}attributeChangedCallback(t){if(t==="open"){m(this,z,Ni).call(this,this.hasAttribute("open"));return}m(this,z,zt).call(this)}get open(){return l(this,Ke)}set open(t){this.toggleAttribute("open",t)}get title(){return this.getAttribute("title")??""}get placement(){return this.getAttribute("placement")==="top"?"top":"bottom"}get value(){return l(this,ut)}set value(t){t===null?(m(this,z,Cn).call(this,null,null),m(this,z,$y).call(this)):m(this,z,Mi).call(this,t),m(this,z,zt).call(this)}close(){m(this,z,Ni).call(this,!1)}}Ke=new WeakMap,ut=new WeakMap,cn=new WeakMap,Nr=new WeakMap,te=new WeakMap,gs=new WeakMap,z=new WeakSet,Ey=function(){var r;const t=this.querySelector("dropdown-item[selected]");t&&m(this,z,Cn).call(this,t.value,((r=t.textContent)==null?void 0:r.trim())??null)},Mi=function(t){var r;for(const i of l(this,z,Ec))i.value===t?(m(this,z,Cn).call(this,t,((r=i.textContent)==null?void 0:r.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},$y=function(){const t=this.querySelectorAll("dropdown-item[selected]");for(const r of t)r.removeAttribute("selected")},Ay=function(t){for(const r of l(this,z,Ec))if(r.value===t)return r;return null},Ec=function(){return this.querySelectorAll("dropdown-item")},xy=function(){return l(this,cn)??this.title},Ni=function(t){l(this,Ke)!==t&&(E(this,Ke,t),m(this,z,zt).call(this))},Cn=function(t,r){E(this,ut,t),E(this,cn,r)},Bn=new WeakMap,ms=new WeakMap,ys=new WeakMap,vs=new WeakMap,pa=new WeakMap,Ty=function(t){t.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||m(this,z,Cy).call(this)},Cy=function(){var r,i;const t=this.querySelector("dropdown-item[selected]");if(t){const s=t.value,o=((r=t.textContent)==null?void 0:r.trim())??null,a=l(this,ut)!==s||l(this,cn)!==o;m(this,z,Cn).call(this,s,o),m(this,z,Mi).call(this,s),a?m(this,z,zt).call(this):m(this,z,Ui).call(this);return}if(l(this,ut)!==null){const s=m(this,z,Ay).call(this,l(this,ut));if(s){const o=((i=s.textContent)==null?void 0:i.trim())??null,a=l(this,cn)!==o;m(this,z,Cn).call(this,l(this,ut),o),m(this,z,Mi).call(this,l(this,ut)),a?m(this,z,zt).call(this):m(this,z,Ui).call(this);return}}if(l(this,ut)!==null||l(this,cn)!==null){m(this,z,Cn).call(this,null,null),m(this,z,zt).call(this);return}m(this,z,Ui).call(this)},$c=function(){const t=l(this,Nr).querySelector('slot[name="trigger"]'),r=t instanceof HTMLSlotElement?t.assignedElements()[0]??null:null;l(this,te)!==r&&(m(this,z,Ac).call(this),E(this,te,r),l(this,te)&&(l(this,te).addEventListener("click",l(this,Bn)),l(this,te)instanceof HTMLButtonElement?l(this,te).hasAttribute("type")||(l(this,te).type="button"):(l(this,te).hasAttribute("role")||l(this,te).setAttribute("role","button"),l(this,te).hasAttribute("tabindex")||(l(this,te).tabIndex=0),l(this,te).addEventListener("keydown",l(this,ms))))),m(this,z,Ui).call(this)},Ui=function(){l(this,te)&&(l(this,te).setAttribute("data-dropdown-trigger",""),l(this,te).setAttribute("aria-haspopup","listbox"),l(this,te).setAttribute("aria-expanded",l(this,Ke)?"true":"false"))},Iy=function(){return this.placement==="top"?YR:_y},Ac=function(){l(this,te)&&(l(this,te).removeEventListener("click",l(this,Bn)),l(this,te).removeEventListener("keydown",l(this,ms)),l(this,te).removeAttribute("data-dropdown-trigger"),l(this,te).removeAttribute("aria-haspopup"),l(this,te).removeAttribute("aria-expanded"),E(this,te,null))},zt=function(){this.toggleAttribute("open",l(this,Ke)),Pe(F`
69
+ <slot name="trigger" @slotchange=${l(this,pa)}>
70
+ <button
71
+ class="fallback-trigger"
72
+ part="trigger"
73
+ type="button"
74
+ aria-haspopup="listbox"
75
+ aria-expanded=${l(this,Ke)?"true":"false"}
76
+ @click=${l(this,Bn)}
77
+ >
78
+ <span class="trigger-label" part="trigger-label">${l(this,z,xy)}</span>
79
+ <span class="trigger-icon" part="trigger-icon" aria-hidden="true">
80
+ ${l(this,z,Iy).call(this,{size:16})}
81
+ </span>
82
+ </button>
83
+ </slot>
84
+ ${l(this,Ke)?F`
85
+ <div
86
+ class="panel"
87
+ part="panel panel-${this.placement}"
88
+ role="listbox"
89
+ >
90
+ <slot></slot>
91
+ </div>
92
+ `:null}
93
+ `,l(this,Nr)),queueMicrotask(()=>m(this,z,$c).call(this))},b(ky,"observedAttributes",["title","placement","open"]);class tD extends HTMLElement{}class nD extends HTMLElement{}class rD extends HTMLElement{}var or,xc,Ry,bs,ws;class Py extends HTMLElement{constructor(){super(...arguments);_(this,or);_(this,bs,()=>{this.action||m(this,or,Ry).call(this)});_(this,ws,t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",l(this,bs)),this.addEventListener("keydown",l(this,ws)),m(this,or,xc).call(this)}disconnectedCallback(){this.removeEventListener("click",l(this,bs)),this.removeEventListener("keydown",l(this,ws))}attributeChangedCallback(){m(this,or,xc).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}or=new WeakSet,xc=function(){if(this.action){this.setAttribute("role","button"),this.removeAttribute("aria-selected");return}this.setAttribute("role","option"),this.setAttribute("aria-selected",this.selected?"true":"false")},Ry=function(){this.dispatchEvent(new Sy(this.value))},bs=new WeakMap,ws=new WeakMap,b(Py,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",ky);customElements.get("dropdown-group")||customElements.define("dropdown-group",tD);customElements.get("dropdown-label")||customElements.define("dropdown-label",nD);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",rD);customElements.get("dropdown-item")||customElements.define("dropdown-item",Py);class iD extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var _s,yn,Tc,ga,Ss,Cc;class Dy extends HTMLElement{constructor(){super();_(this,yn);_(this,_s);_(this,ga,t=>{t.target===t.currentTarget&&m(this,yn,Tc).call(this)});_(this,Ss,t=>{this.open&&t.key==="Escape"&&m(this,yn,Tc).call(this)});E(this,_s,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",l(this,Ss)),m(this,yn,Cc).call(this)}disconnectedCallback(){document.removeEventListener("keydown",l(this,Ss))}attributeChangedCallback(){m(this,yn,Cc).call(this)}get open(){return this.hasAttribute("open")}}_s=new WeakMap,yn=new WeakSet,Tc=function(){this.dispatchEvent(new iD)},ga=new WeakMap,Ss=new WeakMap,Cc=function(){Pe(F`
94
+ ${this.open?F`
95
+ <div class="backdrop" part="backdrop" @click=${l(this,ga)}>
96
+ <slot></slot>
97
+ </div>
98
+ `:null}
99
+ `,l(this,_s))},b(Dy,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",Dy);class sD extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class oD extends HTMLElement{}var ks,Es,Ic;class Oy extends HTMLElement{constructor(){super();_(this,Es);_(this,ks);E(this,ks,this.attachShadow({mode:"open"}))}connectedCallback(){m(this,Es,Ic).call(this)}attributeChangedCallback(){m(this,Es,Ic).call(this)}get closable(){return this.hasAttribute("closable")}}ks=new WeakMap,Es=new WeakSet,Ic=function(){const t=this.querySelector("panel-page");Pe(F`
100
+ <section class="panel" part="panel">
101
+ <header class="title-bar" part="header">
102
+ <h2 class="title" part="title">${(t==null?void 0:t.getAttribute("title"))??""}</h2>
103
+ ${this.closable?F`
104
+ <button
105
+ type="button"
106
+ class="title-button"
107
+ part="button close-button"
108
+ aria-label="Close"
109
+ @click=${()=>this.dispatchEvent(new sD)}
110
+ >
111
+ <span class="close-icon" part="icon close-icon">${wy({size:16})}</span>
112
+ </button>
113
+ `:null}
114
+ </header>
115
+ <slot></slot>
116
+ </section>
117
+ `,l(this,ks))},b(Oy,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",Oy);customElements.get("panel-page")||customElements.define("panel-page",oD);class aD extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const Rf='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Ml=4;var Ve,Vt,Ur,et,$s,Fr,ne,Ly,My,Pc,As,xs,Gn,Ny,Rc,Uy,Fy,Zo,Ho;class zy extends HTMLElement{constructor(){super();_(this,ne);_(this,Ve,!1);_(this,Vt,null);_(this,Ur);_(this,et,null);_(this,$s,"bottom-start");_(this,Fr,!1);_(this,As,t=>{l(this,Ve)&&(l(this,Fr)||t.composedPath().includes(this)||(this.open=!1))});_(this,xs,t=>{if(l(this,Ve)){if(t.key==="Escape"){t.preventDefault(),this.open=!1;return}t.key==="Tab"&&m(this,ne,Ny).call(this,t)}});_(this,Gn,()=>{l(this,Ve)&&m(this,ne,Zo).call(this)});E(this,Ur,this.attachShadow({mode:"open"}))}connectedCallback(){m(this,ne,Ho).call(this)}disconnectedCallback(){m(this,ne,Pc).call(this)}attributeChangedCallback(t){t==="open"&&m(this,ne,Ly).call(this,this.hasAttribute("open"))}get open(){return l(this,Ve)}set open(t){this.toggleAttribute("open",t)}get anchor(){return l(this,Vt)}set anchor(t){l(this,Vt)!==t&&(E(this,Vt,t),l(this,Ve)&&m(this,ne,Zo).call(this))}}Ve=new WeakMap,Vt=new WeakMap,Ur=new WeakMap,et=new WeakMap,$s=new WeakMap,Fr=new WeakMap,ne=new WeakSet,Ly=function(t){var r;l(this,Ve)!==t&&(E(this,Ve,t),t?(E(this,Fr,!0),setTimeout(()=>{E(this,Fr,!1)},0),m(this,ne,Ho).call(this),m(this,ne,My).call(this),queueMicrotask(()=>{l(this,Ve)&&(m(this,ne,Zo).call(this),m(this,ne,Fy).call(this))})):(m(this,ne,Pc).call(this),m(this,ne,Ho).call(this),(r=l(this,Vt))==null||r.focus(),this.dispatchEvent(new aD)))},My=function(){document.addEventListener("click",l(this,As)),document.addEventListener("keydown",l(this,xs),!0),window.addEventListener("resize",l(this,Gn)),window.addEventListener("scroll",l(this,Gn),!0)},Pc=function(){document.removeEventListener("click",l(this,As)),document.removeEventListener("keydown",l(this,xs),!0),window.removeEventListener("resize",l(this,Gn)),window.removeEventListener("scroll",l(this,Gn),!0)},As=new WeakMap,xs=new WeakMap,Gn=new WeakMap,Ny=function(t){const r=m(this,ne,Rc).call(this);if(r.length===0){t.preventDefault();return}const i=r[0],s=r[r.length-1],o=m(this,ne,Uy).call(this),a=o instanceof HTMLElement&&r.includes(o);t.shiftKey?(!a||o===i)&&(t.preventDefault(),s.focus()):(!a||o===s)&&(t.preventDefault(),i.focus())},Rc=function(){if(!l(this,et))return[];const t=l(this,et).querySelector("slot");if(!(t instanceof HTMLSlotElement))return[];const r=[];for(const i of t.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches(Rf)&&r.push(i);for(const s of i.querySelectorAll(Rf))r.push(s)}return r},Uy=function(){var r;let t=document.activeElement;for(;t&&((r=t.shadowRoot)!=null&&r.activeElement);)t=t.shadowRoot.activeElement;return t},Fy=function(){var r;const t=m(this,ne,Rc).call(this);t.length>0?t[0].focus():(r=l(this,et))==null||r.focus()},Zo=function(){if(!l(this,Ve)||!l(this,Vt)||!l(this,et))return;const t=l(this,Vt).getBoundingClientRect(),r=l(this,et).getBoundingClientRect(),s=window.innerHeight-t.bottom,o=r.height+Ml,a=s<o&&t.top>o?"top-start":"bottom-start";E(this,$s,a);const c=a==="bottom-start"?t.bottom+Ml:t.top-r.height-Ml,u=t.left;l(this,et).style.top=`${c}px`,l(this,et).style.left=`${u}px`,l(this,et).setAttribute("data-placement",a)},Ho=function(){this.toggleAttribute("open",l(this,Ve)),Pe(l(this,Ve)?F`<div
118
+ class="panel"
119
+ part="panel"
120
+ data-placement=${l(this,$s)}
121
+ tabindex="-1"
122
+ role="dialog"
123
+ >
124
+ <slot></slot>
125
+ </div>`:oe,l(this,Ur)),E(this,et,l(this,Ur).querySelector(".panel"))},b(zy,"observedAttributes",["open"]);customElements.get("ui-popover")||customElements.define("ui-popover",zy);const lD=pt(),cD="No handler registered for update-content",uD="handleUpdateContent: handler already registered";function hD(n){return n instanceof Error&&typeof n.message=="string"?n.message:String(n)}const dD=di(gt);var Zr,Hr,Vr,Wn,qn,Ts,Ce,Dc,Zy,Hy,Fi,Oc,cp;let fD=(cp=class extends dD{constructor(t){super();_(this,Ce);_(this,Zr);_(this,Hr);_(this,Vr);_(this,Wn,null);_(this,qn,null);_(this,Ts,!1);E(this,Zr,t);const r=t.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");E(this,Hr,r),E(this,Vr,i=>m(this,Ce,Zy).call(this,i)),l(this,Hr).addEventListener("message",l(this,Vr))}get content(){return l(this,qn)}set content(t){m(this,Ce,Oc).call(this),E(this,qn,t),l(this,Ts)&&m(this,Ce,Dc).call(this,t)}handleUpdateContent(t){if(m(this,Ce,Oc).call(this),l(this,Wn)!==null)throw new Error(uD);E(this,Wn,t)}dispose(){l(this,Hr).removeEventListener("message",l(this,Vr)),E(this,Wn,null)}},Zr=new WeakMap,Hr=new WeakMap,Vr=new WeakMap,Wn=new WeakMap,qn=new WeakMap,Ts=new WeakMap,Ce=new WeakSet,Dc=function(t){const r={type:"content-updated",content:t};m(this,Ce,Fi).call(this,r)},Zy=function(t){if(this.disposed||t.source!==l(this,Zr).contentWindow)return;const r=t.data;if(OC(r)){E(this,Ts,!0),this.dispatchEvent(new lD("ready")),l(this,qn)!==null&&m(this,Ce,Dc).call(this,l(this,qn));return}if(zC(r)){m(this,Ce,Hy).call(this,r);return}},Hy=async function(t){const r=l(this,Wn);if(r===null){m(this,Ce,Fi).call(this,{type:"response",id:t.id,error:{message:cD}});return}try{await r(t.content)}catch(i){if(this.disposed)return;m(this,Ce,Fi).call(this,{type:"response",id:t.id,error:{message:hD(i)}});return}this.disposed||m(this,Ce,Fi).call(this,{type:"response",id:t.id,result:{}})},Fi=function(t){const r=l(this,Zr).contentWindow;r&&r.postMessage(t,"*")},Oc=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},cp);function pD(n=window){n.parent!==n&&(n.addEventListener("wheel",e=>{const t=e;n.parent.postMessage({type:"wheel",deltaX:t.deltaX,deltaY:t.deltaY,shiftKey:t.shiftKey},"*"),t.preventDefault()},{passive:!1}),n.addEventListener("message",e=>{const t=e.data;if(t!==null&&typeof t=="object"&&t.type==="scroll"){const r=t,i=typeof r.deltaX=="number"?r.deltaX:0,s=typeof r.deltaY=="number"?r.deltaY:0;n.scrollBy(i,s)}}))}function gD(){return`(${pD.toString()})(window);`}async function mD(n){const e=await fetch(n);if(!e.ok)throw new Error(`Failed to fetch artifact content: ${e.status}`);const t=await e.text(),r=new DOMParser().parseFromString(t,"text/html"),i=r.createElement("base");i.href=n,r.head.insertBefore(i,r.head.firstChild);const s=r.createElement("script");s.textContent=gD(),r.head.appendChild(s);const o=new Blob([`<!DOCTYPE html>
126
+ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const Vy=pt();class yD extends HTMLElement{constructor(){super(...arguments);b(this,"_artifact",null);b(this,"_viewURL",null);b(this,"_contentURL",null);b(this,"_screen",null);b(this,"_subscribedScreen",null);b(this,"_activeView",null);b(this,"_contentState",{kind:"idle"});b(this,"_fetchSequence",0);b(this,"_blobSequence",0);b(this,"_mountedViewURL",null);b(this,"_directRender",!1);b(this,"_blobURL",null);b(this,"handleScreenContentChanged",t=>{!this._artifact||t.artifactID!==this._artifact.id||this._activeView!==null&&this.refetchContent()})}set artifact(t){const r=this._artifact;this._artifact=t,this.render(),r!==null&&r!==t&&this.syncView()}get artifact(){return this._artifact}set viewURL(t){this._viewURL!==t&&(this._viewURL=t,this.syncView())}get viewURL(){return this._viewURL}set contentURL(t){this._contentURL!==t&&(this._contentURL=t,this.syncView())}get contentURL(){return this._contentURL}set screen(t){this._screen!==t&&(this._screen=t,this.syncScreenSubscription())}get screen(){return this._screen}set dragging(t){t?this.setAttribute("dragging","true"):this.removeAttribute("dragging")}get dragging(){return this.getAttribute("dragging")==="true"}get activeView(){return this._activeView}connectedCallback(){this.render(),this.syncView(),this.syncScreenSubscription()}disconnectedCallback(){this.teardownView(),this.unsubscribeFromScreen()}handleClose(){this._artifact&&this.dispatchEvent(new Vy("close-artifact",{artifactID:this._artifact.id,bubbles:!0,composed:!0}))}syncView(){var t;if(this.isConnected){if(this._viewURL!==null){if(this._directRender&&this.teardownView(),this._mountedViewURL!==this._viewURL){this.teardownView(),this._contentState={kind:"loading"},this._mountedViewURL=this._viewURL,this.render();const r=this.querySelector("iframe.artifact-frame");if(!r){this._contentState={kind:"error"},this.render();return}this._activeView=new fD(r),this._activeView.handleUpdateContent(async i=>{await this.saveContent(i)}),this.loadBlobFrame(this._viewURL),this.startContentFetch();return}this._activeView!==null&&this.startContentFetch();return}if(this._contentURL!==null){this.teardownView(),this._directRender=!0,this._contentState={kind:"idle"},this.render(),((t=this._artifact)==null?void 0:t.status)==="committed"&&this.loadBlobFrame(this._contentURL);return}this.teardownView(),this._contentState={kind:"idle"},this.render()}}async saveContent(t){const r=this._screen,i=this._artifact;if(!r||!i)throw new Error("artifact-view: cannot save without a screen and artifact");await r.server.client.artifacts.putContent({artifactID:i.id,content:t})}syncScreenSubscription(){if(!this.isConnected){this.unsubscribeFromScreen();return}this._subscribedScreen!==this._screen&&(this.unsubscribeFromScreen(),this._screen!==null&&(this._screen.addEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=this._screen))}unsubscribeFromScreen(){this._subscribedScreen!==null&&(this._subscribedScreen.removeEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=null)}startContentFetch(){this._fetchSequence+=1;const t=this._fetchSequence,r=this._contentURL,i=this._activeView;if(!i||r===null){this._contentState={kind:"error"},this.render();return}this._contentState={kind:"loading"},(async()=>{try{const s=await fetch(r);if(t!==this._fetchSequence)return;if(!s.ok){this._contentState={kind:"error"},this.teardownView(),this.render();return}const o=await s.text();if(t!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o,this._contentState={kind:"ready"}}catch{if(t!==this._fetchSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}refetchContent(){this._fetchSequence+=1;const t=this._fetchSequence,r=this._contentURL,i=this._activeView;!i||r===null||(async()=>{try{const s=await fetch(r);if(t!==this._fetchSequence||!s.ok)return;const o=await s.text();if(t!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o}catch{}})()}loadBlobFrame(t){this._blobSequence+=1;const r=this._blobSequence;(async()=>{try{const i=await mD(t);if(r!==this._blobSequence){URL.revokeObjectURL(i);return}this._blobURL=i,this.render();const s=this.querySelector("iframe.artifact-frame");s&&(s.src=i)}catch{if(r!==this._blobSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}teardownView(){this._activeView!==null&&(this._activeView.dispose(),this._activeView=null),this._blobURL!==null&&(URL.revokeObjectURL(this._blobURL),this._blobURL=null),this._mountedViewURL=null,this._directRender=!1,this._fetchSequence+=1,this._blobSequence+=1}contentTemplate(){return this._contentState.kind==="error"?F`
127
+ <div class="artifact-content artifact-placeholder">
128
+ <em>Failed to load content</em>
129
+ </div>
130
+ `:this._viewURL!==null||this._directRender?F`
131
+ <iframe
132
+ class="artifact-frame artifact-content"
133
+ src=${this._blobURL??"about:blank"}
134
+ sandbox="allow-scripts"
135
+ ></iframe>
136
+ `:F`
137
+ <div class="artifact-content artifact-placeholder">
138
+ <em>Artifact unavailable</em>
139
+ </div>
140
+ `}template(){const t=this._artifact;return F`
141
+ ${this.contentTemplate()}
142
+ <footer class="artifact-title-bar" drag-handle>
143
+ <div class="artifact-title-group">
144
+ <span class="artifact-title-icon">${WR({size:16})}</span>
145
+ <span class="artifact-title">${t.title}</span>
146
+ </div>
147
+ <button
148
+ icon-only
149
+ class="artifact-close-btn"
150
+ @click=${()=>this.handleClose()}
151
+ aria-label="Close"
152
+ >
153
+ ${wy({size:16})}
154
+ </button>
155
+ </footer>
156
+ `}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),Pe(this.template(),this))}}customElements.define("artifact-view",yD);const ke=n=>({type:"px",...n}),Te=n=>({type:"unit",...n}),ko=2,vD=2;class bD{constructor(e){b(this,"basis");b(this,"min");b(this,"_gap");b(this,"_viewport");b(this,"_unit");this.basis=e.basis,this.min=e.min,this._viewport=e.viewport,this._gap=e.gap??ke({x:pe,y:pe});const t=this._viewport.x??tr,r=this._viewport.y??Xo,i=this._gap.x??pe,s=this._gap.y??pe,o=tr+i*vD,a=t<=o,c=a?t-i*ko:Math.min(tr,t-i*ko),u=a?r-s*ko:Math.min(Xo,r-s*ko),d=(c-i*(Ct-1))/Ct,f=(u-s*(Xe-1))/Xe,v=this.basis.x??0,y=this.basis.y??0,A=this.min.x??0,k=this.min.y??0;this._unit=ke(a?{x:Math.max(A,d),y:Math.max(k,f)}:{x:Math.max(A,Math.min(v,d)),y:Math.max(k,Math.min(y,f))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(e){return Te({x:e.x==null?void 0:e.x/(this._unit.x??1),y:e.y==null?void 0:e.y/(this._unit.y??1)})}toPixels(e){const t=this._unit.x??0,r=this._unit.y??0,i=this._gap.x??pe,s=this._gap.y??pe,o=e.x==null?void 0:e.x*t+Math.max(0,e.x-1)*i,a=e.y==null?void 0:e.y*r+Math.max(0,e.y-1)*s;return ke({x:o,y:a})}}const ir=1e-4,Bt=1e-6,wD=40,_D=24;function jy(n,e){return Math.max(0,n-e*2)}function By(n){const e=[0];for(const t of n)e.push((e[e.length-1]??0)+t);return e}function Gy(n){const e=[0];for(let t=0;t<n.length;t+=1){const r=e[t]??0;e.push(r+n[t]+pe)}return e}function Wy(n,e,t){if(e<0||e>=n.length)return 0;let r=0,i=0;for(let s=e;s<n.length;s+=1){const o=n[s],a=i===0?o:r+pe+o;if(a>t+ir)break;r=a,i+=1}return Math.max(1,i)}function SD(n,e,t){if(e<0||e>=n.length)return 0;let r=0,i=0;for(let s=e;s>=0;s-=1){const o=n[s],a=i===0?o:r+pe+o;if(a>t+ir)break;r=a,i+=1}return Math.max(1,i)}function kD(n,e){if(n.length===0)return 0;let t=0,r=0;for(let i=n.length-1;i>=0;i-=1){const s=n[i],o=r===0?s:t+pe+s;if(o>e+ir)break;t=o,r+=1}return Math.max(1,r)}function Zu(n,e){if(n.length===0)return 0;const t=kD(n,e);return Math.max(0,n.length-t)}function Df(n,e,t){if(n.length===0)return 0;const r=Wy(n,e,t),i=Math.min(n.length,e+r);if(i<=e)return 0;const s=n.slice(e,i);return s.reduce((o,a)=>o+a,0)+Math.max(0,s.length-1)*pe}function zc(n,e,t){const r=n[e]??0;return t-r}function xr(n,e,t,r,i){if(n.length===0)return 0;const s=Zu(n,i),o=e[s]??0,a=Math.max(0,Math.min(o,t));let c=0;for(let Z=0;Z<s;Z+=1){const U=e[Z]??0,ge=e[Z+1]??U;if(a>=U&&a<=ge+ir){c=Z;break}c=Z+1}const u=Math.min(c+1,s),d=e[c]??0,f=e[u]??d,v=Math.max(f-d,ir),y=u===c?0:(a-d)/v,A=Gy(n),k=Df(n,c,i),I=Df(n,u,i),B=(r-k)/2,P=(r-I)/2,le=zc(A,c,B),M=zc(A,u,P);return le+(M-le)*y}function Of(n,e,t,r,i){const s=Zu(n,r),o=e[s]??0;let a=0,c=o;for(let u=0;u<wD;u+=1){const d=(a+c)/2;xr(n,e,d,t,r)>i?a=d:c=d}return(a+c)/2}function zf(n,e,t){const r=Gy(n),[i,s]=e,o=n.slice(i,s+1),a=o.reduce((u,d)=>u+d,0)+Math.max(0,o.length-1)*pe,c=(t-a)/2;return zc(r,i,c)}function ED(n,e,t){const r=Wy(n,e,t);return[e,Math.min(n.length-1,e+r-1)]}function $D(n,e,t){const r=SD(n,e,t);return[Math.max(0,e-r+1),e]}function AD(n){const e=new Set,t=[];for(const r of n){const i=`${r.nodeRange[0]}:${r.nodeRange[1]}`;if(e.has(i))continue;const s=t[t.length-1];s&&Math.abs(s.anchor-r.anchor)<=Bt||(e.add(i),t.push(r))}return t}function xD(n){const{nodeCols:e,nodeWidthsPx:t,viewportWidthPx:r}=n;if(e.length===0||t.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const i=n.gapPx??pe,s=jy(r,i),o=By(e),a=Zu(t,s),c=o[a]??0,u=[];for(let d=0;d<=a;d+=1){const f=ED(t,d,s),v=zf(t,f,r),y=Of(t,o,r,s,v);u.push({nodeRange:f,anchor:Math.max(0,Math.min(c,y))})}for(let d=t.length-1;d>=0;d-=1){const f=$D(t,d,s),v=`${f[0]}:${f[1]}`;if(u.some(k=>`${k.nodeRange[0]}:${k.nodeRange[1]}`===v))continue;const y=zf(t,f,r),A=Of(t,o,r,s,y);u.push({nodeRange:f,anchor:Math.max(0,Math.min(c,A))})}return u.sort((d,f)=>Math.abs(d.anchor-f.anchor)>Bt?d.anchor-f.anchor:d.nodeRange[0]!==f.nodeRange[0]?d.nodeRange[0]-f.nodeRange[0]:d.nodeRange[1]-f.nodeRange[1]),{viewspans:AD(u),minScroll:0,maxScroll:c}}function TD(n,e){var i;let t=0,r=Number.POSITIVE_INFINITY;for(let s=0;s<n.length;s+=1){const o=Math.abs((((i=n[s])==null?void 0:i.anchor)??0)-e);if(o+Bt<r){r=o,t=s;continue}Math.abs(o-r)<=Bt&&s<t&&(t=s)}return t}function CD(n,e,t){return t<=0?0:Math.max(0,Math.min(t-1,n+e))}function Ai(n,e,t){return Math.max(e,Math.min(t,n))}class ID extends gt{constructor(t){super();b(this,"_scroll",0);b(this,"minScroll",0);b(this,"maxScroll",0);b(this,"viewspans",[]);b(this,"activeViewspanIndex",null);b(this,"nodeWidthsPx",[]);b(this,"boundaryCols",[0]);b(this,"viewportWidthPx",0);b(this,"framedViewportWidthPx",0);this._scroll=(t==null?void 0:t.x)??0}get scroll(){return Te({x:this._scroll})}get translate(){return ke({x:xr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx)})}set scroll(t){const r=Ai(t.x??this._scroll,this.minScroll,this.maxScroll);Math.abs(r-this._scroll)<=Bt||(this._scroll=r,this.activeViewspanIndex=null,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}rebuild(t){const r=t.nodeWidths.map(u=>Math.max(0,u.x??0)),i=r.map(u=>t.grid.toPixels(Te({x:u})).x??0),s=t.grid.viewport.x??0,o=t.grid.gap.x??pe,a=xD({nodeCols:r,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this.nodeWidthsPx=i,this.boundaryCols=By(r),this.viewportWidthPx=s,this.framedViewportWidthPx=jy(s,o),this.viewspans=a.viewspans,this.minScroll=a.minScroll,this.maxScroll=a.maxScroll,this.activeViewspanIndex=null;const c=Ai(this._scroll,this.minScroll,this.maxScroll);Math.abs(c-this._scroll)>Bt&&(this._scroll=c,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}step(t){var a;if(this.viewspans.length===0)return;const r=this.activeViewspanIndex??TD(this.viewspans,this._scroll),i=CD(r,t,this.viewspans.length),s=((a=this.viewspans[i])==null?void 0:a.anchor)??this._scroll,o=Ai(s,this.minScroll,this.maxScroll);this.activeViewspanIndex=i,!(Math.abs(o-this._scroll)<=Bt)&&(this._scroll=o,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}wheel(t){const r=Ai(this._scroll+(t.x??0),this.minScroll,this.maxScroll);this.activeViewspanIndex=null,!(Math.abs(r-this._scroll)<=Bt)&&(this._scroll=r,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}wheelPixels(t){const r=t.x??0;if(Math.abs(r)<=ir)return;this.activeViewspanIndex=null;const i=xr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),s=i-r,o=xr(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=xr(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),c=Math.max(o,Math.min(a,s));if(Math.abs(c-i)<=ir)return;let u=this.minScroll,d=this.maxScroll;for(let v=0;v<_D;v+=1){const y=(u+d)/2;xr(this.nodeWidthsPx,this.boundaryCols,y,this.viewportWidthPx,this.framedViewportWidthPx)>c?u=y:d=y}const f=Ai((u+d)/2,this.minScroll,this.maxScroll);Math.abs(f-this._scroll)<=Bt||(this._scroll=f,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}}const Nl={"stack-above":{left:.25,top:0,width:.5,height:.5},"stack-below":{left:.25,top:.5,width:.5,height:.5},"reorder-before":{left:0,top:0,width:.25,height:1},"reorder-after":{left:.75,top:0,width:.25,height:1}},PD=["stack-above","stack-below","reorder-before","reorder-after"];function Ul(n,e){return{left:n.left+n.width*e.left,top:n.top+n.height*e.top,width:n.width*e.width,height:n.height*e.height}}function xn(n,e,t){return n>=t.left&&n<t.left+t.width&&e>=t.top&&e<t.top+t.height}function Hu(n,e){for(const t of n){if(t.type==="card"&&t.id===e)return t;if(t.type==="stack")for(const r of t.children){if(r.type==="card"&&r.id===e)return r;if(r.type==="row"){for(const i of r.children)if(i.id===e)return i}}}return null}function Lc(n){return n.height===Xe||n.height===fn?{...n,height:fn}:n}function Mc(n){return n.height===fn?{...n,height:Xe}:n}function RD(n,e,t,r){const i=n.findIndex(d=>d.type==="stack"&&d.id===e);if(i===-1)return n;const s=n[i];if(!s||s.type!=="stack")return n;const o=s.children.find(d=>d.type==="card"&&d.id===t);if(!o||o.type!=="card")return n;const a=s.children.filter(d=>d.id!==t);if(a.length===s.children.length||a.length<1)return n;const c=[...n];if(a.length===1){const[d]=a;c[i]=d.type==="card"?Mc(d):d}else c[i]={...s,children:a};const u=Math.max(0,Math.min(r,c.length));return c.splice(u,0,Mc(o)),c}const DD=pt(),OD=pt(),zD=50;function LD(n,e){if(n.type!==e.type)return!1;switch(n.type){case"reorder":return e.index===n.index;case"stack":return e.targetCardId===n.targetCardId&&e.position===n.position;case"stack-child-noop":return!0;case"stack-child-extract":return e.toIndex===n.toIndex;case"stack-child-reorder":return e.position===n.position;default:return!1}}function Qs(n){return{id:n.id,type:"drop-target",width:n.width,height:n.height}}function Lf(n){return n.map(ND)}function MD(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n}function ND(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n.type==="stack"?{...n,children:n.children.map(MD)}:n}function qy(n,e){return n.find(r=>r.type==="card"&&r.id===e)??null}function Mf(n,e){return n.find(r=>r.type==="stack"&&r.id===e)??null}function UD(n,e){const t=[...e],r=t.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(r===-1)return null;const i=t[r];if(!i||i.type!=="card")return null;t.splice(r,1);const s=Math.max(0,Math.min(n.lastReorderIndex,t.length));t.splice(s,0,i);const o=t.findIndex(a=>a.type==="card"&&a.id===n.nodeId);return o===-1?null:{base:t,visualDraggedIndex:o}}function FD(n,e,t,r){const i=[...n.base];i.splice(n.visualDraggedIndex,1);const s=i.findIndex(v=>v.type==="card"&&v.id===t.targetCardId),o=s===-1?null:i[s];if(!o||o.type!=="card")return null;const a=qy(r,e.nodeId);if(!a)return null;const c=Lc(a),u=Lc(o),d=Qs(c),f=t.position==="above"?[d,u]:[u,d];return i[s]={id:o.id,type:"stack",children:f},i}function Fl(n,e){return n.parentStackId?HD(n,e):ZD(n,e)}function ZD(n,e){const t=n.hitTarget;if(t.type==="reorder"){const r=e[n.sourceIndex];if(!r||r.type!=="card")return[...e];const i=[...e];return i.splice(n.sourceIndex,1),i.splice(t.index,0,Qs(r)),i}if(t.type==="stack"){const r=UD(n,e);return r?FD(r,n,t,e)??[...e]:[...e]}return[...e]}function HD(n,e){const t=n.hitTarget;switch(t.type){case"stack-child-reorder":return VD(n,e,t.position);case"stack-child-extract":return jD(n,e,t.toIndex);case"stack-child-noop":return BD(n,e);default:return[...e]}}function VD(n,e,t){const r=e.findIndex(v=>v.type==="stack"&&v.id===n.parentStackId);if(r===-1)return[...e];const i=e[r];if(!i||i.type!=="stack")return[...e];if(!i.children.every(v=>v.type==="card"))return[...e];const s=i.children,o=s.findIndex(v=>v.id===n.nodeId);if(o===-1)return[...e];const a=s[o],c=s.filter(v=>v.id!==n.nodeId),u=Qs(a),d=t==="above"?[u,...c]:[...c,u],f=[...e];return f[r]={...i,children:d},f}function jD(n,e,t){if(!n.parentStackId)return[...e];const r=RD(e,n.parentStackId,n.nodeId,t);if(r===e)return[...e];const i=r.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(i===-1)return[...e];const s=r[i];if(!s||s.type!=="card")return[...e];const o=[...r];return o[i]=Qs(s),o}function BD(n,e){const t=e.findIndex(c=>c.type==="stack"&&c.id===n.parentStackId);if(t===-1)return[...e];const r=e[t];if(!r||r.type!=="stack")return[...e];const i=r.children.findIndex(c=>c.type==="card"&&c.id===n.nodeId);if(i===-1)return[...e];const s=r.children[i];if(!s||s.type!=="card")return[...e];const o=[...e],a=[...r.children];return a[i]=Qs(s),o[t]={...r,children:a},o}function GD(n,e){return e.find(r=>r.type==="stack"&&r.id===n.id)?n.id:Eu()}function WD(n,e,t){if(n.type==="drop-target"){const r=Hu(e,t);if(!r)throw new Error(`finalize: missing dragged card ${t}`);return Lc(r)}return n}function qD(n,e,t){const r=n.children.map(s=>WD(s,e,t));return{id:GD(n,e),type:"stack",children:r}}function YD(n,e,t){if(n.type==="drop-target"){const r=Hu(e,t);if(!r)throw new Error(`finalize: missing dragged card ${t}`);return qy(e,t)!==null?r:Mc(r)}return n.type==="card"||n.type==="row"?n:qD(n,e,t)}function KD(n,e,t){return n.map(r=>YD(r,e,t))}function JD(n,e){return JSON.stringify(n)===JSON.stringify(e)}const XD=di(gt);class QD extends XD{constructor(t={}){super();b(this,"pending",null);b(this,"active",null)}start(t){if(this.pending||this.active)return;const r=t.pointer.x??0,i=t.pointer.y??0;this.pending={startX:r,startY:i,grabOffsetX:t.grabOffset.x??0,grabOffsetY:t.grabOffset.y??0,nodeId:t.nodeId,sourceIndex:t.source.index,parentStackId:t.source.parentId,width:t.size.x??0,height:t.size.y??0,baseLayout:t.layout}}update(t){const r=t.pointer.x??0,i=t.pointer.y??0,s=this.pending;if(s){const u=r-s.startX,d=i-s.startY;Math.hypot(u,d)>=$0&&(this.pending=null,this.active={...s,pointerX:r,pointerY:i,hitTarget:{type:"reorder",index:s.sourceIndex},lastReorderIndex:s.sourceIndex},this.emitDrag(),this.dispatchEvent(new Q("change")));return}if(!this.active)return;const o=Fl(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,i,t,o),c=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===i&&LD(this.active.hitTarget,a)&&this.active.lastReorderIndex===c||(this.active={...this.active,pointerX:r,pointerY:i,hitTarget:a,lastReorderIndex:c},this.emitDrag(),this.dispatchEvent(new Q("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const t=this.active.baseLayout;let r=null;try{const i=Fl(this.active,t),s=KD(i,t,this.active.nodeId);JD(s,t)||(r=s)}catch{r=null}this.reset(),r&&this.dispatchEvent(new OD("drop",{layout:r})),this.dispatchEvent(new Q("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new Q("change")))}dispose(){this.reset()}get status(){return this.active?"active":this.pending?"pending":"idle"}reset(){this.pending=null,this.active=null}emitDrag(){if(!this.active)return;const t=Fl(this.active,this.active.baseLayout);this.dispatchEvent(new DD("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:ke({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:ke({x:this.active.pointerX,y:this.active.pointerY}),size:ke({x:this.active.width,y:this.active.height}),projectedLayout:t}))}getHitTargetForPointer(t,r,i,s){return this.active?this.isPointerInsideDragBounds(t,r,i.viewport)?this.active.parentStackId?this.getStackChildHitTarget(t,r,i,s):this.getTopLevelCardHitTarget(t,r,i,s):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(t,r,i,s){var u;if(!((u=this.active)!=null&&u.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(i.geometry);if(o&&xn(t,r,o)){const d=o.top+o.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}const a=this.getSourceRemainingSiblingRect(i.geometry);if(a&&xn(t,r,a)){const d=a.top+a.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(t,r,i,s)}}getSourceRemainingSiblingRect(t){var s,o;if(!((s=this.active)!=null&&s.parentStackId))return;const r=Mf(this.active.baseLayout,this.active.parentStackId);if(!r)return;const i=r.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.nodeId)});if(i)return(o=t.find(a=>a.id===i.id))==null?void 0:o.rect}getSourceStackInteractionRect(t){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const r=t.find(a=>{var c;return a.id===((c=this.active)==null?void 0:c.parentStackId)});if(r)return this.active.sourceStackRect=r.rect,r.rect;const i=Mf(this.active.baseLayout,this.active.parentStackId);if(!i)return this.active.sourceStackRect;const s=i.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.nodeId)});if(s){const a=t.find(c=>c.id===s.id);if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(t,r,i,s){var y,A,k;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return{type:"reorder",index:((y=this.active)==null?void 0:y.sourceIndex)??0};const c=(i.effectiveVelocity??0)<=zD;for(const I of o){const B=I.rect;if(!xn(t,r,B))continue;const P=this.resolveTopLevelTargetForCard(t,r,I,I.logicalIndex,c);if(P)return P;if(!c&&((A=this.active)!=null&&A.hitTarget))return this.active.hitTarget}const u=this.getNearestTargetableZone(t,o);if(!u)return{type:"reorder",index:((k=this.active)==null?void 0:k.sourceIndex)??0};const d=Math.max(u.rect.left,Math.min(u.rect.left+u.rect.width,t)),f=this.resolveTopLevelTargetForCard(d,r,u,u.logicalIndex,c);if(f)return f;const v=u.rect.left+u.rect.width/2;return{type:"reorder",index:t<v?u.logicalIndex:u.logicalIndex+1}}getTopLevelReorderIndexForPointer(t,r,i,s){var u,d;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return((u=this.active)==null?void 0:u.sourceIndex)??0;for(const f of o){if(!xn(t,r,f.rect))continue;const v=Ul(f.rect,Nl["reorder-before"]);if(xn(t,r,v))return f.logicalIndex;const y=Ul(f.rect,Nl["reorder-after"]);if(xn(t,r,y))return f.logicalIndex+1}const a=this.getNearestTargetableZone(t,o);if(!a)return((d=this.active)==null?void 0:d.sourceIndex)??0;const c=a.rect.left+a.rect.width/2;return t<c?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(t,r){const i=new Map(r.map(a=>[a.id,a])),s=[];let o=0;for(const a of t){const c=i.get(a.id);c&&c.type!=="drop-target"&&(c.type==="card"||c.type==="stack")&&(s.push({id:c.id,rect:a.rect,logicalIndex:o}),o+=1)}return s}resolveTopLevelTargetForCard(t,r,i,s,o){const a=i.rect;for(const c of PD){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const u=Nl[c],d=Ul(a,u);if(xn(t,r,d))return c==="stack-above"?{type:"stack",targetCardId:i.id,position:"above"}:c==="stack-below"?{type:"stack",targetCardId:i.id,position:"below"}:c==="reorder-before"?{type:"reorder",index:s}:{type:"reorder",index:s+1}}return null}getNearestTargetableZone(t,r){let i=null,s=Number.POSITIVE_INFINITY;for(const o of r){const a=o.rect.left,c=o.rect.left+o.rect.width,u=t<a?a-t:t>c?t-c:0;u<s&&(s=u,i=o)}return i}isPointerInsideDragBounds(t,r,i){return t>=i.left&&t<=i.left+i.width&&r>=i.top&&r<=i.top+i.height}}const Nf=60,eO=80,Uf=.5,Ff=10;class tO{constructor(){b(this,"awaitingFreshWheelGesture",!1);b(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);b(this,"lastWheelDeltaX",0);b(this,"activeGestureType","none");b(this,"lastWheelGestureAt",Number.NEGATIVE_INFINITY)}markKeyboardNavigation(e){this.awaitingFreshWheelGesture=!0,this.lastWheelEventAt=e,this.activeGestureType="none"}reset(){this.awaitingFreshWheelGesture=!1,this.lastWheelEventAt=Number.NEGATIVE_INFINITY,this.lastWheelDeltaX=0,this.activeGestureType="none",this.lastWheelGestureAt=Number.NEGATIVE_INFINITY}decide(e){const{now:t,shiftKey:r,deltaX:i,deltaY:s,overArtifactContent:o}=e;t-this.lastWheelGestureAt>=Nf&&(this.activeGestureType="none");const c=r&&s!==0,u=c?s:i,d=Math.abs(u),f=Math.abs(s);return this.activeGestureType==="vertical-artifact"&&o?d>=Uf&&d>=f*Ff?this.classifyHorizontal(t,u):(this.lastWheelGestureAt=t,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!c&&o&&f>0&&f>=d*Ff?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=t,{type:"scroll-native"}):this.classifyHorizontal(t,u):d<Uf?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=t,{type:"scroll-native"}):c||d>f?this.classifyHorizontal(t,u):f>d?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=t,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=t,{type:"scroll-native"}):this.classifyHorizontal(t,u)}classifyHorizontal(e,t){const r=e-this.lastWheelEventAt,i=Math.sign(this.lastWheelDeltaX),s=Math.sign(t),o=i!==0&&s!==0&&i!==s,a=i!==0&&Math.abs(t)>=Math.abs(this.lastWheelDeltaX)+eO;return this.awaitingFreshWheelGesture&&r<Nf&&!o&&!a?{type:"ignore"}:(this.lastWheelEventAt=e,this.lastWheelDeltaX=t,this.lastWheelGestureAt=e,this.awaitingFreshWheelGesture=!1,this.activeGestureType="horizontal-filmstrip",{type:"scroll-horizontal",horizontalDelta:t})}}const nO=2,Zf=1e3,Eo=1e-4;function Hf(n,e,t){if(n===0)return 0;const r=e.toPixels(Te({y:Xe})).y??0;return(t-r)/nO}function Zl(n){const e=n.clientWidth>0?n.clientWidth:tr,t=n.clientHeight>0?n.clientHeight:Xo;let r=0,i=0;if(n.isConnected){const o=getComputedStyle(n);r=parseFloat(o.paddingTop)||0,i=parseFloat(o.paddingBottom)||0}const s=Math.max(1,t-r-i);return{width:e,height:s,offsetY:r}}class rO extends Event{constructor(t){super("scroll",{bubbles:!0,composed:!0});b(this,"scrollPosition");this.scrollPosition=t}}class Yy extends Event{constructor(t){super("layout-change",{bubbles:!0,composed:!0});b(this,"layout");this.layout=t}}class iO extends HTMLElement{constructor(){super();b(this,"_layout",[]);b(this,"_scrollPosition",0);b(this,"layoutGrid",null);b(this,"layoutScroll",new ID(Te({x:0})));b(this,"scrollModelKey","");b(this,"resizeObserver",null);b(this,"renderPending",!1);b(this,"animateNextRender",!0);b(this,"wheelGesture",new tO);b(this,"dragController",new QD);b(this,"dragState",null);b(this,"activeDragPointerId",null);b(this,"dragListenersAttached",!1);b(this,"dragFrame",0);b(this,"lastDragFrameTime",0);b(this,"lastPointerX",0);b(this,"lastPointerY",0);b(this,"pointerVelocityPxPerSec",0);b(this,"scrollVelocityPxPerSec",0);b(this,"motionSampleTime",0);b(this,"motionSampleX",0);b(this,"motionSampleY",0);b(this,"dragTrackOffsetXPx",0);b(this,"previousProjectedLayoutForOffset",null);b(this,"renderContent",()=>F``);b(this,"onDragControllerChange",()=>{this.dragController.status==="idle"&&(this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null),this.scheduleRender()});b(this,"onDragControllerDrag",t=>{const r=Lf(t.projectedLayout),i=this.shouldApplyTrackOffset(t.projectedLayout,t.source.parentId),s=t.source.parentId?this.getStackChildAnchorCardId(t.source.parentId,t.nodeId):null;this.dragTrackOffsetXPx=i?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,r,t.nodeId,t.source.parentId,s,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=r,this.dragState={nodeId:t.nodeId,source:t.source,grabOffset:t.grabOffset,pointer:t.pointer,size:t.size,projectedLayout:t.projectedLayout},this.scheduleRender()});b(this,"onDragControllerDrop",t=>{this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.commitLayout(t.layout)});b(this,"onLayoutScrollInternal",t=>{const i=t.scroll.x??0;Math.abs(i-this._scrollPosition)<Eo||(this._scrollPosition=i,this.emitScrollPositionChanged(i),this.scheduleRender())});b(this,"handleKeyDown",t=>{if(t.key==="Escape"&&this.dragController.status!=="idle"){t.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(t.key==="ArrowRight"?(t.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(1)):t.key==="ArrowLeft"&&(t.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(-1)))});b(this,"handleWheel",t=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:t.shiftKey,deltaX:t.deltaX,deltaY:t.deltaY,overArtifactContent:!1});r.type==="scroll-horizontal"&&(t.preventDefault(),this.applyHorizontalWheel(r.horizontalDelta))});b(this,"handleWindowMessage",t=>{var o;if(this._layout.length===0)return;const r=this.findManagedArtifactFrame(t.source);if(!r||!this.isTrustedArtifactFrameMessage(t,r)||!LC(t.data))return;const i=this.wheelGesture.decide({now:Date.now(),shiftKey:t.data.shiftKey,deltaX:t.data.deltaX,deltaY:t.data.deltaY,overArtifactContent:!0});if(i.type==="scroll-horizontal"){this.applyHorizontalWheel(i.horizontalDelta);return}if(i.type!=="scroll-native")return;const s={type:"scroll",deltaX:0,deltaY:t.data.deltaY};(o=r.contentWindow)==null||o.postMessage(s,this.getArtifactFrameTargetOrigin(r))});b(this,"handlePointerDown",t=>{if(t.button!==0||this.dragController.status!=="idle")return;const r=t.target;if(!(r instanceof Element)||!r.closest("[drag-handle]")||r.closest("button, input, textarea, select, a, [role='button']"))return;const i=r.closest(".card-slot");if(!i)return;const s=i.getAttribute("data-layout-node-id");if(!s)return;const o=oO(this._layout,s);if(!o)return;const a=i.getBoundingClientRect();this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.resetMotionTracking(t.clientX,t.clientY),this.focus(),this.dragController.start({nodeId:s,source:{index:o.topLevelIndex,parentId:o.sourceStackId},pointer:ke({x:t.clientX,y:t.clientY}),grabOffset:ke({x:t.clientX-a.left,y:t.clientY-a.top}),size:ke({x:a.width,y:a.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=t.pointerId;try{this.setPointerCapture(t.pointerId)}catch{}t.preventDefault()});b(this,"handleWindowPointerMove",t=>{this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.updatePointerVelocity(t.clientX,t.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop()});b(this,"handleWindowPointerUp",t=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(t.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowPointerCancel",t=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(t.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"runDragFrame",t=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const r=Math.max(0,t-this.lastDragFrameTime)/Zf;this.lastDragFrameTime=t,this.samplePointerVelocityAt(t,this.lastPointerX,this.lastPointerY);const i=this.getBoundingClientRect(),s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,i),o=this.getDragEdgeScrollDeltaPixels(s.x,i,r);this.scrollVelocityPxPerSec=r>Eo?Math.abs(o)/r:0,Math.abs(o)>Eo&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(ke({x:o}))),this.dragController.status==="active"&&this.syncDragTarget(s.x,s.y,i),this.dragFrame=requestAnimationFrame(this.runDragFrame)});this.dragController.addEventListener("change",this.onDragControllerChange),this.dragController.addEventListener("drag",this.onDragControllerDrag),this.dragController.addEventListener("drop",this.onDragControllerDrop),this.layoutScroll.addEventListener("layout-scroll",this.onLayoutScrollInternal)}set layout(t){this._layout=[...t],this.stopDragFrameLoop(),this.dragController.cancel(),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=Te({x:this._scrollPosition}),this.scheduleRender()}get layout(){return this._layout}commitLayout(t){this.layout=t,this.emitLayoutChanged()}set scrollPosition(t){Math.abs(t-this._scrollPosition)<Eo||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=Te({x:t}))}get scrollPosition(){return this._scrollPosition}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.focus(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("pointerdown",this.handlePointerDown),window.addEventListener("message",this.handleWindowMessage),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.render()),this.resizeObserver.observe(this)),this.render()}disconnectedCallback(){var t;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("message",this.handleWindowMessage),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=null,this.wheelGesture.reset(),this.detachDragListeners(),this.dragController.removeEventListener("change",this.onDragControllerChange),this.dragController.removeEventListener("drag",this.onDragControllerDrag),this.dragController.removeEventListener("drop",this.onDragControllerDrop),this.layoutScroll.removeEventListener("layout-scroll",this.onLayoutScrollInternal),this.dragController.dispose(),this.stopDragFrameLoop()}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(t,r){return new bD({basis:ke({x:Pn,y:Pn}),min:ke({x:Kd,y:Kd}),viewport:ke({x:t,y:r}),gap:ke({x:pe,y:pe})})}syncScrollModel(){const t=Zl(this),i=Wi(this._layout).nodes.map(o=>o.width),s=`${t.width}x${t.height}:${i.join(",")}`;s===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=s,this.layoutGrid=this.createGrid(t.width,t.height),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(o=>Te({x:o}))}))}emitScrollPositionChanged(t){this.dispatchEvent(new rO(t))}emitLayoutChanged(){this.dispatchEvent(new Yy([...this._layout]))}shiftWindow(t){this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(t)}applyHorizontalWheel(t){this.syncScrollModel();const r=this.layoutGrid;if(!r)return;this.animateNextRender=!1;const i=r.toUnits(ke({x:t}));this.layoutScroll.wheel(Te({x:i.x??0}))}findManagedArtifactFrame(t){if(!t)return null;const r=this.querySelectorAll("iframe.artifact-frame");for(const i of r)if(i.contentWindow===t)return i;return null}isTrustedArtifactFrameMessage(t,r){if(t.origin==="null")return!0;const i=this.getArtifactFrameOrigin(r);return i===null||t.origin===i}getArtifactFrameTargetOrigin(t){const r=t.getAttribute("sandbox")??"";return new Set(r.split(/\s+/).filter(Boolean)).has("allow-same-origin")?this.getArtifactFrameOrigin(t)??"*":"*"}getArtifactFrameOrigin(t){const r=t.getAttribute("src")??t.src;if(!r)return null;try{return new URL(r,window.location.href).origin}catch{return null}}releaseActiveDragPointerCapture(){this.activeDragPointerId!==null&&this.releasePointerCaptureForEvent(this.activeDragPointerId)}releasePointerCaptureForEvent(t){try{this.hasPointerCapture(t)&&this.releasePointerCapture(t)}catch{}}attachDragListeners(){this.dragListenersAttached||(window.addEventListener("pointermove",this.handleWindowPointerMove),window.addEventListener("pointerup",this.handleWindowPointerUp),window.addEventListener("pointercancel",this.handleWindowPointerCancel),this.addEventListener("pointermove",this.handleWindowPointerMove),this.addEventListener("pointerup",this.handleWindowPointerUp),this.addEventListener("pointercancel",this.handleWindowPointerCancel),window.addEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!0)}detachDragListeners(){this.dragListenersAttached&&(window.removeEventListener("pointermove",this.handleWindowPointerMove),window.removeEventListener("pointerup",this.handleWindowPointerUp),window.removeEventListener("pointercancel",this.handleWindowPointerCancel),this.removeEventListener("pointermove",this.handleWindowPointerMove),this.removeEventListener("pointerup",this.handleWindowPointerUp),this.removeEventListener("pointercancel",this.handleWindowPointerCancel),window.removeEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!1,this.activeDragPointerId=null)}getDisplayModel(){if(this.dragController.status!=="active"||!this.dragState)return{layout:this._layout,activePlaceholderId:null,placeholdersById:new Map};const t=new Map;return t.set(this.dragState.nodeId,{id:this.dragState.nodeId,sourceCardId:this.dragState.nodeId}),{layout:Lf(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:t}}render(){const t=Zl(this),r=this.createGrid(t.width,t.height);this.layoutGrid=r;const i=this.getDisplayModel(),s=i.layout,o=this.dragController.status==="active",a=Wi(s),c=a.nodes.map(M=>M.width),u=`${t.width}x${t.height}:${c.join(",")}`;!o&&u!==this.scrollModelKey&&(this.scrollModelKey=u,this.layoutScroll.rebuild({grid:r,nodeWidths:c.map(M=>Te({x:M}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const d=sO(s),f=r.unit.x??Pn,v=r.unit.y??Pn,y=o?this.dragTrackOffsetXPx:0,A=(this.layoutScroll.translate.x??0)+y,k=Hf(a.nodes.length,r,t.height),I=this.animateNextRender&&!o,B=[`transform: translate(${A}px, ${k}px);`,`transition-duration: ${I?E0:0}ms;`,`pointer-events: ${o?"none":"auto"};`].join(" ");this.animateNextRender=!0,this.style.setProperty("--layout-unit-x",`${f}px`),this.style.setProperty("--layout-unit-y",`${v}px`),this.style.setProperty("--layout-gap",`${pe}px`);const P=this.dragState,le={width:(P==null?void 0:P.size.x)??0,height:(P==null?void 0:P.size.y)??0};Pe(F`
157
+ <div class="track" style=${B}>
158
+ ${a.nodes.map((M,Z)=>F`
159
+ <div
160
+ class="node"
161
+ layout-node=${String(Z)}
162
+ data-layout-node-id=${M.id}
163
+ data-layout-placeholder=${String(i.activePlaceholderId===M.id)}
164
+ layout-node-cols=${String(M.width)}
165
+ style=${`grid-template-columns: repeat(${M.width}, var(--layout-unit-x)); width: ${r.toPixels(Te({x:M.width})).x}px;`}
166
+ >
167
+ ${M.cards.map(U=>{const ge=i.placeholdersById.get(U.id);if(P&&ge)return F`
168
+ <div
169
+ class="card-slot card-placeholder"
170
+ data-layout-placeholder-for=${P.nodeId}
171
+ data-layout-placeholder-ghost="false"
172
+ data-layout-source-stack=${P.source.parentId??""}
173
+ style=${`grid-column: ${U.col} / span ${U.width}; grid-row: ${U.row} / span ${U.height};`}
174
+ ></div>
175
+ `;const ce=d.get(U.id);return ce?F`
176
+ <div
177
+ class="card-slot"
178
+ data-layout-card-id=${U.artifactID}
179
+ data-layout-node-id=${U.id}
180
+ layout-cols=${String(U.width)}
181
+ layout-rows=${String(U.height)}
182
+ style=${`grid-column: ${U.col} / span ${U.width}; grid-row: ${U.row} / span ${U.height};`}
183
+ >
184
+ ${this.renderContent(ce,{isDragging:!1})}
185
+ </div>
186
+ `:null})}
187
+ </div>
188
+ `)}
189
+ </div>
190
+ ${P?(()=>{const M=this.getPlaceholderPixelSize(a,i.activePlaceholderId,r,le),Z=P.pointer.x??0,U=P.pointer.y??0,ge=P.grabOffset.x??0,ce=P.grabOffset.y??0;return F`
191
+ <div
192
+ class="drag-preview"
193
+ data-layout-preview-card-id=${P.nodeId}
194
+ style=${[`width: ${M.width}px;`,`height: ${M.height}px;`,`left: ${Z-ge}px;`,`top: ${U-ce}px;`].join(" ")}
195
+ >
196
+ ${this.renderDraggedPreview(P.nodeId)}
197
+ </div>
198
+ `})():null}
199
+ `,this)}ensureDragFrameLoop(){this.dragFrame!==0||this.dragController.status==="idle"||(this.lastDragFrameTime=performance.now(),this.dragFrame=requestAnimationFrame(this.runDragFrame))}stopDragFrameLoop(){this.dragFrame!==0&&(cancelAnimationFrame(this.dragFrame),this.dragFrame=0,this.scrollVelocityPxPerSec=0)}syncDragTargetForLatestPointer(){if(this.dragController.status==="idle")return;const t=this.getBoundingClientRect();if(this.dragController.status==="active"){const i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,t);this.syncDragTarget(i.x,i.y,t);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,t),this.dragController.status==="pending")return;const r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,t);(r.x!==this.lastPointerX||r.y!==this.lastPointerY)&&this.syncDragTarget(r.x,r.y,t)}syncDragTarget(t,r,i=this.getBoundingClientRect()){if(this.dragController.status==="idle")return;const s=this.getDisplayModel(),o=new Set(s.placeholdersById.keys()),a=this.dragController.status==="active"?this.dragTrackOffsetXPx:0,c=this.measureLayoutGeometry(s.layout,o,a);this.dragController.update({pointer:ke({x:t,y:r}),viewport:{left:i.left,top:i.top,width:i.width,height:i.height},geometry:c,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(t,r){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=t,this.motionSampleY=r}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(t,r){this.samplePointerVelocityAt(performance.now(),t,r)}samplePointerVelocityAt(t,r,i){if(this.motionSampleTime===0){this.motionSampleTime=t,this.motionSampleX=r,this.motionSampleY=i,this.pointerVelocityPxPerSec=0;return}const s=t-this.motionSampleTime;if(s<100)return;const o=r-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/s*Zf,this.motionSampleTime=t,this.motionSampleX=r,this.motionSampleY=i}clampPointerToViewport(t,r,i){return{x:Math.max(i.left,Math.min(i.left+i.width,t)),y:Math.max(i.top,Math.min(i.top+i.height,r))}}isPointerOutsideViewport(t,r,i){return t<i.left||t>i.left+i.width||r<i.top||r>i.top+i.height}getDragEdgeScrollDeltaPixels(t,r,i){var u;const s=r.left+vo,o=r.left+r.width-vo,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??Pn,c=A0*a;if(t<s){const d=Math.max(0,Math.min(1,(s-t)/vo));return-(c*d**Jd)*i}if(t>o){const d=Math.max(0,Math.min(1,(t-o)/vo));return c*d**Jd*i}return 0}measureLayoutGeometry(t,r,i=0){const s=this.layoutGrid;if(!s)return[];const o=Wi(t),a=new Map(o.nodes.map(k=>[k.id,k.width])),c=s.toPixels(Te({y:Xe})).y??Xo,u=Zl(this),d=(this.layoutScroll.translate.x??0)+i,f=Hf(o.nodes.length,s,u.height),v=u.offsetY+f,y=[];let A=d;for(const k of t){const I=a.get(k.id)??Ct,B=s.toPixels(Te({x:I})).x??tr,P={left:A,top:v,width:B,height:c};y.push({id:k.id,rect:P}),A+=B+pe}return y}getPlaceholderPixelSize(t,r,i,s){if(!r)return s;for(const o of t.nodes)for(const a of o.cards)if(a.id===r)return{width:i.toPixels(Te({x:a.width})).x??s.width,height:i.toPixels(Te({y:a.height})).y??s.height};return s}renderDraggedPreview(t){const r=Hu(this._layout,t);return r?this.renderContent(r,{isDragging:!0}):F``}shouldApplyTrackOffset(t,r){if(r)return!0;for(const i of t){if(i.type!=="stack")continue;if(i.children.some(o=>o.type==="drop-target")&&r!==i.id)return!0}return!1}computeDragTrackOffset(t,r,i,s,o,a){if(!t)return a;const c=s?o??this.getStableAnchorCardId(t,r,i):this.getStableAnchorNodeId(t,r,i);if(!c)return a;const u=s?jf(t,c,this.layoutGrid):Bf(t,c,this.layoutGrid),d=s?jf(r,c,this.layoutGrid):Bf(r,c,this.layoutGrid);return u===null||d===null?a:a+(u-d)}getStableAnchorCardId(t,r,i){const s=Vf(t),o=new Set(Vf(r));for(const a of s)if(a!==i&&o.has(a))return a;return null}getStableAnchorNodeId(t,r,i){const s=new Set(r.map(o=>o.id));for(const o of t)if(o.id!==i&&s.has(o.id))return o.id;return null}getStackChildAnchorCardId(t,r){const i=this._layout.find(o=>o.type==="stack"&&o.id===t);if(!i||i.type!=="stack")return null;const s=i.children.find(o=>o.type==="card"&&o.id!==r);return(s==null?void 0:s.id)??null}}function sO(n){const e=new Map;for(const t of n){if(t.type==="card"){e.set(t.id,t);continue}for(const r of t.children)if(r.type==="card")e.set(r.id,r);else for(const i of r.children)e.set(i.id,i)}return e}function oO(n,e){const t=n.findIndex(r=>r.type==="card"&&r.id===e);if(t!==-1)return{topLevelIndex:t};for(let r=0;r<n.length;r+=1){const i=n[r];if(!(!i||i.type!=="stack")&&i.children.some(s=>s.type==="card"&&s.id===e))return{topLevelIndex:r,sourceStackId:i.id}}return null}function Vf(n){const e=[];for(const t of n){if(t.type==="card"){e.push(t.id);continue}if(t.type==="stack"){const r=t.children.find(i=>i.type==="card");r&&e.push(r.id)}}return e}function jf(n,e,t){if(!t)return null;const r=Wi(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.type==="card"&&o.id===e||o.type==="stack"&&o.children.some(u=>u.type==="card"&&u.id===e))return s;const a=i.get(o.id)??Ct,c=t.toPixels(Te({x:a})).x??tr;s+=c+pe}return null}function Bf(n,e,t){if(!t)return null;const r=Wi(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.id===e)return s;const a=i.get(o.id)??Ct,c=t.toPixels(Te({x:a})).x??tr;s+=c+pe}return null}customElements.get("layout-view")||customElements.define("layout-view",iO);class aO extends HTMLElement{constructor(){super(...arguments);b(this,"screenManager",Ge.resolve("ScreenManager"));b(this,"boundModel",null);b(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});b(this,"handleModelChange",()=>{this.render()});b(this,"handleCloseArtifact",t=>{t instanceof Vy&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(t.artifactID)});b(this,"handleScrollPositionChanged",t=>{const r=t;typeof r.scrollPosition=="number"&&Number.isFinite(r.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(r.scrollPosition)});b(this,"handleLayoutChanged",t=>{t instanceof Yy&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(t.layout)})}connectedCallback(){this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.rebindModel(),this.render()}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged),this.unbindModel()}rebindModel(){const t=this.screenManager.activeScreen;this.boundModel!==t&&(this.unbindModel(),this.boundModel=t,t&&t.addEventListener("change",this.handleModelChange))}unbindModel(){this.boundModel&&(this.boundModel.removeEventListener("change",this.handleModelChange),this.boundModel=null)}buildArtifactMap(){const t=this.screenManager.activeScreen;return t?new Map(t.artifacts):new Map}render(){const t=this.screenManager.activeScreen,r=(t==null?void 0:t.layout)??[],i=this.buildArtifactMap();if(r.length===0){Pe(F`<p data-testid="empty-screen" class="empty">
200
+ No artifacts yet. Create one by asking for something.
201
+ </p>`,this);return}Pe(F`
202
+ <layout-view
203
+ .layout=${r}
204
+ .renderContent=${(o,a)=>{const c=i.get(o.artifactID);return!c||!t?F``:F`<artifact-view
205
+ .artifact=${c}
206
+ .screen=${t}
207
+ .viewURL=${t.server.getViewURL(c)}
208
+ .contentURL=${t.server.getContentURL(c.id)}
209
+ .dragging=${a.isDragging}
210
+ ></artifact-view>`}}
211
+ .scrollPosition=${(t==null?void 0:t.scrollPosition)??0}
212
+ @scroll=${this.handleScrollPositionChanged}
213
+ @layout-change=${this.handleLayoutChanged}
214
+ @close-artifact=${this.handleCloseArtifact}
215
+ ></layout-view>
216
+ `,this)}}customElements.define("screen-view",aO);var ma,jr,Cs,Wt,Ky,Jy,Nc;class lO extends HTMLElement{constructor(){super(...arguments);_(this,Wt);_(this,ma,Ge.resolve("ScreenManager"));_(this,jr,Ge.resolve("ServerManager"));_(this,Cs,()=>{m(this,Wt,Nc).call(this)})}connectedCallback(){l(this,jr).addEventListener("change",l(this,Cs)),m(this,Wt,Nc).call(this)}disconnectedCallback(){l(this,jr).removeEventListener("change",l(this,Cs))}}ma=new WeakMap,jr=new WeakMap,Cs=new WeakMap,Wt=new WeakSet,Ky=function(t,r){l(this,ma).setActive(t,r)},Jy=function(){for(const t of l(this,jr).servers.values())return t;return null},Nc=function(){const t=m(this,Wt,Jy).call(this),i=(t?[...t.screens.values()]:[]).slice().sort((o,a)=>o.name.localeCompare(a.name,void 0,{sensitivity:"base"})),s=i.length===0?F`<p class="empty">No screens yet. Hit + to create one.</p>`:F`
217
+ <div class="content">
218
+ <h2 class="heading">Screens</h2>
219
+ <ul class="tiles">
220
+ ${i.map(o=>F`
221
+ <li>
222
+ <button
223
+ class="tile"
224
+ type="button"
225
+ @click=${()=>t&&m(this,Wt,Ky).call(this,t.url,o.id)}
226
+ >
227
+ ${o.name}
228
+ </button>
229
+ </li>
230
+ `)}
231
+ </ul>
232
+ </div>
233
+ `;Pe(s,this)};customElements.get("home-screen")||customElements.define("home-screen",lO);const Hl=new WeakMap,Gf=Object.prototype.hasOwnProperty,cO=(()=>{const n=new Set;let e=HTMLElement.prototype;for(;e;){for(const t of Object.getOwnPropertyNames(e))n.add(t);if(e===Node.prototype)break;e=Object.getPrototypeOf(e)}return n})();function uO(n,e){if(n===Boolean)return e!==null;if(e!==null)return n===Number?Number(e):e}var Is,Uc,Yn,tt,xt,Br,Kn,Gr,Ie,Zi,Xy,Qy,ev,Vo;const On=class On extends HTMLElement{constructor(){var i;super();_(this,Ie);_(this,Yn,new Map);_(this,tt,new Map);_(this,xt,new Map);_(this,Br,!1);_(this,Kn,!1);_(this,Gr,!1);const t=m(i=On,Is,Uc).call(i,this.constructor),r=this;for(const s of t.properties)Gf.call(r,s)&&(l(this,xt).set(s,r[s]),delete r[s])}static get observedAttributes(){var t;return m(t=On,Is,Uc).call(t,this).observedAttributes}connected(){}disconnected(){}changed(t){}connectedCallback(){if(m(this,Ie,ev).call(this),!l(this,Kn))for(const t of m(this,Ie,Zi).call(this).properties)l(this,tt).has(t)||l(this,tt).set(t,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),m(this,Ie,Vo).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(t,r,i){if(r===i)return;const s=m(this,Ie,Zi).call(this).byAttr.get(t);s&&(l(this,xt).has(s.property)||(this[s.property]=uO(s.type,i)))}};Is=new WeakSet,Uc=function(t){const r=Hl.get(t);if(r)return r;const i=[...t.properties??[]],s=t.attributes??{},o=new Map,a=new Map;for(const u of i)if(cO.has(u))throw new Error(`Reactive property "${u}" collides with a built-in DOM property. Rename it to avoid shadowing the platform API.`);for(const[u,d]of Object.entries(s)){if(u.includes("-")&&d.property===void 0)throw new Error(`Attribute "${u}" must declare a "property" name because kebab-case cannot be a property.`);const f=d.property??u;if(!i.includes(f))throw new Error(`Attribute '${u}' references property '${f}', which isn't declared in \`static properties\`. Add it to \`properties\` to make it reactive.`);const v={attribute:u,property:f,type:d.type};o.set(u,v),a.set(f,v)}for(const u of i){const d=Object.getOwnPropertyDescriptor(t.prototype,u);if((d==null?void 0:d.get)!==void 0||(d==null?void 0:d.set)!==void 0)throw new Error(`Observed property "${u}" cannot define a custom getter/setter. Use changed() for side effects instead.`);d===void 0&&Object.defineProperty(t.prototype,u,{configurable:!0,enumerable:!0,get(){return l(this,Yn).get(u)},set(f){m(this,Ie,Xy).call(this,u,f)}})}const c={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return Hl.set(t,c),c},Yn=new WeakMap,tt=new WeakMap,xt=new WeakMap,Br=new WeakMap,Kn=new WeakMap,Gr=new WeakMap,Ie=new WeakSet,Zi=function(){return Hl.get(this.constructor)},Xy=function(t,r){if(!l(this,Gr)&&l(this,xt).has(t))return;const i=l(this,Yn).get(t);Object.is(i,r)||(l(this,tt).has(t)||l(this,tt).set(t,i),l(this,Yn).set(t,r),l(this,xt).delete(t),m(this,Ie,Qy).call(this,t,r),this.isConnected&&m(this,Ie,Vo).call(this))},Qy=function(t,r){const i=m(this,Ie,Zi).call(this).byProp.get(t);if(!i)return;const{attribute:s,type:o}=i;if(o===Boolean){const c=this.hasAttribute(s);r&&!c?this.setAttribute(s,""):!r&&c&&this.removeAttribute(s);return}if(r==null){this.hasAttribute(s)&&this.removeAttribute(s);return}const a=String(r);this.getAttribute(s)!==a&&this.setAttribute(s,a)},ev=function(){const t=this,r=m(this,Ie,Zi).call(this);for(const i of r.properties){if(!Gf.call(t,i))continue;const s=t[i];delete t[i],!(l(this,xt).has(i)||l(this,Yn).has(i))&&(t[i]=s)}E(this,Gr,!0);try{for(const[i,s]of l(this,xt))t[i]=s;l(this,xt).clear()}finally{E(this,Gr,!1)}},Vo=function(){l(this,Br)||!this.isConnected||l(this,Kn)&&l(this,tt).size===0||(E(this,Br,!0),queueMicrotask(()=>{if(E(this,Br,!1),!this.isConnected||l(this,Kn)&&l(this,tt).size===0)return;const t=new Map(l(this,tt));l(this,tt).clear(),E(this,Kn,!0);try{this.changed(t)}catch(r){console.error(r)}this.isConnected&&l(this,tt).size>0&&m(this,Ie,Vo).call(this)}))},_(On,Is),b(On,"properties"),b(On,"attributes");let ts=On;/**
234
+ * @license
235
+ * Copyright 2020 Google LLC
236
+ * SPDX-License-Identifier: BSD-3-Clause
237
+ */const hO=n=>n.strings===void 0;/**
238
+ * @license
239
+ * Copyright 2017 Google LLC
240
+ * SPDX-License-Identifier: BSD-3-Clause
241
+ */const Yi=(n,e)=>{var r;const t=n._$AN;if(t===void 0)return!1;for(const i of t)(r=i._$AO)==null||r.call(i,e,!1),Yi(i,e);return!0},oa=n=>{let e,t;do{if((e=n._$AM)===void 0)break;t=e._$AN,t.delete(n),n=e}while((t==null?void 0:t.size)===0)},tv=n=>{for(let e;e=n._$AM;n=e){let t=e._$AN;if(t===void 0)e._$AN=t=new Set;else if(t.has(n))break;t.add(n),pO(e)}};function dO(n){this._$AN!==void 0?(oa(this),this._$AM=n,tv(this)):this._$AM=n}function fO(n,e=!1,t=0){const r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(e)if(Array.isArray(r))for(let s=t;s<r.length;s++)Yi(r[s],!1),oa(r[s]);else r!=null&&(Yi(r,!1),oa(r));else Yi(this,n)}const pO=n=>{n.type==vy.CHILD&&(n._$AP??(n._$AP=fO),n._$AQ??(n._$AQ=dO))};class gO extends by{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,r){super._$AT(e,t,r),tv(this),this.isConnected=e._$AU}_$AO(e,t=!0){var r,i;e!==this.isConnected&&(this.isConnected=e,e?(r=this.reconnected)==null||r.call(this):(i=this.disconnected)==null||i.call(this)),t&&(Yi(this,e),oa(this))}setValue(e){if(hO(this._$Ct))this._$Ct._$AI(e,this);else{const t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}}/**
242
+ * @license
243
+ * Copyright 2020 Google LLC
244
+ * SPDX-License-Identifier: BSD-3-Clause
245
+ */const $o=()=>new mO;class mO{}const Vl=new WeakMap,Ao=Fu(class extends gO{render(n){return oe}update(n,[e]){var r;const t=e!==this.G;return t&&this.G!==void 0&&this.rt(void 0),(t||this.lt!==this.ct)&&(this.G=e,this.ht=(r=n.options)==null?void 0:r.host,this.rt(this.ct=n.element)),oe}rt(n){if(this.isConnected||(n=void 0),typeof this.G=="function"){const e=this.ht??globalThis;let t=Vl.get(e);t===void 0&&(t=new WeakMap,Vl.set(e,t)),t.get(this.G)!==void 0&&this.G.call(this.ht,void 0),t.set(this.G,n),n!==void 0&&this.G.call(this.ht,n)}else this.G.value=n}get lt(){var n,e;return typeof this.G=="function"?(n=Vl.get(this.ht??globalThis))==null?void 0:n.get(this.G):(e=this.G)==null?void 0:e.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Je,un,Wr,qr,Ps,Jn,Xn,re,Rs,Ds,Me,Fc,Zc,ya,va,ba,wa,_a,Sa,ka,Os,zs,Hi,nv,ht;class yO extends ts{constructor(){super(...arguments);_(this,Me);_(this,Je,Ge.resolve("ScreenManager"));_(this,un,null);_(this,Wr,new DisposableStack);_(this,qr,$o());_(this,Ps,$o());_(this,Jn,$o());_(this,Xn,$o());_(this,re,{kind:"none"});_(this,Rs,()=>{m(this,Me,Fc).call(this),l(this,ht).call(this)});_(this,Ds,()=>{l(this,ht).call(this)});_(this,ya,()=>{l(this,Je).clearActive()});_(this,va,t=>{l(this,re).kind!=="none"&&(t.stopImmediatePropagation(),m(this,Me,Hi).call(this))});_(this,ba,()=>{var r;const t=l(this,Je).activeScreen;t&&((r=l(this,qr).value)==null||r.close(),E(this,re,{kind:"rename",draft:t.name}),l(this,ht).call(this))});_(this,wa,()=>{var t;l(this,Je).activeScreen&&((t=l(this,qr).value)==null||t.close(),E(this,re,{kind:"delete",error:null}),l(this,ht).call(this))});_(this,_a,t=>{if(l(this,re).kind!=="rename")return;const r=t.target;r instanceof HTMLInputElement&&E(this,re,{kind:"rename",draft:r.value})});_(this,Sa,t=>{if(t.preventDefault(),l(this,re).kind!=="rename")return;const r=l(this,Je).activeScreen;if(!r)return;const i=l(this,re).draft.trim();i.length>0&&i!==r.name&&r.rename(i),m(this,Me,Hi).call(this)});_(this,ka,async()=>{if(l(this,re).kind!=="delete")return;const t=l(this,Je).activeScreen;if(t){E(this,re,{kind:"delete",error:null});try{await t.remove(),l(this,Je).clearActive(),m(this,Me,Hi).call(this)}catch(r){E(this,re,{kind:"delete",error:r instanceof Error?r.message:"Failed to delete screen."}),l(this,ht).call(this)}}});_(this,Os,()=>{m(this,Me,Hi).call(this)});_(this,zs,()=>{l(this,re).kind!=="none"&&(E(this,re,{kind:"none"}),l(this,ht).call(this))});_(this,ht,()=>{const t=F`
246
+ <button
247
+ icon-only
248
+ class="home"
249
+ type="button"
250
+ aria-label="Home"
251
+ @click=${l(this,ya)}
252
+ >
253
+ ${JR({weight:"fill"})}
254
+ </button>
255
+ `;Pe(F`${t}${m(this,Me,nv).call(this)}`,this);const r=l(this,Ps).value??null;l(this,Jn).value&&(l(this,Jn).value.anchor=r),l(this,Xn).value&&(l(this,Xn).value.anchor=r)})}connected(){l(this,Je).addEventListener("active-screen-changed",l(this,Rs)),m(this,Me,Fc).call(this),l(this,ht).call(this),l(this,Wr).defer(()=>{l(this,Je).removeEventListener("active-screen-changed",l(this,Rs)),m(this,Me,Zc).call(this)})}disconnected(){l(this,Wr).dispose(),E(this,Wr,new DisposableStack)}}Je=new WeakMap,un=new WeakMap,Wr=new WeakMap,qr=new WeakMap,Ps=new WeakMap,Jn=new WeakMap,Xn=new WeakMap,re=new WeakMap,Rs=new WeakMap,Ds=new WeakMap,Me=new WeakSet,Fc=function(){var r;const t=l(this,Je).activeScreen;l(this,un)!==t&&(m(this,Me,Zc).call(this),E(this,un,t),(r=l(this,un))==null||r.addEventListener("change",l(this,Ds)))},Zc=function(){var t;(t=l(this,un))==null||t.removeEventListener("change",l(this,Ds)),E(this,un,null)},ya=new WeakMap,va=new WeakMap,ba=new WeakMap,wa=new WeakMap,_a=new WeakMap,Sa=new WeakMap,ka=new WeakMap,Os=new WeakMap,zs=new WeakMap,Hi=function(){const t=l(this,re).kind==="rename"?l(this,Jn).value:l(this,re).kind==="delete"?l(this,Xn).value:null;t&&(t.open=!1),E(this,re,{kind:"none"}),l(this,ht).call(this)},nv=function(){const t=l(this,Je).activeScreen;if(!t)return null;const r=l(this,re).kind==="rename"?l(this,re).draft:"",i=l(this,re).kind==="delete"?l(this,re).error:null;return F`
256
+ <span class="separator" aria-hidden="true">
257
+ ${qR()}
258
+ </span>
259
+ <dropdown-menu ${Ao(l(this,qr))}>
260
+ <button
261
+ slot="trigger"
262
+ type="button"
263
+ variant="ghost"
264
+ aria-label=${`Screen actions for ${t.name}`}
265
+ ?data-active=${l(this,re).kind!=="none"}
266
+ @click=${l(this,va)}
267
+ ${Ao(l(this,Ps))}
268
+ >
269
+ ${t.name}
270
+ </button>
271
+ <dropdown-group>
272
+ <dropdown-item action @click=${l(this,ba)}>
273
+ ${XR()} Rename
274
+ </dropdown-item>
275
+ <dropdown-item action danger @click=${l(this,wa)}>
276
+ ${QR()} Delete
277
+ </dropdown-item>
278
+ </dropdown-group>
279
+ </dropdown-menu>
280
+ <ui-popover
281
+ class="rename-popover"
282
+ ?open=${l(this,re).kind==="rename"}
283
+ @close=${l(this,zs)}
284
+ ${Ao(l(this,Jn))}
285
+ >
286
+ <form class="screen-form" @submit=${l(this,Sa)}>
287
+ <label class="field">
288
+ <span>Screen name</span>
289
+ <input
290
+ type="text"
291
+ .value=${r}
292
+ @input=${l(this,_a)}
293
+ />
294
+ </label>
295
+ <div class="actions">
296
+ <button type="button" @click=${l(this,Os)}>Cancel</button>
297
+ <button type="submit" variant="primary">Save</button>
298
+ </div>
299
+ </form>
300
+ </ui-popover>
301
+ <ui-popover
302
+ class="delete-popover"
303
+ ?open=${l(this,re).kind==="delete"}
304
+ @close=${l(this,zs)}
305
+ ${Ao(l(this,Xn))}
306
+ >
307
+ <div class="screen-form">
308
+ <p class="confirm-text">Delete "${t.name}"?</p>
309
+ ${i?F`<p class="error">${i}</p>`:oe}
310
+ <div class="actions">
311
+ <button type="button" @click=${l(this,Os)}>Cancel</button>
312
+ <button
313
+ type="button"
314
+ variant="danger"
315
+ @click=${l(this,ka)}
316
+ >
317
+ Delete
318
+ </button>
319
+ </div>
320
+ </div>
321
+ </ui-popover>
322
+ `},ht=new WeakMap;customElements.define("screen-breadcrumb",yO);var Ea,$a,Yr,ri,rv,Aa,iv;class vO extends HTMLElement{constructor(){super(...arguments);_(this,ri);_(this,Ea,Ge.resolve("ServerManager"));_(this,$a,Ge.resolve("ScreenManager"));_(this,Yr,!1);_(this,Aa,async()=>{if(l(this,Yr))return;const t=m(this,ri,rv).call(this);if(t){E(this,Yr,!0);try{const r=await t.createScreen(bO(new Date));l(this,$a).setActive(t.url,r.id)}catch{}finally{E(this,Yr,!1)}}})}connectedCallback(){m(this,ri,iv).call(this)}}Ea=new WeakMap,$a=new WeakMap,Yr=new WeakMap,ri=new WeakSet,rv=function(){for(const t of l(this,Ea).servers.values())return t;return null},Aa=new WeakMap,iv=function(){Pe(F`
323
+ <button
324
+ icon-only
325
+ class="new-screen"
326
+ type="button"
327
+ aria-label="New screen"
328
+ @click=${l(this,Aa)}
329
+ >
330
+ ${KR({size:16,weight:"bold"})}
331
+ </button>
332
+ `,this)};function bO(n){const e=n.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),t=12,r=n.getHours(),i=r%t===0?t:r%t,s=n.getMinutes().toString().padStart(2,"0"),o=r>=t?"pm":"am";return`${e} at ${i}:${s}${o}`}customElements.define("screen-create-button",vO);function wO(n,e){let t=null;const r=()=>e((t==null?void 0:t.messages)??[]),i=()=>{const o=n.getActiveClient();o!==t&&(t==null||t.removeEventListener("change",r),t=o,t&&(t.addEventListener("change",r),t.connect().catch(a=>{console.error("ACPClient.connect() failed",a)})),r())};n.addEventListener("change",i),i();const s=()=>{n.removeEventListener("change",i),t==null||t.removeEventListener("change",r),t=null};return{dispose:s,[Symbol.dispose](){s()}}}/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */const{entries:sv,setPrototypeOf:Wf,isFrozen:_O,getPrototypeOf:SO,getOwnPropertyDescriptor:kO}=Object;let{freeze:Ne,seal:it,create:jo}=Object,{apply:Hc,construct:Vc}=typeof Reflect<"u"&&Reflect;Ne||(Ne=function(e){return e});it||(it=function(e){return e});Hc||(Hc=function(e,t){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];return e.apply(t,i)});Vc||(Vc=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return new e(...r)});const xo=Ue(Array.prototype.forEach),EO=Ue(Array.prototype.lastIndexOf),qf=Ue(Array.prototype.pop),xi=Ue(Array.prototype.push),$O=Ue(Array.prototype.splice),Bo=Ue(String.prototype.toLowerCase),jl=Ue(String.prototype.toString),Bl=Ue(String.prototype.match),Ti=Ue(String.prototype.replace),AO=Ue(String.prototype.indexOf),xO=Ue(String.prototype.trim),Ye=Ue(Object.prototype.hasOwnProperty),De=Ue(RegExp.prototype.test),Ci=TO(TypeError);function Ue(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return Hc(n,e,r)}}function TO(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Vc(n,t)}}function V(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Bo;Wf&&Wf(n,null);let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){const s=t(i);s!==i&&(_O(e)||(e[r]=s),i=s)}n[i]=!0}return n}function CO(n){for(let e=0;e<n.length;e++)Ye(n,e)||(n[e]=null);return n}function _t(n){const e=jo(null);for(const[t,r]of sv(n))Ye(n,t)&&(Array.isArray(r)?e[t]=CO(r):r&&typeof r=="object"&&r.constructor===Object?e[t]=_t(r):e[t]=r);return e}function Ii(n,e){for(;n!==null;){const r=kO(n,e);if(r){if(r.get)return Ue(r.get);if(typeof r.value=="function")return Ue(r.value)}n=SO(n)}function t(){return null}return t}const Yf=Ne(["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"]),Gl=Ne(["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"]),Wl=Ne(["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"]),IO=Ne(["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"]),ql=Ne(["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"]),PO=Ne(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Kf=Ne(["#text"]),Jf=Ne(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","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","slot"]),Yl=Ne(["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","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","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-rendering","textlength","type","u1","u2","unicode","values","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"]),Xf=Ne(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","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"]),To=Ne(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),RO=it(/\{\{[\w\W]*|[\w\W]*\}\}/gm),DO=it(/<%[\w\W]*|[\w\W]*%>/gm),OO=it(/\$\{[\w\W]*/gm),zO=it(/^data-[\-\w.\u00B7-\uFFFF]+$/),LO=it(/^aria-[\-\w]+$/),ov=it(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),MO=it(/^(?:\w+script|data):/i),NO=it(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),av=it(/^html$/i),UO=it(/^[a-z][.\w]*(-[.\w]+)+$/i);var Qf=Object.freeze({__proto__:null,ARIA_ATTR:LO,ATTR_WHITESPACE:NO,CUSTOM_ELEMENT:UO,DATA_ATTR:zO,DOCTYPE_NAME:av,ERB_EXPR:DO,IS_ALLOWED_URI:ov,IS_SCRIPT_OR_DATA:MO,MUSTACHE_EXPR:RO,TMPLIT_EXPR:OO});const Pi={element:1,text:3,progressingInstruction:7,comment:8,document:9},FO=function(){return typeof window>"u"?null:window},ZO=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(r=t.getAttribute(i));const s="dompurify"+(r?"#"+r:"");try{return e.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},ep=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function lv(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:FO();const e=L=>lv(L);if(e.version="3.3.3",e.removed=[],!n||!n.document||n.document.nodeType!==Pi.document||!n.Element)return e.isSupported=!1,e;let{document:t}=n;const r=t,i=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:c,NodeFilter:u,NamedNodeMap:d=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:f,DOMParser:v,trustedTypes:y}=n,A=c.prototype,k=Ii(A,"cloneNode"),I=Ii(A,"remove"),B=Ii(A,"nextSibling"),P=Ii(A,"childNodes"),le=Ii(A,"parentNode");if(typeof o=="function"){const L=t.createElement("template");L.content&&L.content.ownerDocument&&(t=L.content.ownerDocument)}let M,Z="";const{implementation:U,createNodeIterator:ge,createDocumentFragment:ce,getElementsByTagName:yi}=t,{importNode:to}=r;let $e=ep();e.isSupported=typeof sv=="function"&&typeof le=="function"&&U&&U.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:kn,ERB_EXPR:mt,TMPLIT_EXPR:Xt,DATA_ATTR:qa,ARIA_ATTR:no,IS_SCRIPT_OR_DATA:$v,ATTR_WHITESPACE:eh,CUSTOM_ELEMENT:Av}=Qf;let{IS_ALLOWED_URI:th}=Qf,_e=null;const nh=V({},[...Yf,...Gl,...Wl,...ql,...Kf]);let Ae=null;const rh=V({},[...Jf,...Yl,...Xf,...To]);let me=Object.seal(jo(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}})),vi=null,ro=null;const Qt=Object.seal(jo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ih=!0,Ya=!0,sh=!1,oh=!0,hr=!1,io=!0,En=!1,Ka=!1,Ja=!1,dr=!1,so=!1,oo=!1,ah=!0,lh=!1;const xv="user-content-";let Xa=!0,bi=!1,fr={},yt=null;const Qa=V({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ch=null;const uh=V({},["audio","video","img","source","image","track"]);let el=null;const hh=V({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ao="http://www.w3.org/1998/Math/MathML",lo="http://www.w3.org/2000/svg",It="http://www.w3.org/1999/xhtml";let pr=It,tl=!1,nl=null;const Tv=V({},[ao,lo,It],jl);let co=V({},["mi","mo","mn","ms","mtext"]),uo=V({},["annotation-xml"]);const Cv=V({},["title","style","font","a","script"]);let wi=null;const Iv=["application/xhtml+xml","text/html"],Pv="text/html";let be=null,gr=null;const Rv=t.createElement("form"),dh=function(g){return g instanceof RegExp||g instanceof Function},rl=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(gr&&gr===g)){if((!g||typeof g!="object")&&(g={}),g=_t(g),wi=Iv.indexOf(g.PARSER_MEDIA_TYPE)===-1?Pv:g.PARSER_MEDIA_TYPE,be=wi==="application/xhtml+xml"?jl:Bo,_e=Ye(g,"ALLOWED_TAGS")?V({},g.ALLOWED_TAGS,be):nh,Ae=Ye(g,"ALLOWED_ATTR")?V({},g.ALLOWED_ATTR,be):rh,nl=Ye(g,"ALLOWED_NAMESPACES")?V({},g.ALLOWED_NAMESPACES,jl):Tv,el=Ye(g,"ADD_URI_SAFE_ATTR")?V(_t(hh),g.ADD_URI_SAFE_ATTR,be):hh,ch=Ye(g,"ADD_DATA_URI_TAGS")?V(_t(uh),g.ADD_DATA_URI_TAGS,be):uh,yt=Ye(g,"FORBID_CONTENTS")?V({},g.FORBID_CONTENTS,be):Qa,vi=Ye(g,"FORBID_TAGS")?V({},g.FORBID_TAGS,be):_t({}),ro=Ye(g,"FORBID_ATTR")?V({},g.FORBID_ATTR,be):_t({}),fr=Ye(g,"USE_PROFILES")?g.USE_PROFILES:!1,ih=g.ALLOW_ARIA_ATTR!==!1,Ya=g.ALLOW_DATA_ATTR!==!1,sh=g.ALLOW_UNKNOWN_PROTOCOLS||!1,oh=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,hr=g.SAFE_FOR_TEMPLATES||!1,io=g.SAFE_FOR_XML!==!1,En=g.WHOLE_DOCUMENT||!1,dr=g.RETURN_DOM||!1,so=g.RETURN_DOM_FRAGMENT||!1,oo=g.RETURN_TRUSTED_TYPE||!1,Ja=g.FORCE_BODY||!1,ah=g.SANITIZE_DOM!==!1,lh=g.SANITIZE_NAMED_PROPS||!1,Xa=g.KEEP_CONTENT!==!1,bi=g.IN_PLACE||!1,th=g.ALLOWED_URI_REGEXP||ov,pr=g.NAMESPACE||It,co=g.MATHML_TEXT_INTEGRATION_POINTS||co,uo=g.HTML_INTEGRATION_POINTS||uo,me=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&dh(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(me.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&dh(g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(me.attributeNameCheck=g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),g.CUSTOM_ELEMENT_HANDLING&&typeof g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(me.allowCustomizedBuiltInElements=g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),hr&&(Ya=!1),so&&(dr=!0),fr&&(_e=V({},Kf),Ae=jo(null),fr.html===!0&&(V(_e,Yf),V(Ae,Jf)),fr.svg===!0&&(V(_e,Gl),V(Ae,Yl),V(Ae,To)),fr.svgFilters===!0&&(V(_e,Wl),V(Ae,Yl),V(Ae,To)),fr.mathMl===!0&&(V(_e,ql),V(Ae,Xf),V(Ae,To))),Ye(g,"ADD_TAGS")||(Qt.tagCheck=null),Ye(g,"ADD_ATTR")||(Qt.attributeCheck=null),g.ADD_TAGS&&(typeof g.ADD_TAGS=="function"?Qt.tagCheck=g.ADD_TAGS:(_e===nh&&(_e=_t(_e)),V(_e,g.ADD_TAGS,be))),g.ADD_ATTR&&(typeof g.ADD_ATTR=="function"?Qt.attributeCheck=g.ADD_ATTR:(Ae===rh&&(Ae=_t(Ae)),V(Ae,g.ADD_ATTR,be))),g.ADD_URI_SAFE_ATTR&&V(el,g.ADD_URI_SAFE_ATTR,be),g.FORBID_CONTENTS&&(yt===Qa&&(yt=_t(yt)),V(yt,g.FORBID_CONTENTS,be)),g.ADD_FORBID_CONTENTS&&(yt===Qa&&(yt=_t(yt)),V(yt,g.ADD_FORBID_CONTENTS,be)),Xa&&(_e["#text"]=!0),En&&V(_e,["html","head","body"]),_e.table&&(V(_e,["tbody"]),delete vi.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ci('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ci('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');M=g.TRUSTED_TYPES_POLICY,Z=M.createHTML("")}else M===void 0&&(M=ZO(y,i)),M!==null&&typeof Z=="string"&&(Z=M.createHTML(""));Ne&&Ne(g),gr=g}},fh=V({},[...Gl,...Wl,...IO]),ph=V({},[...ql,...PO]),Dv=function(g){let T=le(g);(!T||!T.tagName)&&(T={namespaceURI:pr,tagName:"template"});const R=Bo(g.tagName),ie=Bo(T.tagName);return nl[g.namespaceURI]?g.namespaceURI===lo?T.namespaceURI===It?R==="svg":T.namespaceURI===ao?R==="svg"&&(ie==="annotation-xml"||co[ie]):!!fh[R]:g.namespaceURI===ao?T.namespaceURI===It?R==="math":T.namespaceURI===lo?R==="math"&&uo[ie]:!!ph[R]:g.namespaceURI===It?T.namespaceURI===lo&&!uo[ie]||T.namespaceURI===ao&&!co[ie]?!1:!ph[R]&&(Cv[R]||!fh[R]):!!(wi==="application/xhtml+xml"&&nl[g.namespaceURI]):!1},vt=function(g){xi(e.removed,{element:g});try{le(g).removeChild(g)}catch{I(g)}},$n=function(g,T){try{xi(e.removed,{attribute:T.getAttributeNode(g),from:T})}catch{xi(e.removed,{attribute:null,from:T})}if(T.removeAttribute(g),g==="is")if(dr||so)try{vt(T)}catch{}else try{T.setAttribute(g,"")}catch{}},gh=function(g){let T=null,R=null;if(Ja)g="<remove></remove>"+g;else{const ye=Bl(g,/^[\r\n\t ]+/);R=ye&&ye[0]}wi==="application/xhtml+xml"&&pr===It&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const ie=M?M.createHTML(g):g;if(pr===It)try{T=new v().parseFromString(ie,wi)}catch{}if(!T||!T.documentElement){T=U.createDocument(pr,"template",null);try{T.documentElement.innerHTML=tl?Z:ie}catch{}}const Re=T.body||T.documentElement;return g&&R&&Re.insertBefore(t.createTextNode(R),Re.childNodes[0]||null),pr===It?yi.call(T,En?"html":"body")[0]:En?T.documentElement:Re},mh=function(g){return ge.call(g.ownerDocument||g,g,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},il=function(g){return g instanceof f&&(typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||!(g.attributes instanceof d)||typeof g.removeAttribute!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function")},yh=function(g){return typeof a=="function"&&g instanceof a};function Pt(L,g,T){xo(L,R=>{R.call(e,g,T,gr)})}const vh=function(g){let T=null;if(Pt($e.beforeSanitizeElements,g,null),il(g))return vt(g),!0;const R=be(g.nodeName);if(Pt($e.uponSanitizeElement,g,{tagName:R,allowedTags:_e}),io&&g.hasChildNodes()&&!yh(g.firstElementChild)&&De(/<[/\w!]/g,g.innerHTML)&&De(/<[/\w!]/g,g.textContent)||g.nodeType===Pi.progressingInstruction||io&&g.nodeType===Pi.comment&&De(/<[/\w]/g,g.data))return vt(g),!0;if(!(Qt.tagCheck instanceof Function&&Qt.tagCheck(R))&&(!_e[R]||vi[R])){if(!vi[R]&&wh(R)&&(me.tagNameCheck instanceof RegExp&&De(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R)))return!1;if(Xa&&!yt[R]){const ie=le(g)||g.parentNode,Re=P(g)||g.childNodes;if(Re&&ie){const ye=Re.length;for(let Fe=ye-1;Fe>=0;--Fe){const Rt=k(Re[Fe],!0);Rt.__removalCount=(g.__removalCount||0)+1,ie.insertBefore(Rt,B(g))}}}return vt(g),!0}return g instanceof c&&!Dv(g)||(R==="noscript"||R==="noembed"||R==="noframes")&&De(/<\/no(script|embed|frames)/i,g.innerHTML)?(vt(g),!0):(hr&&g.nodeType===Pi.text&&(T=g.textContent,xo([kn,mt,Xt],ie=>{T=Ti(T,ie," ")}),g.textContent!==T&&(xi(e.removed,{element:g.cloneNode()}),g.textContent=T)),Pt($e.afterSanitizeElements,g,null),!1)},bh=function(g,T,R){if(ro[T]||ah&&(T==="id"||T==="name")&&(R in t||R in Rv))return!1;if(!(Ya&&!ro[T]&&De(qa,T))){if(!(ih&&De(no,T))){if(!(Qt.attributeCheck instanceof Function&&Qt.attributeCheck(T,g))){if(!Ae[T]||ro[T]){if(!(wh(g)&&(me.tagNameCheck instanceof RegExp&&De(me.tagNameCheck,g)||me.tagNameCheck instanceof Function&&me.tagNameCheck(g))&&(me.attributeNameCheck instanceof RegExp&&De(me.attributeNameCheck,T)||me.attributeNameCheck instanceof Function&&me.attributeNameCheck(T,g))||T==="is"&&me.allowCustomizedBuiltInElements&&(me.tagNameCheck instanceof RegExp&&De(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R))))return!1}else if(!el[T]){if(!De(th,Ti(R,eh,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&g!=="script"&&AO(R,"data:")===0&&ch[g])){if(!(sh&&!De($v,Ti(R,eh,"")))){if(R)return!1}}}}}}}return!0},wh=function(g){return g!=="annotation-xml"&&Bl(g,Av)},_h=function(g){Pt($e.beforeSanitizeAttributes,g,null);const{attributes:T}=g;if(!T||il(g))return;const R={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ae,forceKeepAttr:void 0};let ie=T.length;for(;ie--;){const Re=T[ie],{name:ye,namespaceURI:Fe,value:Rt}=Re,mr=be(ye),sl=Rt;let xe=ye==="value"?sl:xO(sl);if(R.attrName=mr,R.attrValue=xe,R.keepAttr=!0,R.forceKeepAttr=void 0,Pt($e.uponSanitizeAttribute,g,R),xe=R.attrValue,lh&&(mr==="id"||mr==="name")&&($n(ye,g),xe=xv+xe),io&&De(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,xe)){$n(ye,g);continue}if(mr==="attributename"&&Bl(xe,"href")){$n(ye,g);continue}if(R.forceKeepAttr)continue;if(!R.keepAttr){$n(ye,g);continue}if(!oh&&De(/\/>/i,xe)){$n(ye,g);continue}hr&&xo([kn,mt,Xt],kh=>{xe=Ti(xe,kh," ")});const Sh=be(g.nodeName);if(!bh(Sh,mr,xe)){$n(ye,g);continue}if(M&&typeof y=="object"&&typeof y.getAttributeType=="function"&&!Fe)switch(y.getAttributeType(Sh,mr)){case"TrustedHTML":{xe=M.createHTML(xe);break}case"TrustedScriptURL":{xe=M.createScriptURL(xe);break}}if(xe!==sl)try{Fe?g.setAttributeNS(Fe,ye,xe):g.setAttribute(ye,xe),il(g)?vt(g):qf(e.removed)}catch{$n(ye,g)}}Pt($e.afterSanitizeAttributes,g,null)},Ov=function L(g){let T=null;const R=mh(g);for(Pt($e.beforeSanitizeShadowDOM,g,null);T=R.nextNode();)Pt($e.uponSanitizeShadowNode,T,null),vh(T),_h(T),T.content instanceof s&&L(T.content);Pt($e.afterSanitizeShadowDOM,g,null)};return e.sanitize=function(L){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,R=null,ie=null,Re=null;if(tl=!L,tl&&(L="<!-->"),typeof L!="string"&&!yh(L))if(typeof L.toString=="function"){if(L=L.toString(),typeof L!="string")throw Ci("dirty is not a string, aborting")}else throw Ci("toString is not a function");if(!e.isSupported)return L;if(Ka||rl(g),e.removed=[],typeof L=="string"&&(bi=!1),bi){if(L.nodeName){const Rt=be(L.nodeName);if(!_e[Rt]||vi[Rt])throw Ci("root node is forbidden and cannot be sanitized in-place")}}else if(L instanceof a)T=gh("<!---->"),R=T.ownerDocument.importNode(L,!0),R.nodeType===Pi.element&&R.nodeName==="BODY"||R.nodeName==="HTML"?T=R:T.appendChild(R);else{if(!dr&&!hr&&!En&&L.indexOf("<")===-1)return M&&oo?M.createHTML(L):L;if(T=gh(L),!T)return dr?null:oo?Z:""}T&&Ja&&vt(T.firstChild);const ye=mh(bi?L:T);for(;ie=ye.nextNode();)vh(ie),_h(ie),ie.content instanceof s&&Ov(ie.content);if(bi)return L;if(dr){if(so)for(Re=ce.call(T.ownerDocument);T.firstChild;)Re.appendChild(T.firstChild);else Re=T;return(Ae.shadowroot||Ae.shadowrootmode)&&(Re=to.call(r,Re,!0)),Re}let Fe=En?T.outerHTML:T.innerHTML;return En&&_e["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&De(av,T.ownerDocument.doctype.name)&&(Fe="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
333
+ `+Fe),hr&&xo([kn,mt,Xt],Rt=>{Fe=Ti(Fe,Rt," ")}),M&&oo?M.createHTML(Fe):Fe},e.setConfig=function(){let L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};rl(L),Ka=!0},e.clearConfig=function(){gr=null,Ka=!1},e.isValidAttribute=function(L,g,T){gr||rl({});const R=be(L),ie=be(g);return bh(R,ie,T)},e.addHook=function(L,g){typeof g=="function"&&xi($e[L],g)},e.removeHook=function(L,g){if(g!==void 0){const T=EO($e[L],g);return T===-1?void 0:$O($e[L],T,1)[0]}return qf($e[L])},e.removeHooks=function(L){$e[L]=[]},e.removeAllHooks=function(){$e=ep()},e}var cv=lv();function Vu(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ur=Vu();function uv(n){ur=n}var Dn={exec:()=>null};function W(n,e=""){let t=typeof n=="string"?n:n.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(Le.caret,"$1"),t=t.replace(i,o),r},getRegex:()=>new RegExp(t,e)};return r}var HO=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Le={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)}}>`)},VO=/^(?:[ \t]*(?:\n|$))+/,jO=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,BO=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,eo=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,GO=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ju=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,hv=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,dv=W(hv).replace(/bull/g,ju).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(),WO=W(hv).replace(/bull/g,ju).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(),Bu=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,qO=/^[^\n]+/,Gu=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,YO=W(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Gu).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),KO=W(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ju).getRegex(),Ba="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",Wu=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,JO=W("^ {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",Wu).replace("tag",Ba).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),fv=W(Bu).replace("hr",eo).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",Ba).getRegex(),XO=W(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",fv).getRegex(),qu={blockquote:XO,code:jO,def:YO,fences:BO,heading:GO,hr:eo,html:JO,lheading:dv,list:KO,newline:VO,paragraph:fv,table:Dn,text:qO},tp=W("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",eo).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",Ba).getRegex(),QO={...qu,lheading:WO,table:tp,paragraph:W(Bu).replace("hr",eo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",tp).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",Ba).getRegex()},ez={...qu,html:W(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Wu).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:Dn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:W(Bu).replace("hr",eo).replace("heading",` *#{1,6} *[^
334
+ ]`).replace("lheading",dv).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},tz=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,nz=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,pv=/^( {2,}|\\)\n(?!\s*$)/,rz=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,mi=/[\p{P}\p{S}]/u,Ga=/[\s\p{P}\p{S}]/u,Yu=/[^\s\p{P}\p{S}]/u,iz=W(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ga).getRegex(),gv=/(?!~)[\p{P}\p{S}]/u,sz=/(?!~)[\s\p{P}\p{S}]/u,oz=/(?:[^\s\p{P}\p{S}]|~)/u,az=W(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",HO?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),mv=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,lz=W(mv,"u").replace(/punct/g,mi).getRegex(),cz=W(mv,"u").replace(/punct/g,gv).getRegex(),yv="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",uz=W(yv,"gu").replace(/notPunctSpace/g,Yu).replace(/punctSpace/g,Ga).replace(/punct/g,mi).getRegex(),hz=W(yv,"gu").replace(/notPunctSpace/g,oz).replace(/punctSpace/g,sz).replace(/punct/g,gv).getRegex(),dz=W("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Yu).replace(/punctSpace/g,Ga).replace(/punct/g,mi).getRegex(),fz=W(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,mi).getRegex(),pz="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",gz=W(pz,"gu").replace(/notPunctSpace/g,Yu).replace(/punctSpace/g,Ga).replace(/punct/g,mi).getRegex(),mz=W(/\\(punct)/,"gu").replace(/punct/g,mi).getRegex(),yz=W(/^<(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(),vz=W(Wu).replace("(?:-->|$)","-->").getRegex(),bz=W("^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",vz).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),aa=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,wz=W(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",aa).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),vv=W(/^!?\[(label)\]\[(ref)\]/).replace("label",aa).replace("ref",Gu).getRegex(),bv=W(/^!?\[(ref)\](?:\[\])?/).replace("ref",Gu).getRegex(),_z=W("reflink|nolink(?!\\()","g").replace("reflink",vv).replace("nolink",bv).getRegex(),np=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ku={_backpedal:Dn,anyPunctuation:mz,autolink:yz,blockSkip:az,br:pv,code:nz,del:Dn,delLDelim:Dn,delRDelim:Dn,emStrongLDelim:lz,emStrongRDelimAst:uz,emStrongRDelimUnd:dz,escape:tz,link:wz,nolink:bv,punctuation:iz,reflink:vv,reflinkSearch:_z,tag:bz,text:rz,url:Dn},Sz={...Ku,link:W(/^!?\[(label)\]\((.*?)\)/).replace("label",aa).getRegex(),reflink:W(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",aa).getRegex()},jc={...Ku,emStrongRDelimAst:hz,emStrongLDelim:cz,delLDelim:fz,delRDelim:gz,url:W(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",np).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:W(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",np).getRegex()},kz={...jc,br:W(pv).replace("{2,}","*").getRegex(),text:W(jc.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Co={normal:qu,gfm:QO,pedantic:ez},Ri={normal:Ku,gfm:jc,breaks:kz,pedantic:Sz},Ez={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},rp=n=>Ez[n];function St(n,e){if(e){if(Le.escapeTest.test(n))return n.replace(Le.escapeReplace,rp)}else if(Le.escapeTestNoEncode.test(n))return n.replace(Le.escapeReplaceNoEncode,rp);return n}function ip(n){try{n=encodeURI(n).replace(Le.percentDecode,"%")}catch{return null}return n}function sp(n,e){var s;let t=n.replace(Le.findPipe,(o,a,c)=>{let u=!1,d=a;for(;--d>=0&&c[d]==="\\";)u=!u;return u?"|":" |"}),r=t.split(Le.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!((s=r.at(-1))!=null&&s.trim())&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Le.slashPipe,"|");return r}function Di(n,e,t){let r=n.length;if(r===0)return"";let i=0;for(;i<r&&n.charAt(r-i-1)===e;)i++;return n.slice(0,r-i)}function $z(n,e){if(n.indexOf(e[1])===-1)return-1;let t=0;for(let r=0;r<n.length;r++)if(n[r]==="\\")r++;else if(n[r]===e[0])t++;else if(n[r]===e[1]&&(t--,t<0))return r;return t>0?-2:-1}function Az(n,e=0){let t=e,r="";for(let i of n)if(i===" "){let s=4-t%4;r+=" ".repeat(s),t+=s}else r+=i,t++;return r}function op(n,e,t,r,i){let s=e.href,o=e.title||null,a=n[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let c={type:n[0].charAt(0)==="!"?"image":"link",raw:t,href:s,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,c}function xz(n,e,t){let r=n.match(t.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
335
+ `).map(s=>{let o=s.match(t.other.beginningSpace);if(o===null)return s;let[a]=o;return a.length>=i.length?s.slice(i.length):s}).join(`
336
+ `)}var la=class{constructor(n){b(this,"options");b(this,"rules");b(this,"lexer");this.options=n||ur}space(n){let e=this.rules.block.newline.exec(n);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(n){let e=this.rules.block.code.exec(n);if(e){let t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:Di(t,`
337
+ `)}}}fences(n){let e=this.rules.block.fences.exec(n);if(e){let t=e[0],r=xz(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(n){let e=this.rules.block.heading.exec(n);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let r=Di(t,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(t=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(n){let e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:Di(e[0],`
338
+ `)}}blockquote(n){let e=this.rules.block.blockquote.exec(n);if(e){let t=Di(e[0],`
339
+ `).split(`
340
+ `),r="",i="",s=[];for(;t.length>0;){let o=!1,a=[],c;for(c=0;c<t.length;c++)if(this.rules.other.blockquoteStart.test(t[c]))a.push(t[c]),o=!0;else if(!o)a.push(t[c]);else break;t=t.slice(c);let u=a.join(`
341
+ `),d=u.replace(this.rules.other.blockquoteSetextReplace,`
342
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
343
+ ${u}`:u,i=i?`${i}
344
+ ${d}`:d;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,s,!0),this.lexer.state.top=f,t.length===0)break;let v=s.at(-1);if((v==null?void 0:v.type)==="code")break;if((v==null?void 0:v.type)==="blockquote"){let y=v,A=y.raw+`
345
+ `+t.join(`
346
+ `),k=this.blockquote(A);s[s.length-1]=k,r=r.substring(0,r.length-y.raw.length)+k.raw,i=i.substring(0,i.length-y.text.length)+k.text;break}else if((v==null?void 0:v.type)==="list"){let y=v,A=y.raw+`
347
+ `+t.join(`
348
+ `),k=this.list(A);s[s.length-1]=k,r=r.substring(0,r.length-v.raw.length)+k.raw,i=i.substring(0,i.length-y.raw.length)+k.raw,t=A.substring(s.at(-1).raw.length).split(`
349
+ `);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(n){var t,r;let e=this.rules.block.list.exec(n);if(e){let i=e[1].trim(),s=i.length>1,o={type:"list",raw:"",ordered:s,start:s?+i.slice(0,-1):"",loose:!1,items:[]};i=s?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=s?i:"[*+-]");let a=this.rules.other.listItemRegex(i),c=!1;for(;n;){let d=!1,f="",v="";if(!(e=a.exec(n))||this.rules.block.hr.test(n))break;f=e[0],n=n.substring(f.length);let y=Az(e[2].split(`
350
+ `,1)[0],e[1].length),A=n.split(`
351
+ `,1)[0],k=!y.trim(),I=0;if(this.options.pedantic?(I=2,v=y.trimStart()):k?I=e[1].length+1:(I=y.search(this.rules.other.nonSpaceChar),I=I>4?1:I,v=y.slice(I),I+=e[1].length),k&&this.rules.other.blankLine.test(A)&&(f+=A+`
352
+ `,n=n.substring(A.length+1),d=!0),!d){let B=this.rules.other.nextBulletRegex(I),P=this.rules.other.hrRegex(I),le=this.rules.other.fencesBeginRegex(I),M=this.rules.other.headingBeginRegex(I),Z=this.rules.other.htmlBeginRegex(I),U=this.rules.other.blockquoteBeginRegex(I);for(;n;){let ge=n.split(`
353
+ `,1)[0],ce;if(A=ge,this.options.pedantic?(A=A.replace(this.rules.other.listReplaceNesting," "),ce=A):ce=A.replace(this.rules.other.tabCharGlobal," "),le.test(A)||M.test(A)||Z.test(A)||U.test(A)||B.test(A)||P.test(A))break;if(ce.search(this.rules.other.nonSpaceChar)>=I||!A.trim())v+=`
354
+ `+ce.slice(I);else{if(k||y.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||le.test(y)||M.test(y)||P.test(y))break;v+=`
355
+ `+A}k=!A.trim(),f+=ge+`
356
+ `,n=n.substring(ge.length+1),y=ce.slice(I)}}o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(f)&&(c=!0)),o.items.push({type:"list_item",raw:f,task:!!this.options.gfm&&this.rules.other.listIsTask.test(v),loose:!1,text:v,tokens:[]}),o.raw+=f}let u=o.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let d of o.items){if(this.lexer.state.top=!1,d.tokens=this.lexer.blockTokens(d.text,[]),d.task){if(d.text=d.text.replace(this.rules.other.listReplaceTask,""),((t=d.tokens[0])==null?void 0:t.type)==="text"||((r=d.tokens[0])==null?void 0:r.type)==="paragraph"){d.tokens[0].raw=d.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),d.tokens[0].text=d.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let v=this.lexer.inlineQueue.length-1;v>=0;v--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[v].src)){this.lexer.inlineQueue[v].src=this.lexer.inlineQueue[v].src.replace(this.rules.other.listReplaceTask,"");break}}let f=this.rules.other.listTaskCheckbox.exec(d.raw);if(f){let v={type:"checkbox",raw:f[0]+" ",checked:f[0]!=="[ ]"};d.checked=v.checked,o.loose?d.tokens[0]&&["paragraph","text"].includes(d.tokens[0].type)&&"tokens"in d.tokens[0]&&d.tokens[0].tokens?(d.tokens[0].raw=v.raw+d.tokens[0].raw,d.tokens[0].text=v.raw+d.tokens[0].text,d.tokens[0].tokens.unshift(v)):d.tokens.unshift({type:"paragraph",raw:v.raw,text:v.raw,tokens:[v]}):d.tokens.unshift(v)}}if(!o.loose){let f=d.tokens.filter(y=>y.type==="space"),v=f.length>0&&f.some(y=>this.rules.other.anyLine.test(y.raw));o.loose=v}}if(o.loose)for(let d of o.items){d.loose=!0;for(let f of d.tokens)f.type==="text"&&(f.type="paragraph")}return o}}html(n){let e=this.rules.block.html.exec(n);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(n){let e=this.rules.block.def.exec(n);if(e){let t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:e[0],href:r,title:i}}}table(n){var o;let e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=sp(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(o=e[3])!=null&&o.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
357
+ `):[],s={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?s.align.push("right"):this.rules.other.tableAlignCenter.test(a)?s.align.push("center"):this.rules.other.tableAlignLeft.test(a)?s.align.push("left"):s.align.push(null);for(let a=0;a<t.length;a++)s.header.push({text:t[a],tokens:this.lexer.inline(t[a]),header:!0,align:s.align[a]});for(let a of i)s.rows.push(sp(a,s.header.length).map((c,u)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:s.align[u]})));return s}}lheading(n){let e=this.rules.block.lheading.exec(n);if(e){let t=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:t,tokens:this.lexer.inline(t)}}}paragraph(n){let e=this.rules.block.paragraph.exec(n);if(e){let t=e[1].charAt(e[1].length-1)===`
358
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(n){let e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){let e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){let e=this.rules.inline.tag.exec(n);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(n){let e=this.rules.inline.link.exec(n);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let s=Di(t.slice(0,-1),"\\");if((t.length-s.length)%2===0)return}else{let s=$z(e[2],"()");if(s===-2)return;if(s>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+s;e[2]=e[2].substring(0,s),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let r=e[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3])}else i=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?r=r.slice(1):r=r.slice(1,-1)),op(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let t;if((t=this.rules.inline.reflink.exec(n))||(t=this.rules.inline.nolink.exec(n))){let r=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){let s=t[0].charAt(0);return{type:"text",raw:s,text:s}}return op(t,i,t[0],this.lexer,this.rules)}}emStrong(n,e,t=""){let r=this.rules.inline.emStrongLDelim.exec(n);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!t||this.rules.inline.punctuation.exec(t))){let i=[...r[0]].length-1,s,o,a=i,c=0,u=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*n.length+i);(r=u.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(o=[...s].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&i%3&&!((i+o)%3)){c+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+c);let d=[...r[0]][0].length,f=n.slice(0,i+r.index+d+o);if(Math.min(i,o)%2){let y=f.slice(1,-1);return{type:"em",raw:f,text:y,tokens:this.lexer.inlineTokens(y)}}let v=f.slice(2,-2);return{type:"strong",raw:f,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(n){let e=this.rules.inline.code.exec(n);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(t),i=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return r&&i&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(n){let e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n,e,t=""){let r=this.rules.inline.delLDelim.exec(n);if(r&&(!r[1]||!t||this.rules.inline.punctuation.exec(t))){let i=[...r[0]].length-1,s,o,a=i,c=this.rules.inline.delRDelim;for(c.lastIndex=0,e=e.slice(-1*n.length+i);(r=c.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(o=[...s].length,o!==i))continue;if(r[3]||r[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let u=[...r[0]][0].length,d=n.slice(0,i+r.index+u+o),f=d.slice(i,-i);return{type:"del",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}}}autolink(n){let e=this.rules.inline.autolink.exec(n);if(e){let t,r;return e[2]==="@"?(t=e[1],r="mailto:"+t):(t=e[1],r=t),{type:"link",raw:e[0],text:t,href:r,tokens:[{type:"text",raw:t,text:t}]}}}url(n){var t;let e;if(e=this.rules.inline.url.exec(n)){let r,i;if(e[2]==="@")r=e[0],i="mailto:"+r;else{let s;do s=e[0],e[0]=((t=this.rules.inline._backpedal.exec(e[0]))==null?void 0:t[0])??"";while(s!==e[0]);r=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0]}return{type:"link",raw:e[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(n){let e=this.rules.inline.text.exec(n);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},dt=class Bc{constructor(e){b(this,"tokens");b(this,"options");b(this,"state");b(this,"inlineQueue");b(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ur,this.options.tokenizer=this.options.tokenizer||new la,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:Le,block:Co.normal,inline:Ri.normal};this.options.pedantic?(t.block=Co.pedantic,t.inline=Ri.pedantic):this.options.gfm&&(t.block=Co.gfm,this.options.breaks?t.inline=Ri.breaks:t.inline=Ri.gfm),this.tokenizer.rules=t}static get rules(){return{block:Co,inline:Ri}}static lex(e,t){return new Bc(t).lex(e)}static lexInline(e,t){return new Bc(t).inlineTokens(e)}lex(e){e=e.replace(Le.carriageReturn,`
359
+ `),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let r=this.inlineQueue[t];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],r=!1){var i,s,o;for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Le.tabCharGlobal," ").replace(Le.spaceLine,""));e;){let a;if((s=(i=this.options.extensions)==null?void 0:i.block)!=null&&s.some(u=>(a=u.call({lexer:this},e,t))?(e=e.substring(a.raw.length),t.push(a),!0):!1))continue;if(a=this.tokenizer.space(e)){e=e.substring(a.raw.length);let u=t.at(-1);a.raw.length===1&&u!==void 0?u.raw+=`
360
+ `:t.push(a);continue}if(a=this.tokenizer.code(e)){e=e.substring(a.raw.length);let u=t.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
361
+ `)?"":`
362
+ `)+a.raw,u.text+=`
363
+ `+a.text,this.inlineQueue.at(-1).src=u.text):t.push(a);continue}if(a=this.tokenizer.fences(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.heading(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.hr(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.blockquote(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.list(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.html(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.def(e)){e=e.substring(a.raw.length);let u=t.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
364
+ `)?"":`
365
+ `)+a.raw,u.text+=`
366
+ `+a.raw,this.inlineQueue.at(-1).src=u.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},t.push(a));continue}if(a=this.tokenizer.table(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.lheading(e)){e=e.substring(a.raw.length),t.push(a);continue}let c=e;if((o=this.options.extensions)!=null&&o.startBlock){let u=1/0,d=e.slice(1),f;this.options.extensions.startBlock.forEach(v=>{f=v.call({lexer:this},d),typeof f=="number"&&f>=0&&(u=Math.min(u,f))}),u<1/0&&u>=0&&(c=e.substring(0,u+1))}if(this.state.top&&(a=this.tokenizer.paragraph(c))){let u=t.at(-1);r&&(u==null?void 0:u.type)==="paragraph"?(u.raw+=(u.raw.endsWith(`
367
+ `)?"":`
368
+ `)+a.raw,u.text+=`
369
+ `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):t.push(a),r=c.length!==e.length,e=e.substring(a.raw.length);continue}if(a=this.tokenizer.text(e)){e=e.substring(a.raw.length);let u=t.at(-1);(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
370
+ `)?"":`
371
+ `)+a.raw,u.text+=`
372
+ `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):t.push(a);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){var c,u,d,f,v;this.tokenizer.lexer=this;let r=e,i=null;if(this.tokens.links){let y=Object.keys(this.tokens.links);if(y.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)y.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)s=i[2]?i[2].length:0,r=r.slice(0,i.index+s)+"["+"a".repeat(i[0].length-s-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=((u=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:u.call({lexer:this},r))??r;let o=!1,a="";for(;e;){o||(a=""),o=!1;let y;if((f=(d=this.options.extensions)==null?void 0:d.inline)!=null&&f.some(k=>(y=k.call({lexer:this},e,t))?(e=e.substring(y.raw.length),t.push(y),!0):!1))continue;if(y=this.tokenizer.escape(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.tag(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.link(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(y.raw.length);let k=t.at(-1);y.type==="text"&&(k==null?void 0:k.type)==="text"?(k.raw+=y.raw,k.text+=y.text):t.push(y);continue}if(y=this.tokenizer.emStrong(e,r,a)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.codespan(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.br(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.del(e,r,a)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.autolink(e)){e=e.substring(y.raw.length),t.push(y);continue}if(!this.state.inLink&&(y=this.tokenizer.url(e))){e=e.substring(y.raw.length),t.push(y);continue}let A=e;if((v=this.options.extensions)!=null&&v.startInline){let k=1/0,I=e.slice(1),B;this.options.extensions.startInline.forEach(P=>{B=P.call({lexer:this},I),typeof B=="number"&&B>=0&&(k=Math.min(k,B))}),k<1/0&&k>=0&&(A=e.substring(0,k+1))}if(y=this.tokenizer.inlineText(A)){e=e.substring(y.raw.length),y.raw.slice(-1)!=="_"&&(a=y.raw.slice(-1)),o=!0;let k=t.at(-1);(k==null?void 0:k.type)==="text"?(k.raw+=y.raw,k.text+=y.text):t.push(y);continue}if(e){let k="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(k);break}else throw new Error(k)}}return t}},ca=class{constructor(n){b(this,"options");b(this,"parser");this.options=n||ur}space(n){return""}code({text:n,lang:e,escaped:t}){var s;let r=(s=(e||"").match(Le.notSpaceStart))==null?void 0:s[0],i=n.replace(Le.endingNewline,"")+`
373
+ `;return r?'<pre><code class="language-'+St(r)+'">'+(t?i:St(i,!0))+`</code></pre>
374
+ `:"<pre><code>"+(t?i:St(i,!0))+`</code></pre>
375
+ `}blockquote({tokens:n}){return`<blockquote>
376
+ ${this.parser.parse(n)}</blockquote>
377
+ `}html({text:n}){return n}def(n){return""}heading({tokens:n,depth:e}){return`<h${e}>${this.parser.parseInline(n)}</h${e}>
378
+ `}hr(n){return`<hr>
379
+ `}list(n){let e=n.ordered,t=n.start,r="";for(let o=0;o<n.items.length;o++){let a=n.items[o];r+=this.listitem(a)}let i=e?"ol":"ul",s=e&&t!==1?' start="'+t+'"':"";return"<"+i+s+`>
380
+ `+r+"</"+i+`>
381
+ `}listitem(n){return`<li>${this.parser.parse(n.tokens)}</li>
382
+ `}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
383
+ `}table(n){let e="",t="";for(let i=0;i<n.header.length;i++)t+=this.tablecell(n.header[i]);e+=this.tablerow({text:t});let r="";for(let i=0;i<n.rows.length;i++){let s=n.rows[i];t="";for(let o=0;o<s.length;o++)t+=this.tablecell(s[o]);r+=this.tablerow({text:t})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
384
+ <thead>
385
+ `+e+`</thead>
386
+ `+r+`</table>
387
+ `}tablerow({text:n}){return`<tr>
388
+ ${n}</tr>
389
+ `}tablecell(n){let e=this.parser.parseInline(n.tokens),t=n.header?"th":"td";return(n.align?`<${t} align="${n.align}">`:`<${t}>`)+e+`</${t}>
390
+ `}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${St(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:t}){let r=this.parser.parseInline(t),i=ip(n);if(i===null)return r;n=i;let s='<a href="'+n+'"';return e&&(s+=' title="'+St(e)+'"'),s+=">"+r+"</a>",s}image({href:n,title:e,text:t,tokens:r}){r&&(t=this.parser.parseInline(r,this.parser.textRenderer));let i=ip(n);if(i===null)return St(t);n=i;let s=`<img src="${n}" alt="${St(t)}"`;return e&&(s+=` title="${St(e)}"`),s+=">",s}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:St(n.text)}},Ju=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}checkbox({raw:n}){return n}},ft=class Gc{constructor(e){b(this,"options");b(this,"renderer");b(this,"textRenderer");this.options=e||ur,this.options.renderer=this.options.renderer||new ca,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ju}static parse(e,t){return new Gc(t).parse(e)}static parseInline(e,t){return new Gc(t).parseInline(e)}parse(e){var r,i;this.renderer.parser=this;let t="";for(let s=0;s<e.length;s++){let o=e[s];if((i=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&i[o.type]){let c=o,u=this.options.extensions.renderers[c.type].call({parser:this},c);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(c.type)){t+=u||"";continue}}let a=o;switch(a.type){case"space":{t+=this.renderer.space(a);break}case"hr":{t+=this.renderer.hr(a);break}case"heading":{t+=this.renderer.heading(a);break}case"code":{t+=this.renderer.code(a);break}case"table":{t+=this.renderer.table(a);break}case"blockquote":{t+=this.renderer.blockquote(a);break}case"list":{t+=this.renderer.list(a);break}case"checkbox":{t+=this.renderer.checkbox(a);break}case"html":{t+=this.renderer.html(a);break}case"def":{t+=this.renderer.def(a);break}case"paragraph":{t+=this.renderer.paragraph(a);break}case"text":{t+=this.renderer.text(a);break}default:{let c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return t}parseInline(e,t=this.renderer){var i,s;this.renderer.parser=this;let r="";for(let o=0;o<e.length;o++){let a=e[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[a.type]){let u=this.options.extensions.renderers[a.type].call({parser:this},a);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=u||"";continue}}let c=a;switch(c.type){case"escape":{r+=t.text(c);break}case"html":{r+=t.html(c);break}case"link":{r+=t.link(c);break}case"image":{r+=t.image(c);break}case"checkbox":{r+=t.checkbox(c);break}case"strong":{r+=t.strong(c);break}case"em":{r+=t.em(c);break}case"codespan":{r+=t.codespan(c);break}case"br":{r+=t.br(c);break}case"del":{r+=t.del(c);break}case"text":{r+=t.text(c);break}default:{let u='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return r}},Io,Vi=(Io=class{constructor(n){b(this,"options");b(this,"block");this.options=n||ur}preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}emStrongMask(n){return n}provideLexer(){return this.block?dt.lex:dt.lexInline}provideParser(){return this.block?ft.parse:ft.parseInline}},b(Io,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),b(Io,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Io),Tz=class{constructor(...n){b(this,"defaults",Vu());b(this,"options",this.setOptions);b(this,"parse",this.parseMarkdown(!0));b(this,"parseInline",this.parseMarkdown(!1));b(this,"Parser",ft);b(this,"Renderer",ca);b(this,"TextRenderer",Ju);b(this,"Lexer",dt);b(this,"Tokenizer",la);b(this,"Hooks",Vi);this.use(...n)}walkTokens(n,e){var r,i;let t=[];for(let s of n)switch(t=t.concat(e.call(this,s)),s.type){case"table":{let o=s;for(let a of o.header)t=t.concat(this.walkTokens(a.tokens,e));for(let a of o.rows)for(let c of a)t=t.concat(this.walkTokens(c.tokens,e));break}case"list":{let o=s;t=t.concat(this.walkTokens(o.items,e));break}default:{let o=s;(i=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let c=o[a].flat(1/0);t=t.concat(this.walkTokens(c,e))}):o.tokens&&(t=t.concat(this.walkTokens(o.tokens,e)))}}return t}use(...n){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(t=>{let r={...t};if(r.async=this.defaults.async||r.async||!1,t.extensions&&(t.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=s.apply(this,o)),a}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=e[i.level];s?s.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),t.renderer){let i=this.defaults.renderer||new ca(this.defaults);for(let s in t.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=t.renderer[o],c=i[o];i[o]=(...u)=>{let d=a.apply(i,u);return d===!1&&(d=c.apply(i,u)),d||""}}r.renderer=i}if(t.tokenizer){let i=this.defaults.tokenizer||new la(this.defaults);for(let s in t.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=t.tokenizer[o],c=i[o];i[o]=(...u)=>{let d=a.apply(i,u);return d===!1&&(d=c.apply(i,u)),d}}r.tokenizer=i}if(t.hooks){let i=this.defaults.hooks||new Vi;for(let s in t.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=t.hooks[o],c=i[o];Vi.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&Vi.passThroughHooksRespectAsync.has(s))return(async()=>{let f=await a.call(i,u);return c.call(i,f)})();let d=a.call(i,u);return c.call(i,d)}:i[o]=(...u)=>{if(this.defaults.async)return(async()=>{let f=await a.apply(i,u);return f===!1&&(f=await c.apply(i,u)),f})();let d=a.apply(i,u);return d===!1&&(d=c.apply(i,u)),d}}r.hooks=i}if(t.walkTokens){let i=this.defaults.walkTokens,s=t.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return dt.lex(n,e??this.defaults)}parser(n,e){return ft.parse(n,e??this.defaults)}parseMarkdown(n){return(e,t)=>{let r={...t},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=n),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(e):e,a=await(i.hooks?await i.hooks.provideLexer():n?dt.lex:dt.lexInline)(o,i),c=i.hooks?await i.hooks.processAllTokens(a):a;i.walkTokens&&await Promise.all(this.walkTokens(c,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser():n?ft.parse:ft.parseInline)(c,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(s);try{i.hooks&&(e=i.hooks.preprocess(e));let o=(i.hooks?i.hooks.provideLexer():n?dt.lex:dt.lexInline)(e,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():n?ft.parse:ft.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(n,e){return t=>{if(t.message+=`
391
+ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error occurred:</p><pre>"+St(t.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(t);throw t}}},sr=new Tz;function K(n,e){return sr.parse(n,e)}K.options=K.setOptions=function(n){return sr.setOptions(n),K.defaults=sr.defaults,uv(K.defaults),K};K.getDefaults=Vu;K.defaults=ur;K.use=function(...n){return sr.use(...n),K.defaults=sr.defaults,uv(K.defaults),K};K.walkTokens=function(n,e){return sr.walkTokens(n,e)};K.parseInline=sr.parseInline;K.Parser=ft;K.parser=ft.parse;K.Renderer=ca;K.TextRenderer=Ju;K.Lexer=dt;K.lexer=dt.lex;K.Tokenizer=la;K.Hooks=Vi;K.parse=K;K.options;K.setOptions;K.use;K.walkTokens;K.parseInline;ft.parse;dt.lex;cv.addHook("afterSanitizeAttributes",n=>{n.tagName==="A"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"))});function Cz(n){const e=K.parse(n,{async:!1});return cv.sanitize(e,{USE_PROFILES:{html:!0}})}const Iz=8,ap=new WeakMap;function Pz(n){const e=ap.get(n);if(e&&e.text===n.text)return e.html;const t=Cz(n.text);return ap.set(n,{text:n.text,html:t}),t}function lp(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t&&t.kind==="user")return t.id}return null}var jt,Qn,xa,Ta,Ls,Wc;class wv extends ts{constructor(){super(...arguments);_(this,Ls);b(this,"messages",[]);_(this,jt,!0);_(this,Qn,null);_(this,xa,()=>{const t=l(this,Qn);if(!t)return;const i=t.scrollHeight-t.clientHeight-t.scrollTop<=Iz;i!==l(this,jt)&&(E(this,jt,i),this.toggleAttribute("data-pinned",i))});_(this,Ta,()=>{E(this,jt,!0),this.toggleAttribute("data-pinned",!0),m(this,Ls,Wc).call(this,!0)})}changed(t){let r=!1;if(t.has("messages")){const i=t.get("messages")??[],s=lp(this.messages);r=s!==null&&s!==lp(i),r&&E(this,jt,!0)}Pe(this.template(),this),l(this,Qn)||E(this,Qn,this.querySelector(".history-scroll")),this.toggleAttribute("data-pinned",l(this,jt)),m(this,Ls,Wc).call(this,r)}template(){const t=this.messages.filter(r=>r.kind==="user"||r.kind==="assistant");return F`
392
+ <div class="history-scroll" @scroll=${l(this,xa)}>
393
+ ${t.map(r=>{const i=r.kind==="assistant"?VR(Pz(r)):r.text;return F`<div
394
+ class="message message-${r.kind}"
395
+ data-message-id=${r.id}
396
+ >${i}</div>`})}
397
+ </div>
398
+ <button
399
+ type="button"
400
+ class="history-jump"
401
+ aria-label="Jump to latest message"
402
+ @click=${l(this,Ta)}
403
+ >
404
+ ${_y({size:16})}
405
+ </button>
406
+ `}}jt=new WeakMap,Qn=new WeakMap,xa=new WeakMap,Ta=new WeakMap,Ls=new WeakSet,Wc=function(t){requestAnimationFrame(()=>{const r=l(this,Qn);r&&(!l(this,jt)&&!t||(r.scrollTop=r.scrollHeight-r.clientHeight))})},b(wv,"properties",["messages"]);customElements.define("message-history",wv);var Ms,Ns,Kr,Us,vn,Yc,Kc,Fs,Zs;class qc extends ts{constructor(){super(...arguments);_(this,vn);b(this,"placeholder","What do you want to do?");b(this,"open",!1);b(this,"messages",[]);_(this,Ms,Ge.resolve("ACPClientManager"));_(this,Ns,Ge.resolve("ShortcutService"));_(this,Kr,null);b(this,"handleTriggerActivate",()=>{this.open=!0});b(this,"handleKeydown",t=>{if(t.key!=="Enter"||t.shiftKey)return;const r=t.currentTarget,i=r.value.trim();if(t.preventDefault(),!i)return;r.value="";const s=l(this,Ms).getActiveClient();s&&s.sendMessage({text:i}).catch(o=>{console.error("ACPClient.sendMessage() failed",o)})});_(this,Us,t=>{if(t.shortcut!=="focusCommandInput")return;if(!this.open){this.open=!0;return}const r=this.querySelector("textarea");if(r){if(document.activeElement===r){this.open=!1;return}r.focus()}});_(this,Fs,t=>{t.target instanceof Node&&(this.contains(t.target)||(this.open=!1))});_(this,Zs,t=>{t.key==="Escape"&&(this.open=!1)})}connected(){const t=new DisposableStack;E(this,Kr,t);const r=wO(l(this,Ms),i=>{this.messages=i});t.defer(()=>r.dispose()),l(this,Ns).addEventListener("shortcut-triggered",l(this,Us)),t.defer(()=>l(this,Ns).removeEventListener("shortcut-triggered",l(this,Us))),this.open&&m(this,vn,Yc).call(this)}disconnected(){var t;(t=l(this,Kr))==null||t.dispose(),E(this,Kr,null),m(this,vn,Kc).call(this)}changed(t){if(Pe(this.template(),this),t.has("open"))if(this.open){m(this,vn,Yc).call(this);const r=this.querySelector("textarea");r==null||r.focus()}else m(this,vn,Kc).call(this)}template(){return this.open?F`
407
+ <message-history .messages=${this.messages}></message-history>
408
+ <textarea
409
+ class="input"
410
+ rows="1"
411
+ @keydown=${this.handleKeydown}
412
+ ></textarea>
413
+ `:F`
414
+ <button
415
+ class="trigger"
416
+ type="button"
417
+ @click=${this.handleTriggerActivate}
418
+ @focus=${this.handleTriggerActivate}
419
+ >
420
+ <span class="label">${this.placeholder}</span>
421
+ <span class="kbd" aria-hidden="true">⌘K</span>
422
+ </button>
423
+ `}}Ms=new WeakMap,Ns=new WeakMap,Kr=new WeakMap,Us=new WeakMap,vn=new WeakSet,Yc=function(){document.addEventListener("mousedown",l(this,Fs)),document.addEventListener("keydown",l(this,Zs))},Kc=function(){document.removeEventListener("mousedown",l(this,Fs)),document.removeEventListener("keydown",l(this,Zs))},Fs=new WeakMap,Zs=new WeakMap,b(qc,"properties",["placeholder","open","messages"]),b(qc,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",qc);class _v extends Event{constructor(t){super("auth-submit",{bubbles:!0,composed:!0});b(this,"token");this.token=t}}class Rz extends HTMLElement{constructor(){super(...arguments);b(this,"_invalid",!1);b(this,"_tokenValue","")}set invalid(t){this._invalid=t,this.render()}get invalid(){return this._invalid}set tokenValue(t){this._tokenValue=t,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(t){const r=t.currentTarget;this._tokenValue=r.value}handleSubmit(t){t.preventDefault();const r=this._tokenValue.trim();r&&this.dispatchEvent(new _v(r))}render(){Pe(F`
424
+ <modal-overlay open>
425
+ <section class="auth-modal">
426
+ <form class="auth-form" @submit=${t=>this.handleSubmit(t)}>
427
+ <h2 class="auth-modal-title">Enter access token</h2>
428
+ <p class="auth-modal-copy">This Television server requires a token.</p>
429
+ <label class="settings-field">
430
+ <span>Token</span>
431
+ <input
432
+ class=${this.invalid?"auth-token-input-invalid":""}
433
+ type="password"
434
+ name="token"
435
+ .value=${this.tokenValue}
436
+ @input=${t=>this.handleInput(t)}
437
+ required
438
+ />
439
+ </label>
440
+ <button type="submit" class="settings-submit-button">Connect</button>
441
+ </form>
442
+ </section>
443
+ </modal-overlay>
444
+ `,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",Rz);class Dz extends HTMLElement{constructor(){super(...arguments);b(this,"runtimeServerURL",hy());b(this,"electronMode",dy());b(this,"serverManager",Ge.resolve("ServerManager"));b(this,"screenManager",Ge.resolve("ScreenManager"));b(this,"connectError",null);b(this,"handleServerManagerChange",()=>{this.render()});b(this,"handleActiveScreenChanged",()=>{this.render()})}connectedCallback(){this.serverManager.addEventListener("change",this.handleServerManagerChange),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.addEventListener("auth-submit",t=>{var i;const r=t instanceof _v?t.token:t instanceof CustomEvent&&typeof((i=t.detail)==null?void 0:i.token)=="string"?t.detail.token:null;r&&this.handleAuthSubmit(r)}),this.initializeConnection(),this.render()}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleServerManagerChange),this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged)}async initializeConnection(){if(this.electronMode){this.serverManager.connectConfiguredServers(this.runtimeServerURL,Sc());return}if(this.serverManager.activeServer)return;const t=new gc({url:this.runtimeServerURL,name:"Server",token:Sc()});this.serverManager.add(t),this.serverManager.setActive(t);try{await t.connect(),this.connectError=null}catch(r){this.connectError=r instanceof Error&&!(r instanceof pc)?r.message:null}this.render()}async handleAuthSubmit(t){const r=this.serverManager.activeServer;if(r){this.connectError=null,r.token=t,this.updateTokenQueryParam(t);try{await r.connect()}catch(i){i instanceof pc||(this.connectError=i instanceof Error?i.message:String(i))}this.render()}}updateTokenQueryParam(t){const r=new URL(window.location.href);r.searchParams.set("token",t),window.history.replaceState({},"",`${r.pathname}${r.search}${r.hash}`)}render(){const t=this.serverManager.activeServer,r=(t==null?void 0:t.status)??null;if(r==="connecting"){Pe(F`
445
+ <main class="auth-gate"><p>Connecting...</p></main>
446
+ `,this);return}if(r==="disconnected"){const o=t;if(!o)return;Pe(F`
447
+ <main class="auth-gate">
448
+ <auth-modal
449
+ .invalid=${!!o.token}
450
+ .tokenValue=${o.token??""}
451
+ ></auth-modal>
452
+ </main>
453
+ `,this);return}const s=this.screenManager.activeScreen?F`<screen-view></screen-view>`:F`<home-screen></home-screen>`;Pe(F`
454
+ <main>
455
+ ${this.connectError?F`<p data-testid="auth-error">${this.connectError}</p>`:F`
456
+ ${s}
457
+ ${r==="connected"?F`
458
+ <div class="chrome">
459
+ <div class="top-row electron-draggable">
460
+ <screen-breadcrumb></screen-breadcrumb>
461
+ <screen-create-button></screen-create-button>
462
+ </div>
463
+ <command-panel></command-panel>
464
+ </div>
465
+ `:null}
466
+ `}
467
+ </main>
468
+ `,this)}}customElements.get("television-app")||customElements.define("television-app",Dz);const Xu=dy(),Wa=hy(),Sv=new X0(Xu?"television-electron":"television-browser",J0(Wa)),kv=new jC({localStore:Sv,localServerURL:Wa}),Ev=new q0({localStore:Sv,serverManager:kv}),Oz=new $R({serverURL:Wa,token:Sc()??"",screenManager:Ev}),zz=new xR;Ge.register("ServerManager",()=>kv);Ge.register("ScreenManager",()=>Ev);Ge.register("ACPClientManager",()=>Oz);Ge.register("ShortcutService",()=>zz);const Qu=document.createElement("television-app");Qu.runtimeServerURL=Wa;Qu.electronMode=Xu;Xu&&document.body.classList.add("electron");document.body.appendChild(Qu);