@telepath-computer/television 0.1.40 → 0.1.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,468 +0,0 @@
|
|
|
1
|
-
var Rv=Object.defineProperty;var Eh=n=>{throw TypeError(n)};var Dv=(n,e,t)=>e in n?Rv(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var b=(n,e,t)=>Dv(n,typeof e!="symbol"?e+"":e,t),rl=(n,e,t)=>e.has(n)||Eh("Cannot "+t);var c=(n,e,t)=>(rl(n,e,"read from private field"),t?t.call(n):e.get(n)),S=(n,e,t)=>e.has(n)?Eh("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),E=(n,e,t,r)=>(rl(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),m=(n,e,t)=>(rl(n,e,"access private method"),t);var $h=(n,e,t,r)=>({set _(i){E(n,e,i,t)},get _(){return c(n,e,r)}});(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function t(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=t(i);fetch(i.href,s)}})();var In=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ov(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),t}var Ah=Object.prototype.toString,up=function(e){var t=Ah.call(e),r=t==="[object Arguments]";return r||(r=t!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Ah.call(e.callee)==="[object Function]"),r},il,xh;function zv(){if(xh)return il;xh=1;var n;if(!Object.keys){var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,r=up,i=Object.prototype.propertyIsEnumerable,s=!i.call({toString:null},"toString"),o=i.call(function(){},"prototype"),a=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(v){var y=v.constructor;return y&&y.prototype===v},u={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},d=function(){if(typeof window>"u")return!1;for(var v in window)try{if(!u["$"+v]&&e.call(window,v)&&window[v]!==null&&typeof window[v]=="object")try{l(window[v])}catch{return!0}}catch{return!0}return!1}(),f=function(v){if(typeof window>"u"||!d)return l(v);try{return l(v)}catch{return!1}};n=function(y){var A=y!==null&&typeof y=="object",k=t.call(y)==="[object Function]",I=r(y),G=A&&t.call(y)==="[object String]",P=[];if(!A&&!k&&!I)throw new TypeError("Object.keys called on a non-object");var le=o&&k;if(G&&y.length>0&&!e.call(y,0))for(var M=0;M<y.length;++M)P.push(String(M));if(I&&y.length>0)for(var Z=0;Z<y.length;++Z)P.push(String(Z));else for(var U in y)!(le&&U==="prototype")&&e.call(y,U)&&P.push(String(U));if(s)for(var ge=f(y),ce=0;ce<a.length;++ce)!(ge&&a[ce]==="constructor")&&e.call(y,a[ce])&&P.push(a[ce]);return P}}return il=n,il}var Lv=Array.prototype.slice,Mv=up,Th=Object.keys,To=Th?function(e){return Th(e)}:zv(),Ch=Object.keys;To.shim=function(){if(Object.keys){var e=function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2);e||(Object.keys=function(r){return Mv(r)?Ch(Lv.call(r)):Ch(r)})}else Object.keys=To;return Object.keys||To};var Nv=To,Co=Object.defineProperty||!1;if(Co)try{Co({},"a",{value:1})}catch{Co=!1}var Us=Co,qt=SyntaxError,B=TypeError,Uv=Object.getOwnPropertyDescriptor,Io=Uv;if(Io)try{Io([],"length")}catch{Io=null}var ii=Io,Ih=Us,Fv=qt,yr=B,Ph=ii,hp=function(e,t,r){if(!e||typeof e!="object"&&typeof e!="function")throw new yr("`obj` must be an object or a function`");if(typeof t!="string"&&typeof t!="symbol")throw new yr("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new yr("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new yr("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new yr("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new yr("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,l=!!Ph&&Ph(e,t);if(Ih)Ih(e,t,{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[t]=r;else throw new Fv("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Jl=Us,dp=function(){return!!Jl};dp.hasArrayLengthDefineBug=function(){if(!Jl)return null;try{return Jl([],"length",{value:1}).length!==1}catch{return!0}};var Aa=dp,Zv=Nv,Hv=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Vv=Object.prototype.toString,jv=Array.prototype.concat,Rh=hp,Gv=function(n){return typeof n=="function"&&Vv.call(n)==="[object Function]"},fp=Aa(),Bv=function(n,e,t,r){if(e in n){if(r===!0){if(n[e]===t)return}else if(!Gv(r)||!r())return}fp?Rh(n,e,t,!0):Rh(n,e,t)},pp=function(n,e){var t=arguments.length>2?arguments[2]:{},r=Zv(e);Hv&&(r=jv.call(r,Object.getOwnPropertySymbols(e)));for(var i=0;i<r.length;i+=1)Bv(n,r[i],e[r[i]],t[r[i]])};pp.supportsDescriptors=!!fp;var ar=pp,Po={exports:{}};typeof self<"u"?Po.exports=self:typeof window<"u"?Po.exports=window:Po.exports=Function("return this")();var gp=Po.exports,Wv=gp,mp=function(){return typeof In!="object"||!In||In.Math!==Math||In.Array!==Array?Wv:In},qv=ar,Yv=ii,Kv=mp,Jv=function(){var e=Kv();if(qv.supportsDescriptors){var t=Yv(e,"globalThis");(!t||t.configurable&&(t.enumerable||!t.writable||globalThis!==e))&&Object.defineProperty(e,"globalThis",{configurable:!0,enumerable:!1,value:e,writable:!0})}else(typeof globalThis!="object"||globalThis!==e)&&(e.globalThis=e);return e},Xv=ar,Qv=gp,yp=mp,eb=Jv,tb=yp(),vp=function(){return tb};Xv(vp,{getPolyfill:yp,implementation:Qv,shim:eb});var Jc=vp,Yt=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},Xc=Object,bp=Error,nb=EvalError,rb=RangeError,Qc=ReferenceError,ib=URIError,sb=Math.abs,ob=Math.floor,ab=Math.max,lb=Math.min,cb=Math.pow,ub=Math.round,eu=Number.isNaN||function(e){return e!==e},hb=eu,db=function(e){return hb(e)||e===0?e:e<0?-1:1},si=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},t=Symbol("test"),r=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var i=42;e[t]=i;for(var s in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,t);if(a.value!==i||a.enumerable!==!0)return!1}return!0},Dh=typeof Symbol<"u"&&Symbol,fb=si,tu=function(){return typeof Dh!="function"||typeof Symbol!="function"||typeof Dh("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:fb()},sl,Oh;function wp(){return Oh||(Oh=1,sl=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),sl}var ol,zh;function _p(){if(zh)return ol;zh=1;var n=Xc;return ol=n.getPrototypeOf||null,ol}var pb="Function.prototype.bind called on incompatible ",gb=Object.prototype.toString,mb=Math.max,yb="[object Function]",Lh=function(e,t){for(var r=[],i=0;i<e.length;i+=1)r[i]=e[i];for(var s=0;s<t.length;s+=1)r[s+e.length]=t[s];return r},vb=function(e,t){for(var r=[],i=t,s=0;i<e.length;i+=1,s+=1)r[s]=e[i];return r},bb=function(n,e){for(var t="",r=0;r<n.length;r+=1)t+=n[r],r+1<n.length&&(t+=e);return t},wb=function(e){var t=this;if(typeof t!="function"||gb.apply(t)!==yb)throw new TypeError(pb+t);for(var r=vb(arguments,1),i,s=function(){if(this instanceof i){var d=t.apply(this,Lh(r,arguments));return Object(d)===d?d:this}return t.apply(e,Lh(r,arguments))},o=mb(0,t.length-r.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(i=Function("binder","return function ("+bb(a,",")+"){ return binder.apply(this,arguments); }")(s),t.prototype){var u=function(){};u.prototype=t.prototype,i.prototype=new u,u.prototype=null}return i},_b=wb,Fs=Function.prototype.bind||_b,nu=Function.prototype.call,ru=Function.prototype.apply,Sb=typeof Reflect<"u"&&Reflect&&Reflect.apply,kb=Fs,Eb=ru,$b=nu,Ab=Sb,Sp=Ab||kb.call($b,Eb),xb=Fs,Tb=B,Cb=nu,Ib=Sp,xa=function(e){if(e.length<1||typeof e[0]!="function")throw new Tb("a function is required");return Ib(xb,Cb,e)},al,Mh;function Pb(){if(Mh)return al;Mh=1;var n=xa,e=ii,t;try{t=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var r=!!t&&e&&e(Object.prototype,"__proto__"),i=Object,s=i.getPrototypeOf;return al=r&&typeof r.get=="function"?n([r.get]):typeof s=="function"?function(a){return s(a==null?a:i(a))}:!1,al}var ll,Nh;function kp(){if(Nh)return ll;Nh=1;var n=wp(),e=_p(),t=Pb();return ll=n?function(i){return n(i)}:e?function(i){if(!i||typeof i!="object"&&typeof i!="function")throw new TypeError("getProto: not an object");return e(i)}:t?function(i){return t(i)}:null,ll}var Rb=Function.prototype.call,Db=Object.prototype.hasOwnProperty,Ob=Fs,Kt=Ob.call(Rb,Db),j,zb=Xc,Lb=bp,Mb=nb,Nb=rb,Ub=Qc,Jr=qt,Pr=B,Fb=ib,Zb=sb,Hb=ob,Vb=ab,jb=lb,Gb=cb,Bb=ub,Wb=db,Ep=Function,cl=function(n){try{return Ep('"use strict"; return ('+n+").constructor;")()}catch{}},Ki=ii,qb=Us,ul=function(){throw new Pr},Yb=Ki?function(){try{return arguments.callee,ul}catch{try{return Ki(arguments,"callee").get}catch{return ul}}}():ul,vr=tu(),Se=kp(),Kb=_p(),Jb=wp(),$p=ru,Zs=nu,_r={},Xb=typeof Uint8Array>"u"||!Se?j:Se(Uint8Array),er={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?j:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?j:ArrayBuffer,"%ArrayIteratorPrototype%":vr&&Se?Se([][Symbol.iterator]()):j,"%AsyncFromSyncIteratorPrototype%":j,"%AsyncFunction%":_r,"%AsyncGenerator%":_r,"%AsyncGeneratorFunction%":_r,"%AsyncIteratorPrototype%":_r,"%Atomics%":typeof Atomics>"u"?j:Atomics,"%BigInt%":typeof BigInt>"u"?j:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?j:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?j:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?j:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Lb,"%eval%":eval,"%EvalError%":Mb,"%Float16Array%":typeof Float16Array>"u"?j:Float16Array,"%Float32Array%":typeof Float32Array>"u"?j:Float32Array,"%Float64Array%":typeof Float64Array>"u"?j:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?j:FinalizationRegistry,"%Function%":Ep,"%GeneratorFunction%":_r,"%Int8Array%":typeof Int8Array>"u"?j:Int8Array,"%Int16Array%":typeof Int16Array>"u"?j:Int16Array,"%Int32Array%":typeof Int32Array>"u"?j:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":vr&&Se?Se(Se([][Symbol.iterator]())):j,"%JSON%":typeof JSON=="object"?JSON:j,"%Map%":typeof Map>"u"?j:Map,"%MapIteratorPrototype%":typeof Map>"u"||!vr||!Se?j:Se(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":zb,"%Object.getOwnPropertyDescriptor%":Ki,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?j:Promise,"%Proxy%":typeof Proxy>"u"?j:Proxy,"%RangeError%":Nb,"%ReferenceError%":Ub,"%Reflect%":typeof Reflect>"u"?j:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?j:Set,"%SetIteratorPrototype%":typeof Set>"u"||!vr||!Se?j:Se(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?j:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":vr&&Se?Se(""[Symbol.iterator]()):j,"%Symbol%":vr?Symbol:j,"%SyntaxError%":Jr,"%ThrowTypeError%":Yb,"%TypedArray%":Xb,"%TypeError%":Pr,"%Uint8Array%":typeof Uint8Array>"u"?j:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?j:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?j:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?j:Uint32Array,"%URIError%":Fb,"%WeakMap%":typeof WeakMap>"u"?j:WeakMap,"%WeakRef%":typeof WeakRef>"u"?j:WeakRef,"%WeakSet%":typeof WeakSet>"u"?j:WeakSet,"%Function.prototype.call%":Zs,"%Function.prototype.apply%":$p,"%Object.defineProperty%":qb,"%Object.getPrototypeOf%":Kb,"%Math.abs%":Zb,"%Math.floor%":Hb,"%Math.max%":Vb,"%Math.min%":jb,"%Math.pow%":Gb,"%Math.round%":Bb,"%Math.sign%":Wb,"%Reflect.getPrototypeOf%":Jb};if(Se)try{null.error}catch(n){var Qb=Se(Se(n));er["%Error.prototype%"]=Qb}var ew=function n(e){var t;if(e==="%AsyncFunction%")t=cl("async function () {}");else if(e==="%GeneratorFunction%")t=cl("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=cl("async function* () {}");else if(e==="%AsyncGenerator%"){var r=n("%AsyncGeneratorFunction%");r&&(t=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=n("%AsyncGenerator%");i&&Se&&(t=Se(i.prototype))}return er[e]=t,t},Uh={__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"]},Hs=Fs,Vo=Kt,tw=Hs.call(Zs,Array.prototype.concat),nw=Hs.call($p,Array.prototype.splice),Fh=Hs.call(Zs,String.prototype.replace),jo=Hs.call(Zs,String.prototype.slice),rw=Hs.call(Zs,RegExp.prototype.exec),iw=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,sw=/\\(\\)?/g,ow=function(e){var t=jo(e,0,1),r=jo(e,-1);if(t==="%"&&r!=="%")throw new Jr("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&t!=="%")throw new Jr("invalid intrinsic syntax, expected opening `%`");var i=[];return Fh(e,iw,function(s,o,a,l){i[i.length]=a?Fh(l,sw,"$1"):o||s}),i},aw=function(e,t){var r=e,i;if(Vo(Uh,r)&&(i=Uh[r],r="%"+i[0]+"%"),Vo(er,r)){var s=er[r];if(s===_r&&(s=ew(r)),typeof s>"u"&&!t)throw new Pr("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:s}}throw new Jr("intrinsic "+e+" does not exist!")},st=function(e,t){if(typeof e!="string"||e.length===0)throw new Pr("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof t!="boolean")throw new Pr('"allowMissing" argument must be a boolean');if(rw(/^%?[^%]*%?$/,e)===null)throw new Jr("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=ow(e),i=r.length>0?r[0]:"",s=aw("%"+i+"%",t),o=s.name,a=s.value,l=!1,u=s.alias;u&&(i=u[0],nw(r,tw([0,1],u)));for(var d=1,f=!0;d<r.length;d+=1){var v=r[d],y=jo(v,0,1),A=jo(v,-1);if((y==='"'||y==="'"||y==="`"||A==='"'||A==="'"||A==="`")&&y!==A)throw new Jr("property names with quotes must have matching quotes");if((v==="constructor"||!f)&&(l=!0),i+="."+v,o="%"+i+"%",Vo(er,o))a=er[o];else if(a!=null){if(!(v in a)){if(!t)throw new Pr("base intrinsic for "+e+" exists, but the property is not available.");return}if(Ki&&d+1>=r.length){var k=Ki(a,v);f=!!k,f&&"get"in k&&!("originalValue"in k.get)?a=k.get:a=a[v]}else f=Vo(a,v),a=a[v];f&&!l&&(er[o]=a)}}return a},hl,Zh;function bn(){if(Zh)return hl;Zh=1;var n=st,e=xa,t=e([n("%String.prototype.indexOf%")]);return hl=function(i,s){var o=n(i,!!s);return typeof o=="function"&&t(i,".prototype.")>-1?e([o]):o},hl}var dl,Hh;function iu(){if(Hh)return dl;Hh=1;var n=st,e=n("%Array%"),t=!e.isArray&&bn()("Object.prototype.toString");return dl=e.isArray||function(i){return t(i)==="[object Array]"},dl}var lw=Aa,Vh=Us,Ap=lw.hasArrayLengthDefineBug(),cw=Ap&&iu(),uw=bn(),hw=uw("Object.prototype.propertyIsEnumerable"),su=function(e,t,r,i,s,o){if(!Vh){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&hw(i,s)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return i[s]=a,t(i[s],a)}return Ap&&s==="length"&&"[[Value]]"in o&&cw(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(Vh(i,s,r(o)),!0)},dw=B,_i=Kt,fw={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},oi=function(e){if(!e||typeof e!="object")return!1;for(var t in e)if(_i(e,t)&&!fw[t])return!1;var r=_i(e,"[[Value]]")||_i(e,"[[Writable]]"),i=_i(e,"[[Get]]")||_i(e,"[[Set]]");if(r&&i)throw new dw("Property Descriptors may not be both accessor and data descriptors");return!0},xp=function(e){if(typeof e>"u")return e;var t={};return"[[Value]]"in e&&(t.value=e["[[Value]]"]),"[[Writable]]"in e&&(t.writable=!!e["[[Writable]]"]),"[[Get]]"in e&&(t.get=e["[[Get]]"]),"[[Set]]"in e&&(t.set=e["[[Set]]"]),"[[Enumerable]]"in e&&(t.enumerable=!!e["[[Enumerable]]"]),"[[Configurable]]"in e&&(t.configurable=!!e["[[Configurable]]"]),t},pw=B,gw=oi,mw=xp,Tp=function(e){if(typeof e<"u"&&!gw(e))throw new pw("Assertion failed: `Desc` must be a Property Descriptor");return mw(e)},yw=B,jh=Kt,vw=oi,Cp=function(e){if(typeof e>"u")return!1;if(!vw(e))throw new yw("Assertion failed: `Desc` must be a Property Descriptor");return!(!jh(e,"[[Value]]")&&!jh(e,"[[Writable]]"))},ai=function(e){return typeof e=="string"||typeof e=="symbol"},Gh=eu,Ip=function(e,t){return e===t?e===0?1/e===1/t:!0:Gh(e)&&Gh(t)},Bh=B,bw=Yt,ww=su,_w=Tp,Sw=Cp,kw=ai,Ew=Ip,ou=function(e,t,r){if(!bw(e))throw new Bh("Assertion failed: Type(O) is not Object");if(!kw(t))throw new Bh("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return ww(Sw,Ew,_w,e,t,i)},Pp=Function.prototype.toString,Tr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,Xl,Ro;if(typeof Tr=="function"&&typeof Object.defineProperty=="function")try{Xl=Object.defineProperty({},"length",{get:function(){throw Ro}}),Ro={},Tr(function(){throw 42},null,Xl)}catch(n){n!==Ro&&(Tr=null)}else Tr=null;var $w=/^\s*class\b/,Ql=function(e){try{var t=Pp.call(e);return $w.test(t)}catch{return!1}},fl=function(e){try{return Ql(e)?!1:(Pp.call(e),!0)}catch{return!1}},Do=Object.prototype.toString,Aw="[object Object]",xw="[object Function]",Tw="[object GeneratorFunction]",Cw="[object HTMLAllCollection]",Iw="[object HTML document.all class]",Pw="[object HTMLCollection]",Rw=typeof Symbol=="function"&&!!Symbol.toStringTag,Dw=!(0 in[,]),ec=function(){return!1};if(typeof document=="object"){var Ow=document.all;Do.call(Ow)===Do.call(document.all)&&(ec=function(e){if((Dw||!e)&&(typeof e>"u"||typeof e=="object"))try{var t=Do.call(e);return(t===Cw||t===Iw||t===Pw||t===Aw)&&e("")==null}catch{}return!1})}var Rp=Tr?function(e){if(ec(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{Tr(e,null,Xl)}catch(t){if(t!==Ro)return!1}return!Ql(e)&&fl(e)}:function(e){if(ec(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(Rw)return fl(e);if(Ql(e))return!1;var t=Do.call(e);return t!==xw&&t!==Tw&&!/^\[object HTML/.test(t)?!1:fl(e)},zw=Rp,Lw=function(e){return!!e},yt=Kt,lo=B,Mw=Yt,Wh=zw,pl=Lw,Nw=function(e){if(!Mw(e))throw new lo("ToPropertyDescriptor requires an object");var t={};if(yt(e,"enumerable")&&(t["[[Enumerable]]"]=pl(e.enumerable)),yt(e,"configurable")&&(t["[[Configurable]]"]=pl(e.configurable)),yt(e,"value")&&(t["[[Value]]"]=e.value),yt(e,"writable")&&(t["[[Writable]]"]=pl(e.writable)),yt(e,"get")){var r=e.get;if(typeof r<"u"&&!Wh(r))throw new lo("getter must be a function");t["[[Get]]"]=r}if(yt(e,"set")){var i=e.set;if(typeof i<"u"&&!Wh(i))throw new lo("setter must be a function");t["[[Set]]"]=i}if((yt(t,"[[Get]]")||yt(t,"[[Set]]"))&&(yt(t,"[[Value]]")||yt(t,"[[Writable]]")))throw new lo("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},gl=B,Uw=Yt,qh=oi,Fw=su,Zw=Tp,Hw=Cp,Vw=ai,jw=Ip,Gw=Nw,Bw=function(e,t,r){if(!Uw(e))throw new gl("Assertion failed: Type(O) is not Object");if(!Vw(t))throw new gl("Assertion failed: P is not a Property Key");var i=qh(r)?r:Gw(r);if(!qh(i))throw new gl("Assertion failed: Desc is not a valid Property Descriptor");return Fw(Hw,jw,Zw,e,t,i)},Yh=B,Ww=Yt,qw=Bw,Yw=ai,Kw=function(e,t,r){if(!Ww(e))throw new Yh("Assertion failed: Type(O) is not Object");if(!Yw(t))throw new Yh("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return qw(e,t,i)},Jw=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,Xw=Xc,Qw=Xw.setPrototypeOf||null,e_=xa,Kh=ii,t_=B,Dp={};try{Dp.__proto__=null}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var n_=!("toString"in Dp),ml=Kh&&Kh(Object.prototype,"__proto__"),r_=n_&&(!!ml&&typeof ml.set=="function"&&e_([ml.set])||function(e,t){if(e==null)throw new t_("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=t,t}),Jh=Jw,i_=Qw,Xh=r_,s_=B,o_=Jh?function(e,t){if(Jh(e,t))return e;throw new s_("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:i_||(Xh?function(e,t){return Xh(e,t),e}:null),Qh=B,a_=Yt,ed=kp(),l_=function(e){if(!a_(e))throw new Qh("Assertion failed: O must be an Object");if(!ed)throw new Qh("This environment does not support fetching prototypes.");return ed(e)},c_=B,u_=o_,h_=Yt,d_=l_,f_=function(e,t){if(t!==null&&!h_(t))throw new c_("Assertion failed: V must be Object or Null");try{u_(e,t)}catch{return!1}return d_(e)===t},yl=ou,td=Kw,Op=f_,p_=Aa(),au=bp;function Vs(n,e,t){var r=new au(t);return Op(r,Oo),delete r.constructor,td(r,"error",n),td(r,"suppressed",e),r}p_&&Object.defineProperty(Vs,"prototype",{writable:!1});var Oo=Vs.prototype;if(!yl(Oo,"constructor",Vs)||!yl(Oo,"message","")||!yl(Oo,"name","SuppressedError"))throw new au("unable to install SuppressedError.prototype properties; please report this!");Op(Vs.prototype,au.prototype);var g_=Vs,m_=g_,zp=function(){return typeof SuppressedError=="function"?SuppressedError:m_},y_=ar,nd=Jc(),v_=zp,b_=function(){var e=v_();return y_(nd,{SuppressedError:e},{SuppressedError:function(){return nd.SuppressedError!==e}}),e};b_();var w_=B,__=oi,S_=xp,k_=function(e){if(typeof e<"u"&&!__(e))throw new w_("Assertion failed: `Desc` must be a Property Descriptor");return S_(e)},E_=B,rd=Kt,$_=oi,A_=function(e){if(typeof e>"u")return!1;if(!$_(e))throw new E_("Assertion failed: `Desc` must be a Property Descriptor");return!(!rd(e,"[[Value]]")&&!rd(e,"[[Writable]]"))},id=eu,x_=function(e,t){return e===t?e===0?1/e===1/t:!0:id(e)&&id(t)},li=Rp,T_=function(e){return!!e},vt=Kt,co=B,C_=Yt,sd=li,vl=T_,I_=function(e){if(!C_(e))throw new co("ToPropertyDescriptor requires an object");var t={};if(vt(e,"enumerable")&&(t["[[Enumerable]]"]=vl(e.enumerable)),vt(e,"configurable")&&(t["[[Configurable]]"]=vl(e.configurable)),vt(e,"value")&&(t["[[Value]]"]=e.value),vt(e,"writable")&&(t["[[Writable]]"]=vl(e.writable)),vt(e,"get")){var r=e.get;if(typeof r<"u"&&!sd(r))throw new co("getter must be a function");t["[[Get]]"]=r}if(vt(e,"set")){var i=e.set;if(typeof i<"u"&&!sd(i))throw new co("setter must be a function");t["[[Set]]"]=i}if((vt(t,"[[Get]]")||vt(t,"[[Set]]"))&&(vt(t,"[[Value]]")||vt(t,"[[Writable]]")))throw new co("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return t},bl=B,P_=Yt,od=oi,R_=su,D_=k_,O_=A_,z_=ai,L_=x_,M_=I_,js=function(e,t,r){if(!P_(e))throw new bl("Assertion failed: Type(O) is not Object");if(!z_(t))throw new bl("Assertion failed: P is not a Property Key");var i=od(r)?r:M_(r);if(!od(i))throw new bl("Assertion failed: Desc is not a valid Property Descriptor");return R_(O_,L_,D_,e,t,i)},N_=si(),U_=N_?Symbol.dispose||Symbol("Symbol.dispose"):null,F_=si,Z_=U_,lu=function(){return F_()&&Symbol.dispose||Z_},H_=tu,V_=js,j_=lu,G_=function(){var e=j_();return H_()&&V_(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},B_=si(),W_=B_?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,q_=si,Y_=W_,cu=function(){return q_()&&Symbol.asyncDispose||Y_},K_=tu,J_=js,X_=cu,Q_=function(){var e=X_();return K_()&&J_(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},eS=iu(),tS=st,nS=bn(),rS=B,iS=eS,sS=tS("%Reflect.apply%",!0)||nS("Function.prototype.apply"),Ta=function(e,t){var r=arguments.length>2?arguments[2]:[];if(!iS(r))throw new rS("Assertion failed: optional `argumentsList`, if provided, must be a List");return sS(e,t,r)};const oS={},aS=Object.freeze(Object.defineProperty({__proto__:null,default:oS},Symbol.toStringTag,{value:"Module"})),lS=Ov(aS);var uu=typeof Map=="function"&&Map.prototype,wl=Object.getOwnPropertyDescriptor&&uu?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Go=uu&&wl&&typeof wl.get=="function"?wl.get:null,ad=uu&&Map.prototype.forEach,hu=typeof Set=="function"&&Set.prototype,_l=Object.getOwnPropertyDescriptor&&hu?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Bo=hu&&_l&&typeof _l.get=="function"?_l.get:null,ld=hu&&Set.prototype.forEach,cS=typeof WeakMap=="function"&&WeakMap.prototype,ji=cS?WeakMap.prototype.has:null,uS=typeof WeakSet=="function"&&WeakSet.prototype,Gi=uS?WeakSet.prototype.has:null,hS=typeof WeakRef=="function"&&WeakRef.prototype,cd=hS?WeakRef.prototype.deref:null,dS=Boolean.prototype.valueOf,fS=Object.prototype.toString,pS=Function.prototype.toString,gS=String.prototype.match,du=String.prototype.slice,hn=String.prototype.replace,mS=String.prototype.toUpperCase,ud=String.prototype.toLowerCase,Lp=RegExp.prototype.test,hd=Array.prototype.concat,$t=Array.prototype.join,yS=Array.prototype.slice,dd=Math.floor,tc=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Sl=Object.getOwnPropertySymbols,nc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Xr=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Bi=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Xr||!0)?Symbol.toStringTag:null,Mp=Object.prototype.propertyIsEnumerable,fd=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(n){return n.__proto__}:null);function pd(n,e){if(n===1/0||n===-1/0||n!==n||n&&n>-1e3&&n<1e3||Lp.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof n=="number"){var r=n<0?-dd(-n):dd(n);if(r!==n){var i=String(r),s=du.call(e,i.length+1);return hn.call(i,t,"$&_")+"."+hn.call(hn.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return hn.call(e,t,"$&_")}var rc=lS,gd=rc.custom,md=Fp(gd)?gd:null,Np={__proto__:null,double:'"',single:"'"},vS={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},ci=function n(e,t,r,i){var s=t||{};if(zt(s,"quoteStyle")&&!zt(Np,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(zt(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=zt(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(zt(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(zt(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 Hp(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 ic(e)?"[Array]":"[Object]";var f=LS(s,r);if(typeof i>"u")i=[];else if(Zp(i,e)>=0)return"[Circular]";function v(pt,Xt,Ga){if(Xt&&(i=yS.call(i),i.push(Xt)),Ga){var Qs={depth:s.depth};return zt(s,"quoteStyle")&&(Qs.quoteStyle=s.quoteStyle),n(pt,Qs,r+1,i)}return n(pt,s,r+1,i)}if(typeof e=="function"&&!yd(e)){var y=xS(e),A=uo(e,v);return"[Function"+(y?": "+y:" (anonymous)")+"]"+(A.length>0?" { "+$t.call(A,", ")+" }":"")}if(Fp(e)){var k=Xr?hn.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):nc.call(e);return typeof e=="object"&&!Xr?Si(k):k}if(DS(e)){for(var I="<"+ud.call(String(e.nodeName)),G=e.attributes||[],P=0;P<G.length;P++)I+=" "+G[P].name+"="+Up(bS(G[P].value),"double",s);return I+=">",e.childNodes&&e.childNodes.length&&(I+="..."),I+="</"+ud.call(String(e.nodeName))+">",I}if(ic(e)){if(e.length===0)return"[]";var le=uo(e,v);return f&&!zS(le)?"["+sc(le,f)+"]":"[ "+$t.call(le,", ")+" ]"}if(_S(e)){var M=uo(e,v);return!("cause"in Error.prototype)&&"cause"in e&&!Mp.call(e,"cause")?"{ ["+String(e)+"] "+$t.call(hd.call("[cause]: "+v(e.cause),M),", ")+" }":M.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+$t.call(M,", ")+" }"}if(typeof e=="object"&&o){if(md&&typeof e[md]=="function"&&rc)return rc(e,{depth:d-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(TS(e)){var Z=[];return ad&&ad.call(e,function(pt,Xt){Z.push(v(Xt,e,!0)+" => "+v(pt,e))}),vd("Map",Go.call(e),Z,f)}if(PS(e)){var U=[];return ld&&ld.call(e,function(pt){U.push(v(pt,e))}),vd("Set",Bo.call(e),U,f)}if(CS(e))return kl("WeakMap");if(RS(e))return kl("WeakSet");if(IS(e))return kl("WeakRef");if(kS(e))return Si(v(Number(e)));if($S(e))return Si(v(tc.call(e)));if(ES(e))return Si(dS.call(e));if(SS(e))return Si(v(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof In<"u"&&e===In)return"{ [object globalThis] }";if(!wS(e)&&!yd(e)){var ge=uo(e,v),ce=fd?fd(e)===Object.prototype:e instanceof Object||e.constructor===Object,yi=e instanceof Object?"":"null prototype",Xs=!ce&&Bi&&Object(e)===e&&Bi in e?du.call(wn(e),8,-1):yi?"Object":"",$e=ce||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",kn=$e+(Xs||yi?"["+$t.call(hd.call([],Xs||[],yi||[]),": ")+"] ":"");return ge.length===0?kn+"{}":f?kn+"{"+sc(ge,f)+"}":kn+"{ "+$t.call(ge,", ")+" }"}return String(e)};function Up(n,e,t){var r=t.quoteStyle||e,i=Np[r];return i+n+i}function bS(n){return hn.call(String(n),/"/g,""")}function lr(n){return!Bi||!(typeof n=="object"&&(Bi in n||typeof n[Bi]<"u"))}function ic(n){return wn(n)==="[object Array]"&&lr(n)}function wS(n){return wn(n)==="[object Date]"&&lr(n)}function yd(n){return wn(n)==="[object RegExp]"&&lr(n)}function _S(n){return wn(n)==="[object Error]"&&lr(n)}function SS(n){return wn(n)==="[object String]"&&lr(n)}function kS(n){return wn(n)==="[object Number]"&&lr(n)}function ES(n){return wn(n)==="[object Boolean]"&&lr(n)}function Fp(n){if(Xr)return n&&typeof n=="object"&&n instanceof Symbol;if(typeof n=="symbol")return!0;if(!n||typeof n!="object"||!nc)return!1;try{return nc.call(n),!0}catch{}return!1}function $S(n){if(!n||typeof n!="object"||!tc)return!1;try{return tc.call(n),!0}catch{}return!1}var AS=Object.prototype.hasOwnProperty||function(n){return n in this};function zt(n,e){return AS.call(n,e)}function wn(n){return fS.call(n)}function xS(n){if(n.name)return n.name;var e=gS.call(pS.call(n),/^function\s*([\w$]+)/);return e?e[1]:null}function Zp(n,e){if(n.indexOf)return n.indexOf(e);for(var t=0,r=n.length;t<r;t++)if(n[t]===e)return t;return-1}function TS(n){if(!Go||!n||typeof n!="object")return!1;try{Go.call(n);try{Bo.call(n)}catch{return!0}return n instanceof Map}catch{}return!1}function CS(n){if(!ji||!n||typeof n!="object")return!1;try{ji.call(n,ji);try{Gi.call(n,Gi)}catch{return!0}return n instanceof WeakMap}catch{}return!1}function IS(n){if(!cd||!n||typeof n!="object")return!1;try{return cd.call(n),!0}catch{}return!1}function PS(n){if(!Bo||!n||typeof n!="object")return!1;try{Bo.call(n);try{Go.call(n)}catch{return!0}return n instanceof Set}catch{}return!1}function RS(n){if(!Gi||!n||typeof n!="object")return!1;try{Gi.call(n,Gi);try{ji.call(n,ji)}catch{return!0}return n instanceof WeakSet}catch{}return!1}function DS(n){return!n||typeof n!="object"?!1:typeof HTMLElement<"u"&&n instanceof HTMLElement?!0:typeof n.nodeName=="string"&&typeof n.getAttribute=="function"}function Hp(n,e){if(n.length>e.maxStringLength){var t=n.length-e.maxStringLength,r="... "+t+" more character"+(t>1?"s":"");return Hp(du.call(n,0,e.maxStringLength),e)+r}var i=vS[e.quoteStyle||"single"];i.lastIndex=0;var s=hn.call(hn.call(n,i,"\\$1"),/[\x00-\x1f]/g,OS);return Up(s,"single",e)}function OS(n){var e=n.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+mS.call(e.toString(16))}function Si(n){return"Object("+n+")"}function kl(n){return n+" { ? }"}function vd(n,e,t,r){var i=r?sc(t,r):$t.call(t,", ");return n+" ("+e+") {"+i+"}"}function zS(n){for(var e=0;e<n.length;e++)if(Zp(n[e],`
|
|
2
|
-
`)>=0)return!1;return!0}function LS(n,e){var t;if(n.indent===" ")t=" ";else if(typeof n.indent=="number"&&n.indent>0)t=$t.call(Array(n.indent+1)," ");else return null;return{base:t,prev:$t.call(Array(e+1),t)}}function sc(n,e){if(n.length===0)return"";var t=`
|
|
3
|
-
`+e.prev+e.base;return t+$t.call(n,","+t)+`
|
|
4
|
-
`+e.prev}function uo(n,e){var t=ic(n),r=[];if(t){r.length=n.length;for(var i=0;i<n.length;i++)r[i]=zt(n,i)?e(n[i],n):""}var s=typeof Sl=="function"?Sl(n):[],o;if(Xr){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var l in n)zt(n,l)&&(t&&String(Number(l))===l&&l<n.length||Xr&&o["$"+l]instanceof Symbol||(Lp.call(/[^\w$]/,l)?r.push(e(l,n)+": "+e(n[l],n)):r.push(l+": "+e(n[l],n))));if(typeof Sl=="function")for(var u=0;u<s.length;u++)Mp.call(n,s[u])&&r.push("["+e(s[u])+"]: "+e(n[s[u]],n));return r}var MS=ci,NS=B,Ca=function(n,e,t){for(var r=n,i;(i=r.next)!=null;r=i)if(i.key===e)return r.next=i.next,t||(i.next=n.next,n.next=i),i},US=function(n,e){if(n){var t=Ca(n,e);return t&&t.value}},FS=function(n,e,t){var r=Ca(n,e);r?r.value=t:n.next={key:e,next:n.next,value:t}},ZS=function(n,e){return n?!!Ca(n,e):!1},HS=function(n,e){if(n)return Ca(n,e,!0)},VS=function(){var e,t={assert:function(r){if(!t.has(r))throw new NS("Side channel does not contain "+MS(r))},delete:function(r){var i=e&&e.next,s=HS(e,r);return s&&i&&i===s&&(e=void 0),!!s},get:function(r){return US(e,r)},has:function(r){return ZS(e,r)},set:function(r,i){e||(e={next:void 0}),FS(e,r,i)}};return t},jS=st,Gs=bn(),GS=ci,BS=B,bd=jS("%Map%",!0),WS=Gs("Map.prototype.get",!0),qS=Gs("Map.prototype.set",!0),YS=Gs("Map.prototype.has",!0),KS=Gs("Map.prototype.delete",!0),JS=Gs("Map.prototype.size",!0),Vp=!!bd&&function(){var e,t={assert:function(r){if(!t.has(r))throw new BS("Side channel does not contain "+GS(r))},delete:function(r){if(e){var i=KS(e,r);return JS(e)===0&&(e=void 0),i}return!1},get:function(r){if(e)return WS(e,r)},has:function(r){return e?YS(e,r):!1},set:function(r,i){e||(e=new bd),qS(e,r,i)}};return t},XS=st,Ia=bn(),QS=ci,ho=Vp,ek=B,br=XS("%WeakMap%",!0),tk=Ia("WeakMap.prototype.get",!0),nk=Ia("WeakMap.prototype.set",!0),rk=Ia("WeakMap.prototype.has",!0),ik=Ia("WeakMap.prototype.delete",!0),sk=br?function(){var e,t,r={assert:function(i){if(!r.has(i))throw new ek("Side channel does not contain "+QS(i))},delete:function(i){if(br&&i&&(typeof i=="object"||typeof i=="function")){if(e)return ik(e,i)}else if(ho&&t)return t.delete(i);return!1},get:function(i){return br&&i&&(typeof i=="object"||typeof i=="function")&&e?tk(e,i):t&&t.get(i)},has:function(i){return br&&i&&(typeof i=="object"||typeof i=="function")&&e?rk(e,i):!!t&&t.has(i)},set:function(i,s){br&&i&&(typeof i=="object"||typeof i=="function")?(e||(e=new br),nk(e,i,s)):ho&&(t||(t=ho()),t.set(i,s))}};return r}:ho,ok=B,ak=ci,lk=VS,ck=Vp,uk=sk,hk=uk||ck||lk,dk=function(){var e,t={assert:function(r){if(!t.has(r))throw new ok("Side channel does not contain "+ak(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=hk()),e.set(r,i)}};return t},fk=Kt,ki=dk(),Rt=B,fu={assert:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Rt("`O` is not an object");if(typeof e!="string")throw new Rt("`slot` must be a string");if(ki.assert(n),!fu.has(n,e))throw new Rt("`"+e+"` is not present on `O`")},get:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Rt("`O` is not an object");if(typeof e!="string")throw new Rt("`slot` must be a string");var t=ki.get(n);return t&&t["$"+e]},has:function(n,e){if(!n||typeof n!="object"&&typeof n!="function")throw new Rt("`O` is not an object");if(typeof e!="string")throw new Rt("`slot` must be a string");var t=ki.get(n);return!!t&&fk(t,"$"+e)},set:function(n,e,t){if(!n||typeof n!="object"&&typeof n!="function")throw new Rt("`O` is not an object");if(typeof e!="string")throw new Rt("`slot` must be a string");var r=ki.get(n);r||(r={},ki.set(n,r)),r["$"+e]=t}};Object.freeze&&Object.freeze(fu);var pu=fu,jp=qt,dn=pu,Bs=function n(e,t){if(!(this instanceof n))return new n(e,t);if(e!=="normal"&&e!=="break"&&e!=="continue"&&e!=="return"&&e!=="throw")throw new jp('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');dn.set(this,"[[Type]]",e),dn.set(this,"[[Value]]",t)};Bs.prototype.type=function(){return dn.get(this,"[[Type]]")};Bs.prototype.value=function(){return dn.get(this,"[[Value]]")};Bs.prototype["?"]=function(){var e=dn.get(this,"[[Type]]"),t=dn.get(this,"[[Value]]");if(e==="throw")throw t;return t};Bs.prototype["!"]=function(){var e=dn.get(this,"[[Type]]");if(e!=="normal")throw new jp('Assertion failed: Completion Record is not of type "normal"');return dn.get(this,"[[Value]]")};var gu=Bs,pk=gu,mu=function(e){return new pk("normal",e)},El,wd;function gk(){if(wd)return El;wd=1;var n=si;return El=function(){return n()&&!!Symbol.toStringTag},El}var mk=st,_d=mk("%Object.defineProperty%",!0),yk=gk()(),vk=Kt,bk=B,fo=yk?Symbol.toStringTag:null,Gp=function(e,t){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,i=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof r<"u"&&typeof r!="boolean"||typeof i<"u"&&typeof i!="boolean")throw new bk("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");fo&&(r||!vk(e,fo))&&(_d?_d(e,fo,{configurable:!i,enumerable:!1,value:t,writable:!1}):e[fo]=t)},Bp={exports:{}},wk=st,Sd=hp,_k=Aa(),kd=ii,Ed=B,Sk=wk("%Math.floor%"),kk=function(e,t){if(typeof e!="function")throw new Ed("`fn` is not a function");if(typeof t!="number"||t<0||t>4294967295||Sk(t)!==t)throw new Ed("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in e&&kd){var o=kd(e,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!r)&&(_k?Sd(e,"length",t,!0,!0):Sd(e,"length",t)),e},Ek=Fs,$k=ru,Ak=Sp,xk=function(){return Ak(Ek,$k,arguments)};(function(n){var e=kk,t=Us,r=xa,i=xk;n.exports=function(o){var a=r(arguments),l=1+o.length-(arguments.length-1);return e(a,l>0?l:0,!0)},t?t(n.exports,"apply",{value:i}):n.exports.apply=i})(Bp);var yu=Bp.exports,Tk=function(e,t){for(var r=0;r<e.length;r+=1)if(!t(e[r],r,e))return!1;return!0},Ck=Object,Ik=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||Ck(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},Pk=Kt,Rk=iu(),Dk=Tk,Ok=Ik,zk=function(e){return e&&typeof e=="object"&&Pk(e,"[[DisposableResourceStack]]")&&Rk(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||Dk(e["[[DisposableResourceStack]]"],Ok))},Lk=Yt,Mk=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(Lk(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},Nk=Mk,vu=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":Nk(e)},Uk=B,Fk=ci,Zk=ai,Hk=function(e,t){if(!Zk(t))throw new Uk("Assertion failed: P is not a Property Key, got "+Fk(t));return e[t]},$d=B,Vk=Hk,jk=li,Gk=ai,Ad=ci,Bk=function(e,t){if(!Gk(t))throw new $d("Assertion failed: P is not a Property Key");var r=Vk(e,t);if(r!=null){if(!jk(r))throw new $d(Ad(t)+" is not a function: "+Ad(r));return r}},oc={exports:{}},Wk=st,qk=Wk,xd=qk("%Reflect.construct%",!0),Wo=js;try{Wo({},"",{"[[Get]]":function(){}})}catch{Wo=null}if(Wo&&xd){var Td={},Cd={};Wo(Cd,"length",{"[[Get]]":function(){throw Td},"[[Enumerable]]":!0}),oc.exports=function(e){try{xd(e,Cd)}catch(t){return t===Td}}}else oc.exports=function(e){return typeof e=="function"&&!!e.prototype};var Yk=oc.exports,$l=B,Id=li,Kk=Yk,Jk=function(e){if(!Kk(e))throw new $l("C must be a constructor");var t={"[[Resolve]]":void 0,"[[Reject]]":void 0},r=new e(function(i,s){if(typeof t["[[Resolve]]"]<"u"||typeof t["[[Reject]]"]<"u")throw new $l("executor has already been called");t["[[Resolve]]"]=i,t["[[Reject]]"]=s});if(!Id(t["[[Resolve]]"])||!Id(t["[[Reject]]"]))throw new $l("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":t["[[Resolve]]"],"[[Reject]]":t["[[Reject]]"]}},Pd=qt,Xk=B,Al=Ta,Rd=Bk,Qk=Jk,eE=vu,Dd=lu(),Od=cu(),tE=function(e,t){if(eE(e)!=="Object")throw new Xk("`V` must be an Object");if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new Pd("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(t==="ASYNC-DISPOSE"&&Od&&(r=Rd(e,Od)),!r){if(!Dd)throw new Pd("`Symbol.dispose` is not supported");if(r=Rd(e,Dd),typeof r<"u")return function(){var i=this;if(t==="ASYNC-DISPOSE"){var s=Qk(Promise);try{Al(r,i),Al(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}Al(r,i)}}return r},nE=qt,xl=B,rE=li,iE=vu,sE=tE,oE=function(e,t){if(t!=="SYNC-DISPOSE"&&t!=="ASYNC-DISPOSE")throw new nE("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"&&iE(e)!=="Object")throw new xl("`V` must be an Object, or `null` or `undefined`");if(r=sE(e,t),typeof r>"u")throw new xl("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!rE(r))throw new xl("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":t,"[[DisposeMethod]]":r}},aE=qt,po=B,lE=zk,zd=oE,cE=bn(),uE=cE("Array.prototype.push"),Wp=function(e,t,r){if(!lE(e))throw new po("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new aE("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 po("Assertion failed: `method`, when present, must be a function");if(!e["[[DisposableResourceStack]]"])throw new po("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var s;if(arguments.length<4){if(t==null&&r==="SYNC_DISPOSE")return"UNUSED";s=zd(t,r)}else{if(typeof t<"u")throw new po("Assertion failed: `V` must be undefined when `method` is present");s=zd(void 0,r,i)}return uE(e["[[DisposableResourceStack]]"],s),"UNUSED"},Tl,Ld;function bu(){if(Ld)return Tl;Ld=1;var n=st,e=yu,t=qt,r=n("%Promise.resolve%",!0),i=r&&e(r);return Tl=function(o,a){if(!i)throw new t("This environment does not support Promises.");return i(o,a)},Tl}var Cl,Md;function hE(){if(Md)return Cl;Md=1;var n=st,e=qt,t=n("%Promise%",!0),r=Ta,i=bu(),s=vu;return Cl=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(t,d)},Cl}var Il,Nd;function dE(){if(Nd)return Il;Nd=1;var n=gu;return Il=function(t){return new n("throw",t)},Il}var fE=st,Pl=qt,Ud=B,pE=fE("%Promise%",!0),gE=bn(),Fd=gE("Promise.prototype.then",!0),mE=gu,Zd=hE(),yE=mu,vE=bu(),Hd=dE(),bE=zp(),qp=function(e,t){if(!(t instanceof mE))throw new Ud("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new Ud("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var i,s=r.length-1;s>=0;s-=1)if(!i)i=r[s]["[[Hint]]"];else if(i!==r[s]["[[Hint]]"])throw new Pl("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&vE(pE,t),a=function(v){if(t.type()==="throw"){var y=t.value(),A=new bE(v,y);t=Hd(A)}else t=Hd(v)},l=i==="ASYNC-DISPOSE"&&function(y){return Fd(o,function(){var A=Zd(y["[[ResourceValue]]"],y["[[Hint]]"],y["[[DisposeMethod]]"]);if(!A)throw new Pl("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return Fd(A,yE)},a)},u=r.length-1;u>=0;u-=1)if(i==="ASYNC-DISPOSE")o=l(r[u]);else{var d=r[u];try{var f=Zd(d["[[ResourceValue]]"],d["[[Hint]]"],d["[[DisposeMethod]]"]);if(f)throw new Pl("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(v){a(v)}}return e["[[DisposableResourceStack]]"]=null,i==="ASYNC-DISPOSE"?o:t},Yp=function(){var e=[];return{"[[DisposableResourceStack]]":e}},Pa=Qc,wu=B,wE=Ta,ui=ou,_E=js,Kp=li,SE=mu,je=pu,kE=Gp,Jp=ar.supportsDescriptors,EE=yu,_u=Wp,$E=qp,Xp=Yp,Vd=lu(),tt=function n(){if(!(this instanceof n)||je.has(this,"[[DisposableState]]")||je.has(this,"[[DisposeCapability]]"))throw new wu("can only be used with new");je.set(this,"[[DisposableState]]","PENDING"),je.set(this,"[[DisposeCapability]]",Xp())},Qp=function(){var e=this;return je.assert(e,"[[DisposableState]]"),je.get(e,"[[DisposableState]]")==="DISPOSED"},Ws=EE(Qp);Jp?_E(tt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":Qp}):tt.prototype.disposed=!1;var eg=function(e){je.set(e,"[[DisposableState]]","DISPOSED"),Jp||(e.disposed=!0)};ui(tt.prototype,"dispose",function(){var e=this;if(!Ws(e))return eg(e),$E(je.get(e,"[[DisposeCapability]]"),SE())["?"]()});ui(tt.prototype,"use",function(e){var t=this;if(Ws(t))throw new Pa("a disposed stack can not use anything new");return _u(je.get(t,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});ui(tt.prototype,"adopt",function(e,t){var r=this;if(Ws(r))throw new Pa("a disposed stack can not use anything new");if(!Kp(t))throw new wu("`onDispose` must be a function");var i=function(){return wE(t,void 0,[e])};return _u(je.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",i),e});ui(tt.prototype,"defer",function(e){var t=this;if(Ws(t))throw new Pa("a disposed stack can not defer anything new");if(!Kp(e))throw new wu("`onDispose` must be a function");_u(je.get(t,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});ui(tt.prototype,"move",function(){var e=this;if(Ws(e))throw new Pa("a disposed stack can not use anything new");var t=new tt;return je.set(t,"[[DisposeCapability]]",je.get(e,"[[DisposeCapability]]")),je.set(e,"[[DisposeCapability]]",Xp()),eg(e),t});Vd&&ui(tt.prototype,Vd,tt.prototype.dispose);kE(tt.prototype,"DisposableStack");var AE=tt,xE=AE,TE=function(){return typeof DisposableStack=="function"?DisposableStack:xE},CE=ar,IE=Jc(),PE=TE,RE=function(){var e=PE();return CE(IE,{DisposableStack:e},{DisposableStack:!0}),e},DE=st,Ra=Qc,Su=B,jd=DE("%Promise%",!0),ku=Wp,OE=Ta,hi=ou,zE=js,LE=qp,tg=li,ng=Yp,ME=mu,Gd=bu(),Ge=pu,NE=Gp,rg=ar.supportsDescriptors,UE=yu,FE=bn(),ZE=FE("Promise.prototype.then",!0),Bd=cu(),nt=function n(){if(!(this instanceof n)||Ge.has(this,"[[AsyncDisposableState]]")||Ge.has(this,"[[DisposeCapability]]"))throw new Su("can only be used with new");Ge.set(this,"[[AsyncDisposableState]]","pending"),Ge.set(this,"[[DisposeCapability]]",ng())},ig=function(){var e=this;return Ge.assert(e,"[[AsyncDisposableState]]"),Ge.get(e,"[[AsyncDisposableState]]")==="disposed"},qs=UE(ig);rg?zE(nt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":ig}):nt.prototype.disposed=!1;var sg=function(e){Ge.set(e,"[[AsyncDisposableState]]","disposed"),rg||(e.disposed=!0)};hi(nt.prototype,"disposeAsync",function(){var e=this;return qs(e)?Gd(jd):(sg(e),ZE(Gd(jd,LE(Ge.get(e,"[[DisposeCapability]]"),ME())),function(t){return t["?"]()}))});hi(nt.prototype,"use",function(e){var t=this;if(qs(t))throw new Ra("a disposed stack can not use anything new");return ku(Ge.get(t,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});hi(nt.prototype,"adopt",function(e,t){var r=this;if(qs(r))throw new Ra("a disposed stack can not use anything new");if(!tg(t))throw new Su("`onDisposeAsync` must be a function");var i=function(){return OE(t,void 0,[e])};return i.value=e,ku(Ge.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",i),e});hi(nt.prototype,"defer",function(e){var t=this;if(qs(t))throw new Ra("a disposed stack can not defer anything new");if(!tg(e))throw new Su("`onDispose` must be a function");ku(Ge.get(t,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});hi(nt.prototype,"move",function(){var e=this;if(qs(e))throw new Ra("a disposed stack can not use anything new");var t=new nt;return Ge.set(t,"[[DisposeCapability]]",Ge.get(e,"[[DisposeCapability]]")),Ge.set(e,"[[DisposeCapability]]",ng()),sg(e),t});Bd&&hi(nt.prototype,Bd,nt.prototype.disposeAsync);NE(nt.prototype,"AsyncDisposableStack");var HE=nt,VE=HE,jE=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:VE},GE=ar,BE=Jc(),WE=jE,qE=function(){var e=WE();return GE(BE,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},YE=G_,KE=Q_,JE=RE,XE=qE,QE=function(){YE(),KE(),JE(),XE()};QE();const Wd=new WeakMap;function e0(n){return(typeof n=="object"||typeof n=="function")&&n!==null&&"then"in n&&typeof n.then=="function"}function wr(n){return typeof n=="string"?n:typeof n=="symbol"?n.description??n.toString():n.name||"(anonymous class)"}function qd(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function t0(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class n0{constructor(){b(this,"entries",new Map);b(this,"constructionStack",[])}register(e,t){if(t===void 0){if(typeof e!="function")throw qd();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof t!="function")throw qd();if(t.constructor.name==="AsyncFunction")throw t0();this.storeFactory(e,t)}has(e){var t;return((t=this.entries.get(e))==null?void 0:t.factory)!==void 0}resolve(e){return this.resolveAny(e)}storeFactory(e,t){const r=this.getOrCreateEntry(e);r.factory=t,r.instance=void 0,r.error=void 0}validateClassRegistration(e){const t=Wd.get(e);if(t){if(e.length!==t.length)throw new Error(`${wr(e)} cannot be registered with register(Class). @injectable(...) declared ${t.length} dependencies but constructor arity is ${e.length}. Use register(Key, () => value) instead.`);return}if(e.length!==0)throw new Error(`${wr(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const t=Wd.get(e);if(!t)return new e;const r=t.map(i=>this.resolveAny(i));return new e(...r)}resolveAny(e){return this.getOrCreateEntry(e).proxy}getOrCreateEntry(e){let t=this.entries.get(e);return t||(t={key:e},t.proxy=this.createProxy(t),this.entries.set(e,t),t)}createProxy(e){return new Proxy({},{get:(t,r)=>{if(r==="then")return;const i=this.getInstance(e),s=Reflect.get(i,r,i);return typeof s=="function"?s.bind(i):s},set:(t,r,i)=>{const s=this.getInstance(e);return Reflect.set(s,r,i,s)},has:(t,r)=>{const i=this.getInstance(e);return r in i}})}getInstance(e){if(e.instance)return e.instance;if(e.error)throw e.error;if(!e.factory)throw new Error(`${wr(e.key)} was resolved but never registered`);const t=this.constructionStack.indexOf(e.key);if(t!==-1){const r=[...this.constructionStack.slice(t),e.key].map(i=>wr(i)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(e.key);try{const r=e.factory();if(e0(r))throw new Error(`Factory for ${wr(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${wr(e.key)} returned a non-object value. Wrap primitives in an object.`);return e.instance=r,r}catch(r){throw e.error=r,r}finally{this.constructionStack.pop()}}}const rt=new n0,r0=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function i0(n){for(const e of Object.keys(n))if(r0.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function s0(n,e){i0(e);for(const t of Object.keys(e))Object.defineProperty(n,t,{value:e[t],writable:!0,enumerable:!0,configurable:!0})}function xt(){class n extends Event{constructor(t,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(t,{bubbles:s,cancelable:o,composed:a}),s0(this,l)}}return n}class Tt extends globalThis.EventTarget{}function o0(n,e,t){const r=n.dispose.bind(n);n.dispose=()=>{if(!e())return t(),r()}}function di(n){var t;class e extends n{constructor(...s){super(...s);S(this,t,!1);o0(this,()=>c(this,t),()=>{E(this,t,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return c(this,t)}}return t=new WeakMap,e}const a0=xt(),zo=xt(),og="0123456789ABCDEFGHJKMNPQRSTVWXYZ",qo=32,l0=16,ag=10,Yd=0xffffffffffff;var zn;(function(n){n.Base32IncorrectEncoding="B32_ENC_INVALID",n.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",n.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",n.EncodeTimeNegative="ENC_TIME_NEG",n.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",n.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",n.PRNGDetectFailure="PRNG_DETECT",n.ULIDInvalid="ULID_INVALID",n.Unexpected="UNEXPECTED",n.UUIDInvalid="UUID_INVALID"})(zn||(zn={}));class Oi extends Error{constructor(e,t){super(`${t} (${e})`),this.name="ULIDError",this.code=e}}function c0(n){const e=Math.floor(n()*qo)%qo;return og.charAt(e)}function u0(n){const e=h0(),t=e&&(e.crypto||e.msCrypto)||null;if(typeof(t==null?void 0:t.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return t.getRandomValues(r),r[0]/256};if(typeof(t==null?void 0:t.randomBytes)=="function")return()=>t.randomBytes(1).readUInt8()/256;throw new Oi(zn.PRNGDetectFailure,"Failed to find a reliable PRNG")}function h0(){return p0()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function d0(n,e){let t="";for(;n>0;n--)t=c0(e)+t;return t}function f0(n,e=ag){if(isNaN(n))throw new Oi(zn.EncodeTimeValueMalformed,`Time must be a number: ${n}`);if(n>Yd)throw new Oi(zn.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Yd}: ${n}`);if(n<0)throw new Oi(zn.EncodeTimeNegative,`Time must be positive: ${n}`);if(Number.isInteger(n)===!1)throw new Oi(zn.EncodeTimeValueMalformed,`Time must be an integer: ${n}`);let t,r="";for(let i=e;i>0;i--)t=n%qo,r=og.charAt(t)+r,n=(n-t)/qo;return r}function p0(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Eu(n,e){const t=u0(),r=Date.now();return f0(r,ag)+d0(l0,t)}const At=4,Je=6,lg=2,ac=2,g0=At,m0=Je,$u="auto",fn="auto",Pn=120,Kd=75,pe=16,tr=Pn*At+pe*(At-1),Yo=Pn*Je+pe*(Je-1),y0=200,v0=4,go=150,b0=10,Jd=2,w0=4;function cg(n){return dg(n)}function ug(n,e){return dg(n.flatMap(t=>pg(t,e)))}function hg(n){const e=[],t=new Set;for(const r of n){if(r.type==="row"){e.push(`Top-level rows are invalid: ${r.id}`);continue}gg(r,"strip",e,t)}return{valid:e.length===0,errors:e}}function Wi(n){const e=cg(n),t=hg(e);if(!t.valid)throw new Error(`Invalid layout: ${t.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(E0)}}function dg(n){const e=[];for(const t of n){const r=fg(t);for(const i of r){if(i.type==="row"){e.push(...i.children.map(Bt));continue}e.push(i)}}return e}function fg(n){switch(n.type){case"card":return[Bt(n)];case"row":{const e=n.children.map(Bt);return e.length===0?[]:e.length===1?[e[0]]:[{...n,children:e}]}case"stack":{const e=[];for(const t of n.children){const r=fg(t);for(const i of r){if(i.type==="stack"){e.push(...i.children.map(lc));continue}if(i.type==="row"){e.push({...i,children:i.children.map(Bt)});continue}e.push(Bt(i))}}return e.length===0?[]:e.length===1?[lc(e[0])]:[{...n,children:e}]}}}function pg(n,e){switch(n.type){case"card":return n.artifactID===e?[]:[Bt(n)];case"row":{const t=n.children.filter(r=>r.artifactID!==e).map(Bt);return t.length===0?[]:t.length===1?[t[0]]:[{...n,children:t}]}case"stack":{const t=n.children.flatMap(r=>pg(r,e).filter(s=>s.type!=="stack"));return t.length===0?[]:t.length===1?[lc(t[0])]:[{...n,children:t}]}}}function gg(n,e,t,r){switch(n.type){case"card":mg(n,e,t,r);return;case"row":_0(n,e,t,r);return;case"stack":S0(n,e,t,r);return}}function mg(n,e,t,r){Au(n.id,t),typeof n.artifactID!="string"||n.artifactID.length===0?t.push(`Card ${n.id} is missing artifactID`):r.has(n.artifactID)?t.push(`Duplicate artifactID in layout: ${n.artifactID}`):r.add(n.artifactID),k0(n.width)||t.push(`Card ${n.id} width must be an integer in the range 2-4`),yg(n.height)||t.push(`Card ${n.id} height must be an integer in the range 2-6 or "auto"`);const i=Rn(n.width);e==="row"&&i<lg&&t.push(`Row child ${n.id} must be at least 2 columns wide`)}function _0(n,e,t,r){if(Au(n.id,t),e!=="stack"&&t.push(`Row ${n.id} may only appear inside a stack`),yg(n.height,w0)||t.push(`Row ${n.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(n.children)||n.children.length===0){t.push(`Row ${n.id} must contain card nodes`);return}let i=0;for(const s of n.children){if(s.type!=="card"){t.push(`Row ${n.id} must contain only card nodes`);continue}mg(s,"row",t,r),i+=Rn(s.width)}i!==At&&t.push(`Row ${n.id} children must sum to 4 columns`)}function S0(n,e,t,r){if(Au(n.id,t),e!=="strip"&&t.push(`Invalid nested stack at ${n.id}; stack children cannot contain another nested stack`),!Array.isArray(n.children)||n.children.length===0){t.push(`Stack ${n.id} must contain at least one child`);return}let i=0,s=0;for(const a of n.children){if(a.type==="stack"){t.push(`Stack ${n.id} cannot contain another nested stack`);continue}if(gg(a,"stack",t,r),a.height===fn){s+=1;continue}i+=a.height}if(i>Je&&t.push(`Stack ${n.id} exceeds the 6-row budget`),s===0)return;const o=Je-i;if(o<s*ac||o%s!==0){t.push(`Stack ${n.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<ac&&t.push(`Stack ${n.id} has auto-height children below the minimum row size`)}function Au(n,e){(typeof n!="string"||n.length===0)&&e.push(`Node id must be a non-empty string: ${String(n)}`)}function k0(n){return n===$u||Number.isInteger(n)&&n>=lg&&n<=g0}function yg(n,e=m0){return n===fn||Number.isInteger(n)&&n>=ac&&n<=e}function Rn(n){return n===$u?At:n}function E0(n){if(n.type==="card")return{id:n.id,type:"card",width:Rn(n.width),cards:[{id:n.id,artifactID:n.artifactID,col:1,row:1,width:Rn(n.width),height:vg(n.height,Je)}]};const e=$0(n.children),t=[];let r=1;for(let i=0;i<n.children.length;i+=1){const s=n.children[i],o=e[i];if(s.type==="card")t.push({id:s.id,artifactID:s.artifactID,col:1,row:r,width:Rn(s.width),height:o});else{let a=1;for(const l of s.children)t.push({id:l.id,artifactID:l.artifactID,col:a,row:r,width:Rn(l.width),height:o}),a+=Rn(l.width)}r+=o}return{id:n.id,type:"stack",width:t.reduce((i,s)=>Math.max(i,s.col+s.width-1),1),cards:t}}function $0(n){let e=0,t=0;for(const i of n)i.height===fn?t+=1:e+=i.height;const r=t>0?(Je-e)/t:0;return n.map(i=>vg(i.height,r))}function vg(n,e){return n===fn?e:n}function Bt(n){return{...n}}function lc(n){return n.type==="card"?Bt(n):{...n,children:n.children.map(Bt)}}function bg(n,e={}){return{id:e.id??Eu(),type:"card",artifactID:n,width:e.width??$u,height:e.height??fn}}function wg(n,e){return n.some(t=>_g(t,e))}function _g(n,e){switch(n.type){case"card":return n.artifactID===e;case"row":return n.children.some(t=>t.artifactID===e);case"stack":return n.children.some(t=>_g(t,e))}}function Xd(n){return n.layout.flatMap(Sg)}function Sg(n){switch(n.type){case"card":return[n.artifactID];case"row":return n.children.map(e=>e.artifactID);case"stack":return n.children.flatMap(Sg)}}const Q=xt(),kg=xt(),Ei=xt(),A0=xt();function x0(n){class e extends Error{constructor(r,i){super(r),this.name=n,i&&Object.assign(this,i)}}return e}const T0=x0("RequestError"),C0=200,I0=300;class P0{constructor(e,t){b(this,"serverURL");b(this,"token");this.serverURL=e.replace(/\/$/,""),this.token=t.token}async requestJSON(e,t,r){const i=await this.request(e,t,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),s=await R0(i);if(!i.ok||i.status<C0||i.status>=I0)throw this.createError(typeof s.error=="string"?s.error:i.statusText,i.status);return s}async requestVoid(e,t){const r=await this.request(e,t);if(!r.ok)throw this.createError(await Rl(r,r.statusText),r.status)}async requestText(e,t){const r=await this.request(e,t);if(!r.ok)throw this.createError(await Rl(r,r.statusText),r.status);return r.text()}async requestRawVoid(e,t,r){const i=await this.request(e,t,r,{"content-type":"text/plain"});if(!i.ok)throw this.createError(await Rl(i,i.statusText),i.status)}createError(e,t){const r={serverURL:this.serverURL};return t!==void 0&&(r.status=t),new T0(e,r)}async request(e,t,r,i){const s=`${this.serverURL}${t}`;try{return await fetch(s,{method:e,headers:this.buildHeaders(i),body:r})}catch(o){throw this.createError(o instanceof Error?o.message:"Failed to reach server")}}buildHeaders(e){const t={...e??{}};return this.token&&(t.Authorization=`Bearer ${this.token}`),Object.keys(t).length>0?t:void 0}}async function R0(n){try{return await n.json()}catch{const e=await n.text().catch(()=>"");return e?{message:e}:{}}}async function Rl(n,e){try{const t=await n.json();if(typeof t.error=="string")return t.error;if(typeof t.message=="string")return t.message}catch{}return e}function Eg(n){return n.map(e=>`${e.name} (${e.id})`).join(", ")}var _t,aa,$g;class D0{constructor(e){S(this,aa);S(this,_t);E(this,_t,e)}list(){return c(this,_t).requestJSON("GET","/screens")}async get(e={}){const t=await m(this,aa,$g).call(this,e.screenID);return c(this,_t).requestJSON("GET",`/screens/${encodeURIComponent(t)}`)}create(e){const t={name:e.name};return e.id!==void 0&&(t.id=e.id),c(this,_t).requestJSON("POST","/screens",t)}update(e){const t={};return e.name!==void 0&&(t.name=e.name),e.layout!==void 0&&(t.layout=e.layout),c(this,_t).requestJSON("PATCH",`/screens/${encodeURIComponent(e.screenID)}`,t)}remove(e){return c(this,_t).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}_t=new WeakMap,aa=new WeakSet,$g=async function(e){if(e!==void 0)return e;const{screens:t}=await this.list();if(t.length===1)return t[0].id;throw c(this,_t).createError(`screenID is required when multiple screens exist. Available screens: ${Eg(t)}`)};var Ze,ns,la,Ag;class O0{constructor(e,t){S(this,la);S(this,Ze);S(this,ns);E(this,Ze,e),E(this,ns,t)}async create(e){const t=await m(this,la,Ag).call(this,e.screenID);return c(this,Ze).requestJSON("POST",`/screens/${encodeURIComponent(t)}/artifact`,{type:e.type,title:e.title,externalFilePath:e.externalFilePath})}get(e){return c(this,Ze).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const t={};return e.title!==void 0&&(t.title=e.title),c(this,Ze).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,t)}edit(e){return c(this,Ze).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return c(this,Ze).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return c(this,Ze).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}remove(e){return c(this,Ze).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return c(this,Ze).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return c(this,Ze).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}Ze=new WeakMap,ns=new WeakMap,la=new WeakSet,Ag=async function(e){if(e!==void 0)return e;const{screens:t}=await c(this,ns).list();if(t.length===1)return t[0].id;throw c(this,Ze).createError(`screenID is required when multiple screens exist. Available screens: ${Eg(t)}`)};var rs;class z0{constructor(e){S(this,rs);E(this,rs,e)}async list(){const{views:e}=await c(this,rs).requestJSON("GET","/views");return e}}rs=new WeakMap;var tn;class L0{constructor(e,t={}){b(this,"screens");b(this,"artifacts");b(this,"views");S(this,tn);E(this,tn,new P0(e,t)),this.screens=new D0(c(this,tn)),this.artifacts=new O0(c(this,tn),this.screens),this.views=new z0(c(this,tn))}health(){return c(this,tn).requestJSON("GET","/health")}}tn=new WeakMap;const M0=di(Tt);var Mn,He,Nn,ze,nn,rn,J,Sr,xg,is,Tg,Cg,Ig,Pg,cc,uc,hc,Rg;class N0 extends M0{constructor(t){var i;super();S(this,J);b(this,"id");b(this,"server");S(this,Mn);S(this,He,new Map);S(this,Nn);S(this,ze);S(this,nn);S(this,rn,null);S(this,is,t=>{if(this.disposed)return;const r=t.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&m(this,J,Tg).call(this,r.screen);break;case"artifact-created":r.screenID===this.id&&m(this,J,Cg).call(this,r.artifact);break;case"artifact-updated":m(this,J,Ig).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&m(this,J,Pg).call(this,r.artifactID);break;case"artifact-content-changed":c(this,He).has(r.artifactID)&&this.dispatchEvent(new A0("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=t.screen.id,this.server=t.server,E(this,Mn,t.localStore),E(this,Nn,t.screen.name),E(this,ze,structuredClone(t.screen.layout));const r=((i=c(this,Mn).get().screens[this.id])==null?void 0:i.scrollPosition)??0;E(this,nn,Math.max(0,r)),this.server.addEventListener("server-event",c(this,is)),m(this,J,xg).call(this)}get name(){return c(this,Nn)}get layout(){return c(this,ze)}get scrollPosition(){return c(this,nn)}get artifacts(){return c(this,He)}setScrollPosition(t){m(this,J,Sr).call(this);const r=Math.max(0,t);r!==c(this,nn)&&(E(this,nn,r),m(this,J,Rg).call(this),this.dispatchEvent(new Q("change")))}setLayout(t){m(this,J,Sr).call(this);const r=cg(t);if(!hg(r).valid)return;const s=m(this,J,uc).call(this);E(this,ze,r),E(this,rn,{layout:r,snapshot:s}),this.dispatchEvent(new Q("change")),this.server.client.screens.update({screenID:this.id,layout:r.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=c(this,rn))==null?void 0:o.layout)===r&&(E(this,rn,null),m(this,J,hc).call(this,s),this.dispatchEvent(new Q("change")))})}rename(t){m(this,J,Sr).call(this),E(this,Nn,t),this.dispatchEvent(new Q("change")),this.server.client.screens.update({screenID:this.id,name:t}).catch(()=>{})}async remove(){m(this,J,Sr).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(t){if(m(this,J,Sr).call(this),!c(this,He).has(t))return;const r=m(this,J,uc).call(this);m(this,J,cc).call(this,t),this.dispatchEvent(new Q("change")),this.server.client.artifacts.remove({artifactID:t,screenID:this.id}).catch(()=>{this.disposed||(m(this,J,hc).call(this,r),this.dispatchEvent(new Q("change")))})}dispose(){this.server.removeEventListener("server-event",c(this,is))}}Mn=new WeakMap,He=new WeakMap,Nn=new WeakMap,ze=new WeakMap,nn=new WeakMap,rn=new WeakMap,J=new WeakSet,Sr=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},xg=async function(){try{const t=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of t.artifacts)c(this,He).set(r.id,r);this.dispatchEvent(new Q("change"))}catch{}},is=new WeakMap,Tg=function(t){c(this,rn)&&E(this,rn,null),E(this,Nn,t.name),E(this,ze,structuredClone(t.layout)),this.dispatchEvent(new Q("change"))},Cg=function(t){wg(c(this,ze),t.id)||E(this,ze,[...c(this,ze),bg(t.id)]),c(this,He).set(t.id,t),this.dispatchEvent(new Q("change"))},Ig=function(t){const r=c(this,He).get(t.id);r&&(c(this,He).set(t.id,{...r,...t}),this.dispatchEvent(new Q("change")))},Pg=function(t){m(this,J,cc).call(this,t)&&this.dispatchEvent(new Q("change"))},cc=function(t){const r=c(this,He).delete(t),i=Xd({layout:c(this,ze)}).length,s=ug(c(this,ze),t),o=Xd({layout:s}).length;return E(this,ze,s),r||i!==o},uc=function(){return{layout:structuredClone(c(this,ze)),artifacts:new Map([...c(this,He).entries()].map(([t,r])=>[t,structuredClone(r)]))}},hc=function(t){E(this,ze,structuredClone(t.layout)),c(this,He).clear();for(const[r,i]of t.artifacts)c(this,He).set(r,structuredClone(i))},Rg=function(){const t=c(this,Mn).get();c(this,Mn).set({...t,screens:{...t.screens,[this.id]:{scrollPosition:c(this,nn)}}})};const U0=di(Tt);var Xe,Mt,at,ss,os,as,Dr,Lo;class F0 extends U0{constructor(t){super();S(this,Dr);S(this,Xe);S(this,Mt);S(this,at,null);S(this,ss,()=>{this.disposed||m(this,Dr,Lo).call(this)});S(this,os,()=>{this.disposed||m(this,Dr,Lo).call(this)});S(this,as,t=>{var i;if(this.disposed)return;const r=t.event;r.type==="screen-removed"&&((i=c(this,at))==null?void 0:i.id)===r.screenID&&this.clearActive()});E(this,Xe,t.localStore),E(this,Mt,t.serverManager),c(this,Xe).addEventListener("change",c(this,ss)),c(this,Mt).addEventListener("change",c(this,os)),c(this,Mt).addEventListener("server-event",c(this,as)),m(this,Dr,Lo).call(this)}get activeScreen(){return c(this,at)}setActive(t,r){const i=c(this,Xe).get();i.activeServerURL===t&&i.activeScreenID===r||c(this,Xe).set({...i,activeServerURL:t,activeScreenID:r})}clearActive(){const t=c(this,Xe).get();t.activeScreenID!==null&&c(this,Xe).set({...t,activeScreenID:null})}dispose(){var t;c(this,Xe).removeEventListener("change",c(this,ss)),c(this,Mt).removeEventListener("change",c(this,os)),c(this,Mt).removeEventListener("server-event",c(this,as)),(t=c(this,at))==null||t.dispose(),E(this,at,null)}}Xe=new WeakMap,Mt=new WeakMap,at=new WeakMap,ss=new WeakMap,os=new WeakMap,as=new WeakMap,Dr=new WeakSet,Lo=function(){var l,u,d;const{activeServerURL:t,activeScreenID:r}=c(this,Xe).get(),i=t?c(this,Mt).servers.get(t)??null:null,s=i&&r?i.screens.get(r)??null:null,o=((l=c(this,at))==null?void 0:l.id)??null,a=(s==null?void 0:s.id)??null;o===a&&((u=c(this,at))==null?void 0:u.server)===i||((d=c(this,at))==null||d.dispose(),E(this,at,i&&s?new N0({screen:s,server:i,localStore:c(this,Xe)}):null),this.dispatchEvent(new a0("active-screen-changed")))};const Z0="Local",H0="store-";function Lt(n){return new URL(n).origin}function V0(n){return{servers:[{url:Lt(n),name:Z0}],activeServerURL:null,activeScreenID:null,screens:{}}}var Un,Fn,Zn;class j0 extends Tt{constructor(t,r,i={}){super();S(this,Un);S(this,Fn);S(this,Zn);E(this,Un,`${H0}${t}`),E(this,Fn,i.storage??G0());const s=c(this,Fn).getItem(c(this,Un));s===null?(E(this,Zn,r),c(this,Fn).setItem(c(this,Un),JSON.stringify(r))):E(this,Zn,JSON.parse(s))}get(){return c(this,Zn)}set(t){E(this,Zn,t),c(this,Fn).setItem(c(this,Un),JSON.stringify(t)),this.dispatchEvent(new Q("change"))}}Un=new WeakMap,Fn=new WeakMap,Zn=new WeakMap;function G0(){const n=globalThis.localStorage;if(!n)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return n}function $(n,e,t){function r(a,l){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:l,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(n))return;a._zod.traits.add(n),e(a,l);const u=o.prototype,d=Object.keys(u);for(let f=0;f<d.length;f++){const v=d[f];v in a||(a[v]=u[v].bind(a))}}const i=(t==null?void 0:t.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:n});function o(a){var l;const u=t!=null&&t.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 t!=null&&t.Parent&&a instanceof t.Parent?!0:(u=(l=a==null?void 0:a._zod)==null?void 0:l.traits)==null?void 0:u.has(n)}}),Object.defineProperty(o,"name",{value:n}),o}class Rr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Dg extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Og={};function pn(n){return Og}function zg(n){const e=Object.values(n).filter(r=>typeof r=="number");return Object.entries(n).filter(([r,i])=>e.indexOf(+r)===-1).map(([r,i])=>i)}function dc(n,e){return typeof e=="bigint"?e.toString():e}function xu(n){return{get value(){{const e=n();return Object.defineProperty(this,"value",{value:e}),e}}}}function Tu(n){return n==null}function Cu(n){const e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function B0(n,e){const t=(n.toString().split(".")[1]||"").length,r=e.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const l=r.match(/\d?e-(\d?)/);l!=null&&l[1]&&(i=Number.parseInt(l[1]))}const s=t>i?t:i,o=Number.parseInt(n.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return o%a/10**s}const Qd=Symbol("evaluating");function X(n,e,t){let r;Object.defineProperty(n,e,{get(){if(r!==Qd)return r===void 0&&(r=Qd,r=t()),r},set(i){Object.defineProperty(n,e,{value:i})},configurable:!0})}function cr(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function _n(...n){const e={};for(const t of n){const r=Object.getOwnPropertyDescriptors(t);Object.assign(e,r)}return Object.defineProperties({},e)}function ef(n){return JSON.stringify(n)}function W0(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Lg="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function Ko(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const q0=xu(()=>{var n;if(typeof navigator<"u"&&((n=navigator==null?void 0:navigator.userAgent)!=null&&n.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Qr(n){if(Ko(n)===!1)return!1;const e=n.constructor;if(e===void 0||typeof e!="function")return!0;const t=e.prototype;return!(Ko(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}function Mg(n){return Qr(n)?{...n}:Array.isArray(n)?[...n]:n}const Y0=new Set(["string","number","symbol"]);function ei(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Sn(n,e,t){const r=new n._zod.constr(e??n._zod.def);return(!e||t!=null&&t.parent)&&(r._zod.parent=n),r}function O(n){const e=n;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function K0(n){return Object.keys(n).filter(e=>n[e]._zod.optin==="optional"&&n[e]._zod.optout==="optional")}const J0={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 X0(n,e){const t=n._zod.def,r=t.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=_n(n._zod.def,{get shape(){const o={};for(const a in e){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(o[a]=t.shape[a])}return cr(this,"shape",o),o},checks:[]});return Sn(n,s)}function Q0(n,e){const t=n._zod.def,r=t.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=_n(n._zod.def,{get shape(){const o={...n._zod.def.shape};for(const a in e){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete o[a]}return cr(this,"shape",o),o},checks:[]});return Sn(n,s)}function e$(n,e){if(!Qr(e))throw new Error("Invalid input to extend: expected a plain object");const t=n._zod.def.checks;if(t&&t.length>0){const s=n._zod.def.shape;for(const o in e)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=_n(n._zod.def,{get shape(){const s={...n._zod.def.shape,...e};return cr(this,"shape",s),s}});return Sn(n,i)}function t$(n,e){if(!Qr(e))throw new Error("Invalid input to safeExtend: expected a plain object");const t=_n(n._zod.def,{get shape(){const r={...n._zod.def.shape,...e};return cr(this,"shape",r),r}});return Sn(n,t)}function n$(n,e){const t=_n(n._zod.def,{get shape(){const r={...n._zod.def.shape,...e._zod.def.shape};return cr(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return Sn(n,t)}function r$(n,e,t){const i=e._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=_n(e._zod.def,{get shape(){const a=e._zod.def.shape,l={...a};if(t)for(const u in t){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);t[u]&&(l[u]=n?new n({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)l[u]=n?new n({type:"optional",innerType:a[u]}):a[u];return cr(this,"shape",l),l},checks:[]});return Sn(e,o)}function i$(n,e,t){const r=_n(e._zod.def,{get shape(){const i=e._zod.def.shape,s={...i};if(t)for(const o in t){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(s[o]=new n({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new n({type:"nonoptional",innerType:i[o]});return cr(this,"shape",s),s}});return Sn(e,r)}function Cr(n,e=0){var t;if(n.aborted===!0)return!0;for(let r=e;r<n.issues.length;r++)if(((t=n.issues[r])==null?void 0:t.continue)!==!0)return!0;return!1}function Ir(n,e){return e.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(n),t})}function mo(n){return typeof n=="string"?n:n==null?void 0:n.message}function gn(n,e,t){var i,s,o,a,l,u;const r={...n,path:n.path??[]};if(!n.message){const d=mo((o=(s=(i=n.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,n))??mo((a=e==null?void 0:e.error)==null?void 0:a.call(e,n))??mo((l=t.customError)==null?void 0:l.call(t,n))??mo((u=t.localeError)==null?void 0:u.call(t,n))??"Invalid input";r.message=d}return delete r.inst,delete r.continue,e!=null&&e.reportInput||delete r.input,r}function Iu(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function Ji(...n){const[e,t,r]=n;return typeof e=="string"?{message:e,code:"custom",input:t,inst:r}:{...e}}const Ng=(n,e)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:e,enumerable:!1}),n.message=JSON.stringify(e,dc,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},Ug=$("$ZodError",Ng),Fg=$("$ZodError",Ng,{Parent:Error});function s$(n,e=t=>t.message){const t={},r=[];for(const i of n.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):r.push(e(i));return{formErrors:r,fieldErrors:t}}function o$(n,e=t=>t.message){const t={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>r({issues:o}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)t._errors.push(e(s));else{let o=t,a=0;for(;a<s.path.length;){const 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(n),t}const Pu=n=>(e,t,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},o=e._zod.run({value:t,issues:[]},s);if(o instanceof Promise)throw new Rr;if(o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(l=>gn(l,s,pn())));throw Lg(a,i==null?void 0:i.callee),a}return o.value},Ru=n=>async(e,t,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=e._zod.run({value:t,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??n)(o.issues.map(l=>gn(l,s,pn())));throw Lg(a,i==null?void 0:i.callee),a}return o.value},Da=n=>(e,t,r)=>{const i=r?{...r,async:!1}:{async:!1},s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new Rr;return s.issues.length?{success:!1,error:new(n??Ug)(s.issues.map(o=>gn(o,i,pn())))}:{success:!0,data:s.value}},a$=Da(Fg),Oa=n=>async(e,t,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=e._zod.run({value:t,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new n(s.issues.map(o=>gn(o,i,pn())))}:{success:!0,data:s.value}},l$=Oa(Fg),c$=n=>(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Pu(n)(e,t,i)},u$=n=>(e,t,r)=>Pu(n)(e,t,r),h$=n=>async(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ru(n)(e,t,i)},d$=n=>async(e,t,r)=>Ru(n)(e,t,r),f$=n=>(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Da(n)(e,t,i)},p$=n=>(e,t,r)=>Da(n)(e,t,r),g$=n=>async(e,t,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Oa(n)(e,t,i)},m$=n=>async(e,t,r)=>Oa(n)(e,t,r),y$=/^[cC][^\s-]{8,}$/,v$=/^[0-9a-z]+$/,b$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,w$=/^[0-9a-vA-V]{20}$/,_$=/^[A-Za-z0-9]{27}$/,S$=/^[a-zA-Z0-9_-]{21}$/,k$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,E$=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,tf=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,$$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,A$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function x$(){return new RegExp(A$,"u")}const T$=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,C$=/^(([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}|:))$/,I$=/^((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])$/,P$=/^(([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])$/,R$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Zg=/^[A-Za-z0-9_-]*$/,D$=/^\+[1-9]\d{6,14}$/,Hg="(?:(?:\\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])))",O$=new RegExp(`^${Hg}$`);function Vg(n){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${e}`:n.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${n.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function z$(n){return new RegExp(`^${Vg(n)}$`)}function L$(n){const e=Vg({precision:n.precision}),t=["Z"];n.local&&t.push(""),n.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${e}(?:${t.join("|")})`;return new RegExp(`^${Hg}T(?:${r})$`)}const M$=n=>{const e=n?`[\\s\\S]{${(n==null?void 0:n.minimum)??0},${(n==null?void 0:n.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},N$=/^-?\d+$/,jg=/^-?\d+(?:\.\d+)?$/,U$=/^(?:true|false)$/i,F$=/^[^A-Z]*$/,Z$=/^[^a-z]*$/,Be=$("$ZodCheck",(n,e)=>{var t;n._zod??(n._zod={}),n._zod.def=e,(t=n._zod).onattach??(t.onattach=[])}),Gg={number:"number",bigint:"bigint",object:"date"},Bg=$("$ZodCheckLessThan",(n,e)=>{Be.init(n,e);const t=Gg[typeof e.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?i.maximum=e.value:i.exclusiveMaximum=e.value)}),n._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:t,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),Wg=$("$ZodCheckGreaterThan",(n,e)=>{Be.init(n,e);const t=Gg[typeof e.value];n._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?i.minimum=e.value:i.exclusiveMinimum=e.value)}),n._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:t,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),H$=$("$ZodCheckMultipleOf",(n,e)=>{Be.init(n,e),n._zod.onattach.push(t=>{var r;(r=t._zod.bag).multipleOf??(r.multipleOf=e.value)}),n._zod.check=t=>{if(typeof t.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof t.value=="bigint"?t.value%e.value===BigInt(0):B0(t.value,e.value)===0)||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:e.value,input:t.value,inst:n,continue:!e.abort})}}),V$=$("$ZodCheckNumberFormat",(n,e)=>{var o;Be.init(n,e),e.format=e.format||"float64";const t=(o=e.format)==null?void 0:o.includes("int"),r=t?"int":"number",[i,s]=J0[e.format];n._zod.onattach.push(a=>{const l=a._zod.bag;l.format=e.format,l.minimum=i,l.maximum=s,t&&(l.pattern=N$)}),n._zod.check=a=>{const l=a.value;if(t){if(!Number.isInteger(l)){a.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:l,inst:n});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:n,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:n,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:n,continue:!e.abort}),l>s&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:s,inclusive:!0,inst:n,continue:!e.abort})}}),j$=$("$ZodCheckMaxLength",(n,e)=>{var t;Be.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Tu(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<i&&(r._zod.bag.maximum=e.maximum)}),n._zod.check=r=>{const i=r.value;if(i.length<=e.maximum)return;const o=Iu(i);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),G$=$("$ZodCheckMinLength",(n,e)=>{var t;Be.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Tu(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(r._zod.bag.minimum=e.minimum)}),n._zod.check=r=>{const i=r.value;if(i.length>=e.minimum)return;const o=Iu(i);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:n,continue:!e.abort})}}),B$=$("$ZodCheckLengthEquals",(n,e)=>{var t;Be.init(n,e),(t=n._zod.def).when??(t.when=r=>{const i=r.value;return!Tu(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=e.length,i.maximum=e.length,i.length=e.length}),n._zod.check=r=>{const i=r.value,s=i.length;if(s===e.length)return;const o=Iu(i),a=s>e.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:r.value,inst:n,continue:!e.abort})}}),za=$("$ZodCheckStringFormat",(n,e)=>{var t,r;Be.init(n,e),n._zod.onattach.push(i=>{const s=i._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(t=n._zod).check??(t.check=i=>{e.pattern.lastIndex=0,!e.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:e.format,input:i.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:n,continue:!e.abort})}):(r=n._zod).check??(r.check=()=>{})}),W$=$("$ZodCheckRegex",(n,e)=>{za.init(n,e),n._zod.check=t=>{e.pattern.lastIndex=0,!e.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:e.pattern.toString(),inst:n,continue:!e.abort})}}),q$=$("$ZodCheckLowerCase",(n,e)=>{e.pattern??(e.pattern=F$),za.init(n,e)}),Y$=$("$ZodCheckUpperCase",(n,e)=>{e.pattern??(e.pattern=Z$),za.init(n,e)}),K$=$("$ZodCheckIncludes",(n,e)=>{Be.init(n,e);const t=ei(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position}}${t}`:t);e.pattern=r,n._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),n._zod.check=i=>{i.value.includes(e.includes,e.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:i.value,inst:n,continue:!e.abort})}}),J$=$("$ZodCheckStartsWith",(n,e)=>{Be.init(n,e);const t=new RegExp(`^${ei(e.prefix)}.*`);e.pattern??(e.pattern=t),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._zod.check=r=>{r.value.startsWith(e.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:r.value,inst:n,continue:!e.abort})}}),X$=$("$ZodCheckEndsWith",(n,e)=>{Be.init(n,e);const t=new RegExp(`.*${ei(e.suffix)}$`);e.pattern??(e.pattern=t),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),n._zod.check=r=>{r.value.endsWith(e.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:r.value,inst:n,continue:!e.abort})}}),Q$=$("$ZodCheckOverwrite",(n,e)=>{Be.init(n,e),n._zod.check=t=>{t.value=e.tx(t.value)}});class eA{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const r=e.split(`
|
|
5
|
-
`).filter(o=>o),i=Math.min(...r.map(o=>o.length-o.trimStart().length)),s=r.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const e=Function,t=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new e(...t,i.join(`
|
|
6
|
-
`))}}const tA={major:4,minor:3,patch:6},he=$("$ZodType",(n,e)=>{var i;var t;n??(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=tA;const r=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&r.unshift(n);for(const s of r)for(const o of s._zod.onattach)o(n);if(r.length===0)(t=n._zod).deferred??(t.deferred=[]),(i=n._zod.deferred)==null||i.push(()=>{n._zod.run=n._zod.parse});else{const s=(a,l,u)=>{let d=Cr(a),f;for(const v of l){if(v._zod.def.when){if(!v._zod.def.when(a))continue}else if(d)continue;const y=a.issues.length,A=v._zod.check(a);if(A instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Rr;if(f||A instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await A,a.issues.length!==y&&(d||(d=Cr(a,y)))});else{if(a.issues.length===y)continue;d||(d=Cr(a,y))}}return f?f.then(()=>a):a},o=(a,l,u)=>{if(Cr(a))return a.aborted=!0,a;const d=s(l,r,u);if(d instanceof Promise){if(u.async===!1)throw new Rr;return d.then(f=>n._zod.parse(f,u))}return n._zod.parse(d,u)};n._zod.run=(a,l)=>{if(l.skipChecks)return n._zod.parse(a,l);if(l.direction==="backward"){const d=n._zod.parse({value:a.value,issues:[]},{...l,skipChecks:!0});return d instanceof Promise?d.then(f=>o(f,a,l)):o(d,a,l)}const u=n._zod.parse(a,l);if(u instanceof Promise){if(l.async===!1)throw new Rr;return u.then(d=>s(d,r,l))}return s(u,r,l)}}X(n,"~standard",()=>({validate:s=>{var o;try{const a=a$(n,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return l$(n,s).then(l=>{var u;return l.success?{value:l.data}:{issues:(u=l.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),Du=$("$ZodString",(n,e)=>{var t;he.init(n,e),n._zod.pattern=[...((t=n==null?void 0:n._zod.bag)==null?void 0:t.patterns)??[]].pop()??M$(n._zod.bag),n._zod.parse=(r,i)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:n}),r}}),ae=$("$ZodStringFormat",(n,e)=>{za.init(n,e),Du.init(n,e)}),nA=$("$ZodGUID",(n,e)=>{e.pattern??(e.pattern=E$),ae.init(n,e)}),rA=$("$ZodUUID",(n,e)=>{if(e.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(r===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=tf(r))}else e.pattern??(e.pattern=tf());ae.init(n,e)}),iA=$("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=$$),ae.init(n,e)}),sA=$("$ZodURL",(n,e)=>{ae.init(n,e),n._zod.check=t=>{try{const r=t.value.trim(),i=new URL(r);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(i.hostname)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:t.value,inst:n,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:t.value,inst:n,continue:!e.abort})),e.normalize?t.value=i.href:t.value=r;return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort})}}}),oA=$("$ZodEmoji",(n,e)=>{e.pattern??(e.pattern=x$()),ae.init(n,e)}),aA=$("$ZodNanoID",(n,e)=>{e.pattern??(e.pattern=S$),ae.init(n,e)}),lA=$("$ZodCUID",(n,e)=>{e.pattern??(e.pattern=y$),ae.init(n,e)}),cA=$("$ZodCUID2",(n,e)=>{e.pattern??(e.pattern=v$),ae.init(n,e)}),uA=$("$ZodULID",(n,e)=>{e.pattern??(e.pattern=b$),ae.init(n,e)}),hA=$("$ZodXID",(n,e)=>{e.pattern??(e.pattern=w$),ae.init(n,e)}),dA=$("$ZodKSUID",(n,e)=>{e.pattern??(e.pattern=_$),ae.init(n,e)}),fA=$("$ZodISODateTime",(n,e)=>{e.pattern??(e.pattern=L$(e)),ae.init(n,e)}),pA=$("$ZodISODate",(n,e)=>{e.pattern??(e.pattern=O$),ae.init(n,e)}),gA=$("$ZodISOTime",(n,e)=>{e.pattern??(e.pattern=z$(e)),ae.init(n,e)}),mA=$("$ZodISODuration",(n,e)=>{e.pattern??(e.pattern=k$),ae.init(n,e)}),yA=$("$ZodIPv4",(n,e)=>{e.pattern??(e.pattern=T$),ae.init(n,e),n._zod.bag.format="ipv4"}),vA=$("$ZodIPv6",(n,e)=>{e.pattern??(e.pattern=C$),ae.init(n,e),n._zod.bag.format="ipv6",n._zod.check=t=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:n,continue:!e.abort})}}}),bA=$("$ZodCIDRv4",(n,e)=>{e.pattern??(e.pattern=I$),ae.init(n,e)}),wA=$("$ZodCIDRv6",(n,e)=>{e.pattern??(e.pattern=P$),ae.init(n,e),n._zod.check=t=>{const r=t.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:n,continue:!e.abort})}}});function qg(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}const _A=$("$ZodBase64",(n,e)=>{e.pattern??(e.pattern=R$),ae.init(n,e),n._zod.bag.contentEncoding="base64",n._zod.check=t=>{qg(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:n,continue:!e.abort})}});function SA(n){if(!Zg.test(n))return!1;const e=n.replace(/[-_]/g,r=>r==="-"?"+":"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return qg(t)}const kA=$("$ZodBase64URL",(n,e)=>{e.pattern??(e.pattern=Zg),ae.init(n,e),n._zod.bag.contentEncoding="base64url",n._zod.check=t=>{SA(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:n,continue:!e.abort})}}),EA=$("$ZodE164",(n,e)=>{e.pattern??(e.pattern=D$),ae.init(n,e)});function $A(n,e=null){try{const t=n.split(".");if(t.length!==3)return!1;const[r]=t;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&(!("alg"in i)||i.alg!==e))}catch{return!1}}const AA=$("$ZodJWT",(n,e)=>{ae.init(n,e),n._zod.check=t=>{$A(t.value,e.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:n,continue:!e.abort})}}),Yg=$("$ZodNumber",(n,e)=>{he.init(n,e),n._zod.pattern=n._zod.bag.pattern??jg,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=Number(t.value)}catch{}const i=t.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return t;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return t.issues.push({expected:"number",code:"invalid_type",input:i,inst:n,...s?{received:s}:{}}),t}}),xA=$("$ZodNumberFormat",(n,e)=>{V$.init(n,e),Yg.init(n,e)}),TA=$("$ZodBoolean",(n,e)=>{he.init(n,e),n._zod.pattern=U$,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=!!t.value}catch{}const i=t.value;return typeof i=="boolean"||t.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:n}),t}}),CA=$("$ZodUnknown",(n,e)=>{he.init(n,e),n._zod.parse=t=>t}),IA=$("$ZodNever",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:n}),t)});function nf(n,e,t){n.issues.length&&e.issues.push(...Ir(t,n.issues)),e.value[t]=n.value}const PA=$("$ZodArray",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>{const i=t.value;if(!Array.isArray(i))return t.issues.push({expected:"array",code:"invalid_type",input:i,inst:n}),t;t.value=Array(i.length);const s=[];for(let o=0;o<i.length;o++){const a=i[o],l=e.element._zod.run({value:a,issues:[]},r);l instanceof Promise?s.push(l.then(u=>nf(u,t,o))):nf(l,t,o)}return s.length?Promise.all(s).then(()=>t):t}});function Jo(n,e,t,r,i){if(n.issues.length){if(i&&!(t in r))return;e.issues.push(...Ir(t,n.issues))}n.value===void 0?t in r&&(e.value[t]=void 0):e.value[t]=n.value}function Kg(n){var r,i,s,o;const e=Object.keys(n.shape);for(const a of e)if(!((o=(s=(i=(r=n.shape)==null?void 0:r[a])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const t=K0(n.shape);return{...n,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(t)}}function Jg(n,e,t,r,i,s){const o=[],a=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optout==="optional";for(const f in e){if(a.has(f))continue;if(u==="never"){o.push(f);continue}const v=l.run({value:e[f],issues:[]},r);v instanceof Promise?n.push(v.then(y=>Jo(y,t,f,e,d))):Jo(v,t,f,e,d)}return o.length&&t.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:s}),n.length?Promise.all(n).then(()=>t):t}const RA=$("$ZodObject",(n,e)=>{he.init(n,e);const t=Object.getOwnPropertyDescriptor(e,"shape");if(!(t!=null&&t.get)){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const l={...a};return Object.defineProperty(e,"shape",{value:l}),l}})}const r=xu(()=>Kg(e));X(n._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 f of d.values)l[u].add(f)}}return l});const i=Ko,s=e.catchall;let o;n._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:n}),a;a.value={};const d=[],f=o.shape;for(const v of o.keys){const y=f[v],A=y._zod.optout==="optional",k=y._zod.run({value:u[v],issues:[]},l);k instanceof Promise?d.push(k.then(I=>Jo(I,a,v,u,A))):Jo(k,a,v,u,A)}return s?Jg(d,u,a,l,r.value,n):d.length?Promise.all(d).then(()=>a):a}}),DA=$("$ZodObjectJIT",(n,e)=>{RA.init(n,e);const t=n._zod.parse,r=xu(()=>Kg(e)),i=v=>{var le;const y=new eA(["shape","payload","ctx"]),A=r.value,k=M=>{const Z=ef(M);return`shape[${Z}]._zod.run({ value: input[${Z}], issues: [] }, ctx)`};y.write("const input = payload.value;");const I=Object.create(null);let G=0;for(const M of A.keys)I[M]=`key_${G++}`;y.write("const newResult = {};");for(const M of A.keys){const Z=I[M],U=ef(M),ge=v[M],ce=((le=ge==null?void 0:ge._zod)==null?void 0:le.optout)==="optional";y.write(`const ${Z} = ${k(M)};`),ce?y.write(`
|
|
7
|
-
if (${Z}.issues.length) {
|
|
8
|
-
if (${U} in input) {
|
|
9
|
-
payload.issues = payload.issues.concat(${Z}.issues.map(iss => ({
|
|
10
|
-
...iss,
|
|
11
|
-
path: iss.path ? [${U}, ...iss.path] : [${U}]
|
|
12
|
-
})));
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (${Z}.value === undefined) {
|
|
17
|
-
if (${U} in input) {
|
|
18
|
-
newResult[${U}] = undefined;
|
|
19
|
-
}
|
|
20
|
-
} else {
|
|
21
|
-
newResult[${U}] = ${Z}.value;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
`):y.write(`
|
|
25
|
-
if (${Z}.issues.length) {
|
|
26
|
-
payload.issues = payload.issues.concat(${Z}.issues.map(iss => ({
|
|
27
|
-
...iss,
|
|
28
|
-
path: iss.path ? [${U}, ...iss.path] : [${U}]
|
|
29
|
-
})));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (${Z}.value === undefined) {
|
|
33
|
-
if (${U} in input) {
|
|
34
|
-
newResult[${U}] = undefined;
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
newResult[${U}] = ${Z}.value;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
`)}y.write("payload.value = newResult;"),y.write("return payload;");const P=y.compile();return(M,Z)=>P(v,M,Z)};let s;const o=Ko,a=!Og.jitless,u=a&&q0.value,d=e.catchall;let f;n._zod.parse=(v,y)=>{f??(f=r.value);const A=v.value;return o(A)?a&&u&&(y==null?void 0:y.async)===!1&&y.jitless!==!0?(s||(s=i(e.shape)),v=s(v,y),d?Jg([],A,v,y,f,n):v):t(v,y):(v.issues.push({expected:"object",code:"invalid_type",input:A,inst:n}),v)}});function rf(n,e,t,r){for(const s of n)if(s.issues.length===0)return e.value=s.value,e;const i=n.filter(s=>!Cr(s));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:n.map(s=>s.issues.map(o=>gn(o,r,pn())))}),e)}const OA=$("$ZodUnion",(n,e)=>{he.init(n,e),X(n._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),X(n._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),X(n._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),X(n._zod,"pattern",()=>{if(e.options.every(i=>i._zod.pattern)){const i=e.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>Cu(s.source)).join("|")})$`)}});const t=e.options.length===1,r=e.options[0]._zod.run;n._zod.parse=(i,s)=>{if(t)return r(i,s);let o=!1;const a=[];for(const 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=>rf(l,i,n,s)):rf(a,i,n,s)}}),zA=$("$ZodIntersection",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>{const i=t.value,s=e.left._zod.run({value:i,issues:[]},r),o=e.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([l,u])=>sf(t,l,u)):sf(t,s,o)}});function fc(n,e){if(n===e)return{valid:!0,data:n};if(n instanceof Date&&e instanceof Date&&+n==+e)return{valid:!0,data:n};if(Qr(n)&&Qr(e)){const t=Object.keys(e),r=Object.keys(n).filter(s=>t.indexOf(s)!==-1),i={...n,...e};for(const s of r){const o=fc(n[s],e[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let r=0;r<n.length;r++){const i=n[r],s=e[r],o=fc(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};t.push(o.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function sf(n,e,t){const r=new Map;let i;for(const a of e.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else n.issues.push(a);for(const a of t.issues)if(a.code==="unrecognized_keys")for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else n.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&n.issues.push({...i,keys:s}),Cr(n))return n;const o=fc(e.value,t.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return n.value=o.data,n}const LA=$("$ZodRecord",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>{const i=t.value;if(!Qr(i))return t.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),t;const s=[],o=e.keyType._zod.values;if(o){t.value={};const a=new Set;for(const u of o)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const d=e.valueType._zod.run({value:i[u],issues:[]},r);d instanceof Promise?s.push(d.then(f=>{f.issues.length&&t.issues.push(...Ir(u,f.issues)),t.value[u]=f.value})):(d.issues.length&&t.issues.push(...Ir(u,d.issues)),t.value[u]=d.value)}let l;for(const u in i)a.has(u)||(l=l??[],l.push(u));l&&l.length>0&&t.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:l})}else{t.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"&&jg.test(a)&&l.issues.length){const f=e.keyType._zod.run({value:Number(a),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(l=f)}if(l.issues.length){e.mode==="loose"?t.value[a]=i[a]:t.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(f=>gn(f,r,pn())),input:a,path:[a],inst:n});continue}const d=e.valueType._zod.run({value:i[a],issues:[]},r);d instanceof Promise?s.push(d.then(f=>{f.issues.length&&t.issues.push(...Ir(a,f.issues)),t.value[l.value]=f.value})):(d.issues.length&&t.issues.push(...Ir(a,d.issues)),t.value[l.value]=d.value)}}return s.length?Promise.all(s).then(()=>t):t}}),MA=$("$ZodEnum",(n,e)=>{he.init(n,e);const t=zg(e.entries),r=new Set(t);n._zod.values=r,n._zod.pattern=new RegExp(`^(${t.filter(i=>Y0.has(typeof i)).map(i=>typeof i=="string"?ei(i):i.toString()).join("|")})$`),n._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:t,input:o,inst:n}),i}}),NA=$("$ZodLiteral",(n,e)=>{if(he.init(n,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const t=new Set(e.values);n._zod.values=t,n._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?ei(r):r?ei(r.toString()):String(r)).join("|")})$`),n._zod.parse=(r,i)=>{const s=r.value;return t.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:n}),r}}),UA=$("$ZodTransform",(n,e)=>{he.init(n,e),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new Dg(n.constructor.name);const i=e.transform(t.value,t);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(t.value=o,t));if(i instanceof Promise)throw new Rr;return t.value=i,t}});function of(n,e){return n.issues.length&&e===void 0?{issues:[],value:void 0}:n}const Xg=$("$ZodOptional",(n,e)=>{he.init(n,e),n._zod.optin="optional",n._zod.optout="optional",X(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),X(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${Cu(t.source)})?$`):void 0}),n._zod.parse=(t,r)=>{if(e.innerType._zod.optin==="optional"){const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>of(s,t.value)):of(i,t.value)}return t.value===void 0?t:e.innerType._zod.run(t,r)}}),FA=$("$ZodExactOptional",(n,e)=>{Xg.init(n,e),X(n._zod,"values",()=>e.innerType._zod.values),X(n._zod,"pattern",()=>e.innerType._zod.pattern),n._zod.parse=(t,r)=>e.innerType._zod.run(t,r)}),ZA=$("$ZodNullable",(n,e)=>{he.init(n,e),X(n._zod,"optin",()=>e.innerType._zod.optin),X(n._zod,"optout",()=>e.innerType._zod.optout),X(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${Cu(t.source)}|null)$`):void 0}),X(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),n._zod.parse=(t,r)=>t.value===null?t:e.innerType._zod.run(t,r)}),HA=$("$ZodDefault",(n,e)=>{he.init(n,e),n._zod.optin="optional",X(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);if(t.value===void 0)return t.value=e.defaultValue,t;const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>af(s,e)):af(i,e)}});function af(n,e){return n.value===void 0&&(n.value=e.defaultValue),n}const VA=$("$ZodPrefault",(n,e)=>{he.init(n,e),n._zod.optin="optional",X(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>(r.direction==="backward"||t.value===void 0&&(t.value=e.defaultValue),e.innerType._zod.run(t,r))}),jA=$("$ZodNonOptional",(n,e)=>{he.init(n,e),X(n._zod,"values",()=>{const t=e.innerType._zod.values;return t?new Set([...t].filter(r=>r!==void 0)):void 0}),n._zod.parse=(t,r)=>{const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>lf(s,n)):lf(i,n)}});function lf(n,e){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:e}),n}const GA=$("$ZodCatch",(n,e)=>{he.init(n,e),X(n._zod,"optin",()=>e.innerType._zod.optin),X(n._zod,"optout",()=>e.innerType._zod.optout),X(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(s=>(t.value=s.value,s.issues.length&&(t.value=e.catchValue({...t,error:{issues:s.issues.map(o=>gn(o,r,pn()))},input:t.value}),t.issues=[]),t)):(t.value=i.value,i.issues.length&&(t.value=e.catchValue({...t,error:{issues:i.issues.map(s=>gn(s,r,pn()))},input:t.value}),t.issues=[]),t)}}),BA=$("$ZodPipe",(n,e)=>{he.init(n,e),X(n._zod,"values",()=>e.in._zod.values),X(n._zod,"optin",()=>e.in._zod.optin),X(n._zod,"optout",()=>e.out._zod.optout),X(n._zod,"propValues",()=>e.in._zod.propValues),n._zod.parse=(t,r)=>{if(r.direction==="backward"){const s=e.out._zod.run(t,r);return s instanceof Promise?s.then(o=>yo(o,e.in,r)):yo(s,e.in,r)}const i=e.in._zod.run(t,r);return i instanceof Promise?i.then(s=>yo(s,e.out,r)):yo(i,e.out,r)}});function yo(n,e,t){return n.issues.length?(n.aborted=!0,n):e._zod.run({value:n.value,issues:n.issues},t)}const WA=$("$ZodReadonly",(n,e)=>{he.init(n,e),X(n._zod,"propValues",()=>e.innerType._zod.propValues),X(n._zod,"values",()=>e.innerType._zod.values),X(n._zod,"optin",()=>{var t,r;return(r=(t=e.innerType)==null?void 0:t._zod)==null?void 0:r.optin}),X(n._zod,"optout",()=>{var t,r;return(r=(t=e.innerType)==null?void 0:t._zod)==null?void 0:r.optout}),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(cf):cf(i)}});function cf(n){return n.value=Object.freeze(n.value),n}const qA=$("$ZodCustom",(n,e)=>{Be.init(n,e),he.init(n,e),n._zod.parse=(t,r)=>t,n._zod.check=t=>{const r=t.value,i=e.fn(r);if(i instanceof Promise)return i.then(s=>uf(s,t,r,n));uf(i,t,r,n)}});function uf(n,e,t,r){if(!n){const i={code:"custom",input:t,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),e.issues.push(Ji(i))}}var hf;class YA{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const r=t[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};delete r.id;const i={...r,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function KA(){return new YA}(hf=globalThis).__zod_globalRegistry??(hf.__zod_globalRegistry=KA());const zi=globalThis.__zod_globalRegistry;function JA(n,e){return new n({type:"string",...O(e)})}function XA(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...O(e)})}function df(n,e){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...O(e)})}function QA(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...O(e)})}function ex(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(e)})}function tx(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(e)})}function nx(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(e)})}function rx(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...O(e)})}function ix(n,e){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...O(e)})}function sx(n,e){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(e)})}function ox(n,e){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...O(e)})}function ax(n,e){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(e)})}function lx(n,e){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...O(e)})}function cx(n,e){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...O(e)})}function ux(n,e){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(e)})}function hx(n,e){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(e)})}function dx(n,e){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(e)})}function fx(n,e){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(e)})}function px(n,e){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(e)})}function gx(n,e){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...O(e)})}function mx(n,e){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...O(e)})}function yx(n,e){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...O(e)})}function vx(n,e){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...O(e)})}function bx(n,e){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(e)})}function wx(n,e){return new n({type:"string",format:"date",check:"string_format",...O(e)})}function _x(n,e){return new n({type:"string",format:"time",check:"string_format",precision:null,...O(e)})}function Sx(n,e){return new n({type:"string",format:"duration",check:"string_format",...O(e)})}function kx(n,e){return new n({type:"number",checks:[],...O(e)})}function Ex(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...O(e)})}function $x(n,e){return new n({type:"boolean",...O(e)})}function Ax(n){return new n({type:"unknown"})}function xx(n,e){return new n({type:"never",...O(e)})}function ff(n,e){return new Bg({check:"less_than",...O(e),value:n,inclusive:!1})}function Dl(n,e){return new Bg({check:"less_than",...O(e),value:n,inclusive:!0})}function pf(n,e){return new Wg({check:"greater_than",...O(e),value:n,inclusive:!1})}function Ol(n,e){return new Wg({check:"greater_than",...O(e),value:n,inclusive:!0})}function gf(n,e){return new H$({check:"multiple_of",...O(e),value:n})}function Qg(n,e){return new j$({check:"max_length",...O(e),maximum:n})}function Xo(n,e){return new G$({check:"min_length",...O(e),minimum:n})}function em(n,e){return new B$({check:"length_equals",...O(e),length:n})}function Tx(n,e){return new W$({check:"string_format",format:"regex",...O(e),pattern:n})}function Cx(n){return new q$({check:"string_format",format:"lowercase",...O(n)})}function Ix(n){return new Y$({check:"string_format",format:"uppercase",...O(n)})}function Px(n,e){return new K$({check:"string_format",format:"includes",...O(e),includes:n})}function Rx(n,e){return new J$({check:"string_format",format:"starts_with",...O(e),prefix:n})}function Dx(n,e){return new X$({check:"string_format",format:"ends_with",...O(e),suffix:n})}function fi(n){return new Q$({check:"overwrite",tx:n})}function Ox(n){return fi(e=>e.normalize(n))}function zx(){return fi(n=>n.trim())}function Lx(){return fi(n=>n.toLowerCase())}function Mx(){return fi(n=>n.toUpperCase())}function Nx(){return fi(n=>W0(n))}function Ux(n,e,t){return new n({type:"array",element:e,...O(t)})}function Fx(n,e,t){return new n({type:"custom",check:"custom",fn:e,...O(t)})}function Zx(n){const e=Hx(t=>(t.addIssue=r=>{if(typeof r=="string")t.issues.push(Ji(r,t.value,e._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=t.value),i.inst??(i.inst=e),i.continue??(i.continue=!e._zod.def.abort),t.issues.push(Ji(i))}},n(t.value,t)));return e}function Hx(n,e){const t=new Be({check:"custom",...O(e)});return t._zod.check=n,t}function tm(n){let e=(n==null?void 0:n.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:n.processors??{},metadataRegistry:(n==null?void 0:n.metadata)??zi,target:e,unrepresentable:(n==null?void 0:n.unrepresentable)??"throw",override:(n==null?void 0:n.override)??(()=>{}),io:(n==null?void 0:n.io)??"output",counter:0,seen:new Map,cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",external:(n==null?void 0:n.external)??void 0}}function ve(n,e,t={path:[],schemaPath:[]}){var d,f;var r;const i=n._zod.def,s=e.seen.get(n);if(s)return s.count++,t.schemaPath.includes(n)&&(s.cycle=t.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:t.path};e.seen.set(n,o);const a=(f=(d=n._zod).toJSONSchema)==null?void 0:f.call(d);if(a)o.schema=a;else{const v={...t,schemaPath:[...t.schemaPath,n],path:t.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(e,o.schema,v);else{const A=o.schema,k=e.processors[i.type];if(!k)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);k(n,e,A,v)}const y=n._zod.parent;y&&(o.ref||(o.ref=y),ve(y,e,v),e.seen.get(y).isParent=!0)}const l=e.metadataRegistry.get(n);return l&&Object.assign(o.schema,l),e.io==="input"&&Oe(n)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(n).schema}function nm(n,e){var o,a,l,u;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const d of n.seen.entries()){const f=(o=n.metadataRegistry.get(d[0]))==null?void 0:o.id;if(f){const v=r.get(f);if(v&&v!==d[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(f,d[0])}}const i=d=>{var k;const f=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const I=(k=n.external.registry.get(d[0]))==null?void 0:k.id,G=n.external.uri??(le=>le);if(I)return{ref:G(I)};const P=d[1].defId??d[1].schema.id??`schema${n.counter++}`;return d[1].defId=P,{defId:P,ref:`${G("__shared")}#/${f}/${P}`}}if(d[1]===t)return{ref:"#"};const y=`#/${f}/`,A=d[1].schema.id??`__schema${n.counter++}`;return{defId:A,ref:y+A}},s=d=>{if(d[1].schema.$ref)return;const f=d[1],{ref:v,defId:y}=i(d);f.def={...f.schema},y&&(f.defId=y);const A=f.schema;for(const k in A)delete A[k];A.$ref=v};if(n.cycles==="throw")for(const d of n.seen.entries()){const f=d[1];if(f.cycle)throw new Error(`Cycle detected: #/${(a=f.cycle)==null?void 0:a.join("/")}/<root>
|
|
41
|
-
|
|
42
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of n.seen.entries()){const f=d[1];if(e===d[0]){s(d);continue}if(n.external){const y=(l=n.external.registry.get(d[0]))==null?void 0:l.id;if(e!==d[0]&&y){s(d);continue}}if((u=n.metadataRegistry.get(d[0]))==null?void 0:u.id){s(d);continue}if(f.cycle){s(d);continue}if(f.count>1&&n.reused==="ref"){s(d);continue}}}function rm(n,e){var o,a,l;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const d=n.seen.get(u);if(d.ref===null)return;const f=d.def??d.schema,v={...f},y=d.ref;if(d.ref=null,y){r(y);const k=n.seen.get(y),I=k.schema;if(I.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(I)):Object.assign(f,I),Object.assign(f,v),u._zod.parent===y)for(const P in f)P==="$ref"||P==="allOf"||P in v||delete f[P];if(I.$ref&&k.def)for(const P in f)P==="$ref"||P==="allOf"||P in k.def&&JSON.stringify(f[P])===JSON.stringify(k.def[P])&&delete f[P]}const A=u._zod.parent;if(A&&A!==y){r(A);const k=n.seen.get(A);if(k!=null&&k.schema.$ref&&(f.$ref=k.schema.$ref,k.def))for(const I in f)I==="$ref"||I==="allOf"||I in k.def&&JSON.stringify(f[I])===JSON.stringify(k.def[I])&&delete f[I]}n.override({zodSchema:u,jsonSchema:f,path:d.path??[]})};for(const u of[...n.seen.entries()].reverse())r(u[0]);const i={};if(n.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":n.target,(o=n.external)!=null&&o.uri){const u=(a=n.external.registry.get(e))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=n.external.uri(u)}Object.assign(i,t.def??t.schema);const s=((l=n.external)==null?void 0:l.defs)??{};for(const u of n.seen.entries()){const d=u[1];d.def&&d.defId&&(s[d.defId]=d.def)}n.external||Object.keys(s).length>0&&(n.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...e["~standard"],jsonSchema:{input:Qo(e,"input",n.processors),output:Qo(e,"output",n.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Oe(n,e){const t=e??{seen:new Set};if(t.seen.has(n))return!1;t.seen.add(n);const r=n._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Oe(r.element,t);if(r.type==="set")return Oe(r.valueType,t);if(r.type==="lazy")return Oe(r.getter(),t);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Oe(r.innerType,t);if(r.type==="intersection")return Oe(r.left,t)||Oe(r.right,t);if(r.type==="record"||r.type==="map")return Oe(r.keyType,t)||Oe(r.valueType,t);if(r.type==="pipe")return Oe(r.in,t)||Oe(r.out,t);if(r.type==="object"){for(const i in r.shape)if(Oe(r.shape[i],t))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(Oe(i,t))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(Oe(i,t))return!0;return!!(r.rest&&Oe(r.rest,t))}return!1}const Vx=(n,e={})=>t=>{const r=tm({...t,processors:e});return ve(n,r),nm(r,n),rm(r,n)},Qo=(n,e,t={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=tm({...i??{},target:s,io:e,processors:t});return ve(n,o),nm(o,n),rm(o,n)},jx={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Gx=(n,e,t,r)=>{const i=t;i.type="string";const{minimum:s,maximum:o,format:a,patterns:l,contentEncoding:u}=n._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=jx[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(f=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Bx=(n,e,t,r)=>{const i=t,{minimum:s,maximum:o,format:a,multipleOf:l,exclusiveMaximum:u,exclusiveMinimum:d}=n._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof d=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.minimum=d,i.exclusiveMinimum=!0):i.exclusiveMinimum=d),typeof s=="number"&&(i.minimum=s,typeof d=="number"&&e.target!=="draft-04"&&(d>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof o=="number"&&(i.maximum=o,typeof u=="number"&&e.target!=="draft-04"&&(u<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof l=="number"&&(i.multipleOf=l)},Wx=(n,e,t,r)=>{t.type="boolean"},qx=(n,e,t,r)=>{t.not={}},Yx=(n,e,t,r)=>{},Kx=(n,e,t,r)=>{const i=n._zod.def,s=zg(i.entries);s.every(o=>typeof o=="number")&&(t.type="number"),s.every(o=>typeof o=="string")&&(t.type="string"),t.enum=s},Jx=(n,e,t,r)=>{const i=n._zod.def,s=[];for(const o of i.values)if(o===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];t.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?t.enum=[o]:t.const=o}else s.every(o=>typeof o=="number")&&(t.type="number"),s.every(o=>typeof o=="string")&&(t.type="string"),s.every(o=>typeof o=="boolean")&&(t.type="boolean"),s.every(o=>o===null)&&(t.type="null"),t.enum=s},Xx=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Qx=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},eT=(n,e,t,r)=>{const i=t,s=n._zod.def,{minimum:o,maximum:a}=n._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=ve(s.element,e,{...r,path:[...r.path,"items"]})},tT=(n,e,t,r)=>{var u;const i=t,s=n._zod.def;i.type="object",i.properties={};const o=s.shape;for(const d in o)i.properties[d]=ve(o[d],e,{...r,path:[...r.path,"properties",d]});const a=new Set(Object.keys(o)),l=new Set([...a].filter(d=>{const f=s.shape[d]._zod;return e.io==="input"?f.optin===void 0:f.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=ve(s.catchall,e,{...r,path:[...r.path,"additionalProperties"]})):e.io==="output"&&(i.additionalProperties=!1)},nT=(n,e,t,r)=>{const i=n._zod.def,s=i.inclusive===!1,o=i.options.map((a,l)=>ve(a,e,{...r,path:[...r.path,s?"oneOf":"anyOf",l]}));s?t.oneOf=o:t.anyOf=o},rT=(n,e,t,r)=>{const i=n._zod.def,s=ve(i.left,e,{...r,path:[...r.path,"allOf",0]}),o=ve(i.right,e,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,l=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];t.allOf=l},iT=(n,e,t,r)=>{const i=t,s=n._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=ve(s.valueType,e,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const f of l)i.patternProperties[f.source]=d}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(i.propertyNames=ve(s.keyType,e,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=ve(s.valueType,e,{...r,path:[...r.path,"additionalProperties"]});const u=o._zod.values;if(u){const d=[...u].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(i.required=d)}},sT=(n,e,t,r)=>{const i=n._zod.def,s=ve(i.innerType,e,r),o=e.seen.get(n);e.target==="openapi-3.0"?(o.ref=i.innerType,t.nullable=!0):t.anyOf=[s,{type:"null"}]},oT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType},aT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,t.default=JSON.parse(JSON.stringify(i.defaultValue))},lT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,e.io==="input"&&(t._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},cT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}t.default=o},uT=(n,e,t,r)=>{const i=n._zod.def,s=e.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;ve(s,e,r);const o=e.seen.get(n);o.ref=s},hT=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType,t.readOnly=!0},im=(n,e,t,r)=>{const i=n._zod.def;ve(i.innerType,e,r);const s=e.seen.get(n);s.ref=i.innerType},dT=$("ZodISODateTime",(n,e)=>{fA.init(n,e),fe.init(n,e)});function fT(n){return bx(dT,n)}const pT=$("ZodISODate",(n,e)=>{pA.init(n,e),fe.init(n,e)});function gT(n){return wx(pT,n)}const mT=$("ZodISOTime",(n,e)=>{gA.init(n,e),fe.init(n,e)});function yT(n){return _x(mT,n)}const vT=$("ZodISODuration",(n,e)=>{mA.init(n,e),fe.init(n,e)});function bT(n){return Sx(vT,n)}const sm=(n,e)=>{Ug.init(n,e),n.name="ZodError",Object.defineProperties(n,{format:{value:t=>o$(n,t)},flatten:{value:t=>s$(n,t)},addIssue:{value:t=>{n.issues.push(t),n.message=JSON.stringify(n.issues,dc,2)}},addIssues:{value:t=>{n.issues.push(...t),n.message=JSON.stringify(n.issues,dc,2)}},isEmpty:{get(){return n.issues.length===0}}})},mf=$("ZodError",sm),ot=$("ZodError",sm,{Parent:Error}),wT=Pu(ot),_T=Ru(ot),ST=Da(ot),kT=Oa(ot),ET=c$(ot),$T=u$(ot),AT=h$(ot),xT=d$(ot),TT=f$(ot),CT=p$(ot),IT=g$(ot),PT=m$(ot),de=$("ZodType",(n,e)=>(he.init(n,e),Object.assign(n["~standard"],{jsonSchema:{input:Qo(n,"input"),output:Qo(n,"output")}}),n.toJSONSchema=Vx(n,{}),n.def=e,n.type=e.type,Object.defineProperty(n,"_def",{value:e}),n.check=(...t)=>n.clone(_n(e,{checks:[...e.checks??[],...t.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),n.with=n.check,n.clone=(t,r)=>Sn(n,t,r),n.brand=()=>n,n.register=(t,r)=>(t.add(n,r),n),n.parse=(t,r)=>wT(n,t,r,{callee:n.parse}),n.safeParse=(t,r)=>ST(n,t,r),n.parseAsync=async(t,r)=>_T(n,t,r,{callee:n.parseAsync}),n.safeParseAsync=async(t,r)=>kT(n,t,r),n.spa=n.safeParseAsync,n.encode=(t,r)=>ET(n,t,r),n.decode=(t,r)=>$T(n,t,r),n.encodeAsync=async(t,r)=>AT(n,t,r),n.decodeAsync=async(t,r)=>xT(n,t,r),n.safeEncode=(t,r)=>TT(n,t,r),n.safeDecode=(t,r)=>CT(n,t,r),n.safeEncodeAsync=async(t,r)=>IT(n,t,r),n.safeDecodeAsync=async(t,r)=>PT(n,t,r),n.refine=(t,r)=>n.check(SC(t,r)),n.superRefine=t=>n.check(kC(t)),n.overwrite=t=>n.check(fi(t)),n.optional=()=>bf(n),n.exactOptional=()=>cC(n),n.nullable=()=>wf(n),n.nullish=()=>bf(wf(n)),n.nonoptional=t=>gC(n,t),n.array=()=>D(n),n.or=t=>H([n,t]),n.and=t=>La(n,t),n.transform=t=>_f(n,aC(t)),n.default=t=>dC(n,t),n.prefault=t=>pC(n,t),n.catch=t=>yC(n,t),n.pipe=t=>_f(n,t),n.readonly=()=>wC(n),n.describe=t=>{const r=n.clone();return zi.add(r,{description:t}),r},Object.defineProperty(n,"description",{get(){var t;return(t=zi.get(n))==null?void 0:t.description},configurable:!0}),n.meta=(...t)=>{if(t.length===0)return zi.get(n);const r=n.clone();return zi.add(r,t[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=t=>t(n),n)),om=$("_ZodString",(n,e)=>{Du.init(n,e),de.init(n,e),n._zod.processJSONSchema=(r,i,s)=>Gx(n,r,i);const t=n._zod.bag;n.format=t.format??null,n.minLength=t.minimum??null,n.maxLength=t.maximum??null,n.regex=(...r)=>n.check(Tx(...r)),n.includes=(...r)=>n.check(Px(...r)),n.startsWith=(...r)=>n.check(Rx(...r)),n.endsWith=(...r)=>n.check(Dx(...r)),n.min=(...r)=>n.check(Xo(...r)),n.max=(...r)=>n.check(Qg(...r)),n.length=(...r)=>n.check(em(...r)),n.nonempty=(...r)=>n.check(Xo(1,...r)),n.lowercase=r=>n.check(Cx(r)),n.uppercase=r=>n.check(Ix(r)),n.trim=()=>n.check(zx()),n.normalize=(...r)=>n.check(Ox(...r)),n.toLowerCase=()=>n.check(Lx()),n.toUpperCase=()=>n.check(Mx()),n.slugify=()=>n.check(Nx())}),RT=$("ZodString",(n,e)=>{Du.init(n,e),om.init(n,e),n.email=t=>n.check(XA(DT,t)),n.url=t=>n.check(rx(OT,t)),n.jwt=t=>n.check(vx(YT,t)),n.emoji=t=>n.check(ix(zT,t)),n.guid=t=>n.check(df(yf,t)),n.uuid=t=>n.check(QA(vo,t)),n.uuidv4=t=>n.check(ex(vo,t)),n.uuidv6=t=>n.check(tx(vo,t)),n.uuidv7=t=>n.check(nx(vo,t)),n.nanoid=t=>n.check(sx(LT,t)),n.guid=t=>n.check(df(yf,t)),n.cuid=t=>n.check(ox(MT,t)),n.cuid2=t=>n.check(ax(NT,t)),n.ulid=t=>n.check(lx(UT,t)),n.base64=t=>n.check(gx(BT,t)),n.base64url=t=>n.check(mx(WT,t)),n.xid=t=>n.check(cx(FT,t)),n.ksuid=t=>n.check(ux(ZT,t)),n.ipv4=t=>n.check(hx(HT,t)),n.ipv6=t=>n.check(dx(VT,t)),n.cidrv4=t=>n.check(fx(jT,t)),n.cidrv6=t=>n.check(px(GT,t)),n.e164=t=>n.check(yx(qT,t)),n.datetime=t=>n.check(fT(t)),n.date=t=>n.check(gT(t)),n.time=t=>n.check(yT(t)),n.duration=t=>n.check(bT(t))});function h(n){return JA(RT,n)}const fe=$("ZodStringFormat",(n,e)=>{ae.init(n,e),om.init(n,e)}),DT=$("ZodEmail",(n,e)=>{iA.init(n,e),fe.init(n,e)}),yf=$("ZodGUID",(n,e)=>{nA.init(n,e),fe.init(n,e)}),vo=$("ZodUUID",(n,e)=>{rA.init(n,e),fe.init(n,e)}),OT=$("ZodURL",(n,e)=>{sA.init(n,e),fe.init(n,e)}),zT=$("ZodEmoji",(n,e)=>{oA.init(n,e),fe.init(n,e)}),LT=$("ZodNanoID",(n,e)=>{aA.init(n,e),fe.init(n,e)}),MT=$("ZodCUID",(n,e)=>{lA.init(n,e),fe.init(n,e)}),NT=$("ZodCUID2",(n,e)=>{cA.init(n,e),fe.init(n,e)}),UT=$("ZodULID",(n,e)=>{uA.init(n,e),fe.init(n,e)}),FT=$("ZodXID",(n,e)=>{hA.init(n,e),fe.init(n,e)}),ZT=$("ZodKSUID",(n,e)=>{dA.init(n,e),fe.init(n,e)}),HT=$("ZodIPv4",(n,e)=>{yA.init(n,e),fe.init(n,e)}),VT=$("ZodIPv6",(n,e)=>{vA.init(n,e),fe.init(n,e)}),jT=$("ZodCIDRv4",(n,e)=>{bA.init(n,e),fe.init(n,e)}),GT=$("ZodCIDRv6",(n,e)=>{wA.init(n,e),fe.init(n,e)}),BT=$("ZodBase64",(n,e)=>{_A.init(n,e),fe.init(n,e)}),WT=$("ZodBase64URL",(n,e)=>{kA.init(n,e),fe.init(n,e)}),qT=$("ZodE164",(n,e)=>{EA.init(n,e),fe.init(n,e)}),YT=$("ZodJWT",(n,e)=>{AA.init(n,e),fe.init(n,e)}),am=$("ZodNumber",(n,e)=>{Yg.init(n,e),de.init(n,e),n._zod.processJSONSchema=(r,i,s)=>Bx(n,r,i),n.gt=(r,i)=>n.check(pf(r,i)),n.gte=(r,i)=>n.check(Ol(r,i)),n.min=(r,i)=>n.check(Ol(r,i)),n.lt=(r,i)=>n.check(ff(r,i)),n.lte=(r,i)=>n.check(Dl(r,i)),n.max=(r,i)=>n.check(Dl(r,i)),n.int=r=>n.check(vf(r)),n.safe=r=>n.check(vf(r)),n.positive=r=>n.check(pf(0,r)),n.nonnegative=r=>n.check(Ol(0,r)),n.negative=r=>n.check(ff(0,r)),n.nonpositive=r=>n.check(Dl(0,r)),n.multipleOf=(r,i)=>n.check(gf(r,i)),n.step=(r,i)=>n.check(gf(r,i)),n.finite=()=>n;const t=n._zod.bag;n.minValue=Math.max(t.minimum??Number.NEGATIVE_INFINITY,t.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(t.maximum??Number.POSITIVE_INFINITY,t.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(t.format??"").includes("int")||Number.isSafeInteger(t.multipleOf??.5),n.isFinite=!0,n.format=t.format??null});function N(n){return kx(am,n)}const KT=$("ZodNumberFormat",(n,e)=>{xA.init(n,e),am.init(n,e)});function vf(n){return Ex(KT,n)}const JT=$("ZodBoolean",(n,e)=>{TA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Wx(n,t,r)});function Ee(n){return $x(JT,n)}const XT=$("ZodUnknown",(n,e)=>{CA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Yx()});function w(){return Ax(XT)}const QT=$("ZodNever",(n,e)=>{IA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>qx(n,t,r)});function eC(n){return xx(QT,n)}const tC=$("ZodArray",(n,e)=>{PA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>eT(n,t,r,i),n.element=e.element,n.min=(t,r)=>n.check(Xo(t,r)),n.nonempty=t=>n.check(Xo(1,t)),n.max=(t,r)=>n.check(Qg(t,r)),n.length=(t,r)=>n.check(em(t,r)),n.unwrap=()=>n.element});function D(n,e){return Ux(tC,n,e)}const lm=$("ZodObject",(n,e)=>{DA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>tT(n,t,r,i),X(n,"shape",()=>e.shape),n.keyof=()=>ea(Object.keys(n._zod.def.shape)),n.catchall=t=>n.clone({...n._zod.def,catchall:t}),n.passthrough=()=>n.clone({...n._zod.def,catchall:w()}),n.loose=()=>n.clone({...n._zod.def,catchall:w()}),n.strict=()=>n.clone({...n._zod.def,catchall:eC()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=t=>e$(n,t),n.safeExtend=t=>t$(n,t),n.merge=t=>n$(n,t),n.pick=t=>X0(n,t),n.omit=t=>Q0(n,t),n.partial=(...t)=>r$(um,n,t[0]),n.required=(...t)=>i$(hm,n,t[0])});function cm(n,e){const t={type:"object",shape:n??{},...O(e)};return new lm(t)}function p(n,e){return new lm({type:"object",shape:n,catchall:w(),...O(e)})}const nC=$("ZodUnion",(n,e)=>{OA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>nT(n,t,r,i),n.options=e.options});function H(n,e){return new nC({type:"union",options:n,...O(e)})}const rC=$("ZodIntersection",(n,e)=>{zA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>rT(n,t,r,i)});function La(n,e){return new rC({type:"intersection",left:n,right:e})}const iC=$("ZodRecord",(n,e)=>{LA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>iT(n,t,r,i),n.keyType=e.keyType,n.valueType=e.valueType});function _(n,e,t){return new iC({type:"record",keyType:n,valueType:e,...O(t)})}const pc=$("ZodEnum",(n,e)=>{MA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(r,i,s)=>Kx(n,r,i),n.enum=e.entries,n.options=Object.values(e.entries);const t=new Set(Object.keys(e.entries));n.extract=(r,i)=>{const s={};for(const o of r)if(t.has(o))s[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new pc({...e,checks:[],...O(i),entries:s})},n.exclude=(r,i)=>{const s={...e.entries};for(const o of r)if(t.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new pc({...e,checks:[],...O(i),entries:s})}});function ea(n,e){const t=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new pc({type:"enum",entries:t,...O(e)})}const sC=$("ZodLiteral",(n,e)=>{NA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Jx(n,t,r),n.values=new Set(e.values),Object.defineProperty(n,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function x(n,e){return new sC({type:"literal",values:Array.isArray(n)?n:[n],...O(e)})}const oC=$("ZodTransform",(n,e)=>{UA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Qx(n,t),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new Dg(n.constructor.name);t.addIssue=s=>{if(typeof s=="string")t.issues.push(Ji(s,t.value,e));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=t.value),o.inst??(o.inst=n),t.issues.push(Ji(o))}};const i=e.transform(t.value,t);return i instanceof Promise?i.then(s=>(t.value=s,t)):(t.value=i,t)}});function aC(n){return new oC({type:"transform",transform:n})}const um=$("ZodOptional",(n,e)=>{Xg.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>im(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function bf(n){return new um({type:"optional",innerType:n})}const lC=$("ZodExactOptional",(n,e)=>{FA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>im(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function cC(n){return new lC({type:"optional",innerType:n})}const uC=$("ZodNullable",(n,e)=>{ZA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>sT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function wf(n){return new uC({type:"nullable",innerType:n})}const hC=$("ZodDefault",(n,e)=>{HA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>aT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function dC(n,e){return new hC({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():Mg(e)}})}const fC=$("ZodPrefault",(n,e)=>{VA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>lT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function pC(n,e){return new fC({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():Mg(e)}})}const hm=$("ZodNonOptional",(n,e)=>{jA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>oT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function gC(n,e){return new hm({type:"nonoptional",innerType:n,...O(e)})}const mC=$("ZodCatch",(n,e)=>{GA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>cT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function yC(n,e){return new mC({type:"catch",innerType:n,catchValue:typeof e=="function"?e:()=>e})}const vC=$("ZodPipe",(n,e)=>{BA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>uT(n,t,r,i),n.in=e.in,n.out=e.out});function _f(n,e){return new vC({type:"pipe",in:n,out:e})}const bC=$("ZodReadonly",(n,e)=>{WA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>hT(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function wC(n){return new bC({type:"readonly",innerType:n})}const _C=$("ZodCustom",(n,e)=>{qA.init(n,e),de.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Xx(n,t)});function SC(n,e={}){return Fx(_C,n,e)}function kC(n){return Zx(n)}const EC=["text/markdown","text/html"],$C=["committed","pending"];cm({id:h().min(1),type:ea(EC),title:h(),status:ea($C),externalFilePath:h().optional()});cm({name:h().min(1),description:h(),accepts:D(h().min(1)).min(1)});function Ou(n){return typeof n=="object"&&n!==null}function AC(n){return!Ou(n)||n.type!=="ready"?!1:!("id"in n)}function xC(n){return!(!Ou(n)||n.type!=="update-content"||typeof n.id!="string"||typeof n.content!="string")}function TC(n){return!Ou(n)||n.type!=="wheel"||typeof n.deltaX!="number"||typeof n.deltaY!="number"||typeof n.shiftKey!="boolean"?!1:!("id"in n)}function CC(n,e){if(n===e)return 2;if(n==="*/*")return 0;const t=n.indexOf("/");if(t>0&&n.slice(t+1)==="*"){const r=n.slice(0,t),i=e.indexOf("/");if(i>0&&e.slice(0,i)===r)return 1}return null}function IC(n,e){let t=null;for(const r of n.accepts){const i=CC(r,e);i!==null&&(t===null||i>t)&&(t=i)}return t}function PC(n,e){let t=-1,r=null;for(const i of e){const s=IC(i,n);s!==null&&(s>t||s===t&&r!==null&&i.id<r.id)&&(t=s,r=i)}return r}const RC=4401;class gc extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class mc extends Tt{constructor(t){super();b(this,"url");b(this,"name");b(this,"token");b(this,"status","disconnected");b(this,"screens",new Map);b(this,"views",[]);b(this,"client");b(this,"createSocket");b(this,"createClient");b(this,"socket",null);b(this,"connectAttempt",0);this.url=Lt(t.url),this.name=t.name,this.token=t.token??null,this.createSocket=t.createSocket??(r=>new WebSocket(r)),this.createClient=t.createClient??((r,i)=>new L0(r,{token:i??void 0})),this.client=this.createClient(this.url,this.token)}async connect(){var i;this.connectAttempt+=1;const t=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this.token),this.status="connecting",this.dispatchEvent(new Q("change"));const r=this.createSocket(DC(this.url,this.token));return this.socket=r,await new Promise((s,o)=>{let a=!1;const l=()=>{a||this.connectAttempt!==t||(a=!0,this.status="connected",this.dispatchEvent(new Q("change")),s())},u=f=>{a||this.connectAttempt!==t||(a=!0,this.status="disconnected",this.dispatchEvent(new Q("change")),o(f))},d=async()=>{try{const[{screens:f},v]=await Promise.all([this.client.screens.list(),this.client.views.list()]);this.screens=new Map(f.map(y=>[y.id,structuredClone(y)])),this.views=v,this.dispatchEvent(new Q("change")),l()}catch(f){u(f instanceof Error?f:new Error(String(f)))}};r.addEventListener("open",()=>{d()}),r.addEventListener("message",f=>{const v=zC(f);v&&(this.applyServerEvent(v),this.dispatchEvent(new kg("server-event",{serverURL:this.url,event:v})))}),r.addEventListener("close",f=>{if(this.connectAttempt===t){if(this.socket=null,OC(f)===RC){u(new gc);return}if(!a){u(new Error("Connection closed before initialization"));return}this.status="disconnected",this.dispatchEvent(new Q("change"))}}),r.addEventListener("error",()=>{u(new Error("WebSocket connection failed"))})})}disconnect(){var t;this.connectAttempt+=1,(t=this.socket)==null||t.close(),this.socket=null,this.status="disconnected",this.dispatchEvent(new Q("change"))}getViewURL(t){const r=PC(t.type,this.views);if(!r)return null;const i=`${this.url}/views/${encodeURIComponent(r.id)}/`;return this.token===null?i:`${i}?token=${encodeURIComponent(this.token)}`}getContentURL(t){const r=`${this.url}/artifacts/${encodeURIComponent(t)}/content`;return this.token===null?r:`${r}?token=${encodeURIComponent(this.token)}`}async createScreen(t){const{screen:r}=await this.client.screens.create({name:t});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(t){switch(t.type){case"screen-created":this.screens.set(t.screen.id,structuredClone(t.screen)),this.dispatchEvent(new zo("screens-changed"));break;case"screen-updated":this.screens.set(t.screen.id,structuredClone(t.screen)),this.dispatchEvent(new zo("screens-changed"));break;case"screen-removed":this.screens.delete(t.screenID),this.dispatchEvent(new zo("screens-changed"));break;case"artifact-created":{const r=this.screens.get(t.screenID);r&&!wg(r.layout,t.artifact.id)&&(r.layout=[...r.layout,bg(t.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(t.screenID);r&&(r.layout=ug(r.layout,t.artifactID));break}}}}function DC(n,e){const t=new URL(n);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/events",t.search="",e&&t.searchParams.set("token",e),t.hash="",t.toString()}function OC(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}function zC(n){const e=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!e)return null;try{return JSON.parse(e)}catch{return null}}class LC extends Tt{constructor(t){super();b(this,"servers",new Map);b(this,"localServerURL");b(this,"localStore");b(this,"createSocket");b(this,"lastActiveServerURL");b(this,"serverListeners",new Map);b(this,"handleLocalStoreChange",()=>{const t=this.localStore.get().activeServerURL;t!==this.lastActiveServerURL&&(this.lastActiveServerURL=t,this.dispatchEvent(new Q("change")))});this.localStore=t.localStore,this.localServerURL=t.localServerURL?Lt(t.localServerURL):null,this.createSocket=t.createSocket??(r=>new WebSocket(r)),this.lastActiveServerURL=this.localStore.get().activeServerURL,this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const t=this.localStore.get().activeServerURL;return t===null?null:this.servers.get(t)??null}add(t){const r=Lt(t.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,t);const s=()=>{this.dispatchEvent(new Q("change"))},o=l=>{this.dispatchEvent(new kg("server-event",{serverURL:l.serverURL,event:l.event}))},a=()=>{this.dispatchEvent(new zo("screens-changed"))};t.addEventListener("change",s),t.addEventListener("server-event",o),t.addEventListener("screens-changed",a),this.serverListeners.set(r,{onServerChange:s,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new Q("change"))}remove(t){const r=Lt(t);if(this.localServerURL&&r===this.localServerURL)return;const i=this.servers.get(r);if(!i)return;const s=this.serverListeners.get(r);s&&(i.removeEventListener("change",s.onServerChange),i.removeEventListener("server-event",s.onServerEvent),i.removeEventListener("screens-changed",s.onScreensChanged),this.serverListeners.delete(r)),i.disconnect(),this.servers.delete(r);const o=this.localStore.get(),a=o.activeServerURL===r;this.localStore.set({...o,servers:o.servers.filter(l=>l.url!==r),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new Q("change"))}setActive(t){const r=this.localStore.get(),i=t?Lt(t.url):null;r.activeServerURL!==i&&this.localStore.set({...r,activeServerURL:i})}connectConfiguredServers(t){const r=this.localStore.get().servers;for(const s of r){const o=new mc({url:s.url,name:s.name,createSocket:this.createSocket});this.add(o),o.connect().catch(()=>{})}const i=t?this.servers.get(Lt(t))??null:null;this.setActive(i??this.servers.values().next().value??null)}addServer(t,r){const i=Lt(t);this.remove(i);const s=this.localStore.get();this.localStore.set({...s,servers:[...s.servers.filter(a=>Lt(a.url)!==i),{url:i,name:r}]});const o=new mc({url:i,name:r,createSocket:this.createSocket});this.add(o),this.setActive(o),o.connect().catch(()=>{})}removeServer(t){this.remove(t)}}const se={authenticate:"authenticate",document_did_change:"document/didChange",document_did_close:"document/didClose",document_did_focus:"document/didFocus",document_did_open:"document/didOpen",document_did_save:"document/didSave",initialize:"initialize",logout:"logout",nes_accept:"nes/accept",nes_close:"nes/close",nes_reject:"nes/reject",nes_start:"nes/start",nes_suggest:"nes/suggest",session_cancel:"session/cancel",session_close:"session/close",session_fork:"session/fork",session_list:"session/list",session_load:"session/load",session_new:"session/new",session_prompt:"session/prompt",session_resume:"session/resume",session_set_config_option:"session/set_config_option",session_set_mode:"session/set_mode",session_set_model:"session/set_model"},Dt={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"},MC=1,NC=p({_meta:_(h(),w()).nullish(),terminal:Ee().optional().default(!1)}),UC=p({_meta:_(h(),w()).nullish(),label:h().nullish(),name:h(),optional:Ee().optional().default(!1),secret:Ee().optional().default(!0)}),FC=p({_meta:_(h(),w()).nullish(),description:h().nullish(),id:h(),name:h()}),ZC=p({_meta:_(h(),w()).nullish(),description:h().nullish(),id:h(),link:h().nullish(),name:h(),vars:D(UC)}),HC=p({_meta:_(h(),w()).nullish(),args:D(h()).optional(),description:h().nullish(),env:_(h(),h()).optional(),id:h(),name:h()}),VC=H([ZC.and(p({type:x("env_var")})),HC.and(p({type:x("terminal")})),FC]),jC=p({_meta:_(h(),w()).nullish(),methodId:h()}),GC=p({_meta:_(h(),w()).nullish()}),BC=p({_meta:_(h(),w()).nullish(),blob:h(),mimeType:h().nullish(),uri:h()}),WC=p({default:Ee().nullish(),description:h().nullish(),title:h().nullish()}),qC=p({_meta:_(h(),w()).nullish()}),YC=p({_meta:_(h(),w()).nullish()}),KC=p({amount:N(),currency:h()}),JC=p({_meta:_(h(),w()).nullish(),terminalId:h()}),XC=p({_meta:_(h(),w()).nullish(),newText:h(),oldText:h().nullish(),path:h()}),QC=H([h(),N(),N(),Ee(),D(h())]),eI=p({content:_(h(),QC).nullish()}),tI=H([eI.and(p({action:x("accept")})),p({action:x("decline")}),p({action:x("cancel")})]),nI=p({_meta:_(h(),w()).nullish()}),dm=h(),rI=p({_meta:_(h(),w()).nullish(),elicitationId:dm}),iI=p({_meta:_(h(),w()).nullish(),action:tI}),sI=x("object"),oI=x("string"),aI=p({_meta:_(h(),w()).nullish()}),lI=p({_meta:_(h(),w()).nullish(),form:nI.nullish(),url:aI.nullish()}),cI=p({elicitationId:dm,url:h().url()}),fm=p({const:h(),title:h()}),pm=p({_meta:_(h(),w()).nullish(),name:h(),value:h()}),uI=H([x(-32700),x(-32600),x(-32601),x(-32602),x(-32603),x(-32800),x(-32e3),x(-32002),x(-32042),N().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),gm=p({code:uI,data:w().optional(),message:h()}),mm=w(),ym=w(),vm=w(),hI=p({_meta:_(h(),w()).nullish(),readTextFile:Ee().optional().default(!1),writeTextFile:Ee().optional().default(!1)}),bm=p({_meta:_(h(),w()).nullish(),name:h(),value:h()}),wm=p({_meta:_(h(),w()).nullish(),name:h(),title:h().nullish(),version:h()}),dI=p({default:N().nullish(),description:h().nullish(),maximum:N().nullish(),minimum:N().nullish(),title:h().nullish()}),fI=p({_meta:_(h(),w()).nullish()}),pI=p({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cursor:h().nullish(),cwd:h().nullish()}),gI=p({_meta:_(h(),w()).nullish()}),mI=p({_meta:_(h(),w()).nullish(),logout:gI.nullish()}),yI=p({_meta:_(h(),w()).nullish()}),vI=p({_meta:_(h(),w()).nullish()}),bI=p({_meta:_(h(),w()).nullish(),http:Ee().optional().default(!1),sse:Ee().optional().default(!1)}),wI=p({_meta:_(h(),w()).nullish(),headers:D(bm),name:h(),url:h()}),_I=p({_meta:_(h(),w()).nullish(),headers:D(bm),name:h(),url:h()}),SI=p({_meta:_(h(),w()).nullish(),args:D(h()),command:h(),env:D(pm),name:h()}),Ma=H([wI.and(p({type:x("http")})),_I.and(p({type:x("sse")})),SI]),zu=h(),kI=p({_meta:_(h(),w()).nullish(),description:h().nullish(),modelId:zu,name:h()}),EI=H([x("error"),x("warning"),x("information"),x("hint")]),$I=p({_meta:_(h(),w()).nullish()}),AI=p({_meta:_(h(),w()).nullish()}),xI=p({_meta:_(h(),w()).nullish()}),TI=p({_meta:_(h(),w()).nullish()}),CI=p({_meta:_(h(),w()).nullish()}),II=p({_meta:_(h(),w()).nullish(),maxCount:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),PI=p({diff:h(),uri:h()}),RI=p({endLine:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:h()}),DI=p({_meta:_(h(),w()).nullish()}),OI=p({_meta:_(h(),w()).nullish()}),zI=p({languageId:h(),text:h(),uri:h()}),LI=p({_meta:_(h(),w()).nullish(),maxCount:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),MI=H([x("rejected"),x("ignored"),x("replaced"),x("cancelled")]),NI=p({excerpts:D(RI),uri:h()}),UI=p({_meta:_(h(),w()).nullish()}),FI=p({_meta:_(h(),w()).nullish()}),ZI=p({name:h(),owner:h(),remoteUrl:h()}),HI=p({_meta:_(h(),w()).nullish()}),VI=p({_meta:_(h(),w()).nullish(),jump:DI.nullish(),rename:FI.nullish(),searchAndReplace:HI.nullish()}),jI=p({id:h(),isRegex:Ee().nullish(),replace:h(),search:h(),uri:h()}),GI=H([x("automatic"),x("diagnostic"),x("manual")]),BI=p({_meta:_(h(),w()).nullish(),maxCount:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),WI=p({_meta:_(h(),w()).nullish(),diagnostics:$I.nullish(),editHistory:II.nullish(),openFiles:OI.nullish(),recentFiles:LI.nullish(),relatedSnippets:UI.nullish(),userActions:BI.nullish()}),qI=p({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ma)}),YI=p({default:N().nullish(),description:h().nullish(),maximum:N().nullish(),minimum:N().nullish(),title:h().nullish()}),_m=h(),KI=H([x("allow_once"),x("allow_always"),x("reject_once"),x("reject_always")]),JI=p({_meta:_(h(),w()).nullish(),kind:KI,name:h(),optionId:_m}),XI=H([x("high"),x("medium"),x("low")]),QI=H([x("pending"),x("in_progress"),x("completed")]),eP=p({_meta:_(h(),w()).nullish(),content:h(),priority:XI,status:QI}),tP=p({_meta:_(h(),w()).nullish(),entries:D(eP)}),mn=p({character:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),nP=p({id:h(),position:mn,uri:h()}),rP=p({id:h(),newName:h(),position:mn,uri:h()}),iP=p({action:h(),position:mn,timestampMs:N(),uri:h()}),Sm=H([x("utf-16"),x("utf-32"),x("utf-8")]),sP=p({_meta:_(h(),w()).nullish(),auth:NC.optional().default({terminal:!1}),elicitation:lI.nullish(),fs:hI.optional().default({readTextFile:!1,writeTextFile:!1}),nes:VI.nullish(),positionEncodings:D(Sm).optional(),terminal:Ee().optional().default(!1)}),oP=p({_meta:_(h(),w()).nullish(),audio:Ee().optional().default(!1),embeddedContext:Ee().optional().default(!1),image:Ee().optional().default(!1)}),km=N().int().gte(0).lte(65535),aP=p({_meta:_(h(),w()).nullish(),clientCapabilities:sP.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:wm.nullish(),protocolVersion:km}),pi=p({end:mn,start:mn}),lP=p({message:h(),range:pi,severity:EI,uri:h()}),cP=p({languageId:h(),lastFocusedMs:N().nullish(),uri:h(),visibleRange:pi.nullish()}),uP=p({_meta:_(h(),w()).nullish(),diagnostics:D(lP).nullish(),editHistory:D(PI).nullish(),openFiles:D(cP).nullish(),recentFiles:D(zI).nullish(),relatedSnippets:D(NI).nullish(),userActions:D(iP).nullish()}),hP=p({newText:h(),range:pi}),dP=p({cursorPosition:mn.nullish(),edits:D(hP),id:h(),uri:h()}),fP=H([dP.and(p({kind:x("edit")})),nP.and(p({kind:x("jump")})),rP.and(p({kind:x("rename")})),jI.and(p({kind:x("searchAndReplace")}))]),pP=p({_meta:_(h(),w()).nullish(),content:h()}),gP=p({_meta:_(h(),w()).nullish()}),nr=H([N(),h()]).nullable();p({_meta:_(h(),w()).nullish(),requestId:nr});const mP=ea(["assistant","user"]),Ys=p({_meta:_(h(),w()).nullish(),audience:D(mP).nullish(),lastModified:h().nullish(),priority:N().nullish()}),yP=p({_meta:_(h(),w()).nullish(),annotations:Ys.nullish(),data:h(),mimeType:h()}),vP=p({_meta:_(h(),w()).nullish(),annotations:Ys.nullish(),data:h(),mimeType:h(),uri:h().nullish()}),bP=p({_meta:_(h(),w()).nullish(),annotations:Ys.nullish(),description:h().nullish(),mimeType:h().nullish(),name:h(),size:N().nullish(),title:h().nullish(),uri:h()}),wP=p({_meta:_(h(),w()).nullish(),optionId:_m}),_P=H([p({outcome:x("cancelled")}),wP.and(p({outcome:x("selected")}))]),SP=p({_meta:_(h(),w()).nullish(),outcome:_P}),kP=p({_meta:_(h(),w()).nullish()}),EP=p({_meta:_(h(),w()).nullish()}),$P=p({currentValue:Ee()}),AP=h(),Em=h(),xP=H([x("mode"),x("model"),x("thought_level"),h()]),Lu=h(),$m=p({_meta:_(h(),w()).nullish(),description:h().nullish(),name:h(),value:Lu}),TP=p({_meta:_(h(),w()).nullish(),group:AP,name:h(),options:D($m)}),CP=H([D($m),D(TP)]),IP=p({currentValue:Lu,options:CP}),gi=La(H([IP.and(p({type:x("select")})),$P.and(p({type:x("boolean")}))]),p({_meta:_(h(),w()).nullish(),category:xP.nullish(),description:h().nullish(),id:Em,name:h()})),PP=p({_meta:_(h(),w()).nullish(),configOptions:D(gi)}),RP=p({_meta:_(h(),w()).nullish()}),Y=h(),DP=p({_meta:_(h(),w()).nullish(),id:h(),sessionId:Y}),OP=p({_meta:_(h(),w()).nullish(),sessionId:Y}),zP=p({_meta:_(h(),w()).nullish(),sessionId:Y}),LP=p({_meta:_(h(),w()).nullish(),sessionId:Y}),Am=p({_meta:_(h(),w()).nullish(),args:D(h()).optional(),command:h(),cwd:h().nullish(),env:D(pm).optional(),outputByteLimit:N().nullish(),sessionId:Y}),MP=p({_meta:_(h(),w()).nullish(),sessionId:Y,uri:h()}),NP=p({_meta:_(h(),w()).nullish(),position:mn,sessionId:Y,uri:h(),version:N(),visibleRange:pi}),UP=p({_meta:_(h(),w()).nullish(),languageId:h(),sessionId:Y,text:h(),uri:h(),version:N()}),FP=p({_meta:_(h(),w()).nullish(),sessionId:Y,uri:h()}),ZP=p({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ma).optional(),sessionId:Y}),xm=p({_meta:_(h(),w()).nullish(),sessionId:Y,terminalId:h()}),HP=p({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ma),sessionId:Y}),Tm=p({_meta:_(h(),w()).nullish(),limit:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h(),sessionId:Y}),VP=p({_meta:_(h(),w()).nullish(),id:h(),reason:MI.nullish(),sessionId:Y}),Cm=p({_meta:_(h(),w()).nullish(),sessionId:Y,terminalId:h()}),jP=p({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),mcpServers:D(Ma).optional(),sessionId:Y}),GP=p({_meta:_(h(),w()).nullish(),additionalDirectories:D(h()).optional(),cwd:h(),sessionId:Y,title:h().nullish(),updatedAt:h().nullish()}),BP=p({_meta:_(h(),w()).nullish(),nextCursor:h().nullish(),sessions:D(GP)}),WP=p({_meta:_(h(),w()).nullish(),title:h().nullish(),updatedAt:h().nullish()}),qP=p({_meta:_(h(),w()).nullish()}),Na=h(),YP=p({_meta:_(h(),w()).nullish(),currentModeId:Na}),KP=p({_meta:_(h(),w()).nullish(),description:h().nullish(),id:Na,name:h()}),Ua=p({_meta:_(h(),w()).nullish(),availableModes:D(KP),currentModeId:Na}),Fa=p({_meta:_(h(),w()).nullish(),availableModels:D(kI),currentModelId:zu}),JP=p({_meta:_(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Fa.nullish(),modes:Ua.nullish(),sessionId:Y}),XP=p({_meta:_(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Fa.nullish(),modes:Ua.nullish()}),QP=p({_meta:_(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Fa.nullish(),modes:Ua.nullish(),sessionId:Y}),e1=p({_meta:_(h(),w()).nullish(),configOptions:D(gi).nullish(),models:Fa.nullish(),modes:Ua.nullish()}),t1=p({_meta:_(h(),w()).nullish()}),n1=p({_meta:_(h(),w()).nullish(),additionalDirectories:kP.nullish(),close:EP.nullish(),fork:RP.nullish(),list:qP.nullish(),resume:t1.nullish()}),r1=La(H([p({type:x("boolean"),value:Ee()}),p({value:Lu})]),p({_meta:_(h(),w()).nullish(),configId:Em,sessionId:Y})),i1=p({_meta:_(h(),w()).nullish(),configOptions:D(gi)}),s1=p({_meta:_(h(),w()).nullish(),modeId:Na,sessionId:Y}),o1=p({_meta:_(h(),w()).nullish()}),a1=p({_meta:_(h(),w()).nullish(),modelId:zu,sessionId:Y}),l1=p({_meta:_(h(),w()).nullish()}),c1=p({_meta:_(h(),w()).nullish(),sessionId:Y}),u1=H([x("end_turn"),x("max_tokens"),x("max_turn_requests"),x("refusal"),x("cancelled")]),h1=H([x("email"),x("uri"),x("date"),x("date-time")]),d1=p({default:h().nullish(),description:h().nullish(),enum:D(h()).nullish(),format:h1.nullish(),maxLength:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:D(fm).nullish(),pattern:h().nullish(),title:h().nullish()}),f1=p({_meta:_(h(),w()).nullish(),context:uP.nullish(),position:mn,selection:pi.nullish(),sessionId:Y,triggerKind:GI,uri:h(),version:N()}),p1=p({_meta:_(h(),w()).nullish(),suggestions:D(fP)}),g1=p({_meta:_(h(),w()).nullish(),terminalId:h()}),m1=p({_meta:_(h(),w()).nullish(),exitCode:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),Im=p({_meta:_(h(),w()).nullish(),sessionId:Y,terminalId:h()}),y1=p({_meta:_(h(),w()).nullish(),exitStatus:m1.nullish(),output:h(),truncated:Ee()}),v1=p({_meta:_(h(),w()).nullish(),annotations:Ys.nullish(),text:h()}),b1=p({range:pi.nullish(),text:h()}),w1=p({_meta:_(h(),w()).nullish(),contentChanges:D(b1),sessionId:Y,uri:h(),version:N()});p({method:h(),params:H([OP,UP,w1,MP,FP,NP,DP,VP,mm]).nullish()});const _1=H([x("full"),x("incremental")]),S1=p({_meta:_(h(),w()).nullish(),syncKind:_1}),k1=p({_meta:_(h(),w()).nullish(),didChange:S1.nullish(),didClose:AI.nullish(),didFocus:xI.nullish(),didOpen:TI.nullish(),didSave:CI.nullish()}),E1=p({_meta:_(h(),w()).nullish(),document:k1.nullish()}),$1=p({_meta:_(h(),w()).nullish(),context:WI.nullish(),events:E1.nullish()}),A1=p({_meta:_(h(),w()).nullish(),auth:mI.optional().default({}),loadSession:Ee().optional().default(!1),mcpCapabilities:bI.optional().default({http:!1,sse:!1}),nes:$1.nullish(),positionEncoding:Sm.nullish(),promptCapabilities:oP.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:n1.optional().default({})}),x1=p({_meta:_(h(),w()).nullish(),agentCapabilities:A1.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:wm.nullish(),authMethods:D(VC).optional().default([]),protocolVersion:km}),T1=p({_meta:_(h(),w()).nullish(),mimeType:h().nullish(),text:h(),uri:h()}),C1=H([T1,BC]),I1=p({_meta:_(h(),w()).nullish(),annotations:Ys.nullish(),resource:C1}),Mu=H([v1.and(p({type:x("text")})),vP.and(p({type:x("image")})),yP.and(p({type:x("audio")})),bP.and(p({type:x("resource_link")})),I1.and(p({type:x("resource")}))]),P1=p({_meta:_(h(),w()).nullish(),content:Mu}),zl=p({_meta:_(h(),w()).nullish(),content:Mu,messageId:h().nullish()}),R1=p({_meta:_(h(),w()).nullish(),messageId:h().nullish(),prompt:D(Mu),sessionId:Y}),D1=p({anyOf:D(fm)}),Pm=H([P1.and(p({type:x("content")})),XC.and(p({type:x("diff")})),g1.and(p({type:x("terminal")}))]),Rm=h(),Dm=p({_meta:_(h(),w()).nullish(),line:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h()}),Om=H([x("pending"),x("in_progress"),x("completed"),x("failed")]),zm=H([x("read"),x("edit"),x("delete"),x("move"),x("search"),x("execute"),x("think"),x("fetch"),x("switch_mode"),x("other")]),O1=p({_meta:_(h(),w()).nullish(),content:D(Pm).optional(),kind:zm.optional(),locations:D(Dm).optional(),rawInput:w().optional(),rawOutput:w().optional(),status:Om.optional(),title:h(),toolCallId:Rm}),Lm=p({_meta:_(h(),w()).nullish(),content:D(Pm).nullish(),kind:zm.nullish(),locations:D(Dm).nullish(),rawInput:w().optional(),rawOutput:w().optional(),status:Om.nullish(),title:h().nullish(),toolCallId:Rm}),Mm=p({_meta:_(h(),w()).nullish(),options:D(JI),sessionId:Y,toolCall:Lm}),z1=p({_meta:_(h(),w()).nullish(),hint:h()}),L1=z1,M1=p({_meta:_(h(),w()).nullish(),description:h(),input:L1.nullish(),name:h()}),N1=p({_meta:_(h(),w()).nullish(),availableCommands:D(M1)}),U1=p({enum:D(h()),type:oI}),F1=H([U1,D1]),Z1=p({default:D(h()).nullish(),description:h().nullish(),items:F1,maxItems:N().nullish(),minItems:N().nullish(),title:h().nullish()}),H1=H([d1.and(p({type:x("string")})),YI.and(p({type:x("number")})),dI.and(p({type:x("integer")})),WC.and(p({type:x("boolean")})),Z1.and(p({type:x("array")}))]),V1=p({description:h().nullish(),properties:_(h(),H1).optional().default({}),required:D(h()).nullish(),title:h().nullish(),type:sI.optional().default("object")}),j1=p({requestedSchema:V1}),G1=La(H([j1.and(p({mode:x("form")})),cI.and(p({mode:x("url")}))]),p({_meta:_(h(),w()).nullish(),message:h(),sessionId:Y})),B1=p({cachedReadTokens:N().nullish(),cachedWriteTokens:N().nullish(),inputTokens:N(),outputTokens:N(),thoughtTokens:N().nullish(),totalTokens:N()}),W1=p({_meta:_(h(),w()).nullish(),stopReason:u1,usage:B1.nullish(),userMessageId:h().nullish()});H([p({id:nr,result:H([x1,GC,vI,QP,XP,BP,JP,e1,YC,o1,i1,W1,l1,c1,p1,qC,vm])}),p({error:gm,id:nr})]);const q1=p({_meta:_(h(),w()).nullish(),cost:KC.nullish(),size:N(),used:N()}),Y1=H([zl.and(p({sessionUpdate:x("user_message_chunk")})),zl.and(p({sessionUpdate:x("agent_message_chunk")})),zl.and(p({sessionUpdate:x("agent_thought_chunk")})),O1.and(p({sessionUpdate:x("tool_call")})),Lm.and(p({sessionUpdate:x("tool_call_update")})),tP.and(p({sessionUpdate:x("plan")})),N1.and(p({sessionUpdate:x("available_commands_update")})),YP.and(p({sessionUpdate:x("current_mode_update")})),PP.and(p({sessionUpdate:x("config_option_update")})),WP.and(p({sessionUpdate:x("session_info_update")})),q1.and(p({sessionUpdate:x("usage_update")}))]),Nm=p({_meta:_(h(),w()).nullish(),sessionId:Y,update:Y1});p({method:h(),params:H([Nm,rI,mm]).nullish()});const Um=p({_meta:_(h(),w()).nullish(),sessionId:Y,terminalId:h()}),K1=p({_meta:_(h(),w()).nullish(),exitCode:N().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),J1=p({name:h(),uri:h()}),X1=p({_meta:_(h(),w()).nullish(),repository:ZI.nullish(),workspaceFolders:D(J1).nullish(),workspaceUri:h().nullish()});p({id:nr,method:h(),params:H([aP,jC,yI,qI,HP,pI,ZP,jP,LP,s1,r1,R1,a1,X1,f1,zP,ym]).nullish()});const Fm=p({_meta:_(h(),w()).nullish(),content:h(),path:h(),sessionId:Y});p({id:nr,method:h(),params:H([Fm,Tm,Mm,Am,Im,Cm,Um,xm,G1,ym]).nullish()});const Q1=p({_meta:_(h(),w()).nullish()});H([p({id:nr,result:H([Q1,pP,SP,JC,y1,gP,K1,fI,iI,vm])}),p({error:gm,id:nr})]);var q;class eR{constructor(e,t){S(this,q);const r=e(this),i=async(o,a)=>{var l,u,d,f,v,y,A;switch(o){case Dt.fs_write_text_file:{const k=Fm.parse(a);return(l=r.writeTextFile)==null?void 0:l.call(r,k)}case Dt.fs_read_text_file:{const k=Tm.parse(a);return(u=r.readTextFile)==null?void 0:u.call(r,k)}case Dt.session_request_permission:{const k=Mm.parse(a);return r.requestPermission(k)}case Dt.terminal_create:{const k=Am.parse(a);return(d=r.createTerminal)==null?void 0:d.call(r,k)}case Dt.terminal_output:{const k=Im.parse(a);return(f=r.terminalOutput)==null?void 0:f.call(r,k)}case Dt.terminal_release:{const k=Cm.parse(a);return await((v=r.releaseTerminal)==null?void 0:v.call(r,k))??{}}case Dt.terminal_wait_for_exit:{const k=Um.parse(a);return(y=r.waitForTerminalExit)==null?void 0:y.call(r,k)}case Dt.terminal_kill:{const k=xm.parse(a);return await((A=r.killTerminal)==null?void 0:A.call(r,k))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw we.methodNotFound(o)}},s=async(o,a)=>{switch(o){case Dt.session_update:{const l=Nm.parse(a);return r.sessionUpdate(l)}default:if(r.extNotification)return r.extNotification(o,a);throw we.methodNotFound(o)}};E(this,q,new tR(i,s,t))}async initialize(e){return await c(this,q).sendRequest(se.initialize,e)}async newSession(e){return await c(this,q).sendRequest(se.session_new,e)}async loadSession(e){return await c(this,q).sendRequest(se.session_load,e)??{}}async unstable_forkSession(e){return await c(this,q).sendRequest(se.session_fork,e)}async listSessions(e){return await c(this,q).sendRequest(se.session_list,e)}async unstable_resumeSession(e){return await c(this,q).sendRequest(se.session_resume,e)}async unstable_closeSession(e){return await c(this,q).sendRequest(se.session_close,e)}async setSessionMode(e){return await c(this,q).sendRequest(se.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await c(this,q).sendRequest(se.session_set_model,e)??{}}async setSessionConfigOption(e){return await c(this,q).sendRequest(se.session_set_config_option,e)}async authenticate(e){return await c(this,q).sendRequest(se.authenticate,e)??{}}async unstable_logout(e){return await c(this,q).sendRequest(se.logout,e)??{}}async prompt(e){return await c(this,q).sendRequest(se.session_prompt,e)}async cancel(e){return await c(this,q).sendNotification(se.session_cancel,e)}async unstable_startNes(e){return await c(this,q).sendRequest(se.nes_start,e)}async unstable_suggestNes(e){return await c(this,q).sendRequest(se.nes_suggest,e)}async unstable_closeNes(e){return await c(this,q).sendRequest(se.nes_close,e)??{}}async unstable_didOpenDocument(e){return await c(this,q).sendNotification(se.document_did_open,e)}async unstable_didChangeDocument(e){return await c(this,q).sendNotification(se.document_did_change,e)}async unstable_didCloseDocument(e){return await c(this,q).sendNotification(se.document_did_close,e)}async unstable_didSaveDocument(e){return await c(this,q).sendNotification(se.document_did_save,e)}async unstable_didFocusDocument(e){return await c(this,q).sendNotification(se.document_did_focus,e)}async unstable_acceptNes(e){return await c(this,q).sendNotification(se.nes_accept,e)}async unstable_rejectNes(e){return await c(this,q).sendNotification(se.nes_reject,e)}async extMethod(e,t){return await c(this,q).sendRequest(e,t)}async extNotification(e,t){return await c(this,q).sendNotification(e,t)}get signal(){return c(this,q).signal}get closed(){return c(this,q).closed}}q=new WeakMap;var sn,ca,ls,cs,Or,zr,St,us,ue,Zm,yc,Hm,Vm,jm,Gm,vc,Li;class tR{constructor(e,t,r){S(this,ue);S(this,sn,new Map);S(this,ca,0);S(this,ls);S(this,cs);S(this,Or);S(this,zr,Promise.resolve());S(this,St,new AbortController);S(this,us);E(this,ls,e),E(this,cs,t),E(this,Or,r),E(this,us,new Promise(i=>{c(this,St).signal.addEventListener("abort",()=>i())})),m(this,ue,Zm).call(this)}get signal(){return c(this,St).signal}get closed(){return c(this,us)}async sendRequest(e,t){m(this,ue,vc).call(this);const r=$h(this,ca)._++,i=new Promise((s,o)=>{c(this,sn).set(r,{resolve:s,reject:o})});return await m(this,ue,Li).call(this,{jsonrpc:"2.0",id:r,method:e,params:t}),i}async sendNotification(e,t){m(this,ue,vc).call(this),await m(this,ue,Li).call(this,{jsonrpc:"2.0",method:e,params:t})}}sn=new WeakMap,ca=new WeakMap,ls=new WeakMap,cs=new WeakMap,Or=new WeakMap,zr=new WeakMap,St=new WeakMap,us=new WeakMap,ue=new WeakSet,Zm=async function(){let e;try{const t=c(this,Or).readable.getReader();try{for(;!c(this,St).signal.aborted;){const{value:r,done:i}=await t.read();if(i)break;if(r)try{m(this,ue,Hm).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&m(this,ue,Li).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{t.releaseLock()}}catch(t){e=t}finally{m(this,ue,yc).call(this,e)}},yc=function(e){if(c(this,St).signal.aborted)return;const t=e??new Error("ACP connection closed");for(const r of c(this,sn).values())r.reject(t);c(this,sn).clear(),c(this,St).abort(t)},Hm=async function(e){if("method"in e&&"id"in e){const t=await m(this,ue,Vm).call(this,e.method,e.params);"error"in t&&console.error("Error handling request",e,t.error),await m(this,ue,Li).call(this,{jsonrpc:"2.0",id:e.id,...t})}else if("method"in e){const t=await m(this,ue,jm).call(this,e.method,e.params);"error"in t&&console.error("Error handling notification",e,t.error)}else"id"in e?m(this,ue,Gm).call(this,e):console.error("Invalid message",{message:e})},Vm=async function(e,t){try{return{result:await c(this,ls).call(this,e,t)??null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof mf)return we.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return we.internalError(i?JSON.parse(i):{}).toResult()}catch{return we.internalError({details:i}).toResult()}}},jm=async function(e,t){try{return await c(this,cs).call(this,e,t),{result:null}}catch(r){if(r instanceof we)return r.toResult();if(r instanceof mf)return we.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return we.internalError(i?JSON.parse(i):{}).toResult()}catch{return we.internalError({details:i}).toResult()}}},Gm=function(e){const t=c(this,sn).get(e.id);if(t){if("result"in e)t.resolve(e.result);else if("error"in e){const{code:r,message:i,data:s}=e.error;t.reject(new we(r,i,s))}c(this,sn).delete(e.id)}else console.error("Got response to unknown request",e.id)},vc=function(){if(c(this,St).signal.aborted)throw c(this,St).signal.reason??new Error("ACP connection closed")},Li=async function(e){return E(this,zr,c(this,zr).then(async()=>{const t=c(this,Or).writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(t=>{m(this,ue,yc).call(this,t)})),c(this,zr)};class we extends Error{constructor(t,r,i){super(r);b(this,"code");b(this,"data");this.code=t,this.name="RequestError",this.data=i}static parseError(t,r){return new we(-32700,`Parse error${r?`: ${r}`:""}`,t)}static invalidRequest(t,r){return new we(-32600,`Invalid request${r?`: ${r}`:""}`,t)}static methodNotFound(t){return new we(-32601,`"Method not found": ${t}`,{method:t})}static invalidParams(t,r){return new we(-32602,`Invalid params${r?`: ${r}`:""}`,t)}static internalError(t,r){return new we(-32603,`Internal error${r?`: ${r}`:""}`,t)}static authRequired(t,r){return new we(-32e3,`Authentication required${r?`: ${r}`:""}`,t)}static resourceNotFound(t){return new we(-32002,`Resource not found${t?`: ${t}`:""}`,t&&{uri:t})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const nR=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,rR=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,iR=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,sR=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,oR="single_session",aR={name:"television-acp-client",version:"0.0.0"},Bm="agent:main:television",lR=di(Tt);var ee,Nt,Lr,Ut,Hn,Vn,on,Mr,kt,lt,an,jn,Ft,ln,hs,Zt,ct,ua,Ht,C,Wm,qm,bc,Ym,Km,Jm,Xm,Qm,ey,ty,Tn,kr,Er,We,ny,$r,wc,_c,Mo,ry,ds,fs,Sc,Ar,iy,sy;class cR extends lR{constructor(t){super();S(this,C);S(this,ee,uR());S(this,Nt,null);S(this,Lr,null);S(this,Ut,null);S(this,Hn,null);S(this,Vn,null);S(this,on,null);S(this,Mr,1);S(this,kt,null);S(this,lt,null);S(this,an,!1);S(this,jn,!1);S(this,Ft,null);S(this,ln,new Set);S(this,hs);S(this,Zt);S(this,ct);S(this,ua,t=>{m(this,C,qm).call(this,t)});S(this,Ht,null);S(this,ds,()=>{m(this,C,Ar).call(this,"ACP bridge websocket closed")});S(this,fs,()=>{m(this,C,Ar).call(this,"ACP bridge websocket error")});E(this,Zt,t),E(this,ct,t.sessionMode??oR),E(this,hs,t.createSocket??(r=>new WebSocket(r)))}getState(){return c(this,ee)}get messages(){return c(this,ee).messageOrder.map(t=>c(this,ee).messagesById[t]).filter(t=>t!==void 0)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(c(this,ee).lifecycle.status!=="ready"){m(this,C,We).call(this,{lifecycle:{status:"connecting"}}),c(this,Lr)??E(this,Lr,m(this,C,Wm).call(this));try{await c(this,Lr),await m(this,C,bc).call(this)}catch(t){throw m(this,C,Ar).call(this,bo(t)),t}}}dispose(){m(this,C,Sc).call(this),m(this,C,We).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null}})}async sendMessage(t){if(await this.connect(),c(this,ee).lifecycle.status!=="ready"||c(this,ee).run.status==="running"||c(this,ee).run.status==="cancelling")throw new Error("ACPClient is not ready to send a new message");const r=t.text.trim();if(!r)throw new Error("Cannot send an empty message");m(this,C,kr).call(this,{id:m(this,C,$r).call(this,"user"),kind:"user",text:r,status:"final"}),m(this,C,We).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const i=await m(this,C,Mo).call(this).prompt({sessionId:m(this,C,_c).call(this),prompt:[{type:"text",text:m(this,C,ny).call(this,r)}]});m(this,C,Tn).call(this,i.stopReason==="cancelled"?"cancelled":"final"),m(this,C,We).call(this,{run:{status:i.stopReason==="cancelled"?"cancelled":"completed",stopReason:i.stopReason,canCancel:!1,error:null}})}catch(i){throw m(this,C,sy).call(this)||(m(this,C,Tn).call(this,"error"),m(this,C,We).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:bo(i)}})),i}}async cancel(){if(await this.connect(),!c(this,ee).run.canCancel||c(this,ee).run.status!=="running")throw new Error("No active cancellable run");m(this,C,We).call(this,{run:{...c(this,ee).run,status:"cancelling"}}),await m(this,C,Mo).call(this).cancel({sessionId:m(this,C,_c).call(this)})}setScreenContext(t){var s,o,a;const r={screenID:t.screenID,screenName:t.screenName};if(((s=c(this,lt))==null?void 0:s.screenID)===r.screenID&&((o=c(this,lt))==null?void 0:o.screenName)===r.screenName)return;const i=((a=c(this,lt))==null?void 0:a.screenID)??null;if(E(this,lt,r),c(this,ct)==="single_session"){(!c(this,on)||i!==r.screenID)&&E(this,an,!0);return}c(this,on)!==Sf(c(this,ct),r.screenID,c(this,Zt).clientGUID??"default-client")&&(E(this,Ut,null),E(this,Hn,null),c(this,Nt)&&c(this,ee).run.status==="idle"&&m(this,C,bc).call(this).catch(l=>{m(this,C,Ar).call(this,bo(l))}))}}ee=new WeakMap,Nt=new WeakMap,Lr=new WeakMap,Ut=new WeakMap,Hn=new WeakMap,Vn=new WeakMap,on=new WeakMap,Mr=new WeakMap,kt=new WeakMap,lt=new WeakMap,an=new WeakMap,jn=new WeakMap,Ft=new WeakMap,ln=new WeakMap,hs=new WeakMap,Zt=new WeakMap,ct=new WeakMap,ua=new WeakMap,Ht=new WeakMap,C=new WeakSet,Wm=async function(){try{m(this,C,We).call(this,{lifecycle:{status:"connecting"}});const{stream:t,socket:r}=await fR({serverURL:c(this,Zt).serverURL,token:c(this,Zt).token,createSocket:c(this,hs),onDisconnect:c(this,ua)});E(this,Ht,r),r.addEventListener("close",c(this,ds)),r.addEventListener("error",c(this,fs)),E(this,Nt,new eR(i=>({connection:i,sessionUpdate:async s=>{await m(this,C,Km).call(this,s)},requestPermission:async s=>m(this,C,Jm).call(this,s)}),t)),await c(this,Nt).initialize({protocolVersion:MC,clientCapabilities:{},clientInfo:aR})}catch(t){throw t}},qm=function(t){m(this,C,Ar).call(this,bo(t))},bc=async function(){const t=m(this,C,ry).call(this);if(c(this,Ut)&&c(this,Hn)===t){await c(this,Ut);return}E(this,Hn,t),E(this,Ut,m(this,C,Ym).call(this,t)),await c(this,Ut)},Ym=async function(t){const r=m(this,C,Mo).call(this);m(this,C,iy).call(this);let i,s=!1;try{E(this,jn,!0),E(this,Ft,null),await r.loadSession({sessionId:t,cwd:"/",mcpServers:[],_meta:{sessionKey:t}}),i=t,s=c(this,ee).messageOrder.length>0}catch{i=(await r.newSession({cwd:"/",mcpServers:[],_meta:{sessionKey:t}})).sessionId,s=!1}finally{E(this,jn,!1),E(this,Ft,null),m(this,C,Tn).call(this,"final")}await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),E(this,Vn,i),E(this,on,t),s?(c(this,ln).add(t),c(this,ct)==="single_session"&&E(this,an,!1)):(c(this,ln).delete(t),E(this,an,c(this,ct)==="single_session")),m(this,C,We).call(this,{lifecycle:{status:"ready"}})},Km=async function(t){const r=t.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&m(this,C,ty).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&m(this,C,Xm).call(this,r.content.text);return;case"tool_call":m(this,C,Qm).call(this,r);return;case"tool_call_update":m(this,C,ey).call(this,r);return;case"agent_thought_chunk":return;default:return}},Jm=async function(t){return{outcome:{outcome:"cancelled"}}},Xm=function(t){E(this,Ft,null);const r=hR(t);if(!r)return;if(!c(this,kt)){const s={id:m(this,C,$r).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};E(this,kt,s.id),m(this,C,kr).call(this,s);return}const i=c(this,ee).messagesById[c(this,kt)];if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");m(this,C,Er).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},Qm=function(t){m(this,C,Tn).call(this,"final");const r=m(this,C,wc).call(this,t.toolCallId),i={id:(r==null?void 0:r.id)??m(this,C,$r).call(this,"tool"),kind:"tool_call",toolCallId:t.toolCallId,title:t.title,toolKind:t.kind??"other",status:t.status==="failed"?"failed":t.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??"",locations:t.locations??(r==null?void 0:r.locations)};if(r){m(this,C,Er).call(this,i);return}m(this,C,kr).call(this,i)},ey=function(t){const r=m(this,C,wc).call(this,t.toolCallId),i=(r==null?void 0:r.text)??"",s=dR(t.content),o=s?`${i}${s}`:i,a={id:(r==null?void 0:r.id)??m(this,C,$r).call(this,"tool"),kind:"tool_call",toolCallId:t.toolCallId,title:(r==null?void 0:r.title)??t.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:t.status==="failed"?"failed":t.status==="completed"?"completed":"in_progress",text:o,locations:t.locations??(r==null?void 0:r.locations)};if(r){m(this,C,Er).call(this,a);return}m(this,C,kr).call(this,a)},ty=function(t){if(m(this,C,Tn).call(this,"final"),!t)return;const r=c(this,jn)?c(this,Ft):null;if(!r){const s=kf(t);if(!s)return;const o={id:m(this,C,$r).call(this,"user"),kind:"user",text:s,status:"final"};m(this,C,kr).call(this,o),c(this,jn)&&E(this,Ft,o.id);return}const i=c(this,ee).messagesById[r];if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");m(this,C,Er).call(this,{...i,text:kf(`${i.text}${t}`)})},Tn=function(t){if(!c(this,kt))return;const r=c(this,ee).messagesById[c(this,kt)];(r==null?void 0:r.kind)==="assistant"&&m(this,C,Er).call(this,{...r,status:t}),E(this,kt,null)},kr=function(t){m(this,C,We).call(this,{messagesById:{...c(this,ee).messagesById,[t.id]:t},messageOrder:[...c(this,ee).messageOrder,t.id]})},Er=function(t){m(this,C,We).call(this,{messagesById:{...c(this,ee).messagesById,[t.id]:t}})},We=function(t){const r={...c(this,ee),...t};E(this,ee,{...r,sendDisabled:r.lifecycle.status!=="ready"||r.run.status==="running"||r.run.status==="cancelling",cancelDisabled:!(r.run.status==="running"||r.run.status==="cancelling")||!r.run.canCancel}),this.dispatchEvent(new Q("change"))},ny=function(t){const r=c(this,on);return!c(this,lt)||!r||!(c(this,ct)==="single_session"?c(this,an)||!c(this,ln).has(r):!c(this,ln).has(r))?t:(E(this,an,!1),c(this,ln).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${c(this,lt).screenID}`,`screen_name: ${c(this,lt).screenName??""}`,"When the user asks to inspect or change Television state with the tv CLI, use this screen ID with the --screen argument.","[/Television screen context]","",t].join(`
|
|
43
|
-
`))},$r=function(t){const r=`${t}-${c(this,Mr)}`;return E(this,Mr,c(this,Mr)+1),r},wc=function(t){for(const r of c(this,ee).messageOrder){const i=c(this,ee).messagesById[r];if((i==null?void 0:i.kind)==="tool_call"&&i.toolCallId===t)return i}return null},_c=function(){if(!c(this,Vn))throw new Error("ACP session is not ready");return c(this,Vn)},Mo=function(){if(!c(this,Nt))throw new Error("ACP connection is not ready");return c(this,Nt)},ry=function(){var r;if(c(this,ct)==="single_session")return`${Bm}-${(c(this,Zt).clientGUID??"default-client").toLowerCase()}`;const t=(r=c(this,lt))==null?void 0:r.screenID;if(!t)throw new Error("Screen context is required for per-screen session mode");return Sf(c(this,ct),t,c(this,Zt).clientGUID??"default-client")},ds=new WeakMap,fs=new WeakMap,Sc=function(){E(this,Nt,null),E(this,Lr,null),E(this,Ut,null),E(this,Hn,null),E(this,Vn,null),E(this,on,null),c(this,Ht)&&(c(this,Ht).removeEventListener("close",c(this,ds)),c(this,Ht).removeEventListener("error",c(this,fs)),c(this,Ht).close(),E(this,Ht,null))},Ar=function(t){this.disposed||c(this,ee).lifecycle.status==="disconnected"||(m(this,C,Tn).call(this,"error"),m(this,C,Sc).call(this),m(this,C,We).call(this,{lifecycle:{status:"disconnected",...t?{error:t}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null}}))},iy=function(){E(this,kt,null),E(this,Ft,null),E(this,Mr,1),m(this,C,We).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},sy=function(){return c(this,ee).lifecycle.status==="disconnected"};function uR(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function Sf(n,e,t){return n==="single_session"?`${Bm}-${t.toLowerCase()}`:`agent:main:television-${t.toLowerCase()}-${e.toLowerCase()}`}function oy(n){return n.replace(/^(?:\s*\n)+/,"")}function kf(n){let e=n;return e=e.replace(nR,""),e=e.replace(rR,""),e=e.replace(iR,""),e=oy(e),e}function hR(n){let e=n;return e=e.replace(sR,""),e=oy(e),e}function dR(n){return!n||n.length===0?"":n.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function fR(n){const e=n.createSocket(gR(n.serverURL,n.token));let t=!1,r,i;const s=new Promise((l,u)=>{r=l,i=u}),o=new ReadableStream({start(l){let u=!1;const d=()=>{e.send(JSON.stringify({type:"acp-bridge-connect"}))},f=A=>{const k=pR(A);if(!k)return;let I;try{I=JSON.parse(k)}catch(G){const P=G instanceof Error?G:new Error(String(G));i(P),l.error(P);return}switch(I.type){case"acp-bridge-status":if(I.status==="ready"){t||(t=!0,r());return}if(I.status==="error"||I.status==="exited"){const G=new Error(I.error??`ACP bridge ${I.status}`);t||i(G),l.error(G)}return;case"acp-bridge-message":l.enqueue(I.message);return}},v=()=>{var k;if(u)return;u=!0;const A=new Error("ACP bridge websocket closed");t||i(A),(k=n.onDisconnect)==null||k.call(n,A),l.close()},y=()=>{var k;if(u)return;u=!0;const A=new Error("ACP bridge websocket error");t||i(A),(k=n.onDisconnect)==null||k.call(n,A),l.error(A)};e.addEventListener("open",d),e.addEventListener("message",f),e.addEventListener("close",v),e.addEventListener("error",y)}}),a=new WritableStream({async write(l){await s,e.send(JSON.stringify({type:"acp-bridge-message",message:l}))},close(){e.close()},abort(){e.close()}});return await s,{stream:{readable:o,writable:a},socket:e}}function pR(n){if(typeof n=="string")return n;if(n instanceof Uint8Array)return new TextDecoder().decode(n);if(typeof Buffer<"u"&&n instanceof Buffer)return n.toString("utf8");if(typeof n=="object"&&n!==null&&"data"in n){const e=n.data;if(typeof e=="string")return e;if(e instanceof Uint8Array)return new TextDecoder().decode(e);if(Array.isArray(e))return Buffer.concat(e).toString("utf8")}return null}function gR(n,e){const t=new URL(n);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/acp",t.search="",t.searchParams.set("token",e),t.hash="",t.toString()}function bo(n){return n instanceof Error?n.message:String(n)}const Ef="television.acpClientGUID",mR=di(Tt);class yR extends mR{constructor(t){super();b(this,"screenManager");b(this,"clients",new Map);b(this,"options");b(this,"sessionMode");b(this,"clientGUID");b(this,"activeClient",null);b(this,"handleActiveScreenChanged",()=>{this.syncActiveClient()});this.screenManager=t.screenManager,this.sessionMode=t.sessionMode??"single_session",this.options={serverURL:t.serverURL,token:t.token,...t.createSocket?{createSocket:t.createSocket}:{},...t.sessionMode?{sessionMode:t.sessionMode}:{}},this.clientGUID=t.clientGUID??vR(t.storage??window.localStorage),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.syncActiveClient()}getActiveClient(){return this.activeClient}dispose(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged);for(const t of this.clients.values())t.dispose();this.clients.clear(),this.activeClient=null}syncActiveClient(){const t=this.screenManager.activeScreen,r=t?this.getClientForScreen(t):null;this.activeClient!==r&&(this.activeClient=r,this.dispatchEvent(new Q("change")))}getClientForScreen(t){const r=this.sessionMode==="single_session"?"single_session":t.id;let i=this.clients.get(r);return i||(i=new cR({...this.options,sessionMode:this.sessionMode,clientGUID:this.clientGUID}),this.clients.set(r,i)),i.setScreenContext({screenID:t.id,screenName:t.name}),i}}function vR(n){const e=n.getItem(Ef);if(e)return e;const t=Eu().toLowerCase();return n.setItem(Ef,t),t}const bR="serverURL",wR="token",_R="mode",SR="electron";function ay(n=window.location.search,e=window.location.origin){const r=new URLSearchParams(n).get(bR);return r?new URL(r).origin:new URL(e).origin}function ly(n=window.location.search){return new URLSearchParams(n).get(wR)}function cy(n=window.location.search){return new URLSearchParams(n).get(_R)===SR}/**
|
|
44
|
-
* @license
|
|
45
|
-
* Copyright 2017 Google LLC
|
|
46
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
-
*/const qi=globalThis,$f=n=>n,ta=qi.trustedTypes,Af=ta?ta.createPolicy("lit-html",{createHTML:n=>n}):void 0,uy="$lit$",en=`lit$${Math.random().toFixed(9).slice(2)}$`,hy="?"+en,kR=`<${hy}>`,rr=document,Xi=()=>rr.createComment(""),Qi=n=>n===null||typeof n!="object"&&typeof n!="function",Nu=Array.isArray,ER=n=>Nu(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",Ll=`[
|
|
48
|
-
\f\r]`,$i=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,xf=/-->/g,Tf=/>/g,An=RegExp(`>|${Ll}(?:([^\\s"'>=/]+)(${Ll}*=${Ll}*(?:[^
|
|
49
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),Cf=/'/g,If=/"/g,dy=/^(?:script|style|textarea|title)$/i,$R=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),F=$R(1),ti=Symbol.for("lit-noChange"),oe=Symbol.for("lit-nothing"),Pf=new WeakMap,Ln=rr.createTreeWalker(rr,129);function fy(n,e){if(!Nu(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return Af!==void 0?Af.createHTML(e):e}const AR=(n,e)=>{const t=n.length-1,r=[];let i,s=e===2?"<svg>":e===3?"<math>":"",o=$i;for(let a=0;a<t;a++){const l=n[a];let u,d,f=-1,v=0;for(;v<l.length&&(o.lastIndex=v,d=o.exec(l),d!==null);)v=o.lastIndex,o===$i?d[1]==="!--"?o=xf:d[1]!==void 0?o=Tf:d[2]!==void 0?(dy.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=An):d[3]!==void 0&&(o=An):o===An?d[0]===">"?(o=i??$i,f=-1):d[1]===void 0?f=-2:(f=o.lastIndex-d[2].length,u=d[1],o=d[3]===void 0?An:d[3]==='"'?If:Cf):o===If||o===Cf?o=An:o===xf||o===Tf?o=$i:(o=An,i=void 0);const y=o===An&&n[a+1].startsWith("/>")?" ":"";s+=o===$i?l+kR:f>=0?(r.push(u),l.slice(0,f)+uy+l.slice(f)+en+y):l+en+(f===-2?a:y)}return[fy(n,s+(n[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class es{constructor({strings:e,_$litType$:t},r){let i;this.parts=[];let s=0,o=0;const a=e.length-1,l=this.parts,[u,d]=AR(e,t);if(this.el=es.createElement(u,r),Ln.currentNode=this.el.content,t===2||t===3){const f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(i=Ln.nextNode())!==null&&l.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const f of i.getAttributeNames())if(f.endsWith(uy)){const v=d[o++],y=i.getAttribute(f).split(en),A=/([.?@])?(.*)/.exec(v);l.push({type:1,index:s,name:A[2],strings:y,ctor:A[1]==="."?TR:A[1]==="?"?CR:A[1]==="@"?IR:Za}),i.removeAttribute(f)}else f.startsWith(en)&&(l.push({type:6,index:s}),i.removeAttribute(f));if(dy.test(i.tagName)){const f=i.textContent.split(en),v=f.length-1;if(v>0){i.textContent=ta?ta.emptyScript:"";for(let y=0;y<v;y++)i.append(f[y],Xi()),Ln.nextNode(),l.push({type:2,index:++s});i.append(f[v],Xi())}}}else if(i.nodeType===8)if(i.data===hy)l.push({type:2,index:s});else{let f=-1;for(;(f=i.data.indexOf(en,f+1))!==-1;)l.push({type:7,index:s}),f+=en.length-1}s++}}static createElement(e,t){const r=rr.createElement("template");return r.innerHTML=e,r}}function ni(n,e,t=n,r){var o,a;if(e===ti)return e;let i=r!==void 0?(o=t._$Co)==null?void 0:o[r]:t._$Cl;const s=Qi(e)?void 0:e._$litDirective$;return(i==null?void 0:i.constructor)!==s&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),s===void 0?i=void 0:(i=new s(n),i._$AT(n,t,r)),r!==void 0?(t._$Co??(t._$Co=[]))[r]=i:t._$Cl=i),i!==void 0&&(e=ni(n,i._$AS(n,e.values),i,r)),e}class xR{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:r}=this._$AD,i=((e==null?void 0:e.creationScope)??rr).importNode(t,!0);Ln.currentNode=i;let s=Ln.nextNode(),o=0,a=0,l=r[0];for(;l!==void 0;){if(o===l.index){let u;l.type===2?u=new Uu(s,s.nextSibling,this,e):l.type===1?u=new l.ctor(s,l.name,l.strings,this,e):l.type===6&&(u=new PR(s,this,e)),this._$AV.push(u),l=r[++a]}o!==(l==null?void 0:l.index)&&(s=Ln.nextNode(),o++)}return Ln.currentNode=rr,i}p(e){let t=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,t),t+=r.strings.length-2):r._$AI(e[t])),t++}}let Uu=class py{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,r,i){this.type=2,this._$AH=oe,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=r,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=ni(this,e,t),Qi(e)?e===oe||e==null||e===""?(this._$AH!==oe&&this._$AR(),this._$AH=oe):e!==this._$AH&&e!==ti&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):ER(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==oe&&Qi(this._$AH)?this._$AA.nextSibling.data=e:this.T(rr.createTextNode(e)),this._$AH=e}$(e){var s;const{values:t,_$litType$:r}=e,i=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=es.createElement(fy(r.h,r.h[0]),this.options)),r);if(((s=this._$AH)==null?void 0:s._$AD)===i)this._$AH.p(t);else{const o=new xR(i,this),a=o.u(this.options);o.p(t),this.T(a),this._$AH=o}}_$AC(e){let t=Pf.get(e.strings);return t===void 0&&Pf.set(e.strings,t=new es(e)),t}k(e){Nu(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let r,i=0;for(const s of e)i===t.length?t.push(r=new py(this.O(Xi()),this.O(Xi()),this,this.options)):r=t[i],r._$AI(s),i++;i<t.length&&(this._$AR(r&&r._$AB.nextSibling,i),t.length=i)}_$AR(e=this._$AA.nextSibling,t){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,t);e!==this._$AB;){const i=$f(e).nextSibling;$f(e).remove(),e=i}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},Za=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,r,i,s){this.type=1,this._$AH=oe,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=s,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=oe}_$AI(e,t=this,r,i){const s=this.strings;let o=!1;if(s===void 0)e=ni(this,e,t,0),o=!Qi(e)||e!==this._$AH&&e!==ti,o&&(this._$AH=e);else{const a=e;let l,u;for(e=s[0],l=0;l<s.length-1;l++)u=ni(this,a[r+l],t,l),u===ti&&(u=this._$AH[l]),o||(o=!Qi(u)||u!==this._$AH[l]),u===oe?e=oe:e!==oe&&(e+=(u??"")+s[l+1]),this._$AH[l]=u}o&&!i&&this.j(e)}j(e){e===oe?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},TR=class extends Za{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===oe?void 0:e}},CR=class extends Za{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==oe)}},IR=class extends Za{constructor(e,t,r,i,s){super(e,t,r,i,s),this.type=5}_$AI(e,t=this){if((e=ni(this,e,t,0)??oe)===ti)return;const r=this._$AH,i=e===oe&&r!==oe||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,s=e!==oe&&(r===oe||i);i&&this.element.removeEventListener(this.name,this,r),s&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}};class PR{constructor(e,t,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){ni(this,e)}}const Ml=qi.litHtmlPolyfillSupport;Ml==null||Ml(es,Uu),(qi.litHtmlVersions??(qi.litHtmlVersions=[])).push("3.3.2");const Pe=(n,e,t)=>{const r=e;let i=r._$litPart$;return i===void 0&&(r._$litPart$=i=new Uu(e.insertBefore(Xi(),null),null,void 0,{})),i._$AI(n),i};/**
|
|
50
|
-
* @license
|
|
51
|
-
* Copyright 2017 Google LLC
|
|
52
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
|
-
*/const gy={CHILD:2},Fu=n=>(...e)=>({_$litDirective$:n,values:e});class my{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,r){this._$Ct=e,this._$AM=t,this._$Ci=r}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}/**
|
|
54
|
-
* @license
|
|
55
|
-
* Copyright 2017 Google LLC
|
|
56
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
57
|
-
*/let na=class extends my{constructor(e){if(super(e),this.it=oe,e.type!==gy.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===oe||e==null)return this._t=void 0,this.it=e;if(e===ti)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};na.directiveName="unsafeHTML",na.resultType=1;const RR=Fu(na);/**
|
|
58
|
-
* @license
|
|
59
|
-
* Copyright 2017 Google LLC
|
|
60
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
-
*/class kc extends na{}kc.directiveName="unsafeSVG",kc.resultType=2;const DR=Fu(kc),OR={size:16,color:"currentColor",weight:"regular"};function zR(n){return typeof n=="string"?{regular:n}:n}function Jt(n,e="0 0 256 256"){const t=zR(n);return r=>{const{size:i,color:s,weight:o}={...OR,...r},a=t[o]??t.regular;return F`<svg
|
|
62
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
63
|
-
data-ui-icon=""
|
|
64
|
-
width="${i}"
|
|
65
|
-
height="${i}"
|
|
66
|
-
viewBox="${e}"
|
|
67
|
-
fill="${s}"
|
|
68
|
-
>${DR(a)}</svg>`}}const LR=Jt('<path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" d="M200 224H56C53.8783 224 51.8434 223.157 50.3431 221.657C48.8429 220.157 48 218.122 48 216V40C48 37.8783 48.8429 35.8434 50.3431 34.3431C51.8434 32.8429 53.8783 32 56 32H152L208 88V216C208 218.122 207.157 220.157 205.657 221.657C204.157 223.157 202.122 224 200 224Z"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" d="M152 32V88H208"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" d="M80 88H124.5"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" d="M80 128H175"/><path fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" d="M80 169H175"/>'),yy=Jt('<path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"/>'),MR=Jt('<path d="M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z"/>'),vy=Jt('<path d="M213.66,93.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,82.34L128,156.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"/>'),NR=Jt('<path d="M213.66,162.34l-80-80a8,8,0,0,0-11.32,0l-80,80A8,8,0,0,0,53.66,173.66L128,99.31l74.34,74.35a8,8,0,0,0,11.32-11.32Z"/>'),UR=Jt('<path d="M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"/>'),FR=Jt({regular:'<path d="M219.31,108.68l-80-80a16,16,0,0,0-22.62,0l-80,80A15.87,15.87,0,0,0,32,120v96a8,8,0,0,0,8,8h64a8,8,0,0,0,8-8V160h32v56a8,8,0,0,0,8,8h64a8,8,0,0,0,8-8V120A15.87,15.87,0,0,0,219.31,108.68ZM208,208H160V152a8,8,0,0,0-8-8H104a8,8,0,0,0-8,8v56H48V120l80-80,80,80Z"/>',bold:'<path d="M222.14,105.85l-80-80a20,20,0,0,0-28.28,0l-80,80A19.86,19.86,0,0,0,28,120v96a12,12,0,0,0,12,12h64a12,12,0,0,0,12-12V164h24v52a12,12,0,0,0,12,12h64a12,12,0,0,0,12-12V120A19.86,19.86,0,0,0,222.14,105.85ZM204,204H164V152a12,12,0,0,0-12-12H104a12,12,0,0,0-12,12v52H52V121.65l76-76,76,76Z"/>',fill:'<path d="M224,120v96a8,8,0,0,1-8,8H160a8,8,0,0,1-8-8V164a4,4,0,0,0-4-4H108a4,4,0,0,0-4,4v52a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V120a16,16,0,0,1,4.69-11.31l80-80a16,16,0,0,1,22.62,0l80,80A16,16,0,0,1,224,120Z"/>'}),ZR=Jt({regular:'<path d="M227.31,73.37,182.63,28.68a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H92.69A15.86,15.86,0,0,0,104,219.31L227.31,96a16,16,0,0,0,0-22.63ZM51.31,160,136,75.31,152.69,92,68,176.68ZM48,179.31,76.69,208H48Zm48,25.38L79.31,188,164,103.31,180.69,120Zm96-96L147.31,64l24-24L216,84.68Z"/>',bold:'<path d="M230.14,70.54,185.46,25.85a20,20,0,0,0-28.29,0L33.86,149.17A19.85,19.85,0,0,0,28,163.31V208a20,20,0,0,0,20,20H92.69a19.86,19.86,0,0,0,14.14-5.86L230.14,98.82a20,20,0,0,0,0-28.28ZM93,180l71-71,11,11-71,71ZM76,163,65,152l71-71,11,11ZM52,173l15.51,15.51h0L83,204H52ZM192,103,153,64l18.34-18.34,39,39Z"/>'}),HR=Jt({regular:'<path d="M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z"/>',bold:'<path d="M216,44H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v4H40a12,12,0,0,0,0,24h4V208a20,20,0,0,0,20,20H192a20,20,0,0,0,20-20V68h4a12,12,0,0,0,0-24ZM104,40h48v4H104Zm84,164H68V68H188Zm-84-48V120a12,12,0,0,1,24,0v36a12,12,0,0,1-24,0Zm40,0V120a12,12,0,0,1,24,0v36a12,12,0,0,1-24,0Z"/>'});class by extends Event{constructor(t){super("dropdown-item-select",{bubbles:!0,composed:!0});b(this,"value");this.value=t}}class VR extends Event{constructor(t){super("select",{bubbles:!0,composed:!0});b(this,"value");this.value=t}}var Ye,ut,cn,Nr,te,ps,z,_y,Mi,Sy,ky,Ec,Ey,Ni,Cn,Gn,gs,ms,ys,ha,$y,Ay,$c,Ui,xy,Ac,Ot;class wy extends HTMLElement{constructor(){super();S(this,z);S(this,Ye,!1);S(this,ut,null);S(this,cn,null);S(this,Nr);S(this,te,null);S(this,ps,new MutationObserver(t=>m(this,z,$y).call(this,t)));S(this,Gn,()=>{m(this,z,Ni).call(this,!c(this,Ye))});S(this,gs,t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),c(this,Gn).call(this))});S(this,ms,t=>{c(this,Ye)&&(t.composedPath().includes(this)||m(this,z,Ni).call(this,!1))});S(this,ys,t=>{t instanceof by&&(t.stopPropagation(),E(this,Ye,!1),m(this,z,Mi).call(this,t.value),m(this,z,Ot).call(this),this.dispatchEvent(new VR(t.value)))});S(this,ha,()=>{m(this,z,$c).call(this)});E(this,Nr,this.attachShadow({mode:"open"}))}connectedCallback(){this.addEventListener("dropdown-item-select",c(this,ys)),document.addEventListener("click",c(this,ms),!0),m(this,z,_y).call(this),c(this,ps).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),m(this,z,Ot).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",c(this,ys)),document.removeEventListener("click",c(this,ms),!0),c(this,ps).disconnect(),m(this,z,Ac).call(this)}attributeChangedCallback(t){if(t==="open"){m(this,z,Ni).call(this,this.hasAttribute("open"));return}m(this,z,Ot).call(this)}get open(){return c(this,Ye)}set open(t){this.toggleAttribute("open",t)}get title(){return this.getAttribute("title")??""}get placement(){return this.getAttribute("placement")==="top"?"top":"bottom"}get value(){return c(this,ut)}set value(t){t===null?(m(this,z,Cn).call(this,null,null),m(this,z,Sy).call(this)):m(this,z,Mi).call(this,t),m(this,z,Ot).call(this)}close(){m(this,z,Ni).call(this,!1)}}Ye=new WeakMap,ut=new WeakMap,cn=new WeakMap,Nr=new WeakMap,te=new WeakMap,ps=new WeakMap,z=new WeakSet,_y=function(){var r;const t=this.querySelector("dropdown-item[selected]");t&&m(this,z,Cn).call(this,t.value,((r=t.textContent)==null?void 0:r.trim())??null)},Mi=function(t){var r;for(const i of c(this,z,Ec))i.value===t?(m(this,z,Cn).call(this,t,((r=i.textContent)==null?void 0:r.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},Sy=function(){const t=this.querySelectorAll("dropdown-item[selected]");for(const r of t)r.removeAttribute("selected")},ky=function(t){for(const r of c(this,z,Ec))if(r.value===t)return r;return null},Ec=function(){return this.querySelectorAll("dropdown-item")},Ey=function(){return c(this,cn)??this.title},Ni=function(t){c(this,Ye)!==t&&(E(this,Ye,t),m(this,z,Ot).call(this))},Cn=function(t,r){E(this,ut,t),E(this,cn,r)},Gn=new WeakMap,gs=new WeakMap,ms=new WeakMap,ys=new WeakMap,ha=new WeakMap,$y=function(t){t.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||m(this,z,Ay).call(this)},Ay=function(){var r,i;const t=this.querySelector("dropdown-item[selected]");if(t){const s=t.value,o=((r=t.textContent)==null?void 0:r.trim())??null,a=c(this,ut)!==s||c(this,cn)!==o;m(this,z,Cn).call(this,s,o),m(this,z,Mi).call(this,s),a?m(this,z,Ot).call(this):m(this,z,Ui).call(this);return}if(c(this,ut)!==null){const s=m(this,z,ky).call(this,c(this,ut));if(s){const o=((i=s.textContent)==null?void 0:i.trim())??null,a=c(this,cn)!==o;m(this,z,Cn).call(this,c(this,ut),o),m(this,z,Mi).call(this,c(this,ut)),a?m(this,z,Ot).call(this):m(this,z,Ui).call(this);return}}if(c(this,ut)!==null||c(this,cn)!==null){m(this,z,Cn).call(this,null,null),m(this,z,Ot).call(this);return}m(this,z,Ui).call(this)},$c=function(){const t=c(this,Nr).querySelector('slot[name="trigger"]'),r=t instanceof HTMLSlotElement?t.assignedElements()[0]??null:null;c(this,te)!==r&&(m(this,z,Ac).call(this),E(this,te,r),c(this,te)&&(c(this,te).addEventListener("click",c(this,Gn)),c(this,te)instanceof HTMLButtonElement?c(this,te).hasAttribute("type")||(c(this,te).type="button"):(c(this,te).hasAttribute("role")||c(this,te).setAttribute("role","button"),c(this,te).hasAttribute("tabindex")||(c(this,te).tabIndex=0),c(this,te).addEventListener("keydown",c(this,gs))))),m(this,z,Ui).call(this)},Ui=function(){c(this,te)&&(c(this,te).setAttribute("data-dropdown-trigger",""),c(this,te).setAttribute("aria-haspopup","listbox"),c(this,te).setAttribute("aria-expanded",c(this,Ye)?"true":"false"))},xy=function(){return this.placement==="top"?NR:vy},Ac=function(){c(this,te)&&(c(this,te).removeEventListener("click",c(this,Gn)),c(this,te).removeEventListener("keydown",c(this,gs)),c(this,te).removeAttribute("data-dropdown-trigger"),c(this,te).removeAttribute("aria-haspopup"),c(this,te).removeAttribute("aria-expanded"),E(this,te,null))},Ot=function(){this.toggleAttribute("open",c(this,Ye)),Pe(F`
|
|
69
|
-
<slot name="trigger" @slotchange=${c(this,ha)}>
|
|
70
|
-
<button
|
|
71
|
-
class="fallback-trigger"
|
|
72
|
-
part="trigger"
|
|
73
|
-
type="button"
|
|
74
|
-
aria-haspopup="listbox"
|
|
75
|
-
aria-expanded=${c(this,Ye)?"true":"false"}
|
|
76
|
-
@click=${c(this,Gn)}
|
|
77
|
-
>
|
|
78
|
-
<span class="trigger-label" part="trigger-label">${c(this,z,Ey)}</span>
|
|
79
|
-
<span class="trigger-icon" part="trigger-icon" aria-hidden="true">
|
|
80
|
-
${c(this,z,xy).call(this,{size:16})}
|
|
81
|
-
</span>
|
|
82
|
-
</button>
|
|
83
|
-
</slot>
|
|
84
|
-
${c(this,Ye)?F`
|
|
85
|
-
<div
|
|
86
|
-
class="panel"
|
|
87
|
-
part="panel panel-${this.placement}"
|
|
88
|
-
role="listbox"
|
|
89
|
-
>
|
|
90
|
-
<slot></slot>
|
|
91
|
-
</div>
|
|
92
|
-
`:null}
|
|
93
|
-
`,c(this,Nr)),queueMicrotask(()=>m(this,z,$c).call(this))},b(wy,"observedAttributes",["title","placement","open"]);class jR extends HTMLElement{}class GR extends HTMLElement{}class BR extends HTMLElement{}var or,xc,Cy,vs,bs;class Ty extends HTMLElement{constructor(){super(...arguments);S(this,or);S(this,vs,()=>{this.action||m(this,or,Cy).call(this)});S(this,bs,t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",c(this,vs)),this.addEventListener("keydown",c(this,bs)),m(this,or,xc).call(this)}disconnectedCallback(){this.removeEventListener("click",c(this,vs)),this.removeEventListener("keydown",c(this,bs))}attributeChangedCallback(){m(this,or,xc).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}or=new WeakSet,xc=function(){if(this.action){this.setAttribute("role","button"),this.removeAttribute("aria-selected");return}this.setAttribute("role","option"),this.setAttribute("aria-selected",this.selected?"true":"false")},Cy=function(){this.dispatchEvent(new by(this.value))},vs=new WeakMap,bs=new WeakMap,b(Ty,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",wy);customElements.get("dropdown-group")||customElements.define("dropdown-group",jR);customElements.get("dropdown-label")||customElements.define("dropdown-label",GR);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",BR);customElements.get("dropdown-item")||customElements.define("dropdown-item",Ty);class WR extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var ws,yn,Tc,da,_s,Cc;class Iy extends HTMLElement{constructor(){super();S(this,yn);S(this,ws);S(this,da,t=>{t.target===t.currentTarget&&m(this,yn,Tc).call(this)});S(this,_s,t=>{this.open&&t.key==="Escape"&&m(this,yn,Tc).call(this)});E(this,ws,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",c(this,_s)),m(this,yn,Cc).call(this)}disconnectedCallback(){document.removeEventListener("keydown",c(this,_s))}attributeChangedCallback(){m(this,yn,Cc).call(this)}get open(){return this.hasAttribute("open")}}ws=new WeakMap,yn=new WeakSet,Tc=function(){this.dispatchEvent(new WR)},da=new WeakMap,_s=new WeakMap,Cc=function(){Pe(F`
|
|
94
|
-
${this.open?F`
|
|
95
|
-
<div class="backdrop" part="backdrop" @click=${c(this,da)}>
|
|
96
|
-
<slot></slot>
|
|
97
|
-
</div>
|
|
98
|
-
`:null}
|
|
99
|
-
`,c(this,ws))},b(Iy,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",Iy);class qR extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class YR extends HTMLElement{}var Ss,ks,Ic;class Py extends HTMLElement{constructor(){super();S(this,ks);S(this,Ss);E(this,Ss,this.attachShadow({mode:"open"}))}connectedCallback(){m(this,ks,Ic).call(this)}attributeChangedCallback(){m(this,ks,Ic).call(this)}get closable(){return this.hasAttribute("closable")}}Ss=new WeakMap,ks=new WeakSet,Ic=function(){const t=this.querySelector("panel-page");Pe(F`
|
|
100
|
-
<section class="panel" part="panel">
|
|
101
|
-
<header class="title-bar" part="header">
|
|
102
|
-
<h2 class="title" part="title">${(t==null?void 0:t.getAttribute("title"))??""}</h2>
|
|
103
|
-
${this.closable?F`
|
|
104
|
-
<button
|
|
105
|
-
type="button"
|
|
106
|
-
class="title-button"
|
|
107
|
-
part="button close-button"
|
|
108
|
-
aria-label="Close"
|
|
109
|
-
@click=${()=>this.dispatchEvent(new qR)}
|
|
110
|
-
>
|
|
111
|
-
<span class="close-icon" part="icon close-icon">${yy({size:16})}</span>
|
|
112
|
-
</button>
|
|
113
|
-
`:null}
|
|
114
|
-
</header>
|
|
115
|
-
<slot></slot>
|
|
116
|
-
</section>
|
|
117
|
-
`,c(this,Ss))},b(Py,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",Py);customElements.get("panel-page")||customElements.define("panel-page",YR);class KR extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const Rf='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Nl=4;var Ve,Vt,Ur,Qe,Es,Fr,ne,Dy,Oy,Pc,$s,As,Bn,zy,Rc,Ly,My,No,Uo;class Ry extends HTMLElement{constructor(){super();S(this,ne);S(this,Ve,!1);S(this,Vt,null);S(this,Ur);S(this,Qe,null);S(this,Es,"bottom-start");S(this,Fr,!1);S(this,$s,t=>{c(this,Ve)&&(c(this,Fr)||t.composedPath().includes(this)||(this.open=!1))});S(this,As,t=>{if(c(this,Ve)){if(t.key==="Escape"){t.preventDefault(),this.open=!1;return}t.key==="Tab"&&m(this,ne,zy).call(this,t)}});S(this,Bn,()=>{c(this,Ve)&&m(this,ne,No).call(this)});E(this,Ur,this.attachShadow({mode:"open"}))}connectedCallback(){m(this,ne,Uo).call(this)}disconnectedCallback(){m(this,ne,Pc).call(this)}attributeChangedCallback(t){t==="open"&&m(this,ne,Dy).call(this,this.hasAttribute("open"))}get open(){return c(this,Ve)}set open(t){this.toggleAttribute("open",t)}get anchor(){return c(this,Vt)}set anchor(t){c(this,Vt)!==t&&(E(this,Vt,t),c(this,Ve)&&m(this,ne,No).call(this))}}Ve=new WeakMap,Vt=new WeakMap,Ur=new WeakMap,Qe=new WeakMap,Es=new WeakMap,Fr=new WeakMap,ne=new WeakSet,Dy=function(t){var r;c(this,Ve)!==t&&(E(this,Ve,t),t?(E(this,Fr,!0),setTimeout(()=>{E(this,Fr,!1)},0),m(this,ne,Uo).call(this),m(this,ne,Oy).call(this),queueMicrotask(()=>{c(this,Ve)&&(m(this,ne,No).call(this),m(this,ne,My).call(this))})):(m(this,ne,Pc).call(this),m(this,ne,Uo).call(this),(r=c(this,Vt))==null||r.focus(),this.dispatchEvent(new KR)))},Oy=function(){document.addEventListener("click",c(this,$s)),document.addEventListener("keydown",c(this,As),!0),window.addEventListener("resize",c(this,Bn)),window.addEventListener("scroll",c(this,Bn),!0)},Pc=function(){document.removeEventListener("click",c(this,$s)),document.removeEventListener("keydown",c(this,As),!0),window.removeEventListener("resize",c(this,Bn)),window.removeEventListener("scroll",c(this,Bn),!0)},$s=new WeakMap,As=new WeakMap,Bn=new WeakMap,zy=function(t){const r=m(this,ne,Rc).call(this);if(r.length===0){t.preventDefault();return}const i=r[0],s=r[r.length-1],o=m(this,ne,Ly).call(this),a=o instanceof HTMLElement&&r.includes(o);t.shiftKey?(!a||o===i)&&(t.preventDefault(),s.focus()):(!a||o===s)&&(t.preventDefault(),i.focus())},Rc=function(){if(!c(this,Qe))return[];const t=c(this,Qe).querySelector("slot");if(!(t instanceof HTMLSlotElement))return[];const r=[];for(const i of t.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches(Rf)&&r.push(i);for(const s of i.querySelectorAll(Rf))r.push(s)}return r},Ly=function(){var r;let t=document.activeElement;for(;t&&((r=t.shadowRoot)!=null&&r.activeElement);)t=t.shadowRoot.activeElement;return t},My=function(){var r;const t=m(this,ne,Rc).call(this);t.length>0?t[0].focus():(r=c(this,Qe))==null||r.focus()},No=function(){if(!c(this,Ve)||!c(this,Vt)||!c(this,Qe))return;const t=c(this,Vt).getBoundingClientRect(),r=c(this,Qe).getBoundingClientRect(),s=window.innerHeight-t.bottom,o=r.height+Nl,a=s<o&&t.top>o?"top-start":"bottom-start";E(this,Es,a);const l=a==="bottom-start"?t.bottom+Nl:t.top-r.height-Nl,u=t.left;c(this,Qe).style.top=`${l}px`,c(this,Qe).style.left=`${u}px`,c(this,Qe).setAttribute("data-placement",a)},Uo=function(){this.toggleAttribute("open",c(this,Ve)),Pe(c(this,Ve)?F`<div
|
|
118
|
-
class="panel"
|
|
119
|
-
part="panel"
|
|
120
|
-
data-placement=${c(this,Es)}
|
|
121
|
-
tabindex="-1"
|
|
122
|
-
role="dialog"
|
|
123
|
-
>
|
|
124
|
-
<slot></slot>
|
|
125
|
-
</div>`:oe,c(this,Ur)),E(this,Qe,c(this,Ur).querySelector(".panel"))},b(Ry,"observedAttributes",["open"]);customElements.get("ui-popover")||customElements.define("ui-popover",Ry);const JR=xt(),XR="No handler registered for update-content",QR="handleUpdateContent: handler already registered";function eD(n){return n instanceof Error&&typeof n.message=="string"?n.message:String(n)}const tD=di(Tt);var Zr,Hr,Vr,Wn,qn,xs,Ce,Dc,Ny,Uy,Fi,Oc,cp;let nD=(cp=class extends tD{constructor(t){super();S(this,Ce);S(this,Zr);S(this,Hr);S(this,Vr);S(this,Wn,null);S(this,qn,null);S(this,xs,!1);E(this,Zr,t);const r=t.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");E(this,Hr,r),E(this,Vr,i=>m(this,Ce,Ny).call(this,i)),c(this,Hr).addEventListener("message",c(this,Vr))}get content(){return c(this,qn)}set content(t){m(this,Ce,Oc).call(this),E(this,qn,t),c(this,xs)&&m(this,Ce,Dc).call(this,t)}handleUpdateContent(t){if(m(this,Ce,Oc).call(this),c(this,Wn)!==null)throw new Error(QR);E(this,Wn,t)}dispose(){c(this,Hr).removeEventListener("message",c(this,Vr)),E(this,Wn,null)}},Zr=new WeakMap,Hr=new WeakMap,Vr=new WeakMap,Wn=new WeakMap,qn=new WeakMap,xs=new WeakMap,Ce=new WeakSet,Dc=function(t){const r={type:"content-updated",content:t};m(this,Ce,Fi).call(this,r)},Ny=function(t){if(this.disposed||t.source!==c(this,Zr).contentWindow)return;const r=t.data;if(AC(r)){E(this,xs,!0),this.dispatchEvent(new JR("ready")),c(this,qn)!==null&&m(this,Ce,Dc).call(this,c(this,qn));return}if(xC(r)){m(this,Ce,Uy).call(this,r);return}},Uy=async function(t){const r=c(this,Wn);if(r===null){m(this,Ce,Fi).call(this,{type:"response",id:t.id,error:{message:XR}});return}try{await r(t.content)}catch(i){if(this.disposed)return;m(this,Ce,Fi).call(this,{type:"response",id:t.id,error:{message:eD(i)}});return}this.disposed||m(this,Ce,Fi).call(this,{type:"response",id:t.id,result:{}})},Fi=function(t){const r=c(this,Zr).contentWindow;r&&r.postMessage(t,"*")},Oc=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},cp);function rD(n=window){n.parent!==n&&(n.addEventListener("wheel",e=>{const t=e;n.parent.postMessage({type:"wheel",deltaX:t.deltaX,deltaY:t.deltaY,shiftKey:t.shiftKey},"*"),t.preventDefault()},{passive:!1}),n.addEventListener("message",e=>{const t=e.data;if(t!==null&&typeof t=="object"&&t.type==="scroll"){const r=t,i=typeof r.deltaX=="number"?r.deltaX:0,s=typeof r.deltaY=="number"?r.deltaY:0;n.scrollBy(i,s)}}))}function iD(){return`(${rD.toString()})(window);`}async function sD(n){const e=await fetch(n);if(!e.ok)throw new Error(`Failed to fetch artifact content: ${e.status}`);const t=await e.text(),r=new DOMParser().parseFromString(t,"text/html"),i=r.createElement("base");i.href=n,r.head.insertBefore(i,r.head.firstChild);const s=r.createElement("script");s.textContent=iD(),r.head.appendChild(s);const o=new Blob([`<!DOCTYPE html>
|
|
126
|
-
${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const Fy=xt();class oD extends HTMLElement{constructor(){super(...arguments);b(this,"_artifact",null);b(this,"_viewURL",null);b(this,"_contentURL",null);b(this,"_screen",null);b(this,"_subscribedScreen",null);b(this,"_activeView",null);b(this,"_contentState",{kind:"idle"});b(this,"_fetchSequence",0);b(this,"_blobSequence",0);b(this,"_mountedViewURL",null);b(this,"_directRender",!1);b(this,"_blobURL",null);b(this,"handleScreenContentChanged",t=>{!this._artifact||t.artifactID!==this._artifact.id||this._activeView!==null&&this.refetchContent()})}set artifact(t){const r=this._artifact;this._artifact=t,this.render(),r!==null&&r!==t&&this.syncView()}get artifact(){return this._artifact}set viewURL(t){this._viewURL!==t&&(this._viewURL=t,this.syncView())}get viewURL(){return this._viewURL}set contentURL(t){this._contentURL!==t&&(this._contentURL=t,this.syncView())}get contentURL(){return this._contentURL}set screen(t){this._screen!==t&&(this._screen=t,this.syncScreenSubscription())}get screen(){return this._screen}set dragging(t){t?this.setAttribute("dragging","true"):this.removeAttribute("dragging")}get dragging(){return this.getAttribute("dragging")==="true"}get activeView(){return this._activeView}connectedCallback(){this.render(),this.syncView(),this.syncScreenSubscription()}disconnectedCallback(){this.teardownView(),this.unsubscribeFromScreen()}handleClose(){this._artifact&&this.dispatchEvent(new Fy("close-artifact",{artifactID:this._artifact.id,bubbles:!0,composed:!0}))}syncView(){var t;if(this.isConnected){if(this._viewURL!==null){if(this._directRender&&this.teardownView(),this._mountedViewURL!==this._viewURL){this.teardownView(),this._contentState={kind:"loading"},this._mountedViewURL=this._viewURL,this.render();const r=this.querySelector("iframe.artifact-frame");if(!r){this._contentState={kind:"error"},this.render();return}this._activeView=new nD(r),this._activeView.handleUpdateContent(async i=>{await this.saveContent(i)}),this.loadBlobFrame(this._viewURL),this.startContentFetch();return}this._activeView!==null&&this.startContentFetch();return}if(this._contentURL!==null){this.teardownView(),this._directRender=!0,this._contentState={kind:"idle"},this.render(),((t=this._artifact)==null?void 0:t.status)==="committed"&&this.loadBlobFrame(this._contentURL);return}this.teardownView(),this._contentState={kind:"idle"},this.render()}}async saveContent(t){const r=this._screen,i=this._artifact;if(!r||!i)throw new Error("artifact-view: cannot save without a screen and artifact");await r.server.client.artifacts.putContent({artifactID:i.id,content:t})}syncScreenSubscription(){if(!this.isConnected){this.unsubscribeFromScreen();return}this._subscribedScreen!==this._screen&&(this.unsubscribeFromScreen(),this._screen!==null&&(this._screen.addEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=this._screen))}unsubscribeFromScreen(){this._subscribedScreen!==null&&(this._subscribedScreen.removeEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=null)}startContentFetch(){this._fetchSequence+=1;const t=this._fetchSequence,r=this._contentURL,i=this._activeView;if(!i||r===null){this._contentState={kind:"error"},this.render();return}this._contentState={kind:"loading"},(async()=>{try{const s=await fetch(r);if(t!==this._fetchSequence)return;if(!s.ok){this._contentState={kind:"error"},this.teardownView(),this.render();return}const o=await s.text();if(t!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o,this._contentState={kind:"ready"}}catch{if(t!==this._fetchSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}refetchContent(){this._fetchSequence+=1;const t=this._fetchSequence,r=this._contentURL,i=this._activeView;!i||r===null||(async()=>{try{const s=await fetch(r);if(t!==this._fetchSequence||!s.ok)return;const o=await s.text();if(t!==this._fetchSequence||this._activeView!==i)return;this._activeView.content=o}catch{}})()}loadBlobFrame(t){this._blobSequence+=1;const r=this._blobSequence;(async()=>{try{const i=await sD(t);if(r!==this._blobSequence){URL.revokeObjectURL(i);return}this._blobURL=i,this.render();const s=this.querySelector("iframe.artifact-frame");s&&(s.src=i)}catch{if(r!==this._blobSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}teardownView(){this._activeView!==null&&(this._activeView.dispose(),this._activeView=null),this._blobURL!==null&&(URL.revokeObjectURL(this._blobURL),this._blobURL=null),this._mountedViewURL=null,this._directRender=!1,this._fetchSequence+=1,this._blobSequence+=1}contentTemplate(){return this._contentState.kind==="error"?F`
|
|
127
|
-
<div class="artifact-content artifact-placeholder">
|
|
128
|
-
<em>Failed to load content</em>
|
|
129
|
-
</div>
|
|
130
|
-
`:this._viewURL!==null||this._directRender?F`
|
|
131
|
-
<iframe
|
|
132
|
-
class="artifact-frame artifact-content"
|
|
133
|
-
src=${this._blobURL??"about:blank"}
|
|
134
|
-
sandbox="allow-scripts"
|
|
135
|
-
></iframe>
|
|
136
|
-
`:F`
|
|
137
|
-
<div class="artifact-content artifact-placeholder">
|
|
138
|
-
<em>Artifact unavailable</em>
|
|
139
|
-
</div>
|
|
140
|
-
`}template(){const t=this._artifact;return F`
|
|
141
|
-
${this.contentTemplate()}
|
|
142
|
-
<footer class="artifact-title-bar" drag-handle>
|
|
143
|
-
<div class="artifact-title-group">
|
|
144
|
-
<span class="artifact-title-icon">${LR({size:16})}</span>
|
|
145
|
-
<span class="artifact-title">${t.title}</span>
|
|
146
|
-
</div>
|
|
147
|
-
<button
|
|
148
|
-
icon-only
|
|
149
|
-
class="artifact-close-btn"
|
|
150
|
-
@click=${()=>this.handleClose()}
|
|
151
|
-
aria-label="Close"
|
|
152
|
-
>
|
|
153
|
-
${yy({size:16})}
|
|
154
|
-
</button>
|
|
155
|
-
</footer>
|
|
156
|
-
`}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),Pe(this.template(),this))}}customElements.define("artifact-view",oD);const ke=n=>({type:"px",...n}),Te=n=>({type:"unit",...n}),wo=2,aD=2;class lD{constructor(e){b(this,"basis");b(this,"min");b(this,"_gap");b(this,"_viewport");b(this,"_unit");this.basis=e.basis,this.min=e.min,this._viewport=e.viewport,this._gap=e.gap??ke({x:pe,y:pe});const t=this._viewport.x??tr,r=this._viewport.y??Yo,i=this._gap.x??pe,s=this._gap.y??pe,o=tr+i*aD,a=t<=o,l=a?t-i*wo:Math.min(tr,t-i*wo),u=a?r-s*wo:Math.min(Yo,r-s*wo),d=(l-i*(At-1))/At,f=(u-s*(Je-1))/Je,v=this.basis.x??0,y=this.basis.y??0,A=this.min.x??0,k=this.min.y??0;this._unit=ke(a?{x:Math.max(A,d),y:Math.max(k,f)}:{x:Math.max(A,Math.min(v,d)),y:Math.max(k,Math.min(y,f))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(e){return Te({x:e.x==null?void 0:e.x/(this._unit.x??1),y:e.y==null?void 0:e.y/(this._unit.y??1)})}toPixels(e){const t=this._unit.x??0,r=this._unit.y??0,i=this._gap.x??pe,s=this._gap.y??pe,o=e.x==null?void 0:e.x*t+Math.max(0,e.x-1)*i,a=e.y==null?void 0:e.y*r+Math.max(0,e.y-1)*s;return ke({x:o,y:a})}}const ir=1e-4,Gt=1e-6,cD=40,uD=24;function Zy(n,e){return Math.max(0,n-e*2)}function Hy(n){const e=[0];for(const t of n)e.push((e[e.length-1]??0)+t);return e}function Vy(n){const e=[0];for(let t=0;t<n.length;t+=1){const r=e[t]??0;e.push(r+n[t]+pe)}return e}function jy(n,e,t){if(e<0||e>=n.length)return 0;let r=0,i=0;for(let s=e;s<n.length;s+=1){const o=n[s],a=i===0?o:r+pe+o;if(a>t+ir)break;r=a,i+=1}return Math.max(1,i)}function hD(n,e,t){if(e<0||e>=n.length)return 0;let r=0,i=0;for(let s=e;s>=0;s-=1){const o=n[s],a=i===0?o:r+pe+o;if(a>t+ir)break;r=a,i+=1}return Math.max(1,i)}function dD(n,e){if(n.length===0)return 0;let t=0,r=0;for(let i=n.length-1;i>=0;i-=1){const s=n[i],o=r===0?s:t+pe+s;if(o>e+ir)break;t=o,r+=1}return Math.max(1,r)}function Zu(n,e){if(n.length===0)return 0;const t=dD(n,e);return Math.max(0,n.length-t)}function Df(n,e,t){if(n.length===0)return 0;const r=jy(n,e,t),i=Math.min(n.length,e+r);if(i<=e)return 0;const s=n.slice(e,i);return s.reduce((o,a)=>o+a,0)+Math.max(0,s.length-1)*pe}function zc(n,e,t){const r=n[e]??0;return t-r}function xr(n,e,t,r,i){if(n.length===0)return 0;const s=Zu(n,i),o=e[s]??0,a=Math.max(0,Math.min(o,t));let l=0;for(let Z=0;Z<s;Z+=1){const U=e[Z]??0,ge=e[Z+1]??U;if(a>=U&&a<=ge+ir){l=Z;break}l=Z+1}const u=Math.min(l+1,s),d=e[l]??0,f=e[u]??d,v=Math.max(f-d,ir),y=u===l?0:(a-d)/v,A=Vy(n),k=Df(n,l,i),I=Df(n,u,i),G=(r-k)/2,P=(r-I)/2,le=zc(A,l,G),M=zc(A,u,P);return le+(M-le)*y}function Of(n,e,t,r,i){const s=Zu(n,r),o=e[s]??0;let a=0,l=o;for(let u=0;u<cD;u+=1){const d=(a+l)/2;xr(n,e,d,t,r)>i?a=d:l=d}return(a+l)/2}function zf(n,e,t){const r=Vy(n),[i,s]=e,o=n.slice(i,s+1),a=o.reduce((u,d)=>u+d,0)+Math.max(0,o.length-1)*pe,l=(t-a)/2;return zc(r,i,l)}function fD(n,e,t){const r=jy(n,e,t);return[e,Math.min(n.length-1,e+r-1)]}function pD(n,e,t){const r=hD(n,e,t);return[Math.max(0,e-r+1),e]}function gD(n){const e=new Set,t=[];for(const r of n){const i=`${r.nodeRange[0]}:${r.nodeRange[1]}`;if(e.has(i))continue;const s=t[t.length-1];s&&Math.abs(s.anchor-r.anchor)<=Gt||(e.add(i),t.push(r))}return t}function mD(n){const{nodeCols:e,nodeWidthsPx:t,viewportWidthPx:r}=n;if(e.length===0||t.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const i=n.gapPx??pe,s=Zy(r,i),o=Hy(e),a=Zu(t,s),l=o[a]??0,u=[];for(let d=0;d<=a;d+=1){const f=fD(t,d,s),v=zf(t,f,r),y=Of(t,o,r,s,v);u.push({nodeRange:f,anchor:Math.max(0,Math.min(l,y))})}for(let d=t.length-1;d>=0;d-=1){const f=pD(t,d,s),v=`${f[0]}:${f[1]}`;if(u.some(k=>`${k.nodeRange[0]}:${k.nodeRange[1]}`===v))continue;const y=zf(t,f,r),A=Of(t,o,r,s,y);u.push({nodeRange:f,anchor:Math.max(0,Math.min(l,A))})}return u.sort((d,f)=>Math.abs(d.anchor-f.anchor)>Gt?d.anchor-f.anchor:d.nodeRange[0]!==f.nodeRange[0]?d.nodeRange[0]-f.nodeRange[0]:d.nodeRange[1]-f.nodeRange[1]),{viewspans:gD(u),minScroll:0,maxScroll:l}}function yD(n,e){var i;let t=0,r=Number.POSITIVE_INFINITY;for(let s=0;s<n.length;s+=1){const o=Math.abs((((i=n[s])==null?void 0:i.anchor)??0)-e);if(o+Gt<r){r=o,t=s;continue}Math.abs(o-r)<=Gt&&s<t&&(t=s)}return t}function vD(n,e,t){return t<=0?0:Math.max(0,Math.min(t-1,n+e))}function Ai(n,e,t){return Math.max(e,Math.min(t,n))}class bD extends Tt{constructor(t){super();b(this,"_scroll",0);b(this,"minScroll",0);b(this,"maxScroll",0);b(this,"viewspans",[]);b(this,"activeViewspanIndex",null);b(this,"nodeWidthsPx",[]);b(this,"boundaryCols",[0]);b(this,"viewportWidthPx",0);b(this,"framedViewportWidthPx",0);this._scroll=(t==null?void 0:t.x)??0}get scroll(){return Te({x:this._scroll})}get translate(){return ke({x:xr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx)})}set scroll(t){const r=Ai(t.x??this._scroll,this.minScroll,this.maxScroll);Math.abs(r-this._scroll)<=Gt||(this._scroll=r,this.activeViewspanIndex=null,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}rebuild(t){const r=t.nodeWidths.map(u=>Math.max(0,u.x??0)),i=r.map(u=>t.grid.toPixels(Te({x:u})).x??0),s=t.grid.viewport.x??0,o=t.grid.gap.x??pe,a=mD({nodeCols:r,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this.nodeWidthsPx=i,this.boundaryCols=Hy(r),this.viewportWidthPx=s,this.framedViewportWidthPx=Zy(s,o),this.viewspans=a.viewspans,this.minScroll=a.minScroll,this.maxScroll=a.maxScroll,this.activeViewspanIndex=null;const l=Ai(this._scroll,this.minScroll,this.maxScroll);Math.abs(l-this._scroll)>Gt&&(this._scroll=l,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}step(t){var a;if(this.viewspans.length===0)return;const r=this.activeViewspanIndex??yD(this.viewspans,this._scroll),i=vD(r,t,this.viewspans.length),s=((a=this.viewspans[i])==null?void 0:a.anchor)??this._scroll,o=Ai(s,this.minScroll,this.maxScroll);this.activeViewspanIndex=i,!(Math.abs(o-this._scroll)<=Gt)&&(this._scroll=o,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}wheel(t){const r=Ai(this._scroll+(t.x??0),this.minScroll,this.maxScroll);this.activeViewspanIndex=null,!(Math.abs(r-this._scroll)<=Gt)&&(this._scroll=r,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}wheelPixels(t){const r=t.x??0;if(Math.abs(r)<=ir)return;this.activeViewspanIndex=null;const i=xr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),s=i-r,o=xr(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=xr(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),l=Math.max(o,Math.min(a,s));if(Math.abs(l-i)<=ir)return;let u=this.minScroll,d=this.maxScroll;for(let v=0;v<uD;v+=1){const y=(u+d)/2;xr(this.nodeWidthsPx,this.boundaryCols,y,this.viewportWidthPx,this.framedViewportWidthPx)>l?u=y:d=y}const f=Ai((u+d)/2,this.minScroll,this.maxScroll);Math.abs(f-this._scroll)<=Gt||(this._scroll=f,this.dispatchEvent(new Ei("layout-scroll",{scroll:this.scroll})))}}const Ul={"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}},wD=["stack-above","stack-below","reorder-before","reorder-after"];function Fl(n,e){return{left:n.left+n.width*e.left,top:n.top+n.height*e.top,width:n.width*e.width,height:n.height*e.height}}function xn(n,e,t){return n>=t.left&&n<t.left+t.width&&e>=t.top&&e<t.top+t.height}function Hu(n,e){for(const t of n){if(t.type==="card"&&t.id===e)return t;if(t.type==="stack")for(const r of t.children){if(r.type==="card"&&r.id===e)return r;if(r.type==="row"){for(const i of r.children)if(i.id===e)return i}}}return null}function Lc(n){return n.height===Je||n.height===fn?{...n,height:fn}:n}function Mc(n){return n.height===fn?{...n,height:Je}:n}function _D(n,e,t,r){const i=n.findIndex(d=>d.type==="stack"&&d.id===e);if(i===-1)return n;const s=n[i];if(!s||s.type!=="stack")return n;const o=s.children.find(d=>d.type==="card"&&d.id===t);if(!o||o.type!=="card")return n;const a=s.children.filter(d=>d.id!==t);if(a.length===s.children.length||a.length<1)return n;const l=[...n];if(a.length===1){const[d]=a;l[i]=d.type==="card"?Mc(d):d}else l[i]={...s,children:a};const u=Math.max(0,Math.min(r,l.length));return l.splice(u,0,Mc(o)),l}const SD=xt(),kD=xt(),ED=50;function $D(n,e){if(n.type!==e.type)return!1;switch(n.type){case"reorder":return e.index===n.index;case"stack":return e.targetCardId===n.targetCardId&&e.position===n.position;case"stack-child-noop":return!0;case"stack-child-extract":return e.toIndex===n.toIndex;case"stack-child-reorder":return e.position===n.position;default:return!1}}function Ks(n){return{id:n.id,type:"drop-target",width:n.width,height:n.height}}function Lf(n){return n.map(xD)}function AD(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n}function xD(n){return n.type==="drop-target"?{id:n.id,type:"card",artifactID:n.id,width:n.width,height:n.height}:n.type==="stack"?{...n,children:n.children.map(AD)}:n}function Gy(n,e){return n.find(r=>r.type==="card"&&r.id===e)??null}function Mf(n,e){return n.find(r=>r.type==="stack"&&r.id===e)??null}function TD(n,e){const t=[...e],r=t.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(r===-1)return null;const i=t[r];if(!i||i.type!=="card")return null;t.splice(r,1);const s=Math.max(0,Math.min(n.lastReorderIndex,t.length));t.splice(s,0,i);const o=t.findIndex(a=>a.type==="card"&&a.id===n.nodeId);return o===-1?null:{base:t,visualDraggedIndex:o}}function CD(n,e,t,r){const i=[...n.base];i.splice(n.visualDraggedIndex,1);const s=i.findIndex(v=>v.type==="card"&&v.id===t.targetCardId),o=s===-1?null:i[s];if(!o||o.type!=="card")return null;const a=Gy(r,e.nodeId);if(!a)return null;const l=Lc(a),u=Lc(o),d=Ks(l),f=t.position==="above"?[d,u]:[u,d];return i[s]={id:o.id,type:"stack",children:f},i}function Zl(n,e){return n.parentStackId?PD(n,e):ID(n,e)}function ID(n,e){const t=n.hitTarget;if(t.type==="reorder"){const r=e[n.sourceIndex];if(!r||r.type!=="card")return[...e];const i=[...e];return i.splice(n.sourceIndex,1),i.splice(t.index,0,Ks(r)),i}if(t.type==="stack"){const r=TD(n,e);return r?CD(r,n,t,e)??[...e]:[...e]}return[...e]}function PD(n,e){const t=n.hitTarget;switch(t.type){case"stack-child-reorder":return RD(n,e,t.position);case"stack-child-extract":return DD(n,e,t.toIndex);case"stack-child-noop":return OD(n,e);default:return[...e]}}function RD(n,e,t){const r=e.findIndex(v=>v.type==="stack"&&v.id===n.parentStackId);if(r===-1)return[...e];const i=e[r];if(!i||i.type!=="stack")return[...e];if(!i.children.every(v=>v.type==="card"))return[...e];const s=i.children,o=s.findIndex(v=>v.id===n.nodeId);if(o===-1)return[...e];const a=s[o],l=s.filter(v=>v.id!==n.nodeId),u=Ks(a),d=t==="above"?[u,...l]:[...l,u],f=[...e];return f[r]={...i,children:d},f}function DD(n,e,t){if(!n.parentStackId)return[...e];const r=_D(e,n.parentStackId,n.nodeId,t);if(r===e)return[...e];const i=r.findIndex(a=>a.type==="card"&&a.id===n.nodeId);if(i===-1)return[...e];const s=r[i];if(!s||s.type!=="card")return[...e];const o=[...r];return o[i]=Ks(s),o}function OD(n,e){const t=e.findIndex(l=>l.type==="stack"&&l.id===n.parentStackId);if(t===-1)return[...e];const r=e[t];if(!r||r.type!=="stack")return[...e];const i=r.children.findIndex(l=>l.type==="card"&&l.id===n.nodeId);if(i===-1)return[...e];const s=r.children[i];if(!s||s.type!=="card")return[...e];const o=[...e],a=[...r.children];return a[i]=Ks(s),o[t]={...r,children:a},o}function zD(n,e){return e.find(r=>r.type==="stack"&&r.id===n.id)?n.id:Eu()}function LD(n,e,t){if(n.type==="drop-target"){const r=Hu(e,t);if(!r)throw new Error(`finalize: missing dragged card ${t}`);return Lc(r)}return n}function MD(n,e,t){const r=n.children.map(s=>LD(s,e,t));return{id:zD(n,e),type:"stack",children:r}}function ND(n,e,t){if(n.type==="drop-target"){const r=Hu(e,t);if(!r)throw new Error(`finalize: missing dragged card ${t}`);return Gy(e,t)!==null?r:Mc(r)}return n.type==="card"||n.type==="row"?n:MD(n,e,t)}function UD(n,e,t){return n.map(r=>ND(r,e,t))}function FD(n,e){return JSON.stringify(n)===JSON.stringify(e)}const ZD=di(Tt);class HD extends ZD{constructor(t={}){super();b(this,"pending",null);b(this,"active",null)}start(t){if(this.pending||this.active)return;const r=t.pointer.x??0,i=t.pointer.y??0;this.pending={startX:r,startY:i,grabOffsetX:t.grabOffset.x??0,grabOffsetY:t.grabOffset.y??0,nodeId:t.nodeId,sourceIndex:t.source.index,parentStackId:t.source.parentId,width:t.size.x??0,height:t.size.y??0,baseLayout:t.layout}}update(t){const r=t.pointer.x??0,i=t.pointer.y??0,s=this.pending;if(s){const u=r-s.startX,d=i-s.startY;Math.hypot(u,d)>=v0&&(this.pending=null,this.active={...s,pointerX:r,pointerY:i,hitTarget:{type:"reorder",index:s.sourceIndex},lastReorderIndex:s.sourceIndex},this.emitDrag(),this.dispatchEvent(new Q("change")));return}if(!this.active)return;const o=Zl(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,i,t,o),l=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===i&&$D(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 Q("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const t=this.active.baseLayout;let r=null;try{const i=Zl(this.active,t),s=UD(i,t,this.active.nodeId);FD(s,t)||(r=s)}catch{r=null}this.reset(),r&&this.dispatchEvent(new kD("drop",{layout:r})),this.dispatchEvent(new Q("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new Q("change")))}dispose(){this.reset()}get status(){return this.active?"active":this.pending?"pending":"idle"}reset(){this.pending=null,this.active=null}emitDrag(){if(!this.active)return;const t=Zl(this.active,this.active.baseLayout);this.dispatchEvent(new SD("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:ke({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:ke({x:this.active.pointerX,y:this.active.pointerY}),size:ke({x:this.active.width,y:this.active.height}),projectedLayout:t}))}getHitTargetForPointer(t,r,i,s){return this.active?this.isPointerInsideDragBounds(t,r,i.viewport)?this.active.parentStackId?this.getStackChildHitTarget(t,r,i,s):this.getTopLevelCardHitTarget(t,r,i,s):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(t,r,i,s){var u;if(!((u=this.active)!=null&&u.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(i.geometry);if(o&&xn(t,r,o)){const d=o.top+o.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}const a=this.getSourceRemainingSiblingRect(i.geometry);if(a&&xn(t,r,a)){const d=a.top+a.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(t,r,i,s)}}getSourceRemainingSiblingRect(t){var s,o;if(!((s=this.active)!=null&&s.parentStackId))return;const r=Mf(this.active.baseLayout,this.active.parentStackId);if(!r)return;const i=r.children.find(a=>{var l;return a.type==="card"&&a.id!==((l=this.active)==null?void 0:l.nodeId)});if(i)return(o=t.find(a=>a.id===i.id))==null?void 0:o.rect}getSourceStackInteractionRect(t){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const r=t.find(a=>{var l;return a.id===((l=this.active)==null?void 0:l.parentStackId)});if(r)return this.active.sourceStackRect=r.rect,r.rect;const i=Mf(this.active.baseLayout,this.active.parentStackId);if(!i)return this.active.sourceStackRect;const s=i.children.find(a=>{var l;return a.type==="card"&&a.id!==((l=this.active)==null?void 0:l.nodeId)});if(s){const a=t.find(l=>l.id===s.id);if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(t,r,i,s){var y,A,k;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return{type:"reorder",index:((y=this.active)==null?void 0:y.sourceIndex)??0};const l=(i.effectiveVelocity??0)<=ED;for(const I of o){const G=I.rect;if(!xn(t,r,G))continue;const P=this.resolveTopLevelTargetForCard(t,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(t,o);if(!u)return{type:"reorder",index:((k=this.active)==null?void 0:k.sourceIndex)??0};const d=Math.max(u.rect.left,Math.min(u.rect.left+u.rect.width,t)),f=this.resolveTopLevelTargetForCard(d,r,u,u.logicalIndex,l);if(f)return f;const v=u.rect.left+u.rect.width/2;return{type:"reorder",index:t<v?u.logicalIndex:u.logicalIndex+1}}getTopLevelReorderIndexForPointer(t,r,i,s){var u,d;const o=this.getTopLevelZoneNodes(i.geometry,s);if(o.length===0)return((u=this.active)==null?void 0:u.sourceIndex)??0;for(const f of o){if(!xn(t,r,f.rect))continue;const v=Fl(f.rect,Ul["reorder-before"]);if(xn(t,r,v))return f.logicalIndex;const y=Fl(f.rect,Ul["reorder-after"]);if(xn(t,r,y))return f.logicalIndex+1}const a=this.getNearestTargetableZone(t,o);if(!a)return((d=this.active)==null?void 0:d.sourceIndex)??0;const l=a.rect.left+a.rect.width/2;return t<l?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(t,r){const i=new Map(r.map(a=>[a.id,a])),s=[];let o=0;for(const a of t){const 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(t,r,i,s,o){const a=i.rect;for(const l of wD){if(!o&&(l==="stack-above"||l==="stack-below"))continue;const u=Ul[l],d=Fl(a,u);if(xn(t,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(t,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=t<a?a-t:t>l?t-l:0;u<s&&(s=u,i=o)}return i}isPointerInsideDragBounds(t,r,i){return t>=i.left&&t<=i.left+i.width&&r>=i.top&&r<=i.top+i.height}}const Nf=60,VD=80,Uf=.5,Ff=10;class jD{constructor(){b(this,"awaitingFreshWheelGesture",!1);b(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);b(this,"lastWheelDeltaX",0);b(this,"activeGestureType","none");b(this,"lastWheelGestureAt",Number.NEGATIVE_INFINITY)}markKeyboardNavigation(e){this.awaitingFreshWheelGesture=!0,this.lastWheelEventAt=e,this.activeGestureType="none"}reset(){this.awaitingFreshWheelGesture=!1,this.lastWheelEventAt=Number.NEGATIVE_INFINITY,this.lastWheelDeltaX=0,this.activeGestureType="none",this.lastWheelGestureAt=Number.NEGATIVE_INFINITY}decide(e){const{now:t,shiftKey:r,deltaX:i,deltaY:s,overArtifactContent:o}=e;t-this.lastWheelGestureAt>=Nf&&(this.activeGestureType="none");const l=r&&s!==0,u=l?s:i,d=Math.abs(u),f=Math.abs(s);return this.activeGestureType==="vertical-artifact"&&o?d>=Uf&&d>=f*Ff?this.classifyHorizontal(t,u):(this.lastWheelGestureAt=t,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!l&&o&&f>0&&f>=d*Ff?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=t,{type:"scroll-native"}):this.classifyHorizontal(t,u):d<Uf?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=t,{type:"scroll-native"}):l||d>f?this.classifyHorizontal(t,u):f>d?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=t,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=t,{type:"scroll-native"}):this.classifyHorizontal(t,u)}classifyHorizontal(e,t){const r=e-this.lastWheelEventAt,i=Math.sign(this.lastWheelDeltaX),s=Math.sign(t),o=i!==0&&s!==0&&i!==s,a=i!==0&&Math.abs(t)>=Math.abs(this.lastWheelDeltaX)+VD;return this.awaitingFreshWheelGesture&&r<Nf&&!o&&!a?{type:"ignore"}:(this.lastWheelEventAt=e,this.lastWheelDeltaX=t,this.lastWheelGestureAt=e,this.awaitingFreshWheelGesture=!1,this.activeGestureType="horizontal-filmstrip",{type:"scroll-horizontal",horizontalDelta:t})}}const GD=2,Zf=1e3,_o=1e-4;function Hf(n,e,t){if(n===0)return 0;const r=e.toPixels(Te({y:Je})).y??0;return(t-r)/GD}function Hl(n){const e=n.clientWidth>0?n.clientWidth:tr,t=n.clientHeight>0?n.clientHeight:Yo;let r=0,i=0;if(n.isConnected){const o=getComputedStyle(n);r=parseFloat(o.paddingTop)||0,i=parseFloat(o.paddingBottom)||0}const s=Math.max(1,t-r-i);return{width:e,height:s,offsetY:r}}class BD extends Event{constructor(t){super("scroll",{bubbles:!0,composed:!0});b(this,"scrollPosition");this.scrollPosition=t}}class By extends Event{constructor(t){super("layout-change",{bubbles:!0,composed:!0});b(this,"layout");this.layout=t}}class WD extends HTMLElement{constructor(){super();b(this,"_layout",[]);b(this,"_scrollPosition",0);b(this,"layoutGrid",null);b(this,"layoutScroll",new bD(Te({x:0})));b(this,"scrollModelKey","");b(this,"resizeObserver",null);b(this,"renderPending",!1);b(this,"animateNextRender",!0);b(this,"wheelGesture",new jD);b(this,"dragController",new HD);b(this,"dragState",null);b(this,"activeDragPointerId",null);b(this,"dragListenersAttached",!1);b(this,"dragFrame",0);b(this,"lastDragFrameTime",0);b(this,"lastPointerX",0);b(this,"lastPointerY",0);b(this,"pointerVelocityPxPerSec",0);b(this,"scrollVelocityPxPerSec",0);b(this,"motionSampleTime",0);b(this,"motionSampleX",0);b(this,"motionSampleY",0);b(this,"dragTrackOffsetXPx",0);b(this,"previousProjectedLayoutForOffset",null);b(this,"renderContent",()=>F``);b(this,"onDragControllerChange",()=>{this.dragController.status==="idle"&&(this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null),this.scheduleRender()});b(this,"onDragControllerDrag",t=>{const r=Lf(t.projectedLayout),i=this.shouldApplyTrackOffset(t.projectedLayout,t.source.parentId),s=t.source.parentId?this.getStackChildAnchorCardId(t.source.parentId,t.nodeId):null;this.dragTrackOffsetXPx=i?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,r,t.nodeId,t.source.parentId,s,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=r,this.dragState={nodeId:t.nodeId,source:t.source,grabOffset:t.grabOffset,pointer:t.pointer,size:t.size,projectedLayout:t.projectedLayout},this.scheduleRender()});b(this,"onDragControllerDrop",t=>{this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.commitLayout(t.layout)});b(this,"onLayoutScrollInternal",t=>{const i=t.scroll.x??0;Math.abs(i-this._scrollPosition)<_o||(this._scrollPosition=i,this.emitScrollPositionChanged(i),this.scheduleRender())});b(this,"handleKeyDown",t=>{if(t.key==="Escape"&&this.dragController.status!=="idle"){t.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(t.key==="ArrowRight"?(t.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(1)):t.key==="ArrowLeft"&&(t.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(-1)))});b(this,"handleWheel",t=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:t.shiftKey,deltaX:t.deltaX,deltaY:t.deltaY,overArtifactContent:!1});r.type==="scroll-horizontal"&&(t.preventDefault(),this.applyHorizontalWheel(r.horizontalDelta))});b(this,"handleWindowMessage",t=>{var o;if(this._layout.length===0)return;const r=this.findManagedArtifactFrame(t.source);if(!r||!this.isTrustedArtifactFrameMessage(t,r)||!TC(t.data))return;const i=this.wheelGesture.decide({now:Date.now(),shiftKey:t.data.shiftKey,deltaX:t.data.deltaX,deltaY:t.data.deltaY,overArtifactContent:!0});if(i.type==="scroll-horizontal"){this.applyHorizontalWheel(i.horizontalDelta);return}if(i.type!=="scroll-native")return;const s={type:"scroll",deltaX:0,deltaY:t.data.deltaY};(o=r.contentWindow)==null||o.postMessage(s,this.getArtifactFrameTargetOrigin(r))});b(this,"handlePointerDown",t=>{if(t.button!==0||this.dragController.status!=="idle")return;const r=t.target;if(!(r instanceof Element)||!r.closest("[drag-handle]")||r.closest("button, input, textarea, select, a, [role='button']"))return;const i=r.closest(".card-slot");if(!i)return;const s=i.getAttribute("data-layout-node-id");if(!s)return;const o=YD(this._layout,s);if(!o)return;const a=i.getBoundingClientRect();this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.resetMotionTracking(t.clientX,t.clientY),this.focus(),this.dragController.start({nodeId:s,source:{index:o.topLevelIndex,parentId:o.sourceStackId},pointer:ke({x:t.clientX,y:t.clientY}),grabOffset:ke({x:t.clientX-a.left,y:t.clientY-a.top}),size:ke({x:a.width,y:a.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=t.pointerId;try{this.setPointerCapture(t.pointerId)}catch{}t.preventDefault()});b(this,"handleWindowPointerMove",t=>{this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.updatePointerVelocity(t.clientX,t.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop()});b(this,"handleWindowPointerUp",t=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(t.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowPointerCancel",t=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(t.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});b(this,"runDragFrame",t=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const r=Math.max(0,t-this.lastDragFrameTime)/Zf;this.lastDragFrameTime=t,this.samplePointerVelocityAt(t,this.lastPointerX,this.lastPointerY);const i=this.getBoundingClientRect(),s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,i),o=this.getDragEdgeScrollDeltaPixels(s.x,i,r);this.scrollVelocityPxPerSec=r>_o?Math.abs(o)/r:0,Math.abs(o)>_o&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(ke({x:o}))),this.dragController.status==="active"&&this.syncDragTarget(s.x,s.y,i),this.dragFrame=requestAnimationFrame(this.runDragFrame)});this.dragController.addEventListener("change",this.onDragControllerChange),this.dragController.addEventListener("drag",this.onDragControllerDrag),this.dragController.addEventListener("drop",this.onDragControllerDrop),this.layoutScroll.addEventListener("layout-scroll",this.onLayoutScrollInternal)}set layout(t){this._layout=[...t],this.stopDragFrameLoop(),this.dragController.cancel(),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=Te({x:this._scrollPosition}),this.scheduleRender()}get layout(){return this._layout}commitLayout(t){this.layout=t,this.emitLayoutChanged()}set scrollPosition(t){Math.abs(t-this._scrollPosition)<_o||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=Te({x:t}))}get scrollPosition(){return this._scrollPosition}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.focus(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("pointerdown",this.handlePointerDown),window.addEventListener("message",this.handleWindowMessage),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.render()),this.resizeObserver.observe(this)),this.render()}disconnectedCallback(){var t;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("message",this.handleWindowMessage),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=null,this.wheelGesture.reset(),this.detachDragListeners(),this.dragController.removeEventListener("change",this.onDragControllerChange),this.dragController.removeEventListener("drag",this.onDragControllerDrag),this.dragController.removeEventListener("drop",this.onDragControllerDrop),this.layoutScroll.removeEventListener("layout-scroll",this.onLayoutScrollInternal),this.dragController.dispose(),this.stopDragFrameLoop()}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(t,r){return new lD({basis:ke({x:Pn,y:Pn}),min:ke({x:Kd,y:Kd}),viewport:ke({x:t,y:r}),gap:ke({x:pe,y:pe})})}syncScrollModel(){const t=Hl(this),i=Wi(this._layout).nodes.map(o=>o.width),s=`${t.width}x${t.height}:${i.join(",")}`;s===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=s,this.layoutGrid=this.createGrid(t.width,t.height),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(o=>Te({x:o}))}))}emitScrollPositionChanged(t){this.dispatchEvent(new BD(t))}emitLayoutChanged(){this.dispatchEvent(new By([...this._layout]))}shiftWindow(t){this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(t)}applyHorizontalWheel(t){this.syncScrollModel();const r=this.layoutGrid;if(!r)return;this.animateNextRender=!1;const i=r.toUnits(ke({x:t}));this.layoutScroll.wheel(Te({x:i.x??0}))}findManagedArtifactFrame(t){if(!t)return null;const r=this.querySelectorAll("iframe.artifact-frame");for(const i of r)if(i.contentWindow===t)return i;return null}isTrustedArtifactFrameMessage(t,r){if(t.origin==="null")return!0;const i=this.getArtifactFrameOrigin(r);return i===null||t.origin===i}getArtifactFrameTargetOrigin(t){const r=t.getAttribute("sandbox")??"";return new Set(r.split(/\s+/).filter(Boolean)).has("allow-same-origin")?this.getArtifactFrameOrigin(t)??"*":"*"}getArtifactFrameOrigin(t){const r=t.getAttribute("src")??t.src;if(!r)return null;try{return new URL(r,window.location.href).origin}catch{return null}}releaseActiveDragPointerCapture(){this.activeDragPointerId!==null&&this.releasePointerCaptureForEvent(this.activeDragPointerId)}releasePointerCaptureForEvent(t){try{this.hasPointerCapture(t)&&this.releasePointerCapture(t)}catch{}}attachDragListeners(){this.dragListenersAttached||(window.addEventListener("pointermove",this.handleWindowPointerMove),window.addEventListener("pointerup",this.handleWindowPointerUp),window.addEventListener("pointercancel",this.handleWindowPointerCancel),this.addEventListener("pointermove",this.handleWindowPointerMove),this.addEventListener("pointerup",this.handleWindowPointerUp),this.addEventListener("pointercancel",this.handleWindowPointerCancel),window.addEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!0)}detachDragListeners(){this.dragListenersAttached&&(window.removeEventListener("pointermove",this.handleWindowPointerMove),window.removeEventListener("pointerup",this.handleWindowPointerUp),window.removeEventListener("pointercancel",this.handleWindowPointerCancel),this.removeEventListener("pointermove",this.handleWindowPointerMove),this.removeEventListener("pointerup",this.handleWindowPointerUp),this.removeEventListener("pointercancel",this.handleWindowPointerCancel),window.removeEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!1,this.activeDragPointerId=null)}getDisplayModel(){if(this.dragController.status!=="active"||!this.dragState)return{layout:this._layout,activePlaceholderId:null,placeholdersById:new Map};const t=new Map;return t.set(this.dragState.nodeId,{id:this.dragState.nodeId,sourceCardId:this.dragState.nodeId}),{layout:Lf(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:t}}render(){const t=Hl(this),r=this.createGrid(t.width,t.height);this.layoutGrid=r;const i=this.getDisplayModel(),s=i.layout,o=this.dragController.status==="active",a=Wi(s),l=a.nodes.map(M=>M.width),u=`${t.width}x${t.height}:${l.join(",")}`;!o&&u!==this.scrollModelKey&&(this.scrollModelKey=u,this.layoutScroll.rebuild({grid:r,nodeWidths:l.map(M=>Te({x:M}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const d=qD(s),f=r.unit.x??Pn,v=r.unit.y??Pn,y=o?this.dragTrackOffsetXPx:0,A=(this.layoutScroll.translate.x??0)+y,k=Hf(a.nodes.length,r,t.height),I=this.animateNextRender&&!o,G=[`transform: translate(${A}px, ${k}px);`,`transition-duration: ${I?y0:0}ms;`,`pointer-events: ${o?"none":"auto"};`].join(" ");this.animateNextRender=!0,this.style.setProperty("--layout-unit-x",`${f}px`),this.style.setProperty("--layout-unit-y",`${v}px`),this.style.setProperty("--layout-gap",`${pe}px`);const P=this.dragState,le={width:(P==null?void 0:P.size.x)??0,height:(P==null?void 0:P.size.y)??0};Pe(F`
|
|
157
|
-
<div class="track" style=${G}>
|
|
158
|
-
${a.nodes.map((M,Z)=>F`
|
|
159
|
-
<div
|
|
160
|
-
class="node"
|
|
161
|
-
layout-node=${String(Z)}
|
|
162
|
-
data-layout-node-id=${M.id}
|
|
163
|
-
data-layout-placeholder=${String(i.activePlaceholderId===M.id)}
|
|
164
|
-
layout-node-cols=${String(M.width)}
|
|
165
|
-
style=${`grid-template-columns: repeat(${M.width}, var(--layout-unit-x)); width: ${r.toPixels(Te({x:M.width})).x}px;`}
|
|
166
|
-
>
|
|
167
|
-
${M.cards.map(U=>{const ge=i.placeholdersById.get(U.id);if(P&&ge)return F`
|
|
168
|
-
<div
|
|
169
|
-
class="card-slot card-placeholder"
|
|
170
|
-
data-layout-placeholder-for=${P.nodeId}
|
|
171
|
-
data-layout-placeholder-ghost="false"
|
|
172
|
-
data-layout-source-stack=${P.source.parentId??""}
|
|
173
|
-
style=${`grid-column: ${U.col} / span ${U.width}; grid-row: ${U.row} / span ${U.height};`}
|
|
174
|
-
></div>
|
|
175
|
-
`;const ce=d.get(U.id);return ce?F`
|
|
176
|
-
<div
|
|
177
|
-
class="card-slot"
|
|
178
|
-
data-layout-card-id=${U.artifactID}
|
|
179
|
-
data-layout-node-id=${U.id}
|
|
180
|
-
layout-cols=${String(U.width)}
|
|
181
|
-
layout-rows=${String(U.height)}
|
|
182
|
-
style=${`grid-column: ${U.col} / span ${U.width}; grid-row: ${U.row} / span ${U.height};`}
|
|
183
|
-
>
|
|
184
|
-
${this.renderContent(ce,{isDragging:!1})}
|
|
185
|
-
</div>
|
|
186
|
-
`:null})}
|
|
187
|
-
</div>
|
|
188
|
-
`)}
|
|
189
|
-
</div>
|
|
190
|
-
${P?(()=>{const M=this.getPlaceholderPixelSize(a,i.activePlaceholderId,r,le),Z=P.pointer.x??0,U=P.pointer.y??0,ge=P.grabOffset.x??0,ce=P.grabOffset.y??0;return F`
|
|
191
|
-
<div
|
|
192
|
-
class="drag-preview"
|
|
193
|
-
data-layout-preview-card-id=${P.nodeId}
|
|
194
|
-
style=${[`width: ${M.width}px;`,`height: ${M.height}px;`,`left: ${Z-ge}px;`,`top: ${U-ce}px;`].join(" ")}
|
|
195
|
-
>
|
|
196
|
-
${this.renderDraggedPreview(P.nodeId)}
|
|
197
|
-
</div>
|
|
198
|
-
`})():null}
|
|
199
|
-
`,this)}ensureDragFrameLoop(){this.dragFrame!==0||this.dragController.status==="idle"||(this.lastDragFrameTime=performance.now(),this.dragFrame=requestAnimationFrame(this.runDragFrame))}stopDragFrameLoop(){this.dragFrame!==0&&(cancelAnimationFrame(this.dragFrame),this.dragFrame=0,this.scrollVelocityPxPerSec=0)}syncDragTargetForLatestPointer(){if(this.dragController.status==="idle")return;const t=this.getBoundingClientRect();if(this.dragController.status==="active"){const i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,t);this.syncDragTarget(i.x,i.y,t);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,t),this.dragController.status==="pending")return;const r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,t);(r.x!==this.lastPointerX||r.y!==this.lastPointerY)&&this.syncDragTarget(r.x,r.y,t)}syncDragTarget(t,r,i=this.getBoundingClientRect()){if(this.dragController.status==="idle")return;const s=this.getDisplayModel(),o=new Set(s.placeholdersById.keys()),a=this.dragController.status==="active"?this.dragTrackOffsetXPx:0,l=this.measureLayoutGeometry(s.layout,o,a);this.dragController.update({pointer:ke({x:t,y:r}),viewport:{left:i.left,top:i.top,width:i.width,height:i.height},geometry:l,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(t,r){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=t,this.motionSampleY=r}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(t,r){this.samplePointerVelocityAt(performance.now(),t,r)}samplePointerVelocityAt(t,r,i){if(this.motionSampleTime===0){this.motionSampleTime=t,this.motionSampleX=r,this.motionSampleY=i,this.pointerVelocityPxPerSec=0;return}const s=t-this.motionSampleTime;if(s<100)return;const o=r-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/s*Zf,this.motionSampleTime=t,this.motionSampleX=r,this.motionSampleY=i}clampPointerToViewport(t,r,i){return{x:Math.max(i.left,Math.min(i.left+i.width,t)),y:Math.max(i.top,Math.min(i.top+i.height,r))}}isPointerOutsideViewport(t,r,i){return t<i.left||t>i.left+i.width||r<i.top||r>i.top+i.height}getDragEdgeScrollDeltaPixels(t,r,i){var u;const s=r.left+go,o=r.left+r.width-go,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??Pn,l=b0*a;if(t<s){const d=Math.max(0,Math.min(1,(s-t)/go));return-(l*d**Jd)*i}if(t>o){const d=Math.max(0,Math.min(1,(t-o)/go));return l*d**Jd*i}return 0}measureLayoutGeometry(t,r,i=0){const s=this.layoutGrid;if(!s)return[];const o=Wi(t),a=new Map(o.nodes.map(k=>[k.id,k.width])),l=s.toPixels(Te({y:Je})).y??Yo,u=Hl(this),d=(this.layoutScroll.translate.x??0)+i,f=Hf(o.nodes.length,s,u.height),v=u.offsetY+f,y=[];let A=d;for(const k of t){const I=a.get(k.id)??At,G=s.toPixels(Te({x:I})).x??tr,P={left:A,top:v,width:G,height:l};y.push({id:k.id,rect:P}),A+=G+pe}return y}getPlaceholderPixelSize(t,r,i,s){if(!r)return s;for(const o of t.nodes)for(const a of o.cards)if(a.id===r)return{width:i.toPixels(Te({x:a.width})).x??s.width,height:i.toPixels(Te({y:a.height})).y??s.height};return s}renderDraggedPreview(t){const r=Hu(this._layout,t);return r?this.renderContent(r,{isDragging:!0}):F``}shouldApplyTrackOffset(t,r){if(r)return!0;for(const i of t){if(i.type!=="stack")continue;if(i.children.some(o=>o.type==="drop-target")&&r!==i.id)return!0}return!1}computeDragTrackOffset(t,r,i,s,o,a){if(!t)return a;const l=s?o??this.getStableAnchorCardId(t,r,i):this.getStableAnchorNodeId(t,r,i);if(!l)return a;const u=s?jf(t,l,this.layoutGrid):Gf(t,l,this.layoutGrid),d=s?jf(r,l,this.layoutGrid):Gf(r,l,this.layoutGrid);return u===null||d===null?a:a+(u-d)}getStableAnchorCardId(t,r,i){const s=Vf(t),o=new Set(Vf(r));for(const a of s)if(a!==i&&o.has(a))return a;return null}getStableAnchorNodeId(t,r,i){const s=new Set(r.map(o=>o.id));for(const o of t)if(o.id!==i&&s.has(o.id))return o.id;return null}getStackChildAnchorCardId(t,r){const i=this._layout.find(o=>o.type==="stack"&&o.id===t);if(!i||i.type!=="stack")return null;const s=i.children.find(o=>o.type==="card"&&o.id!==r);return(s==null?void 0:s.id)??null}}function qD(n){const e=new Map;for(const t of n){if(t.type==="card"){e.set(t.id,t);continue}for(const r of t.children)if(r.type==="card")e.set(r.id,r);else for(const i of r.children)e.set(i.id,i)}return e}function YD(n,e){const t=n.findIndex(r=>r.type==="card"&&r.id===e);if(t!==-1)return{topLevelIndex:t};for(let r=0;r<n.length;r+=1){const i=n[r];if(!(!i||i.type!=="stack")&&i.children.some(s=>s.type==="card"&&s.id===e))return{topLevelIndex:r,sourceStackId:i.id}}return null}function Vf(n){const e=[];for(const t of n){if(t.type==="card"){e.push(t.id);continue}if(t.type==="stack"){const r=t.children.find(i=>i.type==="card");r&&e.push(r.id)}}return e}function jf(n,e,t){if(!t)return null;const r=Wi(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.type==="card"&&o.id===e||o.type==="stack"&&o.children.some(u=>u.type==="card"&&u.id===e))return s;const a=i.get(o.id)??At,l=t.toPixels(Te({x:a})).x??tr;s+=l+pe}return null}function Gf(n,e,t){if(!t)return null;const r=Wi(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(o.id===e)return s;const a=i.get(o.id)??At,l=t.toPixels(Te({x:a})).x??tr;s+=l+pe}return null}customElements.get("layout-view")||customElements.define("layout-view",WD);class KD extends HTMLElement{constructor(){super(...arguments);b(this,"screenManager",rt.resolve("ScreenManager"));b(this,"boundModel",null);b(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});b(this,"handleModelChange",()=>{this.render()});b(this,"handleCloseArtifact",t=>{t instanceof Fy&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(t.artifactID)});b(this,"handleScrollPositionChanged",t=>{const r=t;typeof r.scrollPosition=="number"&&Number.isFinite(r.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(r.scrollPosition)});b(this,"handleLayoutChanged",t=>{t instanceof By&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(t.layout)})}connectedCallback(){this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.rebindModel(),this.render()}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged),this.unbindModel()}rebindModel(){const t=this.screenManager.activeScreen;this.boundModel!==t&&(this.unbindModel(),this.boundModel=t,t&&t.addEventListener("change",this.handleModelChange))}unbindModel(){this.boundModel&&(this.boundModel.removeEventListener("change",this.handleModelChange),this.boundModel=null)}buildArtifactMap(){const t=this.screenManager.activeScreen;return t?new Map(t.artifacts):new Map}render(){const t=this.screenManager.activeScreen,r=(t==null?void 0:t.layout)??[],i=this.buildArtifactMap();if(r.length===0){Pe(F`<p data-testid="empty-screen" class="empty">
|
|
200
|
-
No artifacts yet. Create one by asking for something.
|
|
201
|
-
</p>`,this);return}Pe(F`
|
|
202
|
-
<layout-view
|
|
203
|
-
.layout=${r}
|
|
204
|
-
.renderContent=${(o,a)=>{const l=i.get(o.artifactID);return!l||!t?F``:F`<artifact-view
|
|
205
|
-
.artifact=${l}
|
|
206
|
-
.screen=${t}
|
|
207
|
-
.viewURL=${t.server.getViewURL(l)}
|
|
208
|
-
.contentURL=${t.server.getContentURL(l.id)}
|
|
209
|
-
.dragging=${a.isDragging}
|
|
210
|
-
></artifact-view>`}}
|
|
211
|
-
.scrollPosition=${(t==null?void 0:t.scrollPosition)??0}
|
|
212
|
-
@scroll=${this.handleScrollPositionChanged}
|
|
213
|
-
@layout-change=${this.handleLayoutChanged}
|
|
214
|
-
@close-artifact=${this.handleCloseArtifact}
|
|
215
|
-
></layout-view>
|
|
216
|
-
`,this)}}customElements.define("screen-view",KD);var fa,jr,Ts,Wt,Wy,qy,Nc;class JD extends HTMLElement{constructor(){super(...arguments);S(this,Wt);S(this,fa,rt.resolve("ScreenManager"));S(this,jr,rt.resolve("ServerManager"));S(this,Ts,()=>{m(this,Wt,Nc).call(this)})}connectedCallback(){c(this,jr).addEventListener("change",c(this,Ts)),m(this,Wt,Nc).call(this)}disconnectedCallback(){c(this,jr).removeEventListener("change",c(this,Ts))}}fa=new WeakMap,jr=new WeakMap,Ts=new WeakMap,Wt=new WeakSet,Wy=function(t,r){c(this,fa).setActive(t,r)},qy=function(){for(const t of c(this,jr).servers.values())return t;return null},Nc=function(){const t=m(this,Wt,qy).call(this),i=(t?[...t.screens.values()]:[]).slice().sort((o,a)=>o.name.localeCompare(a.name,void 0,{sensitivity:"base"})),s=i.length===0?F`<p class="empty">No screens yet. Hit + to create one.</p>`:F`
|
|
217
|
-
<div class="content">
|
|
218
|
-
<h2 class="heading">Screens</h2>
|
|
219
|
-
<ul class="tiles">
|
|
220
|
-
${i.map(o=>F`
|
|
221
|
-
<li>
|
|
222
|
-
<button
|
|
223
|
-
class="tile"
|
|
224
|
-
type="button"
|
|
225
|
-
@click=${()=>t&&m(this,Wt,Wy).call(this,t.url,o.id)}
|
|
226
|
-
>
|
|
227
|
-
${o.name}
|
|
228
|
-
</button>
|
|
229
|
-
</li>
|
|
230
|
-
`)}
|
|
231
|
-
</ul>
|
|
232
|
-
</div>
|
|
233
|
-
`;Pe(s,this)};customElements.get("home-screen")||customElements.define("home-screen",JD);const Vl=new WeakMap,Bf=Object.prototype.hasOwnProperty,XD=(()=>{const n=new Set;let e=HTMLElement.prototype;for(;e;){for(const t of Object.getOwnPropertyNames(e))n.add(t);if(e===Node.prototype)break;e=Object.getPrototypeOf(e)}return n})();function QD(n,e){if(n===Boolean)return e!==null;if(e!==null)return n===Number?Number(e):e}var Cs,Uc,Yn,et,Et,Gr,Kn,Br,Ie,Zi,Yy,Ky,Jy,Fo;const On=class On extends HTMLElement{constructor(){var i;super();S(this,Ie);S(this,Yn,new Map);S(this,et,new Map);S(this,Et,new Map);S(this,Gr,!1);S(this,Kn,!1);S(this,Br,!1);const t=m(i=On,Cs,Uc).call(i,this.constructor),r=this;for(const s of t.properties)Bf.call(r,s)&&(c(this,Et).set(s,r[s]),delete r[s])}static get observedAttributes(){var t;return m(t=On,Cs,Uc).call(t,this).observedAttributes}connected(){}disconnected(){}changed(t){}connectedCallback(){if(m(this,Ie,Jy).call(this),!c(this,Kn))for(const t of m(this,Ie,Zi).call(this).properties)c(this,et).has(t)||c(this,et).set(t,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),m(this,Ie,Fo).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(t,r,i){if(r===i)return;const s=m(this,Ie,Zi).call(this).byAttr.get(t);s&&(c(this,Et).has(s.property)||(this[s.property]=QD(s.type,i)))}};Cs=new WeakSet,Uc=function(t){const r=Vl.get(t);if(r)return r;const i=[...t.properties??[]],s=t.attributes??{},o=new Map,a=new Map;for(const u of i)if(XD.has(u))throw new Error(`Reactive property "${u}" collides with a built-in DOM property. Rename it to avoid shadowing the platform API.`);for(const[u,d]of Object.entries(s)){if(u.includes("-")&&d.property===void 0)throw new Error(`Attribute "${u}" must declare a "property" name because kebab-case cannot be a property.`);const f=d.property??u;if(!i.includes(f))throw new Error(`Attribute '${u}' references property '${f}', which isn't declared in \`static properties\`. Add it to \`properties\` to make it reactive.`);const v={attribute:u,property:f,type:d.type};o.set(u,v),a.set(f,v)}for(const u of i){const d=Object.getOwnPropertyDescriptor(t.prototype,u);if((d==null?void 0:d.get)!==void 0||(d==null?void 0:d.set)!==void 0)throw new Error(`Observed property "${u}" cannot define a custom getter/setter. Use changed() for side effects instead.`);d===void 0&&Object.defineProperty(t.prototype,u,{configurable:!0,enumerable:!0,get(){return c(this,Yn).get(u)},set(f){m(this,Ie,Yy).call(this,u,f)}})}const l={properties:i,observedAttributes:Object.keys(s),byAttr:o,byProp:a};return Vl.set(t,l),l},Yn=new WeakMap,et=new WeakMap,Et=new WeakMap,Gr=new WeakMap,Kn=new WeakMap,Br=new WeakMap,Ie=new WeakSet,Zi=function(){return Vl.get(this.constructor)},Yy=function(t,r){if(!c(this,Br)&&c(this,Et).has(t))return;const i=c(this,Yn).get(t);Object.is(i,r)||(c(this,et).has(t)||c(this,et).set(t,i),c(this,Yn).set(t,r),c(this,Et).delete(t),m(this,Ie,Ky).call(this,t,r),this.isConnected&&m(this,Ie,Fo).call(this))},Ky=function(t,r){const i=m(this,Ie,Zi).call(this).byProp.get(t);if(!i)return;const{attribute:s,type:o}=i;if(o===Boolean){const 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)},Jy=function(){const t=this,r=m(this,Ie,Zi).call(this);for(const i of r.properties){if(!Bf.call(t,i))continue;const s=t[i];delete t[i],!(c(this,Et).has(i)||c(this,Yn).has(i))&&(t[i]=s)}E(this,Br,!0);try{for(const[i,s]of c(this,Et))t[i]=s;c(this,Et).clear()}finally{E(this,Br,!1)}},Fo=function(){c(this,Gr)||!this.isConnected||c(this,Kn)&&c(this,et).size===0||(E(this,Gr,!0),queueMicrotask(()=>{if(E(this,Gr,!1),!this.isConnected||c(this,Kn)&&c(this,et).size===0)return;const t=new Map(c(this,et));c(this,et).clear(),E(this,Kn,!0);try{this.changed(t)}catch(r){console.error(r)}this.isConnected&&c(this,et).size>0&&m(this,Ie,Fo).call(this)}))},S(On,Cs),b(On,"properties"),b(On,"attributes");let ts=On;/**
|
|
234
|
-
* @license
|
|
235
|
-
* Copyright 2020 Google LLC
|
|
236
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
237
|
-
*/const eO=n=>n.strings===void 0;/**
|
|
238
|
-
* @license
|
|
239
|
-
* Copyright 2017 Google LLC
|
|
240
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
241
|
-
*/const Yi=(n,e)=>{var r;const t=n._$AN;if(t===void 0)return!1;for(const i of t)(r=i._$AO)==null||r.call(i,e,!1),Yi(i,e);return!0},ra=n=>{let e,t;do{if((e=n._$AM)===void 0)break;t=e._$AN,t.delete(n),n=e}while((t==null?void 0:t.size)===0)},Xy=n=>{for(let e;e=n._$AM;n=e){let t=e._$AN;if(t===void 0)e._$AN=t=new Set;else if(t.has(n))break;t.add(n),rO(e)}};function tO(n){this._$AN!==void 0?(ra(this),this._$AM=n,Xy(this)):this._$AM=n}function nO(n,e=!1,t=0){const r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(e)if(Array.isArray(r))for(let s=t;s<r.length;s++)Yi(r[s],!1),ra(r[s]);else r!=null&&(Yi(r,!1),ra(r));else Yi(this,n)}const rO=n=>{n.type==gy.CHILD&&(n._$AP??(n._$AP=nO),n._$AQ??(n._$AQ=tO))};class iO extends my{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,r){super._$AT(e,t,r),Xy(this),this.isConnected=e._$AU}_$AO(e,t=!0){var r,i;e!==this.isConnected&&(this.isConnected=e,e?(r=this.reconnected)==null||r.call(this):(i=this.disconnected)==null||i.call(this)),t&&(Yi(this,e),ra(this))}setValue(e){if(eO(this._$Ct))this._$Ct._$AI(e,this);else{const t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}}/**
|
|
242
|
-
* @license
|
|
243
|
-
* Copyright 2020 Google LLC
|
|
244
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
245
|
-
*/const So=()=>new sO;class sO{}const jl=new WeakMap,ko=Fu(class extends iO{render(n){return oe}update(n,[e]){var r;const t=e!==this.G;return t&&this.G!==void 0&&this.rt(void 0),(t||this.lt!==this.ct)&&(this.G=e,this.ht=(r=n.options)==null?void 0:r.host,this.rt(this.ct=n.element)),oe}rt(n){if(this.isConnected||(n=void 0),typeof this.G=="function"){const e=this.ht??globalThis;let t=jl.get(e);t===void 0&&(t=new WeakMap,jl.set(e,t)),t.get(this.G)!==void 0&&this.G.call(this.ht,void 0),t.set(this.G,n),n!==void 0&&this.G.call(this.ht,n)}else this.G.value=n}get lt(){var n,e;return typeof this.G=="function"?(n=jl.get(this.ht??globalThis))==null?void 0:n.get(this.G):(e=this.G)==null?void 0:e.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Ke,un,Wr,qr,Is,Jn,Xn,re,Ps,Rs,Me,Fc,Zc,pa,ga,ma,ya,va,ba,wa,Ds,Os,Hi,Qy,ht;class oO extends ts{constructor(){super(...arguments);S(this,Me);S(this,Ke,rt.resolve("ScreenManager"));S(this,un,null);S(this,Wr,new DisposableStack);S(this,qr,So());S(this,Is,So());S(this,Jn,So());S(this,Xn,So());S(this,re,{kind:"none"});S(this,Ps,()=>{m(this,Me,Fc).call(this),c(this,ht).call(this)});S(this,Rs,()=>{c(this,ht).call(this)});S(this,pa,()=>{c(this,Ke).clearActive()});S(this,ga,t=>{c(this,re).kind!=="none"&&(t.stopImmediatePropagation(),m(this,Me,Hi).call(this))});S(this,ma,()=>{var r;const t=c(this,Ke).activeScreen;t&&((r=c(this,qr).value)==null||r.close(),E(this,re,{kind:"rename",draft:t.name}),c(this,ht).call(this))});S(this,ya,()=>{var t;c(this,Ke).activeScreen&&((t=c(this,qr).value)==null||t.close(),E(this,re,{kind:"delete",error:null}),c(this,ht).call(this))});S(this,va,t=>{if(c(this,re).kind!=="rename")return;const r=t.target;r instanceof HTMLInputElement&&E(this,re,{kind:"rename",draft:r.value})});S(this,ba,t=>{if(t.preventDefault(),c(this,re).kind!=="rename")return;const r=c(this,Ke).activeScreen;if(!r)return;const i=c(this,re).draft.trim();i.length>0&&i!==r.name&&r.rename(i),m(this,Me,Hi).call(this)});S(this,wa,async()=>{if(c(this,re).kind!=="delete")return;const t=c(this,Ke).activeScreen;if(t){E(this,re,{kind:"delete",error:null});try{await t.remove(),c(this,Ke).clearActive(),m(this,Me,Hi).call(this)}catch(r){E(this,re,{kind:"delete",error:r instanceof Error?r.message:"Failed to delete screen."}),c(this,ht).call(this)}}});S(this,Ds,()=>{m(this,Me,Hi).call(this)});S(this,Os,()=>{c(this,re).kind!=="none"&&(E(this,re,{kind:"none"}),c(this,ht).call(this))});S(this,ht,()=>{const t=F`
|
|
246
|
-
<button
|
|
247
|
-
icon-only
|
|
248
|
-
class="home"
|
|
249
|
-
type="button"
|
|
250
|
-
aria-label="Home"
|
|
251
|
-
@click=${c(this,pa)}
|
|
252
|
-
>
|
|
253
|
-
${FR({weight:"fill"})}
|
|
254
|
-
</button>
|
|
255
|
-
`;Pe(F`${t}${m(this,Me,Qy).call(this)}`,this);const r=c(this,Is).value??null;c(this,Jn).value&&(c(this,Jn).value.anchor=r),c(this,Xn).value&&(c(this,Xn).value.anchor=r)})}connected(){c(this,Ke).addEventListener("active-screen-changed",c(this,Ps)),m(this,Me,Fc).call(this),c(this,ht).call(this),c(this,Wr).defer(()=>{c(this,Ke).removeEventListener("active-screen-changed",c(this,Ps)),m(this,Me,Zc).call(this)})}disconnected(){c(this,Wr).dispose(),E(this,Wr,new DisposableStack)}}Ke=new WeakMap,un=new WeakMap,Wr=new WeakMap,qr=new WeakMap,Is=new WeakMap,Jn=new WeakMap,Xn=new WeakMap,re=new WeakMap,Ps=new WeakMap,Rs=new WeakMap,Me=new WeakSet,Fc=function(){var r;const t=c(this,Ke).activeScreen;c(this,un)!==t&&(m(this,Me,Zc).call(this),E(this,un,t),(r=c(this,un))==null||r.addEventListener("change",c(this,Rs)))},Zc=function(){var t;(t=c(this,un))==null||t.removeEventListener("change",c(this,Rs)),E(this,un,null)},pa=new WeakMap,ga=new WeakMap,ma=new WeakMap,ya=new WeakMap,va=new WeakMap,ba=new WeakMap,wa=new WeakMap,Ds=new WeakMap,Os=new WeakMap,Hi=function(){const t=c(this,re).kind==="rename"?c(this,Jn).value:c(this,re).kind==="delete"?c(this,Xn).value:null;t&&(t.open=!1),E(this,re,{kind:"none"}),c(this,ht).call(this)},Qy=function(){const t=c(this,Ke).activeScreen;if(!t)return null;const r=c(this,re).kind==="rename"?c(this,re).draft:"",i=c(this,re).kind==="delete"?c(this,re).error:null;return F`
|
|
256
|
-
<span class="separator" aria-hidden="true">
|
|
257
|
-
${MR()}
|
|
258
|
-
</span>
|
|
259
|
-
<dropdown-menu ${ko(c(this,qr))}>
|
|
260
|
-
<button
|
|
261
|
-
slot="trigger"
|
|
262
|
-
type="button"
|
|
263
|
-
variant="ghost"
|
|
264
|
-
aria-label=${`Screen actions for ${t.name}`}
|
|
265
|
-
?data-active=${c(this,re).kind!=="none"}
|
|
266
|
-
@click=${c(this,ga)}
|
|
267
|
-
${ko(c(this,Is))}
|
|
268
|
-
>
|
|
269
|
-
${t.name}
|
|
270
|
-
</button>
|
|
271
|
-
<dropdown-group>
|
|
272
|
-
<dropdown-item action @click=${c(this,ma)}>
|
|
273
|
-
${ZR()} Rename
|
|
274
|
-
</dropdown-item>
|
|
275
|
-
<dropdown-item action danger @click=${c(this,ya)}>
|
|
276
|
-
${HR()} Delete
|
|
277
|
-
</dropdown-item>
|
|
278
|
-
</dropdown-group>
|
|
279
|
-
</dropdown-menu>
|
|
280
|
-
<ui-popover
|
|
281
|
-
class="rename-popover"
|
|
282
|
-
?open=${c(this,re).kind==="rename"}
|
|
283
|
-
@close=${c(this,Os)}
|
|
284
|
-
${ko(c(this,Jn))}
|
|
285
|
-
>
|
|
286
|
-
<form class="screen-form" @submit=${c(this,ba)}>
|
|
287
|
-
<label class="field">
|
|
288
|
-
<span>Screen name</span>
|
|
289
|
-
<input
|
|
290
|
-
type="text"
|
|
291
|
-
.value=${r}
|
|
292
|
-
@input=${c(this,va)}
|
|
293
|
-
/>
|
|
294
|
-
</label>
|
|
295
|
-
<div class="actions">
|
|
296
|
-
<button type="button" @click=${c(this,Ds)}>Cancel</button>
|
|
297
|
-
<button type="submit" variant="primary">Save</button>
|
|
298
|
-
</div>
|
|
299
|
-
</form>
|
|
300
|
-
</ui-popover>
|
|
301
|
-
<ui-popover
|
|
302
|
-
class="delete-popover"
|
|
303
|
-
?open=${c(this,re).kind==="delete"}
|
|
304
|
-
@close=${c(this,Os)}
|
|
305
|
-
${ko(c(this,Xn))}
|
|
306
|
-
>
|
|
307
|
-
<div class="screen-form">
|
|
308
|
-
<p class="confirm-text">Delete "${t.name}"?</p>
|
|
309
|
-
${i?F`<p class="error">${i}</p>`:oe}
|
|
310
|
-
<div class="actions">
|
|
311
|
-
<button type="button" @click=${c(this,Ds)}>Cancel</button>
|
|
312
|
-
<button
|
|
313
|
-
type="button"
|
|
314
|
-
variant="danger"
|
|
315
|
-
@click=${c(this,wa)}
|
|
316
|
-
>
|
|
317
|
-
Delete
|
|
318
|
-
</button>
|
|
319
|
-
</div>
|
|
320
|
-
</div>
|
|
321
|
-
</ui-popover>
|
|
322
|
-
`},ht=new WeakMap;customElements.define("screen-breadcrumb",oO);var _a,Sa,Yr,ri,ev,ka,tv;class aO extends HTMLElement{constructor(){super(...arguments);S(this,ri);S(this,_a,rt.resolve("ServerManager"));S(this,Sa,rt.resolve("ScreenManager"));S(this,Yr,!1);S(this,ka,async()=>{if(c(this,Yr))return;const t=m(this,ri,ev).call(this);if(t){E(this,Yr,!0);try{const r=await t.createScreen(lO(new Date));c(this,Sa).setActive(t.url,r.id)}catch{}finally{E(this,Yr,!1)}}})}connectedCallback(){m(this,ri,tv).call(this)}}_a=new WeakMap,Sa=new WeakMap,Yr=new WeakMap,ri=new WeakSet,ev=function(){for(const t of c(this,_a).servers.values())return t;return null},ka=new WeakMap,tv=function(){Pe(F`
|
|
323
|
-
<button
|
|
324
|
-
icon-only
|
|
325
|
-
class="new-screen"
|
|
326
|
-
type="button"
|
|
327
|
-
aria-label="New screen"
|
|
328
|
-
@click=${c(this,ka)}
|
|
329
|
-
>
|
|
330
|
-
${UR({size:16,weight:"bold"})}
|
|
331
|
-
</button>
|
|
332
|
-
`,this)};function lO(n){const e=n.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),t=n.getHours(),r=t%12===0?12:t%12,i=n.getMinutes().toString().padStart(2,"0"),s=t>=12?"pm":"am";return`${e} at ${r}:${i}${s}`}customElements.define("screen-create-button",aO);function cO(n,e){let t=null;const r=()=>e((t==null?void 0:t.messages)??[]),i=()=>{const o=n.getActiveClient();o!==t&&(t==null||t.removeEventListener("change",r),t=o,t&&(t.addEventListener("change",r),t.connect().catch(a=>{console.error("ACPClient.connect() failed",a)})),r())};n.addEventListener("change",i),i();const s=()=>{n.removeEventListener("change",i),t==null||t.removeEventListener("change",r),t=null};return{dispose:s,[Symbol.dispose](){s()}}}/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */const{entries:nv,setPrototypeOf:Wf,isFrozen:uO,getPrototypeOf:hO,getOwnPropertyDescriptor:dO}=Object;let{freeze:Ne,seal:it,create:Zo}=Object,{apply:Hc,construct:Vc}=typeof Reflect<"u"&&Reflect;Ne||(Ne=function(e){return e});it||(it=function(e){return e});Hc||(Hc=function(e,t){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];return e.apply(t,i)});Vc||(Vc=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return new e(...r)});const Eo=Ue(Array.prototype.forEach),fO=Ue(Array.prototype.lastIndexOf),qf=Ue(Array.prototype.pop),xi=Ue(Array.prototype.push),pO=Ue(Array.prototype.splice),Ho=Ue(String.prototype.toLowerCase),Gl=Ue(String.prototype.toString),Bl=Ue(String.prototype.match),Ti=Ue(String.prototype.replace),gO=Ue(String.prototype.indexOf),mO=Ue(String.prototype.trim),qe=Ue(Object.prototype.hasOwnProperty),De=Ue(RegExp.prototype.test),Ci=yO(TypeError);function Ue(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return Hc(n,e,r)}}function yO(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Vc(n,t)}}function V(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ho;Wf&&Wf(n,null);let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){const s=t(i);s!==i&&(uO(e)||(e[r]=s),i=s)}n[i]=!0}return n}function vO(n){for(let e=0;e<n.length;e++)qe(n,e)||(n[e]=null);return n}function bt(n){const e=Zo(null);for(const[t,r]of nv(n))qe(n,t)&&(Array.isArray(r)?e[t]=vO(r):r&&typeof r=="object"&&r.constructor===Object?e[t]=bt(r):e[t]=r);return e}function Ii(n,e){for(;n!==null;){const r=dO(n,e);if(r){if(r.get)return Ue(r.get);if(typeof r.value=="function")return Ue(r.value)}n=hO(n)}function t(){return null}return t}const Yf=Ne(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Wl=Ne(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),ql=Ne(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),bO=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"]),Yl=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"]),wO=Ne(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Kf=Ne(["#text"]),Jf=Ne(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Kl=Ne(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Xf=Ne(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),$o=Ne(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),_O=it(/\{\{[\w\W]*|[\w\W]*\}\}/gm),SO=it(/<%[\w\W]*|[\w\W]*%>/gm),kO=it(/\$\{[\w\W]*/gm),EO=it(/^data-[\-\w.\u00B7-\uFFFF]+$/),$O=it(/^aria-[\-\w]+$/),rv=it(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),AO=it(/^(?:\w+script|data):/i),xO=it(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),iv=it(/^html$/i),TO=it(/^[a-z][.\w]*(-[.\w]+)+$/i);var Qf=Object.freeze({__proto__:null,ARIA_ATTR:$O,ATTR_WHITESPACE:xO,CUSTOM_ELEMENT:TO,DATA_ATTR:EO,DOCTYPE_NAME:iv,ERB_EXPR:SO,IS_ALLOWED_URI:rv,IS_SCRIPT_OR_DATA:AO,MUSTACHE_EXPR:_O,TMPLIT_EXPR:kO});const Pi={element:1,text:3,progressingInstruction:7,comment:8,document:9},CO=function(){return typeof window>"u"?null:window},IO=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(r=t.getAttribute(i));const s="dompurify"+(r?"#"+r:"");try{return e.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},ep=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function sv(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:CO();const e=L=>sv(L);if(e.version="3.3.3",e.removed=[],!n||!n.document||n.document.nodeType!==Pi.document||!n.Element)return e.isSupported=!1,e;let{document:t}=n;const r=t,i=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:u,NamedNodeMap:d=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:f,DOMParser:v,trustedTypes:y}=n,A=l.prototype,k=Ii(A,"cloneNode"),I=Ii(A,"remove"),G=Ii(A,"nextSibling"),P=Ii(A,"childNodes"),le=Ii(A,"parentNode");if(typeof o=="function"){const L=t.createElement("template");L.content&&L.content.ownerDocument&&(t=L.content.ownerDocument)}let M,Z="";const{implementation:U,createNodeIterator:ge,createDocumentFragment:ce,getElementsByTagName:yi}=t,{importNode:Xs}=r;let $e=ep();e.isSupported=typeof nv=="function"&&typeof le=="function"&&U&&U.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:kn,ERB_EXPR:pt,TMPLIT_EXPR:Xt,DATA_ATTR:Ga,ARIA_ATTR:Qs,IS_SCRIPT_OR_DATA:Sv,ATTR_WHITESPACE:eh,CUSTOM_ELEMENT:kv}=Qf;let{IS_ALLOWED_URI:th}=Qf,_e=null;const nh=V({},[...Yf,...Wl,...ql,...Yl,...Kf]);let Ae=null;const rh=V({},[...Jf,...Kl,...Xf,...$o]);let me=Object.seal(Zo(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),vi=null,eo=null;const Qt=Object.seal(Zo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ih=!0,Ba=!0,sh=!1,oh=!0,hr=!1,to=!0,En=!1,Wa=!1,qa=!1,dr=!1,no=!1,ro=!1,ah=!0,lh=!1;const Ev="user-content-";let Ya=!0,bi=!1,fr={},gt=null;const Ka=V({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ch=null;const uh=V({},["audio","video","img","source","image","track"]);let Ja=null;const hh=V({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),io="http://www.w3.org/1998/Math/MathML",so="http://www.w3.org/2000/svg",Ct="http://www.w3.org/1999/xhtml";let pr=Ct,Xa=!1,Qa=null;const $v=V({},[io,so,Ct],Gl);let oo=V({},["mi","mo","mn","ms","mtext"]),ao=V({},["annotation-xml"]);const Av=V({},["title","style","font","a","script"]);let wi=null;const xv=["application/xhtml+xml","text/html"],Tv="text/html";let be=null,gr=null;const Cv=t.createElement("form"),dh=function(g){return g instanceof RegExp||g instanceof Function},el=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(gr&&gr===g)){if((!g||typeof g!="object")&&(g={}),g=bt(g),wi=xv.indexOf(g.PARSER_MEDIA_TYPE)===-1?Tv:g.PARSER_MEDIA_TYPE,be=wi==="application/xhtml+xml"?Gl:Ho,_e=qe(g,"ALLOWED_TAGS")?V({},g.ALLOWED_TAGS,be):nh,Ae=qe(g,"ALLOWED_ATTR")?V({},g.ALLOWED_ATTR,be):rh,Qa=qe(g,"ALLOWED_NAMESPACES")?V({},g.ALLOWED_NAMESPACES,Gl):$v,Ja=qe(g,"ADD_URI_SAFE_ATTR")?V(bt(hh),g.ADD_URI_SAFE_ATTR,be):hh,ch=qe(g,"ADD_DATA_URI_TAGS")?V(bt(uh),g.ADD_DATA_URI_TAGS,be):uh,gt=qe(g,"FORBID_CONTENTS")?V({},g.FORBID_CONTENTS,be):Ka,vi=qe(g,"FORBID_TAGS")?V({},g.FORBID_TAGS,be):bt({}),eo=qe(g,"FORBID_ATTR")?V({},g.FORBID_ATTR,be):bt({}),fr=qe(g,"USE_PROFILES")?g.USE_PROFILES:!1,ih=g.ALLOW_ARIA_ATTR!==!1,Ba=g.ALLOW_DATA_ATTR!==!1,sh=g.ALLOW_UNKNOWN_PROTOCOLS||!1,oh=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,hr=g.SAFE_FOR_TEMPLATES||!1,to=g.SAFE_FOR_XML!==!1,En=g.WHOLE_DOCUMENT||!1,dr=g.RETURN_DOM||!1,no=g.RETURN_DOM_FRAGMENT||!1,ro=g.RETURN_TRUSTED_TYPE||!1,qa=g.FORCE_BODY||!1,ah=g.SANITIZE_DOM!==!1,lh=g.SANITIZE_NAMED_PROPS||!1,Ya=g.KEEP_CONTENT!==!1,bi=g.IN_PLACE||!1,th=g.ALLOWED_URI_REGEXP||rv,pr=g.NAMESPACE||Ct,oo=g.MATHML_TEXT_INTEGRATION_POINTS||oo,ao=g.HTML_INTEGRATION_POINTS||ao,me=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&dh(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(me.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&dh(g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(me.attributeNameCheck=g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),g.CUSTOM_ELEMENT_HANDLING&&typeof g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(me.allowCustomizedBuiltInElements=g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),hr&&(Ba=!1),no&&(dr=!0),fr&&(_e=V({},Kf),Ae=Zo(null),fr.html===!0&&(V(_e,Yf),V(Ae,Jf)),fr.svg===!0&&(V(_e,Wl),V(Ae,Kl),V(Ae,$o)),fr.svgFilters===!0&&(V(_e,ql),V(Ae,Kl),V(Ae,$o)),fr.mathMl===!0&&(V(_e,Yl),V(Ae,Xf),V(Ae,$o))),qe(g,"ADD_TAGS")||(Qt.tagCheck=null),qe(g,"ADD_ATTR")||(Qt.attributeCheck=null),g.ADD_TAGS&&(typeof g.ADD_TAGS=="function"?Qt.tagCheck=g.ADD_TAGS:(_e===nh&&(_e=bt(_e)),V(_e,g.ADD_TAGS,be))),g.ADD_ATTR&&(typeof g.ADD_ATTR=="function"?Qt.attributeCheck=g.ADD_ATTR:(Ae===rh&&(Ae=bt(Ae)),V(Ae,g.ADD_ATTR,be))),g.ADD_URI_SAFE_ATTR&&V(Ja,g.ADD_URI_SAFE_ATTR,be),g.FORBID_CONTENTS&&(gt===Ka&&(gt=bt(gt)),V(gt,g.FORBID_CONTENTS,be)),g.ADD_FORBID_CONTENTS&&(gt===Ka&&(gt=bt(gt)),V(gt,g.ADD_FORBID_CONTENTS,be)),Ya&&(_e["#text"]=!0),En&&V(_e,["html","head","body"]),_e.table&&(V(_e,["tbody"]),delete vi.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ci('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ci('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');M=g.TRUSTED_TYPES_POLICY,Z=M.createHTML("")}else M===void 0&&(M=IO(y,i)),M!==null&&typeof Z=="string"&&(Z=M.createHTML(""));Ne&&Ne(g),gr=g}},fh=V({},[...Wl,...ql,...bO]),ph=V({},[...Yl,...wO]),Iv=function(g){let T=le(g);(!T||!T.tagName)&&(T={namespaceURI:pr,tagName:"template"});const R=Ho(g.tagName),ie=Ho(T.tagName);return Qa[g.namespaceURI]?g.namespaceURI===so?T.namespaceURI===Ct?R==="svg":T.namespaceURI===io?R==="svg"&&(ie==="annotation-xml"||oo[ie]):!!fh[R]:g.namespaceURI===io?T.namespaceURI===Ct?R==="math":T.namespaceURI===so?R==="math"&&ao[ie]:!!ph[R]:g.namespaceURI===Ct?T.namespaceURI===so&&!ao[ie]||T.namespaceURI===io&&!oo[ie]?!1:!ph[R]&&(Av[R]||!fh[R]):!!(wi==="application/xhtml+xml"&&Qa[g.namespaceURI]):!1},mt=function(g){xi(e.removed,{element:g});try{le(g).removeChild(g)}catch{I(g)}},$n=function(g,T){try{xi(e.removed,{attribute:T.getAttributeNode(g),from:T})}catch{xi(e.removed,{attribute:null,from:T})}if(T.removeAttribute(g),g==="is")if(dr||no)try{mt(T)}catch{}else try{T.setAttribute(g,"")}catch{}},gh=function(g){let T=null,R=null;if(qa)g="<remove></remove>"+g;else{const ye=Bl(g,/^[\r\n\t ]+/);R=ye&&ye[0]}wi==="application/xhtml+xml"&&pr===Ct&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const ie=M?M.createHTML(g):g;if(pr===Ct)try{T=new v().parseFromString(ie,wi)}catch{}if(!T||!T.documentElement){T=U.createDocument(pr,"template",null);try{T.documentElement.innerHTML=Xa?Z:ie}catch{}}const Re=T.body||T.documentElement;return g&&R&&Re.insertBefore(t.createTextNode(R),Re.childNodes[0]||null),pr===Ct?yi.call(T,En?"html":"body")[0]:En?T.documentElement:Re},mh=function(g){return ge.call(g.ownerDocument||g,g,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},tl=function(g){return g instanceof f&&(typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||!(g.attributes instanceof d)||typeof g.removeAttribute!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function")},yh=function(g){return typeof a=="function"&&g instanceof a};function It(L,g,T){Eo(L,R=>{R.call(e,g,T,gr)})}const vh=function(g){let T=null;if(It($e.beforeSanitizeElements,g,null),tl(g))return mt(g),!0;const R=be(g.nodeName);if(It($e.uponSanitizeElement,g,{tagName:R,allowedTags:_e}),to&&g.hasChildNodes()&&!yh(g.firstElementChild)&&De(/<[/\w!]/g,g.innerHTML)&&De(/<[/\w!]/g,g.textContent)||g.nodeType===Pi.progressingInstruction||to&&g.nodeType===Pi.comment&&De(/<[/\w]/g,g.data))return mt(g),!0;if(!(Qt.tagCheck instanceof Function&&Qt.tagCheck(R))&&(!_e[R]||vi[R])){if(!vi[R]&&wh(R)&&(me.tagNameCheck instanceof RegExp&&De(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R)))return!1;if(Ya&&!gt[R]){const ie=le(g)||g.parentNode,Re=P(g)||g.childNodes;if(Re&&ie){const ye=Re.length;for(let Fe=ye-1;Fe>=0;--Fe){const Pt=k(Re[Fe],!0);Pt.__removalCount=(g.__removalCount||0)+1,ie.insertBefore(Pt,G(g))}}}return mt(g),!0}return g instanceof l&&!Iv(g)||(R==="noscript"||R==="noembed"||R==="noframes")&&De(/<\/no(script|embed|frames)/i,g.innerHTML)?(mt(g),!0):(hr&&g.nodeType===Pi.text&&(T=g.textContent,Eo([kn,pt,Xt],ie=>{T=Ti(T,ie," ")}),g.textContent!==T&&(xi(e.removed,{element:g.cloneNode()}),g.textContent=T)),It($e.afterSanitizeElements,g,null),!1)},bh=function(g,T,R){if(eo[T]||ah&&(T==="id"||T==="name")&&(R in t||R in Cv))return!1;if(!(Ba&&!eo[T]&&De(Ga,T))){if(!(ih&&De(Qs,T))){if(!(Qt.attributeCheck instanceof Function&&Qt.attributeCheck(T,g))){if(!Ae[T]||eo[T]){if(!(wh(g)&&(me.tagNameCheck instanceof RegExp&&De(me.tagNameCheck,g)||me.tagNameCheck instanceof Function&&me.tagNameCheck(g))&&(me.attributeNameCheck instanceof RegExp&&De(me.attributeNameCheck,T)||me.attributeNameCheck instanceof Function&&me.attributeNameCheck(T,g))||T==="is"&&me.allowCustomizedBuiltInElements&&(me.tagNameCheck instanceof RegExp&&De(me.tagNameCheck,R)||me.tagNameCheck instanceof Function&&me.tagNameCheck(R))))return!1}else if(!Ja[T]){if(!De(th,Ti(R,eh,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&g!=="script"&&gO(R,"data:")===0&&ch[g])){if(!(sh&&!De(Sv,Ti(R,eh,"")))){if(R)return!1}}}}}}}return!0},wh=function(g){return g!=="annotation-xml"&&Bl(g,kv)},_h=function(g){It($e.beforeSanitizeAttributes,g,null);const{attributes:T}=g;if(!T||tl(g))return;const R={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ae,forceKeepAttr:void 0};let ie=T.length;for(;ie--;){const Re=T[ie],{name:ye,namespaceURI:Fe,value:Pt}=Re,mr=be(ye),nl=Pt;let xe=ye==="value"?nl:mO(nl);if(R.attrName=mr,R.attrValue=xe,R.keepAttr=!0,R.forceKeepAttr=void 0,It($e.uponSanitizeAttribute,g,R),xe=R.attrValue,lh&&(mr==="id"||mr==="name")&&($n(ye,g),xe=Ev+xe),to&&De(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,xe)){$n(ye,g);continue}if(mr==="attributename"&&Bl(xe,"href")){$n(ye,g);continue}if(R.forceKeepAttr)continue;if(!R.keepAttr){$n(ye,g);continue}if(!oh&&De(/\/>/i,xe)){$n(ye,g);continue}hr&&Eo([kn,pt,Xt],kh=>{xe=Ti(xe,kh," ")});const Sh=be(g.nodeName);if(!bh(Sh,mr,xe)){$n(ye,g);continue}if(M&&typeof y=="object"&&typeof y.getAttributeType=="function"&&!Fe)switch(y.getAttributeType(Sh,mr)){case"TrustedHTML":{xe=M.createHTML(xe);break}case"TrustedScriptURL":{xe=M.createScriptURL(xe);break}}if(xe!==nl)try{Fe?g.setAttributeNS(Fe,ye,xe):g.setAttribute(ye,xe),tl(g)?mt(g):qf(e.removed)}catch{$n(ye,g)}}It($e.afterSanitizeAttributes,g,null)},Pv=function L(g){let T=null;const R=mh(g);for(It($e.beforeSanitizeShadowDOM,g,null);T=R.nextNode();)It($e.uponSanitizeShadowNode,T,null),vh(T),_h(T),T.content instanceof s&&L(T.content);It($e.afterSanitizeShadowDOM,g,null)};return e.sanitize=function(L){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,R=null,ie=null,Re=null;if(Xa=!L,Xa&&(L="<!-->"),typeof L!="string"&&!yh(L))if(typeof L.toString=="function"){if(L=L.toString(),typeof L!="string")throw Ci("dirty is not a string, aborting")}else throw Ci("toString is not a function");if(!e.isSupported)return L;if(Wa||el(g),e.removed=[],typeof L=="string"&&(bi=!1),bi){if(L.nodeName){const Pt=be(L.nodeName);if(!_e[Pt]||vi[Pt])throw Ci("root node is forbidden and cannot be sanitized in-place")}}else if(L instanceof a)T=gh("<!---->"),R=T.ownerDocument.importNode(L,!0),R.nodeType===Pi.element&&R.nodeName==="BODY"||R.nodeName==="HTML"?T=R:T.appendChild(R);else{if(!dr&&!hr&&!En&&L.indexOf("<")===-1)return M&&ro?M.createHTML(L):L;if(T=gh(L),!T)return dr?null:ro?Z:""}T&&qa&&mt(T.firstChild);const ye=mh(bi?L:T);for(;ie=ye.nextNode();)vh(ie),_h(ie),ie.content instanceof s&&Pv(ie.content);if(bi)return L;if(dr){if(no)for(Re=ce.call(T.ownerDocument);T.firstChild;)Re.appendChild(T.firstChild);else Re=T;return(Ae.shadowroot||Ae.shadowrootmode)&&(Re=Xs.call(r,Re,!0)),Re}let Fe=En?T.outerHTML:T.innerHTML;return En&&_e["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&De(iv,T.ownerDocument.doctype.name)&&(Fe="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
|
|
333
|
-
`+Fe),hr&&Eo([kn,pt,Xt],Pt=>{Fe=Ti(Fe,Pt," ")}),M&&ro?M.createHTML(Fe):Fe},e.setConfig=function(){let L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};el(L),Wa=!0},e.clearConfig=function(){gr=null,Wa=!1},e.isValidAttribute=function(L,g,T){gr||el({});const R=be(L),ie=be(g);return bh(R,ie,T)},e.addHook=function(L,g){typeof g=="function"&&xi($e[L],g)},e.removeHook=function(L,g){if(g!==void 0){const T=fO($e[L],g);return T===-1?void 0:pO($e[L],T,1)[0]}return qf($e[L])},e.removeHooks=function(L){$e[L]=[]},e.removeAllHooks=function(){$e=ep()},e}var ov=sv();function Vu(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ur=Vu();function av(n){ur=n}var Dn={exec:()=>null};function W(n,e=""){let t=typeof n=="string"?n:n.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(Le.caret,"$1"),t=t.replace(i,o),r},getRegex:()=>new RegExp(t,e)};return r}var PO=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Le={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}>`)},RO=/^(?:[ \t]*(?:\n|$))+/,DO=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,OO=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Js=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,zO=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ju=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,lv=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,cv=W(lv).replace(/bull/g,ju).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),LO=W(lv).replace(/bull/g,ju).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Gu=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,MO=/^[^\n]+/,Bu=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,NO=W(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Bu).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),UO=W(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ju).getRegex(),Ha="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Wu=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,FO=W("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Wu).replace("tag",Ha).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),uv=W(Gu).replace("hr",Js).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",Ha).getRegex(),ZO=W(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",uv).getRegex(),qu={blockquote:ZO,code:DO,def:NO,fences:OO,heading:zO,hr:Js,html:FO,lheading:cv,list:UO,newline:RO,paragraph:uv,table:Dn,text:MO},tp=W("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Js).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",Ha).getRegex(),HO={...qu,lheading:LO,table:tp,paragraph:W(Gu).replace("hr",Js).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",tp).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ha).getRegex()},VO={...qu,html:W(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Wu).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Dn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:W(Gu).replace("hr",Js).replace("heading",` *#{1,6} *[^
|
|
334
|
-
]`).replace("lheading",cv).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},jO=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,GO=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,hv=/^( {2,}|\\)\n(?!\s*$)/,BO=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,mi=/[\p{P}\p{S}]/u,Va=/[\s\p{P}\p{S}]/u,Yu=/[^\s\p{P}\p{S}]/u,WO=W(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Va).getRegex(),dv=/(?!~)[\p{P}\p{S}]/u,qO=/(?!~)[\s\p{P}\p{S}]/u,YO=/(?:[^\s\p{P}\p{S}]|~)/u,KO=W(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",PO?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),fv=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,JO=W(fv,"u").replace(/punct/g,mi).getRegex(),XO=W(fv,"u").replace(/punct/g,dv).getRegex(),pv="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",QO=W(pv,"gu").replace(/notPunctSpace/g,Yu).replace(/punctSpace/g,Va).replace(/punct/g,mi).getRegex(),ez=W(pv,"gu").replace(/notPunctSpace/g,YO).replace(/punctSpace/g,qO).replace(/punct/g,dv).getRegex(),tz=W("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Yu).replace(/punctSpace/g,Va).replace(/punct/g,mi).getRegex(),nz=W(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,mi).getRegex(),rz="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",iz=W(rz,"gu").replace(/notPunctSpace/g,Yu).replace(/punctSpace/g,Va).replace(/punct/g,mi).getRegex(),sz=W(/\\(punct)/,"gu").replace(/punct/g,mi).getRegex(),oz=W(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),az=W(Wu).replace("(?:-->|$)","-->").getRegex(),lz=W("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",az).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ia=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,cz=W(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ia).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),gv=W(/^!?\[(label)\]\[(ref)\]/).replace("label",ia).replace("ref",Bu).getRegex(),mv=W(/^!?\[(ref)\](?:\[\])?/).replace("ref",Bu).getRegex(),uz=W("reflink|nolink(?!\\()","g").replace("reflink",gv).replace("nolink",mv).getRegex(),np=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ku={_backpedal:Dn,anyPunctuation:sz,autolink:oz,blockSkip:KO,br:hv,code:GO,del:Dn,delLDelim:Dn,delRDelim:Dn,emStrongLDelim:JO,emStrongRDelimAst:QO,emStrongRDelimUnd:tz,escape:jO,link:cz,nolink:mv,punctuation:WO,reflink:gv,reflinkSearch:uz,tag:lz,text:BO,url:Dn},hz={...Ku,link:W(/^!?\[(label)\]\((.*?)\)/).replace("label",ia).getRegex(),reflink:W(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ia).getRegex()},jc={...Ku,emStrongRDelimAst:ez,emStrongLDelim:XO,delLDelim:nz,delRDelim:iz,url:W(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",np).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:W(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",np).getRegex()},dz={...jc,br:W(hv).replace("{2,}","*").getRegex(),text:W(jc.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ao={normal:qu,gfm:HO,pedantic:VO},Ri={normal:Ku,gfm:jc,breaks:dz,pedantic:hz},fz={"&":"&","<":"<",">":">",'"':""","'":"'"},rp=n=>fz[n];function wt(n,e){if(e){if(Le.escapeTest.test(n))return n.replace(Le.escapeReplace,rp)}else if(Le.escapeTestNoEncode.test(n))return n.replace(Le.escapeReplaceNoEncode,rp);return n}function ip(n){try{n=encodeURI(n).replace(Le.percentDecode,"%")}catch{return null}return n}function sp(n,e){var s;let t=n.replace(Le.findPipe,(o,a,l)=>{let u=!1,d=a;for(;--d>=0&&l[d]==="\\";)u=!u;return u?"|":" |"}),r=t.split(Le.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!((s=r.at(-1))!=null&&s.trim())&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Le.slashPipe,"|");return r}function Di(n,e,t){let r=n.length;if(r===0)return"";let i=0;for(;i<r&&n.charAt(r-i-1)===e;)i++;return n.slice(0,r-i)}function pz(n,e){if(n.indexOf(e[1])===-1)return-1;let t=0;for(let r=0;r<n.length;r++)if(n[r]==="\\")r++;else if(n[r]===e[0])t++;else if(n[r]===e[1]&&(t--,t<0))return r;return t>0?-2:-1}function gz(n,e=0){let t=e,r="";for(let i of n)if(i===" "){let s=4-t%4;r+=" ".repeat(s),t+=s}else r+=i,t++;return r}function op(n,e,t,r,i){let s=e.href,o=e.title||null,a=n[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:n[0].charAt(0)==="!"?"image":"link",raw:t,href:s,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,l}function mz(n,e,t){let r=n.match(t.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
|
|
335
|
-
`).map(s=>{let o=s.match(t.other.beginningSpace);if(o===null)return s;let[a]=o;return a.length>=i.length?s.slice(i.length):s}).join(`
|
|
336
|
-
`)}var sa=class{constructor(n){b(this,"options");b(this,"rules");b(this,"lexer");this.options=n||ur}space(n){let e=this.rules.block.newline.exec(n);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(n){let e=this.rules.block.code.exec(n);if(e){let t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:Di(t,`
|
|
337
|
-
`)}}}fences(n){let e=this.rules.block.fences.exec(n);if(e){let t=e[0],r=mz(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(n){let e=this.rules.block.heading.exec(n);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let r=Di(t,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(t=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(n){let e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:Di(e[0],`
|
|
338
|
-
`)}}blockquote(n){let e=this.rules.block.blockquote.exec(n);if(e){let t=Di(e[0],`
|
|
339
|
-
`).split(`
|
|
340
|
-
`),r="",i="",s=[];for(;t.length>0;){let o=!1,a=[],l;for(l=0;l<t.length;l++)if(this.rules.other.blockquoteStart.test(t[l]))a.push(t[l]),o=!0;else if(!o)a.push(t[l]);else break;t=t.slice(l);let u=a.join(`
|
|
341
|
-
`),d=u.replace(this.rules.other.blockquoteSetextReplace,`
|
|
342
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
343
|
-
${u}`:u,i=i?`${i}
|
|
344
|
-
${d}`:d;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,s,!0),this.lexer.state.top=f,t.length===0)break;let v=s.at(-1);if((v==null?void 0:v.type)==="code")break;if((v==null?void 0:v.type)==="blockquote"){let y=v,A=y.raw+`
|
|
345
|
-
`+t.join(`
|
|
346
|
-
`),k=this.blockquote(A);s[s.length-1]=k,r=r.substring(0,r.length-y.raw.length)+k.raw,i=i.substring(0,i.length-y.text.length)+k.text;break}else if((v==null?void 0:v.type)==="list"){let y=v,A=y.raw+`
|
|
347
|
-
`+t.join(`
|
|
348
|
-
`),k=this.list(A);s[s.length-1]=k,r=r.substring(0,r.length-v.raw.length)+k.raw,i=i.substring(0,i.length-y.raw.length)+k.raw,t=A.substring(s.at(-1).raw.length).split(`
|
|
349
|
-
`);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(n){var t,r;let e=this.rules.block.list.exec(n);if(e){let i=e[1].trim(),s=i.length>1,o={type:"list",raw:"",ordered:s,start:s?+i.slice(0,-1):"",loose:!1,items:[]};i=s?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=s?i:"[*+-]");let a=this.rules.other.listItemRegex(i),l=!1;for(;n;){let d=!1,f="",v="";if(!(e=a.exec(n))||this.rules.block.hr.test(n))break;f=e[0],n=n.substring(f.length);let y=gz(e[2].split(`
|
|
350
|
-
`,1)[0],e[1].length),A=n.split(`
|
|
351
|
-
`,1)[0],k=!y.trim(),I=0;if(this.options.pedantic?(I=2,v=y.trimStart()):k?I=e[1].length+1:(I=y.search(this.rules.other.nonSpaceChar),I=I>4?1:I,v=y.slice(I),I+=e[1].length),k&&this.rules.other.blankLine.test(A)&&(f+=A+`
|
|
352
|
-
`,n=n.substring(A.length+1),d=!0),!d){let G=this.rules.other.nextBulletRegex(I),P=this.rules.other.hrRegex(I),le=this.rules.other.fencesBeginRegex(I),M=this.rules.other.headingBeginRegex(I),Z=this.rules.other.htmlBeginRegex(I),U=this.rules.other.blockquoteBeginRegex(I);for(;n;){let ge=n.split(`
|
|
353
|
-
`,1)[0],ce;if(A=ge,this.options.pedantic?(A=A.replace(this.rules.other.listReplaceNesting," "),ce=A):ce=A.replace(this.rules.other.tabCharGlobal," "),le.test(A)||M.test(A)||Z.test(A)||U.test(A)||G.test(A)||P.test(A))break;if(ce.search(this.rules.other.nonSpaceChar)>=I||!A.trim())v+=`
|
|
354
|
-
`+ce.slice(I);else{if(k||y.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||le.test(y)||M.test(y)||P.test(y))break;v+=`
|
|
355
|
-
`+A}k=!A.trim(),f+=ge+`
|
|
356
|
-
`,n=n.substring(ge.length+1),y=ce.slice(I)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(f)&&(l=!0)),o.items.push({type:"list_item",raw:f,task:!!this.options.gfm&&this.rules.other.listIsTask.test(v),loose:!1,text:v,tokens:[]}),o.raw+=f}let u=o.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let d of o.items){if(this.lexer.state.top=!1,d.tokens=this.lexer.blockTokens(d.text,[]),d.task){if(d.text=d.text.replace(this.rules.other.listReplaceTask,""),((t=d.tokens[0])==null?void 0:t.type)==="text"||((r=d.tokens[0])==null?void 0:r.type)==="paragraph"){d.tokens[0].raw=d.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),d.tokens[0].text=d.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let v=this.lexer.inlineQueue.length-1;v>=0;v--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[v].src)){this.lexer.inlineQueue[v].src=this.lexer.inlineQueue[v].src.replace(this.rules.other.listReplaceTask,"");break}}let f=this.rules.other.listTaskCheckbox.exec(d.raw);if(f){let v={type:"checkbox",raw:f[0]+" ",checked:f[0]!=="[ ]"};d.checked=v.checked,o.loose?d.tokens[0]&&["paragraph","text"].includes(d.tokens[0].type)&&"tokens"in d.tokens[0]&&d.tokens[0].tokens?(d.tokens[0].raw=v.raw+d.tokens[0].raw,d.tokens[0].text=v.raw+d.tokens[0].text,d.tokens[0].tokens.unshift(v)):d.tokens.unshift({type:"paragraph",raw:v.raw,text:v.raw,tokens:[v]}):d.tokens.unshift(v)}}if(!o.loose){let f=d.tokens.filter(y=>y.type==="space"),v=f.length>0&&f.some(y=>this.rules.other.anyLine.test(y.raw));o.loose=v}}if(o.loose)for(let d of o.items){d.loose=!0;for(let f of d.tokens)f.type==="text"&&(f.type="paragraph")}return o}}html(n){let e=this.rules.block.html.exec(n);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(n){let e=this.rules.block.def.exec(n);if(e){let t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:e[0],href:r,title:i}}}table(n){var o;let e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=sp(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(o=e[3])!=null&&o.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
357
|
-
`):[],s={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?s.align.push("right"):this.rules.other.tableAlignCenter.test(a)?s.align.push("center"):this.rules.other.tableAlignLeft.test(a)?s.align.push("left"):s.align.push(null);for(let a=0;a<t.length;a++)s.header.push({text:t[a],tokens:this.lexer.inline(t[a]),header:!0,align:s.align[a]});for(let a of i)s.rows.push(sp(a,s.header.length).map((l,u)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:s.align[u]})));return s}}lheading(n){let e=this.rules.block.lheading.exec(n);if(e){let t=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:t,tokens:this.lexer.inline(t)}}}paragraph(n){let e=this.rules.block.paragraph.exec(n);if(e){let t=e[1].charAt(e[1].length-1)===`
|
|
358
|
-
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(n){let e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){let e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){let e=this.rules.inline.tag.exec(n);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(n){let e=this.rules.inline.link.exec(n);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let s=Di(t.slice(0,-1),"\\");if((t.length-s.length)%2===0)return}else{let s=pz(e[2],"()");if(s===-2)return;if(s>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+s;e[2]=e[2].substring(0,s),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let r=e[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3])}else i=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?r=r.slice(1):r=r.slice(1,-1)),op(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let t;if((t=this.rules.inline.reflink.exec(n))||(t=this.rules.inline.nolink.exec(n))){let r=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){let s=t[0].charAt(0);return{type:"text",raw:s,text:s}}return op(t,i,t[0],this.lexer,this.rules)}}emStrong(n,e,t=""){let r=this.rules.inline.emStrongLDelim.exec(n);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!t||this.rules.inline.punctuation.exec(t))){let i=[...r[0]].length-1,s,o,a=i,l=0,u=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*n.length+i);(r=u.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(o=[...s].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&i%3&&!((i+o)%3)){l+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+l);let d=[...r[0]][0].length,f=n.slice(0,i+r.index+d+o);if(Math.min(i,o)%2){let y=f.slice(1,-1);return{type:"em",raw:f,text:y,tokens:this.lexer.inlineTokens(y)}}let v=f.slice(2,-2);return{type:"strong",raw:f,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(n){let e=this.rules.inline.code.exec(n);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(t),i=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return r&&i&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(n){let e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n,e,t=""){let r=this.rules.inline.delLDelim.exec(n);if(r&&(!r[1]||!t||this.rules.inline.punctuation.exec(t))){let i=[...r[0]].length-1,s,o,a=i,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*n.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=n.slice(0,i+r.index+u+o),f=d.slice(i,-i);return{type:"del",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}}}autolink(n){let e=this.rules.inline.autolink.exec(n);if(e){let t,r;return e[2]==="@"?(t=e[1],r="mailto:"+t):(t=e[1],r=t),{type:"link",raw:e[0],text:t,href:r,tokens:[{type:"text",raw:t,text:t}]}}}url(n){var t;let e;if(e=this.rules.inline.url.exec(n)){let r,i;if(e[2]==="@")r=e[0],i="mailto:"+r;else{let s;do s=e[0],e[0]=((t=this.rules.inline._backpedal.exec(e[0]))==null?void 0:t[0])??"";while(s!==e[0]);r=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0]}return{type:"link",raw:e[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(n){let e=this.rules.inline.text.exec(n);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},dt=class Gc{constructor(e){b(this,"tokens");b(this,"options");b(this,"state");b(this,"inlineQueue");b(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ur,this.options.tokenizer=this.options.tokenizer||new sa,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:Le,block:Ao.normal,inline:Ri.normal};this.options.pedantic?(t.block=Ao.pedantic,t.inline=Ri.pedantic):this.options.gfm&&(t.block=Ao.gfm,this.options.breaks?t.inline=Ri.breaks:t.inline=Ri.gfm),this.tokenizer.rules=t}static get rules(){return{block:Ao,inline:Ri}}static lex(e,t){return new Gc(t).lex(e)}static lexInline(e,t){return new Gc(t).inlineTokens(e)}lex(e){e=e.replace(Le.carriageReturn,`
|
|
359
|
-
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let r=this.inlineQueue[t];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],r=!1){var i,s,o;for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Le.tabCharGlobal," ").replace(Le.spaceLine,""));e;){let a;if((s=(i=this.options.extensions)==null?void 0:i.block)!=null&&s.some(u=>(a=u.call({lexer:this},e,t))?(e=e.substring(a.raw.length),t.push(a),!0):!1))continue;if(a=this.tokenizer.space(e)){e=e.substring(a.raw.length);let u=t.at(-1);a.raw.length===1&&u!==void 0?u.raw+=`
|
|
360
|
-
`:t.push(a);continue}if(a=this.tokenizer.code(e)){e=e.substring(a.raw.length);let u=t.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
361
|
-
`)?"":`
|
|
362
|
-
`)+a.raw,u.text+=`
|
|
363
|
-
`+a.text,this.inlineQueue.at(-1).src=u.text):t.push(a);continue}if(a=this.tokenizer.fences(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.heading(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.hr(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.blockquote(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.list(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.html(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.def(e)){e=e.substring(a.raw.length);let u=t.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
364
|
-
`)?"":`
|
|
365
|
-
`)+a.raw,u.text+=`
|
|
366
|
-
`+a.raw,this.inlineQueue.at(-1).src=u.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},t.push(a));continue}if(a=this.tokenizer.table(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.lheading(e)){e=e.substring(a.raw.length),t.push(a);continue}let l=e;if((o=this.options.extensions)!=null&&o.startBlock){let u=1/0,d=e.slice(1),f;this.options.extensions.startBlock.forEach(v=>{f=v.call({lexer:this},d),typeof f=="number"&&f>=0&&(u=Math.min(u,f))}),u<1/0&&u>=0&&(l=e.substring(0,u+1))}if(this.state.top&&(a=this.tokenizer.paragraph(l))){let u=t.at(-1);r&&(u==null?void 0:u.type)==="paragraph"?(u.raw+=(u.raw.endsWith(`
|
|
367
|
-
`)?"":`
|
|
368
|
-
`)+a.raw,u.text+=`
|
|
369
|
-
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):t.push(a),r=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=t.at(-1);(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
|
|
370
|
-
`)?"":`
|
|
371
|
-
`)+a.raw,u.text+=`
|
|
372
|
-
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):t.push(a);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){var l,u,d,f,v;this.tokenizer.lexer=this;let r=e,i=null;if(this.tokens.links){let y=Object.keys(this.tokens.links);if(y.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)y.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)s=i[2]?i[2].length:0,r=r.slice(0,i.index+s)+"["+"a".repeat(i[0].length-s-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=((u=(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 y;if((f=(d=this.options.extensions)==null?void 0:d.inline)!=null&&f.some(k=>(y=k.call({lexer:this},e,t))?(e=e.substring(y.raw.length),t.push(y),!0):!1))continue;if(y=this.tokenizer.escape(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.tag(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.link(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(y.raw.length);let k=t.at(-1);y.type==="text"&&(k==null?void 0:k.type)==="text"?(k.raw+=y.raw,k.text+=y.text):t.push(y);continue}if(y=this.tokenizer.emStrong(e,r,a)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.codespan(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.br(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.del(e,r,a)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.autolink(e)){e=e.substring(y.raw.length),t.push(y);continue}if(!this.state.inLink&&(y=this.tokenizer.url(e))){e=e.substring(y.raw.length),t.push(y);continue}let A=e;if((v=this.options.extensions)!=null&&v.startInline){let k=1/0,I=e.slice(1),G;this.options.extensions.startInline.forEach(P=>{G=P.call({lexer:this},I),typeof G=="number"&&G>=0&&(k=Math.min(k,G))}),k<1/0&&k>=0&&(A=e.substring(0,k+1))}if(y=this.tokenizer.inlineText(A)){e=e.substring(y.raw.length),y.raw.slice(-1)!=="_"&&(a=y.raw.slice(-1)),o=!0;let k=t.at(-1);(k==null?void 0:k.type)==="text"?(k.raw+=y.raw,k.text+=y.text):t.push(y);continue}if(e){let k="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(k);break}else throw new Error(k)}}return t}},oa=class{constructor(n){b(this,"options");b(this,"parser");this.options=n||ur}space(n){return""}code({text:n,lang:e,escaped:t}){var s;let r=(s=(e||"").match(Le.notSpaceStart))==null?void 0:s[0],i=n.replace(Le.endingNewline,"")+`
|
|
373
|
-
`;return r?'<pre><code class="language-'+wt(r)+'">'+(t?i:wt(i,!0))+`</code></pre>
|
|
374
|
-
`:"<pre><code>"+(t?i:wt(i,!0))+`</code></pre>
|
|
375
|
-
`}blockquote({tokens:n}){return`<blockquote>
|
|
376
|
-
${this.parser.parse(n)}</blockquote>
|
|
377
|
-
`}html({text:n}){return n}def(n){return""}heading({tokens:n,depth:e}){return`<h${e}>${this.parser.parseInline(n)}</h${e}>
|
|
378
|
-
`}hr(n){return`<hr>
|
|
379
|
-
`}list(n){let e=n.ordered,t=n.start,r="";for(let o=0;o<n.items.length;o++){let a=n.items[o];r+=this.listitem(a)}let i=e?"ol":"ul",s=e&&t!==1?' start="'+t+'"':"";return"<"+i+s+`>
|
|
380
|
-
`+r+"</"+i+`>
|
|
381
|
-
`}listitem(n){return`<li>${this.parser.parse(n.tokens)}</li>
|
|
382
|
-
`}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
|
|
383
|
-
`}table(n){let e="",t="";for(let i=0;i<n.header.length;i++)t+=this.tablecell(n.header[i]);e+=this.tablerow({text:t});let r="";for(let i=0;i<n.rows.length;i++){let s=n.rows[i];t="";for(let o=0;o<s.length;o++)t+=this.tablecell(s[o]);r+=this.tablerow({text:t})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
384
|
-
<thead>
|
|
385
|
-
`+e+`</thead>
|
|
386
|
-
`+r+`</table>
|
|
387
|
-
`}tablerow({text:n}){return`<tr>
|
|
388
|
-
${n}</tr>
|
|
389
|
-
`}tablecell(n){let e=this.parser.parseInline(n.tokens),t=n.header?"th":"td";return(n.align?`<${t} align="${n.align}">`:`<${t}>`)+e+`</${t}>
|
|
390
|
-
`}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${wt(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:t}){let r=this.parser.parseInline(t),i=ip(n);if(i===null)return r;n=i;let s='<a href="'+n+'"';return e&&(s+=' title="'+wt(e)+'"'),s+=">"+r+"</a>",s}image({href:n,title:e,text:t,tokens:r}){r&&(t=this.parser.parseInline(r,this.parser.textRenderer));let i=ip(n);if(i===null)return wt(t);n=i;let s=`<img src="${n}" alt="${wt(t)}"`;return e&&(s+=` title="${wt(e)}"`),s+=">",s}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:wt(n.text)}},Ju=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}checkbox({raw:n}){return n}},ft=class Bc{constructor(e){b(this,"options");b(this,"renderer");b(this,"textRenderer");this.options=e||ur,this.options.renderer=this.options.renderer||new oa,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ju}static parse(e,t){return new Bc(t).parse(e)}static parseInline(e,t){return new Bc(t).parseInline(e)}parse(e){var r,i;this.renderer.parser=this;let t="";for(let s=0;s<e.length;s++){let o=e[s];if((i=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&i[o.type]){let 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)){t+=u||"";continue}}let a=o;switch(a.type){case"space":{t+=this.renderer.space(a);break}case"hr":{t+=this.renderer.hr(a);break}case"heading":{t+=this.renderer.heading(a);break}case"code":{t+=this.renderer.code(a);break}case"table":{t+=this.renderer.table(a);break}case"blockquote":{t+=this.renderer.blockquote(a);break}case"list":{t+=this.renderer.list(a);break}case"checkbox":{t+=this.renderer.checkbox(a);break}case"html":{t+=this.renderer.html(a);break}case"def":{t+=this.renderer.def(a);break}case"paragraph":{t+=this.renderer.paragraph(a);break}case"text":{t+=this.renderer.text(a);break}default:{let l='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return t}parseInline(e,t=this.renderer){var i,s;this.renderer.parser=this;let r="";for(let o=0;o<e.length;o++){let a=e[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[a.type]){let u=this.options.extensions.renderers[a.type].call({parser:this},a);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=u||"";continue}}let l=a;switch(l.type){case"escape":{r+=t.text(l);break}case"html":{r+=t.html(l);break}case"link":{r+=t.link(l);break}case"image":{r+=t.image(l);break}case"checkbox":{r+=t.checkbox(l);break}case"strong":{r+=t.strong(l);break}case"em":{r+=t.em(l);break}case"codespan":{r+=t.codespan(l);break}case"br":{r+=t.br(l);break}case"del":{r+=t.del(l);break}case"text":{r+=t.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}},xo,Vi=(xo=class{constructor(n){b(this,"options");b(this,"block");this.options=n||ur}preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}emStrongMask(n){return n}provideLexer(){return this.block?dt.lex:dt.lexInline}provideParser(){return this.block?ft.parse:ft.parseInline}},b(xo,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),b(xo,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),xo),yz=class{constructor(...n){b(this,"defaults",Vu());b(this,"options",this.setOptions);b(this,"parse",this.parseMarkdown(!0));b(this,"parseInline",this.parseMarkdown(!1));b(this,"Parser",ft);b(this,"Renderer",oa);b(this,"TextRenderer",Ju);b(this,"Lexer",dt);b(this,"Tokenizer",sa);b(this,"Hooks",Vi);this.use(...n)}walkTokens(n,e){var r,i;let t=[];for(let s of n)switch(t=t.concat(e.call(this,s)),s.type){case"table":{let o=s;for(let a of o.header)t=t.concat(this.walkTokens(a.tokens,e));for(let a of o.rows)for(let l of a)t=t.concat(this.walkTokens(l.tokens,e));break}case"list":{let o=s;t=t.concat(this.walkTokens(o.items,e));break}default:{let o=s;(i=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let l=o[a].flat(1/0);t=t.concat(this.walkTokens(l,e))}):o.tokens&&(t=t.concat(this.walkTokens(o.tokens,e)))}}return t}use(...n){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(t=>{let r={...t};if(r.async=this.defaults.async||r.async||!1,t.extensions&&(t.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=s.apply(this,o)),a}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=e[i.level];s?s.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),t.renderer){let i=this.defaults.renderer||new oa(this.defaults);for(let s in t.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=t.renderer[o],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(t.tokenizer){let i=this.defaults.tokenizer||new sa(this.defaults);for(let s in t.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=t.tokenizer[o],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(t.hooks){let i=this.defaults.hooks||new Vi;for(let s in t.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=t.hooks[o],l=i[o];Vi.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&Vi.passThroughHooksRespectAsync.has(s))return(async()=>{let f=await a.call(i,u);return l.call(i,f)})();let d=a.call(i,u);return l.call(i,d)}:i[o]=(...u)=>{if(this.defaults.async)return(async()=>{let f=await a.apply(i,u);return f===!1&&(f=await l.apply(i,u)),f})();let d=a.apply(i,u);return d===!1&&(d=l.apply(i,u)),d}}r.hooks=i}if(t.walkTokens){let i=this.defaults.walkTokens,s=t.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return dt.lex(n,e??this.defaults)}parser(n,e){return ft.parse(n,e??this.defaults)}parseMarkdown(n){return(e,t)=>{let r={...t},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=n),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(e):e,a=await(i.hooks?await i.hooks.provideLexer():n?dt.lex:dt.lexInline)(o,i),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():n?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():n?dt.lex:dt.lexInline)(e,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():n?ft.parse:ft.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(n,e){return t=>{if(t.message+=`
|
|
391
|
-
Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error occurred:</p><pre>"+wt(t.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(t);throw t}}},sr=new yz;function K(n,e){return sr.parse(n,e)}K.options=K.setOptions=function(n){return sr.setOptions(n),K.defaults=sr.defaults,av(K.defaults),K};K.getDefaults=Vu;K.defaults=ur;K.use=function(...n){return sr.use(...n),K.defaults=sr.defaults,av(K.defaults),K};K.walkTokens=function(n,e){return sr.walkTokens(n,e)};K.parseInline=sr.parseInline;K.Parser=ft;K.parser=ft.parse;K.Renderer=oa;K.TextRenderer=Ju;K.Lexer=dt;K.lexer=dt.lex;K.Tokenizer=sa;K.Hooks=Vi;K.parse=K;K.options;K.setOptions;K.use;K.walkTokens;K.parseInline;ft.parse;dt.lex;ov.addHook("afterSanitizeAttributes",n=>{n.tagName==="A"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"))});function vz(n){const e=K.parse(n,{async:!1});return ov.sanitize(e,{USE_PROFILES:{html:!0}})}const bz=8,ap=new WeakMap;function wz(n){const e=ap.get(n);if(e&&e.text===n.text)return e.html;const t=vz(n.text);return ap.set(n,{text:n.text,html:t}),t}function lp(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t&&t.kind==="user")return t.id}return null}var jt,Qn,Ea,$a,zs,Wc;class yv extends ts{constructor(){super(...arguments);S(this,zs);b(this,"messages",[]);S(this,jt,!0);S(this,Qn,null);S(this,Ea,()=>{const t=c(this,Qn);if(!t)return;const i=t.scrollHeight-t.clientHeight-t.scrollTop<=bz;i!==c(this,jt)&&(E(this,jt,i),this.toggleAttribute("data-pinned",i))});S(this,$a,()=>{E(this,jt,!0),this.toggleAttribute("data-pinned",!0),m(this,zs,Wc).call(this,!0)})}changed(t){let r=!1;if(t.has("messages")){const i=t.get("messages")??[],s=lp(this.messages);r=s!==null&&s!==lp(i),r&&E(this,jt,!0)}Pe(this.template(),this),c(this,Qn)||E(this,Qn,this.querySelector(".history-scroll")),this.toggleAttribute("data-pinned",c(this,jt)),m(this,zs,Wc).call(this,r)}template(){const t=this.messages.filter(r=>r.kind==="user"||r.kind==="assistant");return F`
|
|
392
|
-
<div class="history-scroll" @scroll=${c(this,Ea)}>
|
|
393
|
-
${t.map(r=>{const i=r.kind==="assistant"?RR(wz(r)):r.text;return F`<div
|
|
394
|
-
class="message message-${r.kind}"
|
|
395
|
-
data-message-id=${r.id}
|
|
396
|
-
>${i}</div>`})}
|
|
397
|
-
</div>
|
|
398
|
-
<button
|
|
399
|
-
type="button"
|
|
400
|
-
class="history-jump"
|
|
401
|
-
aria-label="Jump to latest message"
|
|
402
|
-
@click=${c(this,$a)}
|
|
403
|
-
>
|
|
404
|
-
${vy({size:16})}
|
|
405
|
-
</button>
|
|
406
|
-
`}}jt=new WeakMap,Qn=new WeakMap,Ea=new WeakMap,$a=new WeakMap,zs=new WeakSet,Wc=function(t){requestAnimationFrame(()=>{const r=c(this,Qn);r&&(!c(this,jt)&&!t||(r.scrollTop=r.scrollHeight-r.clientHeight))})},b(yv,"properties",["messages"]);customElements.define("message-history",yv);var Ls,Kr,vn,Yc,Kc,Ms,Ns;class qc extends ts{constructor(){super(...arguments);S(this,vn);b(this,"placeholder","What do you want to do?");b(this,"open",!1);b(this,"messages",[]);S(this,Ls,rt.resolve("ACPClientManager"));S(this,Kr);b(this,"handleTriggerActivate",()=>{this.open=!0});b(this,"handleKeydown",t=>{if(t.key!=="Enter"||t.shiftKey)return;const r=t.currentTarget,i=r.value.trim();if(t.preventDefault(),!i)return;r.value="";const s=c(this,Ls).getActiveClient();s&&s.sendMessage({text:i}).catch(o=>{console.error("ACPClient.sendMessage() failed",o)})});S(this,Ms,t=>{t.target instanceof Node&&(this.contains(t.target)||(this.open=!1))});S(this,Ns,t=>{t.key==="Escape"&&(this.open=!1)})}connected(){E(this,Kr,cO(c(this,Ls),t=>{this.messages=t})),this.open&&m(this,vn,Yc).call(this)}disconnected(){var t;(t=c(this,Kr))==null||t.dispose(),E(this,Kr,void 0),m(this,vn,Kc).call(this)}changed(t){if(Pe(this.template(),this),t.has("open"))if(this.open){m(this,vn,Yc).call(this);const r=this.querySelector("textarea");r==null||r.focus()}else m(this,vn,Kc).call(this)}template(){return this.open?F`
|
|
407
|
-
<message-history .messages=${this.messages}></message-history>
|
|
408
|
-
<textarea
|
|
409
|
-
class="input"
|
|
410
|
-
rows="1"
|
|
411
|
-
placeholder=${this.placeholder}
|
|
412
|
-
@keydown=${this.handleKeydown}
|
|
413
|
-
></textarea>
|
|
414
|
-
`:F`
|
|
415
|
-
<button
|
|
416
|
-
class="trigger"
|
|
417
|
-
type="button"
|
|
418
|
-
@click=${this.handleTriggerActivate}
|
|
419
|
-
@focus=${this.handleTriggerActivate}
|
|
420
|
-
>
|
|
421
|
-
${this.placeholder}
|
|
422
|
-
</button>
|
|
423
|
-
`}}Ls=new WeakMap,Kr=new WeakMap,vn=new WeakSet,Yc=function(){document.addEventListener("mousedown",c(this,Ms)),document.addEventListener("keydown",c(this,Ns))},Kc=function(){document.removeEventListener("mousedown",c(this,Ms)),document.removeEventListener("keydown",c(this,Ns))},Ms=new WeakMap,Ns=new WeakMap,b(qc,"properties",["placeholder","open","messages"]),b(qc,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",qc);class vv extends Event{constructor(t){super("auth-submit",{bubbles:!0,composed:!0});b(this,"token");this.token=t}}class _z extends HTMLElement{constructor(){super(...arguments);b(this,"_invalid",!1);b(this,"_tokenValue","")}set invalid(t){this._invalid=t,this.render()}get invalid(){return this._invalid}set tokenValue(t){this._tokenValue=t,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(t){const r=t.currentTarget;this._tokenValue=r.value}handleSubmit(t){t.preventDefault();const r=this._tokenValue.trim();r&&this.dispatchEvent(new vv(r))}render(){Pe(F`
|
|
424
|
-
<modal-overlay open>
|
|
425
|
-
<section class="auth-modal">
|
|
426
|
-
<form class="auth-form" @submit=${t=>this.handleSubmit(t)}>
|
|
427
|
-
<h2 class="auth-modal-title">Enter access token</h2>
|
|
428
|
-
<p class="auth-modal-copy">This Television server requires a token.</p>
|
|
429
|
-
<label class="settings-field">
|
|
430
|
-
<span>Token</span>
|
|
431
|
-
<input
|
|
432
|
-
class=${this.invalid?"auth-token-input-invalid":""}
|
|
433
|
-
type="password"
|
|
434
|
-
name="token"
|
|
435
|
-
.value=${this.tokenValue}
|
|
436
|
-
@input=${t=>this.handleInput(t)}
|
|
437
|
-
required
|
|
438
|
-
/>
|
|
439
|
-
</label>
|
|
440
|
-
<button type="submit" class="settings-submit-button">Connect</button>
|
|
441
|
-
</form>
|
|
442
|
-
</section>
|
|
443
|
-
</modal-overlay>
|
|
444
|
-
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",_z);class Sz extends HTMLElement{constructor(){super(...arguments);b(this,"runtimeServerURL",ay());b(this,"electronMode",cy());b(this,"serverManager",rt.resolve("ServerManager"));b(this,"screenManager",rt.resolve("ScreenManager"));b(this,"connectError",null);b(this,"handleServerManagerChange",()=>{this.render()});b(this,"handleActiveScreenChanged",()=>{this.render()})}connectedCallback(){this.serverManager.addEventListener("change",this.handleServerManagerChange),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.addEventListener("auth-submit",t=>{var i;const r=t instanceof vv?t.token:t instanceof CustomEvent&&typeof((i=t.detail)==null?void 0:i.token)=="string"?t.detail.token:null;r&&this.handleAuthSubmit(r)}),this.initializeConnection(),this.render()}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleServerManagerChange),this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged)}async initializeConnection(){if(this.electronMode){this.serverManager.connectConfiguredServers(this.runtimeServerURL);return}if(this.serverManager.activeServer)return;const t=new mc({url:this.runtimeServerURL,name:"Server",token:ly()});this.serverManager.add(t),this.serverManager.setActive(t);try{await t.connect(),this.connectError=null}catch(r){this.connectError=r instanceof Error&&!(r instanceof gc)?r.message:null}this.render()}async handleAuthSubmit(t){const r=this.serverManager.activeServer;if(r){this.connectError=null,r.token=t,this.updateTokenQueryParam(t);try{await r.connect()}catch(i){i instanceof gc||(this.connectError=i instanceof Error?i.message:String(i))}this.render()}}updateTokenQueryParam(t){const r=new URL(window.location.href);r.searchParams.set("token",t),window.history.replaceState({},"",`${r.pathname}${r.search}${r.hash}`)}render(){const t=this.serverManager.activeServer,r=(t==null?void 0:t.status)??null;if(r==="connecting"){Pe(F`
|
|
445
|
-
<main class="auth-gate"><p>Connecting...</p></main>
|
|
446
|
-
`,this);return}if(r==="disconnected"){const o=t;if(!o)return;Pe(F`
|
|
447
|
-
<main class="auth-gate">
|
|
448
|
-
<auth-modal
|
|
449
|
-
.invalid=${!!o.token}
|
|
450
|
-
.tokenValue=${o.token??""}
|
|
451
|
-
></auth-modal>
|
|
452
|
-
</main>
|
|
453
|
-
`,this);return}const s=this.screenManager.activeScreen?F`<screen-view></screen-view>`:F`<home-screen></home-screen>`;Pe(F`
|
|
454
|
-
<main>
|
|
455
|
-
${this.connectError?F`<p data-testid="auth-error">${this.connectError}</p>`:F`
|
|
456
|
-
${s}
|
|
457
|
-
${r==="connected"?F`
|
|
458
|
-
<div class="chrome">
|
|
459
|
-
<div class="top-row">
|
|
460
|
-
<screen-breadcrumb></screen-breadcrumb>
|
|
461
|
-
<screen-create-button></screen-create-button>
|
|
462
|
-
</div>
|
|
463
|
-
<command-panel></command-panel>
|
|
464
|
-
</div>
|
|
465
|
-
`:null}
|
|
466
|
-
`}
|
|
467
|
-
</main>
|
|
468
|
-
`,this)}}customElements.get("television-app")||customElements.define("television-app",Sz);const Xu=cy(),ja=ay(),bv=new j0(Xu?"television-electron":"television-browser",V0(ja)),wv=new LC({localStore:bv,localServerURL:ja}),_v=new F0({localStore:bv,serverManager:wv}),kz=new yR({serverURL:ja,token:ly()??"",screenManager:_v});rt.register("ServerManager",()=>wv);rt.register("ScreenManager",()=>_v);rt.register("ACPClientManager",()=>kz);const Qu=document.createElement("television-app");Qu.runtimeServerURL=ja;Qu.electronMode=Xu;Xu&&document.body.classList.add("electron");document.body.appendChild(Qu);
|