@telepath-computer/television 0.1.42 → 0.1.44

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,474 @@
1
+ var nb=Object.defineProperty;var Rh=t=>{throw TypeError(t)};var rb=(t,e,n)=>e in t?nb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var b=(t,e,n)=>rb(t,typeof e!="symbol"?e+"":e,n),ll=(t,e,n)=>e.has(t)||Rh("Cannot "+n);var l=(t,e,n)=>(ll(t,e,"read from private field"),n?n.call(t):e.get(t)),_=(t,e,n)=>e.has(t)?Rh("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),x=(t,e,n,r)=>(ll(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),m=(t,e,n)=>(ll(t,e,"access private method"),n);var Dh=(t,e,n,r)=>({set _(i){x(t,e,i,n)},get _(){return l(t,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 n(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=n(i);fetch(i.href,s)}})();var Pn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ib(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}),n}var Oh=Object.prototype.toString,xf=function(e){var n=Oh.call(e),r=n==="[object Arguments]";return r||(r=n!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Oh.call(e.callee)==="[object Function]"),r},cl,zh;function sb(){if(zh)return cl;zh=1;var t;if(!Object.keys){var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=xf,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(y){var v=y.constructor;return v&&v.prototype===y},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 y in window)try{if(!u["$"+y]&&e.call(window,y)&&window[y]!==null&&typeof window[y]=="object")try{c(window[y])}catch{return!0}}catch{return!0}return!1}(),p=function(y){if(typeof window>"u"||!d)return c(y);try{return c(y)}catch{return!1}};t=function(v){var $=v!==null&&typeof v=="object",k=n.call(v)==="[object Function]",I=r(v),B=$&&n.call(v)==="[object String]",P=[];if(!$&&!k&&!I)throw new TypeError("Object.keys called on a non-object");var K=o&&k;if(B&&v.length>0&&!e.call(v,0))for(var L=0;L<v.length;++L)P.push(String(L));if(I&&v.length>0)for(var Z=0;Z<v.length;++Z)P.push(String(Z));else for(var N in v)!(K&&N==="prototype")&&e.call(v,N)&&P.push(String(N));if(s)for(var ce=p(v),ue=0;ue<a.length;++ue)!(ce&&a[ue]==="constructor")&&e.call(v,a[ue])&&P.push(a[ue]);return P}}return cl=t,cl}var ob=Array.prototype.slice,ab=xf,Lh=Object.keys,Do=Lh?function(e){return Lh(e)}:sb(),Mh=Object.keys;Do.shim=function(){if(Object.keys){var e=function(){var n=Object.keys(arguments);return n&&n.length===arguments.length}(1,2);e||(Object.keys=function(r){return ab(r)?Mh(ob.call(r)):Mh(r)})}else Object.keys=Do;return Object.keys||Do};var lb=Do,Oo=Object.defineProperty||!1;if(Oo)try{Oo({},"a",{value:1})}catch{Oo=!1}var Bs=Oo,qt=SyntaxError,G=TypeError,cb=Object.getOwnPropertyDescriptor,zo=cb;if(zo)try{zo([],"length")}catch{zo=null}var si=zo,Nh=Bs,ub=qt,_r=G,Uh=si,Ef=function(e,n,r){if(!e||typeof e!="object"&&typeof e!="function")throw new _r("`obj` must be an object or a function`");if(typeof n!="string"&&typeof n!="symbol")throw new _r("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new _r("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new _r("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new _r("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new _r("`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=!!Uh&&Uh(e,n);if(Nh)Nh(e,n,{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[n]=r;else throw new ub("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},nc=Bs,$f=function(){return!!nc};$f.hasArrayLengthDefineBug=function(){if(!nc)return null;try{return nc([],"length",{value:1}).length!==1}catch{return!0}};var Pa=$f,hb=lb,db=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",pb=Object.prototype.toString,fb=Array.prototype.concat,Fh=Ef,gb=function(t){return typeof t=="function"&&pb.call(t)==="[object Function]"},Af=Pa(),mb=function(t,e,n,r){if(e in t){if(r===!0){if(t[e]===n)return}else if(!gb(r)||!r())return}Af?Fh(t,e,n,!0):Fh(t,e,n)},Tf=function(t,e){var n=arguments.length>2?arguments[2]:{},r=hb(e);db&&(r=fb.call(r,Object.getOwnPropertySymbols(e)));for(var i=0;i<r.length;i+=1)mb(t,r[i],e[r[i]],n[r[i]])};Tf.supportsDescriptors=!!Af;var hr=Tf,Lo={exports:{}};typeof self<"u"?Lo.exports=self:typeof window<"u"?Lo.exports=window:Lo.exports=Function("return this")();var Cf=Lo.exports,vb=Cf,If=function(){return typeof Pn!="object"||!Pn||Pn.Math!==Math||Pn.Array!==Array?vb:Pn},yb=hr,bb=si,wb=If,_b=function(){var e=wb();if(yb.supportsDescriptors){var n=bb(e,"globalThis");(!n||n.configurable&&(n.enumerable||!n.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},Sb=hr,kb=Cf,Pf=If,xb=_b,Eb=Pf(),Rf=function(){return Eb};Sb(Rf,{getPolyfill:Pf,implementation:kb,shim:xb});var ru=Rf,Yt=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},iu=Object,Df=Error,$b=EvalError,Ab=RangeError,su=ReferenceError,Tb=URIError,Cb=Math.abs,Ib=Math.floor,Pb=Math.max,Rb=Math.min,Db=Math.pow,Ob=Math.round,ou=Number.isNaN||function(e){return e!==e},zb=ou,Lb=function(e){return zb(e)||e===0?e:e<0?-1:1},oi=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},n=Symbol("test"),r=Object(n);if(typeof n=="string"||Object.prototype.toString.call(n)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var i=42;e[n]=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]!==n||!Object.prototype.propertyIsEnumerable.call(e,n))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,n);if(a.value!==i||a.enumerable!==!0)return!1}return!0},Zh=typeof Symbol<"u"&&Symbol,Mb=oi,au=function(){return typeof Zh!="function"||typeof Symbol!="function"||typeof Zh("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Mb()},Of=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,ul,Hh;function zf(){if(Hh)return ul;Hh=1;var t=iu;return ul=t.getPrototypeOf||null,ul}var Nb="Function.prototype.bind called on incompatible ",Ub=Object.prototype.toString,Fb=Math.max,Zb="[object Function]",Bh=function(e,n){for(var r=[],i=0;i<e.length;i+=1)r[i]=e[i];for(var s=0;s<n.length;s+=1)r[s+e.length]=n[s];return r},Hb=function(e,n){for(var r=[],i=n,s=0;i<e.length;i+=1,s+=1)r[s]=e[i];return r},Bb=function(t,e){for(var n="",r=0;r<t.length;r+=1)n+=t[r],r+1<t.length&&(n+=e);return n},Vb=function(e){var n=this;if(typeof n!="function"||Ub.apply(n)!==Zb)throw new TypeError(Nb+n);for(var r=Hb(arguments,1),i,s=function(){if(this instanceof i){var d=n.apply(this,Bh(r,arguments));return Object(d)===d?d:this}return n.apply(e,Bh(r,arguments))},o=Fb(0,n.length-r.length),a=[],c=0;c<o;c++)a[c]="$"+c;if(i=Function("binder","return function ("+Bb(a,",")+"){ return binder.apply(this,arguments); }")(s),n.prototype){var u=function(){};u.prototype=n.prototype,i.prototype=new u,u.prototype=null}return i},jb=Vb,Vs=Function.prototype.bind||jb,lu=Function.prototype.call,cu=Function.prototype.apply,Gb=typeof Reflect<"u"&&Reflect&&Reflect.apply,Wb=Vs,qb=cu,Yb=lu,Kb=Gb,Lf=Kb||Wb.call(Yb,qb),Jb=Vs,Xb=G,Qb=lu,ew=Lf,Ra=function(e){if(e.length<1||typeof e[0]!="function")throw new Xb("a function is required");return ew(Jb,Qb,e)},tw=Ra,Vh=si,Mf;try{Mf=[].__proto__===Array.prototype}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var hl=!!Mf&&Vh&&Vh(Object.prototype,"__proto__"),Nf=Object,jh=Nf.getPrototypeOf,nw=hl&&typeof hl.get=="function"?tw([hl.get]):typeof jh=="function"?function(e){return jh(e==null?e:Nf(e))}:!1,Gh=Of,Wh=zf(),qh=nw,Uf=Gh?function(e){return Gh(e)}:Wh?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return Wh(e)}:qh?function(e){return qh(e)}:null,rw=Function.prototype.call,iw=Object.prototype.hasOwnProperty,sw=Vs,Kt=sw.call(rw,iw),j,ow=iu,aw=Df,lw=$b,cw=Ab,uw=su,Qr=qt,zr=G,hw=Tb,dw=Cb,pw=Ib,fw=Pb,gw=Rb,mw=Db,vw=Ob,yw=Lb,Ff=Function,dl=function(t){try{return Ff('"use strict"; return ('+t+").constructor;")()}catch{}},Ji=si,bw=Bs,pl=function(){throw new zr},ww=Ji?function(){try{return arguments.callee,pl}catch{try{return Ji(arguments,"callee").get}catch{return pl}}}():pl,Sr=au(),Se=Uf,_w=zf(),Sw=Of,Zf=cu,js=lu,Er={},kw=typeof Uint8Array>"u"||!Se?j:Se(Uint8Array),ir={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?j:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?j:ArrayBuffer,"%ArrayIteratorPrototype%":Sr&&Se?Se([][Symbol.iterator]()):j,"%AsyncFromSyncIteratorPrototype%":j,"%AsyncFunction%":Er,"%AsyncGenerator%":Er,"%AsyncGeneratorFunction%":Er,"%AsyncIteratorPrototype%":Er,"%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%":aw,"%eval%":eval,"%EvalError%":lw,"%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%":Ff,"%GeneratorFunction%":Er,"%Int8Array%":typeof Int8Array>"u"?j:Int8Array,"%Int16Array%":typeof Int16Array>"u"?j:Int16Array,"%Int32Array%":typeof Int32Array>"u"?j:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Sr&&Se?Se(Se([][Symbol.iterator]())):j,"%JSON%":typeof JSON=="object"?JSON:j,"%Map%":typeof Map>"u"?j:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Sr||!Se?j:Se(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":ow,"%Object.getOwnPropertyDescriptor%":Ji,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?j:Promise,"%Proxy%":typeof Proxy>"u"?j:Proxy,"%RangeError%":cw,"%ReferenceError%":uw,"%Reflect%":typeof Reflect>"u"?j:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?j:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Sr||!Se?j:Se(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?j:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Sr&&Se?Se(""[Symbol.iterator]()):j,"%Symbol%":Sr?Symbol:j,"%SyntaxError%":Qr,"%ThrowTypeError%":ww,"%TypedArray%":kw,"%TypeError%":zr,"%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%":hw,"%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%":Zf,"%Object.defineProperty%":bw,"%Object.getPrototypeOf%":_w,"%Math.abs%":dw,"%Math.floor%":pw,"%Math.max%":fw,"%Math.min%":gw,"%Math.pow%":mw,"%Math.round%":vw,"%Math.sign%":yw,"%Reflect.getPrototypeOf%":Sw};if(Se)try{null.error}catch(t){var xw=Se(Se(t));ir["%Error.prototype%"]=xw}var Ew=function t(e){var n;if(e==="%AsyncFunction%")n=dl("async function () {}");else if(e==="%GeneratorFunction%")n=dl("function* () {}");else if(e==="%AsyncGeneratorFunction%")n=dl("async function* () {}");else if(e==="%AsyncGenerator%"){var r=t("%AsyncGeneratorFunction%");r&&(n=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=t("%AsyncGenerator%");i&&Se&&(n=Se(i.prototype))}return ir[e]=n,n},Yh={__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"]},Gs=Vs,qo=Kt,$w=Gs.call(js,Array.prototype.concat),Aw=Gs.call(Zf,Array.prototype.splice),Kh=Gs.call(js,String.prototype.replace),Yo=Gs.call(js,String.prototype.slice),Tw=Gs.call(js,RegExp.prototype.exec),Cw=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Iw=/\\(\\)?/g,Pw=function(e){var n=Yo(e,0,1),r=Yo(e,-1);if(n==="%"&&r!=="%")throw new Qr("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&n!=="%")throw new Qr("invalid intrinsic syntax, expected opening `%`");var i=[];return Kh(e,Cw,function(s,o,a,c){i[i.length]=a?Kh(c,Iw,"$1"):o||s}),i},Rw=function(e,n){var r=e,i;if(qo(Yh,r)&&(i=Yh[r],r="%"+i[0]+"%"),qo(ir,r)){var s=ir[r];if(s===Er&&(s=Ew(r)),typeof s>"u"&&!n)throw new zr("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:s}}throw new Qr("intrinsic "+e+" does not exist!")},st=function(e,n){if(typeof e!="string"||e.length===0)throw new zr("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof n!="boolean")throw new zr('"allowMissing" argument must be a boolean');if(Tw(/^%?[^%]*%?$/,e)===null)throw new Qr("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=Pw(e),i=r.length>0?r[0]:"",s=Rw("%"+i+"%",n),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],Aw(r,$w([0,1],u)));for(var d=1,p=!0;d<r.length;d+=1){var y=r[d],v=Yo(y,0,1),$=Yo(y,-1);if((v==='"'||v==="'"||v==="`"||$==='"'||$==="'"||$==="`")&&v!==$)throw new Qr("property names with quotes must have matching quotes");if((y==="constructor"||!p)&&(c=!0),i+="."+y,o="%"+i+"%",qo(ir,o))a=ir[o];else if(a!=null){if(!(y in a)){if(!n)throw new zr("base intrinsic for "+e+" exists, but the property is not available.");return}if(Ji&&d+1>=r.length){var k=Ji(a,y);p=!!k,p&&"get"in k&&!("originalValue"in k.get)?a=k.get:a=a[y]}else p=qo(a,y),a=a[y];p&&!c&&(ir[o]=a)}}return a},fl,Jh;function wn(){if(Jh)return fl;Jh=1;var t=st,e=Ra,n=e([t("%String.prototype.indexOf%")]);return fl=function(i,s){var o=t(i,!!s);return typeof o=="function"&&n(i,".prototype.")>-1?e([o]):o},fl}var gl,Xh;function uu(){if(Xh)return gl;Xh=1;var t=st,e=t("%Array%"),n=!e.isArray&&wn()("Object.prototype.toString");return gl=e.isArray||function(i){return n(i)==="[object Array]"},gl}var Dw=Pa,Qh=Bs,Hf=Dw.hasArrayLengthDefineBug(),Ow=Hf&&uu(),zw=wn(),Lw=zw("Object.prototype.propertyIsEnumerable"),hu=function(e,n,r,i,s,o){if(!Qh){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&Lw(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,n(i[s],a)}return Hf&&s==="length"&&"[[Value]]"in o&&Ow(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(Qh(i,s,r(o)),!0)},Mw=G,Si=Kt,Nw={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},ai=function(e){if(!e||typeof e!="object")return!1;for(var n in e)if(Si(e,n)&&!Nw[n])return!1;var r=Si(e,"[[Value]]")||Si(e,"[[Writable]]"),i=Si(e,"[[Get]]")||Si(e,"[[Set]]");if(r&&i)throw new Mw("Property Descriptors may not be both accessor and data descriptors");return!0},Bf=function(e){if(typeof e>"u")return e;var n={};return"[[Value]]"in e&&(n.value=e["[[Value]]"]),"[[Writable]]"in e&&(n.writable=!!e["[[Writable]]"]),"[[Get]]"in e&&(n.get=e["[[Get]]"]),"[[Set]]"in e&&(n.set=e["[[Set]]"]),"[[Enumerable]]"in e&&(n.enumerable=!!e["[[Enumerable]]"]),"[[Configurable]]"in e&&(n.configurable=!!e["[[Configurable]]"]),n},Uw=G,Fw=ai,Zw=Bf,Vf=function(e){if(typeof e<"u"&&!Fw(e))throw new Uw("Assertion failed: `Desc` must be a Property Descriptor");return Zw(e)},Hw=G,ed=Kt,Bw=ai,jf=function(e){if(typeof e>"u")return!1;if(!Bw(e))throw new Hw("Assertion failed: `Desc` must be a Property Descriptor");return!(!ed(e,"[[Value]]")&&!ed(e,"[[Writable]]"))},li=function(e){return typeof e=="string"||typeof e=="symbol"},td=ou,Gf=function(e,n){return e===n?e===0?1/e===1/n:!0:td(e)&&td(n)},nd=G,Vw=Yt,jw=hu,Gw=Vf,Ww=jf,qw=li,Yw=Gf,du=function(e,n,r){if(!Vw(e))throw new nd("Assertion failed: Type(O) is not Object");if(!qw(n))throw new nd("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return jw(Ww,Yw,Gw,e,n,i)},Wf=Function.prototype.toString,Rr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,rc,Mo;if(typeof Rr=="function"&&typeof Object.defineProperty=="function")try{rc=Object.defineProperty({},"length",{get:function(){throw Mo}}),Mo={},Rr(function(){throw 42},null,rc)}catch(t){t!==Mo&&(Rr=null)}else Rr=null;var Kw=/^\s*class\b/,ic=function(e){try{var n=Wf.call(e);return Kw.test(n)}catch{return!1}},ml=function(e){try{return ic(e)?!1:(Wf.call(e),!0)}catch{return!1}},No=Object.prototype.toString,Jw="[object Object]",Xw="[object Function]",Qw="[object GeneratorFunction]",e0="[object HTMLAllCollection]",t0="[object HTML document.all class]",n0="[object HTMLCollection]",r0=typeof Symbol=="function"&&!!Symbol.toStringTag,i0=!(0 in[,]),sc=function(){return!1};if(typeof document=="object"){var s0=document.all;No.call(s0)===No.call(document.all)&&(sc=function(e){if((i0||!e)&&(typeof e>"u"||typeof e=="object"))try{var n=No.call(e);return(n===e0||n===t0||n===n0||n===Jw)&&e("")==null}catch{}return!1})}var qf=Rr?function(e){if(sc(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{Rr(e,null,rc)}catch(n){if(n!==Mo)return!1}return!ic(e)&&ml(e)}:function(e){if(sc(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(r0)return ml(e);if(ic(e))return!1;var n=No.call(e);return n!==Xw&&n!==Qw&&!/^\[object HTML/.test(n)?!1:ml(e)},o0=qf,a0=function(e){return!!e},bt=Kt,po=G,l0=Yt,rd=o0,vl=a0,c0=function(e){if(!l0(e))throw new po("ToPropertyDescriptor requires an object");var n={};if(bt(e,"enumerable")&&(n["[[Enumerable]]"]=vl(e.enumerable)),bt(e,"configurable")&&(n["[[Configurable]]"]=vl(e.configurable)),bt(e,"value")&&(n["[[Value]]"]=e.value),bt(e,"writable")&&(n["[[Writable]]"]=vl(e.writable)),bt(e,"get")){var r=e.get;if(typeof r<"u"&&!rd(r))throw new po("getter must be a function");n["[[Get]]"]=r}if(bt(e,"set")){var i=e.set;if(typeof i<"u"&&!rd(i))throw new po("setter must be a function");n["[[Set]]"]=i}if((bt(n,"[[Get]]")||bt(n,"[[Set]]"))&&(bt(n,"[[Value]]")||bt(n,"[[Writable]]")))throw new po("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},yl=G,u0=Yt,id=ai,h0=hu,d0=Vf,p0=jf,f0=li,g0=Gf,m0=c0,v0=function(e,n,r){if(!u0(e))throw new yl("Assertion failed: Type(O) is not Object");if(!f0(n))throw new yl("Assertion failed: P is not a Property Key");var i=id(r)?r:m0(r);if(!id(i))throw new yl("Assertion failed: Desc is not a valid Property Descriptor");return h0(p0,g0,d0,e,n,i)},sd=G,y0=Yt,b0=v0,w0=li,_0=function(e,n,r){if(!y0(e))throw new sd("Assertion failed: Type(O) is not Object");if(!w0(n))throw new sd("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return b0(e,n,i)},S0=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,k0=iu,x0=k0.setPrototypeOf||null,E0=Ra,od=si,$0=G,Yf={};try{Yf.__proto__=null}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var A0=!("toString"in Yf),bl=od&&od(Object.prototype,"__proto__"),T0=A0&&(!!bl&&typeof bl.set=="function"&&E0([bl.set])||function(e,n){if(e==null)throw new $0("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=n,n}),ad=S0,C0=x0,ld=T0,I0=G,P0=ad?function(e,n){if(ad(e,n))return e;throw new I0("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:C0||(ld?function(e,n){return ld(e,n),e}:null),cd=G,R0=Yt,ud=Uf,D0=function(e){if(!R0(e))throw new cd("Assertion failed: O must be an Object");if(!ud)throw new cd("This environment does not support fetching prototypes.");return ud(e)},O0=G,z0=P0,L0=Yt,M0=D0,N0=function(e,n){if(n!==null&&!L0(n))throw new O0("Assertion failed: V must be Object or Null");try{z0(e,n)}catch{return!1}return M0(e)===n},wl=du,hd=_0,Kf=N0,U0=Pa(),pu=Df;function Ws(t,e,n){var r=new pu(n);return Kf(r,Uo),delete r.constructor,hd(r,"error",t),hd(r,"suppressed",e),r}U0&&Object.defineProperty(Ws,"prototype",{writable:!1});var Uo=Ws.prototype;if(!wl(Uo,"constructor",Ws)||!wl(Uo,"message","")||!wl(Uo,"name","SuppressedError"))throw new pu("unable to install SuppressedError.prototype properties; please report this!");Kf(Ws.prototype,pu.prototype);var F0=Ws,Z0=F0,Jf=function(){return typeof SuppressedError=="function"?SuppressedError:Z0},H0=hr,dd=ru(),B0=Jf,V0=function(){var e=B0();return H0(dd,{SuppressedError:e},{SuppressedError:function(){return dd.SuppressedError!==e}}),e};V0();var j0=G,G0=ai,W0=Bf,q0=function(e){if(typeof e<"u"&&!G0(e))throw new j0("Assertion failed: `Desc` must be a Property Descriptor");return W0(e)},Y0=G,pd=Kt,K0=ai,J0=function(e){if(typeof e>"u")return!1;if(!K0(e))throw new Y0("Assertion failed: `Desc` must be a Property Descriptor");return!(!pd(e,"[[Value]]")&&!pd(e,"[[Writable]]"))},fd=ou,X0=function(e,n){return e===n?e===0?1/e===1/n:!0:fd(e)&&fd(n)},ci=qf,Q0=function(e){return!!e},wt=Kt,fo=G,e_=Yt,gd=ci,_l=Q0,t_=function(e){if(!e_(e))throw new fo("ToPropertyDescriptor requires an object");var n={};if(wt(e,"enumerable")&&(n["[[Enumerable]]"]=_l(e.enumerable)),wt(e,"configurable")&&(n["[[Configurable]]"]=_l(e.configurable)),wt(e,"value")&&(n["[[Value]]"]=e.value),wt(e,"writable")&&(n["[[Writable]]"]=_l(e.writable)),wt(e,"get")){var r=e.get;if(typeof r<"u"&&!gd(r))throw new fo("getter must be a function");n["[[Get]]"]=r}if(wt(e,"set")){var i=e.set;if(typeof i<"u"&&!gd(i))throw new fo("setter must be a function");n["[[Set]]"]=i}if((wt(n,"[[Get]]")||wt(n,"[[Set]]"))&&(wt(n,"[[Value]]")||wt(n,"[[Writable]]")))throw new fo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},Sl=G,n_=Yt,md=ai,r_=hu,i_=q0,s_=J0,o_=li,a_=X0,l_=t_,qs=function(e,n,r){if(!n_(e))throw new Sl("Assertion failed: Type(O) is not Object");if(!o_(n))throw new Sl("Assertion failed: P is not a Property Key");var i=md(r)?r:l_(r);if(!md(i))throw new Sl("Assertion failed: Desc is not a valid Property Descriptor");return r_(s_,a_,i_,e,n,i)},c_=oi(),u_=c_?Symbol.dispose||Symbol("Symbol.dispose"):null,h_=oi,d_=u_,fu=function(){return h_()&&Symbol.dispose||d_},p_=au,f_=qs,g_=fu,m_=function(){var e=g_();return p_()&&f_(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},v_=oi(),y_=v_?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,b_=oi,w_=y_,gu=function(){return b_()&&Symbol.asyncDispose||w_},__=au,S_=qs,k_=gu,x_=function(){var e=k_();return __()&&S_(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},E_=uu(),$_=st,A_=wn(),T_=G,C_=E_,I_=$_("%Reflect.apply%",!0)||A_("Function.prototype.apply"),Da=function(e,n){var r=arguments.length>2?arguments[2]:[];if(!C_(r))throw new T_("Assertion failed: optional `argumentsList`, if provided, must be a List");return I_(e,n,r)};const P_={},R_=Object.freeze(Object.defineProperty({__proto__:null,default:P_},Symbol.toStringTag,{value:"Module"})),D_=ib(R_);var mu=typeof Map=="function"&&Map.prototype,kl=Object.getOwnPropertyDescriptor&&mu?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Ko=mu&&kl&&typeof kl.get=="function"?kl.get:null,vd=mu&&Map.prototype.forEach,vu=typeof Set=="function"&&Set.prototype,xl=Object.getOwnPropertyDescriptor&&vu?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Jo=vu&&xl&&typeof xl.get=="function"?xl.get:null,yd=vu&&Set.prototype.forEach,O_=typeof WeakMap=="function"&&WeakMap.prototype,ji=O_?WeakMap.prototype.has:null,z_=typeof WeakSet=="function"&&WeakSet.prototype,Gi=z_?WeakSet.prototype.has:null,L_=typeof WeakRef=="function"&&WeakRef.prototype,bd=L_?WeakRef.prototype.deref:null,M_=Boolean.prototype.valueOf,N_=Object.prototype.toString,U_=Function.prototype.toString,F_=String.prototype.match,yu=String.prototype.slice,hn=String.prototype.replace,Z_=String.prototype.toUpperCase,wd=String.prototype.toLowerCase,Xf=RegExp.prototype.test,_d=Array.prototype.concat,Tt=Array.prototype.join,H_=Array.prototype.slice,Sd=Math.floor,oc=typeof BigInt=="function"?BigInt.prototype.valueOf:null,El=Object.getOwnPropertySymbols,ac=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,ei=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Wi=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===ei||!0)?Symbol.toStringTag:null,Qf=Object.prototype.propertyIsEnumerable,kd=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function xd(t,e){if(t===1/0||t===-1/0||t!==t||t&&t>-1e3&&t<1e3||Xf.call(/e/,e))return e;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof t=="number"){var r=t<0?-Sd(-t):Sd(t);if(r!==t){var i=String(r),s=yu.call(e,i.length+1);return hn.call(i,n,"$&_")+"."+hn.call(hn.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return hn.call(e,n,"$&_")}var lc=D_,Ed=lc.custom,$d=ng(Ed)?Ed:null,eg={__proto__:null,double:'"',single:"'"},B_={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},ui=function t(e,n,r,i){var s=n||{};if(Lt(s,"quoteStyle")&&!Lt(eg,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 ig(e,s);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var c=String(e);return a?xd(e,c):c}if(typeof e=="bigint"){var u=String(e)+"n";return a?xd(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 cc(e)?"[Array]":"[Object]";var p=aS(s,r);if(typeof i>"u")i=[];else if(rg(i,e)>=0)return"[Circular]";function y(mt,Xt,Ka){if(Xt&&(i=H_.call(i),i.push(Xt)),Ka){var ro={depth:s.depth};return Lt(s,"quoteStyle")&&(ro.quoteStyle=s.quoteStyle),t(mt,ro,r+1,i)}return t(mt,s,r+1,i)}if(typeof e=="function"&&!Ad(e)){var v=X_(e),$=go(e,y);return"[Function"+(v?": "+v:" (anonymous)")+"]"+($.length>0?" { "+Tt.call($,", ")+" }":"")}if(ng(e)){var k=ei?hn.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):ac.call(e);return typeof e=="object"&&!ei?ki(k):k}if(iS(e)){for(var I="<"+wd.call(String(e.nodeName)),B=e.attributes||[],P=0;P<B.length;P++)I+=" "+B[P].name+"="+tg(V_(B[P].value),"double",s);return I+=">",e.childNodes&&e.childNodes.length&&(I+="..."),I+="</"+wd.call(String(e.nodeName))+">",I}if(cc(e)){if(e.length===0)return"[]";var K=go(e,y);return p&&!oS(K)?"["+uc(K,p)+"]":"[ "+Tt.call(K,", ")+" ]"}if(G_(e)){var L=go(e,y);return!("cause"in Error.prototype)&&"cause"in e&&!Qf.call(e,"cause")?"{ ["+String(e)+"] "+Tt.call(_d.call("[cause]: "+y(e.cause),L),", ")+" }":L.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+Tt.call(L,", ")+" }"}if(typeof e=="object"&&o){if($d&&typeof e[$d]=="function"&&lc)return lc(e,{depth:d-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(Q_(e)){var Z=[];return vd&&vd.call(e,function(mt,Xt){Z.push(y(Xt,e,!0)+" => "+y(mt,e))}),Td("Map",Ko.call(e),Z,p)}if(nS(e)){var N=[];return yd&&yd.call(e,function(mt){N.push(y(mt,e))}),Td("Set",Jo.call(e),N,p)}if(eS(e))return $l("WeakMap");if(rS(e))return $l("WeakSet");if(tS(e))return $l("WeakRef");if(q_(e))return ki(y(Number(e)));if(K_(e))return ki(y(oc.call(e)));if(Y_(e))return ki(M_.call(e));if(W_(e))return ki(y(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof Pn<"u"&&e===Pn)return"{ [object globalThis] }";if(!j_(e)&&!Ad(e)){var ce=go(e,y),ue=kd?kd(e)===Object.prototype:e instanceof Object||e.constructor===Object,yi=e instanceof Object?"":"null prototype",no=!ue&&Wi&&Object(e)===e&&Wi in e?yu.call(_n(e),8,-1):yi?"Object":"",Ee=ue||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",xn=Ee+(no||yi?"["+Tt.call(_d.call([],no||[],yi||[]),": ")+"] ":"");return ce.length===0?xn+"{}":p?xn+"{"+uc(ce,p)+"}":xn+"{ "+Tt.call(ce,", ")+" }"}return String(e)};function tg(t,e,n){var r=n.quoteStyle||e,i=eg[r];return i+t+i}function V_(t){return hn.call(String(t),/"/g,"&quot;")}function dr(t){return!Wi||!(typeof t=="object"&&(Wi in t||typeof t[Wi]<"u"))}function cc(t){return _n(t)==="[object Array]"&&dr(t)}function j_(t){return _n(t)==="[object Date]"&&dr(t)}function Ad(t){return _n(t)==="[object RegExp]"&&dr(t)}function G_(t){return _n(t)==="[object Error]"&&dr(t)}function W_(t){return _n(t)==="[object String]"&&dr(t)}function q_(t){return _n(t)==="[object Number]"&&dr(t)}function Y_(t){return _n(t)==="[object Boolean]"&&dr(t)}function ng(t){if(ei)return t&&typeof t=="object"&&t instanceof Symbol;if(typeof t=="symbol")return!0;if(!t||typeof t!="object"||!ac)return!1;try{return ac.call(t),!0}catch{}return!1}function K_(t){if(!t||typeof t!="object"||!oc)return!1;try{return oc.call(t),!0}catch{}return!1}var J_=Object.prototype.hasOwnProperty||function(t){return t in this};function Lt(t,e){return J_.call(t,e)}function _n(t){return N_.call(t)}function X_(t){if(t.name)return t.name;var e=F_.call(U_.call(t),/^function\s*([\w$]+)/);return e?e[1]:null}function rg(t,e){if(t.indexOf)return t.indexOf(e);for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1}function Q_(t){if(!Ko||!t||typeof t!="object")return!1;try{Ko.call(t);try{Jo.call(t)}catch{return!0}return t instanceof Map}catch{}return!1}function eS(t){if(!ji||!t||typeof t!="object")return!1;try{ji.call(t,ji);try{Gi.call(t,Gi)}catch{return!0}return t instanceof WeakMap}catch{}return!1}function tS(t){if(!bd||!t||typeof t!="object")return!1;try{return bd.call(t),!0}catch{}return!1}function nS(t){if(!Jo||!t||typeof t!="object")return!1;try{Jo.call(t);try{Ko.call(t)}catch{return!0}return t instanceof Set}catch{}return!1}function rS(t){if(!Gi||!t||typeof t!="object")return!1;try{Gi.call(t,Gi);try{ji.call(t,ji)}catch{return!0}return t instanceof WeakSet}catch{}return!1}function iS(t){return!t||typeof t!="object"?!1:typeof HTMLElement<"u"&&t instanceof HTMLElement?!0:typeof t.nodeName=="string"&&typeof t.getAttribute=="function"}function ig(t,e){if(t.length>e.maxStringLength){var n=t.length-e.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return ig(yu.call(t,0,e.maxStringLength),e)+r}var i=B_[e.quoteStyle||"single"];i.lastIndex=0;var s=hn.call(hn.call(t,i,"\\$1"),/[\x00-\x1f]/g,sS);return tg(s,"single",e)}function sS(t){var e=t.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return n?"\\"+n:"\\x"+(e<16?"0":"")+Z_.call(e.toString(16))}function ki(t){return"Object("+t+")"}function $l(t){return t+" { ? }"}function Td(t,e,n,r){var i=r?uc(n,r):Tt.call(n,", ");return t+" ("+e+") {"+i+"}"}function oS(t){for(var e=0;e<t.length;e++)if(rg(t[e],`
2
+ `)>=0)return!1;return!0}function aS(t,e){var n;if(t.indent===" ")n=" ";else if(typeof t.indent=="number"&&t.indent>0)n=Tt.call(Array(t.indent+1)," ");else return null;return{base:n,prev:Tt.call(Array(e+1),n)}}function uc(t,e){if(t.length===0)return"";var n=`
3
+ `+e.prev+e.base;return n+Tt.call(t,","+n)+`
4
+ `+e.prev}function go(t,e){var n=cc(t),r=[];if(n){r.length=t.length;for(var i=0;i<t.length;i++)r[i]=Lt(t,i)?e(t[i],t):""}var s=typeof El=="function"?El(t):[],o;if(ei){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in t)Lt(t,c)&&(n&&String(Number(c))===c&&c<t.length||ei&&o["$"+c]instanceof Symbol||(Xf.call(/[^\w$]/,c)?r.push(e(c,t)+": "+e(t[c],t)):r.push(c+": "+e(t[c],t))));if(typeof El=="function")for(var u=0;u<s.length;u++)Qf.call(t,s[u])&&r.push("["+e(s[u])+"]: "+e(t[s[u]],t));return r}var lS=ui,cS=G,Oa=function(t,e,n){for(var r=t,i;(i=r.next)!=null;r=i)if(i.key===e)return r.next=i.next,n||(i.next=t.next,t.next=i),i},uS=function(t,e){if(t){var n=Oa(t,e);return n&&n.value}},hS=function(t,e,n){var r=Oa(t,e);r?r.value=n:t.next={key:e,next:t.next,value:n}},dS=function(t,e){return t?!!Oa(t,e):!1},pS=function(t,e){if(t)return Oa(t,e,!0)},fS=function(){var e,n={assert:function(r){if(!n.has(r))throw new cS("Side channel does not contain "+lS(r))},delete:function(r){var i=e&&e.next,s=pS(e,r);return s&&i&&i===s&&(e=void 0),!!s},get:function(r){return uS(e,r)},has:function(r){return dS(e,r)},set:function(r,i){e||(e={next:void 0}),hS(e,r,i)}};return n},gS=st,Ys=wn(),mS=ui,vS=G,Cd=gS("%Map%",!0),yS=Ys("Map.prototype.get",!0),bS=Ys("Map.prototype.set",!0),wS=Ys("Map.prototype.has",!0),_S=Ys("Map.prototype.delete",!0),SS=Ys("Map.prototype.size",!0),sg=!!Cd&&function(){var e,n={assert:function(r){if(!n.has(r))throw new vS("Side channel does not contain "+mS(r))},delete:function(r){if(e){var i=_S(e,r);return SS(e)===0&&(e=void 0),i}return!1},get:function(r){if(e)return yS(e,r)},has:function(r){return e?wS(e,r):!1},set:function(r,i){e||(e=new Cd),bS(e,r,i)}};return n},kS=st,za=wn(),xS=ui,mo=sg,ES=G,kr=kS("%WeakMap%",!0),$S=za("WeakMap.prototype.get",!0),AS=za("WeakMap.prototype.set",!0),TS=za("WeakMap.prototype.has",!0),CS=za("WeakMap.prototype.delete",!0),IS=kr?function(){var e,n,r={assert:function(i){if(!r.has(i))throw new ES("Side channel does not contain "+xS(i))},delete:function(i){if(kr&&i&&(typeof i=="object"||typeof i=="function")){if(e)return CS(e,i)}else if(mo&&n)return n.delete(i);return!1},get:function(i){return kr&&i&&(typeof i=="object"||typeof i=="function")&&e?$S(e,i):n&&n.get(i)},has:function(i){return kr&&i&&(typeof i=="object"||typeof i=="function")&&e?TS(e,i):!!n&&n.has(i)},set:function(i,s){kr&&i&&(typeof i=="object"||typeof i=="function")?(e||(e=new kr),AS(e,i,s)):mo&&(n||(n=mo()),n.set(i,s))}};return r}:mo,PS=G,RS=ui,DS=fS,OS=sg,zS=IS,LS=zS||OS||DS,MS=function(){var e,n={assert:function(r){if(!n.has(r))throw new PS("Side channel does not contain "+RS(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=LS()),e.set(r,i)}};return n},NS=Kt,xi=MS(),Dt=G,bu={assert:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new Dt("`O` is not an object");if(typeof e!="string")throw new Dt("`slot` must be a string");if(xi.assert(t),!bu.has(t,e))throw new Dt("`"+e+"` is not present on `O`")},get:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new Dt("`O` is not an object");if(typeof e!="string")throw new Dt("`slot` must be a string");var n=xi.get(t);return n&&n["$"+e]},has:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new Dt("`O` is not an object");if(typeof e!="string")throw new Dt("`slot` must be a string");var n=xi.get(t);return!!n&&NS(n,"$"+e)},set:function(t,e,n){if(!t||typeof t!="object"&&typeof t!="function")throw new Dt("`O` is not an object");if(typeof e!="string")throw new Dt("`slot` must be a string");var r=xi.get(t);r||(r={},xi.set(t,r)),r["$"+e]=n}};Object.freeze&&Object.freeze(bu);var wu=bu,og=qt,dn=wu,Ks=function t(e,n){if(!(this instanceof t))return new t(e,n);if(e!=="normal"&&e!=="break"&&e!=="continue"&&e!=="return"&&e!=="throw")throw new og('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');dn.set(this,"[[Type]]",e),dn.set(this,"[[Value]]",n)};Ks.prototype.type=function(){return dn.get(this,"[[Type]]")};Ks.prototype.value=function(){return dn.get(this,"[[Value]]")};Ks.prototype["?"]=function(){var e=dn.get(this,"[[Type]]"),n=dn.get(this,"[[Value]]");if(e==="throw")throw n;return n};Ks.prototype["!"]=function(){var e=dn.get(this,"[[Type]]");if(e!=="normal")throw new og('Assertion failed: Completion Record is not of type "normal"');return dn.get(this,"[[Value]]")};var _u=Ks,US=_u,Su=function(e){return new US("normal",e)},Al,Id;function FS(){if(Id)return Al;Id=1;var t=oi;return Al=function(){return t()&&!!Symbol.toStringTag},Al}var ZS=st,Pd=ZS("%Object.defineProperty%",!0),HS=FS()(),BS=Kt,VS=G,vo=HS?Symbol.toStringTag:null,ag=function(e,n){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 VS("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");vo&&(r||!BS(e,vo))&&(Pd?Pd(e,vo,{configurable:!i,enumerable:!1,value:n,writable:!1}):e[vo]=n)},lg={exports:{}},jS=st,Rd=Ef,GS=Pa(),Dd=si,Od=G,WS=jS("%Math.floor%"),qS=function(e,n){if(typeof e!="function")throw new Od("`fn` is not a function");if(typeof n!="number"||n<0||n>4294967295||WS(n)!==n)throw new Od("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in e&&Dd){var o=Dd(e,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!r)&&(GS?Rd(e,"length",n,!0,!0):Rd(e,"length",n)),e},YS=Vs,KS=cu,JS=Lf,XS=function(){return JS(YS,KS,arguments)};(function(t){var e=qS,n=Bs,r=Ra,i=XS;t.exports=function(o){var a=r(arguments),c=1+o.length-(arguments.length-1);return e(a,c>0?c:0,!0)},n?n(t.exports,"apply",{value:i}):t.exports.apply=i})(lg);var ku=lg.exports,QS=function(e,n){for(var r=0;r<e.length;r+=1)if(!n(e[r],r,e))return!1;return!0},ek=Object,tk=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||ek(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},nk=Kt,rk=uu(),ik=QS,sk=tk,ok=function(e){return e&&typeof e=="object"&&nk(e,"[[DisposableResourceStack]]")&&rk(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||ik(e["[[DisposableResourceStack]]"],sk))},ak=Yt,lk=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(ak(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},ck=lk,xu=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":ck(e)},uk=G,hk=ui,dk=li,pk=function(e,n){if(!dk(n))throw new uk("Assertion failed: P is not a Property Key, got "+hk(n));return e[n]},zd=G,fk=pk,gk=ci,mk=li,Ld=ui,vk=function(e,n){if(!mk(n))throw new zd("Assertion failed: P is not a Property Key");var r=fk(e,n);if(r!=null){if(!gk(r))throw new zd(Ld(n)+" is not a function: "+Ld(r));return r}},hc={exports:{}},yk=st,bk=yk,Md=bk("%Reflect.construct%",!0),Xo=qs;try{Xo({},"",{"[[Get]]":function(){}})}catch{Xo=null}if(Xo&&Md){var Nd={},Ud={};Xo(Ud,"length",{"[[Get]]":function(){throw Nd},"[[Enumerable]]":!0}),hc.exports=function(e){try{Md(e,Ud)}catch(n){return n===Nd}}}else hc.exports=function(e){return typeof e=="function"&&!!e.prototype};var wk=hc.exports,Tl=G,Fd=ci,_k=wk,Sk=function(e){if(!_k(e))throw new Tl("C must be a constructor");var n={"[[Resolve]]":void 0,"[[Reject]]":void 0},r=new e(function(i,s){if(typeof n["[[Resolve]]"]<"u"||typeof n["[[Reject]]"]<"u")throw new Tl("executor has already been called");n["[[Resolve]]"]=i,n["[[Reject]]"]=s});if(!Fd(n["[[Resolve]]"])||!Fd(n["[[Reject]]"]))throw new Tl("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":n["[[Resolve]]"],"[[Reject]]":n["[[Reject]]"]}},Zd=qt,kk=G,Cl=Da,Hd=vk,xk=Sk,Ek=xu,Bd=fu(),Vd=gu(),$k=function(e,n){if(Ek(e)!=="Object")throw new kk("`V` must be an Object");if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new Zd("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(n==="ASYNC-DISPOSE"&&Vd&&(r=Hd(e,Vd)),!r){if(!Bd)throw new Zd("`Symbol.dispose` is not supported");if(r=Hd(e,Bd),typeof r<"u")return function(){var i=this;if(n==="ASYNC-DISPOSE"){var s=xk(Promise);try{Cl(r,i),Cl(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}Cl(r,i)}}return r},Ak=qt,Il=G,Tk=ci,Ck=xu,Ik=$k,Pk=function(e,n){if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new Ak("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"&&Ck(e)!=="Object")throw new Il("`V` must be an Object, or `null` or `undefined`");if(r=Ik(e,n),typeof r>"u")throw new Il("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!Tk(r))throw new Il("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":n,"[[DisposeMethod]]":r}},Rk=qt,yo=G,Dk=ok,jd=Pk,Ok=wn(),zk=Ok("Array.prototype.push"),cg=function(e,n,r){if(!Dk(e))throw new yo("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new Rk("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(n==null&&r==="SYNC_DISPOSE")return"UNUSED";s=jd(n,r)}else{if(typeof n<"u")throw new yo("Assertion failed: `V` must be undefined when `method` is present");s=jd(void 0,r,i)}return zk(e["[[DisposableResourceStack]]"],s),"UNUSED"},Pl,Gd;function Eu(){if(Gd)return Pl;Gd=1;var t=st,e=ku,n=qt,r=t("%Promise.resolve%",!0),i=r&&e(r);return Pl=function(o,a){if(!i)throw new n("This environment does not support Promises.");return i(o,a)},Pl}var Rl,Wd;function Lk(){if(Wd)return Rl;Wd=1;var t=st,e=qt,n=t("%Promise%",!0),r=Da,i=Eu(),s=xu;return Rl=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(n,d)},Rl}var Dl,qd;function Mk(){if(qd)return Dl;qd=1;var t=_u;return Dl=function(n){return new t("throw",n)},Dl}var Nk=st,Ol=qt,Yd=G,Uk=Nk("%Promise%",!0),Fk=wn(),Kd=Fk("Promise.prototype.then",!0),Zk=_u,Jd=Lk(),Hk=Su,Bk=Eu(),Xd=Mk(),Vk=Jf(),ug=function(e,n){if(!(n instanceof Zk))throw new Yd("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new Yd("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 Ol("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&Bk(Uk,n),a=function(y){if(n.type()==="throw"){var v=n.value(),$=new Vk(y,v);n=Xd($)}else n=Xd(y)},c=i==="ASYNC-DISPOSE"&&function(v){return Kd(o,function(){var $=Jd(v["[[ResourceValue]]"],v["[[Hint]]"],v["[[DisposeMethod]]"]);if(!$)throw new Ol("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return Kd($,Hk)},a)},u=r.length-1;u>=0;u-=1)if(i==="ASYNC-DISPOSE")o=c(r[u]);else{var d=r[u];try{var p=Jd(d["[[ResourceValue]]"],d["[[Hint]]"],d["[[DisposeMethod]]"]);if(p)throw new Ol("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(y){a(y)}}return e["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:n},hg=function(){var e=[];return{"[[DisposableResourceStack]]":e}},La=su,$u=G,jk=Da,hi=du,Gk=qs,dg=ci,Wk=Su,Ve=wu,qk=ag,pg=hr.supportsDescriptors,Yk=ku,Au=cg,Kk=ug,fg=hg,Qd=fu(),nt=function t(){if(!(this instanceof t)||Ve.has(this,"[[DisposableState]]")||Ve.has(this,"[[DisposeCapability]]"))throw new $u("can only be used with new");Ve.set(this,"[[DisposableState]]","PENDING"),Ve.set(this,"[[DisposeCapability]]",fg())},gg=function(){var e=this;return Ve.assert(e,"[[DisposableState]]"),Ve.get(e,"[[DisposableState]]")==="DISPOSED"},Js=Yk(gg);pg?Gk(nt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":gg}):nt.prototype.disposed=!1;var mg=function(e){Ve.set(e,"[[DisposableState]]","DISPOSED"),pg||(e.disposed=!0)};hi(nt.prototype,"dispose",function(){var e=this;if(!Js(e))return mg(e),Kk(Ve.get(e,"[[DisposeCapability]]"),Wk())["?"]()});hi(nt.prototype,"use",function(e){var n=this;if(Js(n))throw new La("a disposed stack can not use anything new");return Au(Ve.get(n,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});hi(nt.prototype,"adopt",function(e,n){var r=this;if(Js(r))throw new La("a disposed stack can not use anything new");if(!dg(n))throw new $u("`onDispose` must be a function");var i=function(){return jk(n,void 0,[e])};return Au(Ve.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),e});hi(nt.prototype,"defer",function(e){var n=this;if(Js(n))throw new La("a disposed stack can not defer anything new");if(!dg(e))throw new $u("`onDispose` must be a function");Au(Ve.get(n,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});hi(nt.prototype,"move",function(){var e=this;if(Js(e))throw new La("a disposed stack can not use anything new");var n=new nt;return Ve.set(n,"[[DisposeCapability]]",Ve.get(e,"[[DisposeCapability]]")),Ve.set(e,"[[DisposeCapability]]",fg()),mg(e),n});Qd&&hi(nt.prototype,Qd,nt.prototype.dispose);qk(nt.prototype,"DisposableStack");var Jk=nt,Xk=Jk,Qk=function(){return typeof DisposableStack=="function"?DisposableStack:Xk},ex=hr,tx=ru(),nx=Qk,rx=function(){var e=nx();return ex(tx,{DisposableStack:e},{DisposableStack:!0}),e},ix=st,Ma=su,Tu=G,ep=ix("%Promise%",!0),Cu=cg,sx=Da,di=du,ox=qs,ax=ug,vg=ci,yg=hg,lx=Su,tp=Eu(),je=wu,cx=ag,bg=hr.supportsDescriptors,ux=ku,hx=wn(),dx=hx("Promise.prototype.then",!0),np=gu(),rt=function t(){if(!(this instanceof t)||je.has(this,"[[AsyncDisposableState]]")||je.has(this,"[[DisposeCapability]]"))throw new Tu("can only be used with new");je.set(this,"[[AsyncDisposableState]]","pending"),je.set(this,"[[DisposeCapability]]",yg())},wg=function(){var e=this;return je.assert(e,"[[AsyncDisposableState]]"),je.get(e,"[[AsyncDisposableState]]")==="disposed"},Xs=ux(wg);bg?ox(rt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":wg}):rt.prototype.disposed=!1;var _g=function(e){je.set(e,"[[AsyncDisposableState]]","disposed"),bg||(e.disposed=!0)};di(rt.prototype,"disposeAsync",function(){var e=this;return Xs(e)?tp(ep):(_g(e),dx(tp(ep,ax(je.get(e,"[[DisposeCapability]]"),lx())),function(n){return n["?"]()}))});di(rt.prototype,"use",function(e){var n=this;if(Xs(n))throw new Ma("a disposed stack can not use anything new");return Cu(je.get(n,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});di(rt.prototype,"adopt",function(e,n){var r=this;if(Xs(r))throw new Ma("a disposed stack can not use anything new");if(!vg(n))throw new Tu("`onDisposeAsync` must be a function");var i=function(){return sx(n,void 0,[e])};return i.value=e,Cu(je.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),e});di(rt.prototype,"defer",function(e){var n=this;if(Xs(n))throw new Ma("a disposed stack can not defer anything new");if(!vg(e))throw new Tu("`onDispose` must be a function");Cu(je.get(n,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});di(rt.prototype,"move",function(){var e=this;if(Xs(e))throw new Ma("a disposed stack can not use anything new");var n=new rt;return je.set(n,"[[DisposeCapability]]",je.get(e,"[[DisposeCapability]]")),je.set(e,"[[DisposeCapability]]",yg()),_g(e),n});np&&di(rt.prototype,np,rt.prototype.disposeAsync);cx(rt.prototype,"AsyncDisposableStack");var px=rt,fx=px,gx=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:fx},mx=hr,vx=ru(),yx=gx,bx=function(){var e=yx();return mx(vx,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},wx=m_,_x=x_,Sx=rx,kx=bx,xx=function(){wx(),_x(),Sx(),kx()};xx();const rp=new WeakMap;function Ex(t){return(typeof t=="object"||typeof t=="function")&&t!==null&&"then"in t&&typeof t.then=="function"}function xr(t){return typeof t=="string"?t:typeof t=="symbol"?t.description??t.toString():t.name||"(anonymous class)"}function ip(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function $x(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class Ax{constructor(){b(this,"entries",new Map);b(this,"constructionStack",[])}register(e,n){if(n===void 0){if(typeof e!="function")throw ip();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof n!="function")throw ip();if(n.constructor.name==="AsyncFunction")throw $x();this.storeFactory(e,n)}has(e){var n;return((n=this.entries.get(e))==null?void 0:n.factory)!==void 0}resolve(e){return this.resolveAny(e)}storeFactory(e,n){const r=this.getOrCreateEntry(e);r.factory=n,r.instance=void 0,r.error=void 0}validateClassRegistration(e){const n=rp.get(e);if(n){if(e.length!==n.length)throw new Error(`${xr(e)} cannot be registered with register(Class). @injectable(...) declared ${n.length} dependencies but constructor arity is ${e.length}. Use register(Key, () => value) instead.`);return}if(e.length!==0)throw new Error(`${xr(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const n=rp.get(e);if(!n)return new e;const r=n.map(i=>this.resolveAny(i));return new e(...r)}resolveAny(e){return this.getOrCreateEntry(e).proxy}getOrCreateEntry(e){let n=this.entries.get(e);return n||(n={key:e},n.proxy=this.createProxy(n),this.entries.set(e,n),n)}createProxy(e){return new Proxy({},{get:(n,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:(n,r,i)=>{const s=this.getInstance(e);return Reflect.set(s,r,i,s)},has:(n,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(`${xr(e.key)} was resolved but never registered`);const n=this.constructionStack.indexOf(e.key);if(n!==-1){const r=[...this.constructionStack.slice(n),e.key].map(i=>xr(i)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(e.key);try{const r=e.factory();if(Ex(r))throw new Error(`Factory for ${xr(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${xr(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 Ax,Tx=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function Cx(t){for(const e of Object.keys(t))if(Tx.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function Ix(t,e){Cx(e);for(const n of Object.keys(e))Object.defineProperty(t,n,{value:e[n],writable:!0,enumerable:!0,configurable:!0})}function ft(){class t extends Event{constructor(n,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(n,{bubbles:s,cancelable:o,composed:a}),Ix(this,c)}}return t}class gt extends globalThis.EventTarget{}function Px(t,e,n){const r=t.dispose.bind(t);t.dispose=()=>{if(!e())return n(),r()}}function pi(t){var n;class e extends t{constructor(...s){super(...s);_(this,n,!1);Px(this,()=>l(this,n),()=>{x(this,n,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return l(this,n)}}return n=new WeakMap,e}const Rx=ft(),Dx=ft(),Fo=ft(),Sg="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Qo=32,Ox=16,kg=10,sp=0xffffffffffff;var Ln;(function(t){t.Base32IncorrectEncoding="B32_ENC_INVALID",t.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",t.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",t.EncodeTimeNegative="ENC_TIME_NEG",t.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",t.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",t.PRNGDetectFailure="PRNG_DETECT",t.ULIDInvalid="ULID_INVALID",t.Unexpected="UNEXPECTED",t.UUIDInvalid="UUID_INVALID"})(Ln||(Ln={}));class zi extends Error{constructor(e,n){super(`${n} (${e})`),this.name="ULIDError",this.code=e}}function zx(t){const e=Math.floor(t()*Qo)%Qo;return Sg.charAt(e)}function Lx(t){const e=Mx(),n=e&&(e.crypto||e.msCrypto)||null;if(typeof(n==null?void 0:n.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return n.getRandomValues(r),r[0]/256};if(typeof(n==null?void 0:n.randomBytes)=="function")return()=>n.randomBytes(1).readUInt8()/256;throw new zi(Ln.PRNGDetectFailure,"Failed to find a reliable PRNG")}function Mx(){return Fx()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function Nx(t,e){let n="";for(;t>0;t--)n=zx(e)+n;return n}function Ux(t,e=kg){if(isNaN(t))throw new zi(Ln.EncodeTimeValueMalformed,`Time must be a number: ${t}`);if(t>sp)throw new zi(Ln.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${sp}: ${t}`);if(t<0)throw new zi(Ln.EncodeTimeNegative,`Time must be positive: ${t}`);if(Number.isInteger(t)===!1)throw new zi(Ln.EncodeTimeValueMalformed,`Time must be an integer: ${t}`);let n,r="";for(let i=e;i>0;i--)n=t%Qo,r=Sg.charAt(n)+r,t=(t-n)/Qo;return r}function Fx(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Iu(t,e){const n=Lx(),r=Date.now();return Ux(r,kg)+Nx(Ox,n)}const Ct=4,Xe=6,xg=2,dc=2,Zx=Ct,Hx=Xe,Pu="auto",pn="auto",Rn=120,op=75,ge=16,sr=Rn*Ct+ge*(Ct-1),ea=Rn*Xe+ge*(Xe-1),Bx=200,Vx=4,bo=150,jx=10,ap=2,Gx=4;function Eg(t){return Tg(t)}function $g(t,e){return Tg(t.flatMap(n=>Ig(n,e)))}function Ag(t){const e=[],n=new Set;for(const r of t){if(r.type==="row"){e.push(`Top-level rows are invalid: ${r.id}`);continue}Pg(r,"strip",e,n)}return{valid:e.length===0,errors:e}}function qi(t){const e=Eg(t),n=Ag(e);if(!n.valid)throw new Error(`Invalid layout: ${n.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(Kx)}}function Tg(t){const e=[];for(const n of t){const r=Cg(n);for(const i of r){if(i.type==="row"){e.push(...i.children.map(Gt));continue}e.push(i)}}return e}function Cg(t){switch(t.type){case"card":return[Gt(t)];case"row":{const e=t.children.map(Gt);return e.length===0?[]:e.length===1?[e[0]]:[{...t,children:e}]}case"stack":{const e=[];for(const n of t.children){const r=Cg(n);for(const i of r){if(i.type==="stack"){e.push(...i.children.map(pc));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?[pc(e[0])]:[{...t,children:e}]}}}function Ig(t,e){switch(t.type){case"card":return t.artifactID===e?[]:[Gt(t)];case"row":{const n=t.children.filter(r=>r.artifactID!==e).map(Gt);return n.length===0?[]:n.length===1?[n[0]]:[{...t,children:n}]}case"stack":{const n=t.children.flatMap(r=>Ig(r,e).filter(s=>s.type!=="stack"));return n.length===0?[]:n.length===1?[pc(n[0])]:[{...t,children:n}]}}}function Pg(t,e,n,r){switch(t.type){case"card":Rg(t,e,n,r);return;case"row":Wx(t,e,n,r);return;case"stack":qx(t,e,n,r);return}}function Rg(t,e,n,r){Ru(t.id,n),typeof t.artifactID!="string"||t.artifactID.length===0?n.push(`Card ${t.id} is missing artifactID`):r.has(t.artifactID)?n.push(`Duplicate artifactID in layout: ${t.artifactID}`):r.add(t.artifactID),Yx(t.width)||n.push(`Card ${t.id} width must be an integer in the range 2-4`),Dg(t.height)||n.push(`Card ${t.id} height must be an integer in the range 2-6 or "auto"`);const i=Dn(t.width);e==="row"&&i<xg&&n.push(`Row child ${t.id} must be at least 2 columns wide`)}function Wx(t,e,n,r){if(Ru(t.id,n),e!=="stack"&&n.push(`Row ${t.id} may only appear inside a stack`),Dg(t.height,Gx)||n.push(`Row ${t.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(t.children)||t.children.length===0){n.push(`Row ${t.id} must contain card nodes`);return}let i=0;for(const s of t.children){if(s.type!=="card"){n.push(`Row ${t.id} must contain only card nodes`);continue}Rg(s,"row",n,r),i+=Dn(s.width)}i!==Ct&&n.push(`Row ${t.id} children must sum to 4 columns`)}function qx(t,e,n,r){if(Ru(t.id,n),e!=="strip"&&n.push(`Invalid nested stack at ${t.id}; stack children cannot contain another nested stack`),!Array.isArray(t.children)||t.children.length===0){n.push(`Stack ${t.id} must contain at least one child`);return}let i=0,s=0;for(const a of t.children){if(a.type==="stack"){n.push(`Stack ${t.id} cannot contain another nested stack`);continue}if(Pg(a,"stack",n,r),a.height===pn){s+=1;continue}i+=a.height}if(i>Xe&&n.push(`Stack ${t.id} exceeds the 6-row budget`),s===0)return;const o=Xe-i;if(o<s*dc||o%s!==0){n.push(`Stack ${t.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<dc&&n.push(`Stack ${t.id} has auto-height children below the minimum row size`)}function Ru(t,e){(typeof t!="string"||t.length===0)&&e.push(`Node id must be a non-empty string: ${String(t)}`)}function Yx(t){return t===Pu||Number.isInteger(t)&&t>=xg&&t<=Zx}function Dg(t,e=Hx){return t===pn||Number.isInteger(t)&&t>=dc&&t<=e}function Dn(t){return t===Pu?Ct:t}function Kx(t){if(t.type==="card")return{id:t.id,type:"card",width:Dn(t.width),cards:[{id:t.id,artifactID:t.artifactID,col:1,row:1,width:Dn(t.width),height:Og(t.height,Xe)}]};const e=Jx(t.children),n=[];let r=1;for(let i=0;i<t.children.length;i+=1){const s=t.children[i],o=e[i];if(s.type==="card")n.push({id:s.id,artifactID:s.artifactID,col:1,row:r,width:Dn(s.width),height:o});else{let a=1;for(const c of s.children)n.push({id:c.id,artifactID:c.artifactID,col:a,row:r,width:Dn(c.width),height:o}),a+=Dn(c.width)}r+=o}return{id:t.id,type:"stack",width:n.reduce((i,s)=>Math.max(i,s.col+s.width-1),1),cards:n}}function Jx(t){let e=0,n=0;for(const i of t)i.height===pn?n+=1:e+=i.height;const r=n>0?(Xe-e)/n:0;return t.map(i=>Og(i.height,r))}function Og(t,e){return t===pn?e:t}function Gt(t){return{...t}}function pc(t){return t.type==="card"?Gt(t):{...t,children:t.children.map(Gt)}}function zg(t,e={}){return{id:e.id??Iu(),type:"card",artifactID:t,width:e.width??Pu,height:e.height??pn}}function Lg(t,e){return t.some(n=>Mg(n,e))}function Mg(t,e){switch(t.type){case"card":return t.artifactID===e;case"row":return t.children.some(n=>n.artifactID===e);case"stack":return t.children.some(n=>Mg(n,e))}}function lp(t){return t.layout.flatMap(Ng)}function Ng(t){switch(t.type){case"card":return[t.artifactID];case"row":return t.children.map(e=>e.artifactID);case"stack":return t.children.flatMap(Ng)}}const ee=ft(),Ug=ft(),Ei=ft(),Xx=ft();function Qx(t){class e extends Error{constructor(r,i){super(r),this.name=t,i&&Object.assign(this,i)}}return e}const eE=Qx("RequestError"),tE=200,nE=300;class rE{constructor(e,n){b(this,"serverURL");b(this,"token");this.serverURL=e.replace(/\/$/,""),this.token=n.token}async requestJSON(e,n,r){const i=await this.request(e,n,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),s=await iE(i);if(!i.ok||i.status<tE||i.status>=nE)throw this.createError(typeof s.error=="string"?s.error:i.statusText,i.status);return s}async requestVoid(e,n){const r=await this.request(e,n);if(!r.ok)throw this.createError(await zl(r,r.statusText),r.status)}async requestText(e,n){const r=await this.request(e,n);if(!r.ok)throw this.createError(await zl(r,r.statusText),r.status);return r.text()}async requestRawVoid(e,n,r){const i=await this.request(e,n,r,{"content-type":"text/plain"});if(!i.ok)throw this.createError(await zl(i,i.statusText),i.status)}createError(e,n){const r={serverURL:this.serverURL};return n!==void 0&&(r.status=n),new eE(e,r)}async request(e,n,r,i){const s=`${this.serverURL}${n}`;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 n={...e??{}};return this.token&&(n.Authorization=`Bearer ${this.token}`),Object.keys(n).length>0?n:void 0}}async function iE(t){try{return await t.json()}catch{const e=await t.text().catch(()=>"");return e?{message:e}:{}}}async function zl(t,e){try{const n=await t.json();if(typeof n.error=="string")return n.error;if(typeof n.message=="string")return n.message}catch{}return e}function Fg(t){return t.map(e=>`${e.name} (${e.id})`).join(", ")}var xt,da,Zg;class sE{constructor(e){_(this,da);_(this,xt);x(this,xt,e)}list(){return l(this,xt).requestJSON("GET","/screens")}async get(e={}){const n=await m(this,da,Zg).call(this,e.screenID);return l(this,xt).requestJSON("GET",`/screens/${encodeURIComponent(n)}`)}create(e){const n={name:e.name};return e.id!==void 0&&(n.id=e.id),l(this,xt).requestJSON("POST","/screens",n)}update(e){const n={};return e.name!==void 0&&(n.name=e.name),e.layout!==void 0&&(n.layout=e.layout),l(this,xt).requestJSON("PATCH",`/screens/${encodeURIComponent(e.screenID)}`,n)}remove(e){return l(this,xt).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}xt=new WeakMap,da=new WeakSet,Zg=async function(e){if(e!==void 0)return e;const{screens:n}=await this.list();if(n.length===1)return n[0].id;throw l(this,xt).createError(`screenID is required when multiple screens exist. Available screens: ${Fg(n)}`)};var Ze,rs,pa,Hg;class oE{constructor(e,n){_(this,pa);_(this,Ze);_(this,rs);x(this,Ze,e),x(this,rs,n)}async create(e){const n=await m(this,pa,Hg).call(this,e.screenID);return l(this,Ze).requestJSON("POST",`/screens/${encodeURIComponent(n)}/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 n={};return e.title!==void 0&&(n.title=e.title),l(this,Ze).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,n)}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,rs=new WeakMap,pa=new WeakSet,Hg=async function(e){if(e!==void 0)return e;const{screens:n}=await l(this,rs).list();if(n.length===1)return n[0].id;throw l(this,Ze).createError(`screenID is required when multiple screens exist. Available screens: ${Fg(n)}`)};var is;class aE{constructor(e){_(this,is);x(this,is,e)}async list(){const{views:e}=await l(this,is).requestJSON("GET","/views");return e}}is=new WeakMap;var tn;class lE{constructor(e,n={}){b(this,"screens");b(this,"artifacts");b(this,"views");_(this,tn);x(this,tn,new rE(e,n)),this.screens=new sE(l(this,tn)),this.artifacts=new oE(l(this,tn),this.screens),this.views=new aE(l(this,tn))}health(){return l(this,tn).requestJSON("GET","/health")}}tn=new WeakMap;const cE={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},uE=pi(gt);var Un,He,Fn,Le,nn,rn,X,$r,Bg,ss,Vg,jg,Gg,Wg,fc,gc,mc,qg;class hE extends uE{constructor(n){var i;super();_(this,X);b(this,"id");b(this,"server");_(this,Un);_(this,He,new Map);_(this,Fn);_(this,Le);_(this,nn);_(this,rn,null);_(this,ss,n=>{if(this.disposed)return;const r=n.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&m(this,X,Vg).call(this,r.screen);break;case"artifact-created":r.screenID===this.id&&m(this,X,jg).call(this,r.artifact);break;case"artifact-updated":m(this,X,Gg).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&m(this,X,Wg).call(this,r.artifactID);break;case"artifact-content-changed":l(this,He).has(r.artifactID)&&this.dispatchEvent(new Xx("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=n.screen.id,this.server=n.server,x(this,Un,n.localStore),x(this,Fn,n.screen.name),x(this,Le,structuredClone(n.screen.layout));const r=((i=l(this,Un).get().screens[this.id])==null?void 0:i.scrollPosition)??0;x(this,nn,Math.max(0,r)),this.server.addEventListener("server-event",l(this,ss)),m(this,X,Bg).call(this)}get name(){return l(this,Fn)}get layout(){return l(this,Le)}get scrollPosition(){return l(this,nn)}get artifacts(){return l(this,He)}setScrollPosition(n){m(this,X,$r).call(this);const r=Math.max(0,n);r!==l(this,nn)&&(x(this,nn,r),m(this,X,qg).call(this),this.dispatchEvent(new ee("change")))}setLayout(n){m(this,X,$r).call(this);const r=Eg(n);if(!Ag(r).valid)return;const s=m(this,X,gc).call(this);x(this,Le,r),x(this,rn,{layout:r,snapshot:s}),this.dispatchEvent(new ee("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&&(x(this,rn,null),m(this,X,mc).call(this,s),this.dispatchEvent(new ee("change")))})}rename(n){m(this,X,$r).call(this),x(this,Fn,n),this.dispatchEvent(new ee("change")),this.server.client.screens.update({screenID:this.id,name:n}).catch(()=>{})}async remove(){m(this,X,$r).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(n){if(m(this,X,$r).call(this),!l(this,He).has(n))return;const r=m(this,X,gc).call(this);m(this,X,fc).call(this,n),this.dispatchEvent(new ee("change")),this.server.client.artifacts.remove({artifactID:n,screenID:this.id}).catch(()=>{this.disposed||(m(this,X,mc).call(this,r),this.dispatchEvent(new ee("change")))})}dispose(){this.server.removeEventListener("server-event",l(this,ss))}}Un=new WeakMap,He=new WeakMap,Fn=new WeakMap,Le=new WeakMap,nn=new WeakMap,rn=new WeakMap,X=new WeakSet,$r=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Bg=async function(){try{const n=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of n.artifacts)l(this,He).set(r.id,r);this.dispatchEvent(new ee("change"))}catch{}},ss=new WeakMap,Vg=function(n){l(this,rn)&&x(this,rn,null),x(this,Fn,n.name),x(this,Le,structuredClone(n.layout)),this.dispatchEvent(new ee("change"))},jg=function(n){Lg(l(this,Le),n.id)||x(this,Le,[...l(this,Le),zg(n.id)]),l(this,He).set(n.id,n),this.dispatchEvent(new ee("change"))},Gg=function(n){const r=l(this,He).get(n.id);r&&(l(this,He).set(n.id,{...r,...n}),this.dispatchEvent(new ee("change")))},Wg=function(n){m(this,X,fc).call(this,n)&&this.dispatchEvent(new ee("change"))},fc=function(n){const r=l(this,He).delete(n),i=lp({layout:l(this,Le)}).length,s=$g(l(this,Le),n),o=lp({layout:s}).length;return x(this,Le,s),r||i!==o},gc=function(){return{layout:structuredClone(l(this,Le)),artifacts:new Map([...l(this,He).entries()].map(([n,r])=>[n,structuredClone(r)]))}},mc=function(n){x(this,Le,structuredClone(n.layout)),l(this,He).clear();for(const[r,i]of n.artifacts)l(this,He).set(r,structuredClone(i))},qg=function(){const n=l(this,Un).get();l(this,Un).set({...n,screens:{...n.screens,[this.id]:{scrollPosition:l(this,nn)}}})};const dE=pi(gt);var Qe,Mt,at,os,as,ls,Mr,Zo;class pE extends dE{constructor(n){super();_(this,Mr);_(this,Qe);_(this,Mt);_(this,at,null);_(this,os,()=>{this.disposed||m(this,Mr,Zo).call(this)});_(this,as,()=>{this.disposed||m(this,Mr,Zo).call(this)});_(this,ls,n=>{var i;if(this.disposed)return;const r=n.event;r.type==="screen-removed"&&((i=l(this,at))==null?void 0:i.id)===r.screenID&&this.clearActive()});x(this,Qe,n.localStore),x(this,Mt,n.serverManager),l(this,Qe).addEventListener("change",l(this,os)),l(this,Mt).addEventListener("change",l(this,as)),l(this,Mt).addEventListener("server-event",l(this,ls)),m(this,Mr,Zo).call(this)}get activeScreen(){return l(this,at)}setActive(n,r){const i=l(this,Qe).get();i.activeServerURL===n&&i.activeScreenID===r||l(this,Qe).set({...i,activeServerURL:n,activeScreenID:r})}clearActive(){const n=l(this,Qe).get();n.activeScreenID!==null&&l(this,Qe).set({...n,activeScreenID:null})}dispose(){var n;l(this,Qe).removeEventListener("change",l(this,os)),l(this,Mt).removeEventListener("change",l(this,as)),l(this,Mt).removeEventListener("server-event",l(this,ls)),(n=l(this,at))==null||n.dispose(),x(this,at,null)}}Qe=new WeakMap,Mt=new WeakMap,at=new WeakMap,os=new WeakMap,as=new WeakMap,ls=new WeakMap,Mr=new WeakSet,Zo=function(){var c,u,d;const{activeServerURL:n,activeScreenID:r}=l(this,Qe).get(),i=n?l(this,Mt).servers.get(n)??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(),x(this,at,i&&s?new hE({screen:s,server:i,localStore:l(this,Qe)}):null),this.dispatchEvent(new Rx("active-screen-changed")))};const fE="Local",gE="store-";function kt(t){return new URL(t).origin}function mE(t){return{servers:[{url:kt(t),name:fE}],activeServerURL:null,activeScreenID:null,screens:{}}}var Zn,Hn,Bn;class vE extends gt{constructor(n,r,i={}){super();_(this,Zn);_(this,Hn);_(this,Bn);x(this,Zn,`${gE}${n}`),x(this,Hn,i.storage??yE());const s=l(this,Hn).getItem(l(this,Zn));s===null?(x(this,Bn,r),l(this,Hn).setItem(l(this,Zn),JSON.stringify(r))):x(this,Bn,JSON.parse(s))}get(){return l(this,Bn)}set(n){x(this,Bn,n),l(this,Hn).setItem(l(this,Zn),JSON.stringify(n)),this.dispatchEvent(new ee("change"))}}Zn=new WeakMap,Hn=new WeakMap,Bn=new WeakMap;function yE(){const t=globalThis.localStorage;if(!t)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return t}function E(t,e,n){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(t))return;a._zod.traits.add(t),e(a,c);const u=o.prototype,d=Object.keys(u);for(let p=0;p<d.length;p++){const y=d[p];y in a||(a[y]=u[y].bind(a))}}const i=(n==null?void 0:n.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:t});function o(a){var c;const u=n!=null&&n.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 n!=null&&n.Parent&&a instanceof n.Parent?!0:(u=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:u.has(t)}}),Object.defineProperty(o,"name",{value:t}),o}class Lr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Yg extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Kg={};function fn(t){return Kg}function Jg(t){const e=Object.values(t).filter(r=>typeof r=="number");return Object.entries(t).filter(([r,i])=>e.indexOf(+r)===-1).map(([r,i])=>i)}function vc(t,e){return typeof e=="bigint"?e.toString():e}function Du(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function Ou(t){return t==null}function zu(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function bE(t,e){const n=(t.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=n>i?n:i,o=Number.parseInt(t.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return o%a/10**s}const cp=Symbol("evaluating");function Q(t,e,n){let r;Object.defineProperty(t,e,{get(){if(r!==cp)return r===void 0&&(r=cp,r=n()),r},set(i){Object.defineProperty(t,e,{value:i})},configurable:!0})}function pr(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Sn(...t){const e={};for(const n of t){const r=Object.getOwnPropertyDescriptors(n);Object.assign(e,r)}return Object.defineProperties({},e)}function up(t){return JSON.stringify(t)}function wE(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Xg="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function ta(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const _E=Du(()=>{var t;if(typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)!=null&&t.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function ti(t){if(ta(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const n=e.prototype;return!(ta(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Qg(t){return ti(t)?{...t}:Array.isArray(t)?[...t]:t}const SE=new Set(["string","number","symbol"]);function ni(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function kn(t,e,n){const r=new t._zod.constr(e??t._zod.def);return(!e||n!=null&&n.parent)&&(r._zod.parent=t),r}function O(t){const e=t;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 kE(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const xE={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 EE(t,e){const n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=Sn(t._zod.def,{get shape(){const o={};for(const a in e){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(o[a]=n.shape[a])}return pr(this,"shape",o),o},checks:[]});return kn(t,s)}function $E(t,e){const n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=Sn(t._zod.def,{get shape(){const o={...t._zod.def.shape};for(const a in e){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete o[a]}return pr(this,"shape",o),o},checks:[]});return kn(t,s)}function AE(t,e){if(!ti(e))throw new Error("Invalid input to extend: expected a plain object");const n=t._zod.def.checks;if(n&&n.length>0){const s=t._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=Sn(t._zod.def,{get shape(){const s={...t._zod.def.shape,...e};return pr(this,"shape",s),s}});return kn(t,i)}function TE(t,e){if(!ti(e))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Sn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e};return pr(this,"shape",r),r}});return kn(t,n)}function CE(t,e){const n=Sn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return pr(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return kn(t,n)}function IE(t,e,n){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=Sn(e._zod.def,{get shape(){const a=e._zod.def.shape,c={...a};if(n)for(const u in n){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=t?new t({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=t?new t({type:"optional",innerType:a[u]}):a[u];return pr(this,"shape",c),c},checks:[]});return kn(e,o)}function PE(t,e,n){const r=Sn(e._zod.def,{get shape(){const i=e._zod.def.shape,s={...i};if(n)for(const o in n){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(s[o]=new t({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new t({type:"nonoptional",innerType:i[o]});return pr(this,"shape",s),s}});return kn(e,r)}function Dr(t,e=0){var n;if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(((n=t.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function Or(t,e){return e.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(t),n})}function wo(t){return typeof t=="string"?t:t==null?void 0:t.message}function gn(t,e,n){var i,s,o,a,c,u;const r={...t,path:t.path??[]};if(!t.message){const d=wo((o=(s=(i=t.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,t))??wo((a=e==null?void 0:e.error)==null?void 0:a.call(e,t))??wo((c=n.customError)==null?void 0:c.call(n,t))??wo((u=n.localeError)==null?void 0:u.call(n,t))??"Invalid input";r.message=d}return delete r.inst,delete r.continue,e!=null&&e.reportInput||delete r.input,r}function Lu(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Xi(...t){const[e,n,r]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:r}:{...e}}const em=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,vc,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},tm=E("$ZodError",em),nm=E("$ZodError",em,{Parent:Error});function RE(t,e=n=>n.message){const n={},r=[];for(const i of t.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(e(i))):r.push(e(i));return{formErrors:r,fieldErrors:n}}function DE(t,e=n=>n.message){const n={_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)n._errors.push(e(s));else{let o=n,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(t),n}const Mu=t=>(e,n,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},o=e._zod.run({value:n,issues:[]},s);if(o instanceof Promise)throw new Lr;if(o.issues.length){const a=new((i==null?void 0:i.Err)??t)(o.issues.map(c=>gn(c,s,fn())));throw Xg(a,i==null?void 0:i.callee),a}return o.value},Nu=t=>async(e,n,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=e._zod.run({value:n,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??t)(o.issues.map(c=>gn(c,s,fn())));throw Xg(a,i==null?void 0:i.callee),a}return o.value},Na=t=>(e,n,r)=>{const i=r?{...r,async:!1}:{async:!1},s=e._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new Lr;return s.issues.length?{success:!1,error:new(t??tm)(s.issues.map(o=>gn(o,i,fn())))}:{success:!0,data:s.value}},OE=Na(nm),Ua=t=>async(e,n,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=e._zod.run({value:n,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(o=>gn(o,i,fn())))}:{success:!0,data:s.value}},zE=Ua(nm),LE=t=>(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Mu(t)(e,n,i)},ME=t=>(e,n,r)=>Mu(t)(e,n,r),NE=t=>async(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Nu(t)(e,n,i)},UE=t=>async(e,n,r)=>Nu(t)(e,n,r),FE=t=>(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Na(t)(e,n,i)},ZE=t=>(e,n,r)=>Na(t)(e,n,r),HE=t=>async(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ua(t)(e,n,i)},BE=t=>async(e,n,r)=>Ua(t)(e,n,r),VE=/^[cC][^\s-]{8,}$/,jE=/^[0-9a-z]+$/,GE=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,WE=/^[0-9a-vA-V]{20}$/,qE=/^[A-Za-z0-9]{27}$/,YE=/^[a-zA-Z0-9_-]{21}$/,KE=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,JE=/^([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})$/,hp=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[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)$/,XE=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,QE="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function e$(){return new RegExp(QE,"u")}const t$=/^(?:(?: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])$/,n$=/^(([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}|:))$/,r$=/^((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])$/,i$=/^(([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])$/,s$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,rm=/^[A-Za-z0-9_-]*$/,o$=/^\+[1-9]\d{6,14}$/,im="(?:(?:\\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])))",a$=new RegExp(`^${im}$`);function sm(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function l$(t){return new RegExp(`^${sm(t)}$`)}function c$(t){const e=sm({precision:t.precision}),n=["Z"];t.local&&n.push(""),t.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${e}(?:${n.join("|")})`;return new RegExp(`^${im}T(?:${r})$`)}const u$=t=>{const e=t?`[\\s\\S]{${(t==null?void 0:t.minimum)??0},${(t==null?void 0:t.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},h$=/^-?\d+$/,om=/^-?\d+(?:\.\d+)?$/,d$=/^(?:true|false)$/i,p$=/^[^A-Z]*$/,f$=/^[^a-z]*$/,We=E("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),am={number:"number",bigint:"bigint",object:"date"},lm=E("$ZodCheckLessThan",(t,e)=>{We.init(t,e);const n=am[typeof e.value];t._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)}),t._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),cm=E("$ZodCheckGreaterThan",(t,e)=>{We.init(t,e);const n=am[typeof e.value];t._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)}),t._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),g$=E("$ZodCheckMultipleOf",(t,e)=>{We.init(t,e),t._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=e.value)}),t._zod.check=n=>{if(typeof n.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%e.value===BigInt(0):bE(n.value,e.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:e.value,input:n.value,inst:t,continue:!e.abort})}}),m$=E("$ZodCheckNumberFormat",(t,e)=>{var o;We.init(t,e),e.format=e.format||"float64";const n=(o=e.format)==null?void 0:o.includes("int"),r=n?"int":"number",[i,s]=xE[e.format];t._zod.onattach.push(a=>{const c=a._zod.bag;c.format=e.format,c.minimum=i,c.maximum=s,n&&(c.pattern=h$)}),t._zod.check=a=>{const c=a.value;if(n){if(!Number.isInteger(c)){a.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:c,inst:t});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:t,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:t,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:t,continue:!e.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:t,continue:!e.abort})}}),v$=E("$ZodCheckMaxLength",(t,e)=>{var n;We.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!Ou(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<i&&(r._zod.bag.maximum=e.maximum)}),t._zod.check=r=>{const i=r.value;if(i.length<=e.maximum)return;const o=Lu(i);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:t,continue:!e.abort})}}),y$=E("$ZodCheckMinLength",(t,e)=>{var n;We.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!Ou(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(r._zod.bag.minimum=e.minimum)}),t._zod.check=r=>{const i=r.value;if(i.length>=e.minimum)return;const o=Lu(i);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:t,continue:!e.abort})}}),b$=E("$ZodCheckLengthEquals",(t,e)=>{var n;We.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!Ou(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=e.length,i.maximum=e.length,i.length=e.length}),t._zod.check=r=>{const i=r.value,s=i.length;if(s===e.length)return;const o=Lu(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:t,continue:!e.abort})}}),Fa=E("$ZodCheckStringFormat",(t,e)=>{var n,r;We.init(t,e),t._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?(n=t._zod).check??(n.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:t,continue:!e.abort})}):(r=t._zod).check??(r.check=()=>{})}),w$=E("$ZodCheckRegex",(t,e)=>{Fa.init(t,e),t._zod.check=n=>{e.pattern.lastIndex=0,!e.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),_$=E("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=p$),Fa.init(t,e)}),S$=E("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=f$),Fa.init(t,e)}),k$=E("$ZodCheckIncludes",(t,e)=>{We.init(t,e);const n=ni(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position}}${n}`:n);e.pattern=r,t._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._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:t,continue:!e.abort})}}),x$=E("$ZodCheckStartsWith",(t,e)=>{We.init(t,e);const n=new RegExp(`^${ni(e.prefix)}.*`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),t._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:t,continue:!e.abort})}}),E$=E("$ZodCheckEndsWith",(t,e)=>{We.init(t,e);const n=new RegExp(`.*${ni(e.suffix)}$`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),t._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:t,continue:!e.abort})}}),$$=E("$ZodCheckOverwrite",(t,e)=>{We.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}});class A${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,n=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new e(...n,i.join(`
6
+ `))}}const T$={major:4,minor:3,patch:6},de=E("$ZodType",(t,e)=>{var i;var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=T$;const r=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&r.unshift(t);for(const s of r)for(const o of s._zod.onattach)o(t);if(r.length===0)(n=t._zod).deferred??(n.deferred=[]),(i=t._zod.deferred)==null||i.push(()=>{t._zod.run=t._zod.parse});else{const s=(a,c,u)=>{let d=Dr(a),p;for(const y of c){if(y._zod.def.when){if(!y._zod.def.when(a))continue}else if(d)continue;const v=a.issues.length,$=y._zod.check(a);if($ instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Lr;if(p||$ instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await $,a.issues.length!==v&&(d||(d=Dr(a,v)))});else{if(a.issues.length===v)continue;d||(d=Dr(a,v))}}return p?p.then(()=>a):a},o=(a,c,u)=>{if(Dr(a))return a.aborted=!0,a;const d=s(c,r,u);if(d instanceof Promise){if(u.async===!1)throw new Lr;return d.then(p=>t._zod.parse(p,u))}return t._zod.parse(d,u)};t._zod.run=(a,c)=>{if(c.skipChecks)return t._zod.parse(a,c);if(c.direction==="backward"){const d=t._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(p=>o(p,a,c)):o(d,a,c)}const u=t._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new Lr;return u.then(d=>s(d,r,c))}return s(u,r,c)}}Q(t,"~standard",()=>({validate:s=>{var o;try{const a=OE(t,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return zE(t,s).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),Uu=E("$ZodString",(t,e)=>{var n;de.init(t,e),t._zod.pattern=[...((n=t==null?void 0:t._zod.bag)==null?void 0:n.patterns)??[]].pop()??u$(t._zod.bag),t._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:t}),r}}),le=E("$ZodStringFormat",(t,e)=>{Fa.init(t,e),Uu.init(t,e)}),C$=E("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=JE),le.init(t,e)}),I$=E("$ZodUUID",(t,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=hp(r))}else e.pattern??(e.pattern=hp());le.init(t,e)}),P$=E("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=XE),le.init(t,e)}),R$=E("$ZodURL",(t,e)=>{le.init(t,e),t._zod.check=n=>{try{const r=n.value.trim(),i=new URL(r);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:n.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:n.value,inst:t,continue:!e.abort})),e.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:t,continue:!e.abort})}}}),D$=E("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=e$()),le.init(t,e)}),O$=E("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=YE),le.init(t,e)}),z$=E("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=VE),le.init(t,e)}),L$=E("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=jE),le.init(t,e)}),M$=E("$ZodULID",(t,e)=>{e.pattern??(e.pattern=GE),le.init(t,e)}),N$=E("$ZodXID",(t,e)=>{e.pattern??(e.pattern=WE),le.init(t,e)}),U$=E("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=qE),le.init(t,e)}),F$=E("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=c$(e)),le.init(t,e)}),Z$=E("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=a$),le.init(t,e)}),H$=E("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=l$(e)),le.init(t,e)}),B$=E("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=KE),le.init(t,e)}),V$=E("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=t$),le.init(t,e),t._zod.bag.format="ipv4"}),j$=E("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=n$),le.init(t,e),t._zod.bag.format="ipv6",t._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:t,continue:!e.abort})}}}),G$=E("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=r$),le.init(t,e)}),W$=E("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=i$),le.init(t,e),t._zod.check=n=>{const r=n.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{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:t,continue:!e.abort})}}});function um(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const q$=E("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=s$),le.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{um(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort})}});function Y$(t){if(!rm.test(t))return!1;const e=t.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=e.padEnd(Math.ceil(e.length/4)*4,"=");return um(n)}const K$=E("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=rm),le.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=n=>{Y$(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!e.abort})}}),J$=E("$ZodE164",(t,e)=>{e.pattern??(e.pattern=o$),le.init(t,e)});function X$(t,e=null){try{const n=t.split(".");if(n.length!==3)return!1;const[r]=n;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 Q$=E("$ZodJWT",(t,e)=>{le.init(t,e),t._zod.check=n=>{X$(n.value,e.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!e.abort})}}),hm=E("$ZodNumber",(t,e)=>{de.init(t,e),t._zod.pattern=t._zod.bag.pattern??om,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:t,...s?{received:s}:{}}),n}}),eA=E("$ZodNumberFormat",(t,e)=>{m$.init(t,e),hm.init(t,e)}),tA=E("$ZodBoolean",(t,e)=>{de.init(t,e),t._zod.pattern=d$,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:t}),n}}),nA=E("$ZodUnknown",(t,e)=>{de.init(t,e),t._zod.parse=n=>n}),rA=E("$ZodNever",(t,e)=>{de.init(t,e),t._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:t}),n)});function dp(t,e,n){t.issues.length&&e.issues.push(...Or(n,t.issues)),e.value[n]=t.value}const iA=E("$ZodArray",(t,e)=>{de.init(t,e),t._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:t}),n;n.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=>dp(u,n,o))):dp(c,n,o)}return s.length?Promise.all(s).then(()=>n):n}});function na(t,e,n,r,i){if(t.issues.length){if(i&&!(n in r))return;e.issues.push(...Or(n,t.issues))}t.value===void 0?n in r&&(e.value[n]=void 0):e.value[n]=t.value}function dm(t){var r,i,s,o;const e=Object.keys(t.shape);for(const a of e)if(!((o=(s=(i=(r=t.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 n=kE(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}function pm(t,e,n,r,i,s){const o=[],a=i.keySet,c=i.catchall._zod,u=c.def.type,d=c.optout==="optional";for(const p in e){if(a.has(p))continue;if(u==="never"){o.push(p);continue}const y=c.run({value:e[p],issues:[]},r);y instanceof Promise?t.push(y.then(v=>na(v,n,p,e,d))):na(y,n,p,e,d)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:s}),t.length?Promise.all(t).then(()=>n):n}const sA=E("$ZodObject",(t,e)=>{de.init(t,e);const n=Object.getOwnPropertyDescriptor(e,"shape");if(!(n!=null&&n.get)){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const c={...a};return Object.defineProperty(e,"shape",{value:c}),c}})}const r=Du(()=>dm(e));Q(t._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 p of d.values)c[u].add(p)}}return c});const i=ta,s=e.catchall;let o;t._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:t}),a;a.value={};const d=[],p=o.shape;for(const y of o.keys){const v=p[y],$=v._zod.optout==="optional",k=v._zod.run({value:u[y],issues:[]},c);k instanceof Promise?d.push(k.then(I=>na(I,a,y,u,$))):na(k,a,y,u,$)}return s?pm(d,u,a,c,r.value,t):d.length?Promise.all(d).then(()=>a):a}}),oA=E("$ZodObjectJIT",(t,e)=>{sA.init(t,e);const n=t._zod.parse,r=Du(()=>dm(e)),i=y=>{var K;const v=new A$(["shape","payload","ctx"]),$=r.value,k=L=>{const Z=up(L);return`shape[${Z}]._zod.run({ value: input[${Z}], issues: [] }, ctx)`};v.write("const input = payload.value;");const I=Object.create(null);let B=0;for(const L of $.keys)I[L]=`key_${B++}`;v.write("const newResult = {};");for(const L of $.keys){const Z=I[L],N=up(L),ce=y[L],ue=((K=ce==null?void 0:ce._zod)==null?void 0:K.optout)==="optional";v.write(`const ${Z} = ${k(L)};`),ue?v.write(`
7
+ if (${Z}.issues.length) {
8
+ if (${N} in input) {
9
+ payload.issues = payload.issues.concat(${Z}.issues.map(iss => ({
10
+ ...iss,
11
+ path: iss.path ? [${N}, ...iss.path] : [${N}]
12
+ })));
13
+ }
14
+ }
15
+
16
+ if (${Z}.value === undefined) {
17
+ if (${N} in input) {
18
+ newResult[${N}] = undefined;
19
+ }
20
+ } else {
21
+ newResult[${N}] = ${Z}.value;
22
+ }
23
+
24
+ `):v.write(`
25
+ if (${Z}.issues.length) {
26
+ payload.issues = payload.issues.concat(${Z}.issues.map(iss => ({
27
+ ...iss,
28
+ path: iss.path ? [${N}, ...iss.path] : [${N}]
29
+ })));
30
+ }
31
+
32
+ if (${Z}.value === undefined) {
33
+ if (${N} in input) {
34
+ newResult[${N}] = undefined;
35
+ }
36
+ } else {
37
+ newResult[${N}] = ${Z}.value;
38
+ }
39
+
40
+ `)}v.write("payload.value = newResult;"),v.write("return payload;");const P=v.compile();return(L,Z)=>P(y,L,Z)};let s;const o=ta,a=!Kg.jitless,u=a&&_E.value,d=e.catchall;let p;t._zod.parse=(y,v)=>{p??(p=r.value);const $=y.value;return o($)?a&&u&&(v==null?void 0:v.async)===!1&&v.jitless!==!0?(s||(s=i(e.shape)),y=s(y,v),d?pm([],$,y,v,p,t):y):n(y,v):(y.issues.push({expected:"object",code:"invalid_type",input:$,inst:t}),y)}});function pp(t,e,n,r){for(const s of t)if(s.issues.length===0)return e.value=s.value,e;const i=t.filter(s=>!Dr(s));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(s=>s.issues.map(o=>gn(o,r,fn())))}),e)}const aA=E("$ZodUnion",(t,e)=>{de.init(t,e),Q(t._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Q(t._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Q(t._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),Q(t._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=>zu(s.source)).join("|")})$`)}});const n=e.options.length===1,r=e.options[0]._zod.run;t._zod.parse=(i,s)=>{if(n)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=>pp(c,i,t,s)):pp(a,i,t,s)}}),lA=E("$ZodIntersection",(t,e)=>{de.init(t,e),t._zod.parse=(n,r)=>{const i=n.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])=>fp(n,c,u)):fp(n,s,o)}});function yc(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(ti(t)&&ti(e)){const n=Object.keys(e),r=Object.keys(t).filter(s=>n.indexOf(s)!==-1),i={...t,...e};for(const s of r){const o=yc(t[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(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<t.length;r++){const i=t[r],s=e[r],o=yc(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function fp(t,e,n){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 t.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else t.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&t.issues.push({...i,keys:s}),Dr(t))return t;const o=yc(e.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return t.value=o.data,t}const cA=E("$ZodRecord",(t,e)=>{de.init(t,e),t._zod.parse=(n,r)=>{const i=n.value;if(!ti(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:t}),n;const s=[],o=e.keyType._zod.values;if(o){n.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(p=>{p.issues.length&&n.issues.push(...Or(u,p.issues)),n.value[u]=p.value})):(d.issues.length&&n.issues.push(...Or(u,d.issues)),n.value[u]=d.value)}let c;for(const u in i)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:t,keys:c})}else{n.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"&&om.test(a)&&c.issues.length){const p=e.keyType._zod.run({value:Number(a),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(c=p)}if(c.issues.length){e.mode==="loose"?n.value[a]=i[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(p=>gn(p,r,fn())),input:a,path:[a],inst:t});continue}const d=e.valueType._zod.run({value:i[a],issues:[]},r);d instanceof Promise?s.push(d.then(p=>{p.issues.length&&n.issues.push(...Or(a,p.issues)),n.value[c.value]=p.value})):(d.issues.length&&n.issues.push(...Or(a,d.issues)),n.value[c.value]=d.value)}}return s.length?Promise.all(s).then(()=>n):n}}),uA=E("$ZodEnum",(t,e)=>{de.init(t,e);const n=Jg(e.entries),r=new Set(n);t._zod.values=r,t._zod.pattern=new RegExp(`^(${n.filter(i=>SE.has(typeof i)).map(i=>typeof i=="string"?ni(i):i.toString()).join("|")})$`),t._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:n,input:o,inst:t}),i}}),hA=E("$ZodLiteral",(t,e)=>{if(de.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(e.values);t._zod.values=n,t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?ni(r):r?ni(r.toString()):String(r)).join("|")})$`),t._zod.parse=(r,i)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:t}),r}}),dA=E("$ZodTransform",(t,e)=>{de.init(t,e),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Yg(t.constructor.name);const i=e.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(n.value=o,n));if(i instanceof Promise)throw new Lr;return n.value=i,n}});function gp(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const fm=E("$ZodOptional",(t,e)=>{de.init(t,e),t._zod.optin="optional",t._zod.optout="optional",Q(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),Q(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${zu(n.source)})?$`):void 0}),t._zod.parse=(n,r)=>{if(e.innerType._zod.optin==="optional"){const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>gp(s,n.value)):gp(i,n.value)}return n.value===void 0?n:e.innerType._zod.run(n,r)}}),pA=E("$ZodExactOptional",(t,e)=>{fm.init(t,e),Q(t._zod,"values",()=>e.innerType._zod.values),Q(t._zod,"pattern",()=>e.innerType._zod.pattern),t._zod.parse=(n,r)=>e.innerType._zod.run(n,r)}),fA=E("$ZodNullable",(t,e)=>{de.init(t,e),Q(t._zod,"optin",()=>e.innerType._zod.optin),Q(t._zod,"optout",()=>e.innerType._zod.optout),Q(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${zu(n.source)}|null)$`):void 0}),Q(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(n,r)=>n.value===null?n:e.innerType._zod.run(n,r)}),gA=E("$ZodDefault",(t,e)=>{de.init(t,e),t._zod.optin="optional",Q(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);if(n.value===void 0)return n.value=e.defaultValue,n;const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>mp(s,e)):mp(i,e)}});function mp(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const mA=E("$ZodPrefault",(t,e)=>{de.init(t,e),t._zod.optin="optional",Q(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=e.defaultValue),e.innerType._zod.run(n,r))}),vA=E("$ZodNonOptional",(t,e)=>{de.init(t,e),Q(t._zod,"values",()=>{const n=e.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),t._zod.parse=(n,r)=>{const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>vp(s,t)):vp(i,t)}});function vp(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}const yA=E("$ZodCatch",(t,e)=>{de.init(t,e),Q(t._zod,"optin",()=>e.innerType._zod.optin),Q(t._zod,"optout",()=>e.innerType._zod.optout),Q(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>(n.value=s.value,s.issues.length&&(n.value=e.catchValue({...n,error:{issues:s.issues.map(o=>gn(o,r,fn()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=e.catchValue({...n,error:{issues:i.issues.map(s=>gn(s,r,fn()))},input:n.value}),n.issues=[]),n)}}),bA=E("$ZodPipe",(t,e)=>{de.init(t,e),Q(t._zod,"values",()=>e.in._zod.values),Q(t._zod,"optin",()=>e.in._zod.optin),Q(t._zod,"optout",()=>e.out._zod.optout),Q(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=e.out._zod.run(n,r);return s instanceof Promise?s.then(o=>_o(o,e.in,r)):_o(s,e.in,r)}const i=e.in._zod.run(n,r);return i instanceof Promise?i.then(s=>_o(s,e.out,r)):_o(i,e.out,r)}});function _o(t,e,n){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},n)}const wA=E("$ZodReadonly",(t,e)=>{de.init(t,e),Q(t._zod,"propValues",()=>e.innerType._zod.propValues),Q(t._zod,"values",()=>e.innerType._zod.values),Q(t._zod,"optin",()=>{var n,r;return(r=(n=e.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),Q(t._zod,"optout",()=>{var n,r;return(r=(n=e.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(yp):yp(i)}});function yp(t){return t.value=Object.freeze(t.value),t}const _A=E("$ZodCustom",(t,e)=>{We.init(t,e),de.init(t,e),t._zod.parse=(n,r)=>n,t._zod.check=n=>{const r=n.value,i=e.fn(r);if(i instanceof Promise)return i.then(s=>bp(s,n,r,t));bp(i,n,r,t)}});function bp(t,e,n,r){if(!t){const i={code:"custom",input:n,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(Xi(i))}}var wp;class SA{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...n){const r=n[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 n=this._map.get(e);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(e),this}get(e){const n=e._zod.parent;if(n){const r={...this.get(n)??{}};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 kA(){return new SA}(wp=globalThis).__zod_globalRegistry??(wp.__zod_globalRegistry=kA());const Li=globalThis.__zod_globalRegistry;function xA(t,e){return new t({type:"string",...O(e)})}function EA(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...O(e)})}function _p(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...O(e)})}function $A(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...O(e)})}function AA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(e)})}function TA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(e)})}function CA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(e)})}function IA(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...O(e)})}function PA(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...O(e)})}function RA(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(e)})}function DA(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...O(e)})}function OA(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(e)})}function zA(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...O(e)})}function LA(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...O(e)})}function MA(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(e)})}function NA(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(e)})}function UA(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(e)})}function FA(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(e)})}function ZA(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(e)})}function HA(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...O(e)})}function BA(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...O(e)})}function VA(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...O(e)})}function jA(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...O(e)})}function GA(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(e)})}function WA(t,e){return new t({type:"string",format:"date",check:"string_format",...O(e)})}function qA(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...O(e)})}function YA(t,e){return new t({type:"string",format:"duration",check:"string_format",...O(e)})}function KA(t,e){return new t({type:"number",checks:[],...O(e)})}function JA(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...O(e)})}function XA(t,e){return new t({type:"boolean",...O(e)})}function QA(t){return new t({type:"unknown"})}function e1(t,e){return new t({type:"never",...O(e)})}function Sp(t,e){return new lm({check:"less_than",...O(e),value:t,inclusive:!1})}function Ll(t,e){return new lm({check:"less_than",...O(e),value:t,inclusive:!0})}function kp(t,e){return new cm({check:"greater_than",...O(e),value:t,inclusive:!1})}function Ml(t,e){return new cm({check:"greater_than",...O(e),value:t,inclusive:!0})}function xp(t,e){return new g$({check:"multiple_of",...O(e),value:t})}function gm(t,e){return new v$({check:"max_length",...O(e),maximum:t})}function ra(t,e){return new y$({check:"min_length",...O(e),minimum:t})}function mm(t,e){return new b$({check:"length_equals",...O(e),length:t})}function t1(t,e){return new w$({check:"string_format",format:"regex",...O(e),pattern:t})}function n1(t){return new _$({check:"string_format",format:"lowercase",...O(t)})}function r1(t){return new S$({check:"string_format",format:"uppercase",...O(t)})}function i1(t,e){return new k$({check:"string_format",format:"includes",...O(e),includes:t})}function s1(t,e){return new x$({check:"string_format",format:"starts_with",...O(e),prefix:t})}function o1(t,e){return new E$({check:"string_format",format:"ends_with",...O(e),suffix:t})}function fi(t){return new $$({check:"overwrite",tx:t})}function a1(t){return fi(e=>e.normalize(t))}function l1(){return fi(t=>t.trim())}function c1(){return fi(t=>t.toLowerCase())}function u1(){return fi(t=>t.toUpperCase())}function h1(){return fi(t=>wE(t))}function d1(t,e,n){return new t({type:"array",element:e,...O(n)})}function p1(t,e,n){return new t({type:"custom",check:"custom",fn:e,...O(n)})}function f1(t){const e=g1(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Xi(r,n.value,e._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),i.continue??(i.continue=!e._zod.def.abort),n.issues.push(Xi(i))}},t(n.value,n)));return e}function g1(t,e){const n=new We({check:"custom",...O(e)});return n._zod.check=t,n}function vm(t){let e=(t==null?void 0:t.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:(t==null?void 0:t.metadata)??Li,target:e,unrepresentable:(t==null?void 0:t.unrepresentable)??"throw",override:(t==null?void 0:t.override)??(()=>{}),io:(t==null?void 0:t.io)??"output",counter:0,seen:new Map,cycles:(t==null?void 0:t.cycles)??"ref",reused:(t==null?void 0:t.reused)??"inline",external:(t==null?void 0:t.external)??void 0}}function ye(t,e,n={path:[],schemaPath:[]}){var d,p;var r;const i=t._zod.def,s=e.seen.get(t);if(s)return s.count++,n.schemaPath.includes(t)&&(s.cycle=n.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};e.seen.set(t,o);const a=(p=(d=t._zod).toJSONSchema)==null?void 0:p.call(d);if(a)o.schema=a;else{const y={...n,schemaPath:[...n.schemaPath,t],path:n.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,o.schema,y);else{const $=o.schema,k=e.processors[i.type];if(!k)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);k(t,e,$,y)}const v=t._zod.parent;v&&(o.ref||(o.ref=v),ye(v,e,y),e.seen.get(v).isParent=!0)}const c=e.metadataRegistry.get(t);return c&&Object.assign(o.schema,c),e.io==="input"&&ze(t)&&(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(t).schema}function ym(t,e){var o,a,c,u;const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const d of t.seen.entries()){const p=(o=t.metadataRegistry.get(d[0]))==null?void 0:o.id;if(p){const y=r.get(p);if(y&&y!==d[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(p,d[0])}}const i=d=>{var k;const p=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const I=(k=t.external.registry.get(d[0]))==null?void 0:k.id,B=t.external.uri??(K=>K);if(I)return{ref:B(I)};const P=d[1].defId??d[1].schema.id??`schema${t.counter++}`;return d[1].defId=P,{defId:P,ref:`${B("__shared")}#/${p}/${P}`}}if(d[1]===n)return{ref:"#"};const v=`#/${p}/`,$=d[1].schema.id??`__schema${t.counter++}`;return{defId:$,ref:v+$}},s=d=>{if(d[1].schema.$ref)return;const p=d[1],{ref:y,defId:v}=i(d);p.def={...p.schema},v&&(p.defId=v);const $=p.schema;for(const k in $)delete $[k];$.$ref=y};if(t.cycles==="throw")for(const d of t.seen.entries()){const p=d[1];if(p.cycle)throw new Error(`Cycle detected: #/${(a=p.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 t.seen.entries()){const p=d[1];if(e===d[0]){s(d);continue}if(t.external){const v=(c=t.external.registry.get(d[0]))==null?void 0:c.id;if(e!==d[0]&&v){s(d);continue}}if((u=t.metadataRegistry.get(d[0]))==null?void 0:u.id){s(d);continue}if(p.cycle){s(d);continue}if(p.count>1&&t.reused==="ref"){s(d);continue}}}function bm(t,e){var o,a,c;const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const d=t.seen.get(u);if(d.ref===null)return;const p=d.def??d.schema,y={...p},v=d.ref;if(d.ref=null,v){r(v);const k=t.seen.get(v),I=k.schema;if(I.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(I)):Object.assign(p,I),Object.assign(p,y),u._zod.parent===v)for(const P in p)P==="$ref"||P==="allOf"||P in y||delete p[P];if(I.$ref&&k.def)for(const P in p)P==="$ref"||P==="allOf"||P in k.def&&JSON.stringify(p[P])===JSON.stringify(k.def[P])&&delete p[P]}const $=u._zod.parent;if($&&$!==v){r($);const k=t.seen.get($);if(k!=null&&k.schema.$ref&&(p.$ref=k.schema.$ref,k.def))for(const I in p)I==="$ref"||I==="allOf"||I in k.def&&JSON.stringify(p[I])===JSON.stringify(k.def[I])&&delete p[I]}t.override({zodSchema:u,jsonSchema:p,path:d.path??[]})};for(const u of[...t.seen.entries()].reverse())r(u[0]);const i={};if(t.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":t.target,(o=t.external)!=null&&o.uri){const u=(a=t.external.registry.get(e))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=t.external.uri(u)}Object.assign(i,n.def??n.schema);const s=((c=t.external)==null?void 0:c.defs)??{};for(const u of t.seen.entries()){const d=u[1];d.def&&d.defId&&(s[d.defId]=d.def)}t.external||Object.keys(s).length>0&&(t.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:ia(e,"input",t.processors),output:ia(e,"output",t.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function ze(t,e){const n=e??{seen:new Set};if(n.seen.has(t))return!1;n.seen.add(t);const r=t._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return ze(r.element,n);if(r.type==="set")return ze(r.valueType,n);if(r.type==="lazy")return ze(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return ze(r.innerType,n);if(r.type==="intersection")return ze(r.left,n)||ze(r.right,n);if(r.type==="record"||r.type==="map")return ze(r.keyType,n)||ze(r.valueType,n);if(r.type==="pipe")return ze(r.in,n)||ze(r.out,n);if(r.type==="object"){for(const i in r.shape)if(ze(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(ze(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(ze(i,n))return!0;return!!(r.rest&&ze(r.rest,n))}return!1}const m1=(t,e={})=>n=>{const r=vm({...n,processors:e});return ye(t,r),ym(r,t),bm(r,t)},ia=(t,e,n={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=vm({...i??{},target:s,io:e,processors:n});return ye(t,o),ym(o,t),bm(o,t)},v1={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},y1=(t,e,n,r)=>{const i=n;i.type="string";const{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:u}=t._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=v1[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(p=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},b1=(t,e,n,r)=>{const i=n,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=t._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)},w1=(t,e,n,r)=>{n.type="boolean"},_1=(t,e,n,r)=>{n.not={}},S1=(t,e,n,r)=>{},k1=(t,e,n,r)=>{const i=t._zod.def,s=Jg(i.entries);s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),n.enum=s},x1=(t,e,n,r)=>{const i=t._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];n.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?n.enum=[o]:n.const=o}else s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),s.every(o=>typeof o=="boolean")&&(n.type="boolean"),s.every(o=>o===null)&&(n.type="null"),n.enum=s},E1=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},$1=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},A1=(t,e,n,r)=>{const i=n,s=t._zod.def,{minimum:o,maximum:a}=t._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=ye(s.element,e,{...r,path:[...r.path,"items"]})},T1=(t,e,n,r)=>{var u;const i=n,s=t._zod.def;i.type="object",i.properties={};const o=s.shape;for(const d in o)i.properties[d]=ye(o[d],e,{...r,path:[...r.path,"properties",d]});const a=new Set(Object.keys(o)),c=new Set([...a].filter(d=>{const p=s.shape[d]._zod;return e.io==="input"?p.optin===void 0:p.optout===void 0}));c.size>0&&(i.required=Array.from(c)),((u=s.catchall)==null?void 0:u._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=ye(s.catchall,e,{...r,path:[...r.path,"additionalProperties"]})):e.io==="output"&&(i.additionalProperties=!1)},C1=(t,e,n,r)=>{const i=t._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>ye(a,e,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?n.oneOf=o:n.anyOf=o},I1=(t,e,n,r)=>{const i=t._zod.def,s=ye(i.left,e,{...r,path:[...r.path,"allOf",0]}),o=ye(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]];n.allOf=c},P1=(t,e,n,r)=>{const i=n,s=t._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=ye(s.valueType,e,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const p of c)i.patternProperties[p.source]=d}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(i.propertyNames=ye(s.keyType,e,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=ye(s.valueType,e,{...r,path:[...r.path,"additionalProperties"]});const u=o._zod.values;if(u){const d=[...u].filter(p=>typeof p=="string"||typeof p=="number");d.length>0&&(i.required=d)}},R1=(t,e,n,r)=>{const i=t._zod.def,s=ye(i.innerType,e,r),o=e.seen.get(t);e.target==="openapi-3.0"?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},D1=(t,e,n,r)=>{const i=t._zod.def;ye(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType},O1=(t,e,n,r)=>{const i=t._zod.def;ye(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},z1=(t,e,n,r)=>{const i=t._zod.def;ye(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType,e.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},L1=(t,e,n,r)=>{const i=t._zod.def;ye(i.innerType,e,r);const s=e.seen.get(t);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")}n.default=o},M1=(t,e,n,r)=>{const i=t._zod.def,s=e.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;ye(s,e,r);const o=e.seen.get(t);o.ref=s},N1=(t,e,n,r)=>{const i=t._zod.def;ye(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType,n.readOnly=!0},wm=(t,e,n,r)=>{const i=t._zod.def;ye(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType},U1=E("ZodISODateTime",(t,e)=>{F$.init(t,e),fe.init(t,e)});function F1(t){return GA(U1,t)}const Z1=E("ZodISODate",(t,e)=>{Z$.init(t,e),fe.init(t,e)});function H1(t){return WA(Z1,t)}const B1=E("ZodISOTime",(t,e)=>{H$.init(t,e),fe.init(t,e)});function V1(t){return qA(B1,t)}const j1=E("ZodISODuration",(t,e)=>{B$.init(t,e),fe.init(t,e)});function G1(t){return YA(j1,t)}const _m=(t,e)=>{tm.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:n=>DE(t,n)},flatten:{value:n=>RE(t,n)},addIssue:{value:n=>{t.issues.push(n),t.message=JSON.stringify(t.issues,vc,2)}},addIssues:{value:n=>{t.issues.push(...n),t.message=JSON.stringify(t.issues,vc,2)}},isEmpty:{get(){return t.issues.length===0}}})},Ep=E("ZodError",_m),ot=E("ZodError",_m,{Parent:Error}),W1=Mu(ot),q1=Nu(ot),Y1=Na(ot),K1=Ua(ot),J1=LE(ot),X1=ME(ot),Q1=NE(ot),eT=UE(ot),tT=FE(ot),nT=ZE(ot),rT=HE(ot),iT=BE(ot),pe=E("ZodType",(t,e)=>(de.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:ia(t,"input"),output:ia(t,"output")}}),t.toJSONSchema=m1(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...n)=>t.clone(Sn(e,{checks:[...e.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),t.with=t.check,t.clone=(n,r)=>kn(t,n,r),t.brand=()=>t,t.register=(n,r)=>(n.add(t,r),t),t.parse=(n,r)=>W1(t,n,r,{callee:t.parse}),t.safeParse=(n,r)=>Y1(t,n,r),t.parseAsync=async(n,r)=>q1(t,n,r,{callee:t.parseAsync}),t.safeParseAsync=async(n,r)=>K1(t,n,r),t.spa=t.safeParseAsync,t.encode=(n,r)=>J1(t,n,r),t.decode=(n,r)=>X1(t,n,r),t.encodeAsync=async(n,r)=>Q1(t,n,r),t.decodeAsync=async(n,r)=>eT(t,n,r),t.safeEncode=(n,r)=>tT(t,n,r),t.safeDecode=(n,r)=>nT(t,n,r),t.safeEncodeAsync=async(n,r)=>rT(t,n,r),t.safeDecodeAsync=async(n,r)=>iT(t,n,r),t.refine=(n,r)=>t.check(YT(n,r)),t.superRefine=n=>t.check(KT(n)),t.overwrite=n=>t.check(fi(n)),t.optional=()=>Tp(t),t.exactOptional=()=>LT(t),t.nullable=()=>Cp(t),t.nullish=()=>Tp(Cp(t)),t.nonoptional=n=>HT(t,n),t.array=()=>D(t),t.or=n=>H([t,n]),t.and=n=>Za(t,n),t.transform=n=>Ip(t,OT(n)),t.default=n=>UT(t,n),t.prefault=n=>ZT(t,n),t.catch=n=>VT(t,n),t.pipe=n=>Ip(t,n),t.readonly=()=>WT(t),t.describe=n=>{const r=t.clone();return Li.add(r,{description:n}),r},Object.defineProperty(t,"description",{get(){var n;return(n=Li.get(t))==null?void 0:n.description},configurable:!0}),t.meta=(...n)=>{if(n.length===0)return Li.get(t);const r=t.clone();return Li.add(r,n[0]),r},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t.apply=n=>n(t),t)),Sm=E("_ZodString",(t,e)=>{Uu.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(r,i,s)=>y1(t,r,i);const n=t._zod.bag;t.format=n.format??null,t.minLength=n.minimum??null,t.maxLength=n.maximum??null,t.regex=(...r)=>t.check(t1(...r)),t.includes=(...r)=>t.check(i1(...r)),t.startsWith=(...r)=>t.check(s1(...r)),t.endsWith=(...r)=>t.check(o1(...r)),t.min=(...r)=>t.check(ra(...r)),t.max=(...r)=>t.check(gm(...r)),t.length=(...r)=>t.check(mm(...r)),t.nonempty=(...r)=>t.check(ra(1,...r)),t.lowercase=r=>t.check(n1(r)),t.uppercase=r=>t.check(r1(r)),t.trim=()=>t.check(l1()),t.normalize=(...r)=>t.check(a1(...r)),t.toLowerCase=()=>t.check(c1()),t.toUpperCase=()=>t.check(u1()),t.slugify=()=>t.check(h1())}),sT=E("ZodString",(t,e)=>{Uu.init(t,e),Sm.init(t,e),t.email=n=>t.check(EA(oT,n)),t.url=n=>t.check(IA(aT,n)),t.jwt=n=>t.check(jA(ST,n)),t.emoji=n=>t.check(PA(lT,n)),t.guid=n=>t.check(_p($p,n)),t.uuid=n=>t.check($A(So,n)),t.uuidv4=n=>t.check(AA(So,n)),t.uuidv6=n=>t.check(TA(So,n)),t.uuidv7=n=>t.check(CA(So,n)),t.nanoid=n=>t.check(RA(cT,n)),t.guid=n=>t.check(_p($p,n)),t.cuid=n=>t.check(DA(uT,n)),t.cuid2=n=>t.check(OA(hT,n)),t.ulid=n=>t.check(zA(dT,n)),t.base64=n=>t.check(HA(bT,n)),t.base64url=n=>t.check(BA(wT,n)),t.xid=n=>t.check(LA(pT,n)),t.ksuid=n=>t.check(MA(fT,n)),t.ipv4=n=>t.check(NA(gT,n)),t.ipv6=n=>t.check(UA(mT,n)),t.cidrv4=n=>t.check(FA(vT,n)),t.cidrv6=n=>t.check(ZA(yT,n)),t.e164=n=>t.check(VA(_T,n)),t.datetime=n=>t.check(F1(n)),t.date=n=>t.check(H1(n)),t.time=n=>t.check(V1(n)),t.duration=n=>t.check(G1(n))});function h(t){return xA(sT,t)}const fe=E("ZodStringFormat",(t,e)=>{le.init(t,e),Sm.init(t,e)}),oT=E("ZodEmail",(t,e)=>{P$.init(t,e),fe.init(t,e)}),$p=E("ZodGUID",(t,e)=>{C$.init(t,e),fe.init(t,e)}),So=E("ZodUUID",(t,e)=>{I$.init(t,e),fe.init(t,e)}),aT=E("ZodURL",(t,e)=>{R$.init(t,e),fe.init(t,e)}),lT=E("ZodEmoji",(t,e)=>{D$.init(t,e),fe.init(t,e)}),cT=E("ZodNanoID",(t,e)=>{O$.init(t,e),fe.init(t,e)}),uT=E("ZodCUID",(t,e)=>{z$.init(t,e),fe.init(t,e)}),hT=E("ZodCUID2",(t,e)=>{L$.init(t,e),fe.init(t,e)}),dT=E("ZodULID",(t,e)=>{M$.init(t,e),fe.init(t,e)}),pT=E("ZodXID",(t,e)=>{N$.init(t,e),fe.init(t,e)}),fT=E("ZodKSUID",(t,e)=>{U$.init(t,e),fe.init(t,e)}),gT=E("ZodIPv4",(t,e)=>{V$.init(t,e),fe.init(t,e)}),mT=E("ZodIPv6",(t,e)=>{j$.init(t,e),fe.init(t,e)}),vT=E("ZodCIDRv4",(t,e)=>{G$.init(t,e),fe.init(t,e)}),yT=E("ZodCIDRv6",(t,e)=>{W$.init(t,e),fe.init(t,e)}),bT=E("ZodBase64",(t,e)=>{q$.init(t,e),fe.init(t,e)}),wT=E("ZodBase64URL",(t,e)=>{K$.init(t,e),fe.init(t,e)}),_T=E("ZodE164",(t,e)=>{J$.init(t,e),fe.init(t,e)}),ST=E("ZodJWT",(t,e)=>{Q$.init(t,e),fe.init(t,e)}),km=E("ZodNumber",(t,e)=>{hm.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(r,i,s)=>b1(t,r,i),t.gt=(r,i)=>t.check(kp(r,i)),t.gte=(r,i)=>t.check(Ml(r,i)),t.min=(r,i)=>t.check(Ml(r,i)),t.lt=(r,i)=>t.check(Sp(r,i)),t.lte=(r,i)=>t.check(Ll(r,i)),t.max=(r,i)=>t.check(Ll(r,i)),t.int=r=>t.check(Ap(r)),t.safe=r=>t.check(Ap(r)),t.positive=r=>t.check(kp(0,r)),t.nonnegative=r=>t.check(Ml(0,r)),t.negative=r=>t.check(Sp(0,r)),t.nonpositive=r=>t.check(Ll(0,r)),t.multipleOf=(r,i)=>t.check(xp(r,i)),t.step=(r,i)=>t.check(xp(r,i)),t.finite=()=>t;const n=t._zod.bag;t.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),t.isFinite=!0,t.format=n.format??null});function U(t){return KA(km,t)}const kT=E("ZodNumberFormat",(t,e)=>{eA.init(t,e),km.init(t,e)});function Ap(t){return JA(kT,t)}const xT=E("ZodBoolean",(t,e)=>{tA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>w1(t,n,r)});function xe(t){return XA(xT,t)}const ET=E("ZodUnknown",(t,e)=>{nA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>S1()});function w(){return QA(ET)}const $T=E("ZodNever",(t,e)=>{rA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>_1(t,n,r)});function AT(t){return e1($T,t)}const TT=E("ZodArray",(t,e)=>{iA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>A1(t,n,r,i),t.element=e.element,t.min=(n,r)=>t.check(ra(n,r)),t.nonempty=n=>t.check(ra(1,n)),t.max=(n,r)=>t.check(gm(n,r)),t.length=(n,r)=>t.check(mm(n,r)),t.unwrap=()=>t.element});function D(t,e){return d1(TT,t,e)}const xm=E("ZodObject",(t,e)=>{oA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>T1(t,n,r,i),Q(t,"shape",()=>e.shape),t.keyof=()=>sa(Object.keys(t._zod.def.shape)),t.catchall=n=>t.clone({...t._zod.def,catchall:n}),t.passthrough=()=>t.clone({...t._zod.def,catchall:w()}),t.loose=()=>t.clone({...t._zod.def,catchall:w()}),t.strict=()=>t.clone({...t._zod.def,catchall:AT()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=n=>AE(t,n),t.safeExtend=n=>TE(t,n),t.merge=n=>CE(t,n),t.pick=n=>EE(t,n),t.omit=n=>$E(t,n),t.partial=(...n)=>IE($m,t,n[0]),t.required=(...n)=>PE(Am,t,n[0])});function Em(t,e){const n={type:"object",shape:t??{},...O(e)};return new xm(n)}function f(t,e){return new xm({type:"object",shape:t,catchall:w(),...O(e)})}const CT=E("ZodUnion",(t,e)=>{aA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>C1(t,n,r,i),t.options=e.options});function H(t,e){return new CT({type:"union",options:t,...O(e)})}const IT=E("ZodIntersection",(t,e)=>{lA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>I1(t,n,r,i)});function Za(t,e){return new IT({type:"intersection",left:t,right:e})}const PT=E("ZodRecord",(t,e)=>{cA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>P1(t,n,r,i),t.keyType=e.keyType,t.valueType=e.valueType});function S(t,e,n){return new PT({type:"record",keyType:t,valueType:e,...O(n)})}const bc=E("ZodEnum",(t,e)=>{uA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(r,i,s)=>k1(t,r,i),t.enum=e.entries,t.options=Object.values(e.entries);const n=new Set(Object.keys(e.entries));t.extract=(r,i)=>{const s={};for(const o of r)if(n.has(o))s[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new bc({...e,checks:[],...O(i),entries:s})},t.exclude=(r,i)=>{const s={...e.entries};for(const o of r)if(n.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new bc({...e,checks:[],...O(i),entries:s})}});function sa(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new bc({type:"enum",entries:n,...O(e)})}const RT=E("ZodLiteral",(t,e)=>{hA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>x1(t,n,r),t.values=new Set(e.values),Object.defineProperty(t,"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 A(t,e){return new RT({type:"literal",values:Array.isArray(t)?t:[t],...O(e)})}const DT=E("ZodTransform",(t,e)=>{dA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>$1(t,n),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Yg(t.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(Xi(s,n.value,e));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),n.issues.push(Xi(o))}};const i=e.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n)):(n.value=i,n)}});function OT(t){return new DT({type:"transform",transform:t})}const $m=E("ZodOptional",(t,e)=>{fm.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>wm(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function Tp(t){return new $m({type:"optional",innerType:t})}const zT=E("ZodExactOptional",(t,e)=>{pA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>wm(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function LT(t){return new zT({type:"optional",innerType:t})}const MT=E("ZodNullable",(t,e)=>{fA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>R1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function Cp(t){return new MT({type:"nullable",innerType:t})}const NT=E("ZodDefault",(t,e)=>{gA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>O1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function UT(t,e){return new NT({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():Qg(e)}})}const FT=E("ZodPrefault",(t,e)=>{mA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>z1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function ZT(t,e){return new FT({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():Qg(e)}})}const Am=E("ZodNonOptional",(t,e)=>{vA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>D1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function HT(t,e){return new Am({type:"nonoptional",innerType:t,...O(e)})}const BT=E("ZodCatch",(t,e)=>{yA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>L1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function VT(t,e){return new BT({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const jT=E("ZodPipe",(t,e)=>{bA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>M1(t,n,r,i),t.in=e.in,t.out=e.out});function Ip(t,e){return new jT({type:"pipe",in:t,out:e})}const GT=E("ZodReadonly",(t,e)=>{wA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>N1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function WT(t){return new GT({type:"readonly",innerType:t})}const qT=E("ZodCustom",(t,e)=>{_A.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>E1(t,n)});function YT(t,e={}){return p1(qT,t,e)}function KT(t){return f1(t)}const JT=["text/markdown","text/html"],XT=["committed","pending"];Em({id:h().min(1),type:sa(JT),title:h(),status:sa(XT),externalFilePath:h().optional()});Em({name:h().min(1),description:h(),accepts:D(h().min(1)).min(1)});function Fu(t){return typeof t=="object"&&t!==null}function QT(t){return!Fu(t)||t.type!=="ready"?!1:!("id"in t)}function eC(t){return!(!Fu(t)||t.type!=="update-content"||typeof t.id!="string"||typeof t.content!="string")}function tC(t){return!Fu(t)||t.type!=="wheel"||typeof t.deltaX!="number"||typeof t.deltaY!="number"||typeof t.shiftKey!="boolean"?!1:!("id"in t)}function nC(t,e){if(t===e)return 2;if(t==="*/*")return 0;const n=t.indexOf("/");if(n>0&&t.slice(n+1)==="*"){const r=t.slice(0,n),i=e.indexOf("/");if(i>0&&e.slice(0,i)===r)return 1}return null}function rC(t,e){let n=null;for(const r of t.accepts){const i=nC(r,e);i!==null&&(n===null||i>n)&&(n=i)}return n}function iC(t,e){let n=-1,r=null;for(const i of e){const s=rC(i,t);s!==null&&(s>n||s===n&&r!==null&&i.id<r.id)&&(n=s,r=i)}return r}const sC=4401;class wc extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class _c extends gt{constructor(n){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(n.url),this.name=n.name,this.token=n.token??null,this.createSocket=n.createSocket??(r=>new WebSocket(r)),this.createClient=n.createClient??((r,i)=>new lE(r,{token:i??void 0})),this.client=this.createClient(this.url,this.token)}async connect(){var i;this.connectAttempt+=1;const n=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this.token),this.status="connecting",this.dispatchEvent(new ee("change"));const r=this.createSocket(oC(this.url,this.token));return this.socket=r,await new Promise((s,o)=>{let a=!1;const c=()=>{a||this.connectAttempt!==n||(a=!0,this.status="connected",this.dispatchEvent(new ee("change")),s())},u=p=>{a||this.connectAttempt!==n||(a=!0,this.status="disconnected",this.dispatchEvent(new ee("change")),o(p))},d=async()=>{try{const[{screens:p},y]=await Promise.all([this.client.screens.list(),this.client.views.list()]);this.screens=new Map(p.map(v=>[v.id,structuredClone(v)])),this.views=y,this.dispatchEvent(new ee("change")),c()}catch(p){u(p instanceof Error?p:new Error(String(p)))}};r.addEventListener("open",()=>{d()}),r.addEventListener("message",p=>{const y=lC(p);y&&(this.applyServerEvent(y),this.dispatchEvent(new Ug("server-event",{serverURL:this.url,event:y})))}),r.addEventListener("close",p=>{if(this.connectAttempt===n){if(this.socket=null,aC(p)===sC){u(new wc);return}if(!a){u(new Error("Connection closed before initialization"));return}this.status="disconnected",this.dispatchEvent(new ee("change"))}}),r.addEventListener("error",()=>{u(new Error("WebSocket connection failed"))})})}disconnect(){var n;this.connectAttempt+=1,(n=this.socket)==null||n.close(),this.socket=null,this.status="disconnected",this.dispatchEvent(new ee("change"))}getViewURL(n){const r=iC(n.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(n){const r=`${this.url}/artifacts/${encodeURIComponent(n)}/content`;return this.token===null?r:`${r}?token=${encodeURIComponent(this.token)}`}async createScreen(n){const{screen:r}=await this.client.screens.create({name:n});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(n){switch(n.type){case"screen-created":this.screens.set(n.screen.id,structuredClone(n.screen)),this.dispatchEvent(new Fo("screens-changed"));break;case"screen-updated":this.screens.set(n.screen.id,structuredClone(n.screen)),this.dispatchEvent(new Fo("screens-changed"));break;case"screen-removed":this.screens.delete(n.screenID),this.dispatchEvent(new Fo("screens-changed"));break;case"artifact-created":{const r=this.screens.get(n.screenID);r&&!Lg(r.layout,n.artifact.id)&&(r.layout=[...r.layout,zg(n.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(n.screenID);r&&(r.layout=$g(r.layout,n.artifactID));break}}}}function oC(t,e){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname="/events",n.search="",e&&n.searchParams.set("token",e),n.hash="",n.toString()}function aC(t){return typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="number"?t.code:null}function lC(t){const e=typeof t=="string"?t:typeof t=="object"&&t!==null&&"data"in t&&typeof t.data=="string"?t.data:"";if(!e)return null;try{return JSON.parse(e)}catch{return null}}class cC extends gt{constructor(n){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 n=this.localStore.get().activeServerURL;n!==this.lastActiveServerURL&&(this.lastActiveServerURL=n,this.dispatchEvent(new ee("change")))});this.localStore=n.localStore,this.localServerURL=n.localServerURL?kt(n.localServerURL):null,this.createSocket=n.createSocket??(r=>new WebSocket(r)),this.lastActiveServerURL=this.localStore.get().activeServerURL,this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const n=this.localStore.get().activeServerURL;return n===null?null:this.servers.get(n)??null}add(n){const r=kt(n.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,n);const s=()=>{this.dispatchEvent(new ee("change"))},o=c=>{this.dispatchEvent(new Ug("server-event",{serverURL:c.serverURL,event:c.event}))},a=()=>{this.dispatchEvent(new Fo("screens-changed"))};n.addEventListener("change",s),n.addEventListener("server-event",o),n.addEventListener("screens-changed",a),this.serverListeners.set(r,{onServerChange:s,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new ee("change"))}remove(n){const r=kt(n);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 ee("change"))}setActive(n){const r=this.localStore.get(),i=n?kt(n.url):null;r.activeServerURL!==i&&this.localStore.set({...r,activeServerURL:i})}connectConfiguredServers(n,r){const i=this.localStore.get().servers,s=n?kt(n):null;for(const a of i){const c=kt(a.url),u=s!==null&&c===s,d=new _c({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(n,r){const i=kt(n);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 _c({url:i,name:r,createSocket:this.createSocket});this.add(o),this.setActive(o),o.connect().catch(()=>{})}removeServer(n){this.remove(n)}}const oe={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"},uC=1,hC=f({_meta:S(h(),w()).nullish(),terminal:xe().optional().default(!1)}),dC=f({_meta:S(h(),w()).nullish(),label:h().nullish(),name:h(),optional:xe().optional().default(!1),secret:xe().optional().default(!0)}),pC=f({_meta:S(h(),w()).nullish(),description:h().nullish(),id:h(),name:h()}),fC=f({_meta:S(h(),w()).nullish(),description:h().nullish(),id:h(),link:h().nullish(),name:h(),vars:D(dC)}),gC=f({_meta:S(h(),w()).nullish(),args:D(h()).optional(),description:h().nullish(),env:S(h(),h()).optional(),id:h(),name:h()}),mC=H([fC.and(f({type:A("env_var")})),gC.and(f({type:A("terminal")})),pC]),vC=f({_meta:S(h(),w()).nullish(),methodId:h()}),yC=f({_meta:S(h(),w()).nullish()}),bC=f({_meta:S(h(),w()).nullish(),blob:h(),mimeType:h().nullish(),uri:h()}),wC=f({default:xe().nullish(),description:h().nullish(),title:h().nullish()}),_C=f({_meta:S(h(),w()).nullish()}),SC=f({_meta:S(h(),w()).nullish()}),kC=f({amount:U(),currency:h()}),xC=f({_meta:S(h(),w()).nullish(),terminalId:h()}),EC=f({_meta:S(h(),w()).nullish(),newText:h(),oldText:h().nullish(),path:h()}),$C=H([h(),U(),U(),xe(),D(h())]),AC=f({content:S(h(),$C).nullish()}),TC=H([AC.and(f({action:A("accept")})),f({action:A("decline")}),f({action:A("cancel")})]),CC=f({_meta:S(h(),w()).nullish()}),Tm=h(),IC=f({_meta:S(h(),w()).nullish(),elicitationId:Tm}),PC=f({_meta:S(h(),w()).nullish(),action:TC}),RC=A("object"),DC=A("string"),OC=f({_meta:S(h(),w()).nullish()}),zC=f({_meta:S(h(),w()).nullish(),form:CC.nullish(),url:OC.nullish()}),LC=f({elicitationId:Tm,url:h().url()}),Cm=f({const:h(),title:h()}),Im=f({_meta:S(h(),w()).nullish(),name:h(),value:h()}),MC=H([A(-32700),A(-32600),A(-32601),A(-32602),A(-32603),A(-32800),A(-32e3),A(-32002),A(-32042),U().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),Pm=f({code:MC,data:w().optional(),message:h()}),Rm=w(),Dm=w(),Om=w(),NC=f({_meta:S(h(),w()).nullish(),readTextFile:xe().optional().default(!1),writeTextFile:xe().optional().default(!1)}),zm=f({_meta:S(h(),w()).nullish(),name:h(),value:h()}),Lm=f({_meta:S(h(),w()).nullish(),name:h(),title:h().nullish(),version:h()}),UC=f({default:U().nullish(),description:h().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:h().nullish()}),FC=f({_meta:S(h(),w()).nullish()}),ZC=f({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cursor:h().nullish(),cwd:h().nullish()}),HC=f({_meta:S(h(),w()).nullish()}),BC=f({_meta:S(h(),w()).nullish(),logout:HC.nullish()}),VC=f({_meta:S(h(),w()).nullish()}),jC=f({_meta:S(h(),w()).nullish()}),GC=f({_meta:S(h(),w()).nullish(),http:xe().optional().default(!1),sse:xe().optional().default(!1)}),WC=f({_meta:S(h(),w()).nullish(),headers:D(zm),name:h(),url:h()}),qC=f({_meta:S(h(),w()).nullish(),headers:D(zm),name:h(),url:h()}),YC=f({_meta:S(h(),w()).nullish(),args:D(h()),command:h(),env:D(Im),name:h()}),Ha=H([WC.and(f({type:A("http")})),qC.and(f({type:A("sse")})),YC]),Zu=h(),KC=f({_meta:S(h(),w()).nullish(),description:h().nullish(),modelId:Zu,name:h()}),JC=H([A("error"),A("warning"),A("information"),A("hint")]),XC=f({_meta:S(h(),w()).nullish()}),QC=f({_meta:S(h(),w()).nullish()}),eI=f({_meta:S(h(),w()).nullish()}),tI=f({_meta:S(h(),w()).nullish()}),nI=f({_meta:S(h(),w()).nullish()}),rI=f({_meta:S(h(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),iI=f({diff:h(),uri:h()}),sI=f({endLine:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:h()}),oI=f({_meta:S(h(),w()).nullish()}),aI=f({_meta:S(h(),w()).nullish()}),lI=f({languageId:h(),text:h(),uri:h()}),cI=f({_meta:S(h(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),uI=H([A("rejected"),A("ignored"),A("replaced"),A("cancelled")]),hI=f({excerpts:D(sI),uri:h()}),dI=f({_meta:S(h(),w()).nullish()}),pI=f({_meta:S(h(),w()).nullish()}),fI=f({name:h(),owner:h(),remoteUrl:h()}),gI=f({_meta:S(h(),w()).nullish()}),mI=f({_meta:S(h(),w()).nullish(),jump:oI.nullish(),rename:pI.nullish(),searchAndReplace:gI.nullish()}),vI=f({id:h(),isRegex:xe().nullish(),replace:h(),search:h(),uri:h()}),yI=H([A("automatic"),A("diagnostic"),A("manual")]),bI=f({_meta:S(h(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),wI=f({_meta:S(h(),w()).nullish(),diagnostics:XC.nullish(),editHistory:rI.nullish(),openFiles:aI.nullish(),recentFiles:cI.nullish(),relatedSnippets:dI.nullish(),userActions:bI.nullish()}),_I=f({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ha)}),SI=f({default:U().nullish(),description:h().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:h().nullish()}),Mm=h(),kI=H([A("allow_once"),A("allow_always"),A("reject_once"),A("reject_always")]),xI=f({_meta:S(h(),w()).nullish(),kind:kI,name:h(),optionId:Mm}),EI=H([A("high"),A("medium"),A("low")]),$I=H([A("pending"),A("in_progress"),A("completed")]),AI=f({_meta:S(h(),w()).nullish(),content:h(),priority:EI,status:$I}),TI=f({_meta:S(h(),w()).nullish(),entries:D(AI)}),mn=f({character:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),CI=f({id:h(),position:mn,uri:h()}),II=f({id:h(),newName:h(),position:mn,uri:h()}),PI=f({action:h(),position:mn,timestampMs:U(),uri:h()}),Nm=H([A("utf-16"),A("utf-32"),A("utf-8")]),RI=f({_meta:S(h(),w()).nullish(),auth:hC.optional().default({terminal:!1}),elicitation:zC.nullish(),fs:NC.optional().default({readTextFile:!1,writeTextFile:!1}),nes:mI.nullish(),positionEncodings:D(Nm).optional(),terminal:xe().optional().default(!1)}),DI=f({_meta:S(h(),w()).nullish(),audio:xe().optional().default(!1),embeddedContext:xe().optional().default(!1),image:xe().optional().default(!1)}),Um=U().int().gte(0).lte(65535),OI=f({_meta:S(h(),w()).nullish(),clientCapabilities:RI.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Lm.nullish(),protocolVersion:Um}),gi=f({end:mn,start:mn}),zI=f({message:h(),range:gi,severity:JC,uri:h()}),LI=f({languageId:h(),lastFocusedMs:U().nullish(),uri:h(),visibleRange:gi.nullish()}),MI=f({_meta:S(h(),w()).nullish(),diagnostics:D(zI).nullish(),editHistory:D(iI).nullish(),openFiles:D(LI).nullish(),recentFiles:D(lI).nullish(),relatedSnippets:D(hI).nullish(),userActions:D(PI).nullish()}),NI=f({newText:h(),range:gi}),UI=f({cursorPosition:mn.nullish(),edits:D(NI),id:h(),uri:h()}),FI=H([UI.and(f({kind:A("edit")})),CI.and(f({kind:A("jump")})),II.and(f({kind:A("rename")})),vI.and(f({kind:A("searchAndReplace")}))]),ZI=f({_meta:S(h(),w()).nullish(),content:h()}),HI=f({_meta:S(h(),w()).nullish()}),or=H([U(),h()]).nullable();f({_meta:S(h(),w()).nullish(),requestId:or});const BI=sa(["assistant","user"]),Qs=f({_meta:S(h(),w()).nullish(),audience:D(BI).nullish(),lastModified:h().nullish(),priority:U().nullish()}),VI=f({_meta:S(h(),w()).nullish(),annotations:Qs.nullish(),data:h(),mimeType:h()}),jI=f({_meta:S(h(),w()).nullish(),annotations:Qs.nullish(),data:h(),mimeType:h(),uri:h().nullish()}),GI=f({_meta:S(h(),w()).nullish(),annotations:Qs.nullish(),description:h().nullish(),mimeType:h().nullish(),name:h(),size:U().nullish(),title:h().nullish(),uri:h()}),WI=f({_meta:S(h(),w()).nullish(),optionId:Mm}),qI=H([f({outcome:A("cancelled")}),WI.and(f({outcome:A("selected")}))]),YI=f({_meta:S(h(),w()).nullish(),outcome:qI}),KI=f({_meta:S(h(),w()).nullish()}),JI=f({_meta:S(h(),w()).nullish()}),XI=f({currentValue:xe()}),QI=h(),Fm=h(),eP=H([A("mode"),A("model"),A("thought_level"),h()]),Hu=h(),Zm=f({_meta:S(h(),w()).nullish(),description:h().nullish(),name:h(),value:Hu}),tP=f({_meta:S(h(),w()).nullish(),group:QI,name:h(),options:D(Zm)}),nP=H([D(Zm),D(tP)]),rP=f({currentValue:Hu,options:nP}),mi=Za(H([rP.and(f({type:A("select")})),XI.and(f({type:A("boolean")}))]),f({_meta:S(h(),w()).nullish(),category:eP.nullish(),description:h().nullish(),id:Fm,name:h()})),iP=f({_meta:S(h(),w()).nullish(),configOptions:D(mi)}),sP=f({_meta:S(h(),w()).nullish()}),Y=h(),oP=f({_meta:S(h(),w()).nullish(),id:h(),sessionId:Y}),aP=f({_meta:S(h(),w()).nullish(),sessionId:Y}),lP=f({_meta:S(h(),w()).nullish(),sessionId:Y}),cP=f({_meta:S(h(),w()).nullish(),sessionId:Y}),Hm=f({_meta:S(h(),w()).nullish(),args:D(h()).optional(),command:h(),cwd:h().nullish(),env:D(Im).optional(),outputByteLimit:U().nullish(),sessionId:Y}),uP=f({_meta:S(h(),w()).nullish(),sessionId:Y,uri:h()}),hP=f({_meta:S(h(),w()).nullish(),position:mn,sessionId:Y,uri:h(),version:U(),visibleRange:gi}),dP=f({_meta:S(h(),w()).nullish(),languageId:h(),sessionId:Y,text:h(),uri:h(),version:U()}),pP=f({_meta:S(h(),w()).nullish(),sessionId:Y,uri:h()}),fP=f({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ha).optional(),sessionId:Y}),Bm=f({_meta:S(h(),w()).nullish(),sessionId:Y,terminalId:h()}),gP=f({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ha),sessionId:Y}),Vm=f({_meta:S(h(),w()).nullish(),limit:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h(),sessionId:Y}),mP=f({_meta:S(h(),w()).nullish(),id:h(),reason:uI.nullish(),sessionId:Y}),jm=f({_meta:S(h(),w()).nullish(),sessionId:Y,terminalId:h()}),vP=f({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ha).optional(),sessionId:Y}),yP=f({_meta:S(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),sessionId:Y,title:h().nullish(),updatedAt:h().nullish()}),bP=f({_meta:S(h(),w()).nullish(),nextCursor:h().nullish(),sessions:D(yP)}),wP=f({_meta:S(h(),w()).nullish(),title:h().nullish(),updatedAt:h().nullish()}),_P=f({_meta:S(h(),w()).nullish()}),Ba=h(),SP=f({_meta:S(h(),w()).nullish(),currentModeId:Ba}),kP=f({_meta:S(h(),w()).nullish(),description:h().nullish(),id:Ba,name:h()}),Va=f({_meta:S(h(),w()).nullish(),availableModes:D(kP),currentModeId:Ba}),ja=f({_meta:S(h(),w()).nullish(),availableModels:D(KC),currentModelId:Zu}),xP=f({_meta:S(h(),w()).nullish(),configOptions:D(mi).nullish(),models:ja.nullish(),modes:Va.nullish(),sessionId:Y}),EP=f({_meta:S(h(),w()).nullish(),configOptions:D(mi).nullish(),models:ja.nullish(),modes:Va.nullish()}),$P=f({_meta:S(h(),w()).nullish(),configOptions:D(mi).nullish(),models:ja.nullish(),modes:Va.nullish(),sessionId:Y}),AP=f({_meta:S(h(),w()).nullish(),configOptions:D(mi).nullish(),models:ja.nullish(),modes:Va.nullish()}),TP=f({_meta:S(h(),w()).nullish()}),CP=f({_meta:S(h(),w()).nullish(),additionalDirectories:KI.nullish(),close:JI.nullish(),fork:sP.nullish(),list:_P.nullish(),resume:TP.nullish()}),IP=Za(H([f({type:A("boolean"),value:xe()}),f({value:Hu})]),f({_meta:S(h(),w()).nullish(),configId:Fm,sessionId:Y})),PP=f({_meta:S(h(),w()).nullish(),configOptions:D(mi)}),RP=f({_meta:S(h(),w()).nullish(),modeId:Ba,sessionId:Y}),DP=f({_meta:S(h(),w()).nullish()}),OP=f({_meta:S(h(),w()).nullish(),modelId:Zu,sessionId:Y}),zP=f({_meta:S(h(),w()).nullish()}),LP=f({_meta:S(h(),w()).nullish(),sessionId:Y}),MP=H([A("end_turn"),A("max_tokens"),A("max_turn_requests"),A("refusal"),A("cancelled")]),NP=H([A("email"),A("uri"),A("date"),A("date-time")]),UP=f({default:h().nullish(),description:h().nullish(),enum:D(h()).nullish(),format:NP.nullish(),maxLength:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:D(Cm).nullish(),pattern:h().nullish(),title:h().nullish()}),FP=f({_meta:S(h(),w()).nullish(),context:MI.nullish(),position:mn,selection:gi.nullish(),sessionId:Y,triggerKind:yI,uri:h(),version:U()}),ZP=f({_meta:S(h(),w()).nullish(),suggestions:D(FI)}),HP=f({_meta:S(h(),w()).nullish(),terminalId:h()}),BP=f({_meta:S(h(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),Gm=f({_meta:S(h(),w()).nullish(),sessionId:Y,terminalId:h()}),VP=f({_meta:S(h(),w()).nullish(),exitStatus:BP.nullish(),output:h(),truncated:xe()}),jP=f({_meta:S(h(),w()).nullish(),annotations:Qs.nullish(),text:h()}),GP=f({range:gi.nullish(),text:h()}),WP=f({_meta:S(h(),w()).nullish(),contentChanges:D(GP),sessionId:Y,uri:h(),version:U()});f({method:h(),params:H([aP,dP,WP,uP,pP,hP,oP,mP,Rm]).nullish()});const qP=H([A("full"),A("incremental")]),YP=f({_meta:S(h(),w()).nullish(),syncKind:qP}),KP=f({_meta:S(h(),w()).nullish(),didChange:YP.nullish(),didClose:QC.nullish(),didFocus:eI.nullish(),didOpen:tI.nullish(),didSave:nI.nullish()}),JP=f({_meta:S(h(),w()).nullish(),document:KP.nullish()}),XP=f({_meta:S(h(),w()).nullish(),context:wI.nullish(),events:JP.nullish()}),QP=f({_meta:S(h(),w()).nullish(),auth:BC.optional().default({}),loadSession:xe().optional().default(!1),mcpCapabilities:GC.optional().default({http:!1,sse:!1}),nes:XP.nullish(),positionEncoding:Nm.nullish(),promptCapabilities:DI.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:CP.optional().default({})}),eR=f({_meta:S(h(),w()).nullish(),agentCapabilities:QP.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Lm.nullish(),authMethods:D(mC).optional().default([]),protocolVersion:Um}),tR=f({_meta:S(h(),w()).nullish(),mimeType:h().nullish(),text:h(),uri:h()}),nR=H([tR,bC]),rR=f({_meta:S(h(),w()).nullish(),annotations:Qs.nullish(),resource:nR}),Bu=H([jP.and(f({type:A("text")})),jI.and(f({type:A("image")})),VI.and(f({type:A("audio")})),GI.and(f({type:A("resource_link")})),rR.and(f({type:A("resource")}))]),iR=f({_meta:S(h(),w()).nullish(),content:Bu}),Nl=f({_meta:S(h(),w()).nullish(),content:Bu,messageId:h().nullish()}),sR=f({_meta:S(h(),w()).nullish(),messageId:h().nullish(),prompt:D(Bu),sessionId:Y}),oR=f({anyOf:D(Cm)}),Wm=H([iR.and(f({type:A("content")})),EC.and(f({type:A("diff")})),HP.and(f({type:A("terminal")}))]),qm=h(),Ym=f({_meta:S(h(),w()).nullish(),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h()}),Km=H([A("pending"),A("in_progress"),A("completed"),A("failed")]),Jm=H([A("read"),A("edit"),A("delete"),A("move"),A("search"),A("execute"),A("think"),A("fetch"),A("switch_mode"),A("other")]),aR=f({_meta:S(h(),w()).nullish(),content:D(Wm).optional(),kind:Jm.optional(),locations:D(Ym).optional(),rawInput:w().optional(),rawOutput:w().optional(),status:Km.optional(),title:h(),toolCallId:qm}),Xm=f({_meta:S(h(),w()).nullish(),content:D(Wm).nullish(),kind:Jm.nullish(),locations:D(Ym).nullish(),rawInput:w().optional(),rawOutput:w().optional(),status:Km.nullish(),title:h().nullish(),toolCallId:qm}),Qm=f({_meta:S(h(),w()).nullish(),options:D(xI),sessionId:Y,toolCall:Xm}),lR=f({_meta:S(h(),w()).nullish(),hint:h()}),cR=lR,uR=f({_meta:S(h(),w()).nullish(),description:h(),input:cR.nullish(),name:h()}),hR=f({_meta:S(h(),w()).nullish(),availableCommands:D(uR)}),dR=f({enum:D(h()),type:DC}),pR=H([dR,oR]),fR=f({default:D(h()).nullish(),description:h().nullish(),items:pR,maxItems:U().nullish(),minItems:U().nullish(),title:h().nullish()}),gR=H([UP.and(f({type:A("string")})),SI.and(f({type:A("number")})),UC.and(f({type:A("integer")})),wC.and(f({type:A("boolean")})),fR.and(f({type:A("array")}))]),mR=f({description:h().nullish(),properties:S(h(),gR).optional().default({}),required:D(h()).nullish(),title:h().nullish(),type:RC.optional().default("object")}),vR=f({requestedSchema:mR}),yR=Za(H([vR.and(f({mode:A("form")})),LC.and(f({mode:A("url")}))]),f({_meta:S(h(),w()).nullish(),message:h(),sessionId:Y})),bR=f({cachedReadTokens:U().nullish(),cachedWriteTokens:U().nullish(),inputTokens:U(),outputTokens:U(),thoughtTokens:U().nullish(),totalTokens:U()}),wR=f({_meta:S(h(),w()).nullish(),stopReason:MP,usage:bR.nullish(),userMessageId:h().nullish()});H([f({id:or,result:H([eR,yC,jC,$P,EP,bP,xP,AP,SC,DP,PP,wR,zP,LP,ZP,_C,Om])}),f({error:Pm,id:or})]);const _R=f({_meta:S(h(),w()).nullish(),cost:kC.nullish(),size:U(),used:U()}),SR=H([Nl.and(f({sessionUpdate:A("user_message_chunk")})),Nl.and(f({sessionUpdate:A("agent_message_chunk")})),Nl.and(f({sessionUpdate:A("agent_thought_chunk")})),aR.and(f({sessionUpdate:A("tool_call")})),Xm.and(f({sessionUpdate:A("tool_call_update")})),TI.and(f({sessionUpdate:A("plan")})),hR.and(f({sessionUpdate:A("available_commands_update")})),SP.and(f({sessionUpdate:A("current_mode_update")})),iP.and(f({sessionUpdate:A("config_option_update")})),wP.and(f({sessionUpdate:A("session_info_update")})),_R.and(f({sessionUpdate:A("usage_update")}))]),ev=f({_meta:S(h(),w()).nullish(),sessionId:Y,update:SR});f({method:h(),params:H([ev,IC,Rm]).nullish()});const tv=f({_meta:S(h(),w()).nullish(),sessionId:Y,terminalId:h()}),kR=f({_meta:S(h(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),xR=f({name:h(),uri:h()}),ER=f({_meta:S(h(),w()).nullish(),repository:fI.nullish(),workspaceFolders:D(xR).nullish(),workspaceUri:h().nullish()});f({id:or,method:h(),params:H([OI,vC,VC,_I,gP,ZC,fP,vP,cP,RP,IP,sR,OP,ER,FP,lP,Dm]).nullish()});const nv=f({_meta:S(h(),w()).nullish(),content:h(),path:h(),sessionId:Y});f({id:or,method:h(),params:H([nv,Vm,Qm,Hm,Gm,jm,tv,Bm,yR,Dm]).nullish()});const $R=f({_meta:S(h(),w()).nullish()});H([f({id:or,result:H([$R,ZI,YI,xC,VP,HI,kR,FC,PC,Om])}),f({error:Pm,id:or})]);var q;class AR{constructor(e,n){_(this,q);const r=e(this),i=async(o,a)=>{var c,u,d,p,y,v,$;switch(o){case Ot.fs_write_text_file:{const k=nv.parse(a);return(c=r.writeTextFile)==null?void 0:c.call(r,k)}case Ot.fs_read_text_file:{const k=Vm.parse(a);return(u=r.readTextFile)==null?void 0:u.call(r,k)}case Ot.session_request_permission:{const k=Qm.parse(a);return r.requestPermission(k)}case Ot.terminal_create:{const k=Hm.parse(a);return(d=r.createTerminal)==null?void 0:d.call(r,k)}case Ot.terminal_output:{const k=Gm.parse(a);return(p=r.terminalOutput)==null?void 0:p.call(r,k)}case Ot.terminal_release:{const k=jm.parse(a);return await((y=r.releaseTerminal)==null?void 0:y.call(r,k))??{}}case Ot.terminal_wait_for_exit:{const k=tv.parse(a);return(v=r.waitForTerminalExit)==null?void 0:v.call(r,k)}case Ot.terminal_kill:{const k=Bm.parse(a);return await(($=r.killTerminal)==null?void 0:$.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=ev.parse(a);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(o,a);throw we.methodNotFound(o)}};x(this,q,new TR(i,s,n))}async initialize(e){return await l(this,q).sendRequest(oe.initialize,e)}async newSession(e){return await l(this,q).sendRequest(oe.session_new,e)}async loadSession(e){return await l(this,q).sendRequest(oe.session_load,e)??{}}async unstable_forkSession(e){return await l(this,q).sendRequest(oe.session_fork,e)}async listSessions(e){return await l(this,q).sendRequest(oe.session_list,e)}async unstable_resumeSession(e){return await l(this,q).sendRequest(oe.session_resume,e)}async unstable_closeSession(e){return await l(this,q).sendRequest(oe.session_close,e)}async setSessionMode(e){return await l(this,q).sendRequest(oe.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await l(this,q).sendRequest(oe.session_set_model,e)??{}}async setSessionConfigOption(e){return await l(this,q).sendRequest(oe.session_set_config_option,e)}async authenticate(e){return await l(this,q).sendRequest(oe.authenticate,e)??{}}async unstable_logout(e){return await l(this,q).sendRequest(oe.logout,e)??{}}async prompt(e){return await l(this,q).sendRequest(oe.session_prompt,e)}async cancel(e){return await l(this,q).sendNotification(oe.session_cancel,e)}async unstable_startNes(e){return await l(this,q).sendRequest(oe.nes_start,e)}async unstable_suggestNes(e){return await l(this,q).sendRequest(oe.nes_suggest,e)}async unstable_closeNes(e){return await l(this,q).sendRequest(oe.nes_close,e)??{}}async unstable_didOpenDocument(e){return await l(this,q).sendNotification(oe.document_did_open,e)}async unstable_didChangeDocument(e){return await l(this,q).sendNotification(oe.document_did_change,e)}async unstable_didCloseDocument(e){return await l(this,q).sendNotification(oe.document_did_close,e)}async unstable_didSaveDocument(e){return await l(this,q).sendNotification(oe.document_did_save,e)}async unstable_didFocusDocument(e){return await l(this,q).sendNotification(oe.document_did_focus,e)}async unstable_acceptNes(e){return await l(this,q).sendNotification(oe.nes_accept,e)}async unstable_rejectNes(e){return await l(this,q).sendNotification(oe.nes_reject,e)}async extMethod(e,n){return await l(this,q).sendRequest(e,n)}async extNotification(e,n){return await l(this,q).sendNotification(e,n)}get signal(){return l(this,q).signal}get closed(){return l(this,q).closed}}q=new WeakMap;var sn,fa,cs,us,Nr,Ur,Et,hs,he,rv,Sc,iv,sv,ov,av,kc,Mi;class TR{constructor(e,n,r){_(this,he);_(this,sn,new Map);_(this,fa,0);_(this,cs);_(this,us);_(this,Nr);_(this,Ur,Promise.resolve());_(this,Et,new AbortController);_(this,hs);x(this,cs,e),x(this,us,n),x(this,Nr,r),x(this,hs,new Promise(i=>{l(this,Et).signal.addEventListener("abort",()=>i())})),m(this,he,rv).call(this)}get signal(){return l(this,Et).signal}get closed(){return l(this,hs)}async sendRequest(e,n){m(this,he,kc).call(this);const r=Dh(this,fa)._++,i=new Promise((s,o)=>{l(this,sn).set(r,{resolve:s,reject:o})});return await m(this,he,Mi).call(this,{jsonrpc:"2.0",id:r,method:e,params:n}),i}async sendNotification(e,n){m(this,he,kc).call(this),await m(this,he,Mi).call(this,{jsonrpc:"2.0",method:e,params:n})}}sn=new WeakMap,fa=new WeakMap,cs=new WeakMap,us=new WeakMap,Nr=new WeakMap,Ur=new WeakMap,Et=new WeakMap,hs=new WeakMap,he=new WeakSet,rv=async function(){let e;try{const n=l(this,Nr).readable.getReader();try{for(;!l(this,Et).signal.aborted;){const{value:r,done:i}=await n.read();if(i)break;if(r)try{m(this,he,iv).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&m(this,he,Mi).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{n.releaseLock()}}catch(n){e=n}finally{m(this,he,Sc).call(this,e)}},Sc=function(e){if(l(this,Et).signal.aborted)return;const n=e??new Error("ACP connection closed");for(const r of l(this,sn).values())r.reject(n);l(this,sn).clear(),l(this,Et).abort(n)},iv=async function(e){if("method"in e&&"id"in e){const n=await m(this,he,sv).call(this,e.method,e.params);"error"in n&&console.error("Error handling request",e,n.error),await m(this,he,Mi).call(this,{jsonrpc:"2.0",id:e.id,...n})}else if("method"in e){const n=await m(this,he,ov).call(this,e.method,e.params);"error"in n&&console.error("Error handling notification",e,n.error)}else"id"in e?m(this,he,av).call(this,e):console.error("Invalid message",{message:e})},sv=async function(e,n){try{return{result:await l(this,cs).call(this,e,n)??null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof Ep)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()}}},ov=async function(e,n){try{return await l(this,us).call(this,e,n),{result:null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof Ep)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()}}},av=function(e){const n=l(this,sn).get(e.id);if(n){if("result"in e)n.resolve(e.result);else if("error"in e){const{code:r,message:i,data:s}=e.error;n.reject(new we(r,i,s))}l(this,sn).delete(e.id)}else console.error("Got response to unknown request",e.id)},kc=function(){if(l(this,Et).signal.aborted)throw l(this,Et).signal.reason??new Error("ACP connection closed")},Mi=async function(e){return x(this,Ur,l(this,Ur).then(async()=>{const n=l(this,Nr).writable.getWriter();try{await n.write(e)}finally{n.releaseLock()}}).catch(n=>{m(this,he,Sc).call(this,n)})),l(this,Ur)};class we extends Error{constructor(n,r,i){super(r);b(this,"code");b(this,"data");this.code=n,this.name="RequestError",this.data=i}static parseError(n,r){return new we(-32700,`Parse error${r?`: ${r}`:""}`,n)}static invalidRequest(n,r){return new we(-32600,`Invalid request${r?`: ${r}`:""}`,n)}static methodNotFound(n){return new we(-32601,`"Method not found": ${n}`,{method:n})}static invalidParams(n,r){return new we(-32602,`Invalid params${r?`: ${r}`:""}`,n)}static internalError(n,r){return new we(-32603,`Internal error${r?`: ${r}`:""}`,n)}static authRequired(n,r){return new we(-32e3,`Authentication required${r?`: ${r}`:""}`,n)}static resourceNotFound(n){return new we(-32002,`Resource not found${n?`: ${n}`:""}`,n&&{uri:n})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const CR=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,IR=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,PR=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,RR=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,DR="single_session",OR={name:"television-acp-client",version:"0.0.0"},lv="agent:main:television",zR=pi(gt);var te,Nt,Fr,Ut,Vn,jn,on,Zr,$t,lt,an,Gn,Ft,ln,ds,Zt,ct,ga,Ht,C,cv,uv,xc,hv,dv,pv,fv,gv,mv,vv,Cn,Ar,Tr,qe,yv,Cr,Ec,$c,Ho,bv,ps,fs,Ac,Ir,wv,_v;class LR extends zR{constructor(n){super();_(this,C);_(this,te,MR());_(this,Nt,null);_(this,Fr,null);_(this,Ut,null);_(this,Vn,null);_(this,jn,null);_(this,on,null);_(this,Zr,1);_(this,$t,null);_(this,lt,null);_(this,an,!1);_(this,Gn,!1);_(this,Ft,null);_(this,ln,new Set);_(this,ds);_(this,Zt);_(this,ct);_(this,ga,n=>{m(this,C,uv).call(this,n)});_(this,Ht,null);_(this,ps,()=>{m(this,C,Ir).call(this,"ACP bridge websocket closed")});_(this,fs,()=>{m(this,C,Ir).call(this,"ACP bridge websocket error")});x(this,Zt,n),x(this,ct,n.sessionMode??DR),x(this,ds,n.createSocket??(r=>new WebSocket(r)))}getState(){return l(this,te)}get messages(){return l(this,te).messageOrder.map(n=>l(this,te).messagesById[n]).filter(n=>n!==void 0)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(l(this,te).lifecycle.status!=="ready"){m(this,C,qe).call(this,{lifecycle:{status:"connecting"}}),l(this,Fr)??x(this,Fr,m(this,C,cv).call(this));try{await l(this,Fr),await m(this,C,xc).call(this)}catch(n){throw m(this,C,Ir).call(this,ko(n)),n}}}dispose(){m(this,C,Ac).call(this),m(this,C,qe).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null}})}async sendMessage(n){if(await this.connect(),l(this,te).lifecycle.status!=="ready"||l(this,te).run.status==="running"||l(this,te).run.status==="cancelling")throw new Error("ACPClient is not ready to send a new message");const r=n.text.trim();if(!r)throw new Error("Cannot send an empty message");m(this,C,Ar).call(this,{id:m(this,C,Cr).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,Ho).call(this).prompt({sessionId:m(this,C,$c).call(this),prompt:[{type:"text",text:m(this,C,yv).call(this,r)}]});m(this,C,Cn).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,_v).call(this)||(m(this,C,Cn).call(this,"error"),m(this,C,qe).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:ko(i)}})),i}}async cancel(){if(await this.connect(),!l(this,te).run.canCancel||l(this,te).run.status!=="running")throw new Error("No active cancellable run");m(this,C,qe).call(this,{run:{...l(this,te).run,status:"cancelling"}}),await m(this,C,Ho).call(this).cancel({sessionId:m(this,C,$c).call(this)})}setScreenContext(n){var s,o,a;const r={screenID:n.screenID,screenName:n.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(x(this,lt,r),l(this,ct)==="single_session"){(!l(this,on)||i!==r.screenID)&&x(this,an,!0);return}l(this,on)!==Pp(l(this,ct),r.screenID,l(this,Zt).clientGUID??"default-client")&&(x(this,Ut,null),x(this,Vn,null),l(this,Nt)&&l(this,te).run.status==="idle"&&m(this,C,xc).call(this).catch(c=>{m(this,C,Ir).call(this,ko(c))}))}}te=new WeakMap,Nt=new WeakMap,Fr=new WeakMap,Ut=new WeakMap,Vn=new WeakMap,jn=new WeakMap,on=new WeakMap,Zr=new WeakMap,$t=new WeakMap,lt=new WeakMap,an=new WeakMap,Gn=new WeakMap,Ft=new WeakMap,ln=new WeakMap,ds=new WeakMap,Zt=new WeakMap,ct=new WeakMap,ga=new WeakMap,Ht=new WeakMap,C=new WeakSet,cv=async function(){try{m(this,C,qe).call(this,{lifecycle:{status:"connecting"}});const{stream:n,socket:r}=await FR({serverURL:l(this,Zt).serverURL,token:l(this,Zt).token,createSocket:l(this,ds),onDisconnect:l(this,ga)});x(this,Ht,r),r.addEventListener("close",l(this,ps)),r.addEventListener("error",l(this,fs)),x(this,Nt,new AR(i=>({connection:i,sessionUpdate:async s=>{await m(this,C,dv).call(this,s)},requestPermission:async s=>m(this,C,pv).call(this,s)}),n)),await l(this,Nt).initialize({protocolVersion:uC,clientCapabilities:{},clientInfo:OR})}catch(n){throw n}},uv=function(n){m(this,C,Ir).call(this,ko(n))},xc=async function(){const n=m(this,C,bv).call(this);if(l(this,Ut)&&l(this,Vn)===n){await l(this,Ut);return}x(this,Vn,n),x(this,Ut,m(this,C,hv).call(this,n)),await l(this,Ut)},hv=async function(n){const r=m(this,C,Ho).call(this);m(this,C,wv).call(this);let i,s=!1;try{x(this,Gn,!0),x(this,Ft,null),await r.loadSession({sessionId:n,cwd:"/",mcpServers:[],_meta:{sessionKey:n}}),i=n,s=l(this,te).messageOrder.length>0}catch{i=(await r.newSession({cwd:"/",mcpServers:[],_meta:{sessionKey:n}})).sessionId,s=!1}finally{x(this,Gn,!1),x(this,Ft,null),m(this,C,Cn).call(this,"final")}await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),x(this,jn,i),x(this,on,n),s?(l(this,ln).add(n),l(this,ct)==="single_session"&&x(this,an,!1)):(l(this,ln).delete(n),x(this,an,l(this,ct)==="single_session")),m(this,C,qe).call(this,{lifecycle:{status:"ready"}})},dv=async function(n){const r=n.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&m(this,C,vv).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&m(this,C,fv).call(this,r.content.text);return;case"tool_call":m(this,C,gv).call(this,r);return;case"tool_call_update":m(this,C,mv).call(this,r);return;case"agent_thought_chunk":return;default:return}},pv=async function(n){return{outcome:{outcome:"cancelled"}}},fv=function(n){x(this,Ft,null);const r=NR(n);if(!r)return;if(!l(this,$t)){const s={id:m(this,C,Cr).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};x(this,$t,s.id),m(this,C,Ar).call(this,s);return}const i=l(this,te).messagesById[l(this,$t)];if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");m(this,C,Tr).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},gv=function(n){m(this,C,Cn).call(this,"final");const r=m(this,C,Ec).call(this,n.toolCallId),i={id:(r==null?void 0:r.id)??m(this,C,Cr).call(this,"tool"),kind:"tool_call",toolCallId:n.toolCallId,title:n.title,toolKind:n.kind??"other",status:n.status==="failed"?"failed":n.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??"",locations:n.locations??(r==null?void 0:r.locations)};if(r){m(this,C,Tr).call(this,i);return}m(this,C,Ar).call(this,i)},mv=function(n){const r=m(this,C,Ec).call(this,n.toolCallId),i=(r==null?void 0:r.text)??"",s=UR(n.content),o=s?`${i}${s}`:i,a={id:(r==null?void 0:r.id)??m(this,C,Cr).call(this,"tool"),kind:"tool_call",toolCallId:n.toolCallId,title:(r==null?void 0:r.title)??n.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:n.status==="failed"?"failed":n.status==="completed"?"completed":"in_progress",text:o,locations:n.locations??(r==null?void 0:r.locations)};if(r){m(this,C,Tr).call(this,a);return}m(this,C,Ar).call(this,a)},vv=function(n){if(m(this,C,Cn).call(this,"final"),!n)return;const r=l(this,Gn)?l(this,Ft):null;if(!r){const s=Rp(n);if(!s)return;const o={id:m(this,C,Cr).call(this,"user"),kind:"user",text:s,status:"final"};m(this,C,Ar).call(this,o),l(this,Gn)&&x(this,Ft,o.id);return}const i=l(this,te).messagesById[r];if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");m(this,C,Tr).call(this,{...i,text:Rp(`${i.text}${n}`)})},Cn=function(n){if(!l(this,$t))return;const r=l(this,te).messagesById[l(this,$t)];(r==null?void 0:r.kind)==="assistant"&&m(this,C,Tr).call(this,{...r,status:n}),x(this,$t,null)},Ar=function(n){m(this,C,qe).call(this,{messagesById:{...l(this,te).messagesById,[n.id]:n},messageOrder:[...l(this,te).messageOrder,n.id]})},Tr=function(n){m(this,C,qe).call(this,{messagesById:{...l(this,te).messagesById,[n.id]:n}})},qe=function(n){const r={...l(this,te),...n};x(this,te,{...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 ee("change"))},yv=function(n){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))?n:(x(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]","",n].join(`
43
+ `))},Cr=function(n){const r=`${n}-${l(this,Zr)}`;return x(this,Zr,l(this,Zr)+1),r},Ec=function(n){for(const r of l(this,te).messageOrder){const i=l(this,te).messagesById[r];if((i==null?void 0:i.kind)==="tool_call"&&i.toolCallId===n)return i}return null},$c=function(){if(!l(this,jn))throw new Error("ACP session is not ready");return l(this,jn)},Ho=function(){if(!l(this,Nt))throw new Error("ACP connection is not ready");return l(this,Nt)},bv=function(){var r;if(l(this,ct)==="single_session")return`${lv}-${(l(this,Zt).clientGUID??"default-client").toLowerCase()}`;const n=(r=l(this,lt))==null?void 0:r.screenID;if(!n)throw new Error("Screen context is required for per-screen session mode");return Pp(l(this,ct),n,l(this,Zt).clientGUID??"default-client")},ps=new WeakMap,fs=new WeakMap,Ac=function(){x(this,Nt,null),x(this,Fr,null),x(this,Ut,null),x(this,Vn,null),x(this,jn,null),x(this,on,null),l(this,Ht)&&(l(this,Ht).removeEventListener("close",l(this,ps)),l(this,Ht).removeEventListener("error",l(this,fs)),l(this,Ht).close(),x(this,Ht,null))},Ir=function(n){this.disposed||l(this,te).lifecycle.status==="disconnected"||(m(this,C,Cn).call(this,"error"),m(this,C,Ac).call(this),m(this,C,qe).call(this,{lifecycle:{status:"disconnected",...n?{error:n}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null}}))},wv=function(){x(this,$t,null),x(this,Ft,null),x(this,Zr,1),m(this,C,qe).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},_v=function(){return l(this,te).lifecycle.status==="disconnected"};function MR(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function Pp(t,e,n){return t==="single_session"?`${lv}-${n.toLowerCase()}`:`agent:main:television-${n.toLowerCase()}-${e.toLowerCase()}`}function Sv(t){return t.replace(/^(?:\s*\n)+/,"")}function Rp(t){let e=t;return e=e.replace(CR,""),e=e.replace(IR,""),e=e.replace(PR,""),e=Sv(e),e}function NR(t){let e=t;return e=e.replace(RR,""),e=Sv(e),e}function UR(t){return!t||t.length===0?"":t.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function FR(t){const e=t.createSocket(HR(t.serverURL,t.token));let n=!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"}))},p=$=>{const k=ZR($);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"){n||(n=!0,r());return}if(I.status==="error"||I.status==="exited"){const B=new Error(I.error??`ACP bridge ${I.status}`);n||i(B),c.error(B)}return;case"acp-bridge-message":c.enqueue(I.message);return}},y=()=>{var k;if(u)return;u=!0;const $=new Error("ACP bridge websocket closed");n||i($),(k=t.onDisconnect)==null||k.call(t,$),c.close()},v=()=>{var k;if(u)return;u=!0;const $=new Error("ACP bridge websocket error");n||i($),(k=t.onDisconnect)==null||k.call(t,$),c.error($)};e.addEventListener("open",d),e.addEventListener("message",p),e.addEventListener("close",y),e.addEventListener("error",v)}}),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 ZR(t){if(typeof t=="string")return t;if(t instanceof Uint8Array)return new TextDecoder().decode(t);if(typeof Buffer<"u"&&t instanceof Buffer)return t.toString("utf8");if(typeof t=="object"&&t!==null&&"data"in t){const e=t.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 HR(t,e){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname="/acp",n.search="",n.searchParams.set("token",e),n.hash="",n.toString()}function ko(t){return t instanceof Error?t.message:String(t)}const Dp="television.acpClientGUID",BR=pi(gt);class VR extends BR{constructor(n){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=n.screenManager,this.sessionMode=n.sessionMode??"single_session",this.options={serverURL:n.serverURL,token:n.token,...n.createSocket?{createSocket:n.createSocket}:{},...n.sessionMode?{sessionMode:n.sessionMode}:{}},this.clientGUID=n.clientGUID??jR(n.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 n of this.clients.values())n.dispose();this.clients.clear(),this.activeClient=null}syncActiveClient(){const n=this.screenManager.activeScreen,r=n?this.getClientForScreen(n):null;this.activeClient!==r&&(this.activeClient=r,this.dispatchEvent(new ee("change")))}getClientForScreen(n){const r=this.sessionMode==="single_session"?"single_session":n.id;let i=this.clients.get(r);return i||(i=new LR({...this.options,sessionMode:this.sessionMode,clientGUID:this.clientGUID}),this.clients.set(r,i)),i.setScreenContext({screenID:n.id,screenName:n.name}),i}}function jR(t){const e=t.getItem(Dp);if(e)return e;const n=Iu().toLowerCase();return t.setItem(Dp,n),n}var gs;class GR extends gt{constructor(){super();_(this,gs,n=>{const r=WR(n);r!==null&&(n.preventDefault(),this.dispatchEvent(new Dx("shortcut-triggered",{shortcut:r})))});document.addEventListener("keydown",l(this,gs))}dispose(){document.removeEventListener("keydown",l(this,gs))}}gs=new WeakMap;function WR(t){for(const[e,n]of Object.entries(cE))if(qR(t,n.trigger))return e;return null}function qR(t,e){return!(t.key.toLowerCase()!==e.key.toLowerCase()||t.metaKey!==!!e.meta||t.ctrlKey!==!!e.ctrl||t.shiftKey!==!!e.shift||t.altKey!==!!e.alt)}const YR="serverURL",KR="token",JR="mode",XR="electron";function kv(t=window.location.search,e=window.location.origin){const r=new URLSearchParams(t).get(YR);return r?new URL(r).origin:new URL(e).origin}function Tc(t=window.location.search){return new URLSearchParams(t).get(KR)}function xv(t=window.location.search){return new URLSearchParams(t).get(JR)===XR}/**
44
+ * @license
45
+ * Copyright 2017 Google LLC
46
+ * SPDX-License-Identifier: BSD-3-Clause
47
+ */const Yi=globalThis,Op=t=>t,oa=Yi.trustedTypes,zp=oa?oa.createPolicy("lit-html",{createHTML:t=>t}):void 0,Ev="$lit$",en=`lit$${Math.random().toFixed(9).slice(2)}$`,$v="?"+en,QR=`<${$v}>`,ar=document,Qi=()=>ar.createComment(""),es=t=>t===null||typeof t!="object"&&typeof t!="function",Vu=Array.isArray,eD=t=>Vu(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",Ul=`[
48
+ \f\r]`,$i=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Lp=/-->/g,Mp=/>/g,An=RegExp(`>|${Ul}(?:([^\\s"'>=/]+)(${Ul}*=${Ul}*(?:[^
49
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Np=/'/g,Up=/"/g,Av=/^(?:script|style|textarea|title)$/i,tD=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),F=tD(1),ri=Symbol.for("lit-noChange"),ae=Symbol.for("lit-nothing"),Fp=new WeakMap,Mn=ar.createTreeWalker(ar,129);function Tv(t,e){if(!Vu(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return zp!==void 0?zp.createHTML(e):e}const nD=(t,e)=>{const n=t.length-1,r=[];let i,s=e===2?"<svg>":e===3?"<math>":"",o=$i;for(let a=0;a<n;a++){const c=t[a];let u,d,p=-1,y=0;for(;y<c.length&&(o.lastIndex=y,d=o.exec(c),d!==null);)y=o.lastIndex,o===$i?d[1]==="!--"?o=Lp:d[1]!==void 0?o=Mp:d[2]!==void 0?(Av.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=An):d[3]!==void 0&&(o=An):o===An?d[0]===">"?(o=i??$i,p=-1):d[1]===void 0?p=-2:(p=o.lastIndex-d[2].length,u=d[1],o=d[3]===void 0?An:d[3]==='"'?Up:Np):o===Up||o===Np?o=An:o===Lp||o===Mp?o=$i:(o=An,i=void 0);const v=o===An&&t[a+1].startsWith("/>")?" ":"";s+=o===$i?c+QR:p>=0?(r.push(u),c.slice(0,p)+Ev+c.slice(p)+en+v):c+en+(p===-2?a:v)}return[Tv(t,s+(t[n]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class ts{constructor({strings:e,_$litType$:n},r){let i;this.parts=[];let s=0,o=0;const a=e.length-1,c=this.parts,[u,d]=nD(e,n);if(this.el=ts.createElement(u,r),Mn.currentNode=this.el.content,n===2||n===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=Mn.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(Ev)){const y=d[o++],v=i.getAttribute(p).split(en),$=/([.?@])?(.*)/.exec(y);c.push({type:1,index:s,name:$[2],strings:v,ctor:$[1]==="."?iD:$[1]==="?"?sD:$[1]==="@"?oD:Ga}),i.removeAttribute(p)}else p.startsWith(en)&&(c.push({type:6,index:s}),i.removeAttribute(p));if(Av.test(i.tagName)){const p=i.textContent.split(en),y=p.length-1;if(y>0){i.textContent=oa?oa.emptyScript:"";for(let v=0;v<y;v++)i.append(p[v],Qi()),Mn.nextNode(),c.push({type:2,index:++s});i.append(p[y],Qi())}}}else if(i.nodeType===8)if(i.data===$v)c.push({type:2,index:s});else{let p=-1;for(;(p=i.data.indexOf(en,p+1))!==-1;)c.push({type:7,index:s}),p+=en.length-1}s++}}static createElement(e,n){const r=ar.createElement("template");return r.innerHTML=e,r}}function ii(t,e,n=t,r){var o,a;if(e===ri)return e;let i=r!==void 0?(o=n._$Co)==null?void 0:o[r]:n._$Cl;const s=es(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(t),i._$AT(t,n,r)),r!==void 0?(n._$Co??(n._$Co=[]))[r]=i:n._$Cl=i),i!==void 0&&(e=ii(t,i._$AS(t,e.values),i,r)),e}class rD{constructor(e,n){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:n},parts:r}=this._$AD,i=((e==null?void 0:e.creationScope)??ar).importNode(n,!0);Mn.currentNode=i;let s=Mn.nextNode(),o=0,a=0,c=r[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new ju(s,s.nextSibling,this,e):c.type===1?u=new c.ctor(s,c.name,c.strings,this,e):c.type===6&&(u=new aD(s,this,e)),this._$AV.push(u),c=r[++a]}o!==(c==null?void 0:c.index)&&(s=Mn.nextNode(),o++)}return Mn.currentNode=ar,i}p(e){let n=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,n),n+=r.strings.length-2):r._$AI(e[n])),n++}}let ju=class Cv{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,n,r,i){this.type=2,this._$AH=ae,this._$AN=void 0,this._$AA=e,this._$AB=n,this._$AM=r,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=n.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,n=this){e=ii(this,e,n),es(e)?e===ae||e==null||e===""?(this._$AH!==ae&&this._$AR(),this._$AH=ae):e!==this._$AH&&e!==ri&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):eD(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!==ae&&es(this._$AH)?this._$AA.nextSibling.data=e:this.T(ar.createTextNode(e)),this._$AH=e}$(e){var s;const{values:n,_$litType$:r}=e,i=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=ts.createElement(Tv(r.h,r.h[0]),this.options)),r);if(((s=this._$AH)==null?void 0:s._$AD)===i)this._$AH.p(n);else{const o=new rD(i,this),a=o.u(this.options);o.p(n),this.T(a),this._$AH=o}}_$AC(e){let n=Fp.get(e.strings);return n===void 0&&Fp.set(e.strings,n=new ts(e)),n}k(e){Vu(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let r,i=0;for(const s of e)i===n.length?n.push(r=new Cv(this.O(Qi()),this.O(Qi()),this,this.options)):r=n[i],r._$AI(s),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,n){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,n);e!==this._$AB;){const i=Op(e).nextSibling;Op(e).remove(),e=i}}setConnected(e){var n;this._$AM===void 0&&(this._$Cv=e,(n=this._$AP)==null||n.call(this,e))}},Ga=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,n,r,i,s){this.type=1,this._$AH=ae,this._$AN=void 0,this.element=e,this.name=n,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=ae}_$AI(e,n=this,r,i){const s=this.strings;let o=!1;if(s===void 0)e=ii(this,e,n,0),o=!es(e)||e!==this._$AH&&e!==ri,o&&(this._$AH=e);else{const a=e;let c,u;for(e=s[0],c=0;c<s.length-1;c++)u=ii(this,a[r+c],n,c),u===ri&&(u=this._$AH[c]),o||(o=!es(u)||u!==this._$AH[c]),u===ae?e=ae:e!==ae&&(e+=(u??"")+s[c+1]),this._$AH[c]=u}o&&!i&&this.j(e)}j(e){e===ae?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},iD=class extends Ga{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ae?void 0:e}},sD=class extends Ga{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==ae)}},oD=class extends Ga{constructor(e,n,r,i,s){super(e,n,r,i,s),this.type=5}_$AI(e,n=this){if((e=ii(this,e,n,0)??ae)===ri)return;const r=this._$AH,i=e===ae&&r!==ae||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,s=e!==ae&&(r===ae||i);i&&this.element.removeEventListener(this.name,this,r),s&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var n;typeof this._$AH=="function"?this._$AH.call(((n=this.options)==null?void 0:n.host)??this.element,e):this._$AH.handleEvent(e)}};class aD{constructor(e,n,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=n,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){ii(this,e)}}const Fl=Yi.litHtmlPolyfillSupport;Fl==null||Fl(ts,ju),(Yi.litHtmlVersions??(Yi.litHtmlVersions=[])).push("3.3.2");const Re=(t,e,n)=>{const r=e;let i=r._$litPart$;return i===void 0&&(r._$litPart$=i=new ju(e.insertBefore(Qi(),null),null,void 0,{})),i._$AI(t),i},lD=.5,Zp=.1,Hp=8,cD=4,Iv=3,Pv=3,uD=4,Nn=255,Rv=.2126,Dv=.7152,Ov=.0722;async function Gu(t){const e=hD(t);if(!e)return"light";try{return await fD(t,e)>=lD?"light":"dark"}catch{return"light"}}function hD(t){if(typeof document.elementsFromPoint!="function")return null;const e=t.getBoundingClientRect(),n=e.left+e.width/2,r=e.top+e.height/2,i=document.elementsFromPoint(n,r);for(const s of i){if(!(s instanceof HTMLElement)||s===t||t.contains(s))continue;const o=window.getComputedStyle(s);if(dD(o))return s}return null}function dD(t){return t.backgroundImage&&t.backgroundImage!=="none"?!0:pD(t.backgroundColor)>0}function pD(t){if(!t)return 0;const e=t.match(/rgba?\(([^)]+)\)/);if(!e)return 0;const n=e[1].split(/[\s,/]+/).filter(Boolean);return n.length===uD?parseFloat(n[Iv]):n.length===Pv?1:0}async function fD(t,e){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),i={x:xo((n.left-r.left)/r.width),y:xo((n.top-r.top)/r.height),width:xo(n.width/r.width),height:xo(n.height/r.height)},s=window.getComputedStyle(e),o=gD(s.backgroundImage);return o?vD({url:o,surfaceWidth:r.width,surfaceHeight:r.height,region:i}):yD(s.backgroundColor)}function gD(t){const e=t.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return e?e[1]:null}const Bp=new Map;function mD(t){let e=Bp.get(t);return e||(e=new Promise((n,r)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>n(i),i.onerror=()=>r(new Error(`Failed to load ${t}`)),i.src=t}),Bp.set(t,e),e)}async function vD(t){const e=await mD(t.url),n=Math.max(Hp,Math.ceil(t.surfaceWidth*Zp)),r=Math.max(Hp,Math.ceil(t.surfaceHeight*Zp)),i=document.createElement("canvas");i.width=n,i.height=r;const s=i.getContext("2d",{willReadFrequently:!0});if(!s)return 1;const o=t.surfaceWidth/t.surfaceHeight,a=e.naturalWidth/e.naturalHeight;let c,u;a>o?(u=r,c=r*a):(c=n,u=n/a);const d=(n-c)/2,p=(r-u)/2;s.drawImage(e,d,p,c,u);const y=Math.max(0,Math.floor(t.region.x*n)),v=Math.max(0,Math.floor(t.region.y*r)),$=Math.max(1,Math.min(n-y,Math.floor(t.region.width*n))),k=Math.max(1,Math.min(r-v,Math.floor(t.region.height*r))),I=s.getImageData(y,v,$,k).data;let B=0,P=0;for(let K=0;K<I.length;K+=cD){const L=I[K]/Nn,Z=I[K+1]/Nn,N=I[K+2]/Nn,ce=I[K+Iv]/Nn;B+=ce*(Rv*L+Dv*Z+Ov*N),P+=1}return P>0?B/P:1}function yD(t){const e=t.match(/rgba?\(([^)]+)\)/);if(!e)return 1;const n=e[1].split(/[\s,/]+/).filter(Boolean).map(parseFloat);if(n.length<Pv)return 1;const r=n[0]/Nn,i=n[1]/Nn,s=n[2]/Nn;return Rv*r+Dv*i+Ov*s}function xo(t){return t<0?0:t>1?1:t}const Zl=new WeakSet,Vp=new WeakSet;function zv(t){if(Vp.has(t))return;Vp.add(t);for(const n of t.querySelectorAll('button[variant="ghost"]'))Hl(n);if(typeof MutationObserver!="function")return;new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const i of r.addedNodes)bD(i,Hl);else r.type==="attributes"&&r.target instanceof HTMLButtonElement&&r.target.getAttribute("variant")==="ghost"&&Hl(r.target)}).observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["variant"]})}function bD(t,e){if(t instanceof Element){t instanceof HTMLButtonElement&&t.getAttribute("variant")==="ghost"&&e(t);for(const n of t.querySelectorAll('button[variant="ghost"]'))e(n)}}async function Hl(t){if(Zl.has(t))return;Zl.add(t);const e=await Gu(t);if(t.getAttribute("variant")!=="ghost"){Zl.delete(t);return}t.setAttribute("tone",e)}const wD="*,*:before,*:after{box-sizing:border-box}html,body{margin:0;padding:0;width:100%;height:100%}h1,h2,h3,h4,h5,h6,p,ul,ol,blockquote,pre,hr{margin:0}button,input,textarea,select{font:inherit;color:inherit}@font-face{font-family:Hind;src:url("+new URL("Hind-Variable-C47b_dt9.woff2",import.meta.url).href+') format("woff2-variations");font-weight:300 700;font-style:normal;font-display:swap}:root{--font-sans: "Hind", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;--font-brand: var(--font-sans);--font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;--font-weight-body: 500;--text-base: 13.5px;--text-scale: 1.125;--text-sm: round(calc(var(--text-base) / var(--text-scale)), 1px);--text-lg: round(calc(var(--text-base) * var(--text-scale)), 1px);--text-xl: round(calc(var(--text-lg) * var(--text-scale)), 1px);--leading-base: 1.5;--space-2: 2px;--space-4: 4px;--space-6: 6px;--space-8: 8px;--space-12: 12px;--space-16: 16px;--space-20: 20px;--space-24: 24px;--space-32: 32px;--space-48: 48px;--space-64: 64px;--radius-4: 4px;--radius-8: 8px;--radius-12: 12px;--radius-16: 16px;--radius-24: 24px;--radius-full: 9999px;--shadow-hairline: 0 0 0 .5px var(--color-border);--shadow-control: 0 1px 1px rgb(0 0 0 / .04), 0 2px 6px rgb(0 0 0 / .06);--alpha-50: 4%;--alpha-100: 8%;--alpha-200: 15%;--alpha-300: 22%;--alpha-400: 30%;--alpha-500: 40%;--alpha-600: 50%;--alpha-700: 65%;--alpha-800: 80%;--alpha-900: 90%;--alpha-950: 95%;--tint-50: color-mix(in srgb, currentColor var(--alpha-50), transparent);--tint-100: color-mix(in srgb, currentColor var(--alpha-100), transparent);--tint-200: color-mix(in srgb, currentColor var(--alpha-200), transparent);--tint-300: color-mix(in srgb, currentColor var(--alpha-300), transparent);--tint-400: color-mix(in srgb, currentColor var(--alpha-400), transparent);--tint-500: color-mix(in srgb, currentColor var(--alpha-500), transparent);--tint-600: color-mix(in srgb, currentColor var(--alpha-600), transparent);--tint-700: color-mix(in srgb, currentColor var(--alpha-700), transparent);--tint-800: color-mix(in srgb, currentColor var(--alpha-800), transparent);--tint-900: color-mix(in srgb, currentColor var(--alpha-900), transparent);--tint-950: color-mix(in srgb, currentColor var(--alpha-950), transparent);--color-overlay-hover: color-mix(in srgb, var(--black) var(--alpha-100), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-300), transparent);--backdrop-blur-glass: blur(20px) saturate(1.4);--black: #000000;--white: #ffffff;--neutral-50: oklch(.985 0 0);--neutral-100: oklch(.97 0 0);--neutral-200: oklch(.923 0 0);--neutral-300: oklch(.869 0 0);--neutral-350: oklch(.79 0 0);--neutral-400: oklch(.709 0 0);--neutral-500: oklch(.553 0 0);--neutral-600: oklch(.444 0 0);--neutral-700: oklch(.374 0 0);--neutral-800: oklch(.268 0 0);--neutral-900: oklch(.216 0 0);--neutral-950: oklch(.147 0 0);--red-50: oklch(.969 .015 12.422);--red-100: oklch(.941 .03 12.58);--red-200: oklch(.892 .058 10.001);--red-300: oklch(.81 .117 11.638);--red-400: oklch(.712 .194 13.428);--red-500: oklch(.645 .246 16.439);--red-600: oklch(.586 .253 17.585);--red-700: oklch(.514 .222 16.935);--red-800: oklch(.455 .188 13.697);--red-900: oklch(.41 .159 10.272);--red-950: oklch(.271 .105 12.094);--orange-50: oklch(.98 .016 73.684);--orange-100: oklch(.954 .038 75.164);--orange-200: oklch(.901 .076 70.697);--orange-300: oklch(.837 .128 66.29);--orange-400: oklch(.75 .183 55.934);--orange-500: oklch(.705 .213 47.604);--orange-600: oklch(.646 .222 41.116);--orange-700: oklch(.553 .195 38.402);--orange-800: oklch(.47 .157 37.304);--orange-900: oklch(.408 .123 38.172);--orange-950: oklch(.266 .079 36.259);--yellow-50: oklch(.987 .026 102.212);--yellow-100: oklch(.973 .071 103.193);--yellow-200: oklch(.945 .129 101.54);--yellow-300: oklch(.905 .182 98.111);--yellow-400: oklch(.852 .199 91.936);--yellow-500: oklch(.795 .184 86.047);--yellow-600: oklch(.681 .162 75.834);--yellow-700: oklch(.554 .135 66.442);--yellow-800: oklch(.476 .114 61.907);--yellow-900: oklch(.421 .095 57.708);--yellow-950: oklch(.286 .066 53.813);--green-50: oklch(.979 .021 166.113);--green-100: oklch(.95 .052 163.051);--green-200: oklch(.905 .093 164.15);--green-300: oklch(.845 .143 164.978);--green-400: oklch(.765 .177 163.223);--green-500: oklch(.696 .17 162.48);--green-600: oklch(.596 .145 163.225);--green-700: oklch(.508 .118 165.612);--green-800: oklch(.432 .095 166.913);--green-900: oklch(.378 .077 168.94);--green-950: oklch(.262 .051 172.552);--blue-50: oklch(.97 .014 254.604);--blue-100: oklch(.932 .032 255.585);--blue-200: oklch(.882 .059 254.128);--blue-300: oklch(.809 .105 251.813);--blue-400: oklch(.707 .165 254.624);--blue-500: oklch(.623 .214 259.815);--blue-600: oklch(.546 .245 262.881);--blue-700: oklch(.488 .243 264.376);--blue-800: oklch(.424 .199 265.638);--blue-900: oklch(.379 .146 265.522);--blue-950: oklch(.282 .091 267.935);--purple-50: oklch(.969 .016 293.756);--purple-100: oklch(.943 .029 294.588);--purple-200: oklch(.894 .057 293.283);--purple-300: oklch(.811 .111 293.571);--purple-400: oklch(.702 .183 293.541);--purple-500: oklch(.606 .25 292.717);--purple-600: oklch(.541 .281 293.009);--purple-700: oklch(.491 .27 292.581);--purple-800: oklch(.432 .232 292.759);--purple-900: oklch(.38 .189 293.745);--purple-950: oklch(.283 .141 291.089)}@supports (corner-shape: squircle){:root{--radius-8: 10px;--radius-12: 15px;--radius-16: 20px;--radius-24: 30px}}:root[data-font=system]{--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif}:root{--color-bg: var(--neutral-50);--color-bg-muted: var(--neutral-100);--color-surface: var(--white);--color-surface-muted: var(--neutral-100);--color-interactive: var(--neutral-200);--color-interactive-hover: var(--neutral-300);--color-border: rgba(0, 0, 0, .1);--color-border-muted: rgba(0, 0, 0, .06);--color-text: var(--neutral-900);--color-text-muted: var(--neutral-500);--color-link: inherit;--color-focus-ring: var(--neutral-500);--color-overlay-backdrop: rgb(0 0 0 / .5);--color-highlight: rgb(255 255 255 / .5);--color-primary: var(--blue-500);--color-danger: var(--red-600);color-scheme:light}body{font-family:var(--font-sans);font-size:var(--text-base);font-weight:var(--font-weight-body);line-height:var(--leading-base);letter-spacing:.015em;color:var(--color-text);background:var(--color-bg);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}a{color:var(--color-link);text-underline-offset:.15em;text-decoration-thickness:.08em}h1,h2,h3,h4,h5,h6{font-weight:600;color:inherit}code{font-family:var(--font-mono);font-size:.9em;background:var(--color-bg-muted);padding:var(--space-2) var(--space-4);border-radius:var(--radius-4)}pre{font-family:var(--font-mono);background:var(--color-bg-muted);padding:var(--space-12);border-radius:var(--radius-8);overflow-x:auto}pre code{background:none;padding:0}blockquote{padding-left:var(--space-16);border-left:3px solid var(--color-border);color:var(--color-text-muted)}hr{border:none;border-top:1px solid var(--color-border)}table{border-collapse:collapse}th,td{padding:var(--space-8) var(--space-12);border:1px solid var(--color-border);text-align:left}th{background:var(--color-bg-muted);font-weight:600}input,textarea{padding:6px 10px;border:.5px solid var(--tint-300);border-radius:var(--radius-12);background:var(--tint-100);color:inherit;font:inherit;transition:background .12s ease,border-color .12s ease,box-shadow .12s ease}textarea{resize:none}input::placeholder,textarea::placeholder{color:var(--tint-500)}input:focus,textarea:focus{background:color-mix(in srgb,var(--white) var(--alpha-300),transparent);border-color:var(--color-primary);outline:none;box-shadow:0 0 0 1.5px var(--color-primary)}label.field{display:grid;gap:4px;font-size:13px}label.field>span{font-size:11.5px;font-weight:450;color:var(--tint-800)}@supports (corner-shape: squircle){*{corner-shape:squircle}}button{display:inline-flex;align-items:center;justify-content:center;gap:var(--space-6);padding:4px 14px;border:.5px solid var(--tint-200);border-radius:var(--radius-12);background:var(--color-surface);color:inherit;font:inherit;cursor:default;box-shadow:var(--shadow-control)}button:hover:not(:disabled){background:color-mix(in srgb,var(--color-surface) 96%,black)}button:active:not(:disabled){background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}button:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}button[variant=primary]{background:var(--color-primary);border-color:#0000002e;color:var(--white)}button[variant=primary]:hover:not(:disabled){background:color-mix(in srgb,var(--color-primary) 92%,black)}button[variant=primary]:active:not(:disabled){background:color-mix(in srgb,var(--color-primary) 82%,black);box-shadow:inset 0 1px 2px #0000002e}button[variant=danger]{background:var(--color-danger);border-color:#0000002e;color:var(--white)}button[variant=danger]:hover:not(:disabled){background:color-mix(in srgb,var(--color-danger) 92%,black)}button[variant=danger]:active:not(:disabled){background:color-mix(in srgb,var(--color-danger) 82%,black);box-shadow:inset 0 1px 2px #0000002e}button[variant=ghost]{background:transparent;border-color:transparent;color:inherit;box-shadow:none}button[variant=ghost]:hover:not(:disabled){background:var(--color-overlay-hover)}button[variant=ghost]:active:not(:disabled){background:var(--color-overlay-active);box-shadow:none}button[variant=ghost][data-active]:not(:disabled),button[variant=ghost][data-active]:hover:not(:disabled),button[variant=ghost][aria-expanded=true]:not(:disabled),button[variant=ghost][aria-expanded=true]:hover:not(:disabled){background:var(--color-overlay-active);box-shadow:none}button:disabled{background:var(--tint-300);border-color:transparent;color:var(--tint-700);box-shadow:none}[tone=dark] button:not([variant]):not(:disabled){background:var(--tint-200);border-color:var(--tint-300);box-shadow:inset 0 .5px 0 var(--tint-300)}[tone=dark] button:not([variant]):hover:not(:disabled){background:var(--tint-300)}[tone=dark] button:not([variant]):active:not(:disabled){background:var(--tint-400);box-shadow:inset 0 1px 2px #0003}[tone=light] button:not([variant]):not(:disabled){background:var(--color-surface);border-color:var(--tint-200);box-shadow:var(--shadow-control)}[tone=light] button:not([variant]):hover:not(:disabled){background:color-mix(in srgb,var(--color-surface) 96%,black)}[tone=light] button:not([variant]):active:not(:disabled){background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}button[size=sm]{min-height:24px;padding:var(--space-2) var(--space-8)}button[size=md]{min-height:32px;padding:var(--space-6) var(--space-12)}button[icon-only]{width:24px;height:24px;min-height:0;padding:0}[data-ui-icon]{display:inline-block;vertical-align:middle}.prose{line-height:var(--leading-base)}.prose h1{font-size:var(--text-xl);margin-bottom:var(--space-8)}.prose h2{font-size:var(--text-lg);margin-top:var(--space-24);margin-bottom:var(--space-8)}.prose h3,.prose h4,.prose h5,.prose h6{font-size:var(--text-base);margin-top:var(--space-24);margin-bottom:var(--space-8)}.prose p{margin:var(--space-12) 0}.prose ul,.prose ol{padding-left:var(--space-24);margin:var(--space-12) 0}.prose blockquote,.prose pre{margin:var(--space-12) 0}.prose hr{margin:var(--space-24) 0}.prose table{width:100%;margin:var(--space-12) 0}.prose img{max-width:100%;height:auto}.prose>:first-child{margin-top:0}.prose>:last-child{margin-bottom:0}[material=paper]{background:var(--white);border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);color:var(--color-text)}[material=glass]{background:color-mix(in srgb,var(--white) var(--alpha-700),transparent);border:.5px solid color-mix(in srgb,var(--black) var(--alpha-100),transparent);color:var(--color-text);backdrop-filter:var(--backdrop-blur-glass);-webkit-backdrop-filter:var(--backdrop-blur-glass)}[tone=dark]{color:color-mix(in srgb,var(--white) var(--alpha-950),transparent);border-color:color-mix(in srgb,var(--white) var(--alpha-200),transparent);--color-overlay-hover: color-mix(in srgb, var(--white) var(--alpha-200), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-500), transparent)}[tone=dark][material=paper]{background:#000}[tone=dark][material=glass]{background:color-mix(in srgb,var(--black) var(--alpha-600),transparent)}[tone=light]{color:var(--color-text);border-color:color-mix(in srgb,var(--black) var(--alpha-100),transparent);--color-overlay-hover: color-mix(in srgb, var(--black) var(--alpha-100), transparent);--color-overlay-active: color-mix(in srgb, var(--black) var(--alpha-300), transparent)}[level="1"]{box-shadow:0 12px 32px #00000024}[level="2"]{box-shadow:0 4px 6px -2px #0000001f,0 40px 60px -16px #00000038}dropdown-menu{position:relative;display:inline-block;color:inherit}dropdown-group{display:grid;gap:var(--space-4)}dropdown-label{display:block;padding:var(--space-4) var(--space-8);color:var(--color-text-muted);font:inherit;font-size:var(--text-sm);font-weight:600;letter-spacing:.04em;text-transform:uppercase}dropdown-divider{display:block;height:1px;margin:2px 0;background:var(--color-border)}[data-dropdown-trigger][aria-expanded=true],[data-dropdown-trigger][aria-expanded=true]:hover,dropdown-menu[open]::part(trigger),dropdown-menu[open]::part(trigger):hover{background:color-mix(in srgb,var(--color-surface) 88%,black);box-shadow:inset 0 1px 2px #00000014}[data-dropdown-trigger-label],dropdown-menu::part(trigger-label){min-width:0}[data-dropdown-trigger-icon],dropdown-menu::part(trigger-icon){display:inline-flex;align-items:center;justify-content:center;flex:none;color:var(--color-text-muted);transform:translateY(1px)}dropdown-item:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}dropdown-menu::part(panel){position:absolute;left:0;min-width:192px;padding:var(--space-4);border-radius:var(--radius-8);display:flex;flex-direction:column;gap:2px;z-index:2000}dropdown-menu::part(panel-bottom){top:calc(100% + var(--space-4))}dropdown-menu::part(panel-top){bottom:calc(100% + var(--space-4))}dropdown-item{display:flex;align-items:center;gap:var(--space-8);margin:0;padding:6px 12px;border-radius:var(--radius-8);font:inherit;line-height:1.2;color:inherit;font-weight:var(--font-weight-body);-webkit-user-select:none;user-select:none}dropdown-item>[data-ui-icon]{flex:none}dropdown-item[selected]{background:var(--color-overlay-active)}dropdown-item:hover{background:var(--color-primary);color:var(--white)}dropdown-item[action]{color:inherit}dropdown-item[danger]{color:var(--color-danger)}dropdown-item[danger]:hover{background:var(--color-danger);color:var(--white)}modal-overlay{color:inherit}modal-overlay::part(backdrop){position:fixed;top:0;right:0;bottom:0;left:0;z-index:var(--layer-overlay);display:flex;align-items:center;justify-content:center;padding:var(--space-16);background:var(--color-overlay-backdrop)}panel-view{display:block}panel-view::part(panel){display:flex;flex-direction:column;gap:var(--space-16);color:var(--color-text)}panel-view::part(header){display:flex;align-items:center;justify-content:space-between;gap:var(--space-12)}panel-view::part(title){margin:0;font:inherit;font-size:var(--text-lg);font-weight:600;color:var(--color-text)}panel-view::part(button){display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;margin:0;border:1px solid var(--color-border);border-radius:var(--radius-4);background:var(--color-surface);color:var(--color-text);box-shadow:none}panel-view::part(button):hover{background:var(--color-interactive-hover)}panel-view::part(button):focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:2px}panel-view::part(icon){display:inline-flex;align-items:center;justify-content:center;flex:none}ui-popover{display:contents}ui-popover::part(panel){position:fixed;min-width:192px;max-width:384px;padding:var(--space-16) var(--space-20);border-radius:var(--radius-16);outline:none;z-index:2000}ui-pill{display:inline-block;vertical-align:baseline;margin:2px 0;padding:0 var(--space-8);font-size:var(--text-sm);font-weight:500;line-height:1.7;border-radius:var(--radius-full);border:1px solid var(--neutral-300);background:var(--neutral-200);color:var(--neutral-900);white-space:nowrap}ui-pill[color=gray]{border-color:var(--neutral-300);background:var(--neutral-200);color:var(--neutral-900)}ui-pill[color=red]{border-color:var(--red-200);background:var(--red-100);color:var(--red-950)}ui-pill[color=orange]{border-color:var(--orange-200);background:var(--orange-100);color:var(--orange-950)}ui-pill[color=yellow]{border-color:var(--yellow-200);background:var(--yellow-100);color:var(--yellow-950)}ui-pill[color=green]{border-color:var(--green-200);background:var(--green-100);color:var(--green-950)}ui-pill[color=blue]{border-color:var(--blue-200);background:var(--blue-100);color:var(--blue-950)}ui-pill[color=purple]{border-color:var(--purple-200);background:var(--purple-100);color:var(--purple-950)}',Wu=new CSSStyleSheet;Wu.replaceSync(wD);try{document.adoptedStyleSheets=[...document.adoptedStyleSheets,Wu]}catch{}zv(document);function Lv(t){try{t.adoptedStyleSheets=[...t.adoptedStyleSheets,Wu]}catch{}zv(t)}/**
50
+ * @license
51
+ * Copyright 2017 Google LLC
52
+ * SPDX-License-Identifier: BSD-3-Clause
53
+ */const Mv={CHILD:2},qu=t=>(...e)=>({_$litDirective$:t,values:e});class Nv{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,n,r){this._$Ct=e,this._$AM=n,this._$Ci=r}_$AS(e,n){return this.update(e,n)}update(e,n){return this.render(...n)}}/**
54
+ * @license
55
+ * Copyright 2017 Google LLC
56
+ * SPDX-License-Identifier: BSD-3-Clause
57
+ */let aa=class extends Nv{constructor(e){if(super(e),this.it=ae,e.type!==Mv.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===ae||e==null)return this._t=void 0,this.it=e;if(e===ri)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 n=[e];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}};aa.directiveName="unsafeHTML",aa.resultType=1;const _D=qu(aa);/**
58
+ * @license
59
+ * Copyright 2017 Google LLC
60
+ * SPDX-License-Identifier: BSD-3-Clause
61
+ */class Cc extends aa{}Cc.directiveName="unsafeSVG",Cc.resultType=2;const SD=qu(Cc),kD={size:16,color:"currentColor",weight:"regular"};function xD(t){return typeof t=="string"?{regular:t}:t}function Jt(t,e="0 0 256 256"){const n=xD(t);return r=>{const{size:i,color:s,weight:o}={...kD,...r},a=n[o]??n.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
+ >${SD(a)}</svg>`}}const ED=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"/>'),Uv=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"/>'),$D=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"/>'),Fv=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"/>'),AD=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"/>'),TD=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"/>'),CD=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"/>'}),ID=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"/>'}),PD=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 Zv extends Event{constructor(n){super("dropdown-item-select",{bubbles:!0,composed:!0});b(this,"value");this.value=n}}class RD extends Event{constructor(n){super("select",{bubbles:!0,composed:!0});b(this,"value");this.value=n}}var Ke,ut,cn,Wn,ne,ms,z,Bv,Ni,Vv,jv,Ic,Gv,Ui,In,qn,vs,ys,bs,ma,Wv,qv,Pc,Fi,Yv,Rc,zt;class Hv extends HTMLElement{constructor(){super();_(this,z);_(this,Ke,!1);_(this,ut,null);_(this,cn,null);_(this,Wn);_(this,ne,null);_(this,ms,new MutationObserver(n=>m(this,z,Wv).call(this,n)));_(this,qn,()=>{m(this,z,Ui).call(this,!l(this,Ke))});_(this,vs,n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),l(this,qn).call(this))});_(this,ys,n=>{l(this,Ke)&&(n.composedPath().includes(this)||m(this,z,Ui).call(this,!1))});_(this,bs,n=>{n instanceof Zv&&(n.stopPropagation(),x(this,Ke,!1),m(this,z,Ni).call(this,n.value),m(this,z,zt).call(this),this.dispatchEvent(new RD(n.value)))});_(this,ma,()=>{m(this,z,Pc).call(this)});x(this,Wn,this.attachShadow({mode:"open"})),Lv(l(this,Wn))}connectedCallback(){this.addEventListener("dropdown-item-select",l(this,bs)),document.addEventListener("click",l(this,ys),!0),m(this,z,Bv).call(this),l(this,ms).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,bs)),document.removeEventListener("click",l(this,ys),!0),l(this,ms).disconnect(),m(this,z,Rc).call(this)}attributeChangedCallback(n){if(n==="open"){m(this,z,Ui).call(this,this.hasAttribute("open"));return}m(this,z,zt).call(this)}get open(){return l(this,Ke)}set open(n){this.toggleAttribute("open",n)}get title(){return this.getAttribute("title")??""}get placement(){return this.getAttribute("placement")==="top"?"top":"bottom"}get value(){return l(this,ut)}set value(n){n===null?(m(this,z,In).call(this,null,null),m(this,z,Vv).call(this)):m(this,z,Ni).call(this,n),m(this,z,zt).call(this)}close(){m(this,z,Ui).call(this,!1)}}Ke=new WeakMap,ut=new WeakMap,cn=new WeakMap,Wn=new WeakMap,ne=new WeakMap,ms=new WeakMap,z=new WeakSet,Bv=function(){var r;const n=this.querySelector("dropdown-item[selected]");n&&m(this,z,In).call(this,n.value,((r=n.textContent)==null?void 0:r.trim())??null)},Ni=function(n){var r;for(const i of l(this,z,Ic))i.value===n?(m(this,z,In).call(this,n,((r=i.textContent)==null?void 0:r.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},Vv=function(){const n=this.querySelectorAll("dropdown-item[selected]");for(const r of n)r.removeAttribute("selected")},jv=function(n){for(const r of l(this,z,Ic))if(r.value===n)return r;return null},Ic=function(){return this.querySelectorAll("dropdown-item")},Gv=function(){return l(this,cn)??this.title},Ui=function(n){l(this,Ke)!==n&&(x(this,Ke,n),m(this,z,zt).call(this))},In=function(n,r){x(this,ut,n),x(this,cn,r)},qn=new WeakMap,vs=new WeakMap,ys=new WeakMap,bs=new WeakMap,ma=new WeakMap,Wv=function(n){n.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||m(this,z,qv).call(this)},qv=function(){var r,i;const n=this.querySelector("dropdown-item[selected]");if(n){const s=n.value,o=((r=n.textContent)==null?void 0:r.trim())??null,a=l(this,ut)!==s||l(this,cn)!==o;m(this,z,In).call(this,s,o),m(this,z,Ni).call(this,s),a?m(this,z,zt).call(this):m(this,z,Fi).call(this);return}if(l(this,ut)!==null){const s=m(this,z,jv).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,In).call(this,l(this,ut),o),m(this,z,Ni).call(this,l(this,ut)),a?m(this,z,zt).call(this):m(this,z,Fi).call(this);return}}if(l(this,ut)!==null||l(this,cn)!==null){m(this,z,In).call(this,null,null),m(this,z,zt).call(this);return}m(this,z,Fi).call(this)},Pc=function(){const n=l(this,Wn).querySelector('slot[name="trigger"]'),r=n instanceof HTMLSlotElement?n.assignedElements()[0]??null:null;l(this,ne)!==r&&(m(this,z,Rc).call(this),x(this,ne,r),l(this,ne)&&(l(this,ne).addEventListener("click",l(this,qn)),l(this,ne)instanceof HTMLButtonElement?l(this,ne).hasAttribute("type")||(l(this,ne).type="button"):(l(this,ne).hasAttribute("role")||l(this,ne).setAttribute("role","button"),l(this,ne).hasAttribute("tabindex")||(l(this,ne).tabIndex=0),l(this,ne).addEventListener("keydown",l(this,vs))))),m(this,z,Fi).call(this)},Fi=function(){l(this,ne)&&(l(this,ne).setAttribute("data-dropdown-trigger",""),l(this,ne).setAttribute("aria-haspopup","listbox"),l(this,ne).setAttribute("aria-expanded",l(this,Ke)?"true":"false"))},Yv=function(){return this.placement==="top"?AD:Fv},Rc=function(){l(this,ne)&&(l(this,ne).removeEventListener("click",l(this,qn)),l(this,ne).removeEventListener("keydown",l(this,vs)),l(this,ne).removeAttribute("data-dropdown-trigger"),l(this,ne).removeAttribute("aria-haspopup"),l(this,ne).removeAttribute("aria-expanded"),x(this,ne,null))},zt=function(){this.toggleAttribute("open",l(this,Ke)),Re(F`
69
+ <slot name="trigger" @slotchange=${l(this,ma)}>
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,qn)}
77
+ >
78
+ <span class="trigger-label" part="trigger-label">${l(this,z,Gv)}</span>
79
+ <span class="trigger-icon" part="trigger-icon" aria-hidden="true">
80
+ ${l(this,z,Yv).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
+ material="paper"
90
+ level="1"
91
+ >
92
+ <slot></slot>
93
+ </div>
94
+ `:null}
95
+ `,l(this,Wn)),queueMicrotask(()=>m(this,z,Pc).call(this))},b(Hv,"observedAttributes",["title","placement","open"]);class DD extends HTMLElement{}class OD extends HTMLElement{}class zD extends HTMLElement{}var ur,Dc,Jv,ws,_s;class Kv extends HTMLElement{constructor(){super(...arguments);_(this,ur);_(this,ws,()=>{this.action||m(this,ur,Jv).call(this)});_(this,_s,n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",l(this,ws)),this.addEventListener("keydown",l(this,_s)),m(this,ur,Dc).call(this)}disconnectedCallback(){this.removeEventListener("click",l(this,ws)),this.removeEventListener("keydown",l(this,_s))}attributeChangedCallback(){m(this,ur,Dc).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}ur=new WeakSet,Dc=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")},Jv=function(){this.dispatchEvent(new Zv(this.value))},ws=new WeakMap,_s=new WeakMap,b(Kv,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",Hv);customElements.get("dropdown-group")||customElements.define("dropdown-group",DD);customElements.get("dropdown-label")||customElements.define("dropdown-label",OD);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",zD);customElements.get("dropdown-item")||customElements.define("dropdown-item",Kv);class LD extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var Ss,vn,Oc,va,ks,zc;class Xv extends HTMLElement{constructor(){super();_(this,vn);_(this,Ss);_(this,va,n=>{n.target===n.currentTarget&&m(this,vn,Oc).call(this)});_(this,ks,n=>{this.open&&n.key==="Escape"&&m(this,vn,Oc).call(this)});x(this,Ss,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",l(this,ks)),m(this,vn,zc).call(this)}disconnectedCallback(){document.removeEventListener("keydown",l(this,ks))}attributeChangedCallback(){m(this,vn,zc).call(this)}get open(){return this.hasAttribute("open")}}Ss=new WeakMap,vn=new WeakSet,Oc=function(){this.dispatchEvent(new LD)},va=new WeakMap,ks=new WeakMap,zc=function(){Re(F`
96
+ ${this.open?F`
97
+ <div class="backdrop" part="backdrop" @click=${l(this,va)}>
98
+ <slot></slot>
99
+ </div>
100
+ `:null}
101
+ `,l(this,Ss))},b(Xv,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",Xv);class MD extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class ND extends HTMLElement{}var xs,Es,Lc;class Qv extends HTMLElement{constructor(){super();_(this,Es);_(this,xs);x(this,xs,this.attachShadow({mode:"open"}))}connectedCallback(){m(this,Es,Lc).call(this)}attributeChangedCallback(){m(this,Es,Lc).call(this)}get closable(){return this.hasAttribute("closable")}}xs=new WeakMap,Es=new WeakSet,Lc=function(){const n=this.querySelector("panel-page");Re(F`
102
+ <section class="panel" part="panel">
103
+ <header class="title-bar" part="header">
104
+ <h2 class="title" part="title">${(n==null?void 0:n.getAttribute("title"))??""}</h2>
105
+ ${this.closable?F`
106
+ <button
107
+ type="button"
108
+ class="title-button"
109
+ part="button close-button"
110
+ aria-label="Close"
111
+ @click=${()=>this.dispatchEvent(new MD)}
112
+ >
113
+ <span class="close-icon" part="icon close-icon">${Uv({size:16})}</span>
114
+ </button>
115
+ `:null}
116
+ </header>
117
+ <slot></slot>
118
+ </section>
119
+ `,l(this,xs))},b(Qv,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",Qv);customElements.get("panel-page")||customElements.define("panel-page",ND);class UD extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const jp='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Bl=4;var Be,Bt,Yn,et,$s,Hr,re,ty,ny,Mc,As,Ts,Kn,ry,Nc,iy,sy,Bo,Vo;class ey extends HTMLElement{constructor(){super();_(this,re);_(this,Be,!1);_(this,Bt,null);_(this,Yn);_(this,et,null);_(this,$s,"bottom-start");_(this,Hr,!1);_(this,As,n=>{l(this,Be)&&(l(this,Hr)||n.composedPath().includes(this)||(this.open=!1))});_(this,Ts,n=>{if(l(this,Be)){if(n.key==="Escape"){n.preventDefault(),this.open=!1;return}n.key==="Tab"&&m(this,re,ry).call(this,n)}});_(this,Kn,()=>{l(this,Be)&&m(this,re,Bo).call(this)});x(this,Yn,this.attachShadow({mode:"open"})),Lv(l(this,Yn))}connectedCallback(){this.hasAttribute("tone")||this.setAttribute("tone","light"),m(this,re,Vo).call(this)}disconnectedCallback(){m(this,re,Mc).call(this)}attributeChangedCallback(n){n==="open"&&m(this,re,ty).call(this,this.hasAttribute("open"))}get open(){return l(this,Be)}set open(n){this.toggleAttribute("open",n)}get anchor(){return l(this,Bt)}set anchor(n){l(this,Bt)!==n&&(x(this,Bt,n),l(this,Be)&&m(this,re,Bo).call(this))}}Be=new WeakMap,Bt=new WeakMap,Yn=new WeakMap,et=new WeakMap,$s=new WeakMap,Hr=new WeakMap,re=new WeakSet,ty=function(n){var r;l(this,Be)!==n&&(x(this,Be,n),n?(x(this,Hr,!0),setTimeout(()=>{x(this,Hr,!1)},0),m(this,re,Vo).call(this),m(this,re,ny).call(this),queueMicrotask(()=>{l(this,Be)&&(m(this,re,Bo).call(this),m(this,re,sy).call(this))})):(m(this,re,Mc).call(this),m(this,re,Vo).call(this),(r=l(this,Bt))==null||r.focus(),this.dispatchEvent(new UD)))},ny=function(){document.addEventListener("click",l(this,As)),document.addEventListener("keydown",l(this,Ts),!0),window.addEventListener("resize",l(this,Kn)),window.addEventListener("scroll",l(this,Kn),!0)},Mc=function(){document.removeEventListener("click",l(this,As)),document.removeEventListener("keydown",l(this,Ts),!0),window.removeEventListener("resize",l(this,Kn)),window.removeEventListener("scroll",l(this,Kn),!0)},As=new WeakMap,Ts=new WeakMap,Kn=new WeakMap,ry=function(n){const r=m(this,re,Nc).call(this);if(r.length===0){n.preventDefault();return}const i=r[0],s=r[r.length-1],o=m(this,re,iy).call(this),a=o instanceof HTMLElement&&r.includes(o);n.shiftKey?(!a||o===i)&&(n.preventDefault(),s.focus()):(!a||o===s)&&(n.preventDefault(),i.focus())},Nc=function(){if(!l(this,et))return[];const n=l(this,et).querySelector("slot");if(!(n instanceof HTMLSlotElement))return[];const r=[];for(const i of n.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches(jp)&&r.push(i);for(const s of i.querySelectorAll(jp))r.push(s)}return r},iy=function(){var r;let n=document.activeElement;for(;n&&((r=n.shadowRoot)!=null&&r.activeElement);)n=n.shadowRoot.activeElement;return n},sy=function(){var r;const n=m(this,re,Nc).call(this);n.length>0?n[0].focus():(r=l(this,et))==null||r.focus()},Bo=function(){if(!l(this,Be)||!l(this,Bt)||!l(this,et))return;const n=l(this,Bt).getBoundingClientRect(),r=l(this,et).getBoundingClientRect(),s=window.innerHeight-n.bottom,o=r.height+Bl,a=s<o&&n.top>o?"top-start":"bottom-start";x(this,$s,a);const c=a==="bottom-start"?n.bottom+Bl:n.top-r.height-Bl,u=n.left;l(this,et).style.top=`${c}px`,l(this,et).style.left=`${u}px`,l(this,et).setAttribute("data-placement",a)},Vo=function(){this.toggleAttribute("open",l(this,Be)),Re(l(this,Be)?F`<div
120
+ class="panel"
121
+ part="panel"
122
+ data-placement=${l(this,$s)}
123
+ tabindex="-1"
124
+ role="dialog"
125
+ material="paper"
126
+ level="1"
127
+ >
128
+ <slot></slot>
129
+ </div>`:ae,l(this,Yn)),x(this,et,l(this,Yn).querySelector(".panel"))},b(ey,"observedAttributes",["open"]);customElements.get("ui-popover")||customElements.define("ui-popover",ey);const FD=ft(),ZD="No handler registered for update-content",HD="handleUpdateContent: handler already registered";function BD(t){return t instanceof Error&&typeof t.message=="string"?t.message:String(t)}const VD=pi(gt);var Br,Vr,jr,Jn,Xn,Cs,Ce,Uc,oy,ay,Zi,Fc,kf;let jD=(kf=class extends VD{constructor(n){super();_(this,Ce);_(this,Br);_(this,Vr);_(this,jr);_(this,Jn,null);_(this,Xn,null);_(this,Cs,!1);x(this,Br,n);const r=n.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");x(this,Vr,r),x(this,jr,i=>m(this,Ce,oy).call(this,i)),l(this,Vr).addEventListener("message",l(this,jr))}get content(){return l(this,Xn)}set content(n){m(this,Ce,Fc).call(this),x(this,Xn,n),l(this,Cs)&&m(this,Ce,Uc).call(this,n)}handleUpdateContent(n){if(m(this,Ce,Fc).call(this),l(this,Jn)!==null)throw new Error(HD);x(this,Jn,n)}dispose(){l(this,Vr).removeEventListener("message",l(this,jr)),x(this,Jn,null)}},Br=new WeakMap,Vr=new WeakMap,jr=new WeakMap,Jn=new WeakMap,Xn=new WeakMap,Cs=new WeakMap,Ce=new WeakSet,Uc=function(n){const r={type:"content-updated",content:n};m(this,Ce,Zi).call(this,r)},oy=function(n){if(this.disposed||n.source!==l(this,Br).contentWindow)return;const r=n.data;if(QT(r)){x(this,Cs,!0),this.dispatchEvent(new FD("ready")),l(this,Xn)!==null&&m(this,Ce,Uc).call(this,l(this,Xn));return}if(eC(r)){m(this,Ce,ay).call(this,r);return}},ay=async function(n){const r=l(this,Jn);if(r===null){m(this,Ce,Zi).call(this,{type:"response",id:n.id,error:{message:ZD}});return}try{await r(n.content)}catch(i){if(this.disposed)return;m(this,Ce,Zi).call(this,{type:"response",id:n.id,error:{message:BD(i)}});return}this.disposed||m(this,Ce,Zi).call(this,{type:"response",id:n.id,result:{}})},Zi=function(n){const r=l(this,Br).contentWindow;r&&r.postMessage(n,"*")},Fc=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},kf);function GD(t=window){t.parent!==t&&(t.addEventListener("wheel",e=>{const n=e;t.parent.postMessage({type:"wheel",deltaX:n.deltaX,deltaY:n.deltaY,shiftKey:n.shiftKey},"*"),n.preventDefault()},{passive:!1}),t.addEventListener("message",e=>{const n=e.data;if(n!==null&&typeof n=="object"&&n.type==="scroll"){const r=n,i=typeof r.deltaX=="number"?r.deltaX:0,s=typeof r.deltaY=="number"?r.deltaY:0;t.scrollBy(i,s)}}))}function WD(){return`(${GD.toString()})(window);`}async function qD(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch artifact content: ${e.status}`);const n=await e.text(),r=new DOMParser().parseFromString(n,"text/html"),i=r.createElement("base");i.href=t,r.head.insertBefore(i,r.head.firstChild);const s=r.createElement("script");s.textContent=WD(),r.head.appendChild(s);const o=new Blob([`<!DOCTYPE html>
130
+ ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const ly=ft();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",n=>{!this._artifact||n.artifactID!==this._artifact.id||this._activeView!==null&&this.refetchContent()})}set artifact(n){const r=this._artifact;this._artifact=n,this.render(),r!==null&&r!==n&&this.syncView()}get artifact(){return this._artifact}set viewURL(n){this._viewURL!==n&&(this._viewURL=n,this.syncView())}get viewURL(){return this._viewURL}set contentURL(n){this._contentURL!==n&&(this._contentURL=n,this.syncView())}get contentURL(){return this._contentURL}set screen(n){this._screen!==n&&(this._screen=n,this.syncScreenSubscription())}get screen(){return this._screen}set dragging(n){n?this.setAttribute("dragging","true"):this.removeAttribute("dragging")}get dragging(){return this.getAttribute("dragging")==="true"}get activeView(){return this._activeView}connectedCallback(){this.setAttribute("level","2"),this.render(),this.syncView(),this.syncScreenSubscription()}disconnectedCallback(){this.teardownView(),this.unsubscribeFromScreen()}handleClose(){this._artifact&&this.dispatchEvent(new ly("close-artifact",{artifactID:this._artifact.id,bubbles:!0,composed:!0}))}syncView(){var n;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 jD(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(),((n=this._artifact)==null?void 0:n.status)==="committed"&&this.loadBlobFrame(this._contentURL);return}this.teardownView(),this._contentState={kind:"idle"},this.render()}}async saveContent(n){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:n})}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 n=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(n!==this._fetchSequence)return;if(!s.ok){this._contentState={kind:"error"},this.teardownView(),this.render();return}const o=await s.text();if(n!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o,this._contentState={kind:"ready"}}catch{if(n!==this._fetchSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}refetchContent(){this._fetchSequence+=1;const n=this._fetchSequence,r=this._contentURL,i=this._activeView;!i||r===null||(async()=>{try{const s=await fetch(r);if(n!==this._fetchSequence||!s.ok)return;const o=await s.text();if(n!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o}catch{}})()}loadBlobFrame(n){this._blobSequence+=1;const r=this._blobSequence;(async()=>{try{const i=await qD(n);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`
131
+ <div class="artifact-content artifact-placeholder">
132
+ <em>Failed to load content</em>
133
+ </div>
134
+ `:this._viewURL!==null||this._directRender?F`
135
+ <iframe
136
+ class="artifact-frame artifact-content"
137
+ src=${this._blobURL??"about:blank"}
138
+ sandbox="allow-scripts"
139
+ ></iframe>
140
+ `:F`
141
+ <div class="artifact-content artifact-placeholder">
142
+ <em>Artifact unavailable</em>
143
+ </div>
144
+ `}template(){const n=this._artifact;return F`
145
+ ${this.contentTemplate()}
146
+ <footer class="artifact-title-bar" drag-handle material="glass">
147
+ <div class="artifact-title-group">
148
+ <span class="artifact-title-icon">${ED({size:16})}</span>
149
+ <span class="artifact-title">${n.title}</span>
150
+ </div>
151
+ <button
152
+ icon-only
153
+ variant="ghost"
154
+ class="artifact-close-btn"
155
+ @click=${()=>this.handleClose()}
156
+ aria-label="Close"
157
+ >
158
+ ${Uv({size:16})}
159
+ </button>
160
+ </footer>
161
+ `}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),Re(this.template(),this))}}customElements.define("artifact-view",YD);const ke=t=>({type:"px",...t}),Te=t=>({type:"unit",...t}),Eo=2,KD=2;class JD{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:ge,y:ge});const n=this._viewport.x??sr,r=this._viewport.y??ea,i=this._gap.x??ge,s=this._gap.y??ge,o=sr+i*KD,a=n<=o,c=a?n-i*Eo:Math.min(sr,n-i*Eo),u=a?r-s*Eo:Math.min(ea,r-s*Eo),d=(c-i*(Ct-1))/Ct,p=(u-s*(Xe-1))/Xe,y=this.basis.x??0,v=this.basis.y??0,$=this.min.x??0,k=this.min.y??0;this._unit=ke(a?{x:Math.max($,d),y:Math.max(k,p)}:{x:Math.max($,Math.min(y,d)),y:Math.max(k,Math.min(v,p))})}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 n=this._unit.x??0,r=this._unit.y??0,i=this._gap.x??ge,s=this._gap.y??ge,o=e.x==null?void 0:e.x*n+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 lr=1e-4,jt=1e-6,XD=40,QD=24;function cy(t,e){return Math.max(0,t-e*2)}function uy(t){const e=[0];for(const n of t)e.push((e[e.length-1]??0)+n);return e}function hy(t){const e=[0];for(let n=0;n<t.length;n+=1){const r=e[n]??0;e.push(r+t[n]+ge)}return e}function dy(t,e,n){if(e<0||e>=t.length)return 0;let r=0,i=0;for(let s=e;s<t.length;s+=1){const o=t[s],a=i===0?o:r+ge+o;if(a>n+lr)break;r=a,i+=1}return Math.max(1,i)}function e2(t,e,n){if(e<0||e>=t.length)return 0;let r=0,i=0;for(let s=e;s>=0;s-=1){const o=t[s],a=i===0?o:r+ge+o;if(a>n+lr)break;r=a,i+=1}return Math.max(1,i)}function t2(t,e){if(t.length===0)return 0;let n=0,r=0;for(let i=t.length-1;i>=0;i-=1){const s=t[i],o=r===0?s:n+ge+s;if(o>e+lr)break;n=o,r+=1}return Math.max(1,r)}function Yu(t,e){if(t.length===0)return 0;const n=t2(t,e);return Math.max(0,t.length-n)}function Gp(t,e,n){if(t.length===0)return 0;const r=dy(t,e,n),i=Math.min(t.length,e+r);if(i<=e)return 0;const s=t.slice(e,i);return s.reduce((o,a)=>o+a,0)+Math.max(0,s.length-1)*ge}function Zc(t,e,n){const r=t[e]??0;return n-r}function Pr(t,e,n,r,i){if(t.length===0)return 0;const s=Yu(t,i),o=e[s]??0,a=Math.max(0,Math.min(o,n));let c=0;for(let Z=0;Z<s;Z+=1){const N=e[Z]??0,ce=e[Z+1]??N;if(a>=N&&a<=ce+lr){c=Z;break}c=Z+1}const u=Math.min(c+1,s),d=e[c]??0,p=e[u]??d,y=Math.max(p-d,lr),v=u===c?0:(a-d)/y,$=hy(t),k=Gp(t,c,i),I=Gp(t,u,i),B=(r-k)/2,P=(r-I)/2,K=Zc($,c,B),L=Zc($,u,P);return K+(L-K)*v}function Wp(t,e,n,r,i){const s=Yu(t,r),o=e[s]??0;let a=0,c=o;for(let u=0;u<XD;u+=1){const d=(a+c)/2;Pr(t,e,d,n,r)>i?a=d:c=d}return(a+c)/2}function qp(t,e,n){const r=hy(t),[i,s]=e,o=t.slice(i,s+1),a=o.reduce((u,d)=>u+d,0)+Math.max(0,o.length-1)*ge,c=(n-a)/2;return Zc(r,i,c)}function n2(t,e,n){const r=dy(t,e,n);return[e,Math.min(t.length-1,e+r-1)]}function r2(t,e,n){const r=e2(t,e,n);return[Math.max(0,e-r+1),e]}function i2(t){const e=new Set,n=[];for(const r of t){const i=`${r.nodeRange[0]}:${r.nodeRange[1]}`;if(e.has(i))continue;const s=n[n.length-1];s&&Math.abs(s.anchor-r.anchor)<=jt||(e.add(i),n.push(r))}return n}function s2(t){const{nodeCols:e,nodeWidthsPx:n,viewportWidthPx:r}=t;if(e.length===0||n.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const i=t.gapPx??ge,s=cy(r,i),o=uy(e),a=Yu(n,s),c=o[a]??0,u=[];for(let d=0;d<=a;d+=1){const p=n2(n,d,s),y=qp(n,p,r),v=Wp(n,o,r,s,y);u.push({nodeRange:p,anchor:Math.max(0,Math.min(c,v))})}for(let d=n.length-1;d>=0;d-=1){const p=r2(n,d,s),y=`${p[0]}:${p[1]}`;if(u.some(k=>`${k.nodeRange[0]}:${k.nodeRange[1]}`===y))continue;const v=qp(n,p,r),$=Wp(n,o,r,s,v);u.push({nodeRange:p,anchor:Math.max(0,Math.min(c,$))})}return u.sort((d,p)=>Math.abs(d.anchor-p.anchor)>jt?d.anchor-p.anchor:d.nodeRange[0]!==p.nodeRange[0]?d.nodeRange[0]-p.nodeRange[0]:d.nodeRange[1]-p.nodeRange[1]),{viewspans:i2(u),minScroll:0,maxScroll:c}}function o2(t,e){var i;let n=0,r=Number.POSITIVE_INFINITY;for(let s=0;s<t.length;s+=1){const o=Math.abs((((i=t[s])==null?void 0:i.anchor)??0)-e);if(o+jt<r){r=o,n=s;continue}Math.abs(o-r)<=jt&&s<n&&(n=s)}return n}function a2(t,e,n){return n<=0?0:Math.max(0,Math.min(n-1,t+e))}function Ai(t,e,n){return Math.max(e,Math.min(n,t))}class l2 extends gt{constructor(n){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=(n==null?void 0:n.x)??0}get scroll(){return Te({x:this._scroll})}get translate(){return ke({x:Pr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx)})}set scroll(n){const r=Ai(n.x??this._scroll,this.minScroll,this.maxScroll);Math.abs(r-this._scroll)<=jt||(this._scroll=r,this.activeViewspanIndex=null,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}rebuild(n){const r=n.nodeWidths.map(u=>Math.max(0,u.x??0)),i=r.map(u=>n.grid.toPixels(Te({x:u})).x??0),s=n.grid.viewport.x??0,o=n.grid.gap.x??ge,a=s2({nodeCols:r,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this.nodeWidthsPx=i,this.boundaryCols=uy(r),this.viewportWidthPx=s,this.framedViewportWidthPx=cy(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)>jt&&(this._scroll=c,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}step(n){var a;if(this.viewspans.length===0)return;const r=this.activeViewspanIndex??o2(this.viewspans,this._scroll),i=a2(r,n,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)<=jt)&&(this._scroll=o,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}wheel(n){const r=Ai(this._scroll+(n.x??0),this.minScroll,this.maxScroll);this.activeViewspanIndex=null,!(Math.abs(r-this._scroll)<=jt)&&(this._scroll=r,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}wheelPixels(n){const r=n.x??0;if(Math.abs(r)<=lr)return;this.activeViewspanIndex=null;const i=Pr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),s=i-r,o=Pr(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=Pr(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),c=Math.max(o,Math.min(a,s));if(Math.abs(c-i)<=lr)return;let u=this.minScroll,d=this.maxScroll;for(let y=0;y<QD;y+=1){const v=(u+d)/2;Pr(this.nodeWidthsPx,this.boundaryCols,v,this.viewportWidthPx,this.framedViewportWidthPx)>c?u=v:d=v}const p=Ai((u+d)/2,this.minScroll,this.maxScroll);Math.abs(p-this._scroll)<=jt||(this._scroll=p,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}}const Vl={"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}},c2=["stack-above","stack-below","reorder-before","reorder-after"];function jl(t,e){return{left:t.left+t.width*e.left,top:t.top+t.height*e.top,width:t.width*e.width,height:t.height*e.height}}function Tn(t,e,n){return t>=n.left&&t<n.left+n.width&&e>=n.top&&e<n.top+n.height}function Ku(t,e){for(const n of t){if(n.type==="card"&&n.id===e)return n;if(n.type==="stack")for(const r of n.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 Hc(t){return t.height===Xe||t.height===pn?{...t,height:pn}:t}function Bc(t){return t.height===pn?{...t,height:Xe}:t}function u2(t,e,n,r){const i=t.findIndex(d=>d.type==="stack"&&d.id===e);if(i===-1)return t;const s=t[i];if(!s||s.type!=="stack")return t;const o=s.children.find(d=>d.type==="card"&&d.id===n);if(!o||o.type!=="card")return t;const a=s.children.filter(d=>d.id!==n);if(a.length===s.children.length||a.length<1)return t;const c=[...t];if(a.length===1){const[d]=a;c[i]=d.type==="card"?Bc(d):d}else c[i]={...s,children:a};const u=Math.max(0,Math.min(r,c.length));return c.splice(u,0,Bc(o)),c}const h2=ft(),d2=ft(),p2=50;function f2(t,e){if(t.type!==e.type)return!1;switch(t.type){case"reorder":return e.index===t.index;case"stack":return e.targetCardId===t.targetCardId&&e.position===t.position;case"stack-child-noop":return!0;case"stack-child-extract":return e.toIndex===t.toIndex;case"stack-child-reorder":return e.position===t.position;default:return!1}}function eo(t){return{id:t.id,type:"drop-target",width:t.width,height:t.height}}function Yp(t){return t.map(m2)}function g2(t){return t.type==="drop-target"?{id:t.id,type:"card",artifactID:t.id,width:t.width,height:t.height}:t}function m2(t){return t.type==="drop-target"?{id:t.id,type:"card",artifactID:t.id,width:t.width,height:t.height}:t.type==="stack"?{...t,children:t.children.map(g2)}:t}function py(t,e){return t.find(r=>r.type==="card"&&r.id===e)??null}function Kp(t,e){return t.find(r=>r.type==="stack"&&r.id===e)??null}function v2(t,e){const n=[...e],r=n.findIndex(a=>a.type==="card"&&a.id===t.nodeId);if(r===-1)return null;const i=n[r];if(!i||i.type!=="card")return null;n.splice(r,1);const s=Math.max(0,Math.min(t.lastReorderIndex,n.length));n.splice(s,0,i);const o=n.findIndex(a=>a.type==="card"&&a.id===t.nodeId);return o===-1?null:{base:n,visualDraggedIndex:o}}function y2(t,e,n,r){const i=[...t.base];i.splice(t.visualDraggedIndex,1);const s=i.findIndex(y=>y.type==="card"&&y.id===n.targetCardId),o=s===-1?null:i[s];if(!o||o.type!=="card")return null;const a=py(r,e.nodeId);if(!a)return null;const c=Hc(a),u=Hc(o),d=eo(c),p=n.position==="above"?[d,u]:[u,d];return i[s]={id:o.id,type:"stack",children:p},i}function Gl(t,e){return t.parentStackId?w2(t,e):b2(t,e)}function b2(t,e){const n=t.hitTarget;if(n.type==="reorder"){const r=e[t.sourceIndex];if(!r||r.type!=="card")return[...e];const i=[...e];return i.splice(t.sourceIndex,1),i.splice(n.index,0,eo(r)),i}if(n.type==="stack"){const r=v2(t,e);return r?y2(r,t,n,e)??[...e]:[...e]}return[...e]}function w2(t,e){const n=t.hitTarget;switch(n.type){case"stack-child-reorder":return _2(t,e,n.position);case"stack-child-extract":return S2(t,e,n.toIndex);case"stack-child-noop":return k2(t,e);default:return[...e]}}function _2(t,e,n){const r=e.findIndex(y=>y.type==="stack"&&y.id===t.parentStackId);if(r===-1)return[...e];const i=e[r];if(!i||i.type!=="stack")return[...e];if(!i.children.every(y=>y.type==="card"))return[...e];const s=i.children,o=s.findIndex(y=>y.id===t.nodeId);if(o===-1)return[...e];const a=s[o],c=s.filter(y=>y.id!==t.nodeId),u=eo(a),d=n==="above"?[u,...c]:[...c,u],p=[...e];return p[r]={...i,children:d},p}function S2(t,e,n){if(!t.parentStackId)return[...e];const r=u2(e,t.parentStackId,t.nodeId,n);if(r===e)return[...e];const i=r.findIndex(a=>a.type==="card"&&a.id===t.nodeId);if(i===-1)return[...e];const s=r[i];if(!s||s.type!=="card")return[...e];const o=[...r];return o[i]=eo(s),o}function k2(t,e){const n=e.findIndex(c=>c.type==="stack"&&c.id===t.parentStackId);if(n===-1)return[...e];const r=e[n];if(!r||r.type!=="stack")return[...e];const i=r.children.findIndex(c=>c.type==="card"&&c.id===t.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]=eo(s),o[n]={...r,children:a},o}function x2(t,e){return e.find(r=>r.type==="stack"&&r.id===t.id)?t.id:Iu()}function E2(t,e,n){if(t.type==="drop-target"){const r=Ku(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return Hc(r)}return t}function $2(t,e,n){const r=t.children.map(s=>E2(s,e,n));return{id:x2(t,e),type:"stack",children:r}}function A2(t,e,n){if(t.type==="drop-target"){const r=Ku(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return py(e,n)!==null?r:Bc(r)}return t.type==="card"||t.type==="row"?t:$2(t,e,n)}function T2(t,e,n){return t.map(r=>A2(r,e,n))}function C2(t,e){return JSON.stringify(t)===JSON.stringify(e)}const I2=pi(gt);class P2 extends I2{constructor(n={}){super();b(this,"pending",null);b(this,"active",null)}start(n){if(this.pending||this.active)return;const r=n.pointer.x??0,i=n.pointer.y??0;this.pending={startX:r,startY:i,grabOffsetX:n.grabOffset.x??0,grabOffsetY:n.grabOffset.y??0,nodeId:n.nodeId,sourceIndex:n.source.index,parentStackId:n.source.parentId,width:n.size.x??0,height:n.size.y??0,baseLayout:n.layout}}update(n){const r=n.pointer.x??0,i=n.pointer.y??0,s=this.pending;if(s){const u=r-s.startX,d=i-s.startY;Math.hypot(u,d)>=Vx&&(this.pending=null,this.active={...s,pointerX:r,pointerY:i,hitTarget:{type:"reorder",index:s.sourceIndex},lastReorderIndex:s.sourceIndex},this.emitDrag(),this.dispatchEvent(new ee("change")));return}if(!this.active)return;const o=Gl(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,i,n,o),c=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===i&&f2(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 ee("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const n=this.active.baseLayout;let r=null;try{const i=Gl(this.active,n),s=T2(i,n,this.active.nodeId);C2(s,n)||(r=s)}catch{r=null}this.reset(),r&&this.dispatchEvent(new d2("drop",{layout:r})),this.dispatchEvent(new ee("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new ee("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 n=Gl(this.active,this.active.baseLayout);this.dispatchEvent(new h2("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:n}))}getHitTargetForPointer(n,r,i,s){return this.active?this.isPointerInsideDragBounds(n,r,i.viewport)?this.active.parentStackId?this.getStackChildHitTarget(n,r,i,s):this.getTopLevelCardHitTarget(n,r,i,s):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(n,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&&Tn(n,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&&Tn(n,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(n,r,i,s)}}getSourceRemainingSiblingRect(n){var s,o;if(!((s=this.active)!=null&&s.parentStackId))return;const r=Kp(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=n.find(a=>a.id===i.id))==null?void 0:o.rect}getSourceStackInteractionRect(n){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const r=n.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=Kp(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=n.find(c=>c.id===s.id);if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(n,r,i,s){var v,$,k;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return{type:"reorder",index:((v=this.active)==null?void 0:v.sourceIndex)??0};const c=(i.effectiveVelocity??0)<=p2;for(const I of o){const B=I.rect;if(!Tn(n,r,B))continue;const P=this.resolveTopLevelTargetForCard(n,r,I,I.logicalIndex,c);if(P)return P;if(!c&&(($=this.active)!=null&&$.hitTarget))return this.active.hitTarget}const u=this.getNearestTargetableZone(n,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,n)),p=this.resolveTopLevelTargetForCard(d,r,u,u.logicalIndex,c);if(p)return p;const y=u.rect.left+u.rect.width/2;return{type:"reorder",index:n<y?u.logicalIndex:u.logicalIndex+1}}getTopLevelReorderIndexForPointer(n,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 p of o){if(!Tn(n,r,p.rect))continue;const y=jl(p.rect,Vl["reorder-before"]);if(Tn(n,r,y))return p.logicalIndex;const v=jl(p.rect,Vl["reorder-after"]);if(Tn(n,r,v))return p.logicalIndex+1}const a=this.getNearestTargetableZone(n,o);if(!a)return((d=this.active)==null?void 0:d.sourceIndex)??0;const c=a.rect.left+a.rect.width/2;return n<c?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(n,r){const i=new Map(r.map(a=>[a.id,a])),s=[];let o=0;for(const a of n){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(n,r,i,s,o){const a=i.rect;for(const c of c2){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const u=Vl[c],d=jl(a,u);if(Tn(n,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(n,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=n<a?a-n:n>c?n-c:0;u<s&&(s=u,i=o)}return i}isPointerInsideDragBounds(n,r,i){return n>=i.left&&n<=i.left+i.width&&r>=i.top&&r<=i.top+i.height}}const Jp=60,R2=80,Xp=.5,Qp=10;class D2{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:n,shiftKey:r,deltaX:i,deltaY:s,overArtifactContent:o}=e;n-this.lastWheelGestureAt>=Jp&&(this.activeGestureType="none");const c=r&&s!==0,u=c?s:i,d=Math.abs(u),p=Math.abs(s);return this.activeGestureType==="vertical-artifact"&&o?d>=Xp&&d>=p*Qp?this.classifyHorizontal(n,u):(this.lastWheelGestureAt=n,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!c&&o&&p>0&&p>=d*Qp?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,u):d<Xp?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):c||d>p?this.classifyHorizontal(n,u):p>d?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,u)}classifyHorizontal(e,n){const r=e-this.lastWheelEventAt,i=Math.sign(this.lastWheelDeltaX),s=Math.sign(n),o=i!==0&&s!==0&&i!==s,a=i!==0&&Math.abs(n)>=Math.abs(this.lastWheelDeltaX)+R2;return this.awaitingFreshWheelGesture&&r<Jp&&!o&&!a?{type:"ignore"}:(this.lastWheelEventAt=e,this.lastWheelDeltaX=n,this.lastWheelGestureAt=e,this.awaitingFreshWheelGesture=!1,this.activeGestureType="horizontal-filmstrip",{type:"scroll-horizontal",horizontalDelta:n})}}const O2=2,ef=1e3,$o=1e-4;function tf(t,e,n){if(t===0)return 0;const r=e.toPixels(Te({y:Xe})).y??0;return(n-r)/O2}function Wl(t){const e=t.clientWidth>0?t.clientWidth:sr,n=t.clientHeight>0?t.clientHeight:ea;let r=0,i=0;if(t.isConnected){const o=getComputedStyle(t);r=parseFloat(o.paddingTop)||0,i=parseFloat(o.paddingBottom)||0}const s=Math.max(1,n-r-i);return{width:e,height:s,offsetY:r}}class z2 extends Event{constructor(n){super("scroll",{bubbles:!0,composed:!0});b(this,"scrollPosition");this.scrollPosition=n}}class fy extends Event{constructor(n){super("layout-change",{bubbles:!0,composed:!0});b(this,"layout");this.layout=n}}class L2 extends HTMLElement{constructor(){super();b(this,"_layout",[]);b(this,"_scrollPosition",0);b(this,"layoutGrid",null);b(this,"layoutScroll",new l2(Te({x:0})));b(this,"scrollModelKey","");b(this,"resizeObserver",null);b(this,"renderPending",!1);b(this,"animateNextRender",!0);b(this,"wheelGesture",new D2);b(this,"dragController",new P2);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",n=>{const r=Yp(n.projectedLayout),i=this.shouldApplyTrackOffset(n.projectedLayout,n.source.parentId),s=n.source.parentId?this.getStackChildAnchorCardId(n.source.parentId,n.nodeId):null;this.dragTrackOffsetXPx=i?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,r,n.nodeId,n.source.parentId,s,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=r,this.dragState={nodeId:n.nodeId,source:n.source,grabOffset:n.grabOffset,pointer:n.pointer,size:n.size,projectedLayout:n.projectedLayout},this.scheduleRender()});b(this,"onDragControllerDrop",n=>{this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.commitLayout(n.layout)});b(this,"onLayoutScrollInternal",n=>{const i=n.scroll.x??0;Math.abs(i-this._scrollPosition)<$o||(this._scrollPosition=i,this.emitScrollPositionChanged(i),this.scheduleRender())});b(this,"handleKeyDown",n=>{if(n.key==="Escape"&&this.dragController.status!=="idle"){n.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(n.key==="ArrowRight"?(n.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(1)):n.key==="ArrowLeft"&&(n.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(-1)))});b(this,"handleWheel",n=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:n.shiftKey,deltaX:n.deltaX,deltaY:n.deltaY,overArtifactContent:!1});r.type==="scroll-horizontal"&&(n.preventDefault(),this.applyHorizontalWheel(r.horizontalDelta))});b(this,"handleWindowMessage",n=>{var o;if(this._layout.length===0)return;const r=this.findManagedArtifactFrame(n.source);if(!r||!this.isTrustedArtifactFrameMessage(n,r)||!tC(n.data))return;const i=this.wheelGesture.decide({now:Date.now(),shiftKey:n.data.shiftKey,deltaX:n.data.deltaX,deltaY:n.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:n.data.deltaY};(o=r.contentWindow)==null||o.postMessage(s,this.getArtifactFrameTargetOrigin(r))});b(this,"handlePointerDown",n=>{if(n.button!==0||this.dragController.status!=="idle")return;const r=n.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=N2(this._layout,s);if(!o)return;const a=i.getBoundingClientRect();this.lastPointerX=n.clientX,this.lastPointerY=n.clientY,this.resetMotionTracking(n.clientX,n.clientY),this.focus(),this.dragController.start({nodeId:s,source:{index:o.topLevelIndex,parentId:o.sourceStackId},pointer:ke({x:n.clientX,y:n.clientY}),grabOffset:ke({x:n.clientX-a.left,y:n.clientY-a.top}),size:ke({x:a.width,y:a.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=n.pointerId;try{this.setPointerCapture(n.pointerId)}catch{}n.preventDefault()});b(this,"handleWindowPointerMove",n=>{this.lastPointerX=n.clientX,this.lastPointerY=n.clientY,this.updatePointerVelocity(n.clientX,n.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop()});b(this,"handleWindowPointerUp",n=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(n.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowPointerCancel",n=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(n.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",n=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const r=Math.max(0,n-this.lastDragFrameTime)/ef;this.lastDragFrameTime=n,this.samplePointerVelocityAt(n,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>$o?Math.abs(o)/r:0,Math.abs(o)>$o&&(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(n){this._layout=[...n],this.stopDragFrameLoop(),this.dragController.cancel(),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=Te({x:this._scrollPosition}),this.scheduleRender()}get layout(){return this._layout}commitLayout(n){this.layout=n,this.emitLayoutChanged()}set scrollPosition(n){Math.abs(n-this._scrollPosition)<$o||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=Te({x:n}))}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 n;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("message",this.handleWindowMessage),(n=this.resizeObserver)==null||n.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(n,r){return new JD({basis:ke({x:Rn,y:Rn}),min:ke({x:op,y:op}),viewport:ke({x:n,y:r}),gap:ke({x:ge,y:ge})})}syncScrollModel(){const n=Wl(this),i=qi(this._layout).nodes.map(o=>o.width),s=`${n.width}x${n.height}:${i.join(",")}`;s===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=s,this.layoutGrid=this.createGrid(n.width,n.height),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(o=>Te({x:o}))}))}emitScrollPositionChanged(n){this.dispatchEvent(new z2(n))}emitLayoutChanged(){this.dispatchEvent(new fy([...this._layout]))}shiftWindow(n){this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(n)}applyHorizontalWheel(n){this.syncScrollModel();const r=this.layoutGrid;if(!r)return;this.animateNextRender=!1;const i=r.toUnits(ke({x:n}));this.layoutScroll.wheel(Te({x:i.x??0}))}findManagedArtifactFrame(n){if(!n)return null;const r=this.querySelectorAll("iframe.artifact-frame");for(const i of r)if(i.contentWindow===n)return i;return null}isTrustedArtifactFrameMessage(n,r){if(n.origin==="null")return!0;const i=this.getArtifactFrameOrigin(r);return i===null||n.origin===i}getArtifactFrameTargetOrigin(n){const r=n.getAttribute("sandbox")??"";return new Set(r.split(/\s+/).filter(Boolean)).has("allow-same-origin")?this.getArtifactFrameOrigin(n)??"*":"*"}getArtifactFrameOrigin(n){const r=n.getAttribute("src")??n.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(n){try{this.hasPointerCapture(n)&&this.releasePointerCapture(n)}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 n=new Map;return n.set(this.dragState.nodeId,{id:this.dragState.nodeId,sourceCardId:this.dragState.nodeId}),{layout:Yp(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:n}}render(){const n=Wl(this),r=this.createGrid(n.width,n.height);this.layoutGrid=r;const i=this.getDisplayModel(),s=i.layout,o=this.dragController.status==="active",a=qi(s),c=a.nodes.map(L=>L.width),u=`${n.width}x${n.height}:${c.join(",")}`;!o&&u!==this.scrollModelKey&&(this.scrollModelKey=u,this.layoutScroll.rebuild({grid:r,nodeWidths:c.map(L=>Te({x:L}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const d=M2(s),p=r.unit.x??Rn,y=r.unit.y??Rn,v=o?this.dragTrackOffsetXPx:0,$=(this.layoutScroll.translate.x??0)+v,k=tf(a.nodes.length,r,n.height),I=this.animateNextRender&&!o,B=[`transform: translate(${$}px, ${k}px);`,`transition-duration: ${I?Bx:0}ms;`,`pointer-events: ${o?"none":"auto"};`].join(" ");this.animateNextRender=!0,this.style.setProperty("--layout-unit-x",`${p}px`),this.style.setProperty("--layout-unit-y",`${y}px`),this.style.setProperty("--layout-gap",`${ge}px`);const P=this.dragState,K={width:(P==null?void 0:P.size.x)??0,height:(P==null?void 0:P.size.y)??0};Re(F`
162
+ <div class="track" style=${B}>
163
+ ${a.nodes.map((L,Z)=>F`
164
+ <div
165
+ class="node"
166
+ layout-node=${String(Z)}
167
+ data-layout-node-id=${L.id}
168
+ data-layout-placeholder=${String(i.activePlaceholderId===L.id)}
169
+ layout-node-cols=${String(L.width)}
170
+ style=${`grid-template-columns: repeat(${L.width}, var(--layout-unit-x)); width: ${r.toPixels(Te({x:L.width})).x}px;`}
171
+ >
172
+ ${L.cards.map(N=>{const ce=i.placeholdersById.get(N.id);if(P&&ce)return F`
173
+ <div
174
+ class="card-slot card-placeholder"
175
+ data-layout-placeholder-for=${P.nodeId}
176
+ data-layout-placeholder-ghost="false"
177
+ data-layout-source-stack=${P.source.parentId??""}
178
+ style=${`grid-column: ${N.col} / span ${N.width}; grid-row: ${N.row} / span ${N.height};`}
179
+ ></div>
180
+ `;const ue=d.get(N.id);return ue?F`
181
+ <div
182
+ class="card-slot"
183
+ data-layout-card-id=${N.artifactID}
184
+ data-layout-node-id=${N.id}
185
+ layout-cols=${String(N.width)}
186
+ layout-rows=${String(N.height)}
187
+ style=${`grid-column: ${N.col} / span ${N.width}; grid-row: ${N.row} / span ${N.height};`}
188
+ >
189
+ ${this.renderContent(ue,{isDragging:!1})}
190
+ </div>
191
+ `:null})}
192
+ </div>
193
+ `)}
194
+ </div>
195
+ ${P?(()=>{const L=this.getPlaceholderPixelSize(a,i.activePlaceholderId,r,K),Z=P.pointer.x??0,N=P.pointer.y??0,ce=P.grabOffset.x??0,ue=P.grabOffset.y??0;return F`
196
+ <div
197
+ class="drag-preview"
198
+ data-layout-preview-card-id=${P.nodeId}
199
+ style=${[`width: ${L.width}px;`,`height: ${L.height}px;`,`left: ${Z-ce}px;`,`top: ${N-ue}px;`].join(" ")}
200
+ >
201
+ ${this.renderDraggedPreview(P.nodeId)}
202
+ </div>
203
+ `})():null}
204
+ `,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 n=this.getBoundingClientRect();if(this.dragController.status==="active"){const i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,n);this.syncDragTarget(i.x,i.y,n);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,n),this.dragController.status==="pending")return;const r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,n);(r.x!==this.lastPointerX||r.y!==this.lastPointerY)&&this.syncDragTarget(r.x,r.y,n)}syncDragTarget(n,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:n,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(n,r){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=n,this.motionSampleY=r}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(n,r){this.samplePointerVelocityAt(performance.now(),n,r)}samplePointerVelocityAt(n,r,i){if(this.motionSampleTime===0){this.motionSampleTime=n,this.motionSampleX=r,this.motionSampleY=i,this.pointerVelocityPxPerSec=0;return}const s=n-this.motionSampleTime;if(s<100)return;const o=r-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/s*ef,this.motionSampleTime=n,this.motionSampleX=r,this.motionSampleY=i}clampPointerToViewport(n,r,i){return{x:Math.max(i.left,Math.min(i.left+i.width,n)),y:Math.max(i.top,Math.min(i.top+i.height,r))}}isPointerOutsideViewport(n,r,i){return n<i.left||n>i.left+i.width||r<i.top||r>i.top+i.height}getDragEdgeScrollDeltaPixels(n,r,i){var u;const s=r.left+bo,o=r.left+r.width-bo,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??Rn,c=jx*a;if(n<s){const d=Math.max(0,Math.min(1,(s-n)/bo));return-(c*d**ap)*i}if(n>o){const d=Math.max(0,Math.min(1,(n-o)/bo));return c*d**ap*i}return 0}measureLayoutGeometry(n,r,i=0){const s=this.layoutGrid;if(!s)return[];const o=qi(n),a=new Map(o.nodes.map(k=>[k.id,k.width])),c=s.toPixels(Te({y:Xe})).y??ea,u=Wl(this),d=(this.layoutScroll.translate.x??0)+i,p=tf(o.nodes.length,s,u.height),y=u.offsetY+p,v=[];let $=d;for(const k of n){const I=a.get(k.id)??Ct,B=s.toPixels(Te({x:I})).x??sr,P={left:$,top:y,width:B,height:c};v.push({id:k.id,rect:P}),$+=B+ge}return v}getPlaceholderPixelSize(n,r,i,s){if(!r)return s;for(const o of n.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(n){const r=Ku(this._layout,n);return r?this.renderContent(r,{isDragging:!0}):F``}shouldApplyTrackOffset(n,r){if(r)return!0;for(const i of n){if(i.type!=="stack")continue;if(i.children.some(o=>o.type==="drop-target")&&r!==i.id)return!0}return!1}computeDragTrackOffset(n,r,i,s,o,a){if(!n)return a;const c=s?o??this.getStableAnchorCardId(n,r,i):this.getStableAnchorNodeId(n,r,i);if(!c)return a;const u=s?rf(n,c,this.layoutGrid):sf(n,c,this.layoutGrid),d=s?rf(r,c,this.layoutGrid):sf(r,c,this.layoutGrid);return u===null||d===null?a:a+(u-d)}getStableAnchorCardId(n,r,i){const s=nf(n),o=new Set(nf(r));for(const a of s)if(a!==i&&o.has(a))return a;return null}getStableAnchorNodeId(n,r,i){const s=new Set(r.map(o=>o.id));for(const o of n)if(o.id!==i&&s.has(o.id))return o.id;return null}getStackChildAnchorCardId(n,r){const i=this._layout.find(o=>o.type==="stack"&&o.id===n);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 M2(t){const e=new Map;for(const n of t){if(n.type==="card"){e.set(n.id,n);continue}for(const r of n.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 N2(t,e){const n=t.findIndex(r=>r.type==="card"&&r.id===e);if(n!==-1)return{topLevelIndex:n};for(let r=0;r<t.length;r+=1){const i=t[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 nf(t){const e=[];for(const n of t){if(n.type==="card"){e.push(n.id);continue}if(n.type==="stack"){const r=n.children.find(i=>i.type==="card");r&&e.push(r.id)}}return e}function rf(t,e,n){if(!n)return null;const r=qi(t),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of t){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=n.toPixels(Te({x:a})).x??sr;s+=c+ge}return null}function sf(t,e,n){if(!n)return null;const r=qi(t),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of t){if(o.id===e)return s;const a=i.get(o.id)??Ct,c=n.toPixels(Te({x:a})).x??sr;s+=c+ge}return null}customElements.get("layout-view")||customElements.define("layout-view",L2);class U2 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",n=>{n instanceof ly&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(n.artifactID)});b(this,"handleScrollPositionChanged",n=>{const r=n;typeof r.scrollPosition=="number"&&Number.isFinite(r.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(r.scrollPosition)});b(this,"handleLayoutChanged",n=>{n instanceof fy&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(n.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 n=this.screenManager.activeScreen;this.boundModel!==n&&(this.unbindModel(),this.boundModel=n,n&&n.addEventListener("change",this.handleModelChange))}unbindModel(){this.boundModel&&(this.boundModel.removeEventListener("change",this.handleModelChange),this.boundModel=null)}buildArtifactMap(){const n=this.screenManager.activeScreen;return n?new Map(n.artifacts):new Map}render(){const n=this.screenManager.activeScreen,r=(n==null?void 0:n.layout)??[],i=this.buildArtifactMap();if(r.length===0){Re(F`<p data-testid="empty-screen" class="empty">
205
+ No artifacts yet. Create one by asking for something.
206
+ </p>`,this);return}Re(F`
207
+ <layout-view
208
+ .layout=${r}
209
+ .renderContent=${(o,a)=>{const c=i.get(o.artifactID);return!c||!n?F``:F`<artifact-view
210
+ .artifact=${c}
211
+ .screen=${n}
212
+ .viewURL=${n.server.getViewURL(c)}
213
+ .contentURL=${n.server.getContentURL(c.id)}
214
+ .dragging=${a.isDragging}
215
+ ></artifact-view>`}}
216
+ .scrollPosition=${(n==null?void 0:n.scrollPosition)??0}
217
+ @scroll=${this.handleScrollPositionChanged}
218
+ @layout-change=${this.handleLayoutChanged}
219
+ @close-artifact=${this.handleCloseArtifact}
220
+ ></layout-view>
221
+ `,this)}}customElements.define("screen-view",U2);var ya,Gr,Is,Wt,gy,my,Vc;class F2 extends HTMLElement{constructor(){super(...arguments);_(this,Wt);_(this,ya,Ge.resolve("ScreenManager"));_(this,Gr,Ge.resolve("ServerManager"));_(this,Is,()=>{m(this,Wt,Vc).call(this)})}connectedCallback(){l(this,Gr).addEventListener("change",l(this,Is)),m(this,Wt,Vc).call(this)}disconnectedCallback(){l(this,Gr).removeEventListener("change",l(this,Is))}}ya=new WeakMap,Gr=new WeakMap,Is=new WeakMap,Wt=new WeakSet,gy=function(n,r){l(this,ya).setActive(n,r)},my=function(){for(const n of l(this,Gr).servers.values())return n;return null},Vc=function(){const n=m(this,Wt,my).call(this),i=(n?[...n.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`
222
+ <ul class="tiles">
223
+ ${i.map(o=>F`
224
+ <li>
225
+ <button
226
+ class="tile"
227
+ type="button"
228
+ material="glass"
229
+ @click=${()=>n&&m(this,Wt,gy).call(this,n.url,o.id)}
230
+ >
231
+ ${o.name}
232
+ </button>
233
+ </li>
234
+ `)}
235
+ </ul>
236
+ `;Re(s,this)};customElements.get("home-screen")||customElements.define("home-screen",F2);const ql=new WeakMap,of=Object.prototype.hasOwnProperty,Z2=(()=>{const t=new Set;let e=HTMLElement.prototype;for(;e;){for(const n of Object.getOwnPropertyNames(e))t.add(n);if(e===Node.prototype)break;e=Object.getPrototypeOf(e)}return t})();function H2(t,e){if(t===Boolean)return e!==null;if(e!==null)return t===Number?Number(e):e}var Ps,jc,Qn,tt,At,Wr,er,qr,Ie,Hi,vy,yy,by,jo;const zn=class zn extends HTMLElement{constructor(){var i;super();_(this,Ie);_(this,Qn,new Map);_(this,tt,new Map);_(this,At,new Map);_(this,Wr,!1);_(this,er,!1);_(this,qr,!1);const n=m(i=zn,Ps,jc).call(i,this.constructor),r=this;for(const s of n.properties)of.call(r,s)&&(l(this,At).set(s,r[s]),delete r[s])}static get observedAttributes(){var n;return m(n=zn,Ps,jc).call(n,this).observedAttributes}connected(){}disconnected(){}changed(n){}connectedCallback(){if(m(this,Ie,by).call(this),!l(this,er))for(const n of m(this,Ie,Hi).call(this).properties)l(this,tt).has(n)||l(this,tt).set(n,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),m(this,Ie,jo).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(n,r,i){if(r===i)return;const s=m(this,Ie,Hi).call(this).byAttr.get(n);s&&(l(this,At).has(s.property)||(this[s.property]=H2(s.type,i)))}};Ps=new WeakSet,jc=function(n){const r=ql.get(n);if(r)return r;const i=[...n.properties??[]],s=n.attributes??{},o=new Map,a=new Map;for(const u of i)if(Z2.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 p=d.property??u;if(!i.includes(p))throw new Error(`Attribute '${u}' references property '${p}', which isn't declared in \`static properties\`. Add it to \`properties\` to make it reactive.`);const y={attribute:u,property:p,type:d.type};o.set(u,y),a.set(p,y)}for(const u of i){const d=Object.getOwnPropertyDescriptor(n.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(n.prototype,u,{configurable:!0,enumerable:!0,get(){return l(this,Qn).get(u)},set(p){m(this,Ie,vy).call(this,u,p)}})}const c={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return ql.set(n,c),c},Qn=new WeakMap,tt=new WeakMap,At=new WeakMap,Wr=new WeakMap,er=new WeakMap,qr=new WeakMap,Ie=new WeakSet,Hi=function(){return ql.get(this.constructor)},vy=function(n,r){if(!l(this,qr)&&l(this,At).has(n))return;const i=l(this,Qn).get(n);Object.is(i,r)||(l(this,tt).has(n)||l(this,tt).set(n,i),l(this,Qn).set(n,r),l(this,At).delete(n),m(this,Ie,yy).call(this,n,r),this.isConnected&&m(this,Ie,jo).call(this))},yy=function(n,r){const i=m(this,Ie,Hi).call(this).byProp.get(n);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)},by=function(){const n=this,r=m(this,Ie,Hi).call(this);for(const i of r.properties){if(!of.call(n,i))continue;const s=n[i];delete n[i],!(l(this,At).has(i)||l(this,Qn).has(i))&&(n[i]=s)}x(this,qr,!0);try{for(const[i,s]of l(this,At))n[i]=s;l(this,At).clear()}finally{x(this,qr,!1)}},jo=function(){l(this,Wr)||!this.isConnected||l(this,er)&&l(this,tt).size===0||(x(this,Wr,!0),queueMicrotask(()=>{if(x(this,Wr,!1),!this.isConnected||l(this,er)&&l(this,tt).size===0)return;const n=new Map(l(this,tt));l(this,tt).clear(),x(this,er,!0);try{this.changed(n)}catch(r){console.error(r)}this.isConnected&&l(this,tt).size>0&&m(this,Ie,jo).call(this)}))},_(zn,Ps),b(zn,"properties"),b(zn,"attributes");let ns=zn;/**
237
+ * @license
238
+ * Copyright 2020 Google LLC
239
+ * SPDX-License-Identifier: BSD-3-Clause
240
+ */const B2=t=>t.strings===void 0;/**
241
+ * @license
242
+ * Copyright 2017 Google LLC
243
+ * SPDX-License-Identifier: BSD-3-Clause
244
+ */const Ki=(t,e)=>{var r;const n=t._$AN;if(n===void 0)return!1;for(const i of n)(r=i._$AO)==null||r.call(i,e,!1),Ki(i,e);return!0},la=t=>{let e,n;do{if((e=t._$AM)===void 0)break;n=e._$AN,n.delete(t),t=e}while((n==null?void 0:n.size)===0)},wy=t=>{for(let e;e=t._$AM;t=e){let n=e._$AN;if(n===void 0)e._$AN=n=new Set;else if(n.has(t))break;n.add(t),G2(e)}};function V2(t){this._$AN!==void 0?(la(this),this._$AM=t,wy(this)):this._$AM=t}function j2(t,e=!1,n=0){const r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(e)if(Array.isArray(r))for(let s=n;s<r.length;s++)Ki(r[s],!1),la(r[s]);else r!=null&&(Ki(r,!1),la(r));else Ki(this,t)}const G2=t=>{t.type==Mv.CHILD&&(t._$AP??(t._$AP=j2),t._$AQ??(t._$AQ=V2))};class W2 extends Nv{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,n,r){super._$AT(e,n,r),wy(this),this.isConnected=e._$AU}_$AO(e,n=!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)),n&&(Ki(this,e),la(this))}setValue(e){if(B2(this._$Ct))this._$Ct._$AI(e,this);else{const n=[...this._$Ct._$AH];n[this._$Ci]=e,this._$Ct._$AI(n,this,0)}}disconnected(){}reconnected(){}}/**
245
+ * @license
246
+ * Copyright 2020 Google LLC
247
+ * SPDX-License-Identifier: BSD-3-Clause
248
+ */const Ao=()=>new q2;class q2{}const Yl=new WeakMap,To=qu(class extends W2{render(t){return ae}update(t,[e]){var r;const n=e!==this.G;return n&&this.G!==void 0&&this.rt(void 0),(n||this.lt!==this.ct)&&(this.G=e,this.ht=(r=t.options)==null?void 0:r.host,this.rt(this.ct=t.element)),ae}rt(t){if(this.isConnected||(t=void 0),typeof this.G=="function"){const e=this.ht??globalThis;let n=Yl.get(e);n===void 0&&(n=new WeakMap,Yl.set(e,n)),n.get(this.G)!==void 0&&this.G.call(this.ht,void 0),n.set(this.G,t),t!==void 0&&this.G.call(this.ht,t)}else this.G.value=t}get lt(){var t,e;return typeof this.G=="function"?(t=Yl.get(this.ht??globalThis))==null?void 0:t.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,Yr,Kr,Rs,tr,nr,ie,Pe,_y,Ds,Os,Gc,Wc,ba,wa,_a,Sa,ka,xa,Ea,zs,Ls,Bi,Sy,ht;class Y2 extends ns{constructor(){super(...arguments);_(this,Pe);_(this,Je,Ge.resolve("ScreenManager"));_(this,un,null);_(this,Yr,new DisposableStack);_(this,Kr,Ao());_(this,Rs,Ao());_(this,tr,Ao());_(this,nr,Ao());_(this,ie,{kind:"none"});_(this,Ds,()=>{m(this,Pe,Gc).call(this),l(this,ht).call(this)});_(this,Os,()=>{l(this,ht).call(this)});_(this,ba,()=>{l(this,Je).clearActive()});_(this,wa,n=>{l(this,ie).kind!=="none"&&(n.stopImmediatePropagation(),m(this,Pe,Bi).call(this))});_(this,_a,()=>{var r;const n=l(this,Je).activeScreen;n&&((r=l(this,Kr).value)==null||r.close(),x(this,ie,{kind:"rename",draft:n.name}),l(this,ht).call(this))});_(this,Sa,()=>{var n;l(this,Je).activeScreen&&((n=l(this,Kr).value)==null||n.close(),x(this,ie,{kind:"delete",error:null}),l(this,ht).call(this))});_(this,ka,n=>{if(l(this,ie).kind!=="rename")return;const r=n.target;r instanceof HTMLInputElement&&x(this,ie,{kind:"rename",draft:r.value})});_(this,xa,n=>{if(n.preventDefault(),l(this,ie).kind!=="rename")return;const r=l(this,Je).activeScreen;if(!r)return;const i=l(this,ie).draft.trim();i.length>0&&i!==r.name&&r.rename(i),m(this,Pe,Bi).call(this)});_(this,Ea,async()=>{if(l(this,ie).kind!=="delete")return;const n=l(this,Je).activeScreen;if(n){x(this,ie,{kind:"delete",error:null});try{await n.remove(),l(this,Je).clearActive(),m(this,Pe,Bi).call(this)}catch(r){x(this,ie,{kind:"delete",error:r instanceof Error?r.message:"Failed to delete screen."}),l(this,ht).call(this)}}});_(this,zs,()=>{m(this,Pe,Bi).call(this)});_(this,Ls,()=>{l(this,ie).kind!=="none"&&(x(this,ie,{kind:"none"}),l(this,ht).call(this))});_(this,ht,()=>{const n=F`
249
+ <button
250
+ icon-only
251
+ variant="ghost"
252
+ class="home"
253
+ type="button"
254
+ aria-label="Home"
255
+ @click=${l(this,ba)}
256
+ >
257
+ ${CD({weight:"fill"})}
258
+ </button>
259
+ `;Re(F`${n}${m(this,Pe,Sy).call(this)}`,this);const r=l(this,Rs).value??null;l(this,tr).value&&(l(this,tr).value.anchor=r),l(this,nr).value&&(l(this,nr).value.anchor=r)})}connected(){l(this,Je).addEventListener("active-screen-changed",l(this,Ds)),m(this,Pe,Gc).call(this),l(this,ht).call(this),m(this,Pe,_y).call(this),l(this,Yr).defer(()=>{l(this,Je).removeEventListener("active-screen-changed",l(this,Ds)),m(this,Pe,Wc).call(this)})}disconnected(){l(this,Yr).dispose(),x(this,Yr,new DisposableStack)}}Je=new WeakMap,un=new WeakMap,Yr=new WeakMap,Kr=new WeakMap,Rs=new WeakMap,tr=new WeakMap,nr=new WeakMap,ie=new WeakMap,Pe=new WeakSet,_y=async function(){const n=await Gu(this);this.setAttribute("tone",n)},Ds=new WeakMap,Os=new WeakMap,Gc=function(){var r;const n=l(this,Je).activeScreen;l(this,un)!==n&&(m(this,Pe,Wc).call(this),x(this,un,n),(r=l(this,un))==null||r.addEventListener("change",l(this,Os)))},Wc=function(){var n;(n=l(this,un))==null||n.removeEventListener("change",l(this,Os)),x(this,un,null)},ba=new WeakMap,wa=new WeakMap,_a=new WeakMap,Sa=new WeakMap,ka=new WeakMap,xa=new WeakMap,Ea=new WeakMap,zs=new WeakMap,Ls=new WeakMap,Bi=function(){const n=l(this,ie).kind==="rename"?l(this,tr).value:l(this,ie).kind==="delete"?l(this,nr).value:null;n&&(n.open=!1),x(this,ie,{kind:"none"}),l(this,ht).call(this)},Sy=function(){const n=l(this,Je).activeScreen;if(!n)return null;const r=l(this,ie).kind==="rename"?l(this,ie).draft:"",i=l(this,ie).kind==="delete"?l(this,ie).error:null;return F`
260
+ <span class="separator" aria-hidden="true">
261
+ ${$D()}
262
+ </span>
263
+ <dropdown-menu ${To(l(this,Kr))}>
264
+ <button
265
+ slot="trigger"
266
+ type="button"
267
+ variant="ghost"
268
+ aria-label=${`Screen actions for ${n.name}`}
269
+ ?data-active=${l(this,ie).kind!=="none"}
270
+ @click=${l(this,wa)}
271
+ ${To(l(this,Rs))}
272
+ >
273
+ ${n.name}
274
+ </button>
275
+ <dropdown-group>
276
+ <dropdown-item action @click=${l(this,_a)}>
277
+ ${ID()} Rename
278
+ </dropdown-item>
279
+ <dropdown-item action danger @click=${l(this,Sa)}>
280
+ ${PD()} Delete
281
+ </dropdown-item>
282
+ </dropdown-group>
283
+ </dropdown-menu>
284
+ <ui-popover
285
+ class="rename-popover"
286
+ ?open=${l(this,ie).kind==="rename"}
287
+ @close=${l(this,Ls)}
288
+ ${To(l(this,tr))}
289
+ >
290
+ <form class="screen-form" @submit=${l(this,xa)}>
291
+ <label class="field">
292
+ <span>Screen name</span>
293
+ <input
294
+ type="text"
295
+ .value=${r}
296
+ @input=${l(this,ka)}
297
+ />
298
+ </label>
299
+ <div class="actions">
300
+ <button type="button" @click=${l(this,zs)}>Cancel</button>
301
+ <button type="submit" variant="primary">Save</button>
302
+ </div>
303
+ </form>
304
+ </ui-popover>
305
+ <ui-popover
306
+ class="delete-popover"
307
+ ?open=${l(this,ie).kind==="delete"}
308
+ @close=${l(this,Ls)}
309
+ ${To(l(this,nr))}
310
+ >
311
+ <div class="screen-form">
312
+ <p class="confirm-text">Delete "${n.name}"?</p>
313
+ ${i?F`<p class="error">${i}</p>`:ae}
314
+ <div class="actions">
315
+ <button type="button" @click=${l(this,zs)}>Cancel</button>
316
+ <button
317
+ type="button"
318
+ variant="danger"
319
+ @click=${l(this,Ea)}
320
+ >
321
+ Delete
322
+ </button>
323
+ </div>
324
+ </div>
325
+ </ui-popover>
326
+ `},ht=new WeakMap;customElements.define("screen-breadcrumb",Y2);var $a,Aa,Jr,yn,ky,xy,Ta,Ey;class K2 extends HTMLElement{constructor(){super(...arguments);_(this,yn);_(this,$a,Ge.resolve("ServerManager"));_(this,Aa,Ge.resolve("ScreenManager"));_(this,Jr,!1);_(this,Ta,async()=>{if(l(this,Jr))return;const n=m(this,yn,xy).call(this);if(n){x(this,Jr,!0);try{const r=await n.createScreen(J2(new Date));l(this,Aa).setActive(n.url,r.id)}catch{}finally{x(this,Jr,!1)}}})}connectedCallback(){m(this,yn,Ey).call(this),m(this,yn,ky).call(this)}}$a=new WeakMap,Aa=new WeakMap,Jr=new WeakMap,yn=new WeakSet,ky=async function(){const n=await Gu(this);this.setAttribute("tone",n)},xy=function(){for(const n of l(this,$a).servers.values())return n;return null},Ta=new WeakMap,Ey=function(){Re(F`
327
+ <button
328
+ icon-only
329
+ variant="ghost"
330
+ class="new-screen"
331
+ type="button"
332
+ aria-label="New screen"
333
+ @click=${l(this,Ta)}
334
+ >
335
+ ${TD({size:16,weight:"bold"})}
336
+ </button>
337
+ `,this)};function J2(t){const e=t.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),n=12,r=t.getHours(),i=r%n===0?n:r%n,s=t.getMinutes().toString().padStart(2,"0"),o=r>=n?"pm":"am";return`${e} at ${i}:${s}${o}`}customElements.define("screen-create-button",K2);function X2(t,e){let n=null;const r=()=>e((n==null?void 0:n.messages)??[]),i=()=>{const o=t.getActiveClient();o!==n&&(n==null||n.removeEventListener("change",r),n=o,n&&(n.addEventListener("change",r),n.connect().catch(a=>{console.error("ACPClient.connect() failed",a)})),r())};t.addEventListener("change",i),i();const s=()=>{t.removeEventListener("change",i),n==null||n.removeEventListener("change",r),n=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:$y,setPrototypeOf:af,isFrozen:Q2,getPrototypeOf:eO,getOwnPropertyDescriptor:tO}=Object;let{freeze:Ne,seal:it,create:Go}=Object,{apply:qc,construct:Yc}=typeof Reflect<"u"&&Reflect;Ne||(Ne=function(e){return e});it||(it=function(e){return e});qc||(qc=function(e,n){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(n,i)});Yc||(Yc=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return new e(...r)});const Co=Ue(Array.prototype.forEach),nO=Ue(Array.prototype.lastIndexOf),lf=Ue(Array.prototype.pop),Ti=Ue(Array.prototype.push),rO=Ue(Array.prototype.splice),Wo=Ue(String.prototype.toLowerCase),Kl=Ue(String.prototype.toString),Jl=Ue(String.prototype.match),Ci=Ue(String.prototype.replace),iO=Ue(String.prototype.indexOf),sO=Ue(String.prototype.trim),Ye=Ue(Object.prototype.hasOwnProperty),Oe=Ue(RegExp.prototype.test),Ii=oO(TypeError);function Ue(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return qc(t,e,r)}}function oO(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Yc(t,n)}}function V(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Wo;af&&af(t,null);let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){const s=n(i);s!==i&&(Q2(e)||(e[r]=s),i=s)}t[i]=!0}return t}function aO(t){for(let e=0;e<t.length;e++)Ye(t,e)||(t[e]=null);return t}function _t(t){const e=Go(null);for(const[n,r]of $y(t))Ye(t,n)&&(Array.isArray(r)?e[n]=aO(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=_t(r):e[n]=r);return e}function Pi(t,e){for(;t!==null;){const r=tO(t,e);if(r){if(r.get)return Ue(r.get);if(typeof r.value=="function")return Ue(r.value)}t=eO(t)}function n(){return null}return n}const cf=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"]),Xl=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"]),Ql=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"]),lO=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"]),ec=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"]),cO=Ne(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),uf=Ne(["#text"]),hf=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"]),tc=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"]),df=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"]),Io=Ne(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),uO=it(/\{\{[\w\W]*|[\w\W]*\}\}/gm),hO=it(/<%[\w\W]*|[\w\W]*%>/gm),dO=it(/\$\{[\w\W]*/gm),pO=it(/^data-[\-\w.\u00B7-\uFFFF]+$/),fO=it(/^aria-[\-\w]+$/),Ay=it(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),gO=it(/^(?:\w+script|data):/i),mO=it(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ty=it(/^html$/i),vO=it(/^[a-z][.\w]*(-[.\w]+)+$/i);var pf=Object.freeze({__proto__:null,ARIA_ATTR:fO,ATTR_WHITESPACE:mO,CUSTOM_ELEMENT:vO,DATA_ATTR:pO,DOCTYPE_NAME:Ty,ERB_EXPR:hO,IS_ALLOWED_URI:Ay,IS_SCRIPT_OR_DATA:gO,MUSTACHE_EXPR:uO,TMPLIT_EXPR:dO});const Ri={element:1,text:3,progressingInstruction:7,comment:8,document:9},yO=function(){return typeof window>"u"?null:window},bO=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(r=n.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}},ff=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Cy(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:yO();const e=M=>Cy(M);if(e.version="3.3.3",e.removed=[],!t||!t.document||t.document.nodeType!==Ri.document||!t.Element)return e.isSupported=!1,e;let{document:n}=t;const r=n,i=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:c,NodeFilter:u,NamedNodeMap:d=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:p,DOMParser:y,trustedTypes:v}=t,$=c.prototype,k=Pi($,"cloneNode"),I=Pi($,"remove"),B=Pi($,"nextSibling"),P=Pi($,"childNodes"),K=Pi($,"parentNode");if(typeof o=="function"){const M=n.createElement("template");M.content&&M.content.ownerDocument&&(n=M.content.ownerDocument)}let L,Z="";const{implementation:N,createNodeIterator:ce,createDocumentFragment:ue,getElementsByTagName:yi}=n,{importNode:no}=r;let Ee=ff();e.isSupported=typeof $y=="function"&&typeof K=="function"&&N&&N.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:xn,ERB_EXPR:mt,TMPLIT_EXPR:Xt,DATA_ATTR:Ka,ARIA_ATTR:ro,IS_SCRIPT_OR_DATA:Gy,ATTR_WHITESPACE:lh,CUSTOM_ELEMENT:Wy}=pf;let{IS_ALLOWED_URI:ch}=pf,_e=null;const uh=V({},[...cf,...Xl,...Ql,...ec,...uf]);let $e=null;const hh=V({},[...hf,...tc,...df,...Io]);let me=Object.seal(Go(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}})),bi=null,io=null;const Qt=Object.seal(Go(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let dh=!0,Ja=!0,ph=!1,fh=!0,gr=!1,so=!0,En=!1,Xa=!1,Qa=!1,mr=!1,oo=!1,ao=!1,gh=!0,mh=!1;const qy="user-content-";let el=!0,wi=!1,vr={},vt=null;const tl=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 vh=null;const yh=V({},["audio","video","img","source","image","track"]);let nl=null;const bh=V({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),lo="http://www.w3.org/1998/Math/MathML",co="http://www.w3.org/2000/svg",It="http://www.w3.org/1999/xhtml";let yr=It,rl=!1,il=null;const Yy=V({},[lo,co,It],Kl);let uo=V({},["mi","mo","mn","ms","mtext"]),ho=V({},["annotation-xml"]);const Ky=V({},["title","style","font","a","script"]);let _i=null;const Jy=["application/xhtml+xml","text/html"],Xy="text/html";let be=null,br=null;const Qy=n.createElement("form"),wh=function(g){return g instanceof RegExp||g instanceof Function},sl=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(br&&br===g)){if((!g||typeof g!="object")&&(g={}),g=_t(g),_i=Jy.indexOf(g.PARSER_MEDIA_TYPE)===-1?Xy:g.PARSER_MEDIA_TYPE,be=_i==="application/xhtml+xml"?Kl:Wo,_e=Ye(g,"ALLOWED_TAGS")?V({},g.ALLOWED_TAGS,be):uh,$e=Ye(g,"ALLOWED_ATTR")?V({},g.ALLOWED_ATTR,be):hh,il=Ye(g,"ALLOWED_NAMESPACES")?V({},g.ALLOWED_NAMESPACES,Kl):Yy,nl=Ye(g,"ADD_URI_SAFE_ATTR")?V(_t(bh),g.ADD_URI_SAFE_ATTR,be):bh,vh=Ye(g,"ADD_DATA_URI_TAGS")?V(_t(yh),g.ADD_DATA_URI_TAGS,be):yh,vt=Ye(g,"FORBID_CONTENTS")?V({},g.FORBID_CONTENTS,be):tl,bi=Ye(g,"FORBID_TAGS")?V({},g.FORBID_TAGS,be):_t({}),io=Ye(g,"FORBID_ATTR")?V({},g.FORBID_ATTR,be):_t({}),vr=Ye(g,"USE_PROFILES")?g.USE_PROFILES:!1,dh=g.ALLOW_ARIA_ATTR!==!1,Ja=g.ALLOW_DATA_ATTR!==!1,ph=g.ALLOW_UNKNOWN_PROTOCOLS||!1,fh=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,gr=g.SAFE_FOR_TEMPLATES||!1,so=g.SAFE_FOR_XML!==!1,En=g.WHOLE_DOCUMENT||!1,mr=g.RETURN_DOM||!1,oo=g.RETURN_DOM_FRAGMENT||!1,ao=g.RETURN_TRUSTED_TYPE||!1,Qa=g.FORCE_BODY||!1,gh=g.SANITIZE_DOM!==!1,mh=g.SANITIZE_NAMED_PROPS||!1,el=g.KEEP_CONTENT!==!1,wi=g.IN_PLACE||!1,ch=g.ALLOWED_URI_REGEXP||Ay,yr=g.NAMESPACE||It,uo=g.MATHML_TEXT_INTEGRATION_POINTS||uo,ho=g.HTML_INTEGRATION_POINTS||ho,me=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&wh(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(me.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&wh(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),gr&&(Ja=!1),oo&&(mr=!0),vr&&(_e=V({},uf),$e=Go(null),vr.html===!0&&(V(_e,cf),V($e,hf)),vr.svg===!0&&(V(_e,Xl),V($e,tc),V($e,Io)),vr.svgFilters===!0&&(V(_e,Ql),V($e,tc),V($e,Io)),vr.mathMl===!0&&(V(_e,ec),V($e,df),V($e,Io))),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===uh&&(_e=_t(_e)),V(_e,g.ADD_TAGS,be))),g.ADD_ATTR&&(typeof g.ADD_ATTR=="function"?Qt.attributeCheck=g.ADD_ATTR:($e===hh&&($e=_t($e)),V($e,g.ADD_ATTR,be))),g.ADD_URI_SAFE_ATTR&&V(nl,g.ADD_URI_SAFE_ATTR,be),g.FORBID_CONTENTS&&(vt===tl&&(vt=_t(vt)),V(vt,g.FORBID_CONTENTS,be)),g.ADD_FORBID_CONTENTS&&(vt===tl&&(vt=_t(vt)),V(vt,g.ADD_FORBID_CONTENTS,be)),el&&(_e["#text"]=!0),En&&V(_e,["html","head","body"]),_e.table&&(V(_e,["tbody"]),delete bi.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ii('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ii('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');L=g.TRUSTED_TYPES_POLICY,Z=L.createHTML("")}else L===void 0&&(L=bO(v,i)),L!==null&&typeof Z=="string"&&(Z=L.createHTML(""));Ne&&Ne(g),br=g}},_h=V({},[...Xl,...Ql,...lO]),Sh=V({},[...ec,...cO]),eb=function(g){let T=K(g);(!T||!T.tagName)&&(T={namespaceURI:yr,tagName:"template"});const R=Wo(g.tagName),se=Wo(T.tagName);return il[g.namespaceURI]?g.namespaceURI===co?T.namespaceURI===It?R==="svg":T.namespaceURI===lo?R==="svg"&&(se==="annotation-xml"||uo[se]):!!_h[R]:g.namespaceURI===lo?T.namespaceURI===It?R==="math":T.namespaceURI===co?R==="math"&&ho[se]:!!Sh[R]:g.namespaceURI===It?T.namespaceURI===co&&!ho[se]||T.namespaceURI===lo&&!uo[se]?!1:!Sh[R]&&(Ky[R]||!_h[R]):!!(_i==="application/xhtml+xml"&&il[g.namespaceURI]):!1},yt=function(g){Ti(e.removed,{element:g});try{K(g).removeChild(g)}catch{I(g)}},$n=function(g,T){try{Ti(e.removed,{attribute:T.getAttributeNode(g),from:T})}catch{Ti(e.removed,{attribute:null,from:T})}if(T.removeAttribute(g),g==="is")if(mr||oo)try{yt(T)}catch{}else try{T.setAttribute(g,"")}catch{}},kh=function(g){let T=null,R=null;if(Qa)g="<remove></remove>"+g;else{const ve=Jl(g,/^[\r\n\t ]+/);R=ve&&ve[0]}_i==="application/xhtml+xml"&&yr===It&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const se=L?L.createHTML(g):g;if(yr===It)try{T=new y().parseFromString(se,_i)}catch{}if(!T||!T.documentElement){T=N.createDocument(yr,"template",null);try{T.documentElement.innerHTML=rl?Z:se}catch{}}const De=T.body||T.documentElement;return g&&R&&De.insertBefore(n.createTextNode(R),De.childNodes[0]||null),yr===It?yi.call(T,En?"html":"body")[0]:En?T.documentElement:De},xh=function(g){return ce.call(g.ownerDocument||g,g,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},ol=function(g){return g instanceof p&&(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")},Eh=function(g){return typeof a=="function"&&g instanceof a};function Pt(M,g,T){Co(M,R=>{R.call(e,g,T,br)})}const $h=function(g){let T=null;if(Pt(Ee.beforeSanitizeElements,g,null),ol(g))return yt(g),!0;const R=be(g.nodeName);if(Pt(Ee.uponSanitizeElement,g,{tagName:R,allowedTags:_e}),so&&g.hasChildNodes()&&!Eh(g.firstElementChild)&&Oe(/<[/\w!]/g,g.innerHTML)&&Oe(/<[/\w!]/g,g.textContent)||g.nodeType===Ri.progressingInstruction||so&&g.nodeType===Ri.comment&&Oe(/<[/\w]/g,g.data))return yt(g),!0;if(!(Qt.tagCheck instanceof Function&&Qt.tagCheck(R))&&(!_e[R]||bi[R])){if(!bi[R]&&Th(R)&&(me.tagNameCheck instanceof RegExp&&Oe(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R)))return!1;if(el&&!vt[R]){const se=K(g)||g.parentNode,De=P(g)||g.childNodes;if(De&&se){const ve=De.length;for(let Fe=ve-1;Fe>=0;--Fe){const Rt=k(De[Fe],!0);Rt.__removalCount=(g.__removalCount||0)+1,se.insertBefore(Rt,B(g))}}}return yt(g),!0}return g instanceof c&&!eb(g)||(R==="noscript"||R==="noembed"||R==="noframes")&&Oe(/<\/no(script|embed|frames)/i,g.innerHTML)?(yt(g),!0):(gr&&g.nodeType===Ri.text&&(T=g.textContent,Co([xn,mt,Xt],se=>{T=Ci(T,se," ")}),g.textContent!==T&&(Ti(e.removed,{element:g.cloneNode()}),g.textContent=T)),Pt(Ee.afterSanitizeElements,g,null),!1)},Ah=function(g,T,R){if(io[T]||gh&&(T==="id"||T==="name")&&(R in n||R in Qy))return!1;if(!(Ja&&!io[T]&&Oe(Ka,T))){if(!(dh&&Oe(ro,T))){if(!(Qt.attributeCheck instanceof Function&&Qt.attributeCheck(T,g))){if(!$e[T]||io[T]){if(!(Th(g)&&(me.tagNameCheck instanceof RegExp&&Oe(me.tagNameCheck,g)||me.tagNameCheck instanceof Function&&me.tagNameCheck(g))&&(me.attributeNameCheck instanceof RegExp&&Oe(me.attributeNameCheck,T)||me.attributeNameCheck instanceof Function&&me.attributeNameCheck(T,g))||T==="is"&&me.allowCustomizedBuiltInElements&&(me.tagNameCheck instanceof RegExp&&Oe(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R))))return!1}else if(!nl[T]){if(!Oe(ch,Ci(R,lh,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&g!=="script"&&iO(R,"data:")===0&&vh[g])){if(!(ph&&!Oe(Gy,Ci(R,lh,"")))){if(R)return!1}}}}}}}return!0},Th=function(g){return g!=="annotation-xml"&&Jl(g,Wy)},Ch=function(g){Pt(Ee.beforeSanitizeAttributes,g,null);const{attributes:T}=g;if(!T||ol(g))return;const R={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$e,forceKeepAttr:void 0};let se=T.length;for(;se--;){const De=T[se],{name:ve,namespaceURI:Fe,value:Rt}=De,wr=be(ve),al=Rt;let Ae=ve==="value"?al:sO(al);if(R.attrName=wr,R.attrValue=Ae,R.keepAttr=!0,R.forceKeepAttr=void 0,Pt(Ee.uponSanitizeAttribute,g,R),Ae=R.attrValue,mh&&(wr==="id"||wr==="name")&&($n(ve,g),Ae=qy+Ae),so&&Oe(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ae)){$n(ve,g);continue}if(wr==="attributename"&&Jl(Ae,"href")){$n(ve,g);continue}if(R.forceKeepAttr)continue;if(!R.keepAttr){$n(ve,g);continue}if(!fh&&Oe(/\/>/i,Ae)){$n(ve,g);continue}gr&&Co([xn,mt,Xt],Ph=>{Ae=Ci(Ae,Ph," ")});const Ih=be(g.nodeName);if(!Ah(Ih,wr,Ae)){$n(ve,g);continue}if(L&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!Fe)switch(v.getAttributeType(Ih,wr)){case"TrustedHTML":{Ae=L.createHTML(Ae);break}case"TrustedScriptURL":{Ae=L.createScriptURL(Ae);break}}if(Ae!==al)try{Fe?g.setAttributeNS(Fe,ve,Ae):g.setAttribute(ve,Ae),ol(g)?yt(g):lf(e.removed)}catch{$n(ve,g)}}Pt(Ee.afterSanitizeAttributes,g,null)},tb=function M(g){let T=null;const R=xh(g);for(Pt(Ee.beforeSanitizeShadowDOM,g,null);T=R.nextNode();)Pt(Ee.uponSanitizeShadowNode,T,null),$h(T),Ch(T),T.content instanceof s&&M(T.content);Pt(Ee.afterSanitizeShadowDOM,g,null)};return e.sanitize=function(M){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,R=null,se=null,De=null;if(rl=!M,rl&&(M="<!-->"),typeof M!="string"&&!Eh(M))if(typeof M.toString=="function"){if(M=M.toString(),typeof M!="string")throw Ii("dirty is not a string, aborting")}else throw Ii("toString is not a function");if(!e.isSupported)return M;if(Xa||sl(g),e.removed=[],typeof M=="string"&&(wi=!1),wi){if(M.nodeName){const Rt=be(M.nodeName);if(!_e[Rt]||bi[Rt])throw Ii("root node is forbidden and cannot be sanitized in-place")}}else if(M instanceof a)T=kh("<!---->"),R=T.ownerDocument.importNode(M,!0),R.nodeType===Ri.element&&R.nodeName==="BODY"||R.nodeName==="HTML"?T=R:T.appendChild(R);else{if(!mr&&!gr&&!En&&M.indexOf("<")===-1)return L&&ao?L.createHTML(M):M;if(T=kh(M),!T)return mr?null:ao?Z:""}T&&Qa&&yt(T.firstChild);const ve=xh(wi?M:T);for(;se=ve.nextNode();)$h(se),Ch(se),se.content instanceof s&&tb(se.content);if(wi)return M;if(mr){if(oo)for(De=ue.call(T.ownerDocument);T.firstChild;)De.appendChild(T.firstChild);else De=T;return($e.shadowroot||$e.shadowrootmode)&&(De=no.call(r,De,!0)),De}let Fe=En?T.outerHTML:T.innerHTML;return En&&_e["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&Oe(Ty,T.ownerDocument.doctype.name)&&(Fe="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
338
+ `+Fe),gr&&Co([xn,mt,Xt],Rt=>{Fe=Ci(Fe,Rt," ")}),L&&ao?L.createHTML(Fe):Fe},e.setConfig=function(){let M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};sl(M),Xa=!0},e.clearConfig=function(){br=null,Xa=!1},e.isValidAttribute=function(M,g,T){br||sl({});const R=be(M),se=be(g);return Ah(R,se,T)},e.addHook=function(M,g){typeof g=="function"&&Ti(Ee[M],g)},e.removeHook=function(M,g){if(g!==void 0){const T=nO(Ee[M],g);return T===-1?void 0:rO(Ee[M],T,1)[0]}return lf(Ee[M])},e.removeHooks=function(M){Ee[M]=[]},e.removeAllHooks=function(){Ee=ff()},e}var Iy=Cy();function Ju(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var fr=Ju();function Py(t){fr=t}var On={exec:()=>null};function W(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(Me.caret,"$1"),n=n.replace(i,o),r},getRegex:()=>new RegExp(n,e)};return r}var wO=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Me={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:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},_O=/^(?:[ \t]*(?:\n|$))+/,SO=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,kO=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,to=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,xO=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Xu=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Ry=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Dy=W(Ry).replace(/bull/g,Xu).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(),EO=W(Ry).replace(/bull/g,Xu).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(),Qu=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,$O=/^[^\n]+/,eh=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,AO=W(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",eh).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),TO=W(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Xu).getRegex(),Wa="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",th=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,CO=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",th).replace("tag",Wa).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Oy=W(Qu).replace("hr",to).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",Wa).getRegex(),IO=W(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Oy).getRegex(),nh={blockquote:IO,code:SO,def:AO,fences:kO,heading:xO,hr:to,html:CO,lheading:Dy,list:TO,newline:_O,paragraph:Oy,table:On,text:$O},gf=W("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",to).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",Wa).getRegex(),PO={...nh,lheading:EO,table:gf,paragraph:W(Qu).replace("hr",to).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",gf).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",Wa).getRegex()},RO={...nh,html:W(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",th).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:On,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:W(Qu).replace("hr",to).replace("heading",` *#{1,6} *[^
339
+ ]`).replace("lheading",Dy).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},DO=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,OO=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,zy=/^( {2,}|\\)\n(?!\s*$)/,zO=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,vi=/[\p{P}\p{S}]/u,qa=/[\s\p{P}\p{S}]/u,rh=/[^\s\p{P}\p{S}]/u,LO=W(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,qa).getRegex(),Ly=/(?!~)[\p{P}\p{S}]/u,MO=/(?!~)[\s\p{P}\p{S}]/u,NO=/(?:[^\s\p{P}\p{S}]|~)/u,UO=W(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",wO?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),My=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,FO=W(My,"u").replace(/punct/g,vi).getRegex(),ZO=W(My,"u").replace(/punct/g,Ly).getRegex(),Ny="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",HO=W(Ny,"gu").replace(/notPunctSpace/g,rh).replace(/punctSpace/g,qa).replace(/punct/g,vi).getRegex(),BO=W(Ny,"gu").replace(/notPunctSpace/g,NO).replace(/punctSpace/g,MO).replace(/punct/g,Ly).getRegex(),VO=W("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,rh).replace(/punctSpace/g,qa).replace(/punct/g,vi).getRegex(),jO=W(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,vi).getRegex(),GO="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",WO=W(GO,"gu").replace(/notPunctSpace/g,rh).replace(/punctSpace/g,qa).replace(/punct/g,vi).getRegex(),qO=W(/\\(punct)/,"gu").replace(/punct/g,vi).getRegex(),YO=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(),KO=W(th).replace("(?:-->|$)","-->").getRegex(),JO=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",KO).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ca=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,XO=W(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ca).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Uy=W(/^!?\[(label)\]\[(ref)\]/).replace("label",ca).replace("ref",eh).getRegex(),Fy=W(/^!?\[(ref)\](?:\[\])?/).replace("ref",eh).getRegex(),QO=W("reflink|nolink(?!\\()","g").replace("reflink",Uy).replace("nolink",Fy).getRegex(),mf=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ih={_backpedal:On,anyPunctuation:qO,autolink:YO,blockSkip:UO,br:zy,code:OO,del:On,delLDelim:On,delRDelim:On,emStrongLDelim:FO,emStrongRDelimAst:HO,emStrongRDelimUnd:VO,escape:DO,link:XO,nolink:Fy,punctuation:LO,reflink:Uy,reflinkSearch:QO,tag:JO,text:zO,url:On},ez={...ih,link:W(/^!?\[(label)\]\((.*?)\)/).replace("label",ca).getRegex(),reflink:W(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ca).getRegex()},Kc={...ih,emStrongRDelimAst:BO,emStrongLDelim:ZO,delLDelim:jO,delRDelim:WO,url:W(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",mf).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",mf).getRegex()},tz={...Kc,br:W(zy).replace("{2,}","*").getRegex(),text:W(Kc.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Po={normal:nh,gfm:PO,pedantic:RO},Di={normal:ih,gfm:Kc,breaks:tz,pedantic:ez},nz={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},vf=t=>nz[t];function St(t,e){if(e){if(Me.escapeTest.test(t))return t.replace(Me.escapeReplace,vf)}else if(Me.escapeTestNoEncode.test(t))return t.replace(Me.escapeReplaceNoEncode,vf);return t}function yf(t){try{t=encodeURI(t).replace(Me.percentDecode,"%")}catch{return null}return t}function bf(t,e){var s;let n=t.replace(Me.findPipe,(o,a,c)=>{let u=!1,d=a;for(;--d>=0&&c[d]==="\\";)u=!u;return u?"|":" |"}),r=n.split(Me.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(Me.slashPipe,"|");return r}function Oi(t,e,n){let r=t.length;if(r===0)return"";let i=0;for(;i<r&&t.charAt(r-i-1)===e;)i++;return t.slice(0,r-i)}function rz(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function iz(t,e=0){let n=e,r="";for(let i of t)if(i===" "){let s=4-n%4;r+=" ".repeat(s),n+=s}else r+=i,n++;return r}function wf(t,e,n,r,i){let s=e.href,o=e.title||null,a=t[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let c={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:s,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,c}function sz(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
340
+ `).map(s=>{let o=s.match(n.other.beginningSpace);if(o===null)return s;let[a]=o;return a.length>=i.length?s.slice(i.length):s}).join(`
341
+ `)}var ua=class{constructor(t){b(this,"options");b(this,"rules");b(this,"lexer");this.options=t||fr}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Oi(n,`
342
+ `)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=sz(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=Oi(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Oi(e[0],`
343
+ `)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=Oi(e[0],`
344
+ `).split(`
345
+ `),r="",i="",s=[];for(;n.length>0;){let o=!1,a=[],c;for(c=0;c<n.length;c++)if(this.rules.other.blockquoteStart.test(n[c]))a.push(n[c]),o=!0;else if(!o)a.push(n[c]);else break;n=n.slice(c);let u=a.join(`
346
+ `),d=u.replace(this.rules.other.blockquoteSetextReplace,`
347
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
348
+ ${u}`:u,i=i?`${i}
349
+ ${d}`:d;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,s,!0),this.lexer.state.top=p,n.length===0)break;let y=s.at(-1);if((y==null?void 0:y.type)==="code")break;if((y==null?void 0:y.type)==="blockquote"){let v=y,$=v.raw+`
350
+ `+n.join(`
351
+ `),k=this.blockquote($);s[s.length-1]=k,r=r.substring(0,r.length-v.raw.length)+k.raw,i=i.substring(0,i.length-v.text.length)+k.text;break}else if((y==null?void 0:y.type)==="list"){let v=y,$=v.raw+`
352
+ `+n.join(`
353
+ `),k=this.list($);s[s.length-1]=k,r=r.substring(0,r.length-y.raw.length)+k.raw,i=i.substring(0,i.length-v.raw.length)+k.raw,n=$.substring(s.at(-1).raw.length).split(`
354
+ `);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(t){var n,r;let e=this.rules.block.list.exec(t);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(;t;){let d=!1,p="",y="";if(!(e=a.exec(t))||this.rules.block.hr.test(t))break;p=e[0],t=t.substring(p.length);let v=iz(e[2].split(`
355
+ `,1)[0],e[1].length),$=t.split(`
356
+ `,1)[0],k=!v.trim(),I=0;if(this.options.pedantic?(I=2,y=v.trimStart()):k?I=e[1].length+1:(I=v.search(this.rules.other.nonSpaceChar),I=I>4?1:I,y=v.slice(I),I+=e[1].length),k&&this.rules.other.blankLine.test($)&&(p+=$+`
357
+ `,t=t.substring($.length+1),d=!0),!d){let B=this.rules.other.nextBulletRegex(I),P=this.rules.other.hrRegex(I),K=this.rules.other.fencesBeginRegex(I),L=this.rules.other.headingBeginRegex(I),Z=this.rules.other.htmlBeginRegex(I),N=this.rules.other.blockquoteBeginRegex(I);for(;t;){let ce=t.split(`
358
+ `,1)[0],ue;if($=ce,this.options.pedantic?($=$.replace(this.rules.other.listReplaceNesting," "),ue=$):ue=$.replace(this.rules.other.tabCharGlobal," "),K.test($)||L.test($)||Z.test($)||N.test($)||B.test($)||P.test($))break;if(ue.search(this.rules.other.nonSpaceChar)>=I||!$.trim())y+=`
359
+ `+ue.slice(I);else{if(k||v.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||K.test(v)||L.test(v)||P.test(v))break;y+=`
360
+ `+$}k=!$.trim(),p+=ce+`
361
+ `,t=t.substring(ce.length+1),v=ue.slice(I)}}o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(c=!0)),o.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(y),loose:!1,text:y,tokens:[]}),o.raw+=p}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,""),((n=d.tokens[0])==null?void 0:n.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 y=this.lexer.inlineQueue.length-1;y>=0;y--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[y].src)){this.lexer.inlineQueue[y].src=this.lexer.inlineQueue[y].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(d.raw);if(p){let y={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};d.checked=y.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=y.raw+d.tokens[0].raw,d.tokens[0].text=y.raw+d.tokens[0].text,d.tokens[0].tokens.unshift(y)):d.tokens.unshift({type:"paragraph",raw:y.raw,text:y.raw,tokens:[y]}):d.tokens.unshift(y)}}if(!o.loose){let p=d.tokens.filter(v=>v.type==="space"),y=p.length>0&&p.some(v=>this.rules.other.anyLine.test(v.raw));o.loose=y}}if(o.loose)for(let d of o.items){d.loose=!0;for(let p of d.tokens)p.type==="text"&&(p.type="paragraph")}return o}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=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:n,raw:e[0],href:r,title:i}}}table(t){var o;let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=bf(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(`
362
+ `):[],s={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.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<n.length;a++)s.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:s.align[a]});for(let a of i)s.rows.push(bf(a,s.header.length).map((c,u)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:s.align[u]})));return s}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
363
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);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(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let s=Oi(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{let s=rz(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(n)?r=r.slice(1):r=r.slice(1,-1)),wf(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(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){let s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return wf(n,i,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){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*t.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,p=t.slice(0,i+r.index+d+o);if(Math.min(i,o)%2){let v=p.slice(1,-1);return{type:"em",raw:p,text:v,tokens:this.lexer.inlineTokens(v)}}let y=p.slice(2,-2);return{type:"strong",raw:p,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let r=this.rules.inline.delLDelim.exec(t);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,s,o,a=i,c=this.rules.inline.delRDelim;for(c.lastIndex=0,e=e.slice(-1*t.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=t.slice(0,i+r.index+u+o),p=d.slice(i,-i);return{type:"del",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){var n;let e;if(e=this.rules.inline.url.exec(t)){let r,i;if(e[2]==="@")r=e[0],i="mailto:"+r;else{let s;do s=e[0],e[0]=((n=this.rules.inline._backpedal.exec(e[0]))==null?void 0:n[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(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},dt=class Jc{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||fr,this.options.tokenizer=this.options.tokenizer||new ua,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 n={other:Me,block:Po.normal,inline:Di.normal};this.options.pedantic?(n.block=Po.pedantic,n.inline=Di.pedantic):this.options.gfm&&(n.block=Po.gfm,this.options.breaks?n.inline=Di.breaks:n.inline=Di.gfm),this.tokenizer.rules=n}static get rules(){return{block:Po,inline:Di}}static lex(e,n){return new Jc(n).lex(e)}static lexInline(e,n){return new Jc(n).inlineTokens(e)}lex(e){e=e.replace(Me.carriageReturn,`
364
+ `),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){var i,s,o;for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Me.tabCharGlobal," ").replace(Me.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,n))?(e=e.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.space(e)){e=e.substring(a.raw.length);let u=n.at(-1);a.raw.length===1&&u!==void 0?u.raw+=`
365
+ `:n.push(a);continue}if(a=this.tokenizer.code(e)){e=e.substring(a.raw.length);let u=n.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
366
+ `)?"":`
367
+ `)+a.raw,u.text+=`
368
+ `+a.text,this.inlineQueue.at(-1).src=u.text):n.push(a);continue}if(a=this.tokenizer.fences(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.heading(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.hr(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.blockquote(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.list(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.html(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.def(e)){e=e.substring(a.raw.length);let u=n.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
369
+ `)?"":`
370
+ `)+a.raw,u.text+=`
371
+ `+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},n.push(a));continue}if(a=this.tokenizer.table(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.lheading(e)){e=e.substring(a.raw.length),n.push(a);continue}let c=e;if((o=this.options.extensions)!=null&&o.startBlock){let u=1/0,d=e.slice(1),p;this.options.extensions.startBlock.forEach(y=>{p=y.call({lexer:this},d),typeof p=="number"&&p>=0&&(u=Math.min(u,p))}),u<1/0&&u>=0&&(c=e.substring(0,u+1))}if(this.state.top&&(a=this.tokenizer.paragraph(c))){let u=n.at(-1);r&&(u==null?void 0:u.type)==="paragraph"?(u.raw+=(u.raw.endsWith(`
372
+ `)?"":`
373
+ `)+a.raw,u.text+=`
374
+ `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):n.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=n.at(-1);(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
375
+ `)?"":`
376
+ `)+a.raw,u.text+=`
377
+ `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):n.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,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){var c,u,d,p,y;this.tokenizer.lexer=this;let r=e,i=null;if(this.tokens.links){let v=Object.keys(this.tokens.links);if(v.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)v.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 v;if((p=(d=this.options.extensions)==null?void 0:d.inline)!=null&&p.some(k=>(v=k.call({lexer:this},e,n))?(e=e.substring(v.raw.length),n.push(v),!0):!1))continue;if(v=this.tokenizer.escape(e)){e=e.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.tag(e)){e=e.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.link(e)){e=e.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(v.raw.length);let k=n.at(-1);v.type==="text"&&(k==null?void 0:k.type)==="text"?(k.raw+=v.raw,k.text+=v.text):n.push(v);continue}if(v=this.tokenizer.emStrong(e,r,a)){e=e.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.codespan(e)){e=e.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.br(e)){e=e.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.del(e,r,a)){e=e.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.autolink(e)){e=e.substring(v.raw.length),n.push(v);continue}if(!this.state.inLink&&(v=this.tokenizer.url(e))){e=e.substring(v.raw.length),n.push(v);continue}let $=e;if((y=this.options.extensions)!=null&&y.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&&($=e.substring(0,k+1))}if(v=this.tokenizer.inlineText($)){e=e.substring(v.raw.length),v.raw.slice(-1)!=="_"&&(a=v.raw.slice(-1)),o=!0;let k=n.at(-1);(k==null?void 0:k.type)==="text"?(k.raw+=v.raw,k.text+=v.text):n.push(v);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 n}},ha=class{constructor(t){b(this,"options");b(this,"parser");this.options=t||fr}space(t){return""}code({text:t,lang:e,escaped:n}){var s;let r=(s=(e||"").match(Me.notSpaceStart))==null?void 0:s[0],i=t.replace(Me.endingNewline,"")+`
378
+ `;return r?'<pre><code class="language-'+St(r)+'">'+(n?i:St(i,!0))+`</code></pre>
379
+ `:"<pre><code>"+(n?i:St(i,!0))+`</code></pre>
380
+ `}blockquote({tokens:t}){return`<blockquote>
381
+ ${this.parser.parse(t)}</blockquote>
382
+ `}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
383
+ `}hr(t){return`<hr>
384
+ `}list(t){let e=t.ordered,n=t.start,r="";for(let o=0;o<t.items.length;o++){let a=t.items[o];r+=this.listitem(a)}let i=e?"ol":"ul",s=e&&n!==1?' start="'+n+'"':"";return"<"+i+s+`>
385
+ `+r+"</"+i+`>
386
+ `}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
387
+ `}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
388
+ `}table(t){let e="",n="";for(let i=0;i<t.header.length;i++)n+=this.tablecell(t.header[i]);e+=this.tablerow({text:n});let r="";for(let i=0;i<t.rows.length;i++){let s=t.rows[i];n="";for(let o=0;o<s.length;o++)n+=this.tablecell(s[o]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
389
+ <thead>
390
+ `+e+`</thead>
391
+ `+r+`</table>
392
+ `}tablerow({text:t}){return`<tr>
393
+ ${t}</tr>
394
+ `}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
395
+ `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${St(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),i=yf(t);if(i===null)return r;t=i;let s='<a href="'+t+'"';return e&&(s+=' title="'+St(e)+'"'),s+=">"+r+"</a>",s}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=yf(t);if(i===null)return St(n);t=i;let s=`<img src="${t}" alt="${St(n)}"`;return e&&(s+=` title="${St(e)}"`),s+=">",s}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:St(t.text)}},sh=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},pt=class Xc{constructor(e){b(this,"options");b(this,"renderer");b(this,"textRenderer");this.options=e||fr,this.options.renderer=this.options.renderer||new ha,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new sh}static parse(e,n){return new Xc(n).parse(e)}static parseInline(e,n){return new Xc(n).parseInline(e)}parse(e){var r,i;this.renderer.parser=this;let n="";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)){n+=u||"";continue}}let a=o;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=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 n}parseInline(e,n=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+=n.text(c);break}case"html":{r+=n.html(c);break}case"link":{r+=n.link(c);break}case"image":{r+=n.image(c);break}case"checkbox":{r+=n.checkbox(c);break}case"strong":{r+=n.strong(c);break}case"em":{r+=n.em(c);break}case"codespan":{r+=n.codespan(c);break}case"br":{r+=n.br(c);break}case"del":{r+=n.del(c);break}case"text":{r+=n.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}},Ro,Vi=(Ro=class{constructor(t){b(this,"options");b(this,"block");this.options=t||fr}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?dt.lex:dt.lexInline}provideParser(){return this.block?pt.parse:pt.parseInline}},b(Ro,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),b(Ro,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Ro),oz=class{constructor(...t){b(this,"defaults",Ju());b(this,"options",this.setOptions);b(this,"parse",this.parseMarkdown(!0));b(this,"parseInline",this.parseMarkdown(!1));b(this,"Parser",pt);b(this,"Renderer",ha);b(this,"TextRenderer",sh);b(this,"Lexer",dt);b(this,"Tokenizer",ua);b(this,"Hooks",Vi);this.use(...t)}walkTokens(t,e){var r,i;let n=[];for(let s of t)switch(n=n.concat(e.call(this,s)),s.type){case"table":{let o=s;for(let a of o.header)n=n.concat(this.walkTokens(a.tokens,e));for(let a of o.rows)for(let c of a)n=n.concat(this.walkTokens(c.tokens,e));break}case"list":{let o=s;n=n.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);n=n.concat(this.walkTokens(c,e))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.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),n.renderer){let i=this.defaults.renderer||new ha(this.defaults);for(let s in n.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=n.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(n.tokenizer){let i=this.defaults.tokenizer||new ua(this.defaults);for(let s in n.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=n.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(n.hooks){let i=this.defaults.hooks||new Vi;for(let s in n.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=n.hooks[o],c=i[o];Vi.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&Vi.passThroughHooksRespectAsync.has(s))return(async()=>{let p=await a.call(i,u);return c.call(i,p)})();let d=a.call(i,u);return c.call(i,d)}:i[o]=(...u)=>{if(this.defaults.async)return(async()=>{let p=await a.apply(i,u);return p===!1&&(p=await c.apply(i,u)),p})();let d=a.apply(i,u);return d===!1&&(d=c.apply(i,u)),d}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,s=n.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(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return dt.lex(t,e??this.defaults)}parser(t,e){return pt.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},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=t),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(e):e,a=await(i.hooks?await i.hooks.provideLexer():t?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():t?pt.parse:pt.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():t?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():t?pt.parse:pt.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(t,e){return n=>{if(n.message+=`
396
+ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+St(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},cr=new oz;function J(t,e){return cr.parse(t,e)}J.options=J.setOptions=function(t){return cr.setOptions(t),J.defaults=cr.defaults,Py(J.defaults),J};J.getDefaults=Ju;J.defaults=fr;J.use=function(...t){return cr.use(...t),J.defaults=cr.defaults,Py(J.defaults),J};J.walkTokens=function(t,e){return cr.walkTokens(t,e)};J.parseInline=cr.parseInline;J.Parser=pt;J.parser=pt.parse;J.Renderer=ha;J.TextRenderer=sh;J.Lexer=dt;J.lexer=dt.lex;J.Tokenizer=ua;J.Hooks=Vi;J.parse=J;J.options;J.setOptions;J.use;J.walkTokens;J.parseInline;pt.parse;dt.lex;Iy.addHook("afterSanitizeAttributes",t=>{t.tagName==="A"&&(t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer"))});function az(t){const e=J.parse(t,{async:!1});return Iy.sanitize(e,{USE_PROFILES:{html:!0}})}const lz=8,_f=new WeakMap;function cz(t){const e=_f.get(t);if(e&&e.text===t.text)return e.html;const n=az(t.text);return _f.set(t,{text:t.text,html:n}),n}function Sf(t){for(let e=t.length-1;e>=0;e-=1){const n=t[e];if(n&&n.kind==="user")return n.id}return null}var Vt,rr,Ca,Ia,Ms,Qc;class Zy extends ns{constructor(){super(...arguments);_(this,Ms);b(this,"messages",[]);_(this,Vt,!0);_(this,rr,null);_(this,Ca,()=>{const n=l(this,rr);if(!n)return;const i=n.scrollHeight-n.clientHeight-n.scrollTop<=lz;i!==l(this,Vt)&&(x(this,Vt,i),this.toggleAttribute("data-pinned",i))});_(this,Ia,()=>{x(this,Vt,!0),this.toggleAttribute("data-pinned",!0),m(this,Ms,Qc).call(this,!0)})}changed(n){let r=!1;if(n.has("messages")){const i=n.get("messages")??[],s=Sf(this.messages);r=s!==null&&s!==Sf(i),r&&x(this,Vt,!0)}Re(this.template(),this),l(this,rr)||x(this,rr,this.querySelector(".history-scroll")),this.toggleAttribute("data-pinned",l(this,Vt)),m(this,Ms,Qc).call(this,r)}template(){const n=this.messages.filter(r=>r.kind==="user"||r.kind==="assistant");return F`
397
+ <div class="history-scroll" @scroll=${l(this,Ca)}>
398
+ ${n.map(r=>{const i=r.kind==="assistant"?_D(cz(r)):r.text;return F`<div
399
+ class="message message-${r.kind}"
400
+ data-message-id=${r.id}
401
+ >${i}</div>`})}
402
+ </div>
403
+ <button
404
+ type="button"
405
+ class="history-jump"
406
+ aria-label="Jump to latest message"
407
+ @click=${l(this,Ia)}
408
+ >
409
+ ${Fv({size:16})}
410
+ </button>
411
+ `}}Vt=new WeakMap,rr=new WeakMap,Ca=new WeakMap,Ia=new WeakMap,Ms=new WeakSet,Qc=function(n){requestAnimationFrame(()=>{const r=l(this,rr);r&&(!l(this,Vt)&&!n||(r.scrollTop=r.scrollHeight-r.clientHeight))})},b(Zy,"properties",["messages"]);customElements.define("message-history",Zy);var Ns,Us,Xr,Fs,bn,tu,nu,Zs,Hs;class eu extends ns{constructor(){super(...arguments);_(this,bn);b(this,"placeholder","What do you want to do?");b(this,"open",!1);b(this,"messages",[]);_(this,Ns,Ge.resolve("ACPClientManager"));_(this,Us,Ge.resolve("ShortcutService"));_(this,Xr,null);b(this,"handleTriggerActivate",()=>{this.open=!0});b(this,"handleKeydown",n=>{if(n.key!=="Enter"||n.shiftKey)return;const r=n.currentTarget,i=r.value.trim();if(n.preventDefault(),!i)return;r.value="";const s=l(this,Ns).getActiveClient();s&&s.sendMessage({text:i}).catch(o=>{console.error("ACPClient.sendMessage() failed",o)})});_(this,Fs,n=>{if(n.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,Zs,n=>{n.target instanceof Node&&(this.contains(n.target)||(this.open=!1))});_(this,Hs,n=>{n.key==="Escape"&&(this.open=!1)})}connected(){this.setAttribute("material","paper"),this.setAttribute("tone","dark"),this.setAttribute("level","overlay");const n=new DisposableStack;x(this,Xr,n);const r=X2(l(this,Ns),i=>{this.messages=i});n.defer(()=>r.dispose()),l(this,Us).addEventListener("shortcut-triggered",l(this,Fs)),n.defer(()=>l(this,Us).removeEventListener("shortcut-triggered",l(this,Fs))),this.open&&m(this,bn,tu).call(this)}disconnected(){var n;(n=l(this,Xr))==null||n.dispose(),x(this,Xr,null),m(this,bn,nu).call(this)}changed(n){if(Re(this.template(),this),n.has("open"))if(this.open){m(this,bn,tu).call(this);const r=this.querySelector("textarea");r==null||r.focus()}else m(this,bn,nu).call(this)}template(){return this.open?F`
412
+ <message-history .messages=${this.messages}></message-history>
413
+ <textarea
414
+ class="input"
415
+ rows="1"
416
+ @keydown=${this.handleKeydown}
417
+ ></textarea>
418
+ `:F`
419
+ <div
420
+ class="trigger"
421
+ tabindex="0"
422
+ role="button"
423
+ @click=${this.handleTriggerActivate}
424
+ @focus=${this.handleTriggerActivate}
425
+ >
426
+ <span class="label">${this.placeholder}</span>
427
+ <span class="kbd" aria-hidden="true">⌘K</span>
428
+ </div>
429
+ `}}Ns=new WeakMap,Us=new WeakMap,Xr=new WeakMap,Fs=new WeakMap,bn=new WeakSet,tu=function(){document.addEventListener("mousedown",l(this,Zs)),document.addEventListener("keydown",l(this,Hs))},nu=function(){document.removeEventListener("mousedown",l(this,Zs)),document.removeEventListener("keydown",l(this,Hs))},Zs=new WeakMap,Hs=new WeakMap,b(eu,"properties",["placeholder","open","messages"]),b(eu,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",eu);class Hy extends Event{constructor(n){super("auth-submit",{bubbles:!0,composed:!0});b(this,"token");this.token=n}}class uz extends HTMLElement{constructor(){super(...arguments);b(this,"_invalid",!1);b(this,"_tokenValue","")}set invalid(n){this._invalid=n,this.render()}get invalid(){return this._invalid}set tokenValue(n){this._tokenValue=n,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(n){const r=n.currentTarget;this._tokenValue=r.value}handleSubmit(n){n.preventDefault();const r=this._tokenValue.trim();r&&this.dispatchEvent(new Hy(r))}render(){Re(F`
430
+ <modal-overlay open>
431
+ <section class="auth-modal">
432
+ <form class="auth-form" @submit=${n=>this.handleSubmit(n)}>
433
+ <h2 class="auth-modal-title">Enter access token</h2>
434
+ <p class="auth-modal-copy">This Television server requires a token.</p>
435
+ <label class="settings-field">
436
+ <span>Token</span>
437
+ <input
438
+ class=${this.invalid?"auth-token-input-invalid":""}
439
+ type="password"
440
+ name="token"
441
+ .value=${this.tokenValue}
442
+ @input=${n=>this.handleInput(n)}
443
+ required
444
+ />
445
+ </label>
446
+ <button type="submit" class="settings-submit-button">Connect</button>
447
+ </form>
448
+ </section>
449
+ </modal-overlay>
450
+ `,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",uz);class hz extends HTMLElement{constructor(){super(...arguments);b(this,"runtimeServerURL",kv());b(this,"electronMode",xv());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",n=>{var i;const r=n instanceof Hy?n.token:n instanceof CustomEvent&&typeof((i=n.detail)==null?void 0:i.token)=="string"?n.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,Tc());return}if(this.serverManager.activeServer)return;const n=new _c({url:this.runtimeServerURL,name:"Server",token:Tc()});this.serverManager.add(n),this.serverManager.setActive(n);try{await n.connect(),this.connectError=null}catch(r){this.connectError=r instanceof Error&&!(r instanceof wc)?r.message:null}this.render()}async handleAuthSubmit(n){const r=this.serverManager.activeServer;if(r){this.connectError=null,r.token=n,this.updateTokenQueryParam(n);try{await r.connect()}catch(i){i instanceof wc||(this.connectError=i instanceof Error?i.message:String(i))}this.render()}}updateTokenQueryParam(n){const r=new URL(window.location.href);r.searchParams.set("token",n),window.history.replaceState({},"",`${r.pathname}${r.search}${r.hash}`)}render(){const n=this.serverManager.activeServer,r=(n==null?void 0:n.status)??null;if(r==="connecting"){Re(F`
451
+ <main class="auth-gate"><p>Connecting...</p></main>
452
+ `,this);return}if(r==="disconnected"){const o=n;if(!o)return;Re(F`
453
+ <main class="auth-gate">
454
+ <auth-modal
455
+ .invalid=${!!o.token}
456
+ .tokenValue=${o.token??""}
457
+ ></auth-modal>
458
+ </main>
459
+ `,this);return}const s=this.screenManager.activeScreen?F`<screen-view></screen-view>`:F`<home-screen></home-screen>`;Re(F`
460
+ <main>
461
+ ${this.connectError?F`<p data-testid="auth-error">${this.connectError}</p>`:F`
462
+ ${s}
463
+ ${r==="connected"?F`
464
+ <div class="chrome">
465
+ <div class="top-row electron-draggable">
466
+ <screen-breadcrumb></screen-breadcrumb>
467
+ <screen-create-button></screen-create-button>
468
+ </div>
469
+ <command-panel></command-panel>
470
+ </div>
471
+ `:null}
472
+ `}
473
+ </main>
474
+ `,this)}}customElements.get("television-app")||customElements.define("television-app",hz);const oh=xv(),Ya=kv(),By=new vE(oh?"television-electron":"television-browser",mE(Ya)),Vy=new cC({localStore:By,localServerURL:Ya}),jy=new pE({localStore:By,serverManager:Vy}),dz=new VR({serverURL:Ya,token:Tc()??"",screenManager:jy}),pz=new GR;Ge.register("ServerManager",()=>Vy);Ge.register("ScreenManager",()=>jy);Ge.register("ACPClientManager",()=>dz);Ge.register("ShortcutService",()=>pz);const ah=document.createElement("television-app");ah.runtimeServerURL=Ya;ah.electronMode=oh;oh&&document.body.classList.add("electron");document.body.appendChild(ah);