@telepath-computer/television 0.1.38 → 0.1.39
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,520 +0,0 @@
|
|
|
1
|
-
var Av=Object.defineProperty;var xu=t=>{throw TypeError(t)};var xv=(t,e,n)=>e in t?Av(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var v=(t,e,n)=>xv(t,typeof e!="symbol"?e+"":e,n),da=(t,e,n)=>e.has(t)||xu("Cannot "+n);var u=(t,e,n)=>(da(t,e,"read from private field"),n?n.call(t):e.get(t)),$=(t,e,n)=>e.has(t)?xu("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),x=(t,e,n,r)=>(da(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),b=(t,e,n)=>(da(t,e,"access private method"),n);var Tu=(t,e,n,r)=>({set _(s){x(t,e,s,n)},get _(){return u(t,e,r)}});(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();var Sn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Tv(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})}),n}var Cu=Object.prototype.toString,hp=function(e){var n=Cu.call(e),r=n==="[object Arguments]";return r||(r=n!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Cu.call(e.callee)==="[object Function]"),r},pa,Iu;function Cv(){if(Iu)return pa;Iu=1;var t;if(!Object.keys){var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=hp,s=Object.prototype.propertyIsEnumerable,i=!s.call({toString:null},"toString"),o=s.call(function(){},"prototype"),a=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(y){var m=y.constructor;return m&&m.prototype===y},c={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},d=function(){if(typeof window>"u")return!1;for(var y in window)try{if(!c["$"+y]&&e.call(window,y)&&window[y]!==null&&typeof window[y]=="object")try{l(window[y])}catch{return!0}}catch{return!0}return!1}(),p=function(y){if(typeof window>"u"||!d)return l(y);try{return l(y)}catch{return!1}};t=function(m){var E=m!==null&&typeof m=="object",k=n.call(m)==="[object Function]",I=r(m),G=E&&n.call(m)==="[object String]",N=[];if(!E&&!k&&!I)throw new TypeError("Object.keys called on a non-object");var j=o&&k;if(G&&m.length>0&&!e.call(m,0))for(var F=0;F<m.length;++F)N.push(String(F));if(I&&m.length>0)for(var L=0;L<m.length;++L)N.push(String(L));else for(var J in m)!(j&&J==="prototype")&&e.call(m,J)&&N.push(String(J));if(i)for(var H=p(m),he=0;he<a.length;++he)!(H&&a[he]==="constructor")&&e.call(m,a[he])&&N.push(a[he]);return N}}return pa=t,pa}var Iv=Array.prototype.slice,Pv=hp,Pu=Object.keys,Hi=Pu?function(e){return Pu(e)}:Cv(),Ru=Object.keys;Hi.shim=function(){if(Object.keys){var e=function(){var n=Object.keys(arguments);return n&&n.length===arguments.length}(1,2);e||(Object.keys=function(r){return Pv(r)?Ru(Iv.call(r)):Ru(r)})}else Object.keys=Hi;return Object.keys||Hi};var Rv=Hi,qi=Object.defineProperty||!1;if(qi)try{qi({},"a",{value:1})}catch{qi=!1}var ai=qi,Ft=SyntaxError,V=TypeError,Dv=Object.getOwnPropertyDescriptor,Yi=Dv;if(Yi)try{Yi([],"length")}catch{Yi=null}var Ur=Yi,Du=ai,Ov=Ft,ir=V,Ou=Ur,dp=function(e,n,r){if(!e||typeof e!="object"&&typeof e!="function")throw new ir("`obj` must be an object or a function`");if(typeof n!="string"&&typeof n!="symbol")throw new ir("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new ir("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new ir("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new ir("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new ir("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,i=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,l=!!Ou&&Ou(e,n);if(Du)Du(e,n,{configurable:o===null&&l?l.configurable:!o,enumerable:s===null&&l?l.enumerable:!s,value:r,writable:i===null&&l?l.writable:!i});else if(a||!s&&!i&&!o)e[n]=r;else throw new Ov("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},sl=ai,pp=function(){return!!sl};pp.hasArrayLengthDefineBug=function(){if(!sl)return null;try{return sl([],"length",{value:1}).length!==1}catch{return!0}};var Oo=pp,zv=Rv,Lv=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Mv=Object.prototype.toString,Nv=Array.prototype.concat,zu=dp,Uv=function(t){return typeof t=="function"&&Mv.call(t)==="[object Function]"},fp=Oo(),Fv=function(t,e,n,r){if(e in t){if(r===!0){if(t[e]===n)return}else if(!Uv(r)||!r())return}fp?zu(t,e,n,!0):zu(t,e,n)},gp=function(t,e){var n=arguments.length>2?arguments[2]:{},r=zv(e);Lv&&(r=Nv.call(r,Object.getOwnPropertySymbols(e)));for(var s=0;s<r.length;s+=1)Fv(t,r[s],e[r[s]],n[r[s]])};gp.supportsDescriptors=!!fp;var Yn=gp,Ki={exports:{}};typeof self<"u"?Ki.exports=self:typeof window<"u"?Ki.exports=window:Ki.exports=Function("return this")();var mp=Ki.exports,Zv=mp,vp=function(){return typeof Sn!="object"||!Sn||Sn.Math!==Math||Sn.Array!==Array?Zv:Sn},jv=Yn,Wv=Ur,Bv=vp,Gv=function(){var e=Bv();if(jv.supportsDescriptors){var n=Wv(e,"globalThis");(!n||n.configurable&&(n.enumerable||!n.writable||globalThis!==e))&&Object.defineProperty(e,"globalThis",{configurable:!0,enumerable:!1,value:e,writable:!0})}else(typeof globalThis!="object"||globalThis!==e)&&(e.globalThis=e);return e},Vv=Yn,Hv=mp,yp=vp,qv=Gv,Yv=yp(),bp=function(){return Yv};Vv(bp,{getPolyfill:yp,implementation:Hv,shim:qv});var tc=bp,Zt=function(e){return!!e&&(typeof e=="function"||typeof e=="object")},nc=Object,wp=Error,Kv=EvalError,Jv=RangeError,rc=ReferenceError,Xv=URIError,Qv=Math.abs,ey=Math.floor,ty=Math.max,ny=Math.min,ry=Math.pow,sy=Math.round,sc=Number.isNaN||function(e){return e!==e},iy=sc,oy=function(e){return iy(e)||e===0?e:e<0?-1:1},Fr=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},n=Symbol("test"),r=Object(n);if(typeof n=="string"||Object.prototype.toString.call(n)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var s=42;e[n]=s;for(var i in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==n||!Object.prototype.propertyIsEnumerable.call(e,n))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,n);if(a.value!==s||a.enumerable!==!0)return!1}return!0},Lu=typeof Symbol<"u"&&Symbol,ay=Fr,ic=function(){return typeof Lu!="function"||typeof Symbol!="function"||typeof Lu("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:ay()},fa,Mu;function _p(){return Mu||(Mu=1,fa=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),fa}var ga,Nu;function Sp(){if(Nu)return ga;Nu=1;var t=nc;return ga=t.getPrototypeOf||null,ga}var ly="Function.prototype.bind called on incompatible ",cy=Object.prototype.toString,uy=Math.max,hy="[object Function]",Uu=function(e,n){for(var r=[],s=0;s<e.length;s+=1)r[s]=e[s];for(var i=0;i<n.length;i+=1)r[i+e.length]=n[i];return r},dy=function(e,n){for(var r=[],s=n,i=0;s<e.length;s+=1,i+=1)r[i]=e[s];return r},py=function(t,e){for(var n="",r=0;r<t.length;r+=1)n+=t[r],r+1<t.length&&(n+=e);return n},fy=function(e){var n=this;if(typeof n!="function"||cy.apply(n)!==hy)throw new TypeError(ly+n);for(var r=dy(arguments,1),s,i=function(){if(this instanceof s){var d=n.apply(this,Uu(r,arguments));return Object(d)===d?d:this}return n.apply(e,Uu(r,arguments))},o=uy(0,n.length-r.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+py(a,",")+"){ return binder.apply(this,arguments); }")(i),n.prototype){var c=function(){};c.prototype=n.prototype,s.prototype=new c,c.prototype=null}return s},gy=fy,li=Function.prototype.bind||gy,oc=Function.prototype.call,ac=Function.prototype.apply,my=typeof Reflect<"u"&&Reflect&&Reflect.apply,vy=li,yy=ac,by=oc,wy=my,kp=wy||vy.call(by,yy),_y=li,Sy=V,ky=oc,Ey=kp,zo=function(e){if(e.length<1||typeof e[0]!="function")throw new Sy("a function is required");return Ey(_y,ky,e)},ma,Fu;function $y(){if(Fu)return ma;Fu=1;var t=zo,e=Ur,n;try{n=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var r=!!n&&e&&e(Object.prototype,"__proto__"),s=Object,i=s.getPrototypeOf;return ma=r&&typeof r.get=="function"?t([r.get]):typeof i=="function"?function(a){return i(a==null?a:s(a))}:!1,ma}var va,Zu;function Ep(){if(Zu)return va;Zu=1;var t=_p(),e=Sp(),n=$y();return va=t?function(s){return t(s)}:e?function(s){if(!s||typeof s!="object"&&typeof s!="function")throw new TypeError("getProto: not an object");return e(s)}:n?function(s){return n(s)}:null,va}var Ay=Function.prototype.call,xy=Object.prototype.hasOwnProperty,Ty=li,jt=Ty.call(Ay,xy),B,Cy=nc,Iy=wp,Py=Kv,Ry=Jv,Dy=rc,Dr=Ft,wr=V,Oy=Xv,zy=Qv,Ly=ey,My=ty,Ny=ny,Uy=ry,Fy=sy,Zy=oy,$p=Function,ya=function(t){try{return $p('"use strict"; return ('+t+").constructor;")()}catch{}},xs=Ur,jy=ai,ba=function(){throw new wr},Wy=xs?function(){try{return arguments.callee,ba}catch{try{return xs(arguments,"callee").get}catch{return ba}}}():ba,or=ic(),_e=Ep(),By=Sp(),Gy=_p(),Ap=ac,ci=oc,cr={},Vy=typeof Uint8Array>"u"||!_e?B:_e(Uint8Array),Wn={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?B:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?B:ArrayBuffer,"%ArrayIteratorPrototype%":or&&_e?_e([][Symbol.iterator]()):B,"%AsyncFromSyncIteratorPrototype%":B,"%AsyncFunction%":cr,"%AsyncGenerator%":cr,"%AsyncGeneratorFunction%":cr,"%AsyncIteratorPrototype%":cr,"%Atomics%":typeof Atomics>"u"?B:Atomics,"%BigInt%":typeof BigInt>"u"?B:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?B:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?B:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?B:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Iy,"%eval%":eval,"%EvalError%":Py,"%Float16Array%":typeof Float16Array>"u"?B:Float16Array,"%Float32Array%":typeof Float32Array>"u"?B:Float32Array,"%Float64Array%":typeof Float64Array>"u"?B:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?B:FinalizationRegistry,"%Function%":$p,"%GeneratorFunction%":cr,"%Int8Array%":typeof Int8Array>"u"?B:Int8Array,"%Int16Array%":typeof Int16Array>"u"?B:Int16Array,"%Int32Array%":typeof Int32Array>"u"?B:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":or&&_e?_e(_e([][Symbol.iterator]())):B,"%JSON%":typeof JSON=="object"?JSON:B,"%Map%":typeof Map>"u"?B:Map,"%MapIteratorPrototype%":typeof Map>"u"||!or||!_e?B:_e(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Cy,"%Object.getOwnPropertyDescriptor%":xs,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?B:Promise,"%Proxy%":typeof Proxy>"u"?B:Proxy,"%RangeError%":Ry,"%ReferenceError%":Dy,"%Reflect%":typeof Reflect>"u"?B:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?B:Set,"%SetIteratorPrototype%":typeof Set>"u"||!or||!_e?B:_e(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?B:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":or&&_e?_e(""[Symbol.iterator]()):B,"%Symbol%":or?Symbol:B,"%SyntaxError%":Dr,"%ThrowTypeError%":Wy,"%TypedArray%":Vy,"%TypeError%":wr,"%Uint8Array%":typeof Uint8Array>"u"?B:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?B:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?B:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?B:Uint32Array,"%URIError%":Oy,"%WeakMap%":typeof WeakMap>"u"?B:WeakMap,"%WeakRef%":typeof WeakRef>"u"?B:WeakRef,"%WeakSet%":typeof WeakSet>"u"?B:WeakSet,"%Function.prototype.call%":ci,"%Function.prototype.apply%":Ap,"%Object.defineProperty%":jy,"%Object.getPrototypeOf%":By,"%Math.abs%":zy,"%Math.floor%":Ly,"%Math.max%":My,"%Math.min%":Ny,"%Math.pow%":Uy,"%Math.round%":Fy,"%Math.sign%":Zy,"%Reflect.getPrototypeOf%":Gy};if(_e)try{null.error}catch(t){var Hy=_e(_e(t));Wn["%Error.prototype%"]=Hy}var qy=function t(e){var n;if(e==="%AsyncFunction%")n=ya("async function () {}");else if(e==="%GeneratorFunction%")n=ya("function* () {}");else if(e==="%AsyncGeneratorFunction%")n=ya("async function* () {}");else if(e==="%AsyncGenerator%"){var r=t("%AsyncGeneratorFunction%");r&&(n=r.prototype)}else if(e==="%AsyncIteratorPrototype%"){var s=t("%AsyncGenerator%");s&&_e&&(n=_e(s.prototype))}return Wn[e]=n,n},ju={__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"]},ui=li,ao=jt,Yy=ui.call(ci,Array.prototype.concat),Ky=ui.call(Ap,Array.prototype.splice),Wu=ui.call(ci,String.prototype.replace),lo=ui.call(ci,String.prototype.slice),Jy=ui.call(ci,RegExp.prototype.exec),Xy=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Qy=/\\(\\)?/g,eb=function(e){var n=lo(e,0,1),r=lo(e,-1);if(n==="%"&&r!=="%")throw new Dr("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&n!=="%")throw new Dr("invalid intrinsic syntax, expected opening `%`");var s=[];return Wu(e,Xy,function(i,o,a,l){s[s.length]=a?Wu(l,Qy,"$1"):o||i}),s},tb=function(e,n){var r=e,s;if(ao(ju,r)&&(s=ju[r],r="%"+s[0]+"%"),ao(Wn,r)){var i=Wn[r];if(i===cr&&(i=qy(r)),typeof i>"u"&&!n)throw new wr("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:s,name:r,value:i}}throw new Dr("intrinsic "+e+" does not exist!")},Qe=function(e,n){if(typeof e!="string"||e.length===0)throw new wr("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof n!="boolean")throw new wr('"allowMissing" argument must be a boolean');if(Jy(/^%?[^%]*%?$/,e)===null)throw new Dr("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=eb(e),s=r.length>0?r[0]:"",i=tb("%"+s+"%",n),o=i.name,a=i.value,l=!1,c=i.alias;c&&(s=c[0],Ky(r,Yy([0,1],c)));for(var d=1,p=!0;d<r.length;d+=1){var y=r[d],m=lo(y,0,1),E=lo(y,-1);if((m==='"'||m==="'"||m==="`"||E==='"'||E==="'"||E==="`")&&m!==E)throw new Dr("property names with quotes must have matching quotes");if((y==="constructor"||!p)&&(l=!0),s+="."+y,o="%"+s+"%",ao(Wn,o))a=Wn[o];else if(a!=null){if(!(y in a)){if(!n)throw new wr("base intrinsic for "+e+" exists, but the property is not available.");return}if(xs&&d+1>=r.length){var k=xs(a,y);p=!!k,p&&"get"in k&&!("originalValue"in k.get)?a=k.get:a=a[y]}else p=ao(a,y),a=a[y];p&&!l&&(Wn[o]=a)}}return a},wa,Bu;function hn(){if(Bu)return wa;Bu=1;var t=Qe,e=zo,n=e([t("%String.prototype.indexOf%")]);return wa=function(s,i){var o=t(s,!!i);return typeof o=="function"&&n(s,".prototype.")>-1?e([o]):o},wa}var _a,Gu;function lc(){if(Gu)return _a;Gu=1;var t=Qe,e=t("%Array%"),n=!e.isArray&&hn()("Object.prototype.toString");return _a=e.isArray||function(s){return n(s)==="[object Array]"},_a}var nb=Oo,Vu=ai,xp=nb.hasArrayLengthDefineBug(),rb=xp&&lc(),sb=hn(),ib=sb("Object.prototype.propertyIsEnumerable"),cc=function(e,n,r,s,i,o){if(!Vu){if(!e(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||i in s&&ib(s,i)!==!!o["[[Enumerable]]"])return!1;var a=o["[[Value]]"];return s[i]=a,n(s[i],a)}return xp&&i==="length"&&"[[Value]]"in o&&rb(s)&&s.length!==o["[[Value]]"]?(s.length=o["[[Value]]"],s.length===o["[[Value]]"]):(Vu(s,i,r(o)),!0)},ob=V,ts=jt,ab={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0},Zr=function(e){if(!e||typeof e!="object")return!1;for(var n in e)if(ts(e,n)&&!ab[n])return!1;var r=ts(e,"[[Value]]")||ts(e,"[[Writable]]"),s=ts(e,"[[Get]]")||ts(e,"[[Set]]");if(r&&s)throw new ob("Property Descriptors may not be both accessor and data descriptors");return!0},Tp=function(e){if(typeof e>"u")return e;var n={};return"[[Value]]"in e&&(n.value=e["[[Value]]"]),"[[Writable]]"in e&&(n.writable=!!e["[[Writable]]"]),"[[Get]]"in e&&(n.get=e["[[Get]]"]),"[[Set]]"in e&&(n.set=e["[[Set]]"]),"[[Enumerable]]"in e&&(n.enumerable=!!e["[[Enumerable]]"]),"[[Configurable]]"in e&&(n.configurable=!!e["[[Configurable]]"]),n},lb=V,cb=Zr,ub=Tp,Cp=function(e){if(typeof e<"u"&&!cb(e))throw new lb("Assertion failed: `Desc` must be a Property Descriptor");return ub(e)},hb=V,Hu=jt,db=Zr,Ip=function(e){if(typeof e>"u")return!1;if(!db(e))throw new hb("Assertion failed: `Desc` must be a Property Descriptor");return!(!Hu(e,"[[Value]]")&&!Hu(e,"[[Writable]]"))},jr=function(e){return typeof e=="string"||typeof e=="symbol"},qu=sc,Pp=function(e,n){return e===n?e===0?1/e===1/n:!0:qu(e)&&qu(n)},Yu=V,pb=Zt,fb=cc,gb=Cp,mb=Ip,vb=jr,yb=Pp,uc=function(e,n,r){if(!pb(e))throw new Yu("Assertion failed: Type(O) is not Object");if(!vb(n))throw new Yu("Assertion failed: P is not a Property Key");var s={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return fb(mb,yb,gb,e,n,s)},Rp=Function.prototype.toString,mr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,il,Ji;if(typeof mr=="function"&&typeof Object.defineProperty=="function")try{il=Object.defineProperty({},"length",{get:function(){throw Ji}}),Ji={},mr(function(){throw 42},null,il)}catch(t){t!==Ji&&(mr=null)}else mr=null;var bb=/^\s*class\b/,ol=function(e){try{var n=Rp.call(e);return bb.test(n)}catch{return!1}},Sa=function(e){try{return ol(e)?!1:(Rp.call(e),!0)}catch{return!1}},Xi=Object.prototype.toString,wb="[object Object]",_b="[object Function]",Sb="[object GeneratorFunction]",kb="[object HTMLAllCollection]",Eb="[object HTML document.all class]",$b="[object HTMLCollection]",Ab=typeof Symbol=="function"&&!!Symbol.toStringTag,xb=!(0 in[,]),al=function(){return!1};if(typeof document=="object"){var Tb=document.all;Xi.call(Tb)===Xi.call(document.all)&&(al=function(e){if((xb||!e)&&(typeof e>"u"||typeof e=="object"))try{var n=Xi.call(e);return(n===kb||n===Eb||n===$b||n===wb)&&e("")==null}catch{}return!1})}var Dp=mr?function(e){if(al(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{mr(e,null,il)}catch(n){if(n!==Ji)return!1}return!ol(e)&&Sa(e)}:function(e){if(al(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(Ab)return Sa(e);if(ol(e))return!1;var n=Xi.call(e);return n!==_b&&n!==Sb&&!/^\[object HTML/.test(n)?!1:Sa(e)},Cb=Dp,Ib=function(e){return!!e},dt=jt,Ii=V,Pb=Zt,Ku=Cb,ka=Ib,Rb=function(e){if(!Pb(e))throw new Ii("ToPropertyDescriptor requires an object");var n={};if(dt(e,"enumerable")&&(n["[[Enumerable]]"]=ka(e.enumerable)),dt(e,"configurable")&&(n["[[Configurable]]"]=ka(e.configurable)),dt(e,"value")&&(n["[[Value]]"]=e.value),dt(e,"writable")&&(n["[[Writable]]"]=ka(e.writable)),dt(e,"get")){var r=e.get;if(typeof r<"u"&&!Ku(r))throw new Ii("getter must be a function");n["[[Get]]"]=r}if(dt(e,"set")){var s=e.set;if(typeof s<"u"&&!Ku(s))throw new Ii("setter must be a function");n["[[Set]]"]=s}if((dt(n,"[[Get]]")||dt(n,"[[Set]]"))&&(dt(n,"[[Value]]")||dt(n,"[[Writable]]")))throw new Ii("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},Ea=V,Db=Zt,Ju=Zr,Ob=cc,zb=Cp,Lb=Ip,Mb=jr,Nb=Pp,Ub=Rb,Fb=function(e,n,r){if(!Db(e))throw new Ea("Assertion failed: Type(O) is not Object");if(!Mb(n))throw new Ea("Assertion failed: P is not a Property Key");var s=Ju(r)?r:Ub(r);if(!Ju(s))throw new Ea("Assertion failed: Desc is not a valid Property Descriptor");return Ob(Lb,Nb,zb,e,n,s)},Xu=V,Zb=Zt,jb=Fb,Wb=jr,Bb=function(e,n,r){if(!Zb(e))throw new Xu("Assertion failed: Type(O) is not Object");if(!Wb(n))throw new Xu("Assertion failed: P is not a Property Key");var s={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return jb(e,n,s)},Gb=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,Vb=nc,Hb=Vb.setPrototypeOf||null,qb=zo,Qu=Ur,Yb=V,Op={};try{Op.__proto__=null}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var Kb=!("toString"in Op),$a=Qu&&Qu(Object.prototype,"__proto__"),Jb=Kb&&(!!$a&&typeof $a.set=="function"&&qb([$a.set])||function(e,n){if(e==null)throw new Yb("set Object.prototype.__proto__ called on null or undefined");return e.__proto__=n,n}),eh=Gb,Xb=Hb,th=Jb,Qb=V,ew=eh?function(e,n){if(eh(e,n))return e;throw new Qb("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:Xb||(th?function(e,n){return th(e,n),e}:null),nh=V,tw=Zt,rh=Ep(),nw=function(e){if(!tw(e))throw new nh("Assertion failed: O must be an Object");if(!rh)throw new nh("This environment does not support fetching prototypes.");return rh(e)},rw=V,sw=ew,iw=Zt,ow=nw,aw=function(e,n){if(n!==null&&!iw(n))throw new rw("Assertion failed: V must be Object or Null");try{sw(e,n)}catch{return!1}return ow(e)===n},Aa=uc,sh=Bb,zp=aw,lw=Oo(),hc=wp;function hi(t,e,n){var r=new hc(n);return zp(r,Qi),delete r.constructor,sh(r,"error",t),sh(r,"suppressed",e),r}lw&&Object.defineProperty(hi,"prototype",{writable:!1});var Qi=hi.prototype;if(!Aa(Qi,"constructor",hi)||!Aa(Qi,"message","")||!Aa(Qi,"name","SuppressedError"))throw new hc("unable to install SuppressedError.prototype properties; please report this!");zp(hi.prototype,hc.prototype);var cw=hi,uw=cw,Lp=function(){return typeof SuppressedError=="function"?SuppressedError:uw},hw=Yn,ih=tc(),dw=Lp,pw=function(){var e=dw();return hw(ih,{SuppressedError:e},{SuppressedError:function(){return ih.SuppressedError!==e}}),e};pw();var fw=V,gw=Zr,mw=Tp,vw=function(e){if(typeof e<"u"&&!gw(e))throw new fw("Assertion failed: `Desc` must be a Property Descriptor");return mw(e)},yw=V,oh=jt,bw=Zr,ww=function(e){if(typeof e>"u")return!1;if(!bw(e))throw new yw("Assertion failed: `Desc` must be a Property Descriptor");return!(!oh(e,"[[Value]]")&&!oh(e,"[[Writable]]"))},ah=sc,_w=function(e,n){return e===n?e===0?1/e===1/n:!0:ah(e)&&ah(n)},Wr=Dp,Sw=function(e){return!!e},pt=jt,Pi=V,kw=Zt,lh=Wr,xa=Sw,Ew=function(e){if(!kw(e))throw new Pi("ToPropertyDescriptor requires an object");var n={};if(pt(e,"enumerable")&&(n["[[Enumerable]]"]=xa(e.enumerable)),pt(e,"configurable")&&(n["[[Configurable]]"]=xa(e.configurable)),pt(e,"value")&&(n["[[Value]]"]=e.value),pt(e,"writable")&&(n["[[Writable]]"]=xa(e.writable)),pt(e,"get")){var r=e.get;if(typeof r<"u"&&!lh(r))throw new Pi("getter must be a function");n["[[Get]]"]=r}if(pt(e,"set")){var s=e.set;if(typeof s<"u"&&!lh(s))throw new Pi("setter must be a function");n["[[Set]]"]=s}if((pt(n,"[[Get]]")||pt(n,"[[Set]]"))&&(pt(n,"[[Value]]")||pt(n,"[[Writable]]")))throw new Pi("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return n},Ta=V,$w=Zt,ch=Zr,Aw=cc,xw=vw,Tw=ww,Cw=jr,Iw=_w,Pw=Ew,di=function(e,n,r){if(!$w(e))throw new Ta("Assertion failed: Type(O) is not Object");if(!Cw(n))throw new Ta("Assertion failed: P is not a Property Key");var s=ch(r)?r:Pw(r);if(!ch(s))throw new Ta("Assertion failed: Desc is not a valid Property Descriptor");return Aw(Tw,Iw,xw,e,n,s)},Rw=Fr(),Dw=Rw?Symbol.dispose||Symbol("Symbol.dispose"):null,Ow=Fr,zw=Dw,dc=function(){return Ow()&&Symbol.dispose||zw},Lw=ic,Mw=di,Nw=dc,Uw=function(){var e=Nw();return Lw()&&Mw(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},Fw=Fr(),Zw=Fw?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,jw=Fr,Ww=Zw,pc=function(){return jw()&&Symbol.asyncDispose||Ww},Bw=ic,Gw=di,Vw=pc,Hw=function(){var e=Vw();return Bw()&&Gw(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":e}),e},qw=lc(),Yw=Qe,Kw=hn(),Jw=V,Xw=qw,Qw=Yw("%Reflect.apply%",!0)||Kw("Function.prototype.apply"),Lo=function(e,n){var r=arguments.length>2?arguments[2]:[];if(!Xw(r))throw new Jw("Assertion failed: optional `argumentsList`, if provided, must be a List");return Qw(e,n,r)};const e_={},t_=Object.freeze(Object.defineProperty({__proto__:null,default:e_},Symbol.toStringTag,{value:"Module"})),n_=Tv(t_);var fc=typeof Map=="function"&&Map.prototype,Ca=Object.getOwnPropertyDescriptor&&fc?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,co=fc&&Ca&&typeof Ca.get=="function"?Ca.get:null,uh=fc&&Map.prototype.forEach,gc=typeof Set=="function"&&Set.prototype,Ia=Object.getOwnPropertyDescriptor&&gc?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,uo=gc&&Ia&&typeof Ia.get=="function"?Ia.get:null,hh=gc&&Set.prototype.forEach,r_=typeof WeakMap=="function"&&WeakMap.prototype,Ss=r_?WeakMap.prototype.has:null,s_=typeof WeakSet=="function"&&WeakSet.prototype,ks=s_?WeakSet.prototype.has:null,i_=typeof WeakRef=="function"&&WeakRef.prototype,dh=i_?WeakRef.prototype.deref:null,o_=Boolean.prototype.valueOf,a_=Object.prototype.toString,l_=Function.prototype.toString,c_=String.prototype.match,mc=String.prototype.slice,en=String.prototype.replace,u_=String.prototype.toUpperCase,ph=String.prototype.toLowerCase,Mp=RegExp.prototype.test,fh=Array.prototype.concat,_t=Array.prototype.join,h_=Array.prototype.slice,gh=Math.floor,ll=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Pa=Object.getOwnPropertySymbols,cl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Or=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Es=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Or||!0)?Symbol.toStringTag:null,Np=Object.prototype.propertyIsEnumerable,mh=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function vh(t,e){if(t===1/0||t===-1/0||t!==t||t&&t>-1e3&&t<1e3||Mp.call(/e/,e))return e;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof t=="number"){var r=t<0?-gh(-t):gh(t);if(r!==t){var s=String(r),i=mc.call(e,s.length+1);return en.call(s,n,"$&_")+"."+en.call(en.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return en.call(e,n,"$&_")}var ul=n_,yh=ul.custom,bh=Zp(yh)?yh:null,Up={__proto__:null,double:'"',single:"'"},d_={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},Br=function t(e,n,r,s){var i=n||{};if(It(i,"quoteStyle")&&!It(Up,i.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(It(i,"maxStringLength")&&(typeof i.maxStringLength=="number"?i.maxStringLength<0&&i.maxStringLength!==1/0:i.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=It(i,"customInspect")?i.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(It(i,"indent")&&i.indent!==null&&i.indent!==" "&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(It(i,"numericSeparator")&&typeof i.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=i.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 Wp(e,i);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var l=String(e);return a?vh(e,l):l}if(typeof e=="bigint"){var c=String(e)+"n";return a?vh(e,c):c}var d=typeof i.depth>"u"?5:i.depth;if(typeof r>"u"&&(r=0),r>=d&&d>0&&typeof e=="object")return hl(e)?"[Array]":"[Object]";var p=I_(i,r);if(typeof s>"u")s=[];else if(jp(s,e)>=0)return"[Circular]";function y(ct,Wt,ea){if(Wt&&(s=h_.call(s),s.push(Wt)),ea){var _i={depth:i.depth};return It(i,"quoteStyle")&&(_i.quoteStyle=i.quoteStyle),t(ct,_i,r+1,s)}return t(ct,i,r+1,s)}if(typeof e=="function"&&!wh(e)){var m=__(e),E=Ri(e,y);return"[Function"+(m?": "+m:" (anonymous)")+"]"+(E.length>0?" { "+_t.call(E,", ")+" }":"")}if(Zp(e)){var k=Or?en.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):cl.call(e);return typeof e=="object"&&!Or?ns(k):k}if(x_(e)){for(var I="<"+ph.call(String(e.nodeName)),G=e.attributes||[],N=0;N<G.length;N++)I+=" "+G[N].name+"="+Fp(p_(G[N].value),"double",i);return I+=">",e.childNodes&&e.childNodes.length&&(I+="..."),I+="</"+ph.call(String(e.nodeName))+">",I}if(hl(e)){if(e.length===0)return"[]";var j=Ri(e,y);return p&&!C_(j)?"["+dl(j,p)+"]":"[ "+_t.call(j,", ")+" ]"}if(g_(e)){var F=Ri(e,y);return!("cause"in Error.prototype)&&"cause"in e&&!Np.call(e,"cause")?"{ ["+String(e)+"] "+_t.call(fh.call("[cause]: "+y(e.cause),F),", ")+" }":F.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+_t.call(F,", ")+" }"}if(typeof e=="object"&&o){if(bh&&typeof e[bh]=="function"&&ul)return ul(e,{depth:d-r});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(S_(e)){var L=[];return uh&&uh.call(e,function(ct,Wt){L.push(y(Wt,e,!0)+" => "+y(ct,e))}),_h("Map",co.call(e),L,p)}if($_(e)){var J=[];return hh&&hh.call(e,function(ct){J.push(y(ct,e))}),_h("Set",uo.call(e),J,p)}if(k_(e))return Ra("WeakMap");if(A_(e))return Ra("WeakSet");if(E_(e))return Ra("WeakRef");if(v_(e))return ns(y(Number(e)));if(b_(e))return ns(y(ll.call(e)));if(y_(e))return ns(o_.call(e));if(m_(e))return ns(y(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof Sn<"u"&&e===Sn)return"{ [object globalThis] }";if(!f_(e)&&!wh(e)){var H=Ri(e,y),he=mh?mh(e)===Object.prototype:e instanceof Object||e.constructor===Object,lt=e instanceof Object?"":"null prototype",wi=!he&&Es&&Object(e)===e&&Es in e?mc.call(dn(e),8,-1):lt?"Object":"",Ee=he||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",gn=Ee+(wi||lt?"["+_t.call(fh.call([],wi||[],lt||[]),": ")+"] ":"");return H.length===0?gn+"{}":p?gn+"{"+dl(H,p)+"}":gn+"{ "+_t.call(H,", ")+" }"}return String(e)};function Fp(t,e,n){var r=n.quoteStyle||e,s=Up[r];return s+t+s}function p_(t){return en.call(String(t),/"/g,""")}function Kn(t){return!Es||!(typeof t=="object"&&(Es in t||typeof t[Es]<"u"))}function hl(t){return dn(t)==="[object Array]"&&Kn(t)}function f_(t){return dn(t)==="[object Date]"&&Kn(t)}function wh(t){return dn(t)==="[object RegExp]"&&Kn(t)}function g_(t){return dn(t)==="[object Error]"&&Kn(t)}function m_(t){return dn(t)==="[object String]"&&Kn(t)}function v_(t){return dn(t)==="[object Number]"&&Kn(t)}function y_(t){return dn(t)==="[object Boolean]"&&Kn(t)}function Zp(t){if(Or)return t&&typeof t=="object"&&t instanceof Symbol;if(typeof t=="symbol")return!0;if(!t||typeof t!="object"||!cl)return!1;try{return cl.call(t),!0}catch{}return!1}function b_(t){if(!t||typeof t!="object"||!ll)return!1;try{return ll.call(t),!0}catch{}return!1}var w_=Object.prototype.hasOwnProperty||function(t){return t in this};function It(t,e){return w_.call(t,e)}function dn(t){return a_.call(t)}function __(t){if(t.name)return t.name;var e=c_.call(l_.call(t),/^function\s*([\w$]+)/);return e?e[1]:null}function jp(t,e){if(t.indexOf)return t.indexOf(e);for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1}function S_(t){if(!co||!t||typeof t!="object")return!1;try{co.call(t);try{uo.call(t)}catch{return!0}return t instanceof Map}catch{}return!1}function k_(t){if(!Ss||!t||typeof t!="object")return!1;try{Ss.call(t,Ss);try{ks.call(t,ks)}catch{return!0}return t instanceof WeakMap}catch{}return!1}function E_(t){if(!dh||!t||typeof t!="object")return!1;try{return dh.call(t),!0}catch{}return!1}function $_(t){if(!uo||!t||typeof t!="object")return!1;try{uo.call(t);try{co.call(t)}catch{return!0}return t instanceof Set}catch{}return!1}function A_(t){if(!ks||!t||typeof t!="object")return!1;try{ks.call(t,ks);try{Ss.call(t,Ss)}catch{return!0}return t instanceof WeakSet}catch{}return!1}function x_(t){return!t||typeof t!="object"?!1:typeof HTMLElement<"u"&&t instanceof HTMLElement?!0:typeof t.nodeName=="string"&&typeof t.getAttribute=="function"}function Wp(t,e){if(t.length>e.maxStringLength){var n=t.length-e.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return Wp(mc.call(t,0,e.maxStringLength),e)+r}var s=d_[e.quoteStyle||"single"];s.lastIndex=0;var i=en.call(en.call(t,s,"\\$1"),/[\x00-\x1f]/g,T_);return Fp(i,"single",e)}function T_(t){var e=t.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return n?"\\"+n:"\\x"+(e<16?"0":"")+u_.call(e.toString(16))}function ns(t){return"Object("+t+")"}function Ra(t){return t+" { ? }"}function _h(t,e,n,r){var s=r?dl(n,r):_t.call(n,", ");return t+" ("+e+") {"+s+"}"}function C_(t){for(var e=0;e<t.length;e++)if(jp(t[e],`
|
|
2
|
-
`)>=0)return!1;return!0}function I_(t,e){var n;if(t.indent===" ")n=" ";else if(typeof t.indent=="number"&&t.indent>0)n=_t.call(Array(t.indent+1)," ");else return null;return{base:n,prev:_t.call(Array(e+1),n)}}function dl(t,e){if(t.length===0)return"";var n=`
|
|
3
|
-
`+e.prev+e.base;return n+_t.call(t,","+n)+`
|
|
4
|
-
`+e.prev}function Ri(t,e){var n=hl(t),r=[];if(n){r.length=t.length;for(var s=0;s<t.length;s++)r[s]=It(t,s)?e(t[s],t):""}var i=typeof Pa=="function"?Pa(t):[],o;if(Or){o={};for(var a=0;a<i.length;a++)o["$"+i[a]]=i[a]}for(var l in t)It(t,l)&&(n&&String(Number(l))===l&&l<t.length||Or&&o["$"+l]instanceof Symbol||(Mp.call(/[^\w$]/,l)?r.push(e(l,t)+": "+e(t[l],t)):r.push(l+": "+e(t[l],t))));if(typeof Pa=="function")for(var c=0;c<i.length;c++)Np.call(t,i[c])&&r.push("["+e(i[c])+"]: "+e(t[i[c]],t));return r}var P_=Br,R_=V,Mo=function(t,e,n){for(var r=t,s;(s=r.next)!=null;r=s)if(s.key===e)return r.next=s.next,n||(s.next=t.next,t.next=s),s},D_=function(t,e){if(t){var n=Mo(t,e);return n&&n.value}},O_=function(t,e,n){var r=Mo(t,e);r?r.value=n:t.next={key:e,next:t.next,value:n}},z_=function(t,e){return t?!!Mo(t,e):!1},L_=function(t,e){if(t)return Mo(t,e,!0)},M_=function(){var e,n={assert:function(r){if(!n.has(r))throw new R_("Side channel does not contain "+P_(r))},delete:function(r){var s=e&&e.next,i=L_(e,r);return i&&s&&s===i&&(e=void 0),!!i},get:function(r){return D_(e,r)},has:function(r){return z_(e,r)},set:function(r,s){e||(e={next:void 0}),O_(e,r,s)}};return n},N_=Qe,pi=hn(),U_=Br,F_=V,Sh=N_("%Map%",!0),Z_=pi("Map.prototype.get",!0),j_=pi("Map.prototype.set",!0),W_=pi("Map.prototype.has",!0),B_=pi("Map.prototype.delete",!0),G_=pi("Map.prototype.size",!0),Bp=!!Sh&&function(){var e,n={assert:function(r){if(!n.has(r))throw new F_("Side channel does not contain "+U_(r))},delete:function(r){if(e){var s=B_(e,r);return G_(e)===0&&(e=void 0),s}return!1},get:function(r){if(e)return Z_(e,r)},has:function(r){return e?W_(e,r):!1},set:function(r,s){e||(e=new Sh),j_(e,r,s)}};return n},V_=Qe,No=hn(),H_=Br,Di=Bp,q_=V,ar=V_("%WeakMap%",!0),Y_=No("WeakMap.prototype.get",!0),K_=No("WeakMap.prototype.set",!0),J_=No("WeakMap.prototype.has",!0),X_=No("WeakMap.prototype.delete",!0),Q_=ar?function(){var e,n,r={assert:function(s){if(!r.has(s))throw new q_("Side channel does not contain "+H_(s))},delete:function(s){if(ar&&s&&(typeof s=="object"||typeof s=="function")){if(e)return X_(e,s)}else if(Di&&n)return n.delete(s);return!1},get:function(s){return ar&&s&&(typeof s=="object"||typeof s=="function")&&e?Y_(e,s):n&&n.get(s)},has:function(s){return ar&&s&&(typeof s=="object"||typeof s=="function")&&e?J_(e,s):!!n&&n.has(s)},set:function(s,i){ar&&s&&(typeof s=="object"||typeof s=="function")?(e||(e=new ar),K_(e,s,i)):Di&&(n||(n=Di()),n.set(s,i))}};return r}:Di,eS=V,tS=Br,nS=M_,rS=Bp,sS=Q_,iS=sS||rS||nS,oS=function(){var e,n={assert:function(r){if(!n.has(r))throw new eS("Side channel does not contain "+tS(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,s){e||(e=iS()),e.set(r,s)}};return n},aS=jt,rs=oS(),xt=V,vc={assert:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new xt("`O` is not an object");if(typeof e!="string")throw new xt("`slot` must be a string");if(rs.assert(t),!vc.has(t,e))throw new xt("`"+e+"` is not present on `O`")},get:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new xt("`O` is not an object");if(typeof e!="string")throw new xt("`slot` must be a string");var n=rs.get(t);return n&&n["$"+e]},has:function(t,e){if(!t||typeof t!="object"&&typeof t!="function")throw new xt("`O` is not an object");if(typeof e!="string")throw new xt("`slot` must be a string");var n=rs.get(t);return!!n&&aS(n,"$"+e)},set:function(t,e,n){if(!t||typeof t!="object"&&typeof t!="function")throw new xt("`O` is not an object");if(typeof e!="string")throw new xt("`slot` must be a string");var r=rs.get(t);r||(r={},rs.set(t,r)),r["$"+e]=n}};Object.freeze&&Object.freeze(vc);var yc=vc,Gp=Ft,rn=yc,fi=function t(e,n){if(!(this instanceof t))return new t(e,n);if(e!=="normal"&&e!=="break"&&e!=="continue"&&e!=="return"&&e!=="throw")throw new Gp('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"');rn.set(this,"[[Type]]",e),rn.set(this,"[[Value]]",n)};fi.prototype.type=function(){return rn.get(this,"[[Type]]")};fi.prototype.value=function(){return rn.get(this,"[[Value]]")};fi.prototype["?"]=function(){var e=rn.get(this,"[[Type]]"),n=rn.get(this,"[[Value]]");if(e==="throw")throw n;return n};fi.prototype["!"]=function(){var e=rn.get(this,"[[Type]]");if(e!=="normal")throw new Gp('Assertion failed: Completion Record is not of type "normal"');return rn.get(this,"[[Value]]")};var bc=fi,lS=bc,wc=function(e){return new lS("normal",e)},Da,kh;function cS(){if(kh)return Da;kh=1;var t=Fr;return Da=function(){return t()&&!!Symbol.toStringTag},Da}var uS=Qe,Eh=uS("%Object.defineProperty%",!0),hS=cS()(),dS=jt,pS=V,Oi=hS?Symbol.toStringTag:null,Vp=function(e,n){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,s=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof r<"u"&&typeof r!="boolean"||typeof s<"u"&&typeof s!="boolean")throw new pS("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");Oi&&(r||!dS(e,Oi))&&(Eh?Eh(e,Oi,{configurable:!s,enumerable:!1,value:n,writable:!1}):e[Oi]=n)},Hp={exports:{}},fS=Qe,$h=dp,gS=Oo(),Ah=Ur,xh=V,mS=fS("%Math.floor%"),vS=function(e,n){if(typeof e!="function")throw new xh("`fn` is not a function");if(typeof n!="number"||n<0||n>4294967295||mS(n)!==n)throw new xh("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],s=!0,i=!0;if("length"in e&&Ah){var o=Ah(e,"length");o&&!o.configurable&&(s=!1),o&&!o.writable&&(i=!1)}return(s||i||!r)&&(gS?$h(e,"length",n,!0,!0):$h(e,"length",n)),e},yS=li,bS=ac,wS=kp,_S=function(){return wS(yS,bS,arguments)};(function(t){var e=vS,n=ai,r=zo,s=_S;t.exports=function(o){var a=r(arguments),l=1+o.length-(arguments.length-1);return e(a,l>0?l:0,!0)},n?n(t.exports,"apply",{value:s}):t.exports.apply=s})(Hp);var _c=Hp.exports,SS=function(e,n){for(var r=0;r<e.length;r+=1)if(!n(e[r],r,e))return!1;return!0},kS=Object,ES=function(e){return e&&typeof e=="object"&&(typeof e["[[ResourceValue]]"]>"u"||kS(e["[[ResourceValue]]"])===e["[[ResourceValue]]"])&&(e["[[Hint]]"]==="SYNC-DISPOSE"||e["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof e["[[DisposeMethod]]"]=="function"||typeof e["[[DisposeMethod]]"]>"u")},$S=jt,AS=lc(),xS=SS,TS=ES,CS=function(e){return e&&typeof e=="object"&&$S(e,"[[DisposableResourceStack]]")&&AS(e["[[DisposableResourceStack]]"])&&(e["[[DisposableResourceStack]]"].length===0||xS(e["[[DisposableResourceStack]]"],TS))},IS=Zt,PS=function(e){if(e===null)return"Null";if(typeof e>"u")return"Undefined";if(IS(e))return"Object";if(typeof e=="number")return"Number";if(typeof e=="boolean")return"Boolean";if(typeof e=="string")return"String"},RS=PS,Sc=function(e){return typeof e=="symbol"?"Symbol":typeof e=="bigint"?"BigInt":RS(e)},DS=V,OS=Br,zS=jr,LS=function(e,n){if(!zS(n))throw new DS("Assertion failed: P is not a Property Key, got "+OS(n));return e[n]},Th=V,MS=LS,NS=Wr,US=jr,Ch=Br,FS=function(e,n){if(!US(n))throw new Th("Assertion failed: P is not a Property Key");var r=MS(e,n);if(r!=null){if(!NS(r))throw new Th(Ch(n)+" is not a function: "+Ch(r));return r}},pl={exports:{}},ZS=Qe,jS=ZS,Ih=jS("%Reflect.construct%",!0),ho=di;try{ho({},"",{"[[Get]]":function(){}})}catch{ho=null}if(ho&&Ih){var Ph={},Rh={};ho(Rh,"length",{"[[Get]]":function(){throw Ph},"[[Enumerable]]":!0}),pl.exports=function(e){try{Ih(e,Rh)}catch(n){return n===Ph}}}else pl.exports=function(e){return typeof e=="function"&&!!e.prototype};var WS=pl.exports,Oa=V,Dh=Wr,BS=WS,GS=function(e){if(!BS(e))throw new Oa("C must be a constructor");var n={"[[Resolve]]":void 0,"[[Reject]]":void 0},r=new e(function(s,i){if(typeof n["[[Resolve]]"]<"u"||typeof n["[[Reject]]"]<"u")throw new Oa("executor has already been called");n["[[Resolve]]"]=s,n["[[Reject]]"]=i});if(!Dh(n["[[Resolve]]"])||!Dh(n["[[Reject]]"]))throw new Oa("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":n["[[Resolve]]"],"[[Reject]]":n["[[Reject]]"]}},Oh=Ft,VS=V,za=Lo,zh=FS,HS=GS,qS=Sc,Lh=dc(),Mh=pc(),YS=function(e,n){if(qS(e)!=="Object")throw new VS("`V` must be an Object");if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new Oh("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(n==="ASYNC-DISPOSE"&&Mh&&(r=zh(e,Mh)),!r){if(!Lh)throw new Oh("`Symbol.dispose` is not supported");if(r=zh(e,Lh),typeof r<"u")return function(){var s=this;if(n==="ASYNC-DISPOSE"){var i=HS(Promise);try{za(r,s),za(i["[[Resolve]]"],void 0,[void 0])}catch(o){i["[[Reject]]"](o)}return i["[[Promise]]"]}za(r,s)}}return r},KS=Ft,La=V,JS=Wr,XS=Sc,QS=YS,ek=function(e,n){if(n!=="SYNC-DISPOSE"&&n!=="ASYNC-DISPOSE")throw new KS("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"&&XS(e)!=="Object")throw new La("`V` must be an Object, or `null` or `undefined`");if(r=QS(e,n),typeof r>"u")throw new La("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!JS(r))throw new La("`method`, when provided, must be a function");return{"[[ResourceValue]]":e,"[[Hint]]":n,"[[DisposeMethod]]":r}},tk=Ft,zi=V,nk=CS,Nh=ek,rk=hn(),sk=rk("Array.prototype.push"),qp=function(e,n,r){if(!nk(e))throw new zi("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new tk("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var s=arguments.length>3?arguments[3]:void 0;if(arguments.length>3&&typeof s!="function")throw new zi("Assertion failed: `method`, when present, must be a function");if(!e["[[DisposableResourceStack]]"])throw new zi("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");var i;if(arguments.length<4){if(n==null&&r==="SYNC_DISPOSE")return"UNUSED";i=Nh(n,r)}else{if(typeof n<"u")throw new zi("Assertion failed: `V` must be undefined when `method` is present");i=Nh(void 0,r,s)}return sk(e["[[DisposableResourceStack]]"],i),"UNUSED"},Ma,Uh;function kc(){if(Uh)return Ma;Uh=1;var t=Qe,e=_c,n=Ft,r=t("%Promise.resolve%",!0),s=r&&e(r);return Ma=function(o,a){if(!s)throw new n("This environment does not support Promises.");return s(o,a)},Ma}var Na,Fh;function ik(){if(Fh)return Na;Fh=1;var t=Qe,e=Ft,n=t("%Promise%",!0),r=Lo,s=kc(),i=Sc;return Na=function(a,l,c){if(typeof a<"u"&&i(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 c<"u"&&typeof c!="function")throw new e("Assertion failed: `method` must be `undefined` or a function");var d=typeof c>"u"?c:r(c,a);if(l==="ASYNC-DISPOSE")return s(n,d)},Na}var Ua,Zh;function ok(){if(Zh)return Ua;Zh=1;var t=bc;return Ua=function(n){return new t("throw",n)},Ua}var ak=Qe,Fa=Ft,jh=V,lk=ak("%Promise%",!0),ck=hn(),Wh=ck("Promise.prototype.then",!0),uk=bc,Bh=ik(),hk=wc,dk=kc(),Gh=ok(),pk=Lp(),Yp=function(e,n){if(!(n instanceof uk))throw new jh("`completion` must be a Completion Record");var r=e["[[DisposableResourceStack]]"];if(!r)throw new jh("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var s,i=r.length-1;i>=0;i-=1)if(!s)s=r[i]["[[Hint]]"];else if(s!==r[i]["[[Hint]]"])throw new Fa("mixed hint stacks are not supported");for(var o=s==="ASYNC-DISPOSE"&&dk(lk,n),a=function(y){if(n.type()==="throw"){var m=n.value(),E=new pk(y,m);n=Gh(E)}else n=Gh(y)},l=s==="ASYNC-DISPOSE"&&function(m){return Wh(o,function(){var E=Bh(m["[[ResourceValue]]"],m["[[Hint]]"],m["[[DisposeMethod]]"]);if(!E)throw new Fa("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return Wh(E,hk)},a)},c=r.length-1;c>=0;c-=1)if(s==="ASYNC-DISPOSE")o=l(r[c]);else{var d=r[c];try{var p=Bh(d["[[ResourceValue]]"],d["[[Hint]]"],d["[[DisposeMethod]]"]);if(p)throw new Fa("Assertion failed: `~SYNC-DISPOSE~` resource returned something from Dispose")}catch(y){a(y)}}return e["[[DisposableResourceStack]]"]=null,s==="ASYNC-DISPOSE"?o:n},Kp=function(){var e=[];return{"[[DisposableResourceStack]]":e}},Uo=rc,Ec=V,fk=Lo,Gr=uc,gk=di,Jp=Wr,mk=wc,Ze=yc,vk=Vp,Xp=Yn.supportsDescriptors,yk=_c,$c=qp,bk=Yp,Qp=Kp,Vh=dc(),Ke=function t(){if(!(this instanceof t)||Ze.has(this,"[[DisposableState]]")||Ze.has(this,"[[DisposeCapability]]"))throw new Ec("can only be used with new");Ze.set(this,"[[DisposableState]]","PENDING"),Ze.set(this,"[[DisposeCapability]]",Qp())},ef=function(){var e=this;return Ze.assert(e,"[[DisposableState]]"),Ze.get(e,"[[DisposableState]]")==="DISPOSED"},gi=yk(ef);Xp?gk(Ke.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":ef}):Ke.prototype.disposed=!1;var tf=function(e){Ze.set(e,"[[DisposableState]]","DISPOSED"),Xp||(e.disposed=!0)};Gr(Ke.prototype,"dispose",function(){var e=this;if(!gi(e))return tf(e),bk(Ze.get(e,"[[DisposeCapability]]"),mk())["?"]()});Gr(Ke.prototype,"use",function(e){var n=this;if(gi(n))throw new Uo("a disposed stack can not use anything new");return $c(Ze.get(n,"[[DisposeCapability]]"),e,"SYNC-DISPOSE"),e});Gr(Ke.prototype,"adopt",function(e,n){var r=this;if(gi(r))throw new Uo("a disposed stack can not use anything new");if(!Jp(n))throw new Ec("`onDispose` must be a function");var s=function(){return fk(n,void 0,[e])};return $c(Ze.get(r,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",s),e});Gr(Ke.prototype,"defer",function(e){var n=this;if(gi(n))throw new Uo("a disposed stack can not defer anything new");if(!Jp(e))throw new Ec("`onDispose` must be a function");$c(Ze.get(n,"[[DisposeCapability]]"),void 0,"SYNC-DISPOSE",e)});Gr(Ke.prototype,"move",function(){var e=this;if(gi(e))throw new Uo("a disposed stack can not use anything new");var n=new Ke;return Ze.set(n,"[[DisposeCapability]]",Ze.get(e,"[[DisposeCapability]]")),Ze.set(e,"[[DisposeCapability]]",Qp()),tf(e),n});Vh&&Gr(Ke.prototype,Vh,Ke.prototype.dispose);vk(Ke.prototype,"DisposableStack");var wk=Ke,_k=wk,Sk=function(){return typeof DisposableStack=="function"?DisposableStack:_k},kk=Yn,Ek=tc(),$k=Sk,Ak=function(){var e=$k();return kk(Ek,{DisposableStack:e},{DisposableStack:!0}),e},xk=Qe,Fo=rc,Ac=V,Hh=xk("%Promise%",!0),xc=qp,Tk=Lo,Vr=uc,Ck=di,Ik=Yp,nf=Wr,rf=Kp,Pk=wc,qh=kc(),je=yc,Rk=Vp,sf=Yn.supportsDescriptors,Dk=_c,Ok=hn(),zk=Ok("Promise.prototype.then",!0),Yh=pc(),Je=function t(){if(!(this instanceof t)||je.has(this,"[[AsyncDisposableState]]")||je.has(this,"[[DisposeCapability]]"))throw new Ac("can only be used with new");je.set(this,"[[AsyncDisposableState]]","pending"),je.set(this,"[[DisposeCapability]]",rf())},of=function(){var e=this;return je.assert(e,"[[AsyncDisposableState]]"),je.get(e,"[[AsyncDisposableState]]")==="disposed"},mi=Dk(of);sf?Ck(Je.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":of}):Je.prototype.disposed=!1;var af=function(e){je.set(e,"[[AsyncDisposableState]]","disposed"),sf||(e.disposed=!0)};Vr(Je.prototype,"disposeAsync",function(){var e=this;return mi(e)?qh(Hh):(af(e),zk(qh(Hh,Ik(je.get(e,"[[DisposeCapability]]"),Pk())),function(n){return n["?"]()}))});Vr(Je.prototype,"use",function(e){var n=this;if(mi(n))throw new Fo("a disposed stack can not use anything new");return xc(je.get(n,"[[DisposeCapability]]"),e,"ASYNC-DISPOSE"),e});Vr(Je.prototype,"adopt",function(e,n){var r=this;if(mi(r))throw new Fo("a disposed stack can not use anything new");if(!nf(n))throw new Ac("`onDisposeAsync` must be a function");var s=function(){return Tk(n,void 0,[e])};return s.value=e,xc(je.get(r,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",s),e});Vr(Je.prototype,"defer",function(e){var n=this;if(mi(n))throw new Fo("a disposed stack can not defer anything new");if(!nf(e))throw new Ac("`onDispose` must be a function");xc(je.get(n,"[[DisposeCapability]]"),void 0,"ASYNC-DISPOSE",e)});Vr(Je.prototype,"move",function(){var e=this;if(mi(e))throw new Fo("a disposed stack can not use anything new");var n=new Je;return je.set(n,"[[DisposeCapability]]",je.get(e,"[[DisposeCapability]]")),je.set(e,"[[DisposeCapability]]",rf()),af(e),n});Yh&&Vr(Je.prototype,Yh,Je.prototype.disposeAsync);Rk(Je.prototype,"AsyncDisposableStack");var Lk=Je,Mk=Lk,Nk=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:Mk},Uk=Yn,Fk=tc(),Zk=Nk,jk=function(){var e=Zk();return Uk(Fk,{AsyncDisposableStack:e},{AsyncDisposableStack:!0}),e},Wk=Uw,Bk=Hw,Gk=Ak,Vk=jk,Hk=function(){Wk(),Bk(),Gk(),Vk()};Hk();const Kh=new WeakMap;function qk(t){return(typeof t=="object"||typeof t=="function")&&t!==null&&"then"in t&&typeof t.then=="function"}function lr(t){return typeof t=="string"?t:typeof t=="symbol"?t.description??t.toString():t.name||"(anonymous class)"}function Jh(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function Yk(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class Kk{constructor(){v(this,"entries",new Map);v(this,"constructionStack",[])}register(e,n){if(n===void 0){if(typeof e!="function")throw Jh();this.validateClassRegistration(e),this.storeFactory(e,()=>this.instantiateClass(e));return}if(typeof n!="function")throw Jh();if(n.constructor.name==="AsyncFunction")throw Yk();this.storeFactory(e,n)}has(e){var n;return((n=this.entries.get(e))==null?void 0:n.factory)!==void 0}resolve(e){return this.resolveAny(e)}storeFactory(e,n){const r=this.getOrCreateEntry(e);r.factory=n,r.instance=void 0,r.error=void 0}validateClassRegistration(e){const n=Kh.get(e);if(n){if(e.length!==n.length)throw new Error(`${lr(e)} cannot be registered with register(Class). @injectable(...) declared ${n.length} dependencies but constructor arity is ${e.length}. Use register(Key, () => value) instead.`);return}if(e.length!==0)throw new Error(`${lr(e)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(e){const n=Kh.get(e);if(!n)return new e;const r=n.map(s=>this.resolveAny(s));return new e(...r)}resolveAny(e){return this.getOrCreateEntry(e).proxy}getOrCreateEntry(e){let n=this.entries.get(e);return n||(n={key:e},n.proxy=this.createProxy(n),this.entries.set(e,n),n)}createProxy(e){return new Proxy({},{get:(n,r)=>{if(r==="then")return;const s=this.getInstance(e),i=Reflect.get(s,r,s);return typeof i=="function"?i.bind(s):i},set:(n,r,s)=>{const i=this.getInstance(e);return Reflect.set(i,r,s,i)},has:(n,r)=>{const s=this.getInstance(e);return r in s}})}getInstance(e){if(e.instance)return e.instance;if(e.error)throw e.error;if(!e.factory)throw new Error(`${lr(e.key)} was resolved but never registered`);const n=this.constructionStack.indexOf(e.key);if(n!==-1){const r=[...this.constructionStack.slice(n),e.key].map(s=>lr(s)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(e.key);try{const r=e.factory();if(qk(r))throw new Error(`Factory for ${lr(e.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${lr(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 Ve=new Kk,Jk=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function Xk(t){for(const e of Object.keys(t))if(Jk.has(e))throw new Error(`Event payload key "${e}" is reserved; choose a different property name`)}function Qk(t,e){Xk(e);for(const n of Object.keys(e))Object.defineProperty(t,n,{value:e[n],writable:!0,enumerable:!0,configurable:!0})}function et(){class t extends Event{constructor(n,r){const{type:s,bubbles:i,cancelable:o,composed:a,...l}=r??{};if(s!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(n,{bubbles:i,cancelable:o,composed:a}),Qk(this,l)}}return t}class kt extends globalThis.EventTarget{}function eE(t,e,n){const r=t.dispose.bind(t);t.dispose=()=>{if(!e())return n(),r()}}function Hr(t){var n;class e extends t{constructor(...i){super(...i);$(this,n,!1);eE(this,()=>u(this,n),()=>{x(this,n,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return u(this,n)}}return n=new WeakMap,e}const tE=et(),eo=et(),lf="0123456789ABCDEFGHJKMNPQRSTVWXYZ",po=32,nE=16,cf=10,Xh=0xffffffffffff;var xn;(function(t){t.Base32IncorrectEncoding="B32_ENC_INVALID",t.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",t.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",t.EncodeTimeNegative="ENC_TIME_NEG",t.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",t.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",t.PRNGDetectFailure="PRNG_DETECT",t.ULIDInvalid="ULID_INVALID",t.Unexpected="UNEXPECTED",t.UUIDInvalid="UUID_INVALID"})(xn||(xn={}));class fs extends Error{constructor(e,n){super(`${n} (${e})`),this.name="ULIDError",this.code=e}}function rE(t){const e=Math.floor(t()*po)%po;return lf.charAt(e)}function sE(t){const e=iE(),n=e&&(e.crypto||e.msCrypto)||null;if(typeof(n==null?void 0:n.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return n.getRandomValues(r),r[0]/256};if(typeof(n==null?void 0:n.randomBytes)=="function")return()=>n.randomBytes(1).readUInt8()/256;throw new fs(xn.PRNGDetectFailure,"Failed to find a reliable PRNG")}function iE(){return lE()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function oE(t,e){let n="";for(;t>0;t--)n=rE(e)+n;return n}function aE(t,e=cf){if(isNaN(t))throw new fs(xn.EncodeTimeValueMalformed,`Time must be a number: ${t}`);if(t>Xh)throw new fs(xn.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Xh}: ${t}`);if(t<0)throw new fs(xn.EncodeTimeNegative,`Time must be positive: ${t}`);if(Number.isInteger(t)===!1)throw new fs(xn.EncodeTimeValueMalformed,`Time must be an integer: ${t}`);let n,r="";for(let s=e;s>0;s--)n=t%po,r=lf.charAt(n)+r,t=(t-n)/po;return r}function lE(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Tc(t,e){const n=sE(),r=Date.now();return aE(r,cf)+oE(nE,n)}const St=4,He=6,uf=2,fl=2,cE=St,uE=He,Cc="auto",sn="auto",kn=120,Qh=75,de=16,tn=kn*St+de*(St-1),vr=kn*He+de*(He-1),hE=200,dE=4,Li=150,pE=10,ed=2,fE=4;function hf(t){return ff(t)}function df(t,e){return ff(t.flatMap(n=>mf(n,e)))}function pf(t){const e=[],n=new Set;for(const r of t){if(r.type==="row"){e.push(`Top-level rows are invalid: ${r.id}`);continue}vf(r,"strip",e,n)}return{valid:e.length===0,errors:e}}function $s(t){const e=hf(t),n=pf(e);if(!n.valid)throw new Error(`Invalid layout: ${n.errors.join("; ")}`);return{totalNodes:e.length,nodes:e.filter(r=>r.type!=="row").map(yE)}}function ff(t){const e=[];for(const n of t){const r=gf(n);for(const s of r){if(s.type==="row"){e.push(...s.children.map(Ut));continue}e.push(s)}}return e}function gf(t){switch(t.type){case"card":return[Ut(t)];case"row":{const e=t.children.map(Ut);return e.length===0?[]:e.length===1?[e[0]]:[{...t,children:e}]}case"stack":{const e=[];for(const n of t.children){const r=gf(n);for(const s of r){if(s.type==="stack"){e.push(...s.children.map(gl));continue}if(s.type==="row"){e.push({...s,children:s.children.map(Ut)});continue}e.push(Ut(s))}}return e.length===0?[]:e.length===1?[gl(e[0])]:[{...t,children:e}]}}}function mf(t,e){switch(t.type){case"card":return t.artifactID===e?[]:[Ut(t)];case"row":{const n=t.children.filter(r=>r.artifactID!==e).map(Ut);return n.length===0?[]:n.length===1?[n[0]]:[{...t,children:n}]}case"stack":{const n=t.children.flatMap(r=>mf(r,e).filter(i=>i.type!=="stack"));return n.length===0?[]:n.length===1?[gl(n[0])]:[{...t,children:n}]}}}function vf(t,e,n,r){switch(t.type){case"card":yf(t,e,n,r);return;case"row":gE(t,e,n,r);return;case"stack":mE(t,e,n,r);return}}function yf(t,e,n,r){Ic(t.id,n),typeof t.artifactID!="string"||t.artifactID.length===0?n.push(`Card ${t.id} is missing artifactID`):r.has(t.artifactID)?n.push(`Duplicate artifactID in layout: ${t.artifactID}`):r.add(t.artifactID),vE(t.width)||n.push(`Card ${t.id} width must be an integer in the range 2-4`),bf(t.height)||n.push(`Card ${t.id} height must be an integer in the range 2-6 or "auto"`);const s=En(t.width);e==="row"&&s<uf&&n.push(`Row child ${t.id} must be at least 2 columns wide`)}function gE(t,e,n,r){if(Ic(t.id,n),e!=="stack"&&n.push(`Row ${t.id} may only appear inside a stack`),bf(t.height,fE)||n.push(`Row ${t.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(t.children)||t.children.length===0){n.push(`Row ${t.id} must contain card nodes`);return}let s=0;for(const i of t.children){if(i.type!=="card"){n.push(`Row ${t.id} must contain only card nodes`);continue}yf(i,"row",n,r),s+=En(i.width)}s!==St&&n.push(`Row ${t.id} children must sum to 4 columns`)}function mE(t,e,n,r){if(Ic(t.id,n),e!=="strip"&&n.push(`Invalid nested stack at ${t.id}; stack children cannot contain another nested stack`),!Array.isArray(t.children)||t.children.length===0){n.push(`Stack ${t.id} must contain at least one child`);return}let s=0,i=0;for(const a of t.children){if(a.type==="stack"){n.push(`Stack ${t.id} cannot contain another nested stack`);continue}if(vf(a,"stack",n,r),a.height===sn){i+=1;continue}s+=a.height}if(s>He&&n.push(`Stack ${t.id} exceeds the 6-row budget`),i===0)return;const o=He-s;if(o<i*fl||o%i!==0){n.push(`Stack ${t.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/i<fl&&n.push(`Stack ${t.id} has auto-height children below the minimum row size`)}function Ic(t,e){(typeof t!="string"||t.length===0)&&e.push(`Node id must be a non-empty string: ${String(t)}`)}function vE(t){return t===Cc||Number.isInteger(t)&&t>=uf&&t<=cE}function bf(t,e=uE){return t===sn||Number.isInteger(t)&&t>=fl&&t<=e}function En(t){return t===Cc?St:t}function yE(t){if(t.type==="card")return{id:t.id,type:"card",width:En(t.width),cards:[{id:t.id,artifactID:t.artifactID,col:1,row:1,width:En(t.width),height:wf(t.height,He)}]};const e=bE(t.children),n=[];let r=1;for(let s=0;s<t.children.length;s+=1){const i=t.children[s],o=e[s];if(i.type==="card")n.push({id:i.id,artifactID:i.artifactID,col:1,row:r,width:En(i.width),height:o});else{let a=1;for(const l of i.children)n.push({id:l.id,artifactID:l.artifactID,col:a,row:r,width:En(l.width),height:o}),a+=En(l.width)}r+=o}return{id:t.id,type:"stack",width:n.reduce((s,i)=>Math.max(s,i.col+i.width-1),1),cards:n}}function bE(t){let e=0,n=0;for(const s of t)s.height===sn?n+=1:e+=s.height;const r=n>0?(He-e)/n:0;return t.map(s=>wf(s.height,r))}function wf(t,e){return t===sn?e:t}function Ut(t){return{...t}}function gl(t){return t.type==="card"?Ut(t):{...t,children:t.children.map(Ut)}}function _f(t,e={}){return{id:e.id??Tc(),type:"card",artifactID:t,width:e.width??Cc,height:e.height??sn}}function Sf(t,e){return t.some(n=>kf(n,e))}function kf(t,e){switch(t.type){case"card":return t.artifactID===e;case"row":return t.children.some(n=>n.artifactID===e);case"stack":return t.children.some(n=>kf(n,e))}}function td(t){return t.layout.flatMap(Ef)}function Ef(t){switch(t.type){case"card":return[t.artifactID];case"row":return t.children.map(e=>e.artifactID);case"stack":return t.children.flatMap(Ef)}}const te=et(),$f=et(),ss=et(),wE=et();function _E(t){class e extends Error{constructor(r,s){super(r),this.name=t,s&&Object.assign(this,s)}}return e}const SE=_E("RequestError"),kE=200,EE=300;class $E{constructor(e,n){v(this,"serverURL");v(this,"token");this.serverURL=e.replace(/\/$/,""),this.token=n.token}async requestJSON(e,n,r){const s=await this.request(e,n,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),i=await AE(s);if(!s.ok||s.status<kE||s.status>=EE)throw this.createError(typeof i.error=="string"?i.error:s.statusText,s.status);return i}async requestVoid(e,n){const r=await this.request(e,n);if(!r.ok)throw this.createError(await Za(r,r.statusText),r.status)}async requestText(e,n){const r=await this.request(e,n);if(!r.ok)throw this.createError(await Za(r,r.statusText),r.status);return r.text()}async requestRawVoid(e,n,r){const s=await this.request(e,n,r,{"content-type":"text/plain"});if(!s.ok)throw this.createError(await Za(s,s.statusText),s.status)}createError(e,n){const r={serverURL:this.serverURL};return n!==void 0&&(r.status=n),new SE(e,r)}async request(e,n,r,s){const i=`${this.serverURL}${n}`;try{return await fetch(i,{method:e,headers:this.buildHeaders(s),body:r})}catch(o){throw this.createError(o instanceof Error?o.message:"Failed to reach server")}}buildHeaders(e){const n={...e??{}};return this.token&&(n.Authorization=`Bearer ${this.token}`),Object.keys(n).length>0?n:void 0}}async function AE(t){try{return await t.json()}catch{const e=await t.text().catch(()=>"");return e?{message:e}:{}}}async function Za(t,e){try{const n=await t.json();if(typeof n.error=="string")return n.error;if(typeof n.message=="string")return n.message}catch{}return e}function Af(t){return t.map(e=>`${e.name} (${e.id})`).join(", ")}var mt,Eo,xf;class xE{constructor(e){$(this,Eo);$(this,mt);x(this,mt,e)}list(){return u(this,mt).requestJSON("GET","/screens")}async get(e={}){const n=await b(this,Eo,xf).call(this,e.screenID);return u(this,mt).requestJSON("GET",`/screens/${encodeURIComponent(n)}`)}create(e){const n={name:e.name};return e.id!==void 0&&(n.id=e.id),u(this,mt).requestJSON("POST","/screens",n)}update(e){const n={};return e.name!==void 0&&(n.name=e.name),e.layout!==void 0&&(n.layout=e.layout),u(this,mt).requestJSON("PATCH",`/screens/${encodeURIComponent(e.screenID)}`,n)}remove(e){return u(this,mt).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}`)}}mt=new WeakMap,Eo=new WeakSet,xf=async function(e){if(e!==void 0)return e;const{screens:n}=await this.list();if(n.length===1)return n[0].id;throw u(this,mt).createError(`screenID is required when multiple screens exist. Available screens: ${Af(n)}`)};var Ne,Ds,$o,Tf;class TE{constructor(e,n){$(this,$o);$(this,Ne);$(this,Ds);x(this,Ne,e),x(this,Ds,n)}async create(e){const n=await b(this,$o,Tf).call(this,e.screenID);return u(this,Ne).requestJSON("POST",`/screens/${encodeURIComponent(n)}/artifact`,{type:e.type,title:e.title,externalFilePath:e.externalFilePath})}get(e){return u(this,Ne).requestJSON("GET",`/artifacts/${encodeURIComponent(e.artifactID)}`)}update(e){const n={};return e.title!==void 0&&(n.title=e.title),u(this,Ne).requestJSON("PATCH",`/artifacts/${encodeURIComponent(e.artifactID)}`,n)}edit(e){return u(this,Ne).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/edit`)}commitPending(e){return u(this,Ne).requestJSON("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/commit`)}abandonPending(e){return u(this,Ne).requestVoid("POST",`/artifacts/${encodeURIComponent(e.artifactID)}/abandon`)}remove(e){return u(this,Ne).requestJSON("DELETE",`/screens/${encodeURIComponent(e.screenID)}/artifacts/${encodeURIComponent(e.artifactID)}`)}getContent(e){return u(this,Ne).requestText("GET",`/artifacts/${encodeURIComponent(e.artifactID)}/content`)}putContent(e){return u(this,Ne).requestRawVoid("PUT",`/artifacts/${encodeURIComponent(e.artifactID)}/content`,e.content)}}Ne=new WeakMap,Ds=new WeakMap,$o=new WeakSet,Tf=async function(e){if(e!==void 0)return e;const{screens:n}=await u(this,Ds).list();if(n.length===1)return n[0].id;throw u(this,Ne).createError(`screenID is required when multiple screens exist. Available screens: ${Af(n)}`)};var Os;class CE{constructor(e){$(this,Os);x(this,Os,e)}async list(){const{views:e}=await u(this,Os).requestJSON("GET","/views");return e}}Os=new WeakMap;var Vt;class IE{constructor(e,n={}){v(this,"screens");v(this,"artifacts");v(this,"views");$(this,Vt);x(this,Vt,new $E(e,n)),this.screens=new xE(u(this,Vt)),this.artifacts=new TE(u(this,Vt),this.screens),this.views=new CE(u(this,Vt))}health(){return u(this,Vt).requestJSON("GET","/health")}}Vt=new WeakMap;const PE=Hr(kt);var Cn,Ue,In,De,Ht,qt,Q,ur,Cf,zs,If,Pf,Rf,Df,ml,vl,yl,Of;class RE extends PE{constructor(n){var s;super();$(this,Q);v(this,"id");v(this,"server");$(this,Cn);$(this,Ue,new Map);$(this,In);$(this,De);$(this,Ht);$(this,qt,null);$(this,zs,n=>{if(this.disposed)return;const r=n.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&b(this,Q,If).call(this,r.screen);break;case"artifact-created":r.screenID===this.id&&b(this,Q,Pf).call(this,r.artifact);break;case"artifact-updated":b(this,Q,Rf).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&b(this,Q,Df).call(this,r.artifactID);break;case"artifact-content-changed":u(this,Ue).has(r.artifactID)&&this.dispatchEvent(new wE("artifact-content-changed",{artifactID:r.artifactID}));break}});this.id=n.screen.id,this.server=n.server,x(this,Cn,n.localStore),x(this,In,n.screen.name),x(this,De,structuredClone(n.screen.layout));const r=((s=u(this,Cn).get().screens[this.id])==null?void 0:s.scrollPosition)??0;x(this,Ht,Math.max(0,r)),this.server.addEventListener("server-event",u(this,zs)),b(this,Q,Cf).call(this)}get name(){return u(this,In)}get layout(){return u(this,De)}get scrollPosition(){return u(this,Ht)}get artifacts(){return u(this,Ue)}setScrollPosition(n){b(this,Q,ur).call(this);const r=Math.max(0,n);r!==u(this,Ht)&&(x(this,Ht,r),b(this,Q,Of).call(this),this.dispatchEvent(new te("change")))}setLayout(n){b(this,Q,ur).call(this);const r=hf(n);if(!pf(r).valid)return;const i=b(this,Q,vl).call(this);x(this,De,r),x(this,qt,{layout:r,snapshot:i}),this.dispatchEvent(new te("change")),this.server.client.screens.update({screenID:this.id,layout:r.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=u(this,qt))==null?void 0:o.layout)===r&&(x(this,qt,null),b(this,Q,yl).call(this,i),this.dispatchEvent(new te("change")))})}rename(n){b(this,Q,ur).call(this),x(this,In,n),this.dispatchEvent(new te("change")),this.server.client.screens.update({screenID:this.id,name:n}).catch(()=>{})}async remove(){b(this,Q,ur).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(n){if(b(this,Q,ur).call(this),!u(this,Ue).has(n))return;const r=b(this,Q,vl).call(this);b(this,Q,ml).call(this,n),this.dispatchEvent(new te("change")),this.server.client.artifacts.remove({artifactID:n,screenID:this.id}).catch(()=>{this.disposed||(b(this,Q,yl).call(this,r),this.dispatchEvent(new te("change")))})}dispose(){this.server.removeEventListener("server-event",u(this,zs))}}Cn=new WeakMap,Ue=new WeakMap,In=new WeakMap,De=new WeakMap,Ht=new WeakMap,qt=new WeakMap,Q=new WeakSet,ur=function(){if(this.disposed)throw new Error("ScreenModel is disposed")},Cf=async function(){try{const n=await this.server.client.screens.get({screenID:this.id});if(this.disposed)return;for(const r of n.artifacts)u(this,Ue).set(r.id,r);this.dispatchEvent(new te("change"))}catch{}},zs=new WeakMap,If=function(n){u(this,qt)&&x(this,qt,null),x(this,In,n.name),x(this,De,structuredClone(n.layout)),this.dispatchEvent(new te("change"))},Pf=function(n){Sf(u(this,De),n.id)||x(this,De,[...u(this,De),_f(n.id)]),u(this,Ue).set(n.id,n),this.dispatchEvent(new te("change"))},Rf=function(n){const r=u(this,Ue).get(n.id);r&&(u(this,Ue).set(n.id,{...r,...n}),this.dispatchEvent(new te("change")))},Df=function(n){b(this,Q,ml).call(this,n)&&this.dispatchEvent(new te("change"))},ml=function(n){const r=u(this,Ue).delete(n),s=td({layout:u(this,De)}).length,i=df(u(this,De),n),o=td({layout:i}).length;return x(this,De,i),r||s!==o},vl=function(){return{layout:structuredClone(u(this,De)),artifacts:new Map([...u(this,Ue).entries()].map(([n,r])=>[n,structuredClone(r)]))}},yl=function(n){x(this,De,structuredClone(n.layout)),u(this,Ue).clear();for(const[r,s]of n.artifacts)u(this,Ue).set(r,structuredClone(s))},Of=function(){const n=u(this,Cn).get();u(this,Cn).set({...n,screens:{...n.screens,[this.id]:{scrollPosition:u(this,Ht)}}})};const DE=Hr(kt);var Fe,vt,nt,Ls,Ms,Ns,nn,to,zf;class OE extends DE{constructor(n){super();$(this,nn);$(this,Fe);$(this,vt);$(this,nt,null);$(this,Ls,()=>{this.disposed||b(this,nn,to).call(this)});$(this,Ms,()=>{this.disposed||b(this,nn,to).call(this)});$(this,Ns,n=>{var s;if(this.disposed)return;const r=n.event;r.type==="screen-removed"&&((s=u(this,nt))==null?void 0:s.id)===r.screenID&&this.clearActive()});x(this,Fe,n.localStore),x(this,vt,n.serverManager),u(this,Fe).addEventListener("change",u(this,Ls)),u(this,vt).addEventListener("change",u(this,Ms)),u(this,vt).addEventListener("server-event",u(this,Ns)),b(this,nn,to).call(this)}get activeScreen(){return u(this,nt)}setActive(n,r){const s=u(this,Fe).get();s.activeServerURL===n&&s.activeScreenID===r||u(this,Fe).set({...s,activeServerURL:n,activeScreenID:r})}clearActive(){const n=u(this,Fe).get();n.activeServerURL===null&&n.activeScreenID===null||u(this,Fe).set({...n,activeServerURL:null,activeScreenID:null})}dispose(){var n;u(this,Fe).removeEventListener("change",u(this,Ls)),u(this,vt).removeEventListener("change",u(this,Ms)),u(this,vt).removeEventListener("server-event",u(this,Ns)),(n=u(this,nt))==null||n.dispose(),x(this,nt,null)}}Fe=new WeakMap,vt=new WeakMap,nt=new WeakMap,Ls=new WeakMap,Ms=new WeakMap,Ns=new WeakMap,nn=new WeakSet,to=function(){var l,c,d;const{activeServerURL:n,activeScreenID:r}=u(this,Fe).get();let s=n?u(this,vt).servers.get(n)??null:null,i=s&&r?s.screens.get(r)??null:null;if(!i){const p=b(this,nn,zf).call(this);if(p){s=p.server,i=p.screen,u(this,Fe).set({...u(this,Fe).get(),activeServerURL:p.server.url,activeScreenID:p.screen.id});return}}const o=((l=u(this,nt))==null?void 0:l.id)??null,a=(i==null?void 0:i.id)??null;o===a&&((c=u(this,nt))==null?void 0:c.server)===s||((d=u(this,nt))==null||d.dispose(),x(this,nt,s&&i?new RE({screen:i,server:s,localStore:u(this,Fe)}):null),this.dispatchEvent(new tE("active-screen-changed")))},zf=function(){for(const n of u(this,vt).servers.values()){const r=n.screens.values().next().value;if(r)return{server:n,screen:r}}return null};const zE="Local",LE="store-";function Pt(t){return new URL(t).origin}function ME(t){return{servers:[{url:Pt(t),name:zE}],activeServerURL:null,activeScreenID:null,screens:{}}}var Pn,Rn,Dn;class NE extends kt{constructor(n,r,s={}){super();$(this,Pn);$(this,Rn);$(this,Dn);x(this,Pn,`${LE}${n}`),x(this,Rn,s.storage??UE());const i=u(this,Rn).getItem(u(this,Pn));i===null?(x(this,Dn,r),u(this,Rn).setItem(u(this,Pn),JSON.stringify(r))):x(this,Dn,JSON.parse(i))}get(){return u(this,Dn)}set(n){x(this,Dn,n),u(this,Rn).setItem(u(this,Pn),JSON.stringify(n)),this.dispatchEvent(new te("change"))}}Pn=new WeakMap,Rn=new WeakMap,Dn=new WeakMap;function UE(){const t=globalThis.localStorage;if(!t)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return t}function S(t,e,n){function r(a,l){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:l,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,l);const c=o.prototype,d=Object.keys(c);for(let p=0;p<d.length;p++){const y=d[p];y in a||(a[y]=c[y].bind(a))}}const s=(n==null?void 0:n.Parent)??Object;class i extends s{}Object.defineProperty(i,"name",{value:t});function o(a){var l;const c=n!=null&&n.Parent?new i:this;r(c,a),(l=c._zod).deferred??(l.deferred=[]);for(const d of c._zod.deferred)d();return c}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var l,c;return n!=null&&n.Parent&&a instanceof n.Parent?!0:(c=(l=a==null?void 0:a._zod)==null?void 0:l.traits)==null?void 0:c.has(t)}}),Object.defineProperty(o,"name",{value:t}),o}class _r extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Lf extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Mf={};function on(t){return Mf}function Nf(t){const e=Object.values(t).filter(r=>typeof r=="number");return Object.entries(t).filter(([r,s])=>e.indexOf(+r)===-1).map(([r,s])=>s)}function bl(t,e){return typeof e=="bigint"?e.toString():e}function Pc(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function Rc(t){return t==null}function Dc(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function FE(t,e){const n=(t.toString().split(".")[1]||"").length,r=e.toString();let s=(r.split(".")[1]||"").length;if(s===0&&/\d?e-\d?/.test(r)){const l=r.match(/\d?e-(\d?)/);l!=null&&l[1]&&(s=Number.parseInt(l[1]))}const i=n>s?n:s,o=Number.parseInt(t.toFixed(i).replace(".","")),a=Number.parseInt(e.toFixed(i).replace(".",""));return o%a/10**i}const nd=Symbol("evaluating");function ee(t,e,n){let r;Object.defineProperty(t,e,{get(){if(r!==nd)return r===void 0&&(r=nd,r=n()),r},set(s){Object.defineProperty(t,e,{value:s})},configurable:!0})}function Jn(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function pn(...t){const e={};for(const n of t){const r=Object.getOwnPropertyDescriptors(n);Object.assign(e,r)}return Object.defineProperties({},e)}function rd(t){return JSON.stringify(t)}function ZE(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Uf="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function fo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const jE=Pc(()=>{var t;if(typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)!=null&&t.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function zr(t){if(fo(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const n=e.prototype;return!(fo(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Ff(t){return zr(t)?{...t}:Array.isArray(t)?[...t]:t}const WE=new Set(["string","number","symbol"]);function Lr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fn(t,e,n){const r=new t._zod.constr(e??t._zod.def);return(!e||n!=null&&n.parent)&&(r._zod.parent=t),r}function O(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function BE(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const GE={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 VE(t,e){const n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=pn(t._zod.def,{get shape(){const o={};for(const a in e){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(o[a]=n.shape[a])}return Jn(this,"shape",o),o},checks:[]});return fn(t,i)}function HE(t,e){const n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=pn(t._zod.def,{get shape(){const o={...t._zod.def.shape};for(const a in e){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete o[a]}return Jn(this,"shape",o),o},checks:[]});return fn(t,i)}function qE(t,e){if(!zr(e))throw new Error("Invalid input to extend: expected a plain object");const n=t._zod.def.checks;if(n&&n.length>0){const i=t._zod.def.shape;for(const o in e)if(Object.getOwnPropertyDescriptor(i,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const s=pn(t._zod.def,{get shape(){const i={...t._zod.def.shape,...e};return Jn(this,"shape",i),i}});return fn(t,s)}function YE(t,e){if(!zr(e))throw new Error("Invalid input to safeExtend: expected a plain object");const n=pn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e};return Jn(this,"shape",r),r}});return fn(t,n)}function KE(t,e){const n=pn(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return Jn(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return fn(t,n)}function JE(t,e,n){const s=e._zod.def.checks;if(s&&s.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=pn(e._zod.def,{get shape(){const a=e._zod.def.shape,l={...a};if(n)for(const c in n){if(!(c in a))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(l[c]=t?new t({type:"optional",innerType:a[c]}):a[c])}else for(const c in a)l[c]=t?new t({type:"optional",innerType:a[c]}):a[c];return Jn(this,"shape",l),l},checks:[]});return fn(e,o)}function XE(t,e,n){const r=pn(e._zod.def,{get shape(){const s=e._zod.def.shape,i={...s};if(n)for(const o in n){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(i[o]=new t({type:"nonoptional",innerType:s[o]}))}else for(const o in s)i[o]=new t({type:"nonoptional",innerType:s[o]});return Jn(this,"shape",i),i}});return fn(e,r)}function yr(t,e=0){var n;if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(((n=t.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function br(t,e){return e.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(t),n})}function Mi(t){return typeof t=="string"?t:t==null?void 0:t.message}function an(t,e,n){var s,i,o,a,l,c;const r={...t,path:t.path??[]};if(!t.message){const d=Mi((o=(i=(s=t.inst)==null?void 0:s._zod.def)==null?void 0:i.error)==null?void 0:o.call(i,t))??Mi((a=e==null?void 0:e.error)==null?void 0:a.call(e,t))??Mi((l=n.customError)==null?void 0:l.call(n,t))??Mi((c=n.localeError)==null?void 0:c.call(n,t))??"Invalid input";r.message=d}return delete r.inst,delete r.continue,e!=null&&e.reportInput||delete r.input,r}function Oc(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Ts(...t){const[e,n,r]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:r}:{...e}}const Zf=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,bl,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},jf=S("$ZodError",Zf),Wf=S("$ZodError",Zf,{Parent:Error});function QE(t,e=n=>n.message){const n={},r=[];for(const s of t.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:n}}function e$(t,e=n=>n.message){const n={_errors:[]},r=s=>{for(const i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(o=>r({issues:o}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({issues:i.issues});else if(i.path.length===0)n._errors.push(e(i));else{let o=n,a=0;for(;a<i.path.length;){const l=i.path[a];a===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(e(i))):o[l]=o[l]||{_errors:[]},o=o[l],a++}}};return r(t),n}const zc=t=>(e,n,r,s)=>{const i=r?Object.assign(r,{async:!1}):{async:!1},o=e._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new _r;if(o.issues.length){const a=new((s==null?void 0:s.Err)??t)(o.issues.map(l=>an(l,i,on())));throw Uf(a,s==null?void 0:s.callee),a}return o.value},Lc=t=>async(e,n,r,s)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let o=e._zod.run({value:n,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((s==null?void 0:s.Err)??t)(o.issues.map(l=>an(l,i,on())));throw Uf(a,s==null?void 0:s.callee),a}return o.value},Zo=t=>(e,n,r)=>{const s=r?{...r,async:!1}:{async:!1},i=e._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new _r;return i.issues.length?{success:!1,error:new(t??jf)(i.issues.map(o=>an(o,s,on())))}:{success:!0,data:i.value}},t$=Zo(Wf),jo=t=>async(e,n,r)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=e._zod.run({value:n,issues:[]},s);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new t(i.issues.map(o=>an(o,s,on())))}:{success:!0,data:i.value}},n$=jo(Wf),r$=t=>(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return zc(t)(e,n,s)},s$=t=>(e,n,r)=>zc(t)(e,n,r),i$=t=>async(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Lc(t)(e,n,s)},o$=t=>async(e,n,r)=>Lc(t)(e,n,r),a$=t=>(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Zo(t)(e,n,s)},l$=t=>(e,n,r)=>Zo(t)(e,n,r),c$=t=>async(e,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return jo(t)(e,n,s)},u$=t=>async(e,n,r)=>jo(t)(e,n,r),h$=/^[cC][^\s-]{8,}$/,d$=/^[0-9a-z]+$/,p$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,f$=/^[0-9a-vA-V]{20}$/,g$=/^[A-Za-z0-9]{27}$/,m$=/^[a-zA-Z0-9_-]{21}$/,v$=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,y$=/^([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})$/,sd=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,b$=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,w$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function _$(){return new RegExp(w$,"u")}const S$=/^(?:(?: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])$/,k$=/^(([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}|:))$/,E$=/^((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])$/,$$=/^(([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])$/,A$=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Bf=/^[A-Za-z0-9_-]*$/,x$=/^\+[1-9]\d{6,14}$/,Gf="(?:(?:\\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])))",T$=new RegExp(`^${Gf}$`);function Vf(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function C$(t){return new RegExp(`^${Vf(t)}$`)}function I$(t){const e=Vf({precision:t.precision}),n=["Z"];t.local&&n.push(""),t.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${e}(?:${n.join("|")})`;return new RegExp(`^${Gf}T(?:${r})$`)}const P$=t=>{const e=t?`[\\s\\S]{${(t==null?void 0:t.minimum)??0},${(t==null?void 0:t.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},R$=/^-?\d+$/,Hf=/^-?\d+(?:\.\d+)?$/,D$=/^(?:true|false)$/i,O$=/^[^A-Z]*$/,z$=/^[^a-z]*$/,We=S("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),qf={number:"number",bigint:"bigint",object:"date"},Yf=S("$ZodCheckLessThan",(t,e)=>{We.init(t,e);const n=qf[typeof e.value];t._zod.onattach.push(r=>{const s=r._zod.bag,i=(e.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<i&&(e.inclusive?s.maximum=e.value:s.exclusiveMaximum=e.value)}),t._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Kf=S("$ZodCheckGreaterThan",(t,e)=>{We.init(t,e);const n=qf[typeof e.value];t._zod.onattach.push(r=>{const s=r._zod.bag,i=(e.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>i&&(e.inclusive?s.minimum=e.value:s.exclusiveMinimum=e.value)}),t._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),L$=S("$ZodCheckMultipleOf",(t,e)=>{We.init(t,e),t._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=e.value)}),t._zod.check=n=>{if(typeof n.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%e.value===BigInt(0):FE(n.value,e.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:e.value,input:n.value,inst:t,continue:!e.abort})}}),M$=S("$ZodCheckNumberFormat",(t,e)=>{var o;We.init(t,e),e.format=e.format||"float64";const n=(o=e.format)==null?void 0:o.includes("int"),r=n?"int":"number",[s,i]=GE[e.format];t._zod.onattach.push(a=>{const l=a._zod.bag;l.format=e.format,l.minimum=s,l.maximum=i,n&&(l.pattern=R$)}),t._zod.check=a=>{const l=a.value;if(n){if(!Number.isInteger(l)){a.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:l,inst:t});return}if(!Number.isSafeInteger(l)){l>0?a.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,inclusive:!0,continue:!e.abort}):a.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,inclusive:!0,continue:!e.abort});return}}l<s&&a.issues.push({origin:"number",input:l,code:"too_small",minimum:s,inclusive:!0,inst:t,continue:!e.abort}),l>i&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:i,inclusive:!0,inst:t,continue:!e.abort})}}),N$=S("$ZodCheckMaxLength",(t,e)=>{var n;We.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!Rc(s)&&s.length!==void 0}),t._zod.onattach.push(r=>{const s=r._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<s&&(r._zod.bag.maximum=e.maximum)}),t._zod.check=r=>{const s=r.value;if(s.length<=e.maximum)return;const o=Oc(s);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),U$=S("$ZodCheckMinLength",(t,e)=>{var n;We.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!Rc(s)&&s.length!==void 0}),t._zod.onattach.push(r=>{const s=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>s&&(r._zod.bag.minimum=e.minimum)}),t._zod.check=r=>{const s=r.value;if(s.length>=e.minimum)return;const o=Oc(s);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),F$=S("$ZodCheckLengthEquals",(t,e)=>{var n;We.init(t,e),(n=t._zod.def).when??(n.when=r=>{const s=r.value;return!Rc(s)&&s.length!==void 0}),t._zod.onattach.push(r=>{const s=r._zod.bag;s.minimum=e.length,s.maximum=e.length,s.length=e.length}),t._zod.check=r=>{const s=r.value,i=s.length;if(i===e.length)return;const o=Oc(s),a=i>e.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:r.value,inst:t,continue:!e.abort})}}),Wo=S("$ZodCheckStringFormat",(t,e)=>{var n,r;We.init(t,e),t._zod.onattach.push(s=>{const i=s._zod.bag;i.format=e.format,e.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(e.pattern))}),e.pattern?(n=t._zod).check??(n.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(r=t._zod).check??(r.check=()=>{})}),Z$=S("$ZodCheckRegex",(t,e)=>{Wo.init(t,e),t._zod.check=n=>{e.pattern.lastIndex=0,!e.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),j$=S("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=O$),Wo.init(t,e)}),W$=S("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=z$),Wo.init(t,e)}),B$=S("$ZodCheckIncludes",(t,e)=>{We.init(t,e);const n=Lr(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position}}${n}`:n);e.pattern=r,t._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),t._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:t,continue:!e.abort})}}),G$=S("$ZodCheckStartsWith",(t,e)=>{We.init(t,e);const n=new RegExp(`^${Lr(e.prefix)}.*`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=r=>{r.value.startsWith(e.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:r.value,inst:t,continue:!e.abort})}}),V$=S("$ZodCheckEndsWith",(t,e)=>{We.init(t,e);const n=new RegExp(`.*${Lr(e.suffix)}$`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=r=>{r.value.endsWith(e.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:r.value,inst:t,continue:!e.abort})}}),H$=S("$ZodCheckOverwrite",(t,e)=>{We.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}});class q${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),s=Math.min(...r.map(o=>o.length-o.trimStart().length)),i=r.map(o=>o.slice(s)).map(o=>" ".repeat(this.indent*2)+o);for(const o of i)this.content.push(o)}compile(){const e=Function,n=this==null?void 0:this.args,s=[...((this==null?void 0:this.content)??[""]).map(i=>` ${i}`)];return new e(...n,s.join(`
|
|
6
|
-
`))}}const Y$={major:4,minor:3,patch:6},le=S("$ZodType",(t,e)=>{var s;var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=Y$;const r=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&r.unshift(t);for(const i of r)for(const o of i._zod.onattach)o(t);if(r.length===0)(n=t._zod).deferred??(n.deferred=[]),(s=t._zod.deferred)==null||s.push(()=>{t._zod.run=t._zod.parse});else{const i=(a,l,c)=>{let d=yr(a),p;for(const y of l){if(y._zod.def.when){if(!y._zod.def.when(a))continue}else if(d)continue;const m=a.issues.length,E=y._zod.check(a);if(E instanceof Promise&&(c==null?void 0:c.async)===!1)throw new _r;if(p||E instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await E,a.issues.length!==m&&(d||(d=yr(a,m)))});else{if(a.issues.length===m)continue;d||(d=yr(a,m))}}return p?p.then(()=>a):a},o=(a,l,c)=>{if(yr(a))return a.aborted=!0,a;const d=i(l,r,c);if(d instanceof Promise){if(c.async===!1)throw new _r;return d.then(p=>t._zod.parse(p,c))}return t._zod.parse(d,c)};t._zod.run=(a,l)=>{if(l.skipChecks)return t._zod.parse(a,l);if(l.direction==="backward"){const d=t._zod.parse({value:a.value,issues:[]},{...l,skipChecks:!0});return d instanceof Promise?d.then(p=>o(p,a,l)):o(d,a,l)}const c=t._zod.parse(a,l);if(c instanceof Promise){if(l.async===!1)throw new _r;return c.then(d=>i(d,r,l))}return i(c,r,l)}}ee(t,"~standard",()=>({validate:i=>{var o;try{const a=t$(t,i);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return n$(t,i).then(l=>{var c;return l.success?{value:l.data}:{issues:(c=l.error)==null?void 0:c.issues}})}},vendor:"zod",version:1}))}),Mc=S("$ZodString",(t,e)=>{var n;le.init(t,e),t._zod.pattern=[...((n=t==null?void 0:t._zod.bag)==null?void 0:n.patterns)??[]].pop()??P$(t._zod.bag),t._zod.parse=(r,s)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),oe=S("$ZodStringFormat",(t,e)=>{Wo.init(t,e),Mc.init(t,e)}),K$=S("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=y$),oe.init(t,e)}),J$=S("$ZodUUID",(t,e)=>{if(e.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(r===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=sd(r))}else e.pattern??(e.pattern=sd());oe.init(t,e)}),X$=S("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=b$),oe.init(t,e)}),Q$=S("$ZodURL",(t,e)=>{oe.init(t,e),t._zod.check=n=>{try{const r=n.value.trim(),s=new URL(r);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(s.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:n.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:n.value,inst:t,continue:!e.abort})),e.normalize?n.value=s.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:t,continue:!e.abort})}}}),eA=S("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=_$()),oe.init(t,e)}),tA=S("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=m$),oe.init(t,e)}),nA=S("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=h$),oe.init(t,e)}),rA=S("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=d$),oe.init(t,e)}),sA=S("$ZodULID",(t,e)=>{e.pattern??(e.pattern=p$),oe.init(t,e)}),iA=S("$ZodXID",(t,e)=>{e.pattern??(e.pattern=f$),oe.init(t,e)}),oA=S("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=g$),oe.init(t,e)}),aA=S("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=I$(e)),oe.init(t,e)}),lA=S("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=T$),oe.init(t,e)}),cA=S("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=C$(e)),oe.init(t,e)}),uA=S("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=v$),oe.init(t,e)}),hA=S("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=S$),oe.init(t,e),t._zod.bag.format="ipv4"}),dA=S("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=k$),oe.init(t,e),t._zod.bag.format="ipv6",t._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:t,continue:!e.abort})}}}),pA=S("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=E$),oe.init(t,e)}),fA=S("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=$$),oe.init(t,e),t._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[s,i]=r;if(!i)throw new Error;const o=Number(i);if(`${o}`!==i)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${s}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:t,continue:!e.abort})}}});function Jf(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const gA=S("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=A$),oe.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{Jf(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort})}});function mA(t){if(!Bf.test(t))return!1;const e=t.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=e.padEnd(Math.ceil(e.length/4)*4,"=");return Jf(n)}const vA=S("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Bf),oe.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=n=>{mA(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!e.abort})}}),yA=S("$ZodE164",(t,e)=>{e.pattern??(e.pattern=x$),oe.init(t,e)});function bA(t,e=null){try{const n=t.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const s=JSON.parse(atob(r));return!("typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&(!("alg"in s)||s.alg!==e))}catch{return!1}}const wA=S("$ZodJWT",(t,e)=>{oe.init(t,e),t._zod.check=n=>{bA(n.value,e.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!e.abort})}}),Xf=S("$ZodNumber",(t,e)=>{le.init(t,e),t._zod.pattern=t._zod.bag.pattern??Hf,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=Number(n.value)}catch{}const s=n.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return n;const i=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:s,inst:t,...i?{received:i}:{}}),n}}),_A=S("$ZodNumberFormat",(t,e)=>{M$.init(t,e),Xf.init(t,e)}),SA=S("$ZodBoolean",(t,e)=>{le.init(t,e),t._zod.pattern=D$,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=!!n.value}catch{}const s=n.value;return typeof s=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:t}),n}}),kA=S("$ZodUnknown",(t,e)=>{le.init(t,e),t._zod.parse=n=>n}),EA=S("$ZodNever",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:t}),n)});function id(t,e,n){t.issues.length&&e.issues.push(...br(n,t.issues)),e.value[n]=t.value}const $A=S("$ZodArray",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{const s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:t}),n;n.value=Array(s.length);const i=[];for(let o=0;o<s.length;o++){const a=s[o],l=e.element._zod.run({value:a,issues:[]},r);l instanceof Promise?i.push(l.then(c=>id(c,n,o))):id(l,n,o)}return i.length?Promise.all(i).then(()=>n):n}});function go(t,e,n,r,s){if(t.issues.length){if(s&&!(n in r))return;e.issues.push(...br(n,t.issues))}t.value===void 0?n in r&&(e.value[n]=void 0):e.value[n]=t.value}function Qf(t){var r,s,i,o;const e=Object.keys(t.shape);for(const a of e)if(!((o=(i=(s=(r=t.shape)==null?void 0:r[a])==null?void 0:s._zod)==null?void 0:i.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=BE(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}function eg(t,e,n,r,s,i){const o=[],a=s.keySet,l=s.catchall._zod,c=l.def.type,d=l.optout==="optional";for(const p in e){if(a.has(p))continue;if(c==="never"){o.push(p);continue}const y=l.run({value:e[p],issues:[]},r);y instanceof Promise?t.push(y.then(m=>go(m,n,p,e,d))):go(y,n,p,e,d)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:i}),t.length?Promise.all(t).then(()=>n):n}const AA=S("$ZodObject",(t,e)=>{le.init(t,e);const n=Object.getOwnPropertyDescriptor(e,"shape");if(!(n!=null&&n.get)){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const l={...a};return Object.defineProperty(e,"shape",{value:l}),l}})}const r=Pc(()=>Qf(e));ee(t._zod,"propValues",()=>{const a=e.shape,l={};for(const c in a){const d=a[c]._zod;if(d.values){l[c]??(l[c]=new Set);for(const p of d.values)l[c].add(p)}}return l});const s=fo,i=e.catchall;let o;t._zod.parse=(a,l)=>{o??(o=r.value);const c=a.value;if(!s(c))return a.issues.push({expected:"object",code:"invalid_type",input:c,inst:t}),a;a.value={};const d=[],p=o.shape;for(const y of o.keys){const m=p[y],E=m._zod.optout==="optional",k=m._zod.run({value:c[y],issues:[]},l);k instanceof Promise?d.push(k.then(I=>go(I,a,y,c,E))):go(k,a,y,c,E)}return i?eg(d,c,a,l,r.value,t):d.length?Promise.all(d).then(()=>a):a}}),xA=S("$ZodObjectJIT",(t,e)=>{AA.init(t,e);const n=t._zod.parse,r=Pc(()=>Qf(e)),s=y=>{var j;const m=new q$(["shape","payload","ctx"]),E=r.value,k=F=>{const L=rd(F);return`shape[${L}]._zod.run({ value: input[${L}], issues: [] }, ctx)`};m.write("const input = payload.value;");const I=Object.create(null);let G=0;for(const F of E.keys)I[F]=`key_${G++}`;m.write("const newResult = {};");for(const F of E.keys){const L=I[F],J=rd(F),H=y[F],he=((j=H==null?void 0:H._zod)==null?void 0:j.optout)==="optional";m.write(`const ${L} = ${k(F)};`),he?m.write(`
|
|
7
|
-
if (${L}.issues.length) {
|
|
8
|
-
if (${J} in input) {
|
|
9
|
-
payload.issues = payload.issues.concat(${L}.issues.map(iss => ({
|
|
10
|
-
...iss,
|
|
11
|
-
path: iss.path ? [${J}, ...iss.path] : [${J}]
|
|
12
|
-
})));
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (${L}.value === undefined) {
|
|
17
|
-
if (${J} in input) {
|
|
18
|
-
newResult[${J}] = undefined;
|
|
19
|
-
}
|
|
20
|
-
} else {
|
|
21
|
-
newResult[${J}] = ${L}.value;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
`):m.write(`
|
|
25
|
-
if (${L}.issues.length) {
|
|
26
|
-
payload.issues = payload.issues.concat(${L}.issues.map(iss => ({
|
|
27
|
-
...iss,
|
|
28
|
-
path: iss.path ? [${J}, ...iss.path] : [${J}]
|
|
29
|
-
})));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (${L}.value === undefined) {
|
|
33
|
-
if (${J} in input) {
|
|
34
|
-
newResult[${J}] = undefined;
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
newResult[${J}] = ${L}.value;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
`)}m.write("payload.value = newResult;"),m.write("return payload;");const N=m.compile();return(F,L)=>N(y,F,L)};let i;const o=fo,a=!Mf.jitless,c=a&&jE.value,d=e.catchall;let p;t._zod.parse=(y,m)=>{p??(p=r.value);const E=y.value;return o(E)?a&&c&&(m==null?void 0:m.async)===!1&&m.jitless!==!0?(i||(i=s(e.shape)),y=i(y,m),d?eg([],E,y,m,p,t):y):n(y,m):(y.issues.push({expected:"object",code:"invalid_type",input:E,inst:t}),y)}});function od(t,e,n,r){for(const i of t)if(i.issues.length===0)return e.value=i.value,e;const s=t.filter(i=>!yr(i));return s.length===1?(e.value=s[0].value,s[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(i=>i.issues.map(o=>an(o,r,on())))}),e)}const TA=S("$ZodUnion",(t,e)=>{le.init(t,e),ee(t._zod,"optin",()=>e.options.some(s=>s._zod.optin==="optional")?"optional":void 0),ee(t._zod,"optout",()=>e.options.some(s=>s._zod.optout==="optional")?"optional":void 0),ee(t._zod,"values",()=>{if(e.options.every(s=>s._zod.values))return new Set(e.options.flatMap(s=>Array.from(s._zod.values)))}),ee(t._zod,"pattern",()=>{if(e.options.every(s=>s._zod.pattern)){const s=e.options.map(i=>i._zod.pattern);return new RegExp(`^(${s.map(i=>Dc(i.source)).join("|")})$`)}});const n=e.options.length===1,r=e.options[0]._zod.run;t._zod.parse=(s,i)=>{if(n)return r(s,i);let o=!1;const a=[];for(const l of e.options){const c=l._zod.run({value:s.value,issues:[]},i);if(c instanceof Promise)a.push(c),o=!0;else{if(c.issues.length===0)return c;a.push(c)}}return o?Promise.all(a).then(l=>od(l,s,t,i)):od(a,s,t,i)}}),CA=S("$ZodIntersection",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{const s=n.value,i=e.left._zod.run({value:s,issues:[]},r),o=e.right._zod.run({value:s,issues:[]},r);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([l,c])=>ad(n,l,c)):ad(n,i,o)}});function wl(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(zr(t)&&zr(e)){const n=Object.keys(e),r=Object.keys(t).filter(i=>n.indexOf(i)!==-1),s={...t,...e};for(const i of r){const o=wl(t[i],e[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};s[i]=o.data}return{valid:!0,data:s}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<t.length;r++){const s=t[r],i=e[r],o=wl(s,i);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ad(t,e,n){const r=new Map;let s;for(const a of e.issues)if(a.code==="unrecognized_keys"){s??(s=a);for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else t.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else t.issues.push(a);const i=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&s&&t.issues.push({...s,keys:i}),yr(t))return t;const o=wl(e.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return t.value=o.data,t}const IA=S("$ZodRecord",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{const s=n.value;if(!zr(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:t}),n;const i=[],o=e.keyType._zod.values;if(o){n.value={};const a=new Set;for(const c of o)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){a.add(typeof c=="number"?c.toString():c);const d=e.valueType._zod.run({value:s[c],issues:[]},r);d instanceof Promise?i.push(d.then(p=>{p.issues.length&&n.issues.push(...br(c,p.issues)),n.value[c]=p.value})):(d.issues.length&&n.issues.push(...br(c,d.issues)),n.value[c]=d.value)}let l;for(const c in s)a.has(c)||(l=l??[],l.push(c));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:t,keys:l})}else{n.value={};for(const a of Reflect.ownKeys(s)){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"&&Hf.test(a)&&l.issues.length){const p=e.keyType._zod.run({value:Number(a),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(l=p)}if(l.issues.length){e.mode==="loose"?n.value[a]=s[a]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(p=>an(p,r,on())),input:a,path:[a],inst:t});continue}const d=e.valueType._zod.run({value:s[a],issues:[]},r);d instanceof Promise?i.push(d.then(p=>{p.issues.length&&n.issues.push(...br(a,p.issues)),n.value[l.value]=p.value})):(d.issues.length&&n.issues.push(...br(a,d.issues)),n.value[l.value]=d.value)}}return i.length?Promise.all(i).then(()=>n):n}}),PA=S("$ZodEnum",(t,e)=>{le.init(t,e);const n=Nf(e.entries),r=new Set(n);t._zod.values=r,t._zod.pattern=new RegExp(`^(${n.filter(s=>WE.has(typeof s)).map(s=>typeof s=="string"?Lr(s):s.toString()).join("|")})$`),t._zod.parse=(s,i)=>{const o=s.value;return r.has(o)||s.issues.push({code:"invalid_value",values:n,input:o,inst:t}),s}}),RA=S("$ZodLiteral",(t,e)=>{if(le.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(e.values);t._zod.values=n,t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?Lr(r):r?Lr(r.toString()):String(r)).join("|")})$`),t._zod.parse=(r,s)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:e.values,input:i,inst:t}),r}}),DA=S("$ZodTransform",(t,e)=>{le.init(t,e),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Lf(t.constructor.name);const s=e.transform(n.value,n);if(r.async)return(s instanceof Promise?s:Promise.resolve(s)).then(o=>(n.value=o,n));if(s instanceof Promise)throw new _r;return n.value=s,n}});function ld(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const tg=S("$ZodOptional",(t,e)=>{le.init(t,e),t._zod.optin="optional",t._zod.optout="optional",ee(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),ee(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${Dc(n.source)})?$`):void 0}),t._zod.parse=(n,r)=>{if(e.innerType._zod.optin==="optional"){const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>ld(i,n.value)):ld(s,n.value)}return n.value===void 0?n:e.innerType._zod.run(n,r)}}),OA=S("$ZodExactOptional",(t,e)=>{tg.init(t,e),ee(t._zod,"values",()=>e.innerType._zod.values),ee(t._zod,"pattern",()=>e.innerType._zod.pattern),t._zod.parse=(n,r)=>e.innerType._zod.run(n,r)}),zA=S("$ZodNullable",(t,e)=>{le.init(t,e),ee(t._zod,"optin",()=>e.innerType._zod.optin),ee(t._zod,"optout",()=>e.innerType._zod.optout),ee(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${Dc(n.source)}|null)$`):void 0}),ee(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(n,r)=>n.value===null?n:e.innerType._zod.run(n,r)}),LA=S("$ZodDefault",(t,e)=>{le.init(t,e),t._zod.optin="optional",ee(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);if(n.value===void 0)return n.value=e.defaultValue,n;const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>cd(i,e)):cd(s,e)}});function cd(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const MA=S("$ZodPrefault",(t,e)=>{le.init(t,e),t._zod.optin="optional",ee(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=e.defaultValue),e.innerType._zod.run(n,r))}),NA=S("$ZodNonOptional",(t,e)=>{le.init(t,e),ee(t._zod,"values",()=>{const n=e.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),t._zod.parse=(n,r)=>{const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>ud(i,t)):ud(s,t)}});function ud(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}const UA=S("$ZodCatch",(t,e)=>{le.init(t,e),ee(t._zod,"optin",()=>e.innerType._zod.optin),ee(t._zod,"optout",()=>e.innerType._zod.optout),ee(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>(n.value=i.value,i.issues.length&&(n.value=e.catchValue({...n,error:{issues:i.issues.map(o=>an(o,r,on()))},input:n.value}),n.issues=[]),n)):(n.value=s.value,s.issues.length&&(n.value=e.catchValue({...n,error:{issues:s.issues.map(i=>an(i,r,on()))},input:n.value}),n.issues=[]),n)}}),FA=S("$ZodPipe",(t,e)=>{le.init(t,e),ee(t._zod,"values",()=>e.in._zod.values),ee(t._zod,"optin",()=>e.in._zod.optin),ee(t._zod,"optout",()=>e.out._zod.optout),ee(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=e.out._zod.run(n,r);return i instanceof Promise?i.then(o=>Ni(o,e.in,r)):Ni(i,e.in,r)}const s=e.in._zod.run(n,r);return s instanceof Promise?s.then(i=>Ni(i,e.out,r)):Ni(s,e.out,r)}});function Ni(t,e,n){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},n)}const ZA=S("$ZodReadonly",(t,e)=>{le.init(t,e),ee(t._zod,"propValues",()=>e.innerType._zod.propValues),ee(t._zod,"values",()=>e.innerType._zod.values),ee(t._zod,"optin",()=>{var n,r;return(r=(n=e.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),ee(t._zod,"optout",()=>{var n,r;return(r=(n=e.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(hd):hd(s)}});function hd(t){return t.value=Object.freeze(t.value),t}const jA=S("$ZodCustom",(t,e)=>{We.init(t,e),le.init(t,e),t._zod.parse=(n,r)=>n,t._zod.check=n=>{const r=n.value,s=e.fn(r);if(s instanceof Promise)return s.then(i=>dd(i,n,r,t));dd(s,n,r,t)}});function dd(t,e,n,r){if(!t){const s={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(s.params=r._zod.def.params),e.issues.push(Ts(s))}}var pd;class WA{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...n){const r=n[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const n=this._map.get(e);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(e),this}get(e){const n=e._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const s={...r,...this._map.get(e)};return Object.keys(s).length?s:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function BA(){return new WA}(pd=globalThis).__zod_globalRegistry??(pd.__zod_globalRegistry=BA());const gs=globalThis.__zod_globalRegistry;function GA(t,e){return new t({type:"string",...O(e)})}function VA(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...O(e)})}function fd(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...O(e)})}function HA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...O(e)})}function qA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(e)})}function YA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(e)})}function KA(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(e)})}function JA(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...O(e)})}function XA(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...O(e)})}function QA(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(e)})}function ex(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...O(e)})}function tx(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(e)})}function nx(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...O(e)})}function rx(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...O(e)})}function sx(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(e)})}function ix(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(e)})}function ox(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(e)})}function ax(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(e)})}function lx(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(e)})}function cx(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...O(e)})}function ux(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...O(e)})}function hx(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...O(e)})}function dx(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...O(e)})}function px(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(e)})}function fx(t,e){return new t({type:"string",format:"date",check:"string_format",...O(e)})}function gx(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...O(e)})}function mx(t,e){return new t({type:"string",format:"duration",check:"string_format",...O(e)})}function vx(t,e){return new t({type:"number",checks:[],...O(e)})}function yx(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...O(e)})}function bx(t,e){return new t({type:"boolean",...O(e)})}function wx(t){return new t({type:"unknown"})}function _x(t,e){return new t({type:"never",...O(e)})}function gd(t,e){return new Yf({check:"less_than",...O(e),value:t,inclusive:!1})}function ja(t,e){return new Yf({check:"less_than",...O(e),value:t,inclusive:!0})}function md(t,e){return new Kf({check:"greater_than",...O(e),value:t,inclusive:!1})}function Wa(t,e){return new Kf({check:"greater_than",...O(e),value:t,inclusive:!0})}function vd(t,e){return new L$({check:"multiple_of",...O(e),value:t})}function ng(t,e){return new N$({check:"max_length",...O(e),maximum:t})}function mo(t,e){return new U$({check:"min_length",...O(e),minimum:t})}function rg(t,e){return new F$({check:"length_equals",...O(e),length:t})}function Sx(t,e){return new Z$({check:"string_format",format:"regex",...O(e),pattern:t})}function kx(t){return new j$({check:"string_format",format:"lowercase",...O(t)})}function Ex(t){return new W$({check:"string_format",format:"uppercase",...O(t)})}function $x(t,e){return new B$({check:"string_format",format:"includes",...O(e),includes:t})}function Ax(t,e){return new G$({check:"string_format",format:"starts_with",...O(e),prefix:t})}function xx(t,e){return new V$({check:"string_format",format:"ends_with",...O(e),suffix:t})}function qr(t){return new H$({check:"overwrite",tx:t})}function Tx(t){return qr(e=>e.normalize(t))}function Cx(){return qr(t=>t.trim())}function Ix(){return qr(t=>t.toLowerCase())}function Px(){return qr(t=>t.toUpperCase())}function Rx(){return qr(t=>ZE(t))}function Dx(t,e,n){return new t({type:"array",element:e,...O(n)})}function Ox(t,e,n){return new t({type:"custom",check:"custom",fn:e,...O(n)})}function zx(t){const e=Lx(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Ts(r,n.value,e._zod.def));else{const s=r;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=e),s.continue??(s.continue=!e._zod.def.abort),n.issues.push(Ts(s))}},t(n.value,n)));return e}function Lx(t,e){const n=new We({check:"custom",...O(e)});return n._zod.check=t,n}function sg(t){let e=(t==null?void 0:t.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:(t==null?void 0:t.metadata)??gs,target:e,unrepresentable:(t==null?void 0:t.unrepresentable)??"throw",override:(t==null?void 0:t.override)??(()=>{}),io:(t==null?void 0:t.io)??"output",counter:0,seen:new Map,cycles:(t==null?void 0:t.cycles)??"ref",reused:(t==null?void 0:t.reused)??"inline",external:(t==null?void 0:t.external)??void 0}}function me(t,e,n={path:[],schemaPath:[]}){var d,p;var r;const s=t._zod.def,i=e.seen.get(t);if(i)return i.count++,n.schemaPath.includes(t)&&(i.cycle=n.path),i.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};e.seen.set(t,o);const a=(p=(d=t._zod).toJSONSchema)==null?void 0:p.call(d);if(a)o.schema=a;else{const y={...n,schemaPath:[...n.schemaPath,t],path:n.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,o.schema,y);else{const E=o.schema,k=e.processors[s.type];if(!k)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);k(t,e,E,y)}const m=t._zod.parent;m&&(o.ref||(o.ref=m),me(m,e,y),e.seen.get(m).isParent=!0)}const l=e.metadataRegistry.get(t);return l&&Object.assign(o.schema,l),e.io==="input"&&Re(t)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(t).schema}function ig(t,e){var o,a,l,c;const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const d of t.seen.entries()){const p=(o=t.metadataRegistry.get(d[0]))==null?void 0:o.id;if(p){const y=r.get(p);if(y&&y!==d[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(p,d[0])}}const s=d=>{var k;const p=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const I=(k=t.external.registry.get(d[0]))==null?void 0:k.id,G=t.external.uri??(j=>j);if(I)return{ref:G(I)};const N=d[1].defId??d[1].schema.id??`schema${t.counter++}`;return d[1].defId=N,{defId:N,ref:`${G("__shared")}#/${p}/${N}`}}if(d[1]===n)return{ref:"#"};const m=`#/${p}/`,E=d[1].schema.id??`__schema${t.counter++}`;return{defId:E,ref:m+E}},i=d=>{if(d[1].schema.$ref)return;const p=d[1],{ref:y,defId:m}=s(d);p.def={...p.schema},m&&(p.defId=m);const E=p.schema;for(const k in E)delete E[k];E.$ref=y};if(t.cycles==="throw")for(const d of t.seen.entries()){const p=d[1];if(p.cycle)throw new Error(`Cycle detected: #/${(a=p.cycle)==null?void 0:a.join("/")}/<root>
|
|
41
|
-
|
|
42
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of t.seen.entries()){const p=d[1];if(e===d[0]){i(d);continue}if(t.external){const m=(l=t.external.registry.get(d[0]))==null?void 0:l.id;if(e!==d[0]&&m){i(d);continue}}if((c=t.metadataRegistry.get(d[0]))==null?void 0:c.id){i(d);continue}if(p.cycle){i(d);continue}if(p.count>1&&t.reused==="ref"){i(d);continue}}}function og(t,e){var o,a,l;const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=c=>{const d=t.seen.get(c);if(d.ref===null)return;const p=d.def??d.schema,y={...p},m=d.ref;if(d.ref=null,m){r(m);const k=t.seen.get(m),I=k.schema;if(I.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(I)):Object.assign(p,I),Object.assign(p,y),c._zod.parent===m)for(const N in p)N==="$ref"||N==="allOf"||N in y||delete p[N];if(I.$ref&&k.def)for(const N in p)N==="$ref"||N==="allOf"||N in k.def&&JSON.stringify(p[N])===JSON.stringify(k.def[N])&&delete p[N]}const E=c._zod.parent;if(E&&E!==m){r(E);const k=t.seen.get(E);if(k!=null&&k.schema.$ref&&(p.$ref=k.schema.$ref,k.def))for(const I in p)I==="$ref"||I==="allOf"||I in k.def&&JSON.stringify(p[I])===JSON.stringify(k.def[I])&&delete p[I]}t.override({zodSchema:c,jsonSchema:p,path:d.path??[]})};for(const c of[...t.seen.entries()].reverse())r(c[0]);const s={};if(t.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":t.target,(o=t.external)!=null&&o.uri){const c=(a=t.external.registry.get(e))==null?void 0:a.id;if(!c)throw new Error("Schema is missing an `id` property");s.$id=t.external.uri(c)}Object.assign(s,n.def??n.schema);const i=((l=t.external)==null?void 0:l.defs)??{};for(const c of t.seen.entries()){const d=c[1];d.def&&d.defId&&(i[d.defId]=d.def)}t.external||Object.keys(i).length>0&&(t.target==="draft-2020-12"?s.$defs=i:s.definitions=i);try{const c=JSON.parse(JSON.stringify(s));return Object.defineProperty(c,"~standard",{value:{...e["~standard"],jsonSchema:{input:vo(e,"input",t.processors),output:vo(e,"output",t.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function Re(t,e){const n=e??{seen:new Set};if(n.seen.has(t))return!1;n.seen.add(t);const r=t._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Re(r.element,n);if(r.type==="set")return Re(r.valueType,n);if(r.type==="lazy")return Re(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Re(r.innerType,n);if(r.type==="intersection")return Re(r.left,n)||Re(r.right,n);if(r.type==="record"||r.type==="map")return Re(r.keyType,n)||Re(r.valueType,n);if(r.type==="pipe")return Re(r.in,n)||Re(r.out,n);if(r.type==="object"){for(const s in r.shape)if(Re(r.shape[s],n))return!0;return!1}if(r.type==="union"){for(const s of r.options)if(Re(s,n))return!0;return!1}if(r.type==="tuple"){for(const s of r.items)if(Re(s,n))return!0;return!!(r.rest&&Re(r.rest,n))}return!1}const Mx=(t,e={})=>n=>{const r=sg({...n,processors:e});return me(t,r),ig(r,t),og(r,t)},vo=(t,e,n={})=>r=>{const{libraryOptions:s,target:i}=r??{},o=sg({...s??{},target:i,io:e,processors:n});return me(t,o),ig(o,t),og(o,t)},Nx={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ux=(t,e,n,r)=>{const s=n;s.type="string";const{minimum:i,maximum:o,format:a,patterns:l,contentEncoding:c}=t._zod.bag;if(typeof i=="number"&&(s.minLength=i),typeof o=="number"&&(s.maxLength=o),a&&(s.format=Nx[a]??a,s.format===""&&delete s.format,a==="time"&&delete s.format),c&&(s.contentEncoding=c),l&&l.size>0){const d=[...l];d.length===1?s.pattern=d[0].source:d.length>1&&(s.allOf=[...d.map(p=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},Fx=(t,e,n,r)=>{const s=n,{minimum:i,maximum:o,format:a,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:d}=t._zod.bag;typeof a=="string"&&a.includes("int")?s.type="integer":s.type="number",typeof d=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(s.minimum=d,s.exclusiveMinimum=!0):s.exclusiveMinimum=d),typeof i=="number"&&(s.minimum=i,typeof d=="number"&&e.target!=="draft-04"&&(d>=i?delete s.minimum:delete s.exclusiveMinimum)),typeof c=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(s.maximum=c,s.exclusiveMaximum=!0):s.exclusiveMaximum=c),typeof o=="number"&&(s.maximum=o,typeof c=="number"&&e.target!=="draft-04"&&(c<=o?delete s.maximum:delete s.exclusiveMaximum)),typeof l=="number"&&(s.multipleOf=l)},Zx=(t,e,n,r)=>{n.type="boolean"},jx=(t,e,n,r)=>{n.not={}},Wx=(t,e,n,r)=>{},Bx=(t,e,n,r)=>{const s=t._zod.def,i=Nf(s.entries);i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),n.enum=i},Gx=(t,e,n,r)=>{const s=t._zod.def,i=[];for(const o of s.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");i.push(Number(o))}else i.push(o);if(i.length!==0)if(i.length===1){const o=i[0];n.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?n.enum=[o]:n.const=o}else i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),i.every(o=>typeof o=="boolean")&&(n.type="boolean"),i.every(o=>o===null)&&(n.type="null"),n.enum=i},Vx=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Hx=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},qx=(t,e,n,r)=>{const s=n,i=t._zod.def,{minimum:o,maximum:a}=t._zod.bag;typeof o=="number"&&(s.minItems=o),typeof a=="number"&&(s.maxItems=a),s.type="array",s.items=me(i.element,e,{...r,path:[...r.path,"items"]})},Yx=(t,e,n,r)=>{var c;const s=n,i=t._zod.def;s.type="object",s.properties={};const o=i.shape;for(const d in o)s.properties[d]=me(o[d],e,{...r,path:[...r.path,"properties",d]});const a=new Set(Object.keys(o)),l=new Set([...a].filter(d=>{const p=i.shape[d]._zod;return e.io==="input"?p.optin===void 0:p.optout===void 0}));l.size>0&&(s.required=Array.from(l)),((c=i.catchall)==null?void 0:c._zod.def.type)==="never"?s.additionalProperties=!1:i.catchall?i.catchall&&(s.additionalProperties=me(i.catchall,e,{...r,path:[...r.path,"additionalProperties"]})):e.io==="output"&&(s.additionalProperties=!1)},Kx=(t,e,n,r)=>{const s=t._zod.def,i=s.inclusive===!1,o=s.options.map((a,l)=>me(a,e,{...r,path:[...r.path,i?"oneOf":"anyOf",l]}));i?n.oneOf=o:n.anyOf=o},Jx=(t,e,n,r)=>{const s=t._zod.def,i=me(s.left,e,{...r,path:[...r.path,"allOf",0]}),o=me(s.right,e,{...r,path:[...r.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1,l=[...a(i)?i.allOf:[i],...a(o)?o.allOf:[o]];n.allOf=l},Xx=(t,e,n,r)=>{const s=n,i=t._zod.def;s.type="object";const o=i.keyType,a=o._zod.bag,l=a==null?void 0:a.patterns;if(i.mode==="loose"&&l&&l.size>0){const d=me(i.valueType,e,{...r,path:[...r.path,"patternProperties","*"]});s.patternProperties={};for(const p of l)s.patternProperties[p.source]=d}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(s.propertyNames=me(i.keyType,e,{...r,path:[...r.path,"propertyNames"]})),s.additionalProperties=me(i.valueType,e,{...r,path:[...r.path,"additionalProperties"]});const c=o._zod.values;if(c){const d=[...c].filter(p=>typeof p=="string"||typeof p=="number");d.length>0&&(s.required=d)}},Qx=(t,e,n,r)=>{const s=t._zod.def,i=me(s.innerType,e,r),o=e.seen.get(t);e.target==="openapi-3.0"?(o.ref=s.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},eT=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType},tT=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType,n.default=JSON.parse(JSON.stringify(s.defaultValue))},nT=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType,e.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(s.defaultValue)))},rT=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType;let o;try{o=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},sT=(t,e,n,r)=>{const s=t._zod.def,i=e.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;me(i,e,r);const o=e.seen.get(t);o.ref=i},iT=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType,n.readOnly=!0},ag=(t,e,n,r)=>{const s=t._zod.def;me(s.innerType,e,r);const i=e.seen.get(t);i.ref=s.innerType},oT=S("ZodISODateTime",(t,e)=>{aA.init(t,e),ue.init(t,e)});function aT(t){return px(oT,t)}const lT=S("ZodISODate",(t,e)=>{lA.init(t,e),ue.init(t,e)});function cT(t){return fx(lT,t)}const uT=S("ZodISOTime",(t,e)=>{cA.init(t,e),ue.init(t,e)});function hT(t){return gx(uT,t)}const dT=S("ZodISODuration",(t,e)=>{uA.init(t,e),ue.init(t,e)});function pT(t){return mx(dT,t)}const lg=(t,e)=>{jf.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:n=>e$(t,n)},flatten:{value:n=>QE(t,n)},addIssue:{value:n=>{t.issues.push(n),t.message=JSON.stringify(t.issues,bl,2)}},addIssues:{value:n=>{t.issues.push(...n),t.message=JSON.stringify(t.issues,bl,2)}},isEmpty:{get(){return t.issues.length===0}}})},yd=S("ZodError",lg),tt=S("ZodError",lg,{Parent:Error}),fT=zc(tt),gT=Lc(tt),mT=Zo(tt),vT=jo(tt),yT=r$(tt),bT=s$(tt),wT=i$(tt),_T=o$(tt),ST=a$(tt),kT=l$(tt),ET=c$(tt),$T=u$(tt),ce=S("ZodType",(t,e)=>(le.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:vo(t,"input"),output:vo(t,"output")}}),t.toJSONSchema=Mx(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...n)=>t.clone(pn(e,{checks:[...e.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),t.with=t.check,t.clone=(n,r)=>fn(t,n,r),t.brand=()=>t,t.register=(n,r)=>(n.add(t,r),t),t.parse=(n,r)=>fT(t,n,r,{callee:t.parse}),t.safeParse=(n,r)=>mT(t,n,r),t.parseAsync=async(n,r)=>gT(t,n,r,{callee:t.parseAsync}),t.safeParseAsync=async(n,r)=>vT(t,n,r),t.spa=t.safeParseAsync,t.encode=(n,r)=>yT(t,n,r),t.decode=(n,r)=>bT(t,n,r),t.encodeAsync=async(n,r)=>wT(t,n,r),t.decodeAsync=async(n,r)=>_T(t,n,r),t.safeEncode=(n,r)=>ST(t,n,r),t.safeDecode=(n,r)=>kT(t,n,r),t.safeEncodeAsync=async(n,r)=>ET(t,n,r),t.safeDecodeAsync=async(n,r)=>$T(t,n,r),t.refine=(n,r)=>t.check(mC(n,r)),t.superRefine=n=>t.check(vC(n)),t.overwrite=n=>t.check(qr(n)),t.optional=()=>_d(t),t.exactOptional=()=>rC(t),t.nullable=()=>Sd(t),t.nullish=()=>_d(Sd(t)),t.nonoptional=n=>cC(t,n),t.array=()=>R(t),t.or=n=>Z([t,n]),t.and=n=>Bo(t,n),t.transform=n=>kd(t,tC(n)),t.default=n=>oC(t,n),t.prefault=n=>lC(t,n),t.catch=n=>hC(t,n),t.pipe=n=>kd(t,n),t.readonly=()=>fC(t),t.describe=n=>{const r=t.clone();return gs.add(r,{description:n}),r},Object.defineProperty(t,"description",{get(){var n;return(n=gs.get(t))==null?void 0:n.description},configurable:!0}),t.meta=(...n)=>{if(n.length===0)return gs.get(t);const r=t.clone();return gs.add(r,n[0]),r},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t.apply=n=>n(t),t)),cg=S("_ZodString",(t,e)=>{Mc.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>Ux(t,r,s);const n=t._zod.bag;t.format=n.format??null,t.minLength=n.minimum??null,t.maxLength=n.maximum??null,t.regex=(...r)=>t.check(Sx(...r)),t.includes=(...r)=>t.check($x(...r)),t.startsWith=(...r)=>t.check(Ax(...r)),t.endsWith=(...r)=>t.check(xx(...r)),t.min=(...r)=>t.check(mo(...r)),t.max=(...r)=>t.check(ng(...r)),t.length=(...r)=>t.check(rg(...r)),t.nonempty=(...r)=>t.check(mo(1,...r)),t.lowercase=r=>t.check(kx(r)),t.uppercase=r=>t.check(Ex(r)),t.trim=()=>t.check(Cx()),t.normalize=(...r)=>t.check(Tx(...r)),t.toLowerCase=()=>t.check(Ix()),t.toUpperCase=()=>t.check(Px()),t.slugify=()=>t.check(Rx())}),AT=S("ZodString",(t,e)=>{Mc.init(t,e),cg.init(t,e),t.email=n=>t.check(VA(xT,n)),t.url=n=>t.check(JA(TT,n)),t.jwt=n=>t.check(dx(WT,n)),t.emoji=n=>t.check(XA(CT,n)),t.guid=n=>t.check(fd(bd,n)),t.uuid=n=>t.check(HA(Ui,n)),t.uuidv4=n=>t.check(qA(Ui,n)),t.uuidv6=n=>t.check(YA(Ui,n)),t.uuidv7=n=>t.check(KA(Ui,n)),t.nanoid=n=>t.check(QA(IT,n)),t.guid=n=>t.check(fd(bd,n)),t.cuid=n=>t.check(ex(PT,n)),t.cuid2=n=>t.check(tx(RT,n)),t.ulid=n=>t.check(nx(DT,n)),t.base64=n=>t.check(cx(FT,n)),t.base64url=n=>t.check(ux(ZT,n)),t.xid=n=>t.check(rx(OT,n)),t.ksuid=n=>t.check(sx(zT,n)),t.ipv4=n=>t.check(ix(LT,n)),t.ipv6=n=>t.check(ox(MT,n)),t.cidrv4=n=>t.check(ax(NT,n)),t.cidrv6=n=>t.check(lx(UT,n)),t.e164=n=>t.check(hx(jT,n)),t.datetime=n=>t.check(aT(n)),t.date=n=>t.check(cT(n)),t.time=n=>t.check(hT(n)),t.duration=n=>t.check(pT(n))});function h(t){return GA(AT,t)}const ue=S("ZodStringFormat",(t,e)=>{oe.init(t,e),cg.init(t,e)}),xT=S("ZodEmail",(t,e)=>{X$.init(t,e),ue.init(t,e)}),bd=S("ZodGUID",(t,e)=>{K$.init(t,e),ue.init(t,e)}),Ui=S("ZodUUID",(t,e)=>{J$.init(t,e),ue.init(t,e)}),TT=S("ZodURL",(t,e)=>{Q$.init(t,e),ue.init(t,e)}),CT=S("ZodEmoji",(t,e)=>{eA.init(t,e),ue.init(t,e)}),IT=S("ZodNanoID",(t,e)=>{tA.init(t,e),ue.init(t,e)}),PT=S("ZodCUID",(t,e)=>{nA.init(t,e),ue.init(t,e)}),RT=S("ZodCUID2",(t,e)=>{rA.init(t,e),ue.init(t,e)}),DT=S("ZodULID",(t,e)=>{sA.init(t,e),ue.init(t,e)}),OT=S("ZodXID",(t,e)=>{iA.init(t,e),ue.init(t,e)}),zT=S("ZodKSUID",(t,e)=>{oA.init(t,e),ue.init(t,e)}),LT=S("ZodIPv4",(t,e)=>{hA.init(t,e),ue.init(t,e)}),MT=S("ZodIPv6",(t,e)=>{dA.init(t,e),ue.init(t,e)}),NT=S("ZodCIDRv4",(t,e)=>{pA.init(t,e),ue.init(t,e)}),UT=S("ZodCIDRv6",(t,e)=>{fA.init(t,e),ue.init(t,e)}),FT=S("ZodBase64",(t,e)=>{gA.init(t,e),ue.init(t,e)}),ZT=S("ZodBase64URL",(t,e)=>{vA.init(t,e),ue.init(t,e)}),jT=S("ZodE164",(t,e)=>{yA.init(t,e),ue.init(t,e)}),WT=S("ZodJWT",(t,e)=>{wA.init(t,e),ue.init(t,e)}),ug=S("ZodNumber",(t,e)=>{Xf.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>Fx(t,r,s),t.gt=(r,s)=>t.check(md(r,s)),t.gte=(r,s)=>t.check(Wa(r,s)),t.min=(r,s)=>t.check(Wa(r,s)),t.lt=(r,s)=>t.check(gd(r,s)),t.lte=(r,s)=>t.check(ja(r,s)),t.max=(r,s)=>t.check(ja(r,s)),t.int=r=>t.check(wd(r)),t.safe=r=>t.check(wd(r)),t.positive=r=>t.check(md(0,r)),t.nonnegative=r=>t.check(Wa(0,r)),t.negative=r=>t.check(gd(0,r)),t.nonpositive=r=>t.check(ja(0,r)),t.multipleOf=(r,s)=>t.check(vd(r,s)),t.step=(r,s)=>t.check(vd(r,s)),t.finite=()=>t;const n=t._zod.bag;t.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),t.isFinite=!0,t.format=n.format??null});function U(t){return vx(ug,t)}const BT=S("ZodNumberFormat",(t,e)=>{_A.init(t,e),ug.init(t,e)});function wd(t){return yx(BT,t)}const GT=S("ZodBoolean",(t,e)=>{SA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Zx(t,n,r)});function ke(t){return bx(GT,t)}const VT=S("ZodUnknown",(t,e)=>{kA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Wx()});function w(){return wx(VT)}const HT=S("ZodNever",(t,e)=>{EA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>jx(t,n,r)});function qT(t){return _x(HT,t)}const YT=S("ZodArray",(t,e)=>{$A.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>qx(t,n,r,s),t.element=e.element,t.min=(n,r)=>t.check(mo(n,r)),t.nonempty=n=>t.check(mo(1,n)),t.max=(n,r)=>t.check(ng(n,r)),t.length=(n,r)=>t.check(rg(n,r)),t.unwrap=()=>t.element});function R(t,e){return Dx(YT,t,e)}const hg=S("ZodObject",(t,e)=>{xA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Yx(t,n,r,s),ee(t,"shape",()=>e.shape),t.keyof=()=>yo(Object.keys(t._zod.def.shape)),t.catchall=n=>t.clone({...t._zod.def,catchall:n}),t.passthrough=()=>t.clone({...t._zod.def,catchall:w()}),t.loose=()=>t.clone({...t._zod.def,catchall:w()}),t.strict=()=>t.clone({...t._zod.def,catchall:qT()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=n=>qE(t,n),t.safeExtend=n=>YE(t,n),t.merge=n=>KE(t,n),t.pick=n=>VE(t,n),t.omit=n=>HE(t,n),t.partial=(...n)=>JE(pg,t,n[0]),t.required=(...n)=>XE(fg,t,n[0])});function dg(t,e){const n={type:"object",shape:t??{},...O(e)};return new hg(n)}function f(t,e){return new hg({type:"object",shape:t,catchall:w(),...O(e)})}const KT=S("ZodUnion",(t,e)=>{TA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Kx(t,n,r,s),t.options=e.options});function Z(t,e){return new KT({type:"union",options:t,...O(e)})}const JT=S("ZodIntersection",(t,e)=>{CA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Jx(t,n,r,s)});function Bo(t,e){return new JT({type:"intersection",left:t,right:e})}const XT=S("ZodRecord",(t,e)=>{IA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Xx(t,n,r,s),t.keyType=e.keyType,t.valueType=e.valueType});function _(t,e,n){return new XT({type:"record",keyType:t,valueType:e,...O(n)})}const _l=S("ZodEnum",(t,e)=>{PA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(r,s,i)=>Bx(t,r,s),t.enum=e.entries,t.options=Object.values(e.entries);const n=new Set(Object.keys(e.entries));t.extract=(r,s)=>{const i={};for(const o of r)if(n.has(o))i[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new _l({...e,checks:[],...O(s),entries:i})},t.exclude=(r,s)=>{const i={...e.entries};for(const o of r)if(n.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new _l({...e,checks:[],...O(s),entries:i})}});function yo(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new _l({type:"enum",entries:n,...O(e)})}const QT=S("ZodLiteral",(t,e)=>{RA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Gx(t,n,r),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function A(t,e){return new QT({type:"literal",values:Array.isArray(t)?t:[t],...O(e)})}const eC=S("ZodTransform",(t,e)=>{DA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Hx(t,n),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Lf(t.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Ts(i,n.value,e));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),n.issues.push(Ts(o))}};const s=e.transform(n.value,n);return s instanceof Promise?s.then(i=>(n.value=i,n)):(n.value=s,n)}});function tC(t){return new eC({type:"transform",transform:t})}const pg=S("ZodOptional",(t,e)=>{tg.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ag(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function _d(t){return new pg({type:"optional",innerType:t})}const nC=S("ZodExactOptional",(t,e)=>{OA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>ag(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function rC(t){return new nC({type:"optional",innerType:t})}const sC=S("ZodNullable",(t,e)=>{zA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Qx(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function Sd(t){return new sC({type:"nullable",innerType:t})}const iC=S("ZodDefault",(t,e)=>{LA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>tT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function oC(t,e){return new iC({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():Ff(e)}})}const aC=S("ZodPrefault",(t,e)=>{MA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>nT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function lC(t,e){return new aC({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():Ff(e)}})}const fg=S("ZodNonOptional",(t,e)=>{NA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>eT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function cC(t,e){return new fg({type:"nonoptional",innerType:t,...O(e)})}const uC=S("ZodCatch",(t,e)=>{UA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>rT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function hC(t,e){return new uC({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const dC=S("ZodPipe",(t,e)=>{FA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>sT(t,n,r,s),t.in=e.in,t.out=e.out});function kd(t,e){return new dC({type:"pipe",in:t,out:e})}const pC=S("ZodReadonly",(t,e)=>{ZA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>iT(t,n,r,s),t.unwrap=()=>t._zod.def.innerType});function fC(t){return new pC({type:"readonly",innerType:t})}const gC=S("ZodCustom",(t,e)=>{jA.init(t,e),ce.init(t,e),t._zod.processJSONSchema=(n,r,s)=>Vx(t,n)});function mC(t,e={}){return Ox(gC,t,e)}function vC(t){return zx(t)}const yC=["text/markdown","text/html"],bC=["committed","pending"];dg({id:h().min(1),type:yo(yC),title:h(),status:yo(bC),externalFilePath:h().optional()});dg({name:h().min(1),description:h(),accepts:R(h().min(1)).min(1)});function Nc(t){return typeof t=="object"&&t!==null}function wC(t){return!Nc(t)||t.type!=="ready"?!1:!("id"in t)}function _C(t){return!(!Nc(t)||t.type!=="update-content"||typeof t.id!="string"||typeof t.content!="string")}function SC(t){return!Nc(t)||t.type!=="wheel"||typeof t.deltaX!="number"||typeof t.deltaY!="number"||typeof t.shiftKey!="boolean"?!1:!("id"in t)}function kC(t,e){if(t===e)return 2;if(t==="*/*")return 0;const n=t.indexOf("/");if(n>0&&t.slice(n+1)==="*"){const r=t.slice(0,n),s=e.indexOf("/");if(s>0&&e.slice(0,s)===r)return 1}return null}function EC(t,e){let n=null;for(const r of t.accepts){const s=kC(r,e);s!==null&&(n===null||s>n)&&(n=s)}return n}function $C(t,e){let n=-1,r=null;for(const s of e){const i=EC(s,t);i!==null&&(i>n||i===n&&r!==null&&s.id<r.id)&&(n=i,r=s)}return r}const AC=4401;class Sl extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class kl extends kt{constructor(n){super();v(this,"url");v(this,"name");v(this,"token");v(this,"status","disconnected");v(this,"screens",new Map);v(this,"views",[]);v(this,"client");v(this,"createSocket");v(this,"createClient");v(this,"socket",null);v(this,"connectAttempt",0);this.url=Pt(n.url),this.name=n.name,this.token=n.token??null,this.createSocket=n.createSocket??(r=>new WebSocket(r)),this.createClient=n.createClient??((r,s)=>new IE(r,{token:s??void 0})),this.client=this.createClient(this.url,this.token)}async connect(){var s;this.connectAttempt+=1;const n=this.connectAttempt;(s=this.socket)==null||s.close(),this.client=this.createClient(this.url,this.token),this.status="connecting",this.dispatchEvent(new te("change"));const r=this.createSocket(xC(this.url,this.token));return this.socket=r,await new Promise((i,o)=>{let a=!1;const l=()=>{a||this.connectAttempt!==n||(a=!0,this.status="connected",this.dispatchEvent(new te("change")),i())},c=p=>{a||this.connectAttempt!==n||(a=!0,this.status="disconnected",this.dispatchEvent(new te("change")),o(p))},d=async()=>{try{const[{screens:p},y]=await Promise.all([this.client.screens.list(),this.client.views.list()]);this.screens=new Map(p.map(m=>[m.id,structuredClone(m)])),this.views=y,this.dispatchEvent(new te("change")),l()}catch(p){c(p instanceof Error?p:new Error(String(p)))}};r.addEventListener("open",()=>{d()}),r.addEventListener("message",p=>{const y=CC(p);y&&(this.applyServerEvent(y),this.dispatchEvent(new $f("server-event",{serverURL:this.url,event:y})))}),r.addEventListener("close",p=>{if(this.connectAttempt===n){if(this.socket=null,TC(p)===AC){c(new Sl);return}if(!a){c(new Error("Connection closed before initialization"));return}this.status="disconnected",this.dispatchEvent(new te("change"))}}),r.addEventListener("error",()=>{c(new Error("WebSocket connection failed"))})})}disconnect(){var n;this.connectAttempt+=1,(n=this.socket)==null||n.close(),this.socket=null,this.status="disconnected",this.dispatchEvent(new te("change"))}getViewURL(n){const r=$C(n.type,this.views);if(!r)return null;const s=`${this.url}/views/${encodeURIComponent(r.id)}/`;return this.token===null?s:`${s}?token=${encodeURIComponent(this.token)}`}getContentURL(n){const r=`${this.url}/artifacts/${encodeURIComponent(n)}/content`;return this.token===null?r:`${r}?token=${encodeURIComponent(this.token)}`}async createScreen(n){const{screen:r}=await this.client.screens.create({name:n});return this.screens.set(r.id,structuredClone(r)),r}applyServerEvent(n){switch(n.type){case"screen-created":this.screens.set(n.screen.id,structuredClone(n.screen)),this.dispatchEvent(new eo("screens-changed"));break;case"screen-updated":this.screens.set(n.screen.id,structuredClone(n.screen)),this.dispatchEvent(new eo("screens-changed"));break;case"screen-removed":this.screens.delete(n.screenID),this.dispatchEvent(new eo("screens-changed"));break;case"artifact-created":{const r=this.screens.get(n.screenID);r&&!Sf(r.layout,n.artifact.id)&&(r.layout=[...r.layout,_f(n.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(n.screenID);r&&(r.layout=df(r.layout,n.artifactID));break}}}}function xC(t,e){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname="/events",n.search="",e&&n.searchParams.set("token",e),n.hash="",n.toString()}function TC(t){return typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="number"?t.code:null}function CC(t){const e=typeof t=="string"?t:typeof t=="object"&&t!==null&&"data"in t&&typeof t.data=="string"?t.data:"";if(!e)return null;try{return JSON.parse(e)}catch{return null}}class IC extends kt{constructor(n){super();v(this,"servers",new Map);v(this,"localServerURL");v(this,"localStore");v(this,"createSocket");v(this,"lastActiveServerURL");v(this,"serverListeners",new Map);v(this,"handleLocalStoreChange",()=>{const n=this.localStore.get().activeServerURL;n!==this.lastActiveServerURL&&(this.lastActiveServerURL=n,this.dispatchEvent(new te("change")))});this.localStore=n.localStore,this.localServerURL=n.localServerURL?Pt(n.localServerURL):null,this.createSocket=n.createSocket??(r=>new WebSocket(r)),this.lastActiveServerURL=this.localStore.get().activeServerURL,this.localStore.addEventListener("change",this.handleLocalStoreChange)}get activeServer(){const n=this.localStore.get().activeServerURL;return n===null?null:this.servers.get(n)??null}add(n){const r=Pt(n.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,n);const i=()=>{this.dispatchEvent(new te("change"))},o=l=>{this.dispatchEvent(new $f("server-event",{serverURL:l.serverURL,event:l.event}))},a=()=>{this.dispatchEvent(new eo("screens-changed"))};n.addEventListener("change",i),n.addEventListener("server-event",o),n.addEventListener("screens-changed",a),this.serverListeners.set(r,{onServerChange:i,onServerEvent:o,onScreensChanged:a}),this.dispatchEvent(new te("change"))}remove(n){const r=Pt(n);if(this.localServerURL&&r===this.localServerURL)return;const s=this.servers.get(r);if(!s)return;const i=this.serverListeners.get(r);i&&(s.removeEventListener("change",i.onServerChange),s.removeEventListener("server-event",i.onServerEvent),s.removeEventListener("screens-changed",i.onScreensChanged),this.serverListeners.delete(r)),s.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 te("change"))}setActive(n){const r=this.localStore.get(),s=n?Pt(n.url):null;r.activeServerURL!==s&&this.localStore.set({...r,activeServerURL:s})}connectConfiguredServers(n){const r=this.localStore.get().servers;for(const i of r){const o=new kl({url:i.url,name:i.name,createSocket:this.createSocket});this.add(o),o.connect().catch(()=>{})}const s=n?this.servers.get(Pt(n))??null:null;this.setActive(s??this.servers.values().next().value??null)}addServer(n,r){const s=Pt(n);this.remove(s);const i=this.localStore.get();this.localStore.set({...i,servers:[...i.servers.filter(a=>Pt(a.url)!==s),{url:s,name:r}]});const o=new kl({url:s,name:r,createSocket:this.createSocket});this.add(o),this.setActive(o),o.connect().catch(()=>{})}removeServer(n){this.remove(n)}}const ie={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"},Tt={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"},PC=1,RC=f({_meta:_(h(),w()).nullish(),terminal:ke().optional().default(!1)}),DC=f({_meta:_(h(),w()).nullish(),label:h().nullish(),name:h(),optional:ke().optional().default(!1),secret:ke().optional().default(!0)}),OC=f({_meta:_(h(),w()).nullish(),description:h().nullish(),id:h(),name:h()}),zC=f({_meta:_(h(),w()).nullish(),description:h().nullish(),id:h(),link:h().nullish(),name:h(),vars:R(DC)}),LC=f({_meta:_(h(),w()).nullish(),args:R(h()).optional(),description:h().nullish(),env:_(h(),h()).optional(),id:h(),name:h()}),MC=Z([zC.and(f({type:A("env_var")})),LC.and(f({type:A("terminal")})),OC]),NC=f({_meta:_(h(),w()).nullish(),methodId:h()}),UC=f({_meta:_(h(),w()).nullish()}),FC=f({_meta:_(h(),w()).nullish(),blob:h(),mimeType:h().nullish(),uri:h()}),ZC=f({default:ke().nullish(),description:h().nullish(),title:h().nullish()}),jC=f({_meta:_(h(),w()).nullish()}),WC=f({_meta:_(h(),w()).nullish()}),BC=f({amount:U(),currency:h()}),GC=f({_meta:_(h(),w()).nullish(),terminalId:h()}),VC=f({_meta:_(h(),w()).nullish(),newText:h(),oldText:h().nullish(),path:h()}),HC=Z([h(),U(),U(),ke(),R(h())]),qC=f({content:_(h(),HC).nullish()}),YC=Z([qC.and(f({action:A("accept")})),f({action:A("decline")}),f({action:A("cancel")})]),KC=f({_meta:_(h(),w()).nullish()}),gg=h(),JC=f({_meta:_(h(),w()).nullish(),elicitationId:gg}),XC=f({_meta:_(h(),w()).nullish(),action:YC}),QC=A("object"),eI=A("string"),tI=f({_meta:_(h(),w()).nullish()}),nI=f({_meta:_(h(),w()).nullish(),form:KC.nullish(),url:tI.nullish()}),rI=f({elicitationId:gg,url:h().url()}),mg=f({const:h(),title:h()}),vg=f({_meta:_(h(),w()).nullish(),name:h(),value:h()}),sI=Z([A(-32700),A(-32600),A(-32601),A(-32602),A(-32603),A(-32800),A(-32e3),A(-32002),A(-32042),U().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),yg=f({code:sI,data:w().optional(),message:h()}),bg=w(),wg=w(),_g=w(),iI=f({_meta:_(h(),w()).nullish(),readTextFile:ke().optional().default(!1),writeTextFile:ke().optional().default(!1)}),Sg=f({_meta:_(h(),w()).nullish(),name:h(),value:h()}),kg=f({_meta:_(h(),w()).nullish(),name:h(),title:h().nullish(),version:h()}),oI=f({default:U().nullish(),description:h().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:h().nullish()}),aI=f({_meta:_(h(),w()).nullish()}),lI=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cursor:h().nullish(),cwd:h().nullish()}),cI=f({_meta:_(h(),w()).nullish()}),uI=f({_meta:_(h(),w()).nullish(),logout:cI.nullish()}),hI=f({_meta:_(h(),w()).nullish()}),dI=f({_meta:_(h(),w()).nullish()}),pI=f({_meta:_(h(),w()).nullish(),http:ke().optional().default(!1),sse:ke().optional().default(!1)}),fI=f({_meta:_(h(),w()).nullish(),headers:R(Sg),name:h(),url:h()}),gI=f({_meta:_(h(),w()).nullish(),headers:R(Sg),name:h(),url:h()}),mI=f({_meta:_(h(),w()).nullish(),args:R(h()),command:h(),env:R(vg),name:h()}),Go=Z([fI.and(f({type:A("http")})),gI.and(f({type:A("sse")})),mI]),Uc=h(),vI=f({_meta:_(h(),w()).nullish(),description:h().nullish(),modelId:Uc,name:h()}),yI=Z([A("error"),A("warning"),A("information"),A("hint")]),bI=f({_meta:_(h(),w()).nullish()}),wI=f({_meta:_(h(),w()).nullish()}),_I=f({_meta:_(h(),w()).nullish()}),SI=f({_meta:_(h(),w()).nullish()}),kI=f({_meta:_(h(),w()).nullish()}),EI=f({_meta:_(h(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),$I=f({diff:h(),uri:h()}),AI=f({endLine:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:h()}),xI=f({_meta:_(h(),w()).nullish()}),TI=f({_meta:_(h(),w()).nullish()}),CI=f({languageId:h(),text:h(),uri:h()}),II=f({_meta:_(h(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),PI=Z([A("rejected"),A("ignored"),A("replaced"),A("cancelled")]),RI=f({excerpts:R(AI),uri:h()}),DI=f({_meta:_(h(),w()).nullish()}),OI=f({_meta:_(h(),w()).nullish()}),zI=f({name:h(),owner:h(),remoteUrl:h()}),LI=f({_meta:_(h(),w()).nullish()}),MI=f({_meta:_(h(),w()).nullish(),jump:xI.nullish(),rename:OI.nullish(),searchAndReplace:LI.nullish()}),NI=f({id:h(),isRegex:ke().nullish(),replace:h(),search:h(),uri:h()}),UI=Z([A("automatic"),A("diagnostic"),A("manual")]),FI=f({_meta:_(h(),w()).nullish(),maxCount:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),ZI=f({_meta:_(h(),w()).nullish(),diagnostics:bI.nullish(),editHistory:EI.nullish(),openFiles:TI.nullish(),recentFiles:II.nullish(),relatedSnippets:DI.nullish(),userActions:FI.nullish()}),jI=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),mcpServers:R(Go)}),WI=f({default:U().nullish(),description:h().nullish(),maximum:U().nullish(),minimum:U().nullish(),title:h().nullish()}),Eg=h(),BI=Z([A("allow_once"),A("allow_always"),A("reject_once"),A("reject_always")]),GI=f({_meta:_(h(),w()).nullish(),kind:BI,name:h(),optionId:Eg}),VI=Z([A("high"),A("medium"),A("low")]),HI=Z([A("pending"),A("in_progress"),A("completed")]),qI=f({_meta:_(h(),w()).nullish(),content:h(),priority:VI,status:HI}),YI=f({_meta:_(h(),w()).nullish(),entries:R(qI)}),ln=f({character:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),KI=f({id:h(),position:ln,uri:h()}),JI=f({id:h(),newName:h(),position:ln,uri:h()}),XI=f({action:h(),position:ln,timestampMs:U(),uri:h()}),$g=Z([A("utf-16"),A("utf-32"),A("utf-8")]),QI=f({_meta:_(h(),w()).nullish(),auth:RC.optional().default({terminal:!1}),elicitation:nI.nullish(),fs:iI.optional().default({readTextFile:!1,writeTextFile:!1}),nes:MI.nullish(),positionEncodings:R($g).optional(),terminal:ke().optional().default(!1)}),e0=f({_meta:_(h(),w()).nullish(),audio:ke().optional().default(!1),embeddedContext:ke().optional().default(!1),image:ke().optional().default(!1)}),Ag=U().int().gte(0).lte(65535),t0=f({_meta:_(h(),w()).nullish(),clientCapabilities:QI.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:kg.nullish(),protocolVersion:Ag}),Yr=f({end:ln,start:ln}),n0=f({message:h(),range:Yr,severity:yI,uri:h()}),r0=f({languageId:h(),lastFocusedMs:U().nullish(),uri:h(),visibleRange:Yr.nullish()}),s0=f({_meta:_(h(),w()).nullish(),diagnostics:R(n0).nullish(),editHistory:R($I).nullish(),openFiles:R(r0).nullish(),recentFiles:R(CI).nullish(),relatedSnippets:R(RI).nullish(),userActions:R(XI).nullish()}),i0=f({newText:h(),range:Yr}),o0=f({cursorPosition:ln.nullish(),edits:R(i0),id:h(),uri:h()}),a0=Z([o0.and(f({kind:A("edit")})),KI.and(f({kind:A("jump")})),JI.and(f({kind:A("rename")})),NI.and(f({kind:A("searchAndReplace")}))]),l0=f({_meta:_(h(),w()).nullish(),content:h()}),c0=f({_meta:_(h(),w()).nullish()}),Bn=Z([U(),h()]).nullable();f({_meta:_(h(),w()).nullish(),requestId:Bn});const u0=yo(["assistant","user"]),vi=f({_meta:_(h(),w()).nullish(),audience:R(u0).nullish(),lastModified:h().nullish(),priority:U().nullish()}),h0=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),data:h(),mimeType:h()}),d0=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),data:h(),mimeType:h(),uri:h().nullish()}),p0=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),description:h().nullish(),mimeType:h().nullish(),name:h(),size:U().nullish(),title:h().nullish(),uri:h()}),f0=f({_meta:_(h(),w()).nullish(),optionId:Eg}),g0=Z([f({outcome:A("cancelled")}),f0.and(f({outcome:A("selected")}))]),m0=f({_meta:_(h(),w()).nullish(),outcome:g0}),v0=f({_meta:_(h(),w()).nullish()}),y0=f({_meta:_(h(),w()).nullish()}),b0=f({currentValue:ke()}),w0=h(),xg=h(),_0=Z([A("mode"),A("model"),A("thought_level"),h()]),Fc=h(),Tg=f({_meta:_(h(),w()).nullish(),description:h().nullish(),name:h(),value:Fc}),S0=f({_meta:_(h(),w()).nullish(),group:w0,name:h(),options:R(Tg)}),k0=Z([R(Tg),R(S0)]),E0=f({currentValue:Fc,options:k0}),Kr=Bo(Z([E0.and(f({type:A("select")})),b0.and(f({type:A("boolean")}))]),f({_meta:_(h(),w()).nullish(),category:_0.nullish(),description:h().nullish(),id:xg,name:h()})),$0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr)}),A0=f({_meta:_(h(),w()).nullish()}),K=h(),x0=f({_meta:_(h(),w()).nullish(),id:h(),sessionId:K}),T0=f({_meta:_(h(),w()).nullish(),sessionId:K}),C0=f({_meta:_(h(),w()).nullish(),sessionId:K}),I0=f({_meta:_(h(),w()).nullish(),sessionId:K}),Cg=f({_meta:_(h(),w()).nullish(),args:R(h()).optional(),command:h(),cwd:h().nullish(),env:R(vg).optional(),outputByteLimit:U().nullish(),sessionId:K}),P0=f({_meta:_(h(),w()).nullish(),sessionId:K,uri:h()}),R0=f({_meta:_(h(),w()).nullish(),position:ln,sessionId:K,uri:h(),version:U(),visibleRange:Yr}),D0=f({_meta:_(h(),w()).nullish(),languageId:h(),sessionId:K,text:h(),uri:h(),version:U()}),O0=f({_meta:_(h(),w()).nullish(),sessionId:K,uri:h()}),z0=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),mcpServers:R(Go).optional(),sessionId:K}),Ig=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),L0=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),mcpServers:R(Go),sessionId:K}),Pg=f({_meta:_(h(),w()).nullish(),limit:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h(),sessionId:K}),M0=f({_meta:_(h(),w()).nullish(),id:h(),reason:PI.nullish(),sessionId:K}),Rg=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),N0=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),mcpServers:R(Go).optional(),sessionId:K}),U0=f({_meta:_(h(),w()).nullish(),additionalDirectories:R(h()).optional(),cwd:h(),sessionId:K,title:h().nullish(),updatedAt:h().nullish()}),F0=f({_meta:_(h(),w()).nullish(),nextCursor:h().nullish(),sessions:R(U0)}),Z0=f({_meta:_(h(),w()).nullish(),title:h().nullish(),updatedAt:h().nullish()}),j0=f({_meta:_(h(),w()).nullish()}),Vo=h(),W0=f({_meta:_(h(),w()).nullish(),currentModeId:Vo}),B0=f({_meta:_(h(),w()).nullish(),description:h().nullish(),id:Vo,name:h()}),Ho=f({_meta:_(h(),w()).nullish(),availableModes:R(B0),currentModeId:Vo}),qo=f({_meta:_(h(),w()).nullish(),availableModels:R(vI),currentModelId:Uc}),G0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr).nullish(),models:qo.nullish(),modes:Ho.nullish(),sessionId:K}),V0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr).nullish(),models:qo.nullish(),modes:Ho.nullish()}),H0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr).nullish(),models:qo.nullish(),modes:Ho.nullish(),sessionId:K}),q0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr).nullish(),models:qo.nullish(),modes:Ho.nullish()}),Y0=f({_meta:_(h(),w()).nullish()}),K0=f({_meta:_(h(),w()).nullish(),additionalDirectories:v0.nullish(),close:y0.nullish(),fork:A0.nullish(),list:j0.nullish(),resume:Y0.nullish()}),J0=Bo(Z([f({type:A("boolean"),value:ke()}),f({value:Fc})]),f({_meta:_(h(),w()).nullish(),configId:xg,sessionId:K})),X0=f({_meta:_(h(),w()).nullish(),configOptions:R(Kr)}),Q0=f({_meta:_(h(),w()).nullish(),modeId:Vo,sessionId:K}),eP=f({_meta:_(h(),w()).nullish()}),tP=f({_meta:_(h(),w()).nullish(),modelId:Uc,sessionId:K}),nP=f({_meta:_(h(),w()).nullish()}),rP=f({_meta:_(h(),w()).nullish(),sessionId:K}),sP=Z([A("end_turn"),A("max_tokens"),A("max_turn_requests"),A("refusal"),A("cancelled")]),iP=Z([A("email"),A("uri"),A("date"),A("date-time")]),oP=f({default:h().nullish(),description:h().nullish(),enum:R(h()).nullish(),format:iP.nullish(),maxLength:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:R(mg).nullish(),pattern:h().nullish(),title:h().nullish()}),aP=f({_meta:_(h(),w()).nullish(),context:s0.nullish(),position:ln,selection:Yr.nullish(),sessionId:K,triggerKind:UI,uri:h(),version:U()}),lP=f({_meta:_(h(),w()).nullish(),suggestions:R(a0)}),cP=f({_meta:_(h(),w()).nullish(),terminalId:h()}),uP=f({_meta:_(h(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),Dg=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),hP=f({_meta:_(h(),w()).nullish(),exitStatus:uP.nullish(),output:h(),truncated:ke()}),dP=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),text:h()}),pP=f({range:Yr.nullish(),text:h()}),fP=f({_meta:_(h(),w()).nullish(),contentChanges:R(pP),sessionId:K,uri:h(),version:U()});f({method:h(),params:Z([T0,D0,fP,P0,O0,R0,x0,M0,bg]).nullish()});const gP=Z([A("full"),A("incremental")]),mP=f({_meta:_(h(),w()).nullish(),syncKind:gP}),vP=f({_meta:_(h(),w()).nullish(),didChange:mP.nullish(),didClose:wI.nullish(),didFocus:_I.nullish(),didOpen:SI.nullish(),didSave:kI.nullish()}),yP=f({_meta:_(h(),w()).nullish(),document:vP.nullish()}),bP=f({_meta:_(h(),w()).nullish(),context:ZI.nullish(),events:yP.nullish()}),wP=f({_meta:_(h(),w()).nullish(),auth:uI.optional().default({}),loadSession:ke().optional().default(!1),mcpCapabilities:pI.optional().default({http:!1,sse:!1}),nes:bP.nullish(),positionEncoding:$g.nullish(),promptCapabilities:e0.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:K0.optional().default({})}),_P=f({_meta:_(h(),w()).nullish(),agentCapabilities:wP.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:kg.nullish(),authMethods:R(MC).optional().default([]),protocolVersion:Ag}),SP=f({_meta:_(h(),w()).nullish(),mimeType:h().nullish(),text:h(),uri:h()}),kP=Z([SP,FC]),EP=f({_meta:_(h(),w()).nullish(),annotations:vi.nullish(),resource:kP}),Zc=Z([dP.and(f({type:A("text")})),d0.and(f({type:A("image")})),h0.and(f({type:A("audio")})),p0.and(f({type:A("resource_link")})),EP.and(f({type:A("resource")}))]),$P=f({_meta:_(h(),w()).nullish(),content:Zc}),Ba=f({_meta:_(h(),w()).nullish(),content:Zc,messageId:h().nullish()}),AP=f({_meta:_(h(),w()).nullish(),messageId:h().nullish(),prompt:R(Zc),sessionId:K}),xP=f({anyOf:R(mg)}),Og=Z([$P.and(f({type:A("content")})),VC.and(f({type:A("diff")})),cP.and(f({type:A("terminal")}))]),zg=h(),Lg=f({_meta:_(h(),w()).nullish(),line:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:h()}),Mg=Z([A("pending"),A("in_progress"),A("completed"),A("failed")]),Ng=Z([A("read"),A("edit"),A("delete"),A("move"),A("search"),A("execute"),A("think"),A("fetch"),A("switch_mode"),A("other")]),TP=f({_meta:_(h(),w()).nullish(),content:R(Og).optional(),kind:Ng.optional(),locations:R(Lg).optional(),rawInput:w().optional(),rawOutput:w().optional(),status:Mg.optional(),title:h(),toolCallId:zg}),Ug=f({_meta:_(h(),w()).nullish(),content:R(Og).nullish(),kind:Ng.nullish(),locations:R(Lg).nullish(),rawInput:w().optional(),rawOutput:w().optional(),status:Mg.nullish(),title:h().nullish(),toolCallId:zg}),Fg=f({_meta:_(h(),w()).nullish(),options:R(GI),sessionId:K,toolCall:Ug}),CP=f({_meta:_(h(),w()).nullish(),hint:h()}),IP=CP,PP=f({_meta:_(h(),w()).nullish(),description:h(),input:IP.nullish(),name:h()}),RP=f({_meta:_(h(),w()).nullish(),availableCommands:R(PP)}),DP=f({enum:R(h()),type:eI}),OP=Z([DP,xP]),zP=f({default:R(h()).nullish(),description:h().nullish(),items:OP,maxItems:U().nullish(),minItems:U().nullish(),title:h().nullish()}),LP=Z([oP.and(f({type:A("string")})),WI.and(f({type:A("number")})),oI.and(f({type:A("integer")})),ZC.and(f({type:A("boolean")})),zP.and(f({type:A("array")}))]),MP=f({description:h().nullish(),properties:_(h(),LP).optional().default({}),required:R(h()).nullish(),title:h().nullish(),type:QC.optional().default("object")}),NP=f({requestedSchema:MP}),UP=Bo(Z([NP.and(f({mode:A("form")})),rI.and(f({mode:A("url")}))]),f({_meta:_(h(),w()).nullish(),message:h(),sessionId:K})),FP=f({cachedReadTokens:U().nullish(),cachedWriteTokens:U().nullish(),inputTokens:U(),outputTokens:U(),thoughtTokens:U().nullish(),totalTokens:U()}),ZP=f({_meta:_(h(),w()).nullish(),stopReason:sP,usage:FP.nullish(),userMessageId:h().nullish()});Z([f({id:Bn,result:Z([_P,UC,dI,H0,V0,F0,G0,q0,WC,eP,X0,ZP,nP,rP,lP,jC,_g])}),f({error:yg,id:Bn})]);const jP=f({_meta:_(h(),w()).nullish(),cost:BC.nullish(),size:U(),used:U()}),WP=Z([Ba.and(f({sessionUpdate:A("user_message_chunk")})),Ba.and(f({sessionUpdate:A("agent_message_chunk")})),Ba.and(f({sessionUpdate:A("agent_thought_chunk")})),TP.and(f({sessionUpdate:A("tool_call")})),Ug.and(f({sessionUpdate:A("tool_call_update")})),YI.and(f({sessionUpdate:A("plan")})),RP.and(f({sessionUpdate:A("available_commands_update")})),W0.and(f({sessionUpdate:A("current_mode_update")})),$0.and(f({sessionUpdate:A("config_option_update")})),Z0.and(f({sessionUpdate:A("session_info_update")})),jP.and(f({sessionUpdate:A("usage_update")}))]),Zg=f({_meta:_(h(),w()).nullish(),sessionId:K,update:WP});f({method:h(),params:Z([Zg,JC,bg]).nullish()});const jg=f({_meta:_(h(),w()).nullish(),sessionId:K,terminalId:h()}),BP=f({_meta:_(h(),w()).nullish(),exitCode:U().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:h().nullish()}),GP=f({name:h(),uri:h()}),VP=f({_meta:_(h(),w()).nullish(),repository:zI.nullish(),workspaceFolders:R(GP).nullish(),workspaceUri:h().nullish()});f({id:Bn,method:h(),params:Z([t0,NC,hI,jI,L0,lI,z0,N0,I0,Q0,J0,AP,tP,VP,aP,C0,wg]).nullish()});const Wg=f({_meta:_(h(),w()).nullish(),content:h(),path:h(),sessionId:K});f({id:Bn,method:h(),params:Z([Wg,Pg,Fg,Cg,Dg,Rg,jg,Ig,UP,wg]).nullish()});const HP=f({_meta:_(h(),w()).nullish()});Z([f({id:Bn,result:Z([HP,l0,m0,GC,hP,c0,BP,aI,XC,_g])}),f({error:yg,id:Bn})]);var Y;class qP{constructor(e,n){$(this,Y);const r=e(this),s=async(o,a)=>{var l,c,d,p,y,m,E;switch(o){case Tt.fs_write_text_file:{const k=Wg.parse(a);return(l=r.writeTextFile)==null?void 0:l.call(r,k)}case Tt.fs_read_text_file:{const k=Pg.parse(a);return(c=r.readTextFile)==null?void 0:c.call(r,k)}case Tt.session_request_permission:{const k=Fg.parse(a);return r.requestPermission(k)}case Tt.terminal_create:{const k=Cg.parse(a);return(d=r.createTerminal)==null?void 0:d.call(r,k)}case Tt.terminal_output:{const k=Dg.parse(a);return(p=r.terminalOutput)==null?void 0:p.call(r,k)}case Tt.terminal_release:{const k=Rg.parse(a);return await((y=r.releaseTerminal)==null?void 0:y.call(r,k))??{}}case Tt.terminal_wait_for_exit:{const k=jg.parse(a);return(m=r.waitForTerminalExit)==null?void 0:m.call(r,k)}case Tt.terminal_kill:{const k=Ig.parse(a);return await((E=r.killTerminal)==null?void 0:E.call(r,k))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw ye.methodNotFound(o)}},i=async(o,a)=>{switch(o){case Tt.session_update:{const l=Zg.parse(a);return r.sessionUpdate(l)}default:if(r.extNotification)return r.extNotification(o,a);throw ye.methodNotFound(o)}};x(this,Y,new YP(s,i,n))}async initialize(e){return await u(this,Y).sendRequest(ie.initialize,e)}async newSession(e){return await u(this,Y).sendRequest(ie.session_new,e)}async loadSession(e){return await u(this,Y).sendRequest(ie.session_load,e)??{}}async unstable_forkSession(e){return await u(this,Y).sendRequest(ie.session_fork,e)}async listSessions(e){return await u(this,Y).sendRequest(ie.session_list,e)}async unstable_resumeSession(e){return await u(this,Y).sendRequest(ie.session_resume,e)}async unstable_closeSession(e){return await u(this,Y).sendRequest(ie.session_close,e)}async setSessionMode(e){return await u(this,Y).sendRequest(ie.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await u(this,Y).sendRequest(ie.session_set_model,e)??{}}async setSessionConfigOption(e){return await u(this,Y).sendRequest(ie.session_set_config_option,e)}async authenticate(e){return await u(this,Y).sendRequest(ie.authenticate,e)??{}}async unstable_logout(e){return await u(this,Y).sendRequest(ie.logout,e)??{}}async prompt(e){return await u(this,Y).sendRequest(ie.session_prompt,e)}async cancel(e){return await u(this,Y).sendNotification(ie.session_cancel,e)}async unstable_startNes(e){return await u(this,Y).sendRequest(ie.nes_start,e)}async unstable_suggestNes(e){return await u(this,Y).sendRequest(ie.nes_suggest,e)}async unstable_closeNes(e){return await u(this,Y).sendRequest(ie.nes_close,e)??{}}async unstable_didOpenDocument(e){return await u(this,Y).sendNotification(ie.document_did_open,e)}async unstable_didChangeDocument(e){return await u(this,Y).sendNotification(ie.document_did_change,e)}async unstable_didCloseDocument(e){return await u(this,Y).sendNotification(ie.document_did_close,e)}async unstable_didSaveDocument(e){return await u(this,Y).sendNotification(ie.document_did_save,e)}async unstable_didFocusDocument(e){return await u(this,Y).sendNotification(ie.document_did_focus,e)}async unstable_acceptNes(e){return await u(this,Y).sendNotification(ie.nes_accept,e)}async unstable_rejectNes(e){return await u(this,Y).sendNotification(ie.nes_reject,e)}async extMethod(e,n){return await u(this,Y).sendRequest(e,n)}async extNotification(e,n){return await u(this,Y).sendNotification(e,n)}get signal(){return u(this,Y).signal}get closed(){return u(this,Y).closed}}Y=new WeakMap;var Yt,Ao,Us,Fs,Sr,kr,yt,Zs,ae,Bg,El,Gg,Vg,Hg,qg,$l,ms;class YP{constructor(e,n,r){$(this,ae);$(this,Yt,new Map);$(this,Ao,0);$(this,Us);$(this,Fs);$(this,Sr);$(this,kr,Promise.resolve());$(this,yt,new AbortController);$(this,Zs);x(this,Us,e),x(this,Fs,n),x(this,Sr,r),x(this,Zs,new Promise(s=>{u(this,yt).signal.addEventListener("abort",()=>s())})),b(this,ae,Bg).call(this)}get signal(){return u(this,yt).signal}get closed(){return u(this,Zs)}async sendRequest(e,n){b(this,ae,$l).call(this);const r=Tu(this,Ao)._++,s=new Promise((i,o)=>{u(this,Yt).set(r,{resolve:i,reject:o})});return await b(this,ae,ms).call(this,{jsonrpc:"2.0",id:r,method:e,params:n}),s}async sendNotification(e,n){b(this,ae,$l).call(this),await b(this,ae,ms).call(this,{jsonrpc:"2.0",method:e,params:n})}}Yt=new WeakMap,Ao=new WeakMap,Us=new WeakMap,Fs=new WeakMap,Sr=new WeakMap,kr=new WeakMap,yt=new WeakMap,Zs=new WeakMap,ae=new WeakSet,Bg=async function(){let e;try{const n=u(this,Sr).readable.getReader();try{for(;!u(this,yt).signal.aborted;){const{value:r,done:s}=await n.read();if(s)break;if(r)try{b(this,ae,Gg).call(this,r)}catch(i){console.error("Unexpected error during message processing:",r,i),"id"in r&&r.id!==void 0&&b(this,ae,ms).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{n.releaseLock()}}catch(n){e=n}finally{b(this,ae,El).call(this,e)}},El=function(e){if(u(this,yt).signal.aborted)return;const n=e??new Error("ACP connection closed");for(const r of u(this,Yt).values())r.reject(n);u(this,Yt).clear(),u(this,yt).abort(n)},Gg=async function(e){if("method"in e&&"id"in e){const n=await b(this,ae,Vg).call(this,e.method,e.params);"error"in n&&console.error("Error handling request",e,n.error),await b(this,ae,ms).call(this,{jsonrpc:"2.0",id:e.id,...n})}else if("method"in e){const n=await b(this,ae,Hg).call(this,e.method,e.params);"error"in n&&console.error("Error handling notification",e,n.error)}else"id"in e?b(this,ae,qg).call(this,e):console.error("Invalid message",{message:e})},Vg=async function(e,n){try{return{result:await u(this,Us).call(this,e,n)??null}}catch(r){if(r instanceof ye)return r.toResult();if(r instanceof yd)return ye.invalidParams(r.format()).toResult();let s;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(s=r.message);try{return ye.internalError(s?JSON.parse(s):{}).toResult()}catch{return ye.internalError({details:s}).toResult()}}},Hg=async function(e,n){try{return await u(this,Fs).call(this,e,n),{result:null}}catch(r){if(r instanceof ye)return r.toResult();if(r instanceof yd)return ye.invalidParams(r.format()).toResult();let s;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(s=r.message);try{return ye.internalError(s?JSON.parse(s):{}).toResult()}catch{return ye.internalError({details:s}).toResult()}}},qg=function(e){const n=u(this,Yt).get(e.id);if(n){if("result"in e)n.resolve(e.result);else if("error"in e){const{code:r,message:s,data:i}=e.error;n.reject(new ye(r,s,i))}u(this,Yt).delete(e.id)}else console.error("Got response to unknown request",e.id)},$l=function(){if(u(this,yt).signal.aborted)throw u(this,yt).signal.reason??new Error("ACP connection closed")},ms=async function(e){return x(this,kr,u(this,kr).then(async()=>{const n=u(this,Sr).writable.getWriter();try{await n.write(e)}finally{n.releaseLock()}}).catch(n=>{b(this,ae,El).call(this,n)})),u(this,kr)};class ye extends Error{constructor(n,r,s){super(r);v(this,"code");v(this,"data");this.code=n,this.name="RequestError",this.data=s}static parseError(n,r){return new ye(-32700,`Parse error${r?`: ${r}`:""}`,n)}static invalidRequest(n,r){return new ye(-32600,`Invalid request${r?`: ${r}`:""}`,n)}static methodNotFound(n){return new ye(-32601,`"Method not found": ${n}`,{method:n})}static invalidParams(n,r){return new ye(-32602,`Invalid params${r?`: ${r}`:""}`,n)}static internalError(n,r){return new ye(-32603,`Internal error${r?`: ${r}`:""}`,n)}static authRequired(n,r){return new ye(-32e3,`Authentication required${r?`: ${r}`:""}`,n)}static resourceNotFound(n){return new ye(-32002,`Resource not found${n?`: ${n}`:""}`,n&&{uri:n})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}const KP=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,JP=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,XP=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,QP=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,eR="single_session",tR={name:"television-acp-client",version:"0.0.0"},Yg="agent:main:television",nR=Hr(kt);var ne,Rt,Er,Dt,On,zn,Kt,$r,bt,rt,Jt,Ln,Ot,Xt,js,zt,st,xo,Lt,C,Kg,Jg,Al,Xg,Qg,em,tm,nm,rm,sm,wn,hr,dr,Be,im,pr,xl,Tl,no,om,Ws,Bs,Cl,fr,am,lm;class rR extends nR{constructor(n){super();$(this,C);$(this,ne,sR());$(this,Rt,null);$(this,Er,null);$(this,Dt,null);$(this,On,null);$(this,zn,null);$(this,Kt,null);$(this,$r,1);$(this,bt,null);$(this,rt,null);$(this,Jt,!1);$(this,Ln,!1);$(this,Ot,null);$(this,Xt,new Set);$(this,js);$(this,zt);$(this,st);$(this,xo,n=>{b(this,C,Jg).call(this,n)});$(this,Lt,null);$(this,Ws,()=>{b(this,C,fr).call(this,"ACP bridge websocket closed")});$(this,Bs,()=>{b(this,C,fr).call(this,"ACP bridge websocket error")});x(this,zt,n),x(this,st,n.sessionMode??eR),x(this,js,n.createSocket??(r=>new WebSocket(r)))}getState(){return u(this,ne)}get messages(){return u(this,ne).messageOrder.map(n=>u(this,ne).messagesById[n]).filter(n=>n!==void 0)}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(u(this,ne).lifecycle.status!=="ready"){b(this,C,Be).call(this,{lifecycle:{status:"connecting"}}),u(this,Er)??x(this,Er,b(this,C,Kg).call(this));try{await u(this,Er),await b(this,C,Al).call(this)}catch(n){throw b(this,C,fr).call(this,Fi(n)),n}}}dispose(){b(this,C,Cl).call(this),b(this,C,Be).call(this,{lifecycle:{status:"disposed"},run:{status:"idle",stopReason:null,canCancel:!1,error:null}})}async sendMessage(n){if(await this.connect(),u(this,ne).lifecycle.status!=="ready"||u(this,ne).run.status==="running"||u(this,ne).run.status==="cancelling")throw new Error("ACPClient is not ready to send a new message");const r=n.text.trim();if(!r)throw new Error("Cannot send an empty message");b(this,C,hr).call(this,{id:b(this,C,pr).call(this,"user"),kind:"user",text:r,status:"final"}),b(this,C,Be).call(this,{run:{status:"running",stopReason:null,canCancel:!0,error:null}});try{const s=await b(this,C,no).call(this).prompt({sessionId:b(this,C,Tl).call(this),prompt:[{type:"text",text:b(this,C,im).call(this,r)}]});b(this,C,wn).call(this,s.stopReason==="cancelled"?"cancelled":"final"),b(this,C,Be).call(this,{run:{status:s.stopReason==="cancelled"?"cancelled":"completed",stopReason:s.stopReason,canCancel:!1,error:null}})}catch(s){throw b(this,C,lm).call(this)||(b(this,C,wn).call(this,"error"),b(this,C,Be).call(this,{run:{status:"error",stopReason:null,canCancel:!1,error:Fi(s)}})),s}}async cancel(){if(await this.connect(),!u(this,ne).run.canCancel||u(this,ne).run.status!=="running")throw new Error("No active cancellable run");b(this,C,Be).call(this,{run:{...u(this,ne).run,status:"cancelling"}}),await b(this,C,no).call(this).cancel({sessionId:b(this,C,Tl).call(this)})}setScreenContext(n){var i,o,a;const r={screenID:n.screenID,screenName:n.screenName};if(((i=u(this,rt))==null?void 0:i.screenID)===r.screenID&&((o=u(this,rt))==null?void 0:o.screenName)===r.screenName)return;const s=((a=u(this,rt))==null?void 0:a.screenID)??null;if(x(this,rt,r),u(this,st)==="single_session"){(!u(this,Kt)||s!==r.screenID)&&x(this,Jt,!0);return}u(this,Kt)!==Ed(u(this,st),r.screenID,u(this,zt).clientGUID??"default-client")&&(x(this,Dt,null),x(this,On,null),u(this,Rt)&&u(this,ne).run.status==="idle"&&b(this,C,Al).call(this).catch(l=>{b(this,C,fr).call(this,Fi(l))}))}}ne=new WeakMap,Rt=new WeakMap,Er=new WeakMap,Dt=new WeakMap,On=new WeakMap,zn=new WeakMap,Kt=new WeakMap,$r=new WeakMap,bt=new WeakMap,rt=new WeakMap,Jt=new WeakMap,Ln=new WeakMap,Ot=new WeakMap,Xt=new WeakMap,js=new WeakMap,zt=new WeakMap,st=new WeakMap,xo=new WeakMap,Lt=new WeakMap,C=new WeakSet,Kg=async function(){try{b(this,C,Be).call(this,{lifecycle:{status:"connecting"}});const{stream:n,socket:r}=await aR({serverURL:u(this,zt).serverURL,token:u(this,zt).token,createSocket:u(this,js),onDisconnect:u(this,xo)});x(this,Lt,r),r.addEventListener("close",u(this,Ws)),r.addEventListener("error",u(this,Bs)),x(this,Rt,new qP(s=>({connection:s,sessionUpdate:async i=>{await b(this,C,Qg).call(this,i)},requestPermission:async i=>b(this,C,em).call(this,i)}),n)),await u(this,Rt).initialize({protocolVersion:PC,clientCapabilities:{},clientInfo:tR})}catch(n){throw n}},Jg=function(n){b(this,C,fr).call(this,Fi(n))},Al=async function(){const n=b(this,C,om).call(this);if(u(this,Dt)&&u(this,On)===n){await u(this,Dt);return}x(this,On,n),x(this,Dt,b(this,C,Xg).call(this,n)),await u(this,Dt)},Xg=async function(n){const r=b(this,C,no).call(this);b(this,C,am).call(this);let s,i=!1;try{x(this,Ln,!0),x(this,Ot,null),await r.loadSession({sessionId:n,cwd:"/",mcpServers:[],_meta:{sessionKey:n}}),s=n,i=u(this,ne).messageOrder.length>0}catch{s=(await r.newSession({cwd:"/",mcpServers:[],_meta:{sessionKey:n}})).sessionId,i=!1}finally{x(this,Ln,!1),x(this,Ot,null),b(this,C,wn).call(this,"final")}await r.setSessionConfigOption({sessionId:s,configId:"verbose_level",value:"full"}),x(this,zn,s),x(this,Kt,n),i?(u(this,Xt).add(n),u(this,st)==="single_session"&&x(this,Jt,!1)):(u(this,Xt).delete(n),x(this,Jt,u(this,st)==="single_session")),b(this,C,Be).call(this,{lifecycle:{status:"ready"}})},Qg=async function(n){const r=n.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&b(this,C,sm).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&b(this,C,tm).call(this,r.content.text);return;case"tool_call":b(this,C,nm).call(this,r);return;case"tool_call_update":b(this,C,rm).call(this,r);return;case"agent_thought_chunk":return;default:return}},em=async function(n){return{outcome:{outcome:"cancelled"}}},tm=function(n){x(this,Ot,null);const r=iR(n);if(!r)return;if(!u(this,bt)){const i={id:b(this,C,pr).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};x(this,bt,i.id),b(this,C,hr).call(this,i);return}const s=u(this,ne).messagesById[u(this,bt)];if(!s||s.kind!=="assistant")throw new Error("Open assistant message invariant violated");b(this,C,dr).call(this,{...s,text:`${s.text}${r}`,status:"streaming"})},nm=function(n){b(this,C,wn).call(this,"final");const r=b(this,C,xl).call(this,n.toolCallId),s={id:(r==null?void 0:r.id)??b(this,C,pr).call(this,"tool"),kind:"tool_call",toolCallId:n.toolCallId,title:n.title,toolKind:n.kind??"other",status:n.status==="failed"?"failed":n.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??"",locations:n.locations??(r==null?void 0:r.locations)};if(r){b(this,C,dr).call(this,s);return}b(this,C,hr).call(this,s)},rm=function(n){const r=b(this,C,xl).call(this,n.toolCallId),s=(r==null?void 0:r.text)??"",i=oR(n.content),o=i?`${s}${i}`:s,a={id:(r==null?void 0:r.id)??b(this,C,pr).call(this,"tool"),kind:"tool_call",toolCallId:n.toolCallId,title:(r==null?void 0:r.title)??n.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:n.status==="failed"?"failed":n.status==="completed"?"completed":"in_progress",text:o,locations:n.locations??(r==null?void 0:r.locations)};if(r){b(this,C,dr).call(this,a);return}b(this,C,hr).call(this,a)},sm=function(n){if(b(this,C,wn).call(this,"final"),!n)return;const r=u(this,Ln)?u(this,Ot):null;if(!r){const i=$d(n);if(!i)return;const o={id:b(this,C,pr).call(this,"user"),kind:"user",text:i,status:"final"};b(this,C,hr).call(this,o),u(this,Ln)&&x(this,Ot,o.id);return}const s=u(this,ne).messagesById[r];if(!s||s.kind!=="user")throw new Error("Replay user message invariant violated");b(this,C,dr).call(this,{...s,text:$d(`${s.text}${n}`)})},wn=function(n){if(!u(this,bt))return;const r=u(this,ne).messagesById[u(this,bt)];(r==null?void 0:r.kind)==="assistant"&&b(this,C,dr).call(this,{...r,status:n}),x(this,bt,null)},hr=function(n){b(this,C,Be).call(this,{messagesById:{...u(this,ne).messagesById,[n.id]:n},messageOrder:[...u(this,ne).messageOrder,n.id]})},dr=function(n){b(this,C,Be).call(this,{messagesById:{...u(this,ne).messagesById,[n.id]:n}})},Be=function(n){const r={...u(this,ne),...n};x(this,ne,{...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 te("change"))},im=function(n){const r=u(this,Kt);return!u(this,rt)||!r||!(u(this,st)==="single_session"?u(this,Jt)||!u(this,Xt).has(r):!u(this,Xt).has(r))?n:(x(this,Jt,!1),u(this,Xt).add(r),["[Television screen context]","This chat session is coming from a Television client in the screen below.",`screen_id: ${u(this,rt).screenID}`,`screen_name: ${u(this,rt).screenName??""}`,"When the user asks to inspect or change Television state with the tv CLI, use this screen ID with the --screen argument.","[/Television screen context]","",n].join(`
|
|
43
|
-
`))},pr=function(n){const r=`${n}-${u(this,$r)}`;return x(this,$r,u(this,$r)+1),r},xl=function(n){for(const r of u(this,ne).messageOrder){const s=u(this,ne).messagesById[r];if((s==null?void 0:s.kind)==="tool_call"&&s.toolCallId===n)return s}return null},Tl=function(){if(!u(this,zn))throw new Error("ACP session is not ready");return u(this,zn)},no=function(){if(!u(this,Rt))throw new Error("ACP connection is not ready");return u(this,Rt)},om=function(){var r;if(u(this,st)==="single_session")return`${Yg}-${(u(this,zt).clientGUID??"default-client").toLowerCase()}`;const n=(r=u(this,rt))==null?void 0:r.screenID;if(!n)throw new Error("Screen context is required for per-screen session mode");return Ed(u(this,st),n,u(this,zt).clientGUID??"default-client")},Ws=new WeakMap,Bs=new WeakMap,Cl=function(){x(this,Rt,null),x(this,Er,null),x(this,Dt,null),x(this,On,null),x(this,zn,null),x(this,Kt,null),u(this,Lt)&&(u(this,Lt).removeEventListener("close",u(this,Ws)),u(this,Lt).removeEventListener("error",u(this,Bs)),u(this,Lt).close(),x(this,Lt,null))},fr=function(n){this.disposed||u(this,ne).lifecycle.status==="disconnected"||(b(this,C,wn).call(this,"error"),b(this,C,Cl).call(this),b(this,C,Be).call(this,{lifecycle:{status:"disconnected",...n?{error:n}:{}},run:{status:"idle",stopReason:null,canCancel:!1,error:null}}))},am=function(){x(this,bt,null),x(this,Ot,null),x(this,$r,1),b(this,C,Be).call(this,{run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[]})},lm=function(){return u(this,ne).lifecycle.status==="disconnected"};function sR(){return{lifecycle:{status:"connecting"},run:{status:"idle",stopReason:null,canCancel:!1,error:null},messagesById:{},messageOrder:[],sendDisabled:!0,cancelDisabled:!0}}function Ed(t,e,n){return t==="single_session"?`${Yg}-${n.toLowerCase()}`:`agent:main:television-${n.toLowerCase()}-${e.toLowerCase()}`}function cm(t){return t.replace(/^(?:\s*\n)+/,"")}function $d(t){let e=t;return e=e.replace(KP,""),e=e.replace(JP,""),e=e.replace(XP,""),e=cm(e),e}function iR(t){let e=t;return e=e.replace(QP,""),e=cm(e),e}function oR(t){return!t||t.length===0?"":t.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function aR(t){const e=t.createSocket(cR(t.serverURL,t.token));let n=!1,r,s;const i=new Promise((l,c)=>{r=l,s=c}),o=new ReadableStream({start(l){let c=!1;const d=()=>{e.send(JSON.stringify({type:"acp-bridge-connect"}))},p=E=>{const k=lR(E);if(!k)return;let I;try{I=JSON.parse(k)}catch(G){const N=G instanceof Error?G:new Error(String(G));s(N),l.error(N);return}switch(I.type){case"acp-bridge-status":if(I.status==="ready"){n||(n=!0,r());return}if(I.status==="error"||I.status==="exited"){const G=new Error(I.error??`ACP bridge ${I.status}`);n||s(G),l.error(G)}return;case"acp-bridge-message":l.enqueue(I.message);return}},y=()=>{var k;if(c)return;c=!0;const E=new Error("ACP bridge websocket closed");n||s(E),(k=t.onDisconnect)==null||k.call(t,E),l.close()},m=()=>{var k;if(c)return;c=!0;const E=new Error("ACP bridge websocket error");n||s(E),(k=t.onDisconnect)==null||k.call(t,E),l.error(E)};e.addEventListener("open",d),e.addEventListener("message",p),e.addEventListener("close",y),e.addEventListener("error",m)}}),a=new WritableStream({async write(l){await i,e.send(JSON.stringify({type:"acp-bridge-message",message:l}))},close(){e.close()},abort(){e.close()}});return await i,{stream:{readable:o,writable:a},socket:e}}function lR(t){if(typeof t=="string")return t;if(t instanceof Uint8Array)return new TextDecoder().decode(t);if(typeof Buffer<"u"&&t instanceof Buffer)return t.toString("utf8");if(typeof t=="object"&&t!==null&&"data"in t){const e=t.data;if(typeof e=="string")return e;if(e instanceof Uint8Array)return new TextDecoder().decode(e);if(Array.isArray(e))return Buffer.concat(e).toString("utf8")}return null}function cR(t,e){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname="/acp",n.search="",n.searchParams.set("token",e),n.hash="",n.toString()}function Fi(t){return t instanceof Error?t.message:String(t)}const Ad="television.acpClientGUID",uR=Hr(kt);class hR extends uR{constructor(n){super();v(this,"screenManager");v(this,"clients",new Map);v(this,"options");v(this,"sessionMode");v(this,"clientGUID");v(this,"activeClient",null);v(this,"handleActiveScreenChanged",()=>{this.syncActiveClient()});this.screenManager=n.screenManager,this.sessionMode=n.sessionMode??"single_session",this.options={serverURL:n.serverURL,token:n.token,...n.createSocket?{createSocket:n.createSocket}:{},...n.sessionMode?{sessionMode:n.sessionMode}:{}},this.clientGUID=n.clientGUID??dR(n.storage??window.localStorage),this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.syncActiveClient()}getActiveClient(){return this.activeClient}dispose(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged);for(const n of this.clients.values())n.dispose();this.clients.clear(),this.activeClient=null}syncActiveClient(){const n=this.screenManager.activeScreen,r=n?this.getClientForScreen(n):null;this.activeClient!==r&&(this.activeClient=r,this.dispatchEvent(new te("change")))}getClientForScreen(n){const r=this.sessionMode==="single_session"?"single_session":n.id;let s=this.clients.get(r);return s||(s=new rR({...this.options,sessionMode:this.sessionMode,clientGUID:this.clientGUID}),this.clients.set(r,s)),s.setScreenContext({screenID:n.id,screenName:n.name}),s}}function dR(t){const e=t.getItem(Ad);if(e)return e;const n=Tc().toLowerCase();return t.setItem(Ad,n),n}const pR="serverURL",fR="token",gR="mode",mR="electron";function um(t=window.location.search,e=window.location.origin){const r=new URLSearchParams(t).get(pR);return r?new URL(r).origin:new URL(e).origin}function hm(t=window.location.search){return new URLSearchParams(t).get(fR)}function dm(t=window.location.search){return new URLSearchParams(t).get(gR)===mR}/**
|
|
44
|
-
* @license
|
|
45
|
-
* Copyright 2017 Google LLC
|
|
46
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
-
*/const As=globalThis,xd=t=>t,bo=As.trustedTypes,Td=bo?bo.createPolicy("lit-html",{createHTML:t=>t}):void 0,pm="$lit$",Gt=`lit$${Math.random().toFixed(9).slice(2)}$`,fm="?"+Gt,vR=`<${fm}>`,Gn=document,Cs=()=>Gn.createComment(""),Is=t=>t===null||typeof t!="object"&&typeof t!="function",jc=Array.isArray,yR=t=>jc(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",Ga=`[
|
|
48
|
-
\f\r]`,is=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Cd=/-->/g,Id=/>/g,yn=RegExp(`>|${Ga}(?:([^\\s"'>=/]+)(${Ga}*=${Ga}*(?:[^
|
|
49
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),Pd=/'/g,Rd=/"/g,gm=/^(?:script|style|textarea|title)$/i,bR=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),M=bR(1),Mr=Symbol.for("lit-noChange"),ge=Symbol.for("lit-nothing"),Dd=new WeakMap,Tn=Gn.createTreeWalker(Gn,129);function mm(t,e){if(!jc(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Td!==void 0?Td.createHTML(e):e}const wR=(t,e)=>{const n=t.length-1,r=[];let s,i=e===2?"<svg>":e===3?"<math>":"",o=is;for(let a=0;a<n;a++){const l=t[a];let c,d,p=-1,y=0;for(;y<l.length&&(o.lastIndex=y,d=o.exec(l),d!==null);)y=o.lastIndex,o===is?d[1]==="!--"?o=Cd:d[1]!==void 0?o=Id:d[2]!==void 0?(gm.test(d[2])&&(s=RegExp("</"+d[2],"g")),o=yn):d[3]!==void 0&&(o=yn):o===yn?d[0]===">"?(o=s??is,p=-1):d[1]===void 0?p=-2:(p=o.lastIndex-d[2].length,c=d[1],o=d[3]===void 0?yn:d[3]==='"'?Rd:Pd):o===Rd||o===Pd?o=yn:o===Cd||o===Id?o=is:(o=yn,s=void 0);const m=o===yn&&t[a+1].startsWith("/>")?" ":"";i+=o===is?l+vR:p>=0?(r.push(c),l.slice(0,p)+pm+l.slice(p)+Gt+m):l+Gt+(p===-2?a:m)}return[mm(t,i+(t[n]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class Ps{constructor({strings:e,_$litType$:n},r){let s;this.parts=[];let i=0,o=0;const a=e.length-1,l=this.parts,[c,d]=wR(e,n);if(this.el=Ps.createElement(c,r),Tn.currentNode=this.el.content,n===2||n===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(s=Tn.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const p of s.getAttributeNames())if(p.endsWith(pm)){const y=d[o++],m=s.getAttribute(p).split(Gt),E=/([.?@])?(.*)/.exec(y);l.push({type:1,index:i,name:E[2],strings:m,ctor:E[1]==="."?SR:E[1]==="?"?kR:E[1]==="@"?ER:Yo}),s.removeAttribute(p)}else p.startsWith(Gt)&&(l.push({type:6,index:i}),s.removeAttribute(p));if(gm.test(s.tagName)){const p=s.textContent.split(Gt),y=p.length-1;if(y>0){s.textContent=bo?bo.emptyScript:"";for(let m=0;m<y;m++)s.append(p[m],Cs()),Tn.nextNode(),l.push({type:2,index:++i});s.append(p[y],Cs())}}}else if(s.nodeType===8)if(s.data===fm)l.push({type:2,index:i});else{let p=-1;for(;(p=s.data.indexOf(Gt,p+1))!==-1;)l.push({type:7,index:i}),p+=Gt.length-1}i++}}static createElement(e,n){const r=Gn.createElement("template");return r.innerHTML=e,r}}function Nr(t,e,n=t,r){var o,a;if(e===Mr)return e;let s=r!==void 0?(o=n._$Co)==null?void 0:o[r]:n._$Cl;const i=Is(e)?void 0:e._$litDirective$;return(s==null?void 0:s.constructor)!==i&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),i===void 0?s=void 0:(s=new i(t),s._$AT(t,n,r)),r!==void 0?(n._$Co??(n._$Co=[]))[r]=s:n._$Cl=s),s!==void 0&&(e=Nr(t,s._$AS(t,e.values),s,r)),e}class _R{constructor(e,n){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:n},parts:r}=this._$AD,s=((e==null?void 0:e.creationScope)??Gn).importNode(n,!0);Tn.currentNode=s;let i=Tn.nextNode(),o=0,a=0,l=r[0];for(;l!==void 0;){if(o===l.index){let c;l.type===2?c=new Wc(i,i.nextSibling,this,e):l.type===1?c=new l.ctor(i,l.name,l.strings,this,e):l.type===6&&(c=new $R(i,this,e)),this._$AV.push(c),l=r[++a]}o!==(l==null?void 0:l.index)&&(i=Tn.nextNode(),o++)}return Tn.currentNode=Gn,s}p(e){let n=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,n),n+=r.strings.length-2):r._$AI(e[n])),n++}}let Wc=class vm{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,n,r,s){this.type=2,this._$AH=ge,this._$AN=void 0,this._$AA=e,this._$AB=n,this._$AM=r,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=n.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,n=this){e=Nr(this,e,n),Is(e)?e===ge||e==null||e===""?(this._$AH!==ge&&this._$AR(),this._$AH=ge):e!==this._$AH&&e!==Mr&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):yR(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!==ge&&Is(this._$AH)?this._$AA.nextSibling.data=e:this.T(Gn.createTextNode(e)),this._$AH=e}$(e){var i;const{values:n,_$litType$:r}=e,s=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=Ps.createElement(mm(r.h,r.h[0]),this.options)),r);if(((i=this._$AH)==null?void 0:i._$AD)===s)this._$AH.p(n);else{const o=new _R(s,this),a=o.u(this.options);o.p(n),this.T(a),this._$AH=o}}_$AC(e){let n=Dd.get(e.strings);return n===void 0&&Dd.set(e.strings,n=new Ps(e)),n}k(e){jc(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let r,s=0;for(const i of e)s===n.length?n.push(r=new vm(this.O(Cs()),this.O(Cs()),this,this.options)):r=n[s],r._$AI(i),s++;s<n.length&&(this._$AR(r&&r._$AB.nextSibling,s),n.length=s)}_$AR(e=this._$AA.nextSibling,n){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,n);e!==this._$AB;){const s=xd(e).nextSibling;xd(e).remove(),e=s}}setConnected(e){var n;this._$AM===void 0&&(this._$Cv=e,(n=this._$AP)==null||n.call(this,e))}},Yo=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,n,r,s,i){this.type=1,this._$AH=ge,this._$AN=void 0,this.element=e,this.name=n,this._$AM=s,this.options=i,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=ge}_$AI(e,n=this,r,s){const i=this.strings;let o=!1;if(i===void 0)e=Nr(this,e,n,0),o=!Is(e)||e!==this._$AH&&e!==Mr,o&&(this._$AH=e);else{const a=e;let l,c;for(e=i[0],l=0;l<i.length-1;l++)c=Nr(this,a[r+l],n,l),c===Mr&&(c=this._$AH[l]),o||(o=!Is(c)||c!==this._$AH[l]),c===ge?e=ge:e!==ge&&(e+=(c??"")+i[l+1]),this._$AH[l]=c}o&&!s&&this.j(e)}j(e){e===ge?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},SR=class extends Yo{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ge?void 0:e}},kR=class extends Yo{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==ge)}},ER=class extends Yo{constructor(e,n,r,s,i){super(e,n,r,s,i),this.type=5}_$AI(e,n=this){if((e=Nr(this,e,n,0)??ge)===Mr)return;const r=this._$AH,s=e===ge&&r!==ge||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,i=e!==ge&&(r===ge||s);s&&this.element.removeEventListener(this.name,this,r),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var n;typeof this._$AH=="function"?this._$AH.call(((n=this.options)==null?void 0:n.host)??this.element,e):this._$AH.handleEvent(e)}};class $R{constructor(e,n,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=n,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){Nr(this,e)}}const Va=As.litHtmlPolyfillSupport;Va==null||Va(Ps,Wc),(As.litHtmlVersions??(As.litHtmlVersions=[])).push("3.3.2");const be=(t,e,n)=>{const r=e;let s=r._$litPart$;return s===void 0&&(r._$litPart$=s=new Wc(e.insertBefore(Cs(),null),null,void 0,{})),s._$AI(t),s};/**
|
|
50
|
-
* @license
|
|
51
|
-
* Copyright 2017 Google LLC
|
|
52
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
|
-
*/const AR={CHILD:2},ym=t=>(...e)=>({_$litDirective$:t,values:e});class xR{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,n,r){this._$Ct=e,this._$AM=n,this._$Ci=r}_$AS(e,n){return this.update(e,n)}update(e,n){return this.render(...n)}}/**
|
|
54
|
-
* @license
|
|
55
|
-
* Copyright 2017 Google LLC
|
|
56
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
57
|
-
*/class wo extends xR{constructor(e){if(super(e),this.it=ge,e.type!==AR.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===ge||e==null)return this._t=void 0,this.it=e;if(e===Mr)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const n=[e];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}}wo.directiveName="unsafeHTML",wo.resultType=1;const TR=ym(wo);/**
|
|
58
|
-
* @license
|
|
59
|
-
* Copyright 2017 Google LLC
|
|
60
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
-
*/class Il extends wo{}Il.directiveName="unsafeSVG",Il.resultType=2;const CR=ym(Il),IR={size:16,color:"currentColor",weight:"regular"};function PR(t){return typeof t=="string"?{regular:t}:t}function Ko(t,e="0 0 256 256"){const n=PR(t);return r=>{const{size:s,color:i,weight:o}={...IR,...r},a=n[o]??n.regular;return M`<svg
|
|
62
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
63
|
-
data-ui-icon=""
|
|
64
|
-
width="${s}"
|
|
65
|
-
height="${s}"
|
|
66
|
-
viewBox="${e}"
|
|
67
|
-
fill="${i}"
|
|
68
|
-
>${CR(a)}</svg>`}}const RR=Ko('<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"/>'),bm=Ko('<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"/>'),wm=Ko('<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"/>'),DR=Ko('<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"/>');class _m extends Event{constructor(n){super("dropdown-item-select",{bubbles:!0,composed:!0});v(this,"value");this.value=n}}class OR extends Event{constructor(n){super("select",{bubbles:!0,composed:!0});v(this,"value");this.value=n}}var qe,it,Qt,Ar,re,Gs,D,km,vs,Em,$m,Pl,Rl,ro,_n,Mn,Vs,Hs,qs,To,Am,xm,Dl,ys,Ol,zl,Ct;class Sm extends HTMLElement{constructor(){super();$(this,D);$(this,qe,!1);$(this,it,null);$(this,Qt,null);$(this,Ar);$(this,re,null);$(this,Gs,new MutationObserver(n=>b(this,D,Am).call(this,n)));$(this,Mn,()=>{b(this,D,ro).call(this,!u(this,qe))});$(this,Vs,n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),u(this,Mn).call(this))});$(this,Hs,n=>{u(this,qe)&&(n.composedPath().includes(this)||b(this,D,ro).call(this,!1))});$(this,qs,n=>{n instanceof _m&&(n.stopPropagation(),x(this,qe,!1),b(this,D,vs).call(this,n.value),b(this,D,Ct).call(this),this.dispatchEvent(new OR(n.value)))});$(this,To,()=>{b(this,D,Dl).call(this)});x(this,Ar,this.attachShadow({mode:"open"}))}connectedCallback(){this.addEventListener("dropdown-item-select",u(this,qs)),document.addEventListener("click",u(this,Hs),!0),b(this,D,km).call(this),u(this,Gs).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),b(this,D,Ct).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",u(this,qs)),document.removeEventListener("click",u(this,Hs),!0),u(this,Gs).disconnect(),b(this,D,zl).call(this)}attributeChangedCallback(){b(this,D,Ct).call(this)}get title(){return this.getAttribute("title")??""}get placement(){return this.getAttribute("placement")==="top"?"top":"bottom"}get value(){return u(this,it)}set value(n){n===null?(b(this,D,_n).call(this,null,null),b(this,D,Em).call(this)):b(this,D,vs).call(this,n),b(this,D,Ct).call(this)}close(){b(this,D,ro).call(this,!1)}}qe=new WeakMap,it=new WeakMap,Qt=new WeakMap,Ar=new WeakMap,re=new WeakMap,Gs=new WeakMap,D=new WeakSet,km=function(){var r;const n=this.querySelector("dropdown-item[selected]");n&&b(this,D,_n).call(this,n.value,((r=n.textContent)==null?void 0:r.trim())??null)},vs=function(n){var r;for(const s of u(this,D,Pl))s.value===n?(b(this,D,_n).call(this,n,((r=s.textContent)==null?void 0:r.trim())??null),s.hasAttribute("selected")||s.setAttribute("selected","")):s.hasAttribute("selected")&&s.removeAttribute("selected")},Em=function(){const n=this.querySelectorAll("dropdown-item[selected]");for(const r of n)r.removeAttribute("selected")},$m=function(n){for(const r of u(this,D,Pl))if(r.value===n)return r;return null},Pl=function(){return this.querySelectorAll("dropdown-item")},Rl=function(){return u(this,Qt)??this.title},ro=function(n){u(this,qe)!==n&&(x(this,qe,n),b(this,D,Ct).call(this))},_n=function(n,r){x(this,it,n),x(this,Qt,r)},Mn=new WeakMap,Vs=new WeakMap,Hs=new WeakMap,qs=new WeakMap,To=new WeakMap,Am=function(n){n.every(s=>s.target instanceof Element?s.target.closest('[slot="trigger"]')!==null:!1)||b(this,D,xm).call(this)},xm=function(){var r,s;const n=this.querySelector("dropdown-item[selected]");if(n){const i=n.value,o=((r=n.textContent)==null?void 0:r.trim())??null,a=u(this,it)!==i||u(this,Qt)!==o;b(this,D,_n).call(this,i,o),b(this,D,vs).call(this,i),a?b(this,D,Ct).call(this):b(this,D,ys).call(this);return}if(u(this,it)!==null){const i=b(this,D,$m).call(this,u(this,it));if(i){const o=((s=i.textContent)==null?void 0:s.trim())??null,a=u(this,Qt)!==o;b(this,D,_n).call(this,u(this,it),o),b(this,D,vs).call(this,u(this,it)),a?b(this,D,Ct).call(this):b(this,D,ys).call(this);return}}if(u(this,it)!==null||u(this,Qt)!==null){b(this,D,_n).call(this,null,null),b(this,D,Ct).call(this);return}b(this,D,ys).call(this)},Dl=function(){const n=u(this,Ar).querySelector('slot[name="trigger"]'),r=n instanceof HTMLSlotElement?n.assignedElements()[0]??null:null;u(this,re)!==r&&(b(this,D,zl).call(this),x(this,re,r),u(this,re)&&(u(this,re).addEventListener("click",u(this,Mn)),u(this,re)instanceof HTMLButtonElement?u(this,re).hasAttribute("type")||(u(this,re).type="button"):(u(this,re).hasAttribute("role")||u(this,re).setAttribute("role","button"),u(this,re).hasAttribute("tabindex")||(u(this,re).tabIndex=0),u(this,re).addEventListener("keydown",u(this,Vs))))),b(this,D,ys).call(this)},ys=function(){u(this,re)&&(u(this,re).setAttribute("data-dropdown-trigger",""),u(this,re).setAttribute("aria-haspopup","listbox"),u(this,re).setAttribute("aria-expanded",u(this,qe)?"true":"false"),be(M`
|
|
69
|
-
<span class="trigger-label" data-dropdown-trigger-label>${u(this,D,Rl)}</span>
|
|
70
|
-
<span class="trigger-icon" data-dropdown-trigger-icon aria-hidden="true">
|
|
71
|
-
${u(this,D,Ol).call(this,{size:16})}
|
|
72
|
-
</span>
|
|
73
|
-
`,u(this,re)))},Ol=function(){return this.placement==="top"?DR:wm},zl=function(){u(this,re)&&(u(this,re).removeEventListener("click",u(this,Mn)),u(this,re).removeEventListener("keydown",u(this,Vs)),u(this,re).removeAttribute("data-dropdown-trigger"),u(this,re).removeAttribute("aria-haspopup"),u(this,re).removeAttribute("aria-expanded"),x(this,re,null))},Ct=function(){this.toggleAttribute("open",u(this,qe)),be(M`
|
|
74
|
-
<slot name="trigger" @slotchange=${u(this,To)}>
|
|
75
|
-
<button
|
|
76
|
-
class="fallback-trigger"
|
|
77
|
-
part="trigger"
|
|
78
|
-
type="button"
|
|
79
|
-
aria-haspopup="listbox"
|
|
80
|
-
aria-expanded=${u(this,qe)?"true":"false"}
|
|
81
|
-
@click=${u(this,Mn)}
|
|
82
|
-
>
|
|
83
|
-
<span class="trigger-label" part="trigger-label">${u(this,D,Rl)}</span>
|
|
84
|
-
<span class="trigger-icon" part="trigger-icon" aria-hidden="true">
|
|
85
|
-
${u(this,D,Ol).call(this,{size:16})}
|
|
86
|
-
</span>
|
|
87
|
-
</button>
|
|
88
|
-
</slot>
|
|
89
|
-
${u(this,qe)?M`
|
|
90
|
-
<div
|
|
91
|
-
class="panel"
|
|
92
|
-
part="panel panel-${this.placement}"
|
|
93
|
-
role="listbox"
|
|
94
|
-
>
|
|
95
|
-
<slot></slot>
|
|
96
|
-
</div>
|
|
97
|
-
`:null}
|
|
98
|
-
`,u(this,Ar)),queueMicrotask(()=>b(this,D,Dl).call(this))},v(Sm,"observedAttributes",["title","placement"]);class zR extends HTMLElement{}class LR extends HTMLElement{}class MR extends HTMLElement{}var qn,Ll,Cm,Ys,Ks;class Tm extends HTMLElement{constructor(){super(...arguments);$(this,qn);$(this,Ys,()=>{this.action||b(this,qn,Cm).call(this)});$(this,Ks,n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",u(this,Ys)),this.addEventListener("keydown",u(this,Ks)),b(this,qn,Ll).call(this)}disconnectedCallback(){this.removeEventListener("click",u(this,Ys)),this.removeEventListener("keydown",u(this,Ks))}attributeChangedCallback(){b(this,qn,Ll).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}qn=new WeakSet,Ll=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")},Cm=function(){this.dispatchEvent(new _m(this.value))},Ys=new WeakMap,Ks=new WeakMap,v(Tm,"observedAttributes",["action","selected","value"]);customElements.get("dropdown-menu")||customElements.define("dropdown-menu",Sm);customElements.get("dropdown-group")||customElements.define("dropdown-group",zR);customElements.get("dropdown-label")||customElements.define("dropdown-label",LR);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",MR);customElements.get("dropdown-item")||customElements.define("dropdown-item",Tm);class NR extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var Js,cn,Ml,Co,Xs,Nl;class Im extends HTMLElement{constructor(){super();$(this,cn);$(this,Js);$(this,Co,n=>{n.target===n.currentTarget&&b(this,cn,Ml).call(this)});$(this,Xs,n=>{this.open&&n.key==="Escape"&&b(this,cn,Ml).call(this)});x(this,Js,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",u(this,Xs)),b(this,cn,Nl).call(this)}disconnectedCallback(){document.removeEventListener("keydown",u(this,Xs))}attributeChangedCallback(){b(this,cn,Nl).call(this)}get open(){return this.hasAttribute("open")}}Js=new WeakMap,cn=new WeakSet,Ml=function(){this.dispatchEvent(new NR)},Co=new WeakMap,Xs=new WeakMap,Nl=function(){be(M`
|
|
99
|
-
${this.open?M`
|
|
100
|
-
<div class="backdrop" part="backdrop" @click=${u(this,Co)}>
|
|
101
|
-
<slot></slot>
|
|
102
|
-
</div>
|
|
103
|
-
`:null}
|
|
104
|
-
`,u(this,Js))},v(Im,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",Im);class Pm extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class UR extends HTMLElement{}var Qs,ei,Ul;class Rm extends HTMLElement{constructor(){super();$(this,ei);$(this,Qs);x(this,Qs,this.attachShadow({mode:"open"}))}connectedCallback(){b(this,ei,Ul).call(this)}attributeChangedCallback(){b(this,ei,Ul).call(this)}get closable(){return this.hasAttribute("closable")}}Qs=new WeakMap,ei=new WeakSet,Ul=function(){const n=this.querySelector("panel-page");be(M`
|
|
105
|
-
<section class="panel" part="panel">
|
|
106
|
-
<header class="title-bar" part="header">
|
|
107
|
-
<h2 class="title" part="title">${(n==null?void 0:n.getAttribute("title"))??""}</h2>
|
|
108
|
-
${this.closable?M`
|
|
109
|
-
<button
|
|
110
|
-
type="button"
|
|
111
|
-
class="title-button"
|
|
112
|
-
part="button close-button"
|
|
113
|
-
aria-label="Close"
|
|
114
|
-
@click=${()=>this.dispatchEvent(new Pm)}
|
|
115
|
-
>
|
|
116
|
-
<span class="close-icon" part="icon close-icon">${bm({size:16})}</span>
|
|
117
|
-
</button>
|
|
118
|
-
`:null}
|
|
119
|
-
</header>
|
|
120
|
-
<slot></slot>
|
|
121
|
-
</section>
|
|
122
|
-
`,u(this,Qs))},v(Rm,"observedAttributes",["closable"]);customElements.get("panel-view")||customElements.define("panel-view",Rm);customElements.get("panel-page")||customElements.define("panel-page",UR);const FR=et(),ZR="No handler registered for update-content",jR="handleUpdateContent: handler already registered";function WR(t){return t instanceof Error&&typeof t.message=="string"?t.message:String(t)}const BR=Hr(kt);var xr,Tr,Cr,Nn,Un,ti,Te,Fl,Dm,Om,bs,Zl,up;let GR=(up=class extends BR{constructor(n){super();$(this,Te);$(this,xr);$(this,Tr);$(this,Cr);$(this,Nn,null);$(this,Un,null);$(this,ti,!1);x(this,xr,n);const r=n.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");x(this,Tr,r),x(this,Cr,s=>b(this,Te,Dm).call(this,s)),u(this,Tr).addEventListener("message",u(this,Cr))}get content(){return u(this,Un)}set content(n){b(this,Te,Zl).call(this),x(this,Un,n),u(this,ti)&&b(this,Te,Fl).call(this,n)}handleUpdateContent(n){if(b(this,Te,Zl).call(this),u(this,Nn)!==null)throw new Error(jR);x(this,Nn,n)}dispose(){u(this,Tr).removeEventListener("message",u(this,Cr)),x(this,Nn,null)}},xr=new WeakMap,Tr=new WeakMap,Cr=new WeakMap,Nn=new WeakMap,Un=new WeakMap,ti=new WeakMap,Te=new WeakSet,Fl=function(n){const r={type:"content-updated",content:n};b(this,Te,bs).call(this,r)},Dm=function(n){if(this.disposed||n.source!==u(this,xr).contentWindow)return;const r=n.data;if(wC(r)){x(this,ti,!0),this.dispatchEvent(new FR("ready")),u(this,Un)!==null&&b(this,Te,Fl).call(this,u(this,Un));return}if(_C(r)){b(this,Te,Om).call(this,r);return}},Om=async function(n){const r=u(this,Nn);if(r===null){b(this,Te,bs).call(this,{type:"response",id:n.id,error:{message:ZR}});return}try{await r(n.content)}catch(s){if(this.disposed)return;b(this,Te,bs).call(this,{type:"response",id:n.id,error:{message:WR(s)}});return}this.disposed||b(this,Te,bs).call(this,{type:"response",id:n.id,result:{}})},bs=function(n){const r=u(this,xr).contentWindow;r&&r.postMessage(n,"*")},Zl=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},up);function VR(t=window){t.parent!==t&&(t.addEventListener("wheel",e=>{const n=e;t.parent.postMessage({type:"wheel",deltaX:n.deltaX,deltaY:n.deltaY,shiftKey:n.shiftKey},"*"),n.preventDefault()},{passive:!1}),t.addEventListener("message",e=>{const n=e.data;if(n!==null&&typeof n=="object"&&n.type==="scroll"){const r=n,s=typeof r.deltaX=="number"?r.deltaX:0,i=typeof r.deltaY=="number"?r.deltaY:0;t.scrollBy(s,i)}}))}function HR(){return`(${VR.toString()})(window);`}async function qR(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch artifact content: ${e.status}`);const n=await e.text(),r=new DOMParser().parseFromString(n,"text/html"),s=r.createElement("base");s.href=t,r.head.insertBefore(s,r.head.firstChild);const i=r.createElement("script");i.textContent=HR(),r.head.appendChild(i);const o=new Blob([`<!DOCTYPE html>
|
|
123
|
-
${r.documentElement.outerHTML}`],{type:"text/html"});return URL.createObjectURL(o)}const zm=et();class YR extends HTMLElement{constructor(){super(...arguments);v(this,"_artifact",null);v(this,"_viewURL",null);v(this,"_contentURL",null);v(this,"_screen",null);v(this,"_subscribedScreen",null);v(this,"_activeView",null);v(this,"_contentState",{kind:"idle"});v(this,"_fetchSequence",0);v(this,"_blobSequence",0);v(this,"_mountedViewURL",null);v(this,"_directRender",!1);v(this,"_blobURL",null);v(this,"handleScreenContentChanged",n=>{!this._artifact||n.artifactID!==this._artifact.id||this._activeView!==null&&this.refetchContent()})}set artifact(n){const r=this._artifact;this._artifact=n,this.render(),r!==null&&r!==n&&this.syncView()}get artifact(){return this._artifact}set viewURL(n){this._viewURL!==n&&(this._viewURL=n,this.syncView())}get viewURL(){return this._viewURL}set contentURL(n){this._contentURL!==n&&(this._contentURL=n,this.syncView())}get contentURL(){return this._contentURL}set screen(n){this._screen!==n&&(this._screen=n,this.syncScreenSubscription())}get screen(){return this._screen}set dragging(n){n?this.setAttribute("dragging","true"):this.removeAttribute("dragging")}get dragging(){return this.getAttribute("dragging")==="true"}get activeView(){return this._activeView}connectedCallback(){this.render(),this.syncView(),this.syncScreenSubscription()}disconnectedCallback(){this.teardownView(),this.unsubscribeFromScreen()}handleClose(){this._artifact&&this.dispatchEvent(new zm("close-artifact",{artifactID:this._artifact.id,bubbles:!0,composed:!0}))}syncView(){var n;if(this.isConnected){if(this._viewURL!==null){if(this._directRender&&this.teardownView(),this._mountedViewURL!==this._viewURL){this.teardownView(),this._contentState={kind:"loading"},this._mountedViewURL=this._viewURL,this.render();const r=this.querySelector("iframe.artifact-frame");if(!r){this._contentState={kind:"error"},this.render();return}this._activeView=new GR(r),this._activeView.handleUpdateContent(async s=>{await this.saveContent(s)}),this.loadBlobFrame(this._viewURL),this.startContentFetch();return}this._activeView!==null&&this.startContentFetch();return}if(this._contentURL!==null){this.teardownView(),this._directRender=!0,this._contentState={kind:"idle"},this.render(),((n=this._artifact)==null?void 0:n.status)==="committed"&&this.loadBlobFrame(this._contentURL);return}this.teardownView(),this._contentState={kind:"idle"},this.render()}}async saveContent(n){const r=this._screen,s=this._artifact;if(!r||!s)throw new Error("artifact-view: cannot save without a screen and artifact");await r.server.client.artifacts.putContent({artifactID:s.id,content:n})}syncScreenSubscription(){if(!this.isConnected){this.unsubscribeFromScreen();return}this._subscribedScreen!==this._screen&&(this.unsubscribeFromScreen(),this._screen!==null&&(this._screen.addEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=this._screen))}unsubscribeFromScreen(){this._subscribedScreen!==null&&(this._subscribedScreen.removeEventListener("artifact-content-changed",this.handleScreenContentChanged),this._subscribedScreen=null)}startContentFetch(){this._fetchSequence+=1;const n=this._fetchSequence,r=this._contentURL,s=this._activeView;if(!s||r===null){this._contentState={kind:"error"},this.render();return}this._contentState={kind:"loading"},(async()=>{try{const i=await fetch(r);if(n!==this._fetchSequence)return;if(!i.ok){this._contentState={kind:"error"},this.teardownView(),this.render();return}const o=await i.text();if(n!==this._fetchSequence||this._activeView!==s)return;this._activeView.content=o,this._contentState={kind:"ready"}}catch{if(n!==this._fetchSequence)return;this._contentState={kind:"error"},this.teardownView(),this.render()}})()}refetchContent(){this._fetchSequence+=1;const n=this._fetchSequence,r=this._contentURL,s=this._activeView;!s||r===null||(async()=>{try{const i=await fetch(r);if(n!==this._fetchSequence||!i.ok)return;const o=await i.text();if(n!==this._fetchSequence||this._activeView!==s)return;this._activeView.content=o}catch{}})()}loadBlobFrame(n){this._blobSequence+=1;const r=this._blobSequence;(async()=>{try{const s=await qR(n);if(r!==this._blobSequence){URL.revokeObjectURL(s);return}this._blobURL=s,this.render();const i=this.querySelector("iframe.artifact-frame");i&&(i.src=s)}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"?M`
|
|
124
|
-
<div class="artifact-content artifact-placeholder">
|
|
125
|
-
<em>Failed to load content</em>
|
|
126
|
-
</div>
|
|
127
|
-
`:this._viewURL!==null||this._directRender?M`
|
|
128
|
-
<iframe
|
|
129
|
-
class="artifact-frame artifact-content"
|
|
130
|
-
src=${this._blobURL??"about:blank"}
|
|
131
|
-
sandbox="allow-scripts"
|
|
132
|
-
></iframe>
|
|
133
|
-
`:M`
|
|
134
|
-
<div class="artifact-content artifact-placeholder">
|
|
135
|
-
<em>Artifact unavailable</em>
|
|
136
|
-
</div>
|
|
137
|
-
`}template(){const n=this._artifact;return M`
|
|
138
|
-
${this.contentTemplate()}
|
|
139
|
-
<footer class="artifact-title-bar" drag-handle>
|
|
140
|
-
<div class="artifact-title-group">
|
|
141
|
-
<span class="artifact-title-icon">${RR({size:16})}</span>
|
|
142
|
-
<span class="artifact-title">${n.title}</span>
|
|
143
|
-
</div>
|
|
144
|
-
<button
|
|
145
|
-
class="artifact-close-btn"
|
|
146
|
-
@click=${()=>this.handleClose()}
|
|
147
|
-
aria-label="Close"
|
|
148
|
-
>
|
|
149
|
-
${bm({size:16})}
|
|
150
|
-
</button>
|
|
151
|
-
</footer>
|
|
152
|
-
`}render(){this._artifact&&(this.setAttribute("type",this._artifact.type),be(this.template(),this))}}customElements.define("artifact-view",YR);const Se=t=>({type:"px",...t}),xe=t=>({type:"unit",...t}),Zi=2,KR=2;class JR{constructor(e){v(this,"basis");v(this,"min");v(this,"_gap");v(this,"_viewport");v(this,"_unit");this.basis=e.basis,this.min=e.min,this._viewport=e.viewport,this._gap=e.gap??Se({x:de,y:de});const n=this._viewport.x??tn,r=this._viewport.y??vr,s=this._gap.x??de,i=this._gap.y??de,o=tn+s*KR,a=n<=o,l=a?n-s*Zi:Math.min(tn,n-s*Zi),c=a?r-i*Zi:Math.min(vr,r-i*Zi),d=(l-s*(St-1))/St,p=(c-i*(He-1))/He,y=this.basis.x??0,m=this.basis.y??0,E=this.min.x??0,k=this.min.y??0;this._unit=Se(a?{x:Math.max(E,d),y:Math.max(k,p)}:{x:Math.max(E,Math.min(y,d)),y:Math.max(k,Math.min(m,p))})}get unit(){return this._unit}get viewport(){return this._viewport}get gap(){return this._gap}toUnits(e){return xe({x:e.x==null?void 0:e.x/(this._unit.x??1),y:e.y==null?void 0:e.y/(this._unit.y??1)})}toPixels(e){const n=this._unit.x??0,r=this._unit.y??0,s=this._gap.x??de,i=this._gap.y??de,o=e.x==null?void 0:e.x*n+Math.max(0,e.x-1)*s,a=e.y==null?void 0:e.y*r+Math.max(0,e.y-1)*i;return Se({x:o,y:a})}}const Vn=1e-4,Nt=1e-6,XR=40,QR=24;function Lm(t,e){return Math.max(0,t-e*2)}function Mm(t){const e=[0];for(const n of t)e.push((e[e.length-1]??0)+n);return e}function Nm(t){const e=[0];for(let n=0;n<t.length;n+=1){const r=e[n]??0;e.push(r+t[n]+de)}return e}function Um(t,e,n){if(e<0||e>=t.length)return 0;let r=0,s=0;for(let i=e;i<t.length;i+=1){const o=t[i],a=s===0?o:r+de+o;if(a>n+Vn)break;r=a,s+=1}return Math.max(1,s)}function eD(t,e,n){if(e<0||e>=t.length)return 0;let r=0,s=0;for(let i=e;i>=0;i-=1){const o=t[i],a=s===0?o:r+de+o;if(a>n+Vn)break;r=a,s+=1}return Math.max(1,s)}function tD(t,e){if(t.length===0)return 0;let n=0,r=0;for(let s=t.length-1;s>=0;s-=1){const i=t[s],o=r===0?i:n+de+i;if(o>e+Vn)break;n=o,r+=1}return Math.max(1,r)}function Bc(t,e){if(t.length===0)return 0;const n=tD(t,e);return Math.max(0,t.length-n)}function Od(t,e,n){if(t.length===0)return 0;const r=Um(t,e,n),s=Math.min(t.length,e+r);if(s<=e)return 0;const i=t.slice(e,s);return i.reduce((o,a)=>o+a,0)+Math.max(0,i.length-1)*de}function jl(t,e,n){const r=t[e]??0;return n-r}function gr(t,e,n,r,s){if(t.length===0)return 0;const i=Bc(t,s),o=e[i]??0,a=Math.max(0,Math.min(o,n));let l=0;for(let L=0;L<i;L+=1){const J=e[L]??0,H=e[L+1]??J;if(a>=J&&a<=H+Vn){l=L;break}l=L+1}const c=Math.min(l+1,i),d=e[l]??0,p=e[c]??d,y=Math.max(p-d,Vn),m=c===l?0:(a-d)/y,E=Nm(t),k=Od(t,l,s),I=Od(t,c,s),G=(r-k)/2,N=(r-I)/2,j=jl(E,l,G),F=jl(E,c,N);return j+(F-j)*m}function zd(t,e,n,r,s){const i=Bc(t,r),o=e[i]??0;let a=0,l=o;for(let c=0;c<XR;c+=1){const d=(a+l)/2;gr(t,e,d,n,r)>s?a=d:l=d}return(a+l)/2}function Ld(t,e,n){const r=Nm(t),[s,i]=e,o=t.slice(s,i+1),a=o.reduce((c,d)=>c+d,0)+Math.max(0,o.length-1)*de,l=(n-a)/2;return jl(r,s,l)}function nD(t,e,n){const r=Um(t,e,n);return[e,Math.min(t.length-1,e+r-1)]}function rD(t,e,n){const r=eD(t,e,n);return[Math.max(0,e-r+1),e]}function sD(t){const e=new Set,n=[];for(const r of t){const s=`${r.nodeRange[0]}:${r.nodeRange[1]}`;if(e.has(s))continue;const i=n[n.length-1];i&&Math.abs(i.anchor-r.anchor)<=Nt||(e.add(s),n.push(r))}return n}function iD(t){const{nodeCols:e,nodeWidthsPx:n,viewportWidthPx:r}=t;if(e.length===0||n.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const s=t.gapPx??de,i=Lm(r,s),o=Mm(e),a=Bc(n,i),l=o[a]??0,c=[];for(let d=0;d<=a;d+=1){const p=nD(n,d,i),y=Ld(n,p,r),m=zd(n,o,r,i,y);c.push({nodeRange:p,anchor:Math.max(0,Math.min(l,m))})}for(let d=n.length-1;d>=0;d-=1){const p=rD(n,d,i),y=`${p[0]}:${p[1]}`;if(c.some(k=>`${k.nodeRange[0]}:${k.nodeRange[1]}`===y))continue;const m=Ld(n,p,r),E=zd(n,o,r,i,m);c.push({nodeRange:p,anchor:Math.max(0,Math.min(l,E))})}return c.sort((d,p)=>Math.abs(d.anchor-p.anchor)>Nt?d.anchor-p.anchor:d.nodeRange[0]!==p.nodeRange[0]?d.nodeRange[0]-p.nodeRange[0]:d.nodeRange[1]-p.nodeRange[1]),{viewspans:sD(c),minScroll:0,maxScroll:l}}function oD(t,e){var s;let n=0,r=Number.POSITIVE_INFINITY;for(let i=0;i<t.length;i+=1){const o=Math.abs((((s=t[i])==null?void 0:s.anchor)??0)-e);if(o+Nt<r){r=o,n=i;continue}Math.abs(o-r)<=Nt&&i<n&&(n=i)}return n}function aD(t,e,n){return n<=0?0:Math.max(0,Math.min(n-1,t+e))}function os(t,e,n){return Math.max(e,Math.min(n,t))}class lD extends kt{constructor(n){super();v(this,"_scroll",0);v(this,"minScroll",0);v(this,"maxScroll",0);v(this,"viewspans",[]);v(this,"activeViewspanIndex",null);v(this,"nodeWidthsPx",[]);v(this,"boundaryCols",[0]);v(this,"viewportWidthPx",0);v(this,"framedViewportWidthPx",0);this._scroll=(n==null?void 0:n.x)??0}get scroll(){return xe({x:this._scroll})}get translate(){return Se({x:gr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx)})}set scroll(n){const r=os(n.x??this._scroll,this.minScroll,this.maxScroll);Math.abs(r-this._scroll)<=Nt||(this._scroll=r,this.activeViewspanIndex=null,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}rebuild(n){const r=n.nodeWidths.map(c=>Math.max(0,c.x??0)),s=r.map(c=>n.grid.toPixels(xe({x:c})).x??0),i=n.grid.viewport.x??0,o=n.grid.gap.x??de,a=iD({nodeCols:r,nodeWidthsPx:s,viewportWidthPx:i,gapPx:o});this.nodeWidthsPx=s,this.boundaryCols=Mm(r),this.viewportWidthPx=i,this.framedViewportWidthPx=Lm(i,o),this.viewspans=a.viewspans,this.minScroll=a.minScroll,this.maxScroll=a.maxScroll,this.activeViewspanIndex=null;const l=os(this._scroll,this.minScroll,this.maxScroll);Math.abs(l-this._scroll)>Nt&&(this._scroll=l,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}step(n){var a;if(this.viewspans.length===0)return;const r=this.activeViewspanIndex??oD(this.viewspans,this._scroll),s=aD(r,n,this.viewspans.length),i=((a=this.viewspans[s])==null?void 0:a.anchor)??this._scroll,o=os(i,this.minScroll,this.maxScroll);this.activeViewspanIndex=s,!(Math.abs(o-this._scroll)<=Nt)&&(this._scroll=o,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}wheel(n){const r=os(this._scroll+(n.x??0),this.minScroll,this.maxScroll);this.activeViewspanIndex=null,!(Math.abs(r-this._scroll)<=Nt)&&(this._scroll=r,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}wheelPixels(n){const r=n.x??0;if(Math.abs(r)<=Vn)return;this.activeViewspanIndex=null;const s=gr(this.nodeWidthsPx,this.boundaryCols,this._scroll,this.viewportWidthPx,this.framedViewportWidthPx),i=s-r,o=gr(this.nodeWidthsPx,this.boundaryCols,this.maxScroll,this.viewportWidthPx,this.framedViewportWidthPx),a=gr(this.nodeWidthsPx,this.boundaryCols,this.minScroll,this.viewportWidthPx,this.framedViewportWidthPx),l=Math.max(o,Math.min(a,i));if(Math.abs(l-s)<=Vn)return;let c=this.minScroll,d=this.maxScroll;for(let y=0;y<QR;y+=1){const m=(c+d)/2;gr(this.nodeWidthsPx,this.boundaryCols,m,this.viewportWidthPx,this.framedViewportWidthPx)>l?c=m:d=m}const p=os((c+d)/2,this.minScroll,this.maxScroll);Math.abs(p-this._scroll)<=Nt||(this._scroll=p,this.dispatchEvent(new ss("layout-scroll",{scroll:this.scroll})))}}const Ha={"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}},cD=["stack-above","stack-below","reorder-before","reorder-after"];function qa(t,e){return{left:t.left+t.width*e.left,top:t.top+t.height*e.top,width:t.width*e.width,height:t.height*e.height}}function bn(t,e,n){return t>=n.left&&t<n.left+n.width&&e>=n.top&&e<n.top+n.height}function Gc(t,e){for(const n of t){if(n.type==="card"&&n.id===e)return n;if(n.type==="stack")for(const r of n.children){if(r.type==="card"&&r.id===e)return r;if(r.type==="row"){for(const s of r.children)if(s.id===e)return s}}}return null}function Wl(t){return t.height===He||t.height===sn?{...t,height:sn}:t}function Bl(t){return t.height===sn?{...t,height:He}:t}function uD(t,e,n,r){const s=t.findIndex(d=>d.type==="stack"&&d.id===e);if(s===-1)return t;const i=t[s];if(!i||i.type!=="stack")return t;const o=i.children.find(d=>d.type==="card"&&d.id===n);if(!o||o.type!=="card")return t;const a=i.children.filter(d=>d.id!==n);if(a.length===i.children.length||a.length<1)return t;const l=[...t];if(a.length===1){const[d]=a;l[s]=d.type==="card"?Bl(d):d}else l[s]={...i,children:a};const c=Math.max(0,Math.min(r,l.length));return l.splice(c,0,Bl(o)),l}const hD=et(),dD=et(),pD=50;function fD(t,e){if(t.type!==e.type)return!1;switch(t.type){case"reorder":return e.index===t.index;case"stack":return e.targetCardId===t.targetCardId&&e.position===t.position;case"stack-child-noop":return!0;case"stack-child-extract":return e.toIndex===t.toIndex;case"stack-child-reorder":return e.position===t.position;default:return!1}}function yi(t){return{id:t.id,type:"drop-target",width:t.width,height:t.height}}function Md(t){return t.map(mD)}function gD(t){return t.type==="drop-target"?{id:t.id,type:"card",artifactID:t.id,width:t.width,height:t.height}:t}function mD(t){return t.type==="drop-target"?{id:t.id,type:"card",artifactID:t.id,width:t.width,height:t.height}:t.type==="stack"?{...t,children:t.children.map(gD)}:t}function Fm(t,e){return t.find(r=>r.type==="card"&&r.id===e)??null}function Nd(t,e){return t.find(r=>r.type==="stack"&&r.id===e)??null}function vD(t,e){const n=[...e],r=n.findIndex(a=>a.type==="card"&&a.id===t.nodeId);if(r===-1)return null;const s=n[r];if(!s||s.type!=="card")return null;n.splice(r,1);const i=Math.max(0,Math.min(t.lastReorderIndex,n.length));n.splice(i,0,s);const o=n.findIndex(a=>a.type==="card"&&a.id===t.nodeId);return o===-1?null:{base:n,visualDraggedIndex:o}}function yD(t,e,n,r){const s=[...t.base];s.splice(t.visualDraggedIndex,1);const i=s.findIndex(y=>y.type==="card"&&y.id===n.targetCardId),o=i===-1?null:s[i];if(!o||o.type!=="card")return null;const a=Fm(r,e.nodeId);if(!a)return null;const l=Wl(a),c=Wl(o),d=yi(l),p=n.position==="above"?[d,c]:[c,d];return s[i]={id:o.id,type:"stack",children:p},s}function Ya(t,e){return t.parentStackId?wD(t,e):bD(t,e)}function bD(t,e){const n=t.hitTarget;if(n.type==="reorder"){const r=e[t.sourceIndex];if(!r||r.type!=="card")return[...e];const s=[...e];return s.splice(t.sourceIndex,1),s.splice(n.index,0,yi(r)),s}if(n.type==="stack"){const r=vD(t,e);return r?yD(r,t,n,e)??[...e]:[...e]}return[...e]}function wD(t,e){const n=t.hitTarget;switch(n.type){case"stack-child-reorder":return _D(t,e,n.position);case"stack-child-extract":return SD(t,e,n.toIndex);case"stack-child-noop":return kD(t,e);default:return[...e]}}function _D(t,e,n){const r=e.findIndex(y=>y.type==="stack"&&y.id===t.parentStackId);if(r===-1)return[...e];const s=e[r];if(!s||s.type!=="stack")return[...e];if(!s.children.every(y=>y.type==="card"))return[...e];const i=s.children,o=i.findIndex(y=>y.id===t.nodeId);if(o===-1)return[...e];const a=i[o],l=i.filter(y=>y.id!==t.nodeId),c=yi(a),d=n==="above"?[c,...l]:[...l,c],p=[...e];return p[r]={...s,children:d},p}function SD(t,e,n){if(!t.parentStackId)return[...e];const r=uD(e,t.parentStackId,t.nodeId,n);if(r===e)return[...e];const s=r.findIndex(a=>a.type==="card"&&a.id===t.nodeId);if(s===-1)return[...e];const i=r[s];if(!i||i.type!=="card")return[...e];const o=[...r];return o[s]=yi(i),o}function kD(t,e){const n=e.findIndex(l=>l.type==="stack"&&l.id===t.parentStackId);if(n===-1)return[...e];const r=e[n];if(!r||r.type!=="stack")return[...e];const s=r.children.findIndex(l=>l.type==="card"&&l.id===t.nodeId);if(s===-1)return[...e];const i=r.children[s];if(!i||i.type!=="card")return[...e];const o=[...e],a=[...r.children];return a[s]=yi(i),o[n]={...r,children:a},o}function ED(t,e){return e.find(r=>r.type==="stack"&&r.id===t.id)?t.id:Tc()}function $D(t,e,n){if(t.type==="drop-target"){const r=Gc(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return Wl(r)}return t}function AD(t,e,n){const r=t.children.map(i=>$D(i,e,n));return{id:ED(t,e),type:"stack",children:r}}function xD(t,e,n){if(t.type==="drop-target"){const r=Gc(e,n);if(!r)throw new Error(`finalize: missing dragged card ${n}`);return Fm(e,n)!==null?r:Bl(r)}return t.type==="card"||t.type==="row"?t:AD(t,e,n)}function TD(t,e,n){return t.map(r=>xD(r,e,n))}function CD(t,e){return JSON.stringify(t)===JSON.stringify(e)}const ID=Hr(kt);class PD extends ID{constructor(n={}){super();v(this,"pending",null);v(this,"active",null)}start(n){if(this.pending||this.active)return;const r=n.pointer.x??0,s=n.pointer.y??0;this.pending={startX:r,startY:s,grabOffsetX:n.grabOffset.x??0,grabOffsetY:n.grabOffset.y??0,nodeId:n.nodeId,sourceIndex:n.source.index,parentStackId:n.source.parentId,width:n.size.x??0,height:n.size.y??0,baseLayout:n.layout}}update(n){const r=n.pointer.x??0,s=n.pointer.y??0,i=this.pending;if(i){const c=r-i.startX,d=s-i.startY;Math.hypot(c,d)>=dE&&(this.pending=null,this.active={...i,pointerX:r,pointerY:s,hitTarget:{type:"reorder",index:i.sourceIndex},lastReorderIndex:i.sourceIndex},this.emitDrag(),this.dispatchEvent(new te("change")));return}if(!this.active)return;const o=Ya(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,s,n,o),l=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===s&&fD(this.active.hitTarget,a)&&this.active.lastReorderIndex===l||(this.active={...this.active,pointerX:r,pointerY:s,hitTarget:a,lastReorderIndex:l},this.emitDrag(),this.dispatchEvent(new te("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const n=this.active.baseLayout;let r=null;try{const s=Ya(this.active,n),i=TD(s,n,this.active.nodeId);CD(i,n)||(r=i)}catch{r=null}this.reset(),r&&this.dispatchEvent(new dD("drop",{layout:r})),this.dispatchEvent(new te("change"))}cancel(){!this.pending&&!this.active||(this.reset(),this.dispatchEvent(new te("change")))}dispose(){this.reset()}get status(){return this.active?"active":this.pending?"pending":"idle"}reset(){this.pending=null,this.active=null}emitDrag(){if(!this.active)return;const n=Ya(this.active,this.active.baseLayout);this.dispatchEvent(new hD("drag",{nodeId:this.active.nodeId,source:{index:this.active.sourceIndex,parentId:this.active.parentStackId},grabOffset:Se({x:this.active.grabOffsetX,y:this.active.grabOffsetY}),pointer:Se({x:this.active.pointerX,y:this.active.pointerY}),size:Se({x:this.active.width,y:this.active.height}),projectedLayout:n}))}getHitTargetForPointer(n,r,s,i){return this.active?this.isPointerInsideDragBounds(n,r,s.viewport)?this.active.parentStackId?this.getStackChildHitTarget(n,r,s,i):this.getTopLevelCardHitTarget(n,r,s,i):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(n,r,s,i){var c;if(!((c=this.active)!=null&&c.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(s.geometry);if(o&&bn(n,r,o)){const d=o.top+o.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}const a=this.getSourceRemainingSiblingRect(s.geometry);if(a&&bn(n,r,a)){const d=a.top+a.height/2;return{type:"stack-child-reorder",position:r<d?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(n,r,s,i)}}getSourceRemainingSiblingRect(n){var i,o;if(!((i=this.active)!=null&&i.parentStackId))return;const r=Nd(this.active.baseLayout,this.active.parentStackId);if(!r)return;const s=r.children.find(a=>{var l;return a.type==="card"&&a.id!==((l=this.active)==null?void 0:l.nodeId)});if(s)return(o=n.find(a=>a.id===s.id))==null?void 0:o.rect}getSourceStackInteractionRect(n){var o;if(!((o=this.active)!=null&&o.parentStackId))return;const r=n.find(a=>{var l;return a.id===((l=this.active)==null?void 0:l.parentStackId)});if(r)return this.active.sourceStackRect=r.rect,r.rect;const s=Nd(this.active.baseLayout,this.active.parentStackId);if(!s)return this.active.sourceStackRect;const i=s.children.find(a=>{var l;return a.type==="card"&&a.id!==((l=this.active)==null?void 0:l.nodeId)});if(i){const a=n.find(l=>l.id===i.id);if(a)return a.rect}return this.active.sourceStackRect}getTopLevelCardHitTarget(n,r,s,i){var m,E,k;const o=this.getTopLevelZoneNodes(s.geometry,i);if(o.length===0)return{type:"reorder",index:((m=this.active)==null?void 0:m.sourceIndex)??0};const l=(s.effectiveVelocity??0)<=pD;for(const I of o){const G=I.rect;if(!bn(n,r,G))continue;const N=this.resolveTopLevelTargetForCard(n,r,I,I.logicalIndex,l);if(N)return N;if(!l&&((E=this.active)!=null&&E.hitTarget))return this.active.hitTarget}const c=this.getNearestTargetableZone(n,o);if(!c)return{type:"reorder",index:((k=this.active)==null?void 0:k.sourceIndex)??0};const d=Math.max(c.rect.left,Math.min(c.rect.left+c.rect.width,n)),p=this.resolveTopLevelTargetForCard(d,r,c,c.logicalIndex,l);if(p)return p;const y=c.rect.left+c.rect.width/2;return{type:"reorder",index:n<y?c.logicalIndex:c.logicalIndex+1}}getTopLevelReorderIndexForPointer(n,r,s,i){var c,d;const o=this.getTopLevelZoneNodes(s.geometry,i);if(o.length===0)return((c=this.active)==null?void 0:c.sourceIndex)??0;for(const p of o){if(!bn(n,r,p.rect))continue;const y=qa(p.rect,Ha["reorder-before"]);if(bn(n,r,y))return p.logicalIndex;const m=qa(p.rect,Ha["reorder-after"]);if(bn(n,r,m))return p.logicalIndex+1}const a=this.getNearestTargetableZone(n,o);if(!a)return((d=this.active)==null?void 0:d.sourceIndex)??0;const l=a.rect.left+a.rect.width/2;return n<l?a.logicalIndex:a.logicalIndex+1}getTopLevelZoneNodes(n,r){const s=new Map(r.map(a=>[a.id,a])),i=[];let o=0;for(const a of n){const l=s.get(a.id);l&&l.type!=="drop-target"&&(l.type==="card"||l.type==="stack")&&(i.push({id:l.id,rect:a.rect,logicalIndex:o}),o+=1)}return i}resolveTopLevelTargetForCard(n,r,s,i,o){const a=s.rect;for(const l of cD){if(!o&&(l==="stack-above"||l==="stack-below"))continue;const c=Ha[l],d=qa(a,c);if(bn(n,r,d))return l==="stack-above"?{type:"stack",targetCardId:s.id,position:"above"}:l==="stack-below"?{type:"stack",targetCardId:s.id,position:"below"}:l==="reorder-before"?{type:"reorder",index:i}:{type:"reorder",index:i+1}}return null}getNearestTargetableZone(n,r){let s=null,i=Number.POSITIVE_INFINITY;for(const o of r){const a=o.rect.left,l=o.rect.left+o.rect.width,c=n<a?a-n:n>l?n-l:0;c<i&&(i=c,s=o)}return s}isPointerInsideDragBounds(n,r,s){return n>=s.left&&n<=s.left+s.width&&r>=s.top&&r<=s.top+s.height}}const Ud=60,RD=80,Fd=.5,Zd=10;class DD{constructor(){v(this,"awaitingFreshWheelGesture",!1);v(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);v(this,"lastWheelDeltaX",0);v(this,"activeGestureType","none");v(this,"lastWheelGestureAt",Number.NEGATIVE_INFINITY)}markKeyboardNavigation(e){this.awaitingFreshWheelGesture=!0,this.lastWheelEventAt=e,this.activeGestureType="none"}reset(){this.awaitingFreshWheelGesture=!1,this.lastWheelEventAt=Number.NEGATIVE_INFINITY,this.lastWheelDeltaX=0,this.activeGestureType="none",this.lastWheelGestureAt=Number.NEGATIVE_INFINITY}decide(e){const{now:n,shiftKey:r,deltaX:s,deltaY:i,overArtifactContent:o}=e;n-this.lastWheelGestureAt>=Ud&&(this.activeGestureType="none");const l=r&&i!==0,c=l?i:s,d=Math.abs(c),p=Math.abs(i);return this.activeGestureType==="vertical-artifact"&&o?d>=Fd&&d>=p*Zd?this.classifyHorizontal(n,c):(this.lastWheelGestureAt=n,{type:"scroll-native"}):this.activeGestureType==="horizontal-filmstrip"?!l&&o&&p>0&&p>=d*Zd?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,c):d<Fd?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):l||d>p?this.classifyHorizontal(n,c):p>d?(o&&(this.activeGestureType="vertical-artifact"),this.lastWheelGestureAt=n,{type:"scroll-native"}):o?(this.activeGestureType="vertical-artifact",this.lastWheelGestureAt=n,{type:"scroll-native"}):this.classifyHorizontal(n,c)}classifyHorizontal(e,n){const r=e-this.lastWheelEventAt,s=Math.sign(this.lastWheelDeltaX),i=Math.sign(n),o=s!==0&&i!==0&&s!==i,a=s!==0&&Math.abs(n)>=Math.abs(this.lastWheelDeltaX)+RD;return this.awaitingFreshWheelGesture&&r<Ud&&!o&&!a?{type:"ignore"}:(this.lastWheelEventAt=e,this.lastWheelDeltaX=n,this.lastWheelGestureAt=e,this.awaitingFreshWheelGesture=!1,this.activeGestureType="horizontal-filmstrip",{type:"scroll-horizontal",horizontalDelta:n})}}const OD=2,jd=1e3,ji=1e-4;function Wd(t,e,n){if(t===0)return 0;const r=e.toPixels(xe({y:He})).y??0;return(n-r)/OD}class zD extends Event{constructor(n){super("scroll",{bubbles:!0,composed:!0});v(this,"scrollPosition");this.scrollPosition=n}}class Zm extends Event{constructor(n){super("layout-change",{bubbles:!0,composed:!0});v(this,"layout");this.layout=n}}class LD extends HTMLElement{constructor(){super();v(this,"_layout",[]);v(this,"_scrollPosition",0);v(this,"layoutGrid",null);v(this,"layoutScroll",new lD(xe({x:0})));v(this,"scrollModelKey","");v(this,"resizeObserver",null);v(this,"renderPending",!1);v(this,"animateNextRender",!0);v(this,"wheelGesture",new DD);v(this,"dragController",new PD);v(this,"dragState",null);v(this,"activeDragPointerId",null);v(this,"dragListenersAttached",!1);v(this,"dragFrame",0);v(this,"lastDragFrameTime",0);v(this,"lastPointerX",0);v(this,"lastPointerY",0);v(this,"pointerVelocityPxPerSec",0);v(this,"scrollVelocityPxPerSec",0);v(this,"motionSampleTime",0);v(this,"motionSampleX",0);v(this,"motionSampleY",0);v(this,"dragTrackOffsetXPx",0);v(this,"previousProjectedLayoutForOffset",null);v(this,"renderContent",()=>M``);v(this,"onDragControllerChange",()=>{this.dragController.status==="idle"&&(this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null),this.scheduleRender()});v(this,"onDragControllerDrag",n=>{const r=Md(n.projectedLayout),s=this.shouldApplyTrackOffset(n.projectedLayout,n.source.parentId),i=n.source.parentId?this.getStackChildAnchorCardId(n.source.parentId,n.nodeId):null;this.dragTrackOffsetXPx=s?this.computeDragTrackOffset(this.previousProjectedLayoutForOffset,r,n.nodeId,n.source.parentId,i,this.dragTrackOffsetXPx):0,this.previousProjectedLayoutForOffset=r,this.dragState={nodeId:n.nodeId,source:n.source,grabOffset:n.grabOffset,pointer:n.pointer,size:n.size,projectedLayout:n.projectedLayout},this.scheduleRender()});v(this,"onDragControllerDrop",n=>{this.dragState=null,this.dragTrackOffsetXPx=0,this.previousProjectedLayoutForOffset=null,this.commitLayout(n.layout)});v(this,"onLayoutScrollInternal",n=>{const s=n.scroll.x??0;Math.abs(s-this._scrollPosition)<ji||(this._scrollPosition=s,this.emitScrollPositionChanged(s),this.scheduleRender())});v(this,"handleKeyDown",n=>{if(n.key==="Escape"&&this.dragController.status!=="idle"){n.preventDefault(),this.stopDragFrameLoop(),this.releaseActiveDragPointerCapture(),this.dragController.cancel(),this.detachDragListeners();return}this.dragController.status==="idle"&&(n.key==="ArrowRight"?(n.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(1)):n.key==="ArrowLeft"&&(n.preventDefault(),this.wheelGesture.markKeyboardNavigation(Date.now()),this.shiftWindow(-1)))});v(this,"handleWheel",n=>{if(this._layout.length===0)return;const r=this.wheelGesture.decide({now:Date.now(),shiftKey:n.shiftKey,deltaX:n.deltaX,deltaY:n.deltaY,overArtifactContent:!1});r.type==="scroll-horizontal"&&(n.preventDefault(),this.applyHorizontalWheel(r.horizontalDelta))});v(this,"handleWindowMessage",n=>{var o;if(this._layout.length===0)return;const r=this.findManagedArtifactFrame(n.source);if(!r||!this.isTrustedArtifactFrameMessage(n,r)||!SC(n.data))return;const s=this.wheelGesture.decide({now:Date.now(),shiftKey:n.data.shiftKey,deltaX:n.data.deltaX,deltaY:n.data.deltaY,overArtifactContent:!0});if(s.type==="scroll-horizontal"){this.applyHorizontalWheel(s.horizontalDelta);return}if(s.type!=="scroll-native")return;const i={type:"scroll",deltaX:0,deltaY:n.data.deltaY};(o=r.contentWindow)==null||o.postMessage(i,this.getArtifactFrameTargetOrigin(r))});v(this,"handlePointerDown",n=>{if(n.button!==0||this.dragController.status!=="idle")return;const r=n.target;if(!(r instanceof Element)||!r.closest("[drag-handle]")||r.closest("button, input, textarea, select, a, [role='button']"))return;const s=r.closest(".card-slot");if(!s)return;const i=s.getAttribute("data-layout-node-id");if(!i)return;const o=ND(this._layout,i);if(!o)return;const a=s.getBoundingClientRect();this.lastPointerX=n.clientX,this.lastPointerY=n.clientY,this.resetMotionTracking(n.clientX,n.clientY),this.focus(),this.dragController.start({nodeId:i,source:{index:o.topLevelIndex,parentId:o.sourceStackId},pointer:Se({x:n.clientX,y:n.clientY}),grabOffset:Se({x:n.clientX-a.left,y:n.clientY-a.top}),size:Se({x:a.width,y:a.height}),layout:this._layout}),this.attachDragListeners(),this.activeDragPointerId=n.pointerId;try{this.setPointerCapture(n.pointerId)}catch{}n.preventDefault()});v(this,"handleWindowPointerMove",n=>{this.lastPointerX=n.clientX,this.lastPointerY=n.clientY,this.updatePointerVelocity(n.clientX,n.clientY),this.syncDragTargetForLatestPointer(),this.ensureDragFrameLoop()});v(this,"handleWindowPointerUp",n=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(n.pointerId),this.dragController.drop(),this.clearMotionTracking(),this.detachDragListeners()});v(this,"handleWindowPointerCancel",n=>{this.stopDragFrameLoop(),this.releasePointerCaptureForEvent(n.pointerId),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});v(this,"handleWindowBlur",()=>{this.releaseActiveDragPointerCapture(),this.stopDragFrameLoop(),this.dragController.cancel(),this.clearMotionTracking(),this.detachDragListeners()});v(this,"runDragFrame",n=>{if(this.dragController.status==="idle"){this.dragFrame=0;return}const r=Math.max(0,n-this.lastDragFrameTime)/jd;this.lastDragFrameTime=n,this.samplePointerVelocityAt(n,this.lastPointerX,this.lastPointerY);const s=this.getBoundingClientRect(),i=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,s),o=this.getDragEdgeScrollDeltaPixels(i.x,s,r);this.scrollVelocityPxPerSec=r>ji?Math.abs(o)/r:0,Math.abs(o)>ji&&(this.animateNextRender=!1,this.layoutScroll.wheelPixels(Se({x:o}))),this.dragController.status==="active"&&this.syncDragTarget(i.x,i.y,s),this.dragFrame=requestAnimationFrame(this.runDragFrame)});this.dragController.addEventListener("change",this.onDragControllerChange),this.dragController.addEventListener("drag",this.onDragControllerDrag),this.dragController.addEventListener("drop",this.onDragControllerDrop),this.layoutScroll.addEventListener("layout-scroll",this.onLayoutScrollInternal)}set layout(n){this._layout=[...n],this.stopDragFrameLoop(),this.dragController.cancel(),this.scrollModelKey="",this.syncScrollModel(),this.layoutScroll.scroll=xe({x:this._scrollPosition}),this.scheduleRender()}get layout(){return this._layout}commitLayout(n){this.layout=n,this.emitLayoutChanged()}set scrollPosition(n){Math.abs(n-this._scrollPosition)<ji||(this.animateNextRender=!1,this.syncScrollModel(),this.layoutScroll.scroll=xe({x:n}))}get scrollPosition(){return this._scrollPosition}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.focus(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("pointerdown",this.handlePointerDown),window.addEventListener("message",this.handleWindowMessage),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.render()),this.resizeObserver.observe(this)),this.render()}disconnectedCallback(){var n;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("message",this.handleWindowMessage),(n=this.resizeObserver)==null||n.disconnect(),this.resizeObserver=null,this.wheelGesture.reset(),this.detachDragListeners(),this.dragController.removeEventListener("change",this.onDragControllerChange),this.dragController.removeEventListener("drag",this.onDragControllerDrag),this.dragController.removeEventListener("drop",this.onDragControllerDrop),this.layoutScroll.removeEventListener("layout-scroll",this.onLayoutScrollInternal),this.dragController.dispose(),this.stopDragFrameLoop()}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.render()}))}createGrid(n,r){return new JR({basis:Se({x:kn,y:kn}),min:Se({x:Qh,y:Qh}),viewport:Se({x:n,y:r}),gap:Se({x:de,y:de})})}syncScrollModel(){const n=this.clientWidth>0?this.clientWidth:tn,r=this.clientHeight>0?this.clientHeight:vr,i=$s(this._layout).nodes.map(a=>a.width),o=`${n}x${r}:${i.join(",")}`;o===this.scrollModelKey&&this.layoutGrid||(this.scrollModelKey=o,this.layoutGrid=this.createGrid(n,r),this.layoutScroll.rebuild({grid:this.layoutGrid,nodeWidths:i.map(a=>xe({x:a}))}))}emitScrollPositionChanged(n){this.dispatchEvent(new zD(n))}emitLayoutChanged(){this.dispatchEvent(new Zm([...this._layout]))}shiftWindow(n){this.syncScrollModel(),this.animateNextRender=!0,this.layoutScroll.step(n)}applyHorizontalWheel(n){this.syncScrollModel();const r=this.layoutGrid;if(!r)return;this.animateNextRender=!1;const s=r.toUnits(Se({x:n}));this.layoutScroll.wheel(xe({x:s.x??0}))}findManagedArtifactFrame(n){if(!n)return null;const r=this.querySelectorAll("iframe.artifact-frame");for(const s of r)if(s.contentWindow===n)return s;return null}isTrustedArtifactFrameMessage(n,r){if(n.origin==="null")return!0;const s=this.getArtifactFrameOrigin(r);return s===null||n.origin===s}getArtifactFrameTargetOrigin(n){const r=n.getAttribute("sandbox")??"";return new Set(r.split(/\s+/).filter(Boolean)).has("allow-same-origin")?this.getArtifactFrameOrigin(n)??"*":"*"}getArtifactFrameOrigin(n){const r=n.getAttribute("src")??n.src;if(!r)return null;try{return new URL(r,window.location.href).origin}catch{return null}}releaseActiveDragPointerCapture(){this.activeDragPointerId!==null&&this.releasePointerCaptureForEvent(this.activeDragPointerId)}releasePointerCaptureForEvent(n){try{this.hasPointerCapture(n)&&this.releasePointerCapture(n)}catch{}}attachDragListeners(){this.dragListenersAttached||(window.addEventListener("pointermove",this.handleWindowPointerMove),window.addEventListener("pointerup",this.handleWindowPointerUp),window.addEventListener("pointercancel",this.handleWindowPointerCancel),this.addEventListener("pointermove",this.handleWindowPointerMove),this.addEventListener("pointerup",this.handleWindowPointerUp),this.addEventListener("pointercancel",this.handleWindowPointerCancel),window.addEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!0)}detachDragListeners(){this.dragListenersAttached&&(window.removeEventListener("pointermove",this.handleWindowPointerMove),window.removeEventListener("pointerup",this.handleWindowPointerUp),window.removeEventListener("pointercancel",this.handleWindowPointerCancel),this.removeEventListener("pointermove",this.handleWindowPointerMove),this.removeEventListener("pointerup",this.handleWindowPointerUp),this.removeEventListener("pointercancel",this.handleWindowPointerCancel),window.removeEventListener("blur",this.handleWindowBlur),this.dragListenersAttached=!1,this.activeDragPointerId=null)}getDisplayModel(){if(this.dragController.status!=="active"||!this.dragState)return{layout:this._layout,activePlaceholderId:null,placeholdersById:new Map};const n=new Map;return n.set(this.dragState.nodeId,{id:this.dragState.nodeId,sourceCardId:this.dragState.nodeId}),{layout:Md(this.dragState.projectedLayout),activePlaceholderId:this.dragState.nodeId,placeholdersById:n}}render(){const n=this.clientWidth>0?this.clientWidth:tn,r=this.clientHeight>0?this.clientHeight:vr,s=this.createGrid(n,r);this.layoutGrid=s;const i=this.getDisplayModel(),o=i.layout,a=this.dragController.status==="active",l=$s(o),c=l.nodes.map(L=>L.width),d=`${n}x${r}:${c.join(",")}`;!a&&d!==this.scrollModelKey&&(this.scrollModelKey=d,this.layoutScroll.rebuild({grid:s,nodeWidths:c.map(L=>xe({x:L}))}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const p=MD(o),y=s.unit.x??kn,m=s.unit.y??kn,E=a?this.dragTrackOffsetXPx:0,k=(this.layoutScroll.translate.x??0)+E,I=Wd(l.nodes.length,s,r),G=this.animateNextRender&&!a,N=[`transform: translate(${k}px, ${I}px);`,`transition-duration: ${G?hE:0}ms;`,`pointer-events: ${a?"none":"auto"};`].join(" ");this.animateNextRender=!0,this.style.setProperty("--layout-unit-x",`${y}px`),this.style.setProperty("--layout-unit-y",`${m}px`),this.style.setProperty("--layout-gap",`${de}px`);const j=this.dragState,F={width:(j==null?void 0:j.size.x)??0,height:(j==null?void 0:j.size.y)??0};be(M`
|
|
153
|
-
<div class="track" style=${N}>
|
|
154
|
-
${l.nodes.map((L,J)=>M`
|
|
155
|
-
<div
|
|
156
|
-
class="node"
|
|
157
|
-
layout-node=${String(J)}
|
|
158
|
-
data-layout-node-id=${L.id}
|
|
159
|
-
data-layout-placeholder=${String(i.activePlaceholderId===L.id)}
|
|
160
|
-
layout-node-cols=${String(L.width)}
|
|
161
|
-
style=${`grid-template-columns: repeat(${L.width}, var(--layout-unit-x)); width: ${s.toPixels(xe({x:L.width})).x}px;`}
|
|
162
|
-
>
|
|
163
|
-
${L.cards.map(H=>{const he=i.placeholdersById.get(H.id);if(j&&he)return M`
|
|
164
|
-
<div
|
|
165
|
-
class="card-slot card-placeholder"
|
|
166
|
-
data-layout-placeholder-for=${j.nodeId}
|
|
167
|
-
data-layout-placeholder-ghost="false"
|
|
168
|
-
data-layout-source-stack=${j.source.parentId??""}
|
|
169
|
-
style=${`grid-column: ${H.col} / span ${H.width}; grid-row: ${H.row} / span ${H.height};`}
|
|
170
|
-
></div>
|
|
171
|
-
`;const lt=p.get(H.id);return lt?M`
|
|
172
|
-
<div
|
|
173
|
-
class="card-slot"
|
|
174
|
-
data-layout-card-id=${H.artifactID}
|
|
175
|
-
data-layout-node-id=${H.id}
|
|
176
|
-
layout-cols=${String(H.width)}
|
|
177
|
-
layout-rows=${String(H.height)}
|
|
178
|
-
style=${`grid-column: ${H.col} / span ${H.width}; grid-row: ${H.row} / span ${H.height};`}
|
|
179
|
-
>
|
|
180
|
-
${this.renderContent(lt,{isDragging:!1})}
|
|
181
|
-
</div>
|
|
182
|
-
`:null})}
|
|
183
|
-
</div>
|
|
184
|
-
`)}
|
|
185
|
-
</div>
|
|
186
|
-
${j?(()=>{const L=this.getPlaceholderPixelSize(l,i.activePlaceholderId,s,F),J=j.pointer.x??0,H=j.pointer.y??0,he=j.grabOffset.x??0,lt=j.grabOffset.y??0;return M`
|
|
187
|
-
<div
|
|
188
|
-
class="drag-preview"
|
|
189
|
-
data-layout-preview-card-id=${j.nodeId}
|
|
190
|
-
style=${[`width: ${L.width}px;`,`height: ${L.height}px;`,`left: ${J-he}px;`,`top: ${H-lt}px;`].join(" ")}
|
|
191
|
-
>
|
|
192
|
-
${this.renderDraggedPreview(j.nodeId)}
|
|
193
|
-
</div>
|
|
194
|
-
`})():null}
|
|
195
|
-
`,this)}ensureDragFrameLoop(){this.dragFrame!==0||this.dragController.status==="idle"||(this.lastDragFrameTime=performance.now(),this.dragFrame=requestAnimationFrame(this.runDragFrame))}stopDragFrameLoop(){this.dragFrame!==0&&(cancelAnimationFrame(this.dragFrame),this.dragFrame=0,this.scrollVelocityPxPerSec=0)}syncDragTargetForLatestPointer(){if(this.dragController.status==="idle")return;const n=this.getBoundingClientRect();if(this.dragController.status==="active"){const s=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,n);this.syncDragTarget(s.x,s.y,n);return}if(this.syncDragTarget(this.lastPointerX,this.lastPointerY,n),this.dragController.status==="pending")return;const r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,n);(r.x!==this.lastPointerX||r.y!==this.lastPointerY)&&this.syncDragTarget(r.x,r.y,n)}syncDragTarget(n,r,s=this.getBoundingClientRect()){if(this.dragController.status==="idle")return;const i=this.getDisplayModel(),o=new Set(i.placeholdersById.keys()),a=this.dragController.status==="active"?this.dragTrackOffsetXPx:0,l=this.measureLayoutGeometry(i.layout,o,a);this.dragController.update({pointer:Se({x:n,y:r}),viewport:{left:s.left,top:s.top,width:s.width,height:s.height},geometry:l,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(n,r){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=n,this.motionSampleY=r}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(n,r){this.samplePointerVelocityAt(performance.now(),n,r)}samplePointerVelocityAt(n,r,s){if(this.motionSampleTime===0){this.motionSampleTime=n,this.motionSampleX=r,this.motionSampleY=s,this.pointerVelocityPxPerSec=0;return}const i=n-this.motionSampleTime;if(i<100)return;const o=r-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/i*jd,this.motionSampleTime=n,this.motionSampleX=r,this.motionSampleY=s}clampPointerToViewport(n,r,s){return{x:Math.max(s.left,Math.min(s.left+s.width,n)),y:Math.max(s.top,Math.min(s.top+s.height,r))}}isPointerOutsideViewport(n,r,s){return n<s.left||n>s.left+s.width||r<s.top||r>s.top+s.height}getDragEdgeScrollDeltaPixels(n,r,s){var c;const i=r.left+Li,o=r.left+r.width-Li,a=((c=this.layoutGrid)==null?void 0:c.unit.x)??kn,l=pE*a;if(n<i){const d=Math.max(0,Math.min(1,(i-n)/Li));return-(l*d**ed)*s}if(n>o){const d=Math.max(0,Math.min(1,(n-o)/Li));return l*d**ed*s}return 0}measureLayoutGeometry(n,r,s=0){const i=this.layoutGrid;if(!i)return[];const o=$s(n),a=new Map(o.nodes.map(E=>[E.id,E.width])),l=i.toPixels(xe({y:He})).y??vr,c=this.clientHeight>0?this.clientHeight:vr,d=(this.layoutScroll.translate.x??0)+s,p=Wd(o.nodes.length,i,c),y=[];let m=d;for(const E of n){const k=a.get(E.id)??St,I=i.toPixels(xe({x:k})).x??tn,G={left:m,top:p,width:I,height:l};y.push({id:E.id,rect:G}),m+=I+de}return y}getPlaceholderPixelSize(n,r,s,i){if(!r)return i;for(const o of n.nodes)for(const a of o.cards)if(a.id===r)return{width:s.toPixels(xe({x:a.width})).x??i.width,height:s.toPixels(xe({y:a.height})).y??i.height};return i}renderDraggedPreview(n){const r=Gc(this._layout,n);return r?this.renderContent(r,{isDragging:!0}):M``}shouldApplyTrackOffset(n,r){if(r)return!0;for(const s of n){if(s.type!=="stack")continue;if(s.children.some(o=>o.type==="drop-target")&&r!==s.id)return!0}return!1}computeDragTrackOffset(n,r,s,i,o,a){if(!n)return a;const l=i?o??this.getStableAnchorCardId(n,r,s):this.getStableAnchorNodeId(n,r,s);if(!l)return a;const c=i?Gd(n,l,this.layoutGrid):Vd(n,l,this.layoutGrid),d=i?Gd(r,l,this.layoutGrid):Vd(r,l,this.layoutGrid);return c===null||d===null?a:a+(c-d)}getStableAnchorCardId(n,r,s){const i=Bd(n),o=new Set(Bd(r));for(const a of i)if(a!==s&&o.has(a))return a;return null}getStableAnchorNodeId(n,r,s){const i=new Set(r.map(o=>o.id));for(const o of n)if(o.id!==s&&i.has(o.id))return o.id;return null}getStackChildAnchorCardId(n,r){const s=this._layout.find(o=>o.type==="stack"&&o.id===n);if(!s||s.type!=="stack")return null;const i=s.children.find(o=>o.type==="card"&&o.id!==r);return(i==null?void 0:i.id)??null}}function MD(t){const e=new Map;for(const n of t){if(n.type==="card"){e.set(n.id,n);continue}for(const r of n.children)if(r.type==="card")e.set(r.id,r);else for(const s of r.children)e.set(s.id,s)}return e}function ND(t,e){const n=t.findIndex(r=>r.type==="card"&&r.id===e);if(n!==-1)return{topLevelIndex:n};for(let r=0;r<t.length;r+=1){const s=t[r];if(!(!s||s.type!=="stack")&&s.children.some(i=>i.type==="card"&&i.id===e))return{topLevelIndex:r,sourceStackId:s.id}}return null}function Bd(t){const e=[];for(const n of t){if(n.type==="card"){e.push(n.id);continue}if(n.type==="stack"){const r=n.children.find(s=>s.type==="card");r&&e.push(r.id)}}return e}function Gd(t,e,n){if(!n)return null;const r=$s(t),s=new Map(r.nodes.map(o=>[o.id,o.width]));let i=0;for(const o of t){if(o.type==="card"&&o.id===e||o.type==="stack"&&o.children.some(c=>c.type==="card"&&c.id===e))return i;const a=s.get(o.id)??St,l=n.toPixels(xe({x:a})).x??tn;i+=l+de}return null}function Vd(t,e,n){if(!n)return null;const r=$s(t),s=new Map(r.nodes.map(o=>[o.id,o.width]));let i=0;for(const o of t){if(o.id===e)return i;const a=s.get(o.id)??St,l=n.toPixels(xe({x:a})).x??tn;i+=l+de}return null}customElements.get("layout-view")||customElements.define("layout-view",LD);class UD extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ve.resolve("ScreenManager"));v(this,"boundModel",null);v(this,"handleActiveScreenChanged",()=>{this.rebindModel(),this.render()});v(this,"handleModelChange",()=>{this.render()});v(this,"handleCloseArtifact",n=>{n instanceof zm&&this.screenManager.activeScreen&&this.screenManager.activeScreen.removeArtifact(n.artifactID)});v(this,"handleScrollPositionChanged",n=>{const r=n;typeof r.scrollPosition=="number"&&Number.isFinite(r.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(r.scrollPosition)});v(this,"handleLayoutChanged",n=>{n instanceof Zm&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setLayout(n.layout)})}connectedCallback(){this.screenManager.addEventListener("active-screen-changed",this.handleActiveScreenChanged),this.rebindModel(),this.render()}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveScreenChanged),this.unbindModel()}rebindModel(){const n=this.screenManager.activeScreen;this.boundModel!==n&&(this.unbindModel(),this.boundModel=n,n&&n.addEventListener("change",this.handleModelChange))}unbindModel(){this.boundModel&&(this.boundModel.removeEventListener("change",this.handleModelChange),this.boundModel=null)}buildArtifactMap(){const n=this.screenManager.activeScreen;return n?new Map(n.artifacts):new Map}render(){const n=this.screenManager.activeScreen,r=(n==null?void 0:n.layout)??[],s=this.buildArtifactMap();if(r.length===0){be(M`<p data-testid="empty-screen">No artifacts yet.</p>`,this);return}be(M`
|
|
196
|
-
<layout-view
|
|
197
|
-
.layout=${r}
|
|
198
|
-
.renderContent=${(o,a)=>{const l=s.get(o.artifactID);return!l||!n?M``:M`<artifact-view
|
|
199
|
-
.artifact=${l}
|
|
200
|
-
.screen=${n}
|
|
201
|
-
.viewURL=${n.server.getViewURL(l)}
|
|
202
|
-
.contentURL=${n.server.getContentURL(l.id)}
|
|
203
|
-
.dragging=${a.isDragging}
|
|
204
|
-
></artifact-view>`}}
|
|
205
|
-
.scrollPosition=${(n==null?void 0:n.scrollPosition)??0}
|
|
206
|
-
@scroll=${this.handleScrollPositionChanged}
|
|
207
|
-
@layout-change=${this.handleLayoutChanged}
|
|
208
|
-
@close-artifact=${this.handleCloseArtifact}
|
|
209
|
-
></layout-view>
|
|
210
|
-
`,this)}}customElements.define("screen-view",UD);const Ka=new WeakMap,Hd=Object.prototype.hasOwnProperty,FD=(()=>{const t=new Set;let e=HTMLElement.prototype;for(;e;){for(const n of Object.getOwnPropertyNames(e))t.add(n);if(e===Node.prototype)break;e=Object.getPrototypeOf(e)}return t})();function ZD(t,e){if(t===Boolean)return e!==null;if(e!==null)return t===Number?Number(e):e}var ni,Gl,Fn,Ye,wt,Ir,Zn,Pr,Ce,ws,jm,Wm,Bm,so;const An=class An extends HTMLElement{constructor(){var s;super();$(this,Ce);$(this,Fn,new Map);$(this,Ye,new Map);$(this,wt,new Map);$(this,Ir,!1);$(this,Zn,!1);$(this,Pr,!1);const n=b(s=An,ni,Gl).call(s,this.constructor),r=this;for(const i of n.properties)Hd.call(r,i)&&(u(this,wt).set(i,r[i]),delete r[i])}static get observedAttributes(){var n;return b(n=An,ni,Gl).call(n,this).observedAttributes}connected(){}disconnected(){}changed(n){}connectedCallback(){if(b(this,Ce,Bm).call(this),!u(this,Zn))for(const n of b(this,Ce,ws).call(this).properties)u(this,Ye).has(n)||u(this,Ye).set(n,void 0);this.dispatchEvent(new Event("reactive:connect")),this.connected(),b(this,Ce,so).call(this)}disconnectedCallback(){this.dispatchEvent(new Event("reactive:disconnect")),this.disconnected()}attributeChangedCallback(n,r,s){if(r===s)return;const i=b(this,Ce,ws).call(this).byAttr.get(n);i&&(u(this,wt).has(i.property)||(this[i.property]=ZD(i.type,s)))}};ni=new WeakSet,Gl=function(n){const r=Ka.get(n);if(r)return r;const s=[...n.properties??[]],i=n.attributes??{},o=new Map,a=new Map;for(const c of s)if(FD.has(c))throw new Error(`Reactive property "${c}" collides with a built-in DOM property. Rename it to avoid shadowing the platform API.`);for(const[c,d]of Object.entries(i)){if(c.includes("-")&&d.property===void 0)throw new Error(`Attribute "${c}" must declare a "property" name because kebab-case cannot be a property.`);const p=d.property??c;if(!s.includes(p))throw new Error(`Attribute '${c}' references property '${p}', which isn't declared in \`static properties\`. Add it to \`properties\` to make it reactive.`);const y={attribute:c,property:p,type:d.type};o.set(c,y),a.set(p,y)}for(const c of s){const d=Object.getOwnPropertyDescriptor(n.prototype,c);if((d==null?void 0:d.get)!==void 0||(d==null?void 0:d.set)!==void 0)throw new Error(`Observed property "${c}" cannot define a custom getter/setter. Use changed() for side effects instead.`);d===void 0&&Object.defineProperty(n.prototype,c,{configurable:!0,enumerable:!0,get(){return u(this,Fn).get(c)},set(p){b(this,Ce,jm).call(this,c,p)}})}const l={properties:s,observedAttributes:Object.keys(i),byAttr:o,byProp:a};return Ka.set(n,l),l},Fn=new WeakMap,Ye=new WeakMap,wt=new WeakMap,Ir=new WeakMap,Zn=new WeakMap,Pr=new WeakMap,Ce=new WeakSet,ws=function(){return Ka.get(this.constructor)},jm=function(n,r){if(!u(this,Pr)&&u(this,wt).has(n))return;const s=u(this,Fn).get(n);Object.is(s,r)||(u(this,Ye).has(n)||u(this,Ye).set(n,s),u(this,Fn).set(n,r),u(this,wt).delete(n),b(this,Ce,Wm).call(this,n,r),this.isConnected&&b(this,Ce,so).call(this))},Wm=function(n,r){const s=b(this,Ce,ws).call(this).byProp.get(n);if(!s)return;const{attribute:i,type:o}=s;if(o===Boolean){const l=this.hasAttribute(i);r&&!l?this.setAttribute(i,""):!r&&l&&this.removeAttribute(i);return}if(r==null){this.hasAttribute(i)&&this.removeAttribute(i);return}const a=String(r);this.getAttribute(i)!==a&&this.setAttribute(i,a)},Bm=function(){const n=this,r=b(this,Ce,ws).call(this);for(const s of r.properties){if(!Hd.call(n,s))continue;const i=n[s];delete n[s],!(u(this,wt).has(s)||u(this,Fn).has(s))&&(n[s]=i)}x(this,Pr,!0);try{for(const[s,i]of u(this,wt))n[s]=i;u(this,wt).clear()}finally{x(this,Pr,!1)}},so=function(){u(this,Ir)||!this.isConnected||u(this,Zn)&&u(this,Ye).size===0||(x(this,Ir,!0),queueMicrotask(()=>{if(x(this,Ir,!1),!this.isConnected||u(this,Zn)&&u(this,Ye).size===0)return;const n=new Map(u(this,Ye));u(this,Ye).clear(),x(this,Zn,!0);try{this.changed(n)}catch(r){console.error(r)}this.isConnected&&u(this,Ye).size>0&&b(this,Ce,so).call(this)}))},$(An,ni),v(An,"properties"),v(An,"attributes");let Rs=An;function jD(t,e){let n=null;const r=()=>e((n==null?void 0:n.messages)??[]),s=()=>{const o=t.getActiveClient();o!==n&&(n==null||n.removeEventListener("change",r),n=o,n&&(n.addEventListener("change",r),n.connect().catch(a=>{console.error("ACPClient.connect() failed",a)})),r())};t.addEventListener("change",s),s();const i=()=>{t.removeEventListener("change",s),n==null||n.removeEventListener("change",r),n=null};return{dispose:i,[Symbol.dispose](){i()}}}/*! @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:Gm,setPrototypeOf:qd,isFrozen:WD,getPrototypeOf:BD,getOwnPropertyDescriptor:GD}=Object;let{freeze:ze,seal:Xe,create:io}=Object,{apply:Vl,construct:Hl}=typeof Reflect<"u"&&Reflect;ze||(ze=function(e){return e});Xe||(Xe=function(e){return e});Vl||(Vl=function(e,n){for(var r=arguments.length,s=new Array(r>2?r-2:0),i=2;i<r;i++)s[i-2]=arguments[i];return e.apply(n,s)});Hl||(Hl=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return new e(...r)});const Wi=Le(Array.prototype.forEach),VD=Le(Array.prototype.lastIndexOf),Yd=Le(Array.prototype.pop),as=Le(Array.prototype.push),HD=Le(Array.prototype.splice),oo=Le(String.prototype.toLowerCase),Ja=Le(String.prototype.toString),Xa=Le(String.prototype.match),ls=Le(String.prototype.replace),qD=Le(String.prototype.indexOf),YD=Le(String.prototype.trim),Ge=Le(Object.prototype.hasOwnProperty),Pe=Le(RegExp.prototype.test),cs=KD(TypeError);function Le(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return Vl(t,e,r)}}function KD(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Hl(t,n)}}function W(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:oo;qd&&qd(t,null);let r=e.length;for(;r--;){let s=e[r];if(typeof s=="string"){const i=n(s);i!==s&&(WD(e)||(e[r]=i),s=i)}t[s]=!0}return t}function JD(t){for(let e=0;e<t.length;e++)Ge(t,e)||(t[e]=null);return t}function ft(t){const e=io(null);for(const[n,r]of Gm(t))Ge(t,n)&&(Array.isArray(r)?e[n]=JD(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=ft(r):e[n]=r);return e}function us(t,e){for(;t!==null;){const r=GD(t,e);if(r){if(r.get)return Le(r.get);if(typeof r.value=="function")return Le(r.value)}t=BD(t)}function n(){return null}return n}const Kd=ze(["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"]),Qa=ze(["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"]),el=ze(["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"]),XD=ze(["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"]),tl=ze(["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"]),QD=ze(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Jd=ze(["#text"]),Xd=ze(["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"]),nl=ze(["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"]),Qd=ze(["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"]),Bi=ze(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),eO=Xe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),tO=Xe(/<%[\w\W]*|[\w\W]*%>/gm),nO=Xe(/\$\{[\w\W]*/gm),rO=Xe(/^data-[\-\w.\u00B7-\uFFFF]+$/),sO=Xe(/^aria-[\-\w]+$/),Vm=Xe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),iO=Xe(/^(?:\w+script|data):/i),oO=Xe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Hm=Xe(/^html$/i),aO=Xe(/^[a-z][.\w]*(-[.\w]+)+$/i);var ep=Object.freeze({__proto__:null,ARIA_ATTR:sO,ATTR_WHITESPACE:oO,CUSTOM_ELEMENT:aO,DATA_ATTR:rO,DOCTYPE_NAME:Hm,ERB_EXPR:tO,IS_ALLOWED_URI:Vm,IS_SCRIPT_OR_DATA:iO,MUSTACHE_EXPR:eO,TMPLIT_EXPR:nO});const hs={element:1,text:3,progressingInstruction:7,comment:8,document:9},lO=function(){return typeof window>"u"?null:window},cO=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(r=n.getAttribute(s));const i="dompurify"+(r?"#"+r:"");try{return e.createPolicy(i,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},tp=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function qm(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:lO();const e=z=>qm(z);if(e.version="3.3.3",e.removed=[],!t||!t.document||t.document.nodeType!==hs.document||!t.Element)return e.isSupported=!1,e;let{document:n}=t;const r=n,s=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:c,NamedNodeMap:d=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:p,DOMParser:y,trustedTypes:m}=t,E=l.prototype,k=us(E,"cloneNode"),I=us(E,"remove"),G=us(E,"nextSibling"),N=us(E,"childNodes"),j=us(E,"parentNode");if(typeof o=="function"){const z=n.createElement("template");z.content&&z.content.ownerDocument&&(n=z.content.ownerDocument)}let F,L="";const{implementation:J,createNodeIterator:H,createDocumentFragment:he,getElementsByTagName:lt}=n,{importNode:wi}=r;let Ee=tp();e.isSupported=typeof Gm=="function"&&typeof j=="function"&&J&&J.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:gn,ERB_EXPR:ct,TMPLIT_EXPR:Wt,DATA_ATTR:ea,ARIA_ATTR:_i,IS_SCRIPT_OR_DATA:mv,ATTR_WHITESPACE:ru,CUSTOM_ELEMENT:vv}=ep;let{IS_ALLOWED_URI:su}=ep,we=null;const iu=W({},[...Kd,...Qa,...el,...tl,...Jd]);let $e=null;const ou=W({},[...Xd,...nl,...Qd,...Bi]);let pe=Object.seal(io(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}})),Xr=null,Si=null;const Bt=Object.seal(io(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let au=!0,ta=!0,lu=!1,cu=!0,Qn=!1,ki=!0,mn=!1,na=!1,ra=!1,er=!1,Ei=!1,$i=!1,uu=!0,hu=!1;const yv="user-content-";let sa=!0,Qr=!1,tr={},ut=null;const ia=W({},["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 du=null;const pu=W({},["audio","video","img","source","image","track"]);let oa=null;const fu=W({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ai="http://www.w3.org/1998/Math/MathML",xi="http://www.w3.org/2000/svg",Et="http://www.w3.org/1999/xhtml";let nr=Et,aa=!1,la=null;const bv=W({},[Ai,xi,Et],Ja);let Ti=W({},["mi","mo","mn","ms","mtext"]),Ci=W({},["annotation-xml"]);const wv=W({},["title","style","font","a","script"]);let es=null;const _v=["application/xhtml+xml","text/html"],Sv="text/html";let ve=null,rr=null;const kv=n.createElement("form"),gu=function(g){return g instanceof RegExp||g instanceof Function},ca=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(rr&&rr===g)){if((!g||typeof g!="object")&&(g={}),g=ft(g),es=_v.indexOf(g.PARSER_MEDIA_TYPE)===-1?Sv:g.PARSER_MEDIA_TYPE,ve=es==="application/xhtml+xml"?Ja:oo,we=Ge(g,"ALLOWED_TAGS")?W({},g.ALLOWED_TAGS,ve):iu,$e=Ge(g,"ALLOWED_ATTR")?W({},g.ALLOWED_ATTR,ve):ou,la=Ge(g,"ALLOWED_NAMESPACES")?W({},g.ALLOWED_NAMESPACES,Ja):bv,oa=Ge(g,"ADD_URI_SAFE_ATTR")?W(ft(fu),g.ADD_URI_SAFE_ATTR,ve):fu,du=Ge(g,"ADD_DATA_URI_TAGS")?W(ft(pu),g.ADD_DATA_URI_TAGS,ve):pu,ut=Ge(g,"FORBID_CONTENTS")?W({},g.FORBID_CONTENTS,ve):ia,Xr=Ge(g,"FORBID_TAGS")?W({},g.FORBID_TAGS,ve):ft({}),Si=Ge(g,"FORBID_ATTR")?W({},g.FORBID_ATTR,ve):ft({}),tr=Ge(g,"USE_PROFILES")?g.USE_PROFILES:!1,au=g.ALLOW_ARIA_ATTR!==!1,ta=g.ALLOW_DATA_ATTR!==!1,lu=g.ALLOW_UNKNOWN_PROTOCOLS||!1,cu=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Qn=g.SAFE_FOR_TEMPLATES||!1,ki=g.SAFE_FOR_XML!==!1,mn=g.WHOLE_DOCUMENT||!1,er=g.RETURN_DOM||!1,Ei=g.RETURN_DOM_FRAGMENT||!1,$i=g.RETURN_TRUSTED_TYPE||!1,ra=g.FORCE_BODY||!1,uu=g.SANITIZE_DOM!==!1,hu=g.SANITIZE_NAMED_PROPS||!1,sa=g.KEEP_CONTENT!==!1,Qr=g.IN_PLACE||!1,su=g.ALLOWED_URI_REGEXP||Vm,nr=g.NAMESPACE||Et,Ti=g.MATHML_TEXT_INTEGRATION_POINTS||Ti,Ci=g.HTML_INTEGRATION_POINTS||Ci,pe=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&gu(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(pe.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&gu(g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(pe.attributeNameCheck=g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),g.CUSTOM_ELEMENT_HANDLING&&typeof g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(pe.allowCustomizedBuiltInElements=g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Qn&&(ta=!1),Ei&&(er=!0),tr&&(we=W({},Jd),$e=io(null),tr.html===!0&&(W(we,Kd),W($e,Xd)),tr.svg===!0&&(W(we,Qa),W($e,nl),W($e,Bi)),tr.svgFilters===!0&&(W(we,el),W($e,nl),W($e,Bi)),tr.mathMl===!0&&(W(we,tl),W($e,Qd),W($e,Bi))),Ge(g,"ADD_TAGS")||(Bt.tagCheck=null),Ge(g,"ADD_ATTR")||(Bt.attributeCheck=null),g.ADD_TAGS&&(typeof g.ADD_TAGS=="function"?Bt.tagCheck=g.ADD_TAGS:(we===iu&&(we=ft(we)),W(we,g.ADD_TAGS,ve))),g.ADD_ATTR&&(typeof g.ADD_ATTR=="function"?Bt.attributeCheck=g.ADD_ATTR:($e===ou&&($e=ft($e)),W($e,g.ADD_ATTR,ve))),g.ADD_URI_SAFE_ATTR&&W(oa,g.ADD_URI_SAFE_ATTR,ve),g.FORBID_CONTENTS&&(ut===ia&&(ut=ft(ut)),W(ut,g.FORBID_CONTENTS,ve)),g.ADD_FORBID_CONTENTS&&(ut===ia&&(ut=ft(ut)),W(ut,g.ADD_FORBID_CONTENTS,ve)),sa&&(we["#text"]=!0),mn&&W(we,["html","head","body"]),we.table&&(W(we,["tbody"]),delete Xr.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw cs('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw cs('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');F=g.TRUSTED_TYPES_POLICY,L=F.createHTML("")}else F===void 0&&(F=cO(m,s)),F!==null&&typeof L=="string"&&(L=F.createHTML(""));ze&&ze(g),rr=g}},mu=W({},[...Qa,...el,...XD]),vu=W({},[...tl,...QD]),Ev=function(g){let T=j(g);(!T||!T.tagName)&&(T={namespaceURI:nr,tagName:"template"});const P=oo(g.tagName),se=oo(T.tagName);return la[g.namespaceURI]?g.namespaceURI===xi?T.namespaceURI===Et?P==="svg":T.namespaceURI===Ai?P==="svg"&&(se==="annotation-xml"||Ti[se]):!!mu[P]:g.namespaceURI===Ai?T.namespaceURI===Et?P==="math":T.namespaceURI===xi?P==="math"&&Ci[se]:!!vu[P]:g.namespaceURI===Et?T.namespaceURI===xi&&!Ci[se]||T.namespaceURI===Ai&&!Ti[se]?!1:!vu[P]&&(wv[P]||!mu[P]):!!(es==="application/xhtml+xml"&&la[g.namespaceURI]):!1},ht=function(g){as(e.removed,{element:g});try{j(g).removeChild(g)}catch{I(g)}},vn=function(g,T){try{as(e.removed,{attribute:T.getAttributeNode(g),from:T})}catch{as(e.removed,{attribute:null,from:T})}if(T.removeAttribute(g),g==="is")if(er||Ei)try{ht(T)}catch{}else try{T.setAttribute(g,"")}catch{}},yu=function(g){let T=null,P=null;if(ra)g="<remove></remove>"+g;else{const fe=Xa(g,/^[\r\n\t ]+/);P=fe&&fe[0]}es==="application/xhtml+xml"&&nr===Et&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const se=F?F.createHTML(g):g;if(nr===Et)try{T=new y().parseFromString(se,es)}catch{}if(!T||!T.documentElement){T=J.createDocument(nr,"template",null);try{T.documentElement.innerHTML=aa?L:se}catch{}}const Ie=T.body||T.documentElement;return g&&P&&Ie.insertBefore(n.createTextNode(P),Ie.childNodes[0]||null),nr===Et?lt.call(T,mn?"html":"body")[0]:mn?T.documentElement:Ie},bu=function(g){return H.call(g.ownerDocument||g,g,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ua=function(g){return g instanceof p&&(typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||!(g.attributes instanceof d)||typeof g.removeAttribute!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function")},wu=function(g){return typeof a=="function"&&g instanceof a};function $t(z,g,T){Wi(z,P=>{P.call(e,g,T,rr)})}const _u=function(g){let T=null;if($t(Ee.beforeSanitizeElements,g,null),ua(g))return ht(g),!0;const P=ve(g.nodeName);if($t(Ee.uponSanitizeElement,g,{tagName:P,allowedTags:we}),ki&&g.hasChildNodes()&&!wu(g.firstElementChild)&&Pe(/<[/\w!]/g,g.innerHTML)&&Pe(/<[/\w!]/g,g.textContent)||g.nodeType===hs.progressingInstruction||ki&&g.nodeType===hs.comment&&Pe(/<[/\w]/g,g.data))return ht(g),!0;if(!(Bt.tagCheck instanceof Function&&Bt.tagCheck(P))&&(!we[P]||Xr[P])){if(!Xr[P]&&ku(P)&&(pe.tagNameCheck instanceof RegExp&&Pe(pe.tagNameCheck,P)||pe.tagNameCheck instanceof Function&&pe.tagNameCheck(P)))return!1;if(sa&&!ut[P]){const se=j(g)||g.parentNode,Ie=N(g)||g.childNodes;if(Ie&&se){const fe=Ie.length;for(let Me=fe-1;Me>=0;--Me){const At=k(Ie[Me],!0);At.__removalCount=(g.__removalCount||0)+1,se.insertBefore(At,G(g))}}}return ht(g),!0}return g instanceof l&&!Ev(g)||(P==="noscript"||P==="noembed"||P==="noframes")&&Pe(/<\/no(script|embed|frames)/i,g.innerHTML)?(ht(g),!0):(Qn&&g.nodeType===hs.text&&(T=g.textContent,Wi([gn,ct,Wt],se=>{T=ls(T,se," ")}),g.textContent!==T&&(as(e.removed,{element:g.cloneNode()}),g.textContent=T)),$t(Ee.afterSanitizeElements,g,null),!1)},Su=function(g,T,P){if(Si[T]||uu&&(T==="id"||T==="name")&&(P in n||P in kv))return!1;if(!(ta&&!Si[T]&&Pe(ea,T))){if(!(au&&Pe(_i,T))){if(!(Bt.attributeCheck instanceof Function&&Bt.attributeCheck(T,g))){if(!$e[T]||Si[T]){if(!(ku(g)&&(pe.tagNameCheck instanceof RegExp&&Pe(pe.tagNameCheck,g)||pe.tagNameCheck instanceof Function&&pe.tagNameCheck(g))&&(pe.attributeNameCheck instanceof RegExp&&Pe(pe.attributeNameCheck,T)||pe.attributeNameCheck instanceof Function&&pe.attributeNameCheck(T,g))||T==="is"&&pe.allowCustomizedBuiltInElements&&(pe.tagNameCheck instanceof RegExp&&Pe(pe.tagNameCheck,P)||pe.tagNameCheck instanceof Function&&pe.tagNameCheck(P))))return!1}else if(!oa[T]){if(!Pe(su,ls(P,ru,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&g!=="script"&&qD(P,"data:")===0&&du[g])){if(!(lu&&!Pe(mv,ls(P,ru,"")))){if(P)return!1}}}}}}}return!0},ku=function(g){return g!=="annotation-xml"&&Xa(g,vv)},Eu=function(g){$t(Ee.beforeSanitizeAttributes,g,null);const{attributes:T}=g;if(!T||ua(g))return;const P={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$e,forceKeepAttr:void 0};let se=T.length;for(;se--;){const Ie=T[se],{name:fe,namespaceURI:Me,value:At}=Ie,sr=ve(fe),ha=At;let Ae=fe==="value"?ha:YD(ha);if(P.attrName=sr,P.attrValue=Ae,P.keepAttr=!0,P.forceKeepAttr=void 0,$t(Ee.uponSanitizeAttribute,g,P),Ae=P.attrValue,hu&&(sr==="id"||sr==="name")&&(vn(fe,g),Ae=yv+Ae),ki&&Pe(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ae)){vn(fe,g);continue}if(sr==="attributename"&&Xa(Ae,"href")){vn(fe,g);continue}if(P.forceKeepAttr)continue;if(!P.keepAttr){vn(fe,g);continue}if(!cu&&Pe(/\/>/i,Ae)){vn(fe,g);continue}Qn&&Wi([gn,ct,Wt],Au=>{Ae=ls(Ae,Au," ")});const $u=ve(g.nodeName);if(!Su($u,sr,Ae)){vn(fe,g);continue}if(F&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Me)switch(m.getAttributeType($u,sr)){case"TrustedHTML":{Ae=F.createHTML(Ae);break}case"TrustedScriptURL":{Ae=F.createScriptURL(Ae);break}}if(Ae!==ha)try{Me?g.setAttributeNS(Me,fe,Ae):g.setAttribute(fe,Ae),ua(g)?ht(g):Yd(e.removed)}catch{vn(fe,g)}}$t(Ee.afterSanitizeAttributes,g,null)},$v=function z(g){let T=null;const P=bu(g);for($t(Ee.beforeSanitizeShadowDOM,g,null);T=P.nextNode();)$t(Ee.uponSanitizeShadowNode,T,null),_u(T),Eu(T),T.content instanceof i&&z(T.content);$t(Ee.afterSanitizeShadowDOM,g,null)};return e.sanitize=function(z){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,P=null,se=null,Ie=null;if(aa=!z,aa&&(z="<!-->"),typeof z!="string"&&!wu(z))if(typeof z.toString=="function"){if(z=z.toString(),typeof z!="string")throw cs("dirty is not a string, aborting")}else throw cs("toString is not a function");if(!e.isSupported)return z;if(na||ca(g),e.removed=[],typeof z=="string"&&(Qr=!1),Qr){if(z.nodeName){const At=ve(z.nodeName);if(!we[At]||Xr[At])throw cs("root node is forbidden and cannot be sanitized in-place")}}else if(z instanceof a)T=yu("<!---->"),P=T.ownerDocument.importNode(z,!0),P.nodeType===hs.element&&P.nodeName==="BODY"||P.nodeName==="HTML"?T=P:T.appendChild(P);else{if(!er&&!Qn&&!mn&&z.indexOf("<")===-1)return F&&$i?F.createHTML(z):z;if(T=yu(z),!T)return er?null:$i?L:""}T&&ra&&ht(T.firstChild);const fe=bu(Qr?z:T);for(;se=fe.nextNode();)_u(se),Eu(se),se.content instanceof i&&$v(se.content);if(Qr)return z;if(er){if(Ei)for(Ie=he.call(T.ownerDocument);T.firstChild;)Ie.appendChild(T.firstChild);else Ie=T;return($e.shadowroot||$e.shadowrootmode)&&(Ie=wi.call(r,Ie,!0)),Ie}let Me=mn?T.outerHTML:T.innerHTML;return mn&&we["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&Pe(Hm,T.ownerDocument.doctype.name)&&(Me="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
|
|
211
|
-
`+Me),Qn&&Wi([gn,ct,Wt],At=>{Me=ls(Me,At," ")}),F&&$i?F.createHTML(Me):Me},e.setConfig=function(){let z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ca(z),na=!0},e.clearConfig=function(){rr=null,na=!1},e.isValidAttribute=function(z,g,T){rr||ca({});const P=ve(z),se=ve(g);return Su(P,se,T)},e.addHook=function(z,g){typeof g=="function"&&as(Ee[z],g)},e.removeHook=function(z,g){if(g!==void 0){const T=VD(Ee[z],g);return T===-1?void 0:HD(Ee[z],T,1)[0]}return Yd(Ee[z])},e.removeHooks=function(z){Ee[z]=[]},e.removeAllHooks=function(){Ee=tp()},e}var Ym=qm();function Vc(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Xn=Vc();function Km(t){Xn=t}var $n={exec:()=>null};function q(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(s,i)=>{let o=typeof i=="string"?i:i.source;return o=o.replace(Oe.caret,"$1"),n=n.replace(s,o),r},getRegex:()=>new RegExp(n,e)};return r}var uO=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Oe={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},hO=/^(?:[ \t]*(?:\n|$))+/,dO=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,pO=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,bi=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,fO=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Hc=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Jm=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Xm=q(Jm).replace(/bull/g,Hc).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(),gO=q(Jm).replace(/bull/g,Hc).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(),qc=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,mO=/^[^\n]+/,Yc=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,vO=q(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Yc).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),yO=q(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Hc).getRegex(),Jo="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",Kc=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,bO=q("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Kc).replace("tag",Jo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Qm=q(qc).replace("hr",bi).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",Jo).getRegex(),wO=q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Qm).getRegex(),Jc={blockquote:wO,code:dO,def:vO,fences:pO,heading:fO,hr:bi,html:bO,lheading:Xm,list:yO,newline:hO,paragraph:Qm,table:$n,text:mO},np=q("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",bi).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",Jo).getRegex(),_O={...Jc,lheading:gO,table:np,paragraph:q(qc).replace("hr",bi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",np).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",Jo).getRegex()},SO={...Jc,html:q(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Kc).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:$n,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:q(qc).replace("hr",bi).replace("heading",` *#{1,6} *[^
|
|
212
|
-
]`).replace("lheading",Xm).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},kO=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,EO=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ev=/^( {2,}|\\)\n(?!\s*$)/,$O=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Jr=/[\p{P}\p{S}]/u,Xo=/[\s\p{P}\p{S}]/u,Xc=/[^\s\p{P}\p{S}]/u,AO=q(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Xo).getRegex(),tv=/(?!~)[\p{P}\p{S}]/u,xO=/(?!~)[\s\p{P}\p{S}]/u,TO=/(?:[^\s\p{P}\p{S}]|~)/u,CO=q(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",uO?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),nv=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,IO=q(nv,"u").replace(/punct/g,Jr).getRegex(),PO=q(nv,"u").replace(/punct/g,tv).getRegex(),rv="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",RO=q(rv,"gu").replace(/notPunctSpace/g,Xc).replace(/punctSpace/g,Xo).replace(/punct/g,Jr).getRegex(),DO=q(rv,"gu").replace(/notPunctSpace/g,TO).replace(/punctSpace/g,xO).replace(/punct/g,tv).getRegex(),OO=q("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Xc).replace(/punctSpace/g,Xo).replace(/punct/g,Jr).getRegex(),zO=q(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Jr).getRegex(),LO="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",MO=q(LO,"gu").replace(/notPunctSpace/g,Xc).replace(/punctSpace/g,Xo).replace(/punct/g,Jr).getRegex(),NO=q(/\\(punct)/,"gu").replace(/punct/g,Jr).getRegex(),UO=q(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),FO=q(Kc).replace("(?:-->|$)","-->").getRegex(),ZO=q("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",FO).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),_o=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,jO=q(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",_o).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),sv=q(/^!?\[(label)\]\[(ref)\]/).replace("label",_o).replace("ref",Yc).getRegex(),iv=q(/^!?\[(ref)\](?:\[\])?/).replace("ref",Yc).getRegex(),WO=q("reflink|nolink(?!\\()","g").replace("reflink",sv).replace("nolink",iv).getRegex(),rp=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Qc={_backpedal:$n,anyPunctuation:NO,autolink:UO,blockSkip:CO,br:ev,code:EO,del:$n,delLDelim:$n,delRDelim:$n,emStrongLDelim:IO,emStrongRDelimAst:RO,emStrongRDelimUnd:OO,escape:kO,link:jO,nolink:iv,punctuation:AO,reflink:sv,reflinkSearch:WO,tag:ZO,text:$O,url:$n},BO={...Qc,link:q(/^!?\[(label)\]\((.*?)\)/).replace("label",_o).getRegex(),reflink:q(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",_o).getRegex()},ql={...Qc,emStrongRDelimAst:DO,emStrongLDelim:PO,delLDelim:zO,delRDelim:MO,url:q(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",rp).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:q(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",rp).getRegex()},GO={...ql,br:q(ev).replace("{2,}","*").getRegex(),text:q(ql.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Gi={normal:Jc,gfm:_O,pedantic:SO},ds={normal:Qc,gfm:ql,breaks:GO,pedantic:BO},VO={"&":"&","<":"<",">":">",'"':""","'":"'"},sp=t=>VO[t];function gt(t,e){if(e){if(Oe.escapeTest.test(t))return t.replace(Oe.escapeReplace,sp)}else if(Oe.escapeTestNoEncode.test(t))return t.replace(Oe.escapeReplaceNoEncode,sp);return t}function ip(t){try{t=encodeURI(t).replace(Oe.percentDecode,"%")}catch{return null}return t}function op(t,e){var i;let n=t.replace(Oe.findPipe,(o,a,l)=>{let c=!1,d=a;for(;--d>=0&&l[d]==="\\";)c=!c;return c?"|":" |"}),r=n.split(Oe.splitPipe),s=0;if(r[0].trim()||r.shift(),r.length>0&&!((i=r.at(-1))!=null&&i.trim())&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;s<r.length;s++)r[s]=r[s].trim().replace(Oe.slashPipe,"|");return r}function ps(t,e,n){let r=t.length;if(r===0)return"";let s=0;for(;s<r&&t.charAt(r-s-1)===e;)s++;return t.slice(0,r-s)}function HO(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function qO(t,e=0){let n=e,r="";for(let s of t)if(s===" "){let i=4-n%4;r+=" ".repeat(i),n+=i}else r+=s,n++;return r}function ap(t,e,n,r,s){let i=e.href,o=e.title||null,a=t[1].replace(s.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,l}function YO(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let s=r[1];return e.split(`
|
|
213
|
-
`).map(i=>{let o=i.match(n.other.beginningSpace);if(o===null)return i;let[a]=o;return a.length>=s.length?i.slice(s.length):i}).join(`
|
|
214
|
-
`)}var So=class{constructor(t){v(this,"options");v(this,"rules");v(this,"lexer");this.options=t||Xn}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:ps(n,`
|
|
215
|
-
`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=YO(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=ps(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:ps(e[0],`
|
|
216
|
-
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=ps(e[0],`
|
|
217
|
-
`).split(`
|
|
218
|
-
`),r="",s="",i=[];for(;n.length>0;){let o=!1,a=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))a.push(n[l]),o=!0;else if(!o)a.push(n[l]);else break;n=n.slice(l);let c=a.join(`
|
|
219
|
-
`),d=c.replace(this.rules.other.blockquoteSetextReplace,`
|
|
220
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
221
|
-
${c}`:c,s=s?`${s}
|
|
222
|
-
${d}`:d;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,i,!0),this.lexer.state.top=p,n.length===0)break;let y=i.at(-1);if((y==null?void 0:y.type)==="code")break;if((y==null?void 0:y.type)==="blockquote"){let m=y,E=m.raw+`
|
|
223
|
-
`+n.join(`
|
|
224
|
-
`),k=this.blockquote(E);i[i.length-1]=k,r=r.substring(0,r.length-m.raw.length)+k.raw,s=s.substring(0,s.length-m.text.length)+k.text;break}else if((y==null?void 0:y.type)==="list"){let m=y,E=m.raw+`
|
|
225
|
-
`+n.join(`
|
|
226
|
-
`),k=this.list(E);i[i.length-1]=k,r=r.substring(0,r.length-y.raw.length)+k.raw,s=s.substring(0,s.length-m.raw.length)+k.raw,n=E.substring(i.at(-1).raw.length).split(`
|
|
227
|
-
`);continue}}return{type:"blockquote",raw:r,tokens:i,text:s}}}list(t){var n,r;let e=this.rules.block.list.exec(t);if(e){let s=e[1].trim(),i=s.length>1,o={type:"list",raw:"",ordered:i,start:i?+s.slice(0,-1):"",loose:!1,items:[]};s=i?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=i?s:"[*+-]");let a=this.rules.other.listItemRegex(s),l=!1;for(;t;){let d=!1,p="",y="";if(!(e=a.exec(t))||this.rules.block.hr.test(t))break;p=e[0],t=t.substring(p.length);let m=qO(e[2].split(`
|
|
228
|
-
`,1)[0],e[1].length),E=t.split(`
|
|
229
|
-
`,1)[0],k=!m.trim(),I=0;if(this.options.pedantic?(I=2,y=m.trimStart()):k?I=e[1].length+1:(I=m.search(this.rules.other.nonSpaceChar),I=I>4?1:I,y=m.slice(I),I+=e[1].length),k&&this.rules.other.blankLine.test(E)&&(p+=E+`
|
|
230
|
-
`,t=t.substring(E.length+1),d=!0),!d){let G=this.rules.other.nextBulletRegex(I),N=this.rules.other.hrRegex(I),j=this.rules.other.fencesBeginRegex(I),F=this.rules.other.headingBeginRegex(I),L=this.rules.other.htmlBeginRegex(I),J=this.rules.other.blockquoteBeginRegex(I);for(;t;){let H=t.split(`
|
|
231
|
-
`,1)[0],he;if(E=H,this.options.pedantic?(E=E.replace(this.rules.other.listReplaceNesting," "),he=E):he=E.replace(this.rules.other.tabCharGlobal," "),j.test(E)||F.test(E)||L.test(E)||J.test(E)||G.test(E)||N.test(E))break;if(he.search(this.rules.other.nonSpaceChar)>=I||!E.trim())y+=`
|
|
232
|
-
`+he.slice(I);else{if(k||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||j.test(m)||F.test(m)||N.test(m))break;y+=`
|
|
233
|
-
`+E}k=!E.trim(),p+=H+`
|
|
234
|
-
`,t=t.substring(H.length+1),m=he.slice(I)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(l=!0)),o.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(y),loose:!1,text:y,tokens:[]}),o.raw+=p}let c=o.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let d of o.items){if(this.lexer.state.top=!1,d.tokens=this.lexer.blockTokens(d.text,[]),d.task){if(d.text=d.text.replace(this.rules.other.listReplaceTask,""),((n=d.tokens[0])==null?void 0:n.type)==="text"||((r=d.tokens[0])==null?void 0:r.type)==="paragraph"){d.tokens[0].raw=d.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),d.tokens[0].text=d.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let y=this.lexer.inlineQueue.length-1;y>=0;y--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[y].src)){this.lexer.inlineQueue[y].src=this.lexer.inlineQueue[y].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(d.raw);if(p){let y={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};d.checked=y.checked,o.loose?d.tokens[0]&&["paragraph","text"].includes(d.tokens[0].type)&&"tokens"in d.tokens[0]&&d.tokens[0].tokens?(d.tokens[0].raw=y.raw+d.tokens[0].raw,d.tokens[0].text=y.raw+d.tokens[0].text,d.tokens[0].tokens.unshift(y)):d.tokens.unshift({type:"paragraph",raw:y.raw,text:y.raw,tokens:[y]}):d.tokens.unshift(y)}}if(!o.loose){let p=d.tokens.filter(m=>m.type==="space"),y=p.length>0&&p.some(m=>this.rules.other.anyLine.test(m.raw));o.loose=y}}if(o.loose)for(let d of o.items){d.loose=!0;for(let p of d.tokens)p.type==="text"&&(p.type="paragraph")}return o}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:r,title:s}}}table(t){var o;let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=op(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=(o=e[3])!=null&&o.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
235
|
-
`):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?i.align.push("right"):this.rules.other.tableAlignCenter.test(a)?i.align.push("center"):this.rules.other.tableAlignLeft.test(a)?i.align.push("left"):i.align.push(null);for(let a=0;a<n.length;a++)i.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:i.align[a]});for(let a of s)i.rows.push(op(a,i.header.length).map((l,c)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:i.align[c]})));return i}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
|
|
236
|
-
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=ps(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=HO(e[2],"()");if(i===-2)return;if(i>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let r=e[2],s="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(r);i&&(r=i[1],s=i[3])}else s=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),ap(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=e[r.toLowerCase()];if(!s){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return ap(n,s,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let s=[...r[0]].length-1,i,o,a=s,l=0,c=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,e=e.slice(-1*t.length+s);(r=c.exec(e))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(o=[...i].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&s%3&&!((s+o)%3)){l+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+l);let d=[...r[0]][0].length,p=t.slice(0,s+r.index+d+o);if(Math.min(s,o)%2){let m=p.slice(1,-1);return{type:"em",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}let y=p.slice(2,-2);return{type:"strong",raw:p,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&s&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let r=this.rules.inline.delLDelim.exec(t);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let s=[...r[0]].length-1,i,o,a=s,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*t.length+s);(r=l.exec(e))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(o=[...i].length,o!==s))continue;if(r[3]||r[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let c=[...r[0]][0].length,d=t.slice(0,s+r.index+c+o),p=d.slice(s,-s);return{type:"del",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){var n;let e;if(e=this.rules.inline.url.exec(t)){let r,s;if(e[2]==="@")r=e[0],s="mailto:"+r;else{let i;do i=e[0],e[0]=((n=this.rules.inline._backpedal.exec(e[0]))==null?void 0:n[0])??"";while(i!==e[0]);r=e[0],e[1]==="www."?s="http://"+e[0]:s=e[0]}return{type:"link",raw:e[0],text:r,href:s,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},ot=class Yl{constructor(e){v(this,"tokens");v(this,"options");v(this,"state");v(this,"inlineQueue");v(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Xn,this.options.tokenizer=this.options.tokenizer||new So,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:Oe,block:Gi.normal,inline:ds.normal};this.options.pedantic?(n.block=Gi.pedantic,n.inline=ds.pedantic):this.options.gfm&&(n.block=Gi.gfm,this.options.breaks?n.inline=ds.breaks:n.inline=ds.gfm),this.tokenizer.rules=n}static get rules(){return{block:Gi,inline:ds}}static lex(e,n){return new Yl(n).lex(e)}static lexInline(e,n){return new Yl(n).inlineTokens(e)}lex(e){e=e.replace(Oe.carriageReturn,`
|
|
237
|
-
`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){var s,i,o;for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Oe.tabCharGlobal," ").replace(Oe.spaceLine,""));e;){let a;if((i=(s=this.options.extensions)==null?void 0:s.block)!=null&&i.some(c=>(a=c.call({lexer:this},e,n))?(e=e.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.space(e)){e=e.substring(a.raw.length);let c=n.at(-1);a.raw.length===1&&c!==void 0?c.raw+=`
|
|
238
|
-
`:n.push(a);continue}if(a=this.tokenizer.code(e)){e=e.substring(a.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
239
|
-
`)?"":`
|
|
240
|
-
`)+a.raw,c.text+=`
|
|
241
|
-
`+a.text,this.inlineQueue.at(-1).src=c.text):n.push(a);continue}if(a=this.tokenizer.fences(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.heading(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.hr(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.blockquote(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.list(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.html(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.def(e)){e=e.substring(a.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
242
|
-
`)?"":`
|
|
243
|
-
`)+a.raw,c.text+=`
|
|
244
|
-
`+a.raw,this.inlineQueue.at(-1).src=c.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},n.push(a));continue}if(a=this.tokenizer.table(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.lheading(e)){e=e.substring(a.raw.length),n.push(a);continue}let l=e;if((o=this.options.extensions)!=null&&o.startBlock){let c=1/0,d=e.slice(1),p;this.options.extensions.startBlock.forEach(y=>{p=y.call({lexer:this},d),typeof p=="number"&&p>=0&&(c=Math.min(c,p))}),c<1/0&&c>=0&&(l=e.substring(0,c+1))}if(this.state.top&&(a=this.tokenizer.paragraph(l))){let c=n.at(-1);r&&(c==null?void 0:c.type)==="paragraph"?(c.raw+=(c.raw.endsWith(`
|
|
245
|
-
`)?"":`
|
|
246
|
-
`)+a.raw,c.text+=`
|
|
247
|
-
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(a),r=l.length!==e.length,e=e.substring(a.raw.length);continue}if(a=this.tokenizer.text(e)){e=e.substring(a.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
248
|
-
`)?"":`
|
|
249
|
-
`)+a.raw,c.text+=`
|
|
250
|
-
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(a);continue}if(e){let c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){var l,c,d,p,y;this.tokenizer.lexer=this;let r=e,s=null;if(this.tokens.links){let m=Object.keys(this.tokens.links);if(m.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)m.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,s.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)i=s[2]?s[2].length:0,r=r.slice(0,s.index+i)+"["+"a".repeat(s[0].length-i-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=((c=(l=this.options.hooks)==null?void 0:l.emStrongMask)==null?void 0:c.call({lexer:this},r))??r;let o=!1,a="";for(;e;){o||(a=""),o=!1;let m;if((p=(d=this.options.extensions)==null?void 0:d.inline)!=null&&p.some(k=>(m=k.call({lexer:this},e,n))?(e=e.substring(m.raw.length),n.push(m),!0):!1))continue;if(m=this.tokenizer.escape(e)){e=e.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.tag(e)){e=e.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.link(e)){e=e.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(m.raw.length);let k=n.at(-1);m.type==="text"&&(k==null?void 0:k.type)==="text"?(k.raw+=m.raw,k.text+=m.text):n.push(m);continue}if(m=this.tokenizer.emStrong(e,r,a)){e=e.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.codespan(e)){e=e.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.br(e)){e=e.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.del(e,r,a)){e=e.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.autolink(e)){e=e.substring(m.raw.length),n.push(m);continue}if(!this.state.inLink&&(m=this.tokenizer.url(e))){e=e.substring(m.raw.length),n.push(m);continue}let E=e;if((y=this.options.extensions)!=null&&y.startInline){let k=1/0,I=e.slice(1),G;this.options.extensions.startInline.forEach(N=>{G=N.call({lexer:this},I),typeof G=="number"&&G>=0&&(k=Math.min(k,G))}),k<1/0&&k>=0&&(E=e.substring(0,k+1))}if(m=this.tokenizer.inlineText(E)){e=e.substring(m.raw.length),m.raw.slice(-1)!=="_"&&(a=m.raw.slice(-1)),o=!0;let k=n.at(-1);(k==null?void 0:k.type)==="text"?(k.raw+=m.raw,k.text+=m.text):n.push(m);continue}if(e){let k="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(k);break}else throw new Error(k)}}return n}},ko=class{constructor(t){v(this,"options");v(this,"parser");this.options=t||Xn}space(t){return""}code({text:t,lang:e,escaped:n}){var i;let r=(i=(e||"").match(Oe.notSpaceStart))==null?void 0:i[0],s=t.replace(Oe.endingNewline,"")+`
|
|
251
|
-
`;return r?'<pre><code class="language-'+gt(r)+'">'+(n?s:gt(s,!0))+`</code></pre>
|
|
252
|
-
`:"<pre><code>"+(n?s:gt(s,!0))+`</code></pre>
|
|
253
|
-
`}blockquote({tokens:t}){return`<blockquote>
|
|
254
|
-
${this.parser.parse(t)}</blockquote>
|
|
255
|
-
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
256
|
-
`}hr(t){return`<hr>
|
|
257
|
-
`}list(t){let e=t.ordered,n=t.start,r="";for(let o=0;o<t.items.length;o++){let a=t.items[o];r+=this.listitem(a)}let s=e?"ol":"ul",i=e&&n!==1?' start="'+n+'"':"";return"<"+s+i+`>
|
|
258
|
-
`+r+"</"+s+`>
|
|
259
|
-
`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
|
|
260
|
-
`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
|
|
261
|
-
`}table(t){let e="",n="";for(let s=0;s<t.header.length;s++)n+=this.tablecell(t.header[s]);e+=this.tablerow({text:n});let r="";for(let s=0;s<t.rows.length;s++){let i=t.rows[s];n="";for(let o=0;o<i.length;o++)n+=this.tablecell(i[o]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
262
|
-
<thead>
|
|
263
|
-
`+e+`</thead>
|
|
264
|
-
`+r+`</table>
|
|
265
|
-
`}tablerow({text:t}){return`<tr>
|
|
266
|
-
${t}</tr>
|
|
267
|
-
`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
268
|
-
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${gt(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),s=ip(t);if(s===null)return r;t=s;let i='<a href="'+t+'"';return e&&(i+=' title="'+gt(e)+'"'),i+=">"+r+"</a>",i}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let s=ip(t);if(s===null)return gt(n);t=s;let i=`<img src="${t}" alt="${gt(n)}"`;return e&&(i+=` title="${gt(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:gt(t.text)}},eu=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},at=class Kl{constructor(e){v(this,"options");v(this,"renderer");v(this,"textRenderer");this.options=e||Xn,this.options.renderer=this.options.renderer||new ko,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new eu}static parse(e,n){return new Kl(n).parse(e)}static parseInline(e,n){return new Kl(n).parseInline(e)}parse(e){var r,s;this.renderer.parser=this;let n="";for(let i=0;i<e.length;i++){let o=e[i];if((s=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&s[o.type]){let l=o,c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){n+=c||"";continue}}let a=o;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let l='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return n}parseInline(e,n=this.renderer){var s,i;this.renderer.parser=this;let r="";for(let o=0;o<e.length;o++){let a=e[o];if((i=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&i[a.type]){let c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=c||"";continue}}let l=a;switch(l.type){case"escape":{r+=n.text(l);break}case"html":{r+=n.html(l);break}case"link":{r+=n.link(l);break}case"image":{r+=n.image(l);break}case"checkbox":{r+=n.checkbox(l);break}case"strong":{r+=n.strong(l);break}case"em":{r+=n.em(l);break}case"codespan":{r+=n.codespan(l);break}case"br":{r+=n.br(l);break}case"del":{r+=n.del(l);break}case"text":{r+=n.text(l);break}default:{let c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return r}},Vi,_s=(Vi=class{constructor(t){v(this,"options");v(this,"block");this.options=t||Xn}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?ot.lex:ot.lexInline}provideParser(){return this.block?at.parse:at.parseInline}},v(Vi,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),v(Vi,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Vi),KO=class{constructor(...t){v(this,"defaults",Vc());v(this,"options",this.setOptions);v(this,"parse",this.parseMarkdown(!0));v(this,"parseInline",this.parseMarkdown(!1));v(this,"Parser",at);v(this,"Renderer",ko);v(this,"TextRenderer",eu);v(this,"Lexer",ot);v(this,"Tokenizer",So);v(this,"Hooks",_s);this.use(...t)}walkTokens(t,e){var r,s;let n=[];for(let i of t)switch(n=n.concat(e.call(this,i)),i.type){case"table":{let o=i;for(let a of o.header)n=n.concat(this.walkTokens(a.tokens,e));for(let a of o.rows)for(let l of a)n=n.concat(this.walkTokens(l.tokens,e));break}case"list":{let o=i;n=n.concat(this.walkTokens(o.items,e));break}default:{let o=i;(s=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&s[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let l=o[a].flat(1/0);n=n.concat(this.walkTokens(l,e))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let i=e.renderers[s.name];i?e.renderers[s.name]=function(...o){let a=s.renderer.apply(this,o);return a===!1&&(a=i.apply(this,o)),a}:e.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[s.level];i?i.unshift(s.tokenizer):e[s.level]=[s.tokenizer],s.start&&(s.level==="block"?e.startBlock?e.startBlock.push(s.start):e.startBlock=[s.start]:s.level==="inline"&&(e.startInline?e.startInline.push(s.start):e.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(e.childTokens[s.name]=s.childTokens)}),r.extensions=e),n.renderer){let s=this.defaults.renderer||new ko(this.defaults);for(let i in n.renderer){if(!(i in s))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let o=i,a=n.renderer[o],l=s[o];s[o]=(...c)=>{let d=a.apply(s,c);return d===!1&&(d=l.apply(s,c)),d||""}}r.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new So(this.defaults);for(let i in n.tokenizer){if(!(i in s))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let o=i,a=n.tokenizer[o],l=s[o];s[o]=(...c)=>{let d=a.apply(s,c);return d===!1&&(d=l.apply(s,c)),d}}r.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new _s;for(let i in n.hooks){if(!(i in s))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let o=i,a=n.hooks[o],l=s[o];_s.passThroughHooks.has(i)?s[o]=c=>{if(this.defaults.async&&_s.passThroughHooksRespectAsync.has(i))return(async()=>{let p=await a.call(s,c);return l.call(s,p)})();let d=a.call(s,c);return l.call(s,d)}:s[o]=(...c)=>{if(this.defaults.async)return(async()=>{let p=await a.apply(s,c);return p===!1&&(p=await l.apply(s,c)),p})();let d=a.apply(s,c);return d===!1&&(d=l.apply(s,c)),d}}r.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(o){let a=[];return a.push(i.call(this,o)),s&&(a=a.concat(s.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return ot.lex(t,e??this.defaults)}parser(t,e){return at.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},s={...this.defaults,...r},i=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&r.async===!1)return i(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 i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=t),s.async)return(async()=>{let o=s.hooks?await s.hooks.preprocess(e):e,a=await(s.hooks?await s.hooks.provideLexer():t?ot.lex:ot.lexInline)(o,s),l=s.hooks?await s.hooks.processAllTokens(a):a;s.walkTokens&&await Promise.all(this.walkTokens(l,s.walkTokens));let c=await(s.hooks?await s.hooks.provideParser():t?at.parse:at.parseInline)(l,s);return s.hooks?await s.hooks.postprocess(c):c})().catch(i);try{s.hooks&&(e=s.hooks.preprocess(e));let o=(s.hooks?s.hooks.provideLexer():t?ot.lex:ot.lexInline)(e,s);s.hooks&&(o=s.hooks.processAllTokens(o)),s.walkTokens&&this.walkTokens(o,s.walkTokens);let a=(s.hooks?s.hooks.provideParser():t?at.parse:at.parseInline)(o,s);return s.hooks&&(a=s.hooks.postprocess(a)),a}catch(o){return i(o)}}}onError(t,e){return n=>{if(n.message+=`
|
|
269
|
-
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+gt(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Hn=new KO;function X(t,e){return Hn.parse(t,e)}X.options=X.setOptions=function(t){return Hn.setOptions(t),X.defaults=Hn.defaults,Km(X.defaults),X};X.getDefaults=Vc;X.defaults=Xn;X.use=function(...t){return Hn.use(...t),X.defaults=Hn.defaults,Km(X.defaults),X};X.walkTokens=function(t,e){return Hn.walkTokens(t,e)};X.parseInline=Hn.parseInline;X.Parser=at;X.parser=at.parse;X.Renderer=ko;X.TextRenderer=eu;X.Lexer=ot;X.lexer=ot.lex;X.Tokenizer=So;X.Hooks=_s;X.parse=X;X.options;X.setOptions;X.use;X.walkTokens;X.parseInline;at.parse;ot.lex;Ym.addHook("afterSanitizeAttributes",t=>{t.tagName==="A"&&(t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer"))});function JO(t){const e=X.parse(t,{async:!1});return Ym.sanitize(e,{USE_PROFILES:{html:!0}})}const XO=8,lp=new WeakMap;function QO(t){const e=lp.get(t);if(e&&e.text===t.text)return e.html;const n=JO(t.text);return lp.set(t,{text:t.text,html:n}),n}function cp(t){for(let e=t.length-1;e>=0;e-=1){const n=t[e];if(n&&n.kind==="user")return n.id}return null}var Mt,jn,Io,Po,ri,Jl;class ov extends Rs{constructor(){super(...arguments);$(this,ri);v(this,"messages",[]);$(this,Mt,!0);$(this,jn,null);$(this,Io,()=>{const n=u(this,jn);if(!n)return;const s=n.scrollHeight-n.clientHeight-n.scrollTop<=XO;s!==u(this,Mt)&&(x(this,Mt,s),this.toggleAttribute("data-pinned",s))});$(this,Po,()=>{x(this,Mt,!0),this.toggleAttribute("data-pinned",!0),b(this,ri,Jl).call(this,!0)})}changed(n){let r=!1;if(n.has("messages")){const s=n.get("messages")??[],i=cp(this.messages);r=i!==null&&i!==cp(s),r&&x(this,Mt,!0)}be(this.template(),this),u(this,jn)||x(this,jn,this.querySelector(".history-scroll")),this.toggleAttribute("data-pinned",u(this,Mt)),b(this,ri,Jl).call(this,r)}template(){const n=this.messages.filter(r=>r.kind==="user"||r.kind==="assistant");return M`
|
|
270
|
-
<div class="history-scroll" @scroll=${u(this,Io)}>
|
|
271
|
-
${n.map(r=>{const s=r.kind==="assistant"?TR(QO(r)):r.text;return M`<div
|
|
272
|
-
class="message message-${r.kind}"
|
|
273
|
-
data-message-id=${r.id}
|
|
274
|
-
>${s}</div>`})}
|
|
275
|
-
</div>
|
|
276
|
-
<button
|
|
277
|
-
type="button"
|
|
278
|
-
class="history-jump"
|
|
279
|
-
aria-label="Jump to latest message"
|
|
280
|
-
@click=${u(this,Po)}
|
|
281
|
-
>
|
|
282
|
-
${wm({size:16})}
|
|
283
|
-
</button>
|
|
284
|
-
`}}Mt=new WeakMap,jn=new WeakMap,Io=new WeakMap,Po=new WeakMap,ri=new WeakSet,Jl=function(n){requestAnimationFrame(()=>{const r=u(this,jn);r&&(!u(this,Mt)&&!n||(r.scrollTop=r.scrollHeight-r.clientHeight))})},v(ov,"properties",["messages"]);customElements.define("message-history",ov);const ez=et();var un,Ql,ec,si,ii;class Xl extends Rs{constructor(){super(...arguments);$(this,un);v(this,"placeholder","What do you want to do?");v(this,"open",!1);v(this,"messages",[]);v(this,"handleTriggerActivate",()=>{this.open=!0});v(this,"handleKeydown",n=>{if(n.key!=="Enter"||n.shiftKey)return;const r=n.currentTarget,s=r.value.trim();n.preventDefault(),s&&(r.value="",this.dispatchEvent(new ez("command-submit",{value:s,bubbles:!0,composed:!0})))});$(this,si,n=>{n.target instanceof Node&&(this.contains(n.target)||(this.open=!1))});$(this,ii,n=>{n.key==="Escape"&&(this.open=!1)})}connected(){this.open&&b(this,un,Ql).call(this)}disconnected(){b(this,un,ec).call(this)}changed(n){if(be(this.template(),this),n.has("open"))if(this.open){b(this,un,Ql).call(this);const r=this.querySelector("textarea");r==null||r.focus()}else b(this,un,ec).call(this)}template(){return this.open?M`
|
|
285
|
-
<message-history .messages=${this.messages}></message-history>
|
|
286
|
-
<textarea
|
|
287
|
-
class="input"
|
|
288
|
-
rows="1"
|
|
289
|
-
placeholder=${this.placeholder}
|
|
290
|
-
@keydown=${this.handleKeydown}
|
|
291
|
-
></textarea>
|
|
292
|
-
`:M`
|
|
293
|
-
<button
|
|
294
|
-
class="trigger"
|
|
295
|
-
type="button"
|
|
296
|
-
@click=${this.handleTriggerActivate}
|
|
297
|
-
@focus=${this.handleTriggerActivate}
|
|
298
|
-
>
|
|
299
|
-
${this.placeholder}
|
|
300
|
-
</button>
|
|
301
|
-
`}}un=new WeakSet,Ql=function(){document.addEventListener("mousedown",u(this,si)),document.addEventListener("keydown",u(this,ii))},ec=function(){document.removeEventListener("mousedown",u(this,si)),document.removeEventListener("keydown",u(this,ii))},si=new WeakMap,ii=new WeakMap,v(Xl,"properties",["placeholder","open","messages"]),v(Xl,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",Xl);const rl=et();class tz extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ve.resolve("ScreenManager"));v(this,"serverManager",Ve.resolve("ServerManager"));v(this,"handleChange",()=>{this.render()})}connectedCallback(){this.render(),this.screenManager.addEventListener("active-screen-changed",this.handleChange),this.serverManager.addEventListener("change",this.handleChange),this.serverManager.addEventListener("screens-changed",this.handleChange)}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleChange),this.serverManager.removeEventListener("change",this.handleChange),this.serverManager.removeEventListener("screens-changed",this.handleChange)}handleSelect(n){const r=n.value;for(const[s,i]of this.serverManager.servers)if(i.screens.has(r)){this.screenManager.setActive(s,r);return}}closeDropdown(){var n;(n=this.querySelector("dropdown-menu"))==null||n.close()}handleEditScreen(){this.screenManager.activeScreen&&(this.closeDropdown(),this.dispatchEvent(new rl("edit-screen",{bubbles:!0,composed:!0})))}handleCreateScreen(n){this.closeDropdown(),this.dispatchEvent(new rl("create-screen",{serverURL:n,bubbles:!0,composed:!0}))}handleDeleteScreen(){this.screenManager.activeScreen&&(this.closeDropdown(),this.dispatchEvent(new rl("delete-screen",{bubbles:!0,composed:!0})))}render(){var l;const n=this.screenManager.activeScreen,r=(n==null?void 0:n.name)??"No screens",s=(n==null?void 0:n.id)??null,i=[...this.serverManager.servers.values()],o=i.flatMap(c=>[...c.screens.values()]).sort((c,d)=>c.name.localeCompare(d.name,void 0,{sensitivity:"base"})),a=((l=i[0])==null?void 0:l.url)??null;be(M`
|
|
302
|
-
<dropdown-menu
|
|
303
|
-
title=${r}
|
|
304
|
-
placement="top"
|
|
305
|
-
@select=${c=>this.handleSelect(c)}
|
|
306
|
-
>
|
|
307
|
-
<button
|
|
308
|
-
slot="trigger"
|
|
309
|
-
trigger
|
|
310
|
-
type="button"
|
|
311
|
-
variant="toolbar"
|
|
312
|
-
aria-label="Choose screen"
|
|
313
|
-
></button>
|
|
314
|
-
<dropdown-group>
|
|
315
|
-
${o.map(c=>this.renderScreenItem(c,s,(n==null?void 0:n.name)??null))}
|
|
316
|
-
${a?M`
|
|
317
|
-
<dropdown-item
|
|
318
|
-
action
|
|
319
|
-
@click=${()=>this.handleCreateScreen(a)}
|
|
320
|
-
>
|
|
321
|
-
+ New screen
|
|
322
|
-
</dropdown-item>
|
|
323
|
-
`:null}
|
|
324
|
-
</dropdown-group>
|
|
325
|
-
${n?M`
|
|
326
|
-
<dropdown-divider></dropdown-divider>
|
|
327
|
-
<dropdown-group>
|
|
328
|
-
<dropdown-item
|
|
329
|
-
action
|
|
330
|
-
@click=${()=>this.handleEditScreen()}
|
|
331
|
-
>
|
|
332
|
-
Edit screen...
|
|
333
|
-
</dropdown-item>
|
|
334
|
-
<dropdown-item
|
|
335
|
-
action
|
|
336
|
-
danger
|
|
337
|
-
@click=${()=>this.handleDeleteScreen()}
|
|
338
|
-
>
|
|
339
|
-
Delete screen...
|
|
340
|
-
</dropdown-item>
|
|
341
|
-
</dropdown-group>
|
|
342
|
-
`:null}
|
|
343
|
-
</dropdown-menu>
|
|
344
|
-
`,this)}renderScreenItem(n,r,s){const i=n.id===r,o=i?s??n.name:n.name;return M`
|
|
345
|
-
<dropdown-item value=${n.id} ?selected=${i}>
|
|
346
|
-
${o}
|
|
347
|
-
</dropdown-item>
|
|
348
|
-
`}}customElements.define("screen-picker",tz);var oi,Rr,Ro,Do,lv;class av extends Rs{constructor(){super(...arguments);$(this,Do);v(this,"messages",[]);$(this,oi,Ve.resolve("ACPClientManager"));$(this,Rr);$(this,Ro,n=>{const r=u(this,oi).getActiveClient();if(!r)return;const s=n.value;r.sendMessage({text:s}).catch(i=>{console.error("ACPClient.sendMessage() failed",i)})})}connected(){x(this,Rr,jD(u(this,oi),n=>{this.messages=n}))}disconnected(){var n;(n=u(this,Rr))==null||n.dispose(),x(this,Rr,void 0)}changed(){be(b(this,Do,lv).call(this),this)}}oi=new WeakMap,Rr=new WeakMap,Ro=new WeakMap,Do=new WeakSet,lv=function(){return M`
|
|
349
|
-
<screen-picker></screen-picker>
|
|
350
|
-
<command-panel
|
|
351
|
-
.messages=${this.messages}
|
|
352
|
-
@command-submit=${u(this,Ro)}
|
|
353
|
-
></command-panel>
|
|
354
|
-
`},v(av,"properties",["messages"]);customElements.define("app-toolbar",av);class cv extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ve.resolve("ScreenManager"));v(this,"serverManager",Ve.resolve("ServerManager"));v(this,"handleActiveChange",()=>{this.render()});v(this,"_mode","edit");v(this,"_targetServerURL");v(this,"createPending",!1)}get open(){return this.hasAttribute("open")}set mode(n){this._mode=n,this.render()}get mode(){return this._mode}set targetServerURL(n){this._targetServerURL=n,this.render()}get targetServerURL(){return this._targetServerURL}attributeChangedCallback(n){n==="open"&&(this.open||(this.createPending=!1),this.render())}connectedCallback(){this.render(),this.screenManager.addEventListener("active-screen-changed",this.handleActiveChange)}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleActiveChange)}emitClose(){this.dispatchEvent(new Event("close",{bubbles:!0}))}async handleSubmit(n){var a;n.preventDefault();const r=n.currentTarget,s=new FormData(r),i=String(s.get("name")??"").trim();if(!i)return;if(this._mode==="edit"){(a=this.screenManager.activeScreen)==null||a.rename(i),this.emitClose();return}if(!this._targetServerURL)return;const o=this.serverManager.servers.get(this._targetServerURL);if(o){this.createPending=!0,this.render();try{const l=await o.createScreen(i);this.screenManager.setActive(this._targetServerURL,l.id),this.emitClose()}catch{this.createPending=!1,this.render()}}}render(){var i;const n=this._mode==="edit"?"Edit screen":"New screen",r=this._mode==="edit"?"Save":this.createPending?"Creating...":"Create",s=this._mode==="edit"?((i=this.screenManager.activeScreen)==null?void 0:i.name)??"":"";be(M`
|
|
355
|
-
<modal-overlay ?open=${this.open}>
|
|
356
|
-
<section class="screen-modal">
|
|
357
|
-
<form class="screen-form" @submit=${o=>void this.handleSubmit(o)}>
|
|
358
|
-
<h2 class="screen-modal-title">${n}</h2>
|
|
359
|
-
<label class="settings-field">
|
|
360
|
-
<span>Name</span>
|
|
361
|
-
<input type="text" name="name" .value=${s} required />
|
|
362
|
-
</label>
|
|
363
|
-
<div class="screen-form-actions">
|
|
364
|
-
<button type="submit" class="settings-submit-button" ?disabled=${this.createPending}>
|
|
365
|
-
${r}
|
|
366
|
-
</button>
|
|
367
|
-
<button type="button" class="settings-cancel-button" @click=${()=>this.emitClose()}>
|
|
368
|
-
Cancel
|
|
369
|
-
</button>
|
|
370
|
-
</div>
|
|
371
|
-
</form>
|
|
372
|
-
</section>
|
|
373
|
-
</modal-overlay>
|
|
374
|
-
`,this)}}v(cv,"observedAttributes",["open"]);customElements.define("screen-form-modal",cv);class uv extends HTMLElement{constructor(){super(...arguments);v(this,"screenManager",Ve.resolve("ScreenManager"));v(this,"serverManager",Ve.resolve("ServerManager"));v(this,"handleChange",()=>{this.render()});v(this,"deletePending",!1);v(this,"deleteError",null)}get open(){return this.hasAttribute("open")}attributeChangedCallback(n,r,s){n==="open"&&(s!==null&&r===null&&(this.deletePending=!1,this.deleteError=null),this.render())}connectedCallback(){this.render(),this.screenManager.addEventListener("active-screen-changed",this.handleChange),this.serverManager.addEventListener("change",this.handleChange)}disconnectedCallback(){this.screenManager.removeEventListener("active-screen-changed",this.handleChange),this.serverManager.removeEventListener("change",this.handleChange)}emitClose(){this.dispatchEvent(new Event("close",{bubbles:!0}))}async handleDeleteScreen(){const n=this.screenManager.activeScreen;if(n){this.deletePending=!0,this.deleteError=null,this.render();try{await n.remove(),this.emitClose()}catch(r){this.deletePending=!1,this.deleteError=r instanceof Error?r.message:String(r),this.render()}}}render(){const n=this.screenManager.activeScreen,r=(n==null?void 0:n.server.url)??null,s=r!==null&&r!==this.serverManager.localServerURL;be(M`
|
|
375
|
-
<modal-overlay ?open=${this.open}>
|
|
376
|
-
<section class="screen-modal screen-delete-modal">
|
|
377
|
-
<div class="screen-form">
|
|
378
|
-
<h2 class="screen-modal-title">Delete screen</h2>
|
|
379
|
-
<p class="screen-delete-copy">
|
|
380
|
-
Delete <strong>${(n==null?void 0:n.name)??""}</strong>?
|
|
381
|
-
</p>
|
|
382
|
-
${s?M`<p class="screen-delete-warning">This will delete it for everyone.</p>`:null}
|
|
383
|
-
${this.deleteError?M`<p class="screen-delete-error">${this.deleteError}</p>`:null}
|
|
384
|
-
<div class="screen-form-actions">
|
|
385
|
-
<button
|
|
386
|
-
type="button"
|
|
387
|
-
class="settings-server-remove-button"
|
|
388
|
-
?disabled=${this.deletePending}
|
|
389
|
-
@click=${()=>void this.handleDeleteScreen()}
|
|
390
|
-
>
|
|
391
|
-
${this.deletePending?"Deleting...":"Delete"}
|
|
392
|
-
</button>
|
|
393
|
-
<button
|
|
394
|
-
type="button"
|
|
395
|
-
class="settings-cancel-button"
|
|
396
|
-
?disabled=${this.deletePending}
|
|
397
|
-
@click=${()=>this.emitClose()}
|
|
398
|
-
>
|
|
399
|
-
Cancel
|
|
400
|
-
</button>
|
|
401
|
-
</div>
|
|
402
|
-
</div>
|
|
403
|
-
</section>
|
|
404
|
-
</modal-overlay>
|
|
405
|
-
`,this)}}v(uv,"observedAttributes",["open"]);customElements.define("screen-delete-modal",uv);class hv extends HTMLElement{constructor(){super(...arguments);v(this,"serverManager",Ve.resolve("ServerManager"));v(this,"handleChange",()=>{this.render()});v(this,"addServerFormOpen",!1)}get open(){return this.hasAttribute("open")}attributeChangedCallback(n){n==="open"&&(this.open||(this.addServerFormOpen=!1),this.render())}connectedCallback(){this.render(),this.serverManager.addEventListener("change",this.handleChange)}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleChange)}emitClose(){this.dispatchEvent(new Event("close",{bubbles:!0}))}openAddServerForm(){this.addServerFormOpen=!0,this.render()}closeAddServerForm(){this.addServerFormOpen&&(this.addServerFormOpen=!1,this.render())}handleAddServer(n){n.preventDefault();const r=n.currentTarget,s=new FormData(r),i=String(s.get("name")??"").trim(),o=String(s.get("url")??"").trim();!i||!o||(this.serverManager.addServer(o,i),this.addServerFormOpen=!1,r.reset(),this.render())}render(){const n=[...this.serverManager.servers.values()];be(M`
|
|
406
|
-
<modal-overlay ?open=${this.open}>
|
|
407
|
-
<section class="settings-panel">
|
|
408
|
-
<panel-view closable @close=${r=>r instanceof Pm&&this.emitClose()}>
|
|
409
|
-
<panel-page id="main" title="Settings">
|
|
410
|
-
<div class="settings-section">
|
|
411
|
-
<h3 class="settings-section-title">Servers</h3>
|
|
412
|
-
<div class="settings-server-list">
|
|
413
|
-
${n.map(r=>M`
|
|
414
|
-
<div class="settings-card settings-server">
|
|
415
|
-
<div class="settings-server-details">
|
|
416
|
-
<div class="settings-server-name">${r.name}</div>
|
|
417
|
-
<div class="settings-server-url">${r.url}</div>
|
|
418
|
-
</div>
|
|
419
|
-
${r.url!==this.serverManager.localServerURL?M`
|
|
420
|
-
<button
|
|
421
|
-
type="button"
|
|
422
|
-
class="settings-server-remove-button"
|
|
423
|
-
aria-label=${`Remove ${r.name}`}
|
|
424
|
-
@click=${()=>this.serverManager.removeServer(r.url)}
|
|
425
|
-
>
|
|
426
|
-
Remove
|
|
427
|
-
</button>
|
|
428
|
-
`:null}
|
|
429
|
-
</div>
|
|
430
|
-
`)}
|
|
431
|
-
</div>
|
|
432
|
-
${this.addServerFormOpen?M`
|
|
433
|
-
<form class="settings-card settings-add-server-form" @submit=${r=>this.handleAddServer(r)}>
|
|
434
|
-
<label class="settings-field">
|
|
435
|
-
<span>Name</span>
|
|
436
|
-
<input type="text" name="name" required />
|
|
437
|
-
</label>
|
|
438
|
-
<label class="settings-field">
|
|
439
|
-
<span>URL</span>
|
|
440
|
-
<input type="url" name="url" required />
|
|
441
|
-
</label>
|
|
442
|
-
<div class="settings-form-actions">
|
|
443
|
-
<button type="submit" class="settings-submit-button">Connect</button>
|
|
444
|
-
<button
|
|
445
|
-
type="button"
|
|
446
|
-
class="settings-cancel-button"
|
|
447
|
-
data-action="cancel-connect-form"
|
|
448
|
-
@click=${()=>this.closeAddServerForm()}
|
|
449
|
-
>
|
|
450
|
-
Cancel
|
|
451
|
-
</button>
|
|
452
|
-
</div>
|
|
453
|
-
</form>
|
|
454
|
-
`:M`
|
|
455
|
-
<button
|
|
456
|
-
type="button"
|
|
457
|
-
class="settings-submit-button settings-connect-button"
|
|
458
|
-
data-action="show-connect-form"
|
|
459
|
-
@click=${()=>this.openAddServerForm()}
|
|
460
|
-
>
|
|
461
|
-
+ Connect to server
|
|
462
|
-
</button>
|
|
463
|
-
`}
|
|
464
|
-
</div>
|
|
465
|
-
</panel-page>
|
|
466
|
-
</panel-view>
|
|
467
|
-
</section>
|
|
468
|
-
</modal-overlay>
|
|
469
|
-
`,this)}}v(hv,"observedAttributes",["open"]);customElements.define("settings-modal",hv);class dv extends Event{constructor(n){super("auth-submit",{bubbles:!0,composed:!0});v(this,"token");this.token=n}}class nz extends HTMLElement{constructor(){super(...arguments);v(this,"_invalid",!1);v(this,"_tokenValue","")}set invalid(n){this._invalid=n,this.render()}get invalid(){return this._invalid}set tokenValue(n){this._tokenValue=n,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(n){const r=n.currentTarget;this._tokenValue=r.value}handleSubmit(n){n.preventDefault();const r=this._tokenValue.trim();r&&this.dispatchEvent(new dv(r))}render(){be(M`
|
|
470
|
-
<modal-overlay open>
|
|
471
|
-
<section class="auth-modal">
|
|
472
|
-
<form class="auth-form" @submit=${n=>this.handleSubmit(n)}>
|
|
473
|
-
<h2 class="auth-modal-title">Enter access token</h2>
|
|
474
|
-
<p class="auth-modal-copy">This Television server requires a token.</p>
|
|
475
|
-
<label class="settings-field">
|
|
476
|
-
<span>Token</span>
|
|
477
|
-
<input
|
|
478
|
-
class=${this.invalid?"auth-token-input-invalid":""}
|
|
479
|
-
type="password"
|
|
480
|
-
name="token"
|
|
481
|
-
.value=${this.tokenValue}
|
|
482
|
-
@input=${n=>this.handleInput(n)}
|
|
483
|
-
required
|
|
484
|
-
/>
|
|
485
|
-
</label>
|
|
486
|
-
<button type="submit" class="settings-submit-button">Connect</button>
|
|
487
|
-
</form>
|
|
488
|
-
</section>
|
|
489
|
-
</modal-overlay>
|
|
490
|
-
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",nz);class rz extends HTMLElement{constructor(){super(...arguments);v(this,"runtimeServerURL",um());v(this,"electronMode",dm());v(this,"serverManager",Ve.resolve("ServerManager"));v(this,"modals",{screenForm:{open:!1,mode:"edit"},deleteScreen:{open:!1},settings:{open:!1}});v(this,"connectError",null);v(this,"handleServerManagerChange",()=>{this.render()})}connectedCallback(){this.serverManager.addEventListener("change",this.handleServerManagerChange),this.addEventListener("auth-submit",n=>{var s;const r=n instanceof dv?n.token:n instanceof CustomEvent&&typeof((s=n.detail)==null?void 0:s.token)=="string"?n.detail.token:null;r&&this.handleAuthSubmit(r)}),this.addEventListener("edit-screen",()=>{this.modals.screenForm={open:!0,mode:"edit"},this.render()}),this.addEventListener("create-screen",n=>{const r=n.serverURL;this.modals.screenForm={open:!0,mode:"create",targetServerURL:r},this.render()}),this.addEventListener("delete-screen",()=>{this.modals.deleteScreen={open:!0},this.render()}),this.initializeConnection(),this.render()}disconnectedCallback(){this.serverManager.removeEventListener("change",this.handleServerManagerChange)}async initializeConnection(){if(this.electronMode){this.serverManager.connectConfiguredServers(this.runtimeServerURL);return}if(this.serverManager.activeServer)return;const n=new kl({url:this.runtimeServerURL,name:"Server",token:hm()});this.serverManager.add(n),this.serverManager.setActive(n);try{await n.connect(),this.connectError=null}catch(r){this.connectError=r instanceof Error&&!(r instanceof Sl)?r.message:null}this.render()}async handleAuthSubmit(n){const r=this.serverManager.activeServer;if(r){this.connectError=null,r.token=n,this.updateTokenQueryParam(n);try{await r.connect()}catch(s){s instanceof Sl||(this.connectError=s instanceof Error?s.message:String(s))}this.render()}}updateTokenQueryParam(n){const r=new URL(window.location.href);r.searchParams.set("token",n),window.history.replaceState({},"",`${r.pathname}${r.search}${r.hash}`)}render(){const n=this.serverManager.activeServer,r=(n==null?void 0:n.status)??null;if(r==="connecting"){be(M`
|
|
491
|
-
<main class="auth-gate"><p>Connecting...</p></main>
|
|
492
|
-
`,this);return}if(r==="disconnected"){const i=n;if(!i)return;be(M`
|
|
493
|
-
<main class="auth-gate">
|
|
494
|
-
<auth-modal
|
|
495
|
-
.invalid=${!!i.token}
|
|
496
|
-
.tokenValue=${i.token??""}
|
|
497
|
-
></auth-modal>
|
|
498
|
-
</main>
|
|
499
|
-
`,this);return}const s=M`
|
|
500
|
-
<main>
|
|
501
|
-
${this.connectError?M`<p data-testid="auth-error">${this.connectError}</p>`:M`
|
|
502
|
-
<screen-view></screen-view>
|
|
503
|
-
${r==="connected"?M`<app-toolbar></app-toolbar>`:null}
|
|
504
|
-
`}
|
|
505
|
-
</main>
|
|
506
|
-
<screen-form-modal
|
|
507
|
-
?open=${this.modals.screenForm.open}
|
|
508
|
-
.mode=${this.modals.screenForm.mode}
|
|
509
|
-
.targetServerURL=${this.modals.screenForm.targetServerURL}
|
|
510
|
-
@close=${()=>{this.modals.screenForm={open:!1,mode:"edit"},this.render()}}
|
|
511
|
-
></screen-form-modal>
|
|
512
|
-
<screen-delete-modal
|
|
513
|
-
?open=${this.modals.deleteScreen.open}
|
|
514
|
-
@close=${()=>{this.modals.deleteScreen={open:!1},this.render()}}
|
|
515
|
-
></screen-delete-modal>
|
|
516
|
-
<settings-modal
|
|
517
|
-
?open=${this.modals.settings.open}
|
|
518
|
-
@close=${()=>{this.modals.settings={open:!1},this.render()}}
|
|
519
|
-
></settings-modal>
|
|
520
|
-
`;be(s,this)}}customElements.get("television-app")||customElements.define("television-app",rz);const tu=dm(),Qo=um(),pv=new NE(tu?"television-electron":"television-browser",ME(Qo)),fv=new IC({localStore:pv,localServerURL:Qo}),gv=new OE({localStore:pv,serverManager:fv}),sz=new hR({serverURL:Qo,token:hm()??"",screenManager:gv});Ve.register("ServerManager",()=>fv);Ve.register("ScreenManager",()=>gv);Ve.register("ACPClientManager",()=>sz);const nu=document.createElement("television-app");nu.runtimeServerURL=Qo;nu.electronMode=tu;tu&&document.body.classList.add("electron");document.body.appendChild(nu);
|