@telepath-computer/television 0.1.51 → 0.1.53

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.
@@ -1,480 +0,0 @@
1
- var ub=Object.defineProperty;var Zh=n=>{throw TypeError(n)};var hb=(n,e,t)=>e in n?ub(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var b=(n,e,t)=>hb(n,typeof e!="symbol"?e+"":e,t),gl=(n,e,t)=>e.has(n)||Zh("Cannot "+t);var l=(n,e,t)=>(gl(n,e,"read from private field"),t?t.call(n):e.get(n)),S=(n,e,t)=>e.has(n)?Zh("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),k=(n,e,t,r)=>(gl(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),g=(n,e,t)=>(gl(n,e,"access private method"),t);var Hh=(n,e,t,r)=>({set _(i){k(n,e,i,t)},get _(){return l(n,e,r)}});(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function t(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=t(i);fetch(i.href,s)}})();var Rn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function db(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),t}var Bh=Object.prototype.toString,Df=function(e){var t=Bh.call(e),r=t==="[object Arguments]";return r||(r=t!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Bh.call(e.callee)==="[object Function]"),r},ml,jh;function pb(){if(jh)return ml;jh=1;var n;if(!Object.keys){var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,r=Df,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}};n=function(v){var $=v!==null&&typeof v=="object",E=t.call(v)==="[object Function]",I=r(v),Z=$&&t.call(v)==="[object String]",P=[];if(!$&&!E&&!I)throw new TypeError("Object.keys called on a non-object");var G=o&&E;if(Z&&v.length>0&&!e.call(v,0))for(var O=0;O<v.length;++O)P.push(String(O));if(I&&v.length>0)for(var H=0;H<v.length;++H)P.push(String(H));else for(var N in v)!(G&&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 ml=n,ml}var fb=Array.prototype.slice,gb=Df,Gh=Object.keys,Uo=Gh?function(e){return Gh(e)}:pb(),Vh=Object.keys;Uo.shim=function(){if(Object.keys){var e=function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2);e||(Object.keys=function(r){return gb(r)?Vh(fb.call(r)):Vh(r)})}else Object.keys=Uo;return Object.keys||Uo};var mb=Uo,Fo=Object.defineProperty||!1;if(Fo)try{Fo({},"a",{value:1})}catch{Fo=!1}var Ys=Fo,Kt=SyntaxError,W=TypeError,vb=Object.getOwnPropertyDescriptor,Zo=vb;if(Zo)try{Zo([],"length")}catch{Zo=null}var di=Zo,Wh=Ys,yb=Kt,xr=W,qh=di,Of=function(e,t,r){if(!e||typeof e!="object"&&typeof e!="function")throw new xr("`obj` must be an object or a function`");if(typeof t!="string"&&typeof t!="symbol")throw new xr("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new xr("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new xr("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new xr("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new xr("`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=!!qh&&qh(e,t);if(Wh)Wh(e,t,{configurable:o===null&&c?c.configurable:!o,enumerable:i===null&&c?c.enumerable:!i,value:r,writable:s===null&&c?c.writable:!s});else if(a||!i&&!s&&!o)e[t]=r;else throw new yb("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},uc=Ys,zf=function(){return!!uc};zf.hasArrayLengthDefineBug=function(){if(!uc)return null;try{return uc([],"length",{value:1}).length!==1}catch{return!0}};var Na=zf,bb=mb,wb=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Sb=Object.prototype.toString,_b=Array.prototype.concat,Yh=Of,kb=function(n){return typeof n=="function"&&Sb.call(n)==="[object Function]"},Lf=Na(),Eb=function(n,e,t,r){if(e in n){if(r===!0){if(n[e]===t)return}else if(!kb(r)||!r())return}Lf?Yh(n,e,t,!0):Yh(n,e,t)},Mf=function(n,e){var t=arguments.length>2?arguments[2]:{},r=bb(e);wb&&(r=_b.call(r,Object.getOwnPropertySymbols(e)));for(var i=0;i<r.length;i+=1)Eb(n,r[i],e[r[i]],t[r[i]])};Mf.supportsDescriptors=!!Lf;var gr=Mf,Ho={exports:{}};typeof self<"u"?Ho.exports=self:typeof window<"u"?Ho.exports=window:Ho.exports=Function("return this")();var Nf=Ho.exports,xb=Nf,Uf=function(){return typeof Rn!="object"||!Rn||Rn.Math!==Math||Rn.Array!==Array?xb:Rn},Ab=gr,$b=di,Tb=Uf,Cb=function(){var e=Tb();if(Ab.supportsDescriptors){var t=$b(e,"globalThis");(!t||t.configurable&&(t.enumerable||!t.writable||globalThis!==e))&&Object.defineProperty(e,"globalThis",{configurable:!0,enumerable:!1,value:e,writable:!0})}else(typeof globalThis!="object"||globalThis!==e)&&(e.globalThis=e);return e},Ib=gr,Pb=Nf,Ff=Uf,Rb=Cb,Db=Ff(),Zf=function(){return Db};Ib(Zf,{getPolyfill:Ff,implementation:Pb,shim:Rb});var du=Zf,Jt=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},pu=Object,Hf=Error,Ob=EvalError,zb=RangeError,fu=ReferenceError,Lb=URIError,Mb=Math.abs,Nb=Math.floor,Ub=Math.max,Fb=Math.min,Zb=Math.pow,Hb=Math.round,gu=Number.isNaN||function(e){return e!==e},Bb=gu,jb=function(e){return Bb(e)||e===0?e:e<0?-1:1},pi=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},t=Symbol("test"),r=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var i=42;e[t]=i;for(var s in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,t);if(a.value!==i||a.enumerable!==!0)return!1}return!0},Kh=typeof Symbol<"u"&&Symbol,Gb=pi,mu=function(){return typeof Kh!="function"||typeof Symbol!="function"||typeof Kh("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Gb()},vl,Jh;function Bf(){return Jh||(Jh=1,vl=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),vl}var yl,Xh;function jf(){if(Xh)return yl;Xh=1;var n=pu;return yl=n.getPrototypeOf||null,yl}var Vb="Function.prototype.bind called on incompatible ",Wb=Object.prototype.toString,qb=Math.max,Yb="[object Function]",Qh=function(e,t){for(var r=[],i=0;i<e.length;i+=1)r[i]=e[i];for(var s=0;s<t.length;s+=1)r[s+e.length]=t[s];return r},Kb=function(e,t){for(var r=[],i=t,s=0;i<e.length;i+=1,s+=1)r[s]=e[i];return r},Jb=function(n,e){for(var t="",r=0;r<n.length;r+=1)t+=n[r],r+1<n.length&&(t+=e);return t},Xb=function(e){var t=this;if(typeof t!="function"||Wb.apply(t)!==Yb)throw new TypeError(Vb+t);for(var r=Kb(arguments,1),i,s=function(){if(this instanceof i){var d=t.apply(this,Qh(r,arguments));return Object(d)===d?d:this}return t.apply(e,Qh(r,arguments))},o=qb(0,t.length-r.length),a=[],c=0;c<o;c++)a[c]="$"+c;if(i=Function("binder","return function ("+Jb(a,",")+"){ return binder.apply(this,arguments); }")(s),t.prototype){var u=function(){};u.prototype=t.prototype,i.prototype=new u,u.prototype=null}return i},Qb=Xb,Ks=Function.prototype.bind||Qb,vu=Function.prototype.call,yu=Function.prototype.apply,ew=typeof Reflect<"u"&&Reflect&&Reflect.apply,tw=Ks,nw=yu,rw=vu,iw=ew,Gf=iw||tw.call(rw,nw),sw=Ks,ow=W,aw=vu,lw=Gf,Ua=function(e){if(e.length<1||typeof e[0]!="function")throw new ow("a function is required");return lw(sw,aw,e)},bl,ed;function cw(){if(ed)return bl;ed=1;var n=Ua,e=di,t;try{t=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var r=!!t&&e&&e(Object.prototype,"__proto__"),i=Object,s=i.getPrototypeOf;return bl=r&&typeof r.get=="function"?n([r.get]):typeof s=="function"?function(a){return s(a==null?a:i(a))}:!1,bl}var wl,td;function Vf(){if(td)return wl;td=1;var n=Bf(),e=jf(),t=cw();return wl=n?function(i){return n(i)}:e?function(i){if(!i||typeof i!="object"&&typeof i!="function")throw new TypeError("getProto: not an object");return e(i)}:t?function(i){return t(i)}:null,wl}var uw=Function.prototype.call,hw=Object.prototype.hasOwnProperty,dw=Ks,Xt=dw.call(uw,hw),V,pw=pu,fw=Hf,gw=Ob,mw=zb,vw=fu,oi=Kt,Fr=W,yw=Lb,bw=Mb,ww=Nb,Sw=Ub,_w=Fb,kw=Zb,Ew=Hb,xw=jb,Wf=Function,Sl=function(n){try{return Wf('"use strict"; return ('+n+").constructor;")()}catch{}},rs=di,Aw=Ys,_l=function(){throw new Fr},$w=rs?function(){try{return arguments.callee,_l}catch{try{return rs(arguments,"callee").get}catch{return _l}}}():_l,Ar=mu(),_e=Vf(),Tw=jf(),Cw=Bf(),qf=yu,Js=vu,Cr={},Iw=typeof Uint8Array>"u"||!_e?V:_e(Uint8Array),lr={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?V:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?V:ArrayBuffer,"%ArrayIteratorPrototype%":Ar&&_e?_e([][Symbol.iterator]()):V,"%AsyncFromSyncIteratorPrototype%":V,"%AsyncFunction%":Cr,"%AsyncGenerator%":Cr,"%AsyncGeneratorFunction%":Cr,"%AsyncIteratorPrototype%":Cr,"%Atomics%":typeof Atomics>"u"?V:Atomics,"%BigInt%":typeof BigInt>"u"?V:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?V:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?V:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?V:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":fw,"%eval%":eval,"%EvalError%":gw,"%Float16Array%":typeof Float16Array>"u"?V:Float16Array,"%Float32Array%":typeof Float32Array>"u"?V:Float32Array,"%Float64Array%":typeof Float64Array>"u"?V:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?V:FinalizationRegistry,"%Function%":Wf,"%GeneratorFunction%":Cr,"%Int8Array%":typeof Int8Array>"u"?V:Int8Array,"%Int16Array%":typeof Int16Array>"u"?V:Int16Array,"%Int32Array%":typeof Int32Array>"u"?V:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Ar&&_e?_e(_e([][Symbol.iterator]())):V,"%JSON%":typeof JSON=="object"?JSON:V,"%Map%":typeof Map>"u"?V:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Ar||!_e?V:_e(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":pw,"%Object.getOwnPropertyDescriptor%":rs,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?V:Promise,"%Proxy%":typeof Proxy>"u"?V:Proxy,"%RangeError%":mw,"%ReferenceError%":vw,"%Reflect%":typeof Reflect>"u"?V:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?V:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Ar||!_e?V:_e(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?V:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Ar&&_e?_e(""[Symbol.iterator]()):V,"%Symbol%":Ar?Symbol:V,"%SyntaxError%":oi,"%ThrowTypeError%":$w,"%TypedArray%":Iw,"%TypeError%":Fr,"%Uint8Array%":typeof Uint8Array>"u"?V:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?V:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?V:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?V:Uint32Array,"%URIError%":yw,"%WeakMap%":typeof WeakMap>"u"?V:WeakMap,"%WeakRef%":typeof WeakRef>"u"?V:WeakRef,"%WeakSet%":typeof WeakSet>"u"?V:WeakSet,"%Function.prototype.call%":Js,"%Function.prototype.apply%":qf,"%Object.defineProperty%":Aw,"%Object.getPrototypeOf%":Tw,"%Math.abs%":bw,"%Math.floor%":ww,"%Math.max%":Sw,"%Math.min%":_w,"%Math.pow%":kw,"%Math.round%":Ew,"%Math.sign%":xw,"%Reflect.getPrototypeOf%":Cw};if(_e)try{null.error}catch(n){var Pw=_e(_e(n));lr["%Error.prototype%"]=Pw}var Rw=function n(e){var t;if(e==="%AsyncFunction%")t=Sl("async function () {}");else if(e==="%GeneratorFunction%")t=Sl("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=Sl("async function* () {}");else if(e==="%AsyncGenerator%"){var r=n("%AsyncGeneratorFunction%");r&&(t=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=n("%AsyncGenerator%");i&&_e&&(t=_e(i.prototype))}return lr[e]=t,t},nd={__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"]},Xs=Ks,na=Xt,Dw=Xs.call(Js,Array.prototype.concat),Ow=Xs.call(qf,Array.prototype.splice),rd=Xs.call(Js,String.prototype.replace),ra=Xs.call(Js,String.prototype.slice),zw=Xs.call(Js,RegExp.prototype.exec),Lw=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Mw=/\\(\\)?/g,Nw=function(e){var t=ra(e,0,1),r=ra(e,-1);if(t==="%"&&r!=="%")throw new oi("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&t!=="%")throw new oi("invalid intrinsic syntax, expected opening `%`");var i=[];return rd(e,Lw,function(s,o,a,c){i[i.length]=a?rd(c,Mw,"$1"):o||s}),i},Uw=function(e,t){var r=e,i;if(na(nd,r)&&(i=nd[r],r="%"+i[0]+"%"),na(lr,r)){var s=lr[r];if(s===Cr&&(s=Rw(r)),typeof s>"u"&&!t)throw new Fr("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:s}}throw new oi("intrinsic "+e+" does not exist!")},ot=function(e,t){if(typeof e!="string"||e.length===0)throw new Fr("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof t!="boolean")throw new Fr('"allowMissing" argument must be a boolean');if(zw(/^%?[^%]*%?$/,e)===null)throw new oi("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=Nw(e),i=r.length>0?r[0]:"",s=Uw("%"+i+"%",t),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],Ow(r,Dw([0,1],u)));for(var d=1,p=!0;d<r.length;d+=1){var y=r[d],v=ra(y,0,1),$=ra(y,-1);if((v==='"'||v==="'"||v==="`"||$==='"'||$==="'"||$==="`")&&v!==$)throw new oi("property names with quotes must have matching quotes");if((y==="constructor"||!p)&&(c=!0),i+="."+y,o="%"+i+"%",na(lr,o))a=lr[o];else if(a!=null){if(!(y in a)){if(!t)throw new Fr("base intrinsic for "+e+" exists, but the property is not available.");return}if(rs&&d+1>=r.length){var E=rs(a,y);p=!!E,p&&"get"in E&&!("originalValue"in E.get)?a=E.get:a=a[y]}else p=na(a,y),a=a[y];p&&!c&&(lr[o]=a)}}return a},Yf=ot,Kf=Ua,Fw=Kf([Yf("%String.prototype.indexOf%")]),Sn=function(e,t){var r=Yf(e,!!t);return typeof r=="function"&&Fw(e,".prototype.")>-1?Kf([r]):r},kl,id;function bu(){if(id)return kl;id=1;var n=ot,e=n("%Array%"),t=!e.isArray&&Sn("Object.prototype.toString");return kl=e.isArray||function(i){return t(i)==="[object Array]"},kl}var Zw=Na,sd=Ys,Jf=Zw.hasArrayLengthDefineBug(),Hw=Jf&&bu(),Bw=Sn,jw=Bw("Object.prototype.propertyIsEnumerable"),wu=function(e,t,r,i,s,o){if(!sd){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&jw(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,t(i[s],a)}return Jf&&s==="length"&&"[[Value]]"in o&&Hw(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(sd(i,s,r(o)),!0)},Gw=W,Ci=Xt,Vw={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},fi=function(e){if(!e||typeof e!="object")return!1;for(var t in e)if(Ci(e,t)&&!Vw[t])return!1;var r=Ci(e,"[[Value]]")||Ci(e,"[[Writable]]"),i=Ci(e,"[[Get]]")||Ci(e,"[[Set]]");if(r&&i)throw new Gw("Property Descriptors may not be both accessor and data descriptors");return!0},Xf=function(e){if(typeof e>"u")return e;var t={};return"[[Value]]"in e&&(t.value=e["[[Value]]"]),"[[Writable]]"in e&&(t.writable=!!e["[[Writable]]"]),"[[Get]]"in e&&(t.get=e["[[Get]]"]),"[[Set]]"in e&&(t.set=e["[[Set]]"]),"[[Enumerable]]"in e&&(t.enumerable=!!e["[[Enumerable]]"]),"[[Configurable]]"in e&&(t.configurable=!!e["[[Configurable]]"]),t},Ww=W,qw=fi,Yw=Xf,Qf=function(e){if(typeof e<"u"&&!qw(e))throw new Ww("Assertion failed: `Desc` must be a Property Descriptor");return Yw(e)},Kw=W,od=Xt,Jw=fi,eg=function(e){if(typeof e>"u")return!1;if(!Jw(e))throw new Kw("Assertion failed: `Desc` must be a Property Descriptor");return!(!od(e,"[[Value]]")&&!od(e,"[[Writable]]"))},gi=function(e){return typeof e=="string"||typeof e=="symbol"},ad=gu,tg=function(e,t){return e===t?e===0?1/e===1/t:!0:ad(e)&&ad(t)},ld=W,Xw=Jt,Qw=wu,e0=Qf,t0=eg,n0=gi,r0=tg,Su=function(e,t,r){if(!Xw(e))throw new ld("Assertion failed: Type(O) is not Object");if(!n0(t))throw new ld("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return Qw(t0,r0,e0,e,t,i)},ng=Function.prototype.toString,Lr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,hc,Bo;if(typeof Lr=="function"&&typeof Object.defineProperty=="function")try{hc=Object.defineProperty({},"length",{get:function(){throw Bo}}),Bo={},Lr(function(){throw 42},null,hc)}catch(n){n!==Bo&&(Lr=null)}else Lr=null;var i0=/^\s*class\b/,dc=function(e){try{var t=ng.call(e);return i0.test(t)}catch{return!1}},El=function(e){try{return dc(e)?!1:(ng.call(e),!0)}catch{return!1}},jo=Object.prototype.toString,s0="[object Object]",o0="[object Function]",a0="[object GeneratorFunction]",l0="[object HTMLAllCollection]",c0="[object HTML document.all class]",u0="[object HTMLCollection]",h0=typeof Symbol=="function"&&!!Symbol.toStringTag,d0=!(0 in[,]),pc=function(){return!1};if(typeof document=="object"){var p0=document.all;jo.call(p0)===jo.call(document.all)&&(pc=function(e){if((d0||!e)&&(typeof e>"u"||typeof e=="object"))try{var t=jo.call(e);return(t===l0||t===c0||t===u0||t===s0)&&e("")==null}catch{}return!1})}var rg=Lr?function(e){if(pc(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{Lr(e,null,hc)}catch(t){if(t!==Bo)return!1}return!dc(e)&&El(e)}:function(e){if(pc(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(h0)return El(e);if(dc(e))return!1;var t=jo.call(e);return t!==o0&&t!==a0&&!/^\[object HTML/.test(t)?!1:El(e)},f0=rg,g0=function(e){return!!e},wt=Xt,bo=W,m0=Jt,cd=f0,xl=g0,v0=function(e){if(!m0(e))throw new bo("ToPropertyDescriptor requires an object");var t={};if(wt(e,"enumerable")&&(t["[[Enumerable]]"]=xl(e.enumerable)),wt(e,"configurable")&&(t["[[Configurable]]"]=xl(e.configurable)),wt(e,"value")&&(t["[[Value]]"]=e.value),wt(e,"writable")&&(t["[[Writable]]"]=xl(e.writable)),wt(e,"get")){var r=e.get;if(typeof r<"u"&&!cd(r))throw new bo("getter must be a function");t["[[Get]]"]=r}if(wt(e,"set")){var i=e.set;if(typeof i<"u"&&!cd(i))throw new bo("setter must be a function");t["[[Set]]"]=i}if((wt(t,"[[Get]]")||wt(t,"[[Set]]"))&&(wt(t,"[[Value]]")||wt(t,"[[Writable]]")))throw new bo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},Al=W,y0=Jt,ud=fi,b0=wu,w0=Qf,S0=eg,_0=gi,k0=tg,E0=v0,x0=function(e,t,r){if(!y0(e))throw new Al("Assertion failed: Type(O) is not Object");if(!_0(t))throw new Al("Assertion failed: P is not a Property Key");var i=ud(r)?r:E0(r);if(!ud(i))throw new Al("Assertion failed: Desc is not a valid Property Descriptor");return b0(S0,k0,w0,e,t,i)},hd=W,A0=Jt,$0=x0,T0=gi,C0=function(e,t,r){if(!A0(e))throw new hd("Assertion failed: Type(O) is not Object");if(!T0(t))throw new hd("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return $0(e,t,i)},I0=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,P0=pu,R0=P0.setPrototypeOf||null,D0=Ua,dd=di,O0=W,ig={};try{ig.__proto__=null}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var z0=!("toString"in ig),$l=dd&&dd(Object.prototype,"__proto__"),L0=z0&&(!!$l&&typeof $l.set=="function"&&D0([$l.set])||function(e,t){if(e==null)throw new O0("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=t,t}),pd=I0,M0=R0,fd=L0,N0=W,U0=pd?function(e,t){if(pd(e,t))return e;throw new N0("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:M0||(fd?function(e,t){return fd(e,t),e}:null),gd=W,F0=Jt,md=Vf(),Z0=function(e){if(!F0(e))throw new gd("Assertion failed: O must be an Object");if(!md)throw new gd("This environment does not support fetching prototypes.");return md(e)},H0=W,B0=U0,j0=Jt,G0=Z0,V0=function(e,t){if(t!==null&&!j0(t))throw new H0("Assertion failed: V must be Object or Null");try{B0(e,t)}catch{return!1}return G0(e)===t},Tl=Su,vd=C0,sg=V0,W0=Na(),_u=Hf;function Qs(n,e,t){var r=new _u(t);return sg(r,Go),delete r.constructor,vd(r,"error",n),vd(r,"suppressed",e),r}W0&&Object.defineProperty(Qs,"prototype",{writable:!1});var Go=Qs.prototype;if(!Tl(Go,"constructor",Qs)||!Tl(Go,"message","")||!Tl(Go,"name","SuppressedError"))throw new _u("unable to install SuppressedError.prototype properties; please report this!");sg(Qs.prototype,_u.prototype);var q0=Qs,Y0=q0,og=function(){return typeof SuppressedError=="function"?SuppressedError:Y0},K0=gr,yd=du(),J0=og,X0=function(){var e=J0();return K0(yd,{SuppressedError:e},{SuppressedError:function(){return yd.SuppressedError!==e}}),e};X0();var Q0=W,eS=fi,tS=Xf,nS=function(e){if(typeof e<"u"&&!eS(e))throw new Q0("Assertion failed: `Desc` must be a Property Descriptor");return tS(e)},rS=W,bd=Xt,iS=fi,sS=function(e){if(typeof e>"u")return!1;if(!iS(e))throw new rS("Assertion failed: `Desc` must be a Property Descriptor");return!(!bd(e,"[[Value]]")&&!bd(e,"[[Writable]]"))},wd=gu,oS=function(e,t){return e===t?e===0?1/e===1/t:!0:wd(e)&&wd(t)},mi=rg,aS=function(e){return!!e},St=Xt,wo=W,lS=Jt,Sd=mi,Cl=aS,cS=function(e){if(!lS(e))throw new wo("ToPropertyDescriptor requires an object");var t={};if(St(e,"enumerable")&&(t["[[Enumerable]]"]=Cl(e.enumerable)),St(e,"configurable")&&(t["[[Configurable]]"]=Cl(e.configurable)),St(e,"value")&&(t["[[Value]]"]=e.value),St(e,"writable")&&(t["[[Writable]]"]=Cl(e.writable)),St(e,"get")){var r=e.get;if(typeof r<"u"&&!Sd(r))throw new wo("getter must be a function");t["[[Get]]"]=r}if(St(e,"set")){var i=e.set;if(typeof i<"u"&&!Sd(i))throw new wo("setter must be a function");t["[[Set]]"]=i}if((St(t,"[[Get]]")||St(t,"[[Set]]"))&&(St(t,"[[Value]]")||St(t,"[[Writable]]")))throw new wo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},Il=W,uS=Jt,_d=fi,hS=wu,dS=nS,pS=sS,fS=gi,gS=oS,mS=cS,eo=function(e,t,r){if(!uS(e))throw new Il("Assertion failed: Type(O) is not Object");if(!fS(t))throw new Il("Assertion failed: P is not a Property Key");var i=_d(r)?r:mS(r);if(!_d(i))throw new Il("Assertion failed: Desc is not a valid Property Descriptor");return hS(pS,gS,dS,e,t,i)},vS=pi(),yS=vS?Symbol.dispose||Symbol("Symbol.dispose"):null,bS=pi,wS=yS,ku=function(){return bS()&&Symbol.dispose||wS},SS=mu,_S=eo,kS=ku,ES=function(){var e=kS();return SS()&&_S(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},xS=pi(),AS=xS?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,$S=pi,TS=AS,Eu=function(){return $S()&&Symbol.asyncDispose||TS},CS=mu,IS=eo,PS=Eu,RS=function(){var e=PS();return CS()&&IS(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},DS=bu(),OS=ot,zS=Sn,LS=W,MS=DS,NS=OS("%Reflect.apply%",!0)||zS("Function.prototype.apply"),Fa=function(e,t){var r=arguments.length>2?arguments[2]:[];if(!MS(r))throw new LS("Assertion failed: optional `argumentsList`, if provided, must be a List");return NS(e,t,r)};const US={},FS=Object.freeze(Object.defineProperty({__proto__:null,default:US},Symbol.toStringTag,{value:"Module"})),ZS=db(FS);var xu=typeof Map=="function"&&Map.prototype,Pl=Object.getOwnPropertyDescriptor&&xu?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,ia=xu&&Pl&&typeof Pl.get=="function"?Pl.get:null,kd=xu&&Map.prototype.forEach,Au=typeof Set=="function"&&Set.prototype,Rl=Object.getOwnPropertyDescriptor&&Au?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,sa=Au&&Rl&&typeof Rl.get=="function"?Rl.get:null,Ed=Au&&Set.prototype.forEach,HS=typeof WeakMap=="function"&&WeakMap.prototype,Xi=HS?WeakMap.prototype.has:null,BS=typeof WeakSet=="function"&&WeakSet.prototype,Qi=BS?WeakSet.prototype.has:null,jS=typeof WeakRef=="function"&&WeakRef.prototype,xd=jS?WeakRef.prototype.deref:null,GS=Boolean.prototype.valueOf,VS=Object.prototype.toString,WS=Function.prototype.toString,qS=String.prototype.match,$u=String.prototype.slice,dn=String.prototype.replace,YS=String.prototype.toUpperCase,Ad=String.prototype.toLowerCase,ag=RegExp.prototype.test,$d=Array.prototype.concat,It=Array.prototype.join,KS=Array.prototype.slice,Td=Math.floor,fc=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Dl=Object.getOwnPropertySymbols,gc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,ai=typeof Symbol=="function"&&typeof Symbol.iterator=="object",es=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===ai||!0)?Symbol.toStringTag:null,lg=Object.prototype.propertyIsEnumerable,Cd=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(n){return n.__proto__}:null);function Id(n,e){if(n===1/0||n===-1/0||n!==n||n&&n>-1e3&&n<1e3||ag.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof n=="number"){var r=n<0?-Td(-n):Td(n);if(r!==n){var i=String(r),s=$u.call(e,i.length+1);return dn.call(i,t,"$&_")+"."+dn.call(dn.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return dn.call(e,t,"$&_")}var mc=ZS,Pd=mc.custom,Rd=hg(Pd)?Pd:null,cg={__proto__:null,double:'"',single:"'"},JS={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},vi=function n(e,t,r,i){var s=t||{};if(Nt(s,"quoteStyle")&&!Nt(cg,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Nt(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=Nt(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(Nt(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(Nt(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 pg(e,s);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var c=String(e);return a?Id(e,c):c}if(typeof e=="bigint"){var u=String(e)+"n";return a?Id(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 vc(e)?"[Array]":"[Object]";var p=g_(s,r);if(typeof i>"u")i=[];else if(dg(i,e)>=0)return"[Circular]";function y(vt,en,rl){if(en&&(i=KS.call(i),i.push(en)),rl){var co={depth:s.depth};return Nt(s,"quoteStyle")&&(co.quoteStyle=s.quoteStyle),n(vt,co,r+1,i)}return n(vt,s,r+1,i)}if(typeof e=="function"&&!Dd(e)){var v=o_(e),$=So(e,y);return"[Function"+(v?": "+v:" (anonymous)")+"]"+($.length>0?" { "+It.call($,", ")+" }":"")}if(hg(e)){var E=ai?dn.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):gc.call(e);return typeof e=="object"&&!ai?Ii(E):E}if(d_(e)){for(var I="<"+Ad.call(String(e.nodeName)),Z=e.attributes||[],P=0;P<Z.length;P++)I+=" "+Z[P].name+"="+ug(XS(Z[P].value),"double",s);return I+=">",e.childNodes&&e.childNodes.length&&(I+="..."),I+="</"+Ad.call(String(e.nodeName))+">",I}if(vc(e)){if(e.length===0)return"[]";var G=So(e,y);return p&&!f_(G)?"["+yc(G,p)+"]":"[ "+It.call(G,", ")+" ]"}if(e_(e)){var O=So(e,y);return!("cause"in Error.prototype)&&"cause"in e&&!lg.call(e,"cause")?"{ ["+String(e)+"] "+It.call($d.call("[cause]: "+y(e.cause),O),", ")+" }":O.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+It.call(O,", ")+" }"}if(typeof e=="object"&&o){if(Rd&&typeof e[Rd]=="function"&&mc)return mc(e,{depth:d-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(a_(e)){var H=[];return kd&&kd.call(e,function(vt,en){H.push(y(en,e,!0)+" => "+y(vt,e))}),Od("Map",ia.call(e),H,p)}if(u_(e)){var N=[];return Ed&&Ed.call(e,function(vt){N.push(y(vt,e))}),Od("Set",sa.call(e),N,p)}if(l_(e))return Ol("WeakMap");if(h_(e))return Ol("WeakSet");if(c_(e))return Ol("WeakRef");if(n_(e))return Ii(y(Number(e)));if(i_(e))return Ii(y(fc.call(e)));if(r_(e))return Ii(GS.call(e));if(t_(e))return Ii(y(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof Rn<"u"&&e===Rn)return"{ [object globalThis] }";if(!QS(e)&&!Dd(e)){var ce=So(e,y),ue=Cd?Cd(e)===Object.prototype:e instanceof Object||e.constructor===Object,xi=e instanceof Object?"":"null prototype",lo=!ue&&es&&Object(e)===e&&es in e?$u.call(_n(e),8,-1):xi?"Object":"",xe=ue||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",xn=xe+(lo||xi?"["+It.call($d.call([],lo||[],xi||[]),": ")+"] ":"");return ce.length===0?xn+"{}":p?xn+"{"+yc(ce,p)+"}":xn+"{ "+It.call(ce,", ")+" }"}return String(e)};function ug(n,e,t){var r=t.quoteStyle||e,i=cg[r];return i+n+i}function XS(n){return dn.call(String(n),/"/g,"&quot;")}function mr(n){return!es||!(typeof n=="object"&&(es in n||typeof n[es]<"u"))}function vc(n){return _n(n)==="[object Array]"&&mr(n)}function QS(n){return _n(n)==="[object Date]"&&mr(n)}function Dd(n){return _n(n)==="[object RegExp]"&&mr(n)}function e_(n){return _n(n)==="[object Error]"&&mr(n)}function t_(n){return _n(n)==="[object String]"&&mr(n)}function n_(n){return _n(n)==="[object Number]"&&mr(n)}function r_(n){return _n(n)==="[object Boolean]"&&mr(n)}function hg(n){if(ai)return n&&typeof n=="object"&&n instanceof Symbol;if(typeof n=="symbol")return!0;if(!n||typeof n!="object"||!gc)return!1;try{return gc.call(n),!0}catch{}return!1}function i_(n){if(!n||typeof n!="object"||!fc)return!1;try{return fc.call(n),!0}catch{}return!1}var s_=Object.prototype.hasOwnProperty||function(n){return n in this};function Nt(n,e){return s_.call(n,e)}function _n(n){return VS.call(n)}function o_(n){if(n.name)return n.name;var e=qS.call(WS.call(n),/^function\s*([\w$]+)/);return e?e[1]:null}function dg(n,e){if(n.indexOf)return n.indexOf(e);for(var t=0,r=n.length;t<r;t++)if(n[t]===e)return t;return-1}function a_(n){if(!ia||!n||typeof n!="object")return!1;try{ia.call(n);try{sa.call(n)}catch{return!0}return n instanceof Map}catch{}return!1}function l_(n){if(!Xi||!n||typeof n!="object")return!1;try{Xi.call(n,Xi);try{Qi.call(n,Qi)}catch{return!0}return n instanceof WeakMap}catch{}return!1}function c_(n){if(!xd||!n||typeof n!="object")return!1;try{return xd.call(n),!0}catch{}return!1}function u_(n){if(!sa||!n||typeof n!="object")return!1;try{sa.call(n);try{ia.call(n)}catch{return!0}return n instanceof Set}catch{}return!1}function h_(n){if(!Qi||!n||typeof n!="object")return!1;try{Qi.call(n,Qi);try{Xi.call(n,Xi)}catch{return!0}return n instanceof WeakSet}catch{}return!1}function d_(n){return!n||typeof n!="object"?!1:typeof HTMLElement<"u"&&n instanceof HTMLElement?!0:typeof n.nodeName=="string"&&typeof n.getAttribute=="function"}function pg(n,e){if(n.length>e.maxStringLength){var t=n.length-e.maxStringLength,r="... "+t+" more character"+(t>1?"s":"");return pg($u.call(n,0,e.maxStringLength),e)+r}var i=JS[e.quoteStyle||"single"];i.lastIndex=0;var s=dn.call(dn.call(n,i,"\\$1"),/[\x00-\x1f]/g,p_);return ug(s,"single",e)}function p_(n){var e=n.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+YS.call(e.toString(16))}function Ii(n){return"Object("+n+")"}function Ol(n){return n+" { ? }"}function Od(n,e,t,r){var i=r?yc(t,r):It.call(t,", ");return n+" ("+e+") {"+i+"}"}function f_(n){for(var e=0;e<n.length;e++)if(dg(n[e],`
2
- `)>=0)return!1;return!0}function g_(n,e){var t;if(n.indent===" ")t=" ";else if(typeof n.indent=="number"&&n.indent>0)t=It.call(Array(n.indent+1)," ");else return null;return{base:t,prev:It.call(Array(e+1),t)}}function yc(n,e){if(n.length===0)return"";var t=`
3
- `+e.prev+e.base;return t+It.call(n,","+t)+`
4
- `+e.prev}function So(n,e){var t=vc(n),r=[];if(t){r.length=n.length;for(var i=0;i<n.length;i++)r[i]=Nt(n,i)?e(n[i],n):""}var s=typeof Dl=="function"?Dl(n):[],o;if(ai){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in n)Nt(n,c)&&(t&&String(Number(c))===c&&c<n.length||ai&&o["$"+c]instanceof Symbol||(ag.call(/[^\w$]/,c)?r.push(e(c,n)+": "+e(n[c],n)):r.push(c+": "+e(n[c],n))));if(typeof Dl=="function")for(var u=0;u<s.length;u++)lg.call(n,s[u])&&r.push("["+e(s[u])+"]: "+e(n[s[u]],n));return r}var m_=vi,v_=W,Za=function(n,e,t){for(var r=n,i;(i=r.next)!=null;r=i)if(i.key===e)return r.next=i.next,t||(i.next=n.next,n.next=i),i},y_=function(n,e){if(n){var t=Za(n,e);return t&&t.value}},b_=function(n,e,t){var r=Za(n,e);r?r.value=t:n.next={key:e,next:n.next,value:t}},w_=function(n,e){return n?!!Za(n,e):!1},S_=function(n,e){if(n)return Za(n,e,!0)},__=function(){var e,t={assert:function(r){if(!t.has(r))throw new v_("Side channel does not contain "+m_(r))},delete:function(r){var i=e&&e.next,s=S_(e,r);return s&&i&&i===s&&(e=void 0),!!s},get:function(r){return y_(e,r)},has:function(r){return w_(e,r)},set:function(r,i){e||(e={next:void 0}),b_(e,r,i)}};return t},k_=ot,to=Sn,E_=vi,x_=W,zd=k_("%Map%",!0),A_=to("Map.prototype.get",!0),$_=to("Map.prototype.set",!0),T_=to("Map.prototype.has",!0),C_=to("Map.prototype.delete",!0),I_=to("Map.prototype.size",!0),fg=!!zd&&function(){var e,t={assert:function(r){if(!t.has(r))throw new x_("Side channel does not contain "+E_(r))},delete:function(r){if(e){var i=C_(e,r);return I_(e)===0&&(e=void 0),i}return!1},get:function(r){if(e)return A_(e,r)},has:function(r){return e?T_(e,r):!1},set:function(r,i){e||(e=new zd),$_(e,r,i)}};return t},P_=ot,Ha=Sn,R_=vi,_o=fg,D_=W,$r=P_("%WeakMap%",!0),O_=Ha("WeakMap.prototype.get",!0),z_=Ha("WeakMap.prototype.set",!0),L_=Ha("WeakMap.prototype.has",!0),M_=Ha("WeakMap.prototype.delete",!0),N_=$r?function(){var e,t,r={assert:function(i){if(!r.has(i))throw new D_("Side channel does not contain "+R_(i))},delete:function(i){if($r&&i&&(typeof i=="object"||typeof i=="function")){if(e)return M_(e,i)}else if(_o&&t)return t.delete(i);return!1},get:function(i){return $r&&i&&(typeof i=="object"||typeof i=="function")&&e?O_(e,i):t&&t.get(i)},has:function(i){return $r&&i&&(typeof i=="object"||typeof i=="function")&&e?L_(e,i):!!t&&t.has(i)},set:function(i,s){$r&&i&&(typeof i=="object"||typeof i=="function")?(e||(e=new $r),z_(e,i,s)):_o&&(t||(t=_o()),t.set(i,s))}};return r}:_o,U_=W,F_=vi,Z_=__,H_=fg,B_=N_,j_=B_||H_||Z_,G_=function(){var e,t={assert:function(r){if(!t.has(r))throw new U_("Side channel does not contain "+F_(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=j_()),e.set(r,i)}};return t},V_=Xt,Pi=G_(),zt=W,Tu={assert:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new zt("`O` is not an object");if(typeof e!="string")throw new zt("`slot` must be a string");if(Pi.assert(n),!Tu.has(n,e))throw new zt("`"+e+"` is not present on `O`")},get:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new zt("`O` is not an object");if(typeof e!="string")throw new zt("`slot` must be a string");var t=Pi.get(n);return t&&t["$"+e]},has:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new zt("`O` is not an object");if(typeof e!="string")throw new zt("`slot` must be a string");var t=Pi.get(n);return!!t&&V_(t,"$"+e)},set:function(n,e,t){if(!n||typeof n!="object"&&typeof n!="function")throw new zt("`O` is not an object");if(typeof e!="string")throw new zt("`slot` must be a string");var r=Pi.get(n);r||(r={},Pi.set(n,r)),r["$"+e]=t}};Object.freeze&&Object.freeze(Tu);var Cu=Tu,gg=Kt,pn=Cu,no=function n(e,t){if(!(this instanceof n))return new n(e,t);if(e!=="normal"&&e!=="break"&&e!=="continue"&&e!=="return"&&e!=="throw")throw new gg('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');pn.set(this,"[[Type]]",e),pn.set(this,"[[Value]]",t)};no.prototype.type=function(){return pn.get(this,"[[Type]]")};no.prototype.value=function(){return pn.get(this,"[[Value]]")};no.prototype["?"]=function(){var e=pn.get(this,"[[Type]]"),t=pn.get(this,"[[Value]]");if(e==="throw")throw t;return t};no.prototype["!"]=function(){var e=pn.get(this,"[[Type]]");if(e!=="normal")throw new gg('Assertion failed: Completion Record is not of type "normal"');return pn.get(this,"[[Value]]")};var Iu=no,W_=Iu,Pu=function(e){return new W_("normal",e)},zl,Ld;function q_(){if(Ld)return zl;Ld=1;var n=pi;return zl=function(){return n()&&!!Symbol.toStringTag},zl}var Y_=ot,Md=Y_("%Object.defineProperty%",!0),K_=q_()(),J_=Xt,X_=W,ko=K_?Symbol.toStringTag:null,mg=function(e,t){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,i=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof r<"u"&&typeof r!="boolean"||typeof i<"u"&&typeof i!="boolean")throw new X_("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");ko&&(r||!J_(e,ko))&&(Md?Md(e,ko,{configurable:!i,enumerable:!1,value:t,writable:!1}):e[ko]=t)},vg={exports:{}},Q_=ot,Nd=Of,ek=Na(),Ud=di,Fd=W,tk=Q_("%Math.floor%"),nk=function(e,t){if(typeof e!="function")throw new Fd("`fn` is not a function");if(typeof t!="number"||t<0||t>4294967295||tk(t)!==t)throw new Fd("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in e&&Ud){var o=Ud(e,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!r)&&(ek?Nd(e,"length",t,!0,!0):Nd(e,"length",t)),e},rk=Ks,ik=yu,sk=Gf,ok=function(){return sk(rk,ik,arguments)};(function(n){var e=nk,t=Ys,r=Ua,i=ok;n.exports=function(o){var a=r(arguments),c=1+o.length-(arguments.length-1);return e(a,c>0?c:0,!0)},t?t(n.exports,"apply",{value:i}):n.exports.apply=i})(vg);var Ru=vg.exports,ak=function(e,t){for(var r=0;r<e.length;r+=1)if(!t(e[r],r,e))return!1;return!0},lk=Object,ck=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||lk(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},uk=Xt,hk=bu(),dk=ak,pk=ck,fk=function(e){return e&&typeof e=="object"&&uk(e,"[[DisposableResourceStack]]")&&hk(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||dk(e["[[DisposableResourceStack]]"],pk))},gk=Jt,mk=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(gk(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},vk=mk,Du=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":vk(e)},yk=W,bk=vi,wk=gi,Sk=function(e,t){if(!wk(t))throw new yk("Assertion failed: P is not a Property Key, got "+bk(t));return e[t]},Zd=W,_k=Sk,kk=mi,Ek=gi,Hd=vi,xk=function(e,t){if(!Ek(t))throw new Zd("Assertion failed: P is not a Property Key");var r=_k(e,t);if(r!=null){if(!kk(r))throw new Zd(Hd(t)+" is not a function: "+Hd(r));return r}},bc={exports:{}},Ak=ot,$k=Ak,Bd=$k("%Reflect.construct%",!0),oa=eo;try{oa({},"",{"[[Get]]":function(){}})}catch{oa=null}if(oa&&Bd){var jd={},Gd={};oa(Gd,"length",{"[[Get]]":function(){throw jd},"[[Enumerable]]":!0}),bc.exports=function(e){try{Bd(e,Gd)}catch(t){return t===jd}}}else bc.exports=function(e){return typeof e=="function"&&!!e.prototype};var Tk=bc.exports,Ll=W,Vd=mi,Ck=Tk,Ik=function(e){if(!Ck(e))throw new Ll("C must be a constructor");var t={"[[Resolve]]":void 0,"[[Reject]]":void 0},r=new e(function(i,s){if(typeof t["[[Resolve]]"]<"u"||typeof t["[[Reject]]"]<"u")throw new Ll("executor has already been called");t["[[Resolve]]"]=i,t["[[Reject]]"]=s});if(!Vd(t["[[Resolve]]"])||!Vd(t["[[Reject]]"]))throw new Ll("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":t["[[Resolve]]"],"[[Reject]]":t["[[Reject]]"]}},Wd=Kt,Pk=W,Ml=Fa,qd=xk,Rk=Ik,Dk=Du,Yd=ku(),Kd=Eu(),Ok=function(e,t){if(Dk(e)!=="Object")throw new Pk("`V` must be an Object");if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new Wd("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(t==="ASYNC-DISPOSE"&&Kd&&(r=qd(e,Kd)),!r){if(!Yd)throw new Wd("`Symbol.dispose` is not supported");if(r=qd(e,Yd),typeof r<"u")return function(){var i=this;if(t==="ASYNC-DISPOSE"){var s=Rk(Promise);try{Ml(r,i),Ml(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}Ml(r,i)}}return r},zk=Kt,Nl=W,Lk=mi,Mk=Du,Nk=Ok,Uk=function(e,t){if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new zk("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"&&Mk(e)!=="Object")throw new Nl("`V` must be an Object, or `null` or `undefined`");if(r=Nk(e,t),typeof r>"u")throw new Nl("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!Lk(r))throw new Nl("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":t,"[[DisposeMethod]]":r}},Fk=Kt,Eo=W,Zk=fk,Jd=Uk,Hk=Sn,Bk=Hk("Array.prototype.push"),yg=function(e,t,r){if(!Zk(e))throw new Eo("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new Fk("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 Eo("Assertion failed: `method`, when present, must be a function");if(!e["[[DisposableResourceStack]]"])throw new Eo("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var s;if(arguments.length<4){if(t==null&&r==="SYNC_DISPOSE")return"UNUSED";s=Jd(t,r)}else{if(typeof t<"u")throw new Eo("Assertion failed: `V` must be undefined when `method` is present");s=Jd(void 0,r,i)}return Bk(e["[[DisposableResourceStack]]"],s),"UNUSED"},Ul,Xd;function Ou(){if(Xd)return Ul;Xd=1;var n=ot,e=Ru,t=Kt,r=n("%Promise.resolve%",!0),i=r&&e(r);return Ul=function(o,a){if(!i)throw new t("This environment does not support Promises.");return i(o,a)},Ul}var Fl,Qd;function jk(){if(Qd)return Fl;Qd=1;var n=ot,e=Kt,t=n("%Promise%",!0),r=Fa,i=Ou(),s=Du;return Fl=function(a,c,u){if(typeof a<"u"&&s(a)!=="Object")throw new e("Assertion failed: `V` must be `undefined` or an Object");if(c!=="SYNC-DISPOSE"&&c!=="ASYNC-DISPOSE")throw new e("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");if(typeof u<"u"&&typeof u!="function")throw new e("Assertion failed: `method` must be `undefined` or a function");var d=typeof u>"u"?u:r(u,a);if(c==="ASYNC-DISPOSE")return i(t,d)},Fl}var Zl,ep;function Gk(){if(ep)return Zl;ep=1;var n=Iu;return Zl=function(t){return new n("throw",t)},Zl}var Vk=ot,Hl=Kt,tp=W,Wk=Vk("%Promise%",!0),qk=Sn,np=qk("Promise.prototype.then",!0),Yk=Iu,rp=jk(),Kk=Pu,Jk=Ou(),ip=Gk(),Xk=og(),bg=function(e,t){if(!(t instanceof Yk))throw new tp("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new tp("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 Hl("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&Jk(Wk,t),a=function(y){if(t.type()==="throw"){var v=t.value(),$=new Xk(y,v);t=ip($)}else t=ip(y)},c=i==="ASYNC-DISPOSE"&&function(v){return np(o,function(){var $=rp(v["[[ResourceValue]]"],v["[[Hint]]"],v["[[DisposeMethod]]"]);if(!$)throw new Hl("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return np($,Kk)},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=rp(d["[[ResourceValue]]"],d["[[Hint]]"],d["[[DisposeMethod]]"]);if(p)throw new Hl("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(y){a(y)}}return e["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:t},wg=function(){var e=[];return{"[[DisposableResourceStack]]":e}},Ba=fu,zu=W,Qk=Fa,yi=Su,eE=eo,Sg=mi,tE=Pu,Ge=Cu,nE=mg,_g=gr.supportsDescriptors,rE=Ru,Lu=yg,iE=bg,kg=wg,sp=ku(),rt=function n(){if(!(this instanceof n)||Ge.has(this,"[[DisposableState]]")||Ge.has(this,"[[DisposeCapability]]"))throw new zu("can only be used with new");Ge.set(this,"[[DisposableState]]","PENDING"),Ge.set(this,"[[DisposeCapability]]",kg())},Eg=function(){var e=this;return Ge.assert(e,"[[DisposableState]]"),Ge.get(e,"[[DisposableState]]")==="DISPOSED"},ro=rE(Eg);_g?eE(rt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":Eg}):rt.prototype.disposed=!1;var xg=function(e){Ge.set(e,"[[DisposableState]]","DISPOSED"),_g||(e.disposed=!0)};yi(rt.prototype,"dispose",function(){var e=this;if(!ro(e))return xg(e),iE(Ge.get(e,"[[DisposeCapability]]"),tE())["?"]()});yi(rt.prototype,"use",function(e){var t=this;if(ro(t))throw new Ba("a disposed stack can not use anything new");return Lu(Ge.get(t,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});yi(rt.prototype,"adopt",function(e,t){var r=this;if(ro(r))throw new Ba("a disposed stack can not use anything new");if(!Sg(t))throw new zu("`onDispose` must be a function");var i=function(){return Qk(t,void 0,[e])};return Lu(Ge.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),e});yi(rt.prototype,"defer",function(e){var t=this;if(ro(t))throw new Ba("a disposed stack can not defer anything new");if(!Sg(e))throw new zu("`onDispose` must be a function");Lu(Ge.get(t,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});yi(rt.prototype,"move",function(){var e=this;if(ro(e))throw new Ba("a disposed stack can not use anything new");var t=new rt;return Ge.set(t,"[[DisposeCapability]]",Ge.get(e,"[[DisposeCapability]]")),Ge.set(e,"[[DisposeCapability]]",kg()),xg(e),t});sp&&yi(rt.prototype,sp,rt.prototype.dispose);nE(rt.prototype,"DisposableStack");var sE=rt,oE=sE,aE=function(){return typeof DisposableStack=="function"?DisposableStack:oE},lE=gr,cE=du(),uE=aE,hE=function(){var e=uE();return lE(cE,{DisposableStack:e},{DisposableStack:!0}),e},dE=ot,ja=fu,Mu=W,op=dE("%Promise%",!0),Nu=yg,pE=Fa,bi=Su,fE=eo,gE=bg,Ag=mi,$g=wg,mE=Pu,ap=Ou(),Ve=Cu,vE=mg,Tg=gr.supportsDescriptors,yE=Ru,bE=Sn,wE=bE("Promise.prototype.then",!0),lp=Eu(),it=function n(){if(!(this instanceof n)||Ve.has(this,"[[AsyncDisposableState]]")||Ve.has(this,"[[DisposeCapability]]"))throw new Mu("can only be used with new");Ve.set(this,"[[AsyncDisposableState]]","pending"),Ve.set(this,"[[DisposeCapability]]",$g())},Cg=function(){var e=this;return Ve.assert(e,"[[AsyncDisposableState]]"),Ve.get(e,"[[AsyncDisposableState]]")==="disposed"},io=yE(Cg);Tg?fE(it.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":Cg}):it.prototype.disposed=!1;var Ig=function(e){Ve.set(e,"[[AsyncDisposableState]]","disposed"),Tg||(e.disposed=!0)};bi(it.prototype,"disposeAsync",function(){var e=this;return io(e)?ap(op):(Ig(e),wE(ap(op,gE(Ve.get(e,"[[DisposeCapability]]"),mE())),function(t){return t["?"]()}))});bi(it.prototype,"use",function(e){var t=this;if(io(t))throw new ja("a disposed stack can not use anything new");return Nu(Ve.get(t,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});bi(it.prototype,"adopt",function(e,t){var r=this;if(io(r))throw new ja("a disposed stack can not use anything new");if(!Ag(t))throw new Mu("`onDisposeAsync` must be a function");var i=function(){return pE(t,void 0,[e])};return i.value=e,Nu(Ve.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),e});bi(it.prototype,"defer",function(e){var t=this;if(io(t))throw new ja("a disposed stack can not defer anything new");if(!Ag(e))throw new Mu("`onDispose` must be a function");Nu(Ve.get(t,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});bi(it.prototype,"move",function(){var e=this;if(io(e))throw new ja("a disposed stack can not use anything new");var t=new it;return Ve.set(t,"[[DisposeCapability]]",Ve.get(e,"[[DisposeCapability]]")),Ve.set(e,"[[DisposeCapability]]",$g()),Ig(e),t});lp&&bi(it.prototype,lp,it.prototype.disposeAsync);vE(it.prototype,"AsyncDisposableStack");var SE=it,_E=SE,kE=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:_E},EE=gr,xE=du(),AE=kE,$E=function(){var e=AE();return EE(xE,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},TE=ES,CE=RS,IE=hE,PE=$E,RE=function(){TE(),CE(),IE(),PE()};RE();const cp=new WeakMap;function DE(n){return(typeof n=="object"||typeof n=="function")&&n!==null&&"then"in n&&typeof n.then=="function"}function Tr(n){return typeof n=="string"?n:typeof n=="symbol"?n.description??n.toString():n.name||"(anonymous class)"}function up(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function OE(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class zE{constructor(){b(this,"entries",new Map);b(this,"constructionStack",[])}register(e,t){if(t===void 0){if(typeof e!="function")throw up();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof t!="function")throw up();if(t.constructor.name==="AsyncFunction")throw OE();this.storeFactory(e,t)}has(e){var t;return((t=this.entries.get(e))==null?void 0:t.factory)!==void 0}resolve(e){return this.resolveAny(e)}storeFactory(e,t){const r=this.getOrCreateEntry(e);r.factory=t,r.instance=void 0,r.error=void 0}validateClassRegistration(e){const t=cp.get(e);if(t){if(e.length!==t.length)throw new Error(`${Tr(e)} cannot be registered with register(Class). @injectable(...) declared ${t.length} dependencies but constructor arity is ${e.length}. Use register(Key, () => value) instead.`);return}if(e.length!==0)throw new Error(`${Tr(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const t=cp.get(e);if(!t)return new e;const r=t.map(i=>this.resolveAny(i));return new e(...r)}resolveAny(e){return this.getOrCreateEntry(e).proxy}getOrCreateEntry(e){let t=this.entries.get(e);return t||(t={key:e},t.proxy=this.createProxy(t),this.entries.set(e,t),t)}createProxy(e){return new Proxy({},{get:(t,r)=>{if(r==="then")return;const i=this.getInstance(e),s=Reflect.get(i,r,i);return typeof s=="function"?s.bind(i):s},set:(t,r,i)=>{const s=this.getInstance(e);return Reflect.set(s,r,i,s)},has:(t,r)=>{const i=this.getInstance(e);return r in i}})}getInstance(e){if(e.instance)return e.instance;if(e.error)throw e.error;if(!e.factory)throw new Error(`${Tr(e.key)} was resolved but never registered`);const t=this.constructionStack.indexOf(e.key);if(t!==-1){const r=[...this.constructionStack.slice(t),e.key].map(i=>Tr(i)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(e.key);try{const r=e.factory();if(DE(r))throw new Error(`Factory for ${Tr(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${Tr(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 We=new zE,LE=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function ME(n){for(const e of Object.keys(n))if(LE.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function NE(n,e){ME(e);for(const t of Object.keys(e))Object.defineProperty(n,t,{value:e[t],writable:!0,enumerable:!0,configurable:!0})}function gt(){class n extends Event{constructor(t,r){const{type:i,bubbles:s,cancelable:o,composed:a,...c}=r??{};if(i!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(t,{bubbles:s,cancelable:o,composed:a}),NE(this,c)}}return n}class mt extends globalThis.EventTarget{}function UE(n,e,t){const r=n.dispose.bind(n);n.dispose=()=>{if(!e())return t(),r()}}function wi(n){var t;class e extends n{constructor(...s){super(...s);S(this,t,!1);UE(this,()=>l(this,t),()=>{k(this,t,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return l(this,t)}}return t=new WeakMap,e}const FE=gt(),ZE=gt(),Vo=gt(),Pg="0123456789ABCDEFGHJKMNPQRSTVWXYZ",aa=32,HE=16,Rg=10,hp=0xffffffffffff;var Mn;(function(n){n.Base32IncorrectEncoding="B32_ENC_INVALID",n.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",n.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",n.EncodeTimeNegative="ENC_TIME_NEG",n.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",n.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",n.PRNGDetectFailure="PRNG_DETECT",n.ULIDInvalid="ULID_INVALID",n.Unexpected="UNEXPECTED",n.UUIDInvalid="UUID_INVALID"})(Mn||(Mn={}));class Hi extends Error{constructor(e,t){super(`${t} (${e})`),this.name="ULIDError",this.code=e}}function BE(n){const e=Math.floor(n()*aa)%aa;return Pg.charAt(e)}function jE(n){const e=GE(),t=e&&(e.crypto||e.msCrypto)||null;if(typeof(t==null?void 0:t.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return t.getRandomValues(r),r[0]/256};if(typeof(t==null?void 0:t.randomBytes)=="function")return()=>t.randomBytes(1).readUInt8()/256;throw new Hi(Mn.PRNGDetectFailure,"Failed to find a reliable PRNG")}function GE(){return qE()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function VE(n,e){let t="";for(;n>0;n--)t=BE(e)+t;return t}function WE(n,e=Rg){if(isNaN(n))throw new Hi(Mn.EncodeTimeValueMalformed,`Time must be a number: ${n}`);if(n>hp)throw new Hi(Mn.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${hp}: ${n}`);if(n<0)throw new Hi(Mn.EncodeTimeNegative,`Time must be positive: ${n}`);if(Number.isInteger(n)===!1)throw new Hi(Mn.EncodeTimeValueMalformed,`Time must be an integer: ${n}`);let t,r="";for(let i=e;i>0;i--)t=n%aa,r=Pg.charAt(t)+r,n=(n-t)/aa;return r}function qE(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Uu(n,e){const t=jE(),r=Date.now();return WE(r,Rg)+VE(HE,t)}const Pt=4,Qe=6,Dg=2,wc=2,YE=Pt,KE=Qe,Fu="auto",fn="auto",Dn=120,dp=75,ge=16,cr=Dn*Pt+ge*(Pt-1),la=Dn*Qe+ge*(Qe-1),JE=200,XE=4,xo=150,QE=10,pp=2,ex=4;function Og(n){return Mg(n)}function zg(n,e){return Mg(n.flatMap(t=>Ug(t,e)))}function Lg(n){const e=[],t=new Set;for(const r of n){if(r.type==="row"){e.push(`Top-level rows are invalid: ${r.id}`);continue}Fg(r,"strip",e,t)}return{valid:e.length===0,errors:e}}function Mr(n){const e=Og(n),t=Lg(e);if(!t.valid)throw new Error(`Invalid layout: ${t.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(ix)}}function Mg(n){const e=[];for(const t of n){const r=Ng(t);for(const i of r){if(i.type==="row"){e.push(...i.children.map(qt));continue}e.push(i)}}return e}function Ng(n){switch(n.type){case"card":return[qt(n)];case"row":{const e=n.children.map(qt);return e.length===0?[]:e.length===1?[e[0]]:[{...n,children:e}]}case"stack":{const e=[];for(const t of n.children){const r=Ng(t);for(const i of r){if(i.type==="stack"){e.push(...i.children.map(Sc));continue}if(i.type==="row"){e.push({...i,children:i.children.map(qt)});continue}e.push(qt(i))}}return e.length===0?[]:e.length===1?[Sc(e[0])]:[{...n,children:e}]}}}function Ug(n,e){switch(n.type){case"card":return n.artifactID===e?[]:[qt(n)];case"row":{const t=n.children.filter(r=>r.artifactID!==e).map(qt);return t.length===0?[]:t.length===1?[t[0]]:[{...n,children:t}]}case"stack":{const t=n.children.flatMap(r=>Ug(r,e).filter(s=>s.type!=="stack"));return t.length===0?[]:t.length===1?[Sc(t[0])]:[{...n,children:t}]}}}function Fg(n,e,t,r){switch(n.type){case"card":Zg(n,e,t,r);return;case"row":tx(n,e,t,r);return;case"stack":nx(n,e,t,r);return}}function Zg(n,e,t,r){Zu(n.id,t),typeof n.artifactID!="string"||n.artifactID.length===0?t.push(`Card ${n.id} is missing artifactID`):r.has(n.artifactID)?t.push(`Duplicate artifactID in layout: ${n.artifactID}`):r.add(n.artifactID),rx(n.width)||t.push(`Card ${n.id} width must be an integer in the range 2-4`),Hg(n.height)||t.push(`Card ${n.id} height must be an integer in the range 2-6 or "auto"`);const i=On(n.width);e==="row"&&i<Dg&&t.push(`Row child ${n.id} must be at least 2 columns wide`)}function tx(n,e,t,r){if(Zu(n.id,t),e!=="stack"&&t.push(`Row ${n.id} may only appear inside a stack`),Hg(n.height,ex)||t.push(`Row ${n.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(n.children)||n.children.length===0){t.push(`Row ${n.id} must contain card nodes`);return}let i=0;for(const s of n.children){if(s.type!=="card"){t.push(`Row ${n.id} must contain only card nodes`);continue}Zg(s,"row",t,r),i+=On(s.width)}i!==Pt&&t.push(`Row ${n.id} children must sum to 4 columns`)}function nx(n,e,t,r){if(Zu(n.id,t),e!=="strip"&&t.push(`Invalid nested stack at ${n.id}; stack children cannot contain another nested stack`),!Array.isArray(n.children)||n.children.length===0){t.push(`Stack ${n.id} must contain at least one child`);return}let i=0,s=0;for(const a of n.children){if(a.type==="stack"){t.push(`Stack ${n.id} cannot contain another nested stack`);continue}if(Fg(a,"stack",t,r),a.height===fn){s+=1;continue}i+=a.height}if(i>Qe&&t.push(`Stack ${n.id} exceeds the 6-row budget`),s===0)return;const o=Qe-i;if(o<s*wc||o%s!==0){t.push(`Stack ${n.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<wc&&t.push(`Stack ${n.id} has auto-height children below the minimum row size`)}function Zu(n,e){(typeof n!="string"||n.length===0)&&e.push(`Node id must be a non-empty string: ${String(n)}`)}function rx(n){return n===Fu||Number.isInteger(n)&&n>=Dg&&n<=YE}function Hg(n,e=KE){return n===fn||Number.isInteger(n)&&n>=wc&&n<=e}function On(n){return n===Fu?Pt:n}function ix(n){if(n.type==="card")return{id:n.id,type:"card",width:On(n.width),cards:[{id:n.id,artifactID:n.artifactID,col:1,row:1,width:On(n.width),height:Bg(n.height,Qe)}]};const e=sx(n.children),t=[];let r=1;for(let i=0;i<n.children.length;i+=1){const s=n.children[i],o=e[i];if(s.type==="card")t.push({id:s.id,artifactID:s.artifactID,col:1,row:r,width:On(s.width),height:o});else{let a=1;for(const c of s.children)t.push({id:c.id,artifactID:c.artifactID,col:a,row:r,width:On(c.width),height:o}),a+=On(c.width)}r+=o}return{id:n.id,type:"stack",width:t.reduce((i,s)=>Math.max(i,s.col+s.width-1),1),cards:t}}function sx(n){let e=0,t=0;for(const i of n)i.height===fn?t+=1:e+=i.height;const r=t>0?(Qe-e)/t:0;return n.map(i=>Bg(i.height,r))}function Bg(n,e){return n===fn?e:n}function qt(n){return{...n}}function Sc(n){return n.type==="card"?qt(n):{...n,children:n.children.map(qt)}}function jg(n,e={}){return{id:e.id??Uu(),type:"card",artifactID:n,width:e.width??Fu,height:e.height??fn}}function Gg(n,e){return n.some(t=>Vg(t,e))}function Vg(n,e){switch(n.type){case"card":return n.artifactID===e;case"row":return n.children.some(t=>t.artifactID===e);case"stack":return n.children.some(t=>Vg(t,e))}}function fp(n){return n.layout.flatMap(Wg)}function Wg(n){switch(n.type){case"card":return[n.artifactID];case"row":return n.children.map(e=>e.artifactID);case"stack":return n.children.flatMap(Wg)}}const ee=gt(),qg=gt(),Ri=gt(),ox=gt();function ax(n){class e extends Error{constructor(r,i){super(r),this.name=n,i&&Object.assign(this,i)}}return e}const lx=ax("RequestError"),cx=200,ux=300;class hx{constructor(e,t){b(this,"serverURL");b(this,"token");this.serverURL=e.replace(/\/$/,""),this.token=t.token}async requestJSON(e,t,r){const i=await this.request(e,t,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),s=await dx(i);if(!i.ok||i.status<cx||i.status>=ux)throw this.createError(typeof s.error=="string"?s.error:i.statusText,i.status);return s}async requestVoid(e,t){const r=await this.request(e,t);if(!r.ok)throw this.createError(await Bl(r,r.statusText),r.status)}async requestText(e,t){const r=await this.request(e,t);if(!r.ok)throw this.createError(await Bl(r,r.statusText),r.status);return r.text()}async requestRawVoid(e,t,r){const i=await this.request(e,t,r,{"content-type":"text/plain"});if(!i.ok)throw this.createError(await Bl(i,i.statusText),i.status)}createError(e,t){const r={serverURL:this.serverURL};return t!==void 0&&(r.status=t),new lx(e,r)}async request(e,t,r,i){const s=`${this.serverURL}${t}`;try{return await fetch(s,{method:e,headers:this.buildHeaders(i),body:r})}catch(o){throw this.createError(o instanceof Error?o.message:"Failed to reach server")}}buildHeaders(e){const t={...e??{}};return this.token&&(t.Authorization=`Bearer ${this.token}`),Object.keys(t).length>0?t:void 0}}async function dx(n){try{return await n.json()}catch{const e=await n.text().catch(()=>"");return e?{message:e}:{}}}async function Bl(n,e){try{const t=await n.json();if(typeof t.error=="string")return t.error;if(typeof t.message=="string")return t.message}catch{}return e}function px(n){return n.map(e=>`${e.name} (${e.id})`).join(", ")}var xt,wa,Yg;class fx{constructor(e){S(this,wa);S(this,xt);k(this,xt,e)}list(){return l(this,xt).requestJSON("GET","/screens")}async get(e={}){const t=await g(this,wa,Yg).call(this,e.screenID);return l(this,xt).requestJSON("GET",`/screens/${encodeURIComponent(t)}`)}create(e){const t={name:e.name};return e.id!==void 0&&(t.id=e.id),l(this,xt).requestJSON("POST","/screens",t)}update(e){const t={};return e.name!==void 0&&(t.name=e.name),e.layout!==void 0&&(t.layout=e.layout),l(this,xt).requestJSON("PATCH",`/screens/${encodeURIComponent(e.screenID)}`,t)}remove(e){return l(this,xt).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}xt=new WeakMap,wa=new WeakSet,Yg=async function(e){if(e!==void 0)return e;const{screens:t}=await this.list();if(t.length===1)return t[0].id;throw l(this,xt).createError(`screenID is required when multiple screens exist. Available screens: ${px(t)}`)};var Oe;class gx{constructor(e){S(this,Oe);k(this,Oe,e)}create(e){const t={type:e.type,title:e.title};return e.externalFilePath!==void 0&&(t.externalFilePath=e.externalFilePath),e.screenID!==void 0&&(t.screenID=e.screenID),l(this,Oe).requestJSON("POST","/artifacts",t)}list(e={}){const t=new URLSearchParams;e.screenID!==void 0&&t.set("screenID",e.screenID),e.unplaced&&t.set("unplaced","true");const r=t.toString();return l(this,Oe).requestJSON("GET",r?`/artifacts?${r}`:"/artifacts")}get(e){return l(this,Oe).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const t={};return e.title!==void 0&&(t.title=e.title),l(this,Oe).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,t)}edit(e){return l(this,Oe).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return l(this,Oe).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return l(this,Oe).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}attach(e){return l(this,Oe).requestJSON("POST",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}detach(e){return l(this,Oe).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}delete(e){return l(this,Oe).requestJSON("DELETE",`/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return l(this,Oe).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return l(this,Oe).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}Oe=new WeakMap;var Fn;class mx{constructor(e){S(this,Fn);k(this,Fn,e)}state(){return l(this,Fn).requestJSON("GET","/viewer/state")}setActive(e){return l(this,Fn).requestJSON("PUT","/viewer/active-screen",{screenID:e.screenID})}focus(e){const t={artifactID:e.artifactID};return e.screenID!==void 0&&(t.screenID=e.screenID),l(this,Fn).requestJSON("POST","/viewer/focus",t)}}Fn=new WeakMap;var cs;class vx{constructor(e){S(this,cs);k(this,cs,e)}async list(){const{views:e}=await l(this,cs).requestJSON("GET","/views");return e}}cs=new WeakMap;var Ut;class yx{constructor(e,t={}){b(this,"screens");b(this,"artifacts");b(this,"viewer");b(this,"views");S(this,Ut);k(this,Ut,new hx(e,t)),this.screens=new fx(l(this,Ut)),this.artifacts=new gx(l(this,Ut)),this.viewer=new mx(l(this,Ut)),this.views=new vx(l(this,Ut))}health(){return l(this,Ut).requestJSON("GET","/health")}}Ut=new WeakMap;const bx={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},wx=wi(mt);var Zn,Be,Hn,Me,rn,sn,X,Ir,Kg,us,Jg,Xg,Qg,em,_c,kc,Ec,tm;class Sx extends wx{constructor(t){var i;super();S(this,X);b(this,"id");b(this,"server");S(this,Zn);S(this,Be,new Map);S(this,Hn);S(this,Me);S(this,rn);S(this,sn,null);S(this,us,t=>{if(this.disposed)return;const r=t.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&g(this,X,Jg).call(this,r.screen);break;case"artifact-created":break;case"artifact-attached":r.screenID===this.id&&g(this,X,Xg).call(this,r.cardID,r.artifact);break;case"artifact-updated":g(this,X,Qg).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&g(this,X,em).call(this,r.artifactID);break;case"artifact-content-changed":l(this,Be).has(r.artifactID)&&this.dispatchEvent(new ox("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=t.screen.id,this.server=t.server,k(this,Zn,t.localStore),k(this,Hn,t.screen.name),k(this,Me,structuredClone(t.screen.layout));const r=((i=l(this,Zn).get().screens[this.id])==null?void 0:i.scrollPosition)??0;k(this,rn,Math.max(0,r)),this.server.addEventListener("server-event",l(this,us)),g(this,X,Kg).call(this)}get name(){return l(this,Hn)}get layout(){return l(this,Me)}get scrollPosition(){return l(this,rn)}get artifacts(){return l(this,Be)}setScrollPosition(t){g(this,X,Ir).call(this);const r=Math.max(0,t);r!==l(this,rn)&&(k(this,rn,r),g(this,X,tm).call(this),this.dispatchEvent(new ee("change")))}setLayout(t){g(this,X,Ir).call(this);const r=Og(t);if(!Lg(r).valid)return;const s=g(this,X,kc).call(this);k(this,Me,r),k(this,sn,{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,sn))==null?void 0:o.layout)===r&&(k(this,sn,null),g(this,X,Ec).call(this,s),this.dispatchEvent(new ee("change")))})}rename(t){g(this,X,Ir).call(this),k(this,Hn,t),this.dispatchEvent(new ee("change")),this.server.client.screens.update({screenID:this.id,name:t}).catch(()=>{})}async remove(){g(this,X,Ir).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(t){if(g(this,X,Ir).call(this),!l(this,Be).has(t))return;const r=g(this,X,kc).call(this);g(this,X,_c).call(this,t),this.dispatchEvent(new ee("change")),this.server.client.artifacts.detach({artifactID:t,screenID:this.id}).catch(()=>{this.disposed||(g(this,X,Ec).call(this,r),this.dispatchEvent(new ee("change")))})}dispose(){this.server.removeEventListener("server-event",l(this,us))}}Zn=new WeakMap,Be=new WeakMap,Hn=new WeakMap,Me=new WeakMap,rn=new WeakMap,sn=new WeakMap,X=new WeakSet,Ir=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Kg=async function(){try{const t=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of t.artifacts)l(this,Be).set(r.id,r);this.dispatchEvent(new ee("change"))}catch{}},us=new WeakMap,Jg=function(t){l(this,sn)&&k(this,sn,null),k(this,Hn,t.name),k(this,Me,structuredClone(t.layout)),this.dispatchEvent(new ee("change"))},Xg=function(t,r){Gg(l(this,Me),r.id)||k(this,Me,[...l(this,Me),jg(r.id,{id:t})]),l(this,Be).set(r.id,r),this.dispatchEvent(new ee("change"))},Qg=function(t){const r=l(this,Be).get(t.id);r&&(l(this,Be).set(t.id,{...r,...t}),this.dispatchEvent(new ee("change")))},em=function(t){g(this,X,_c).call(this,t)&&this.dispatchEvent(new ee("change"))},_c=function(t){const r=l(this,Be).delete(t),i=fp({layout:l(this,Me)}).length,s=zg(l(this,Me),t),o=fp({layout:s}).length;return k(this,Me,s),r||i!==o},kc=function(){return{layout:structuredClone(l(this,Me)),artifacts:new Map([...l(this,Be).entries()].map(([t,r])=>[t,structuredClone(r)]))}},Ec=function(t){k(this,Me,structuredClone(t.layout)),l(this,Be).clear();for(const[r,i]of t.artifacts)l(this,Be).set(r,structuredClone(i))},tm=function(){const t=l(this,Zn).get();l(this,Zn).set({...t,screens:{...t.screens,[this.id]:{scrollPosition:l(this,rn)}}})};const _x=wi(mt);var et,At,lt,hs,ds,ps,Hr,Wo;class kx extends _x{constructor(t){super();S(this,Hr);S(this,et);S(this,At);S(this,lt,null);S(this,hs,()=>{this.disposed||g(this,Hr,Wo).call(this)});S(this,ds,()=>{this.disposed||g(this,Hr,Wo).call(this)});S(this,ps,t=>{var i;if(this.disposed)return;const r=t.event;if(r.type==="screen-removed"&&((i=l(this,lt))==null?void 0:i.id)===r.screenID&&this.clearActive(),r.type==="viewer-active-screen-changed"){const s=l(this,At).servers.get(t.serverURL);s&&s.screens.has(r.screenID)&&this.setActive(t.serverURL,r.screenID)}});k(this,et,t.localStore),k(this,At,t.serverManager),l(this,et).addEventListener("change",l(this,hs)),l(this,At).addEventListener("change",l(this,ds)),l(this,At).addEventListener("server-event",l(this,ps)),g(this,Hr,Wo).call(this)}get activeScreen(){return l(this,lt)}setActive(t,r){const i=l(this,et).get();i.activeServerURL===t&&i.activeScreenID===r||l(this,et).set({...i,activeServerURL:t,activeScreenID:r})}clearActive(){const t=l(this,et).get();t.activeScreenID!==null&&l(this,et).set({...t,activeScreenID:null})}dispose(){var t;l(this,et).removeEventListener("change",l(this,hs)),l(this,At).removeEventListener("change",l(this,ds)),l(this,At).removeEventListener("server-event",l(this,ps)),(t=l(this,lt))==null||t.dispose(),k(this,lt,null)}}et=new WeakMap,At=new WeakMap,lt=new WeakMap,hs=new WeakMap,ds=new WeakMap,ps=new WeakMap,Hr=new WeakSet,Wo=function(){var c,u,d;const{activeServerURL:t,activeScreenID:r}=l(this,et).get(),i=t?l(this,At).servers.get(t)??null:null,s=i&&r?i.screens.get(r)??null:null,o=((c=l(this,lt))==null?void 0:c.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=l(this,lt))==null?void 0:u.server)===i||((d=l(this,lt))==null||d.dispose(),k(this,lt,i&&s?new Sx({screen:s,server:i,localStore:l(this,et)}):null),this.dispatchEvent(new FE("active-screen-changed")))};const Ex="Local",xx="store-";function Et(n){return new URL(n).origin}function Ax(n){return{servers:[{url:Et(n),name:Ex}],activeServerURL:null,activeScreenID:null,screens:{}}}var Bn,jn,Gn;class $x extends mt{constructor(t,r,i={}){super();S(this,Bn);S(this,jn);S(this,Gn);k(this,Bn,`${xx}${t}`),k(this,jn,i.storage??Tx());const s=l(this,jn).getItem(l(this,Bn));s===null?(k(this,Gn,r),l(this,jn).setItem(l(this,Bn),JSON.stringify(r))):k(this,Gn,JSON.parse(s))}get(){return l(this,Gn)}set(t){k(this,Gn,t),l(this,jn).setItem(l(this,Bn),JSON.stringify(t)),this.dispatchEvent(new ee("change"))}}Bn=new WeakMap,jn=new WeakMap,Gn=new WeakMap;function Tx(){const n=globalThis.localStorage;if(!n)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return n}function x(n,e,t){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(n))return;a._zod.traits.add(n),e(a,c);const u=o.prototype,d=Object.keys(u);for(let p=0;p<d.length;p++){const y=d[p];y in a||(a[y]=u[y].bind(a))}}const i=(t==null?void 0:t.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:n});function o(a){var c;const u=t!=null&&t.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var c,u;return t!=null&&t.Parent&&a instanceof t.Parent?!0:(u=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:u.has(n)}}),Object.defineProperty(o,"name",{value:n}),o}class Zr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class nm extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const rm={};function gn(n){return rm}function im(n){const e=Object.values(n).filter(r=>typeof r=="number");return Object.entries(n).filter(([r,i])=>e.indexOf(+r)===-1).map(([r,i])=>i)}function xc(n,e){return typeof e=="bigint"?e.toString():e}function Hu(n){return{get value(){{const e=n();return Object.defineProperty(this,"value",{value:e}),e}}}}function Bu(n){return n==null}function ju(n){const e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function Cx(n,e){const t=(n.toString().split(".")[1]||"").length,r=e.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c!=null&&c[1]&&(i=Number.parseInt(c[1]))}const s=t>i?t:i,o=Number.parseInt(n.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return o%a/10**s}const gp=Symbol("evaluating");function Q(n,e,t){let r;Object.defineProperty(n,e,{get(){if(r!==gp)return r===void 0&&(r=gp,r=t()),r},set(i){Object.defineProperty(n,e,{value:i})},configurable:!0})}function vr(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function kn(...n){const e={};for(const t of n){const r=Object.getOwnPropertyDescriptors(t);Object.assign(e,r)}return Object.defineProperties({},e)}function mp(n){return JSON.stringify(n)}function Ix(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const sm="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function ca(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const Px=Hu(()=>{var n;if(typeof navigator<"u"&&((n=navigator==null?void 0:navigator.userAgent)!=null&&n.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function li(n){if(ca(n)===!1)return!1;const e=n.constructor;if(e===void 0||typeof e!="function")return!0;const t=e.prototype;return!(ca(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}function om(n){return li(n)?{...n}:Array.isArray(n)?[...n]:n}const Rx=new Set(["string","number","symbol"]);function ci(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function En(n,e,t){const r=new n._zod.constr(e??n._zod.def);return(!e||t!=null&&t.parent)&&(r._zod.parent=n),r}function z(n){const e=n;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function Dx(n){return Object.keys(n).filter(e=>n[e]._zod.optin==="optional"&&n[e]._zod.optout==="optional")}const Ox={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 zx(n,e){const t=n._zod.def,r=t.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=kn(n._zod.def,{get shape(){const o={};for(const a in e){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(o[a]=t.shape[a])}return vr(this,"shape",o),o},checks:[]});return En(n,s)}function Lx(n,e){const t=n._zod.def,r=t.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=kn(n._zod.def,{get shape(){const o={...n._zod.def.shape};for(const a in e){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete o[a]}return vr(this,"shape",o),o},checks:[]});return En(n,s)}function Mx(n,e){if(!li(e))throw new Error("Invalid input to extend: expected a plain object");const t=n._zod.def.checks;if(t&&t.length>0){const s=n._zod.def.shape;for(const o in e)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=kn(n._zod.def,{get shape(){const s={...n._zod.def.shape,...e};return vr(this,"shape",s),s}});return En(n,i)}function Nx(n,e){if(!li(e))throw new Error("Invalid input to safeExtend: expected a plain object");const t=kn(n._zod.def,{get shape(){const r={...n._zod.def.shape,...e};return vr(this,"shape",r),r}});return En(n,t)}function Ux(n,e){const t=kn(n._zod.def,{get shape(){const r={...n._zod.def.shape,...e._zod.def.shape};return vr(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return En(n,t)}function Fx(n,e,t){const i=e._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=kn(e._zod.def,{get shape(){const a=e._zod.def.shape,c={...a};if(t)for(const u in t){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);t[u]&&(c[u]=n?new n({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=n?new n({type:"optional",innerType:a[u]}):a[u];return vr(this,"shape",c),c},checks:[]});return En(e,o)}function Zx(n,e,t){const r=kn(e._zod.def,{get shape(){const i=e._zod.def.shape,s={...i};if(t)for(const o in t){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(s[o]=new n({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new n({type:"nonoptional",innerType:i[o]});return vr(this,"shape",s),s}});return En(e,r)}function Nr(n,e=0){var t;if(n.aborted===!0)return!0;for(let r=e;r<n.issues.length;r++)if(((t=n.issues[r])==null?void 0:t.continue)!==!0)return!0;return!1}function Ur(n,e){return e.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(n),t})}function Ao(n){return typeof n=="string"?n:n==null?void 0:n.message}function mn(n,e,t){var i,s,o,a,c,u;const r={...n,path:n.path??[]};if(!n.message){const d=Ao((o=(s=(i=n.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,n))??Ao((a=e==null?void 0:e.error)==null?void 0:a.call(e,n))??Ao((c=t.customError)==null?void 0:c.call(t,n))??Ao((u=t.localeError)==null?void 0:u.call(t,n))??"Invalid input";r.message=d}return delete r.inst,delete r.continue,e!=null&&e.reportInput||delete r.input,r}function Gu(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function is(...n){const[e,t,r]=n;return typeof e=="string"?{message:e,code:"custom",input:t,inst:r}:{...e}}const am=(n,e)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:e,enumerable:!1}),n.message=JSON.stringify(e,xc,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},lm=x("$ZodError",am),cm=x("$ZodError",am,{Parent:Error});function Hx(n,e=t=>t.message){const t={},r=[];for(const i of n.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):r.push(e(i));return{formErrors:r,fieldErrors:t}}function Bx(n,e=t=>t.message){const t={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>r({issues:o}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)t._errors.push(e(s));else{let o=t,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(e(s))):o[c]=o[c]||{_errors:[]},o=o[c],a++}}};return r(n),t}const Vu=n=>(e,t,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},o=e._zod.run({value:t,issues:[]},s);if(o instanceof Promise)throw new Zr;if(o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(c=>mn(c,s,gn())));throw sm(a,i==null?void 0:i.callee),a}return o.value},Wu=n=>async(e,t,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=e._zod.run({value:t,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(c=>mn(c,s,gn())));throw sm(a,i==null?void 0:i.callee),a}return o.value},Ga=n=>(e,t,r)=>{const i=r?{...r,async:!1}:{async:!1},s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new Zr;return s.issues.length?{success:!1,error:new(n??lm)(s.issues.map(o=>mn(o,i,gn())))}:{success:!0,data:s.value}},jx=Ga(cm),Va=n=>async(e,t,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=e._zod.run({value:t,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new n(s.issues.map(o=>mn(o,i,gn())))}:{success:!0,data:s.value}},Gx=Va(cm),Vx=n=>(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Vu(n)(e,t,i)},Wx=n=>(e,t,r)=>Vu(n)(e,t,r),qx=n=>async(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Wu(n)(e,t,i)},Yx=n=>async(e,t,r)=>Wu(n)(e,t,r),Kx=n=>(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ga(n)(e,t,i)},Jx=n=>(e,t,r)=>Ga(n)(e,t,r),Xx=n=>async(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Va(n)(e,t,i)},Qx=n=>async(e,t,r)=>Va(n)(e,t,r),eA=/^[cC][^\s-]{8,}$/,tA=/^[0-9a-z]+$/,nA=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,rA=/^[0-9a-vA-V]{20}$/,iA=/^[A-Za-z0-9]{27}$/,sA=/^[a-zA-Z0-9_-]{21}$/,oA=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,aA=/^([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})$/,vp=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,lA=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,cA="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function uA(){return new RegExp(cA,"u")}const hA=/^(?:(?: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])$/,dA=/^(([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}|:))$/,pA=/^((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])$/,fA=/^(([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])$/,gA=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,um=/^[A-Za-z0-9_-]*$/,mA=/^\+[1-9]\d{6,14}$/,hm="(?:(?:\\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])))",vA=new RegExp(`^${hm}$`);function dm(n){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${e}`:n.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${n.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function yA(n){return new RegExp(`^${dm(n)}$`)}function bA(n){const e=dm({precision:n.precision}),t=["Z"];n.local&&t.push(""),n.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${e}(?:${t.join("|")})`;return new RegExp(`^${hm}T(?:${r})$`)}const wA=n=>{const e=n?`[\\s\\S]{${(n==null?void 0:n.minimum)??0},${(n==null?void 0:n.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},SA=/^-?\d+$/,pm=/^-?\d+(?:\.\d+)?$/,_A=/^(?:true|false)$/i,kA=/^[^A-Z]*$/,EA=/^[^a-z]*$/,qe=x("$ZodCheck",(n,e)=>{var t;n._zod??(n._zod={}),n._zod.def=e,(t=n._zod).onattach??(t.onattach=[])}),fm={number:"number",bigint:"bigint",object:"date"},gm=x("$ZodCheckLessThan",(n,e)=>{qe.init(n,e);const t=fm[typeof e.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?i.maximum=e.value:i.exclusiveMaximum=e.value)}),n._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:t,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),mm=x("$ZodCheckGreaterThan",(n,e)=>{qe.init(n,e);const t=fm[typeof e.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?i.minimum=e.value:i.exclusiveMinimum=e.value)}),n._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:t,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),xA=x("$ZodCheckMultipleOf",(n,e)=>{qe.init(n,e),n._zod.onattach.push(t=>{var r;(r=t._zod.bag).multipleOf??(r.multipleOf=e.value)}),n._zod.check=t=>{if(typeof t.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof t.value=="bigint"?t.value%e.value===BigInt(0):Cx(t.value,e.value)===0)||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:e.value,input:t.value,inst:n,continue:!e.abort})}}),AA=x("$ZodCheckNumberFormat",(n,e)=>{var o;qe.init(n,e),e.format=e.format||"float64";const t=(o=e.format)==null?void 0:o.includes("int"),r=t?"int":"number",[i,s]=Ox[e.format];n._zod.onattach.push(a=>{const c=a._zod.bag;c.format=e.format,c.minimum=i,c.maximum=s,t&&(c.pattern=SA)}),n._zod.check=a=>{const c=a.value;if(t){if(!Number.isInteger(c)){a.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:c,inst:n});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!e.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!e.abort});return}}c<i&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!e.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:n,continue:!e.abort})}}),$A=x("$ZodCheckMaxLength",(n,e)=>{var t;qe.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Bu(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<i&&(r._zod.bag.maximum=e.maximum)}),n._zod.check=r=>{const i=r.value;if(i.length<=e.maximum)return;const o=Gu(i);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),TA=x("$ZodCheckMinLength",(n,e)=>{var t;qe.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Bu(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(r._zod.bag.minimum=e.minimum)}),n._zod.check=r=>{const i=r.value;if(i.length>=e.minimum)return;const o=Gu(i);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),CA=x("$ZodCheckLengthEquals",(n,e)=>{var t;qe.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Bu(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=e.length,i.maximum=e.length,i.length=e.length}),n._zod.check=r=>{const i=r.value,s=i.length;if(s===e.length)return;const o=Gu(i),a=s>e.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:r.value,inst:n,continue:!e.abort})}}),Wa=x("$ZodCheckStringFormat",(n,e)=>{var t,r;qe.init(n,e),n._zod.onattach.push(i=>{const s=i._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(t=n._zod).check??(t.check=i=>{e.pattern.lastIndex=0,!e.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:e.format,input:i.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:n,continue:!e.abort})}):(r=n._zod).check??(r.check=()=>{})}),IA=x("$ZodCheckRegex",(n,e)=>{Wa.init(n,e),n._zod.check=t=>{e.pattern.lastIndex=0,!e.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:e.pattern.toString(),inst:n,continue:!e.abort})}}),PA=x("$ZodCheckLowerCase",(n,e)=>{e.pattern??(e.pattern=kA),Wa.init(n,e)}),RA=x("$ZodCheckUpperCase",(n,e)=>{e.pattern??(e.pattern=EA),Wa.init(n,e)}),DA=x("$ZodCheckIncludes",(n,e)=>{qe.init(n,e);const t=ci(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position}}${t}`:t);e.pattern=r,n._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),n._zod.check=i=>{i.value.includes(e.includes,e.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:i.value,inst:n,continue:!e.abort})}}),OA=x("$ZodCheckStartsWith",(n,e)=>{qe.init(n,e);const t=new RegExp(`^${ci(e.prefix)}.*`);e.pattern??(e.pattern=t),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._zod.check=r=>{r.value.startsWith(e.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:r.value,inst:n,continue:!e.abort})}}),zA=x("$ZodCheckEndsWith",(n,e)=>{qe.init(n,e);const t=new RegExp(`.*${ci(e.suffix)}$`);e.pattern??(e.pattern=t),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._zod.check=r=>{r.value.endsWith(e.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:r.value,inst:n,continue:!e.abort})}}),LA=x("$ZodCheckOverwrite",(n,e)=>{qe.init(n,e),n._zod.check=t=>{t.value=e.tx(t.value)}});class MA{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const r=e.split(`
5
- `).filter(o=>o),i=Math.min(...r.map(o=>o.length-o.trimStart().length)),s=r.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const e=Function,t=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new e(...t,i.join(`
6
- `))}}const NA={major:4,minor:3,patch:6},de=x("$ZodType",(n,e)=>{var i;var t;n??(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=NA;const r=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&r.unshift(n);for(const s of r)for(const o of s._zod.onattach)o(n);if(r.length===0)(t=n._zod).deferred??(t.deferred=[]),(i=n._zod.deferred)==null||i.push(()=>{n._zod.run=n._zod.parse});else{const s=(a,c,u)=>{let d=Nr(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 Zr;if(p||$ instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await $,a.issues.length!==v&&(d||(d=Nr(a,v)))});else{if(a.issues.length===v)continue;d||(d=Nr(a,v))}}return p?p.then(()=>a):a},o=(a,c,u)=>{if(Nr(a))return a.aborted=!0,a;const d=s(c,r,u);if(d instanceof Promise){if(u.async===!1)throw new Zr;return d.then(p=>n._zod.parse(p,u))}return n._zod.parse(d,u)};n._zod.run=(a,c)=>{if(c.skipChecks)return n._zod.parse(a,c);if(c.direction==="backward"){const d=n._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(p=>o(p,a,c)):o(d,a,c)}const u=n._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new Zr;return u.then(d=>s(d,r,c))}return s(u,r,c)}}Q(n,"~standard",()=>({validate:s=>{var o;try{const a=jx(n,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return Gx(n,s).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),qu=x("$ZodString",(n,e)=>{var t;de.init(n,e),n._zod.pattern=[...((t=n==null?void 0:n._zod.bag)==null?void 0:t.patterns)??[]].pop()??wA(n._zod.bag),n._zod.parse=(r,i)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:n}),r}}),le=x("$ZodStringFormat",(n,e)=>{Wa.init(n,e),qu.init(n,e)}),UA=x("$ZodGUID",(n,e)=>{e.pattern??(e.pattern=aA),le.init(n,e)}),FA=x("$ZodUUID",(n,e)=>{if(e.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(r===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=vp(r))}else e.pattern??(e.pattern=vp());le.init(n,e)}),ZA=x("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=lA),le.init(n,e)}),HA=x("$ZodURL",(n,e)=>{le.init(n,e),n._zod.check=t=>{try{const r=t.value.trim(),i=new URL(r);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(i.hostname)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:t.value,inst:n,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:t.value,inst:n,continue:!e.abort})),e.normalize?t.value=i.href:t.value=r;return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort})}}}),BA=x("$ZodEmoji",(n,e)=>{e.pattern??(e.pattern=uA()),le.init(n,e)}),jA=x("$ZodNanoID",(n,e)=>{e.pattern??(e.pattern=sA),le.init(n,e)}),GA=x("$ZodCUID",(n,e)=>{e.pattern??(e.pattern=eA),le.init(n,e)}),VA=x("$ZodCUID2",(n,e)=>{e.pattern??(e.pattern=tA),le.init(n,e)}),WA=x("$ZodULID",(n,e)=>{e.pattern??(e.pattern=nA),le.init(n,e)}),qA=x("$ZodXID",(n,e)=>{e.pattern??(e.pattern=rA),le.init(n,e)}),YA=x("$ZodKSUID",(n,e)=>{e.pattern??(e.pattern=iA),le.init(n,e)}),KA=x("$ZodISODateTime",(n,e)=>{e.pattern??(e.pattern=bA(e)),le.init(n,e)}),JA=x("$ZodISODate",(n,e)=>{e.pattern??(e.pattern=vA),le.init(n,e)}),XA=x("$ZodISOTime",(n,e)=>{e.pattern??(e.pattern=yA(e)),le.init(n,e)}),QA=x("$ZodISODuration",(n,e)=>{e.pattern??(e.pattern=oA),le.init(n,e)}),e$=x("$ZodIPv4",(n,e)=>{e.pattern??(e.pattern=hA),le.init(n,e),n._zod.bag.format="ipv4"}),t$=x("$ZodIPv6",(n,e)=>{e.pattern??(e.pattern=dA),le.init(n,e),n._zod.bag.format="ipv6",n._zod.check=t=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:n,continue:!e.abort})}}}),n$=x("$ZodCIDRv4",(n,e)=>{e.pattern??(e.pattern=pA),le.init(n,e)}),r$=x("$ZodCIDRv6",(n,e)=>{e.pattern??(e.pattern=fA),le.init(n,e),n._zod.check=t=>{const r=t.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:n,continue:!e.abort})}}});function vm(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}const i$=x("$ZodBase64",(n,e)=>{e.pattern??(e.pattern=gA),le.init(n,e),n._zod.bag.contentEncoding="base64",n._zod.check=t=>{vm(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:n,continue:!e.abort})}});function s$(n){if(!um.test(n))return!1;const e=n.replace(/[-_]/g,r=>r==="-"?"+":"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return vm(t)}const o$=x("$ZodBase64URL",(n,e)=>{e.pattern??(e.pattern=um),le.init(n,e),n._zod.bag.contentEncoding="base64url",n._zod.check=t=>{s$(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:n,continue:!e.abort})}}),a$=x("$ZodE164",(n,e)=>{e.pattern??(e.pattern=mA),le.init(n,e)});function l$(n,e=null){try{const t=n.split(".");if(t.length!==3)return!1;const[r]=t;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&(!("alg"in i)||i.alg!==e))}catch{return!1}}const c$=x("$ZodJWT",(n,e)=>{le.init(n,e),n._zod.check=t=>{l$(t.value,e.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:n,continue:!e.abort})}}),ym=x("$ZodNumber",(n,e)=>{de.init(n,e),n._zod.pattern=n._zod.bag.pattern??pm,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=Number(t.value)}catch{}const i=t.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return t;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return t.issues.push({expected:"number",code:"invalid_type",input:i,inst:n,...s?{received:s}:{}}),t}}),u$=x("$ZodNumberFormat",(n,e)=>{AA.init(n,e),ym.init(n,e)}),h$=x("$ZodBoolean",(n,e)=>{de.init(n,e),n._zod.pattern=_A,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=!!t.value}catch{}const i=t.value;return typeof i=="boolean"||t.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:n}),t}}),d$=x("$ZodUnknown",(n,e)=>{de.init(n,e),n._zod.parse=t=>t}),p$=x("$ZodNever",(n,e)=>{de.init(n,e),n._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:n}),t)});function yp(n,e,t){n.issues.length&&e.issues.push(...Ur(t,n.issues)),e.value[t]=n.value}const f$=x("$ZodArray",(n,e)=>{de.init(n,e),n._zod.parse=(t,r)=>{const i=t.value;if(!Array.isArray(i))return t.issues.push({expected:"array",code:"invalid_type",input:i,inst:n}),t;t.value=Array(i.length);const s=[];for(let o=0;o<i.length;o++){const a=i[o],c=e.element._zod.run({value:a,issues:[]},r);c instanceof Promise?s.push(c.then(u=>yp(u,t,o))):yp(c,t,o)}return s.length?Promise.all(s).then(()=>t):t}});function ua(n,e,t,r,i){if(n.issues.length){if(i&&!(t in r))return;e.issues.push(...Ur(t,n.issues))}n.value===void 0?t in r&&(e.value[t]=void 0):e.value[t]=n.value}function bm(n){var r,i,s,o;const e=Object.keys(n.shape);for(const a of e)if(!((o=(s=(i=(r=n.shape)==null?void 0:r[a])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const t=Dx(n.shape);return{...n,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(t)}}function wm(n,e,t,r,i,s){const o=[],a=i.keySet,c=i.catchall._zod,u=c.def.type,d=c.optout==="optional";for(const 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?n.push(y.then(v=>ua(v,t,p,e,d))):ua(y,t,p,e,d)}return o.length&&t.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:s}),n.length?Promise.all(n).then(()=>t):t}const g$=x("$ZodObject",(n,e)=>{de.init(n,e);const t=Object.getOwnPropertyDescriptor(e,"shape");if(!(t!=null&&t.get)){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const c={...a};return Object.defineProperty(e,"shape",{value:c}),c}})}const r=Hu(()=>bm(e));Q(n._zod,"propValues",()=>{const a=e.shape,c={};for(const u in a){const d=a[u]._zod;if(d.values){c[u]??(c[u]=new Set);for(const p of d.values)c[u].add(p)}}return c});const i=ca,s=e.catchall;let o;n._zod.parse=(a,c)=>{o??(o=r.value);const u=a.value;if(!i(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:n}),a;a.value={};const d=[],p=o.shape;for(const y of o.keys){const v=p[y],$=v._zod.optout==="optional",E=v._zod.run({value:u[y],issues:[]},c);E instanceof Promise?d.push(E.then(I=>ua(I,a,y,u,$))):ua(E,a,y,u,$)}return s?wm(d,u,a,c,r.value,n):d.length?Promise.all(d).then(()=>a):a}}),m$=x("$ZodObjectJIT",(n,e)=>{g$.init(n,e);const t=n._zod.parse,r=Hu(()=>bm(e)),i=y=>{var G;const v=new MA(["shape","payload","ctx"]),$=r.value,E=O=>{const H=mp(O);return`shape[${H}]._zod.run({ value: input[${H}], issues: [] }, ctx)`};v.write("const input = payload.value;");const I=Object.create(null);let Z=0;for(const O of $.keys)I[O]=`key_${Z++}`;v.write("const newResult = {};");for(const O of $.keys){const H=I[O],N=mp(O),ce=y[O],ue=((G=ce==null?void 0:ce._zod)==null?void 0:G.optout)==="optional";v.write(`const ${H} = ${E(O)};`),ue?v.write(`
7
- if (${H}.issues.length) {
8
- if (${N} in input) {
9
- payload.issues = payload.issues.concat(${H}.issues.map(iss => ({
10
- ...iss,
11
- path: iss.path ? [${N}, ...iss.path] : [${N}]
12
- })));
13
- }
14
- }
15
-
16
- if (${H}.value === undefined) {
17
- if (${N} in input) {
18
- newResult[${N}] = undefined;
19
- }
20
- } else {
21
- newResult[${N}] = ${H}.value;
22
- }
23
-
24
- `):v.write(`
25
- if (${H}.issues.length) {
26
- payload.issues = payload.issues.concat(${H}.issues.map(iss => ({
27
- ...iss,
28
- path: iss.path ? [${N}, ...iss.path] : [${N}]
29
- })));
30
- }
31
-
32
- if (${H}.value === undefined) {
33
- if (${N} in input) {
34
- newResult[${N}] = undefined;
35
- }
36
- } else {
37
- newResult[${N}] = ${H}.value;
38
- }
39
-
40
- `)}v.write("payload.value = newResult;"),v.write("return payload;");const P=v.compile();return(O,H)=>P(y,O,H)};let s;const o=ca,a=!rm.jitless,u=a&&Px.value,d=e.catchall;let p;n._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?wm([],$,y,v,p,n):y):t(y,v):(y.issues.push({expected:"object",code:"invalid_type",input:$,inst:n}),y)}});function bp(n,e,t,r){for(const s of n)if(s.issues.length===0)return e.value=s.value,e;const i=n.filter(s=>!Nr(s));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:n.map(s=>s.issues.map(o=>mn(o,r,gn())))}),e)}const v$=x("$ZodUnion",(n,e)=>{de.init(n,e),Q(n._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Q(n._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Q(n._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),Q(n._zod,"pattern",()=>{if(e.options.every(i=>i._zod.pattern)){const i=e.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>ju(s.source)).join("|")})$`)}});const t=e.options.length===1,r=e.options[0]._zod.run;n._zod.parse=(i,s)=>{if(t)return r(i,s);let o=!1;const a=[];for(const c of e.options){const u=c._zod.run({value:i.value,issues:[]},s);if(u instanceof Promise)a.push(u),o=!0;else{if(u.issues.length===0)return u;a.push(u)}}return o?Promise.all(a).then(c=>bp(c,i,n,s)):bp(a,i,n,s)}}),y$=x("$ZodIntersection",(n,e)=>{de.init(n,e),n._zod.parse=(t,r)=>{const i=t.value,s=e.left._zod.run({value:i,issues:[]},r),o=e.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([c,u])=>wp(t,c,u)):wp(t,s,o)}});function Ac(n,e){if(n===e)return{valid:!0,data:n};if(n instanceof Date&&e instanceof Date&&+n==+e)return{valid:!0,data:n};if(li(n)&&li(e)){const t=Object.keys(e),r=Object.keys(n).filter(s=>t.indexOf(s)!==-1),i={...n,...e};for(const s of r){const o=Ac(n[s],e[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let r=0;r<n.length;r++){const i=n[r],s=e[r],o=Ac(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};t.push(o.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function wp(n,e,t){const r=new Map;let i;for(const a of e.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else n.issues.push(a);for(const a of t.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else n.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&n.issues.push({...i,keys:s}),Nr(n))return n;const o=Ac(e.value,t.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return n.value=o.data,n}const b$=x("$ZodRecord",(n,e)=>{de.init(n,e),n._zod.parse=(t,r)=>{const i=t.value;if(!li(i))return t.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),t;const s=[],o=e.keyType._zod.values;if(o){t.value={};const a=new Set;for(const u of o)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const d=e.valueType._zod.run({value:i[u],issues:[]},r);d instanceof Promise?s.push(d.then(p=>{p.issues.length&&t.issues.push(...Ur(u,p.issues)),t.value[u]=p.value})):(d.issues.length&&t.issues.push(...Ur(u,d.issues)),t.value[u]=d.value)}let c;for(const u in i)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&t.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:c})}else{t.value={};for(const a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let c=e.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&pm.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"?t.value[a]=i[a]:t.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(p=>mn(p,r,gn())),input:a,path:[a],inst:n});continue}const d=e.valueType._zod.run({value:i[a],issues:[]},r);d instanceof Promise?s.push(d.then(p=>{p.issues.length&&t.issues.push(...Ur(a,p.issues)),t.value[c.value]=p.value})):(d.issues.length&&t.issues.push(...Ur(a,d.issues)),t.value[c.value]=d.value)}}return s.length?Promise.all(s).then(()=>t):t}}),w$=x("$ZodEnum",(n,e)=>{de.init(n,e);const t=im(e.entries),r=new Set(t);n._zod.values=r,n._zod.pattern=new RegExp(`^(${t.filter(i=>Rx.has(typeof i)).map(i=>typeof i=="string"?ci(i):i.toString()).join("|")})$`),n._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:t,input:o,inst:n}),i}}),S$=x("$ZodLiteral",(n,e)=>{if(de.init(n,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const t=new Set(e.values);n._zod.values=t,n._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?ci(r):r?ci(r.toString()):String(r)).join("|")})$`),n._zod.parse=(r,i)=>{const s=r.value;return t.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:n}),r}}),_$=x("$ZodTransform",(n,e)=>{de.init(n,e),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new nm(n.constructor.name);const i=e.transform(t.value,t);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(t.value=o,t));if(i instanceof Promise)throw new Zr;return t.value=i,t}});function Sp(n,e){return n.issues.length&&e===void 0?{issues:[],value:void 0}:n}const Sm=x("$ZodOptional",(n,e)=>{de.init(n,e),n._zod.optin="optional",n._zod.optout="optional",Q(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),Q(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${ju(t.source)})?$`):void 0}),n._zod.parse=(t,r)=>{if(e.innerType._zod.optin==="optional"){const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>Sp(s,t.value)):Sp(i,t.value)}return t.value===void 0?t:e.innerType._zod.run(t,r)}}),k$=x("$ZodExactOptional",(n,e)=>{Sm.init(n,e),Q(n._zod,"values",()=>e.innerType._zod.values),Q(n._zod,"pattern",()=>e.innerType._zod.pattern),n._zod.parse=(t,r)=>e.innerType._zod.run(t,r)}),E$=x("$ZodNullable",(n,e)=>{de.init(n,e),Q(n._zod,"optin",()=>e.innerType._zod.optin),Q(n._zod,"optout",()=>e.innerType._zod.optout),Q(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${ju(t.source)}|null)$`):void 0}),Q(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),n._zod.parse=(t,r)=>t.value===null?t:e.innerType._zod.run(t,r)}),x$=x("$ZodDefault",(n,e)=>{de.init(n,e),n._zod.optin="optional",Q(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);if(t.value===void 0)return t.value=e.defaultValue,t;const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>_p(s,e)):_p(i,e)}});function _p(n,e){return n.value===void 0&&(n.value=e.defaultValue),n}const A$=x("$ZodPrefault",(n,e)=>{de.init(n,e),n._zod.optin="optional",Q(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>(r.direction==="backward"||t.value===void 0&&(t.value=e.defaultValue),e.innerType._zod.run(t,r))}),$$=x("$ZodNonOptional",(n,e)=>{de.init(n,e),Q(n._zod,"values",()=>{const t=e.innerType._zod.values;return t?new Set([...t].filter(r=>r!==void 0)):void 0}),n._zod.parse=(t,r)=>{const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>kp(s,n)):kp(i,n)}});function kp(n,e){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:e}),n}const T$=x("$ZodCatch",(n,e)=>{de.init(n,e),Q(n._zod,"optin",()=>e.innerType._zod.optin),Q(n._zod,"optout",()=>e.innerType._zod.optout),Q(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>(t.value=s.value,s.issues.length&&(t.value=e.catchValue({...t,error:{issues:s.issues.map(o=>mn(o,r,gn()))},input:t.value}),t.issues=[]),t)):(t.value=i.value,i.issues.length&&(t.value=e.catchValue({...t,error:{issues:i.issues.map(s=>mn(s,r,gn()))},input:t.value}),t.issues=[]),t)}}),C$=x("$ZodPipe",(n,e)=>{de.init(n,e),Q(n._zod,"values",()=>e.in._zod.values),Q(n._zod,"optin",()=>e.in._zod.optin),Q(n._zod,"optout",()=>e.out._zod.optout),Q(n._zod,"propValues",()=>e.in._zod.propValues),n._zod.parse=(t,r)=>{if(r.direction==="backward"){const s=e.out._zod.run(t,r);return s instanceof Promise?s.then(o=>$o(o,e.in,r)):$o(s,e.in,r)}const i=e.in._zod.run(t,r);return i instanceof Promise?i.then(s=>$o(s,e.out,r)):$o(i,e.out,r)}});function $o(n,e,t){return n.issues.length?(n.aborted=!0,n):e._zod.run({value:n.value,issues:n.issues},t)}const I$=x("$ZodReadonly",(n,e)=>{de.init(n,e),Q(n._zod,"propValues",()=>e.innerType._zod.propValues),Q(n._zod,"values",()=>e.innerType._zod.values),Q(n._zod,"optin",()=>{var t,r;return(r=(t=e.innerType)==null?void 0:t._zod)==null?void 0:r.optin}),Q(n._zod,"optout",()=>{var t,r;return(r=(t=e.innerType)==null?void 0:t._zod)==null?void 0:r.optout}),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(Ep):Ep(i)}});function Ep(n){return n.value=Object.freeze(n.value),n}const P$=x("$ZodCustom",(n,e)=>{qe.init(n,e),de.init(n,e),n._zod.parse=(t,r)=>t,n._zod.check=t=>{const r=t.value,i=e.fn(r);if(i instanceof Promise)return i.then(s=>xp(s,t,r,n));xp(i,t,r,n)}});function xp(n,e,t,r){if(!n){const i={code:"custom",input:t,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),e.issues.push(is(i))}}var Ap;class R${constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const r=t[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};delete r.id;const i={...r,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function D$(){return new R$}(Ap=globalThis).__zod_globalRegistry??(Ap.__zod_globalRegistry=D$());const Bi=globalThis.__zod_globalRegistry;function O$(n,e){return new n({type:"string",...z(e)})}function z$(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...z(e)})}function $p(n,e){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...z(e)})}function L$(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...z(e)})}function M$(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(e)})}function N$(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(e)})}function U$(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(e)})}function F$(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...z(e)})}function Z$(n,e){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...z(e)})}function H$(n,e){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(e)})}function B$(n,e){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...z(e)})}function j$(n,e){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(e)})}function G$(n,e){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...z(e)})}function V$(n,e){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...z(e)})}function W$(n,e){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(e)})}function q$(n,e){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(e)})}function Y$(n,e){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(e)})}function K$(n,e){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(e)})}function J$(n,e){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(e)})}function X$(n,e){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...z(e)})}function Q$(n,e){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...z(e)})}function e1(n,e){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...z(e)})}function t1(n,e){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...z(e)})}function n1(n,e){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(e)})}function r1(n,e){return new n({type:"string",format:"date",check:"string_format",...z(e)})}function i1(n,e){return new n({type:"string",format:"time",check:"string_format",precision:null,...z(e)})}function s1(n,e){return new n({type:"string",format:"duration",check:"string_format",...z(e)})}function o1(n,e){return new n({type:"number",checks:[],...z(e)})}function a1(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...z(e)})}function l1(n,e){return new n({type:"boolean",...z(e)})}function c1(n){return new n({type:"unknown"})}function u1(n,e){return new n({type:"never",...z(e)})}function Tp(n,e){return new gm({check:"less_than",...z(e),value:n,inclusive:!1})}function jl(n,e){return new gm({check:"less_than",...z(e),value:n,inclusive:!0})}function Cp(n,e){return new mm({check:"greater_than",...z(e),value:n,inclusive:!1})}function Gl(n,e){return new mm({check:"greater_than",...z(e),value:n,inclusive:!0})}function Ip(n,e){return new xA({check:"multiple_of",...z(e),value:n})}function _m(n,e){return new $A({check:"max_length",...z(e),maximum:n})}function ha(n,e){return new TA({check:"min_length",...z(e),minimum:n})}function km(n,e){return new CA({check:"length_equals",...z(e),length:n})}function h1(n,e){return new IA({check:"string_format",format:"regex",...z(e),pattern:n})}function d1(n){return new PA({check:"string_format",format:"lowercase",...z(n)})}function p1(n){return new RA({check:"string_format",format:"uppercase",...z(n)})}function f1(n,e){return new DA({check:"string_format",format:"includes",...z(e),includes:n})}function g1(n,e){return new OA({check:"string_format",format:"starts_with",...z(e),prefix:n})}function m1(n,e){return new zA({check:"string_format",format:"ends_with",...z(e),suffix:n})}function Si(n){return new LA({check:"overwrite",tx:n})}function v1(n){return Si(e=>e.normalize(n))}function y1(){return Si(n=>n.trim())}function b1(){return Si(n=>n.toLowerCase())}function w1(){return Si(n=>n.toUpperCase())}function S1(){return Si(n=>Ix(n))}function _1(n,e,t){return new n({type:"array",element:e,...z(t)})}function k1(n,e,t){return new n({type:"custom",check:"custom",fn:e,...z(t)})}function E1(n){const e=x1(t=>(t.addIssue=r=>{if(typeof r=="string")t.issues.push(is(r,t.value,e._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=t.value),i.inst??(i.inst=e),i.continue??(i.continue=!e._zod.def.abort),t.issues.push(is(i))}},n(t.value,t)));return e}function x1(n,e){const t=new qe({check:"custom",...z(e)});return t._zod.check=n,t}function Em(n){let e=(n==null?void 0:n.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:n.processors??{},metadataRegistry:(n==null?void 0:n.metadata)??Bi,target:e,unrepresentable:(n==null?void 0:n.unrepresentable)??"throw",override:(n==null?void 0:n.override)??(()=>{}),io:(n==null?void 0:n.io)??"output",counter:0,seen:new Map,cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",external:(n==null?void 0:n.external)??void 0}}function ye(n,e,t={path:[],schemaPath:[]}){var d,p;var r;const i=n._zod.def,s=e.seen.get(n);if(s)return s.count++,t.schemaPath.includes(n)&&(s.cycle=t.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:t.path};e.seen.set(n,o);const a=(p=(d=n._zod).toJSONSchema)==null?void 0:p.call(d);if(a)o.schema=a;else{const y={...t,schemaPath:[...t.schemaPath,n],path:t.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(e,o.schema,y);else{const $=o.schema,E=e.processors[i.type];if(!E)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);E(n,e,$,y)}const v=n._zod.parent;v&&(o.ref||(o.ref=v),ye(v,e,y),e.seen.get(v).isParent=!0)}const c=e.metadataRegistry.get(n);return c&&Object.assign(o.schema,c),e.io==="input"&&Le(n)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(n).schema}function xm(n,e){var o,a,c,u;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const d of n.seen.entries()){const p=(o=n.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 E;const p=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const I=(E=n.external.registry.get(d[0]))==null?void 0:E.id,Z=n.external.uri??(G=>G);if(I)return{ref:Z(I)};const P=d[1].defId??d[1].schema.id??`schema${n.counter++}`;return d[1].defId=P,{defId:P,ref:`${Z("__shared")}#/${p}/${P}`}}if(d[1]===t)return{ref:"#"};const v=`#/${p}/`,$=d[1].schema.id??`__schema${n.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 E in $)delete $[E];$.$ref=y};if(n.cycles==="throw")for(const d of n.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 n.seen.entries()){const p=d[1];if(e===d[0]){s(d);continue}if(n.external){const v=(c=n.external.registry.get(d[0]))==null?void 0:c.id;if(e!==d[0]&&v){s(d);continue}}if((u=n.metadataRegistry.get(d[0]))==null?void 0:u.id){s(d);continue}if(p.cycle){s(d);continue}if(p.count>1&&n.reused==="ref"){s(d);continue}}}function Am(n,e){var o,a,c;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const d=n.seen.get(u);if(d.ref===null)return;const p=d.def??d.schema,y={...p},v=d.ref;if(d.ref=null,v){r(v);const E=n.seen.get(v),I=E.schema;if(I.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.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&&E.def)for(const P in p)P==="$ref"||P==="allOf"||P in E.def&&JSON.stringify(p[P])===JSON.stringify(E.def[P])&&delete p[P]}const $=u._zod.parent;if($&&$!==v){r($);const E=n.seen.get($);if(E!=null&&E.schema.$ref&&(p.$ref=E.schema.$ref,E.def))for(const I in p)I==="$ref"||I==="allOf"||I in E.def&&JSON.stringify(p[I])===JSON.stringify(E.def[I])&&delete p[I]}n.override({zodSchema:u,jsonSchema:p,path:d.path??[]})};for(const u of[...n.seen.entries()].reverse())r(u[0]);const i={};if(n.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":n.target,(o=n.external)!=null&&o.uri){const u=(a=n.external.registry.get(e))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=n.external.uri(u)}Object.assign(i,t.def??t.schema);const s=((c=n.external)==null?void 0:c.defs)??{};for(const u of n.seen.entries()){const d=u[1];d.def&&d.defId&&(s[d.defId]=d.def)}n.external||Object.keys(s).length>0&&(n.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...e["~standard"],jsonSchema:{input:da(e,"input",n.processors),output:da(e,"output",n.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Le(n,e){const t=e??{seen:new Set};if(t.seen.has(n))return!1;t.seen.add(n);const r=n._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Le(r.element,t);if(r.type==="set")return Le(r.valueType,t);if(r.type==="lazy")return Le(r.getter(),t);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Le(r.innerType,t);if(r.type==="intersection")return Le(r.left,t)||Le(r.right,t);if(r.type==="record"||r.type==="map")return Le(r.keyType,t)||Le(r.valueType,t);if(r.type==="pipe")return Le(r.in,t)||Le(r.out,t);if(r.type==="object"){for(const i in r.shape)if(Le(r.shape[i],t))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(Le(i,t))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(Le(i,t))return!0;return!!(r.rest&&Le(r.rest,t))}return!1}const A1=(n,e={})=>t=>{const r=Em({...t,processors:e});return ye(n,r),xm(r,n),Am(r,n)},da=(n,e,t={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=Em({...i??{},target:s,io:e,processors:t});return ye(n,o),xm(o,n),Am(o,n)},$1={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},T1=(n,e,t,r)=>{const i=t;i.type="string";const{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:u}=n._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=$1[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}))])}},C1=(n,e,t,r)=>{const i=t,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=n._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof d=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.minimum=d,i.exclusiveMinimum=!0):i.exclusiveMinimum=d),typeof s=="number"&&(i.minimum=s,typeof d=="number"&&e.target!=="draft-04"&&(d>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof o=="number"&&(i.maximum=o,typeof u=="number"&&e.target!=="draft-04"&&(u<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},I1=(n,e,t,r)=>{t.type="boolean"},P1=(n,e,t,r)=>{t.not={}},R1=(n,e,t,r)=>{},D1=(n,e,t,r)=>{const i=n._zod.def,s=im(i.entries);s.every(o=>typeof o=="number")&&(t.type="number"),s.every(o=>typeof o=="string")&&(t.type="string"),t.enum=s},O1=(n,e,t,r)=>{const i=n._zod.def,s=[];for(const o of i.values)if(o===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];t.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?t.enum=[o]:t.const=o}else s.every(o=>typeof o=="number")&&(t.type="number"),s.every(o=>typeof o=="string")&&(t.type="string"),s.every(o=>typeof o=="boolean")&&(t.type="boolean"),s.every(o=>o===null)&&(t.type="null"),t.enum=s},z1=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},L1=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},M1=(n,e,t,r)=>{const i=t,s=n._zod.def,{minimum:o,maximum:a}=n._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=ye(s.element,e,{...r,path:[...r.path,"items"]})},N1=(n,e,t,r)=>{var u;const i=t,s=n._zod.def;i.type="object",i.properties={};const o=s.shape;for(const d in o)i.properties[d]=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)},U1=(n,e,t,r)=>{const i=n._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>ye(a,e,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?t.oneOf=o:t.anyOf=o},F1=(n,e,t,r)=>{const i=n._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]];t.allOf=c},Z1=(n,e,t,r)=>{const i=t,s=n._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag,c=a==null?void 0:a.patterns;if(s.mode==="loose"&&c&&c.size>0){const d=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)}},H1=(n,e,t,r)=>{const i=n._zod.def,s=ye(i.innerType,e,r),o=e.seen.get(n);e.target==="openapi-3.0"?(o.ref=i.innerType,t.nullable=!0):t.anyOf=[s,{type:"null"}]},B1=(n,e,t,r)=>{const i=n._zod.def;ye(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType},j1=(n,e,t,r)=>{const i=n._zod.def;ye(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,t.default=JSON.parse(JSON.stringify(i.defaultValue))},G1=(n,e,t,r)=>{const i=n._zod.def;ye(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,e.io==="input"&&(t._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},V1=(n,e,t,r)=>{const i=n._zod.def;ye(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}t.default=o},W1=(n,e,t,r)=>{const i=n._zod.def,s=e.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;ye(s,e,r);const o=e.seen.get(n);o.ref=s},q1=(n,e,t,r)=>{const i=n._zod.def;ye(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,t.readOnly=!0},$m=(n,e,t,r)=>{const i=n._zod.def;ye(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType},Y1=x("ZodISODateTime",(n,e)=>{KA.init(n,e),fe.init(n,e)});function K1(n){return n1(Y1,n)}const J1=x("ZodISODate",(n,e)=>{JA.init(n,e),fe.init(n,e)});function X1(n){return r1(J1,n)}const Q1=x("ZodISOTime",(n,e)=>{XA.init(n,e),fe.init(n,e)});function eT(n){return i1(Q1,n)}const tT=x("ZodISODuration",(n,e)=>{QA.init(n,e),fe.init(n,e)});function nT(n){return s1(tT,n)}const Tm=(n,e)=>{lm.init(n,e),n.name="ZodError",Object.defineProperties(n,{format:{value:t=>Bx(n,t)},flatten:{value:t=>Hx(n,t)},addIssue:{value:t=>{n.issues.push(t),n.message=JSON.stringify(n.issues,xc,2)}},addIssues:{value:t=>{n.issues.push(...t),n.message=JSON.stringify(n.issues,xc,2)}},isEmpty:{get(){return n.issues.length===0}}})},Pp=x("ZodError",Tm),at=x("ZodError",Tm,{Parent:Error}),rT=Vu(at),iT=Wu(at),sT=Ga(at),oT=Va(at),aT=Vx(at),lT=Wx(at),cT=qx(at),uT=Yx(at),hT=Kx(at),dT=Jx(at),pT=Xx(at),fT=Qx(at),pe=x("ZodType",(n,e)=>(de.init(n,e),Object.assign(n["~standard"],{jsonSchema:{input:da(n,"input"),output:da(n,"output")}}),n.toJSONSchema=A1(n,{}),n.def=e,n.type=e.type,Object.defineProperty(n,"_def",{value:e}),n.check=(...t)=>n.clone(kn(e,{checks:[...e.checks??[],...t.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),n.with=n.check,n.clone=(t,r)=>En(n,t,r),n.brand=()=>n,n.register=(t,r)=>(t.add(n,r),n),n.parse=(t,r)=>rT(n,t,r,{callee:n.parse}),n.safeParse=(t,r)=>sT(n,t,r),n.parseAsync=async(t,r)=>iT(n,t,r,{callee:n.parseAsync}),n.safeParseAsync=async(t,r)=>oT(n,t,r),n.spa=n.safeParseAsync,n.encode=(t,r)=>aT(n,t,r),n.decode=(t,r)=>lT(n,t,r),n.encodeAsync=async(t,r)=>cT(n,t,r),n.decodeAsync=async(t,r)=>uT(n,t,r),n.safeEncode=(t,r)=>hT(n,t,r),n.safeDecode=(t,r)=>dT(n,t,r),n.safeEncodeAsync=async(t,r)=>pT(n,t,r),n.safeDecodeAsync=async(t,r)=>fT(n,t,r),n.refine=(t,r)=>n.check(sC(t,r)),n.superRefine=t=>n.check(oC(t)),n.overwrite=t=>n.check(Si(t)),n.optional=()=>Op(n),n.exactOptional=()=>VT(n),n.nullable=()=>zp(n),n.nullish=()=>Op(zp(n)),n.nonoptional=t=>XT(n,t),n.array=()=>D(n),n.or=t=>B([n,t]),n.and=t=>qa(n,t),n.transform=t=>Lp(n,jT(t)),n.default=t=>YT(n,t),n.prefault=t=>JT(n,t),n.catch=t=>eC(n,t),n.pipe=t=>Lp(n,t),n.readonly=()=>rC(n),n.describe=t=>{const r=n.clone();return Bi.add(r,{description:t}),r},Object.defineProperty(n,"description",{get(){var t;return(t=Bi.get(n))==null?void 0:t.description},configurable:!0}),n.meta=(...t)=>{if(t.length===0)return Bi.get(n);const r=n.clone();return Bi.add(r,t[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=t=>t(n),n)),Cm=x("_ZodString",(n,e)=>{qu.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(r,i,s)=>T1(n,r,i);const t=n._zod.bag;n.format=t.format??null,n.minLength=t.minimum??null,n.maxLength=t.maximum??null,n.regex=(...r)=>n.check(h1(...r)),n.includes=(...r)=>n.check(f1(...r)),n.startsWith=(...r)=>n.check(g1(...r)),n.endsWith=(...r)=>n.check(m1(...r)),n.min=(...r)=>n.check(ha(...r)),n.max=(...r)=>n.check(_m(...r)),n.length=(...r)=>n.check(km(...r)),n.nonempty=(...r)=>n.check(ha(1,...r)),n.lowercase=r=>n.check(d1(r)),n.uppercase=r=>n.check(p1(r)),n.trim=()=>n.check(y1()),n.normalize=(...r)=>n.check(v1(...r)),n.toLowerCase=()=>n.check(b1()),n.toUpperCase=()=>n.check(w1()),n.slugify=()=>n.check(S1())}),gT=x("ZodString",(n,e)=>{qu.init(n,e),Cm.init(n,e),n.email=t=>n.check(z$(mT,t)),n.url=t=>n.check(F$(vT,t)),n.jwt=t=>n.check(t1(RT,t)),n.emoji=t=>n.check(Z$(yT,t)),n.guid=t=>n.check($p(Rp,t)),n.uuid=t=>n.check(L$(To,t)),n.uuidv4=t=>n.check(M$(To,t)),n.uuidv6=t=>n.check(N$(To,t)),n.uuidv7=t=>n.check(U$(To,t)),n.nanoid=t=>n.check(H$(bT,t)),n.guid=t=>n.check($p(Rp,t)),n.cuid=t=>n.check(B$(wT,t)),n.cuid2=t=>n.check(j$(ST,t)),n.ulid=t=>n.check(G$(_T,t)),n.base64=t=>n.check(X$(CT,t)),n.base64url=t=>n.check(Q$(IT,t)),n.xid=t=>n.check(V$(kT,t)),n.ksuid=t=>n.check(W$(ET,t)),n.ipv4=t=>n.check(q$(xT,t)),n.ipv6=t=>n.check(Y$(AT,t)),n.cidrv4=t=>n.check(K$($T,t)),n.cidrv6=t=>n.check(J$(TT,t)),n.e164=t=>n.check(e1(PT,t)),n.datetime=t=>n.check(K1(t)),n.date=t=>n.check(X1(t)),n.time=t=>n.check(eT(t)),n.duration=t=>n.check(nT(t))});function h(n){return O$(gT,n)}const fe=x("ZodStringFormat",(n,e)=>{le.init(n,e),Cm.init(n,e)}),mT=x("ZodEmail",(n,e)=>{ZA.init(n,e),fe.init(n,e)}),Rp=x("ZodGUID",(n,e)=>{UA.init(n,e),fe.init(n,e)}),To=x("ZodUUID",(n,e)=>{FA.init(n,e),fe.init(n,e)}),vT=x("ZodURL",(n,e)=>{HA.init(n,e),fe.init(n,e)}),yT=x("ZodEmoji",(n,e)=>{BA.init(n,e),fe.init(n,e)}),bT=x("ZodNanoID",(n,e)=>{jA.init(n,e),fe.init(n,e)}),wT=x("ZodCUID",(n,e)=>{GA.init(n,e),fe.init(n,e)}),ST=x("ZodCUID2",(n,e)=>{VA.init(n,e),fe.init(n,e)}),_T=x("ZodULID",(n,e)=>{WA.init(n,e),fe.init(n,e)}),kT=x("ZodXID",(n,e)=>{qA.init(n,e),fe.init(n,e)}),ET=x("ZodKSUID",(n,e)=>{YA.init(n,e),fe.init(n,e)}),xT=x("ZodIPv4",(n,e)=>{e$.init(n,e),fe.init(n,e)}),AT=x("ZodIPv6",(n,e)=>{t$.init(n,e),fe.init(n,e)}),$T=x("ZodCIDRv4",(n,e)=>{n$.init(n,e),fe.init(n,e)}),TT=x("ZodCIDRv6",(n,e)=>{r$.init(n,e),fe.init(n,e)}),CT=x("ZodBase64",(n,e)=>{i$.init(n,e),fe.init(n,e)}),IT=x("ZodBase64URL",(n,e)=>{o$.init(n,e),fe.init(n,e)}),PT=x("ZodE164",(n,e)=>{a$.init(n,e),fe.init(n,e)}),RT=x("ZodJWT",(n,e)=>{c$.init(n,e),fe.init(n,e)}),Im=x("ZodNumber",(n,e)=>{ym.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(r,i,s)=>C1(n,r,i),n.gt=(r,i)=>n.check(Cp(r,i)),n.gte=(r,i)=>n.check(Gl(r,i)),n.min=(r,i)=>n.check(Gl(r,i)),n.lt=(r,i)=>n.check(Tp(r,i)),n.lte=(r,i)=>n.check(jl(r,i)),n.max=(r,i)=>n.check(jl(r,i)),n.int=r=>n.check(Dp(r)),n.safe=r=>n.check(Dp(r)),n.positive=r=>n.check(Cp(0,r)),n.nonnegative=r=>n.check(Gl(0,r)),n.negative=r=>n.check(Tp(0,r)),n.nonpositive=r=>n.check(jl(0,r)),n.multipleOf=(r,i)=>n.check(Ip(r,i)),n.step=(r,i)=>n.check(Ip(r,i)),n.finite=()=>n;const t=n._zod.bag;n.minValue=Math.max(t.minimum??Number.NEGATIVE_INFINITY,t.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(t.maximum??Number.POSITIVE_INFINITY,t.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(t.format??"").includes("int")||Number.isSafeInteger(t.multipleOf??.5),n.isFinite=!0,n.format=t.format??null});function F(n){return o1(Im,n)}const DT=x("ZodNumberFormat",(n,e)=>{u$.init(n,e),Im.init(n,e)});function Dp(n){return a1(DT,n)}const OT=x("ZodBoolean",(n,e)=>{h$.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>I1(n,t,r)});function Ee(n){return l1(OT,n)}const zT=x("ZodUnknown",(n,e)=>{d$.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>R1()});function w(){return c1(zT)}const LT=x("ZodNever",(n,e)=>{p$.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>P1(n,t,r)});function MT(n){return u1(LT,n)}const NT=x("ZodArray",(n,e)=>{f$.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>M1(n,t,r,i),n.element=e.element,n.min=(t,r)=>n.check(ha(t,r)),n.nonempty=t=>n.check(ha(1,t)),n.max=(t,r)=>n.check(_m(t,r)),n.length=(t,r)=>n.check(km(t,r)),n.unwrap=()=>n.element});function D(n,e){return _1(NT,n,e)}const Pm=x("ZodObject",(n,e)=>{m$.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>N1(n,t,r,i),Q(n,"shape",()=>e.shape),n.keyof=()=>pa(Object.keys(n._zod.def.shape)),n.catchall=t=>n.clone({...n._zod.def,catchall:t}),n.passthrough=()=>n.clone({...n._zod.def,catchall:w()}),n.loose=()=>n.clone({...n._zod.def,catchall:w()}),n.strict=()=>n.clone({...n._zod.def,catchall:MT()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=t=>Mx(n,t),n.safeExtend=t=>Nx(n,t),n.merge=t=>Ux(n,t),n.pick=t=>zx(n,t),n.omit=t=>Lx(n,t),n.partial=(...t)=>Fx(Dm,n,t[0]),n.required=(...t)=>Zx(Om,n,t[0])});function Rm(n,e){const t={type:"object",shape:n??{},...z(e)};return new Pm(t)}function f(n,e){return new Pm({type:"object",shape:n,catchall:w(),...z(e)})}const UT=x("ZodUnion",(n,e)=>{v$.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>U1(n,t,r,i),n.options=e.options});function B(n,e){return new UT({type:"union",options:n,...z(e)})}const FT=x("ZodIntersection",(n,e)=>{y$.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>F1(n,t,r,i)});function qa(n,e){return new FT({type:"intersection",left:n,right:e})}const ZT=x("ZodRecord",(n,e)=>{b$.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Z1(n,t,r,i),n.keyType=e.keyType,n.valueType=e.valueType});function _(n,e,t){return new ZT({type:"record",keyType:n,valueType:e,...z(t)})}const $c=x("ZodEnum",(n,e)=>{w$.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(r,i,s)=>D1(n,r,i),n.enum=e.entries,n.options=Object.values(e.entries);const t=new Set(Object.keys(e.entries));n.extract=(r,i)=>{const s={};for(const o of r)if(t.has(o))s[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new $c({...e,checks:[],...z(i),entries:s})},n.exclude=(r,i)=>{const s={...e.entries};for(const o of r)if(t.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new $c({...e,checks:[],...z(i),entries:s})}});function pa(n,e){const t=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new $c({type:"enum",entries:t,...z(e)})}const HT=x("ZodLiteral",(n,e)=>{S$.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>O1(n,t,r),n.values=new Set(e.values),Object.defineProperty(n,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function A(n,e){return new HT({type:"literal",values:Array.isArray(n)?n:[n],...z(e)})}const BT=x("ZodTransform",(n,e)=>{_$.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>L1(n,t),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new nm(n.constructor.name);t.addIssue=s=>{if(typeof s=="string")t.issues.push(is(s,t.value,e));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=t.value),o.inst??(o.inst=n),t.issues.push(is(o))}};const i=e.transform(t.value,t);return i instanceof Promise?i.then(s=>(t.value=s,t)):(t.value=i,t)}});function jT(n){return new BT({type:"transform",transform:n})}const Dm=x("ZodOptional",(n,e)=>{Sm.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>$m(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function Op(n){return new Dm({type:"optional",innerType:n})}const GT=x("ZodExactOptional",(n,e)=>{k$.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>$m(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function VT(n){return new GT({type:"optional",innerType:n})}const WT=x("ZodNullable",(n,e)=>{E$.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>H1(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function zp(n){return new WT({type:"nullable",innerType:n})}const qT=x("ZodDefault",(n,e)=>{x$.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>j1(n,t,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function YT(n,e){return new qT({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():om(e)}})}const KT=x("ZodPrefault",(n,e)=>{A$.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>G1(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function JT(n,e){return new KT({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():om(e)}})}const Om=x("ZodNonOptional",(n,e)=>{$$.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>B1(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function XT(n,e){return new Om({type:"nonoptional",innerType:n,...z(e)})}const QT=x("ZodCatch",(n,e)=>{T$.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>V1(n,t,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function eC(n,e){return new QT({type:"catch",innerType:n,catchValue:typeof e=="function"?e:()=>e})}const tC=x("ZodPipe",(n,e)=>{C$.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>W1(n,t,r,i),n.in=e.in,n.out=e.out});function Lp(n,e){return new tC({type:"pipe",in:n,out:e})}const nC=x("ZodReadonly",(n,e)=>{I$.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>q1(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function rC(n){return new nC({type:"readonly",innerType:n})}const iC=x("ZodCustom",(n,e)=>{P$.init(n,e),pe.init(n,e),n._zod.processJSONSchema=(t,r,i)=>z1(n,t)});function sC(n,e={}){return k1(iC,n,e)}function oC(n){return E1(n)}const aC=["text/markdown","text/html"],lC=["committed","pending"];Rm({id:h().min(1),type:pa(aC),title:h(),status:pa(lC),externalFilePath:h().optional()});Rm({name:h().min(1),description:h(),accepts:D(h().min(1)).min(1)});function Yu(n){return typeof n=="object"&&n!==null}function cC(n){return!Yu(n)||n.type!=="ready"?!1:!("id"in n)}function uC(n){return!(!Yu(n)||n.type!=="update-content"||typeof n.id!="string"||typeof n.content!="string")}function hC(n){return!Yu(n)||n.type!=="wheel"||typeof n.deltaX!="number"||typeof n.deltaY!="number"||typeof n.shiftKey!="boolean"?!1:!("id"in n)}function dC(n,e){if(n===e)return 2;if(n==="*/*")return 0;const t=n.indexOf("/");if(t>0&&n.slice(t+1)==="*"){const r=n.slice(0,t),i=e.indexOf("/");if(i>0&&e.slice(0,i)===r)return 1}return null}function pC(n,e){let t=null;for(const r of n.accepts){const i=dC(r,e);i!==null&&(t===null||i>t)&&(t=i)}return t}function fC(n,e){let t=-1,r=null;for(const i of e){const s=pC(i,n);s!==null&&(s>t||s===t&&r!==null&&i.id<r.id)&&(t=s,r=i)}return r}const gC=4401;class Tc extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class Cc extends mt{constructor(t){super();b(this,"url");b(this,"name");b(this,"token");b(this,"status","disconnected");b(this,"screens",new Map);b(this,"views",[]);b(this,"client");b(this,"createSocket");b(this,"createClient");b(this,"socket",null);b(this,"connectAttempt",0);this.url=Et(t.url),this.name=t.name,this.token=t.token??null,this.createSocket=t.createSocket??(r=>new WebSocket(r)),this.createClient=t.createClient??((r,i)=>new yx(r,{token:i??void 0})),this.client=this.createClient(this.url,this.token)}async connect(){var i;this.connectAttempt+=1;const t=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this.token),this.status="connecting",this.dispatchEvent(new ee("change"));const r=this.createSocket(mC(this.url,this.token));return this.socket=r,await new Promise((s,o)=>{let a=!1;const c=()=>{a||this.connectAttempt!==t||(a=!0,this.status="connected",this.dispatchEvent(new ee("change")),s())},u=p=>{a||this.connectAttempt!==t||(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=yC(p);y&&(this.applyServerEvent(y),this.dispatchEvent(new qg("server-event",{serverURL:this.url,event:y})))}),r.addEventListener("close",p=>{if(this.connectAttempt===t){if(this.socket=null,vC(p)===gC){u(new Tc);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 t;this.connectAttempt+=1,(t=this.socket)==null||t.close(),this.socket=null,this.status="disconnected",this.dispatchEvent(new ee("change"))}getViewURL(t){const r=fC(t.type,this.views);if(!r)return null;const i=`${this.url}/views/${encodeURIComponent(r.id)}/`;return this.token===null?i:`${i}?token=${encodeURIComponent(this.token)}`}getContentURL(t){const r=`${this.url}/artifacts/${encodeURIComponent(t)}/content`;return this.token===null?r:`${r}?token=${encodeURIComponent(this.token)}`}async createScreen(t){const{screen:r}=await this.client.screens.create({name:t});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(t){switch(t.type){case"screen-created":this.screens.set(t.screen.id,structuredClone(t.screen)),this.dispatchEvent(new Vo("screens-changed"));break;case"screen-updated":this.screens.set(t.screen.id,structuredClone(t.screen)),this.dispatchEvent(new Vo("screens-changed"));break;case"screen-removed":this.screens.delete(t.screenID),this.dispatchEvent(new Vo("screens-changed"));break;case"artifact-created":break;case"artifact-attached":{const r=this.screens.get(t.screenID);r&&!Gg(r.layout,t.artifact.id)&&(r.layout=[...r.layout,jg(t.artifact.id,{id:t.cardID})]);break}case"artifact-removed":{const r=this.screens.get(t.screenID);r&&(r.layout=zg(r.layout,t.artifactID));break}}}}function mC(n,e){const t=new URL(n);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/events",t.search="",e&&t.searchParams.set("token",e),t.hash="",t.toString()}function vC(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}function yC(n){const e=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!e)return null;try{return JSON.parse(e)}catch{return null}}class bC extends mt{constructor(t){super();b(this,"servers",new Map);b(this,"localServerURL");b(this,"localStore");b(this,"createSocket");b(this,"lastActiveServerURL");b(this,"serverListeners",new Map);b(this,"handleLocalStoreChange",()=>{const t=this.localStore.get().activeServerURL;t!==this.lastActiveServerURL&&(this.lastActiveServerURL=t,this.dispatchEvent(new ee("change")))});this.localStore=t.localStore,this.localServerURL=t.localServerURL?Et(t.localServerURL):null,this.createSocket=t.createSocket??(r=>new WebSocket(r)),this.lastActiveServerURL=this.localStore.get().activeServerURL,this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const t=this.localStore.get().activeServerURL;return t===null?null:this.servers.get(t)??null}add(t){const r=Et(t.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,t);const s=()=>{this.dispatchEvent(new ee("change"))},o=c=>{this.dispatchEvent(new qg("server-event",{serverURL:c.serverURL,event:c.event}))},a=()=>{this.dispatchEvent(new Vo("screens-changed"))};t.addEventListener("change",s),t.addEventListener("server-event",o),t.addEventListener("screens-changed",a),this.serverListeners.set(r,{onServerChange:s,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new ee("change"))}remove(t){const r=Et(t);if(this.localServerURL&&r===this.localServerURL)return;const i=this.servers.get(r);if(!i)return;const s=this.serverListeners.get(r);s&&(i.removeEventListener("change",s.onServerChange),i.removeEventListener("server-event",s.onServerEvent),i.removeEventListener("screens-changed",s.onScreensChanged),this.serverListeners.delete(r)),i.disconnect(),this.servers.delete(r);const o=this.localStore.get(),a=o.activeServerURL===r;this.localStore.set({...o,servers:o.servers.filter(c=>c.url!==r),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new ee("change"))}setActive(t){const r=this.localStore.get(),i=t?Et(t.url):null;r.activeServerURL!==i&&this.localStore.set({...r,activeServerURL:i})}connectConfiguredServers(t,r){const i=this.localStore.get().servers,s=t?Et(t):null;for(const a of i){const c=Et(a.url),u=s!==null&&c===s,d=new Cc({url:a.url,name:a.name,token:u?r??null:null,createSocket:this.createSocket});this.add(d),d.connect().catch(()=>{})}const o=s?this.servers.get(s)??null:null;this.setActive(o??this.servers.values().next().value??null)}addServer(t,r){const i=Et(t);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>Et(a.url)!==i),{url:i,name:r}]});const o=new Cc({url:i,name:r,createSocket:this.createSocket});this.add(o),this.setActive(o),o.connect().catch(()=>{})}removeServer(t){this.remove(t)}}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"},Lt={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"},wC=1,SC=f({_meta:_(h(),w()).nullish(),terminal:Ee().optional().default(!1)}),_C=f({_meta:_(h(),w()).nullish(),label:h().nullish(),name:h(),optional:Ee().optional().default(!1),secret:Ee().optional().default(!0)}),kC=f({_meta:_(h(),w()).nullish(),description:h().nullish(),id:h(),name:h()}),EC=f({_meta:_(h(),w()).nullish(),description:h().nullish(),id:h(),link:h().nullish(),name:h(),vars:D(_C)}),xC=f({_meta:_(h(),w()).nullish(),args:D(h()).optional(),description:h().nullish(),env:_(h(),h()).optional(),id:h(),name:h()}),AC=B([EC.and(f({type:A("env_var")})),xC.and(f({type:A("terminal")})),kC]),$C=f({_meta:_(h(),w()).nullish(),methodId:h()}),TC=f({_meta:_(h(),w()).nullish()}),CC=f({_meta:_(h(),w()).nullish(),blob:h(),mimeType:h().nullish(),uri:h()}),IC=f({default:Ee().nullish(),description:h().nullish(),title:h().nullish()}),PC=f({_meta:_(h(),w()).nullish()}),RC=f({_meta:_(h(),w()).nullish()}),DC=f({amount:F(),currency:h()}),OC=f({_meta:_(h(),w()).nullish(),terminalId:h()}),zC=f({_meta:_(h(),w()).nullish(),newText:h(),oldText:h().nullish(),path:h()}),LC=B([h(),F(),F(),Ee(),D(h())]),MC=f({content:_(h(),LC).nullish()}),NC=B([MC.and(f({action:A("accept")})),f({action:A("decline")}),f({action:A("cancel")})]),UC=f({_meta:_(h(),w()).nullish()}),zm=h(),FC=f({_meta:_(h(),w()).nullish(),elicitationId:zm}),ZC=f({_meta:_(h(),w()).nullish(),action:NC}),HC=A("object"),BC=A("string"),jC=f({_meta:_(h(),w()).nullish()}),GC=f({_meta:_(h(),w()).nullish(),form:UC.nullish(),url:jC.nullish()}),VC=f({elicitationId:zm,url:h().url()}),Lm=f({const:h(),title:h()}),Mm=f({_meta:_(h(),w()).nullish(),name:h(),value:h()}),WC=B([A(-32700),A(-32600),A(-32601),A(-32602),A(-32603),A(-32800),A(-32e3),A(-32002),A(-32042),F().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),Nm=f({code:WC,data:w().optional(),message:h()}),Um=w(),Fm=w(),Zm=w(),qC=f({_meta:_(h(),w()).nullish(),readTextFile:Ee().optional().default(!1),writeTextFile:Ee().optional().default(!1)}),Hm=f({_meta:_(h(),w()).nullish(),name:h(),value:h()}),Bm=f({_meta:_(h(),w()).nullish(),name:h(),title:h().nullish(),version:h()}),YC=f({default:F().nullish(),description:h().nullish(),maximum:F().nullish(),minimum:F().nullish(),title:h().nullish()}),KC=f({_meta:_(h(),w()).nullish()}),JC=f({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cursor:h().nullish(),cwd:h().nullish()}),XC=f({_meta:_(h(),w()).nullish()}),QC=f({_meta:_(h(),w()).nullish(),logout:XC.nullish()}),eI=f({_meta:_(h(),w()).nullish()}),tI=f({_meta:_(h(),w()).nullish()}),nI=f({_meta:_(h(),w()).nullish(),http:Ee().optional().default(!1),sse:Ee().optional().default(!1)}),rI=f({_meta:_(h(),w()).nullish(),headers:D(Hm),name:h(),url:h()}),iI=f({_meta:_(h(),w()).nullish(),headers:D(Hm),name:h(),url:h()}),sI=f({_meta:_(h(),w()).nullish(),args:D(h()),command:h(),env:D(Mm),name:h()}),Ya=B([rI.and(f({type:A("http")})),iI.and(f({type:A("sse")})),sI]),Ku=h(),oI=f({_meta:_(h(),w()).nullish(),description:h().nullish(),modelId:Ku,name:h()}),aI=B([A("error"),A("warning"),A("information"),A("hint")]),lI=f({_meta:_(h(),w()).nullish()}),cI=f({_meta:_(h(),w()).nullish()}),uI=f({_meta:_(h(),w()).nullish()}),hI=f({_meta:_(h(),w()).nullish()}),dI=f({_meta:_(h(),w()).nullish()}),pI=f({_meta:_(h(),w()).nullish(),maxCount:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),fI=f({diff:h(),uri:h()}),gI=f({endLine:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:h()}),mI=f({_meta:_(h(),w()).nullish()}),vI=f({_meta:_(h(),w()).nullish()}),yI=f({languageId:h(),text:h(),uri:h()}),bI=f({_meta:_(h(),w()).nullish(),maxCount:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),wI=B([A("rejected"),A("ignored"),A("replaced"),A("cancelled")]),SI=f({excerpts:D(gI),uri:h()}),_I=f({_meta:_(h(),w()).nullish()}),kI=f({_meta:_(h(),w()).nullish()}),EI=f({name:h(),owner:h(),remoteUrl:h()}),xI=f({_meta:_(h(),w()).nullish()}),AI=f({_meta:_(h(),w()).nullish(),jump:mI.nullish(),rename:kI.nullish(),searchAndReplace:xI.nullish()}),$I=f({id:h(),isRegex:Ee().nullish(),replace:h(),search:h(),uri:h()}),TI=B([A("automatic"),A("diagnostic"),A("manual")]),CI=f({_meta:_(h(),w()).nullish(),maxCount:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),II=f({_meta:_(h(),w()).nullish(),diagnostics:lI.nullish(),editHistory:pI.nullish(),openFiles:vI.nullish(),recentFiles:bI.nullish(),relatedSnippets:_I.nullish(),userActions:CI.nullish()}),PI=f({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ya)}),RI=f({default:F().nullish(),description:h().nullish(),maximum:F().nullish(),minimum:F().nullish(),title:h().nullish()}),jm=h(),DI=B([A("allow_once"),A("allow_always"),A("reject_once"),A("reject_always")]),OI=f({_meta:_(h(),w()).nullish(),kind:DI,name:h(),optionId:jm}),zI=B([A("high"),A("medium"),A("low")]),LI=B([A("pending"),A("in_progress"),A("completed")]),MI=f({_meta:_(h(),w()).nullish(),content:h(),priority:zI,status:LI}),NI=f({_meta:_(h(),w()).nullish(),entries:D(MI)}),vn=f({character:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),UI=f({id:h(),position:vn,uri:h()}),FI=f({id:h(),newName:h(),position:vn,uri:h()}),ZI=f({action:h(),position:vn,timestampMs:F(),uri:h()}),Gm=B([A("utf-16"),A("utf-32"),A("utf-8")]),HI=f({_meta:_(h(),w()).nullish(),auth:SC.optional().default({terminal:!1}),elicitation:GC.nullish(),fs:qC.optional().default({readTextFile:!1,writeTextFile:!1}),nes:AI.nullish(),positionEncodings:D(Gm).optional(),terminal:Ee().optional().default(!1)}),BI=f({_meta:_(h(),w()).nullish(),audio:Ee().optional().default(!1),embeddedContext:Ee().optional().default(!1),image:Ee().optional().default(!1)}),Vm=F().int().gte(0).lte(65535),jI=f({_meta:_(h(),w()).nullish(),clientCapabilities:HI.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Bm.nullish(),protocolVersion:Vm}),_i=f({end:vn,start:vn}),GI=f({message:h(),range:_i,severity:aI,uri:h()}),VI=f({languageId:h(),lastFocusedMs:F().nullish(),uri:h(),visibleRange:_i.nullish()}),WI=f({_meta:_(h(),w()).nullish(),diagnostics:D(GI).nullish(),editHistory:D(fI).nullish(),openFiles:D(VI).nullish(),recentFiles:D(yI).nullish(),relatedSnippets:D(SI).nullish(),userActions:D(ZI).nullish()}),qI=f({newText:h(),range:_i}),YI=f({cursorPosition:vn.nullish(),edits:D(qI),id:h(),uri:h()}),KI=B([YI.and(f({kind:A("edit")})),UI.and(f({kind:A("jump")})),FI.and(f({kind:A("rename")})),$I.and(f({kind:A("searchAndReplace")}))]),JI=f({_meta:_(h(),w()).nullish(),content:h()}),XI=f({_meta:_(h(),w()).nullish()}),ur=B([F(),h()]).nullable();f({_meta:_(h(),w()).nullish(),requestId:ur});const QI=pa(["assistant","user"]),so=f({_meta:_(h(),w()).nullish(),audience:D(QI).nullish(),lastModified:h().nullish(),priority:F().nullish()}),eP=f({_meta:_(h(),w()).nullish(),annotations:so.nullish(),data:h(),mimeType:h()}),tP=f({_meta:_(h(),w()).nullish(),annotations:so.nullish(),data:h(),mimeType:h(),uri:h().nullish()}),nP=f({_meta:_(h(),w()).nullish(),annotations:so.nullish(),description:h().nullish(),mimeType:h().nullish(),name:h(),size:F().nullish(),title:h().nullish(),uri:h()}),rP=f({_meta:_(h(),w()).nullish(),optionId:jm}),iP=B([f({outcome:A("cancelled")}),rP.and(f({outcome:A("selected")}))]),sP=f({_meta:_(h(),w()).nullish(),outcome:iP}),oP=f({_meta:_(h(),w()).nullish()}),aP=f({_meta:_(h(),w()).nullish()}),lP=f({currentValue:Ee()}),cP=h(),Wm=h(),uP=B([A("mode"),A("model"),A("thought_level"),h()]),Ju=h(),qm=f({_meta:_(h(),w()).nullish(),description:h().nullish(),name:h(),value:Ju}),hP=f({_meta:_(h(),w()).nullish(),group:cP,name:h(),options:D(qm)}),dP=B([D(qm),D(hP)]),pP=f({currentValue:Ju,options:dP}),ki=qa(B([pP.and(f({type:A("select")})),lP.and(f({type:A("boolean")}))]),f({_meta:_(h(),w()).nullish(),category:uP.nullish(),description:h().nullish(),id:Wm,name:h()})),fP=f({_meta:_(h(),w()).nullish(),configOptions:D(ki)}),gP=f({_meta:_(h(),w()).nullish()}),K=h(),mP=f({_meta:_(h(),w()).nullish(),id:h(),sessionId:K}),vP=f({_meta:_(h(),w()).nullish(),sessionId:K}),yP=f({_meta:_(h(),w()).nullish(),sessionId:K}),bP=f({_meta:_(h(),w()).nullish(),sessionId:K}),Ym=f({_meta:_(h(),w()).nullish(),args:D(h()).optional(),command:h(),cwd:h().nullish(),env:D(Mm).optional(),outputByteLimit:F().nullish(),sessionId:K}),wP=f({_meta:_(h(),w()).nullish(),sessionId:K,uri:h()}),SP=f({_meta:_(h(),w()).nullish(),position:vn,sessionId:K,uri:h(),version:F(),visibleRange:_i}),_P=f({_meta:_(h(),w()).nullish(),languageId:h(),sessionId:K,text:h(),uri:h(),version:F()}),kP=f({_meta:_(h(),w()).nullish(),sessionId:K,uri:h()}),EP=f({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ya).optional(),sessionId:K}),Km=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),xP=f({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ya),sessionId:K}),Jm=f({_meta:_(h(),w()).nullish(),limit:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h(),sessionId:K}),AP=f({_meta:_(h(),w()).nullish(),id:h(),reason:wI.nullish(),sessionId:K}),Xm=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),$P=f({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ya).optional(),sessionId:K}),TP=f({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),sessionId:K,title:h().nullish(),updatedAt:h().nullish()}),CP=f({_meta:_(h(),w()).nullish(),nextCursor:h().nullish(),sessions:D(TP)}),IP=f({_meta:_(h(),w()).nullish(),title:h().nullish(),updatedAt:h().nullish()}),PP=f({_meta:_(h(),w()).nullish()}),Ka=h(),RP=f({_meta:_(h(),w()).nullish(),currentModeId:Ka}),DP=f({_meta:_(h(),w()).nullish(),description:h().nullish(),id:Ka,name:h()}),Ja=f({_meta:_(h(),w()).nullish(),availableModes:D(DP),currentModeId:Ka}),Xa=f({_meta:_(h(),w()).nullish(),availableModels:D(oI),currentModelId:Ku}),OP=f({_meta:_(h(),w()).nullish(),configOptions:D(ki).nullish(),models:Xa.nullish(),modes:Ja.nullish(),sessionId:K}),zP=f({_meta:_(h(),w()).nullish(),configOptions:D(ki).nullish(),models:Xa.nullish(),modes:Ja.nullish()}),LP=f({_meta:_(h(),w()).nullish(),configOptions:D(ki).nullish(),models:Xa.nullish(),modes:Ja.nullish(),sessionId:K}),MP=f({_meta:_(h(),w()).nullish(),configOptions:D(ki).nullish(),models:Xa.nullish(),modes:Ja.nullish()}),NP=f({_meta:_(h(),w()).nullish()}),UP=f({_meta:_(h(),w()).nullish(),additionalDirectories:oP.nullish(),close:aP.nullish(),fork:gP.nullish(),list:PP.nullish(),resume:NP.nullish()}),FP=qa(B([f({type:A("boolean"),value:Ee()}),f({value:Ju})]),f({_meta:_(h(),w()).nullish(),configId:Wm,sessionId:K})),ZP=f({_meta:_(h(),w()).nullish(),configOptions:D(ki)}),HP=f({_meta:_(h(),w()).nullish(),modeId:Ka,sessionId:K}),BP=f({_meta:_(h(),w()).nullish()}),jP=f({_meta:_(h(),w()).nullish(),modelId:Ku,sessionId:K}),GP=f({_meta:_(h(),w()).nullish()}),VP=f({_meta:_(h(),w()).nullish(),sessionId:K}),WP=B([A("end_turn"),A("max_tokens"),A("max_turn_requests"),A("refusal"),A("cancelled")]),qP=B([A("email"),A("uri"),A("date"),A("date-time")]),YP=f({default:h().nullish(),description:h().nullish(),enum:D(h()).nullish(),format:qP.nullish(),maxLength:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:D(Lm).nullish(),pattern:h().nullish(),title:h().nullish()}),KP=f({_meta:_(h(),w()).nullish(),context:WI.nullish(),position:vn,selection:_i.nullish(),sessionId:K,triggerKind:TI,uri:h(),version:F()}),JP=f({_meta:_(h(),w()).nullish(),suggestions:D(KI)}),XP=f({_meta:_(h(),w()).nullish(),terminalId:h()}),QP=f({_meta:_(h(),w()).nullish(),exitCode:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),Qm=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),eR=f({_meta:_(h(),w()).nullish(),exitStatus:QP.nullish(),output:h(),truncated:Ee()}),tR=f({_meta:_(h(),w()).nullish(),annotations:so.nullish(),text:h()}),nR=f({range:_i.nullish(),text:h()}),rR=f({_meta:_(h(),w()).nullish(),contentChanges:D(nR),sessionId:K,uri:h(),version:F()});f({method:h(),params:B([vP,_P,rR,wP,kP,SP,mP,AP,Um]).nullish()});const iR=B([A("full"),A("incremental")]),sR=f({_meta:_(h(),w()).nullish(),syncKind:iR}),oR=f({_meta:_(h(),w()).nullish(),didChange:sR.nullish(),didClose:cI.nullish(),didFocus:uI.nullish(),didOpen:hI.nullish(),didSave:dI.nullish()}),aR=f({_meta:_(h(),w()).nullish(),document:oR.nullish()}),lR=f({_meta:_(h(),w()).nullish(),context:II.nullish(),events:aR.nullish()}),cR=f({_meta:_(h(),w()).nullish(),auth:QC.optional().default({}),loadSession:Ee().optional().default(!1),mcpCapabilities:nI.optional().default({http:!1,sse:!1}),nes:lR.nullish(),positionEncoding:Gm.nullish(),promptCapabilities:BI.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:UP.optional().default({})}),uR=f({_meta:_(h(),w()).nullish(),agentCapabilities:cR.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Bm.nullish(),authMethods:D(AC).optional().default([]),protocolVersion:Vm}),hR=f({_meta:_(h(),w()).nullish(),mimeType:h().nullish(),text:h(),uri:h()}),dR=B([hR,CC]),pR=f({_meta:_(h(),w()).nullish(),annotations:so.nullish(),resource:dR}),Xu=B([tR.and(f({type:A("text")})),tP.and(f({type:A("image")})),eP.and(f({type:A("audio")})),nP.and(f({type:A("resource_link")})),pR.and(f({type:A("resource")}))]),fR=f({_meta:_(h(),w()).nullish(),content:Xu}),Vl=f({_meta:_(h(),w()).nullish(),content:Xu,messageId:h().nullish()}),gR=f({_meta:_(h(),w()).nullish(),messageId:h().nullish(),prompt:D(Xu),sessionId:K}),mR=f({anyOf:D(Lm)}),ev=B([fR.and(f({type:A("content")})),zC.and(f({type:A("diff")})),XP.and(f({type:A("terminal")}))]),tv=h(),nv=f({_meta:_(h(),w()).nullish(),line:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h()}),rv=B([A("pending"),A("in_progress"),A("completed"),A("failed")]),iv=B([A("read"),A("edit"),A("delete"),A("move"),A("search"),A("execute"),A("think"),A("fetch"),A("switch_mode"),A("other")]),vR=f({_meta:_(h(),w()).nullish(),content:D(ev).optional(),kind:iv.optional(),locations:D(nv).optional(),rawInput:w().optional(),rawOutput:w().optional(),status:rv.optional(),title:h(),toolCallId:tv}),sv=f({_meta:_(h(),w()).nullish(),content:D(ev).nullish(),kind:iv.nullish(),locations:D(nv).nullish(),rawInput:w().optional(),rawOutput:w().optional(),status:rv.nullish(),title:h().nullish(),toolCallId:tv}),ov=f({_meta:_(h(),w()).nullish(),options:D(OI),sessionId:K,toolCall:sv}),yR=f({_meta:_(h(),w()).nullish(),hint:h()}),bR=yR,wR=f({_meta:_(h(),w()).nullish(),description:h(),input:bR.nullish(),name:h()}),SR=f({_meta:_(h(),w()).nullish(),availableCommands:D(wR)}),_R=f({enum:D(h()),type:BC}),kR=B([_R,mR]),ER=f({default:D(h()).nullish(),description:h().nullish(),items:kR,maxItems:F().nullish(),minItems:F().nullish(),title:h().nullish()}),xR=B([YP.and(f({type:A("string")})),RI.and(f({type:A("number")})),YC.and(f({type:A("integer")})),IC.and(f({type:A("boolean")})),ER.and(f({type:A("array")}))]),AR=f({description:h().nullish(),properties:_(h(),xR).optional().default({}),required:D(h()).nullish(),title:h().nullish(),type:HC.optional().default("object")}),$R=f({requestedSchema:AR}),TR=qa(B([$R.and(f({mode:A("form")})),VC.and(f({mode:A("url")}))]),f({_meta:_(h(),w()).nullish(),message:h(),sessionId:K})),CR=f({cachedReadTokens:F().nullish(),cachedWriteTokens:F().nullish(),inputTokens:F(),outputTokens:F(),thoughtTokens:F().nullish(),totalTokens:F()}),IR=f({_meta:_(h(),w()).nullish(),stopReason:WP,usage:CR.nullish(),userMessageId:h().nullish()});B([f({id:ur,result:B([uR,TC,tI,LP,zP,CP,OP,MP,RC,BP,ZP,IR,GP,VP,JP,PC,Zm])}),f({error:Nm,id:ur})]);const PR=f({_meta:_(h(),w()).nullish(),cost:DC.nullish(),size:F(),used:F()}),RR=B([Vl.and(f({sessionUpdate:A("user_message_chunk")})),Vl.and(f({sessionUpdate:A("agent_message_chunk")})),Vl.and(f({sessionUpdate:A("agent_thought_chunk")})),vR.and(f({sessionUpdate:A("tool_call")})),sv.and(f({sessionUpdate:A("tool_call_update")})),NI.and(f({sessionUpdate:A("plan")})),SR.and(f({sessionUpdate:A("available_commands_update")})),RP.and(f({sessionUpdate:A("current_mode_update")})),fP.and(f({sessionUpdate:A("config_option_update")})),IP.and(f({sessionUpdate:A("session_info_update")})),PR.and(f({sessionUpdate:A("usage_update")}))]),av=f({_meta:_(h(),w()).nullish(),sessionId:K,update:RR});f({method:h(),params:B([av,FC,Um]).nullish()});const lv=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),DR=f({_meta:_(h(),w()).nullish(),exitCode:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),OR=f({name:h(),uri:h()}),zR=f({_meta:_(h(),w()).nullish(),repository:EI.nullish(),workspaceFolders:D(OR).nullish(),workspaceUri:h().nullish()});f({id:ur,method:h(),params:B([jI,$C,eI,PI,xP,JC,EP,$P,bP,HP,FP,gR,jP,zR,KP,yP,Fm]).nullish()});const cv=f({_meta:_(h(),w()).nullish(),content:h(),path:h(),sessionId:K});f({id:ur,method:h(),params:B([cv,Jm,ov,Ym,Qm,Xm,lv,Km,TR,Fm]).nullish()});const LR=f({_meta:_(h(),w()).nullish()});B([f({id:ur,result:B([LR,JI,sP,OC,eR,XI,DR,KC,ZC,Zm])}),f({error:Nm,id:ur})]);var Y;class MR{constructor(e,t){S(this,Y);const r=e(this),i=async(o,a)=>{var c,u,d,p,y,v,$;switch(o){case Lt.fs_write_text_file:{const E=cv.parse(a);return(c=r.writeTextFile)==null?void 0:c.call(r,E)}case Lt.fs_read_text_file:{const E=Jm.parse(a);return(u=r.readTextFile)==null?void 0:u.call(r,E)}case Lt.session_request_permission:{const E=ov.parse(a);return r.requestPermission(E)}case Lt.terminal_create:{const E=Ym.parse(a);return(d=r.createTerminal)==null?void 0:d.call(r,E)}case Lt.terminal_output:{const E=Qm.parse(a);return(p=r.terminalOutput)==null?void 0:p.call(r,E)}case Lt.terminal_release:{const E=Xm.parse(a);return await((y=r.releaseTerminal)==null?void 0:y.call(r,E))??{}}case Lt.terminal_wait_for_exit:{const E=lv.parse(a);return(v=r.waitForTerminalExit)==null?void 0:v.call(r,E)}case Lt.terminal_kill:{const E=Km.parse(a);return await(($=r.killTerminal)==null?void 0:$.call(r,E))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw we.methodNotFound(o)}},s=async(o,a)=>{switch(o){case Lt.session_update:{const c=av.parse(a);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(o,a);throw we.methodNotFound(o)}};k(this,Y,new NR(i,s,t))}async initialize(e){return await l(this,Y).sendRequest(oe.initialize,e)}async newSession(e){return await l(this,Y).sendRequest(oe.session_new,e)}async loadSession(e){return await l(this,Y).sendRequest(oe.session_load,e)??{}}async unstable_forkSession(e){return await l(this,Y).sendRequest(oe.session_fork,e)}async listSessions(e){return await l(this,Y).sendRequest(oe.session_list,e)}async unstable_resumeSession(e){return await l(this,Y).sendRequest(oe.session_resume,e)}async unstable_closeSession(e){return await l(this,Y).sendRequest(oe.session_close,e)}async setSessionMode(e){return await l(this,Y).sendRequest(oe.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await l(this,Y).sendRequest(oe.session_set_model,e)??{}}async setSessionConfigOption(e){return await l(this,Y).sendRequest(oe.session_set_config_option,e)}async authenticate(e){return await l(this,Y).sendRequest(oe.authenticate,e)??{}}async unstable_logout(e){return await l(this,Y).sendRequest(oe.logout,e)??{}}async prompt(e){return await l(this,Y).sendRequest(oe.session_prompt,e)}async cancel(e){return await l(this,Y).sendNotification(oe.session_cancel,e)}async unstable_startNes(e){return await l(this,Y).sendRequest(oe.nes_start,e)}async unstable_suggestNes(e){return await l(this,Y).sendRequest(oe.nes_suggest,e)}async unstable_closeNes(e){return await l(this,Y).sendRequest(oe.nes_close,e)??{}}async unstable_didOpenDocument(e){return await l(this,Y).sendNotification(oe.document_did_open,e)}async unstable_didChangeDocument(e){return await l(this,Y).sendNotification(oe.document_did_change,e)}async unstable_didCloseDocument(e){return await l(this,Y).sendNotification(oe.document_did_close,e)}async unstable_didSaveDocument(e){return await l(this,Y).sendNotification(oe.document_did_save,e)}async unstable_didFocusDocument(e){return await l(this,Y).sendNotification(oe.document_did_focus,e)}async unstable_acceptNes(e){return await l(this,Y).sendNotification(oe.nes_accept,e)}async unstable_rejectNes(e){return await l(this,Y).sendNotification(oe.nes_reject,e)}async extMethod(e,t){return await l(this,Y).sendRequest(e,t)}async extNotification(e,t){return await l(this,Y).sendNotification(e,t)}get signal(){return l(this,Y).signal}get closed(){return l(this,Y).closed}}Y=new WeakMap;var on,Sa,fs,gs,Br,jr,$t,ms,he,uv,Ic,hv,dv,pv,fv,Pc,ji;class NR{constructor(e,t,r){S(this,he);S(this,on,new Map);S(this,Sa,0);S(this,fs);S(this,gs);S(this,Br);S(this,jr,Promise.resolve());S(this,$t,new AbortController);S(this,ms);k(this,fs,e),k(this,gs,t),k(this,Br,r),k(this,ms,new Promise(i=>{l(this,$t).signal.addEventListener("abort",()=>i())})),g(this,he,uv).call(this)}get signal(){return l(this,$t).signal}get closed(){return l(this,ms)}async sendRequest(e,t){g(this,he,Pc).call(this);const r=Hh(this,Sa)._++,i=new Promise((s,o)=>{l(this,on).set(r,{resolve:s,reject:o})});return await g(this,he,ji).call(this,{jsonrpc:"2.0",id:r,method:e,params:t}),i}async sendNotification(e,t){g(this,he,Pc).call(this),await g(this,he,ji).call(this,{jsonrpc:"2.0",method:e,params:t})}}on=new WeakMap,Sa=new WeakMap,fs=new WeakMap,gs=new WeakMap,Br=new WeakMap,jr=new WeakMap,$t=new WeakMap,ms=new WeakMap,he=new WeakSet,uv=async function(){let e;try{const t=l(this,Br).readable.getReader();try{for(;!l(this,$t).signal.aborted;){const{value:r,done:i}=await t.read();if(i)break;if(r)try{g(this,he,hv).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&g(this,he,ji).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{t.releaseLock()}}catch(t){e=t}finally{g(this,he,Ic).call(this,e)}},Ic=function(e){if(l(this,$t).signal.aborted)return;const t=e??new Error("ACP connection closed");for(const r of l(this,on).values())r.reject(t);l(this,on).clear(),l(this,$t).abort(t)},hv=async function(e){if("method"in e&&"id"in e){const t=await g(this,he,dv).call(this,e.method,e.params);"error"in t&&console.error("Error handling request",e,t.error),await g(this,he,ji).call(this,{jsonrpc:"2.0",id:e.id,...t})}else if("method"in e){const t=await g(this,he,pv).call(this,e.method,e.params);"error"in t&&console.error("Error handling notification",e,t.error)}else"id"in e?g(this,he,fv).call(this,e):console.error("Invalid message",{message:e})},dv=async function(e,t){try{return{result:await l(this,fs).call(this,e,t)??null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof Pp)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()}}},pv=async function(e,t){try{return await l(this,gs).call(this,e,t),{result:null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof Pp)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()}}},fv=function(e){const t=l(this,on).get(e.id);if(t){if("result"in e)t.resolve(e.result);else if("error"in e){const{code:r,message:i,data:s}=e.error;t.reject(new we(r,i,s))}l(this,on).delete(e.id)}else console.error("Got response to unknown request",e.id)},Pc=function(){if(l(this,$t).signal.aborted)throw l(this,$t).signal.reason??new Error("ACP connection closed")},ji=async function(e){return k(this,jr,l(this,jr).then(async()=>{const t=l(this,Br).writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(t=>{g(this,he,Ic).call(this,t)})),l(this,jr)};class we extends Error{constructor(t,r,i){super(r);b(this,"code");b(this,"data");this.code=t,this.name="RequestError",this.data=i}static parseError(t,r){return new we(-32700,`Parse error${r?`: ${r}`:""}`,t)}static invalidRequest(t,r){return new we(-32600,`Invalid request${r?`: ${r}`:""}`,t)}static methodNotFound(t){return new we(-32601,`"Method not found": ${t}`,{method:t})}static invalidParams(t,r){return new we(-32602,`Invalid params${r?`: ${r}`:""}`,t)}static internalError(t,r){return new we(-32603,`Internal error${r?`: ${r}`:""}`,t)}static authRequired(t,r){return new we(-32e3,`Authentication required${r?`: ${r}`:""}`,t)}static resourceNotFound(t){return new we(-32002,`Resource not found${t?`: ${t}`:""}`,t&&{uri:t})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const UR=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,FR=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,ZR=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,HR=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,BR="single_session",jR={name:"television-acp-client",version:"0.0.0"},gv="agent:main:television",GR=wi(mt);var te,Ft,Gr,Zt,Vn,Wn,qn,Yn,an,Vr,Tt,ct,ln,Kn,Ht,cn,vs,Bt,ut,_a,jt,C,mv,vv,Rc,yv,bv,wv,Sv,_v,kv,Ev,In,Pr,Rr,He,xv,Dr,Dc,Oc,qo,Av,$v,ys,bs,zc,Or,Tv,Cv;class VR extends GR{constructor(t){super();S(this,C);S(this,te,qR());S(this,Ft,null);S(this,Gr,null);S(this,Zt,null);S(this,Vn,null);S(this,Wn,null);S(this,qn,null);S(this,Yn);S(this,an,null);S(this,Vr,1);S(this,Tt,null);S(this,ct,null);S(this,ln,!1);S(this,Kn,!1);S(this,Ht,null);S(this,cn,new Set);S(this,vs);S(this,Bt);S(this,ut);S(this,_a,t=>{g(this,C,vv).call(this,t)});S(this,jt,null);S(this,ys,()=>{g(this,C,Or).call(this,"ACP bridge websocket closed")});S(this,bs,()=>{g(this,C,Or).call(this,"ACP bridge websocket error")});k(this,Bt,t),k(this,ut,t.sessionMode??BR),k(this,Yn,t.mappedSessionStore??WR()),k(this,vs,t.createSocket??(r=>new WebSocket(r)))}getState(){return l(this,te)}get messages(){return l(this,te).messageOrder.map(t=>l(this,te).messagesById[t]).filter(t=>t!==void 0)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(l(this,te).lifecycle.status!=="ready"){g(this,C,He).call(this,{lifecycle:{status:"connecting"}}),l(this,Gr)??k(this,Gr,g(this,C,mv).call(this));try{await l(this,Gr),await g(this,C,Rc).call(this)}catch(t){throw g(this,C,Or).call(this,Co(t)),t}}}dispose(){g(this,C,zc).call(this),g(this,C,He).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null})}async sendMessage(t){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=t.text.trim();if(!r)throw new Error("Cannot send an empty message");g(this,C,Pr).call(this,{id:g(this,C,Dr).call(this,"user"),kind:"user",text:r,status:"final"}),g(this,C,He).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const i=await g(this,C,qo).call(this).prompt({sessionId:g(this,C,Oc).call(this),prompt:[{type:"text",text:g(this,C,xv).call(this,r)}]});g(this,C,In).call(this,i.stopReason==="cancelled"?"cancelled":"final"),g(this,C,He).call(this,{run:{status:i.stopReason==="cancelled"?"cancelled":"completed",stopReason:i.stopReason,canCancel:!1,error:null}})}catch(i){throw g(this,C,Cv).call(this)||(g(this,C,In).call(this,"error"),g(this,C,He).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:Co(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");g(this,C,He).call(this,{run:{...l(this,te).run,status:"cancelling"}}),await g(this,C,qo).call(this).cancel({sessionId:g(this,C,Oc).call(this)})}setScreenContext(t){var s,o,a;const r={screenID:t.screenID,screenName:t.screenName};if(((s=l(this,ct))==null?void 0:s.screenID)===r.screenID&&((o=l(this,ct))==null?void 0:o.screenName)===r.screenName)return;const i=((a=l(this,ct))==null?void 0:a.screenID)??null;if(k(this,ct,r),l(this,ut)==="single_session"){(!l(this,an)||i!==r.screenID)&&k(this,ln,!0);return}l(this,an)!==Mp(l(this,ut),r.screenID,l(this,Bt).clientGUID??"default-client")&&(k(this,Zt,null),k(this,Vn,null),l(this,Ft)&&l(this,te).run.status==="idle"&&g(this,C,Rc).call(this).catch(c=>{g(this,C,Or).call(this,Co(c))}))}}te=new WeakMap,Ft=new WeakMap,Gr=new WeakMap,Zt=new WeakMap,Vn=new WeakMap,Wn=new WeakMap,qn=new WeakMap,Yn=new WeakMap,an=new WeakMap,Vr=new WeakMap,Tt=new WeakMap,ct=new WeakMap,ln=new WeakMap,Kn=new WeakMap,Ht=new WeakMap,cn=new WeakMap,vs=new WeakMap,Bt=new WeakMap,ut=new WeakMap,_a=new WeakMap,jt=new WeakMap,C=new WeakSet,mv=async function(){try{g(this,C,He).call(this,{lifecycle:{status:"connecting"}});const{stream:t,socket:r,metadata:i}=await JR({serverURL:l(this,Bt).serverURL,token:l(this,Bt).token,createSocket:l(this,vs),onDisconnect:l(this,_a)});k(this,qn,i),g(this,C,He).call(this,{bridge:i}),k(this,jt,r),r.addEventListener("close",l(this,ys)),r.addEventListener("error",l(this,bs)),k(this,Ft,new MR(s=>({connection:s,sessionUpdate:async o=>{await g(this,C,bv).call(this,o)},requestPermission:async o=>g(this,C,wv).call(this,o)}),t)),await l(this,Ft).initialize({protocolVersion:wC,clientCapabilities:{},clientInfo:jR})}catch(t){throw t}},vv=function(t){g(this,C,Or).call(this,Co(t))},Rc=async function(){const t=g(this,C,$v).call(this);if(l(this,Zt)&&l(this,Vn)===t){await l(this,Zt);return}k(this,Vn,t),k(this,Zt,g(this,C,yv).call(this,t)),await l(this,Zt)},yv=async function(t){var a;const r=g(this,C,qo).call(this);g(this,C,Tv).call(this);let i,s=!1;const o={cwd:g(this,C,Av).call(this),mcpServers:[],_meta:{sessionKey:t}};try{if(k(this,Kn,!0),k(this,Ht,null),((a=l(this,qn))==null?void 0:a.sessionIdStrategy)==="mapped"){const c=l(this,Yn).getActualSessionId(t);if(c)try{const u=await r.loadSession({...o,sessionId:c});if(YR(u))throw new Error("Mapped ACP session was not found");i=c,s=!0}catch{i=(await r.newSession(o)).sessionId,l(this,Yn).setActualSessionId(t,i),s=!1}else i=(await r.newSession(o)).sessionId,l(this,Yn).setActualSessionId(t,i),s=!1}else try{await r.loadSession({...o,sessionId:t}),i=t,s=l(this,te).messageOrder.length>0}catch{i=(await r.newSession(o)).sessionId,s=!1}}finally{k(this,Kn,!1),k(this,Ht,null),g(this,C,In).call(this,"final")}await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),k(this,Wn,i),k(this,an,t),s?(l(this,cn).add(t),l(this,ut)==="single_session"&&k(this,ln,!1)):(l(this,cn).delete(t),k(this,ln,l(this,ut)==="single_session")),g(this,C,He).call(this,{lifecycle:{status:"ready"}})},bv=async function(t){const r=t.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&g(this,C,Ev).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&g(this,C,Sv).call(this,r.content.text);return;case"tool_call":g(this,C,_v).call(this,r);return;case"tool_call_update":g(this,C,kv).call(this,r);return;case"agent_thought_chunk":return;default:return}},wv=async function(t){return{outcome:{outcome:"cancelled"}}},Sv=function(t){k(this,Ht,null);const r=KR(t);if(!r)return;if(!l(this,Tt)){const s={id:g(this,C,Dr).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};k(this,Tt,s.id),g(this,C,Pr).call(this,s);return}const i=l(this,te).messagesById[l(this,Tt)];if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");g(this,C,Rr).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},_v=function(t){g(this,C,In).call(this,"final");const r=g(this,C,Dc).call(this,t.toolCallId),i=Up("content"in t?t.content:void 0),s={id:(r==null?void 0:r.id)??g(this,C,Dr).call(this,"tool"),kind:"tool_call",toolCallId:t.toolCallId,title:t.title,toolKind:t.kind??"other",status:t.status==="failed"?"failed":t.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??i,locations:t.locations??(r==null?void 0:r.locations)};if(r){g(this,C,Rr).call(this,s);return}g(this,C,Pr).call(this,s)},kv=function(t){const r=g(this,C,Dc).call(this,t.toolCallId),i=(r==null?void 0:r.text)??"",s=Up(t.content),o=s?`${i}${s}`:i,a={id:(r==null?void 0:r.id)??g(this,C,Dr).call(this,"tool"),kind:"tool_call",toolCallId:t.toolCallId,title:(r==null?void 0:r.title)??t.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:t.status==="failed"?"failed":t.status==="completed"?"completed":"in_progress",text:o,locations:t.locations??(r==null?void 0:r.locations)};if(r){g(this,C,Rr).call(this,a);return}g(this,C,Pr).call(this,a)},Ev=function(t){if(g(this,C,In).call(this,"final"),!t)return;const r=l(this,Kn)?l(this,Ht):null;if(!r){const s=Np(t);if(!s)return;const o={id:g(this,C,Dr).call(this,"user"),kind:"user",text:s,status:"final"};g(this,C,Pr).call(this,o),l(this,Kn)&&k(this,Ht,o.id);return}const i=l(this,te).messagesById[r];if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");g(this,C,Rr).call(this,{...i,text:Np(`${i.text}${t}`)})},In=function(t){if(!l(this,Tt))return;const r=l(this,te).messagesById[l(this,Tt)];(r==null?void 0:r.kind)==="assistant"&&g(this,C,Rr).call(this,{...r,status:t}),k(this,Tt,null)},Pr=function(t){g(this,C,He).call(this,{messagesById:{...l(this,te).messagesById,[t.id]:t},messageOrder:[...l(this,te).messageOrder,t.id]})},Rr=function(t){g(this,C,He).call(this,{messagesById:{...l(this,te).messagesById,[t.id]:t}})},He=function(t){const r={...l(this,te),...t};k(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"))},xv=function(t){const r=l(this,an);return!l(this,ct)||!r||!(l(this,ut)==="single_session"?l(this,ln)||!l(this,cn).has(r):!l(this,cn).has(r))?t:(k(this,ln,!1),l(this,cn).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${l(this,ct).screenID}`,`screen_name: ${l(this,ct).screenName??""}`,"When the user asks to inspect or change Television state with the tv CLI, use this screen ID with the --screen argument.","[/Television screen context]","",t].join(`
43
- `))},Dr=function(t){const r=`${t}-${l(this,Vr)}`;return k(this,Vr,l(this,Vr)+1),r},Dc=function(t){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===t)return i}return null},Oc=function(){if(!l(this,Wn))throw new Error("ACP session is not ready");return l(this,Wn)},qo=function(){if(!l(this,Ft))throw new Error("ACP connection is not ready");return l(this,Ft)},Av=function(){var r;const t=(r=l(this,qn))==null?void 0:r.sessionCwd;if(!t)throw new Error("ACP bridge session cwd is not ready");return t},$v=function(){var r;if(l(this,ut)==="single_session")return`${gv}-${(l(this,Bt).clientGUID??"default-client").toLowerCase()}`;const t=(r=l(this,ct))==null?void 0:r.screenID;if(!t)throw new Error("Screen context is required for per-screen session mode");return Mp(l(this,ut),t,l(this,Bt).clientGUID??"default-client")},ys=new WeakMap,bs=new WeakMap,zc=function(){k(this,Ft,null),k(this,Gr,null),k(this,Zt,null),k(this,Vn,null),k(this,Wn,null),k(this,an,null),k(this,qn,null),l(this,jt)&&(l(this,jt).removeEventListener("close",l(this,ys)),l(this,jt).removeEventListener("error",l(this,bs)),l(this,jt).close(),k(this,jt,null))},Or=function(t){this.disposed||l(this,te).lifecycle.status==="disconnected"||(g(this,C,In).call(this,"error"),g(this,C,zc).call(this),g(this,C,He).call(this,{lifecycle:{status:"disconnected",...t?{error:t}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null}))},Tv=function(){k(this,Tt,null),k(this,Ht,null),k(this,Vr,1),g(this,C,He).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},Cv=function(){return l(this,te).lifecycle.status==="disconnected"};function WR(){const n=new Map;return{getActualSessionId(e){return n.get(e)??null},setActualSessionId(e,t){n.set(e,t)},clearActualSessionId(e){n.delete(e)}}}function qR(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null,messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function YR(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function Mp(n,e,t){return n==="single_session"?`${gv}-${t.toLowerCase()}`:`agent:main:television-${t.toLowerCase()}-${e.toLowerCase()}`}function Iv(n){return n.replace(/^(?:\s*\n)+/,"")}function Np(n){let e=n;return e=e.replace(UR,""),e=e.replace(FR,""),e=e.replace(ZR,""),e=Iv(e),e}function KR(n){let e=n;return e=e.replace(HR,""),e=Iv(e),e}function Up(n){return!n||n.length===0?"":n.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function JR(n){const e=n.createSocket(eD(n.serverURL,n.token));let t=!1,r,i;const s=new Promise((u,d)=>{r=u,i=d}),o=new ReadableStream({start(u){let d=!1;const p=()=>{e.send(JSON.stringify({type:"acp-bridge-connect"}))},y=E=>{const I=QR(E);if(!I)return;let Z;try{Z=JSON.parse(I)}catch(P){const G=P instanceof Error?P:new Error(String(P));i(G),u.error(G);return}switch(Z.type){case"acp-bridge-status":if(Z.status==="ready"){let P;try{P=XR(Z)}catch(G){const O=G instanceof Error?G:new Error(String(G));t||i(O),u.error(O);return}t||(t=!0,r(P));return}if(Z.status==="error"||Z.status==="exited"){const P=new Error(Z.error??`ACP bridge ${Z.status}`);t||i(P),u.error(P)}return;case"acp-bridge-message":u.enqueue(Z.message);return}},v=()=>{var I;if(d)return;d=!0;const E=new Error("ACP bridge websocket closed");t||i(E),(I=n.onDisconnect)==null||I.call(n,E),u.close()},$=()=>{var I;if(d)return;d=!0;const E=new Error("ACP bridge websocket error");t||i(E),(I=n.onDisconnect)==null||I.call(n,E),u.error(E)};e.addEventListener("open",p),e.addEventListener("message",y),e.addEventListener("close",v),e.addEventListener("error",$)}}),a=new WritableStream({async write(u){await s,e.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){e.close()},abort(){e.close()}}),c=await s;return{stream:{readable:o,writable:a},socket:e,metadata:c}}function XR(n){const{agent:e,sessionIdStrategy:t,sessionCwd:r}=n;if((e==="openclaw"||e==="hermes")&&(t==="deterministic"||t==="mapped")&&typeof r=="string"&&r.length>0)return{agent:e,sessionIdStrategy:t,sessionCwd:r};throw new Error("ACP bridge ready status missing bootstrap metadata")}function QR(n){if(typeof n=="string")return n;if(n instanceof Uint8Array)return new TextDecoder().decode(n);if(typeof Buffer<"u"&&n instanceof Buffer)return n.toString("utf8");if(typeof n=="object"&&n!==null&&"data"in n){const e=n.data;if(typeof e=="string")return e;if(e instanceof Uint8Array)return new TextDecoder().decode(e);if(Array.isArray(e))return Buffer.concat(e).toString("utf8")}return null}function eD(n,e){const t=new URL(n);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/acp",t.search="",t.searchParams.set("token",e),t.hash="",t.toString()}function Co(n){return n instanceof Error?n.message:String(n)}const Fp="television.acpClientGUID",Zp="television.acpMappedSessions",tD=wi(mt);class nD extends tD{constructor(t){super();b(this,"screenManager");b(this,"clients",new Map);b(this,"options");b(this,"sessionMode");b(this,"clientGUID");b(this,"mappedSessionStore");b(this,"activeClient",null);b(this,"handleActiveScreenChanged",()=>{this.syncActiveClient()});this.screenManager=t.screenManager,this.sessionMode=t.sessionMode??"single_session";const r=t.storage??sD();this.options={serverURL:t.serverURL,token:t.token,...t.createSocket?{createSocket:t.createSocket}:{},...t.sessionMode?{sessionMode:t.sessionMode}:{}},this.clientGUID=t.clientGUID??aD(oD(r)),this.mappedSessionStore=t.mappedSessionStore??(r?new iD(r,t.serverURL):new rD),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.syncActiveClient()}getActiveClient(){return this.activeClient}dispose(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged);for(const t of this.clients.values())t.dispose();this.clients.clear(),this.activeClient=null}syncActiveClient(){const t=this.screenManager.activeScreen,r=t?this.getClientForScreen(t):null;this.activeClient!==r&&(this.activeClient=r,this.dispatchEvent(new ee("change")))}getClientForScreen(t){const r=this.sessionMode==="single_session"?"single_session":t.id;let i=this.clients.get(r);return i||(i=new VR({...this.options,sessionMode:this.sessionMode,clientGUID:this.clientGUID,mappedSessionStore:this.mappedSessionStore}),this.clients.set(r,i)),i.setScreenContext({screenID:t.id,screenName:t.name}),i}}var Wr;class rD{constructor(){S(this,Wr,new Map)}getActualSessionId(e){return l(this,Wr).get(e)??null}setActualSessionId(e,t){l(this,Wr).set(e,t)}clearActualSessionId(e){l(this,Wr).delete(e)}}Wr=new WeakMap;const Hp=1;var qr,ws,Xe,Yo,Ko,Lc;class iD{constructor(e,t){S(this,Xe);S(this,qr);S(this,ws);k(this,qr,e),k(this,ws,t)}getActualSessionId(e){const t=g(this,Xe,Ko).call(this)[g(this,Xe,Yo).call(this,e)];return typeof t=="string"&&t.length>0?t:null}setActualSessionId(e,t){const r=g(this,Xe,Ko).call(this);r[g(this,Xe,Yo).call(this,e)]=t,g(this,Xe,Lc).call(this,r)}clearActualSessionId(e){const t=g(this,Xe,Ko).call(this);delete t[g(this,Xe,Yo).call(this,e)],g(this,Xe,Lc).call(this,t)}}qr=new WeakMap,ws=new WeakMap,Xe=new WeakSet,Yo=function(e){return JSON.stringify([l(this,ws),e])},Ko=function(){const e=l(this,qr).getItem(Zp);if(!e)return{};let t;try{t=JSON.parse(e)}catch{return{}}if(typeof t!="object"||t===null||Array.isArray(t))return{};const r=t;return r.version!==Hp?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},Lc=function(e){const t={version:Hp,entries:e};l(this,qr).setItem(Zp,JSON.stringify(t))};function sD(){return typeof window>"u"?null:window.localStorage}function oD(n){if(!n)throw new Error("ACPClientManager requires storage when clientGUID is not provided");return n}function aD(n){const e=n.getItem(Fp);if(e)return e;const t=Uu().toLowerCase();return n.setItem(Fp,t),t}var Ss;class lD extends mt{constructor(){super();S(this,Ss,t=>{const r=cD(t);r!==null&&(t.preventDefault(),this.dispatchEvent(new ZE("shortcut-triggered",{shortcut:r})))});document.addEventListener("keydown",l(this,Ss))}dispose(){document.removeEventListener("keydown",l(this,Ss))}}Ss=new WeakMap;function cD(n){for(const[e,t]of Object.entries(bx))if(uD(n,t.trigger))return e;return null}function uD(n,e){return!(n.key.toLowerCase()!==e.key.toLowerCase()||n.metaKey!==!!e.meta||n.ctrlKey!==!!e.ctrl||n.shiftKey!==!!e.shift||n.altKey!==!!e.alt)}const hD="serverURL",dD="token",pD="mode",fD="electron";function Pv(n=window.location.search,e=window.location.origin){const r=new URLSearchParams(n).get(hD);return r?new URL(r).origin:new URL(e).origin}function Mc(n=window.location.search){return new URLSearchParams(n).get(dD)}function Rv(n=window.location.search){return new URLSearchParams(n).get(pD)===fD}/**
44
- * @license
45
- * Copyright 2017 Google LLC
46
- * SPDX-License-Identifier: BSD-3-Clause
47
- */const ts=globalThis,Bp=n=>n,fa=ts.trustedTypes,jp=fa?fa.createPolicy("lit-html",{createHTML:n=>n}):void 0,Dv="$lit$",nn=`lit$${Math.random().toFixed(9).slice(2)}$`,Ov="?"+nn,gD=`<${Ov}>`,hr=document,ss=()=>hr.createComment(""),os=n=>n===null||typeof n!="object"&&typeof n!="function",Qu=Array.isArray,mD=n=>Qu(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",Wl=`[
48
- \f\r]`,Di=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Gp=/-->/g,Vp=/>/g,Tn=RegExp(`>|${Wl}(?:([^\\s"'>=/]+)(${Wl}*=${Wl}*(?:[^
49
- \f\r"'\`<>=]|("|')|))|$)`,"g"),Wp=/'/g,qp=/"/g,zv=/^(?:script|style|textarea|title)$/i,vD=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),U=vD(1),ui=Symbol.for("lit-noChange"),ae=Symbol.for("lit-nothing"),Yp=new WeakMap,Nn=hr.createTreeWalker(hr,129);function Lv(n,e){if(!Qu(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return jp!==void 0?jp.createHTML(e):e}const yD=(n,e)=>{const t=n.length-1,r=[];let i,s=e===2?"<svg>":e===3?"<math>":"",o=Di;for(let a=0;a<t;a++){const c=n[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===Di?d[1]==="!--"?o=Gp:d[1]!==void 0?o=Vp:d[2]!==void 0?(zv.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=Tn):d[3]!==void 0&&(o=Tn):o===Tn?d[0]===">"?(o=i??Di,p=-1):d[1]===void 0?p=-2:(p=o.lastIndex-d[2].length,u=d[1],o=d[3]===void 0?Tn:d[3]==='"'?qp:Wp):o===qp||o===Wp?o=Tn:o===Gp||o===Vp?o=Di:(o=Tn,i=void 0);const v=o===Tn&&n[a+1].startsWith("/>")?" ":"";s+=o===Di?c+gD:p>=0?(r.push(u),c.slice(0,p)+Dv+c.slice(p)+nn+v):c+nn+(p===-2?a:v)}return[Lv(n,s+(n[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class as{constructor({strings:e,_$litType$:t},r){let i;this.parts=[];let s=0,o=0;const a=e.length-1,c=this.parts,[u,d]=yD(e,t);if(this.el=as.createElement(u,r),Nn.currentNode=this.el.content,t===2||t===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=Nn.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(Dv)){const y=d[o++],v=i.getAttribute(p).split(nn),$=/([.?@])?(.*)/.exec(y);c.push({type:1,index:s,name:$[2],strings:v,ctor:$[1]==="."?wD:$[1]==="?"?SD:$[1]==="@"?_D:Qa}),i.removeAttribute(p)}else p.startsWith(nn)&&(c.push({type:6,index:s}),i.removeAttribute(p));if(zv.test(i.tagName)){const p=i.textContent.split(nn),y=p.length-1;if(y>0){i.textContent=fa?fa.emptyScript:"";for(let v=0;v<y;v++)i.append(p[v],ss()),Nn.nextNode(),c.push({type:2,index:++s});i.append(p[y],ss())}}}else if(i.nodeType===8)if(i.data===Ov)c.push({type:2,index:s});else{let p=-1;for(;(p=i.data.indexOf(nn,p+1))!==-1;)c.push({type:7,index:s}),p+=nn.length-1}s++}}static createElement(e,t){const r=hr.createElement("template");return r.innerHTML=e,r}}function hi(n,e,t=n,r){var o,a;if(e===ui)return e;let i=r!==void 0?(o=t._$Co)==null?void 0:o[r]:t._$Cl;const s=os(e)?void 0:e._$litDirective$;return(i==null?void 0:i.constructor)!==s&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),s===void 0?i=void 0:(i=new s(n),i._$AT(n,t,r)),r!==void 0?(t._$Co??(t._$Co=[]))[r]=i:t._$Cl=i),i!==void 0&&(e=hi(n,i._$AS(n,e.values),i,r)),e}class bD{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:r}=this._$AD,i=((e==null?void 0:e.creationScope)??hr).importNode(t,!0);Nn.currentNode=i;let s=Nn.nextNode(),o=0,a=0,c=r[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new eh(s,s.nextSibling,this,e):c.type===1?u=new c.ctor(s,c.name,c.strings,this,e):c.type===6&&(u=new kD(s,this,e)),this._$AV.push(u),c=r[++a]}o!==(c==null?void 0:c.index)&&(s=Nn.nextNode(),o++)}return Nn.currentNode=hr,i}p(e){let t=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,t),t+=r.strings.length-2):r._$AI(e[t])),t++}}let eh=class Mv{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,r,i){this.type=2,this._$AH=ae,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=r,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=hi(this,e,t),os(e)?e===ae||e==null||e===""?(this._$AH!==ae&&this._$AR(),this._$AH=ae):e!==this._$AH&&e!==ui&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):mD(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&&os(this._$AH)?this._$AA.nextSibling.data=e:this.T(hr.createTextNode(e)),this._$AH=e}$(e){var s;const{values:t,_$litType$:r}=e,i=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=as.createElement(Lv(r.h,r.h[0]),this.options)),r);if(((s=this._$AH)==null?void 0:s._$AD)===i)this._$AH.p(t);else{const o=new bD(i,this),a=o.u(this.options);o.p(t),this.T(a),this._$AH=o}}_$AC(e){let t=Yp.get(e.strings);return t===void 0&&Yp.set(e.strings,t=new as(e)),t}k(e){Qu(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let r,i=0;for(const s of e)i===t.length?t.push(r=new Mv(this.O(ss()),this.O(ss()),this,this.options)):r=t[i],r._$AI(s),i++;i<t.length&&(this._$AR(r&&r._$AB.nextSibling,i),t.length=i)}_$AR(e=this._$AA.nextSibling,t){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,t);e!==this._$AB;){const i=Bp(e).nextSibling;Bp(e).remove(),e=i}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},Qa=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,r,i,s){this.type=1,this._$AH=ae,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=s,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=ae}_$AI(e,t=this,r,i){const s=this.strings;let o=!1;if(s===void 0)e=hi(this,e,t,0),o=!os(e)||e!==this._$AH&&e!==ui,o&&(this._$AH=e);else{const a=e;let c,u;for(e=s[0],c=0;c<s.length-1;c++)u=hi(this,a[r+c],t,c),u===ui&&(u=this._$AH[c]),o||(o=!os(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??"")}},wD=class extends Qa{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ae?void 0:e}},SD=class extends Qa{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==ae)}},_D=class extends Qa{constructor(e,t,r,i,s){super(e,t,r,i,s),this.type=5}_$AI(e,t=this){if((e=hi(this,e,t,0)??ae)===ui)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 t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}};class kD{constructor(e,t,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){hi(this,e)}}const ql=ts.litHtmlPolyfillSupport;ql==null||ql(as,eh),(ts.litHtmlVersions??(ts.litHtmlVersions=[])).push("3.3.2");const Re=(n,e,t)=>{const r=e;let i=r._$litPart$;return i===void 0&&(r._$litPart$=i=new eh(e.insertBefore(ss(),null),null,void 0,{})),i._$AI(n),i},ED=.5,Kp=.1,Jp=8,xD=4,Nv=3,Uv=3,AD=4,Un=255,Fv=.2126,Zv=.7152,Hv=.0722;async function th(n){const e=$D(n);if(!e)return"light";try{return await ID(n,e)>=ED?"light":"dark"}catch{return"light"}}function $D(n){if(typeof document.elementsFromPoint!="function")return null;const e=n.getBoundingClientRect(),t=e.left+e.width/2,r=e.top+e.height/2,i=document.elementsFromPoint(t,r);for(const s of i){if(!(s instanceof HTMLElement)||s===n||n.contains(s))continue;const o=window.getComputedStyle(s);if(TD(o))return s}return null}function TD(n){return n.backgroundImage&&n.backgroundImage!=="none"?!0:CD(n.backgroundColor)>0}function CD(n){if(!n)return 0;const e=n.match(/rgba?\(([^)]+)\)/);if(!e)return 0;const t=e[1].split(/[\s,/]+/).filter(Boolean);return t.length===AD?parseFloat(t[Nv]):t.length===Uv?1:0}async function ID(n,e){const t=n.getBoundingClientRect(),r=e.getBoundingClientRect(),i={x:Io((t.left-r.left)/r.width),y:Io((t.top-r.top)/r.height),width:Io(t.width/r.width),height:Io(t.height/r.height)},s=window.getComputedStyle(e),o=PD(s.backgroundImage);return o?DD({url:o,surfaceWidth:r.width,surfaceHeight:r.height,region:i}):OD(s.backgroundColor)}function PD(n){const e=n.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return e?e[1]:null}const Xp=new Map;function RD(n){let e=Xp.get(n);return e||(e=new Promise((t,r)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>t(i),i.onerror=()=>r(new Error(`Failed to load ${n}`)),i.src=n}),Xp.set(n,e),e)}async function DD(n){const e=await RD(n.url),t=Math.max(Jp,Math.ceil(n.surfaceWidth*Kp)),r=Math.max(Jp,Math.ceil(n.surfaceHeight*Kp)),i=document.createElement("canvas");i.width=t,i.height=r;const s=i.getContext("2d",{willReadFrequently:!0});if(!s)return 1;const o=n.surfaceWidth/n.surfaceHeight,a=e.naturalWidth/e.naturalHeight;let c,u;a>o?(u=r,c=r*a):(c=t,u=t/a);const d=(t-c)/2,p=(r-u)/2;s.drawImage(e,d,p,c,u);const y=Math.max(0,Math.floor(n.region.x*t)),v=Math.max(0,Math.floor(n.region.y*r)),$=Math.max(1,Math.min(t-y,Math.floor(n.region.width*t))),E=Math.max(1,Math.min(r-v,Math.floor(n.region.height*r))),I=s.getImageData(y,v,$,E).data;let Z=0,P=0;for(let G=0;G<I.length;G+=xD){const O=I[G]/Un,H=I[G+1]/Un,N=I[G+2]/Un,ce=I[G+Nv]/Un;Z+=ce*(Fv*O+Zv*H+Hv*N),P+=1}return P>0?Z/P:1}function OD(n){const e=n.match(/rgba?\(([^)]+)\)/);if(!e)return 1;const t=e[1].split(/[\s,/]+/).filter(Boolean).map(parseFloat);if(t.length<Uv)return 1;const r=t[0]/Un,i=t[1]/Un,s=t[2]/Un;return Fv*r+Zv*i+Hv*s}function Io(n){return n<0?0:n>1?1:n}const Yl=new WeakSet,Qp=new WeakSet;function Bv(n){if(Qp.has(n))return;Qp.add(n);for(const t of n.querySelectorAll('button[variant="ghost"]'))Kl(t);if(typeof MutationObserver!="function")return;new MutationObserver(t=>{for(const r of t)if(r.type==="childList")for(const i of r.addedNodes)zD(i,Kl);else r.type==="attributes"&&r.target instanceof HTMLButtonElement&&r.target.getAttribute("variant")==="ghost"&&Kl(r.target)}).observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["variant"]})}function zD(n,e){if(n instanceof Element){n instanceof HTMLButtonElement&&n.getAttribute("variant")==="ghost"&&e(n);for(const t of n.querySelectorAll('button[variant="ghost"]'))e(t)}}async function Kl(n){if(Yl.has(n))return;Yl.add(n);const e=await th(n);if(n.getAttribute("variant")!=="ghost"){Yl.delete(n);return}n.setAttribute("tone",e)}const LD="*,*: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)}',nh=new CSSStyleSheet;nh.replaceSync(LD);try{document.adoptedStyleSheets=[...document.adoptedStyleSheets,nh]}catch{}Bv(document);function jv(n){try{n.adoptedStyleSheets=[...n.adoptedStyleSheets,nh]}catch{}Bv(n)}/**
50
- * @license
51
- * Copyright 2017 Google LLC
52
- * SPDX-License-Identifier: BSD-3-Clause
53
- */const Gv={CHILD:2},rh=n=>(...e)=>({_$litDirective$:n,values:e});class Vv{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,r){this._$Ct=e,this._$AM=t,this._$Ci=r}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}/**
54
- * @license
55
- * Copyright 2017 Google LLC
56
- * SPDX-License-Identifier: BSD-3-Clause
57
- */let ga=class extends Vv{constructor(e){if(super(e),this.it=ae,e.type!==Gv.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===ui)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};ga.directiveName="unsafeHTML",ga.resultType=1;const MD=rh(ga);/**
58
- * @license
59
- * Copyright 2017 Google LLC
60
- * SPDX-License-Identifier: BSD-3-Clause
61
- */class Nc extends ga{}Nc.directiveName="unsafeSVG",Nc.resultType=2;const ND=rh(Nc),UD={size:16,color:"currentColor",weight:"regular"};function FD(n){return typeof n=="string"?{regular:n}:n}function Qt(n,e="0 0 256 256"){const t=FD(n);return r=>{const{size:i,color:s,weight:o}={...UD,...r},a=t[o]??t.regular;return U`<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
- >${ND(a)}</svg>`}}const ZD=Qt('<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"/>'),Wv=Qt('<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"/>'),HD=Qt('<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"/>'),qv=Qt('<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"/>'),BD=Qt('<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"/>'),jD=Qt('<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"/>'),GD=Qt({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"/>'}),VD=Qt({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"/>'}),WD=Qt({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 Yv extends Event{constructor(t){super("dropdown-item-select",{bubbles:!0,composed:!0});b(this,"value");this.value=t}}class qD extends Event{constructor(t){super("select",{bubbles:!0,composed:!0});b(this,"value");this.value=t}}var Ke,ht,un,Jn,ne,_s,L,Jv,Gi,Xv,Qv,Uc,ey,Vi,Pn,Xn,ks,Es,xs,ka,ty,ny,Fc,Wi,ry,Zc,Mt;class Kv extends HTMLElement{constructor(){super();S(this,L);S(this,Ke,!1);S(this,ht,null);S(this,un,null);S(this,Jn);S(this,ne,null);S(this,_s,new MutationObserver(t=>g(this,L,ty).call(this,t)));S(this,Xn,()=>{g(this,L,Vi).call(this,!l(this,Ke))});S(this,ks,t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),l(this,Xn).call(this))});S(this,Es,t=>{l(this,Ke)&&(t.composedPath().includes(this)||g(this,L,Vi).call(this,!1))});S(this,xs,t=>{t instanceof Yv&&(t.stopPropagation(),k(this,Ke,!1),g(this,L,Gi).call(this,t.value),g(this,L,Mt).call(this),this.dispatchEvent(new qD(t.value)))});S(this,ka,()=>{g(this,L,Fc).call(this)});k(this,Jn,this.attachShadow({mode:"open"})),jv(l(this,Jn))}connectedCallback(){this.addEventListener("dropdown-item-select",l(this,xs)),document.addEventListener("click",l(this,Es),!0),g(this,L,Jv).call(this),l(this,_s).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),g(this,L,Mt).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",l(this,xs)),document.removeEventListener("click",l(this,Es),!0),l(this,_s).disconnect(),g(this,L,Zc).call(this)}attributeChangedCallback(t){if(t==="open"){g(this,L,Vi).call(this,this.hasAttribute("open"));return}g(this,L,Mt).call(this)}get open(){return l(this,Ke)}set open(t){this.toggleAttribute("open",t)}get title(){return this.getAttribute("title")??""}get placement(){return this.getAttribute("placement")==="top"?"top":"bottom"}get value(){return l(this,ht)}set value(t){t===null?(g(this,L,Pn).call(this,null,null),g(this,L,Xv).call(this)):g(this,L,Gi).call(this,t),g(this,L,Mt).call(this)}close(){g(this,L,Vi).call(this,!1)}}Ke=new WeakMap,ht=new WeakMap,un=new WeakMap,Jn=new WeakMap,ne=new WeakMap,_s=new WeakMap,L=new WeakSet,Jv=function(){var r;const t=this.querySelector("dropdown-item[selected]");t&&g(this,L,Pn).call(this,t.value,((r=t.textContent)==null?void 0:r.trim())??null)},Gi=function(t){var r;for(const i of l(this,L,Uc))i.value===t?(g(this,L,Pn).call(this,t,((r=i.textContent)==null?void 0:r.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},Xv=function(){const t=this.querySelectorAll("dropdown-item[selected]");for(const r of t)r.removeAttribute("selected")},Qv=function(t){for(const r of l(this,L,Uc))if(r.value===t)return r;return null},Uc=function(){return this.querySelectorAll("dropdown-item")},ey=function(){return l(this,un)??this.title},Vi=function(t){l(this,Ke)!==t&&(k(this,Ke,t),g(this,L,Mt).call(this))},Pn=function(t,r){k(this,ht,t),k(this,un,r)},Xn=new WeakMap,ks=new WeakMap,Es=new WeakMap,xs=new WeakMap,ka=new WeakMap,ty=function(t){t.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||g(this,L,ny).call(this)},ny=function(){var r,i;const t=this.querySelector("dropdown-item[selected]");if(t){const s=t.value,o=((r=t.textContent)==null?void 0:r.trim())??null,a=l(this,ht)!==s||l(this,un)!==o;g(this,L,Pn).call(this,s,o),g(this,L,Gi).call(this,s),a?g(this,L,Mt).call(this):g(this,L,Wi).call(this);return}if(l(this,ht)!==null){const s=g(this,L,Qv).call(this,l(this,ht));if(s){const o=((i=s.textContent)==null?void 0:i.trim())??null,a=l(this,un)!==o;g(this,L,Pn).call(this,l(this,ht),o),g(this,L,Gi).call(this,l(this,ht)),a?g(this,L,Mt).call(this):g(this,L,Wi).call(this);return}}if(l(this,ht)!==null||l(this,un)!==null){g(this,L,Pn).call(this,null,null),g(this,L,Mt).call(this);return}g(this,L,Wi).call(this)},Fc=function(){const t=l(this,Jn).querySelector('slot[name="trigger"]'),r=t instanceof HTMLSlotElement?t.assignedElements()[0]??null:null;l(this,ne)!==r&&(g(this,L,Zc).call(this),k(this,ne,r),l(this,ne)&&(l(this,ne).addEventListener("click",l(this,Xn)),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,ks))))),g(this,L,Wi).call(this)},Wi=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"))},ry=function(){return this.placement==="top"?BD:qv},Zc=function(){l(this,ne)&&(l(this,ne).removeEventListener("click",l(this,Xn)),l(this,ne).removeEventListener("keydown",l(this,ks)),l(this,ne).removeAttribute("data-dropdown-trigger"),l(this,ne).removeAttribute("aria-haspopup"),l(this,ne).removeAttribute("aria-expanded"),k(this,ne,null))},Mt=function(){this.toggleAttribute("open",l(this,Ke)),Re(U`
69
- <slot name="trigger" @slotchange=${l(this,ka)}>
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,Xn)}
77
- >
78
- <span class="trigger-label" part="trigger-label">${l(this,L,ey)}</span>
79
- <span class="trigger-icon" part="trigger-icon" aria-hidden="true">
80
- ${l(this,L,ry).call(this,{size:16})}
81
- </span>
82
- </button>
83
- </slot>
84
- ${l(this,Ke)?U`
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,Jn)),queueMicrotask(()=>g(this,L,Fc).call(this))},b(Kv,"observedAttributes",["title","placement","open"]);class YD extends HTMLElement{}class KD extends HTMLElement{}class JD extends HTMLElement{}var fr,Hc,sy,As,$s;class iy extends HTMLElement{constructor(){super(...arguments);S(this,fr);S(this,As,()=>{this.action||g(this,fr,sy).call(this)});S(this,$s,t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",l(this,As)),this.addEventListener("keydown",l(this,$s)),g(this,fr,Hc).call(this)}disconnectedCallback(){this.removeEventListener("click",l(this,As)),this.removeEventListener("keydown",l(this,$s))}attributeChangedCallback(){g(this,fr,Hc).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}fr=new WeakSet,Hc=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")},sy=function(){this.dispatchEvent(new Yv(this.value))},As=new WeakMap,$s=new WeakMap,b(iy,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",Kv);customElements.get("dropdown-group")||customElements.define("dropdown-group",YD);customElements.get("dropdown-label")||customElements.define("dropdown-label",KD);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",JD);customElements.get("dropdown-item")||customElements.define("dropdown-item",iy);class XD extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var Ts,yn,Bc,Ea,Cs,jc;class oy extends HTMLElement{constructor(){super();S(this,yn);S(this,Ts);S(this,Ea,t=>{t.target===t.currentTarget&&g(this,yn,Bc).call(this)});S(this,Cs,t=>{this.open&&t.key==="Escape"&&g(this,yn,Bc).call(this)});k(this,Ts,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",l(this,Cs)),g(this,yn,jc).call(this)}disconnectedCallback(){document.removeEventListener("keydown",l(this,Cs))}attributeChangedCallback(){g(this,yn,jc).call(this)}get open(){return this.hasAttribute("open")}}Ts=new WeakMap,yn=new WeakSet,Bc=function(){this.dispatchEvent(new XD)},Ea=new WeakMap,Cs=new WeakMap,jc=function(){Re(U`
96
- ${this.open?U`
97
- <div class="backdrop" part="backdrop" @click=${l(this,Ea)}>
98
- <slot></slot>
99
- </div>
100
- `:null}
101
- `,l(this,Ts))},b(oy,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",oy);class QD extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class eO extends HTMLElement{}var Is,Ps,Gc;class ay extends HTMLElement{constructor(){super();S(this,Ps);S(this,Is);k(this,Is,this.attachShadow({mode:"open"}))}connectedCallback(){g(this,Ps,Gc).call(this)}attributeChangedCallback(){g(this,Ps,Gc).call(this)}get closable(){return this.hasAttribute("closable")}}Is=new WeakMap,Ps=new WeakSet,Gc=function(){const t=this.querySelector("panel-page");Re(U`
102
- <section class="panel" part="panel">
103
- <header class="title-bar" part="header">
104
- <h2 class="title" part="title">${(t==null?void 0:t.getAttribute("title"))??""}</h2>
105
- ${this.closable?U`
106
- <button
107
- type="button"
108
- class="title-button"
109
- part="button close-button"
110
- aria-label="Close"
111
- @click=${()=>this.dispatchEvent(new QD)}
112
- >
113
- <span class="close-icon" part="icon close-icon">${Wv({size:16})}</span>
114
- </button>
115
- `:null}
116
- </header>
117
- <slot></slot>
118
- </section>
119
- `,l(this,Is))},b(ay,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",ay);customElements.get("panel-page")||customElements.define("panel-page",eO);class tO extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const ef='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Jl=4;var je,Gt,Qn,tt,Rs,Yr,re,cy,uy,Vc,Ds,Os,er,hy,Wc,dy,py,Jo,Xo;class ly extends HTMLElement{constructor(){super();S(this,re);S(this,je,!1);S(this,Gt,null);S(this,Qn);S(this,tt,null);S(this,Rs,"bottom-start");S(this,Yr,!1);S(this,Ds,t=>{l(this,je)&&(l(this,Yr)||t.composedPath().includes(this)||(this.open=!1))});S(this,Os,t=>{if(l(this,je)){if(t.key==="Escape"){t.preventDefault(),this.open=!1;return}t.key==="Tab"&&g(this,re,hy).call(this,t)}});S(this,er,()=>{l(this,je)&&g(this,re,Jo).call(this)});k(this,Qn,this.attachShadow({mode:"open"})),jv(l(this,Qn))}connectedCallback(){this.hasAttribute("tone")||this.setAttribute("tone","light"),g(this,re,Xo).call(this)}disconnectedCallback(){g(this,re,Vc).call(this)}attributeChangedCallback(t){t==="open"&&g(this,re,cy).call(this,this.hasAttribute("open"))}get open(){return l(this,je)}set open(t){this.toggleAttribute("open",t)}get anchor(){return l(this,Gt)}set anchor(t){l(this,Gt)!==t&&(k(this,Gt,t),l(this,je)&&g(this,re,Jo).call(this))}}je=new WeakMap,Gt=new WeakMap,Qn=new WeakMap,tt=new WeakMap,Rs=new WeakMap,Yr=new WeakMap,re=new WeakSet,cy=function(t){var r;l(this,je)!==t&&(k(this,je,t),t?(k(this,Yr,!0),setTimeout(()=>{k(this,Yr,!1)},0),g(this,re,Xo).call(this),g(this,re,uy).call(this),queueMicrotask(()=>{l(this,je)&&(g(this,re,Jo).call(this),g(this,re,py).call(this))})):(g(this,re,Vc).call(this),g(this,re,Xo).call(this),(r=l(this,Gt))==null||r.focus(),this.dispatchEvent(new tO)))},uy=function(){document.addEventListener("click",l(this,Ds)),document.addEventListener("keydown",l(this,Os),!0),window.addEventListener("resize",l(this,er)),window.addEventListener("scroll",l(this,er),!0)},Vc=function(){document.removeEventListener("click",l(this,Ds)),document.removeEventListener("keydown",l(this,Os),!0),window.removeEventListener("resize",l(this,er)),window.removeEventListener("scroll",l(this,er),!0)},Ds=new WeakMap,Os=new WeakMap,er=new WeakMap,hy=function(t){const r=g(this,re,Wc).call(this);if(r.length===0){t.preventDefault();return}const i=r[0],s=r[r.length-1],o=g(this,re,dy).call(this),a=o instanceof HTMLElement&&r.includes(o);t.shiftKey?(!a||o===i)&&(t.preventDefault(),s.focus()):(!a||o===s)&&(t.preventDefault(),i.focus())},Wc=function(){if(!l(this,tt))return[];const t=l(this,tt).querySelector("slot");if(!(t instanceof HTMLSlotElement))return[];const r=[];for(const i of t.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches(ef)&&r.push(i);for(const s of i.querySelectorAll(ef))r.push(s)}return r},dy=function(){var r;let t=document.activeElement;for(;t&&((r=t.shadowRoot)!=null&&r.activeElement);)t=t.shadowRoot.activeElement;return t},py=function(){var r;const t=g(this,re,Wc).call(this);t.length>0?t[0].focus():(r=l(this,tt))==null||r.focus()},Jo=function(){if(!l(this,je)||!l(this,Gt)||!l(this,tt))return;const t=l(this,Gt).getBoundingClientRect(),r=l(this,tt).getBoundingClientRect(),s=window.innerHeight-t.bottom,o=r.height+Jl,a=s<o&&t.top>o?"top-start":"bottom-start";k(this,Rs,a);const c=a==="bottom-start"?t.bottom+Jl:t.top-r.height-Jl,u=t.left;l(this,tt).style.top=`${c}px`,l(this,tt).style.left=`${u}px`,l(this,tt).setAttribute("data-placement",a)},Xo=function(){this.toggleAttribute("open",l(this,je)),Re(l(this,je)?U`<div
120
- class="panel"
121
- part="panel"
122
- data-placement=${l(this,Rs)}
123
- tabindex="-1"
124
- role="dialog"
125
- material="paper"
126
- level="1"
127
- >
128
- <slot></slot>
129
- </div>`:ae,l(this,Qn)),k(this,tt,l(this,Qn).querySelector(".panel"))},b(ly,"observedAttributes",["open"]);customElements.get("ui-popover")||customElements.define("ui-popover",ly);const nO=gt(),rO="No handler registered for update-content",iO="handleUpdateContent: handler already registered";function sO(n){return n instanceof Error&&typeof n.message=="string"?n.message:String(n)}const oO=wi(mt);var Kr,Jr,Xr,tr,nr,zs,Ce,qc,fy,gy,qi,Yc,Rf;let aO=(Rf=class extends oO{constructor(t){super();S(this,Ce);S(this,Kr);S(this,Jr);S(this,Xr);S(this,tr,null);S(this,nr,null);S(this,zs,!1);k(this,Kr,t);const r=t.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");k(this,Jr,r),k(this,Xr,i=>g(this,Ce,fy).call(this,i)),l(this,Jr).addEventListener("message",l(this,Xr))}get content(){return l(this,nr)}set content(t){g(this,Ce,Yc).call(this),k(this,nr,t),l(this,zs)&&g(this,Ce,qc).call(this,t)}handleUpdateContent(t){if(g(this,Ce,Yc).call(this),l(this,tr)!==null)throw new Error(iO);k(this,tr,t)}dispose(){l(this,Jr).removeEventListener("message",l(this,Xr)),k(this,tr,null)}},Kr=new WeakMap,Jr=new WeakMap,Xr=new WeakMap,tr=new WeakMap,nr=new WeakMap,zs=new WeakMap,Ce=new WeakSet,qc=function(t){const r={type:"content-updated",content:t};g(this,Ce,qi).call(this,r)},fy=function(t){if(this.disposed||t.source!==l(this,Kr).contentWindow)return;const r=t.data;if(cC(r)){k(this,zs,!0),this.dispatchEvent(new nO("ready")),l(this,nr)!==null&&g(this,Ce,qc).call(this,l(this,nr));return}if(uC(r)){g(this,Ce,gy).call(this,r);return}},gy=async function(t){const r=l(this,tr);if(r===null){g(this,Ce,qi).call(this,{type:"response",id:t.id,error:{message:rO}});return}try{await r(t.content)}catch(i){if(this.disposed)return;g(this,Ce,qi).call(this,{type:"response",id:t.id,error:{message:sO(i)}});return}this.disposed||g(this,Ce,qi).call(this,{type:"response",id:t.id,result:{}})},qi=function(t){const r=l(this,Kr).contentWindow;r&&r.postMessage(t,"*")},Yc=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},Rf);function lO(n=window){if(n.parent===n)return;let e=0,t=0;n.addEventListener("wheel",r=>{const i=r;e=i.clientX,t=i.clientY,n.parent.postMessage({type:"wheel",deltaX:i.deltaX,deltaY:i.deltaY,shiftKey:i.shiftKey},"*"),i.preventDefault()},{passive:!1}),n.addEventListener("message",r=>{var u,d;const i=r.data;if(i===null||typeof i!="object"||i.type!=="scroll")return;const s=i,o=typeof s.deltaX=="number"?s.deltaX:0,a=typeof s.deltaY=="number"?s.deltaY:0;let c=((d=(u=n.document).elementFromPoint)==null?void 0:d.call(u,e,t))??null;for(;c!==null;){const p=n.getComputedStyle(c);if(a!==0){const y=(p.overflowY==="auto"||p.overflowY==="scroll")&&c.scrollHeight>c.clientHeight,v=a>0?c.scrollTop+c.clientHeight<c.scrollHeight:c.scrollTop>0;if(y&&v){c.scrollBy(o,a);return}}if(o!==0){const y=(p.overflowX==="auto"||p.overflowX==="scroll")&&c.scrollWidth>c.clientWidth,v=o>0?c.scrollLeft+c.clientWidth<c.scrollWidth:c.scrollLeft>0;if(y&&v){c.scrollBy(o,a);return}}c=c.parentElement}n.scrollBy(o,a)})}function cO(){return`(${lO.toString()})(window);`}async function uO(n){const e=await fetch(n);if(!e.ok)throw new Error(`Failed to fetch artifact content: ${e.status}`);const t=await e.text(),r=new DOMParser().parseFromString(t,"text/html"),i=r.createElement("base");i.href=n,r.head.insertBefore(i,r.head.firstChild);const s=r.createElement("script");s.textContent=cO(),r.head.appendChild(s);const o=new Blob([`<!DOCTYPE html>
130
- ${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const my=gt();class hO extends HTMLElement{constructor(){super(...arguments);b(this,"_artifact",null);b(this,"_viewURL",null);b(this,"_contentURL",null);b(this,"_screen",null);b(this,"_subscribedScreen",null);b(this,"_activeView",null);b(this,"_contentState",{kind:"idle"});b(this,"_fetchSequence",0);b(this,"_blobSequence",0);b(this,"_mountedViewURL",null);b(this,"_directRender",!1);b(this,"_blobURL",null);b(this,"handleScreenContentChanged",t=>{!this._artifact||t.artifactID!==this._artifact.id||this._activeView!==null&&this.refetchContent()})}set artifact(t){const r=this._artifact;this._artifact=t,this.render(),r!==null&&r!==t&&this.syncView()}get artifact(){return this._artifact}set viewURL(t){this._viewURL!==t&&(this._viewURL=t,this.syncView())}get viewURL(){return this._viewURL}set contentURL(t){this._contentURL!==t&&(this._contentURL=t,this.syncView())}get contentURL(){return this._contentURL}set screen(t){this._screen!==t&&(this._screen=t,this.syncScreenSubscription())}get screen(){return this._screen}set dragging(t){t?this.setAttribute("dragging","true"):this.removeAttribute("dragging")}get dragging(){return this.getAttribute("dragging")==="true"}get activeView(){return this._activeView}connectedCallback(){this.setAttribute("level","2"),this.render(),this.syncView(),this.syncScreenSubscription()}disconnectedCallback(){this.teardownView(),this.unsubscribeFromScreen()}handleClose(){this._artifact&&this.dispatchEvent(new my("close-artifact",{artifactID:this._artifact.id,bubbles:!0,composed:!0}))}syncView(){var t;if(this.isConnected){if(this._viewURL!==null){if(this._directRender&&this.teardownView(),this._mountedViewURL!==this._viewURL){this.teardownView(),this._contentState={kind:"loading"},this._mountedViewURL=this._viewURL,this.render();const r=this.querySelector("iframe.artifact-frame");if(!r){this._contentState={kind:"error"},this.render();return}this._activeView=new aO(r),this._activeView.handleUpdateContent(async i=>{await this.saveContent(i)}),this.loadBlobFrame(this._viewURL),this.startContentFetch();return}this._activeView!==null&&this.startContentFetch();return}if(this._contentURL!==null){this.teardownView(),this._directRender=!0,this._contentState={kind:"idle"},this.render(),((t=this._artifact)==null?void 0:t.status)==="committed"&&this.loadBlobFrame(this._contentURL);return}this.teardownView(),this._contentState={kind:"idle"},this.render()}}async saveContent(t){const r=this._screen,i=this._artifact;if(!r||!i)throw new Error("artifact-view: cannot save without a screen and artifact");await r.server.client.artifacts.putContent({artifactID:i.id,content:t})}syncScreenSubscription(){if(!this.isConnected){this.unsubscribeFromScreen();return}this._subscribedScreen!==this._screen&&(this.unsubscribeFromScreen(),this._screen!==null&&(this._screen.addEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=this._screen))}unsubscribeFromScreen(){this._subscribedScreen!==null&&(this._subscribedScreen.removeEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=null)}startContentFetch(){this._fetchSequence+=1;const t=this._fetchSequence,r=this._contentURL,i=this._activeView;if(!i||r===null){this._contentState={kind:"error"},this.render();return}this._contentState={kind:"loading"},(async()=>{try{const s=await fetch(r);if(t!==this._fetchSequence)return;if(!s.ok){this._contentState={kind:"error"},this.teardownView(),this.render();return}const o=await s.text();if(t!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o,this._contentState={kind:"ready"}}catch{if(t!==this._fetchSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}refetchContent(){this._fetchSequence+=1;const t=this._fetchSequence,r=this._contentURL,i=this._activeView;!i||r===null||(async()=>{try{const s=await fetch(r);if(t!==this._fetchSequence||!s.ok)return;const o=await s.text();if(t!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o}catch{}})()}loadBlobFrame(t){this._blobSequence+=1;const r=this._blobSequence;(async()=>{try{const i=await uO(t);if(r!==this._blobSequence){URL.revokeObjectURL(i);return}this._blobURL=i,this.render();const s=this.querySelector("iframe.artifact-frame");s&&(s.src=i)}catch{if(r!==this._blobSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}teardownView(){this._activeView!==null&&(this._activeView.dispose(),this._activeView=null),this._blobURL!==null&&(URL.revokeObjectURL(this._blobURL),this._blobURL=null),this._mountedViewURL=null,this._directRender=!1,this._fetchSequence+=1,this._blobSequence+=1}contentTemplate(){return this._contentState.kind==="error"?U`
131
- <div class="artifact-content artifact-placeholder">
132
- <em>Failed to load content</em>
133
- </div>
134
- `:this._viewURL!==null||this._directRender?U`
135
- <iframe
136
- class="artifact-frame artifact-content"
137
- src=${this._blobURL??"about:blank"}
138
- sandbox="allow-scripts"
139
- ></iframe>
140
- `:U`
141
- <div class="artifact-content artifact-placeholder">
142
- <em>Artifact unavailable</em>
143
- </div>
144
- `}template(){const t=this._artifact;return U`
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">${ZD({size:16})}</span>
149
- <span class="artifact-title">${t.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
- ${Wv({size:16})}
159
- </button>
160
- </footer>
161
- `}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),Re(this.template(),this))}}customElements.define("artifact-view",hO);const ke=n=>({type:"px",...n}),Te=n=>({type:"unit",...n}),Po=2,dO=2;class pO{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 t=this._viewport.x??cr,r=this._viewport.y??la,i=this._gap.x??ge,s=this._gap.y??ge,o=cr+i*dO,a=t<=o,c=a?t-i*Po:Math.min(cr,t-i*Po),u=a?r-s*Po:Math.min(la,r-s*Po),d=(c-i*(Pt-1))/Pt,p=(u-s*(Qe-1))/Qe,y=this.basis.x??0,v=this.basis.y??0,$=this.min.x??0,E=this.min.y??0;this._unit=ke(a?{x:Math.max($,d),y:Math.max(E,p)}:{x:Math.max($,Math.min(y,d)),y:Math.max(E,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 t=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*t+Math.max(0,e.x-1)*i,a=e.y==null?void 0:e.y*r+Math.max(0,e.y-1)*s;return ke({x:o,y:a})}}const dr=1e-4,Wt=1e-6,fO=40,gO=24;function vy(n,e){return Math.max(0,n-e*2)}function yy(n){const e=[0];for(const t of n)e.push((e[e.length-1]??0)+t);return e}function by(n){const e=[0];for(let t=0;t<n.length;t+=1){const r=e[t]??0;e.push(r+n[t]+ge)}return e}function wy(n,e,t){if(e<0||e>=n.length)return 0;let r=0,i=0;for(let s=e;s<n.length;s+=1){const o=n[s],a=i===0?o:r+ge+o;if(a>t+dr)break;r=a,i+=1}return Math.max(1,i)}function mO(n,e,t){if(e<0||e>=n.length)return 0;let r=0,i=0;for(let s=e;s>=0;s-=1){const o=n[s],a=i===0?o:r+ge+o;if(a>t+dr)break;r=a,i+=1}return Math.max(1,i)}function vO(n,e){if(n.length===0)return 0;let t=0,r=0;for(let i=n.length-1;i>=0;i-=1){const s=n[i],o=r===0?s:t+ge+s;if(o>e+dr)break;t=o,r+=1}return Math.max(1,r)}function ih(n,e){if(n.length===0)return 0;const t=vO(n,e);return Math.max(0,n.length-t)}function tf(n,e,t){if(n.length===0)return 0;const r=wy(n,e,t),i=Math.min(n.length,e+r);if(i<=e)return 0;const s=n.slice(e,i);return s.reduce((o,a)=>o+a,0)+Math.max(0,s.length-1)*ge}function Kc(n,e,t){const r=n[e]??0;return t-r}function zr(n,e,t,r,i){if(n.length===0)return 0;const s=ih(n,i),o=e[s]??0,a=Math.max(0,Math.min(o,t));let c=0;for(let H=0;H<s;H+=1){const N=e[H]??0,ce=e[H+1]??N;if(a>=N&&a<=ce+dr){c=H;break}c=H+1}const u=Math.min(c+1,s),d=e[c]??0,p=e[u]??d,y=Math.max(p-d,dr),v=u===c?0:(a-d)/y,$=by(n),E=tf(n,c,i),I=tf(n,u,i),Z=(r-E)/2,P=(r-I)/2,G=Kc($,c,Z),O=Kc($,u,P);return G+(O-G)*v}function nf(n,e,t,r,i){const s=ih(n,r),o=e[s]??0;let a=0,c=o;for(let u=0;u<fO;u+=1){const d=(a+c)/2;zr(n,e,d,t,r)>i?a=d:c=d}return(a+c)/2}function rf(n,e,t){const r=by(n),[i,s]=e,o=n.slice(i,s+1),a=o.reduce((u,d)=>u+d,0)+Math.max(0,o.length-1)*ge,c=(t-a)/2;return Kc(r,i,c)}function yO(n,e,t){const r=wy(n,e,t);return[e,Math.min(n.length-1,e+r-1)]}function bO(n,e,t){const r=mO(n,e,t);return[Math.max(0,e-r+1),e]}function wO(n){const e=new Set,t=[];for(const r of n){const i=`${r.nodeRange[0]}:${r.nodeRange[1]}`;if(e.has(i))continue;const s=t[t.length-1];s&&Math.abs(s.anchor-r.anchor)<=Wt||(e.add(i),t.push(r))}return t}function SO(n){const{nodeCols:e,nodeWidthsPx:t,viewportWidthPx:r}=n;if(e.length===0||t.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const i=n.gapPx??ge,s=vy(r,i),o=yy(e),a=ih(t,s),c=o[a]??0,u=[];for(let d=0;d<=a;d+=1){const p=yO(t,d,s),y=rf(t,p,r),v=nf(t,o,r,s,y);u.push({nodeRange:p,anchor:Math.max(0,Math.min(c,v))})}for(let d=t.length-1;d>=0;d-=1){const p=bO(t,d,s),y=`${p[0]}:${p[1]}`;if(u.some(E=>`${E.nodeRange[0]}:${E.nodeRange[1]}`===y))continue;const v=rf(t,p,r),$=nf(t,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)>Wt?d.anchor-p.anchor:d.nodeRange[0]!==p.nodeRange[0]?d.nodeRange[0]-p.nodeRange[0]:d.nodeRange[1]-p.nodeRange[1]),{viewspans:wO(u),minScroll:0,maxScroll:c}}function _O(n,e){var i;let t=0,r=Number.POSITIVE_INFINITY;for(let s=0;s<n.length;s+=1){const o=Math.abs((((i=n[s])==null?void 0:i.anchor)??0)-e);if(o+Wt<r){r=o,t=s;continue}Math.abs(o-r)<=Wt&&s<t&&(t=s)}return t}function kO(n,e,t){return t<=0?0:Math.max(0,Math.min(t-1,n+e))}function Oi(n,e,t){return Math.max(e,Math.min(t,n))}class EO extends mt{constructor(t){super();b(this,"_scroll",0);b(this,"minScroll",0);b(this,"maxScroll",0);b(this,"viewspans",[]);b(this,"activeViewspanIndex",null);b(this,"nodeWidthsPx",[]);b(this,"boundaryCols",[0]);b(this,"viewportWidthPx",0);b(this,"framedViewportWidthPx",0);this._scroll=(t==null?void 0:t.x)??0}get scroll(){return Te({x:this._scroll})}get translate(){return ke({x:zr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx)})}set scroll(t){const r=Oi(t.x??this._scroll,this.minScroll,this.maxScroll);Math.abs(r-this._scroll)<=Wt||(this._scroll=r,this.activeViewspanIndex=null,this.dispatchEvent(new Ri("layout-scroll",{scroll:this.scroll})))}rebuild(t){const r=t.nodeWidths.map(u=>Math.max(0,u.x??0)),i=r.map(u=>t.grid.toPixels(Te({x:u})).x??0),s=t.grid.viewport.x??0,o=t.grid.gap.x??ge,a=SO({nodeCols:r,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this.nodeWidthsPx=i,this.boundaryCols=yy(r),this.viewportWidthPx=s,this.framedViewportWidthPx=vy(s,o),this.viewspans=a.viewspans,this.minScroll=a.minScroll,this.maxScroll=a.maxScroll,this.activeViewspanIndex=null;const c=Oi(this._scroll,this.minScroll,this.maxScroll);Math.abs(c-this._scroll)>Wt&&(this._scroll=c,this.dispatchEvent(new Ri("layout-scroll",{scroll:this.scroll})))}step(t){var a;if(this.viewspans.length===0)return;const r=this.activeViewspanIndex??_O(this.viewspans,this._scroll),i=kO(r,t,this.viewspans.length),s=((a=this.viewspans[i])==null?void 0:a.anchor)??this._scroll,o=Oi(s,this.minScroll,this.maxScroll);this.activeViewspanIndex=i,!(Math.abs(o-this._scroll)<=Wt)&&(this._scroll=o,this.dispatchEvent(new Ri("layout-scroll",{scroll:this.scroll})))}wheel(t){const r=Oi(this._scroll+(t.x??0),this.minScroll,this.maxScroll);this.activeViewspanIndex=null,!(Math.abs(r-this._scroll)<=Wt)&&(this._scroll=r,this.dispatchEvent(new Ri("layout-scroll",{scroll:this.scroll})))}wheelPixels(t){const r=t.x??0;if(Math.abs(r)<=dr)return;this.activeViewspanIndex=null;const i=zr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),s=i-r,o=zr(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=zr(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),c=Math.max(o,Math.min(a,s));if(Math.abs(c-i)<=dr)return;let u=this.minScroll,d=this.maxScroll;for(let y=0;y<gO;y+=1){const v=(u+d)/2;zr(this.nodeWidthsPx,this.boundaryCols,v,this.viewportWidthPx,this.framedViewportWidthPx)>c?u=v:d=v}const p=Oi((u+d)/2,this.minScroll,this.maxScroll);Math.abs(p-this._scroll)<=Wt||(this._scroll=p,this.dispatchEvent(new Ri("layout-scroll",{scroll:this.scroll})))}}const Xl={"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}},xO=["stack-above","stack-below","reorder-before","reorder-after"];function Ql(n,e){return{left:n.left+n.width*e.left,top:n.top+n.height*e.top,width:n.width*e.width,height:n.height*e.height}}function Cn(n,e,t){return n>=t.left&&n<t.left+t.width&&e>=t.top&&e<t.top+t.height}function sh(n,e){for(const t of n){if(t.type==="card"&&t.id===e)return t;if(t.type==="stack")for(const r of t.children){if(r.type==="card"&&r.id===e)return r;if(r.type==="row"){for(const i of r.children)if(i.id===e)return i}}}return null}function Jc(n){return n.height===Qe||n.height===fn?{...n,height:fn}:n}function Xc(n){return n.height===fn?{...n,height:Qe}:n}function AO(n,e,t,r){const i=n.findIndex(d=>d.type==="stack"&&d.id===e);if(i===-1)return n;const s=n[i];if(!s||s.type!=="stack")return n;const o=s.children.find(d=>d.type==="card"&&d.id===t);if(!o||o.type!=="card")return n;const a=s.children.filter(d=>d.id!==t);if(a.length===s.children.length||a.length<1)return n;const c=[...n];if(a.length===1){const[d]=a;c[i]=d.type==="card"?Xc(d):d}else c[i]={...s,children:a};const u=Math.max(0,Math.min(r,c.length));return c.splice(u,0,Xc(o)),c}const $O=gt(),TO=gt(),CO=50;function IO(n,e){if(n.type!==e.type)return!1;switch(n.type){case"reorder":return e.index===n.index;case"stack":return e.targetCardId===n.targetCardId&&e.position===n.position;case"stack-child-noop":return!0;case"stack-child-extract":return e.toIndex===n.toIndex;case"stack-child-reorder":return e.position===n.position;default:return!1}}function oo(n){return{id:n.id,type:"drop-target",width:n.width,height:n.height}}function sf(n){return n.map(RO)}function PO(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n}function RO(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n.type==="stack"?{...n,children:n.children.map(PO)}:n}function Sy(n,e){return n.find(r=>r.type==="card"&&r.id===e)??null}function of(n,e){return n.find(r=>r.type==="stack"&&r.id===e)??null}function DO(n,e){const t=[...e],r=t.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(r===-1)return null;const i=t[r];if(!i||i.type!=="card")return null;t.splice(r,1);const s=Math.max(0,Math.min(n.lastReorderIndex,t.length));t.splice(s,0,i);const o=t.findIndex(a=>a.type==="card"&&a.id===n.nodeId);return o===-1?null:{base:t,visualDraggedIndex:o}}function OO(n,e,t,r){const i=[...n.base];i.splice(n.visualDraggedIndex,1);const s=i.findIndex(y=>y.type==="card"&&y.id===t.targetCardId),o=s===-1?null:i[s];if(!o||o.type!=="card")return null;const a=Sy(r,e.nodeId);if(!a)return null;const c=Jc(a),u=Jc(o),d=oo(c),p=t.position==="above"?[d,u]:[u,d];return i[s]={id:o.id,type:"stack",children:p},i}function ec(n,e){return n.parentStackId?LO(n,e):zO(n,e)}function zO(n,e){const t=n.hitTarget;if(t.type==="reorder"){const r=e[n.sourceIndex];if(!r||r.type!=="card")return[...e];const i=[...e];return i.splice(n.sourceIndex,1),i.splice(t.index,0,oo(r)),i}if(t.type==="stack"){const r=DO(n,e);return r?OO(r,n,t,e)??[...e]:[...e]}return[...e]}function LO(n,e){const t=n.hitTarget;switch(t.type){case"stack-child-reorder":return MO(n,e,t.position);case"stack-child-extract":return NO(n,e,t.toIndex);case"stack-child-noop":return UO(n,e);default:return[...e]}}function MO(n,e,t){const r=e.findIndex(y=>y.type==="stack"&&y.id===n.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===n.nodeId);if(o===-1)return[...e];const a=s[o],c=s.filter(y=>y.id!==n.nodeId),u=oo(a),d=t==="above"?[u,...c]:[...c,u],p=[...e];return p[r]={...i,children:d},p}function NO(n,e,t){if(!n.parentStackId)return[...e];const r=AO(e,n.parentStackId,n.nodeId,t);if(r===e)return[...e];const i=r.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(i===-1)return[...e];const s=r[i];if(!s||s.type!=="card")return[...e];const o=[...r];return o[i]=oo(s),o}function UO(n,e){const t=e.findIndex(c=>c.type==="stack"&&c.id===n.parentStackId);if(t===-1)return[...e];const r=e[t];if(!r||r.type!=="stack")return[...e];const i=r.children.findIndex(c=>c.type==="card"&&c.id===n.nodeId);if(i===-1)return[...e];const s=r.children[i];if(!s||s.type!=="card")return[...e];const o=[...e],a=[...r.children];return a[i]=oo(s),o[t]={...r,children:a},o}function FO(n,e){return e.find(r=>r.type==="stack"&&r.id===n.id)?n.id:Uu()}function ZO(n,e,t){if(n.type==="drop-target"){const r=sh(e,t);if(!r)throw new Error(`finalize: missing dragged card ${t}`);return Jc(r)}return n}function HO(n,e,t){const r=n.children.map(s=>ZO(s,e,t));return{id:FO(n,e),type:"stack",children:r}}function BO(n,e,t){if(n.type==="drop-target"){const r=sh(e,t);if(!r)throw new Error(`finalize: missing dragged card ${t}`);return Sy(e,t)!==null?r:Xc(r)}return n.type==="card"||n.type==="row"?n:HO(n,e,t)}function jO(n,e,t){return n.map(r=>BO(r,e,t))}function GO(n,e){return JSON.stringify(n)===JSON.stringify(e)}const VO=wi(mt);class WO extends VO{constructor(t={}){super();b(this,"pending",null);b(this,"active",null)}start(t){if(this.pending||this.active)return;const r=t.pointer.x??0,i=t.pointer.y??0;this.pending={startX:r,startY:i,grabOffsetX:t.grabOffset.x??0,grabOffsetY:t.grabOffset.y??0,nodeId:t.nodeId,sourceIndex:t.source.index,parentStackId:t.source.parentId,width:t.size.x??0,height:t.size.y??0,baseLayout:t.layout}}update(t){const r=t.pointer.x??0,i=t.pointer.y??0,s=this.pending;if(s){const u=r-s.startX,d=i-s.startY;Math.hypot(u,d)>=XE&&(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=ec(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,i,t,o),c=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===i&&IO(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 t=this.active.baseLayout;let r=null;try{const i=ec(this.active,t),s=jO(i,t,this.active.nodeId);GO(s,t)||(r=s)}catch{r=null}this.reset(),r&&this.dispatchEvent(new TO("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 t=ec(this.active,this.active.baseLayout);this.dispatchEvent(new $O("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:ke({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:ke({x:this.active.pointerX,y:this.active.pointerY}),size:ke({x:this.active.width,y:this.active.height}),projectedLayout:t}))}getHitTargetForPointer(t,r,i,s){return this.active?this.isPointerInsideDragBounds(t,r,i.viewport)?this.active.parentStackId?this.getStackChildHitTarget(t,r,i,s):this.getTopLevelCardHitTarget(t,r,i,s):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(t,r,i,s){var u;if(!((u=this.active)!=null&&u.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(i.geometry);if(o&&Cn(t,r,o)){const d=o.top+o.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}const a=this.getSourceRemainingSiblingRect(i.geometry);if(a&&Cn(t,r,a)){const d=a.top+a.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(t,r,i,s)}}getSourceRemainingSiblingRect(t){var s,o;if(!((s=this.active)!=null&&s.parentStackId))return;const r=of(this.active.baseLayout,this.active.parentStackId);if(!r)return;const i=r.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.nodeId)});if(i)return(o=t.find(a=>a.id===i.id))==null?void 0:o.rect}getSourceStackInteractionRect(t){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const r=t.find(a=>{var c;return a.id===((c=this.active)==null?void 0:c.parentStackId)});if(r)return this.active.sourceStackRect=r.rect,r.rect;const i=of(this.active.baseLayout,this.active.parentStackId);if(!i)return this.active.sourceStackRect;const s=i.children.find(a=>{var c;return a.type==="card"&&a.id!==((c=this.active)==null?void 0:c.nodeId)});if(s){const a=t.find(c=>c.id===s.id);if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(t,r,i,s){var v,$,E;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)<=CO;for(const I of o){const Z=I.rect;if(!Cn(t,r,Z))continue;const P=this.resolveTopLevelTargetForCard(t,r,I,I.logicalIndex,c);if(P)return P;if(!c&&(($=this.active)!=null&&$.hitTarget))return this.active.hitTarget}const u=this.getNearestTargetableZone(t,o);if(!u)return{type:"reorder",index:((E=this.active)==null?void 0:E.sourceIndex)??0};const d=Math.max(u.rect.left,Math.min(u.rect.left+u.rect.width,t)),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:t<y?u.logicalIndex:u.logicalIndex+1}}getTopLevelReorderIndexForPointer(t,r,i,s){var u,d;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return((u=this.active)==null?void 0:u.sourceIndex)??0;for(const p of o){if(!Cn(t,r,p.rect))continue;const y=Ql(p.rect,Xl["reorder-before"]);if(Cn(t,r,y))return p.logicalIndex;const v=Ql(p.rect,Xl["reorder-after"]);if(Cn(t,r,v))return p.logicalIndex+1}const a=this.getNearestTargetableZone(t,o);if(!a)return((d=this.active)==null?void 0:d.sourceIndex)??0;const c=a.rect.left+a.rect.width/2;return t<c?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(t,r){const i=new Map(r.map(a=>[a.id,a])),s=[];let o=0;for(const a of t){const c=i.get(a.id);c&&c.type!=="drop-target"&&(c.type==="card"||c.type==="stack")&&(s.push({id:c.id,rect:a.rect,logicalIndex:o}),o+=1)}return s}resolveTopLevelTargetForCard(t,r,i,s,o){const a=i.rect;for(const c of xO){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const u=Xl[c],d=Ql(a,u);if(Cn(t,r,d))return c==="stack-above"?{type:"stack",targetCardId:i.id,position:"above"}:c==="stack-below"?{type:"stack",targetCardId:i.id,position:"below"}:c==="reorder-before"?{type:"reorder",index:s}:{type:"reorder",index:s+1}}return null}getNearestTargetableZone(t,r){let i=null,s=Number.POSITIVE_INFINITY;for(const o of r){const a=o.rect.left,c=o.rect.left+o.rect.width,u=t<a?a-t:t>c?t-c:0;u<s&&(s=u,i=o)}return i}isPointerInsideDragBounds(t,r,i){return t>=i.left&&t<=i.left+i.width&&r>=i.top&&r<=i.top+i.height}}const af=60,qO=80,lf=.5,cf=10;class YO{constructor(){b(this,"awaitingFreshWheelGesture",!1);b(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);b(this,"lastWheelDeltaX",0);b(this,"activeGestureType","none");b(this,"lastWheelGestureAt",Number.NEGATIVE_INFINITY)}markKeyboardNavigation(e){this.awaitingFreshWheelGesture=!0,this.lastWheelEventAt=e,this.activeGestureType="none"}reset(){this.awaitingFreshWheelGesture=!1,this.lastWheelEventAt=Number.NEGATIVE_INFINITY,this.lastWheelDeltaX=0,this.activeGestureType="none",this.lastWheelGestureAt=Number.NEGATIVE_INFINITY}decide(e){const{now:t,shiftKey:r,deltaX:i,deltaY:s,overArtifactContent:o}=e;t-this.lastWheelGestureAt>=af&&(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>=lf&&d>=p*cf?this.classifyHorizontal(t,u):(this.lastWheelGestureAt=t,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!c&&o&&p>0&&p>=d*cf?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=t,{type:"scroll-native"}):this.classifyHorizontal(t,u):d<lf?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=t,{type:"scroll-native"}):c||d>p?this.classifyHorizontal(t,u):p>d?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=t,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=t,{type:"scroll-native"}):this.classifyHorizontal(t,u)}classifyHorizontal(e,t){const r=e-this.lastWheelEventAt,i=Math.sign(this.lastWheelDeltaX),s=Math.sign(t),o=i!==0&&s!==0&&i!==s,a=i!==0&&Math.abs(t)>=Math.abs(this.lastWheelDeltaX)+qO;return this.awaitingFreshWheelGesture&&r<af&&!o&&!a?{type:"ignore"}:(this.lastWheelEventAt=e,this.lastWheelDeltaX=t,this.lastWheelGestureAt=e,this.awaitingFreshWheelGesture=!1,this.activeGestureType="horizontal-filmstrip",{type:"scroll-horizontal",horizontalDelta:t})}}const KO=2,uf=1e3,Ro=1e-4;function JO(n){return n.replace(/["\\]/g,"\\$&")}function hf(n,e,t){if(n===0)return 0;const r=e.toPixels(Te({y:Qe})).y??0;return(t-r)/KO}function tc(n){const e=n.clientWidth>0?n.clientWidth:cr,t=n.clientHeight>0?n.clientHeight:la;let r=0,i=0;if(n.isConnected){const o=getComputedStyle(n);r=parseFloat(o.paddingTop)||0,i=parseFloat(o.paddingBottom)||0}const s=Math.max(1,t-r-i);return{width:e,height:s,offsetY:r}}class XO extends Event{constructor(t){super("scroll",{bubbles:!0,composed:!0});b(this,"scrollPosition");this.scrollPosition=t}}class _y extends Event{constructor(t){super("layout-change",{bubbles:!0,composed:!0});b(this,"layout");this.layout=t}}class QO extends HTMLElement{constructor(){super();b(this,"_layout",[]);b(this,"_scrollPosition",0);b(this,"layoutGrid",null);b(this,"layoutScroll",new EO(Te({x:0})));b(this,"scrollModelKey","");b(this,"resizeObserver",null);b(this,"renderPending",!1);b(this,"animateNextRender",!0);b(this,"wheelGesture",new YO);b(this,"dragController",new WO);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",()=>U``);b(this,"onDragControllerChange",()=>{this.dragController.status==="idle"&&(this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null),this.scheduleRender()});b(this,"onDragControllerDrag",t=>{const r=sf(t.projectedLayout),i=this.shouldApplyTrackOffset(t.projectedLayout,t.source.parentId),s=t.source.parentId?this.getStackChildAnchorCardId(t.source.parentId,t.nodeId):null;this.dragTrackOffsetXPx=i?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,r,t.nodeId,t.source.parentId,s,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=r,this.dragState={nodeId:t.nodeId,source:t.source,grabOffset:t.grabOffset,pointer:t.pointer,size:t.size,projectedLayout:t.projectedLayout},this.scheduleRender()});b(this,"onDragControllerDrop",t=>{this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.commitLayout(t.layout)});b(this,"onLayoutScrollInternal",t=>{const i=t.scroll.x??0;Math.abs(i-this._scrollPosition)<Ro||(this._scrollPosition=i,this.emitScrollPositionChanged(i),this.scheduleRender())});b(this,"handleKeyDown",t=>{if(t.key==="Escape"&&this.dragController.status!=="idle"){t.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(t.key==="ArrowRight"?(t.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(1)):t.key==="ArrowLeft"&&(t.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(-1)))});b(this,"handleWheel",t=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:t.shiftKey,deltaX:t.deltaX,deltaY:t.deltaY,overArtifactContent:!1});r.type==="scroll-horizontal"&&(t.preventDefault(),this.applyHorizontalWheel(r.horizontalDelta))});b(this,"handleWindowMessage",t=>{var o;if(this._layout.length===0)return;const r=this.findManagedArtifactFrame(t.source);if(!r||!this.isTrustedArtifactFrameMessage(t,r)||!hC(t.data))return;const i=this.wheelGesture.decide({now:Date.now(),shiftKey:t.data.shiftKey,deltaX:t.data.deltaX,deltaY:t.data.deltaY,overArtifactContent:!0});if(i.type==="scroll-horizontal"){this.applyHorizontalWheel(i.horizontalDelta);return}if(i.type!=="scroll-native")return;const s={type:"scroll",deltaX:0,deltaY:t.data.deltaY};(o=r.contentWindow)==null||o.postMessage(s,this.getArtifactFrameTargetOrigin(r))});b(this,"handlePointerDown",t=>{if(t.button!==0||this.dragController.status!=="idle")return;const r=t.target;if(!(r instanceof Element)||!r.closest("[drag-handle]")||r.closest("button, input, textarea, select, a, [role='button']"))return;const i=r.closest(".card-slot");if(!i)return;const s=i.getAttribute("data-layout-node-id");if(!s)return;const o=t2(this._layout,s);if(!o)return;const a=i.getBoundingClientRect();this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.resetMotionTracking(t.clientX,t.clientY),this.focus(),this.dragController.start({nodeId:s,source:{index:o.topLevelIndex,parentId:o.sourceStackId},pointer:ke({x:t.clientX,y:t.clientY}),grabOffset:ke({x:t.clientX-a.left,y:t.clientY-a.top}),size:ke({x:a.width,y:a.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=t.pointerId;try{this.setPointerCapture(t.pointerId)}catch{}t.preventDefault()});b(this,"handleWindowPointerMove",t=>{this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.updatePointerVelocity(t.clientX,t.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop()});b(this,"handleWindowPointerUp",t=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(t.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowPointerCancel",t=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(t.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"runDragFrame",t=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const r=Math.max(0,t-this.lastDragFrameTime)/uf;this.lastDragFrameTime=t,this.samplePointerVelocityAt(t,this.lastPointerX,this.lastPointerY);const i=this.getBoundingClientRect(),s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,i),o=this.getDragEdgeScrollDeltaPixels(s.x,i,r);this.scrollVelocityPxPerSec=r>Ro?Math.abs(o)/r:0,Math.abs(o)>Ro&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(ke({x:o}))),this.dragController.status==="active"&&this.syncDragTarget(s.x,s.y,i),this.dragFrame=requestAnimationFrame(this.runDragFrame)});this.dragController.addEventListener("change",this.onDragControllerChange),this.dragController.addEventListener("drag",this.onDragControllerDrag),this.dragController.addEventListener("drop",this.onDragControllerDrop),this.layoutScroll.addEventListener("layout-scroll",this.onLayoutScrollInternal)}set layout(t){this._layout=[...t],this.stopDragFrameLoop(),this.dragController.cancel(),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=Te({x:this._scrollPosition}),this.scheduleRender()}get layout(){return this._layout}commitLayout(t){this.layout=t,this.emitLayoutChanged()}set scrollPosition(t){Math.abs(t-this._scrollPosition)<Ro||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=Te({x:t}))}get scrollPosition(){return this._scrollPosition}focusArtifact(t){const r=Mr(this._layout),i=r.nodes.findIndex(o=>o.cards.some(a=>a.artifactID===t));if(i<0)return;let s=0;for(let o=0;o<i;o+=1)s+=r.nodes[o].width;this.scrollPosition=s,queueMicrotask(()=>{const o=this.querySelector(`.card-slot[data-layout-card-id="${JO(t)}"]`);if(!o)return;o.classList.remove("card-focus-pulse"),o.offsetHeight,o.classList.add("card-focus-pulse");const a=()=>{o.classList.remove("card-focus-pulse"),o.removeEventListener("animationend",a)};o.addEventListener("animationend",a)})}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.focus(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("pointerdown",this.handlePointerDown),window.addEventListener("message",this.handleWindowMessage),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.render()),this.resizeObserver.observe(this)),this.render()}disconnectedCallback(){var t;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("message",this.handleWindowMessage),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=null,this.wheelGesture.reset(),this.detachDragListeners(),this.dragController.removeEventListener("change",this.onDragControllerChange),this.dragController.removeEventListener("drag",this.onDragControllerDrag),this.dragController.removeEventListener("drop",this.onDragControllerDrop),this.layoutScroll.removeEventListener("layout-scroll",this.onLayoutScrollInternal),this.dragController.dispose(),this.stopDragFrameLoop()}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(t,r){return new pO({basis:ke({x:Dn,y:Dn}),min:ke({x:dp,y:dp}),viewport:ke({x:t,y:r}),gap:ke({x:ge,y:ge})})}syncScrollModel(){const t=tc(this),i=Mr(this._layout).nodes.map(o=>o.width),s=`${t.width}x${t.height}:${i.join(",")}`;s===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=s,this.layoutGrid=this.createGrid(t.width,t.height),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(o=>Te({x:o}))}))}emitScrollPositionChanged(t){this.dispatchEvent(new XO(t))}emitLayoutChanged(){this.dispatchEvent(new _y([...this._layout]))}shiftWindow(t){this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(t)}applyHorizontalWheel(t){this.syncScrollModel();const r=this.layoutGrid;if(!r)return;this.animateNextRender=!1;const i=r.toUnits(ke({x:t}));this.layoutScroll.wheel(Te({x:i.x??0}))}findManagedArtifactFrame(t){if(!t)return null;const r=this.querySelectorAll("iframe.artifact-frame");for(const i of r)if(i.contentWindow===t)return i;return null}isTrustedArtifactFrameMessage(t,r){if(t.origin==="null")return!0;const i=this.getArtifactFrameOrigin(r);return i===null||t.origin===i}getArtifactFrameTargetOrigin(t){const r=t.getAttribute("sandbox")??"";return new Set(r.split(/\s+/).filter(Boolean)).has("allow-same-origin")?this.getArtifactFrameOrigin(t)??"*":"*"}getArtifactFrameOrigin(t){const r=t.getAttribute("src")??t.src;if(!r)return null;try{return new URL(r,window.location.href).origin}catch{return null}}releaseActiveDragPointerCapture(){this.activeDragPointerId!==null&&this.releasePointerCaptureForEvent(this.activeDragPointerId)}releasePointerCaptureForEvent(t){try{this.hasPointerCapture(t)&&this.releasePointerCapture(t)}catch{}}attachDragListeners(){this.dragListenersAttached||(window.addEventListener("pointermove",this.handleWindowPointerMove),window.addEventListener("pointerup",this.handleWindowPointerUp),window.addEventListener("pointercancel",this.handleWindowPointerCancel),this.addEventListener("pointermove",this.handleWindowPointerMove),this.addEventListener("pointerup",this.handleWindowPointerUp),this.addEventListener("pointercancel",this.handleWindowPointerCancel),window.addEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!0)}detachDragListeners(){this.dragListenersAttached&&(window.removeEventListener("pointermove",this.handleWindowPointerMove),window.removeEventListener("pointerup",this.handleWindowPointerUp),window.removeEventListener("pointercancel",this.handleWindowPointerCancel),this.removeEventListener("pointermove",this.handleWindowPointerMove),this.removeEventListener("pointerup",this.handleWindowPointerUp),this.removeEventListener("pointercancel",this.handleWindowPointerCancel),window.removeEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!1,this.activeDragPointerId=null)}getDisplayModel(){if(this.dragController.status!=="active"||!this.dragState)return{layout:this._layout,activePlaceholderId:null,placeholdersById:new Map};const t=new Map;return t.set(this.dragState.nodeId,{id:this.dragState.nodeId,sourceCardId:this.dragState.nodeId}),{layout:sf(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:t}}render(){const t=tc(this),r=this.createGrid(t.width,t.height);this.layoutGrid=r;const i=this.getDisplayModel(),s=i.layout,o=this.dragController.status==="active",a=Mr(s),c=a.nodes.map(O=>O.width),u=`${t.width}x${t.height}:${c.join(",")}`;!o&&u!==this.scrollModelKey&&(this.scrollModelKey=u,this.layoutScroll.rebuild({grid:r,nodeWidths:c.map(O=>Te({x:O}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const d=e2(s),p=r.unit.x??Dn,y=r.unit.y??Dn,v=o?this.dragTrackOffsetXPx:0,$=(this.layoutScroll.translate.x??0)+v,E=hf(a.nodes.length,r,t.height),I=this.animateNextRender&&!o,Z=[`transform: translate(${$}px, ${E}px);`,`transition-duration: ${I?JE: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,G={width:(P==null?void 0:P.size.x)??0,height:(P==null?void 0:P.size.y)??0};Re(U`
162
- <div class="track" style=${Z}>
163
- ${a.nodes.map((O,H)=>U`
164
- <div
165
- class="node"
166
- layout-node=${String(H)}
167
- data-layout-node-id=${O.id}
168
- data-layout-placeholder=${String(i.activePlaceholderId===O.id)}
169
- layout-node-cols=${String(O.width)}
170
- style=${`grid-template-columns: repeat(${O.width}, var(--layout-unit-x)); width: ${r.toPixels(Te({x:O.width})).x}px;`}
171
- >
172
- ${O.cards.map(N=>{const ce=i.placeholdersById.get(N.id);if(P&&ce)return U`
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?U`
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 O=this.getPlaceholderPixelSize(a,i.activePlaceholderId,r,G),H=P.pointer.x??0,N=P.pointer.y??0,ce=P.grabOffset.x??0,ue=P.grabOffset.y??0;return U`
196
- <div
197
- class="drag-preview"
198
- data-layout-preview-card-id=${P.nodeId}
199
- style=${[`width: ${O.width}px;`,`height: ${O.height}px;`,`left: ${H-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 t=this.getBoundingClientRect();if(this.dragController.status==="active"){const i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,t);this.syncDragTarget(i.x,i.y,t);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,t),this.dragController.status==="pending")return;const r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,t);(r.x!==this.lastPointerX||r.y!==this.lastPointerY)&&this.syncDragTarget(r.x,r.y,t)}syncDragTarget(t,r,i=this.getBoundingClientRect()){if(this.dragController.status==="idle")return;const s=this.getDisplayModel(),o=new Set(s.placeholdersById.keys()),a=this.dragController.status==="active"?this.dragTrackOffsetXPx:0,c=this.measureLayoutGeometry(s.layout,o,a);this.dragController.update({pointer:ke({x:t,y:r}),viewport:{left:i.left,top:i.top,width:i.width,height:i.height},geometry:c,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(t,r){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=t,this.motionSampleY=r}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(t,r){this.samplePointerVelocityAt(performance.now(),t,r)}samplePointerVelocityAt(t,r,i){if(this.motionSampleTime===0){this.motionSampleTime=t,this.motionSampleX=r,this.motionSampleY=i,this.pointerVelocityPxPerSec=0;return}const s=t-this.motionSampleTime;if(s<100)return;const o=r-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/s*uf,this.motionSampleTime=t,this.motionSampleX=r,this.motionSampleY=i}clampPointerToViewport(t,r,i){return{x:Math.max(i.left,Math.min(i.left+i.width,t)),y:Math.max(i.top,Math.min(i.top+i.height,r))}}isPointerOutsideViewport(t,r,i){return t<i.left||t>i.left+i.width||r<i.top||r>i.top+i.height}getDragEdgeScrollDeltaPixels(t,r,i){var u;const s=r.left+xo,o=r.left+r.width-xo,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??Dn,c=QE*a;if(t<s){const d=Math.max(0,Math.min(1,(s-t)/xo));return-(c*d**pp)*i}if(t>o){const d=Math.max(0,Math.min(1,(t-o)/xo));return c*d**pp*i}return 0}measureLayoutGeometry(t,r,i=0){const s=this.layoutGrid;if(!s)return[];const o=Mr(t),a=new Map(o.nodes.map(E=>[E.id,E.width])),c=s.toPixels(Te({y:Qe})).y??la,u=tc(this),d=(this.layoutScroll.translate.x??0)+i,p=hf(o.nodes.length,s,u.height),y=u.offsetY+p,v=[];let $=d;for(const E of t){const I=a.get(E.id)??Pt,Z=s.toPixels(Te({x:I})).x??cr,P={left:$,top:y,width:Z,height:c};v.push({id:E.id,rect:P}),$+=Z+ge}return v}getPlaceholderPixelSize(t,r,i,s){if(!r)return s;for(const o of t.nodes)for(const a of o.cards)if(a.id===r)return{width:i.toPixels(Te({x:a.width})).x??s.width,height:i.toPixels(Te({y:a.height})).y??s.height};return s}renderDraggedPreview(t){const r=sh(this._layout,t);return r?this.renderContent(r,{isDragging:!0}):U``}shouldApplyTrackOffset(t,r){if(r)return!0;for(const i of t){if(i.type!=="stack")continue;if(i.children.some(o=>o.type==="drop-target")&&r!==i.id)return!0}return!1}computeDragTrackOffset(t,r,i,s,o,a){if(!t)return a;const c=s?o??this.getStableAnchorCardId(t,r,i):this.getStableAnchorNodeId(t,r,i);if(!c)return a;const u=s?pf(t,c,this.layoutGrid):ff(t,c,this.layoutGrid),d=s?pf(r,c,this.layoutGrid):ff(r,c,this.layoutGrid);return u===null||d===null?a:a+(u-d)}getStableAnchorCardId(t,r,i){const s=df(t),o=new Set(df(r));for(const a of s)if(a!==i&&o.has(a))return a;return null}getStableAnchorNodeId(t,r,i){const s=new Set(r.map(o=>o.id));for(const o of t)if(o.id!==i&&s.has(o.id))return o.id;return null}getStackChildAnchorCardId(t,r){const i=this._layout.find(o=>o.type==="stack"&&o.id===t);if(!i||i.type!=="stack")return null;const s=i.children.find(o=>o.type==="card"&&o.id!==r);return(s==null?void 0:s.id)??null}}function e2(n){const e=new Map;for(const t of n){if(t.type==="card"){e.set(t.id,t);continue}for(const r of t.children)if(r.type==="card")e.set(r.id,r);else for(const i of r.children)e.set(i.id,i)}return e}function t2(n,e){const t=n.findIndex(r=>r.type==="card"&&r.id===e);if(t!==-1)return{topLevelIndex:t};for(let r=0;r<n.length;r+=1){const i=n[r];if(!(!i||i.type!=="stack")&&i.children.some(s=>s.type==="card"&&s.id===e))return{topLevelIndex:r,sourceStackId:i.id}}return null}function df(n){const e=[];for(const t of n){if(t.type==="card"){e.push(t.id);continue}if(t.type==="stack"){const r=t.children.find(i=>i.type==="card");r&&e.push(r.id)}}return e}function pf(n,e,t){if(!t)return null;const r=Mr(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.type==="card"&&o.id===e||o.type==="stack"&&o.children.some(u=>u.type==="card"&&u.id===e))return s;const a=i.get(o.id)??Pt,c=t.toPixels(Te({x:a})).x??cr;s+=c+ge}return null}function ff(n,e,t){if(!t)return null;const r=Mr(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.id===e)return s;const a=i.get(o.id)??Pt,c=t.toPixels(Te({x:a})).x??cr;s+=c+ge}return null}customElements.get("layout-view")||customElements.define("layout-view",QO);class n2 extends HTMLElement{constructor(){super(...arguments);b(this,"screenManager",We.resolve("ScreenManager"));b(this,"boundModel",null);b(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});b(this,"handleModelChange",()=>{this.render()});b(this,"handleCloseArtifact",t=>{t instanceof my&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(t.artifactID)});b(this,"handleScrollPositionChanged",t=>{const r=t;typeof r.scrollPosition=="number"&&Number.isFinite(r.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(r.scrollPosition)});b(this,"handleLayoutChanged",t=>{t instanceof _y&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(t.layout)});b(this,"handleServerEvent",t=>{const r=t.event;if(r.type!=="viewer-focus"||!this.boundModel||r.screenID!==this.boundModel.id)return;const i=this.querySelector("layout-view");i&&i.focusArtifact(r.artifactID)})}connectedCallback(){this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.rebindModel(),this.render()}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged),this.unbindModel()}rebindModel(){const t=this.screenManager.activeScreen;this.boundModel!==t&&(this.unbindModel(),this.boundModel=t,t&&(t.addEventListener("change",this.handleModelChange),t.server.addEventListener("server-event",this.handleServerEvent)))}unbindModel(){this.boundModel&&(this.boundModel.removeEventListener("change",this.handleModelChange),this.boundModel.server.removeEventListener("server-event",this.handleServerEvent),this.boundModel=null)}buildArtifactMap(){const t=this.screenManager.activeScreen;return t?new Map(t.artifacts):new Map}render(){const t=this.screenManager.activeScreen,r=(t==null?void 0:t.layout)??[],i=this.buildArtifactMap();if(r.length===0){Re(U`<p data-testid="empty-screen" class="empty">
205
- No artifacts yet. Create one by asking for something.
206
- </p>`,this);return}Re(U`
207
- <layout-view
208
- .layout=${r}
209
- .renderContent=${(o,a)=>{const c=i.get(o.artifactID);return!c||!t?U``:U`<artifact-view
210
- .artifact=${c}
211
- .screen=${t}
212
- .viewURL=${t.server.getViewURL(c)}
213
- .contentURL=${t.server.getContentURL(c.id)}
214
- .dragging=${a.isDragging}
215
- ></artifact-view>`}}
216
- .scrollPosition=${(t==null?void 0:t.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",n2);var xa,Qr,Ls,Yt,ky,Ey,Qc;class r2 extends HTMLElement{constructor(){super(...arguments);S(this,Yt);S(this,xa,We.resolve("ScreenManager"));S(this,Qr,We.resolve("ServerManager"));S(this,Ls,()=>{g(this,Yt,Qc).call(this)})}connectedCallback(){l(this,Qr).addEventListener("change",l(this,Ls)),g(this,Yt,Qc).call(this)}disconnectedCallback(){l(this,Qr).removeEventListener("change",l(this,Ls))}}xa=new WeakMap,Qr=new WeakMap,Ls=new WeakMap,Yt=new WeakSet,ky=function(t,r){l(this,xa).setActive(t,r)},Ey=function(){for(const t of l(this,Qr).servers.values())return t;return null},Qc=function(){const t=g(this,Yt,Ey).call(this),i=(t?[...t.screens.values()]:[]).slice().sort((o,a)=>o.name.localeCompare(a.name,void 0,{sensitivity:"base"})),s=i.length===0?U`<p class="empty">No screens yet. Hit + to create one.</p>`:U`
222
- <ul class="tiles">
223
- ${i.map(o=>U`
224
- <li>
225
- <button
226
- class="tile"
227
- type="button"
228
- material="glass"
229
- @click=${()=>t&&g(this,Yt,ky).call(this,t.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",r2);const nc=new WeakMap,gf=Object.prototype.hasOwnProperty,i2=(()=>{const n=new Set;let e=HTMLElement.prototype;for(;e;){for(const t of Object.getOwnPropertyNames(e))n.add(t);if(e===Node.prototype)break;e=Object.getPrototypeOf(e)}return n})();function s2(n,e){if(n===Boolean)return e!==null;if(e!==null)return n===Number?Number(e):e}var Ms,eu,rr,nt,Ct,ei,ir,ti,Ie,Yi,xy,Ay,$y,Qo;const Ln=class Ln extends HTMLElement{constructor(){var i;super();S(this,Ie);S(this,rr,new Map);S(this,nt,new Map);S(this,Ct,new Map);S(this,ei,!1);S(this,ir,!1);S(this,ti,!1);const t=g(i=Ln,Ms,eu).call(i,this.constructor),r=this;for(const s of t.properties)gf.call(r,s)&&(l(this,Ct).set(s,r[s]),delete r[s])}static get observedAttributes(){var t;return g(t=Ln,Ms,eu).call(t,this).observedAttributes}connected(){}disconnected(){}changed(t){}connectedCallback(){if(g(this,Ie,$y).call(this),!l(this,ir))for(const t of g(this,Ie,Yi).call(this).properties)l(this,nt).has(t)||l(this,nt).set(t,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),g(this,Ie,Qo).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(t,r,i){if(r===i)return;const s=g(this,Ie,Yi).call(this).byAttr.get(t);s&&(l(this,Ct).has(s.property)||(this[s.property]=s2(s.type,i)))}};Ms=new WeakSet,eu=function(t){const r=nc.get(t);if(r)return r;const i=[...t.properties??[]],s=t.attributes??{},o=new Map,a=new Map;for(const u of i)if(i2.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(t.prototype,u);if((d==null?void 0:d.get)!==void 0||(d==null?void 0:d.set)!==void 0)throw new Error(`Observed property "${u}" cannot define a custom getter/setter. Use changed() for side effects instead.`);d===void 0&&Object.defineProperty(t.prototype,u,{configurable:!0,enumerable:!0,get(){return l(this,rr).get(u)},set(p){g(this,Ie,xy).call(this,u,p)}})}const c={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return nc.set(t,c),c},rr=new WeakMap,nt=new WeakMap,Ct=new WeakMap,ei=new WeakMap,ir=new WeakMap,ti=new WeakMap,Ie=new WeakSet,Yi=function(){return nc.get(this.constructor)},xy=function(t,r){if(!l(this,ti)&&l(this,Ct).has(t))return;const i=l(this,rr).get(t);Object.is(i,r)||(l(this,nt).has(t)||l(this,nt).set(t,i),l(this,rr).set(t,r),l(this,Ct).delete(t),g(this,Ie,Ay).call(this,t,r),this.isConnected&&g(this,Ie,Qo).call(this))},Ay=function(t,r){const i=g(this,Ie,Yi).call(this).byProp.get(t);if(!i)return;const{attribute:s,type:o}=i;if(o===Boolean){const c=this.hasAttribute(s);r&&!c?this.setAttribute(s,""):!r&&c&&this.removeAttribute(s);return}if(r==null){this.hasAttribute(s)&&this.removeAttribute(s);return}const a=String(r);this.getAttribute(s)!==a&&this.setAttribute(s,a)},$y=function(){const t=this,r=g(this,Ie,Yi).call(this);for(const i of r.properties){if(!gf.call(t,i))continue;const s=t[i];delete t[i],!(l(this,Ct).has(i)||l(this,rr).has(i))&&(t[i]=s)}k(this,ti,!0);try{for(const[i,s]of l(this,Ct))t[i]=s;l(this,Ct).clear()}finally{k(this,ti,!1)}},Qo=function(){l(this,ei)||!this.isConnected||l(this,ir)&&l(this,nt).size===0||(k(this,ei,!0),queueMicrotask(()=>{if(k(this,ei,!1),!this.isConnected||l(this,ir)&&l(this,nt).size===0)return;const t=new Map(l(this,nt));l(this,nt).clear(),k(this,ir,!0);try{this.changed(t)}catch(r){console.error(r)}this.isConnected&&l(this,nt).size>0&&g(this,Ie,Qo).call(this)}))},S(Ln,Ms),b(Ln,"properties"),b(Ln,"attributes");let ls=Ln;/**
237
- * @license
238
- * Copyright 2020 Google LLC
239
- * SPDX-License-Identifier: BSD-3-Clause
240
- */const o2=n=>n.strings===void 0;/**
241
- * @license
242
- * Copyright 2017 Google LLC
243
- * SPDX-License-Identifier: BSD-3-Clause
244
- */const ns=(n,e)=>{var r;const t=n._$AN;if(t===void 0)return!1;for(const i of t)(r=i._$AO)==null||r.call(i,e,!1),ns(i,e);return!0},ma=n=>{let e,t;do{if((e=n._$AM)===void 0)break;t=e._$AN,t.delete(n),n=e}while((t==null?void 0:t.size)===0)},Ty=n=>{for(let e;e=n._$AM;n=e){let t=e._$AN;if(t===void 0)e._$AN=t=new Set;else if(t.has(n))break;t.add(n),c2(e)}};function a2(n){this._$AN!==void 0?(ma(this),this._$AM=n,Ty(this)):this._$AM=n}function l2(n,e=!1,t=0){const r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(e)if(Array.isArray(r))for(let s=t;s<r.length;s++)ns(r[s],!1),ma(r[s]);else r!=null&&(ns(r,!1),ma(r));else ns(this,n)}const c2=n=>{n.type==Gv.CHILD&&(n._$AP??(n._$AP=l2),n._$AQ??(n._$AQ=a2))};class u2 extends Vv{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,r){super._$AT(e,t,r),Ty(this),this.isConnected=e._$AU}_$AO(e,t=!0){var r,i;e!==this.isConnected&&(this.isConnected=e,e?(r=this.reconnected)==null||r.call(this):(i=this.disconnected)==null||i.call(this)),t&&(ns(this,e),ma(this))}setValue(e){if(o2(this._$Ct))this._$Ct._$AI(e,this);else{const t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}}/**
245
- * @license
246
- * Copyright 2020 Google LLC
247
- * SPDX-License-Identifier: BSD-3-Clause
248
- */const Do=()=>new h2;class h2{}const rc=new WeakMap,Oo=rh(class extends u2{render(n){return ae}update(n,[e]){var r;const t=e!==this.G;return t&&this.G!==void 0&&this.rt(void 0),(t||this.lt!==this.ct)&&(this.G=e,this.ht=(r=n.options)==null?void 0:r.host,this.rt(this.ct=n.element)),ae}rt(n){if(this.isConnected||(n=void 0),typeof this.G=="function"){const e=this.ht??globalThis;let t=rc.get(e);t===void 0&&(t=new WeakMap,rc.set(e,t)),t.get(this.G)!==void 0&&this.G.call(this.ht,void 0),t.set(this.G,n),n!==void 0&&this.G.call(this.ht,n)}else this.G.value=n}get lt(){var n,e;return typeof this.G=="function"?(n=rc.get(this.ht??globalThis))==null?void 0:n.get(this.G):(e=this.G)==null?void 0:e.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Je,hn,ni,ri,Ns,sr,or,ie,Pe,Cy,Us,Fs,tu,nu,Aa,$a,Ta,Ca,Ia,Pa,Ra,Zs,Hs,Ki,Iy,dt;class d2 extends ls{constructor(){super(...arguments);S(this,Pe);S(this,Je,We.resolve("ScreenManager"));S(this,hn,null);S(this,ni,new DisposableStack);S(this,ri,Do());S(this,Ns,Do());S(this,sr,Do());S(this,or,Do());S(this,ie,{kind:"none"});S(this,Us,()=>{g(this,Pe,tu).call(this),l(this,dt).call(this)});S(this,Fs,()=>{l(this,dt).call(this)});S(this,Aa,()=>{l(this,Je).clearActive()});S(this,$a,t=>{l(this,ie).kind!=="none"&&(t.stopImmediatePropagation(),g(this,Pe,Ki).call(this))});S(this,Ta,()=>{var r;const t=l(this,Je).activeScreen;t&&((r=l(this,ri).value)==null||r.close(),k(this,ie,{kind:"rename",draft:t.name}),l(this,dt).call(this))});S(this,Ca,()=>{var t;l(this,Je).activeScreen&&((t=l(this,ri).value)==null||t.close(),k(this,ie,{kind:"delete",error:null}),l(this,dt).call(this))});S(this,Ia,t=>{if(l(this,ie).kind!=="rename")return;const r=t.target;r instanceof HTMLInputElement&&k(this,ie,{kind:"rename",draft:r.value})});S(this,Pa,t=>{if(t.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),g(this,Pe,Ki).call(this)});S(this,Ra,async()=>{if(l(this,ie).kind!=="delete")return;const t=l(this,Je).activeScreen;if(t){k(this,ie,{kind:"delete",error:null});try{await t.remove(),l(this,Je).clearActive(),g(this,Pe,Ki).call(this)}catch(r){k(this,ie,{kind:"delete",error:r instanceof Error?r.message:"Failed to delete screen."}),l(this,dt).call(this)}}});S(this,Zs,()=>{g(this,Pe,Ki).call(this)});S(this,Hs,()=>{l(this,ie).kind!=="none"&&(k(this,ie,{kind:"none"}),l(this,dt).call(this))});S(this,dt,()=>{const t=U`
249
- <button
250
- icon-only
251
- variant="ghost"
252
- class="home"
253
- type="button"
254
- aria-label="Home"
255
- @click=${l(this,Aa)}
256
- >
257
- ${GD({weight:"fill"})}
258
- </button>
259
- `;Re(U`${t}${g(this,Pe,Iy).call(this)}`,this);const r=l(this,Ns).value??null;l(this,sr).value&&(l(this,sr).value.anchor=r),l(this,or).value&&(l(this,or).value.anchor=r)})}connected(){l(this,Je).addEventListener("active-screen-changed",l(this,Us)),g(this,Pe,tu).call(this),l(this,dt).call(this),g(this,Pe,Cy).call(this),l(this,ni).defer(()=>{l(this,Je).removeEventListener("active-screen-changed",l(this,Us)),g(this,Pe,nu).call(this)})}disconnected(){l(this,ni).dispose(),k(this,ni,new DisposableStack)}}Je=new WeakMap,hn=new WeakMap,ni=new WeakMap,ri=new WeakMap,Ns=new WeakMap,sr=new WeakMap,or=new WeakMap,ie=new WeakMap,Pe=new WeakSet,Cy=async function(){const t=await th(this);this.setAttribute("tone",t)},Us=new WeakMap,Fs=new WeakMap,tu=function(){var r;const t=l(this,Je).activeScreen;l(this,hn)!==t&&(g(this,Pe,nu).call(this),k(this,hn,t),(r=l(this,hn))==null||r.addEventListener("change",l(this,Fs)))},nu=function(){var t;(t=l(this,hn))==null||t.removeEventListener("change",l(this,Fs)),k(this,hn,null)},Aa=new WeakMap,$a=new WeakMap,Ta=new WeakMap,Ca=new WeakMap,Ia=new WeakMap,Pa=new WeakMap,Ra=new WeakMap,Zs=new WeakMap,Hs=new WeakMap,Ki=function(){const t=l(this,ie).kind==="rename"?l(this,sr).value:l(this,ie).kind==="delete"?l(this,or).value:null;t&&(t.open=!1),k(this,ie,{kind:"none"}),l(this,dt).call(this)},Iy=function(){const t=l(this,Je).activeScreen;if(!t)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 U`
260
- <span class="separator" aria-hidden="true">
261
- ${HD()}
262
- </span>
263
- <dropdown-menu ${Oo(l(this,ri))}>
264
- <button
265
- slot="trigger"
266
- type="button"
267
- variant="ghost"
268
- aria-label=${`Screen actions for ${t.name}`}
269
- ?data-active=${l(this,ie).kind!=="none"}
270
- @click=${l(this,$a)}
271
- ${Oo(l(this,Ns))}
272
- >
273
- ${t.name}
274
- </button>
275
- <dropdown-group>
276
- <dropdown-item action @click=${l(this,Ta)}>
277
- ${VD()} Rename
278
- </dropdown-item>
279
- <dropdown-item action danger @click=${l(this,Ca)}>
280
- ${WD()} 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,Hs)}
288
- ${Oo(l(this,sr))}
289
- >
290
- <form class="screen-form" @submit=${l(this,Pa)}>
291
- <label class="field">
292
- <span>Screen name</span>
293
- <input
294
- type="text"
295
- .value=${r}
296
- @input=${l(this,Ia)}
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,Hs)}
309
- ${Oo(l(this,or))}
310
- >
311
- <div class="screen-form">
312
- <p class="confirm-text">Delete "${t.name}"?</p>
313
- ${i?U`<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,Ra)}
320
- >
321
- Delete
322
- </button>
323
- </div>
324
- </div>
325
- </ui-popover>
326
- `},dt=new WeakMap;customElements.define("screen-breadcrumb",d2);var Da,Oa,ii,bn,Py,Ry,za,Dy;class p2 extends HTMLElement{constructor(){super(...arguments);S(this,bn);S(this,Da,We.resolve("ServerManager"));S(this,Oa,We.resolve("ScreenManager"));S(this,ii,!1);S(this,za,async()=>{if(l(this,ii))return;const t=g(this,bn,Ry).call(this);if(t){k(this,ii,!0);try{const r=await t.createScreen(f2(new Date));l(this,Oa).setActive(t.url,r.id)}catch{}finally{k(this,ii,!1)}}})}connectedCallback(){g(this,bn,Dy).call(this),g(this,bn,Py).call(this)}}Da=new WeakMap,Oa=new WeakMap,ii=new WeakMap,bn=new WeakSet,Py=async function(){const t=await th(this);this.setAttribute("tone",t)},Ry=function(){for(const t of l(this,Da).servers.values())return t;return null},za=new WeakMap,Dy=function(){Re(U`
327
- <button
328
- icon-only
329
- variant="ghost"
330
- class="new-screen"
331
- type="button"
332
- aria-label="New screen"
333
- @click=${l(this,za)}
334
- >
335
- ${jD({size:16,weight:"bold"})}
336
- </button>
337
- `,this)};function f2(n){const e=n.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),t=12,r=n.getHours(),i=r%t===0?t:r%t,s=n.getMinutes().toString().padStart(2,"0"),o=r>=t?"pm":"am";return`${e} at ${i}:${s}${o}`}customElements.define("screen-create-button",p2);function g2(n,e){let t=null;const r=()=>e((t==null?void 0:t.messages)??[]),i=()=>{const o=n.getActiveClient();o!==t&&(t==null||t.removeEventListener("change",r),t=o,t&&(t.addEventListener("change",r),t.connect().catch(a=>{console.error("ACPClient.connect() failed",a)})),r())};n.addEventListener("change",i),i();const s=()=>{n.removeEventListener("change",i),t==null||t.removeEventListener("change",r),t=null};return{dispose:s,[Symbol.dispose](){s()}}}/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */const{entries:Oy,setPrototypeOf:mf,isFrozen:m2,getPrototypeOf:v2,getOwnPropertyDescriptor:y2}=Object;let{freeze:Ue,seal:st,create:ea}=Object,{apply:ru,construct:iu}=typeof Reflect<"u"&&Reflect;Ue||(Ue=function(e){return e});st||(st=function(e){return e});ru||(ru=function(e,t){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];return e.apply(t,i)});iu||(iu=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return new e(...r)});const zo=Fe(Array.prototype.forEach),b2=Fe(Array.prototype.lastIndexOf),vf=Fe(Array.prototype.pop),zi=Fe(Array.prototype.push),w2=Fe(Array.prototype.splice),ta=Fe(String.prototype.toLowerCase),ic=Fe(String.prototype.toString),sc=Fe(String.prototype.match),Li=Fe(String.prototype.replace),S2=Fe(String.prototype.indexOf),_2=Fe(String.prototype.trim),Ye=Fe(Object.prototype.hasOwnProperty),ze=Fe(RegExp.prototype.test),Mi=k2(TypeError);function Fe(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return ru(n,e,r)}}function k2(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return iu(n,t)}}function j(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ta;mf&&mf(n,null);let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){const s=t(i);s!==i&&(m2(e)||(e[r]=s),i=s)}n[i]=!0}return n}function E2(n){for(let e=0;e<n.length;e++)Ye(n,e)||(n[e]=null);return n}function _t(n){const e=ea(null);for(const[t,r]of Oy(n))Ye(n,t)&&(Array.isArray(r)?e[t]=E2(r):r&&typeof r=="object"&&r.constructor===Object?e[t]=_t(r):e[t]=r);return e}function Ni(n,e){for(;n!==null;){const r=y2(n,e);if(r){if(r.get)return Fe(r.get);if(typeof r.value=="function")return Fe(r.value)}n=v2(n)}function t(){return null}return t}const yf=Ue(["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"]),oc=Ue(["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"]),ac=Ue(["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"]),x2=Ue(["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"]),lc=Ue(["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"]),A2=Ue(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),bf=Ue(["#text"]),wf=Ue(["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"]),cc=Ue(["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"]),Sf=Ue(["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"]),Lo=Ue(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),$2=st(/\{\{[\w\W]*|[\w\W]*\}\}/gm),T2=st(/<%[\w\W]*|[\w\W]*%>/gm),C2=st(/\$\{[\w\W]*/gm),I2=st(/^data-[\-\w.\u00B7-\uFFFF]+$/),P2=st(/^aria-[\-\w]+$/),zy=st(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),R2=st(/^(?:\w+script|data):/i),D2=st(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ly=st(/^html$/i),O2=st(/^[a-z][.\w]*(-[.\w]+)+$/i);var _f=Object.freeze({__proto__:null,ARIA_ATTR:P2,ATTR_WHITESPACE:D2,CUSTOM_ELEMENT:O2,DATA_ATTR:I2,DOCTYPE_NAME:Ly,ERB_EXPR:T2,IS_ALLOWED_URI:zy,IS_SCRIPT_OR_DATA:R2,MUSTACHE_EXPR:$2,TMPLIT_EXPR:C2});const Ui={element:1,text:3,progressingInstruction:7,comment:8,document:9},z2=function(){return typeof window>"u"?null:window},L2=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(r=t.getAttribute(i));const s="dompurify"+(r?"#"+r:"");try{return e.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},kf=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function My(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:z2();const e=M=>My(M);if(e.version="3.3.3",e.removed=[],!n||!n.document||n.document.nodeType!==Ui.document||!n.Element)return e.isSupported=!1,e;let{document:t}=n;const r=t,i=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:c,NodeFilter:u,NamedNodeMap:d=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:p,DOMParser:y,trustedTypes:v}=n,$=c.prototype,E=Ni($,"cloneNode"),I=Ni($,"remove"),Z=Ni($,"nextSibling"),P=Ni($,"childNodes"),G=Ni($,"parentNode");if(typeof o=="function"){const M=t.createElement("template");M.content&&M.content.ownerDocument&&(t=M.content.ownerDocument)}let O,H="";const{implementation:N,createNodeIterator:ce,createDocumentFragment:ue,getElementsByTagName:xi}=t,{importNode:lo}=r;let xe=kf();e.isSupported=typeof Oy=="function"&&typeof G=="function"&&N&&N.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:xn,ERB_EXPR:vt,TMPLIT_EXPR:en,DATA_ATTR:rl,ARIA_ATTR:co,IS_SCRIPT_OR_DATA:eb,ATTR_WHITESPACE:vh,CUSTOM_ELEMENT:tb}=_f;let{IS_ALLOWED_URI:yh}=_f,Se=null;const bh=j({},[...yf,...oc,...ac,...lc,...bf]);let Ae=null;const wh=j({},[...wf,...cc,...Sf,...Lo]);let me=Object.seal(ea(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}})),Ai=null,uo=null;const tn=Object.seal(ea(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Sh=!0,il=!0,_h=!1,kh=!0,br=!1,ho=!0,An=!1,sl=!1,ol=!1,wr=!1,po=!1,fo=!1,Eh=!0,xh=!1;const nb="user-content-";let al=!0,$i=!1,Sr={},yt=null;const ll=j({},["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 Ah=null;const $h=j({},["audio","video","img","source","image","track"]);let cl=null;const Th=j({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),go="http://www.w3.org/1998/Math/MathML",mo="http://www.w3.org/2000/svg",Rt="http://www.w3.org/1999/xhtml";let _r=Rt,ul=!1,hl=null;const rb=j({},[go,mo,Rt],ic);let vo=j({},["mi","mo","mn","ms","mtext"]),yo=j({},["annotation-xml"]);const ib=j({},["title","style","font","a","script"]);let Ti=null;const sb=["application/xhtml+xml","text/html"],ob="text/html";let be=null,kr=null;const ab=t.createElement("form"),Ch=function(m){return m instanceof RegExp||m instanceof Function},dl=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(kr&&kr===m)){if((!m||typeof m!="object")&&(m={}),m=_t(m),Ti=sb.indexOf(m.PARSER_MEDIA_TYPE)===-1?ob:m.PARSER_MEDIA_TYPE,be=Ti==="application/xhtml+xml"?ic:ta,Se=Ye(m,"ALLOWED_TAGS")?j({},m.ALLOWED_TAGS,be):bh,Ae=Ye(m,"ALLOWED_ATTR")?j({},m.ALLOWED_ATTR,be):wh,hl=Ye(m,"ALLOWED_NAMESPACES")?j({},m.ALLOWED_NAMESPACES,ic):rb,cl=Ye(m,"ADD_URI_SAFE_ATTR")?j(_t(Th),m.ADD_URI_SAFE_ATTR,be):Th,Ah=Ye(m,"ADD_DATA_URI_TAGS")?j(_t($h),m.ADD_DATA_URI_TAGS,be):$h,yt=Ye(m,"FORBID_CONTENTS")?j({},m.FORBID_CONTENTS,be):ll,Ai=Ye(m,"FORBID_TAGS")?j({},m.FORBID_TAGS,be):_t({}),uo=Ye(m,"FORBID_ATTR")?j({},m.FORBID_ATTR,be):_t({}),Sr=Ye(m,"USE_PROFILES")?m.USE_PROFILES:!1,Sh=m.ALLOW_ARIA_ATTR!==!1,il=m.ALLOW_DATA_ATTR!==!1,_h=m.ALLOW_UNKNOWN_PROTOCOLS||!1,kh=m.ALLOW_SELF_CLOSE_IN_ATTR!==!1,br=m.SAFE_FOR_TEMPLATES||!1,ho=m.SAFE_FOR_XML!==!1,An=m.WHOLE_DOCUMENT||!1,wr=m.RETURN_DOM||!1,po=m.RETURN_DOM_FRAGMENT||!1,fo=m.RETURN_TRUSTED_TYPE||!1,ol=m.FORCE_BODY||!1,Eh=m.SANITIZE_DOM!==!1,xh=m.SANITIZE_NAMED_PROPS||!1,al=m.KEEP_CONTENT!==!1,$i=m.IN_PLACE||!1,yh=m.ALLOWED_URI_REGEXP||zy,_r=m.NAMESPACE||Rt,vo=m.MATHML_TEXT_INTEGRATION_POINTS||vo,yo=m.HTML_INTEGRATION_POINTS||yo,me=m.CUSTOM_ELEMENT_HANDLING||{},m.CUSTOM_ELEMENT_HANDLING&&Ch(m.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(me.tagNameCheck=m.CUSTOM_ELEMENT_HANDLING.tagNameCheck),m.CUSTOM_ELEMENT_HANDLING&&Ch(m.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(me.attributeNameCheck=m.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),m.CUSTOM_ELEMENT_HANDLING&&typeof m.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(me.allowCustomizedBuiltInElements=m.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),br&&(il=!1),po&&(wr=!0),Sr&&(Se=j({},bf),Ae=ea(null),Sr.html===!0&&(j(Se,yf),j(Ae,wf)),Sr.svg===!0&&(j(Se,oc),j(Ae,cc),j(Ae,Lo)),Sr.svgFilters===!0&&(j(Se,ac),j(Ae,cc),j(Ae,Lo)),Sr.mathMl===!0&&(j(Se,lc),j(Ae,Sf),j(Ae,Lo))),Ye(m,"ADD_TAGS")||(tn.tagCheck=null),Ye(m,"ADD_ATTR")||(tn.attributeCheck=null),m.ADD_TAGS&&(typeof m.ADD_TAGS=="function"?tn.tagCheck=m.ADD_TAGS:(Se===bh&&(Se=_t(Se)),j(Se,m.ADD_TAGS,be))),m.ADD_ATTR&&(typeof m.ADD_ATTR=="function"?tn.attributeCheck=m.ADD_ATTR:(Ae===wh&&(Ae=_t(Ae)),j(Ae,m.ADD_ATTR,be))),m.ADD_URI_SAFE_ATTR&&j(cl,m.ADD_URI_SAFE_ATTR,be),m.FORBID_CONTENTS&&(yt===ll&&(yt=_t(yt)),j(yt,m.FORBID_CONTENTS,be)),m.ADD_FORBID_CONTENTS&&(yt===ll&&(yt=_t(yt)),j(yt,m.ADD_FORBID_CONTENTS,be)),al&&(Se["#text"]=!0),An&&j(Se,["html","head","body"]),Se.table&&(j(Se,["tbody"]),delete Ai.tbody),m.TRUSTED_TYPES_POLICY){if(typeof m.TRUSTED_TYPES_POLICY.createHTML!="function")throw Mi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof m.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Mi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');O=m.TRUSTED_TYPES_POLICY,H=O.createHTML("")}else O===void 0&&(O=L2(v,i)),O!==null&&typeof H=="string"&&(H=O.createHTML(""));Ue&&Ue(m),kr=m}},Ih=j({},[...oc,...ac,...x2]),Ph=j({},[...lc,...A2]),lb=function(m){let T=G(m);(!T||!T.tagName)&&(T={namespaceURI:_r,tagName:"template"});const R=ta(m.tagName),se=ta(T.tagName);return hl[m.namespaceURI]?m.namespaceURI===mo?T.namespaceURI===Rt?R==="svg":T.namespaceURI===go?R==="svg"&&(se==="annotation-xml"||vo[se]):!!Ih[R]:m.namespaceURI===go?T.namespaceURI===Rt?R==="math":T.namespaceURI===mo?R==="math"&&yo[se]:!!Ph[R]:m.namespaceURI===Rt?T.namespaceURI===mo&&!yo[se]||T.namespaceURI===go&&!vo[se]?!1:!Ph[R]&&(ib[R]||!Ih[R]):!!(Ti==="application/xhtml+xml"&&hl[m.namespaceURI]):!1},bt=function(m){zi(e.removed,{element:m});try{G(m).removeChild(m)}catch{I(m)}},$n=function(m,T){try{zi(e.removed,{attribute:T.getAttributeNode(m),from:T})}catch{zi(e.removed,{attribute:null,from:T})}if(T.removeAttribute(m),m==="is")if(wr||po)try{bt(T)}catch{}else try{T.setAttribute(m,"")}catch{}},Rh=function(m){let T=null,R=null;if(ol)m="<remove></remove>"+m;else{const ve=sc(m,/^[\r\n\t ]+/);R=ve&&ve[0]}Ti==="application/xhtml+xml"&&_r===Rt&&(m='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+m+"</body></html>");const se=O?O.createHTML(m):m;if(_r===Rt)try{T=new y().parseFromString(se,Ti)}catch{}if(!T||!T.documentElement){T=N.createDocument(_r,"template",null);try{T.documentElement.innerHTML=ul?H:se}catch{}}const De=T.body||T.documentElement;return m&&R&&De.insertBefore(t.createTextNode(R),De.childNodes[0]||null),_r===Rt?xi.call(T,An?"html":"body")[0]:An?T.documentElement:De},Dh=function(m){return ce.call(m.ownerDocument||m,m,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},pl=function(m){return m instanceof p&&(typeof m.nodeName!="string"||typeof m.textContent!="string"||typeof m.removeChild!="function"||!(m.attributes instanceof d)||typeof m.removeAttribute!="function"||typeof m.setAttribute!="function"||typeof m.namespaceURI!="string"||typeof m.insertBefore!="function"||typeof m.hasChildNodes!="function")},Oh=function(m){return typeof a=="function"&&m instanceof a};function Dt(M,m,T){zo(M,R=>{R.call(e,m,T,kr)})}const zh=function(m){let T=null;if(Dt(xe.beforeSanitizeElements,m,null),pl(m))return bt(m),!0;const R=be(m.nodeName);if(Dt(xe.uponSanitizeElement,m,{tagName:R,allowedTags:Se}),ho&&m.hasChildNodes()&&!Oh(m.firstElementChild)&&ze(/<[/\w!]/g,m.innerHTML)&&ze(/<[/\w!]/g,m.textContent)||m.nodeType===Ui.progressingInstruction||ho&&m.nodeType===Ui.comment&&ze(/<[/\w]/g,m.data))return bt(m),!0;if(!(tn.tagCheck instanceof Function&&tn.tagCheck(R))&&(!Se[R]||Ai[R])){if(!Ai[R]&&Mh(R)&&(me.tagNameCheck instanceof RegExp&&ze(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R)))return!1;if(al&&!yt[R]){const se=G(m)||m.parentNode,De=P(m)||m.childNodes;if(De&&se){const ve=De.length;for(let Ze=ve-1;Ze>=0;--Ze){const Ot=E(De[Ze],!0);Ot.__removalCount=(m.__removalCount||0)+1,se.insertBefore(Ot,Z(m))}}}return bt(m),!0}return m instanceof c&&!lb(m)||(R==="noscript"||R==="noembed"||R==="noframes")&&ze(/<\/no(script|embed|frames)/i,m.innerHTML)?(bt(m),!0):(br&&m.nodeType===Ui.text&&(T=m.textContent,zo([xn,vt,en],se=>{T=Li(T,se," ")}),m.textContent!==T&&(zi(e.removed,{element:m.cloneNode()}),m.textContent=T)),Dt(xe.afterSanitizeElements,m,null),!1)},Lh=function(m,T,R){if(uo[T]||Eh&&(T==="id"||T==="name")&&(R in t||R in ab))return!1;if(!(il&&!uo[T]&&ze(rl,T))){if(!(Sh&&ze(co,T))){if(!(tn.attributeCheck instanceof Function&&tn.attributeCheck(T,m))){if(!Ae[T]||uo[T]){if(!(Mh(m)&&(me.tagNameCheck instanceof RegExp&&ze(me.tagNameCheck,m)||me.tagNameCheck instanceof Function&&me.tagNameCheck(m))&&(me.attributeNameCheck instanceof RegExp&&ze(me.attributeNameCheck,T)||me.attributeNameCheck instanceof Function&&me.attributeNameCheck(T,m))||T==="is"&&me.allowCustomizedBuiltInElements&&(me.tagNameCheck instanceof RegExp&&ze(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R))))return!1}else if(!cl[T]){if(!ze(yh,Li(R,vh,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&m!=="script"&&S2(R,"data:")===0&&Ah[m])){if(!(_h&&!ze(eb,Li(R,vh,"")))){if(R)return!1}}}}}}}return!0},Mh=function(m){return m!=="annotation-xml"&&sc(m,tb)},Nh=function(m){Dt(xe.beforeSanitizeAttributes,m,null);const{attributes:T}=m;if(!T||pl(m))return;const R={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ae,forceKeepAttr:void 0};let se=T.length;for(;se--;){const De=T[se],{name:ve,namespaceURI:Ze,value:Ot}=De,Er=be(ve),fl=Ot;let $e=ve==="value"?fl:_2(fl);if(R.attrName=Er,R.attrValue=$e,R.keepAttr=!0,R.forceKeepAttr=void 0,Dt(xe.uponSanitizeAttribute,m,R),$e=R.attrValue,xh&&(Er==="id"||Er==="name")&&($n(ve,m),$e=nb+$e),ho&&ze(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,$e)){$n(ve,m);continue}if(Er==="attributename"&&sc($e,"href")){$n(ve,m);continue}if(R.forceKeepAttr)continue;if(!R.keepAttr){$n(ve,m);continue}if(!kh&&ze(/\/>/i,$e)){$n(ve,m);continue}br&&zo([xn,vt,en],Fh=>{$e=Li($e,Fh," ")});const Uh=be(m.nodeName);if(!Lh(Uh,Er,$e)){$n(ve,m);continue}if(O&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!Ze)switch(v.getAttributeType(Uh,Er)){case"TrustedHTML":{$e=O.createHTML($e);break}case"TrustedScriptURL":{$e=O.createScriptURL($e);break}}if($e!==fl)try{Ze?m.setAttributeNS(Ze,ve,$e):m.setAttribute(ve,$e),pl(m)?bt(m):vf(e.removed)}catch{$n(ve,m)}}Dt(xe.afterSanitizeAttributes,m,null)},cb=function M(m){let T=null;const R=Dh(m);for(Dt(xe.beforeSanitizeShadowDOM,m,null);T=R.nextNode();)Dt(xe.uponSanitizeShadowNode,T,null),zh(T),Nh(T),T.content instanceof s&&M(T.content);Dt(xe.afterSanitizeShadowDOM,m,null)};return e.sanitize=function(M){let m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,R=null,se=null,De=null;if(ul=!M,ul&&(M="<!-->"),typeof M!="string"&&!Oh(M))if(typeof M.toString=="function"){if(M=M.toString(),typeof M!="string")throw Mi("dirty is not a string, aborting")}else throw Mi("toString is not a function");if(!e.isSupported)return M;if(sl||dl(m),e.removed=[],typeof M=="string"&&($i=!1),$i){if(M.nodeName){const Ot=be(M.nodeName);if(!Se[Ot]||Ai[Ot])throw Mi("root node is forbidden and cannot be sanitized in-place")}}else if(M instanceof a)T=Rh("<!---->"),R=T.ownerDocument.importNode(M,!0),R.nodeType===Ui.element&&R.nodeName==="BODY"||R.nodeName==="HTML"?T=R:T.appendChild(R);else{if(!wr&&!br&&!An&&M.indexOf("<")===-1)return O&&fo?O.createHTML(M):M;if(T=Rh(M),!T)return wr?null:fo?H:""}T&&ol&&bt(T.firstChild);const ve=Dh($i?M:T);for(;se=ve.nextNode();)zh(se),Nh(se),se.content instanceof s&&cb(se.content);if($i)return M;if(wr){if(po)for(De=ue.call(T.ownerDocument);T.firstChild;)De.appendChild(T.firstChild);else De=T;return(Ae.shadowroot||Ae.shadowrootmode)&&(De=lo.call(r,De,!0)),De}let Ze=An?T.outerHTML:T.innerHTML;return An&&Se["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&ze(Ly,T.ownerDocument.doctype.name)&&(Ze="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
338
- `+Ze),br&&zo([xn,vt,en],Ot=>{Ze=Li(Ze,Ot," ")}),O&&fo?O.createHTML(Ze):Ze},e.setConfig=function(){let M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};dl(M),sl=!0},e.clearConfig=function(){kr=null,sl=!1},e.isValidAttribute=function(M,m,T){kr||dl({});const R=be(M),se=be(m);return Lh(R,se,T)},e.addHook=function(M,m){typeof m=="function"&&zi(xe[M],m)},e.removeHook=function(M,m){if(m!==void 0){const T=b2(xe[M],m);return T===-1?void 0:w2(xe[M],T,1)[0]}return vf(xe[M])},e.removeHooks=function(M){xe[M]=[]},e.removeAllHooks=function(){xe=kf()},e}var Ny=My();function oh(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var yr=oh();function Uy(n){yr=n}var zn={exec:()=>null};function q(n,e=""){let t=typeof n=="string"?n:n.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(Ne.caret,"$1"),t=t.replace(i,o),r},getRegex:()=>new RegExp(t,e)};return r}var M2=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Ne={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}>`)},N2=/^(?:[ \t]*(?:\n|$))+/,U2=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,F2=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ao=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Z2=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ah=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Fy=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Zy=q(Fy).replace(/bull/g,ah).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(),H2=q(Fy).replace(/bull/g,ah).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(),lh=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,B2=/^[^\n]+/,ch=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,j2=q(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ch).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),G2=q(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ah).getRegex(),el="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",uh=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,V2=q("^ {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",uh).replace("tag",el).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Hy=q(lh).replace("hr",ao).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",el).getRegex(),W2=q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Hy).getRegex(),hh={blockquote:W2,code:U2,def:j2,fences:F2,heading:Z2,hr:ao,html:V2,lheading:Zy,list:G2,newline:N2,paragraph:Hy,table:zn,text:B2},Ef=q("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ao).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",el).getRegex(),q2={...hh,lheading:H2,table:Ef,paragraph:q(lh).replace("hr",ao).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ef).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",el).getRegex()},Y2={...hh,html:q(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",uh).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:zn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:q(lh).replace("hr",ao).replace("heading",` *#{1,6} *[^
339
- ]`).replace("lheading",Zy).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},K2=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,J2=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,By=/^( {2,}|\\)\n(?!\s*$)/,X2=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ei=/[\p{P}\p{S}]/u,tl=/[\s\p{P}\p{S}]/u,dh=/[^\s\p{P}\p{S}]/u,Q2=q(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,tl).getRegex(),jy=/(?!~)[\p{P}\p{S}]/u,ez=/(?!~)[\s\p{P}\p{S}]/u,tz=/(?:[^\s\p{P}\p{S}]|~)/u,nz=q(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",M2?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Gy=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,rz=q(Gy,"u").replace(/punct/g,Ei).getRegex(),iz=q(Gy,"u").replace(/punct/g,jy).getRegex(),Vy="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",sz=q(Vy,"gu").replace(/notPunctSpace/g,dh).replace(/punctSpace/g,tl).replace(/punct/g,Ei).getRegex(),oz=q(Vy,"gu").replace(/notPunctSpace/g,tz).replace(/punctSpace/g,ez).replace(/punct/g,jy).getRegex(),az=q("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,dh).replace(/punctSpace/g,tl).replace(/punct/g,Ei).getRegex(),lz=q(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Ei).getRegex(),cz="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",uz=q(cz,"gu").replace(/notPunctSpace/g,dh).replace(/punctSpace/g,tl).replace(/punct/g,Ei).getRegex(),hz=q(/\\(punct)/,"gu").replace(/punct/g,Ei).getRegex(),dz=q(/^<(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(),pz=q(uh).replace("(?:-->|$)","-->").getRegex(),fz=q("^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",pz).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),va=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,gz=q(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",va).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Wy=q(/^!?\[(label)\]\[(ref)\]/).replace("label",va).replace("ref",ch).getRegex(),qy=q(/^!?\[(ref)\](?:\[\])?/).replace("ref",ch).getRegex(),mz=q("reflink|nolink(?!\\()","g").replace("reflink",Wy).replace("nolink",qy).getRegex(),xf=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ph={_backpedal:zn,anyPunctuation:hz,autolink:dz,blockSkip:nz,br:By,code:J2,del:zn,delLDelim:zn,delRDelim:zn,emStrongLDelim:rz,emStrongRDelimAst:sz,emStrongRDelimUnd:az,escape:K2,link:gz,nolink:qy,punctuation:Q2,reflink:Wy,reflinkSearch:mz,tag:fz,text:X2,url:zn},vz={...ph,link:q(/^!?\[(label)\]\((.*?)\)/).replace("label",va).getRegex(),reflink:q(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",va).getRegex()},su={...ph,emStrongRDelimAst:oz,emStrongLDelim:iz,delLDelim:lz,delRDelim:uz,url:q(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",xf).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:q(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",xf).getRegex()},yz={...su,br:q(By).replace("{2,}","*").getRegex(),text:q(su.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Mo={normal:hh,gfm:q2,pedantic:Y2},Fi={normal:ph,gfm:su,breaks:yz,pedantic:vz},bz={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Af=n=>bz[n];function kt(n,e){if(e){if(Ne.escapeTest.test(n))return n.replace(Ne.escapeReplace,Af)}else if(Ne.escapeTestNoEncode.test(n))return n.replace(Ne.escapeReplaceNoEncode,Af);return n}function $f(n){try{n=encodeURI(n).replace(Ne.percentDecode,"%")}catch{return null}return n}function Tf(n,e){var s;let t=n.replace(Ne.findPipe,(o,a,c)=>{let u=!1,d=a;for(;--d>=0&&c[d]==="\\";)u=!u;return u?"|":" |"}),r=t.split(Ne.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(Ne.slashPipe,"|");return r}function Zi(n,e,t){let r=n.length;if(r===0)return"";let i=0;for(;i<r&&n.charAt(r-i-1)===e;)i++;return n.slice(0,r-i)}function wz(n,e){if(n.indexOf(e[1])===-1)return-1;let t=0;for(let r=0;r<n.length;r++)if(n[r]==="\\")r++;else if(n[r]===e[0])t++;else if(n[r]===e[1]&&(t--,t<0))return r;return t>0?-2:-1}function Sz(n,e=0){let t=e,r="";for(let i of n)if(i===" "){let s=4-t%4;r+=" ".repeat(s),t+=s}else r+=i,t++;return r}function Cf(n,e,t,r,i){let s=e.href,o=e.title||null,a=n[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let c={type:n[0].charAt(0)==="!"?"image":"link",raw:t,href:s,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,c}function _z(n,e,t){let r=n.match(t.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
340
- `).map(s=>{let o=s.match(t.other.beginningSpace);if(o===null)return s;let[a]=o;return a.length>=i.length?s.slice(i.length):s}).join(`
341
- `)}var ya=class{constructor(n){b(this,"options");b(this,"rules");b(this,"lexer");this.options=n||yr}space(n){let e=this.rules.block.newline.exec(n);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(n){let e=this.rules.block.code.exec(n);if(e){let t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:Zi(t,`
342
- `)}}}fences(n){let e=this.rules.block.fences.exec(n);if(e){let t=e[0],r=_z(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(n){let e=this.rules.block.heading.exec(n);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let r=Zi(t,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(t=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(n){let e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:Zi(e[0],`
343
- `)}}blockquote(n){let e=this.rules.block.blockquote.exec(n);if(e){let t=Zi(e[0],`
344
- `).split(`
345
- `),r="",i="",s=[];for(;t.length>0;){let o=!1,a=[],c;for(c=0;c<t.length;c++)if(this.rules.other.blockquoteStart.test(t[c]))a.push(t[c]),o=!0;else if(!o)a.push(t[c]);else break;t=t.slice(c);let u=a.join(`
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,t.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
- `+t.join(`
351
- `),E=this.blockquote($);s[s.length-1]=E,r=r.substring(0,r.length-v.raw.length)+E.raw,i=i.substring(0,i.length-v.text.length)+E.text;break}else if((y==null?void 0:y.type)==="list"){let v=y,$=v.raw+`
352
- `+t.join(`
353
- `),E=this.list($);s[s.length-1]=E,r=r.substring(0,r.length-y.raw.length)+E.raw,i=i.substring(0,i.length-v.raw.length)+E.raw,t=$.substring(s.at(-1).raw.length).split(`
354
- `);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(n){var t,r;let e=this.rules.block.list.exec(n);if(e){let i=e[1].trim(),s=i.length>1,o={type:"list",raw:"",ordered:s,start:s?+i.slice(0,-1):"",loose:!1,items:[]};i=s?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=s?i:"[*+-]");let a=this.rules.other.listItemRegex(i),c=!1;for(;n;){let d=!1,p="",y="";if(!(e=a.exec(n))||this.rules.block.hr.test(n))break;p=e[0],n=n.substring(p.length);let v=Sz(e[2].split(`
355
- `,1)[0],e[1].length),$=n.split(`
356
- `,1)[0],E=!v.trim(),I=0;if(this.options.pedantic?(I=2,y=v.trimStart()):E?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),E&&this.rules.other.blankLine.test($)&&(p+=$+`
357
- `,n=n.substring($.length+1),d=!0),!d){let Z=this.rules.other.nextBulletRegex(I),P=this.rules.other.hrRegex(I),G=this.rules.other.fencesBeginRegex(I),O=this.rules.other.headingBeginRegex(I),H=this.rules.other.htmlBeginRegex(I),N=this.rules.other.blockquoteBeginRegex(I);for(;n;){let ce=n.split(`
358
- `,1)[0],ue;if($=ce,this.options.pedantic?($=$.replace(this.rules.other.listReplaceNesting," "),ue=$):ue=$.replace(this.rules.other.tabCharGlobal," "),G.test($)||O.test($)||H.test($)||N.test($)||Z.test($)||P.test($))break;if(ue.search(this.rules.other.nonSpaceChar)>=I||!$.trim())y+=`
359
- `+ue.slice(I);else{if(E||v.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||G.test(v)||O.test(v)||P.test(v))break;y+=`
360
- `+$}E=!$.trim(),p+=ce+`
361
- `,n=n.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,""),((t=d.tokens[0])==null?void 0:t.type)==="text"||((r=d.tokens[0])==null?void 0:r.type)==="paragraph"){d.tokens[0].raw=d.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),d.tokens[0].text=d.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let 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(n){let e=this.rules.block.html.exec(n);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(n){let e=this.rules.block.def.exec(n);if(e){let t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:e[0],href:r,title:i}}}table(n){var o;let e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=Tf(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(t.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?s.align.push("right"):this.rules.other.tableAlignCenter.test(a)?s.align.push("center"):this.rules.other.tableAlignLeft.test(a)?s.align.push("left"):s.align.push(null);for(let a=0;a<t.length;a++)s.header.push({text:t[a],tokens:this.lexer.inline(t[a]),header:!0,align:s.align[a]});for(let a of i)s.rows.push(Tf(a,s.header.length).map((c,u)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:s.align[u]})));return s}}lheading(n){let e=this.rules.block.lheading.exec(n);if(e){let t=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:t,tokens:this.lexer.inline(t)}}}paragraph(n){let e=this.rules.block.paragraph.exec(n);if(e){let t=e[1].charAt(e[1].length-1)===`
363
- `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(n){let e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){let e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){let e=this.rules.inline.tag.exec(n);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(n){let e=this.rules.inline.link.exec(n);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let s=Zi(t.slice(0,-1),"\\");if((t.length-s.length)%2===0)return}else{let s=wz(e[2],"()");if(s===-2)return;if(s>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+s;e[2]=e[2].substring(0,s),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let r=e[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3])}else i=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?r=r.slice(1):r=r.slice(1,-1)),Cf(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let t;if((t=this.rules.inline.reflink.exec(n))||(t=this.rules.inline.nolink.exec(n))){let r=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){let s=t[0].charAt(0);return{type:"text",raw:s,text:s}}return Cf(t,i,t[0],this.lexer,this.rules)}}emStrong(n,e,t=""){let r=this.rules.inline.emStrongLDelim.exec(n);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!t||this.rules.inline.punctuation.exec(t))){let i=[...r[0]].length-1,s,o,a=i,c=0,u=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*n.length+i);(r=u.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(o=[...s].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&i%3&&!((i+o)%3)){c+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+c);let d=[...r[0]][0].length,p=n.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(n){let e=this.rules.inline.code.exec(n);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(t),i=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return r&&i&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(n){let e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n,e,t=""){let r=this.rules.inline.delLDelim.exec(n);if(r&&(!r[1]||!t||this.rules.inline.punctuation.exec(t))){let i=[...r[0]].length-1,s,o,a=i,c=this.rules.inline.delRDelim;for(c.lastIndex=0,e=e.slice(-1*n.length+i);(r=c.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(o=[...s].length,o!==i))continue;if(r[3]||r[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let u=[...r[0]][0].length,d=n.slice(0,i+r.index+u+o),p=d.slice(i,-i);return{type:"del",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(n){let e=this.rules.inline.autolink.exec(n);if(e){let t,r;return e[2]==="@"?(t=e[1],r="mailto:"+t):(t=e[1],r=t),{type:"link",raw:e[0],text:t,href:r,tokens:[{type:"text",raw:t,text:t}]}}}url(n){var t;let e;if(e=this.rules.inline.url.exec(n)){let r,i;if(e[2]==="@")r=e[0],i="mailto:"+r;else{let s;do s=e[0],e[0]=((t=this.rules.inline._backpedal.exec(e[0]))==null?void 0:t[0])??"";while(s!==e[0]);r=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0]}return{type:"link",raw:e[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(n){let e=this.rules.inline.text.exec(n);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},pt=class ou{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||yr,this.options.tokenizer=this.options.tokenizer||new ya,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:Ne,block:Mo.normal,inline:Fi.normal};this.options.pedantic?(t.block=Mo.pedantic,t.inline=Fi.pedantic):this.options.gfm&&(t.block=Mo.gfm,this.options.breaks?t.inline=Fi.breaks:t.inline=Fi.gfm),this.tokenizer.rules=t}static get rules(){return{block:Mo,inline:Fi}}static lex(e,t){return new ou(t).lex(e)}static lexInline(e,t){return new ou(t).inlineTokens(e)}lex(e){e=e.replace(Ne.carriageReturn,`
364
- `),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let r=this.inlineQueue[t];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],r=!1){var i,s,o;for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Ne.tabCharGlobal," ").replace(Ne.spaceLine,""));e;){let a;if((s=(i=this.options.extensions)==null?void 0:i.block)!=null&&s.some(u=>(a=u.call({lexer:this},e,t))?(e=e.substring(a.raw.length),t.push(a),!0):!1))continue;if(a=this.tokenizer.space(e)){e=e.substring(a.raw.length);let u=t.at(-1);a.raw.length===1&&u!==void 0?u.raw+=`
365
- `:t.push(a);continue}if(a=this.tokenizer.code(e)){e=e.substring(a.raw.length);let u=t.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
366
- `)?"":`
367
- `)+a.raw,u.text+=`
368
- `+a.text,this.inlineQueue.at(-1).src=u.text):t.push(a);continue}if(a=this.tokenizer.fences(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.heading(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.hr(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.blockquote(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.list(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.html(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.def(e)){e=e.substring(a.raw.length);let u=t.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
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},t.push(a));continue}if(a=this.tokenizer.table(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.lheading(e)){e=e.substring(a.raw.length),t.push(a);continue}let c=e;if((o=this.options.extensions)!=null&&o.startBlock){let u=1/0,d=e.slice(1),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=t.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):t.push(a),r=c.length!==e.length,e=e.substring(a.raw.length);continue}if(a=this.tokenizer.text(e)){e=e.substring(a.raw.length);let u=t.at(-1);(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
375
- `)?"":`
376
- `)+a.raw,u.text+=`
377
- `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):t.push(a);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){var c,u,d,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(E=>(v=E.call({lexer:this},e,t))?(e=e.substring(v.raw.length),t.push(v),!0):!1))continue;if(v=this.tokenizer.escape(e)){e=e.substring(v.raw.length),t.push(v);continue}if(v=this.tokenizer.tag(e)){e=e.substring(v.raw.length),t.push(v);continue}if(v=this.tokenizer.link(e)){e=e.substring(v.raw.length),t.push(v);continue}if(v=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(v.raw.length);let E=t.at(-1);v.type==="text"&&(E==null?void 0:E.type)==="text"?(E.raw+=v.raw,E.text+=v.text):t.push(v);continue}if(v=this.tokenizer.emStrong(e,r,a)){e=e.substring(v.raw.length),t.push(v);continue}if(v=this.tokenizer.codespan(e)){e=e.substring(v.raw.length),t.push(v);continue}if(v=this.tokenizer.br(e)){e=e.substring(v.raw.length),t.push(v);continue}if(v=this.tokenizer.del(e,r,a)){e=e.substring(v.raw.length),t.push(v);continue}if(v=this.tokenizer.autolink(e)){e=e.substring(v.raw.length),t.push(v);continue}if(!this.state.inLink&&(v=this.tokenizer.url(e))){e=e.substring(v.raw.length),t.push(v);continue}let $=e;if((y=this.options.extensions)!=null&&y.startInline){let E=1/0,I=e.slice(1),Z;this.options.extensions.startInline.forEach(P=>{Z=P.call({lexer:this},I),typeof Z=="number"&&Z>=0&&(E=Math.min(E,Z))}),E<1/0&&E>=0&&($=e.substring(0,E+1))}if(v=this.tokenizer.inlineText($)){e=e.substring(v.raw.length),v.raw.slice(-1)!=="_"&&(a=v.raw.slice(-1)),o=!0;let E=t.at(-1);(E==null?void 0:E.type)==="text"?(E.raw+=v.raw,E.text+=v.text):t.push(v);continue}if(e){let E="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(E);break}else throw new Error(E)}}return t}},ba=class{constructor(n){b(this,"options");b(this,"parser");this.options=n||yr}space(n){return""}code({text:n,lang:e,escaped:t}){var s;let r=(s=(e||"").match(Ne.notSpaceStart))==null?void 0:s[0],i=n.replace(Ne.endingNewline,"")+`
378
- `;return r?'<pre><code class="language-'+kt(r)+'">'+(t?i:kt(i,!0))+`</code></pre>
379
- `:"<pre><code>"+(t?i:kt(i,!0))+`</code></pre>
380
- `}blockquote({tokens:n}){return`<blockquote>
381
- ${this.parser.parse(n)}</blockquote>
382
- `}html({text:n}){return n}def(n){return""}heading({tokens:n,depth:e}){return`<h${e}>${this.parser.parseInline(n)}</h${e}>
383
- `}hr(n){return`<hr>
384
- `}list(n){let e=n.ordered,t=n.start,r="";for(let o=0;o<n.items.length;o++){let a=n.items[o];r+=this.listitem(a)}let i=e?"ol":"ul",s=e&&t!==1?' start="'+t+'"':"";return"<"+i+s+`>
385
- `+r+"</"+i+`>
386
- `}listitem(n){return`<li>${this.parser.parse(n.tokens)}</li>
387
- `}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
388
- `}table(n){let e="",t="";for(let i=0;i<n.header.length;i++)t+=this.tablecell(n.header[i]);e+=this.tablerow({text:t});let r="";for(let i=0;i<n.rows.length;i++){let s=n.rows[i];t="";for(let o=0;o<s.length;o++)t+=this.tablecell(s[o]);r+=this.tablerow({text:t})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
389
- <thead>
390
- `+e+`</thead>
391
- `+r+`</table>
392
- `}tablerow({text:n}){return`<tr>
393
- ${n}</tr>
394
- `}tablecell(n){let e=this.parser.parseInline(n.tokens),t=n.header?"th":"td";return(n.align?`<${t} align="${n.align}">`:`<${t}>`)+e+`</${t}>
395
- `}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${kt(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:t}){let r=this.parser.parseInline(t),i=$f(n);if(i===null)return r;n=i;let s='<a href="'+n+'"';return e&&(s+=' title="'+kt(e)+'"'),s+=">"+r+"</a>",s}image({href:n,title:e,text:t,tokens:r}){r&&(t=this.parser.parseInline(r,this.parser.textRenderer));let i=$f(n);if(i===null)return kt(t);n=i;let s=`<img src="${n}" alt="${kt(t)}"`;return e&&(s+=` title="${kt(e)}"`),s+=">",s}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:kt(n.text)}},fh=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}checkbox({raw:n}){return n}},ft=class au{constructor(e){b(this,"options");b(this,"renderer");b(this,"textRenderer");this.options=e||yr,this.options.renderer=this.options.renderer||new ba,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new fh}static parse(e,t){return new au(t).parse(e)}static parseInline(e,t){return new au(t).parseInline(e)}parse(e){var r,i;this.renderer.parser=this;let t="";for(let s=0;s<e.length;s++){let o=e[s];if((i=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&i[o.type]){let c=o,u=this.options.extensions.renderers[c.type].call({parser:this},c);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(c.type)){t+=u||"";continue}}let a=o;switch(a.type){case"space":{t+=this.renderer.space(a);break}case"hr":{t+=this.renderer.hr(a);break}case"heading":{t+=this.renderer.heading(a);break}case"code":{t+=this.renderer.code(a);break}case"table":{t+=this.renderer.table(a);break}case"blockquote":{t+=this.renderer.blockquote(a);break}case"list":{t+=this.renderer.list(a);break}case"checkbox":{t+=this.renderer.checkbox(a);break}case"html":{t+=this.renderer.html(a);break}case"def":{t+=this.renderer.def(a);break}case"paragraph":{t+=this.renderer.paragraph(a);break}case"text":{t+=this.renderer.text(a);break}default:{let c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return t}parseInline(e,t=this.renderer){var i,s;this.renderer.parser=this;let r="";for(let o=0;o<e.length;o++){let a=e[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[a.type]){let u=this.options.extensions.renderers[a.type].call({parser:this},a);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=u||"";continue}}let c=a;switch(c.type){case"escape":{r+=t.text(c);break}case"html":{r+=t.html(c);break}case"link":{r+=t.link(c);break}case"image":{r+=t.image(c);break}case"checkbox":{r+=t.checkbox(c);break}case"strong":{r+=t.strong(c);break}case"em":{r+=t.em(c);break}case"codespan":{r+=t.codespan(c);break}case"br":{r+=t.br(c);break}case"del":{r+=t.del(c);break}case"text":{r+=t.text(c);break}default:{let u='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return r}},No,Ji=(No=class{constructor(n){b(this,"options");b(this,"block");this.options=n||yr}preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}emStrongMask(n){return n}provideLexer(){return this.block?pt.lex:pt.lexInline}provideParser(){return this.block?ft.parse:ft.parseInline}},b(No,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),b(No,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),No),kz=class{constructor(...n){b(this,"defaults",oh());b(this,"options",this.setOptions);b(this,"parse",this.parseMarkdown(!0));b(this,"parseInline",this.parseMarkdown(!1));b(this,"Parser",ft);b(this,"Renderer",ba);b(this,"TextRenderer",fh);b(this,"Lexer",pt);b(this,"Tokenizer",ya);b(this,"Hooks",Ji);this.use(...n)}walkTokens(n,e){var r,i;let t=[];for(let s of n)switch(t=t.concat(e.call(this,s)),s.type){case"table":{let o=s;for(let a of o.header)t=t.concat(this.walkTokens(a.tokens,e));for(let a of o.rows)for(let c of a)t=t.concat(this.walkTokens(c.tokens,e));break}case"list":{let o=s;t=t.concat(this.walkTokens(o.items,e));break}default:{let o=s;(i=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let c=o[a].flat(1/0);t=t.concat(this.walkTokens(c,e))}):o.tokens&&(t=t.concat(this.walkTokens(o.tokens,e)))}}return t}use(...n){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(t=>{let r={...t};if(r.async=this.defaults.async||r.async||!1,t.extensions&&(t.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=s.apply(this,o)),a}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=e[i.level];s?s.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),t.renderer){let i=this.defaults.renderer||new ba(this.defaults);for(let s in t.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=t.renderer[o],c=i[o];i[o]=(...u)=>{let d=a.apply(i,u);return d===!1&&(d=c.apply(i,u)),d||""}}r.renderer=i}if(t.tokenizer){let i=this.defaults.tokenizer||new ya(this.defaults);for(let s in t.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=t.tokenizer[o],c=i[o];i[o]=(...u)=>{let d=a.apply(i,u);return d===!1&&(d=c.apply(i,u)),d}}r.tokenizer=i}if(t.hooks){let i=this.defaults.hooks||new Ji;for(let s in t.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=t.hooks[o],c=i[o];Ji.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&Ji.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(t.walkTokens){let i=this.defaults.walkTokens,s=t.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return pt.lex(n,e??this.defaults)}parser(n,e){return ft.parse(n,e??this.defaults)}parseMarkdown(n){return(e,t)=>{let r={...t},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=n),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(e):e,a=await(i.hooks?await i.hooks.provideLexer():n?pt.lex:pt.lexInline)(o,i),c=i.hooks?await i.hooks.processAllTokens(a):a;i.walkTokens&&await Promise.all(this.walkTokens(c,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser():n?ft.parse:ft.parseInline)(c,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(s);try{i.hooks&&(e=i.hooks.preprocess(e));let o=(i.hooks?i.hooks.provideLexer():n?pt.lex:pt.lexInline)(e,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():n?ft.parse:ft.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(n,e){return t=>{if(t.message+=`
396
- Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error occurred:</p><pre>"+kt(t.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(t);throw t}}},pr=new kz;function J(n,e){return pr.parse(n,e)}J.options=J.setOptions=function(n){return pr.setOptions(n),J.defaults=pr.defaults,Uy(J.defaults),J};J.getDefaults=oh;J.defaults=yr;J.use=function(...n){return pr.use(...n),J.defaults=pr.defaults,Uy(J.defaults),J};J.walkTokens=function(n,e){return pr.walkTokens(n,e)};J.parseInline=pr.parseInline;J.Parser=ft;J.parser=ft.parse;J.Renderer=ba;J.TextRenderer=fh;J.Lexer=pt;J.lexer=pt.lex;J.Tokenizer=ya;J.Hooks=Ji;J.parse=J;J.options;J.setOptions;J.use;J.walkTokens;J.parseInline;ft.parse;pt.lex;Ny.addHook("afterSanitizeAttributes",n=>{n.tagName==="A"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"))});function Ez(n){const e=J.parse(n,{async:!1});return Ny.sanitize(e,{USE_PROFILES:{html:!0}})}const xz=8,If=new WeakMap;function Az(n){const e=If.get(n);if(e&&e.text===n.text)return e.html;const t=Ez(n.text);return If.set(n,{text:n.text,html:t}),t}function $z(n){return n.replace(/_/g," ")}function Tz(n){return U`
397
- <div class="tool-call-header">
398
- <span class="tool-call-title">${n.title}</span>
399
- <span class="tool-call-meta">${n.toolKind} · ${$z(n.status)}</span>
400
- </div>
401
- ${n.text?U`<pre class="tool-call-text">${n.text}</pre>`:null}
402
- `}function Pf(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t&&t.kind==="user")return t.id}return null}var Vt,ar,La,Ma,Bs,lu;class Yy extends ls{constructor(){super(...arguments);S(this,Bs);b(this,"messages",[]);S(this,Vt,!0);S(this,ar,null);S(this,La,()=>{const t=l(this,ar);if(!t)return;const i=t.scrollHeight-t.clientHeight-t.scrollTop<=xz;i!==l(this,Vt)&&(k(this,Vt,i),this.toggleAttribute("data-pinned",i))});S(this,Ma,()=>{k(this,Vt,!0),this.toggleAttribute("data-pinned",!0),g(this,Bs,lu).call(this,!0)})}changed(t){let r=!1;if(t.has("messages")){const i=t.get("messages")??[],s=Pf(this.messages);r=s!==null&&s!==Pf(i),r&&k(this,Vt,!0)}Re(this.template(),this),l(this,ar)||k(this,ar,this.querySelector(".history-scroll")),this.toggleAttribute("data-pinned",l(this,Vt)),g(this,Bs,lu).call(this,r)}template(){return U`
403
- <div class="history-scroll" @scroll=${l(this,La)}>
404
- ${this.messages.map(t=>{const r=t.kind==="assistant"?MD(Az(t)):t.kind==="tool_call"?Tz(t):t.text;return U`<div
405
- class="message message-${t.kind}"
406
- data-message-id=${t.id}
407
- >${r}</div>`})}
408
- </div>
409
- <button
410
- type="button"
411
- class="history-jump"
412
- aria-label="Jump to latest message"
413
- @click=${l(this,Ma)}
414
- >
415
- ${qv({size:16})}
416
- </button>
417
- `}}Vt=new WeakMap,ar=new WeakMap,La=new WeakMap,Ma=new WeakMap,Bs=new WeakSet,lu=function(t){requestAnimationFrame(()=>{const r=l(this,ar);r&&(!l(this,Vt)&&!t||(r.scrollTop=r.scrollHeight-r.clientHeight))})},b(Yy,"properties",["messages"]);customElements.define("message-history",Yy);var js,Gs,si,Vs,wn,uu,hu,Ws,qs;class cu extends ls{constructor(){super(...arguments);S(this,wn);b(this,"placeholder","What do you want to do?");b(this,"open",!1);b(this,"messages",[]);S(this,js,We.resolve("ACPClientManager"));S(this,Gs,We.resolve("ShortcutService"));S(this,si,null);b(this,"handleTriggerActivate",()=>{this.open=!0});b(this,"handleKeydown",t=>{if(t.key!=="Enter"||t.shiftKey)return;const r=t.currentTarget,i=r.value.trim();if(t.preventDefault(),!i)return;r.value="";const s=l(this,js).getActiveClient();s&&s.sendMessage({text:i}).catch(o=>{console.error("ACPClient.sendMessage() failed",o)})});S(this,Vs,t=>{if(t.shortcut!=="focusCommandInput")return;if(!this.open){this.open=!0;return}const r=this.querySelector("textarea");if(r){if(document.activeElement===r){this.open=!1;return}r.focus()}});S(this,Ws,t=>{t.target instanceof Node&&(this.contains(t.target)||(this.open=!1))});S(this,qs,t=>{t.key==="Escape"&&(this.open=!1)})}connected(){this.setAttribute("material","paper"),this.setAttribute("tone","dark"),this.setAttribute("level","overlay");const t=new DisposableStack;k(this,si,t);const r=g2(l(this,js),i=>{this.messages=i});t.defer(()=>r.dispose()),l(this,Gs).addEventListener("shortcut-triggered",l(this,Vs)),t.defer(()=>l(this,Gs).removeEventListener("shortcut-triggered",l(this,Vs))),this.open&&g(this,wn,uu).call(this)}disconnected(){var t;(t=l(this,si))==null||t.dispose(),k(this,si,null),g(this,wn,hu).call(this)}changed(t){if(Re(this.template(),this),t.has("open"))if(this.open){g(this,wn,uu).call(this);const r=this.querySelector("textarea");r==null||r.focus()}else g(this,wn,hu).call(this)}template(){return this.open?U`
418
- <message-history .messages=${this.messages}></message-history>
419
- <textarea
420
- class="input"
421
- rows="1"
422
- @keydown=${this.handleKeydown}
423
- ></textarea>
424
- `:U`
425
- <div
426
- class="trigger"
427
- tabindex="0"
428
- role="button"
429
- @click=${this.handleTriggerActivate}
430
- @focus=${this.handleTriggerActivate}
431
- >
432
- <span class="label">${this.placeholder}</span>
433
- <span class="kbd" aria-hidden="true">⌘K</span>
434
- </div>
435
- `}}js=new WeakMap,Gs=new WeakMap,si=new WeakMap,Vs=new WeakMap,wn=new WeakSet,uu=function(){document.addEventListener("mousedown",l(this,Ws)),document.addEventListener("keydown",l(this,qs))},hu=function(){document.removeEventListener("mousedown",l(this,Ws)),document.removeEventListener("keydown",l(this,qs))},Ws=new WeakMap,qs=new WeakMap,b(cu,"properties",["placeholder","open","messages"]),b(cu,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",cu);class Ky extends Event{constructor(t){super("auth-submit",{bubbles:!0,composed:!0});b(this,"token");this.token=t}}class Cz extends HTMLElement{constructor(){super(...arguments);b(this,"_invalid",!1);b(this,"_tokenValue","")}set invalid(t){this._invalid=t,this.render()}get invalid(){return this._invalid}set tokenValue(t){this._tokenValue=t,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(t){const r=t.currentTarget;this._tokenValue=r.value}handleSubmit(t){t.preventDefault();const r=this._tokenValue.trim();r&&this.dispatchEvent(new Ky(r))}render(){Re(U`
436
- <modal-overlay open>
437
- <section class="auth-modal">
438
- <form class="auth-form" @submit=${t=>this.handleSubmit(t)}>
439
- <h2 class="auth-modal-title">Enter access token</h2>
440
- <p class="auth-modal-copy">This Television server requires a token.</p>
441
- <label class="settings-field">
442
- <span>Token</span>
443
- <input
444
- class=${this.invalid?"auth-token-input-invalid":""}
445
- type="password"
446
- name="token"
447
- .value=${this.tokenValue}
448
- @input=${t=>this.handleInput(t)}
449
- required
450
- />
451
- </label>
452
- <button type="submit" class="settings-submit-button">Connect</button>
453
- </form>
454
- </section>
455
- </modal-overlay>
456
- `,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",Cz);class Iz extends HTMLElement{constructor(){super(...arguments);b(this,"runtimeServerURL",Pv());b(this,"electronMode",Rv());b(this,"serverManager",We.resolve("ServerManager"));b(this,"screenManager",We.resolve("ScreenManager"));b(this,"connectError",null);b(this,"handleServerManagerChange",()=>{this.render()});b(this,"handleActiveScreenChanged",()=>{this.render()})}connectedCallback(){this.serverManager.addEventListener("change",this.handleServerManagerChange),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.addEventListener("auth-submit",t=>{var i;const r=t instanceof Ky?t.token:t instanceof CustomEvent&&typeof((i=t.detail)==null?void 0:i.token)=="string"?t.detail.token:null;r&&this.handleAuthSubmit(r)}),this.initializeConnection(),this.render()}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleServerManagerChange),this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged)}async initializeConnection(){if(this.electronMode){this.serverManager.connectConfiguredServers(this.runtimeServerURL,Mc());return}if(this.serverManager.activeServer)return;const t=new Cc({url:this.runtimeServerURL,name:"Server",token:Mc()});this.serverManager.add(t),this.serverManager.setActive(t);try{await t.connect(),this.connectError=null}catch(r){this.connectError=r instanceof Error&&!(r instanceof Tc)?r.message:null}this.render()}async handleAuthSubmit(t){const r=this.serverManager.activeServer;if(r){this.connectError=null,r.token=t,this.updateTokenQueryParam(t);try{await r.connect()}catch(i){i instanceof Tc||(this.connectError=i instanceof Error?i.message:String(i))}this.render()}}updateTokenQueryParam(t){const r=new URL(window.location.href);r.searchParams.set("token",t),window.history.replaceState({},"",`${r.pathname}${r.search}${r.hash}`)}render(){const t=this.serverManager.activeServer,r=(t==null?void 0:t.status)??null;if(r==="connecting"){Re(U`
457
- <main class="auth-gate"><p>Connecting...</p></main>
458
- `,this);return}if(r==="disconnected"){const o=t;if(!o)return;Re(U`
459
- <main class="auth-gate">
460
- <auth-modal
461
- .invalid=${!!o.token}
462
- .tokenValue=${o.token??""}
463
- ></auth-modal>
464
- </main>
465
- `,this);return}const s=this.screenManager.activeScreen?U`<screen-view></screen-view>`:U`<home-screen></home-screen>`;Re(U`
466
- <main>
467
- ${this.connectError?U`<p data-testid="auth-error">${this.connectError}</p>`:U`
468
- ${s}
469
- ${r==="connected"?U`
470
- <div class="chrome">
471
- <div class="top-row electron-draggable">
472
- <screen-breadcrumb></screen-breadcrumb>
473
- <screen-create-button></screen-create-button>
474
- </div>
475
- <command-panel></command-panel>
476
- </div>
477
- `:null}
478
- `}
479
- </main>
480
- `,this)}}customElements.get("television-app")||customElements.define("television-app",Iz);const gh=Rv(),nl=Pv(),Jy=new $x(gh?"television-electron":"television-browser",Ax(nl)),Xy=new bC({localStore:Jy,localServerURL:nl}),Qy=new kx({localStore:Jy,serverManager:Xy}),Pz=new nD({serverURL:nl,token:Mc()??"",screenManager:Qy}),Rz=new lD;We.register("ServerManager",()=>Xy);We.register("ScreenManager",()=>Qy);We.register("ACPClientManager",()=>Pz);We.register("ShortcutService",()=>Rz);const mh=document.createElement("television-app");mh.runtimeServerURL=nl;mh.electronMode=gh;gh&&document.body.classList.add("electron");document.body.appendChild(mh);