@telepath-computer/television 0.1.45 → 0.1.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
var pb=Object.defineProperty;var Fh=t=>{throw TypeError(t)};var fb=(t,e,n)=>e in t?pb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var b=(t,e,n)=>fb(t,typeof e!="symbol"?e+"":e,n),ml=(t,e,n)=>e.has(t)||Fh("Cannot "+n);var c=(t,e,n)=>(ml(t,e,"read from private field"),n?n.call(t):e.get(t)),w=(t,e,n)=>e.has(t)?Fh("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),k=(t,e,n,r)=>(ml(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),g=(t,e,n)=>(ml(t,e,"access private method"),n);var Zh=(t,e,n,r)=>({set _(i){k(t,e,i,n)},get _(){return c(t,e,r)}});(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var Rn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function gb(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}),n}var Hh=Object.prototype.toString,Of=function(e){var n=Hh.call(e),r=n==="[object Arguments]";return r||(r=n!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Hh.call(e.callee)==="[object Function]"),r},vl,Bh;function mb(){if(Bh)return vl;Bh=1;var t;if(!Object.keys){var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=Of,i=Object.prototype.propertyIsEnumerable,s=!i.call({toString:null},"toString"),o=i.call(function(){},"prototype"),a=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=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{l(window[y])}catch{return!0}}catch{return!0}return!1}(),p=function(y){if(typeof window>"u"||!d)return l(y);try{return l(y)}catch{return!1}};t=function(v){var A=v!==null&&typeof v=="object",E=n.call(v)==="[object Function]",I=r(v),Z=A&&n.call(v)==="[object String]",P=[];if(!A&&!E&&!I)throw new TypeError("Object.keys called on a non-object");var V=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)!(V&&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 vl=t,vl}var vb=Array.prototype.slice,yb=Of,jh=Object.keys,Uo=jh?function(e){return jh(e)}:mb(),Vh=Object.keys;Uo.shim=function(){if(Object.keys){var e=function(){var n=Object.keys(arguments);return n&&n.length===arguments.length}(1,2);e||(Object.keys=function(r){return yb(r)?Vh(vb.call(r)):Vh(r)})}else Object.keys=Uo;return Object.keys||Uo};var bb=Uo,Fo=Object.defineProperty||!1;if(Fo)try{Fo({},"a",{value:1})}catch{Fo=!1}var Ys=Fo,Yt=SyntaxError,G=TypeError,wb=Object.getOwnPropertyDescriptor,Zo=wb;if(Zo)try{Zo([],"length")}catch{Zo=null}var ui=Zo,Wh=Ys,Sb=Yt,Er=G,Gh=ui,zf=function(e,n,r){if(!e||typeof e!="object"&&typeof e!="function")throw new Er("`obj` must be an object or a function`");if(typeof n!="string"&&typeof n!="symbol")throw new Er("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Er("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Er("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Er("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Er("`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,l=!!Gh&&Gh(e,n);if(Wh)Wh(e,n,{configurable:o===null&&l?l.configurable:!o,enumerable:i===null&&l?l.enumerable:!i,value:r,writable:s===null&&l?l.writable:!s});else if(a||!i&&!s&&!o)e[n]=r;else throw new Sb("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},cc=Ys,Mf=function(){return!!cc};Mf.hasArrayLengthDefineBug=function(){if(!cc)return null;try{return cc([],"length",{value:1}).length!==1}catch{return!0}};var Ua=Mf,_b=bb,kb=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Eb=Object.prototype.toString,xb=Array.prototype.concat,qh=zf,$b=function(t){return typeof t=="function"&&Eb.call(t)==="[object Function]"},Lf=Ua(),Ab=function(t,e,n,r){if(e in t){if(r===!0){if(t[e]===n)return}else if(!$b(r)||!r())return}Lf?qh(t,e,n,!0):qh(t,e,n)},Nf=function(t,e){var n=arguments.length>2?arguments[2]:{},r=_b(e);kb&&(r=xb.call(r,Object.getOwnPropertySymbols(e)));for(var i=0;i<r.length;i+=1)Ab(t,r[i],e[r[i]],n[r[i]])};Nf.supportsDescriptors=!!Lf;var fr=Nf,Ho={exports:{}};typeof self<"u"?Ho.exports=self:typeof window<"u"?Ho.exports=window:Ho.exports=Function("return this")();var Uf=Ho.exports,Tb=Uf,Ff=function(){return typeof Rn!="object"||!Rn||Rn.Math!==Math||Rn.Array!==Array?Tb:Rn},Cb=fr,Ib=ui,Pb=Ff,Rb=function(){var e=Pb();if(Cb.supportsDescriptors){var n=Ib(e,"globalThis");(!n||n.configurable&&(n.enumerable||!n.writable||globalThis!==e))&&Object.defineProperty(e,"globalThis",{configurable:!0,enumerable:!1,value:e,writable:!0})}else(typeof globalThis!="object"||globalThis!==e)&&(e.globalThis=e);return e},Db=fr,Ob=Uf,Zf=Ff,zb=Rb,Mb=Zf(),Hf=function(){return Mb};Db(Hf,{getPolyfill:Zf,implementation:Ob,shim:zb});var hu=Hf,Kt=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},du=Object,Bf=Error,Lb=EvalError,Nb=RangeError,pu=ReferenceError,Ub=URIError,Fb=Math.abs,Zb=Math.floor,Hb=Math.max,Bb=Math.min,jb=Math.pow,Vb=Math.round,fu=Number.isNaN||function(e){return e!==e},Wb=fu,Gb=function(e){return Wb(e)||e===0?e:e<0?-1:1},hi=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},n=Symbol("test"),r=Object(n);if(typeof n=="string"||Object.prototype.toString.call(n)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var i=42;e[n]=i;for(var s in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==n||!Object.prototype.propertyIsEnumerable.call(e,n))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,n);if(a.value!==i||a.enumerable!==!0)return!1}return!0},Yh=typeof Symbol<"u"&&Symbol,qb=hi,gu=function(){return typeof Yh!="function"||typeof Symbol!="function"||typeof Yh("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:qb()},jf=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,Yb=du,Vf=Yb.getPrototypeOf||null,Kb="Function.prototype.bind called on incompatible ",Jb=Object.prototype.toString,Xb=Math.max,Qb="[object Function]",Kh=function(e,n){for(var r=[],i=0;i<e.length;i+=1)r[i]=e[i];for(var s=0;s<n.length;s+=1)r[s+e.length]=n[s];return r},ew=function(e,n){for(var r=[],i=n,s=0;i<e.length;i+=1,s+=1)r[s]=e[i];return r},tw=function(t,e){for(var n="",r=0;r<t.length;r+=1)n+=t[r],r+1<t.length&&(n+=e);return n},nw=function(e){var n=this;if(typeof n!="function"||Jb.apply(n)!==Qb)throw new TypeError(Kb+n);for(var r=ew(arguments,1),i,s=function(){if(this instanceof i){var d=n.apply(this,Kh(r,arguments));return Object(d)===d?d:this}return n.apply(e,Kh(r,arguments))},o=Xb(0,n.length-r.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(i=Function("binder","return function ("+tw(a,",")+"){ return binder.apply(this,arguments); }")(s),n.prototype){var u=function(){};u.prototype=n.prototype,i.prototype=new u,u.prototype=null}return i},rw=nw,Ks=Function.prototype.bind||rw,mu=Function.prototype.call,vu=Function.prototype.apply,iw=typeof Reflect<"u"&&Reflect&&Reflect.apply,sw=Ks,ow=vu,aw=mu,lw=iw,Wf=lw||sw.call(aw,ow),cw=Ks,uw=G,hw=mu,dw=Wf,Fa=function(e){if(e.length<1||typeof e[0]!="function")throw new uw("a function is required");return dw(cw,hw,e)},pw=Fa,Jh=ui,Gf;try{Gf=[].__proto__===Array.prototype}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var yl=!!Gf&&Jh&&Jh(Object.prototype,"__proto__"),qf=Object,Xh=qf.getPrototypeOf,fw=yl&&typeof yl.get=="function"?pw([yl.get]):typeof Xh=="function"?function(e){return Xh(e==null?e:qf(e))}:!1,Qh=jf,ed=Vf,td=fw,Yf=Qh?function(e){return Qh(e)}:ed?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return ed(e)}:td?function(e){return td(e)}:null,gw=Function.prototype.call,mw=Object.prototype.hasOwnProperty,vw=Ks,Jt=vw.call(gw,mw),W,yw=du,bw=Bf,ww=Lb,Sw=Nb,_w=pu,ii=Yt,Nr=G,kw=Ub,Ew=Fb,xw=Zb,$w=Hb,Aw=Bb,Tw=jb,Cw=Vb,Iw=Gb,Kf=Function,bl=function(t){try{return Kf('"use strict"; return ('+t+").constructor;")()}catch{}},ns=ui,Pw=Ys,wl=function(){throw new Nr},Rw=ns?function(){try{return arguments.callee,wl}catch{try{return ns(arguments,"callee").get}catch{return wl}}}():wl,xr=gu(),_e=Yf,Dw=Vf,Ow=jf,Jf=vu,Js=mu,Tr={},zw=typeof Uint8Array>"u"||!_e?W:_e(Uint8Array),ar={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?W:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?W:ArrayBuffer,"%ArrayIteratorPrototype%":xr&&_e?_e([][Symbol.iterator]()):W,"%AsyncFromSyncIteratorPrototype%":W,"%AsyncFunction%":Tr,"%AsyncGenerator%":Tr,"%AsyncGeneratorFunction%":Tr,"%AsyncIteratorPrototype%":Tr,"%Atomics%":typeof Atomics>"u"?W:Atomics,"%BigInt%":typeof BigInt>"u"?W:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?W:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?W:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?W:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":bw,"%eval%":eval,"%EvalError%":ww,"%Float16Array%":typeof Float16Array>"u"?W:Float16Array,"%Float32Array%":typeof Float32Array>"u"?W:Float32Array,"%Float64Array%":typeof Float64Array>"u"?W:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?W:FinalizationRegistry,"%Function%":Kf,"%GeneratorFunction%":Tr,"%Int8Array%":typeof Int8Array>"u"?W:Int8Array,"%Int16Array%":typeof Int16Array>"u"?W:Int16Array,"%Int32Array%":typeof Int32Array>"u"?W:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":xr&&_e?_e(_e([][Symbol.iterator]())):W,"%JSON%":typeof JSON=="object"?JSON:W,"%Map%":typeof Map>"u"?W:Map,"%MapIteratorPrototype%":typeof Map>"u"||!xr||!_e?W:_e(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":yw,"%Object.getOwnPropertyDescriptor%":ns,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?W:Promise,"%Proxy%":typeof Proxy>"u"?W:Proxy,"%RangeError%":Sw,"%ReferenceError%":_w,"%Reflect%":typeof Reflect>"u"?W:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?W:Set,"%SetIteratorPrototype%":typeof Set>"u"||!xr||!_e?W:_e(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?W:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":xr&&_e?_e(""[Symbol.iterator]()):W,"%Symbol%":xr?Symbol:W,"%SyntaxError%":ii,"%ThrowTypeError%":Rw,"%TypedArray%":zw,"%TypeError%":Nr,"%Uint8Array%":typeof Uint8Array>"u"?W:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?W:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?W:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?W:Uint32Array,"%URIError%":kw,"%WeakMap%":typeof WeakMap>"u"?W:WeakMap,"%WeakRef%":typeof WeakRef>"u"?W:WeakRef,"%WeakSet%":typeof WeakSet>"u"?W:WeakSet,"%Function.prototype.call%":Js,"%Function.prototype.apply%":Jf,"%Object.defineProperty%":Pw,"%Object.getPrototypeOf%":Dw,"%Math.abs%":Ew,"%Math.floor%":xw,"%Math.max%":$w,"%Math.min%":Aw,"%Math.pow%":Tw,"%Math.round%":Cw,"%Math.sign%":Iw,"%Reflect.getPrototypeOf%":Ow};if(_e)try{null.error}catch(t){var Mw=_e(_e(t));ar["%Error.prototype%"]=Mw}var Lw=function t(e){var n;if(e==="%AsyncFunction%")n=bl("async function () {}");else if(e==="%GeneratorFunction%")n=bl("function* () {}");else if(e==="%AsyncGeneratorFunction%")n=bl("async function* () {}");else if(e==="%AsyncGenerator%"){var r=t("%AsyncGeneratorFunction%");r&&(n=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=t("%AsyncGenerator%");i&&_e&&(n=_e(i.prototype))}return ar[e]=n,n},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=Jt,Nw=Xs.call(Js,Array.prototype.concat),Uw=Xs.call(Jf,Array.prototype.splice),rd=Xs.call(Js,String.prototype.replace),ra=Xs.call(Js,String.prototype.slice),Fw=Xs.call(Js,RegExp.prototype.exec),Zw=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Hw=/\\(\\)?/g,Bw=function(e){var n=ra(e,0,1),r=ra(e,-1);if(n==="%"&&r!=="%")throw new ii("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&n!=="%")throw new ii("invalid intrinsic syntax, expected opening `%`");var i=[];return rd(e,Zw,function(s,o,a,l){i[i.length]=a?rd(l,Hw,"$1"):o||s}),i},jw=function(e,n){var r=e,i;if(na(nd,r)&&(i=nd[r],r="%"+i[0]+"%"),na(ar,r)){var s=ar[r];if(s===Tr&&(s=Lw(r)),typeof s>"u"&&!n)throw new Nr("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:s}}throw new ii("intrinsic "+e+" does not exist!")},ot=function(e,n){if(typeof e!="string"||e.length===0)throw new Nr("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof n!="boolean")throw new Nr('"allowMissing" argument must be a boolean');if(Fw(/^%?[^%]*%?$/,e)===null)throw new ii("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=Bw(e),i=r.length>0?r[0]:"",s=jw("%"+i+"%",n),o=s.name,a=s.value,l=!1,u=s.alias;u&&(i=u[0],Uw(r,Nw([0,1],u)));for(var d=1,p=!0;d<r.length;d+=1){var y=r[d],v=ra(y,0,1),A=ra(y,-1);if((v==='"'||v==="'"||v==="`"||A==='"'||A==="'"||A==="`")&&v!==A)throw new ii("property names with quotes must have matching quotes");if((y==="constructor"||!p)&&(l=!0),i+="."+y,o="%"+i+"%",na(ar,o))a=ar[o];else if(a!=null){if(!(y in a)){if(!n)throw new Nr("base intrinsic for "+e+" exists, but the property is not available.");return}if(ns&&d+1>=r.length){var E=ns(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&&!l&&(ar[o]=a)}}return a},Sl,id;function Sn(){if(id)return Sl;id=1;var t=ot,e=Fa,n=e([t("%String.prototype.indexOf%")]);return Sl=function(i,s){var o=t(i,!!s);return typeof o=="function"&&n(i,".prototype.")>-1?e([o]):o},Sl}var _l,sd;function yu(){if(sd)return _l;sd=1;var t=ot,e=t("%Array%"),n=!e.isArray&&Sn()("Object.prototype.toString");return _l=e.isArray||function(i){return n(i)==="[object Array]"},_l}var Vw=Ua,od=Ys,Xf=Vw.hasArrayLengthDefineBug(),Ww=Xf&&yu(),Gw=Sn(),qw=Gw("Object.prototype.propertyIsEnumerable"),bu=function(e,n,r,i,s,o){if(!od){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&qw(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,n(i[s],a)}return Xf&&s==="length"&&"[[Value]]"in o&&Ww(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(od(i,s,r(o)),!0)},Yw=G,Ai=Jt,Kw={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},di=function(e){if(!e||typeof e!="object")return!1;for(var n in e)if(Ai(e,n)&&!Kw[n])return!1;var r=Ai(e,"[[Value]]")||Ai(e,"[[Writable]]"),i=Ai(e,"[[Get]]")||Ai(e,"[[Set]]");if(r&&i)throw new Yw("Property Descriptors may not be both accessor and data descriptors");return!0},Qf=function(e){if(typeof e>"u")return e;var n={};return"[[Value]]"in e&&(n.value=e["[[Value]]"]),"[[Writable]]"in e&&(n.writable=!!e["[[Writable]]"]),"[[Get]]"in e&&(n.get=e["[[Get]]"]),"[[Set]]"in e&&(n.set=e["[[Set]]"]),"[[Enumerable]]"in e&&(n.enumerable=!!e["[[Enumerable]]"]),"[[Configurable]]"in e&&(n.configurable=!!e["[[Configurable]]"]),n},Jw=G,Xw=di,Qw=Qf,eg=function(e){if(typeof e<"u"&&!Xw(e))throw new Jw("Assertion failed: `Desc` must be a Property Descriptor");return Qw(e)},e0=G,ad=Jt,t0=di,tg=function(e){if(typeof e>"u")return!1;if(!t0(e))throw new e0("Assertion failed: `Desc` must be a Property Descriptor");return!(!ad(e,"[[Value]]")&&!ad(e,"[[Writable]]"))},pi=function(e){return typeof e=="string"||typeof e=="symbol"},ld=fu,ng=function(e,n){return e===n?e===0?1/e===1/n:!0:ld(e)&&ld(n)},cd=G,n0=Kt,r0=bu,i0=eg,s0=tg,o0=pi,a0=ng,wu=function(e,n,r){if(!n0(e))throw new cd("Assertion failed: Type(O) is not Object");if(!o0(n))throw new cd("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return r0(s0,a0,i0,e,n,i)},rg=Function.prototype.toString,zr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,uc,Bo;if(typeof zr=="function"&&typeof Object.defineProperty=="function")try{uc=Object.defineProperty({},"length",{get:function(){throw Bo}}),Bo={},zr(function(){throw 42},null,uc)}catch(t){t!==Bo&&(zr=null)}else zr=null;var l0=/^\s*class\b/,hc=function(e){try{var n=rg.call(e);return l0.test(n)}catch{return!1}},kl=function(e){try{return hc(e)?!1:(rg.call(e),!0)}catch{return!1}},jo=Object.prototype.toString,c0="[object Object]",u0="[object Function]",h0="[object GeneratorFunction]",d0="[object HTMLAllCollection]",p0="[object HTML document.all class]",f0="[object HTMLCollection]",g0=typeof Symbol=="function"&&!!Symbol.toStringTag,m0=!(0 in[,]),dc=function(){return!1};if(typeof document=="object"){var v0=document.all;jo.call(v0)===jo.call(document.all)&&(dc=function(e){if((m0||!e)&&(typeof e>"u"||typeof e=="object"))try{var n=jo.call(e);return(n===d0||n===p0||n===f0||n===c0)&&e("")==null}catch{}return!1})}var ig=zr?function(e){if(dc(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{zr(e,null,uc)}catch(n){if(n!==Bo)return!1}return!hc(e)&&kl(e)}:function(e){if(dc(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(g0)return kl(e);if(hc(e))return!1;var n=jo.call(e);return n!==u0&&n!==h0&&!/^\[object HTML/.test(n)?!1:kl(e)},y0=ig,b0=function(e){return!!e},wt=Jt,bo=G,w0=Kt,ud=y0,El=b0,S0=function(e){if(!w0(e))throw new bo("ToPropertyDescriptor requires an object");var n={};if(wt(e,"enumerable")&&(n["[[Enumerable]]"]=El(e.enumerable)),wt(e,"configurable")&&(n["[[Configurable]]"]=El(e.configurable)),wt(e,"value")&&(n["[[Value]]"]=e.value),wt(e,"writable")&&(n["[[Writable]]"]=El(e.writable)),wt(e,"get")){var r=e.get;if(typeof r<"u"&&!ud(r))throw new bo("getter must be a function");n["[[Get]]"]=r}if(wt(e,"set")){var i=e.set;if(typeof i<"u"&&!ud(i))throw new bo("setter must be a function");n["[[Set]]"]=i}if((wt(n,"[[Get]]")||wt(n,"[[Set]]"))&&(wt(n,"[[Value]]")||wt(n,"[[Writable]]")))throw new bo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},xl=G,_0=Kt,hd=di,k0=bu,E0=eg,x0=tg,$0=pi,A0=ng,T0=S0,C0=function(e,n,r){if(!_0(e))throw new xl("Assertion failed: Type(O) is not Object");if(!$0(n))throw new xl("Assertion failed: P is not a Property Key");var i=hd(r)?r:T0(r);if(!hd(i))throw new xl("Assertion failed: Desc is not a valid Property Descriptor");return k0(x0,A0,E0,e,n,i)},dd=G,I0=Kt,P0=C0,R0=pi,D0=function(e,n,r){if(!I0(e))throw new dd("Assertion failed: Type(O) is not Object");if(!R0(n))throw new dd("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return P0(e,n,i)},O0=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,z0=du,M0=z0.setPrototypeOf||null,L0=Fa,pd=ui,N0=G,sg={};try{sg.__proto__=null}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var U0=!("toString"in sg),$l=pd&&pd(Object.prototype,"__proto__"),F0=U0&&(!!$l&&typeof $l.set=="function"&&L0([$l.set])||function(e,n){if(e==null)throw new N0("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=n,n}),fd=O0,Z0=M0,gd=F0,H0=G,B0=fd?function(e,n){if(fd(e,n))return e;throw new H0("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:Z0||(gd?function(e,n){return gd(e,n),e}:null),md=G,j0=Kt,vd=Yf,V0=function(e){if(!j0(e))throw new md("Assertion failed: O must be an Object");if(!vd)throw new md("This environment does not support fetching prototypes.");return vd(e)},W0=G,G0=B0,q0=Kt,Y0=V0,K0=function(e,n){if(n!==null&&!q0(n))throw new W0("Assertion failed: V must be Object or Null");try{G0(e,n)}catch{return!1}return Y0(e)===n},Al=wu,yd=D0,og=K0,J0=Ua(),Su=Bf;function Qs(t,e,n){var r=new Su(n);return og(r,Vo),delete r.constructor,yd(r,"error",t),yd(r,"suppressed",e),r}J0&&Object.defineProperty(Qs,"prototype",{writable:!1});var Vo=Qs.prototype;if(!Al(Vo,"constructor",Qs)||!Al(Vo,"message","")||!Al(Vo,"name","SuppressedError"))throw new Su("unable to install SuppressedError.prototype properties; please report this!");og(Qs.prototype,Su.prototype);var X0=Qs,Q0=X0,ag=function(){return typeof SuppressedError=="function"?SuppressedError:Q0},eS=fr,bd=hu(),tS=ag,nS=function(){var e=tS();return eS(bd,{SuppressedError:e},{SuppressedError:function(){return bd.SuppressedError!==e}}),e};nS();var rS=G,iS=di,sS=Qf,oS=function(e){if(typeof e<"u"&&!iS(e))throw new rS("Assertion failed: `Desc` must be a Property Descriptor");return sS(e)},aS=G,wd=Jt,lS=di,cS=function(e){if(typeof e>"u")return!1;if(!lS(e))throw new aS("Assertion failed: `Desc` must be a Property Descriptor");return!(!wd(e,"[[Value]]")&&!wd(e,"[[Writable]]"))},Sd=fu,uS=function(e,n){return e===n?e===0?1/e===1/n:!0:Sd(e)&&Sd(n)},fi=ig,hS=function(e){return!!e},St=Jt,wo=G,dS=Kt,_d=fi,Tl=hS,pS=function(e){if(!dS(e))throw new wo("ToPropertyDescriptor requires an object");var n={};if(St(e,"enumerable")&&(n["[[Enumerable]]"]=Tl(e.enumerable)),St(e,"configurable")&&(n["[[Configurable]]"]=Tl(e.configurable)),St(e,"value")&&(n["[[Value]]"]=e.value),St(e,"writable")&&(n["[[Writable]]"]=Tl(e.writable)),St(e,"get")){var r=e.get;if(typeof r<"u"&&!_d(r))throw new wo("getter must be a function");n["[[Get]]"]=r}if(St(e,"set")){var i=e.set;if(typeof i<"u"&&!_d(i))throw new wo("setter must be a function");n["[[Set]]"]=i}if((St(n,"[[Get]]")||St(n,"[[Set]]"))&&(St(n,"[[Value]]")||St(n,"[[Writable]]")))throw new wo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},Cl=G,fS=Kt,kd=di,gS=bu,mS=oS,vS=cS,yS=pi,bS=uS,wS=pS,eo=function(e,n,r){if(!fS(e))throw new Cl("Assertion failed: Type(O) is not Object");if(!yS(n))throw new Cl("Assertion failed: P is not a Property Key");var i=kd(r)?r:wS(r);if(!kd(i))throw new Cl("Assertion failed: Desc is not a valid Property Descriptor");return gS(vS,bS,mS,e,n,i)},SS=hi(),_S=SS?Symbol.dispose||Symbol("Symbol.dispose"):null,kS=hi,ES=_S,_u=function(){return kS()&&Symbol.dispose||ES},xS=gu,$S=eo,AS=_u,TS=function(){var e=AS();return xS()&&$S(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},CS=hi(),IS=CS?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,PS=hi,RS=IS,ku=function(){return PS()&&Symbol.asyncDispose||RS},DS=gu,OS=eo,zS=ku,MS=function(){var e=zS();return DS()&&OS(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},LS=yu(),NS=ot,US=Sn(),FS=G,ZS=LS,HS=NS("%Reflect.apply%",!0)||US("Function.prototype.apply"),Za=function(e,n){var r=arguments.length>2?arguments[2]:[];if(!ZS(r))throw new FS("Assertion failed: optional `argumentsList`, if provided, must be a List");return HS(e,n,r)};const BS={},jS=Object.freeze(Object.defineProperty({__proto__:null,default:BS},Symbol.toStringTag,{value:"Module"})),VS=gb(jS);var Eu=typeof Map=="function"&&Map.prototype,Il=Object.getOwnPropertyDescriptor&&Eu?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,ia=Eu&&Il&&typeof Il.get=="function"?Il.get:null,Ed=Eu&&Map.prototype.forEach,xu=typeof Set=="function"&&Set.prototype,Pl=Object.getOwnPropertyDescriptor&&xu?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,sa=xu&&Pl&&typeof Pl.get=="function"?Pl.get:null,xd=xu&&Set.prototype.forEach,WS=typeof WeakMap=="function"&&WeakMap.prototype,Ki=WS?WeakMap.prototype.has:null,GS=typeof WeakSet=="function"&&WeakSet.prototype,Ji=GS?WeakSet.prototype.has:null,qS=typeof WeakRef=="function"&&WeakRef.prototype,$d=qS?WeakRef.prototype.deref:null,YS=Boolean.prototype.valueOf,KS=Object.prototype.toString,JS=Function.prototype.toString,XS=String.prototype.match,$u=String.prototype.slice,dn=String.prototype.replace,QS=String.prototype.toUpperCase,Ad=String.prototype.toLowerCase,lg=RegExp.prototype.test,Td=Array.prototype.concat,Ct=Array.prototype.join,e_=Array.prototype.slice,Cd=Math.floor,pc=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Rl=Object.getOwnPropertySymbols,fc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,si=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Xi=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===si||!0)?Symbol.toStringTag:null,cg=Object.prototype.propertyIsEnumerable,Id=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function Pd(t,e){if(t===1/0||t===-1/0||t!==t||t&&t>-1e3&&t<1e3||lg.call(/e/,e))return e;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof t=="number"){var r=t<0?-Cd(-t):Cd(t);if(r!==t){var i=String(r),s=$u.call(e,i.length+1);return dn.call(i,n,"$&_")+"."+dn.call(dn.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return dn.call(e,n,"$&_")}var gc=VS,Rd=gc.custom,Dd=dg(Rd)?Rd:null,ug={__proto__:null,double:'"',single:"'"},t_={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},gi=function t(e,n,r,i){var s=n||{};if(Lt(s,"quoteStyle")&&!Lt(ug,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Lt(s,"maxStringLength")&&(typeof s.maxStringLength=="number"?s.maxStringLength<0&&s.maxStringLength!==1/0:s.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=Lt(s,"customInspect")?s.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Lt(s,"indent")&&s.indent!==null&&s.indent!==" "&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Lt(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=s.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return fg(e,s);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var l=String(e);return a?Pd(e,l):l}if(typeof e=="bigint"){var u=String(e)+"n";return a?Pd(e,u):u}var d=typeof s.depth>"u"?5:s.depth;if(typeof r>"u"&&(r=0),r>=d&&d>0&&typeof e=="object")return mc(e)?"[Array]":"[Object]";var p=b_(s,r);if(typeof i>"u")i=[];else if(pg(i,e)>=0)return"[Circular]";function y(vt,Qt,il){if(Qt&&(i=e_.call(i),i.push(Qt)),il){var co={depth:s.depth};return Lt(s,"quoteStyle")&&(co.quoteStyle=s.quoteStyle),t(vt,co,r+1,i)}return t(vt,s,r+1,i)}if(typeof e=="function"&&!Od(e)){var v=u_(e),A=So(e,y);return"[Function"+(v?": "+v:" (anonymous)")+"]"+(A.length>0?" { "+Ct.call(A,", ")+" }":"")}if(dg(e)){var E=si?dn.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):fc.call(e);return typeof e=="object"&&!si?Ti(E):E}if(m_(e)){for(var I="<"+Ad.call(String(e.nodeName)),Z=e.attributes||[],P=0;P<Z.length;P++)I+=" "+Z[P].name+"="+hg(n_(Z[P].value),"double",s);return I+=">",e.childNodes&&e.childNodes.length&&(I+="..."),I+="</"+Ad.call(String(e.nodeName))+">",I}if(mc(e)){if(e.length===0)return"[]";var V=So(e,y);return p&&!y_(V)?"["+vc(V,p)+"]":"[ "+Ct.call(V,", ")+" ]"}if(i_(e)){var O=So(e,y);return!("cause"in Error.prototype)&&"cause"in e&&!cg.call(e,"cause")?"{ ["+String(e)+"] "+Ct.call(Td.call("[cause]: "+y(e.cause),O),", ")+" }":O.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+Ct.call(O,", ")+" }"}if(typeof e=="object"&&o){if(Dd&&typeof e[Dd]=="function"&&gc)return gc(e,{depth:d-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(h_(e)){var H=[];return Ed&&Ed.call(e,function(vt,Qt){H.push(y(Qt,e,!0)+" => "+y(vt,e))}),zd("Map",ia.call(e),H,p)}if(f_(e)){var N=[];return xd&&xd.call(e,function(vt){N.push(y(vt,e))}),zd("Set",sa.call(e),N,p)}if(d_(e))return Dl("WeakMap");if(g_(e))return Dl("WeakSet");if(p_(e))return Dl("WeakRef");if(o_(e))return Ti(y(Number(e)));if(l_(e))return Ti(y(pc.call(e)));if(a_(e))return Ti(YS.call(e));if(s_(e))return Ti(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(!r_(e)&&!Od(e)){var ce=So(e,y),ue=Id?Id(e)===Object.prototype:e instanceof Object||e.constructor===Object,ki=e instanceof Object?"":"null prototype",lo=!ue&&Xi&&Object(e)===e&&Xi in e?$u.call(_n(e),8,-1):ki?"Object":"",xe=ue||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",xn=xe+(lo||ki?"["+Ct.call(Td.call([],lo||[],ki||[]),": ")+"] ":"");return ce.length===0?xn+"{}":p?xn+"{"+vc(ce,p)+"}":xn+"{ "+Ct.call(ce,", ")+" }"}return String(e)};function hg(t,e,n){var r=n.quoteStyle||e,i=ug[r];return i+t+i}function n_(t){return dn.call(String(t),/"/g,""")}function gr(t){return!Xi||!(typeof t=="object"&&(Xi in t||typeof t[Xi]<"u"))}function mc(t){return _n(t)==="[object Array]"&&gr(t)}function r_(t){return _n(t)==="[object Date]"&&gr(t)}function Od(t){return _n(t)==="[object RegExp]"&&gr(t)}function i_(t){return _n(t)==="[object Error]"&&gr(t)}function s_(t){return _n(t)==="[object String]"&&gr(t)}function o_(t){return _n(t)==="[object Number]"&&gr(t)}function a_(t){return _n(t)==="[object Boolean]"&&gr(t)}function dg(t){if(si)return t&&typeof t=="object"&&t instanceof Symbol;if(typeof t=="symbol")return!0;if(!t||typeof t!="object"||!fc)return!1;try{return fc.call(t),!0}catch{}return!1}function l_(t){if(!t||typeof t!="object"||!pc)return!1;try{return pc.call(t),!0}catch{}return!1}var c_=Object.prototype.hasOwnProperty||function(t){return t in this};function Lt(t,e){return c_.call(t,e)}function _n(t){return KS.call(t)}function u_(t){if(t.name)return t.name;var e=XS.call(JS.call(t),/^function\s*([\w$]+)/);return e?e[1]:null}function pg(t,e){if(t.indexOf)return t.indexOf(e);for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1}function h_(t){if(!ia||!t||typeof t!="object")return!1;try{ia.call(t);try{sa.call(t)}catch{return!0}return t instanceof Map}catch{}return!1}function d_(t){if(!Ki||!t||typeof t!="object")return!1;try{Ki.call(t,Ki);try{Ji.call(t,Ji)}catch{return!0}return t instanceof WeakMap}catch{}return!1}function p_(t){if(!$d||!t||typeof t!="object")return!1;try{return $d.call(t),!0}catch{}return!1}function f_(t){if(!sa||!t||typeof t!="object")return!1;try{sa.call(t);try{ia.call(t)}catch{return!0}return t instanceof Set}catch{}return!1}function g_(t){if(!Ji||!t||typeof t!="object")return!1;try{Ji.call(t,Ji);try{Ki.call(t,Ki)}catch{return!0}return t instanceof WeakSet}catch{}return!1}function m_(t){return!t||typeof t!="object"?!1:typeof HTMLElement<"u"&&t instanceof HTMLElement?!0:typeof t.nodeName=="string"&&typeof t.getAttribute=="function"}function fg(t,e){if(t.length>e.maxStringLength){var n=t.length-e.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return fg($u.call(t,0,e.maxStringLength),e)+r}var i=t_[e.quoteStyle||"single"];i.lastIndex=0;var s=dn.call(dn.call(t,i,"\\$1"),/[\x00-\x1f]/g,v_);return hg(s,"single",e)}function v_(t){var e=t.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return n?"\\"+n:"\\x"+(e<16?"0":"")+QS.call(e.toString(16))}function Ti(t){return"Object("+t+")"}function Dl(t){return t+" { ? }"}function zd(t,e,n,r){var i=r?vc(n,r):Ct.call(n,", ");return t+" ("+e+") {"+i+"}"}function y_(t){for(var e=0;e<t.length;e++)if(pg(t[e],`
|
|
2
|
+
`)>=0)return!1;return!0}function b_(t,e){var n;if(t.indent===" ")n=" ";else if(typeof t.indent=="number"&&t.indent>0)n=Ct.call(Array(t.indent+1)," ");else return null;return{base:n,prev:Ct.call(Array(e+1),n)}}function vc(t,e){if(t.length===0)return"";var n=`
|
|
3
|
+
`+e.prev+e.base;return n+Ct.call(t,","+n)+`
|
|
4
|
+
`+e.prev}function So(t,e){var n=mc(t),r=[];if(n){r.length=t.length;for(var i=0;i<t.length;i++)r[i]=Lt(t,i)?e(t[i],t):""}var s=typeof Rl=="function"?Rl(t):[],o;if(si){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var l in t)Lt(t,l)&&(n&&String(Number(l))===l&&l<t.length||si&&o["$"+l]instanceof Symbol||(lg.call(/[^\w$]/,l)?r.push(e(l,t)+": "+e(t[l],t)):r.push(l+": "+e(t[l],t))));if(typeof Rl=="function")for(var u=0;u<s.length;u++)cg.call(t,s[u])&&r.push("["+e(s[u])+"]: "+e(t[s[u]],t));return r}var w_=gi,S_=G,Ha=function(t,e,n){for(var r=t,i;(i=r.next)!=null;r=i)if(i.key===e)return r.next=i.next,n||(i.next=t.next,t.next=i),i},__=function(t,e){if(t){var n=Ha(t,e);return n&&n.value}},k_=function(t,e,n){var r=Ha(t,e);r?r.value=n:t.next={key:e,next:t.next,value:n}},E_=function(t,e){return t?!!Ha(t,e):!1},x_=function(t,e){if(t)return Ha(t,e,!0)},$_=function(){var e,n={assert:function(r){if(!n.has(r))throw new S_("Side channel does not contain "+w_(r))},delete:function(r){var i=e&&e.next,s=x_(e,r);return s&&i&&i===s&&(e=void 0),!!s},get:function(r){return __(e,r)},has:function(r){return E_(e,r)},set:function(r,i){e||(e={next:void 0}),k_(e,r,i)}};return n},A_=ot,to=Sn(),T_=gi,C_=G,Md=A_("%Map%",!0),I_=to("Map.prototype.get",!0),P_=to("Map.prototype.set",!0),R_=to("Map.prototype.has",!0),D_=to("Map.prototype.delete",!0),O_=to("Map.prototype.size",!0),gg=!!Md&&function(){var e,n={assert:function(r){if(!n.has(r))throw new C_("Side channel does not contain "+T_(r))},delete:function(r){if(e){var i=D_(e,r);return O_(e)===0&&(e=void 0),i}return!1},get:function(r){if(e)return I_(e,r)},has:function(r){return e?R_(e,r):!1},set:function(r,i){e||(e=new Md),P_(e,r,i)}};return n},z_=ot,Ba=Sn(),M_=gi,_o=gg,L_=G,$r=z_("%WeakMap%",!0),N_=Ba("WeakMap.prototype.get",!0),U_=Ba("WeakMap.prototype.set",!0),F_=Ba("WeakMap.prototype.has",!0),Z_=Ba("WeakMap.prototype.delete",!0),H_=$r?function(){var e,n,r={assert:function(i){if(!r.has(i))throw new L_("Side channel does not contain "+M_(i))},delete:function(i){if($r&&i&&(typeof i=="object"||typeof i=="function")){if(e)return Z_(e,i)}else if(_o&&n)return n.delete(i);return!1},get:function(i){return $r&&i&&(typeof i=="object"||typeof i=="function")&&e?N_(e,i):n&&n.get(i)},has:function(i){return $r&&i&&(typeof i=="object"||typeof i=="function")&&e?F_(e,i):!!n&&n.has(i)},set:function(i,s){$r&&i&&(typeof i=="object"||typeof i=="function")?(e||(e=new $r),U_(e,i,s)):_o&&(n||(n=_o()),n.set(i,s))}};return r}:_o,B_=G,j_=gi,V_=$_,W_=gg,G_=H_,q_=G_||W_||V_,Y_=function(){var e,n={assert:function(r){if(!n.has(r))throw new B_("Side channel does not contain "+j_(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=q_()),e.set(r,i)}};return n},K_=Jt,Ci=Y_(),Ot=G,Au={assert:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new Ot("`O` is not an object");if(typeof e!="string")throw new Ot("`slot` must be a string");if(Ci.assert(t),!Au.has(t,e))throw new Ot("`"+e+"` is not present on `O`")},get:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new Ot("`O` is not an object");if(typeof e!="string")throw new Ot("`slot` must be a string");var n=Ci.get(t);return n&&n["$"+e]},has:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new Ot("`O` is not an object");if(typeof e!="string")throw new Ot("`slot` must be a string");var n=Ci.get(t);return!!n&&K_(n,"$"+e)},set:function(t,e,n){if(!t||typeof t!="object"&&typeof t!="function")throw new Ot("`O` is not an object");if(typeof e!="string")throw new Ot("`slot` must be a string");var r=Ci.get(t);r||(r={},Ci.set(t,r)),r["$"+e]=n}};Object.freeze&&Object.freeze(Au);var Tu=Au,mg=Yt,pn=Tu,no=function t(e,n){if(!(this instanceof t))return new t(e,n);if(e!=="normal"&&e!=="break"&&e!=="continue"&&e!=="return"&&e!=="throw")throw new mg('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');pn.set(this,"[[Type]]",e),pn.set(this,"[[Value]]",n)};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]]"),n=pn.get(this,"[[Value]]");if(e==="throw")throw n;return n};no.prototype["!"]=function(){var e=pn.get(this,"[[Type]]");if(e!=="normal")throw new mg('Assertion failed: Completion Record is not of type "normal"');return pn.get(this,"[[Value]]")};var Cu=no,J_=Cu,Iu=function(e){return new J_("normal",e)},Ol,Ld;function X_(){if(Ld)return Ol;Ld=1;var t=hi;return Ol=function(){return t()&&!!Symbol.toStringTag},Ol}var Q_=ot,Nd=Q_("%Object.defineProperty%",!0),ek=X_()(),tk=Jt,nk=G,ko=ek?Symbol.toStringTag:null,vg=function(e,n){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,i=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof r<"u"&&typeof r!="boolean"||typeof i<"u"&&typeof i!="boolean")throw new nk("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");ko&&(r||!tk(e,ko))&&(Nd?Nd(e,ko,{configurable:!i,enumerable:!1,value:n,writable:!1}):e[ko]=n)},yg={exports:{}},rk=ot,Ud=zf,ik=Ua(),Fd=ui,Zd=G,sk=rk("%Math.floor%"),ok=function(e,n){if(typeof e!="function")throw new Zd("`fn` is not a function");if(typeof n!="number"||n<0||n>4294967295||sk(n)!==n)throw new Zd("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in e&&Fd){var o=Fd(e,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!r)&&(ik?Ud(e,"length",n,!0,!0):Ud(e,"length",n)),e},ak=Ks,lk=vu,ck=Wf,uk=function(){return ck(ak,lk,arguments)};(function(t){var e=ok,n=Ys,r=Fa,i=uk;t.exports=function(o){var a=r(arguments),l=1+o.length-(arguments.length-1);return e(a,l>0?l:0,!0)},n?n(t.exports,"apply",{value:i}):t.exports.apply=i})(yg);var Pu=yg.exports,hk=function(e,n){for(var r=0;r<e.length;r+=1)if(!n(e[r],r,e))return!1;return!0},dk=Object,pk=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||dk(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},fk=Jt,gk=yu(),mk=hk,vk=pk,yk=function(e){return e&&typeof e=="object"&&fk(e,"[[DisposableResourceStack]]")&&gk(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||mk(e["[[DisposableResourceStack]]"],vk))},bk=Kt,wk=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(bk(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},Sk=wk,Ru=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":Sk(e)},_k=G,kk=gi,Ek=pi,xk=function(e,n){if(!Ek(n))throw new _k("Assertion failed: P is not a Property Key, got "+kk(n));return e[n]},Hd=G,$k=xk,Ak=fi,Tk=pi,Bd=gi,Ck=function(e,n){if(!Tk(n))throw new Hd("Assertion failed: P is not a Property Key");var r=$k(e,n);if(r!=null){if(!Ak(r))throw new Hd(Bd(n)+" is not a function: "+Bd(r));return r}},yc={exports:{}},Ik=ot,Pk=Ik,jd=Pk("%Reflect.construct%",!0),oa=eo;try{oa({},"",{"[[Get]]":function(){}})}catch{oa=null}if(oa&&jd){var Vd={},Wd={};oa(Wd,"length",{"[[Get]]":function(){throw Vd},"[[Enumerable]]":!0}),yc.exports=function(e){try{jd(e,Wd)}catch(n){return n===Vd}}}else yc.exports=function(e){return typeof e=="function"&&!!e.prototype};var Rk=yc.exports,zl=G,Gd=fi,Dk=Rk,Ok=function(e){if(!Dk(e))throw new zl("C must be a constructor");var n={"[[Resolve]]":void 0,"[[Reject]]":void 0},r=new e(function(i,s){if(typeof n["[[Resolve]]"]<"u"||typeof n["[[Reject]]"]<"u")throw new zl("executor has already been called");n["[[Resolve]]"]=i,n["[[Reject]]"]=s});if(!Gd(n["[[Resolve]]"])||!Gd(n["[[Reject]]"]))throw new zl("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":n["[[Resolve]]"],"[[Reject]]":n["[[Reject]]"]}},qd=Yt,zk=G,Ml=Za,Yd=Ck,Mk=Ok,Lk=Ru,Kd=_u(),Jd=ku(),Nk=function(e,n){if(Lk(e)!=="Object")throw new zk("`V` must be an Object");if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new qd("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(n==="ASYNC-DISPOSE"&&Jd&&(r=Yd(e,Jd)),!r){if(!Kd)throw new qd("`Symbol.dispose` is not supported");if(r=Yd(e,Kd),typeof r<"u")return function(){var i=this;if(n==="ASYNC-DISPOSE"){var s=Mk(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},Uk=Yt,Ll=G,Fk=fi,Zk=Ru,Hk=Nk,Bk=function(e,n){if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new Uk("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"&&Zk(e)!=="Object")throw new Ll("`V` must be an Object, or `null` or `undefined`");if(r=Hk(e,n),typeof r>"u")throw new Ll("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!Fk(r))throw new Ll("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":n,"[[DisposeMethod]]":r}},jk=Yt,Eo=G,Vk=yk,Xd=Bk,Wk=Sn(),Gk=Wk("Array.prototype.push"),bg=function(e,n,r){if(!Vk(e))throw new Eo("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new jk("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(n==null&&r==="SYNC_DISPOSE")return"UNUSED";s=Xd(n,r)}else{if(typeof n<"u")throw new Eo("Assertion failed: `V` must be undefined when `method` is present");s=Xd(void 0,r,i)}return Gk(e["[[DisposableResourceStack]]"],s),"UNUSED"},Nl,Qd;function Du(){if(Qd)return Nl;Qd=1;var t=ot,e=Pu,n=Yt,r=t("%Promise.resolve%",!0),i=r&&e(r);return Nl=function(o,a){if(!i)throw new n("This environment does not support Promises.");return i(o,a)},Nl}var Ul,ep;function qk(){if(ep)return Ul;ep=1;var t=ot,e=Yt,n=t("%Promise%",!0),r=Za,i=Du(),s=Ru;return Ul=function(a,l,u){if(typeof a<"u"&&s(a)!=="Object")throw new e("Assertion failed: `V` must be `undefined` or an Object");if(l!=="SYNC-DISPOSE"&&l!=="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(l==="ASYNC-DISPOSE")return i(n,d)},Ul}var Fl,tp;function Yk(){if(tp)return Fl;tp=1;var t=Cu;return Fl=function(n){return new t("throw",n)},Fl}var Kk=ot,Zl=Yt,np=G,Jk=Kk("%Promise%",!0),Xk=Sn(),rp=Xk("Promise.prototype.then",!0),Qk=Cu,ip=qk(),eE=Iu,tE=Du(),sp=Yk(),nE=ag(),wg=function(e,n){if(!(n instanceof Qk))throw new np("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new np("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 Zl("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&tE(Jk,n),a=function(y){if(n.type()==="throw"){var v=n.value(),A=new nE(y,v);n=sp(A)}else n=sp(y)},l=i==="ASYNC-DISPOSE"&&function(v){return rp(o,function(){var A=ip(v["[[ResourceValue]]"],v["[[Hint]]"],v["[[DisposeMethod]]"]);if(!A)throw new Zl("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return rp(A,eE)},a)},u=r.length-1;u>=0;u-=1)if(i==="ASYNC-DISPOSE")o=l(r[u]);else{var d=r[u];try{var p=ip(d["[[ResourceValue]]"],d["[[Hint]]"],d["[[DisposeMethod]]"]);if(p)throw new Zl("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(y){a(y)}}return e["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:n},Sg=function(){var e=[];return{"[[DisposableResourceStack]]":e}},ja=pu,Ou=G,rE=Za,mi=wu,iE=eo,_g=fi,sE=Iu,Ve=Tu,oE=vg,kg=fr.supportsDescriptors,aE=Pu,zu=bg,lE=wg,Eg=Sg,op=_u(),rt=function t(){if(!(this instanceof t)||Ve.has(this,"[[DisposableState]]")||Ve.has(this,"[[DisposeCapability]]"))throw new Ou("can only be used with new");Ve.set(this,"[[DisposableState]]","PENDING"),Ve.set(this,"[[DisposeCapability]]",Eg())},xg=function(){var e=this;return Ve.assert(e,"[[DisposableState]]"),Ve.get(e,"[[DisposableState]]")==="DISPOSED"},ro=aE(xg);kg?iE(rt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":xg}):rt.prototype.disposed=!1;var $g=function(e){Ve.set(e,"[[DisposableState]]","DISPOSED"),kg||(e.disposed=!0)};mi(rt.prototype,"dispose",function(){var e=this;if(!ro(e))return $g(e),lE(Ve.get(e,"[[DisposeCapability]]"),sE())["?"]()});mi(rt.prototype,"use",function(e){var n=this;if(ro(n))throw new ja("a disposed stack can not use anything new");return zu(Ve.get(n,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});mi(rt.prototype,"adopt",function(e,n){var r=this;if(ro(r))throw new ja("a disposed stack can not use anything new");if(!_g(n))throw new Ou("`onDispose` must be a function");var i=function(){return rE(n,void 0,[e])};return zu(Ve.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),e});mi(rt.prototype,"defer",function(e){var n=this;if(ro(n))throw new ja("a disposed stack can not defer anything new");if(!_g(e))throw new Ou("`onDispose` must be a function");zu(Ve.get(n,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});mi(rt.prototype,"move",function(){var e=this;if(ro(e))throw new ja("a disposed stack can not use anything new");var n=new rt;return Ve.set(n,"[[DisposeCapability]]",Ve.get(e,"[[DisposeCapability]]")),Ve.set(e,"[[DisposeCapability]]",Eg()),$g(e),n});op&&mi(rt.prototype,op,rt.prototype.dispose);oE(rt.prototype,"DisposableStack");var cE=rt,uE=cE,hE=function(){return typeof DisposableStack=="function"?DisposableStack:uE},dE=fr,pE=hu(),fE=hE,gE=function(){var e=fE();return dE(pE,{DisposableStack:e},{DisposableStack:!0}),e},mE=ot,Va=pu,Mu=G,ap=mE("%Promise%",!0),Lu=bg,vE=Za,vi=wu,yE=eo,bE=wg,Ag=fi,Tg=Sg,wE=Iu,lp=Du(),We=Tu,SE=vg,Cg=fr.supportsDescriptors,_E=Pu,kE=Sn(),EE=kE("Promise.prototype.then",!0),cp=ku(),it=function t(){if(!(this instanceof t)||We.has(this,"[[AsyncDisposableState]]")||We.has(this,"[[DisposeCapability]]"))throw new Mu("can only be used with new");We.set(this,"[[AsyncDisposableState]]","pending"),We.set(this,"[[DisposeCapability]]",Tg())},Ig=function(){var e=this;return We.assert(e,"[[AsyncDisposableState]]"),We.get(e,"[[AsyncDisposableState]]")==="disposed"},io=_E(Ig);Cg?yE(it.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":Ig}):it.prototype.disposed=!1;var Pg=function(e){We.set(e,"[[AsyncDisposableState]]","disposed"),Cg||(e.disposed=!0)};vi(it.prototype,"disposeAsync",function(){var e=this;return io(e)?lp(ap):(Pg(e),EE(lp(ap,bE(We.get(e,"[[DisposeCapability]]"),wE())),function(n){return n["?"]()}))});vi(it.prototype,"use",function(e){var n=this;if(io(n))throw new Va("a disposed stack can not use anything new");return Lu(We.get(n,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});vi(it.prototype,"adopt",function(e,n){var r=this;if(io(r))throw new Va("a disposed stack can not use anything new");if(!Ag(n))throw new Mu("`onDisposeAsync` must be a function");var i=function(){return vE(n,void 0,[e])};return i.value=e,Lu(We.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),e});vi(it.prototype,"defer",function(e){var n=this;if(io(n))throw new Va("a disposed stack can not defer anything new");if(!Ag(e))throw new Mu("`onDispose` must be a function");Lu(We.get(n,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});vi(it.prototype,"move",function(){var e=this;if(io(e))throw new Va("a disposed stack can not use anything new");var n=new it;return We.set(n,"[[DisposeCapability]]",We.get(e,"[[DisposeCapability]]")),We.set(e,"[[DisposeCapability]]",Tg()),Pg(e),n});cp&&vi(it.prototype,cp,it.prototype.disposeAsync);SE(it.prototype,"AsyncDisposableStack");var xE=it,$E=xE,AE=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:$E},TE=fr,CE=hu(),IE=AE,PE=function(){var e=IE();return TE(CE,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},RE=TS,DE=MS,OE=gE,zE=PE,ME=function(){RE(),DE(),OE(),zE()};ME();const up=new WeakMap;function LE(t){return(typeof t=="object"||typeof t=="function")&&t!==null&&"then"in t&&typeof t.then=="function"}function Ar(t){return typeof t=="string"?t:typeof t=="symbol"?t.description??t.toString():t.name||"(anonymous class)"}function hp(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function NE(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class UE{constructor(){b(this,"entries",new Map);b(this,"constructionStack",[])}register(e,n){if(n===void 0){if(typeof e!="function")throw hp();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof n!="function")throw hp();if(n.constructor.name==="AsyncFunction")throw NE();this.storeFactory(e,n)}has(e){var n;return((n=this.entries.get(e))==null?void 0:n.factory)!==void 0}resolve(e){return this.resolveAny(e)}storeFactory(e,n){const r=this.getOrCreateEntry(e);r.factory=n,r.instance=void 0,r.error=void 0}validateClassRegistration(e){const n=up.get(e);if(n){if(e.length!==n.length)throw new Error(`${Ar(e)} cannot be registered with register(Class). @injectable(...) declared ${n.length} dependencies but constructor arity is ${e.length}. Use register(Key, () => value) instead.`);return}if(e.length!==0)throw new Error(`${Ar(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const n=up.get(e);if(!n)return new e;const r=n.map(i=>this.resolveAny(i));return new e(...r)}resolveAny(e){return this.getOrCreateEntry(e).proxy}getOrCreateEntry(e){let n=this.entries.get(e);return n||(n={key:e},n.proxy=this.createProxy(n),this.entries.set(e,n),n)}createProxy(e){return new Proxy({},{get:(n,r)=>{if(r==="then")return;const i=this.getInstance(e),s=Reflect.get(i,r,i);return typeof s=="function"?s.bind(i):s},set:(n,r,i)=>{const s=this.getInstance(e);return Reflect.set(s,r,i,s)},has:(n,r)=>{const i=this.getInstance(e);return r in i}})}getInstance(e){if(e.instance)return e.instance;if(e.error)throw e.error;if(!e.factory)throw new Error(`${Ar(e.key)} was resolved but never registered`);const n=this.constructionStack.indexOf(e.key);if(n!==-1){const r=[...this.constructionStack.slice(n),e.key].map(i=>Ar(i)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(e.key);try{const r=e.factory();if(LE(r))throw new Error(`Factory for ${Ar(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${Ar(e.key)} returned a non-object value. Wrap primitives in an object.`);return e.instance=r,r}catch(r){throw e.error=r,r}finally{this.constructionStack.pop()}}}const Ge=new UE,FE=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function ZE(t){for(const e of Object.keys(t))if(FE.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function HE(t,e){ZE(e);for(const n of Object.keys(e))Object.defineProperty(t,n,{value:e[n],writable:!0,enumerable:!0,configurable:!0})}function gt(){class t extends Event{constructor(n,r){const{type:i,bubbles:s,cancelable:o,composed:a,...l}=r??{};if(i!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(n,{bubbles:s,cancelable:o,composed:a}),HE(this,l)}}return t}class mt extends globalThis.EventTarget{}function BE(t,e,n){const r=t.dispose.bind(t);t.dispose=()=>{if(!e())return n(),r()}}function yi(t){var n;class e extends t{constructor(...s){super(...s);w(this,n,!1);BE(this,()=>c(this,n),()=>{k(this,n,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return c(this,n)}}return n=new WeakMap,e}const jE=gt(),VE=gt(),Wo=gt(),Rg="0123456789ABCDEFGHJKMNPQRSTVWXYZ",aa=32,WE=16,Dg=10,dp=0xffffffffffff;var Ln;(function(t){t.Base32IncorrectEncoding="B32_ENC_INVALID",t.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",t.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",t.EncodeTimeNegative="ENC_TIME_NEG",t.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",t.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",t.PRNGDetectFailure="PRNG_DETECT",t.ULIDInvalid="ULID_INVALID",t.Unexpected="UNEXPECTED",t.UUIDInvalid="UUID_INVALID"})(Ln||(Ln={}));class Fi extends Error{constructor(e,n){super(`${n} (${e})`),this.name="ULIDError",this.code=e}}function GE(t){const e=Math.floor(t()*aa)%aa;return Rg.charAt(e)}function qE(t){const e=YE(),n=e&&(e.crypto||e.msCrypto)||null;if(typeof(n==null?void 0:n.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return n.getRandomValues(r),r[0]/256};if(typeof(n==null?void 0:n.randomBytes)=="function")return()=>n.randomBytes(1).readUInt8()/256;throw new Fi(Ln.PRNGDetectFailure,"Failed to find a reliable PRNG")}function YE(){return XE()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function KE(t,e){let n="";for(;t>0;t--)n=GE(e)+n;return n}function JE(t,e=Dg){if(isNaN(t))throw new Fi(Ln.EncodeTimeValueMalformed,`Time must be a number: ${t}`);if(t>dp)throw new Fi(Ln.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${dp}: ${t}`);if(t<0)throw new Fi(Ln.EncodeTimeNegative,`Time must be positive: ${t}`);if(Number.isInteger(t)===!1)throw new Fi(Ln.EncodeTimeValueMalformed,`Time must be an integer: ${t}`);let n,r="";for(let i=e;i>0;i--)n=t%aa,r=Rg.charAt(n)+r,t=(t-n)/aa;return r}function XE(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Nu(t,e){const n=qE(),r=Date.now();return JE(r,Dg)+KE(WE,n)}const It=4,Qe=6,Og=2,bc=2,QE=It,ex=Qe,Uu="auto",fn="auto",Dn=120,pp=75,ge=16,lr=Dn*It+ge*(It-1),la=Dn*Qe+ge*(Qe-1),tx=200,nx=4,xo=150,rx=10,fp=2,ix=4;function zg(t){return Ng(t)}function Mg(t,e){return Ng(t.flatMap(n=>Fg(n,e)))}function Lg(t){const e=[],n=new Set;for(const r of t){if(r.type==="row"){e.push(`Top-level rows are invalid: ${r.id}`);continue}Zg(r,"strip",e,n)}return{valid:e.length===0,errors:e}}function Qi(t){const e=zg(t),n=Lg(e);if(!n.valid)throw new Error(`Invalid layout: ${n.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(lx)}}function Ng(t){const e=[];for(const n of t){const r=Ug(n);for(const i of r){if(i.type==="row"){e.push(...i.children.map(Gt));continue}e.push(i)}}return e}function Ug(t){switch(t.type){case"card":return[Gt(t)];case"row":{const e=t.children.map(Gt);return e.length===0?[]:e.length===1?[e[0]]:[{...t,children:e}]}case"stack":{const e=[];for(const n of t.children){const r=Ug(n);for(const i of r){if(i.type==="stack"){e.push(...i.children.map(wc));continue}if(i.type==="row"){e.push({...i,children:i.children.map(Gt)});continue}e.push(Gt(i))}}return e.length===0?[]:e.length===1?[wc(e[0])]:[{...t,children:e}]}}}function Fg(t,e){switch(t.type){case"card":return t.artifactID===e?[]:[Gt(t)];case"row":{const n=t.children.filter(r=>r.artifactID!==e).map(Gt);return n.length===0?[]:n.length===1?[n[0]]:[{...t,children:n}]}case"stack":{const n=t.children.flatMap(r=>Fg(r,e).filter(s=>s.type!=="stack"));return n.length===0?[]:n.length===1?[wc(n[0])]:[{...t,children:n}]}}}function Zg(t,e,n,r){switch(t.type){case"card":Hg(t,e,n,r);return;case"row":sx(t,e,n,r);return;case"stack":ox(t,e,n,r);return}}function Hg(t,e,n,r){Fu(t.id,n),typeof t.artifactID!="string"||t.artifactID.length===0?n.push(`Card ${t.id} is missing artifactID`):r.has(t.artifactID)?n.push(`Duplicate artifactID in layout: ${t.artifactID}`):r.add(t.artifactID),ax(t.width)||n.push(`Card ${t.id} width must be an integer in the range 2-4`),Bg(t.height)||n.push(`Card ${t.id} height must be an integer in the range 2-6 or "auto"`);const i=On(t.width);e==="row"&&i<Og&&n.push(`Row child ${t.id} must be at least 2 columns wide`)}function sx(t,e,n,r){if(Fu(t.id,n),e!=="stack"&&n.push(`Row ${t.id} may only appear inside a stack`),Bg(t.height,ix)||n.push(`Row ${t.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(t.children)||t.children.length===0){n.push(`Row ${t.id} must contain card nodes`);return}let i=0;for(const s of t.children){if(s.type!=="card"){n.push(`Row ${t.id} must contain only card nodes`);continue}Hg(s,"row",n,r),i+=On(s.width)}i!==It&&n.push(`Row ${t.id} children must sum to 4 columns`)}function ox(t,e,n,r){if(Fu(t.id,n),e!=="strip"&&n.push(`Invalid nested stack at ${t.id}; stack children cannot contain another nested stack`),!Array.isArray(t.children)||t.children.length===0){n.push(`Stack ${t.id} must contain at least one child`);return}let i=0,s=0;for(const a of t.children){if(a.type==="stack"){n.push(`Stack ${t.id} cannot contain another nested stack`);continue}if(Zg(a,"stack",n,r),a.height===fn){s+=1;continue}i+=a.height}if(i>Qe&&n.push(`Stack ${t.id} exceeds the 6-row budget`),s===0)return;const o=Qe-i;if(o<s*bc||o%s!==0){n.push(`Stack ${t.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<bc&&n.push(`Stack ${t.id} has auto-height children below the minimum row size`)}function Fu(t,e){(typeof t!="string"||t.length===0)&&e.push(`Node id must be a non-empty string: ${String(t)}`)}function ax(t){return t===Uu||Number.isInteger(t)&&t>=Og&&t<=QE}function Bg(t,e=ex){return t===fn||Number.isInteger(t)&&t>=bc&&t<=e}function On(t){return t===Uu?It:t}function lx(t){if(t.type==="card")return{id:t.id,type:"card",width:On(t.width),cards:[{id:t.id,artifactID:t.artifactID,col:1,row:1,width:On(t.width),height:jg(t.height,Qe)}]};const e=cx(t.children),n=[];let r=1;for(let i=0;i<t.children.length;i+=1){const s=t.children[i],o=e[i];if(s.type==="card")n.push({id:s.id,artifactID:s.artifactID,col:1,row:r,width:On(s.width),height:o});else{let a=1;for(const l of s.children)n.push({id:l.id,artifactID:l.artifactID,col:a,row:r,width:On(l.width),height:o}),a+=On(l.width)}r+=o}return{id:t.id,type:"stack",width:n.reduce((i,s)=>Math.max(i,s.col+s.width-1),1),cards:n}}function cx(t){let e=0,n=0;for(const i of t)i.height===fn?n+=1:e+=i.height;const r=n>0?(Qe-e)/n:0;return t.map(i=>jg(i.height,r))}function jg(t,e){return t===fn?e:t}function Gt(t){return{...t}}function wc(t){return t.type==="card"?Gt(t):{...t,children:t.children.map(Gt)}}function Vg(t,e={}){return{id:e.id??Nu(),type:"card",artifactID:t,width:e.width??Uu,height:e.height??fn}}function Wg(t,e){return t.some(n=>Gg(n,e))}function Gg(t,e){switch(t.type){case"card":return t.artifactID===e;case"row":return t.children.some(n=>n.artifactID===e);case"stack":return t.children.some(n=>Gg(n,e))}}function gp(t){return t.layout.flatMap(qg)}function qg(t){switch(t.type){case"card":return[t.artifactID];case"row":return t.children.map(e=>e.artifactID);case"stack":return t.children.flatMap(qg)}}const ee=gt(),Yg=gt(),Ii=gt(),ux=gt();function hx(t){class e extends Error{constructor(r,i){super(r),this.name=t,i&&Object.assign(this,i)}}return e}const dx=hx("RequestError"),px=200,fx=300;class gx{constructor(e,n){b(this,"serverURL");b(this,"token");this.serverURL=e.replace(/\/$/,""),this.token=n.token}async requestJSON(e,n,r){const i=await this.request(e,n,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),s=await mx(i);if(!i.ok||i.status<px||i.status>=fx)throw this.createError(typeof s.error=="string"?s.error:i.statusText,i.status);return s}async requestVoid(e,n){const r=await this.request(e,n);if(!r.ok)throw this.createError(await Hl(r,r.statusText),r.status)}async requestText(e,n){const r=await this.request(e,n);if(!r.ok)throw this.createError(await Hl(r,r.statusText),r.status);return r.text()}async requestRawVoid(e,n,r){const i=await this.request(e,n,r,{"content-type":"text/plain"});if(!i.ok)throw this.createError(await Hl(i,i.statusText),i.status)}createError(e,n){const r={serverURL:this.serverURL};return n!==void 0&&(r.status=n),new dx(e,r)}async request(e,n,r,i){const s=`${this.serverURL}${n}`;try{return await fetch(s,{method:e,headers:this.buildHeaders(i),body:r})}catch(o){throw this.createError(o instanceof Error?o.message:"Failed to reach server")}}buildHeaders(e){const n={...e??{}};return this.token&&(n.Authorization=`Bearer ${this.token}`),Object.keys(n).length>0?n:void 0}}async function mx(t){try{return await t.json()}catch{const e=await t.text().catch(()=>"");return e?{message:e}:{}}}async function Hl(t,e){try{const n=await t.json();if(typeof n.error=="string")return n.error;if(typeof n.message=="string")return n.message}catch{}return e}function Kg(t){return t.map(e=>`${e.name} (${e.id})`).join(", ")}var xt,wa,Jg;class vx{constructor(e){w(this,wa);w(this,xt);k(this,xt,e)}list(){return c(this,xt).requestJSON("GET","/screens")}async get(e={}){const n=await g(this,wa,Jg).call(this,e.screenID);return c(this,xt).requestJSON("GET",`/screens/${encodeURIComponent(n)}`)}create(e){const n={name:e.name};return e.id!==void 0&&(n.id=e.id),c(this,xt).requestJSON("POST","/screens",n)}update(e){const n={};return e.name!==void 0&&(n.name=e.name),e.layout!==void 0&&(n.layout=e.layout),c(this,xt).requestJSON("PATCH",`/screens/${encodeURIComponent(e.screenID)}`,n)}remove(e){return c(this,xt).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}xt=new WeakMap,wa=new WeakSet,Jg=async function(e){if(e!==void 0)return e;const{screens:n}=await this.list();if(n.length===1)return n[0].id;throw c(this,xt).createError(`screenID is required when multiple screens exist. Available screens: ${Kg(n)}`)};var He,ls,Sa,Xg;class yx{constructor(e,n){w(this,Sa);w(this,He);w(this,ls);k(this,He,e),k(this,ls,n)}async create(e){const n=await g(this,Sa,Xg).call(this,e.screenID);return c(this,He).requestJSON("POST",`/screens/${encodeURIComponent(n)}/artifact`,{type:e.type,title:e.title,externalFilePath:e.externalFilePath})}get(e){return c(this,He).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const n={};return e.title!==void 0&&(n.title=e.title),c(this,He).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,n)}edit(e){return c(this,He).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return c(this,He).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return c(this,He).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}remove(e){return c(this,He).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return c(this,He).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return c(this,He).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}He=new WeakMap,ls=new WeakMap,Sa=new WeakSet,Xg=async function(e){if(e!==void 0)return e;const{screens:n}=await c(this,ls).list();if(n.length===1)return n[0].id;throw c(this,He).createError(`screenID is required when multiple screens exist. Available screens: ${Kg(n)}`)};var cs;class bx{constructor(e){w(this,cs);k(this,cs,e)}async list(){const{views:e}=await c(this,cs).requestJSON("GET","/views");return e}}cs=new WeakMap;var nn;class wx{constructor(e,n={}){b(this,"screens");b(this,"artifacts");b(this,"views");w(this,nn);k(this,nn,new gx(e,n)),this.screens=new vx(c(this,nn)),this.artifacts=new yx(c(this,nn),this.screens),this.views=new bx(c(this,nn))}health(){return c(this,nn).requestJSON("GET","/health")}}nn=new WeakMap;const Sx={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},_x=yi(mt);var Fn,Be,Zn,Me,rn,sn,X,Cr,Qg,us,em,tm,nm,rm,Sc,_c,kc,im;class kx extends _x{constructor(n){var i;super();w(this,X);b(this,"id");b(this,"server");w(this,Fn);w(this,Be,new Map);w(this,Zn);w(this,Me);w(this,rn);w(this,sn,null);w(this,us,n=>{if(this.disposed)return;const r=n.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&g(this,X,em).call(this,r.screen);break;case"artifact-created":r.screenID===this.id&&g(this,X,tm).call(this,r.artifact);break;case"artifact-updated":g(this,X,nm).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&g(this,X,rm).call(this,r.artifactID);break;case"artifact-content-changed":c(this,Be).has(r.artifactID)&&this.dispatchEvent(new ux("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=n.screen.id,this.server=n.server,k(this,Fn,n.localStore),k(this,Zn,n.screen.name),k(this,Me,structuredClone(n.screen.layout));const r=((i=c(this,Fn).get().screens[this.id])==null?void 0:i.scrollPosition)??0;k(this,rn,Math.max(0,r)),this.server.addEventListener("server-event",c(this,us)),g(this,X,Qg).call(this)}get name(){return c(this,Zn)}get layout(){return c(this,Me)}get scrollPosition(){return c(this,rn)}get artifacts(){return c(this,Be)}setScrollPosition(n){g(this,X,Cr).call(this);const r=Math.max(0,n);r!==c(this,rn)&&(k(this,rn,r),g(this,X,im).call(this),this.dispatchEvent(new ee("change")))}setLayout(n){g(this,X,Cr).call(this);const r=zg(n);if(!Lg(r).valid)return;const s=g(this,X,_c).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=c(this,sn))==null?void 0:o.layout)===r&&(k(this,sn,null),g(this,X,kc).call(this,s),this.dispatchEvent(new ee("change")))})}rename(n){g(this,X,Cr).call(this),k(this,Zn,n),this.dispatchEvent(new ee("change")),this.server.client.screens.update({screenID:this.id,name:n}).catch(()=>{})}async remove(){g(this,X,Cr).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(n){if(g(this,X,Cr).call(this),!c(this,Be).has(n))return;const r=g(this,X,_c).call(this);g(this,X,Sc).call(this,n),this.dispatchEvent(new ee("change")),this.server.client.artifacts.remove({artifactID:n,screenID:this.id}).catch(()=>{this.disposed||(g(this,X,kc).call(this,r),this.dispatchEvent(new ee("change")))})}dispose(){this.server.removeEventListener("server-event",c(this,us))}}Fn=new WeakMap,Be=new WeakMap,Zn=new WeakMap,Me=new WeakMap,rn=new WeakMap,sn=new WeakMap,X=new WeakSet,Cr=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Qg=async function(){try{const n=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of n.artifacts)c(this,Be).set(r.id,r);this.dispatchEvent(new ee("change"))}catch{}},us=new WeakMap,em=function(n){c(this,sn)&&k(this,sn,null),k(this,Zn,n.name),k(this,Me,structuredClone(n.layout)),this.dispatchEvent(new ee("change"))},tm=function(n){Wg(c(this,Me),n.id)||k(this,Me,[...c(this,Me),Vg(n.id)]),c(this,Be).set(n.id,n),this.dispatchEvent(new ee("change"))},nm=function(n){const r=c(this,Be).get(n.id);r&&(c(this,Be).set(n.id,{...r,...n}),this.dispatchEvent(new ee("change")))},rm=function(n){g(this,X,Sc).call(this,n)&&this.dispatchEvent(new ee("change"))},Sc=function(n){const r=c(this,Be).delete(n),i=gp({layout:c(this,Me)}).length,s=Mg(c(this,Me),n),o=gp({layout:s}).length;return k(this,Me,s),r||i!==o},_c=function(){return{layout:structuredClone(c(this,Me)),artifacts:new Map([...c(this,Be).entries()].map(([n,r])=>[n,structuredClone(r)]))}},kc=function(n){k(this,Me,structuredClone(n.layout)),c(this,Be).clear();for(const[r,i]of n.artifacts)c(this,Be).set(r,structuredClone(i))},im=function(){const n=c(this,Fn).get();c(this,Fn).set({...n,screens:{...n.screens,[this.id]:{scrollPosition:c(this,rn)}}})};const Ex=yi(mt);var et,Nt,lt,hs,ds,ps,Fr,Go;class xx extends Ex{constructor(n){super();w(this,Fr);w(this,et);w(this,Nt);w(this,lt,null);w(this,hs,()=>{this.disposed||g(this,Fr,Go).call(this)});w(this,ds,()=>{this.disposed||g(this,Fr,Go).call(this)});w(this,ps,n=>{var i;if(this.disposed)return;const r=n.event;r.type==="screen-removed"&&((i=c(this,lt))==null?void 0:i.id)===r.screenID&&this.clearActive()});k(this,et,n.localStore),k(this,Nt,n.serverManager),c(this,et).addEventListener("change",c(this,hs)),c(this,Nt).addEventListener("change",c(this,ds)),c(this,Nt).addEventListener("server-event",c(this,ps)),g(this,Fr,Go).call(this)}get activeScreen(){return c(this,lt)}setActive(n,r){const i=c(this,et).get();i.activeServerURL===n&&i.activeScreenID===r||c(this,et).set({...i,activeServerURL:n,activeScreenID:r})}clearActive(){const n=c(this,et).get();n.activeScreenID!==null&&c(this,et).set({...n,activeScreenID:null})}dispose(){var n;c(this,et).removeEventListener("change",c(this,hs)),c(this,Nt).removeEventListener("change",c(this,ds)),c(this,Nt).removeEventListener("server-event",c(this,ps)),(n=c(this,lt))==null||n.dispose(),k(this,lt,null)}}et=new WeakMap,Nt=new WeakMap,lt=new WeakMap,hs=new WeakMap,ds=new WeakMap,ps=new WeakMap,Fr=new WeakSet,Go=function(){var l,u,d;const{activeServerURL:n,activeScreenID:r}=c(this,et).get(),i=n?c(this,Nt).servers.get(n)??null:null,s=i&&r?i.screens.get(r)??null:null,o=((l=c(this,lt))==null?void 0:l.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=c(this,lt))==null?void 0:u.server)===i||((d=c(this,lt))==null||d.dispose(),k(this,lt,i&&s?new kx({screen:s,server:i,localStore:c(this,et)}):null),this.dispatchEvent(new jE("active-screen-changed")))};const $x="Local",Ax="store-";function Et(t){return new URL(t).origin}function Tx(t){return{servers:[{url:Et(t),name:$x}],activeServerURL:null,activeScreenID:null,screens:{}}}var Hn,Bn,jn;class Cx extends mt{constructor(n,r,i={}){super();w(this,Hn);w(this,Bn);w(this,jn);k(this,Hn,`${Ax}${n}`),k(this,Bn,i.storage??Ix());const s=c(this,Bn).getItem(c(this,Hn));s===null?(k(this,jn,r),c(this,Bn).setItem(c(this,Hn),JSON.stringify(r))):k(this,jn,JSON.parse(s))}get(){return c(this,jn)}set(n){k(this,jn,n),c(this,Bn).setItem(c(this,Hn),JSON.stringify(n)),this.dispatchEvent(new ee("change"))}}Hn=new WeakMap,Bn=new WeakMap,jn=new WeakMap;function Ix(){const t=globalThis.localStorage;if(!t)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return t}function x(t,e,n){function r(a,l){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:l,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,l);const u=o.prototype,d=Object.keys(u);for(let p=0;p<d.length;p++){const y=d[p];y in a||(a[y]=u[y].bind(a))}}const i=(n==null?void 0:n.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:t});function o(a){var l;const u=n!=null&&n.Parent?new s:this;r(u,a),(l=u._zod).deferred??(l.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 l,u;return n!=null&&n.Parent&&a instanceof n.Parent?!0:(u=(l=a==null?void 0:a._zod)==null?void 0:l.traits)==null?void 0:u.has(t)}}),Object.defineProperty(o,"name",{value:t}),o}class Ur extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class sm extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const om={};function gn(t){return om}function am(t){const e=Object.values(t).filter(r=>typeof r=="number");return Object.entries(t).filter(([r,i])=>e.indexOf(+r)===-1).map(([r,i])=>i)}function Ec(t,e){return typeof e=="bigint"?e.toString():e}function Zu(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function Hu(t){return t==null}function Bu(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function Px(t,e){const n=(t.toString().split(".")[1]||"").length,r=e.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const l=r.match(/\d?e-(\d?)/);l!=null&&l[1]&&(i=Number.parseInt(l[1]))}const s=n>i?n:i,o=Number.parseInt(t.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return o%a/10**s}const mp=Symbol("evaluating");function Q(t,e,n){let r;Object.defineProperty(t,e,{get(){if(r!==mp)return r===void 0&&(r=mp,r=n()),r},set(i){Object.defineProperty(t,e,{value:i})},configurable:!0})}function mr(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function kn(...t){const e={};for(const n of t){const r=Object.getOwnPropertyDescriptors(n);Object.assign(e,r)}return Object.defineProperties({},e)}function vp(t){return JSON.stringify(t)}function Rx(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const lm="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function ca(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const Dx=Zu(()=>{var t;if(typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)!=null&&t.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function oi(t){if(ca(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const n=e.prototype;return!(ca(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function cm(t){return oi(t)?{...t}:Array.isArray(t)?[...t]:t}const Ox=new Set(["string","number","symbol"]);function ai(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function En(t,e,n){const r=new t._zod.constr(e??t._zod.def);return(!e||n!=null&&n.parent)&&(r._zod.parent=t),r}function z(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function zx(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const Mx={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 Lx(t,e){const n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=kn(t._zod.def,{get shape(){const o={};for(const a in e){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(o[a]=n.shape[a])}return mr(this,"shape",o),o},checks:[]});return En(t,s)}function Nx(t,e){const n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=kn(t._zod.def,{get shape(){const o={...t._zod.def.shape};for(const a in e){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete o[a]}return mr(this,"shape",o),o},checks:[]});return En(t,s)}function Ux(t,e){if(!oi(e))throw new Error("Invalid input to extend: expected a plain object");const n=t._zod.def.checks;if(n&&n.length>0){const s=t._zod.def.shape;for(const o in e)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=kn(t._zod.def,{get shape(){const s={...t._zod.def.shape,...e};return mr(this,"shape",s),s}});return En(t,i)}function Fx(t,e){if(!oi(e))throw new Error("Invalid input to safeExtend: expected a plain object");const n=kn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e};return mr(this,"shape",r),r}});return En(t,n)}function Zx(t,e){const n=kn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return mr(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return En(t,n)}function Hx(t,e,n){const i=e._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=kn(e._zod.def,{get shape(){const a=e._zod.def.shape,l={...a};if(n)for(const u in n){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(l[u]=t?new t({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)l[u]=t?new t({type:"optional",innerType:a[u]}):a[u];return mr(this,"shape",l),l},checks:[]});return En(e,o)}function Bx(t,e,n){const r=kn(e._zod.def,{get shape(){const i=e._zod.def.shape,s={...i};if(n)for(const o in n){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(s[o]=new t({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new t({type:"nonoptional",innerType:i[o]});return mr(this,"shape",s),s}});return En(e,r)}function Mr(t,e=0){var n;if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(((n=t.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function Lr(t,e){return e.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(t),n})}function $o(t){return typeof t=="string"?t:t==null?void 0:t.message}function mn(t,e,n){var i,s,o,a,l,u;const r={...t,path:t.path??[]};if(!t.message){const d=$o((o=(s=(i=t.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,t))??$o((a=e==null?void 0:e.error)==null?void 0:a.call(e,t))??$o((l=n.customError)==null?void 0:l.call(n,t))??$o((u=n.localeError)==null?void 0:u.call(n,t))??"Invalid input";r.message=d}return delete r.inst,delete r.continue,e!=null&&e.reportInput||delete r.input,r}function ju(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function rs(...t){const[e,n,r]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:r}:{...e}}const um=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,Ec,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},hm=x("$ZodError",um),dm=x("$ZodError",um,{Parent:Error});function jx(t,e=n=>n.message){const n={},r=[];for(const i of t.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(e(i))):r.push(e(i));return{formErrors:r,fieldErrors:n}}function Vx(t,e=n=>n.message){const n={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>r({issues:o}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(e(s));else{let o=n,a=0;for(;a<s.path.length;){const l=s.path[a];a===s.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(e(s))):o[l]=o[l]||{_errors:[]},o=o[l],a++}}};return r(t),n}const Vu=t=>(e,n,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},o=e._zod.run({value:n,issues:[]},s);if(o instanceof Promise)throw new Ur;if(o.issues.length){const a=new((i==null?void 0:i.Err)??t)(o.issues.map(l=>mn(l,s,gn())));throw lm(a,i==null?void 0:i.callee),a}return o.value},Wu=t=>async(e,n,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=e._zod.run({value:n,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??t)(o.issues.map(l=>mn(l,s,gn())));throw lm(a,i==null?void 0:i.callee),a}return o.value},Wa=t=>(e,n,r)=>{const i=r?{...r,async:!1}:{async:!1},s=e._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new Ur;return s.issues.length?{success:!1,error:new(t??hm)(s.issues.map(o=>mn(o,i,gn())))}:{success:!0,data:s.value}},Wx=Wa(dm),Ga=t=>async(e,n,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=e._zod.run({value:n,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(o=>mn(o,i,gn())))}:{success:!0,data:s.value}},Gx=Ga(dm),qx=t=>(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Vu(t)(e,n,i)},Yx=t=>(e,n,r)=>Vu(t)(e,n,r),Kx=t=>async(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Wu(t)(e,n,i)},Jx=t=>async(e,n,r)=>Wu(t)(e,n,r),Xx=t=>(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Wa(t)(e,n,i)},Qx=t=>(e,n,r)=>Wa(t)(e,n,r),e$=t=>async(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ga(t)(e,n,i)},t$=t=>async(e,n,r)=>Ga(t)(e,n,r),n$=/^[cC][^\s-]{8,}$/,r$=/^[0-9a-z]+$/,i$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,s$=/^[0-9a-vA-V]{20}$/,o$=/^[A-Za-z0-9]{27}$/,a$=/^[a-zA-Z0-9_-]{21}$/,l$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,c$=/^([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})$/,yp=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,u$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,h$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function d$(){return new RegExp(h$,"u")}const p$=/^(?:(?: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])$/,f$=/^(([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}|:))$/,g$=/^((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])$/,m$=/^(([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])$/,v$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,pm=/^[A-Za-z0-9_-]*$/,y$=/^\+[1-9]\d{6,14}$/,fm="(?:(?:\\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])))",b$=new RegExp(`^${fm}$`);function gm(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function w$(t){return new RegExp(`^${gm(t)}$`)}function S$(t){const e=gm({precision:t.precision}),n=["Z"];t.local&&n.push(""),t.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${e}(?:${n.join("|")})`;return new RegExp(`^${fm}T(?:${r})$`)}const _$=t=>{const e=t?`[\\s\\S]{${(t==null?void 0:t.minimum)??0},${(t==null?void 0:t.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},k$=/^-?\d+$/,mm=/^-?\d+(?:\.\d+)?$/,E$=/^(?:true|false)$/i,x$=/^[^A-Z]*$/,$$=/^[^a-z]*$/,qe=x("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),vm={number:"number",bigint:"bigint",object:"date"},ym=x("$ZodCheckLessThan",(t,e)=>{qe.init(t,e);const n=vm[typeof e.value];t._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?i.maximum=e.value:i.exclusiveMaximum=e.value)}),t._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),bm=x("$ZodCheckGreaterThan",(t,e)=>{qe.init(t,e);const n=vm[typeof e.value];t._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?i.minimum=e.value:i.exclusiveMinimum=e.value)}),t._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),A$=x("$ZodCheckMultipleOf",(t,e)=>{qe.init(t,e),t._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=e.value)}),t._zod.check=n=>{if(typeof n.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%e.value===BigInt(0):Px(n.value,e.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:e.value,input:n.value,inst:t,continue:!e.abort})}}),T$=x("$ZodCheckNumberFormat",(t,e)=>{var o;qe.init(t,e),e.format=e.format||"float64";const n=(o=e.format)==null?void 0:o.includes("int"),r=n?"int":"number",[i,s]=Mx[e.format];t._zod.onattach.push(a=>{const l=a._zod.bag;l.format=e.format,l.minimum=i,l.maximum=s,n&&(l.pattern=k$)}),t._zod.check=a=>{const l=a.value;if(n){if(!Number.isInteger(l)){a.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:l,inst:t});return}if(!Number.isSafeInteger(l)){l>0?a.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,inclusive:!0,continue:!e.abort}):a.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,inclusive:!0,continue:!e.abort});return}}l<i&&a.issues.push({origin:"number",input:l,code:"too_small",minimum:i,inclusive:!0,inst:t,continue:!e.abort}),l>s&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:s,inclusive:!0,inst:t,continue:!e.abort})}}),C$=x("$ZodCheckMaxLength",(t,e)=>{var n;qe.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!Hu(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<i&&(r._zod.bag.maximum=e.maximum)}),t._zod.check=r=>{const i=r.value;if(i.length<=e.maximum)return;const o=ju(i);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:t,continue:!e.abort})}}),I$=x("$ZodCheckMinLength",(t,e)=>{var n;qe.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!Hu(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(r._zod.bag.minimum=e.minimum)}),t._zod.check=r=>{const i=r.value;if(i.length>=e.minimum)return;const o=ju(i);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:t,continue:!e.abort})}}),P$=x("$ZodCheckLengthEquals",(t,e)=>{var n;qe.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!Hu(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=e.length,i.maximum=e.length,i.length=e.length}),t._zod.check=r=>{const i=r.value,s=i.length;if(s===e.length)return;const o=ju(i),a=s>e.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:r.value,inst:t,continue:!e.abort})}}),qa=x("$ZodCheckStringFormat",(t,e)=>{var n,r;qe.init(t,e),t._zod.onattach.push(i=>{const s=i._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(n=t._zod).check??(n.check=i=>{e.pattern.lastIndex=0,!e.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:e.format,input:i.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(r=t._zod).check??(r.check=()=>{})}),R$=x("$ZodCheckRegex",(t,e)=>{qa.init(t,e),t._zod.check=n=>{e.pattern.lastIndex=0,!e.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),D$=x("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=x$),qa.init(t,e)}),O$=x("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=$$),qa.init(t,e)}),z$=x("$ZodCheckIncludes",(t,e)=>{qe.init(t,e);const n=ai(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position}}${n}`:n);e.pattern=r,t._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=i=>{i.value.includes(e.includes,e.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:i.value,inst:t,continue:!e.abort})}}),M$=x("$ZodCheckStartsWith",(t,e)=>{qe.init(t,e);const n=new RegExp(`^${ai(e.prefix)}.*`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),t._zod.check=r=>{r.value.startsWith(e.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:r.value,inst:t,continue:!e.abort})}}),L$=x("$ZodCheckEndsWith",(t,e)=>{qe.init(t,e);const n=new RegExp(`.*${ai(e.suffix)}$`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),t._zod.check=r=>{r.value.endsWith(e.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:r.value,inst:t,continue:!e.abort})}}),N$=x("$ZodCheckOverwrite",(t,e)=>{qe.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}});class U${constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const r=e.split(`
|
|
5
|
+
`).filter(o=>o),i=Math.min(...r.map(o=>o.length-o.trimStart().length)),s=r.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const e=Function,n=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new e(...n,i.join(`
|
|
6
|
+
`))}}const F$={major:4,minor:3,patch:6},de=x("$ZodType",(t,e)=>{var i;var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=F$;const r=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&r.unshift(t);for(const s of r)for(const o of s._zod.onattach)o(t);if(r.length===0)(n=t._zod).deferred??(n.deferred=[]),(i=t._zod.deferred)==null||i.push(()=>{t._zod.run=t._zod.parse});else{const s=(a,l,u)=>{let d=Mr(a),p;for(const y of l){if(y._zod.def.when){if(!y._zod.def.when(a))continue}else if(d)continue;const v=a.issues.length,A=y._zod.check(a);if(A instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Ur;if(p||A instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await A,a.issues.length!==v&&(d||(d=Mr(a,v)))});else{if(a.issues.length===v)continue;d||(d=Mr(a,v))}}return p?p.then(()=>a):a},o=(a,l,u)=>{if(Mr(a))return a.aborted=!0,a;const d=s(l,r,u);if(d instanceof Promise){if(u.async===!1)throw new Ur;return d.then(p=>t._zod.parse(p,u))}return t._zod.parse(d,u)};t._zod.run=(a,l)=>{if(l.skipChecks)return t._zod.parse(a,l);if(l.direction==="backward"){const d=t._zod.parse({value:a.value,issues:[]},{...l,skipChecks:!0});return d instanceof Promise?d.then(p=>o(p,a,l)):o(d,a,l)}const u=t._zod.parse(a,l);if(u instanceof Promise){if(l.async===!1)throw new Ur;return u.then(d=>s(d,r,l))}return s(u,r,l)}}Q(t,"~standard",()=>({validate:s=>{var o;try{const a=Wx(t,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return Gx(t,s).then(l=>{var u;return l.success?{value:l.data}:{issues:(u=l.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),Gu=x("$ZodString",(t,e)=>{var n;de.init(t,e),t._zod.pattern=[...((n=t==null?void 0:t._zod.bag)==null?void 0:n.patterns)??[]].pop()??_$(t._zod.bag),t._zod.parse=(r,i)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),le=x("$ZodStringFormat",(t,e)=>{qa.init(t,e),Gu.init(t,e)}),Z$=x("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=c$),le.init(t,e)}),H$=x("$ZodUUID",(t,e)=>{if(e.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(r===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=yp(r))}else e.pattern??(e.pattern=yp());le.init(t,e)}),B$=x("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=u$),le.init(t,e)}),j$=x("$ZodURL",(t,e)=>{le.init(t,e),t._zod.check=n=>{try{const r=n.value.trim(),i=new URL(r);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:n.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:n.value,inst:t,continue:!e.abort})),e.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:t,continue:!e.abort})}}}),V$=x("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=d$()),le.init(t,e)}),W$=x("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=a$),le.init(t,e)}),G$=x("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=n$),le.init(t,e)}),q$=x("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=r$),le.init(t,e)}),Y$=x("$ZodULID",(t,e)=>{e.pattern??(e.pattern=i$),le.init(t,e)}),K$=x("$ZodXID",(t,e)=>{e.pattern??(e.pattern=s$),le.init(t,e)}),J$=x("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=o$),le.init(t,e)}),X$=x("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=S$(e)),le.init(t,e)}),Q$=x("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=b$),le.init(t,e)}),eA=x("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=w$(e)),le.init(t,e)}),tA=x("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=l$),le.init(t,e)}),nA=x("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=p$),le.init(t,e),t._zod.bag.format="ipv4"}),rA=x("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=f$),le.init(t,e),t._zod.bag.format="ipv6",t._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:t,continue:!e.abort})}}}),iA=x("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=g$),le.init(t,e)}),sA=x("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=m$),le.init(t,e),t._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:t,continue:!e.abort})}}});function wm(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const oA=x("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=v$),le.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{wm(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort})}});function aA(t){if(!pm.test(t))return!1;const e=t.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=e.padEnd(Math.ceil(e.length/4)*4,"=");return wm(n)}const lA=x("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=pm),le.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=n=>{aA(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!e.abort})}}),cA=x("$ZodE164",(t,e)=>{e.pattern??(e.pattern=y$),le.init(t,e)});function uA(t,e=null){try{const n=t.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&(!("alg"in i)||i.alg!==e))}catch{return!1}}const hA=x("$ZodJWT",(t,e)=>{le.init(t,e),t._zod.check=n=>{uA(n.value,e.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!e.abort})}}),Sm=x("$ZodNumber",(t,e)=>{de.init(t,e),t._zod.pattern=t._zod.bag.pattern??mm,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:t,...s?{received:s}:{}}),n}}),dA=x("$ZodNumberFormat",(t,e)=>{T$.init(t,e),Sm.init(t,e)}),pA=x("$ZodBoolean",(t,e)=>{de.init(t,e),t._zod.pattern=E$,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:t}),n}}),fA=x("$ZodUnknown",(t,e)=>{de.init(t,e),t._zod.parse=n=>n}),gA=x("$ZodNever",(t,e)=>{de.init(t,e),t._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:t}),n)});function bp(t,e,n){t.issues.length&&e.issues.push(...Lr(n,t.issues)),e.value[n]=t.value}const mA=x("$ZodArray",(t,e)=>{de.init(t,e),t._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:t}),n;n.value=Array(i.length);const s=[];for(let o=0;o<i.length;o++){const a=i[o],l=e.element._zod.run({value:a,issues:[]},r);l instanceof Promise?s.push(l.then(u=>bp(u,n,o))):bp(l,n,o)}return s.length?Promise.all(s).then(()=>n):n}});function ua(t,e,n,r,i){if(t.issues.length){if(i&&!(n in r))return;e.issues.push(...Lr(n,t.issues))}t.value===void 0?n in r&&(e.value[n]=void 0):e.value[n]=t.value}function _m(t){var r,i,s,o;const e=Object.keys(t.shape);for(const a of e)if(!((o=(s=(i=(r=t.shape)==null?void 0:r[a])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=zx(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}function km(t,e,n,r,i,s){const o=[],a=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optout==="optional";for(const p in e){if(a.has(p))continue;if(u==="never"){o.push(p);continue}const y=l.run({value:e[p],issues:[]},r);y instanceof Promise?t.push(y.then(v=>ua(v,n,p,e,d))):ua(y,n,p,e,d)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:s}),t.length?Promise.all(t).then(()=>n):n}const vA=x("$ZodObject",(t,e)=>{de.init(t,e);const n=Object.getOwnPropertyDescriptor(e,"shape");if(!(n!=null&&n.get)){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const l={...a};return Object.defineProperty(e,"shape",{value:l}),l}})}const r=Zu(()=>_m(e));Q(t._zod,"propValues",()=>{const a=e.shape,l={};for(const u in a){const d=a[u]._zod;if(d.values){l[u]??(l[u]=new Set);for(const p of d.values)l[u].add(p)}}return l});const i=ca,s=e.catchall;let o;t._zod.parse=(a,l)=>{o??(o=r.value);const u=a.value;if(!i(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:t}),a;a.value={};const d=[],p=o.shape;for(const y of o.keys){const v=p[y],A=v._zod.optout==="optional",E=v._zod.run({value:u[y],issues:[]},l);E instanceof Promise?d.push(E.then(I=>ua(I,a,y,u,A))):ua(E,a,y,u,A)}return s?km(d,u,a,l,r.value,t):d.length?Promise.all(d).then(()=>a):a}}),yA=x("$ZodObjectJIT",(t,e)=>{vA.init(t,e);const n=t._zod.parse,r=Zu(()=>_m(e)),i=y=>{var V;const v=new U$(["shape","payload","ctx"]),A=r.value,E=O=>{const H=vp(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 A.keys)I[O]=`key_${Z++}`;v.write("const newResult = {};");for(const O of A.keys){const H=I[O],N=vp(O),ce=y[O],ue=((V=ce==null?void 0:ce._zod)==null?void 0:V.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=!om.jitless,u=a&&Dx.value,d=e.catchall;let p;t._zod.parse=(y,v)=>{p??(p=r.value);const A=y.value;return o(A)?a&&u&&(v==null?void 0:v.async)===!1&&v.jitless!==!0?(s||(s=i(e.shape)),y=s(y,v),d?km([],A,y,v,p,t):y):n(y,v):(y.issues.push({expected:"object",code:"invalid_type",input:A,inst:t}),y)}});function wp(t,e,n,r){for(const s of t)if(s.issues.length===0)return e.value=s.value,e;const i=t.filter(s=>!Mr(s));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(s=>s.issues.map(o=>mn(o,r,gn())))}),e)}const bA=x("$ZodUnion",(t,e)=>{de.init(t,e),Q(t._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Q(t._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Q(t._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),Q(t._zod,"pattern",()=>{if(e.options.every(i=>i._zod.pattern)){const i=e.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>Bu(s.source)).join("|")})$`)}});const n=e.options.length===1,r=e.options[0]._zod.run;t._zod.parse=(i,s)=>{if(n)return r(i,s);let o=!1;const a=[];for(const l of e.options){const u=l._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(l=>wp(l,i,t,s)):wp(a,i,t,s)}}),wA=x("$ZodIntersection",(t,e)=>{de.init(t,e),t._zod.parse=(n,r)=>{const i=n.value,s=e.left._zod.run({value:i,issues:[]},r),o=e.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([l,u])=>Sp(n,l,u)):Sp(n,s,o)}});function xc(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(oi(t)&&oi(e)){const n=Object.keys(e),r=Object.keys(t).filter(s=>n.indexOf(s)!==-1),i={...t,...e};for(const s of r){const o=xc(t[s],e[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<t.length;r++){const i=t[r],s=e[r],o=xc(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Sp(t,e,n){const r=new Map;let i;for(const a of e.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else t.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else t.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&t.issues.push({...i,keys:s}),Mr(t))return t;const o=xc(e.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return t.value=o.data,t}const SA=x("$ZodRecord",(t,e)=>{de.init(t,e),t._zod.parse=(n,r)=>{const i=n.value;if(!oi(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:t}),n;const s=[],o=e.keyType._zod.values;if(o){n.value={};const a=new Set;for(const u of o)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const d=e.valueType._zod.run({value:i[u],issues:[]},r);d instanceof Promise?s.push(d.then(p=>{p.issues.length&&n.issues.push(...Lr(u,p.issues)),n.value[u]=p.value})):(d.issues.length&&n.issues.push(...Lr(u,d.issues)),n.value[u]=d.value)}let l;for(const u in i)a.has(u)||(l=l??[],l.push(u));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:t,keys:l})}else{n.value={};for(const a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let l=e.keyType._zod.run({value:a,issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&mm.test(a)&&l.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&&(l=p)}if(l.issues.length){e.mode==="loose"?n.value[a]=i[a]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(p=>mn(p,r,gn())),input:a,path:[a],inst:t});continue}const d=e.valueType._zod.run({value:i[a],issues:[]},r);d instanceof Promise?s.push(d.then(p=>{p.issues.length&&n.issues.push(...Lr(a,p.issues)),n.value[l.value]=p.value})):(d.issues.length&&n.issues.push(...Lr(a,d.issues)),n.value[l.value]=d.value)}}return s.length?Promise.all(s).then(()=>n):n}}),_A=x("$ZodEnum",(t,e)=>{de.init(t,e);const n=am(e.entries),r=new Set(n);t._zod.values=r,t._zod.pattern=new RegExp(`^(${n.filter(i=>Ox.has(typeof i)).map(i=>typeof i=="string"?ai(i):i.toString()).join("|")})$`),t._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:n,input:o,inst:t}),i}}),kA=x("$ZodLiteral",(t,e)=>{if(de.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(e.values);t._zod.values=n,t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?ai(r):r?ai(r.toString()):String(r)).join("|")})$`),t._zod.parse=(r,i)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:t}),r}}),EA=x("$ZodTransform",(t,e)=>{de.init(t,e),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new sm(t.constructor.name);const i=e.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(n.value=o,n));if(i instanceof Promise)throw new Ur;return n.value=i,n}});function _p(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const Em=x("$ZodOptional",(t,e)=>{de.init(t,e),t._zod.optin="optional",t._zod.optout="optional",Q(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),Q(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${Bu(n.source)})?$`):void 0}),t._zod.parse=(n,r)=>{if(e.innerType._zod.optin==="optional"){const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>_p(s,n.value)):_p(i,n.value)}return n.value===void 0?n:e.innerType._zod.run(n,r)}}),xA=x("$ZodExactOptional",(t,e)=>{Em.init(t,e),Q(t._zod,"values",()=>e.innerType._zod.values),Q(t._zod,"pattern",()=>e.innerType._zod.pattern),t._zod.parse=(n,r)=>e.innerType._zod.run(n,r)}),$A=x("$ZodNullable",(t,e)=>{de.init(t,e),Q(t._zod,"optin",()=>e.innerType._zod.optin),Q(t._zod,"optout",()=>e.innerType._zod.optout),Q(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${Bu(n.source)}|null)$`):void 0}),Q(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(n,r)=>n.value===null?n:e.innerType._zod.run(n,r)}),AA=x("$ZodDefault",(t,e)=>{de.init(t,e),t._zod.optin="optional",Q(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);if(n.value===void 0)return n.value=e.defaultValue,n;const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>kp(s,e)):kp(i,e)}});function kp(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const TA=x("$ZodPrefault",(t,e)=>{de.init(t,e),t._zod.optin="optional",Q(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=e.defaultValue),e.innerType._zod.run(n,r))}),CA=x("$ZodNonOptional",(t,e)=>{de.init(t,e),Q(t._zod,"values",()=>{const n=e.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),t._zod.parse=(n,r)=>{const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>Ep(s,t)):Ep(i,t)}});function Ep(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}const IA=x("$ZodCatch",(t,e)=>{de.init(t,e),Q(t._zod,"optin",()=>e.innerType._zod.optin),Q(t._zod,"optout",()=>e.innerType._zod.optout),Q(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>(n.value=s.value,s.issues.length&&(n.value=e.catchValue({...n,error:{issues:s.issues.map(o=>mn(o,r,gn()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=e.catchValue({...n,error:{issues:i.issues.map(s=>mn(s,r,gn()))},input:n.value}),n.issues=[]),n)}}),PA=x("$ZodPipe",(t,e)=>{de.init(t,e),Q(t._zod,"values",()=>e.in._zod.values),Q(t._zod,"optin",()=>e.in._zod.optin),Q(t._zod,"optout",()=>e.out._zod.optout),Q(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=e.out._zod.run(n,r);return s instanceof Promise?s.then(o=>Ao(o,e.in,r)):Ao(s,e.in,r)}const i=e.in._zod.run(n,r);return i instanceof Promise?i.then(s=>Ao(s,e.out,r)):Ao(i,e.out,r)}});function Ao(t,e,n){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},n)}const RA=x("$ZodReadonly",(t,e)=>{de.init(t,e),Q(t._zod,"propValues",()=>e.innerType._zod.propValues),Q(t._zod,"values",()=>e.innerType._zod.values),Q(t._zod,"optin",()=>{var n,r;return(r=(n=e.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),Q(t._zod,"optout",()=>{var n,r;return(r=(n=e.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(xp):xp(i)}});function xp(t){return t.value=Object.freeze(t.value),t}const DA=x("$ZodCustom",(t,e)=>{qe.init(t,e),de.init(t,e),t._zod.parse=(n,r)=>n,t._zod.check=n=>{const r=n.value,i=e.fn(r);if(i instanceof Promise)return i.then(s=>$p(s,n,r,t));$p(i,n,r,t)}});function $p(t,e,n,r){if(!t){const i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),e.issues.push(rs(i))}}var Ap;class OA{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...n){const r=n[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const n=this._map.get(e);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(e),this}get(e){const n=e._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const i={...r,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function zA(){return new OA}(Ap=globalThis).__zod_globalRegistry??(Ap.__zod_globalRegistry=zA());const Zi=globalThis.__zod_globalRegistry;function MA(t,e){return new t({type:"string",...z(e)})}function LA(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...z(e)})}function Tp(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...z(e)})}function NA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...z(e)})}function UA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(e)})}function FA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(e)})}function ZA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(e)})}function HA(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...z(e)})}function BA(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...z(e)})}function jA(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(e)})}function VA(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...z(e)})}function WA(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(e)})}function GA(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...z(e)})}function qA(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...z(e)})}function YA(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(e)})}function KA(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(e)})}function JA(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(e)})}function XA(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(e)})}function QA(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(e)})}function e1(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...z(e)})}function t1(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...z(e)})}function n1(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...z(e)})}function r1(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...z(e)})}function i1(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(e)})}function s1(t,e){return new t({type:"string",format:"date",check:"string_format",...z(e)})}function o1(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...z(e)})}function a1(t,e){return new t({type:"string",format:"duration",check:"string_format",...z(e)})}function l1(t,e){return new t({type:"number",checks:[],...z(e)})}function c1(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...z(e)})}function u1(t,e){return new t({type:"boolean",...z(e)})}function h1(t){return new t({type:"unknown"})}function d1(t,e){return new t({type:"never",...z(e)})}function Cp(t,e){return new ym({check:"less_than",...z(e),value:t,inclusive:!1})}function Bl(t,e){return new ym({check:"less_than",...z(e),value:t,inclusive:!0})}function Ip(t,e){return new bm({check:"greater_than",...z(e),value:t,inclusive:!1})}function jl(t,e){return new bm({check:"greater_than",...z(e),value:t,inclusive:!0})}function Pp(t,e){return new A$({check:"multiple_of",...z(e),value:t})}function xm(t,e){return new C$({check:"max_length",...z(e),maximum:t})}function ha(t,e){return new I$({check:"min_length",...z(e),minimum:t})}function $m(t,e){return new P$({check:"length_equals",...z(e),length:t})}function p1(t,e){return new R$({check:"string_format",format:"regex",...z(e),pattern:t})}function f1(t){return new D$({check:"string_format",format:"lowercase",...z(t)})}function g1(t){return new O$({check:"string_format",format:"uppercase",...z(t)})}function m1(t,e){return new z$({check:"string_format",format:"includes",...z(e),includes:t})}function v1(t,e){return new M$({check:"string_format",format:"starts_with",...z(e),prefix:t})}function y1(t,e){return new L$({check:"string_format",format:"ends_with",...z(e),suffix:t})}function bi(t){return new N$({check:"overwrite",tx:t})}function b1(t){return bi(e=>e.normalize(t))}function w1(){return bi(t=>t.trim())}function S1(){return bi(t=>t.toLowerCase())}function _1(){return bi(t=>t.toUpperCase())}function k1(){return bi(t=>Rx(t))}function E1(t,e,n){return new t({type:"array",element:e,...z(n)})}function x1(t,e,n){return new t({type:"custom",check:"custom",fn:e,...z(n)})}function $1(t){const e=A1(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(rs(r,n.value,e._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),i.continue??(i.continue=!e._zod.def.abort),n.issues.push(rs(i))}},t(n.value,n)));return e}function A1(t,e){const n=new qe({check:"custom",...z(e)});return n._zod.check=t,n}function Am(t){let e=(t==null?void 0:t.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:(t==null?void 0:t.metadata)??Zi,target:e,unrepresentable:(t==null?void 0:t.unrepresentable)??"throw",override:(t==null?void 0:t.override)??(()=>{}),io:(t==null?void 0:t.io)??"output",counter:0,seen:new Map,cycles:(t==null?void 0:t.cycles)??"ref",reused:(t==null?void 0:t.reused)??"inline",external:(t==null?void 0:t.external)??void 0}}function ye(t,e,n={path:[],schemaPath:[]}){var d,p;var r;const i=t._zod.def,s=e.seen.get(t);if(s)return s.count++,n.schemaPath.includes(t)&&(s.cycle=n.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};e.seen.set(t,o);const a=(p=(d=t._zod).toJSONSchema)==null?void 0:p.call(d);if(a)o.schema=a;else{const y={...n,schemaPath:[...n.schemaPath,t],path:n.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,o.schema,y);else{const A=o.schema,E=e.processors[i.type];if(!E)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);E(t,e,A,y)}const v=t._zod.parent;v&&(o.ref||(o.ref=v),ye(v,e,y),e.seen.get(v).isParent=!0)}const l=e.metadataRegistry.get(t);return l&&Object.assign(o.schema,l),e.io==="input"&&ze(t)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(t).schema}function Tm(t,e){var o,a,l,u;const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const d of t.seen.entries()){const p=(o=t.metadataRegistry.get(d[0]))==null?void 0:o.id;if(p){const y=r.get(p);if(y&&y!==d[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(p,d[0])}}const i=d=>{var E;const p=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const I=(E=t.external.registry.get(d[0]))==null?void 0:E.id,Z=t.external.uri??(V=>V);if(I)return{ref:Z(I)};const P=d[1].defId??d[1].schema.id??`schema${t.counter++}`;return d[1].defId=P,{defId:P,ref:`${Z("__shared")}#/${p}/${P}`}}if(d[1]===n)return{ref:"#"};const v=`#/${p}/`,A=d[1].schema.id??`__schema${t.counter++}`;return{defId:A,ref:v+A}},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 A=p.schema;for(const E in A)delete A[E];A.$ref=y};if(t.cycles==="throw")for(const d of t.seen.entries()){const p=d[1];if(p.cycle)throw new Error(`Cycle detected: #/${(a=p.cycle)==null?void 0:a.join("/")}/<root>
|
|
41
|
+
|
|
42
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of t.seen.entries()){const p=d[1];if(e===d[0]){s(d);continue}if(t.external){const v=(l=t.external.registry.get(d[0]))==null?void 0:l.id;if(e!==d[0]&&v){s(d);continue}}if((u=t.metadataRegistry.get(d[0]))==null?void 0:u.id){s(d);continue}if(p.cycle){s(d);continue}if(p.count>1&&t.reused==="ref"){s(d);continue}}}function Cm(t,e){var o,a,l;const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const d=t.seen.get(u);if(d.ref===null)return;const p=d.def??d.schema,y={...p},v=d.ref;if(d.ref=null,v){r(v);const E=t.seen.get(v),I=E.schema;if(I.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(I)):Object.assign(p,I),Object.assign(p,y),u._zod.parent===v)for(const P in p)P==="$ref"||P==="allOf"||P in y||delete p[P];if(I.$ref&&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 A=u._zod.parent;if(A&&A!==v){r(A);const E=t.seen.get(A);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]}t.override({zodSchema:u,jsonSchema:p,path:d.path??[]})};for(const u of[...t.seen.entries()].reverse())r(u[0]);const i={};if(t.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":t.target,(o=t.external)!=null&&o.uri){const u=(a=t.external.registry.get(e))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=t.external.uri(u)}Object.assign(i,n.def??n.schema);const s=((l=t.external)==null?void 0:l.defs)??{};for(const u of t.seen.entries()){const d=u[1];d.def&&d.defId&&(s[d.defId]=d.def)}t.external||Object.keys(s).length>0&&(t.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...e["~standard"],jsonSchema:{input:da(e,"input",t.processors),output:da(e,"output",t.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function ze(t,e){const n=e??{seen:new Set};if(n.seen.has(t))return!1;n.seen.add(t);const r=t._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return ze(r.element,n);if(r.type==="set")return ze(r.valueType,n);if(r.type==="lazy")return ze(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return ze(r.innerType,n);if(r.type==="intersection")return ze(r.left,n)||ze(r.right,n);if(r.type==="record"||r.type==="map")return ze(r.keyType,n)||ze(r.valueType,n);if(r.type==="pipe")return ze(r.in,n)||ze(r.out,n);if(r.type==="object"){for(const i in r.shape)if(ze(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(ze(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(ze(i,n))return!0;return!!(r.rest&&ze(r.rest,n))}return!1}const T1=(t,e={})=>n=>{const r=Am({...n,processors:e});return ye(t,r),Tm(r,t),Cm(r,t)},da=(t,e,n={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=Am({...i??{},target:s,io:e,processors:n});return ye(t,o),Tm(o,t),Cm(o,t)},C1={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},I1=(t,e,n,r)=>{const i=n;i.type="string";const{minimum:s,maximum:o,format:a,patterns:l,contentEncoding:u}=t._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=C1[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),u&&(i.contentEncoding=u),l&&l.size>0){const d=[...l];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}))])}},P1=(t,e,n,r)=>{const i=n,{minimum:s,maximum:o,format:a,multipleOf:l,exclusiveMaximum:u,exclusiveMinimum:d}=t._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof d=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.minimum=d,i.exclusiveMinimum=!0):i.exclusiveMinimum=d),typeof s=="number"&&(i.minimum=s,typeof d=="number"&&e.target!=="draft-04"&&(d>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof o=="number"&&(i.maximum=o,typeof u=="number"&&e.target!=="draft-04"&&(u<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof l=="number"&&(i.multipleOf=l)},R1=(t,e,n,r)=>{n.type="boolean"},D1=(t,e,n,r)=>{n.not={}},O1=(t,e,n,r)=>{},z1=(t,e,n,r)=>{const i=t._zod.def,s=am(i.entries);s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),n.enum=s},M1=(t,e,n,r)=>{const i=t._zod.def,s=[];for(const o of i.values)if(o===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];n.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?n.enum=[o]:n.const=o}else s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),s.every(o=>typeof o=="boolean")&&(n.type="boolean"),s.every(o=>o===null)&&(n.type="null"),n.enum=s},L1=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},N1=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},U1=(t,e,n,r)=>{const i=n,s=t._zod.def,{minimum:o,maximum:a}=t._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=ye(s.element,e,{...r,path:[...r.path,"items"]})},F1=(t,e,n,r)=>{var u;const i=n,s=t._zod.def;i.type="object",i.properties={};const o=s.shape;for(const d in o)i.properties[d]=ye(o[d],e,{...r,path:[...r.path,"properties",d]});const a=new Set(Object.keys(o)),l=new Set([...a].filter(d=>{const p=s.shape[d]._zod;return e.io==="input"?p.optin===void 0:p.optout===void 0}));l.size>0&&(i.required=Array.from(l)),((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)},Z1=(t,e,n,r)=>{const i=t._zod.def,s=i.inclusive===!1,o=i.options.map((a,l)=>ye(a,e,{...r,path:[...r.path,s?"oneOf":"anyOf",l]}));s?n.oneOf=o:n.anyOf=o},H1=(t,e,n,r)=>{const i=t._zod.def,s=ye(i.left,e,{...r,path:[...r.path,"allOf",0]}),o=ye(i.right,e,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,l=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=l},B1=(t,e,n,r)=>{const i=n,s=t._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag,l=a==null?void 0:a.patterns;if(s.mode==="loose"&&l&&l.size>0){const d=ye(s.valueType,e,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const p of l)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)}},j1=(t,e,n,r)=>{const i=t._zod.def,s=ye(i.innerType,e,r),o=e.seen.get(t);e.target==="openapi-3.0"?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},V1=(t,e,n,r)=>{const i=t._zod.def;ye(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType},W1=(t,e,n,r)=>{const i=t._zod.def;ye(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},G1=(t,e,n,r)=>{const i=t._zod.def;ye(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType,e.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},q1=(t,e,n,r)=>{const i=t._zod.def;ye(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},Y1=(t,e,n,r)=>{const i=t._zod.def,s=e.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;ye(s,e,r);const o=e.seen.get(t);o.ref=s},K1=(t,e,n,r)=>{const i=t._zod.def;ye(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType,n.readOnly=!0},Im=(t,e,n,r)=>{const i=t._zod.def;ye(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType},J1=x("ZodISODateTime",(t,e)=>{X$.init(t,e),fe.init(t,e)});function X1(t){return i1(J1,t)}const Q1=x("ZodISODate",(t,e)=>{Q$.init(t,e),fe.init(t,e)});function eT(t){return s1(Q1,t)}const tT=x("ZodISOTime",(t,e)=>{eA.init(t,e),fe.init(t,e)});function nT(t){return o1(tT,t)}const rT=x("ZodISODuration",(t,e)=>{tA.init(t,e),fe.init(t,e)});function iT(t){return a1(rT,t)}const Pm=(t,e)=>{hm.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:n=>Vx(t,n)},flatten:{value:n=>jx(t,n)},addIssue:{value:n=>{t.issues.push(n),t.message=JSON.stringify(t.issues,Ec,2)}},addIssues:{value:n=>{t.issues.push(...n),t.message=JSON.stringify(t.issues,Ec,2)}},isEmpty:{get(){return t.issues.length===0}}})},Rp=x("ZodError",Pm),at=x("ZodError",Pm,{Parent:Error}),sT=Vu(at),oT=Wu(at),aT=Wa(at),lT=Ga(at),cT=qx(at),uT=Yx(at),hT=Kx(at),dT=Jx(at),pT=Xx(at),fT=Qx(at),gT=e$(at),mT=t$(at),pe=x("ZodType",(t,e)=>(de.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:da(t,"input"),output:da(t,"output")}}),t.toJSONSchema=T1(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...n)=>t.clone(kn(e,{checks:[...e.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),t.with=t.check,t.clone=(n,r)=>En(t,n,r),t.brand=()=>t,t.register=(n,r)=>(n.add(t,r),t),t.parse=(n,r)=>sT(t,n,r,{callee:t.parse}),t.safeParse=(n,r)=>aT(t,n,r),t.parseAsync=async(n,r)=>oT(t,n,r,{callee:t.parseAsync}),t.safeParseAsync=async(n,r)=>lT(t,n,r),t.spa=t.safeParseAsync,t.encode=(n,r)=>cT(t,n,r),t.decode=(n,r)=>uT(t,n,r),t.encodeAsync=async(n,r)=>hT(t,n,r),t.decodeAsync=async(n,r)=>dT(t,n,r),t.safeEncode=(n,r)=>pT(t,n,r),t.safeDecode=(n,r)=>fT(t,n,r),t.safeEncodeAsync=async(n,r)=>gT(t,n,r),t.safeDecodeAsync=async(n,r)=>mT(t,n,r),t.refine=(n,r)=>t.check(aC(n,r)),t.superRefine=n=>t.check(lC(n)),t.overwrite=n=>t.check(bi(n)),t.optional=()=>zp(t),t.exactOptional=()=>qT(t),t.nullable=()=>Mp(t),t.nullish=()=>zp(Mp(t)),t.nonoptional=n=>eC(t,n),t.array=()=>D(t),t.or=n=>B([t,n]),t.and=n=>Ya(t,n),t.transform=n=>Lp(t,WT(n)),t.default=n=>JT(t,n),t.prefault=n=>QT(t,n),t.catch=n=>nC(t,n),t.pipe=n=>Lp(t,n),t.readonly=()=>sC(t),t.describe=n=>{const r=t.clone();return Zi.add(r,{description:n}),r},Object.defineProperty(t,"description",{get(){var n;return(n=Zi.get(t))==null?void 0:n.description},configurable:!0}),t.meta=(...n)=>{if(n.length===0)return Zi.get(t);const r=t.clone();return Zi.add(r,n[0]),r},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t.apply=n=>n(t),t)),Rm=x("_ZodString",(t,e)=>{Gu.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(r,i,s)=>I1(t,r,i);const n=t._zod.bag;t.format=n.format??null,t.minLength=n.minimum??null,t.maxLength=n.maximum??null,t.regex=(...r)=>t.check(p1(...r)),t.includes=(...r)=>t.check(m1(...r)),t.startsWith=(...r)=>t.check(v1(...r)),t.endsWith=(...r)=>t.check(y1(...r)),t.min=(...r)=>t.check(ha(...r)),t.max=(...r)=>t.check(xm(...r)),t.length=(...r)=>t.check($m(...r)),t.nonempty=(...r)=>t.check(ha(1,...r)),t.lowercase=r=>t.check(f1(r)),t.uppercase=r=>t.check(g1(r)),t.trim=()=>t.check(w1()),t.normalize=(...r)=>t.check(b1(...r)),t.toLowerCase=()=>t.check(S1()),t.toUpperCase=()=>t.check(_1()),t.slugify=()=>t.check(k1())}),vT=x("ZodString",(t,e)=>{Gu.init(t,e),Rm.init(t,e),t.email=n=>t.check(LA(yT,n)),t.url=n=>t.check(HA(bT,n)),t.jwt=n=>t.check(r1(OT,n)),t.emoji=n=>t.check(BA(wT,n)),t.guid=n=>t.check(Tp(Dp,n)),t.uuid=n=>t.check(NA(To,n)),t.uuidv4=n=>t.check(UA(To,n)),t.uuidv6=n=>t.check(FA(To,n)),t.uuidv7=n=>t.check(ZA(To,n)),t.nanoid=n=>t.check(jA(ST,n)),t.guid=n=>t.check(Tp(Dp,n)),t.cuid=n=>t.check(VA(_T,n)),t.cuid2=n=>t.check(WA(kT,n)),t.ulid=n=>t.check(GA(ET,n)),t.base64=n=>t.check(e1(PT,n)),t.base64url=n=>t.check(t1(RT,n)),t.xid=n=>t.check(qA(xT,n)),t.ksuid=n=>t.check(YA($T,n)),t.ipv4=n=>t.check(KA(AT,n)),t.ipv6=n=>t.check(JA(TT,n)),t.cidrv4=n=>t.check(XA(CT,n)),t.cidrv6=n=>t.check(QA(IT,n)),t.e164=n=>t.check(n1(DT,n)),t.datetime=n=>t.check(X1(n)),t.date=n=>t.check(eT(n)),t.time=n=>t.check(nT(n)),t.duration=n=>t.check(iT(n))});function h(t){return MA(vT,t)}const fe=x("ZodStringFormat",(t,e)=>{le.init(t,e),Rm.init(t,e)}),yT=x("ZodEmail",(t,e)=>{B$.init(t,e),fe.init(t,e)}),Dp=x("ZodGUID",(t,e)=>{Z$.init(t,e),fe.init(t,e)}),To=x("ZodUUID",(t,e)=>{H$.init(t,e),fe.init(t,e)}),bT=x("ZodURL",(t,e)=>{j$.init(t,e),fe.init(t,e)}),wT=x("ZodEmoji",(t,e)=>{V$.init(t,e),fe.init(t,e)}),ST=x("ZodNanoID",(t,e)=>{W$.init(t,e),fe.init(t,e)}),_T=x("ZodCUID",(t,e)=>{G$.init(t,e),fe.init(t,e)}),kT=x("ZodCUID2",(t,e)=>{q$.init(t,e),fe.init(t,e)}),ET=x("ZodULID",(t,e)=>{Y$.init(t,e),fe.init(t,e)}),xT=x("ZodXID",(t,e)=>{K$.init(t,e),fe.init(t,e)}),$T=x("ZodKSUID",(t,e)=>{J$.init(t,e),fe.init(t,e)}),AT=x("ZodIPv4",(t,e)=>{nA.init(t,e),fe.init(t,e)}),TT=x("ZodIPv6",(t,e)=>{rA.init(t,e),fe.init(t,e)}),CT=x("ZodCIDRv4",(t,e)=>{iA.init(t,e),fe.init(t,e)}),IT=x("ZodCIDRv6",(t,e)=>{sA.init(t,e),fe.init(t,e)}),PT=x("ZodBase64",(t,e)=>{oA.init(t,e),fe.init(t,e)}),RT=x("ZodBase64URL",(t,e)=>{lA.init(t,e),fe.init(t,e)}),DT=x("ZodE164",(t,e)=>{cA.init(t,e),fe.init(t,e)}),OT=x("ZodJWT",(t,e)=>{hA.init(t,e),fe.init(t,e)}),Dm=x("ZodNumber",(t,e)=>{Sm.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(r,i,s)=>P1(t,r,i),t.gt=(r,i)=>t.check(Ip(r,i)),t.gte=(r,i)=>t.check(jl(r,i)),t.min=(r,i)=>t.check(jl(r,i)),t.lt=(r,i)=>t.check(Cp(r,i)),t.lte=(r,i)=>t.check(Bl(r,i)),t.max=(r,i)=>t.check(Bl(r,i)),t.int=r=>t.check(Op(r)),t.safe=r=>t.check(Op(r)),t.positive=r=>t.check(Ip(0,r)),t.nonnegative=r=>t.check(jl(0,r)),t.negative=r=>t.check(Cp(0,r)),t.nonpositive=r=>t.check(Bl(0,r)),t.multipleOf=(r,i)=>t.check(Pp(r,i)),t.step=(r,i)=>t.check(Pp(r,i)),t.finite=()=>t;const n=t._zod.bag;t.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),t.isFinite=!0,t.format=n.format??null});function F(t){return l1(Dm,t)}const zT=x("ZodNumberFormat",(t,e)=>{dA.init(t,e),Dm.init(t,e)});function Op(t){return c1(zT,t)}const MT=x("ZodBoolean",(t,e)=>{pA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>R1(t,n,r)});function Ee(t){return u1(MT,t)}const LT=x("ZodUnknown",(t,e)=>{fA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>O1()});function S(){return h1(LT)}const NT=x("ZodNever",(t,e)=>{gA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>D1(t,n,r)});function UT(t){return d1(NT,t)}const FT=x("ZodArray",(t,e)=>{mA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>U1(t,n,r,i),t.element=e.element,t.min=(n,r)=>t.check(ha(n,r)),t.nonempty=n=>t.check(ha(1,n)),t.max=(n,r)=>t.check(xm(n,r)),t.length=(n,r)=>t.check($m(n,r)),t.unwrap=()=>t.element});function D(t,e){return E1(FT,t,e)}const Om=x("ZodObject",(t,e)=>{yA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>F1(t,n,r,i),Q(t,"shape",()=>e.shape),t.keyof=()=>pa(Object.keys(t._zod.def.shape)),t.catchall=n=>t.clone({...t._zod.def,catchall:n}),t.passthrough=()=>t.clone({...t._zod.def,catchall:S()}),t.loose=()=>t.clone({...t._zod.def,catchall:S()}),t.strict=()=>t.clone({...t._zod.def,catchall:UT()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=n=>Ux(t,n),t.safeExtend=n=>Fx(t,n),t.merge=n=>Zx(t,n),t.pick=n=>Lx(t,n),t.omit=n=>Nx(t,n),t.partial=(...n)=>Hx(Mm,t,n[0]),t.required=(...n)=>Bx(Lm,t,n[0])});function zm(t,e){const n={type:"object",shape:t??{},...z(e)};return new Om(n)}function f(t,e){return new Om({type:"object",shape:t,catchall:S(),...z(e)})}const ZT=x("ZodUnion",(t,e)=>{bA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>Z1(t,n,r,i),t.options=e.options});function B(t,e){return new ZT({type:"union",options:t,...z(e)})}const HT=x("ZodIntersection",(t,e)=>{wA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>H1(t,n,r,i)});function Ya(t,e){return new HT({type:"intersection",left:t,right:e})}const BT=x("ZodRecord",(t,e)=>{SA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>B1(t,n,r,i),t.keyType=e.keyType,t.valueType=e.valueType});function _(t,e,n){return new BT({type:"record",keyType:t,valueType:e,...z(n)})}const $c=x("ZodEnum",(t,e)=>{_A.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(r,i,s)=>z1(t,r,i),t.enum=e.entries,t.options=Object.values(e.entries);const n=new Set(Object.keys(e.entries));t.extract=(r,i)=>{const s={};for(const o of r)if(n.has(o))s[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new $c({...e,checks:[],...z(i),entries:s})},t.exclude=(r,i)=>{const s={...e.entries};for(const o of r)if(n.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new $c({...e,checks:[],...z(i),entries:s})}});function pa(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new $c({type:"enum",entries:n,...z(e)})}const jT=x("ZodLiteral",(t,e)=>{kA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>M1(t,n,r),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function $(t,e){return new jT({type:"literal",values:Array.isArray(t)?t:[t],...z(e)})}const VT=x("ZodTransform",(t,e)=>{EA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>N1(t,n),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new sm(t.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(rs(s,n.value,e));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),n.issues.push(rs(o))}};const i=e.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n)):(n.value=i,n)}});function WT(t){return new VT({type:"transform",transform:t})}const Mm=x("ZodOptional",(t,e)=>{Em.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>Im(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function zp(t){return new Mm({type:"optional",innerType:t})}const GT=x("ZodExactOptional",(t,e)=>{xA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>Im(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function qT(t){return new GT({type:"optional",innerType:t})}const YT=x("ZodNullable",(t,e)=>{$A.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>j1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function Mp(t){return new YT({type:"nullable",innerType:t})}const KT=x("ZodDefault",(t,e)=>{AA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>W1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function JT(t,e){return new KT({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():cm(e)}})}const XT=x("ZodPrefault",(t,e)=>{TA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>G1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function QT(t,e){return new XT({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():cm(e)}})}const Lm=x("ZodNonOptional",(t,e)=>{CA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>V1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function eC(t,e){return new Lm({type:"nonoptional",innerType:t,...z(e)})}const tC=x("ZodCatch",(t,e)=>{IA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>q1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function nC(t,e){return new tC({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const rC=x("ZodPipe",(t,e)=>{PA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>Y1(t,n,r,i),t.in=e.in,t.out=e.out});function Lp(t,e){return new rC({type:"pipe",in:t,out:e})}const iC=x("ZodReadonly",(t,e)=>{RA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>K1(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function sC(t){return new iC({type:"readonly",innerType:t})}const oC=x("ZodCustom",(t,e)=>{DA.init(t,e),pe.init(t,e),t._zod.processJSONSchema=(n,r,i)=>L1(t,n)});function aC(t,e={}){return x1(oC,t,e)}function lC(t){return $1(t)}const cC=["text/markdown","text/html"],uC=["committed","pending"];zm({id:h().min(1),type:pa(cC),title:h(),status:pa(uC),externalFilePath:h().optional()});zm({name:h().min(1),description:h(),accepts:D(h().min(1)).min(1)});function qu(t){return typeof t=="object"&&t!==null}function hC(t){return!qu(t)||t.type!=="ready"?!1:!("id"in t)}function dC(t){return!(!qu(t)||t.type!=="update-content"||typeof t.id!="string"||typeof t.content!="string")}function pC(t){return!qu(t)||t.type!=="wheel"||typeof t.deltaX!="number"||typeof t.deltaY!="number"||typeof t.shiftKey!="boolean"?!1:!("id"in t)}function fC(t,e){if(t===e)return 2;if(t==="*/*")return 0;const n=t.indexOf("/");if(n>0&&t.slice(n+1)==="*"){const r=t.slice(0,n),i=e.indexOf("/");if(i>0&&e.slice(0,i)===r)return 1}return null}function gC(t,e){let n=null;for(const r of t.accepts){const i=fC(r,e);i!==null&&(n===null||i>n)&&(n=i)}return n}function mC(t,e){let n=-1,r=null;for(const i of e){const s=gC(i,t);s!==null&&(s>n||s===n&&r!==null&&i.id<r.id)&&(n=s,r=i)}return r}const vC=4401;class Ac extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class Tc extends mt{constructor(n){super();b(this,"url");b(this,"name");b(this,"token");b(this,"status","disconnected");b(this,"screens",new Map);b(this,"views",[]);b(this,"client");b(this,"createSocket");b(this,"createClient");b(this,"socket",null);b(this,"connectAttempt",0);this.url=Et(n.url),this.name=n.name,this.token=n.token??null,this.createSocket=n.createSocket??(r=>new WebSocket(r)),this.createClient=n.createClient??((r,i)=>new wx(r,{token:i??void 0})),this.client=this.createClient(this.url,this.token)}async connect(){var i;this.connectAttempt+=1;const n=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this.token),this.status="connecting",this.dispatchEvent(new ee("change"));const r=this.createSocket(yC(this.url,this.token));return this.socket=r,await new Promise((s,o)=>{let a=!1;const l=()=>{a||this.connectAttempt!==n||(a=!0,this.status="connected",this.dispatchEvent(new ee("change")),s())},u=p=>{a||this.connectAttempt!==n||(a=!0,this.status="disconnected",this.dispatchEvent(new ee("change")),o(p))},d=async()=>{try{const[{screens:p},y]=await Promise.all([this.client.screens.list(),this.client.views.list()]);this.screens=new Map(p.map(v=>[v.id,structuredClone(v)])),this.views=y,this.dispatchEvent(new ee("change")),l()}catch(p){u(p instanceof Error?p:new Error(String(p)))}};r.addEventListener("open",()=>{d()}),r.addEventListener("message",p=>{const y=wC(p);y&&(this.applyServerEvent(y),this.dispatchEvent(new Yg("server-event",{serverURL:this.url,event:y})))}),r.addEventListener("close",p=>{if(this.connectAttempt===n){if(this.socket=null,bC(p)===vC){u(new Ac);return}if(!a){u(new Error("Connection closed before initialization"));return}this.status="disconnected",this.dispatchEvent(new ee("change"))}}),r.addEventListener("error",()=>{u(new Error("WebSocket connection failed"))})})}disconnect(){var n;this.connectAttempt+=1,(n=this.socket)==null||n.close(),this.socket=null,this.status="disconnected",this.dispatchEvent(new ee("change"))}getViewURL(n){const r=mC(n.type,this.views);if(!r)return null;const i=`${this.url}/views/${encodeURIComponent(r.id)}/`;return this.token===null?i:`${i}?token=${encodeURIComponent(this.token)}`}getContentURL(n){const r=`${this.url}/artifacts/${encodeURIComponent(n)}/content`;return this.token===null?r:`${r}?token=${encodeURIComponent(this.token)}`}async createScreen(n){const{screen:r}=await this.client.screens.create({name:n});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(n){switch(n.type){case"screen-created":this.screens.set(n.screen.id,structuredClone(n.screen)),this.dispatchEvent(new Wo("screens-changed"));break;case"screen-updated":this.screens.set(n.screen.id,structuredClone(n.screen)),this.dispatchEvent(new Wo("screens-changed"));break;case"screen-removed":this.screens.delete(n.screenID),this.dispatchEvent(new Wo("screens-changed"));break;case"artifact-created":{const r=this.screens.get(n.screenID);r&&!Wg(r.layout,n.artifact.id)&&(r.layout=[...r.layout,Vg(n.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(n.screenID);r&&(r.layout=Mg(r.layout,n.artifactID));break}}}}function yC(t,e){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname="/events",n.search="",e&&n.searchParams.set("token",e),n.hash="",n.toString()}function bC(t){return typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="number"?t.code:null}function wC(t){const e=typeof t=="string"?t:typeof t=="object"&&t!==null&&"data"in t&&typeof t.data=="string"?t.data:"";if(!e)return null;try{return JSON.parse(e)}catch{return null}}class SC extends mt{constructor(n){super();b(this,"servers",new Map);b(this,"localServerURL");b(this,"localStore");b(this,"createSocket");b(this,"lastActiveServerURL");b(this,"serverListeners",new Map);b(this,"handleLocalStoreChange",()=>{const n=this.localStore.get().activeServerURL;n!==this.lastActiveServerURL&&(this.lastActiveServerURL=n,this.dispatchEvent(new ee("change")))});this.localStore=n.localStore,this.localServerURL=n.localServerURL?Et(n.localServerURL):null,this.createSocket=n.createSocket??(r=>new WebSocket(r)),this.lastActiveServerURL=this.localStore.get().activeServerURL,this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const n=this.localStore.get().activeServerURL;return n===null?null:this.servers.get(n)??null}add(n){const r=Et(n.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,n);const s=()=>{this.dispatchEvent(new ee("change"))},o=l=>{this.dispatchEvent(new Yg("server-event",{serverURL:l.serverURL,event:l.event}))},a=()=>{this.dispatchEvent(new Wo("screens-changed"))};n.addEventListener("change",s),n.addEventListener("server-event",o),n.addEventListener("screens-changed",a),this.serverListeners.set(r,{onServerChange:s,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new ee("change"))}remove(n){const r=Et(n);if(this.localServerURL&&r===this.localServerURL)return;const i=this.servers.get(r);if(!i)return;const s=this.serverListeners.get(r);s&&(i.removeEventListener("change",s.onServerChange),i.removeEventListener("server-event",s.onServerEvent),i.removeEventListener("screens-changed",s.onScreensChanged),this.serverListeners.delete(r)),i.disconnect(),this.servers.delete(r);const o=this.localStore.get(),a=o.activeServerURL===r;this.localStore.set({...o,servers:o.servers.filter(l=>l.url!==r),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new ee("change"))}setActive(n){const r=this.localStore.get(),i=n?Et(n.url):null;r.activeServerURL!==i&&this.localStore.set({...r,activeServerURL:i})}connectConfiguredServers(n,r){const i=this.localStore.get().servers,s=n?Et(n):null;for(const a of i){const l=Et(a.url),u=s!==null&&l===s,d=new Tc({url:a.url,name:a.name,token:u?r??null:null,createSocket:this.createSocket});this.add(d),d.connect().catch(()=>{})}const o=s?this.servers.get(s)??null:null;this.setActive(o??this.servers.values().next().value??null)}addServer(n,r){const i=Et(n);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 Tc({url:i,name:r,createSocket:this.createSocket});this.add(o),this.setActive(o),o.connect().catch(()=>{})}removeServer(n){this.remove(n)}}const oe={authenticate:"authenticate",document_did_change:"document/didChange",document_did_close:"document/didClose",document_did_focus:"document/didFocus",document_did_open:"document/didOpen",document_did_save:"document/didSave",initialize:"initialize",logout:"logout",nes_accept:"nes/accept",nes_close:"nes/close",nes_reject:"nes/reject",nes_start:"nes/start",nes_suggest:"nes/suggest",session_cancel:"session/cancel",session_close:"session/close",session_fork:"session/fork",session_list:"session/list",session_load:"session/load",session_new:"session/new",session_prompt:"session/prompt",session_resume:"session/resume",session_set_config_option:"session/set_config_option",session_set_mode:"session/set_mode",session_set_model:"session/set_model"},zt={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"},_C=1,kC=f({_meta:_(h(),S()).nullish(),terminal:Ee().optional().default(!1)}),EC=f({_meta:_(h(),S()).nullish(),label:h().nullish(),name:h(),optional:Ee().optional().default(!1),secret:Ee().optional().default(!0)}),xC=f({_meta:_(h(),S()).nullish(),description:h().nullish(),id:h(),name:h()}),$C=f({_meta:_(h(),S()).nullish(),description:h().nullish(),id:h(),link:h().nullish(),name:h(),vars:D(EC)}),AC=f({_meta:_(h(),S()).nullish(),args:D(h()).optional(),description:h().nullish(),env:_(h(),h()).optional(),id:h(),name:h()}),TC=B([$C.and(f({type:$("env_var")})),AC.and(f({type:$("terminal")})),xC]),CC=f({_meta:_(h(),S()).nullish(),methodId:h()}),IC=f({_meta:_(h(),S()).nullish()}),PC=f({_meta:_(h(),S()).nullish(),blob:h(),mimeType:h().nullish(),uri:h()}),RC=f({default:Ee().nullish(),description:h().nullish(),title:h().nullish()}),DC=f({_meta:_(h(),S()).nullish()}),OC=f({_meta:_(h(),S()).nullish()}),zC=f({amount:F(),currency:h()}),MC=f({_meta:_(h(),S()).nullish(),terminalId:h()}),LC=f({_meta:_(h(),S()).nullish(),newText:h(),oldText:h().nullish(),path:h()}),NC=B([h(),F(),F(),Ee(),D(h())]),UC=f({content:_(h(),NC).nullish()}),FC=B([UC.and(f({action:$("accept")})),f({action:$("decline")}),f({action:$("cancel")})]),ZC=f({_meta:_(h(),S()).nullish()}),Nm=h(),HC=f({_meta:_(h(),S()).nullish(),elicitationId:Nm}),BC=f({_meta:_(h(),S()).nullish(),action:FC}),jC=$("object"),VC=$("string"),WC=f({_meta:_(h(),S()).nullish()}),GC=f({_meta:_(h(),S()).nullish(),form:ZC.nullish(),url:WC.nullish()}),qC=f({elicitationId:Nm,url:h().url()}),Um=f({const:h(),title:h()}),Fm=f({_meta:_(h(),S()).nullish(),name:h(),value:h()}),YC=B([$(-32700),$(-32600),$(-32601),$(-32602),$(-32603),$(-32800),$(-32e3),$(-32002),$(-32042),F().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),Zm=f({code:YC,data:S().optional(),message:h()}),Hm=S(),Bm=S(),jm=S(),KC=f({_meta:_(h(),S()).nullish(),readTextFile:Ee().optional().default(!1),writeTextFile:Ee().optional().default(!1)}),Vm=f({_meta:_(h(),S()).nullish(),name:h(),value:h()}),Wm=f({_meta:_(h(),S()).nullish(),name:h(),title:h().nullish(),version:h()}),JC=f({default:F().nullish(),description:h().nullish(),maximum:F().nullish(),minimum:F().nullish(),title:h().nullish()}),XC=f({_meta:_(h(),S()).nullish()}),QC=f({_meta:_(h(),S()).nullish(),additionalDirectories:D(h()).optional(),cursor:h().nullish(),cwd:h().nullish()}),eI=f({_meta:_(h(),S()).nullish()}),tI=f({_meta:_(h(),S()).nullish(),logout:eI.nullish()}),nI=f({_meta:_(h(),S()).nullish()}),rI=f({_meta:_(h(),S()).nullish()}),iI=f({_meta:_(h(),S()).nullish(),http:Ee().optional().default(!1),sse:Ee().optional().default(!1)}),sI=f({_meta:_(h(),S()).nullish(),headers:D(Vm),name:h(),url:h()}),oI=f({_meta:_(h(),S()).nullish(),headers:D(Vm),name:h(),url:h()}),aI=f({_meta:_(h(),S()).nullish(),args:D(h()),command:h(),env:D(Fm),name:h()}),Ka=B([sI.and(f({type:$("http")})),oI.and(f({type:$("sse")})),aI]),Yu=h(),lI=f({_meta:_(h(),S()).nullish(),description:h().nullish(),modelId:Yu,name:h()}),cI=B([$("error"),$("warning"),$("information"),$("hint")]),uI=f({_meta:_(h(),S()).nullish()}),hI=f({_meta:_(h(),S()).nullish()}),dI=f({_meta:_(h(),S()).nullish()}),pI=f({_meta:_(h(),S()).nullish()}),fI=f({_meta:_(h(),S()).nullish()}),gI=f({_meta:_(h(),S()).nullish(),maxCount:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),mI=f({diff:h(),uri:h()}),vI=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()}),yI=f({_meta:_(h(),S()).nullish()}),bI=f({_meta:_(h(),S()).nullish()}),wI=f({languageId:h(),text:h(),uri:h()}),SI=f({_meta:_(h(),S()).nullish(),maxCount:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),_I=B([$("rejected"),$("ignored"),$("replaced"),$("cancelled")]),kI=f({excerpts:D(vI),uri:h()}),EI=f({_meta:_(h(),S()).nullish()}),xI=f({_meta:_(h(),S()).nullish()}),$I=f({name:h(),owner:h(),remoteUrl:h()}),AI=f({_meta:_(h(),S()).nullish()}),TI=f({_meta:_(h(),S()).nullish(),jump:yI.nullish(),rename:xI.nullish(),searchAndReplace:AI.nullish()}),CI=f({id:h(),isRegex:Ee().nullish(),replace:h(),search:h(),uri:h()}),II=B([$("automatic"),$("diagnostic"),$("manual")]),PI=f({_meta:_(h(),S()).nullish(),maxCount:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),RI=f({_meta:_(h(),S()).nullish(),diagnostics:uI.nullish(),editHistory:gI.nullish(),openFiles:bI.nullish(),recentFiles:SI.nullish(),relatedSnippets:EI.nullish(),userActions:PI.nullish()}),DI=f({_meta:_(h(),S()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ka)}),OI=f({default:F().nullish(),description:h().nullish(),maximum:F().nullish(),minimum:F().nullish(),title:h().nullish()}),Gm=h(),zI=B([$("allow_once"),$("allow_always"),$("reject_once"),$("reject_always")]),MI=f({_meta:_(h(),S()).nullish(),kind:zI,name:h(),optionId:Gm}),LI=B([$("high"),$("medium"),$("low")]),NI=B([$("pending"),$("in_progress"),$("completed")]),UI=f({_meta:_(h(),S()).nullish(),content:h(),priority:LI,status:NI}),FI=f({_meta:_(h(),S()).nullish(),entries:D(UI)}),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"})}),ZI=f({id:h(),position:vn,uri:h()}),HI=f({id:h(),newName:h(),position:vn,uri:h()}),BI=f({action:h(),position:vn,timestampMs:F(),uri:h()}),qm=B([$("utf-16"),$("utf-32"),$("utf-8")]),jI=f({_meta:_(h(),S()).nullish(),auth:kC.optional().default({terminal:!1}),elicitation:GC.nullish(),fs:KC.optional().default({readTextFile:!1,writeTextFile:!1}),nes:TI.nullish(),positionEncodings:D(qm).optional(),terminal:Ee().optional().default(!1)}),VI=f({_meta:_(h(),S()).nullish(),audio:Ee().optional().default(!1),embeddedContext:Ee().optional().default(!1),image:Ee().optional().default(!1)}),Ym=F().int().gte(0).lte(65535),WI=f({_meta:_(h(),S()).nullish(),clientCapabilities:jI.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Wm.nullish(),protocolVersion:Ym}),wi=f({end:vn,start:vn}),GI=f({message:h(),range:wi,severity:cI,uri:h()}),qI=f({languageId:h(),lastFocusedMs:F().nullish(),uri:h(),visibleRange:wi.nullish()}),YI=f({_meta:_(h(),S()).nullish(),diagnostics:D(GI).nullish(),editHistory:D(mI).nullish(),openFiles:D(qI).nullish(),recentFiles:D(wI).nullish(),relatedSnippets:D(kI).nullish(),userActions:D(BI).nullish()}),KI=f({newText:h(),range:wi}),JI=f({cursorPosition:vn.nullish(),edits:D(KI),id:h(),uri:h()}),XI=B([JI.and(f({kind:$("edit")})),ZI.and(f({kind:$("jump")})),HI.and(f({kind:$("rename")})),CI.and(f({kind:$("searchAndReplace")}))]),QI=f({_meta:_(h(),S()).nullish(),content:h()}),eP=f({_meta:_(h(),S()).nullish()}),cr=B([F(),h()]).nullable();f({_meta:_(h(),S()).nullish(),requestId:cr});const tP=pa(["assistant","user"]),so=f({_meta:_(h(),S()).nullish(),audience:D(tP).nullish(),lastModified:h().nullish(),priority:F().nullish()}),nP=f({_meta:_(h(),S()).nullish(),annotations:so.nullish(),data:h(),mimeType:h()}),rP=f({_meta:_(h(),S()).nullish(),annotations:so.nullish(),data:h(),mimeType:h(),uri:h().nullish()}),iP=f({_meta:_(h(),S()).nullish(),annotations:so.nullish(),description:h().nullish(),mimeType:h().nullish(),name:h(),size:F().nullish(),title:h().nullish(),uri:h()}),sP=f({_meta:_(h(),S()).nullish(),optionId:Gm}),oP=B([f({outcome:$("cancelled")}),sP.and(f({outcome:$("selected")}))]),aP=f({_meta:_(h(),S()).nullish(),outcome:oP}),lP=f({_meta:_(h(),S()).nullish()}),cP=f({_meta:_(h(),S()).nullish()}),uP=f({currentValue:Ee()}),hP=h(),Km=h(),dP=B([$("mode"),$("model"),$("thought_level"),h()]),Ku=h(),Jm=f({_meta:_(h(),S()).nullish(),description:h().nullish(),name:h(),value:Ku}),pP=f({_meta:_(h(),S()).nullish(),group:hP,name:h(),options:D(Jm)}),fP=B([D(Jm),D(pP)]),gP=f({currentValue:Ku,options:fP}),Si=Ya(B([gP.and(f({type:$("select")})),uP.and(f({type:$("boolean")}))]),f({_meta:_(h(),S()).nullish(),category:dP.nullish(),description:h().nullish(),id:Km,name:h()})),mP=f({_meta:_(h(),S()).nullish(),configOptions:D(Si)}),vP=f({_meta:_(h(),S()).nullish()}),K=h(),yP=f({_meta:_(h(),S()).nullish(),id:h(),sessionId:K}),bP=f({_meta:_(h(),S()).nullish(),sessionId:K}),wP=f({_meta:_(h(),S()).nullish(),sessionId:K}),SP=f({_meta:_(h(),S()).nullish(),sessionId:K}),Xm=f({_meta:_(h(),S()).nullish(),args:D(h()).optional(),command:h(),cwd:h().nullish(),env:D(Fm).optional(),outputByteLimit:F().nullish(),sessionId:K}),_P=f({_meta:_(h(),S()).nullish(),sessionId:K,uri:h()}),kP=f({_meta:_(h(),S()).nullish(),position:vn,sessionId:K,uri:h(),version:F(),visibleRange:wi}),EP=f({_meta:_(h(),S()).nullish(),languageId:h(),sessionId:K,text:h(),uri:h(),version:F()}),xP=f({_meta:_(h(),S()).nullish(),sessionId:K,uri:h()}),$P=f({_meta:_(h(),S()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ka).optional(),sessionId:K}),Qm=f({_meta:_(h(),S()).nullish(),sessionId:K,terminalId:h()}),AP=f({_meta:_(h(),S()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ka),sessionId:K}),ev=f({_meta:_(h(),S()).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}),TP=f({_meta:_(h(),S()).nullish(),id:h(),reason:_I.nullish(),sessionId:K}),tv=f({_meta:_(h(),S()).nullish(),sessionId:K,terminalId:h()}),CP=f({_meta:_(h(),S()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ka).optional(),sessionId:K}),IP=f({_meta:_(h(),S()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),sessionId:K,title:h().nullish(),updatedAt:h().nullish()}),PP=f({_meta:_(h(),S()).nullish(),nextCursor:h().nullish(),sessions:D(IP)}),RP=f({_meta:_(h(),S()).nullish(),title:h().nullish(),updatedAt:h().nullish()}),DP=f({_meta:_(h(),S()).nullish()}),Ja=h(),OP=f({_meta:_(h(),S()).nullish(),currentModeId:Ja}),zP=f({_meta:_(h(),S()).nullish(),description:h().nullish(),id:Ja,name:h()}),Xa=f({_meta:_(h(),S()).nullish(),availableModes:D(zP),currentModeId:Ja}),Qa=f({_meta:_(h(),S()).nullish(),availableModels:D(lI),currentModelId:Yu}),MP=f({_meta:_(h(),S()).nullish(),configOptions:D(Si).nullish(),models:Qa.nullish(),modes:Xa.nullish(),sessionId:K}),LP=f({_meta:_(h(),S()).nullish(),configOptions:D(Si).nullish(),models:Qa.nullish(),modes:Xa.nullish()}),NP=f({_meta:_(h(),S()).nullish(),configOptions:D(Si).nullish(),models:Qa.nullish(),modes:Xa.nullish(),sessionId:K}),UP=f({_meta:_(h(),S()).nullish(),configOptions:D(Si).nullish(),models:Qa.nullish(),modes:Xa.nullish()}),FP=f({_meta:_(h(),S()).nullish()}),ZP=f({_meta:_(h(),S()).nullish(),additionalDirectories:lP.nullish(),close:cP.nullish(),fork:vP.nullish(),list:DP.nullish(),resume:FP.nullish()}),HP=Ya(B([f({type:$("boolean"),value:Ee()}),f({value:Ku})]),f({_meta:_(h(),S()).nullish(),configId:Km,sessionId:K})),BP=f({_meta:_(h(),S()).nullish(),configOptions:D(Si)}),jP=f({_meta:_(h(),S()).nullish(),modeId:Ja,sessionId:K}),VP=f({_meta:_(h(),S()).nullish()}),WP=f({_meta:_(h(),S()).nullish(),modelId:Yu,sessionId:K}),GP=f({_meta:_(h(),S()).nullish()}),qP=f({_meta:_(h(),S()).nullish(),sessionId:K}),YP=B([$("end_turn"),$("max_tokens"),$("max_turn_requests"),$("refusal"),$("cancelled")]),KP=B([$("email"),$("uri"),$("date"),$("date-time")]),JP=f({default:h().nullish(),description:h().nullish(),enum:D(h()).nullish(),format:KP.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(Um).nullish(),pattern:h().nullish(),title:h().nullish()}),XP=f({_meta:_(h(),S()).nullish(),context:YI.nullish(),position:vn,selection:wi.nullish(),sessionId:K,triggerKind:II,uri:h(),version:F()}),QP=f({_meta:_(h(),S()).nullish(),suggestions:D(XI)}),eR=f({_meta:_(h(),S()).nullish(),terminalId:h()}),tR=f({_meta:_(h(),S()).nullish(),exitCode:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),nv=f({_meta:_(h(),S()).nullish(),sessionId:K,terminalId:h()}),nR=f({_meta:_(h(),S()).nullish(),exitStatus:tR.nullish(),output:h(),truncated:Ee()}),rR=f({_meta:_(h(),S()).nullish(),annotations:so.nullish(),text:h()}),iR=f({range:wi.nullish(),text:h()}),sR=f({_meta:_(h(),S()).nullish(),contentChanges:D(iR),sessionId:K,uri:h(),version:F()});f({method:h(),params:B([bP,EP,sR,_P,xP,kP,yP,TP,Hm]).nullish()});const oR=B([$("full"),$("incremental")]),aR=f({_meta:_(h(),S()).nullish(),syncKind:oR}),lR=f({_meta:_(h(),S()).nullish(),didChange:aR.nullish(),didClose:hI.nullish(),didFocus:dI.nullish(),didOpen:pI.nullish(),didSave:fI.nullish()}),cR=f({_meta:_(h(),S()).nullish(),document:lR.nullish()}),uR=f({_meta:_(h(),S()).nullish(),context:RI.nullish(),events:cR.nullish()}),hR=f({_meta:_(h(),S()).nullish(),auth:tI.optional().default({}),loadSession:Ee().optional().default(!1),mcpCapabilities:iI.optional().default({http:!1,sse:!1}),nes:uR.nullish(),positionEncoding:qm.nullish(),promptCapabilities:VI.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:ZP.optional().default({})}),dR=f({_meta:_(h(),S()).nullish(),agentCapabilities:hR.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Wm.nullish(),authMethods:D(TC).optional().default([]),protocolVersion:Ym}),pR=f({_meta:_(h(),S()).nullish(),mimeType:h().nullish(),text:h(),uri:h()}),fR=B([pR,PC]),gR=f({_meta:_(h(),S()).nullish(),annotations:so.nullish(),resource:fR}),Ju=B([rR.and(f({type:$("text")})),rP.and(f({type:$("image")})),nP.and(f({type:$("audio")})),iP.and(f({type:$("resource_link")})),gR.and(f({type:$("resource")}))]),mR=f({_meta:_(h(),S()).nullish(),content:Ju}),Vl=f({_meta:_(h(),S()).nullish(),content:Ju,messageId:h().nullish()}),vR=f({_meta:_(h(),S()).nullish(),messageId:h().nullish(),prompt:D(Ju),sessionId:K}),yR=f({anyOf:D(Um)}),rv=B([mR.and(f({type:$("content")})),LC.and(f({type:$("diff")})),eR.and(f({type:$("terminal")}))]),iv=h(),sv=f({_meta:_(h(),S()).nullish(),line:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h()}),ov=B([$("pending"),$("in_progress"),$("completed"),$("failed")]),av=B([$("read"),$("edit"),$("delete"),$("move"),$("search"),$("execute"),$("think"),$("fetch"),$("switch_mode"),$("other")]),bR=f({_meta:_(h(),S()).nullish(),content:D(rv).optional(),kind:av.optional(),locations:D(sv).optional(),rawInput:S().optional(),rawOutput:S().optional(),status:ov.optional(),title:h(),toolCallId:iv}),lv=f({_meta:_(h(),S()).nullish(),content:D(rv).nullish(),kind:av.nullish(),locations:D(sv).nullish(),rawInput:S().optional(),rawOutput:S().optional(),status:ov.nullish(),title:h().nullish(),toolCallId:iv}),cv=f({_meta:_(h(),S()).nullish(),options:D(MI),sessionId:K,toolCall:lv}),wR=f({_meta:_(h(),S()).nullish(),hint:h()}),SR=wR,_R=f({_meta:_(h(),S()).nullish(),description:h(),input:SR.nullish(),name:h()}),kR=f({_meta:_(h(),S()).nullish(),availableCommands:D(_R)}),ER=f({enum:D(h()),type:VC}),xR=B([ER,yR]),$R=f({default:D(h()).nullish(),description:h().nullish(),items:xR,maxItems:F().nullish(),minItems:F().nullish(),title:h().nullish()}),AR=B([JP.and(f({type:$("string")})),OI.and(f({type:$("number")})),JC.and(f({type:$("integer")})),RC.and(f({type:$("boolean")})),$R.and(f({type:$("array")}))]),TR=f({description:h().nullish(),properties:_(h(),AR).optional().default({}),required:D(h()).nullish(),title:h().nullish(),type:jC.optional().default("object")}),CR=f({requestedSchema:TR}),IR=Ya(B([CR.and(f({mode:$("form")})),qC.and(f({mode:$("url")}))]),f({_meta:_(h(),S()).nullish(),message:h(),sessionId:K})),PR=f({cachedReadTokens:F().nullish(),cachedWriteTokens:F().nullish(),inputTokens:F(),outputTokens:F(),thoughtTokens:F().nullish(),totalTokens:F()}),RR=f({_meta:_(h(),S()).nullish(),stopReason:YP,usage:PR.nullish(),userMessageId:h().nullish()});B([f({id:cr,result:B([dR,IC,rI,NP,LP,PP,MP,UP,OC,VP,BP,RR,GP,qP,QP,DC,jm])}),f({error:Zm,id:cr})]);const DR=f({_meta:_(h(),S()).nullish(),cost:zC.nullish(),size:F(),used:F()}),OR=B([Vl.and(f({sessionUpdate:$("user_message_chunk")})),Vl.and(f({sessionUpdate:$("agent_message_chunk")})),Vl.and(f({sessionUpdate:$("agent_thought_chunk")})),bR.and(f({sessionUpdate:$("tool_call")})),lv.and(f({sessionUpdate:$("tool_call_update")})),FI.and(f({sessionUpdate:$("plan")})),kR.and(f({sessionUpdate:$("available_commands_update")})),OP.and(f({sessionUpdate:$("current_mode_update")})),mP.and(f({sessionUpdate:$("config_option_update")})),RP.and(f({sessionUpdate:$("session_info_update")})),DR.and(f({sessionUpdate:$("usage_update")}))]),uv=f({_meta:_(h(),S()).nullish(),sessionId:K,update:OR});f({method:h(),params:B([uv,HC,Hm]).nullish()});const hv=f({_meta:_(h(),S()).nullish(),sessionId:K,terminalId:h()}),zR=f({_meta:_(h(),S()).nullish(),exitCode:F().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),MR=f({name:h(),uri:h()}),LR=f({_meta:_(h(),S()).nullish(),repository:$I.nullish(),workspaceFolders:D(MR).nullish(),workspaceUri:h().nullish()});f({id:cr,method:h(),params:B([WI,CC,nI,DI,AP,QC,$P,CP,SP,jP,HP,vR,WP,LR,XP,wP,Bm]).nullish()});const dv=f({_meta:_(h(),S()).nullish(),content:h(),path:h(),sessionId:K});f({id:cr,method:h(),params:B([dv,ev,cv,Xm,nv,tv,hv,Qm,IR,Bm]).nullish()});const NR=f({_meta:_(h(),S()).nullish()});B([f({id:cr,result:B([NR,QI,aP,MC,nR,eP,zR,XC,BC,jm])}),f({error:Zm,id:cr})]);var Y;class UR{constructor(e,n){w(this,Y);const r=e(this),i=async(o,a)=>{var l,u,d,p,y,v,A;switch(o){case zt.fs_write_text_file:{const E=dv.parse(a);return(l=r.writeTextFile)==null?void 0:l.call(r,E)}case zt.fs_read_text_file:{const E=ev.parse(a);return(u=r.readTextFile)==null?void 0:u.call(r,E)}case zt.session_request_permission:{const E=cv.parse(a);return r.requestPermission(E)}case zt.terminal_create:{const E=Xm.parse(a);return(d=r.createTerminal)==null?void 0:d.call(r,E)}case zt.terminal_output:{const E=nv.parse(a);return(p=r.terminalOutput)==null?void 0:p.call(r,E)}case zt.terminal_release:{const E=tv.parse(a);return await((y=r.releaseTerminal)==null?void 0:y.call(r,E))??{}}case zt.terminal_wait_for_exit:{const E=hv.parse(a);return(v=r.waitForTerminalExit)==null?void 0:v.call(r,E)}case zt.terminal_kill:{const E=Qm.parse(a);return await((A=r.killTerminal)==null?void 0:A.call(r,E))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw we.methodNotFound(o)}},s=async(o,a)=>{switch(o){case zt.session_update:{const l=uv.parse(a);return r.sessionUpdate(l)}default:if(r.extNotification)return r.extNotification(o,a);throw we.methodNotFound(o)}};k(this,Y,new FR(i,s,n))}async initialize(e){return await c(this,Y).sendRequest(oe.initialize,e)}async newSession(e){return await c(this,Y).sendRequest(oe.session_new,e)}async loadSession(e){return await c(this,Y).sendRequest(oe.session_load,e)??{}}async unstable_forkSession(e){return await c(this,Y).sendRequest(oe.session_fork,e)}async listSessions(e){return await c(this,Y).sendRequest(oe.session_list,e)}async unstable_resumeSession(e){return await c(this,Y).sendRequest(oe.session_resume,e)}async unstable_closeSession(e){return await c(this,Y).sendRequest(oe.session_close,e)}async setSessionMode(e){return await c(this,Y).sendRequest(oe.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await c(this,Y).sendRequest(oe.session_set_model,e)??{}}async setSessionConfigOption(e){return await c(this,Y).sendRequest(oe.session_set_config_option,e)}async authenticate(e){return await c(this,Y).sendRequest(oe.authenticate,e)??{}}async unstable_logout(e){return await c(this,Y).sendRequest(oe.logout,e)??{}}async prompt(e){return await c(this,Y).sendRequest(oe.session_prompt,e)}async cancel(e){return await c(this,Y).sendNotification(oe.session_cancel,e)}async unstable_startNes(e){return await c(this,Y).sendRequest(oe.nes_start,e)}async unstable_suggestNes(e){return await c(this,Y).sendRequest(oe.nes_suggest,e)}async unstable_closeNes(e){return await c(this,Y).sendRequest(oe.nes_close,e)??{}}async unstable_didOpenDocument(e){return await c(this,Y).sendNotification(oe.document_did_open,e)}async unstable_didChangeDocument(e){return await c(this,Y).sendNotification(oe.document_did_change,e)}async unstable_didCloseDocument(e){return await c(this,Y).sendNotification(oe.document_did_close,e)}async unstable_didSaveDocument(e){return await c(this,Y).sendNotification(oe.document_did_save,e)}async unstable_didFocusDocument(e){return await c(this,Y).sendNotification(oe.document_did_focus,e)}async unstable_acceptNes(e){return await c(this,Y).sendNotification(oe.nes_accept,e)}async unstable_rejectNes(e){return await c(this,Y).sendNotification(oe.nes_reject,e)}async extMethod(e,n){return await c(this,Y).sendRequest(e,n)}async extNotification(e,n){return await c(this,Y).sendNotification(e,n)}get signal(){return c(this,Y).signal}get closed(){return c(this,Y).closed}}Y=new WeakMap;var on,_a,fs,gs,Zr,Hr,$t,ms,he,pv,Cc,fv,gv,mv,vv,Ic,Hi;class FR{constructor(e,n,r){w(this,he);w(this,on,new Map);w(this,_a,0);w(this,fs);w(this,gs);w(this,Zr);w(this,Hr,Promise.resolve());w(this,$t,new AbortController);w(this,ms);k(this,fs,e),k(this,gs,n),k(this,Zr,r),k(this,ms,new Promise(i=>{c(this,$t).signal.addEventListener("abort",()=>i())})),g(this,he,pv).call(this)}get signal(){return c(this,$t).signal}get closed(){return c(this,ms)}async sendRequest(e,n){g(this,he,Ic).call(this);const r=Zh(this,_a)._++,i=new Promise((s,o)=>{c(this,on).set(r,{resolve:s,reject:o})});return await g(this,he,Hi).call(this,{jsonrpc:"2.0",id:r,method:e,params:n}),i}async sendNotification(e,n){g(this,he,Ic).call(this),await g(this,he,Hi).call(this,{jsonrpc:"2.0",method:e,params:n})}}on=new WeakMap,_a=new WeakMap,fs=new WeakMap,gs=new WeakMap,Zr=new WeakMap,Hr=new WeakMap,$t=new WeakMap,ms=new WeakMap,he=new WeakSet,pv=async function(){let e;try{const n=c(this,Zr).readable.getReader();try{for(;!c(this,$t).signal.aborted;){const{value:r,done:i}=await n.read();if(i)break;if(r)try{g(this,he,fv).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&g(this,he,Hi).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{n.releaseLock()}}catch(n){e=n}finally{g(this,he,Cc).call(this,e)}},Cc=function(e){if(c(this,$t).signal.aborted)return;const n=e??new Error("ACP connection closed");for(const r of c(this,on).values())r.reject(n);c(this,on).clear(),c(this,$t).abort(n)},fv=async function(e){if("method"in e&&"id"in e){const n=await g(this,he,gv).call(this,e.method,e.params);"error"in n&&console.error("Error handling request",e,n.error),await g(this,he,Hi).call(this,{jsonrpc:"2.0",id:e.id,...n})}else if("method"in e){const n=await g(this,he,mv).call(this,e.method,e.params);"error"in n&&console.error("Error handling notification",e,n.error)}else"id"in e?g(this,he,vv).call(this,e):console.error("Invalid message",{message:e})},gv=async function(e,n){try{return{result:await c(this,fs).call(this,e,n)??null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof Rp)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()}}},mv=async function(e,n){try{return await c(this,gs).call(this,e,n),{result:null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof Rp)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()}}},vv=function(e){const n=c(this,on).get(e.id);if(n){if("result"in e)n.resolve(e.result);else if("error"in e){const{code:r,message:i,data:s}=e.error;n.reject(new we(r,i,s))}c(this,on).delete(e.id)}else console.error("Got response to unknown request",e.id)},Ic=function(){if(c(this,$t).signal.aborted)throw c(this,$t).signal.reason??new Error("ACP connection closed")},Hi=async function(e){return k(this,Hr,c(this,Hr).then(async()=>{const n=c(this,Zr).writable.getWriter();try{await n.write(e)}finally{n.releaseLock()}}).catch(n=>{g(this,he,Cc).call(this,n)})),c(this,Hr)};class we extends Error{constructor(n,r,i){super(r);b(this,"code");b(this,"data");this.code=n,this.name="RequestError",this.data=i}static parseError(n,r){return new we(-32700,`Parse error${r?`: ${r}`:""}`,n)}static invalidRequest(n,r){return new we(-32600,`Invalid request${r?`: ${r}`:""}`,n)}static methodNotFound(n){return new we(-32601,`"Method not found": ${n}`,{method:n})}static invalidParams(n,r){return new we(-32602,`Invalid params${r?`: ${r}`:""}`,n)}static internalError(n,r){return new we(-32603,`Internal error${r?`: ${r}`:""}`,n)}static authRequired(n,r){return new we(-32e3,`Authentication required${r?`: ${r}`:""}`,n)}static resourceNotFound(n){return new we(-32002,`Resource not found${n?`: ${n}`:""}`,n&&{uri:n})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const ZR=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,HR=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,BR=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,jR=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,VR="single_session",WR={name:"television-acp-client",version:"0.0.0"},yv="agent:main:television",GR=yi(mt);var te,Ut,Br,Ft,Vn,Wn,Gn,qn,an,jr,At,ct,ln,Yn,Zt,cn,vs,Ht,ut,ka,Bt,C,bv,wv,Pc,Sv,_v,kv,Ev,xv,$v,Av,In,Ir,Pr,Ze,Tv,Rr,Rc,Dc,qo,Cv,Iv,ys,bs,Oc,Dr,Pv,Rv;class qR extends GR{constructor(n){super();w(this,C);w(this,te,KR());w(this,Ut,null);w(this,Br,null);w(this,Ft,null);w(this,Vn,null);w(this,Wn,null);w(this,Gn,null);w(this,qn);w(this,an,null);w(this,jr,1);w(this,At,null);w(this,ct,null);w(this,ln,!1);w(this,Yn,!1);w(this,Zt,null);w(this,cn,new Set);w(this,vs);w(this,Ht);w(this,ut);w(this,ka,n=>{g(this,C,wv).call(this,n)});w(this,Bt,null);w(this,ys,()=>{g(this,C,Dr).call(this,"ACP bridge websocket closed")});w(this,bs,()=>{g(this,C,Dr).call(this,"ACP bridge websocket error")});k(this,Ht,n),k(this,ut,n.sessionMode??VR),k(this,qn,n.mappedSessionStore??YR()),k(this,vs,n.createSocket??(r=>new WebSocket(r)))}getState(){return c(this,te)}get messages(){return c(this,te).messageOrder.map(n=>c(this,te).messagesById[n]).filter(n=>n!==void 0)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(c(this,te).lifecycle.status!=="ready"){g(this,C,Ze).call(this,{lifecycle:{status:"connecting"}}),c(this,Br)??k(this,Br,g(this,C,bv).call(this));try{await c(this,Br),await g(this,C,Pc).call(this)}catch(n){throw g(this,C,Dr).call(this,Co(n)),n}}}dispose(){g(this,C,Oc).call(this),g(this,C,Ze).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null})}async sendMessage(n){if(await this.connect(),c(this,te).lifecycle.status!=="ready"||c(this,te).run.status==="running"||c(this,te).run.status==="cancelling")throw new Error("ACPClient is not ready to send a new message");const r=n.text.trim();if(!r)throw new Error("Cannot send an empty message");g(this,C,Ir).call(this,{id:g(this,C,Rr).call(this,"user"),kind:"user",text:r,status:"final"}),g(this,C,Ze).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,Dc).call(this),prompt:[{type:"text",text:g(this,C,Tv).call(this,r)}]});g(this,C,In).call(this,i.stopReason==="cancelled"?"cancelled":"final"),g(this,C,Ze).call(this,{run:{status:i.stopReason==="cancelled"?"cancelled":"completed",stopReason:i.stopReason,canCancel:!1,error:null}})}catch(i){throw g(this,C,Rv).call(this)||(g(this,C,In).call(this,"error"),g(this,C,Ze).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:Co(i)}})),i}}async cancel(){if(await this.connect(),!c(this,te).run.canCancel||c(this,te).run.status!=="running")throw new Error("No active cancellable run");g(this,C,Ze).call(this,{run:{...c(this,te).run,status:"cancelling"}}),await g(this,C,qo).call(this).cancel({sessionId:g(this,C,Dc).call(this)})}setScreenContext(n){var s,o,a;const r={screenID:n.screenID,screenName:n.screenName};if(((s=c(this,ct))==null?void 0:s.screenID)===r.screenID&&((o=c(this,ct))==null?void 0:o.screenName)===r.screenName)return;const i=((a=c(this,ct))==null?void 0:a.screenID)??null;if(k(this,ct,r),c(this,ut)==="single_session"){(!c(this,an)||i!==r.screenID)&&k(this,ln,!0);return}c(this,an)!==Np(c(this,ut),r.screenID,c(this,Ht).clientGUID??"default-client")&&(k(this,Ft,null),k(this,Vn,null),c(this,Ut)&&c(this,te).run.status==="idle"&&g(this,C,Pc).call(this).catch(l=>{g(this,C,Dr).call(this,Co(l))}))}}te=new WeakMap,Ut=new WeakMap,Br=new WeakMap,Ft=new WeakMap,Vn=new WeakMap,Wn=new WeakMap,Gn=new WeakMap,qn=new WeakMap,an=new WeakMap,jr=new WeakMap,At=new WeakMap,ct=new WeakMap,ln=new WeakMap,Yn=new WeakMap,Zt=new WeakMap,cn=new WeakMap,vs=new WeakMap,Ht=new WeakMap,ut=new WeakMap,ka=new WeakMap,Bt=new WeakMap,C=new WeakSet,bv=async function(){try{g(this,C,Ze).call(this,{lifecycle:{status:"connecting"}});const{stream:n,socket:r,metadata:i}=await QR({serverURL:c(this,Ht).serverURL,token:c(this,Ht).token,createSocket:c(this,vs),onDisconnect:c(this,ka)});k(this,Gn,i),g(this,C,Ze).call(this,{bridge:i}),k(this,Bt,r),r.addEventListener("close",c(this,ys)),r.addEventListener("error",c(this,bs)),k(this,Ut,new UR(s=>({connection:s,sessionUpdate:async o=>{await g(this,C,_v).call(this,o)},requestPermission:async o=>g(this,C,kv).call(this,o)}),n)),await c(this,Ut).initialize({protocolVersion:_C,clientCapabilities:{},clientInfo:WR})}catch(n){throw n}},wv=function(n){g(this,C,Dr).call(this,Co(n))},Pc=async function(){const n=g(this,C,Iv).call(this);if(c(this,Ft)&&c(this,Vn)===n){await c(this,Ft);return}k(this,Vn,n),k(this,Ft,g(this,C,Sv).call(this,n)),await c(this,Ft)},Sv=async function(n){var a;const r=g(this,C,qo).call(this);g(this,C,Pv).call(this);let i,s=!1;const o={cwd:g(this,C,Cv).call(this),mcpServers:[],_meta:{sessionKey:n}};try{if(k(this,Yn,!0),k(this,Zt,null),((a=c(this,Gn))==null?void 0:a.sessionIdStrategy)==="mapped"){const l=c(this,qn).getActualSessionId(n);if(l)try{const u=await r.loadSession({...o,sessionId:l});if(JR(u))throw new Error("Mapped ACP session was not found");i=l,s=!0}catch{i=(await r.newSession(o)).sessionId,c(this,qn).setActualSessionId(n,i),s=!1}else i=(await r.newSession(o)).sessionId,c(this,qn).setActualSessionId(n,i),s=!1}else try{await r.loadSession({...o,sessionId:n}),i=n,s=c(this,te).messageOrder.length>0}catch{i=(await r.newSession(o)).sessionId,s=!1}}finally{k(this,Yn,!1),k(this,Zt,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,n),s?(c(this,cn).add(n),c(this,ut)==="single_session"&&k(this,ln,!1)):(c(this,cn).delete(n),k(this,ln,c(this,ut)==="single_session")),g(this,C,Ze).call(this,{lifecycle:{status:"ready"}})},_v=async function(n){const r=n.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&g(this,C,Av).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&g(this,C,Ev).call(this,r.content.text);return;case"tool_call":g(this,C,xv).call(this,r);return;case"tool_call_update":g(this,C,$v).call(this,r);return;case"agent_thought_chunk":return;default:return}},kv=async function(n){return{outcome:{outcome:"cancelled"}}},Ev=function(n){k(this,Zt,null);const r=XR(n);if(!r)return;if(!c(this,At)){const s={id:g(this,C,Rr).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};k(this,At,s.id),g(this,C,Ir).call(this,s);return}const i=c(this,te).messagesById[c(this,At)];if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");g(this,C,Pr).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},xv=function(n){g(this,C,In).call(this,"final");const r=g(this,C,Rc).call(this,n.toolCallId),i=Fp("content"in n?n.content:void 0),s={id:(r==null?void 0:r.id)??g(this,C,Rr).call(this,"tool"),kind:"tool_call",toolCallId:n.toolCallId,title:n.title,toolKind:n.kind??"other",status:n.status==="failed"?"failed":n.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??i,locations:n.locations??(r==null?void 0:r.locations)};if(r){g(this,C,Pr).call(this,s);return}g(this,C,Ir).call(this,s)},$v=function(n){const r=g(this,C,Rc).call(this,n.toolCallId),i=(r==null?void 0:r.text)??"",s=Fp(n.content),o=s?`${i}${s}`:i,a={id:(r==null?void 0:r.id)??g(this,C,Rr).call(this,"tool"),kind:"tool_call",toolCallId:n.toolCallId,title:(r==null?void 0:r.title)??n.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:n.status==="failed"?"failed":n.status==="completed"?"completed":"in_progress",text:o,locations:n.locations??(r==null?void 0:r.locations)};if(r){g(this,C,Pr).call(this,a);return}g(this,C,Ir).call(this,a)},Av=function(n){if(g(this,C,In).call(this,"final"),!n)return;const r=c(this,Yn)?c(this,Zt):null;if(!r){const s=Up(n);if(!s)return;const o={id:g(this,C,Rr).call(this,"user"),kind:"user",text:s,status:"final"};g(this,C,Ir).call(this,o),c(this,Yn)&&k(this,Zt,o.id);return}const i=c(this,te).messagesById[r];if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");g(this,C,Pr).call(this,{...i,text:Up(`${i.text}${n}`)})},In=function(n){if(!c(this,At))return;const r=c(this,te).messagesById[c(this,At)];(r==null?void 0:r.kind)==="assistant"&&g(this,C,Pr).call(this,{...r,status:n}),k(this,At,null)},Ir=function(n){g(this,C,Ze).call(this,{messagesById:{...c(this,te).messagesById,[n.id]:n},messageOrder:[...c(this,te).messageOrder,n.id]})},Pr=function(n){g(this,C,Ze).call(this,{messagesById:{...c(this,te).messagesById,[n.id]:n}})},Ze=function(n){const r={...c(this,te),...n};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"))},Tv=function(n){const r=c(this,an);return!c(this,ct)||!r||!(c(this,ut)==="single_session"?c(this,ln)||!c(this,cn).has(r):!c(this,cn).has(r))?n:(k(this,ln,!1),c(this,cn).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${c(this,ct).screenID}`,`screen_name: ${c(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]","",n].join(`
|
|
43
|
+
`))},Rr=function(n){const r=`${n}-${c(this,jr)}`;return k(this,jr,c(this,jr)+1),r},Rc=function(n){for(const r of c(this,te).messageOrder){const i=c(this,te).messagesById[r];if((i==null?void 0:i.kind)==="tool_call"&&i.toolCallId===n)return i}return null},Dc=function(){if(!c(this,Wn))throw new Error("ACP session is not ready");return c(this,Wn)},qo=function(){if(!c(this,Ut))throw new Error("ACP connection is not ready");return c(this,Ut)},Cv=function(){var r;const n=(r=c(this,Gn))==null?void 0:r.sessionCwd;if(!n)throw new Error("ACP bridge session cwd is not ready");return n},Iv=function(){var r;if(c(this,ut)==="single_session")return`${yv}-${(c(this,Ht).clientGUID??"default-client").toLowerCase()}`;const n=(r=c(this,ct))==null?void 0:r.screenID;if(!n)throw new Error("Screen context is required for per-screen session mode");return Np(c(this,ut),n,c(this,Ht).clientGUID??"default-client")},ys=new WeakMap,bs=new WeakMap,Oc=function(){k(this,Ut,null),k(this,Br,null),k(this,Ft,null),k(this,Vn,null),k(this,Wn,null),k(this,an,null),k(this,Gn,null),c(this,Bt)&&(c(this,Bt).removeEventListener("close",c(this,ys)),c(this,Bt).removeEventListener("error",c(this,bs)),c(this,Bt).close(),k(this,Bt,null))},Dr=function(n){this.disposed||c(this,te).lifecycle.status==="disconnected"||(g(this,C,In).call(this,"error"),g(this,C,Oc).call(this),g(this,C,Ze).call(this,{lifecycle:{status:"disconnected",...n?{error:n}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null}))},Pv=function(){k(this,At,null),k(this,Zt,null),k(this,jr,1),g(this,C,Ze).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},Rv=function(){return c(this,te).lifecycle.status==="disconnected"};function YR(){const t=new Map;return{getActualSessionId(e){return t.get(e)??null},setActualSessionId(e,n){t.set(e,n)},clearActualSessionId(e){t.delete(e)}}}function KR(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},bridge:null,messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function JR(t){return t==null?!0:typeof t=="object"&&Object.keys(t).length===0}function Np(t,e,n){return t==="single_session"?`${yv}-${n.toLowerCase()}`:`agent:main:television-${n.toLowerCase()}-${e.toLowerCase()}`}function Dv(t){return t.replace(/^(?:\s*\n)+/,"")}function Up(t){let e=t;return e=e.replace(ZR,""),e=e.replace(HR,""),e=e.replace(BR,""),e=Dv(e),e}function XR(t){let e=t;return e=e.replace(jR,""),e=Dv(e),e}function Fp(t){return!t||t.length===0?"":t.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function QR(t){const e=t.createSocket(nD(t.serverURL,t.token));let n=!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=tD(E);if(!I)return;let Z;try{Z=JSON.parse(I)}catch(P){const V=P instanceof Error?P:new Error(String(P));i(V),u.error(V);return}switch(Z.type){case"acp-bridge-status":if(Z.status==="ready"){let P;try{P=eD(Z)}catch(V){const O=V instanceof Error?V:new Error(String(V));n||i(O),u.error(O);return}n||(n=!0,r(P));return}if(Z.status==="error"||Z.status==="exited"){const P=new Error(Z.error??`ACP bridge ${Z.status}`);n||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");n||i(E),(I=t.onDisconnect)==null||I.call(t,E),u.close()},A=()=>{var I;if(d)return;d=!0;const E=new Error("ACP bridge websocket error");n||i(E),(I=t.onDisconnect)==null||I.call(t,E),u.error(E)};e.addEventListener("open",p),e.addEventListener("message",y),e.addEventListener("close",v),e.addEventListener("error",A)}}),a=new WritableStream({async write(u){await s,e.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){e.close()},abort(){e.close()}}),l=await s;return{stream:{readable:o,writable:a},socket:e,metadata:l}}function eD(t){const{agent:e,sessionIdStrategy:n,sessionCwd:r}=t;if((e==="openclaw"||e==="hermes")&&(n==="deterministic"||n==="mapped")&&typeof r=="string"&&r.length>0)return{agent:e,sessionIdStrategy:n,sessionCwd:r};throw new Error("ACP bridge ready status missing bootstrap metadata")}function tD(t){if(typeof t=="string")return t;if(t instanceof Uint8Array)return new TextDecoder().decode(t);if(typeof Buffer<"u"&&t instanceof Buffer)return t.toString("utf8");if(typeof t=="object"&&t!==null&&"data"in t){const e=t.data;if(typeof e=="string")return e;if(e instanceof Uint8Array)return new TextDecoder().decode(e);if(Array.isArray(e))return Buffer.concat(e).toString("utf8")}return null}function nD(t,e){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname="/acp",n.search="",n.searchParams.set("token",e),n.hash="",n.toString()}function Co(t){return t instanceof Error?t.message:String(t)}const Zp="television.acpClientGUID",Hp="television.acpMappedSessions",rD=yi(mt);class iD extends rD{constructor(n){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=n.screenManager,this.sessionMode=n.sessionMode??"single_session";const r=n.storage??aD();this.options={serverURL:n.serverURL,token:n.token,...n.createSocket?{createSocket:n.createSocket}:{},...n.sessionMode?{sessionMode:n.sessionMode}:{}},this.clientGUID=n.clientGUID??cD(lD(r)),this.mappedSessionStore=n.mappedSessionStore??(r?new oD(r,n.serverURL):new sD),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.syncActiveClient()}getActiveClient(){return this.activeClient}dispose(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged);for(const n of this.clients.values())n.dispose();this.clients.clear(),this.activeClient=null}syncActiveClient(){const n=this.screenManager.activeScreen,r=n?this.getClientForScreen(n):null;this.activeClient!==r&&(this.activeClient=r,this.dispatchEvent(new ee("change")))}getClientForScreen(n){const r=this.sessionMode==="single_session"?"single_session":n.id;let i=this.clients.get(r);return i||(i=new qR({...this.options,sessionMode:this.sessionMode,clientGUID:this.clientGUID,mappedSessionStore:this.mappedSessionStore}),this.clients.set(r,i)),i.setScreenContext({screenID:n.id,screenName:n.name}),i}}var Vr;class sD{constructor(){w(this,Vr,new Map)}getActualSessionId(e){return c(this,Vr).get(e)??null}setActualSessionId(e,n){c(this,Vr).set(e,n)}clearActualSessionId(e){c(this,Vr).delete(e)}}Vr=new WeakMap;const Bp=1;var Wr,ws,Xe,Yo,Ko,zc;class oD{constructor(e,n){w(this,Xe);w(this,Wr);w(this,ws);k(this,Wr,e),k(this,ws,n)}getActualSessionId(e){const n=g(this,Xe,Ko).call(this)[g(this,Xe,Yo).call(this,e)];return typeof n=="string"&&n.length>0?n:null}setActualSessionId(e,n){const r=g(this,Xe,Ko).call(this);r[g(this,Xe,Yo).call(this,e)]=n,g(this,Xe,zc).call(this,r)}clearActualSessionId(e){const n=g(this,Xe,Ko).call(this);delete n[g(this,Xe,Yo).call(this,e)],g(this,Xe,zc).call(this,n)}}Wr=new WeakMap,ws=new WeakMap,Xe=new WeakSet,Yo=function(e){return JSON.stringify([c(this,ws),e])},Ko=function(){const e=c(this,Wr).getItem(Hp);if(!e)return{};let n;try{n=JSON.parse(e)}catch{return{}}if(typeof n!="object"||n===null||Array.isArray(n))return{};const r=n;return r.version!==Bp?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},zc=function(e){const n={version:Bp,entries:e};c(this,Wr).setItem(Hp,JSON.stringify(n))};function aD(){return typeof window>"u"?null:window.localStorage}function lD(t){if(!t)throw new Error("ACPClientManager requires storage when clientGUID is not provided");return t}function cD(t){const e=t.getItem(Zp);if(e)return e;const n=Nu().toLowerCase();return t.setItem(Zp,n),n}var Ss;class uD extends mt{constructor(){super();w(this,Ss,n=>{const r=hD(n);r!==null&&(n.preventDefault(),this.dispatchEvent(new VE("shortcut-triggered",{shortcut:r})))});document.addEventListener("keydown",c(this,Ss))}dispose(){document.removeEventListener("keydown",c(this,Ss))}}Ss=new WeakMap;function hD(t){for(const[e,n]of Object.entries(Sx))if(dD(t,n.trigger))return e;return null}function dD(t,e){return!(t.key.toLowerCase()!==e.key.toLowerCase()||t.metaKey!==!!e.meta||t.ctrlKey!==!!e.ctrl||t.shiftKey!==!!e.shift||t.altKey!==!!e.alt)}const pD="serverURL",fD="token",gD="mode",mD="electron";function Ov(t=window.location.search,e=window.location.origin){const r=new URLSearchParams(t).get(pD);return r?new URL(r).origin:new URL(e).origin}function Mc(t=window.location.search){return new URLSearchParams(t).get(fD)}function zv(t=window.location.search){return new URLSearchParams(t).get(gD)===mD}/**
|
|
44
|
+
* @license
|
|
45
|
+
* Copyright 2017 Google LLC
|
|
46
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
+
*/const es=globalThis,jp=t=>t,fa=es.trustedTypes,Vp=fa?fa.createPolicy("lit-html",{createHTML:t=>t}):void 0,Mv="$lit$",tn=`lit$${Math.random().toFixed(9).slice(2)}$`,Lv="?"+tn,vD=`<${Lv}>`,ur=document,is=()=>ur.createComment(""),ss=t=>t===null||typeof t!="object"&&typeof t!="function",Xu=Array.isArray,yD=t=>Xu(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",Wl=`[
|
|
48
|
+
\f\r]`,Pi=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Wp=/-->/g,Gp=/>/g,Tn=RegExp(`>|${Wl}(?:([^\\s"'>=/]+)(${Wl}*=${Wl}*(?:[^
|
|
49
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),qp=/'/g,Yp=/"/g,Nv=/^(?:script|style|textarea|title)$/i,bD=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),U=bD(1),li=Symbol.for("lit-noChange"),ae=Symbol.for("lit-nothing"),Kp=new WeakMap,Nn=ur.createTreeWalker(ur,129);function Uv(t,e){if(!Xu(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Vp!==void 0?Vp.createHTML(e):e}const wD=(t,e)=>{const n=t.length-1,r=[];let i,s=e===2?"<svg>":e===3?"<math>":"",o=Pi;for(let a=0;a<n;a++){const l=t[a];let u,d,p=-1,y=0;for(;y<l.length&&(o.lastIndex=y,d=o.exec(l),d!==null);)y=o.lastIndex,o===Pi?d[1]==="!--"?o=Wp:d[1]!==void 0?o=Gp:d[2]!==void 0?(Nv.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=Tn):d[3]!==void 0&&(o=Tn):o===Tn?d[0]===">"?(o=i??Pi,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]==='"'?Yp:qp):o===Yp||o===qp?o=Tn:o===Wp||o===Gp?o=Pi:(o=Tn,i=void 0);const v=o===Tn&&t[a+1].startsWith("/>")?" ":"";s+=o===Pi?l+vD:p>=0?(r.push(u),l.slice(0,p)+Mv+l.slice(p)+tn+v):l+tn+(p===-2?a:v)}return[Uv(t,s+(t[n]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class os{constructor({strings:e,_$litType$:n},r){let i;this.parts=[];let s=0,o=0;const a=e.length-1,l=this.parts,[u,d]=wD(e,n);if(this.el=os.createElement(u,r),Nn.currentNode=this.el.content,n===2||n===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=Nn.nextNode())!==null&&l.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(Mv)){const y=d[o++],v=i.getAttribute(p).split(tn),A=/([.?@])?(.*)/.exec(y);l.push({type:1,index:s,name:A[2],strings:v,ctor:A[1]==="."?_D:A[1]==="?"?kD:A[1]==="@"?ED:el}),i.removeAttribute(p)}else p.startsWith(tn)&&(l.push({type:6,index:s}),i.removeAttribute(p));if(Nv.test(i.tagName)){const p=i.textContent.split(tn),y=p.length-1;if(y>0){i.textContent=fa?fa.emptyScript:"";for(let v=0;v<y;v++)i.append(p[v],is()),Nn.nextNode(),l.push({type:2,index:++s});i.append(p[y],is())}}}else if(i.nodeType===8)if(i.data===Lv)l.push({type:2,index:s});else{let p=-1;for(;(p=i.data.indexOf(tn,p+1))!==-1;)l.push({type:7,index:s}),p+=tn.length-1}s++}}static createElement(e,n){const r=ur.createElement("template");return r.innerHTML=e,r}}function ci(t,e,n=t,r){var o,a;if(e===li)return e;let i=r!==void 0?(o=n._$Co)==null?void 0:o[r]:n._$Cl;const s=ss(e)?void 0:e._$litDirective$;return(i==null?void 0:i.constructor)!==s&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),s===void 0?i=void 0:(i=new s(t),i._$AT(t,n,r)),r!==void 0?(n._$Co??(n._$Co=[]))[r]=i:n._$Cl=i),i!==void 0&&(e=ci(t,i._$AS(t,e.values),i,r)),e}class SD{constructor(e,n){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:n},parts:r}=this._$AD,i=((e==null?void 0:e.creationScope)??ur).importNode(n,!0);Nn.currentNode=i;let s=Nn.nextNode(),o=0,a=0,l=r[0];for(;l!==void 0;){if(o===l.index){let u;l.type===2?u=new Qu(s,s.nextSibling,this,e):l.type===1?u=new l.ctor(s,l.name,l.strings,this,e):l.type===6&&(u=new xD(s,this,e)),this._$AV.push(u),l=r[++a]}o!==(l==null?void 0:l.index)&&(s=Nn.nextNode(),o++)}return Nn.currentNode=ur,i}p(e){let n=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,n),n+=r.strings.length-2):r._$AI(e[n])),n++}}let Qu=class Fv{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,n,r,i){this.type=2,this._$AH=ae,this._$AN=void 0,this._$AA=e,this._$AB=n,this._$AM=r,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=n.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,n=this){e=ci(this,e,n),ss(e)?e===ae||e==null||e===""?(this._$AH!==ae&&this._$AR(),this._$AH=ae):e!==this._$AH&&e!==li&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):yD(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&&ss(this._$AH)?this._$AA.nextSibling.data=e:this.T(ur.createTextNode(e)),this._$AH=e}$(e){var s;const{values:n,_$litType$:r}=e,i=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=os.createElement(Uv(r.h,r.h[0]),this.options)),r);if(((s=this._$AH)==null?void 0:s._$AD)===i)this._$AH.p(n);else{const o=new SD(i,this),a=o.u(this.options);o.p(n),this.T(a),this._$AH=o}}_$AC(e){let n=Kp.get(e.strings);return n===void 0&&Kp.set(e.strings,n=new os(e)),n}k(e){Xu(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let r,i=0;for(const s of e)i===n.length?n.push(r=new Fv(this.O(is()),this.O(is()),this,this.options)):r=n[i],r._$AI(s),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,n){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,n);e!==this._$AB;){const i=jp(e).nextSibling;jp(e).remove(),e=i}}setConnected(e){var n;this._$AM===void 0&&(this._$Cv=e,(n=this._$AP)==null||n.call(this,e))}},el=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,n,r,i,s){this.type=1,this._$AH=ae,this._$AN=void 0,this.element=e,this.name=n,this._$AM=i,this.options=s,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=ae}_$AI(e,n=this,r,i){const s=this.strings;let o=!1;if(s===void 0)e=ci(this,e,n,0),o=!ss(e)||e!==this._$AH&&e!==li,o&&(this._$AH=e);else{const a=e;let l,u;for(e=s[0],l=0;l<s.length-1;l++)u=ci(this,a[r+l],n,l),u===li&&(u=this._$AH[l]),o||(o=!ss(u)||u!==this._$AH[l]),u===ae?e=ae:e!==ae&&(e+=(u??"")+s[l+1]),this._$AH[l]=u}o&&!i&&this.j(e)}j(e){e===ae?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},_D=class extends el{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ae?void 0:e}},kD=class extends el{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==ae)}},ED=class extends el{constructor(e,n,r,i,s){super(e,n,r,i,s),this.type=5}_$AI(e,n=this){if((e=ci(this,e,n,0)??ae)===li)return;const r=this._$AH,i=e===ae&&r!==ae||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,s=e!==ae&&(r===ae||i);i&&this.element.removeEventListener(this.name,this,r),s&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var n;typeof this._$AH=="function"?this._$AH.call(((n=this.options)==null?void 0:n.host)??this.element,e):this._$AH.handleEvent(e)}};class xD{constructor(e,n,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=n,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){ci(this,e)}}const Gl=es.litHtmlPolyfillSupport;Gl==null||Gl(os,Qu),(es.litHtmlVersions??(es.litHtmlVersions=[])).push("3.3.2");const Re=(t,e,n)=>{const r=e;let i=r._$litPart$;return i===void 0&&(r._$litPart$=i=new Qu(e.insertBefore(is(),null),null,void 0,{})),i._$AI(t),i},$D=.5,Jp=.1,Xp=8,AD=4,Zv=3,Hv=3,TD=4,Un=255,Bv=.2126,jv=.7152,Vv=.0722;async function eh(t){const e=CD(t);if(!e)return"light";try{return await RD(t,e)>=$D?"light":"dark"}catch{return"light"}}function CD(t){if(typeof document.elementsFromPoint!="function")return null;const e=t.getBoundingClientRect(),n=e.left+e.width/2,r=e.top+e.height/2,i=document.elementsFromPoint(n,r);for(const s of i){if(!(s instanceof HTMLElement)||s===t||t.contains(s))continue;const o=window.getComputedStyle(s);if(ID(o))return s}return null}function ID(t){return t.backgroundImage&&t.backgroundImage!=="none"?!0:PD(t.backgroundColor)>0}function PD(t){if(!t)return 0;const e=t.match(/rgba?\(([^)]+)\)/);if(!e)return 0;const n=e[1].split(/[\s,/]+/).filter(Boolean);return n.length===TD?parseFloat(n[Zv]):n.length===Hv?1:0}async function RD(t,e){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),i={x:Io((n.left-r.left)/r.width),y:Io((n.top-r.top)/r.height),width:Io(n.width/r.width),height:Io(n.height/r.height)},s=window.getComputedStyle(e),o=DD(s.backgroundImage);return o?zD({url:o,surfaceWidth:r.width,surfaceHeight:r.height,region:i}):MD(s.backgroundColor)}function DD(t){const e=t.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return e?e[1]:null}const Qp=new Map;function OD(t){let e=Qp.get(t);return e||(e=new Promise((n,r)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>n(i),i.onerror=()=>r(new Error(`Failed to load ${t}`)),i.src=t}),Qp.set(t,e),e)}async function zD(t){const e=await OD(t.url),n=Math.max(Xp,Math.ceil(t.surfaceWidth*Jp)),r=Math.max(Xp,Math.ceil(t.surfaceHeight*Jp)),i=document.createElement("canvas");i.width=n,i.height=r;const s=i.getContext("2d",{willReadFrequently:!0});if(!s)return 1;const o=t.surfaceWidth/t.surfaceHeight,a=e.naturalWidth/e.naturalHeight;let l,u;a>o?(u=r,l=r*a):(l=n,u=n/a);const d=(n-l)/2,p=(r-u)/2;s.drawImage(e,d,p,l,u);const y=Math.max(0,Math.floor(t.region.x*n)),v=Math.max(0,Math.floor(t.region.y*r)),A=Math.max(1,Math.min(n-y,Math.floor(t.region.width*n))),E=Math.max(1,Math.min(r-v,Math.floor(t.region.height*r))),I=s.getImageData(y,v,A,E).data;let Z=0,P=0;for(let V=0;V<I.length;V+=AD){const O=I[V]/Un,H=I[V+1]/Un,N=I[V+2]/Un,ce=I[V+Zv]/Un;Z+=ce*(Bv*O+jv*H+Vv*N),P+=1}return P>0?Z/P:1}function MD(t){const e=t.match(/rgba?\(([^)]+)\)/);if(!e)return 1;const n=e[1].split(/[\s,/]+/).filter(Boolean).map(parseFloat);if(n.length<Hv)return 1;const r=n[0]/Un,i=n[1]/Un,s=n[2]/Un;return Bv*r+jv*i+Vv*s}function Io(t){return t<0?0:t>1?1:t}const ql=new WeakSet,ef=new WeakSet;function Wv(t){if(ef.has(t))return;ef.add(t);for(const n of t.querySelectorAll('button[variant="ghost"]'))Yl(n);if(typeof MutationObserver!="function")return;new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const i of r.addedNodes)LD(i,Yl);else r.type==="attributes"&&r.target instanceof HTMLButtonElement&&r.target.getAttribute("variant")==="ghost"&&Yl(r.target)}).observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["variant"]})}function LD(t,e){if(t instanceof Element){t instanceof HTMLButtonElement&&t.getAttribute("variant")==="ghost"&&e(t);for(const n of t.querySelectorAll('button[variant="ghost"]'))e(n)}}async function Yl(t){if(ql.has(t))return;ql.add(t);const e=await eh(t);if(t.getAttribute("variant")!=="ghost"){ql.delete(t);return}t.setAttribute("tone",e)}const ND="*,*: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)}',th=new CSSStyleSheet;th.replaceSync(ND);try{document.adoptedStyleSheets=[...document.adoptedStyleSheets,th]}catch{}Wv(document);function Gv(t){try{t.adoptedStyleSheets=[...t.adoptedStyleSheets,th]}catch{}Wv(t)}/**
|
|
50
|
+
* @license
|
|
51
|
+
* Copyright 2017 Google LLC
|
|
52
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
|
+
*/const qv={CHILD:2},nh=t=>(...e)=>({_$litDirective$:t,values:e});class Yv{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,n,r){this._$Ct=e,this._$AM=n,this._$Ci=r}_$AS(e,n){return this.update(e,n)}update(e,n){return this.render(...n)}}/**
|
|
54
|
+
* @license
|
|
55
|
+
* Copyright 2017 Google LLC
|
|
56
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
57
|
+
*/let ga=class extends Yv{constructor(e){if(super(e),this.it=ae,e.type!==qv.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===li)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const n=[e];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}};ga.directiveName="unsafeHTML",ga.resultType=1;const UD=nh(ga);/**
|
|
58
|
+
* @license
|
|
59
|
+
* Copyright 2017 Google LLC
|
|
60
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
+
*/class Lc extends ga{}Lc.directiveName="unsafeSVG",Lc.resultType=2;const FD=nh(Lc),ZD={size:16,color:"currentColor",weight:"regular"};function HD(t){return typeof t=="string"?{regular:t}:t}function Xt(t,e="0 0 256 256"){const n=HD(t);return r=>{const{size:i,color:s,weight:o}={...ZD,...r},a=n[o]??n.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
|
+
>${FD(a)}</svg>`}}const BD=Xt('<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"/>'),Kv=Xt('<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"/>'),jD=Xt('<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"/>'),Jv=Xt('<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"/>'),VD=Xt('<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"/>'),WD=Xt('<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=Xt({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"/>'}),qD=Xt({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"/>'}),YD=Xt({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 Xv extends Event{constructor(n){super("dropdown-item-select",{bubbles:!0,composed:!0});b(this,"value");this.value=n}}class KD extends Event{constructor(n){super("select",{bubbles:!0,composed:!0});b(this,"value");this.value=n}}var Ke,ht,un,Kn,ne,_s,M,ey,Bi,ty,ny,Nc,ry,ji,Pn,Jn,ks,Es,xs,Ea,iy,sy,Uc,Vi,oy,Fc,Mt;class Qv extends HTMLElement{constructor(){super();w(this,M);w(this,Ke,!1);w(this,ht,null);w(this,un,null);w(this,Kn);w(this,ne,null);w(this,_s,new MutationObserver(n=>g(this,M,iy).call(this,n)));w(this,Jn,()=>{g(this,M,ji).call(this,!c(this,Ke))});w(this,ks,n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),c(this,Jn).call(this))});w(this,Es,n=>{c(this,Ke)&&(n.composedPath().includes(this)||g(this,M,ji).call(this,!1))});w(this,xs,n=>{n instanceof Xv&&(n.stopPropagation(),k(this,Ke,!1),g(this,M,Bi).call(this,n.value),g(this,M,Mt).call(this),this.dispatchEvent(new KD(n.value)))});w(this,Ea,()=>{g(this,M,Uc).call(this)});k(this,Kn,this.attachShadow({mode:"open"})),Gv(c(this,Kn))}connectedCallback(){this.addEventListener("dropdown-item-select",c(this,xs)),document.addEventListener("click",c(this,Es),!0),g(this,M,ey).call(this),c(this,_s).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),g(this,M,Mt).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",c(this,xs)),document.removeEventListener("click",c(this,Es),!0),c(this,_s).disconnect(),g(this,M,Fc).call(this)}attributeChangedCallback(n){if(n==="open"){g(this,M,ji).call(this,this.hasAttribute("open"));return}g(this,M,Mt).call(this)}get open(){return c(this,Ke)}set open(n){this.toggleAttribute("open",n)}get title(){return this.getAttribute("title")??""}get placement(){return this.getAttribute("placement")==="top"?"top":"bottom"}get value(){return c(this,ht)}set value(n){n===null?(g(this,M,Pn).call(this,null,null),g(this,M,ty).call(this)):g(this,M,Bi).call(this,n),g(this,M,Mt).call(this)}close(){g(this,M,ji).call(this,!1)}}Ke=new WeakMap,ht=new WeakMap,un=new WeakMap,Kn=new WeakMap,ne=new WeakMap,_s=new WeakMap,M=new WeakSet,ey=function(){var r;const n=this.querySelector("dropdown-item[selected]");n&&g(this,M,Pn).call(this,n.value,((r=n.textContent)==null?void 0:r.trim())??null)},Bi=function(n){var r;for(const i of c(this,M,Nc))i.value===n?(g(this,M,Pn).call(this,n,((r=i.textContent)==null?void 0:r.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},ty=function(){const n=this.querySelectorAll("dropdown-item[selected]");for(const r of n)r.removeAttribute("selected")},ny=function(n){for(const r of c(this,M,Nc))if(r.value===n)return r;return null},Nc=function(){return this.querySelectorAll("dropdown-item")},ry=function(){return c(this,un)??this.title},ji=function(n){c(this,Ke)!==n&&(k(this,Ke,n),g(this,M,Mt).call(this))},Pn=function(n,r){k(this,ht,n),k(this,un,r)},Jn=new WeakMap,ks=new WeakMap,Es=new WeakMap,xs=new WeakMap,Ea=new WeakMap,iy=function(n){n.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||g(this,M,sy).call(this)},sy=function(){var r,i;const n=this.querySelector("dropdown-item[selected]");if(n){const s=n.value,o=((r=n.textContent)==null?void 0:r.trim())??null,a=c(this,ht)!==s||c(this,un)!==o;g(this,M,Pn).call(this,s,o),g(this,M,Bi).call(this,s),a?g(this,M,Mt).call(this):g(this,M,Vi).call(this);return}if(c(this,ht)!==null){const s=g(this,M,ny).call(this,c(this,ht));if(s){const o=((i=s.textContent)==null?void 0:i.trim())??null,a=c(this,un)!==o;g(this,M,Pn).call(this,c(this,ht),o),g(this,M,Bi).call(this,c(this,ht)),a?g(this,M,Mt).call(this):g(this,M,Vi).call(this);return}}if(c(this,ht)!==null||c(this,un)!==null){g(this,M,Pn).call(this,null,null),g(this,M,Mt).call(this);return}g(this,M,Vi).call(this)},Uc=function(){const n=c(this,Kn).querySelector('slot[name="trigger"]'),r=n instanceof HTMLSlotElement?n.assignedElements()[0]??null:null;c(this,ne)!==r&&(g(this,M,Fc).call(this),k(this,ne,r),c(this,ne)&&(c(this,ne).addEventListener("click",c(this,Jn)),c(this,ne)instanceof HTMLButtonElement?c(this,ne).hasAttribute("type")||(c(this,ne).type="button"):(c(this,ne).hasAttribute("role")||c(this,ne).setAttribute("role","button"),c(this,ne).hasAttribute("tabindex")||(c(this,ne).tabIndex=0),c(this,ne).addEventListener("keydown",c(this,ks))))),g(this,M,Vi).call(this)},Vi=function(){c(this,ne)&&(c(this,ne).setAttribute("data-dropdown-trigger",""),c(this,ne).setAttribute("aria-haspopup","listbox"),c(this,ne).setAttribute("aria-expanded",c(this,Ke)?"true":"false"))},oy=function(){return this.placement==="top"?VD:Jv},Fc=function(){c(this,ne)&&(c(this,ne).removeEventListener("click",c(this,Jn)),c(this,ne).removeEventListener("keydown",c(this,ks)),c(this,ne).removeAttribute("data-dropdown-trigger"),c(this,ne).removeAttribute("aria-haspopup"),c(this,ne).removeAttribute("aria-expanded"),k(this,ne,null))},Mt=function(){this.toggleAttribute("open",c(this,Ke)),Re(U`
|
|
69
|
+
<slot name="trigger" @slotchange=${c(this,Ea)}>
|
|
70
|
+
<button
|
|
71
|
+
class="fallback-trigger"
|
|
72
|
+
part="trigger"
|
|
73
|
+
type="button"
|
|
74
|
+
aria-haspopup="listbox"
|
|
75
|
+
aria-expanded=${c(this,Ke)?"true":"false"}
|
|
76
|
+
@click=${c(this,Jn)}
|
|
77
|
+
>
|
|
78
|
+
<span class="trigger-label" part="trigger-label">${c(this,M,ry)}</span>
|
|
79
|
+
<span class="trigger-icon" part="trigger-icon" aria-hidden="true">
|
|
80
|
+
${c(this,M,oy).call(this,{size:16})}
|
|
81
|
+
</span>
|
|
82
|
+
</button>
|
|
83
|
+
</slot>
|
|
84
|
+
${c(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
|
+
`,c(this,Kn)),queueMicrotask(()=>g(this,M,Uc).call(this))},b(Qv,"observedAttributes",["title","placement","open"]);class JD extends HTMLElement{}class XD extends HTMLElement{}class QD extends HTMLElement{}var pr,Zc,ly,$s,As;class ay extends HTMLElement{constructor(){super(...arguments);w(this,pr);w(this,$s,()=>{this.action||g(this,pr,ly).call(this)});w(this,As,n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",c(this,$s)),this.addEventListener("keydown",c(this,As)),g(this,pr,Zc).call(this)}disconnectedCallback(){this.removeEventListener("click",c(this,$s)),this.removeEventListener("keydown",c(this,As))}attributeChangedCallback(){g(this,pr,Zc).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}pr=new WeakSet,Zc=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")},ly=function(){this.dispatchEvent(new Xv(this.value))},$s=new WeakMap,As=new WeakMap,b(ay,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",Qv);customElements.get("dropdown-group")||customElements.define("dropdown-group",JD);customElements.get("dropdown-label")||customElements.define("dropdown-label",XD);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",QD);customElements.get("dropdown-item")||customElements.define("dropdown-item",ay);class e2 extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var Ts,yn,Hc,xa,Cs,Bc;class cy extends HTMLElement{constructor(){super();w(this,yn);w(this,Ts);w(this,xa,n=>{n.target===n.currentTarget&&g(this,yn,Hc).call(this)});w(this,Cs,n=>{this.open&&n.key==="Escape"&&g(this,yn,Hc).call(this)});k(this,Ts,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",c(this,Cs)),g(this,yn,Bc).call(this)}disconnectedCallback(){document.removeEventListener("keydown",c(this,Cs))}attributeChangedCallback(){g(this,yn,Bc).call(this)}get open(){return this.hasAttribute("open")}}Ts=new WeakMap,yn=new WeakSet,Hc=function(){this.dispatchEvent(new e2)},xa=new WeakMap,Cs=new WeakMap,Bc=function(){Re(U`
|
|
96
|
+
${this.open?U`
|
|
97
|
+
<div class="backdrop" part="backdrop" @click=${c(this,xa)}>
|
|
98
|
+
<slot></slot>
|
|
99
|
+
</div>
|
|
100
|
+
`:null}
|
|
101
|
+
`,c(this,Ts))},b(cy,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",cy);class t2 extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class n2 extends HTMLElement{}var Is,Ps,jc;class uy extends HTMLElement{constructor(){super();w(this,Ps);w(this,Is);k(this,Is,this.attachShadow({mode:"open"}))}connectedCallback(){g(this,Ps,jc).call(this)}attributeChangedCallback(){g(this,Ps,jc).call(this)}get closable(){return this.hasAttribute("closable")}}Is=new WeakMap,Ps=new WeakSet,jc=function(){const n=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">${(n==null?void 0:n.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 t2)}
|
|
112
|
+
>
|
|
113
|
+
<span class="close-icon" part="icon close-icon">${Kv({size:16})}</span>
|
|
114
|
+
</button>
|
|
115
|
+
`:null}
|
|
116
|
+
</header>
|
|
117
|
+
<slot></slot>
|
|
118
|
+
</section>
|
|
119
|
+
`,c(this,Is))},b(uy,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",uy);customElements.get("panel-page")||customElements.define("panel-page",n2);class r2 extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const tf='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Kl=4;var je,jt,Xn,tt,Rs,Gr,re,dy,py,Vc,Ds,Os,Qn,fy,Wc,gy,my,Jo,Xo;class hy extends HTMLElement{constructor(){super();w(this,re);w(this,je,!1);w(this,jt,null);w(this,Xn);w(this,tt,null);w(this,Rs,"bottom-start");w(this,Gr,!1);w(this,Ds,n=>{c(this,je)&&(c(this,Gr)||n.composedPath().includes(this)||(this.open=!1))});w(this,Os,n=>{if(c(this,je)){if(n.key==="Escape"){n.preventDefault(),this.open=!1;return}n.key==="Tab"&&g(this,re,fy).call(this,n)}});w(this,Qn,()=>{c(this,je)&&g(this,re,Jo).call(this)});k(this,Xn,this.attachShadow({mode:"open"})),Gv(c(this,Xn))}connectedCallback(){this.hasAttribute("tone")||this.setAttribute("tone","light"),g(this,re,Xo).call(this)}disconnectedCallback(){g(this,re,Vc).call(this)}attributeChangedCallback(n){n==="open"&&g(this,re,dy).call(this,this.hasAttribute("open"))}get open(){return c(this,je)}set open(n){this.toggleAttribute("open",n)}get anchor(){return c(this,jt)}set anchor(n){c(this,jt)!==n&&(k(this,jt,n),c(this,je)&&g(this,re,Jo).call(this))}}je=new WeakMap,jt=new WeakMap,Xn=new WeakMap,tt=new WeakMap,Rs=new WeakMap,Gr=new WeakMap,re=new WeakSet,dy=function(n){var r;c(this,je)!==n&&(k(this,je,n),n?(k(this,Gr,!0),setTimeout(()=>{k(this,Gr,!1)},0),g(this,re,Xo).call(this),g(this,re,py).call(this),queueMicrotask(()=>{c(this,je)&&(g(this,re,Jo).call(this),g(this,re,my).call(this))})):(g(this,re,Vc).call(this),g(this,re,Xo).call(this),(r=c(this,jt))==null||r.focus(),this.dispatchEvent(new r2)))},py=function(){document.addEventListener("click",c(this,Ds)),document.addEventListener("keydown",c(this,Os),!0),window.addEventListener("resize",c(this,Qn)),window.addEventListener("scroll",c(this,Qn),!0)},Vc=function(){document.removeEventListener("click",c(this,Ds)),document.removeEventListener("keydown",c(this,Os),!0),window.removeEventListener("resize",c(this,Qn)),window.removeEventListener("scroll",c(this,Qn),!0)},Ds=new WeakMap,Os=new WeakMap,Qn=new WeakMap,fy=function(n){const r=g(this,re,Wc).call(this);if(r.length===0){n.preventDefault();return}const i=r[0],s=r[r.length-1],o=g(this,re,gy).call(this),a=o instanceof HTMLElement&&r.includes(o);n.shiftKey?(!a||o===i)&&(n.preventDefault(),s.focus()):(!a||o===s)&&(n.preventDefault(),i.focus())},Wc=function(){if(!c(this,tt))return[];const n=c(this,tt).querySelector("slot");if(!(n instanceof HTMLSlotElement))return[];const r=[];for(const i of n.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches(tf)&&r.push(i);for(const s of i.querySelectorAll(tf))r.push(s)}return r},gy=function(){var r;let n=document.activeElement;for(;n&&((r=n.shadowRoot)!=null&&r.activeElement);)n=n.shadowRoot.activeElement;return n},my=function(){var r;const n=g(this,re,Wc).call(this);n.length>0?n[0].focus():(r=c(this,tt))==null||r.focus()},Jo=function(){if(!c(this,je)||!c(this,jt)||!c(this,tt))return;const n=c(this,jt).getBoundingClientRect(),r=c(this,tt).getBoundingClientRect(),s=window.innerHeight-n.bottom,o=r.height+Kl,a=s<o&&n.top>o?"top-start":"bottom-start";k(this,Rs,a);const l=a==="bottom-start"?n.bottom+Kl:n.top-r.height-Kl,u=n.left;c(this,tt).style.top=`${l}px`,c(this,tt).style.left=`${u}px`,c(this,tt).setAttribute("data-placement",a)},Xo=function(){this.toggleAttribute("open",c(this,je)),Re(c(this,je)?U`<div
|
|
120
|
+
class="panel"
|
|
121
|
+
part="panel"
|
|
122
|
+
data-placement=${c(this,Rs)}
|
|
123
|
+
tabindex="-1"
|
|
124
|
+
role="dialog"
|
|
125
|
+
material="paper"
|
|
126
|
+
level="1"
|
|
127
|
+
>
|
|
128
|
+
<slot></slot>
|
|
129
|
+
</div>`:ae,c(this,Xn)),k(this,tt,c(this,Xn).querySelector(".panel"))},b(hy,"observedAttributes",["open"]);customElements.get("ui-popover")||customElements.define("ui-popover",hy);const i2=gt(),s2="No handler registered for update-content",o2="handleUpdateContent: handler already registered";function a2(t){return t instanceof Error&&typeof t.message=="string"?t.message:String(t)}const l2=yi(mt);var qr,Yr,Kr,er,tr,zs,Ce,Gc,vy,yy,Wi,qc,Df;let c2=(Df=class extends l2{constructor(n){super();w(this,Ce);w(this,qr);w(this,Yr);w(this,Kr);w(this,er,null);w(this,tr,null);w(this,zs,!1);k(this,qr,n);const r=n.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");k(this,Yr,r),k(this,Kr,i=>g(this,Ce,vy).call(this,i)),c(this,Yr).addEventListener("message",c(this,Kr))}get content(){return c(this,tr)}set content(n){g(this,Ce,qc).call(this),k(this,tr,n),c(this,zs)&&g(this,Ce,Gc).call(this,n)}handleUpdateContent(n){if(g(this,Ce,qc).call(this),c(this,er)!==null)throw new Error(o2);k(this,er,n)}dispose(){c(this,Yr).removeEventListener("message",c(this,Kr)),k(this,er,null)}},qr=new WeakMap,Yr=new WeakMap,Kr=new WeakMap,er=new WeakMap,tr=new WeakMap,zs=new WeakMap,Ce=new WeakSet,Gc=function(n){const r={type:"content-updated",content:n};g(this,Ce,Wi).call(this,r)},vy=function(n){if(this.disposed||n.source!==c(this,qr).contentWindow)return;const r=n.data;if(hC(r)){k(this,zs,!0),this.dispatchEvent(new i2("ready")),c(this,tr)!==null&&g(this,Ce,Gc).call(this,c(this,tr));return}if(dC(r)){g(this,Ce,yy).call(this,r);return}},yy=async function(n){const r=c(this,er);if(r===null){g(this,Ce,Wi).call(this,{type:"response",id:n.id,error:{message:s2}});return}try{await r(n.content)}catch(i){if(this.disposed)return;g(this,Ce,Wi).call(this,{type:"response",id:n.id,error:{message:a2(i)}});return}this.disposed||g(this,Ce,Wi).call(this,{type:"response",id:n.id,result:{}})},Wi=function(n){const r=c(this,qr).contentWindow;r&&r.postMessage(n,"*")},qc=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},Df);function u2(t=window){if(t.parent===t)return;let e=0,n=0;t.addEventListener("wheel",r=>{const i=r;e=i.clientX,n=i.clientY,t.parent.postMessage({type:"wheel",deltaX:i.deltaX,deltaY:i.deltaY,shiftKey:i.shiftKey},"*"),i.preventDefault()},{passive:!1}),t.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 l=((d=(u=t.document).elementFromPoint)==null?void 0:d.call(u,e,n))??null;for(;l!==null;){const p=t.getComputedStyle(l);if(a!==0){const y=(p.overflowY==="auto"||p.overflowY==="scroll")&&l.scrollHeight>l.clientHeight,v=a>0?l.scrollTop+l.clientHeight<l.scrollHeight:l.scrollTop>0;if(y&&v){l.scrollBy(o,a);return}}if(o!==0){const y=(p.overflowX==="auto"||p.overflowX==="scroll")&&l.scrollWidth>l.clientWidth,v=o>0?l.scrollLeft+l.clientWidth<l.scrollWidth:l.scrollLeft>0;if(y&&v){l.scrollBy(o,a);return}}l=l.parentElement}t.scrollBy(o,a)})}function h2(){return`(${u2.toString()})(window);`}async function d2(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch artifact content: ${e.status}`);const n=await e.text(),r=new DOMParser().parseFromString(n,"text/html"),i=r.createElement("base");i.href=t,r.head.insertBefore(i,r.head.firstChild);const s=r.createElement("script");s.textContent=h2(),r.head.appendChild(s);const o=new Blob([`<!DOCTYPE html>
|
|
130
|
+
${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const by=gt();class p2 extends HTMLElement{constructor(){super(...arguments);b(this,"_artifact",null);b(this,"_viewURL",null);b(this,"_contentURL",null);b(this,"_screen",null);b(this,"_subscribedScreen",null);b(this,"_activeView",null);b(this,"_contentState",{kind:"idle"});b(this,"_fetchSequence",0);b(this,"_blobSequence",0);b(this,"_mountedViewURL",null);b(this,"_directRender",!1);b(this,"_blobURL",null);b(this,"handleScreenContentChanged",n=>{!this._artifact||n.artifactID!==this._artifact.id||this._activeView!==null&&this.refetchContent()})}set artifact(n){const r=this._artifact;this._artifact=n,this.render(),r!==null&&r!==n&&this.syncView()}get artifact(){return this._artifact}set viewURL(n){this._viewURL!==n&&(this._viewURL=n,this.syncView())}get viewURL(){return this._viewURL}set contentURL(n){this._contentURL!==n&&(this._contentURL=n,this.syncView())}get contentURL(){return this._contentURL}set screen(n){this._screen!==n&&(this._screen=n,this.syncScreenSubscription())}get screen(){return this._screen}set dragging(n){n?this.setAttribute("dragging","true"):this.removeAttribute("dragging")}get dragging(){return this.getAttribute("dragging")==="true"}get activeView(){return this._activeView}connectedCallback(){this.setAttribute("level","2"),this.render(),this.syncView(),this.syncScreenSubscription()}disconnectedCallback(){this.teardownView(),this.unsubscribeFromScreen()}handleClose(){this._artifact&&this.dispatchEvent(new by("close-artifact",{artifactID:this._artifact.id,bubbles:!0,composed:!0}))}syncView(){var n;if(this.isConnected){if(this._viewURL!==null){if(this._directRender&&this.teardownView(),this._mountedViewURL!==this._viewURL){this.teardownView(),this._contentState={kind:"loading"},this._mountedViewURL=this._viewURL,this.render();const r=this.querySelector("iframe.artifact-frame");if(!r){this._contentState={kind:"error"},this.render();return}this._activeView=new c2(r),this._activeView.handleUpdateContent(async i=>{await this.saveContent(i)}),this.loadBlobFrame(this._viewURL),this.startContentFetch();return}this._activeView!==null&&this.startContentFetch();return}if(this._contentURL!==null){this.teardownView(),this._directRender=!0,this._contentState={kind:"idle"},this.render(),((n=this._artifact)==null?void 0:n.status)==="committed"&&this.loadBlobFrame(this._contentURL);return}this.teardownView(),this._contentState={kind:"idle"},this.render()}}async saveContent(n){const r=this._screen,i=this._artifact;if(!r||!i)throw new Error("artifact-view: cannot save without a screen and artifact");await r.server.client.artifacts.putContent({artifactID:i.id,content:n})}syncScreenSubscription(){if(!this.isConnected){this.unsubscribeFromScreen();return}this._subscribedScreen!==this._screen&&(this.unsubscribeFromScreen(),this._screen!==null&&(this._screen.addEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=this._screen))}unsubscribeFromScreen(){this._subscribedScreen!==null&&(this._subscribedScreen.removeEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=null)}startContentFetch(){this._fetchSequence+=1;const n=this._fetchSequence,r=this._contentURL,i=this._activeView;if(!i||r===null){this._contentState={kind:"error"},this.render();return}this._contentState={kind:"loading"},(async()=>{try{const s=await fetch(r);if(n!==this._fetchSequence)return;if(!s.ok){this._contentState={kind:"error"},this.teardownView(),this.render();return}const o=await s.text();if(n!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o,this._contentState={kind:"ready"}}catch{if(n!==this._fetchSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}refetchContent(){this._fetchSequence+=1;const n=this._fetchSequence,r=this._contentURL,i=this._activeView;!i||r===null||(async()=>{try{const s=await fetch(r);if(n!==this._fetchSequence||!s.ok)return;const o=await s.text();if(n!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o}catch{}})()}loadBlobFrame(n){this._blobSequence+=1;const r=this._blobSequence;(async()=>{try{const i=await d2(n);if(r!==this._blobSequence){URL.revokeObjectURL(i);return}this._blobURL=i,this.render();const s=this.querySelector("iframe.artifact-frame");s&&(s.src=i)}catch{if(r!==this._blobSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}teardownView(){this._activeView!==null&&(this._activeView.dispose(),this._activeView=null),this._blobURL!==null&&(URL.revokeObjectURL(this._blobURL),this._blobURL=null),this._mountedViewURL=null,this._directRender=!1,this._fetchSequence+=1,this._blobSequence+=1}contentTemplate(){return this._contentState.kind==="error"?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 n=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">${BD({size:16})}</span>
|
|
149
|
+
<span class="artifact-title">${n.title}</span>
|
|
150
|
+
</div>
|
|
151
|
+
<button
|
|
152
|
+
icon-only
|
|
153
|
+
variant="ghost"
|
|
154
|
+
class="artifact-close-btn"
|
|
155
|
+
@click=${()=>this.handleClose()}
|
|
156
|
+
aria-label="Close"
|
|
157
|
+
>
|
|
158
|
+
${Kv({size:16})}
|
|
159
|
+
</button>
|
|
160
|
+
</footer>
|
|
161
|
+
`}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),Re(this.template(),this))}}customElements.define("artifact-view",p2);const ke=t=>({type:"px",...t}),Te=t=>({type:"unit",...t}),Po=2,f2=2;class g2{constructor(e){b(this,"basis");b(this,"min");b(this,"_gap");b(this,"_viewport");b(this,"_unit");this.basis=e.basis,this.min=e.min,this._viewport=e.viewport,this._gap=e.gap??ke({x:ge,y:ge});const n=this._viewport.x??lr,r=this._viewport.y??la,i=this._gap.x??ge,s=this._gap.y??ge,o=lr+i*f2,a=n<=o,l=a?n-i*Po:Math.min(lr,n-i*Po),u=a?r-s*Po:Math.min(la,r-s*Po),d=(l-i*(It-1))/It,p=(u-s*(Qe-1))/Qe,y=this.basis.x??0,v=this.basis.y??0,A=this.min.x??0,E=this.min.y??0;this._unit=ke(a?{x:Math.max(A,d),y:Math.max(E,p)}:{x:Math.max(A,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 n=this._unit.x??0,r=this._unit.y??0,i=this._gap.x??ge,s=this._gap.y??ge,o=e.x==null?void 0:e.x*n+Math.max(0,e.x-1)*i,a=e.y==null?void 0:e.y*r+Math.max(0,e.y-1)*s;return ke({x:o,y:a})}}const hr=1e-4,Wt=1e-6,m2=40,v2=24;function wy(t,e){return Math.max(0,t-e*2)}function Sy(t){const e=[0];for(const n of t)e.push((e[e.length-1]??0)+n);return e}function _y(t){const e=[0];for(let n=0;n<t.length;n+=1){const r=e[n]??0;e.push(r+t[n]+ge)}return e}function ky(t,e,n){if(e<0||e>=t.length)return 0;let r=0,i=0;for(let s=e;s<t.length;s+=1){const o=t[s],a=i===0?o:r+ge+o;if(a>n+hr)break;r=a,i+=1}return Math.max(1,i)}function y2(t,e,n){if(e<0||e>=t.length)return 0;let r=0,i=0;for(let s=e;s>=0;s-=1){const o=t[s],a=i===0?o:r+ge+o;if(a>n+hr)break;r=a,i+=1}return Math.max(1,i)}function b2(t,e){if(t.length===0)return 0;let n=0,r=0;for(let i=t.length-1;i>=0;i-=1){const s=t[i],o=r===0?s:n+ge+s;if(o>e+hr)break;n=o,r+=1}return Math.max(1,r)}function rh(t,e){if(t.length===0)return 0;const n=b2(t,e);return Math.max(0,t.length-n)}function nf(t,e,n){if(t.length===0)return 0;const r=ky(t,e,n),i=Math.min(t.length,e+r);if(i<=e)return 0;const s=t.slice(e,i);return s.reduce((o,a)=>o+a,0)+Math.max(0,s.length-1)*ge}function Yc(t,e,n){const r=t[e]??0;return n-r}function Or(t,e,n,r,i){if(t.length===0)return 0;const s=rh(t,i),o=e[s]??0,a=Math.max(0,Math.min(o,n));let l=0;for(let H=0;H<s;H+=1){const N=e[H]??0,ce=e[H+1]??N;if(a>=N&&a<=ce+hr){l=H;break}l=H+1}const u=Math.min(l+1,s),d=e[l]??0,p=e[u]??d,y=Math.max(p-d,hr),v=u===l?0:(a-d)/y,A=_y(t),E=nf(t,l,i),I=nf(t,u,i),Z=(r-E)/2,P=(r-I)/2,V=Yc(A,l,Z),O=Yc(A,u,P);return V+(O-V)*v}function rf(t,e,n,r,i){const s=rh(t,r),o=e[s]??0;let a=0,l=o;for(let u=0;u<m2;u+=1){const d=(a+l)/2;Or(t,e,d,n,r)>i?a=d:l=d}return(a+l)/2}function sf(t,e,n){const r=_y(t),[i,s]=e,o=t.slice(i,s+1),a=o.reduce((u,d)=>u+d,0)+Math.max(0,o.length-1)*ge,l=(n-a)/2;return Yc(r,i,l)}function w2(t,e,n){const r=ky(t,e,n);return[e,Math.min(t.length-1,e+r-1)]}function S2(t,e,n){const r=y2(t,e,n);return[Math.max(0,e-r+1),e]}function _2(t){const e=new Set,n=[];for(const r of t){const i=`${r.nodeRange[0]}:${r.nodeRange[1]}`;if(e.has(i))continue;const s=n[n.length-1];s&&Math.abs(s.anchor-r.anchor)<=Wt||(e.add(i),n.push(r))}return n}function k2(t){const{nodeCols:e,nodeWidthsPx:n,viewportWidthPx:r}=t;if(e.length===0||n.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const i=t.gapPx??ge,s=wy(r,i),o=Sy(e),a=rh(n,s),l=o[a]??0,u=[];for(let d=0;d<=a;d+=1){const p=w2(n,d,s),y=sf(n,p,r),v=rf(n,o,r,s,y);u.push({nodeRange:p,anchor:Math.max(0,Math.min(l,v))})}for(let d=n.length-1;d>=0;d-=1){const p=S2(n,d,s),y=`${p[0]}:${p[1]}`;if(u.some(E=>`${E.nodeRange[0]}:${E.nodeRange[1]}`===y))continue;const v=sf(n,p,r),A=rf(n,o,r,s,v);u.push({nodeRange:p,anchor:Math.max(0,Math.min(l,A))})}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:_2(u),minScroll:0,maxScroll:l}}function E2(t,e){var i;let n=0,r=Number.POSITIVE_INFINITY;for(let s=0;s<t.length;s+=1){const o=Math.abs((((i=t[s])==null?void 0:i.anchor)??0)-e);if(o+Wt<r){r=o,n=s;continue}Math.abs(o-r)<=Wt&&s<n&&(n=s)}return n}function x2(t,e,n){return n<=0?0:Math.max(0,Math.min(n-1,t+e))}function Ri(t,e,n){return Math.max(e,Math.min(n,t))}class $2 extends mt{constructor(n){super();b(this,"_scroll",0);b(this,"minScroll",0);b(this,"maxScroll",0);b(this,"viewspans",[]);b(this,"activeViewspanIndex",null);b(this,"nodeWidthsPx",[]);b(this,"boundaryCols",[0]);b(this,"viewportWidthPx",0);b(this,"framedViewportWidthPx",0);this._scroll=(n==null?void 0:n.x)??0}get scroll(){return Te({x:this._scroll})}get translate(){return ke({x:Or(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx)})}set scroll(n){const r=Ri(n.x??this._scroll,this.minScroll,this.maxScroll);Math.abs(r-this._scroll)<=Wt||(this._scroll=r,this.activeViewspanIndex=null,this.dispatchEvent(new Ii("layout-scroll",{scroll:this.scroll})))}rebuild(n){const r=n.nodeWidths.map(u=>Math.max(0,u.x??0)),i=r.map(u=>n.grid.toPixels(Te({x:u})).x??0),s=n.grid.viewport.x??0,o=n.grid.gap.x??ge,a=k2({nodeCols:r,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this.nodeWidthsPx=i,this.boundaryCols=Sy(r),this.viewportWidthPx=s,this.framedViewportWidthPx=wy(s,o),this.viewspans=a.viewspans,this.minScroll=a.minScroll,this.maxScroll=a.maxScroll,this.activeViewspanIndex=null;const l=Ri(this._scroll,this.minScroll,this.maxScroll);Math.abs(l-this._scroll)>Wt&&(this._scroll=l,this.dispatchEvent(new Ii("layout-scroll",{scroll:this.scroll})))}step(n){var a;if(this.viewspans.length===0)return;const r=this.activeViewspanIndex??E2(this.viewspans,this._scroll),i=x2(r,n,this.viewspans.length),s=((a=this.viewspans[i])==null?void 0:a.anchor)??this._scroll,o=Ri(s,this.minScroll,this.maxScroll);this.activeViewspanIndex=i,!(Math.abs(o-this._scroll)<=Wt)&&(this._scroll=o,this.dispatchEvent(new Ii("layout-scroll",{scroll:this.scroll})))}wheel(n){const r=Ri(this._scroll+(n.x??0),this.minScroll,this.maxScroll);this.activeViewspanIndex=null,!(Math.abs(r-this._scroll)<=Wt)&&(this._scroll=r,this.dispatchEvent(new Ii("layout-scroll",{scroll:this.scroll})))}wheelPixels(n){const r=n.x??0;if(Math.abs(r)<=hr)return;this.activeViewspanIndex=null;const i=Or(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),s=i-r,o=Or(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=Or(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),l=Math.max(o,Math.min(a,s));if(Math.abs(l-i)<=hr)return;let u=this.minScroll,d=this.maxScroll;for(let y=0;y<v2;y+=1){const v=(u+d)/2;Or(this.nodeWidthsPx,this.boundaryCols,v,this.viewportWidthPx,this.framedViewportWidthPx)>l?u=v:d=v}const p=Ri((u+d)/2,this.minScroll,this.maxScroll);Math.abs(p-this._scroll)<=Wt||(this._scroll=p,this.dispatchEvent(new Ii("layout-scroll",{scroll:this.scroll})))}}const Jl={"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}},A2=["stack-above","stack-below","reorder-before","reorder-after"];function Xl(t,e){return{left:t.left+t.width*e.left,top:t.top+t.height*e.top,width:t.width*e.width,height:t.height*e.height}}function Cn(t,e,n){return t>=n.left&&t<n.left+n.width&&e>=n.top&&e<n.top+n.height}function ih(t,e){for(const n of t){if(n.type==="card"&&n.id===e)return n;if(n.type==="stack")for(const r of n.children){if(r.type==="card"&&r.id===e)return r;if(r.type==="row"){for(const i of r.children)if(i.id===e)return i}}}return null}function Kc(t){return t.height===Qe||t.height===fn?{...t,height:fn}:t}function Jc(t){return t.height===fn?{...t,height:Qe}:t}function T2(t,e,n,r){const i=t.findIndex(d=>d.type==="stack"&&d.id===e);if(i===-1)return t;const s=t[i];if(!s||s.type!=="stack")return t;const o=s.children.find(d=>d.type==="card"&&d.id===n);if(!o||o.type!=="card")return t;const a=s.children.filter(d=>d.id!==n);if(a.length===s.children.length||a.length<1)return t;const l=[...t];if(a.length===1){const[d]=a;l[i]=d.type==="card"?Jc(d):d}else l[i]={...s,children:a};const u=Math.max(0,Math.min(r,l.length));return l.splice(u,0,Jc(o)),l}const C2=gt(),I2=gt(),P2=50;function R2(t,e){if(t.type!==e.type)return!1;switch(t.type){case"reorder":return e.index===t.index;case"stack":return e.targetCardId===t.targetCardId&&e.position===t.position;case"stack-child-noop":return!0;case"stack-child-extract":return e.toIndex===t.toIndex;case"stack-child-reorder":return e.position===t.position;default:return!1}}function oo(t){return{id:t.id,type:"drop-target",width:t.width,height:t.height}}function of(t){return t.map(O2)}function D2(t){return t.type==="drop-target"?{id:t.id,type:"card",artifactID:t.id,width:t.width,height:t.height}:t}function O2(t){return t.type==="drop-target"?{id:t.id,type:"card",artifactID:t.id,width:t.width,height:t.height}:t.type==="stack"?{...t,children:t.children.map(D2)}:t}function Ey(t,e){return t.find(r=>r.type==="card"&&r.id===e)??null}function af(t,e){return t.find(r=>r.type==="stack"&&r.id===e)??null}function z2(t,e){const n=[...e],r=n.findIndex(a=>a.type==="card"&&a.id===t.nodeId);if(r===-1)return null;const i=n[r];if(!i||i.type!=="card")return null;n.splice(r,1);const s=Math.max(0,Math.min(t.lastReorderIndex,n.length));n.splice(s,0,i);const o=n.findIndex(a=>a.type==="card"&&a.id===t.nodeId);return o===-1?null:{base:n,visualDraggedIndex:o}}function M2(t,e,n,r){const i=[...t.base];i.splice(t.visualDraggedIndex,1);const s=i.findIndex(y=>y.type==="card"&&y.id===n.targetCardId),o=s===-1?null:i[s];if(!o||o.type!=="card")return null;const a=Ey(r,e.nodeId);if(!a)return null;const l=Kc(a),u=Kc(o),d=oo(l),p=n.position==="above"?[d,u]:[u,d];return i[s]={id:o.id,type:"stack",children:p},i}function Ql(t,e){return t.parentStackId?N2(t,e):L2(t,e)}function L2(t,e){const n=t.hitTarget;if(n.type==="reorder"){const r=e[t.sourceIndex];if(!r||r.type!=="card")return[...e];const i=[...e];return i.splice(t.sourceIndex,1),i.splice(n.index,0,oo(r)),i}if(n.type==="stack"){const r=z2(t,e);return r?M2(r,t,n,e)??[...e]:[...e]}return[...e]}function N2(t,e){const n=t.hitTarget;switch(n.type){case"stack-child-reorder":return U2(t,e,n.position);case"stack-child-extract":return F2(t,e,n.toIndex);case"stack-child-noop":return Z2(t,e);default:return[...e]}}function U2(t,e,n){const r=e.findIndex(y=>y.type==="stack"&&y.id===t.parentStackId);if(r===-1)return[...e];const i=e[r];if(!i||i.type!=="stack")return[...e];if(!i.children.every(y=>y.type==="card"))return[...e];const s=i.children,o=s.findIndex(y=>y.id===t.nodeId);if(o===-1)return[...e];const a=s[o],l=s.filter(y=>y.id!==t.nodeId),u=oo(a),d=n==="above"?[u,...l]:[...l,u],p=[...e];return p[r]={...i,children:d},p}function F2(t,e,n){if(!t.parentStackId)return[...e];const r=T2(e,t.parentStackId,t.nodeId,n);if(r===e)return[...e];const i=r.findIndex(a=>a.type==="card"&&a.id===t.nodeId);if(i===-1)return[...e];const s=r[i];if(!s||s.type!=="card")return[...e];const o=[...r];return o[i]=oo(s),o}function Z2(t,e){const n=e.findIndex(l=>l.type==="stack"&&l.id===t.parentStackId);if(n===-1)return[...e];const r=e[n];if(!r||r.type!=="stack")return[...e];const i=r.children.findIndex(l=>l.type==="card"&&l.id===t.nodeId);if(i===-1)return[...e];const s=r.children[i];if(!s||s.type!=="card")return[...e];const o=[...e],a=[...r.children];return a[i]=oo(s),o[n]={...r,children:a},o}function H2(t,e){return e.find(r=>r.type==="stack"&&r.id===t.id)?t.id:Nu()}function B2(t,e,n){if(t.type==="drop-target"){const r=ih(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return Kc(r)}return t}function j2(t,e,n){const r=t.children.map(s=>B2(s,e,n));return{id:H2(t,e),type:"stack",children:r}}function V2(t,e,n){if(t.type==="drop-target"){const r=ih(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return Ey(e,n)!==null?r:Jc(r)}return t.type==="card"||t.type==="row"?t:j2(t,e,n)}function W2(t,e,n){return t.map(r=>V2(r,e,n))}function G2(t,e){return JSON.stringify(t)===JSON.stringify(e)}const q2=yi(mt);class Y2 extends q2{constructor(n={}){super();b(this,"pending",null);b(this,"active",null)}start(n){if(this.pending||this.active)return;const r=n.pointer.x??0,i=n.pointer.y??0;this.pending={startX:r,startY:i,grabOffsetX:n.grabOffset.x??0,grabOffsetY:n.grabOffset.y??0,nodeId:n.nodeId,sourceIndex:n.source.index,parentStackId:n.source.parentId,width:n.size.x??0,height:n.size.y??0,baseLayout:n.layout}}update(n){const r=n.pointer.x??0,i=n.pointer.y??0,s=this.pending;if(s){const u=r-s.startX,d=i-s.startY;Math.hypot(u,d)>=nx&&(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=Ql(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,i,n,o),l=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===i&&R2(this.active.hitTarget,a)&&this.active.lastReorderIndex===l||(this.active={...this.active,pointerX:r,pointerY:i,hitTarget:a,lastReorderIndex:l},this.emitDrag(),this.dispatchEvent(new ee("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const n=this.active.baseLayout;let r=null;try{const i=Ql(this.active,n),s=W2(i,n,this.active.nodeId);G2(s,n)||(r=s)}catch{r=null}this.reset(),r&&this.dispatchEvent(new I2("drop",{layout:r})),this.dispatchEvent(new ee("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new ee("change")))}dispose(){this.reset()}get status(){return this.active?"active":this.pending?"pending":"idle"}reset(){this.pending=null,this.active=null}emitDrag(){if(!this.active)return;const n=Ql(this.active,this.active.baseLayout);this.dispatchEvent(new C2("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:ke({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:ke({x:this.active.pointerX,y:this.active.pointerY}),size:ke({x:this.active.width,y:this.active.height}),projectedLayout:n}))}getHitTargetForPointer(n,r,i,s){return this.active?this.isPointerInsideDragBounds(n,r,i.viewport)?this.active.parentStackId?this.getStackChildHitTarget(n,r,i,s):this.getTopLevelCardHitTarget(n,r,i,s):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(n,r,i,s){var u;if(!((u=this.active)!=null&&u.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(i.geometry);if(o&&Cn(n,r,o)){const d=o.top+o.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}const a=this.getSourceRemainingSiblingRect(i.geometry);if(a&&Cn(n,r,a)){const d=a.top+a.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(n,r,i,s)}}getSourceRemainingSiblingRect(n){var s,o;if(!((s=this.active)!=null&&s.parentStackId))return;const r=af(this.active.baseLayout,this.active.parentStackId);if(!r)return;const i=r.children.find(a=>{var l;return a.type==="card"&&a.id!==((l=this.active)==null?void 0:l.nodeId)});if(i)return(o=n.find(a=>a.id===i.id))==null?void 0:o.rect}getSourceStackInteractionRect(n){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const r=n.find(a=>{var l;return a.id===((l=this.active)==null?void 0:l.parentStackId)});if(r)return this.active.sourceStackRect=r.rect,r.rect;const i=af(this.active.baseLayout,this.active.parentStackId);if(!i)return this.active.sourceStackRect;const s=i.children.find(a=>{var l;return a.type==="card"&&a.id!==((l=this.active)==null?void 0:l.nodeId)});if(s){const a=n.find(l=>l.id===s.id);if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(n,r,i,s){var v,A,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 l=(i.effectiveVelocity??0)<=P2;for(const I of o){const Z=I.rect;if(!Cn(n,r,Z))continue;const P=this.resolveTopLevelTargetForCard(n,r,I,I.logicalIndex,l);if(P)return P;if(!l&&((A=this.active)!=null&&A.hitTarget))return this.active.hitTarget}const u=this.getNearestTargetableZone(n,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,n)),p=this.resolveTopLevelTargetForCard(d,r,u,u.logicalIndex,l);if(p)return p;const y=u.rect.left+u.rect.width/2;return{type:"reorder",index:n<y?u.logicalIndex:u.logicalIndex+1}}getTopLevelReorderIndexForPointer(n,r,i,s){var u,d;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return((u=this.active)==null?void 0:u.sourceIndex)??0;for(const p of o){if(!Cn(n,r,p.rect))continue;const y=Xl(p.rect,Jl["reorder-before"]);if(Cn(n,r,y))return p.logicalIndex;const v=Xl(p.rect,Jl["reorder-after"]);if(Cn(n,r,v))return p.logicalIndex+1}const a=this.getNearestTargetableZone(n,o);if(!a)return((d=this.active)==null?void 0:d.sourceIndex)??0;const l=a.rect.left+a.rect.width/2;return n<l?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(n,r){const i=new Map(r.map(a=>[a.id,a])),s=[];let o=0;for(const a of n){const l=i.get(a.id);l&&l.type!=="drop-target"&&(l.type==="card"||l.type==="stack")&&(s.push({id:l.id,rect:a.rect,logicalIndex:o}),o+=1)}return s}resolveTopLevelTargetForCard(n,r,i,s,o){const a=i.rect;for(const l of A2){if(!o&&(l==="stack-above"||l==="stack-below"))continue;const u=Jl[l],d=Xl(a,u);if(Cn(n,r,d))return l==="stack-above"?{type:"stack",targetCardId:i.id,position:"above"}:l==="stack-below"?{type:"stack",targetCardId:i.id,position:"below"}:l==="reorder-before"?{type:"reorder",index:s}:{type:"reorder",index:s+1}}return null}getNearestTargetableZone(n,r){let i=null,s=Number.POSITIVE_INFINITY;for(const o of r){const a=o.rect.left,l=o.rect.left+o.rect.width,u=n<a?a-n:n>l?n-l:0;u<s&&(s=u,i=o)}return i}isPointerInsideDragBounds(n,r,i){return n>=i.left&&n<=i.left+i.width&&r>=i.top&&r<=i.top+i.height}}const lf=60,K2=80,cf=.5,uf=10;class J2{constructor(){b(this,"awaitingFreshWheelGesture",!1);b(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);b(this,"lastWheelDeltaX",0);b(this,"activeGestureType","none");b(this,"lastWheelGestureAt",Number.NEGATIVE_INFINITY)}markKeyboardNavigation(e){this.awaitingFreshWheelGesture=!0,this.lastWheelEventAt=e,this.activeGestureType="none"}reset(){this.awaitingFreshWheelGesture=!1,this.lastWheelEventAt=Number.NEGATIVE_INFINITY,this.lastWheelDeltaX=0,this.activeGestureType="none",this.lastWheelGestureAt=Number.NEGATIVE_INFINITY}decide(e){const{now:n,shiftKey:r,deltaX:i,deltaY:s,overArtifactContent:o}=e;n-this.lastWheelGestureAt>=lf&&(this.activeGestureType="none");const l=r&&s!==0,u=l?s:i,d=Math.abs(u),p=Math.abs(s);return this.activeGestureType==="vertical-artifact"&&o?d>=cf&&d>=p*uf?this.classifyHorizontal(n,u):(this.lastWheelGestureAt=n,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!l&&o&&p>0&&p>=d*uf?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,u):d<cf?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):l||d>p?this.classifyHorizontal(n,u):p>d?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,u)}classifyHorizontal(e,n){const r=e-this.lastWheelEventAt,i=Math.sign(this.lastWheelDeltaX),s=Math.sign(n),o=i!==0&&s!==0&&i!==s,a=i!==0&&Math.abs(n)>=Math.abs(this.lastWheelDeltaX)+K2;return this.awaitingFreshWheelGesture&&r<lf&&!o&&!a?{type:"ignore"}:(this.lastWheelEventAt=e,this.lastWheelDeltaX=n,this.lastWheelGestureAt=e,this.awaitingFreshWheelGesture=!1,this.activeGestureType="horizontal-filmstrip",{type:"scroll-horizontal",horizontalDelta:n})}}const X2=2,hf=1e3,Ro=1e-4;function df(t,e,n){if(t===0)return 0;const r=e.toPixels(Te({y:Qe})).y??0;return(n-r)/X2}function ec(t){const e=t.clientWidth>0?t.clientWidth:lr,n=t.clientHeight>0?t.clientHeight:la;let r=0,i=0;if(t.isConnected){const o=getComputedStyle(t);r=parseFloat(o.paddingTop)||0,i=parseFloat(o.paddingBottom)||0}const s=Math.max(1,n-r-i);return{width:e,height:s,offsetY:r}}class Q2 extends Event{constructor(n){super("scroll",{bubbles:!0,composed:!0});b(this,"scrollPosition");this.scrollPosition=n}}class xy extends Event{constructor(n){super("layout-change",{bubbles:!0,composed:!0});b(this,"layout");this.layout=n}}class eO extends HTMLElement{constructor(){super();b(this,"_layout",[]);b(this,"_scrollPosition",0);b(this,"layoutGrid",null);b(this,"layoutScroll",new $2(Te({x:0})));b(this,"scrollModelKey","");b(this,"resizeObserver",null);b(this,"renderPending",!1);b(this,"animateNextRender",!0);b(this,"wheelGesture",new J2);b(this,"dragController",new Y2);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",n=>{const r=of(n.projectedLayout),i=this.shouldApplyTrackOffset(n.projectedLayout,n.source.parentId),s=n.source.parentId?this.getStackChildAnchorCardId(n.source.parentId,n.nodeId):null;this.dragTrackOffsetXPx=i?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,r,n.nodeId,n.source.parentId,s,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=r,this.dragState={nodeId:n.nodeId,source:n.source,grabOffset:n.grabOffset,pointer:n.pointer,size:n.size,projectedLayout:n.projectedLayout},this.scheduleRender()});b(this,"onDragControllerDrop",n=>{this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.commitLayout(n.layout)});b(this,"onLayoutScrollInternal",n=>{const i=n.scroll.x??0;Math.abs(i-this._scrollPosition)<Ro||(this._scrollPosition=i,this.emitScrollPositionChanged(i),this.scheduleRender())});b(this,"handleKeyDown",n=>{if(n.key==="Escape"&&this.dragController.status!=="idle"){n.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(n.key==="ArrowRight"?(n.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(1)):n.key==="ArrowLeft"&&(n.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(-1)))});b(this,"handleWheel",n=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:n.shiftKey,deltaX:n.deltaX,deltaY:n.deltaY,overArtifactContent:!1});r.type==="scroll-horizontal"&&(n.preventDefault(),this.applyHorizontalWheel(r.horizontalDelta))});b(this,"handleWindowMessage",n=>{var o;if(this._layout.length===0)return;const r=this.findManagedArtifactFrame(n.source);if(!r||!this.isTrustedArtifactFrameMessage(n,r)||!pC(n.data))return;const i=this.wheelGesture.decide({now:Date.now(),shiftKey:n.data.shiftKey,deltaX:n.data.deltaX,deltaY:n.data.deltaY,overArtifactContent:!0});if(i.type==="scroll-horizontal"){this.applyHorizontalWheel(i.horizontalDelta);return}if(i.type!=="scroll-native")return;const s={type:"scroll",deltaX:0,deltaY:n.data.deltaY};(o=r.contentWindow)==null||o.postMessage(s,this.getArtifactFrameTargetOrigin(r))});b(this,"handlePointerDown",n=>{if(n.button!==0||this.dragController.status!=="idle")return;const r=n.target;if(!(r instanceof Element)||!r.closest("[drag-handle]")||r.closest("button, input, textarea, select, a, [role='button']"))return;const i=r.closest(".card-slot");if(!i)return;const s=i.getAttribute("data-layout-node-id");if(!s)return;const o=nO(this._layout,s);if(!o)return;const a=i.getBoundingClientRect();this.lastPointerX=n.clientX,this.lastPointerY=n.clientY,this.resetMotionTracking(n.clientX,n.clientY),this.focus(),this.dragController.start({nodeId:s,source:{index:o.topLevelIndex,parentId:o.sourceStackId},pointer:ke({x:n.clientX,y:n.clientY}),grabOffset:ke({x:n.clientX-a.left,y:n.clientY-a.top}),size:ke({x:a.width,y:a.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=n.pointerId;try{this.setPointerCapture(n.pointerId)}catch{}n.preventDefault()});b(this,"handleWindowPointerMove",n=>{this.lastPointerX=n.clientX,this.lastPointerY=n.clientY,this.updatePointerVelocity(n.clientX,n.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop()});b(this,"handleWindowPointerUp",n=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(n.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowPointerCancel",n=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(n.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"runDragFrame",n=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const r=Math.max(0,n-this.lastDragFrameTime)/hf;this.lastDragFrameTime=n,this.samplePointerVelocityAt(n,this.lastPointerX,this.lastPointerY);const i=this.getBoundingClientRect(),s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,i),o=this.getDragEdgeScrollDeltaPixels(s.x,i,r);this.scrollVelocityPxPerSec=r>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(n){this._layout=[...n],this.stopDragFrameLoop(),this.dragController.cancel(),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=Te({x:this._scrollPosition}),this.scheduleRender()}get layout(){return this._layout}commitLayout(n){this.layout=n,this.emitLayoutChanged()}set scrollPosition(n){Math.abs(n-this._scrollPosition)<Ro||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=Te({x:n}))}get scrollPosition(){return this._scrollPosition}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.focus(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("pointerdown",this.handlePointerDown),window.addEventListener("message",this.handleWindowMessage),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.render()),this.resizeObserver.observe(this)),this.render()}disconnectedCallback(){var n;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("message",this.handleWindowMessage),(n=this.resizeObserver)==null||n.disconnect(),this.resizeObserver=null,this.wheelGesture.reset(),this.detachDragListeners(),this.dragController.removeEventListener("change",this.onDragControllerChange),this.dragController.removeEventListener("drag",this.onDragControllerDrag),this.dragController.removeEventListener("drop",this.onDragControllerDrop),this.layoutScroll.removeEventListener("layout-scroll",this.onLayoutScrollInternal),this.dragController.dispose(),this.stopDragFrameLoop()}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(n,r){return new g2({basis:ke({x:Dn,y:Dn}),min:ke({x:pp,y:pp}),viewport:ke({x:n,y:r}),gap:ke({x:ge,y:ge})})}syncScrollModel(){const n=ec(this),i=Qi(this._layout).nodes.map(o=>o.width),s=`${n.width}x${n.height}:${i.join(",")}`;s===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=s,this.layoutGrid=this.createGrid(n.width,n.height),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(o=>Te({x:o}))}))}emitScrollPositionChanged(n){this.dispatchEvent(new Q2(n))}emitLayoutChanged(){this.dispatchEvent(new xy([...this._layout]))}shiftWindow(n){this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(n)}applyHorizontalWheel(n){this.syncScrollModel();const r=this.layoutGrid;if(!r)return;this.animateNextRender=!1;const i=r.toUnits(ke({x:n}));this.layoutScroll.wheel(Te({x:i.x??0}))}findManagedArtifactFrame(n){if(!n)return null;const r=this.querySelectorAll("iframe.artifact-frame");for(const i of r)if(i.contentWindow===n)return i;return null}isTrustedArtifactFrameMessage(n,r){if(n.origin==="null")return!0;const i=this.getArtifactFrameOrigin(r);return i===null||n.origin===i}getArtifactFrameTargetOrigin(n){const r=n.getAttribute("sandbox")??"";return new Set(r.split(/\s+/).filter(Boolean)).has("allow-same-origin")?this.getArtifactFrameOrigin(n)??"*":"*"}getArtifactFrameOrigin(n){const r=n.getAttribute("src")??n.src;if(!r)return null;try{return new URL(r,window.location.href).origin}catch{return null}}releaseActiveDragPointerCapture(){this.activeDragPointerId!==null&&this.releasePointerCaptureForEvent(this.activeDragPointerId)}releasePointerCaptureForEvent(n){try{this.hasPointerCapture(n)&&this.releasePointerCapture(n)}catch{}}attachDragListeners(){this.dragListenersAttached||(window.addEventListener("pointermove",this.handleWindowPointerMove),window.addEventListener("pointerup",this.handleWindowPointerUp),window.addEventListener("pointercancel",this.handleWindowPointerCancel),this.addEventListener("pointermove",this.handleWindowPointerMove),this.addEventListener("pointerup",this.handleWindowPointerUp),this.addEventListener("pointercancel",this.handleWindowPointerCancel),window.addEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!0)}detachDragListeners(){this.dragListenersAttached&&(window.removeEventListener("pointermove",this.handleWindowPointerMove),window.removeEventListener("pointerup",this.handleWindowPointerUp),window.removeEventListener("pointercancel",this.handleWindowPointerCancel),this.removeEventListener("pointermove",this.handleWindowPointerMove),this.removeEventListener("pointerup",this.handleWindowPointerUp),this.removeEventListener("pointercancel",this.handleWindowPointerCancel),window.removeEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!1,this.activeDragPointerId=null)}getDisplayModel(){if(this.dragController.status!=="active"||!this.dragState)return{layout:this._layout,activePlaceholderId:null,placeholdersById:new Map};const n=new Map;return n.set(this.dragState.nodeId,{id:this.dragState.nodeId,sourceCardId:this.dragState.nodeId}),{layout:of(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:n}}render(){const n=ec(this),r=this.createGrid(n.width,n.height);this.layoutGrid=r;const i=this.getDisplayModel(),s=i.layout,o=this.dragController.status==="active",a=Qi(s),l=a.nodes.map(O=>O.width),u=`${n.width}x${n.height}:${l.join(",")}`;!o&&u!==this.scrollModelKey&&(this.scrollModelKey=u,this.layoutScroll.rebuild({grid:r,nodeWidths:l.map(O=>Te({x:O}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const d=tO(s),p=r.unit.x??Dn,y=r.unit.y??Dn,v=o?this.dragTrackOffsetXPx:0,A=(this.layoutScroll.translate.x??0)+v,E=df(a.nodes.length,r,n.height),I=this.animateNextRender&&!o,Z=[`transform: translate(${A}px, ${E}px);`,`transition-duration: ${I?tx: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,V={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,V),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 n=this.getBoundingClientRect();if(this.dragController.status==="active"){const i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,n);this.syncDragTarget(i.x,i.y,n);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,n),this.dragController.status==="pending")return;const r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,n);(r.x!==this.lastPointerX||r.y!==this.lastPointerY)&&this.syncDragTarget(r.x,r.y,n)}syncDragTarget(n,r,i=this.getBoundingClientRect()){if(this.dragController.status==="idle")return;const s=this.getDisplayModel(),o=new Set(s.placeholdersById.keys()),a=this.dragController.status==="active"?this.dragTrackOffsetXPx:0,l=this.measureLayoutGeometry(s.layout,o,a);this.dragController.update({pointer:ke({x:n,y:r}),viewport:{left:i.left,top:i.top,width:i.width,height:i.height},geometry:l,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(n,r){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=n,this.motionSampleY=r}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(n,r){this.samplePointerVelocityAt(performance.now(),n,r)}samplePointerVelocityAt(n,r,i){if(this.motionSampleTime===0){this.motionSampleTime=n,this.motionSampleX=r,this.motionSampleY=i,this.pointerVelocityPxPerSec=0;return}const s=n-this.motionSampleTime;if(s<100)return;const o=r-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/s*hf,this.motionSampleTime=n,this.motionSampleX=r,this.motionSampleY=i}clampPointerToViewport(n,r,i){return{x:Math.max(i.left,Math.min(i.left+i.width,n)),y:Math.max(i.top,Math.min(i.top+i.height,r))}}isPointerOutsideViewport(n,r,i){return n<i.left||n>i.left+i.width||r<i.top||r>i.top+i.height}getDragEdgeScrollDeltaPixels(n,r,i){var u;const s=r.left+xo,o=r.left+r.width-xo,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??Dn,l=rx*a;if(n<s){const d=Math.max(0,Math.min(1,(s-n)/xo));return-(l*d**fp)*i}if(n>o){const d=Math.max(0,Math.min(1,(n-o)/xo));return l*d**fp*i}return 0}measureLayoutGeometry(n,r,i=0){const s=this.layoutGrid;if(!s)return[];const o=Qi(n),a=new Map(o.nodes.map(E=>[E.id,E.width])),l=s.toPixels(Te({y:Qe})).y??la,u=ec(this),d=(this.layoutScroll.translate.x??0)+i,p=df(o.nodes.length,s,u.height),y=u.offsetY+p,v=[];let A=d;for(const E of n){const I=a.get(E.id)??It,Z=s.toPixels(Te({x:I})).x??lr,P={left:A,top:y,width:Z,height:l};v.push({id:E.id,rect:P}),A+=Z+ge}return v}getPlaceholderPixelSize(n,r,i,s){if(!r)return s;for(const o of n.nodes)for(const a of o.cards)if(a.id===r)return{width:i.toPixels(Te({x:a.width})).x??s.width,height:i.toPixels(Te({y:a.height})).y??s.height};return s}renderDraggedPreview(n){const r=ih(this._layout,n);return r?this.renderContent(r,{isDragging:!0}):U``}shouldApplyTrackOffset(n,r){if(r)return!0;for(const i of n){if(i.type!=="stack")continue;if(i.children.some(o=>o.type==="drop-target")&&r!==i.id)return!0}return!1}computeDragTrackOffset(n,r,i,s,o,a){if(!n)return a;const l=s?o??this.getStableAnchorCardId(n,r,i):this.getStableAnchorNodeId(n,r,i);if(!l)return a;const u=s?ff(n,l,this.layoutGrid):gf(n,l,this.layoutGrid),d=s?ff(r,l,this.layoutGrid):gf(r,l,this.layoutGrid);return u===null||d===null?a:a+(u-d)}getStableAnchorCardId(n,r,i){const s=pf(n),o=new Set(pf(r));for(const a of s)if(a!==i&&o.has(a))return a;return null}getStableAnchorNodeId(n,r,i){const s=new Set(r.map(o=>o.id));for(const o of n)if(o.id!==i&&s.has(o.id))return o.id;return null}getStackChildAnchorCardId(n,r){const i=this._layout.find(o=>o.type==="stack"&&o.id===n);if(!i||i.type!=="stack")return null;const s=i.children.find(o=>o.type==="card"&&o.id!==r);return(s==null?void 0:s.id)??null}}function tO(t){const e=new Map;for(const n of t){if(n.type==="card"){e.set(n.id,n);continue}for(const r of n.children)if(r.type==="card")e.set(r.id,r);else for(const i of r.children)e.set(i.id,i)}return e}function nO(t,e){const n=t.findIndex(r=>r.type==="card"&&r.id===e);if(n!==-1)return{topLevelIndex:n};for(let r=0;r<t.length;r+=1){const i=t[r];if(!(!i||i.type!=="stack")&&i.children.some(s=>s.type==="card"&&s.id===e))return{topLevelIndex:r,sourceStackId:i.id}}return null}function pf(t){const e=[];for(const n of t){if(n.type==="card"){e.push(n.id);continue}if(n.type==="stack"){const r=n.children.find(i=>i.type==="card");r&&e.push(r.id)}}return e}function ff(t,e,n){if(!n)return null;const r=Qi(t),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of t){if(o.type==="card"&&o.id===e||o.type==="stack"&&o.children.some(u=>u.type==="card"&&u.id===e))return s;const a=i.get(o.id)??It,l=n.toPixels(Te({x:a})).x??lr;s+=l+ge}return null}function gf(t,e,n){if(!n)return null;const r=Qi(t),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of t){if(o.id===e)return s;const a=i.get(o.id)??It,l=n.toPixels(Te({x:a})).x??lr;s+=l+ge}return null}customElements.get("layout-view")||customElements.define("layout-view",eO);class rO extends HTMLElement{constructor(){super(...arguments);b(this,"screenManager",Ge.resolve("ScreenManager"));b(this,"boundModel",null);b(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});b(this,"handleModelChange",()=>{this.render()});b(this,"handleCloseArtifact",n=>{n instanceof by&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(n.artifactID)});b(this,"handleScrollPositionChanged",n=>{const r=n;typeof r.scrollPosition=="number"&&Number.isFinite(r.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(r.scrollPosition)});b(this,"handleLayoutChanged",n=>{n instanceof xy&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(n.layout)})}connectedCallback(){this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.rebindModel(),this.render()}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged),this.unbindModel()}rebindModel(){const n=this.screenManager.activeScreen;this.boundModel!==n&&(this.unbindModel(),this.boundModel=n,n&&n.addEventListener("change",this.handleModelChange))}unbindModel(){this.boundModel&&(this.boundModel.removeEventListener("change",this.handleModelChange),this.boundModel=null)}buildArtifactMap(){const n=this.screenManager.activeScreen;return n?new Map(n.artifacts):new Map}render(){const n=this.screenManager.activeScreen,r=(n==null?void 0:n.layout)??[],i=this.buildArtifactMap();if(r.length===0){Re(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 l=i.get(o.artifactID);return!l||!n?U``:U`<artifact-view
|
|
210
|
+
.artifact=${l}
|
|
211
|
+
.screen=${n}
|
|
212
|
+
.viewURL=${n.server.getViewURL(l)}
|
|
213
|
+
.contentURL=${n.server.getContentURL(l.id)}
|
|
214
|
+
.dragging=${a.isDragging}
|
|
215
|
+
></artifact-view>`}}
|
|
216
|
+
.scrollPosition=${(n==null?void 0:n.scrollPosition)??0}
|
|
217
|
+
@scroll=${this.handleScrollPositionChanged}
|
|
218
|
+
@layout-change=${this.handleLayoutChanged}
|
|
219
|
+
@close-artifact=${this.handleCloseArtifact}
|
|
220
|
+
></layout-view>
|
|
221
|
+
`,this)}}customElements.define("screen-view",rO);var $a,Jr,Ms,qt,$y,Ay,Xc;class iO extends HTMLElement{constructor(){super(...arguments);w(this,qt);w(this,$a,Ge.resolve("ScreenManager"));w(this,Jr,Ge.resolve("ServerManager"));w(this,Ms,()=>{g(this,qt,Xc).call(this)})}connectedCallback(){c(this,Jr).addEventListener("change",c(this,Ms)),g(this,qt,Xc).call(this)}disconnectedCallback(){c(this,Jr).removeEventListener("change",c(this,Ms))}}$a=new WeakMap,Jr=new WeakMap,Ms=new WeakMap,qt=new WeakSet,$y=function(n,r){c(this,$a).setActive(n,r)},Ay=function(){for(const n of c(this,Jr).servers.values())return n;return null},Xc=function(){const n=g(this,qt,Ay).call(this),i=(n?[...n.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=${()=>n&&g(this,qt,$y).call(this,n.url,o.id)}
|
|
230
|
+
>
|
|
231
|
+
${o.name}
|
|
232
|
+
</button>
|
|
233
|
+
</li>
|
|
234
|
+
`)}
|
|
235
|
+
</ul>
|
|
236
|
+
`;Re(s,this)};customElements.get("home-screen")||customElements.define("home-screen",iO);const tc=new WeakMap,mf=Object.prototype.hasOwnProperty,sO=(()=>{const t=new Set;let e=HTMLElement.prototype;for(;e;){for(const n of Object.getOwnPropertyNames(e))t.add(n);if(e===Node.prototype)break;e=Object.getPrototypeOf(e)}return t})();function oO(t,e){if(t===Boolean)return e!==null;if(e!==null)return t===Number?Number(e):e}var Ls,Qc,nr,nt,Tt,Xr,rr,Qr,Ie,Gi,Ty,Cy,Iy,Qo;const Mn=class Mn extends HTMLElement{constructor(){var i;super();w(this,Ie);w(this,nr,new Map);w(this,nt,new Map);w(this,Tt,new Map);w(this,Xr,!1);w(this,rr,!1);w(this,Qr,!1);const n=g(i=Mn,Ls,Qc).call(i,this.constructor),r=this;for(const s of n.properties)mf.call(r,s)&&(c(this,Tt).set(s,r[s]),delete r[s])}static get observedAttributes(){var n;return g(n=Mn,Ls,Qc).call(n,this).observedAttributes}connected(){}disconnected(){}changed(n){}connectedCallback(){if(g(this,Ie,Iy).call(this),!c(this,rr))for(const n of g(this,Ie,Gi).call(this).properties)c(this,nt).has(n)||c(this,nt).set(n,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(n,r,i){if(r===i)return;const s=g(this,Ie,Gi).call(this).byAttr.get(n);s&&(c(this,Tt).has(s.property)||(this[s.property]=oO(s.type,i)))}};Ls=new WeakSet,Qc=function(n){const r=tc.get(n);if(r)return r;const i=[...n.properties??[]],s=n.attributes??{},o=new Map,a=new Map;for(const u of i)if(sO.has(u))throw new Error(`Reactive property "${u}" collides with a built-in DOM property. Rename it to avoid shadowing the platform API.`);for(const[u,d]of Object.entries(s)){if(u.includes("-")&&d.property===void 0)throw new Error(`Attribute "${u}" must declare a "property" name because kebab-case cannot be a property.`);const p=d.property??u;if(!i.includes(p))throw new Error(`Attribute '${u}' references property '${p}', which isn't declared in \`static properties\`. Add it to \`properties\` to make it reactive.`);const y={attribute:u,property:p,type:d.type};o.set(u,y),a.set(p,y)}for(const u of i){const d=Object.getOwnPropertyDescriptor(n.prototype,u);if((d==null?void 0:d.get)!==void 0||(d==null?void 0:d.set)!==void 0)throw new Error(`Observed property "${u}" cannot define a custom getter/setter. Use changed() for side effects instead.`);d===void 0&&Object.defineProperty(n.prototype,u,{configurable:!0,enumerable:!0,get(){return c(this,nr).get(u)},set(p){g(this,Ie,Ty).call(this,u,p)}})}const l={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return tc.set(n,l),l},nr=new WeakMap,nt=new WeakMap,Tt=new WeakMap,Xr=new WeakMap,rr=new WeakMap,Qr=new WeakMap,Ie=new WeakSet,Gi=function(){return tc.get(this.constructor)},Ty=function(n,r){if(!c(this,Qr)&&c(this,Tt).has(n))return;const i=c(this,nr).get(n);Object.is(i,r)||(c(this,nt).has(n)||c(this,nt).set(n,i),c(this,nr).set(n,r),c(this,Tt).delete(n),g(this,Ie,Cy).call(this,n,r),this.isConnected&&g(this,Ie,Qo).call(this))},Cy=function(n,r){const i=g(this,Ie,Gi).call(this).byProp.get(n);if(!i)return;const{attribute:s,type:o}=i;if(o===Boolean){const l=this.hasAttribute(s);r&&!l?this.setAttribute(s,""):!r&&l&&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)},Iy=function(){const n=this,r=g(this,Ie,Gi).call(this);for(const i of r.properties){if(!mf.call(n,i))continue;const s=n[i];delete n[i],!(c(this,Tt).has(i)||c(this,nr).has(i))&&(n[i]=s)}k(this,Qr,!0);try{for(const[i,s]of c(this,Tt))n[i]=s;c(this,Tt).clear()}finally{k(this,Qr,!1)}},Qo=function(){c(this,Xr)||!this.isConnected||c(this,rr)&&c(this,nt).size===0||(k(this,Xr,!0),queueMicrotask(()=>{if(k(this,Xr,!1),!this.isConnected||c(this,rr)&&c(this,nt).size===0)return;const n=new Map(c(this,nt));c(this,nt).clear(),k(this,rr,!0);try{this.changed(n)}catch(r){console.error(r)}this.isConnected&&c(this,nt).size>0&&g(this,Ie,Qo).call(this)}))},w(Mn,Ls),b(Mn,"properties"),b(Mn,"attributes");let as=Mn;/**
|
|
237
|
+
* @license
|
|
238
|
+
* Copyright 2020 Google LLC
|
|
239
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
240
|
+
*/const aO=t=>t.strings===void 0;/**
|
|
241
|
+
* @license
|
|
242
|
+
* Copyright 2017 Google LLC
|
|
243
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
244
|
+
*/const ts=(t,e)=>{var r;const n=t._$AN;if(n===void 0)return!1;for(const i of n)(r=i._$AO)==null||r.call(i,e,!1),ts(i,e);return!0},ma=t=>{let e,n;do{if((e=t._$AM)===void 0)break;n=e._$AN,n.delete(t),t=e}while((n==null?void 0:n.size)===0)},Py=t=>{for(let e;e=t._$AM;t=e){let n=e._$AN;if(n===void 0)e._$AN=n=new Set;else if(n.has(t))break;n.add(t),uO(e)}};function lO(t){this._$AN!==void 0?(ma(this),this._$AM=t,Py(this)):this._$AM=t}function cO(t,e=!1,n=0){const r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(e)if(Array.isArray(r))for(let s=n;s<r.length;s++)ts(r[s],!1),ma(r[s]);else r!=null&&(ts(r,!1),ma(r));else ts(this,t)}const uO=t=>{t.type==qv.CHILD&&(t._$AP??(t._$AP=cO),t._$AQ??(t._$AQ=lO))};class hO extends Yv{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,n,r){super._$AT(e,n,r),Py(this),this.isConnected=e._$AU}_$AO(e,n=!0){var r,i;e!==this.isConnected&&(this.isConnected=e,e?(r=this.reconnected)==null||r.call(this):(i=this.disconnected)==null||i.call(this)),n&&(ts(this,e),ma(this))}setValue(e){if(aO(this._$Ct))this._$Ct._$AI(e,this);else{const n=[...this._$Ct._$AH];n[this._$Ci]=e,this._$Ct._$AI(n,this,0)}}disconnected(){}reconnected(){}}/**
|
|
245
|
+
* @license
|
|
246
|
+
* Copyright 2020 Google LLC
|
|
247
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
248
|
+
*/const Do=()=>new dO;class dO{}const nc=new WeakMap,Oo=nh(class extends hO{render(t){return ae}update(t,[e]){var r;const n=e!==this.G;return n&&this.G!==void 0&&this.rt(void 0),(n||this.lt!==this.ct)&&(this.G=e,this.ht=(r=t.options)==null?void 0:r.host,this.rt(this.ct=t.element)),ae}rt(t){if(this.isConnected||(t=void 0),typeof this.G=="function"){const e=this.ht??globalThis;let n=nc.get(e);n===void 0&&(n=new WeakMap,nc.set(e,n)),n.get(this.G)!==void 0&&this.G.call(this.ht,void 0),n.set(this.G,t),t!==void 0&&this.G.call(this.ht,t)}else this.G.value=t}get lt(){var t,e;return typeof this.G=="function"?(t=nc.get(this.ht??globalThis))==null?void 0:t.get(this.G):(e=this.G)==null?void 0:e.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Je,hn,ei,ti,Ns,ir,sr,ie,Pe,Ry,Us,Fs,eu,tu,Aa,Ta,Ca,Ia,Pa,Ra,Da,Zs,Hs,qi,Dy,dt;class pO extends as{constructor(){super(...arguments);w(this,Pe);w(this,Je,Ge.resolve("ScreenManager"));w(this,hn,null);w(this,ei,new DisposableStack);w(this,ti,Do());w(this,Ns,Do());w(this,ir,Do());w(this,sr,Do());w(this,ie,{kind:"none"});w(this,Us,()=>{g(this,Pe,eu).call(this),c(this,dt).call(this)});w(this,Fs,()=>{c(this,dt).call(this)});w(this,Aa,()=>{c(this,Je).clearActive()});w(this,Ta,n=>{c(this,ie).kind!=="none"&&(n.stopImmediatePropagation(),g(this,Pe,qi).call(this))});w(this,Ca,()=>{var r;const n=c(this,Je).activeScreen;n&&((r=c(this,ti).value)==null||r.close(),k(this,ie,{kind:"rename",draft:n.name}),c(this,dt).call(this))});w(this,Ia,()=>{var n;c(this,Je).activeScreen&&((n=c(this,ti).value)==null||n.close(),k(this,ie,{kind:"delete",error:null}),c(this,dt).call(this))});w(this,Pa,n=>{if(c(this,ie).kind!=="rename")return;const r=n.target;r instanceof HTMLInputElement&&k(this,ie,{kind:"rename",draft:r.value})});w(this,Ra,n=>{if(n.preventDefault(),c(this,ie).kind!=="rename")return;const r=c(this,Je).activeScreen;if(!r)return;const i=c(this,ie).draft.trim();i.length>0&&i!==r.name&&r.rename(i),g(this,Pe,qi).call(this)});w(this,Da,async()=>{if(c(this,ie).kind!=="delete")return;const n=c(this,Je).activeScreen;if(n){k(this,ie,{kind:"delete",error:null});try{await n.remove(),c(this,Je).clearActive(),g(this,Pe,qi).call(this)}catch(r){k(this,ie,{kind:"delete",error:r instanceof Error?r.message:"Failed to delete screen."}),c(this,dt).call(this)}}});w(this,Zs,()=>{g(this,Pe,qi).call(this)});w(this,Hs,()=>{c(this,ie).kind!=="none"&&(k(this,ie,{kind:"none"}),c(this,dt).call(this))});w(this,dt,()=>{const n=U`
|
|
249
|
+
<button
|
|
250
|
+
icon-only
|
|
251
|
+
variant="ghost"
|
|
252
|
+
class="home"
|
|
253
|
+
type="button"
|
|
254
|
+
aria-label="Home"
|
|
255
|
+
@click=${c(this,Aa)}
|
|
256
|
+
>
|
|
257
|
+
${GD({weight:"fill"})}
|
|
258
|
+
</button>
|
|
259
|
+
`;Re(U`${n}${g(this,Pe,Dy).call(this)}`,this);const r=c(this,Ns).value??null;c(this,ir).value&&(c(this,ir).value.anchor=r),c(this,sr).value&&(c(this,sr).value.anchor=r)})}connected(){c(this,Je).addEventListener("active-screen-changed",c(this,Us)),g(this,Pe,eu).call(this),c(this,dt).call(this),g(this,Pe,Ry).call(this),c(this,ei).defer(()=>{c(this,Je).removeEventListener("active-screen-changed",c(this,Us)),g(this,Pe,tu).call(this)})}disconnected(){c(this,ei).dispose(),k(this,ei,new DisposableStack)}}Je=new WeakMap,hn=new WeakMap,ei=new WeakMap,ti=new WeakMap,Ns=new WeakMap,ir=new WeakMap,sr=new WeakMap,ie=new WeakMap,Pe=new WeakSet,Ry=async function(){const n=await eh(this);this.setAttribute("tone",n)},Us=new WeakMap,Fs=new WeakMap,eu=function(){var r;const n=c(this,Je).activeScreen;c(this,hn)!==n&&(g(this,Pe,tu).call(this),k(this,hn,n),(r=c(this,hn))==null||r.addEventListener("change",c(this,Fs)))},tu=function(){var n;(n=c(this,hn))==null||n.removeEventListener("change",c(this,Fs)),k(this,hn,null)},Aa=new WeakMap,Ta=new WeakMap,Ca=new WeakMap,Ia=new WeakMap,Pa=new WeakMap,Ra=new WeakMap,Da=new WeakMap,Zs=new WeakMap,Hs=new WeakMap,qi=function(){const n=c(this,ie).kind==="rename"?c(this,ir).value:c(this,ie).kind==="delete"?c(this,sr).value:null;n&&(n.open=!1),k(this,ie,{kind:"none"}),c(this,dt).call(this)},Dy=function(){const n=c(this,Je).activeScreen;if(!n)return null;const r=c(this,ie).kind==="rename"?c(this,ie).draft:"",i=c(this,ie).kind==="delete"?c(this,ie).error:null;return U`
|
|
260
|
+
<span class="separator" aria-hidden="true">
|
|
261
|
+
${jD()}
|
|
262
|
+
</span>
|
|
263
|
+
<dropdown-menu ${Oo(c(this,ti))}>
|
|
264
|
+
<button
|
|
265
|
+
slot="trigger"
|
|
266
|
+
type="button"
|
|
267
|
+
variant="ghost"
|
|
268
|
+
aria-label=${`Screen actions for ${n.name}`}
|
|
269
|
+
?data-active=${c(this,ie).kind!=="none"}
|
|
270
|
+
@click=${c(this,Ta)}
|
|
271
|
+
${Oo(c(this,Ns))}
|
|
272
|
+
>
|
|
273
|
+
${n.name}
|
|
274
|
+
</button>
|
|
275
|
+
<dropdown-group>
|
|
276
|
+
<dropdown-item action @click=${c(this,Ca)}>
|
|
277
|
+
${qD()} Rename
|
|
278
|
+
</dropdown-item>
|
|
279
|
+
<dropdown-item action danger @click=${c(this,Ia)}>
|
|
280
|
+
${YD()} Delete
|
|
281
|
+
</dropdown-item>
|
|
282
|
+
</dropdown-group>
|
|
283
|
+
</dropdown-menu>
|
|
284
|
+
<ui-popover
|
|
285
|
+
class="rename-popover"
|
|
286
|
+
?open=${c(this,ie).kind==="rename"}
|
|
287
|
+
@close=${c(this,Hs)}
|
|
288
|
+
${Oo(c(this,ir))}
|
|
289
|
+
>
|
|
290
|
+
<form class="screen-form" @submit=${c(this,Ra)}>
|
|
291
|
+
<label class="field">
|
|
292
|
+
<span>Screen name</span>
|
|
293
|
+
<input
|
|
294
|
+
type="text"
|
|
295
|
+
.value=${r}
|
|
296
|
+
@input=${c(this,Pa)}
|
|
297
|
+
/>
|
|
298
|
+
</label>
|
|
299
|
+
<div class="actions">
|
|
300
|
+
<button type="button" @click=${c(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=${c(this,ie).kind==="delete"}
|
|
308
|
+
@close=${c(this,Hs)}
|
|
309
|
+
${Oo(c(this,sr))}
|
|
310
|
+
>
|
|
311
|
+
<div class="screen-form">
|
|
312
|
+
<p class="confirm-text">Delete "${n.name}"?</p>
|
|
313
|
+
${i?U`<p class="error">${i}</p>`:ae}
|
|
314
|
+
<div class="actions">
|
|
315
|
+
<button type="button" @click=${c(this,Zs)}>Cancel</button>
|
|
316
|
+
<button
|
|
317
|
+
type="button"
|
|
318
|
+
variant="danger"
|
|
319
|
+
@click=${c(this,Da)}
|
|
320
|
+
>
|
|
321
|
+
Delete
|
|
322
|
+
</button>
|
|
323
|
+
</div>
|
|
324
|
+
</div>
|
|
325
|
+
</ui-popover>
|
|
326
|
+
`},dt=new WeakMap;customElements.define("screen-breadcrumb",pO);var Oa,za,ni,bn,Oy,zy,Ma,My;class fO extends HTMLElement{constructor(){super(...arguments);w(this,bn);w(this,Oa,Ge.resolve("ServerManager"));w(this,za,Ge.resolve("ScreenManager"));w(this,ni,!1);w(this,Ma,async()=>{if(c(this,ni))return;const n=g(this,bn,zy).call(this);if(n){k(this,ni,!0);try{const r=await n.createScreen(gO(new Date));c(this,za).setActive(n.url,r.id)}catch{}finally{k(this,ni,!1)}}})}connectedCallback(){g(this,bn,My).call(this),g(this,bn,Oy).call(this)}}Oa=new WeakMap,za=new WeakMap,ni=new WeakMap,bn=new WeakSet,Oy=async function(){const n=await eh(this);this.setAttribute("tone",n)},zy=function(){for(const n of c(this,Oa).servers.values())return n;return null},Ma=new WeakMap,My=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=${c(this,Ma)}
|
|
334
|
+
>
|
|
335
|
+
${WD({size:16,weight:"bold"})}
|
|
336
|
+
</button>
|
|
337
|
+
`,this)};function gO(t){const e=t.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),n=12,r=t.getHours(),i=r%n===0?n:r%n,s=t.getMinutes().toString().padStart(2,"0"),o=r>=n?"pm":"am";return`${e} at ${i}:${s}${o}`}customElements.define("screen-create-button",fO);function mO(t,e){let n=null;const r=()=>e((n==null?void 0:n.messages)??[]),i=()=>{const o=t.getActiveClient();o!==n&&(n==null||n.removeEventListener("change",r),n=o,n&&(n.addEventListener("change",r),n.connect().catch(a=>{console.error("ACPClient.connect() failed",a)})),r())};t.addEventListener("change",i),i();const s=()=>{t.removeEventListener("change",i),n==null||n.removeEventListener("change",r),n=null};return{dispose:s,[Symbol.dispose](){s()}}}/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */const{entries:Ly,setPrototypeOf:vf,isFrozen:vO,getPrototypeOf:yO,getOwnPropertyDescriptor:bO}=Object;let{freeze:Ne,seal:st,create:ea}=Object,{apply:nu,construct:ru}=typeof Reflect<"u"&&Reflect;Ne||(Ne=function(e){return e});st||(st=function(e){return e});nu||(nu=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];return e.apply(n,i)});ru||(ru=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return new e(...r)});const zo=Ue(Array.prototype.forEach),wO=Ue(Array.prototype.lastIndexOf),yf=Ue(Array.prototype.pop),Di=Ue(Array.prototype.push),SO=Ue(Array.prototype.splice),ta=Ue(String.prototype.toLowerCase),rc=Ue(String.prototype.toString),ic=Ue(String.prototype.match),Oi=Ue(String.prototype.replace),_O=Ue(String.prototype.indexOf),kO=Ue(String.prototype.trim),Ye=Ue(Object.prototype.hasOwnProperty),Oe=Ue(RegExp.prototype.test),zi=EO(TypeError);function Ue(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return nu(t,e,r)}}function EO(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return ru(t,n)}}function j(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ta;vf&&vf(t,null);let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){const s=n(i);s!==i&&(vO(e)||(e[r]=s),i=s)}t[i]=!0}return t}function xO(t){for(let e=0;e<t.length;e++)Ye(t,e)||(t[e]=null);return t}function _t(t){const e=ea(null);for(const[n,r]of Ly(t))Ye(t,n)&&(Array.isArray(r)?e[n]=xO(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=_t(r):e[n]=r);return e}function Mi(t,e){for(;t!==null;){const r=bO(t,e);if(r){if(r.get)return Ue(r.get);if(typeof r.value=="function")return Ue(r.value)}t=yO(t)}function n(){return null}return n}const bf=Ne(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),sc=Ne(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),oc=Ne(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),$O=Ne(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ac=Ne(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),AO=Ne(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),wf=Ne(["#text"]),Sf=Ne(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),lc=Ne(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),_f=Ne(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Mo=Ne(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),TO=st(/\{\{[\w\W]*|[\w\W]*\}\}/gm),CO=st(/<%[\w\W]*|[\w\W]*%>/gm),IO=st(/\$\{[\w\W]*/gm),PO=st(/^data-[\-\w.\u00B7-\uFFFF]+$/),RO=st(/^aria-[\-\w]+$/),Ny=st(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),DO=st(/^(?:\w+script|data):/i),OO=st(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Uy=st(/^html$/i),zO=st(/^[a-z][.\w]*(-[.\w]+)+$/i);var kf=Object.freeze({__proto__:null,ARIA_ATTR:RO,ATTR_WHITESPACE:OO,CUSTOM_ELEMENT:zO,DATA_ATTR:PO,DOCTYPE_NAME:Uy,ERB_EXPR:CO,IS_ALLOWED_URI:Ny,IS_SCRIPT_OR_DATA:DO,MUSTACHE_EXPR:TO,TMPLIT_EXPR:IO});const Li={element:1,text:3,progressingInstruction:7,comment:8,document:9},MO=function(){return typeof window>"u"?null:window},LO=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(r=n.getAttribute(i));const s="dompurify"+(r?"#"+r:"");try{return e.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Ef=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Fy(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:MO();const e=L=>Fy(L);if(e.version="3.3.3",e.removed=[],!t||!t.document||t.document.nodeType!==Li.document||!t.Element)return e.isSupported=!1,e;let{document:n}=t;const r=n,i=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:u,NamedNodeMap:d=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:p,DOMParser:y,trustedTypes:v}=t,A=l.prototype,E=Mi(A,"cloneNode"),I=Mi(A,"remove"),Z=Mi(A,"nextSibling"),P=Mi(A,"childNodes"),V=Mi(A,"parentNode");if(typeof o=="function"){const L=n.createElement("template");L.content&&L.content.ownerDocument&&(n=L.content.ownerDocument)}let O,H="";const{implementation:N,createNodeIterator:ce,createDocumentFragment:ue,getElementsByTagName:ki}=n,{importNode:lo}=r;let xe=Ef();e.isSupported=typeof Ly=="function"&&typeof V=="function"&&N&&N.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:xn,ERB_EXPR:vt,TMPLIT_EXPR:Qt,DATA_ATTR:il,ARIA_ATTR:co,IS_SCRIPT_OR_DATA:rb,ATTR_WHITESPACE:mh,CUSTOM_ELEMENT:ib}=kf;let{IS_ALLOWED_URI:vh}=kf,Se=null;const yh=j({},[...bf,...sc,...oc,...ac,...wf]);let $e=null;const bh=j({},[...Sf,...lc,..._f,...Mo]);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}})),Ei=null,uo=null;const en=Object.seal(ea(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let wh=!0,sl=!0,Sh=!1,_h=!0,yr=!1,ho=!0,$n=!1,ol=!1,al=!1,br=!1,po=!1,fo=!1,kh=!0,Eh=!1;const sb="user-content-";let ll=!0,xi=!1,wr={},yt=null;const cl=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 xh=null;const $h=j({},["audio","video","img","source","image","track"]);let ul=null;const Ah=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",Pt="http://www.w3.org/1999/xhtml";let Sr=Pt,hl=!1,dl=null;const ob=j({},[go,mo,Pt],rc);let vo=j({},["mi","mo","mn","ms","mtext"]),yo=j({},["annotation-xml"]);const ab=j({},["title","style","font","a","script"]);let $i=null;const lb=["application/xhtml+xml","text/html"],cb="text/html";let be=null,_r=null;const ub=n.createElement("form"),Th=function(m){return m instanceof RegExp||m instanceof Function},pl=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(_r&&_r===m)){if((!m||typeof m!="object")&&(m={}),m=_t(m),$i=lb.indexOf(m.PARSER_MEDIA_TYPE)===-1?cb:m.PARSER_MEDIA_TYPE,be=$i==="application/xhtml+xml"?rc:ta,Se=Ye(m,"ALLOWED_TAGS")?j({},m.ALLOWED_TAGS,be):yh,$e=Ye(m,"ALLOWED_ATTR")?j({},m.ALLOWED_ATTR,be):bh,dl=Ye(m,"ALLOWED_NAMESPACES")?j({},m.ALLOWED_NAMESPACES,rc):ob,ul=Ye(m,"ADD_URI_SAFE_ATTR")?j(_t(Ah),m.ADD_URI_SAFE_ATTR,be):Ah,xh=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):cl,Ei=Ye(m,"FORBID_TAGS")?j({},m.FORBID_TAGS,be):_t({}),uo=Ye(m,"FORBID_ATTR")?j({},m.FORBID_ATTR,be):_t({}),wr=Ye(m,"USE_PROFILES")?m.USE_PROFILES:!1,wh=m.ALLOW_ARIA_ATTR!==!1,sl=m.ALLOW_DATA_ATTR!==!1,Sh=m.ALLOW_UNKNOWN_PROTOCOLS||!1,_h=m.ALLOW_SELF_CLOSE_IN_ATTR!==!1,yr=m.SAFE_FOR_TEMPLATES||!1,ho=m.SAFE_FOR_XML!==!1,$n=m.WHOLE_DOCUMENT||!1,br=m.RETURN_DOM||!1,po=m.RETURN_DOM_FRAGMENT||!1,fo=m.RETURN_TRUSTED_TYPE||!1,al=m.FORCE_BODY||!1,kh=m.SANITIZE_DOM!==!1,Eh=m.SANITIZE_NAMED_PROPS||!1,ll=m.KEEP_CONTENT!==!1,xi=m.IN_PLACE||!1,vh=m.ALLOWED_URI_REGEXP||Ny,Sr=m.NAMESPACE||Pt,vo=m.MATHML_TEXT_INTEGRATION_POINTS||vo,yo=m.HTML_INTEGRATION_POINTS||yo,me=m.CUSTOM_ELEMENT_HANDLING||{},m.CUSTOM_ELEMENT_HANDLING&&Th(m.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(me.tagNameCheck=m.CUSTOM_ELEMENT_HANDLING.tagNameCheck),m.CUSTOM_ELEMENT_HANDLING&&Th(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),yr&&(sl=!1),po&&(br=!0),wr&&(Se=j({},wf),$e=ea(null),wr.html===!0&&(j(Se,bf),j($e,Sf)),wr.svg===!0&&(j(Se,sc),j($e,lc),j($e,Mo)),wr.svgFilters===!0&&(j(Se,oc),j($e,lc),j($e,Mo)),wr.mathMl===!0&&(j(Se,ac),j($e,_f),j($e,Mo))),Ye(m,"ADD_TAGS")||(en.tagCheck=null),Ye(m,"ADD_ATTR")||(en.attributeCheck=null),m.ADD_TAGS&&(typeof m.ADD_TAGS=="function"?en.tagCheck=m.ADD_TAGS:(Se===yh&&(Se=_t(Se)),j(Se,m.ADD_TAGS,be))),m.ADD_ATTR&&(typeof m.ADD_ATTR=="function"?en.attributeCheck=m.ADD_ATTR:($e===bh&&($e=_t($e)),j($e,m.ADD_ATTR,be))),m.ADD_URI_SAFE_ATTR&&j(ul,m.ADD_URI_SAFE_ATTR,be),m.FORBID_CONTENTS&&(yt===cl&&(yt=_t(yt)),j(yt,m.FORBID_CONTENTS,be)),m.ADD_FORBID_CONTENTS&&(yt===cl&&(yt=_t(yt)),j(yt,m.ADD_FORBID_CONTENTS,be)),ll&&(Se["#text"]=!0),$n&&j(Se,["html","head","body"]),Se.table&&(j(Se,["tbody"]),delete Ei.tbody),m.TRUSTED_TYPES_POLICY){if(typeof m.TRUSTED_TYPES_POLICY.createHTML!="function")throw zi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof m.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw zi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');O=m.TRUSTED_TYPES_POLICY,H=O.createHTML("")}else O===void 0&&(O=LO(v,i)),O!==null&&typeof H=="string"&&(H=O.createHTML(""));Ne&&Ne(m),_r=m}},Ch=j({},[...sc,...oc,...$O]),Ih=j({},[...ac,...AO]),hb=function(m){let T=V(m);(!T||!T.tagName)&&(T={namespaceURI:Sr,tagName:"template"});const R=ta(m.tagName),se=ta(T.tagName);return dl[m.namespaceURI]?m.namespaceURI===mo?T.namespaceURI===Pt?R==="svg":T.namespaceURI===go?R==="svg"&&(se==="annotation-xml"||vo[se]):!!Ch[R]:m.namespaceURI===go?T.namespaceURI===Pt?R==="math":T.namespaceURI===mo?R==="math"&&yo[se]:!!Ih[R]:m.namespaceURI===Pt?T.namespaceURI===mo&&!yo[se]||T.namespaceURI===go&&!vo[se]?!1:!Ih[R]&&(ab[R]||!Ch[R]):!!($i==="application/xhtml+xml"&&dl[m.namespaceURI]):!1},bt=function(m){Di(e.removed,{element:m});try{V(m).removeChild(m)}catch{I(m)}},An=function(m,T){try{Di(e.removed,{attribute:T.getAttributeNode(m),from:T})}catch{Di(e.removed,{attribute:null,from:T})}if(T.removeAttribute(m),m==="is")if(br||po)try{bt(T)}catch{}else try{T.setAttribute(m,"")}catch{}},Ph=function(m){let T=null,R=null;if(al)m="<remove></remove>"+m;else{const ve=ic(m,/^[\r\n\t ]+/);R=ve&&ve[0]}$i==="application/xhtml+xml"&&Sr===Pt&&(m='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+m+"</body></html>");const se=O?O.createHTML(m):m;if(Sr===Pt)try{T=new y().parseFromString(se,$i)}catch{}if(!T||!T.documentElement){T=N.createDocument(Sr,"template",null);try{T.documentElement.innerHTML=hl?H:se}catch{}}const De=T.body||T.documentElement;return m&&R&&De.insertBefore(n.createTextNode(R),De.childNodes[0]||null),Sr===Pt?ki.call(T,$n?"html":"body")[0]:$n?T.documentElement:De},Rh=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)},fl=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")},Dh=function(m){return typeof a=="function"&&m instanceof a};function Rt(L,m,T){zo(L,R=>{R.call(e,m,T,_r)})}const Oh=function(m){let T=null;if(Rt(xe.beforeSanitizeElements,m,null),fl(m))return bt(m),!0;const R=be(m.nodeName);if(Rt(xe.uponSanitizeElement,m,{tagName:R,allowedTags:Se}),ho&&m.hasChildNodes()&&!Dh(m.firstElementChild)&&Oe(/<[/\w!]/g,m.innerHTML)&&Oe(/<[/\w!]/g,m.textContent)||m.nodeType===Li.progressingInstruction||ho&&m.nodeType===Li.comment&&Oe(/<[/\w]/g,m.data))return bt(m),!0;if(!(en.tagCheck instanceof Function&&en.tagCheck(R))&&(!Se[R]||Ei[R])){if(!Ei[R]&&Mh(R)&&(me.tagNameCheck instanceof RegExp&&Oe(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R)))return!1;if(ll&&!yt[R]){const se=V(m)||m.parentNode,De=P(m)||m.childNodes;if(De&&se){const ve=De.length;for(let Fe=ve-1;Fe>=0;--Fe){const Dt=E(De[Fe],!0);Dt.__removalCount=(m.__removalCount||0)+1,se.insertBefore(Dt,Z(m))}}}return bt(m),!0}return m instanceof l&&!hb(m)||(R==="noscript"||R==="noembed"||R==="noframes")&&Oe(/<\/no(script|embed|frames)/i,m.innerHTML)?(bt(m),!0):(yr&&m.nodeType===Li.text&&(T=m.textContent,zo([xn,vt,Qt],se=>{T=Oi(T,se," ")}),m.textContent!==T&&(Di(e.removed,{element:m.cloneNode()}),m.textContent=T)),Rt(xe.afterSanitizeElements,m,null),!1)},zh=function(m,T,R){if(uo[T]||kh&&(T==="id"||T==="name")&&(R in n||R in ub))return!1;if(!(sl&&!uo[T]&&Oe(il,T))){if(!(wh&&Oe(co,T))){if(!(en.attributeCheck instanceof Function&&en.attributeCheck(T,m))){if(!$e[T]||uo[T]){if(!(Mh(m)&&(me.tagNameCheck instanceof RegExp&&Oe(me.tagNameCheck,m)||me.tagNameCheck instanceof Function&&me.tagNameCheck(m))&&(me.attributeNameCheck instanceof RegExp&&Oe(me.attributeNameCheck,T)||me.attributeNameCheck instanceof Function&&me.attributeNameCheck(T,m))||T==="is"&&me.allowCustomizedBuiltInElements&&(me.tagNameCheck instanceof RegExp&&Oe(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R))))return!1}else if(!ul[T]){if(!Oe(vh,Oi(R,mh,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&m!=="script"&&_O(R,"data:")===0&&xh[m])){if(!(Sh&&!Oe(rb,Oi(R,mh,"")))){if(R)return!1}}}}}}}return!0},Mh=function(m){return m!=="annotation-xml"&&ic(m,ib)},Lh=function(m){Rt(xe.beforeSanitizeAttributes,m,null);const{attributes:T}=m;if(!T||fl(m))return;const R={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$e,forceKeepAttr:void 0};let se=T.length;for(;se--;){const De=T[se],{name:ve,namespaceURI:Fe,value:Dt}=De,kr=be(ve),gl=Dt;let Ae=ve==="value"?gl:kO(gl);if(R.attrName=kr,R.attrValue=Ae,R.keepAttr=!0,R.forceKeepAttr=void 0,Rt(xe.uponSanitizeAttribute,m,R),Ae=R.attrValue,Eh&&(kr==="id"||kr==="name")&&(An(ve,m),Ae=sb+Ae),ho&&Oe(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ae)){An(ve,m);continue}if(kr==="attributename"&&ic(Ae,"href")){An(ve,m);continue}if(R.forceKeepAttr)continue;if(!R.keepAttr){An(ve,m);continue}if(!_h&&Oe(/\/>/i,Ae)){An(ve,m);continue}yr&&zo([xn,vt,Qt],Uh=>{Ae=Oi(Ae,Uh," ")});const Nh=be(m.nodeName);if(!zh(Nh,kr,Ae)){An(ve,m);continue}if(O&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!Fe)switch(v.getAttributeType(Nh,kr)){case"TrustedHTML":{Ae=O.createHTML(Ae);break}case"TrustedScriptURL":{Ae=O.createScriptURL(Ae);break}}if(Ae!==gl)try{Fe?m.setAttributeNS(Fe,ve,Ae):m.setAttribute(ve,Ae),fl(m)?bt(m):yf(e.removed)}catch{An(ve,m)}}Rt(xe.afterSanitizeAttributes,m,null)},db=function L(m){let T=null;const R=Rh(m);for(Rt(xe.beforeSanitizeShadowDOM,m,null);T=R.nextNode();)Rt(xe.uponSanitizeShadowNode,T,null),Oh(T),Lh(T),T.content instanceof s&&L(T.content);Rt(xe.afterSanitizeShadowDOM,m,null)};return e.sanitize=function(L){let m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,R=null,se=null,De=null;if(hl=!L,hl&&(L="<!-->"),typeof L!="string"&&!Dh(L))if(typeof L.toString=="function"){if(L=L.toString(),typeof L!="string")throw zi("dirty is not a string, aborting")}else throw zi("toString is not a function");if(!e.isSupported)return L;if(ol||pl(m),e.removed=[],typeof L=="string"&&(xi=!1),xi){if(L.nodeName){const Dt=be(L.nodeName);if(!Se[Dt]||Ei[Dt])throw zi("root node is forbidden and cannot be sanitized in-place")}}else if(L instanceof a)T=Ph("<!---->"),R=T.ownerDocument.importNode(L,!0),R.nodeType===Li.element&&R.nodeName==="BODY"||R.nodeName==="HTML"?T=R:T.appendChild(R);else{if(!br&&!yr&&!$n&&L.indexOf("<")===-1)return O&&fo?O.createHTML(L):L;if(T=Ph(L),!T)return br?null:fo?H:""}T&&al&&bt(T.firstChild);const ve=Rh(xi?L:T);for(;se=ve.nextNode();)Oh(se),Lh(se),se.content instanceof s&&db(se.content);if(xi)return L;if(br){if(po)for(De=ue.call(T.ownerDocument);T.firstChild;)De.appendChild(T.firstChild);else De=T;return($e.shadowroot||$e.shadowrootmode)&&(De=lo.call(r,De,!0)),De}let Fe=$n?T.outerHTML:T.innerHTML;return $n&&Se["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&Oe(Uy,T.ownerDocument.doctype.name)&&(Fe="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
|
|
338
|
+
`+Fe),yr&&zo([xn,vt,Qt],Dt=>{Fe=Oi(Fe,Dt," ")}),O&&fo?O.createHTML(Fe):Fe},e.setConfig=function(){let L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};pl(L),ol=!0},e.clearConfig=function(){_r=null,ol=!1},e.isValidAttribute=function(L,m,T){_r||pl({});const R=be(L),se=be(m);return zh(R,se,T)},e.addHook=function(L,m){typeof m=="function"&&Di(xe[L],m)},e.removeHook=function(L,m){if(m!==void 0){const T=wO(xe[L],m);return T===-1?void 0:SO(xe[L],T,1)[0]}return yf(xe[L])},e.removeHooks=function(L){xe[L]=[]},e.removeAllHooks=function(){xe=Ef()},e}var Zy=Fy();function sh(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var vr=sh();function Hy(t){vr=t}var zn={exec:()=>null};function q(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(Le.caret,"$1"),n=n.replace(i,o),r},getRegex:()=>new RegExp(n,e)};return r}var NO=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Le={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},UO=/^(?:[ \t]*(?:\n|$))+/,FO=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ZO=/^ {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+|$)/,HO=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,oh=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,By=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,jy=q(By).replace(/bull/g,oh).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(),BO=q(By).replace(/bull/g,oh).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(),ah=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,jO=/^[^\n]+/,lh=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,VO=q(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",lh).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),WO=q(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,oh).getRegex(),tl="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",ch=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,GO=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",ch).replace("tag",tl).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Vy=q(ah).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",tl).getRegex(),qO=q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Vy).getRegex(),uh={blockquote:qO,code:FO,def:VO,fences:ZO,heading:HO,hr:ao,html:GO,lheading:jy,list:WO,newline:UO,paragraph:Vy,table:zn,text:jO},xf=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",tl).getRegex(),YO={...uh,lheading:BO,table:xf,paragraph:q(ah).replace("hr",ao).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",xf).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",tl).getRegex()},KO={...uh,html:q(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ch).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(ah).replace("hr",ao).replace("heading",` *#{1,6} *[^
|
|
339
|
+
]`).replace("lheading",jy).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},JO=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,XO=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Wy=/^( {2,}|\\)\n(?!\s*$)/,QO=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,_i=/[\p{P}\p{S}]/u,nl=/[\s\p{P}\p{S}]/u,hh=/[^\s\p{P}\p{S}]/u,ez=q(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,nl).getRegex(),Gy=/(?!~)[\p{P}\p{S}]/u,tz=/(?!~)[\s\p{P}\p{S}]/u,nz=/(?:[^\s\p{P}\p{S}]|~)/u,rz=q(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",NO?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),qy=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,iz=q(qy,"u").replace(/punct/g,_i).getRegex(),sz=q(qy,"u").replace(/punct/g,Gy).getRegex(),Yy="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",oz=q(Yy,"gu").replace(/notPunctSpace/g,hh).replace(/punctSpace/g,nl).replace(/punct/g,_i).getRegex(),az=q(Yy,"gu").replace(/notPunctSpace/g,nz).replace(/punctSpace/g,tz).replace(/punct/g,Gy).getRegex(),lz=q("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,hh).replace(/punctSpace/g,nl).replace(/punct/g,_i).getRegex(),cz=q(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,_i).getRegex(),uz="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",hz=q(uz,"gu").replace(/notPunctSpace/g,hh).replace(/punctSpace/g,nl).replace(/punct/g,_i).getRegex(),dz=q(/\\(punct)/,"gu").replace(/punct/g,_i).getRegex(),pz=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(),fz=q(ch).replace("(?:-->|$)","-->").getRegex(),gz=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",fz).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),va=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,mz=q(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",va).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ky=q(/^!?\[(label)\]\[(ref)\]/).replace("label",va).replace("ref",lh).getRegex(),Jy=q(/^!?\[(ref)\](?:\[\])?/).replace("ref",lh).getRegex(),vz=q("reflink|nolink(?!\\()","g").replace("reflink",Ky).replace("nolink",Jy).getRegex(),$f=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,dh={_backpedal:zn,anyPunctuation:dz,autolink:pz,blockSkip:rz,br:Wy,code:XO,del:zn,delLDelim:zn,delRDelim:zn,emStrongLDelim:iz,emStrongRDelimAst:oz,emStrongRDelimUnd:lz,escape:JO,link:mz,nolink:Jy,punctuation:ez,reflink:Ky,reflinkSearch:vz,tag:gz,text:QO,url:zn},yz={...dh,link:q(/^!?\[(label)\]\((.*?)\)/).replace("label",va).getRegex(),reflink:q(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",va).getRegex()},iu={...dh,emStrongRDelimAst:az,emStrongLDelim:sz,delLDelim:cz,delRDelim:hz,url:q(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",$f).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",$f).getRegex()},bz={...iu,br:q(Wy).replace("{2,}","*").getRegex(),text:q(iu.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Lo={normal:uh,gfm:YO,pedantic:KO},Ni={normal:dh,gfm:iu,breaks:bz,pedantic:yz},wz={"&":"&","<":"<",">":">",'"':""","'":"'"},Af=t=>wz[t];function kt(t,e){if(e){if(Le.escapeTest.test(t))return t.replace(Le.escapeReplace,Af)}else if(Le.escapeTestNoEncode.test(t))return t.replace(Le.escapeReplaceNoEncode,Af);return t}function Tf(t){try{t=encodeURI(t).replace(Le.percentDecode,"%")}catch{return null}return t}function Cf(t,e){var s;let n=t.replace(Le.findPipe,(o,a,l)=>{let u=!1,d=a;for(;--d>=0&&l[d]==="\\";)u=!u;return u?"|":" |"}),r=n.split(Le.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!((s=r.at(-1))!=null&&s.trim())&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Le.slashPipe,"|");return r}function Ui(t,e,n){let r=t.length;if(r===0)return"";let i=0;for(;i<r&&t.charAt(r-i-1)===e;)i++;return t.slice(0,r-i)}function Sz(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function _z(t,e=0){let n=e,r="";for(let i of t)if(i===" "){let s=4-n%4;r+=" ".repeat(s),n+=s}else r+=i,n++;return r}function If(t,e,n,r,i){let s=e.href,o=e.title||null,a=t[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:s,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,l}function kz(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
|
|
340
|
+
`).map(s=>{let o=s.match(n.other.beginningSpace);if(o===null)return s;let[a]=o;return a.length>=i.length?s.slice(i.length):s}).join(`
|
|
341
|
+
`)}var ya=class{constructor(t){b(this,"options");b(this,"rules");b(this,"lexer");this.options=t||vr}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Ui(n,`
|
|
342
|
+
`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=kz(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=Ui(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Ui(e[0],`
|
|
343
|
+
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=Ui(e[0],`
|
|
344
|
+
`).split(`
|
|
345
|
+
`),r="",i="",s=[];for(;n.length>0;){let o=!1,a=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))a.push(n[l]),o=!0;else if(!o)a.push(n[l]);else break;n=n.slice(l);let u=a.join(`
|
|
346
|
+
`),d=u.replace(this.rules.other.blockquoteSetextReplace,`
|
|
347
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
348
|
+
${u}`:u,i=i?`${i}
|
|
349
|
+
${d}`:d;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,s,!0),this.lexer.state.top=p,n.length===0)break;let y=s.at(-1);if((y==null?void 0:y.type)==="code")break;if((y==null?void 0:y.type)==="blockquote"){let v=y,A=v.raw+`
|
|
350
|
+
`+n.join(`
|
|
351
|
+
`),E=this.blockquote(A);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,A=v.raw+`
|
|
352
|
+
`+n.join(`
|
|
353
|
+
`),E=this.list(A);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,n=A.substring(s.at(-1).raw.length).split(`
|
|
354
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(t){var n,r;let e=this.rules.block.list.exec(t);if(e){let i=e[1].trim(),s=i.length>1,o={type:"list",raw:"",ordered:s,start:s?+i.slice(0,-1):"",loose:!1,items:[]};i=s?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=s?i:"[*+-]");let a=this.rules.other.listItemRegex(i),l=!1;for(;t;){let d=!1,p="",y="";if(!(e=a.exec(t))||this.rules.block.hr.test(t))break;p=e[0],t=t.substring(p.length);let v=_z(e[2].split(`
|
|
355
|
+
`,1)[0],e[1].length),A=t.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(A)&&(p+=A+`
|
|
357
|
+
`,t=t.substring(A.length+1),d=!0),!d){let Z=this.rules.other.nextBulletRegex(I),P=this.rules.other.hrRegex(I),V=this.rules.other.fencesBeginRegex(I),O=this.rules.other.headingBeginRegex(I),H=this.rules.other.htmlBeginRegex(I),N=this.rules.other.blockquoteBeginRegex(I);for(;t;){let ce=t.split(`
|
|
358
|
+
`,1)[0],ue;if(A=ce,this.options.pedantic?(A=A.replace(this.rules.other.listReplaceNesting," "),ue=A):ue=A.replace(this.rules.other.tabCharGlobal," "),V.test(A)||O.test(A)||H.test(A)||N.test(A)||Z.test(A)||P.test(A))break;if(ue.search(this.rules.other.nonSpaceChar)>=I||!A.trim())y+=`
|
|
359
|
+
`+ue.slice(I);else{if(E||v.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||V.test(v)||O.test(v)||P.test(v))break;y+=`
|
|
360
|
+
`+A}E=!A.trim(),p+=ce+`
|
|
361
|
+
`,t=t.substring(ce.length+1),v=ue.slice(I)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(l=!0)),o.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(y),loose:!1,text:y,tokens:[]}),o.raw+=p}let u=o.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let d of o.items){if(this.lexer.state.top=!1,d.tokens=this.lexer.blockTokens(d.text,[]),d.task){if(d.text=d.text.replace(this.rules.other.listReplaceTask,""),((n=d.tokens[0])==null?void 0:n.type)==="text"||((r=d.tokens[0])==null?void 0:r.type)==="paragraph"){d.tokens[0].raw=d.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),d.tokens[0].text=d.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let y=this.lexer.inlineQueue.length-1;y>=0;y--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[y].src)){this.lexer.inlineQueue[y].src=this.lexer.inlineQueue[y].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(d.raw);if(p){let y={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};d.checked=y.checked,o.loose?d.tokens[0]&&["paragraph","text"].includes(d.tokens[0].type)&&"tokens"in d.tokens[0]&&d.tokens[0].tokens?(d.tokens[0].raw=y.raw+d.tokens[0].raw,d.tokens[0].text=y.raw+d.tokens[0].text,d.tokens[0].tokens.unshift(y)):d.tokens.unshift({type:"paragraph",raw:y.raw,text:y.raw,tokens:[y]}):d.tokens.unshift(y)}}if(!o.loose){let p=d.tokens.filter(v=>v.type==="space"),y=p.length>0&&p.some(v=>this.rules.other.anyLine.test(v.raw));o.loose=y}}if(o.loose)for(let d of o.items){d.loose=!0;for(let p of d.tokens)p.type==="text"&&(p.type="paragraph")}return o}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:r,title:i}}}table(t){var o;let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=Cf(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(o=e[3])!=null&&o.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
362
|
+
`):[],s={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?s.align.push("right"):this.rules.other.tableAlignCenter.test(a)?s.align.push("center"):this.rules.other.tableAlignLeft.test(a)?s.align.push("left"):s.align.push(null);for(let a=0;a<n.length;a++)s.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:s.align[a]});for(let a of i)s.rows.push(Cf(a,s.header.length).map((l,u)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:s.align[u]})));return s}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
|
|
363
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let s=Ui(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{let s=Sz(e[2],"()");if(s===-2)return;if(s>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+s;e[2]=e[2].substring(0,s),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let r=e[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3])}else i=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),If(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){let s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return If(n,i,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,s,o,a=i,l=0,u=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*t.length+i);(r=u.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(o=[...s].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&i%3&&!((i+o)%3)){l+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+l);let d=[...r[0]][0].length,p=t.slice(0,i+r.index+d+o);if(Math.min(i,o)%2){let v=p.slice(1,-1);return{type:"em",raw:p,text:v,tokens:this.lexer.inlineTokens(v)}}let y=p.slice(2,-2);return{type:"strong",raw:p,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let r=this.rules.inline.delLDelim.exec(t);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,s,o,a=i,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*t.length+i);(r=l.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(o=[...s].length,o!==i))continue;if(r[3]||r[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let u=[...r[0]][0].length,d=t.slice(0,i+r.index+u+o),p=d.slice(i,-i);return{type:"del",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){var n;let e;if(e=this.rules.inline.url.exec(t)){let r,i;if(e[2]==="@")r=e[0],i="mailto:"+r;else{let s;do s=e[0],e[0]=((n=this.rules.inline._backpedal.exec(e[0]))==null?void 0:n[0])??"";while(s!==e[0]);r=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0]}return{type:"link",raw:e[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},pt=class su{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||vr,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 n={other:Le,block:Lo.normal,inline:Ni.normal};this.options.pedantic?(n.block=Lo.pedantic,n.inline=Ni.pedantic):this.options.gfm&&(n.block=Lo.gfm,this.options.breaks?n.inline=Ni.breaks:n.inline=Ni.gfm),this.tokenizer.rules=n}static get rules(){return{block:Lo,inline:Ni}}static lex(e,n){return new su(n).lex(e)}static lexInline(e,n){return new su(n).inlineTokens(e)}lex(e){e=e.replace(Le.carriageReturn,`
|
|
364
|
+
`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){var i,s,o;for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Le.tabCharGlobal," ").replace(Le.spaceLine,""));e;){let a;if((s=(i=this.options.extensions)==null?void 0:i.block)!=null&&s.some(u=>(a=u.call({lexer:this},e,n))?(e=e.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.space(e)){e=e.substring(a.raw.length);let u=n.at(-1);a.raw.length===1&&u!==void 0?u.raw+=`
|
|
365
|
+
`:n.push(a);continue}if(a=this.tokenizer.code(e)){e=e.substring(a.raw.length);let u=n.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
366
|
+
`)?"":`
|
|
367
|
+
`)+a.raw,u.text+=`
|
|
368
|
+
`+a.text,this.inlineQueue.at(-1).src=u.text):n.push(a);continue}if(a=this.tokenizer.fences(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.heading(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.hr(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.blockquote(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.list(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.html(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.def(e)){e=e.substring(a.raw.length);let u=n.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
369
|
+
`)?"":`
|
|
370
|
+
`)+a.raw,u.text+=`
|
|
371
|
+
`+a.raw,this.inlineQueue.at(-1).src=u.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},n.push(a));continue}if(a=this.tokenizer.table(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.lheading(e)){e=e.substring(a.raw.length),n.push(a);continue}let l=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&&(l=e.substring(0,u+1))}if(this.state.top&&(a=this.tokenizer.paragraph(l))){let u=n.at(-1);r&&(u==null?void 0:u.type)==="paragraph"?(u.raw+=(u.raw.endsWith(`
|
|
372
|
+
`)?"":`
|
|
373
|
+
`)+a.raw,u.text+=`
|
|
374
|
+
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):n.push(a),r=l.length!==e.length,e=e.substring(a.raw.length);continue}if(a=this.tokenizer.text(e)){e=e.substring(a.raw.length);let u=n.at(-1);(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
375
|
+
`)?"":`
|
|
376
|
+
`)+a.raw,u.text+=`
|
|
377
|
+
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):n.push(a);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){var l,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=(l=this.options.hooks)==null?void 0:l.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,n))?(e=e.substring(v.raw.length),n.push(v),!0):!1))continue;if(v=this.tokenizer.escape(e)){e=e.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.tag(e)){e=e.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.link(e)){e=e.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(v.raw.length);let E=n.at(-1);v.type==="text"&&(E==null?void 0:E.type)==="text"?(E.raw+=v.raw,E.text+=v.text):n.push(v);continue}if(v=this.tokenizer.emStrong(e,r,a)){e=e.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.codespan(e)){e=e.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.br(e)){e=e.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.del(e,r,a)){e=e.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.autolink(e)){e=e.substring(v.raw.length),n.push(v);continue}if(!this.state.inLink&&(v=this.tokenizer.url(e))){e=e.substring(v.raw.length),n.push(v);continue}let A=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&&(A=e.substring(0,E+1))}if(v=this.tokenizer.inlineText(A)){e=e.substring(v.raw.length),v.raw.slice(-1)!=="_"&&(a=v.raw.slice(-1)),o=!0;let E=n.at(-1);(E==null?void 0:E.type)==="text"?(E.raw+=v.raw,E.text+=v.text):n.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 n}},ba=class{constructor(t){b(this,"options");b(this,"parser");this.options=t||vr}space(t){return""}code({text:t,lang:e,escaped:n}){var s;let r=(s=(e||"").match(Le.notSpaceStart))==null?void 0:s[0],i=t.replace(Le.endingNewline,"")+`
|
|
378
|
+
`;return r?'<pre><code class="language-'+kt(r)+'">'+(n?i:kt(i,!0))+`</code></pre>
|
|
379
|
+
`:"<pre><code>"+(n?i:kt(i,!0))+`</code></pre>
|
|
380
|
+
`}blockquote({tokens:t}){return`<blockquote>
|
|
381
|
+
${this.parser.parse(t)}</blockquote>
|
|
382
|
+
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
383
|
+
`}hr(t){return`<hr>
|
|
384
|
+
`}list(t){let e=t.ordered,n=t.start,r="";for(let o=0;o<t.items.length;o++){let a=t.items[o];r+=this.listitem(a)}let i=e?"ol":"ul",s=e&&n!==1?' start="'+n+'"':"";return"<"+i+s+`>
|
|
385
|
+
`+r+"</"+i+`>
|
|
386
|
+
`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
|
|
387
|
+
`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
|
|
388
|
+
`}table(t){let e="",n="";for(let i=0;i<t.header.length;i++)n+=this.tablecell(t.header[i]);e+=this.tablerow({text:n});let r="";for(let i=0;i<t.rows.length;i++){let s=t.rows[i];n="";for(let o=0;o<s.length;o++)n+=this.tablecell(s[o]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
389
|
+
<thead>
|
|
390
|
+
`+e+`</thead>
|
|
391
|
+
`+r+`</table>
|
|
392
|
+
`}tablerow({text:t}){return`<tr>
|
|
393
|
+
${t}</tr>
|
|
394
|
+
`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
395
|
+
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${kt(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),i=Tf(t);if(i===null)return r;t=i;let s='<a href="'+t+'"';return e&&(s+=' title="'+kt(e)+'"'),s+=">"+r+"</a>",s}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Tf(t);if(i===null)return kt(n);t=i;let s=`<img src="${t}" alt="${kt(n)}"`;return e&&(s+=` title="${kt(e)}"`),s+=">",s}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:kt(t.text)}},ph=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},ft=class ou{constructor(e){b(this,"options");b(this,"renderer");b(this,"textRenderer");this.options=e||vr,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 ph}static parse(e,n){return new ou(n).parse(e)}static parseInline(e,n){return new ou(n).parseInline(e)}parse(e){var r,i;this.renderer.parser=this;let n="";for(let s=0;s<e.length;s++){let o=e[s];if((i=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&i[o.type]){let l=o,u=this.options.extensions.renderers[l.type].call({parser:this},l);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){n+=u||"";continue}}let a=o;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let l='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return n}parseInline(e,n=this.renderer){var i,s;this.renderer.parser=this;let r="";for(let o=0;o<e.length;o++){let a=e[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[a.type]){let u=this.options.extensions.renderers[a.type].call({parser:this},a);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=u||"";continue}}let l=a;switch(l.type){case"escape":{r+=n.text(l);break}case"html":{r+=n.html(l);break}case"link":{r+=n.link(l);break}case"image":{r+=n.image(l);break}case"checkbox":{r+=n.checkbox(l);break}case"strong":{r+=n.strong(l);break}case"em":{r+=n.em(l);break}case"codespan":{r+=n.codespan(l);break}case"br":{r+=n.br(l);break}case"del":{r+=n.del(l);break}case"text":{r+=n.text(l);break}default:{let u='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return r}},No,Yi=(No=class{constructor(t){b(this,"options");b(this,"block");this.options=t||vr}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}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),Ez=class{constructor(...t){b(this,"defaults",sh());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",ph);b(this,"Lexer",pt);b(this,"Tokenizer",ya);b(this,"Hooks",Yi);this.use(...t)}walkTokens(t,e){var r,i;let n=[];for(let s of t)switch(n=n.concat(e.call(this,s)),s.type){case"table":{let o=s;for(let a of o.header)n=n.concat(this.walkTokens(a.tokens,e));for(let a of o.rows)for(let l of a)n=n.concat(this.walkTokens(l.tokens,e));break}case"list":{let o=s;n=n.concat(this.walkTokens(o.items,e));break}default:{let o=s;(i=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let l=o[a].flat(1/0);n=n.concat(this.walkTokens(l,e))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=s.apply(this,o)),a}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=e[i.level];s?s.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){let i=this.defaults.renderer||new ba(this.defaults);for(let s in n.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=n.renderer[o],l=i[o];i[o]=(...u)=>{let d=a.apply(i,u);return d===!1&&(d=l.apply(i,u)),d||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new ya(this.defaults);for(let s in n.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=n.tokenizer[o],l=i[o];i[o]=(...u)=>{let d=a.apply(i,u);return d===!1&&(d=l.apply(i,u)),d}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new Yi;for(let s in n.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=n.hooks[o],l=i[o];Yi.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&Yi.passThroughHooksRespectAsync.has(s))return(async()=>{let p=await a.call(i,u);return l.call(i,p)})();let d=a.call(i,u);return l.call(i,d)}:i[o]=(...u)=>{if(this.defaults.async)return(async()=>{let p=await a.apply(i,u);return p===!1&&(p=await l.apply(i,u)),p})();let d=a.apply(i,u);return d===!1&&(d=l.apply(i,u)),d}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return pt.lex(t,e??this.defaults)}parser(t,e){return ft.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=t),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(e):e,a=await(i.hooks?await i.hooks.provideLexer():t?pt.lex:pt.lexInline)(o,i),l=i.hooks?await i.hooks.processAllTokens(a):a;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser():t?ft.parse:ft.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(s);try{i.hooks&&(e=i.hooks.preprocess(e));let o=(i.hooks?i.hooks.provideLexer():t?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():t?ft.parse:ft.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(t,e){return n=>{if(n.message+=`
|
|
396
|
+
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+kt(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},dr=new Ez;function J(t,e){return dr.parse(t,e)}J.options=J.setOptions=function(t){return dr.setOptions(t),J.defaults=dr.defaults,Hy(J.defaults),J};J.getDefaults=sh;J.defaults=vr;J.use=function(...t){return dr.use(...t),J.defaults=dr.defaults,Hy(J.defaults),J};J.walkTokens=function(t,e){return dr.walkTokens(t,e)};J.parseInline=dr.parseInline;J.Parser=ft;J.parser=ft.parse;J.Renderer=ba;J.TextRenderer=ph;J.Lexer=pt;J.lexer=pt.lex;J.Tokenizer=ya;J.Hooks=Yi;J.parse=J;J.options;J.setOptions;J.use;J.walkTokens;J.parseInline;ft.parse;pt.lex;Zy.addHook("afterSanitizeAttributes",t=>{t.tagName==="A"&&(t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer"))});function xz(t){const e=J.parse(t,{async:!1});return Zy.sanitize(e,{USE_PROFILES:{html:!0}})}const $z=8,Pf=new WeakMap;function Az(t){const e=Pf.get(t);if(e&&e.text===t.text)return e.html;const n=xz(t.text);return Pf.set(t,{text:t.text,html:n}),n}function Tz(t){return t.replace(/_/g," ")}function Cz(t){return U`
|
|
397
|
+
<div class="tool-call-header">
|
|
398
|
+
<span class="tool-call-title">${t.title}</span>
|
|
399
|
+
<span class="tool-call-meta">${t.toolKind} · ${Tz(t.status)}</span>
|
|
400
|
+
</div>
|
|
401
|
+
${t.text?U`<pre class="tool-call-text">${t.text}</pre>`:null}
|
|
402
|
+
`}function Rf(t){for(let e=t.length-1;e>=0;e-=1){const n=t[e];if(n&&n.kind==="user")return n.id}return null}var Vt,or,La,Na,Bs,au;class Xy extends as{constructor(){super(...arguments);w(this,Bs);b(this,"messages",[]);w(this,Vt,!0);w(this,or,null);w(this,La,()=>{const n=c(this,or);if(!n)return;const i=n.scrollHeight-n.clientHeight-n.scrollTop<=$z;i!==c(this,Vt)&&(k(this,Vt,i),this.toggleAttribute("data-pinned",i))});w(this,Na,()=>{k(this,Vt,!0),this.toggleAttribute("data-pinned",!0),g(this,Bs,au).call(this,!0)})}changed(n){let r=!1;if(n.has("messages")){const i=n.get("messages")??[],s=Rf(this.messages);r=s!==null&&s!==Rf(i),r&&k(this,Vt,!0)}Re(this.template(),this),c(this,or)||k(this,or,this.querySelector(".history-scroll")),this.toggleAttribute("data-pinned",c(this,Vt)),g(this,Bs,au).call(this,r)}template(){return U`
|
|
403
|
+
<div class="history-scroll" @scroll=${c(this,La)}>
|
|
404
|
+
${this.messages.map(n=>{const r=n.kind==="assistant"?UD(Az(n)):n.kind==="tool_call"?Cz(n):n.text;return U`<div
|
|
405
|
+
class="message message-${n.kind}"
|
|
406
|
+
data-message-id=${n.id}
|
|
407
|
+
>${r}</div>`})}
|
|
408
|
+
</div>
|
|
409
|
+
<button
|
|
410
|
+
type="button"
|
|
411
|
+
class="history-jump"
|
|
412
|
+
aria-label="Jump to latest message"
|
|
413
|
+
@click=${c(this,Na)}
|
|
414
|
+
>
|
|
415
|
+
${Jv({size:16})}
|
|
416
|
+
</button>
|
|
417
|
+
`}}Vt=new WeakMap,or=new WeakMap,La=new WeakMap,Na=new WeakMap,Bs=new WeakSet,au=function(n){requestAnimationFrame(()=>{const r=c(this,or);r&&(!c(this,Vt)&&!n||(r.scrollTop=r.scrollHeight-r.clientHeight))})},b(Xy,"properties",["messages"]);customElements.define("message-history",Xy);var js,Vs,ri,Ws,wn,cu,uu,Gs,qs;class lu extends as{constructor(){super(...arguments);w(this,wn);b(this,"placeholder","What do you want to do?");b(this,"open",!1);b(this,"messages",[]);w(this,js,Ge.resolve("ACPClientManager"));w(this,Vs,Ge.resolve("ShortcutService"));w(this,ri,null);b(this,"handleTriggerActivate",()=>{this.open=!0});b(this,"handleKeydown",n=>{if(n.key!=="Enter"||n.shiftKey)return;const r=n.currentTarget,i=r.value.trim();if(n.preventDefault(),!i)return;r.value="";const s=c(this,js).getActiveClient();s&&s.sendMessage({text:i}).catch(o=>{console.error("ACPClient.sendMessage() failed",o)})});w(this,Ws,n=>{if(n.shortcut!=="focusCommandInput")return;if(!this.open){this.open=!0;return}const r=this.querySelector("textarea");if(r){if(document.activeElement===r){this.open=!1;return}r.focus()}});w(this,Gs,n=>{n.target instanceof Node&&(this.contains(n.target)||(this.open=!1))});w(this,qs,n=>{n.key==="Escape"&&(this.open=!1)})}connected(){this.setAttribute("material","paper"),this.setAttribute("tone","dark"),this.setAttribute("level","overlay");const n=new DisposableStack;k(this,ri,n);const r=mO(c(this,js),i=>{this.messages=i});n.defer(()=>r.dispose()),c(this,Vs).addEventListener("shortcut-triggered",c(this,Ws)),n.defer(()=>c(this,Vs).removeEventListener("shortcut-triggered",c(this,Ws))),this.open&&g(this,wn,cu).call(this)}disconnected(){var n;(n=c(this,ri))==null||n.dispose(),k(this,ri,null),g(this,wn,uu).call(this)}changed(n){if(Re(this.template(),this),n.has("open"))if(this.open){g(this,wn,cu).call(this);const r=this.querySelector("textarea");r==null||r.focus()}else g(this,wn,uu).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,Vs=new WeakMap,ri=new WeakMap,Ws=new WeakMap,wn=new WeakSet,cu=function(){document.addEventListener("mousedown",c(this,Gs)),document.addEventListener("keydown",c(this,qs))},uu=function(){document.removeEventListener("mousedown",c(this,Gs)),document.removeEventListener("keydown",c(this,qs))},Gs=new WeakMap,qs=new WeakMap,b(lu,"properties",["placeholder","open","messages"]),b(lu,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",lu);class Qy extends Event{constructor(n){super("auth-submit",{bubbles:!0,composed:!0});b(this,"token");this.token=n}}class Iz extends HTMLElement{constructor(){super(...arguments);b(this,"_invalid",!1);b(this,"_tokenValue","")}set invalid(n){this._invalid=n,this.render()}get invalid(){return this._invalid}set tokenValue(n){this._tokenValue=n,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(n){const r=n.currentTarget;this._tokenValue=r.value}handleSubmit(n){n.preventDefault();const r=this._tokenValue.trim();r&&this.dispatchEvent(new Qy(r))}render(){Re(U`
|
|
436
|
+
<modal-overlay open>
|
|
437
|
+
<section class="auth-modal">
|
|
438
|
+
<form class="auth-form" @submit=${n=>this.handleSubmit(n)}>
|
|
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=${n=>this.handleInput(n)}
|
|
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",Iz);class Pz extends HTMLElement{constructor(){super(...arguments);b(this,"runtimeServerURL",Ov());b(this,"electronMode",zv());b(this,"serverManager",Ge.resolve("ServerManager"));b(this,"screenManager",Ge.resolve("ScreenManager"));b(this,"connectError",null);b(this,"handleServerManagerChange",()=>{this.render()});b(this,"handleActiveScreenChanged",()=>{this.render()})}connectedCallback(){this.serverManager.addEventListener("change",this.handleServerManagerChange),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.addEventListener("auth-submit",n=>{var i;const r=n instanceof Qy?n.token:n instanceof CustomEvent&&typeof((i=n.detail)==null?void 0:i.token)=="string"?n.detail.token:null;r&&this.handleAuthSubmit(r)}),this.initializeConnection(),this.render()}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleServerManagerChange),this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged)}async initializeConnection(){if(this.electronMode){this.serverManager.connectConfiguredServers(this.runtimeServerURL,Mc());return}if(this.serverManager.activeServer)return;const n=new Tc({url:this.runtimeServerURL,name:"Server",token:Mc()});this.serverManager.add(n),this.serverManager.setActive(n);try{await n.connect(),this.connectError=null}catch(r){this.connectError=r instanceof Error&&!(r instanceof Ac)?r.message:null}this.render()}async handleAuthSubmit(n){const r=this.serverManager.activeServer;if(r){this.connectError=null,r.token=n,this.updateTokenQueryParam(n);try{await r.connect()}catch(i){i instanceof Ac||(this.connectError=i instanceof Error?i.message:String(i))}this.render()}}updateTokenQueryParam(n){const r=new URL(window.location.href);r.searchParams.set("token",n),window.history.replaceState({},"",`${r.pathname}${r.search}${r.hash}`)}render(){const n=this.serverManager.activeServer,r=(n==null?void 0:n.status)??null;if(r==="connecting"){Re(U`
|
|
457
|
+
<main class="auth-gate"><p>Connecting...</p></main>
|
|
458
|
+
`,this);return}if(r==="disconnected"){const o=n;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",Pz);const fh=zv(),rl=Ov(),eb=new Cx(fh?"television-electron":"television-browser",Tx(rl)),tb=new SC({localStore:eb,localServerURL:rl}),nb=new xx({localStore:eb,serverManager:tb}),Rz=new iD({serverURL:rl,token:Mc()??"",screenManager:nb}),Dz=new uD;Ge.register("ServerManager",()=>tb);Ge.register("ScreenManager",()=>nb);Ge.register("ACPClientManager",()=>Rz);Ge.register("ShortcutService",()=>Dz);const gh=document.createElement("television-app");gh.runtimeServerURL=rl;gh.electronMode=fh;fh&&document.body.classList.add("electron");document.body.appendChild(gh);
|